From f0ae465b965c00653cb0ccc8f5f1c12d8942283f Mon Sep 17 00:00:00 2001
From: Konstantin Kutscher <kutscher@irmb.tu-bs.de>
Date: Thu, 18 Oct 2018 17:48:08 +0200
Subject: [PATCH] fixes initial velocity in createSpheres()

---
 source/Applications/Thermoplast/config.txt    | 24 +++----
 .../Applications/Thermoplast/thermoplast.cpp  | 62 +++++++++++--------
 .../DemCoupling/CreateDemObjectsCoProcessor.h |  2 +-
 source/DemCoupling/DemCoProcessor.cpp         |  3 +-
 source/DemCoupling/DemCoProcessor.h           |  2 +-
 .../WriteDemObjectsCoProcessor.cpp            |  3 +-
 .../pe/PePhysicsEngineGeometryAdapter.h       |  2 +-
 7 files changed, 57 insertions(+), 41 deletions(-)

diff --git a/source/Applications/Thermoplast/config.txt b/source/Applications/Thermoplast/config.txt
index a60b16211..c9e2ee411 100644
--- a/source/Applications/Thermoplast/config.txt
+++ b/source/Applications/Thermoplast/config.txt
@@ -9,16 +9,14 @@ boundingBox = 60 1370 130 190 1530 320 #test bb
  
 blocknx = 10 10 10 
 #blocknx = 300 420 320
-endTime = 3000
-outTime = 3000
 availMem = 25e9
-uLB = 0.1
+#uLB = 0.1
+uLB = 0.03
 
 #PE parameters
 #test pe offset
 peMinOffset = 46 2 2
-#peMaxOffset = -30 -60 -12
-peMaxOffset = -8 -25 -2
+ peMaxOffset = -8 -25 -2
 
 #production pe offset
 #peMinOffset = 46 18 14
@@ -31,14 +29,18 @@ pathGeo = d:/Projects/ThermoPlast/SimGeo
 michel = /michel.stl
 plexiglas = /plexiglas.stl
 
-pathOut = g:/temp/thermoplast2
+pathOut = g:/temp/thermoplast9
 
 logToFile = false
 
 #restart
-cpStart = 3000
-cpStep =  3000
-restart = true
-restartStep = 2000
+restart = false
+restartStep = 5000
+
+#timing
+nupsTime = 100 100 1000000
+cpStart = 1000
+cpStep =  1000
+outTime = 10
+endTime = 1000
 
-nupsTime = 10 10 1000000
\ No newline at end of file
diff --git a/source/Applications/Thermoplast/thermoplast.cpp b/source/Applications/Thermoplast/thermoplast.cpp
index 89158664b..548ccd779 100644
--- a/source/Applications/Thermoplast/thermoplast.cpp
+++ b/source/Applications/Thermoplast/thermoplast.cpp
@@ -149,17 +149,18 @@ std::shared_ptr<DemCoProcessor> makePeCoProcessor(SPtr<Grid3D> grid, SPtr<Commun
    return std::make_shared<DemCoProcessor>(grid, peScheduler, comm, forceCalculator, peSolver);
 }
 
-void createSpheres(double radius,  Vector3D origin, double uLB, SPtr<CreateDemObjectsCoProcessor> createSphereCoProcessor)
+void createSpheres(double radius,  Vector3D origin, double maxX2, double maxX3, double uLB, SPtr<CreateDemObjectsCoProcessor> createSphereCoProcessor)
 {
    double d = 2.0*radius;
-   int maxX2 = 5;//5;
-   int maxX3 = 5;//6;
+   double dividerX2 = maxX2/2.0;
+   double dividerX3 = maxX3/2.0;
    for (int x3 = 0; x3 < maxX3; x3++)
       for (int x2 = 0; x2 < maxX2; x2++)
-         for (int x1 = 0; x1 < 1; x1++)
+         //for (int x1 = 0; x1 < 1; x1++)
          {
-            SPtr<GbObject3D> sphere(new GbSphere3D(origin[0]+2.0*d*(double)x1, origin[1]+(double)x2*1.0*d, origin[2]+(double)x3*1.0*d, radius));
-            createSphereCoProcessor->addGeoObject(sphere, Vector3D(uLB, -uLB+uLB/2.0*(double)x2, -uLB+uLB/2.5*(double)x3));
+            //SPtr<GbObject3D> sphere(new GbSphere3D(origin[0]+2.0*d*(double)x1, origin[1]+(double)x2*1.0*d, origin[2]+(double)x3*1.0*d, radius));
+            SPtr<GbObject3D> sphere(new GbSphere3D(origin[0]+2.0*d, origin[1]+(double)x2*1.0*d, origin[2]+(double)x3*1.0*d, radius));
+            createSphereCoProcessor->addGeoObject(sphere, Vector3D(uLB, -uLB+uLB/dividerX2*(double)x2, -uLB+uLB/dividerX2*(double)x3));
          }
 }
 
@@ -210,11 +211,13 @@ void thermoplast(string configname)
       if (myid==0)
       {
          stringstream logFilename;
-         logFilename<<pathOut+"/logfile"+UbSystem::toString(UbSystem::getTimeStamp())+".txt";
+         logFilename<<pathOut+"/logfile"+UbSystem::getTimeStamp()+".txt";
          UbLog::output_policy::setStream(logFilename.str());
       }
    }
 
+   if (myid==0) UBLOG(logINFO, "BEGIN LOGGING - " << UbSystem::getTimeStamp());
+
    //parameters
    //string          pathOut = "d:/temp/thermoplast3";
    //string          pathGeo = "d:/Projects/ThermoPlast/Geometrie";
@@ -516,7 +519,8 @@ void thermoplast(string configname)
    ////generating spheres 
    //UBLOG(logINFO, "generating spheres - start, rank="<<myid);
    SPtr<UbScheduler> sphereScheduler(new UbScheduler(sphereTime/*10,10,10*/));
-   SPtr<CreateDemObjectsCoProcessor> createSphereCoProcessor(new CreateDemObjectsCoProcessor(grid, sphereScheduler, comm, demCoProcessor, sphereMaterial, 0.03));
+   double toleranz = 0.05;
+   SPtr<CreateDemObjectsCoProcessor> createSphereCoProcessor(new CreateDemObjectsCoProcessor(grid, sphereScheduler, comm, demCoProcessor, sphereMaterial, toleranz));
    //UBLOG(logINFO, "generating spheres - stop, rank="<<myid);
 
    ////restart
@@ -549,14 +553,19 @@ void thermoplast(string configname)
    //sphere prototypes
    //UBLOG(logINFO, "sphere prototypes - start, rank="<<myid);
    double d = 2.0*radiusLB;
-   Vector3D origin1(g_minX1+peMinOffset[0]+radiusLB, geoInjector5->getX2Minimum()+1.4*d, geoInjector5->getX3Minimum()+1.5*d);
-   createSpheres(radiusLB,origin1,uLB,createSphereCoProcessor);
+   double maxX2 = 5;
+   double maxX3 = 5;
+   //Vector3D origin1(g_minX1+peMinOffset[0]+radiusLB, geoInjector5->getX2Minimum()+1.4*d, geoInjector5->getX3Minimum()+1.5*d);
+   Vector3D origin1(g_minX1+peMinOffset[0]-1.5*d, geoInjector5->getX2Minimum()+1.4*d, geoInjector5->getX3Minimum()+1.5*d);
+   createSpheres(radiusLB,origin1,maxX2,maxX3,uLB,createSphereCoProcessor);
 
-   //Vector3D origin2(g_minX1+peMinOffset[0]+radius, geoInjector4->getX2Minimum()+3.0*d, geoInjector4->getX3Minimum()+2.0*d);
-   //createSpheres(radius, origin2, uLB, createSphereCoProcessor);
+   //Vector3D origin2(g_minX1+peMinOffset[0]+radiusLB, geoInjector4->getX2Minimum()+3.0*d, geoInjector4->getX3Minimum()+2.0*d);
+   //createSpheres(radiusLB, origin2, uLB, createSphereCoProcessor);
 
-   //Vector3D origin3(g_minX1+peMinOffset[0]+radius, geoInjector7->getX2Minimum()+2.0*d, geoInjector7->getX3Minimum()+2.0*d);
-   //createSpheres(radius, origin3, uLB, createSphereCoProcessor);
+   //maxX2 = 7;
+   //maxX3 = 7;
+   //Vector3D origin3(g_minX1+peMinOffset[0]+radiusLB, geoInjector7->getX2Minimum()+2.0*d, geoInjector7->getX3Minimum()+2.0*d);
+   //createSpheres(radiusLB, origin3, uLB, createSphereCoProcessor);
 
    //for (int x3 = 0; x3 < 6; x3++)
    //   for (int x2 = 0; x2 < 5; x2++)
@@ -622,6 +631,7 @@ void thermoplast(string configname)
    if (myid == 0) UBLOG(logINFO, "Simulation-start");
    calculator->calculate();
    if (myid == 0) UBLOG(logINFO, "Simulation-end");
+   if (myid==0) UBLOG(logINFO, "END LOGGING - " << UbSystem::getTimeStamp());
 }
 
 
@@ -633,17 +643,19 @@ int main(int argc, char* argv[])
       //Sleep(30000);
       walberla::Environment env(argc, argv);
 
-      if (argv!=NULL)
-      {
-         if (argv[1]!=NULL)
-         {
-            thermoplast(string(argv[1]));
-         }
-         else
-         {
-            cout<<"Configuration file must be set!: "<<argv[0]<<" <config file>"<<endl<<std::flush;
-         }
-      }
+      //if (argv!=NULL)
+      //{
+      //   if (argv[1]!=NULL)
+      //   {
+            //thermoplast(string(argv[1]));
+      //thermoplast(string("thermoplast.cfg"));
+      thermoplast(string("d:/Projects/VirtualFluidsGit/source/Applications/Thermoplast/config.txt"));
+      //   }
+      //   else
+      //   {
+      //      cout<<"Configuration file must be set!: "<<argv[0]<<" <config file>"<<endl<<std::flush;
+      //   }
+      //}
       return 0;
    }
    catch (std::exception& e)
diff --git a/source/DemCoupling/CreateDemObjectsCoProcessor.h b/source/DemCoupling/CreateDemObjectsCoProcessor.h
index 837c032a7..6d3a1dc3e 100644
--- a/source/DemCoupling/CreateDemObjectsCoProcessor.h
+++ b/source/DemCoupling/CreateDemObjectsCoProcessor.h
@@ -7,7 +7,7 @@
 #include <array>
 
 
-#define TIMING
+//#define TIMING
 
 #ifdef TIMING
 #include "UbTiming.h"
diff --git a/source/DemCoupling/DemCoProcessor.cpp b/source/DemCoupling/DemCoProcessor.cpp
index 1033180a4..09deb9165 100644
--- a/source/DemCoupling/DemCoProcessor.cpp
+++ b/source/DemCoupling/DemCoProcessor.cpp
@@ -341,7 +341,7 @@ bool  DemCoProcessor::isDemObjectInAABB(std::array<double, 6> AABB)
    return result;
 }
 
-void DemCoProcessor::addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles)
+int DemCoProcessor::addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles)
 {
    for (int i = 0; i < interactors.size(); i++)
    {
@@ -350,6 +350,7 @@ void DemCoProcessor::addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, st
          interactors[i]->getGbObject3D()->addSurfaceTriangleSet(nodes, triangles);
       }
    }
+   return (int)interactors.size();
 }
 
 void DemCoProcessor::getObjectsPropertiesVector(std::vector<double>& p)
diff --git a/source/DemCoupling/DemCoProcessor.h b/source/DemCoupling/DemCoProcessor.h
index 74693a5de..74718a911 100644
--- a/source/DemCoupling/DemCoProcessor.h
+++ b/source/DemCoupling/DemCoProcessor.h
@@ -50,7 +50,7 @@ public:
     void distributeIDs();
     void setBlockVisitor(std::shared_ptr<BoundaryConditionsBlockVisitor> blockVisitor);
     bool isDemObjectInAABB(std::array<double,6> AABB);
-    void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles);
+    int addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles);
     void getObjectsPropertiesVector(std::vector<double>& p);
     void addPeGeo(walberla::pe::RigidBody* peGeo);
     void removePeGeo(walberla::pe::RigidBody* peGeo);
diff --git a/source/DemCoupling/WriteDemObjectsCoProcessor.cpp b/source/DemCoupling/WriteDemObjectsCoProcessor.cpp
index 130cd3027..30b25c0de 100644
--- a/source/DemCoupling/WriteDemObjectsCoProcessor.cpp
+++ b/source/DemCoupling/WriteDemObjectsCoProcessor.cpp
@@ -31,7 +31,7 @@ void WriteDemObjectsCoProcessor::process(double step)
        std::vector<UbTupleFloat3> nodes;
        std::vector<UbTupleInt3>   triangles;
 
-       demCoProcessor->addSurfaceTriangleSet(nodes, triangles);
+       int numObjcts = demCoProcessor->addSurfaceTriangleSet(nodes, triangles);
 
        int istep = static_cast<int>(step);
 
@@ -67,6 +67,7 @@ void WriteDemObjectsCoProcessor::process(double step)
           {
              WbWriterVtkXmlASCII::getInstance()->addFilesToCollection(cfilePath, filenames, istep, false);
           }
+          UBLOG(logINFO, "WriteDemObjectsCoProcessor number of objects: " << numObjcts);
           UBLOG(logINFO, "WriteDemObjectsCoProcessor step: " << istep);
        }
    }
diff --git a/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.h b/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.h
index c5427ab82..13c830a41 100644
--- a/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.h
+++ b/source/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.h
@@ -7,7 +7,7 @@
 
 
 #include "PhysicsEngineGeometryAdapter.h"
-#include <core\DataTypes.h>
+#include <core/DataTypes.h>
 
 namespace walberla
 {
-- 
GitLab