From 1f01031857f4b4fd9d117179dc050b8831531a16 Mon Sep 17 00:00:00 2001 From: Konstantin Kutscher <kutscher@irmb.tu-bs.de> Date: Sat, 13 Jan 2018 21:52:54 +0100 Subject: [PATCH] problem with Intel compiler is fixed --- source/Applications/DLR-F16-Solid/f16.cpp | 1357 +++++++++-------- source/CMake/compilerflags/icc160.cmake | 12 +- source/CMakeLists.txt | 18 +- source/IncludsList.cmake | 5 +- .../basics/writer/WbWriterVtkXmlASCII.cpp | 1 + source/VirtualFluids.h | 2 +- .../Connectors/CoarseToFineBlock3DConnector.h | 2 +- .../Connectors/D3Q27ETCFOffVectorConnector.h | 2 +- .../Connectors/D3Q27ETFCOffVectorConnector.h | 2 +- .../Connectors/FineToCoarseBlock3DConnector.h | 2 +- .../Connectors/LocalBlock3DConnector.h | 5 +- .../Connectors/RemoteBlock3DConnector.h | 2 +- .../Interactors/Interactor3D.h | 2 +- .../LBM/CompressibleCumulantLBMKernel.cpp | 1 + ...ressibleCumulantViscosity4thLBMKernel.cpp} | 36 +- ...mpressibleCumulantViscosity4thLBMKernel.h} | 8 +- .../LBM/IncompressibleCumulantLBMKernel.cpp | 1 + source/VirtualFluidsCore/LBM/LBMKernel.h | 2 +- source/VirtualFluidsCore/PointerDefinitions.h | 64 +- .../Utilities/ConfigurationFile.hpp | 5 +- 20 files changed, 815 insertions(+), 714 deletions(-) rename source/VirtualFluidsCore/LBM/{CompressibleCumulant2LBMKernel.cpp => CompressibleCumulantViscosity4thLBMKernel.cpp} (97%) rename source/VirtualFluidsCore/LBM/{CompressibleCumulant2LBMKernel.h => CompressibleCumulantViscosity4thLBMKernel.h} (86%) diff --git a/source/Applications/DLR-F16-Solid/f16.cpp b/source/Applications/DLR-F16-Solid/f16.cpp index 4e1c0efe9..63a981863 100644 --- a/source/Applications/DLR-F16-Solid/f16.cpp +++ b/source/Applications/DLR-F16-Solid/f16.cpp @@ -1,653 +1,704 @@ -#include <iostream> -#include <string> - -#include <PointerDefinitions.h> -#include "VirtualFluids.h" -#include <omp.h> -using namespace std; - -void run(string configname) -{ - try - { - ConfigurationFile config; - config.load(configname); - - string pathOut = config.getValue<string>("pathOut"); - string pathGeo = config.getValue<string>("pathGeo"); - string fngFileWhole = config.getValue<string>("fngFileWhole"); - string zigZagTape = config.getValue<string>("zigZagTape"); - int numOfThreads = config.getValue<int>("numOfThreads"); - vector<int> blockNx = config.getVector<int>("blockNx"); - vector<double> boundingBox = config.getVector<double>("boundingBox"); - double restartStep = config.getValue<double>("restartStep"); - double cpStart = config.getValue<double>("cpStart"); - double cpStep = config.getValue<double>("cpStep"); - int endTime = config.getValue<int>("endTime"); - double outTimeStep = config.getValue<double>("outTimeStep"); - double outTimeStart = config.getValue<double>("outTimeStart"); - double availMem = config.getValue<double>("availMem"); - int refineLevel = config.getValue<int>("refineLevel"); - bool logToFile = config.getValue<bool>("logToFile"); - double deltaXfine = config.getValue<double>("deltaXfine"); - double refineDistance = config.getValue<double>("refineDistance"); - double startDistance = config.getValue<double>("startDistance"); - vector<double> nupsStep = config.getVector<double>("nupsStep"); - bool newStart = config.getValue<bool>("newStart"); - bool writeBlocks = config.getValue<bool>("writeBlocks"); - string pathReInit = config.getValue<string>("pathReInit"); - int stepReInit = config.getValue<int>("stepReInit"); - - double pcpStart = config.getValue<double>("pcpStart"); - double pcpStop = config.getValue<double>("pcpStop"); - - double timeAvStart = config.getValue<double>("timeAvStart"); - double timeAvStop = config.getValue<double>("timeAvStop"); - - SPtr<Communicator> comm = MPICommunicator::getInstance(); - int myid = comm->getProcessID(); - - if (logToFile) - { -#if defined(__unix__) - if (myid==0) - { - const char* str = pathOut.c_str(); - mkdir(str, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH); - } -#endif - - if (myid==0) - { - stringstream logFilename; - logFilename<<pathOut+"/logfile"+UbSystem::toString(UbSystem::getTimeStamp())+".txt"; - UbLog::output_policy::setStream(logFilename.str()); - } - } - - if (myid==0) - { - UBLOG(logINFO, "PID = "<<myid<<" Point 1"); - UBLOG(logINFO, "PID = "<<myid<<" Total Physical Memory (RAM): "<<Utilities::getTotalPhysMem()); - UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used: "<<Utilities::getPhysMemUsed()); - UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); - } - - - //the geometry is in mm - - double g_minX1 = boundingBox[0]; - double g_minX2 = boundingBox[2]; - double g_minX3 = boundingBox[4]; - - double g_maxX1 = boundingBox[1]; - double g_maxX2 = boundingBox[3]; - double g_maxX3 = boundingBox[5]; - - ////////////////////////////////////////////////////////////////////////// - double deltaXcoarse = deltaXfine*(double)(1<<refineLevel); - ////////////////////////////////////////////////////////////////////////// - double blockLength = (double)blockNx[0]*deltaXcoarse; - - //########################################################################## - //## physical parameters - //########################################################################## - double Re = 1e6; - - double rhoLB = 0.0; - double rhoReal = 1.2041; //(kg/m3) - //double nueReal = 153.5e-7; //m^2/s - double uReal = 55; //m/s - double lReal = 0.3;//m - //double uReal = Re*nueReal / lReal; - double nuReal = (uReal*lReal)/Re; //m^2/s - - //##Machzahl: - //#Ma = uReal/csReal - double Ma = 0.15;//Ma-Real! - double csReal = uReal / Ma; - double hLB = lReal / deltaXcoarse; - - LBMUnitConverter unitConverter(lReal, csReal, rhoReal, hLB); - - double uLB = uReal * unitConverter.getFactorVelocityWToLb(); - double nuLB = nuReal * unitConverter.getFactorViscosityWToLb(); - double lLB = lReal*1000.0/deltaXcoarse; - //double nuLB = (uLB*lLB)/Re; //0.005; - //double nuLB = 0.005; - - SPtr<LBMUnitConverter> conv = SPtr<LBMUnitConverter>(new LBMUnitConverter()); - - const int baseLevel = 0; - - //////////////////////////////////////////////////////////////////////// - //Grid - ////////////////////////////////////////////////////////////////////////// - SPtr<Grid3D> grid(new Grid3D(comm)); - - //BC adapters - SPtr<BCAdapter> noSlipBCAdapter(new NoSlipBCAdapter()); - noSlipBCAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new NoSlipBCAlgorithm())); - - SPtr<BCAdapter> slipBCAdapter(new SlipBCAdapter()); - slipBCAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new SlipBCAlgorithm())); - - mu::Parser fct; - fct.SetExpr("U"); - fct.DefineConst("U", uLB); - SPtr<BCAdapter> velBCAdapter(new VelocityBCAdapter(true, false, false, fct, 0, BCFunction::INFCONST)); - velBCAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new VelocityWithDensityBCAlgorithm())); - - //fct.SetExpr("U"); - //fct.DefineConst("U", 0.01); - //SPtr<BCAdapter> velBCAdapterOut(new VelocityBCAdapter(true, false, false, fct, 0, BCFunction::INFCONST)); - //velBCAdapterOut->setBcAlgorithm(SPtr<BCAlgorithm>(new VelocityBCAlgorithm())); - - SPtr<BCAdapter> outflowBCAdapter(new DensityBCAdapter(rhoLB)); - outflowBCAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new NonReflectingOutflowBCAlgorithm())); - - BoundaryConditionsBlockVisitor bcVisitor; - bcVisitor.addBC(noSlipBCAdapter); - bcVisitor.addBC(velBCAdapter); - bcVisitor.addBC(outflowBCAdapter); - - SPtr<LBMKernel> kernel = SPtr<LBMKernel>(new CompressibleCumulant2LBMKernel(blockNx[0], blockNx[1], blockNx[2], CompressibleCumulant2LBMKernel::NORMAL)); - SPtr<BCProcessor> bcProc; - bcProc = SPtr<BCProcessor>(new BCProcessor()); - kernel->setBCProcessor(bcProc); - ////////////////////////////////////////////////////////////////////////// - //restart - SPtr<UbScheduler> rSch(new UbScheduler(cpStep, cpStart)); - SPtr<MPIIORestartCoProcessor> restartCoProcessor(new MPIIORestartCoProcessor(grid, rSch, pathOut, comm)); - restartCoProcessor->setLBMKernel(kernel); - restartCoProcessor->setBCProcessor(bcProc); - ////////////////////////////////////////////////////////////////////////// - - if (myid==0) - { - UBLOG(logINFO, "PID = "<<myid<<" Point 2"); - UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); - } - - - if (newStart) - { - //////////////////////////////////////////////////////////////////////// - //define grid - ////////////////////////////////////////////////////////////////////////// - grid->setDeltaX(deltaXcoarse); - grid->setBlockNX(blockNx[0], blockNx[1], blockNx[2]); - - SPtr<GbObject3D> gridCube(new GbCuboid3D(g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3)); - if (myid==0) GbSystem3D::writeGeoObject(gridCube.get(), pathOut+"/geo/gridCube", WbWriterVtkXmlASCII::getInstance()); - GenBlocksGridVisitor genBlocks(gridCube); - grid->accept(genBlocks); - - grid->setPeriodicX1(false); - grid->setPeriodicX2(true); - grid->setPeriodicX3(false); - - if (myid==0) - { - UBLOG(logINFO, "Parameters:"); - UBLOG(logINFO, "* Re = "<<Re); - UBLOG(logINFO, "* Ma = "<<Ma); - UBLOG(logINFO, "* velocity (uReal) = "<<uReal<<" m/s"); - UBLOG(logINFO, "* viscosity (nuReal) = "<<nuReal<<" m^2/s"); - UBLOG(logINFO, "* chord length (lReal)= "<<lReal<<" m"); - UBLOG(logINFO, "* velocity LB (uLB) = "<<uLB); - UBLOG(logINFO, "* viscosity LB (nuLB) = "<<nuLB); - UBLOG(logINFO, "* chord length (l_LB) = "<<lLB<<" dx_base"); - UBLOG(logINFO, "* dx_base = "<<deltaXcoarse<<" m"); - UBLOG(logINFO, "* dx_refine = "<<deltaXfine<<" m"); - UBLOG(logINFO, "* blocknx = "<<blockNx[0]<<"x"<<blockNx[1]<<"x"<<blockNx[2]); - UBLOG(logINFO, "* refineDistance = "<<refineDistance); - UBLOG(logINFO, "* number of levels = "<<refineLevel+1); - UBLOG(logINFO, "* number of threads = "<<numOfThreads); - UBLOG(logINFO, "* number of processes = "<<comm->getNumberOfProcesses()); - UBLOG(logINFO, "* path = "<<pathOut); - UBLOG(logINFO, "Preprozess - start"); - } - - - - //SPtr<GbObject3D> fngMeshWhole(new GbCylinder3D(15.0, 0.0, 0.0, 15.0, 100.0, 0.0, 25.0)); - //GbSystem3D::writeGeoObject(fngMeshWhole.get(), pathOut + "/geo/fngMeshWholeCylinder", WbWriterVtkXmlBinary::getInstance()); - - SPtr<GbTriFaceMesh3D> fngMeshWhole; - if (myid==0) UBLOG(logINFO, "Read fngFileWhole:start"); - fngMeshWhole = SPtr<GbTriFaceMesh3D>(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile2(pathGeo+"/"+fngFileWhole, "fngMeshWhole", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); - if (myid==0) UBLOG(logINFO, "Read fngFileWhole:end"); - fngMeshWhole->rotate(0.0, 0.5, 0.0); - //fngMeshWhole->scale(1e-3,1e-3,1e-3); - //fngMeshWhole->translate(-150.0,-50.0,-1.28); - if (myid==0) GbSystem3D::writeGeoObject(fngMeshWhole.get(), pathOut+"/geo/fngMeshWhole", WbWriterVtkXmlBinary::getInstance()); - - //////////////////////////////////////////////////////////////////////////// - //// Zackenband - //////////////////////////////////////////////////////////////////////////// - ////top - //////////////////////////////////////////////////////////////////////////// - //if (myid==0) UBLOG(logINFO, "Read zigZagTape:start"); - //string ZckbndFilename = pathGeo+"/"+zigZagTape; - //SPtr<GbTriFaceMesh3D> meshBand1(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape1")); - //meshBand1->rotate(0.0, 5, 0.0); - //meshBand1->translate(15, 0, -12.850); - //if (myid==0) GbSystem3D::writeGeoObject(meshBand1.get(), pathOut+"/geo/zigZagTape1", WbWriterVtkXmlASCII::getInstance()); - //// Zackenband2 - //SPtr<GbTriFaceMesh3D> meshBand2(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape2")); - //meshBand2->rotate(0.0, 5, 0.0); - //meshBand2->translate(15, 5, -12.850); - //if (myid==0) GbSystem3D::writeGeoObject(meshBand2.get(), pathOut+"/geo/zigZagTape2", WbWriterVtkXmlASCII::getInstance()); - - ////bottom - //SPtr<GbTriFaceMesh3D> meshBand5(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape5")); - //meshBand5->rotate(0.0, -1, 0.0); - //meshBand5->rotate(0.0, 0.0, 180.0); - ////meshBand5->translate(30, 0, -37.3); - //meshBand5->translate(30, 0, -37.2); - //if (myid==0) GbSystem3D::writeGeoObject(meshBand5.get(), pathOut+"/geo/zigZagTape5", WbWriterVtkXmlASCII::getInstance()); - //// Zackenband6 - //SPtr<GbTriFaceMesh3D> meshBand6(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape6")); - //meshBand6->rotate(0.0, -1, 0.0); - //meshBand6->rotate(0.0, 0.0, 180.0); - ////meshBand6->translate(30, 5, -37.3); - //meshBand6->translate(30, 5, -37.2); - //if (myid==0) GbSystem3D::writeGeoObject(meshBand6.get(), pathOut+"/geo/zigZagTape6", WbWriterVtkXmlASCII::getInstance()); - - //if (myid==0) UBLOG(logINFO, "Read zigZagTape:end"); - - - if (myid==0) - { - UBLOG(logINFO, "PID = "<<myid<<" Point 3"); - UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); - } - ////////////////////////////////////////////////////////////////////////// - SPtr<Interactor3D> fngIntrWhole; - //fngIntrWhole = SPtr<D3Q27Interactor>(new D3Q27Interactor(fngMeshWhole, grid, noSlipBCAdapter, Interactor3D::SOLID));//, Interactor3D::POINTS)); - fngIntrWhole = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(fngMeshWhole, grid, noSlipBCAdapter, Interactor3D::SOLID, Interactor3D::POINTS)); - - //SPtr<D3Q27TriFaceMeshInteractor> triBand1Interactor(new D3Q27TriFaceMeshInteractor(meshBand1, grid, noSlipBCAdapter, Interactor3D::SOLID, Interactor3D::EDGES)); - //SPtr<D3Q27TriFaceMeshInteractor> triBand2Interactor(new D3Q27TriFaceMeshInteractor(meshBand2, grid, noSlipBCAdapter, Interactor3D::SOLID, Interactor3D::EDGES)); - //SPtr<D3Q27TriFaceMeshInteractor> triBand3Interactor(new D3Q27TriFaceMeshInteractor(meshBand5, grid, noSlipBCAdapter, Interactor3D::SOLID, Interactor3D::EDGES)); - //SPtr<D3Q27TriFaceMeshInteractor> triBand4Interactor(new D3Q27TriFaceMeshInteractor(meshBand6, grid, noSlipBCAdapter, Interactor3D::SOLID, Interactor3D::EDGES)); - - if (refineLevel>0 && myid==0 && writeBlocks) - { - if (myid==0) UBLOG(logINFO, "Refinement - start"); - int rank = grid->getRank(); - grid->setRank(0); - - int level; - - //level 1 - level = 1; - SPtr<GbObject3D> refCylinderL2(new GbCylinder3D(0.015, 0.0, 0.0, 0.015, 0.1, 0.0, 0.040)); - GbSystem3D::writeGeoObject(refCylinderL2.get(), pathOut + "/geo/refCylinderL2", WbWriterVtkXmlBinary::getInstance()); - RefineCrossAndInsideGbObjectBlockVisitor refVisitorCylinderL2(refCylinderL2, level); - grid->accept(refVisitorCylinderL2); - - SPtr<GbObject3D> refBoxL2(new GbCuboid3D(0.015, 0.0, -0.04, 1.100, 0.1, 0.04)); - if (myid==0) GbSystem3D::writeGeoObject(refBoxL2.get(), pathOut+"/geo/refBoxL2", WbWriterVtkXmlASCII::getInstance()); - RefineCrossAndInsideGbObjectBlockVisitor refVisitorBoxL2(refBoxL2, level); - grid->accept(refVisitorBoxL2); - - ////level 2 - //level = 2; - //SPtr<GbObject3D> refCylinderL3(new GbCylinder3D(15.0, 0.0, 0.0, 15.0, 100.0, 0.0, 30.0)); - //GbSystem3D::writeGeoObject(refCylinderL3.get(), pathOut + "/geo/refCylinderL3", WbWriterVtkXmlBinary::getInstance()); - //RefineCrossAndInsideGbObjectBlockVisitor refVisitorCylinderL3(refCylinderL3, level); - //grid->accept(refVisitorCylinderL3); - - //SPtr<GbObject3D> refBoxL3(new GbCuboid3D(15.0, 0.0, -30.0, 700.0, 100.0, 30.0)); - //if (myid==0) GbSystem3D::writeGeoObject(refBoxL3.get(), pathOut+"/geo/refBoxL3", WbWriterVtkXmlASCII::getInstance()); - //RefineCrossAndInsideGbObjectBlockVisitor refVisitorBoxL3(refBoxL3, level); - //grid->accept(refVisitorBoxL3); - - ////level 3 - //level = 3; - //SPtr<GbObject3D> refCylinderL4(new GbCylinder3D(15.0, 0.0, 0.0, 15.0, 100.0, 0.0, 25.0)); - //GbSystem3D::writeGeoObject(refCylinderL4.get(), pathOut + "/geo/refCylinderL4", WbWriterVtkXmlBinary::getInstance()); - //RefineCrossAndInsideGbObjectBlockVisitor refVisitorCylinderL4(refCylinderL4, level); - //grid->accept(refVisitorCylinderL4); - - //SPtr<GbObject3D> refBoxL4(new GbCuboid3D(15.0, 0.0, -25.0, 400.0, 100.0, 25.0)); - //if (myid==0) GbSystem3D::writeGeoObject(refBoxL4.get(), pathOut+"/geo/refBoxL4", WbWriterVtkXmlASCII::getInstance()); - //RefineCrossAndInsideGbObjectBlockVisitor refVisitorBoxL4(refBoxL4, level); - //grid->accept(refVisitorBoxL4); - - ////level 4 - //level = 4; - //SPtr<GbObject3D> refBoxL5(new GbCuboid3D(120.0, 0.0, -9.0, 320.0, 100.0, 18.0)); - //if (myid==0) GbSystem3D::writeGeoObject(refBoxL5.get(), pathOut+"/geo/refBoxL5", WbWriterVtkXmlASCII::getInstance()); - //RefineCrossAndInsideGbObjectBlockVisitor refVisitorBoxL5(refBoxL5, level); - //grid->accept(refVisitorBoxL5); - - //last level - //dynamicPointerCast<D3Q27TriFaceMeshInteractor>(fngIntrWhole)->refineBlockGridToLevel(refineLevel, startDistance, refineDistance); - - - grid->setRank(rank); - - { - WriteBlocksCoProcessor ppblocks(grid, SPtr<UbScheduler>(new UbScheduler(1)), pathOut, WbWriterVtkXmlBinary::getInstance(), comm); - ppblocks.process(0); - } - - /////delete solid blocks - if (myid==0) UBLOG(logINFO, "deleteSolidBlocks - start"); - - SetSolidBlockVisitor v(fngIntrWhole, BlockType::SOLID); - grid->accept(v); - std::vector<SPtr<Block3D>>& sb = fngIntrWhole->getSolidBlockSet(); - for(SPtr<Block3D> block : sb) - { - grid->deleteBlock(block); - } - fngIntrWhole->removeSolidBlocks(); - fngIntrWhole->removeBcBlocks(); - - if (myid==0) UBLOG(logINFO, "deleteSolidBlocks - end"); - ////////////////////////////////////// - - - RatioBlockVisitor ratioVisitor(refineLevel); - CheckRatioBlockVisitor checkRatio(refineLevel); - int count = 0; - - do { - grid->accept(ratioVisitor); - checkRatio.resetState(); - grid->accept(checkRatio); - if (myid==0) UBLOG(logINFO, "count = "<<count++<<" state = "<<checkRatio.getState()); - } while (!checkRatio.getState()); - - - { - WriteBlocksCoProcessor ppblocks(grid, SPtr<UbScheduler>(new UbScheduler(1)), pathOut, WbWriterVtkXmlBinary::getInstance(), comm); - ppblocks.process(1); - } - - OverlapBlockVisitor overlapVisitor(refineLevel, false); - grid->accept(overlapVisitor); - - if (myid==0) UBLOG(logINFO, "Refinement - end"); - } - grid->updateDistributedBlocks(comm); - - std::vector<int> dirs; - for (int i = D3Q27System::E; i<=D3Q27System::TS; i++) - { - dirs.push_back(i); - } - SetInterpolationDirsBlockVisitor interDirsVisitor(dirs); - grid->accept(interDirsVisitor); - - //walls - GbCuboid3DPtr addWallZmin(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_minX3)); - if (myid==0) GbSystem3D::writeGeoObject(addWallZmin.get(), pathOut+"/geo/addWallZmin", WbWriterVtkXmlASCII::getInstance()); - - GbCuboid3DPtr addWallZmax(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_maxX3, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); - if (myid==0) GbSystem3D::writeGeoObject(addWallZmax.get(), pathOut+"/geo/addWallZmax", WbWriterVtkXmlASCII::getInstance()); - - //wall interactors - SPtr<D3Q27Interactor> addWallZminInt(new D3Q27Interactor(addWallZmin, grid, velBCAdapter, Interactor3D::SOLID)); - SPtr<D3Q27Interactor> addWallZmaxInt(new D3Q27Interactor(addWallZmax, grid, velBCAdapter, Interactor3D::SOLID)); - - //inflow - GbCuboid3DPtr geoInflow(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_minX1, g_maxX2+blockLength, g_maxX3+blockLength)); - if (myid==0) GbSystem3D::writeGeoObject(geoInflow.get(), pathOut+"/geo/geoInflow", WbWriterVtkXmlASCII::getInstance()); - - //outflow - GbCuboid3DPtr geoOutflow(new GbCuboid3D(g_maxX1, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); - if (myid==0) GbSystem3D::writeGeoObject(geoOutflow.get(), pathOut+"/geo/geoOutflow", WbWriterVtkXmlASCII::getInstance()); - - //inflow - SPtr<D3Q27Interactor> inflowIntr = SPtr<D3Q27Interactor>(new D3Q27Interactor(geoInflow, grid, velBCAdapter, Interactor3D::SOLID)); - - //outflow - SPtr<D3Q27Interactor> outflowIntr = SPtr<D3Q27Interactor>(new D3Q27Interactor(geoOutflow, grid, outflowBCAdapter, Interactor3D::SOLID)); - - //////////////////////////////////////////// - //METIS - SPtr<Grid3DVisitor> metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::KWAY)); - //////////////////////////////////////////// - /////delete solid blocks - if (myid==0) UBLOG(logINFO, "deleteSolidBlocks - start"); - InteractorsHelper intHelper(grid, metisVisitor); - intHelper.addInteractor(inflowIntr); - intHelper.addInteractor(outflowIntr); - intHelper.addInteractor(addWallZminInt); - intHelper.addInteractor(addWallZmaxInt); - //intHelper.addInteractor(triBand1Interactor); - //intHelper.addInteractor(triBand2Interactor); - //intHelper.addInteractor(triBand3Interactor); - //intHelper.addInteractor(triBand4Interactor); - intHelper.addInteractor(fngIntrWhole); - intHelper.selectBlocks(); - - if (myid==0) UBLOG(logINFO, "deleteSolidBlocks - end"); - - if (myid==0) - { - UBLOG(logINFO, "PID = "<<myid<<" Point 4"); - UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); - } - ////////////////////////////////////// - - { - WriteBlocksCoProcessor ppblocks(grid, SPtr<UbScheduler>(new UbScheduler(1)), pathOut, WbWriterVtkXmlBinary::getInstance(), comm); - ppblocks.process(2); - } - - unsigned long long numberOfBlocks = (unsigned long long)grid->getNumberOfBlocks(); - int ghostLayer = 3; - unsigned long long numberOfNodesPerBlock = (unsigned long long)(blockNx[0])* (unsigned long long)(blockNx[1])* (unsigned long long)(blockNx[2]); - unsigned long long numberOfNodes = numberOfBlocks * numberOfNodesPerBlock; - unsigned long long numberOfNodesPerBlockWithGhostLayer = numberOfBlocks * (blockNx[0]+ghostLayer) * (blockNx[1]+ghostLayer) * (blockNx[2]+ghostLayer); - double needMemAll = double(numberOfNodesPerBlockWithGhostLayer*(27*sizeof(double)+sizeof(int)+sizeof(float)*4)); - double needMem = needMemAll/double(comm->getNumberOfProcesses()); - - if (myid==0) - { - UBLOG(logINFO, "Number of blocks = "<<numberOfBlocks); - UBLOG(logINFO, "Number of nodes = "<<numberOfNodes); - int minInitLevel = grid->getCoarsestInitializedLevel(); - int maxInitLevel = grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level<=maxInitLevel; level++) - { - int nobl = grid->getNumberOfBlocks(level); - UBLOG(logINFO, "Number of blocks for level "<<level<<" = "<<nobl); - UBLOG(logINFO, "Number of nodes for level "<<level<<" = "<<nobl*numberOfNodesPerBlock); - } - UBLOG(logINFO, "Necessary memory = "<<needMemAll<<" bytes"); - UBLOG(logINFO, "Necessary memory per process = "<<needMem<<" bytes"); - UBLOG(logINFO, "Available memory per process = "<<availMem<<" bytes"); - } - - - SetKernelBlockVisitor kernelVisitor(kernel, nuLB, availMem, needMem); - grid->accept(kernelVisitor); - - if (myid==0) UBLOG(logINFO, "SetKernelBlockVisitor:end"); - - if (myid==0) - { - UBLOG(logINFO, "PID = "<<myid<<" Point 5"); - UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); - } - - if (refineLevel>0) - { - SetUndefinedNodesBlockVisitor undefNodesVisitor; - grid->accept(undefNodesVisitor); - } - - if (myid==0) UBLOG(logINFO, "SetUndefinedNodesBlockVisitor:end"); - - //BC - intHelper.setBC(); - if (myid==0) UBLOG(logINFO, "intHelper.setBC():end"); - - if (myid==0) - { - UBLOG(logINFO, "PID = "<<myid<<" Point 6"); - UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); - } - - //initialization of distributions - InitDistributionsBlockVisitor initVisitor1(nuLB, rhoLB); - initVisitor1.setVx1(fct); - grid->accept(initVisitor1); - - ////set connectors - InterpolationProcessorPtr iProcessor(new CompressibleOffsetInterpolationProcessor()); - SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); - grid->accept(setConnsVisitor); - - //domain decomposition for threads - //PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); - //grid->accept(pqPartVisitor); - - //bcVisitor should be accept after initialization!!!! - grid->accept(bcVisitor); - if (myid==0) UBLOG(logINFO, "grid->accept(bcVisitor):end"); - - if (myid==0) - { - UBLOG(logINFO, "PID = "<<myid<<" Point 7"); - UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); - } - - //Postrozess - { - SPtr<UbScheduler> geoSch(new UbScheduler(1)); - WriteBoundaryConditionsCoProcessor ppgeo(grid, geoSch, pathOut, WbWriterVtkXmlBinary::getInstance(), conv, comm); - ppgeo.process(0); - } - - if (myid==0) - { - UBLOG(logINFO, "PID = "<<myid<<" Point 8"); - UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); - } - - ////sponge layer - //////////////////////////////////////////////////////////////////////////// - - //GbCuboid3DPtr spongeLayerX1max(new GbCuboid3D(g_maxX1-8.0*blockLength, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); - //if (myid==0) GbSystem3D::writeGeoObject(spongeLayerX1max.get(), pathOut+"/geo/spongeLayerX1max", WbWriterVtkXmlASCII::getInstance()); - //SpongeLayerBlockVisitor slVisitorX1max(spongeLayerX1max, 1.0); - //grid->accept(slVisitorX1max); - - //GbCuboid3DPtr spongeLayerX1min(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_minX1+75, g_maxX2+blockLength, g_maxX3+blockLength)); - //if (myid==0) GbSystem3D::writeGeoObject(spongeLayerX1min.get(), pathOut+"/geo/spongeLayerX1min", WbWriterVtkXmlASCII::getInstance()); - //SpongeLayerBlockVisitor slVisitorX1min(spongeLayerX1min); - //grid->accept(slVisitorX1min); - - //GbCuboid3DPtr spongeLayerX3min(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_minX3+75)); - //if (myid==0) GbSystem3D::writeGeoObject(spongeLayerX3min.get(), pathOut+"/geo/spongeLayerX3min", WbWriterVtkXmlASCII::getInstance()); - //SpongeLayerBlockVisitor slVisitorX3min(spongeLayerX3min); - //grid->accept(slVisitorX3min); - - //GbCuboid3DPtr spongeLayerX3max(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_maxX3-75, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); - //if (myid==0) GbSystem3D::writeGeoObject(spongeLayerX3max.get(), pathOut+"/geo/spongeLayerX3max", WbWriterVtkXmlASCII::getInstance()); - //SpongeLayerBlockVisitor slVisitorX3max(spongeLayerX3max); - //grid->accept(slVisitorX3max); - - ///////////////////////////////////////////////////////////////////////////// - if (myid==0) UBLOG(logINFO, "Preprozess - end"); - } - else - { - restartCoProcessor->restart((int)restartStep); - grid->setTimeStep(restartStep); - //////////////////////////////////////////////////////////////////////////// - InterpolationProcessorPtr iProcessor(new CompressibleOffsetInterpolationProcessor()); - SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); - grid->accept(setConnsVisitor); - - grid->accept(bcVisitor); - - //GbCuboid3DPtr spongeLayerX1max(new GbCuboid3D(g_maxX1-5.0*blockLength, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); - //if (myid==0) GbSystem3D::writeGeoObject(spongeLayerX1max.get(), pathOut+"/geo/spongeLayerX1max", WbWriterVtkXmlASCII::getInstance()); - //SpongeLayerBlockVisitor slVisitorX1max(spongeLayerX1max, 1.0); - //grid->accept(slVisitorX1max); - } - - SPtr<UbScheduler> nupsSch(new UbScheduler(nupsStep[0], nupsStep[1], nupsStep[2])); - NUPSCounterCoProcessor npr(grid, nupsSch, numOfThreads, comm); - - SPtr<UbScheduler> stepSch(new UbScheduler(outTimeStep, outTimeStart)); - - if (myid==0) - { - UBLOG(logINFO, "PID = "<<myid<<" Point 9"); - UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); - } - - SPtr<WriteMacroscopicQuantitiesCoProcessor> writeMQCoProcessor(new WriteMacroscopicQuantitiesCoProcessor(grid, stepSch, pathOut, WbWriterVtkXmlBinary::getInstance(), conv, comm)); - - SPtr<UbScheduler> tavSch(new UbScheduler(1, timeAvStart, timeAvStop)); - SPtr<TimeAveragedValuesCoProcessor> tav(new TimeAveragedValuesCoProcessor(grid, pathOut, WbWriterVtkXmlBinary::getInstance(), tavSch, comm, - TimeAveragedValuesCoProcessor::Density | TimeAveragedValuesCoProcessor::Velocity | TimeAveragedValuesCoProcessor::Fluctuations)); - tav->setWithGhostLayer(true); - - SPtr<IntegrateValuesHelper> mic1(new IntegrateValuesHelper(grid, comm, 300-deltaXcoarse, 35, -600-deltaXcoarse, 300, 65, -600)); - if (myid==0) GbSystem3D::writeGeoObject(mic1->getBoundingBox().get(), pathOut+"/geo/mic1", WbWriterVtkXmlBinary::getInstance()); - SPtr<UbScheduler> stepMV(new UbScheduler(1)); - //TimeseriesCoProcessor tsp1(grid, stepMV, mic1, pathOut+"/mic/mic1", comm); - - omp_set_num_threads(2); - SPtr<Calculator> calculator(new OMPCalculator()); - calculator->setGrid(grid); - calculator->setLastTimeStep(endTime); - calculator->setVisScheduler(stepSch); - calculator->addCoProcessor(restartCoProcessor); - calculator->addCoProcessor(writeMQCoProcessor); - - - if (myid==0) UBLOG(logINFO, "Simulation-start"); - calculator->calculate(); - if (myid==0) UBLOG(logINFO, "Simulation-end"); - - if (myid==0) - { - UBLOG(logINFO, "PID = "<<myid<<" Point 10"); - UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); - } - } - catch (std::exception& e) - { - cerr<<e.what()<<endl<<flush; - } - catch (std::string& s) - { - cerr<<s<<endl; - } - catch (...) - { - cerr<<"unknown exception"<<endl; - } - -} - -int main(int argc, char* argv[]) -{ - - if (argv!=NULL) - { - if (argv[1]!=NULL) - { - run(string(argv[1])); - } - else - { - cout<<"Configuration file must be set!: "<<argv[0]<<" <config file>"<<endl<<std::flush; - } - } - - return 0; -} - +#include <iostream> +#include <string> + +#include <PointerDefinitions.h> +#include "VirtualFluids.h" +#include <omp.h> +using namespace std; + +void run(string configname) +{ + try + { + ConfigurationFile config; + config.load(configname); + + string pathOut = config.getValue<string>("pathOut"); + string pathGeo = config.getValue<string>("pathGeo"); + string fngFileWhole = config.getValue<string>("fngFileWhole"); + string zigZagTape = config.getValue<string>("zigZagTape"); + int numOfThreads = config.getValue<int>("numOfThreads"); + vector<int> blockNx = config.getVector<int>("blockNx"); + vector<double> boundingBox = config.getVector<double>("boundingBox"); + double restartStep = config.getValue<double>("restartStep"); + double cpStart = config.getValue<double>("cpStart"); + double cpStep = config.getValue<double>("cpStep"); + int endTime = config.getValue<int>("endTime"); + double outTimeStep = config.getValue<double>("outTimeStep"); + double outTimeStart = config.getValue<double>("outTimeStart"); + double availMem = config.getValue<double>("availMem"); + int refineLevel = config.getValue<int>("refineLevel"); + bool logToFile = config.getValue<bool>("logToFile"); + double deltaXfine = config.getValue<double>("deltaXfine"); + double refineDistance = config.getValue<double>("refineDistance"); + double startDistance = config.getValue<double>("startDistance"); + vector<double> nupsStep = config.getVector<double>("nupsStep"); + bool newStart = config.getValue<bool>("newStart"); + bool writeBlocks = config.getValue<bool>("writeBlocks"); + string pathReInit = config.getValue<string>("pathReInit"); + int stepReInit = config.getValue<int>("stepReInit"); + + double pcpStart = config.getValue<double>("pcpStart"); + double pcpStop = config.getValue<double>("pcpStop"); + + double timeAvStart = config.getValue<double>("timeAvStart"); + double timeAvStop = config.getValue<double>("timeAvStop"); + + SPtr<Communicator> comm = MPICommunicator::getInstance(); + int myid = comm->getProcessID(); + + if (logToFile) + { +#if defined(__unix__) + if (myid==0) + { + const char* str = pathOut.c_str(); + mkdir(str, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH); + } +#endif + + if (myid==0) + { + stringstream logFilename; + logFilename<<pathOut+"/logfile"+UbSystem::toString(UbSystem::getTimeStamp())+".txt"; + UbLog::output_policy::setStream(logFilename.str()); + } + } + + if (myid==0) + { + UBLOG(logINFO, "PID = "<<myid<<" Point 1"); + UBLOG(logINFO, "PID = "<<myid<<" Total Physical Memory (RAM): "<<Utilities::getTotalPhysMem()); + UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used: "<<Utilities::getPhysMemUsed()); + UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); + } + + + //the geometry is in mm + + double g_minX1 = boundingBox[0]; + double g_minX2 = boundingBox[2]; + double g_minX3 = boundingBox[4]; + + double g_maxX1 = boundingBox[1]; + double g_maxX2 = boundingBox[3]; + double g_maxX3 = boundingBox[5]; + + ////////////////////////////////////////////////////////////////////////// + double deltaXcoarse = deltaXfine*(double)(1<<refineLevel); + ////////////////////////////////////////////////////////////////////////// + double blockLength = (double)blockNx[0]*deltaXcoarse; + + //########################################################################## + //## physical parameters + //########################################################################## + double Re = 1e6; + + double rhoLB = 0.0; + double rhoReal = 1.2041; //(kg/m3) + //double nueReal = 153.5e-7; //m^2/s + double uReal = 55; //m/s + double lReal = 0.3;//m + //double uReal = Re*nueReal / lReal; + double nuReal = (uReal*lReal)/Re; //m^2/s + + //##Machzahl: + //#Ma = uReal/csReal + double Ma = 0.15;//Ma-Real! + double csReal = uReal / Ma; + double hLB = lReal / deltaXcoarse; + + LBMUnitConverter unitConverter(lReal, csReal, rhoReal, hLB); + + double uLB = uReal * unitConverter.getFactorVelocityWToLb(); + double nuLB = nuReal * unitConverter.getFactorViscosityWToLb(); + double lLB = lReal*1000.0/deltaXcoarse; + //double nuLB = (uLB*lLB)/Re; //0.005; + //double nuLB = 0.005; + + SPtr<LBMUnitConverter> conv = SPtr<LBMUnitConverter>(new LBMUnitConverter()); + + const int baseLevel = 0; + + //////////////////////////////////////////////////////////////////////// + //Grid + ////////////////////////////////////////////////////////////////////////// + SPtr<Grid3D> grid(new Grid3D(comm)); + + //BC adapters + SPtr<BCAdapter> noSlipBCAdapter(new NoSlipBCAdapter()); + noSlipBCAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new NoSlipBCAlgorithm())); + + SPtr<BCAdapter> slipBCAdapter(new SlipBCAdapter()); + slipBCAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new SlipBCAlgorithm())); + + mu::Parser fct; + fct.SetExpr("U"); + fct.DefineConst("U", uLB); + SPtr<BCAdapter> velBCAdapter(new VelocityBCAdapter(true, false, false, fct, 0, BCFunction::INFCONST)); + velBCAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new VelocityWithDensityBCAlgorithm())); + + //fct.SetExpr("U"); + //fct.DefineConst("U", 0.01); + //SPtr<BCAdapter> velBCAdapterOut(new VelocityBCAdapter(true, false, false, fct, 0, BCFunction::INFCONST)); + //velBCAdapterOut->setBcAlgorithm(SPtr<BCAlgorithm>(new VelocityBCAlgorithm())); + + SPtr<BCAdapter> outflowBCAdapter(new DensityBCAdapter(rhoLB)); + outflowBCAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new NonReflectingOutflowBCAlgorithm())); + + BoundaryConditionsBlockVisitor bcVisitor; + bcVisitor.addBC(noSlipBCAdapter); + bcVisitor.addBC(velBCAdapter); + bcVisitor.addBC(outflowBCAdapter); + + SPtr<LBMKernel> kernel = SPtr<LBMKernel>(new CompressibleCumulantViscosity4thLBMKernel(blockNx[0], blockNx[1], blockNx[2], CompressibleCumulantViscosity4thLBMKernel::NORMAL)); + SPtr<BCProcessor> bcProc; + bcProc = SPtr<BCProcessor>(new BCProcessor()); + kernel->setBCProcessor(bcProc); + ////////////////////////////////////////////////////////////////////////// + //restart + SPtr<UbScheduler> rSch(new UbScheduler(cpStep, cpStart)); + SPtr<MPIIORestartCoProcessor> restartCoProcessor(new MPIIORestartCoProcessor(grid, rSch, pathOut, comm)); + restartCoProcessor->setLBMKernel(kernel); + restartCoProcessor->setBCProcessor(bcProc); + ////////////////////////////////////////////////////////////////////////// + + if (myid==0) + { + UBLOG(logINFO, "PID = "<<myid<<" Point 2"); + UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); + } + + + if (newStart) + { + //////////////////////////////////////////////////////////////////////// + //define grid + ////////////////////////////////////////////////////////////////////////// + grid->setDeltaX(deltaXcoarse); + grid->setBlockNX(blockNx[0], blockNx[1], blockNx[2]); + + SPtr<GbObject3D> gridCube(new GbCuboid3D(g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3)); + if (myid==0) GbSystem3D::writeGeoObject(gridCube.get(), pathOut+"/geo/gridCube", WbWriterVtkXmlASCII::getInstance()); + GenBlocksGridVisitor genBlocks(gridCube); + grid->accept(genBlocks); + + grid->setPeriodicX1(false); + grid->setPeriodicX2(true); + grid->setPeriodicX3(false); + + if (myid==0) + { + UBLOG(logINFO, "Parameters:"); + UBLOG(logINFO, "* Re = "<<Re); + UBLOG(logINFO, "* Ma = "<<Ma); + UBLOG(logINFO, "* velocity (uReal) = "<<uReal<<" m/s"); + UBLOG(logINFO, "* viscosity (nuReal) = "<<nuReal<<" m^2/s"); + UBLOG(logINFO, "* chord length (lReal)= "<<lReal<<" m"); + UBLOG(logINFO, "* velocity LB (uLB) = "<<uLB); + UBLOG(logINFO, "* viscosity LB (nuLB) = "<<nuLB); + UBLOG(logINFO, "* chord length (l_LB) = "<<lLB<<" dx_base"); + UBLOG(logINFO, "* dx_base = "<<deltaXcoarse<<" m"); + UBLOG(logINFO, "* dx_refine = "<<deltaXfine<<" m"); + UBLOG(logINFO, "* blocknx = "<<blockNx[0]<<"x"<<blockNx[1]<<"x"<<blockNx[2]); + UBLOG(logINFO, "* refineDistance = "<<refineDistance); + UBLOG(logINFO, "* number of levels = "<<refineLevel+1); + UBLOG(logINFO, "* number of threads = "<<numOfThreads); + UBLOG(logINFO, "* number of processes = "<<comm->getNumberOfProcesses()); + UBLOG(logINFO, "* path = "<<pathOut); + UBLOG(logINFO, "Preprozess - start"); + } + + + //SPtr<GbObject3D> fngMeshWhole(new GbCylinder3D(15.0, 0.0, 0.0, 15.0, 100.0, 0.0, 25.0)); + //GbSystem3D::writeGeoObject(fngMeshWhole.get(), pathOut + "/geo/fngMeshWholeCylinder", WbWriterVtkXmlBinary::getInstance()); + + SPtr<GbTriFaceMesh3D> fngMeshWhole; + if (myid==0) UBLOG(logINFO, "Read fngFileWhole:start"); + fngMeshWhole = SPtr<GbTriFaceMesh3D>(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile2(pathGeo+"/"+fngFileWhole, "fngMeshWhole", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); + if (myid==0) UBLOG(logINFO, "Read fngFileWhole:end"); + fngMeshWhole->rotate(0.0, 0.5, 0.0); + //fngMeshWhole->scale(1e-3,1e-3,1e-3); + //fngMeshWhole->translate(-150.0,-50.0,-1.28); + if (myid==0) GbSystem3D::writeGeoObject(fngMeshWhole.get(), pathOut+"/geo/fngMeshWhole", WbWriterVtkXmlBinary::getInstance()); + + if (myid==0) + { + UBLOG(logINFO, "PID = "<<myid<<" Point 3"); + UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); + } + ////////////////////////////////////////////////////////////////////////// + SPtr<Interactor3D> fngIntrWhole; + //fngIntrWhole = SPtr<D3Q27Interactor>(new D3Q27Interactor(fngMeshWhole, grid, noSlipBCAdapter, Interactor3D::SOLID));//, Interactor3D::POINTS)); + fngIntrWhole = SPtr<D3Q27TriFaceMeshInteractor>(new D3Q27TriFaceMeshInteractor(fngMeshWhole, grid, noSlipBCAdapter, Interactor3D::SOLID, Interactor3D::POINTS)); + + if (refineLevel>0 && myid==0 && writeBlocks) + { + if (myid==0) UBLOG(logINFO, "Refinement - start"); + int rank = grid->getRank(); + grid->setRank(0); + + int level; + + //level 1 + level = 1; + SPtr<GbObject3D> refCylinderL2(new GbCylinder3D(0.015, 0.0, 0.0, 0.015, 0.1, 0.0, 0.040)); + GbSystem3D::writeGeoObject(refCylinderL2.get(), pathOut + "/geo/refCylinderL2", WbWriterVtkXmlBinary::getInstance()); + RefineCrossAndInsideGbObjectBlockVisitor refVisitorCylinderL2(refCylinderL2, level); + grid->accept(refVisitorCylinderL2); + + SPtr<GbObject3D> refBoxL2(new GbCuboid3D(0.015, 0.0, -0.04, 1.100, 0.1, 0.04)); + if (myid==0) GbSystem3D::writeGeoObject(refBoxL2.get(), pathOut+"/geo/refBoxL2", WbWriterVtkXmlASCII::getInstance()); + RefineCrossAndInsideGbObjectBlockVisitor refVisitorBoxL2(refBoxL2, level); + grid->accept(refVisitorBoxL2); + + ////level 2 + //level = 2; + //SPtr<GbObject3D> refCylinderL3(new GbCylinder3D(15.0, 0.0, 0.0, 15.0, 100.0, 0.0, 30.0)); + //GbSystem3D::writeGeoObject(refCylinderL3.get(), pathOut + "/geo/refCylinderL3", WbWriterVtkXmlBinary::getInstance()); + //RefineCrossAndInsideGbObjectBlockVisitor refVisitorCylinderL3(refCylinderL3, level); + //grid->accept(refVisitorCylinderL3); + + //SPtr<GbObject3D> refBoxL3(new GbCuboid3D(15.0, 0.0, -30.0, 700.0, 100.0, 30.0)); + //if (myid==0) GbSystem3D::writeGeoObject(refBoxL3.get(), pathOut+"/geo/refBoxL3", WbWriterVtkXmlASCII::getInstance()); + //RefineCrossAndInsideGbObjectBlockVisitor refVisitorBoxL3(refBoxL3, level); + //grid->accept(refVisitorBoxL3); + + ////level 3 + //level = 3; + //SPtr<GbObject3D> refCylinderL4(new GbCylinder3D(15.0, 0.0, 0.0, 15.0, 100.0, 0.0, 25.0)); + //GbSystem3D::writeGeoObject(refCylinderL4.get(), pathOut + "/geo/refCylinderL4", WbWriterVtkXmlBinary::getInstance()); + //RefineCrossAndInsideGbObjectBlockVisitor refVisitorCylinderL4(refCylinderL4, level); + //grid->accept(refVisitorCylinderL4); + + //SPtr<GbObject3D> refBoxL4(new GbCuboid3D(15.0, 0.0, -25.0, 400.0, 100.0, 25.0)); + //if (myid==0) GbSystem3D::writeGeoObject(refBoxL4.get(), pathOut+"/geo/refBoxL4", WbWriterVtkXmlASCII::getInstance()); + //RefineCrossAndInsideGbObjectBlockVisitor refVisitorBoxL4(refBoxL4, level); + //grid->accept(refVisitorBoxL4); + + ////level 4 + //level = 4; + //SPtr<GbObject3D> refBoxL5(new GbCuboid3D(120.0, 0.0, -9.0, 320.0, 100.0, 18.0)); + //if (myid==0) GbSystem3D::writeGeoObject(refBoxL5.get(), pathOut+"/geo/refBoxL5", WbWriterVtkXmlASCII::getInstance()); + //RefineCrossAndInsideGbObjectBlockVisitor refVisitorBoxL5(refBoxL5, level); + //grid->accept(refVisitorBoxL5); + + //last level + //dynamicPointerCast<D3Q27TriFaceMeshInteractor>(fngIntrWhole)->refineBlockGridToLevel(refineLevel, startDistance, refineDistance); + + + grid->setRank(rank); + + { + WriteBlocksCoProcessor ppblocks(grid, SPtr<UbScheduler>(new UbScheduler(1)), pathOut, WbWriterVtkXmlBinary::getInstance(), comm); + ppblocks.process(0); + } + + /////delete solid blocks + if (myid==0) UBLOG(logINFO, "deleteSolidBlocks - start"); + + SetSolidBlockVisitor v(fngIntrWhole, BlockType::SOLID); + grid->accept(v); + std::vector<SPtr<Block3D>>& sb = fngIntrWhole->getSolidBlockSet(); + for(SPtr<Block3D> block : sb) + { + grid->deleteBlock(block); + } + fngIntrWhole->removeSolidBlocks(); + fngIntrWhole->removeBcBlocks(); + + if (myid==0) UBLOG(logINFO, "deleteSolidBlocks - end"); + ////////////////////////////////////// + + + RatioBlockVisitor ratioVisitor(refineLevel); + CheckRatioBlockVisitor checkRatio(refineLevel); + int count = 0; + + do { + grid->accept(ratioVisitor); + checkRatio.resetState(); + grid->accept(checkRatio); + if (myid==0) UBLOG(logINFO, "count = "<<count++<<" state = "<<checkRatio.getState()); + } while (!checkRatio.getState()); + + + { + WriteBlocksCoProcessor ppblocks(grid, SPtr<UbScheduler>(new UbScheduler(1)), pathOut, WbWriterVtkXmlBinary::getInstance(), comm); + ppblocks.process(1); + } + + OverlapBlockVisitor overlapVisitor(refineLevel, false); + grid->accept(overlapVisitor); + + if (myid==0) UBLOG(logINFO, "Refinement - end"); + } + grid->updateDistributedBlocks(comm); + + std::vector<int> dirs; + for (int i = D3Q27System::E; i<=D3Q27System::TS; i++) + { + dirs.push_back(i); + } + SetInterpolationDirsBlockVisitor interDirsVisitor(dirs); + grid->accept(interDirsVisitor); + + //walls + GbCuboid3DPtr addWallZmin(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_minX3)); + if (myid==0) GbSystem3D::writeGeoObject(addWallZmin.get(), pathOut+"/geo/addWallZmin", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr addWallZmax(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_maxX3, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); + if (myid==0) GbSystem3D::writeGeoObject(addWallZmax.get(), pathOut+"/geo/addWallZmax", WbWriterVtkXmlASCII::getInstance()); + + //wall interactors + SPtr<D3Q27Interactor> addWallZminInt(new D3Q27Interactor(addWallZmin, grid, velBCAdapter, Interactor3D::SOLID)); + SPtr<D3Q27Interactor> addWallZmaxInt(new D3Q27Interactor(addWallZmax, grid, velBCAdapter, Interactor3D::SOLID)); + + //inflow + GbCuboid3DPtr geoInflow(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_minX1, g_maxX2+blockLength, g_maxX3+blockLength)); + if (myid==0) GbSystem3D::writeGeoObject(geoInflow.get(), pathOut+"/geo/geoInflow", WbWriterVtkXmlASCII::getInstance()); + + //outflow + GbCuboid3DPtr geoOutflow(new GbCuboid3D(g_maxX1, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); + if (myid==0) GbSystem3D::writeGeoObject(geoOutflow.get(), pathOut+"/geo/geoOutflow", WbWriterVtkXmlASCII::getInstance()); + + //inflow + SPtr<D3Q27Interactor> inflowIntr = SPtr<D3Q27Interactor>(new D3Q27Interactor(geoInflow, grid, velBCAdapter, Interactor3D::SOLID)); + + //outflow + SPtr<D3Q27Interactor> outflowIntr = SPtr<D3Q27Interactor>(new D3Q27Interactor(geoOutflow, grid, outflowBCAdapter, Interactor3D::SOLID)); + + //////////////////////////////////////////// + //METIS + SPtr<Grid3DVisitor> metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::KWAY)); + //////////////////////////////////////////// + /////delete solid blocks + if (myid==0) UBLOG(logINFO, "deleteSolidBlocks - start"); + InteractorsHelper intHelper(grid, metisVisitor); + intHelper.addInteractor(inflowIntr); + intHelper.addInteractor(outflowIntr); + intHelper.addInteractor(addWallZminInt); + intHelper.addInteractor(addWallZmaxInt); + intHelper.addInteractor(fngIntrWhole); + intHelper.selectBlocks(); + + if (myid==0) UBLOG(logINFO, "deleteSolidBlocks - end"); + + if (myid==0) + { + UBLOG(logINFO, "PID = "<<myid<<" Point 4"); + UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); + } + ////////////////////////////////////// + + { + WriteBlocksCoProcessor ppblocks(grid, SPtr<UbScheduler>(new UbScheduler(1)), pathOut, WbWriterVtkXmlBinary::getInstance(), comm); + ppblocks.process(2); + } + + unsigned long long numberOfBlocks = (unsigned long long)grid->getNumberOfBlocks(); + int ghostLayer = 3; + unsigned long long numberOfNodesPerBlock = (unsigned long long)(blockNx[0])* (unsigned long long)(blockNx[1])* (unsigned long long)(blockNx[2]); + unsigned long long numberOfNodes = numberOfBlocks * numberOfNodesPerBlock; + unsigned long long numberOfNodesPerBlockWithGhostLayer = numberOfBlocks * (blockNx[0]+ghostLayer) * (blockNx[1]+ghostLayer) * (blockNx[2]+ghostLayer); + double needMemAll = double(numberOfNodesPerBlockWithGhostLayer*(27*sizeof(double)+sizeof(int)+sizeof(float)*4)); + double needMem = needMemAll/double(comm->getNumberOfProcesses()); + + if (myid==0) + { + UBLOG(logINFO, "Number of blocks = "<<numberOfBlocks); + UBLOG(logINFO, "Number of nodes = "<<numberOfNodes); + int minInitLevel = grid->getCoarsestInitializedLevel(); + int maxInitLevel = grid->getFinestInitializedLevel(); + for (int level = minInitLevel; level<=maxInitLevel; level++) + { + int nobl = grid->getNumberOfBlocks(level); + UBLOG(logINFO, "Number of blocks for level "<<level<<" = "<<nobl); + UBLOG(logINFO, "Number of nodes for level "<<level<<" = "<<nobl*numberOfNodesPerBlock); + } + UBLOG(logINFO, "Necessary memory = "<<needMemAll<<" bytes"); + UBLOG(logINFO, "Necessary memory per process = "<<needMem<<" bytes"); + UBLOG(logINFO, "Available memory per process = "<<availMem<<" bytes"); + } + + + SetKernelBlockVisitor kernelVisitor(kernel, nuLB, availMem, needMem); + grid->accept(kernelVisitor); + + if (myid==0) UBLOG(logINFO, "SetKernelBlockVisitor:end"); + + if (myid==0) + { + UBLOG(logINFO, "PID = "<<myid<<" Point 5"); + UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); + } + + if (refineLevel>0) + { + SetUndefinedNodesBlockVisitor undefNodesVisitor; + grid->accept(undefNodesVisitor); + } + + if (myid==0) UBLOG(logINFO, "SetUndefinedNodesBlockVisitor:end"); + + //BC + intHelper.setBC(); + if (myid==0) UBLOG(logINFO, "intHelper.setBC():end"); + + if (myid==0) + { + UBLOG(logINFO, "PID = "<<myid<<" Point 6"); + UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); + } + + //initialization of distributions + InitDistributionsBlockVisitor initVisitor1(nuLB, rhoLB); + initVisitor1.setVx1(fct); + grid->accept(initVisitor1); + + ////set connectors + InterpolationProcessorPtr iProcessor(new CompressibleOffsetInterpolationProcessor()); + SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); + grid->accept(setConnsVisitor); + + //domain decomposition for threads + //PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); + //grid->accept(pqPartVisitor); + + //bcVisitor should be accept after initialization!!!! + grid->accept(bcVisitor); + if (myid==0) UBLOG(logINFO, "grid->accept(bcVisitor):end"); + + if (myid==0) + { + UBLOG(logINFO, "PID = "<<myid<<" Point 7"); + UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); + } + + //Postrozess + { + SPtr<UbScheduler> geoSch(new UbScheduler(1)); + WriteBoundaryConditionsCoProcessor ppgeo(grid, geoSch, pathOut, WbWriterVtkXmlBinary::getInstance(), conv, comm); + ppgeo.process(0); + } + + if (myid==0) + { + UBLOG(logINFO, "PID = "<<myid<<" Point 8"); + UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); + } + + ////sponge layer + //////////////////////////////////////////////////////////////////////////// + + //GbCuboid3DPtr spongeLayerX1max(new GbCuboid3D(g_maxX1-8.0*blockLength, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); + //if (myid==0) GbSystem3D::writeGeoObject(spongeLayerX1max.get(), pathOut+"/geo/spongeLayerX1max", WbWriterVtkXmlASCII::getInstance()); + //SpongeLayerBlockVisitor slVisitorX1max(spongeLayerX1max, 1.0); + //grid->accept(slVisitorX1max); + + //GbCuboid3DPtr spongeLayerX1min(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_minX1+75, g_maxX2+blockLength, g_maxX3+blockLength)); + //if (myid==0) GbSystem3D::writeGeoObject(spongeLayerX1min.get(), pathOut+"/geo/spongeLayerX1min", WbWriterVtkXmlASCII::getInstance()); + //SpongeLayerBlockVisitor slVisitorX1min(spongeLayerX1min); + //grid->accept(slVisitorX1min); + + //GbCuboid3DPtr spongeLayerX3min(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_minX3+75)); + //if (myid==0) GbSystem3D::writeGeoObject(spongeLayerX3min.get(), pathOut+"/geo/spongeLayerX3min", WbWriterVtkXmlASCII::getInstance()); + //SpongeLayerBlockVisitor slVisitorX3min(spongeLayerX3min); + //grid->accept(slVisitorX3min); + + //GbCuboid3DPtr spongeLayerX3max(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_maxX3-75, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); + //if (myid==0) GbSystem3D::writeGeoObject(spongeLayerX3max.get(), pathOut+"/geo/spongeLayerX3max", WbWriterVtkXmlASCII::getInstance()); + //SpongeLayerBlockVisitor slVisitorX3max(spongeLayerX3max); + //grid->accept(slVisitorX3max); + + ///////////////////////////////////////////////////////////////////////////// + if (myid==0) UBLOG(logINFO, "Preprozess - end"); + } + else + { + restartCoProcessor->restart((int)restartStep); + grid->setTimeStep(restartStep); + //////////////////////////////////////////////////////////////////////////// + InterpolationProcessorPtr iProcessor(new CompressibleOffsetInterpolationProcessor()); + SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); + grid->accept(setConnsVisitor); + + grid->accept(bcVisitor); + + //GbCuboid3DPtr spongeLayerX1max(new GbCuboid3D(g_maxX1-5.0*blockLength, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); + //if (myid==0) GbSystem3D::writeGeoObject(spongeLayerX1max.get(), pathOut+"/geo/spongeLayerX1max", WbWriterVtkXmlASCII::getInstance()); + //SpongeLayerBlockVisitor slVisitorX1max(spongeLayerX1max, 1.0); + //grid->accept(slVisitorX1max); + } + + SPtr<UbScheduler> nupsSch(new UbScheduler(nupsStep[0], nupsStep[1], nupsStep[2])); + std::shared_ptr<NUPSCounterCoProcessor> nupsCoProcessor(new NUPSCounterCoProcessor(grid, nupsSch, numOfThreads, comm)); + + SPtr<UbScheduler> stepSch(new UbScheduler(outTimeStep, outTimeStart)); + + if (myid==0) + { + UBLOG(logINFO, "PID = "<<myid<<" Point 9"); + UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); + } + + SPtr<WriteMacroscopicQuantitiesCoProcessor> writeMQCoProcessor(new WriteMacroscopicQuantitiesCoProcessor(grid, stepSch, pathOut, WbWriterVtkXmlBinary::getInstance(), conv, comm)); + + SPtr<UbScheduler> tavSch(new UbScheduler(1, timeAvStart, timeAvStop)); + SPtr<TimeAveragedValuesCoProcessor> tav(new TimeAveragedValuesCoProcessor(grid, pathOut, WbWriterVtkXmlBinary::getInstance(), tavSch, comm, + TimeAveragedValuesCoProcessor::Density | TimeAveragedValuesCoProcessor::Velocity | TimeAveragedValuesCoProcessor::Fluctuations)); + tav->setWithGhostLayer(true); + + SPtr<IntegrateValuesHelper> mic1(new IntegrateValuesHelper(grid, comm, 300-deltaXcoarse, 35, -600-deltaXcoarse, 300, 65, -600)); + if (myid==0) GbSystem3D::writeGeoObject(mic1->getBoundingBox().get(), pathOut+"/geo/mic1", WbWriterVtkXmlBinary::getInstance()); + SPtr<UbScheduler> stepMV(new UbScheduler(1)); + //TimeseriesCoProcessor tsp1(grid, stepMV, mic1, pathOut+"/mic/mic1", comm); + + //omp_set_num_threads(2); + SPtr<Calculator> calculator(new MPICalculator()); + calculator->setGrid(grid); + calculator->setLastTimeStep(endTime); + calculator->setVisScheduler(stepSch); + calculator->addCoProcessor(nupsCoProcessor); + calculator->addCoProcessor(restartCoProcessor); + calculator->addCoProcessor(writeMQCoProcessor); + + + if (myid==0) UBLOG(logINFO, "Simulation-start"); + calculator->calculate(); + if (myid==0) UBLOG(logINFO, "Simulation-end"); + + if (myid==0) + { + UBLOG(logINFO, "PID = "<<myid<<" Point 10"); + UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); + } + } + catch (std::exception& e) + { + cerr<<e.what()<<endl<<flush; + } + catch (std::string& s) + { + cerr<<s<<endl; + } + catch (...) + { + cerr<<"unknown exception"<<endl; + } + +} + +void test_run() +{ + try + { + + SPtr<Communicator> comm = MPICommunicator::getInstance(); + int myid = comm->getProcessID(); + + if (myid==0) + { + UBLOG(logINFO, "PID = "<<myid<<" Point 1"); + UBLOG(logINFO, "PID = "<<myid<<" Total Physical Memory (RAM): "<<Utilities::getTotalPhysMem()); + UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used: "<<Utilities::getPhysMemUsed()); + UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()/1073741824.0<<" GB"); + } + + double g_minX1 = 0; + double g_minX2 = 0; + double g_minX3 = 0; + + double g_maxX1 = 5; + double g_maxX2 = 5; + double g_maxX3 = 5; + + double blockNx[3] ={ 5, 5, 5 }; + + string pathOut = "d:/temp/DLR-F16-Solid-test"; + + double deltaX = 1; + double rhoLB = 0.0; + double uLB = 0.0866025; + double nuLB = 0.001; //4.33013e-06; + SPtr<LBMUnitConverter> conv = SPtr<LBMUnitConverter>(new LBMUnitConverter()); + //////////////////////////////////////////////////////////////////////// + //Grid + ////////////////////////////////////////////////////////////////////////// + SPtr<Grid3D> grid(new Grid3D(comm)); + grid->setDeltaX(deltaX); + grid->setBlockNX(blockNx[0], blockNx[1], blockNx[2]); + grid->setPeriodicX1(false); + grid->setPeriodicX2(false); + grid->setPeriodicX3(false); + + SPtr<GbObject3D> gridCube(new GbCuboid3D(g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3)); + if (myid==0) GbSystem3D::writeGeoObject(gridCube.get(), pathOut+"/geo/gridCube", WbWriterVtkXmlASCII::getInstance()); + GenBlocksGridVisitor genBlocks(gridCube); + grid->accept(genBlocks); + + WriteBlocksCoProcessor ppblocks(grid, SPtr<UbScheduler>(new UbScheduler(1)), pathOut, WbWriterVtkXmlBinary::getInstance(), comm); + ppblocks.process(0); + + SPtr<LBMKernel> kernel = SPtr<LBMKernel>(new CompressibleCumulantViscosity4thLBMKernel(blockNx[0], blockNx[1], blockNx[2], CompressibleCumulantViscosity4thLBMKernel::NORMAL)); + SPtr<BCProcessor> bcProc; + bcProc = SPtr<BCProcessor>(new BCProcessor()); + kernel->setBCProcessor(bcProc); + + SetKernelBlockVisitor kernelVisitor(kernel, nuLB, 1e9, 12); + grid->accept(kernelVisitor); + + //initialization of distributions + InitDistributionsBlockVisitor initVisitor1(nuLB, rhoLB); + initVisitor1.setVx1(0.001); + grid->accept(initVisitor1); + + SPtr<UbScheduler> stepSch(new UbScheduler(1)); + SPtr<WriteMacroscopicQuantitiesCoProcessor> writeMQCoProcessor(new WriteMacroscopicQuantitiesCoProcessor(grid, stepSch, pathOut, WbWriterVtkXmlBinary::getInstance(), conv, comm)); + + //omp_set_num_threads(numOfThreads); + SPtr<Calculator> calculator(new MPICalculator()); + calculator->setGrid(grid); + calculator->setLastTimeStep(2); + calculator->setVisScheduler(stepSch); + calculator->addCoProcessor(writeMQCoProcessor); + calculator->setVisScheduler(stepSch); + + if (myid==0) UBLOG(logINFO, "Simulation-start"); + calculator->calculate(); + if (myid==0) UBLOG(logINFO, "Simulation-end"); + } + catch (std::exception& e) + { + cerr<<e.what()<<endl<<flush; + } + catch (std::string& s) + { + cerr<<s<<endl; + } + catch (...) + { + cerr<<"unknown exception"<<endl; + } +} + +int main(int argc, char* argv[]) +{ + + if (argv!=NULL) + { + if (argv[1]!=NULL) + { + run(string(argv[1])); + } + else + { + cout<<"Configuration file must be set!: "<<argv[0]<<" <config file>"<<endl<<std::flush; + } + } + + //test_run(); + + return 0; +} + diff --git a/source/CMake/compilerflags/icc160.cmake b/source/CMake/compilerflags/icc160.cmake index ca0e66a75..88b25faa5 100644 --- a/source/CMake/compilerflags/icc160.cmake +++ b/source/CMake/compilerflags/icc160.cmake @@ -26,14 +26,18 @@ MACRO(SET_COMPILER_SPECIFIC_FLAGS_INTERN build_type use64BitOptions) ## OpenMP support ############################################################################################################### IF(USE_OPENMP) - LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-qopenmp") + LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-openmp") ENDIF() - ############################################################################################################### ## mt support ############################################################################################################### - #LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-pthread") - #LIST(APPEND CAB_COMPILER_ADDTIONAL_C_COMPILER_FLAGS "-pthread") + LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-pthread") + LIST(APPEND CAB_COMPILER_ADDTIONAL_C_COMPILER_FLAGS "-pthread") + ############################################################################################################# + # c++ 11 support + ############################################################################################################# + LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-std=c++11") + LIST(APPEND CAB_COMPILER_ADDTIONAL_C_COMPILER_FLAGS "-std=c++11" ENDMACRO(SET_COMPILER_SPECIFIC_FLAGS_INTERN build_type use64BitOptions) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 6c844e1a4..fe601585c 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -29,9 +29,10 @@ SET(USE_METIS ON CACHE BOOL "include METIS library support") SET(USE_MPI ON CACHE BOOL "include MPI library support") SET(USE_VTK OFF CACHE BOOL "include VTK library support") SET(USE_CATALYST OFF CACHE BOOL "include Paraview Catalyst support") -SET(USE_PYTHON OFF CACHE BOOL "include Python scripting support") +SET(USE_BOOST OFF CACHE BOOL "include Paraview Catalyst support") +#SET(USE_PYTHON OFF CACHE BOOL "include Python scripting support") #SET(USE_FETOL OFF CACHE BOOL "include FETOL library support") -#SET(USE_INTEL OFF CACHE BOOL "include Intel compiler support") +SET(USE_INTEL OFF CACHE BOOL "include Intel compiler support") #SET(USE_GCC OFF CACHE BOOL "include gcc compiler support") #CAB @@ -56,6 +57,10 @@ FIND_PACKAGE(MPI REQUIRED) # FIND_PACKAGE(Boost ${BOOST_VERSION} COMPONENTS system date_time thread serialization chrono regex) #ENDIF() +IF(${USE_BOOST}) + FIND_PACKAGE(Boost ${BOOST_VERSION}) +ENDIF() + ################################################################################## # Java ############################################################################## @@ -103,6 +108,15 @@ ENDIF() IF(${USE_CATALYST}) LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DVF_CATALYST) ENDIF() + +IF(${USE_BOOST}) + LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DVF_BOOST) +ENDIF() + +IF(${USE_INTEL}) + SET(CAB_ADDITIONAL_LINK_FLAGS ${CAB_ADDITIONAL_LINK_FLAGS} -parallel) +ENDIF() + # IF(${USE_PYTHON}) # FIND_PACKAGE(PythonLibs) # INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIR}) diff --git a/source/IncludsList.cmake b/source/IncludsList.cmake index 3cad23b41..f78bec3aa 100644 --- a/source/IncludsList.cmake +++ b/source/IncludsList.cmake @@ -25,7 +25,10 @@ INCLUDE_DIRECTORIES(${SOURCE_ROOT}/ThirdParty/Library/basics/transmiitter) INCLUDE_DIRECTORIES(${SOURCE_ROOT}/ThirdParty/Library/basics/utilities) INCLUDE_DIRECTORIES(${SOURCE_ROOT}/ThirdParty/Library/basics/writer) -#INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR}) +IF(${USE_BOOST}) + INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR}) +ENDIF() + INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH}) INCLUDE_DIRECTORIES(${METIS_INCLUDEDIR}) INCLUDE_DIRECTORIES(${ZOLTAN_INCLUDEDIR}) diff --git a/source/ThirdParty/Library/basics/writer/WbWriterVtkXmlASCII.cpp b/source/ThirdParty/Library/basics/writer/WbWriterVtkXmlASCII.cpp index a5e5fdf7c..51a52f581 100644 --- a/source/ThirdParty/Library/basics/writer/WbWriterVtkXmlASCII.cpp +++ b/source/ThirdParty/Library/basics/writer/WbWriterVtkXmlASCII.cpp @@ -1,6 +1,7 @@ #include <basics/writer/WbWriterVtkXmlASCII.h> #include <basics/utilities/UbLogger.h> #include <cstring> +#include <limits> using namespace std; diff --git a/source/VirtualFluids.h b/source/VirtualFluids.h index 40901bbbb..c4e51224b 100644 --- a/source/VirtualFluids.h +++ b/source/VirtualFluids.h @@ -182,7 +182,7 @@ #include <LBM/LBMKernel.h> #include <LBM/IncompressibleCumulantLBMKernel.h> #include <LBM/CompressibleCumulantLBMKernel.h> -#include <LBM/CompressibleCumulant2LBMKernel.h> +#include <LBM/CompressibleCumulantViscosity4thLBMKernel.h> #include <LBM/InitDensityLBMKernel.h> #include <LBM/VoidLBMKernel.h> #include <LBM/LBMSystem.h> diff --git a/source/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.h b/source/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.h index b79f2ad04..dcca43230 100644 --- a/source/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.h +++ b/source/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.h @@ -88,7 +88,7 @@ public: void receiveVectorsX3() {} protected: - std::weak_ptr<Block3D> block; //dieser nvd sendet daten und die empfangenen werden diesem nvd zugeordnet + WPtr<Block3D> block; //dieser nvd sendet daten und die empfangenen werden diesem nvd zugeordnet VectorTransmitterPtr sender00, receiver00, sender01, receiver01, sender10, receiver10, diff --git a/source/VirtualFluidsCore/Connectors/D3Q27ETCFOffVectorConnector.h b/source/VirtualFluidsCore/Connectors/D3Q27ETCFOffVectorConnector.h index ade47eb0a..f4a3571ae 100644 --- a/source/VirtualFluidsCore/Connectors/D3Q27ETCFOffVectorConnector.h +++ b/source/VirtualFluidsCore/Connectors/D3Q27ETCFOffVectorConnector.h @@ -92,7 +92,7 @@ public: void receiveVectorsX3() {} protected: - std::weak_ptr<Block3D> block; //dieser nvd sendet daten und die empfangenen werden diesem nvd zugeordnet + WPtr<Block3D> block; //dieser nvd sendet daten und die empfangenen werden diesem nvd zugeordnet VectorTransmitterPtr senderEvenEvenSW, receiverEvenEvenSW, senderEvenOddNW, receiverEvenOddNW, senderOddEvenSE, receiverOddEvenSE, diff --git a/source/VirtualFluidsCore/Connectors/D3Q27ETFCOffVectorConnector.h b/source/VirtualFluidsCore/Connectors/D3Q27ETFCOffVectorConnector.h index 80be6dbd0..59c6539a1 100644 --- a/source/VirtualFluidsCore/Connectors/D3Q27ETFCOffVectorConnector.h +++ b/source/VirtualFluidsCore/Connectors/D3Q27ETFCOffVectorConnector.h @@ -82,7 +82,7 @@ public: void receiveVectorsX3() {} protected: - std::weak_ptr<Block3D> block; //dieser nvd sendet daten und die empfangenen werden diesem nvd zugeordnet + WPtr<Block3D> block; //dieser nvd sendet daten und die empfangenen werden diesem nvd zugeordnet //gegenstelle muss "inversen" connector besitzen VectorTransmitterPtr sender, receiver; diff --git a/source/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.h b/source/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.h index 908a6acb8..f90c5340b 100644 --- a/source/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.h +++ b/source/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.h @@ -83,7 +83,7 @@ public: void receiveVectorsX3() {} protected: - std::weak_ptr<Block3D> block; + WPtr<Block3D> block; VectorTransmitterPtr sender, receiver; InterpolationProcessorPtr iprocessor; CFconnectorType connType; diff --git a/source/VirtualFluidsCore/Connectors/LocalBlock3DConnector.h b/source/VirtualFluidsCore/Connectors/LocalBlock3DConnector.h index 117a7dd2f..cab9a684e 100644 --- a/source/VirtualFluidsCore/Connectors/LocalBlock3DConnector.h +++ b/source/VirtualFluidsCore/Connectors/LocalBlock3DConnector.h @@ -3,6 +3,7 @@ #include "Block3DConnector.h" #include "Block3D.h" +#include "PointerDefinitions.h" class LocalBlock3DConnector : public Block3DConnector { @@ -50,8 +51,8 @@ public: void receiveVectorsX3() {} protected: - std::weak_ptr<Block3D> from; - std::weak_ptr<Block3D> to; + WPtr<Block3D> from; + WPtr<Block3D> to; }; #endif //LocalBlock3DConnector_H diff --git a/source/VirtualFluidsCore/Connectors/RemoteBlock3DConnector.h b/source/VirtualFluidsCore/Connectors/RemoteBlock3DConnector.h index 07c22e0a5..8db7d5ee7 100644 --- a/source/VirtualFluidsCore/Connectors/RemoteBlock3DConnector.h +++ b/source/VirtualFluidsCore/Connectors/RemoteBlock3DConnector.h @@ -62,7 +62,7 @@ public: void receiveVectorsX3() {} protected: - std::weak_ptr<Block3D> block; + WPtr<Block3D> block; VectorTransmitterPtr sender; VectorTransmitterPtr receiver; }; diff --git a/source/VirtualFluidsCore/Interactors/Interactor3D.h b/source/VirtualFluidsCore/Interactors/Interactor3D.h index 1ab1722b7..9325848ef 100644 --- a/source/VirtualFluidsCore/Interactors/Interactor3D.h +++ b/source/VirtualFluidsCore/Interactors/Interactor3D.h @@ -81,7 +81,7 @@ protected: int type; - std::weak_ptr<Grid3D> grid; + WPtr<Grid3D> grid; SPtr<GbObject3D> geoObject3D; std::vector<SPtr<Block3D> > bcBlocks; diff --git a/source/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp b/source/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp index 6d0732a80..605a1bce7 100644 --- a/source/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp +++ b/source/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp @@ -86,6 +86,7 @@ void CompressibleCumulantLBMKernel::calculate() void CompressibleCumulantLBMKernel::collideAll() { using namespace D3Q27System; + using namespace std; //initializing of forcing stuff if (withForcing) diff --git a/source/VirtualFluidsCore/LBM/CompressibleCumulant2LBMKernel.cpp b/source/VirtualFluidsCore/LBM/CompressibleCumulantViscosity4thLBMKernel.cpp similarity index 97% rename from source/VirtualFluidsCore/LBM/CompressibleCumulant2LBMKernel.cpp rename to source/VirtualFluidsCore/LBM/CompressibleCumulantViscosity4thLBMKernel.cpp index 4ed4ccdcc..7e2406c94 100644 --- a/source/VirtualFluidsCore/LBM/CompressibleCumulant2LBMKernel.cpp +++ b/source/VirtualFluidsCore/LBM/CompressibleCumulantViscosity4thLBMKernel.cpp @@ -1,16 +1,15 @@ -#include "CompressibleCumulant2LBMKernel.h" +#include "CompressibleCumulantViscosity4thLBMKernel.h" #include "D3Q27System.h" #include "InterpolationProcessor.h" #include "D3Q27EsoTwist3DSplittedVector.h" #include <math.h> -#include <omp.h> #include "DataSet3D.h" #include "LBMKernel.h" #define PROOF_CORRECTNESS ////////////////////////////////////////////////////////////////////////// -CompressibleCumulant2LBMKernel::CompressibleCumulant2LBMKernel() +CompressibleCumulantViscosity4thLBMKernel::CompressibleCumulantViscosity4thLBMKernel() { this->nx1 = 0; this->nx2 = 0; @@ -22,7 +21,7 @@ CompressibleCumulant2LBMKernel::CompressibleCumulant2LBMKernel() this->OxxPyyPzz = 1.0; } ////////////////////////////////////////////////////////////////////////// -CompressibleCumulant2LBMKernel::CompressibleCumulant2LBMKernel(int nx1, int nx2, int nx3, Parameter p) +CompressibleCumulantViscosity4thLBMKernel::CompressibleCumulantViscosity4thLBMKernel(int nx1, int nx2, int nx3, Parameter p) { this->nx1 = nx1; this->nx2 = nx2; @@ -34,21 +33,21 @@ CompressibleCumulant2LBMKernel::CompressibleCumulant2LBMKernel(int nx1, int nx2, this->OxxPyyPzz = 1.0; } ////////////////////////////////////////////////////////////////////////// -CompressibleCumulant2LBMKernel::~CompressibleCumulant2LBMKernel(void) +CompressibleCumulantViscosity4thLBMKernel::~CompressibleCumulantViscosity4thLBMKernel(void) { } ////////////////////////////////////////////////////////////////////////// -void CompressibleCumulant2LBMKernel::init() +void CompressibleCumulantViscosity4thLBMKernel::init() { - SPtr<DistributionArray3D> d(new D3Q27EsoTwist3DSplittedVector(nx1+2, nx2+2, nx3+2, -999.0)); + SPtr<DistributionArray3D> d(new D3Q27EsoTwist3DSplittedVector(nx1+2, nx2+2, nx3+2, 0.0)); dataSet->setFdistributions(d); } ////////////////////////////////////////////////////////////////////////// -SPtr<LBMKernel> CompressibleCumulant2LBMKernel::clone() +SPtr<LBMKernel> CompressibleCumulantViscosity4thLBMKernel::clone() { - SPtr<LBMKernel> kernel(new CompressibleCumulant2LBMKernel(nx1, nx2, nx3, parameter)); - dynamicPointerCast<CompressibleCumulant2LBMKernel>(kernel)->init(); + SPtr<LBMKernel> kernel(new CompressibleCumulantViscosity4thLBMKernel(nx1, nx2, nx3, parameter)); + dynamicPointerCast<CompressibleCumulantViscosity4thLBMKernel>(kernel)->init(); kernel->setCollisionFactor(this->collFactor); kernel->setBCProcessor(bcProcessor->clone(kernel)); kernel->setWithForcing(withForcing); @@ -60,34 +59,35 @@ SPtr<LBMKernel> CompressibleCumulant2LBMKernel::clone() switch (parameter) { case NORMAL: - dynamicPointerCast<CompressibleCumulant2LBMKernel>(kernel)->OxyyMxzz = 1.0; + dynamicPointerCast<CompressibleCumulantViscosity4thLBMKernel>(kernel)->OxyyMxzz = 1.0; break; case MAGIC: - dynamicPointerCast<CompressibleCumulant2LBMKernel>(kernel)->OxyyMxzz = 2.0 +(-collFactor); + dynamicPointerCast<CompressibleCumulantViscosity4thLBMKernel>(kernel)->OxyyMxzz = 2.0 +(-collFactor); break; } if (bulkOmegaToOmega) { - dynamicPointerCast<CompressibleCumulant2LBMKernel>(kernel)->OxxPyyPzz = collFactor; + dynamicPointerCast<CompressibleCumulantViscosity4thLBMKernel>(kernel)->OxxPyyPzz = collFactor; } else { - dynamicPointerCast<CompressibleCumulant2LBMKernel>(kernel)->OxxPyyPzz = one; + dynamicPointerCast<CompressibleCumulantViscosity4thLBMKernel>(kernel)->OxxPyyPzz = one; } return kernel; } ////////////////////////////////////////////////////////////////////////// -void CompressibleCumulant2LBMKernel::calculate() +void CompressibleCumulantViscosity4thLBMKernel::calculate() { timer.resetAndStart(); collideAll(); timer.stop(); } ////////////////////////////////////////////////////////////////////////// -void CompressibleCumulant2LBMKernel::collideAll() +void CompressibleCumulantViscosity4thLBMKernel::collideAll() { using namespace D3Q27System; + using namespace std; //initializing of forcing stuff if (withForcing) @@ -1066,13 +1066,13 @@ void CompressibleCumulant2LBMKernel::collideAll() } } ////////////////////////////////////////////////////////////////////////// -double CompressibleCumulant2LBMKernel::getCalculationTime() +double CompressibleCumulantViscosity4thLBMKernel::getCalculationTime() { //return timer.getDuration(); return timer.getTotalTime(); } ////////////////////////////////////////////////////////////////////////// -void CompressibleCumulant2LBMKernel::setBulkOmegaToOmega(bool value) +void CompressibleCumulantViscosity4thLBMKernel::setBulkOmegaToOmega(bool value) { bulkOmegaToOmega = value; } diff --git a/source/VirtualFluidsCore/LBM/CompressibleCumulant2LBMKernel.h b/source/VirtualFluidsCore/LBM/CompressibleCumulantViscosity4thLBMKernel.h similarity index 86% rename from source/VirtualFluidsCore/LBM/CompressibleCumulant2LBMKernel.h rename to source/VirtualFluidsCore/LBM/CompressibleCumulantViscosity4thLBMKernel.h index 04c255af3..4eefd8c3b 100644 --- a/source/VirtualFluidsCore/LBM/CompressibleCumulant2LBMKernel.h +++ b/source/VirtualFluidsCore/LBM/CompressibleCumulantViscosity4thLBMKernel.h @@ -11,20 +11,20 @@ //! \brief compressible cumulant LBM kernel. //! \details CFD solver that use Cascaded Cumulant Lattice Boltzmann method for D3Q27 model //! \author K. Kutscher, M. Geier -class CompressibleCumulant2LBMKernel : public LBMKernel +class CompressibleCumulantViscosity4thLBMKernel : public LBMKernel { public: //! This option set relaxation parameter: NORMAL enum Parameter{NORMAL, MAGIC}; public: - CompressibleCumulant2LBMKernel(); + CompressibleCumulantViscosity4thLBMKernel(); //! Constructor //! \param nx1 number of nodes in x dimension //! \param nx2 number of nodes in y dimension //! \param nx3 number of nodes in z dimension //! \param p set relaxation parameter: NORMAL is OxyyMxzz = 1.0 and MAGIC is OxyyMxzz = 2.0 +(-collFactor) - CompressibleCumulant2LBMKernel(int nx1, int nx2, int nx3, Parameter p); - virtual ~CompressibleCumulant2LBMKernel(void); + CompressibleCumulantViscosity4thLBMKernel(int nx1, int nx2, int nx3, Parameter p); + virtual ~CompressibleCumulantViscosity4thLBMKernel(void); virtual void calculate(); virtual SPtr<LBMKernel> clone(); double getCalculationTime() override; diff --git a/source/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.cpp b/source/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.cpp index 9d7eeeb13..96b295477 100644 --- a/source/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.cpp +++ b/source/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.cpp @@ -74,6 +74,7 @@ void IncompressibleCumulantLBMKernel::calculate() void IncompressibleCumulantLBMKernel::collideAll() { using namespace D3Q27System; + using namespace std; //initializing of forcing stuff if (withForcing) diff --git a/source/VirtualFluidsCore/LBM/LBMKernel.h b/source/VirtualFluidsCore/LBM/LBMKernel.h index bee32d8a0..2152d7a23 100644 --- a/source/VirtualFluidsCore/LBM/LBMKernel.h +++ b/source/VirtualFluidsCore/LBM/LBMKernel.h @@ -94,7 +94,7 @@ protected: bool withSpongeLayer; mu::Parser muSpongeLayer; - std::weak_ptr<Block3D> block; + WPtr<Block3D> block; int nx1, nx2, nx3; diff --git a/source/VirtualFluidsCore/PointerDefinitions.h b/source/VirtualFluidsCore/PointerDefinitions.h index c95fcc9fd..f90359647 100644 --- a/source/VirtualFluidsCore/PointerDefinitions.h +++ b/source/VirtualFluidsCore/PointerDefinitions.h @@ -5,32 +5,54 @@ #ifndef SHARED_POINTER_H #define SHARED_POINTER_H -#include <memory> - -#define useStdSmartPointer - -#ifdef useStdSmartPointer - #define smartPointerNamespace std +//#define useStdSmartPointer + +//#ifdef useStdSmartPointer +//#ifndef VF_BOOST +// #include <memory> +// #define smartPointerNamespace std +//#else +// #include <boost/enable_shared_from_this.hpp> +// #include <boost/pointer_cast.hpp> +// #include <boost/shared_ptr.hpp> +// #define smartPointerNamespace boost +//#endif +// +// +//template <class T> +//using SPtr = smartPointerNamespace::shared_ptr<T>; +// +//template <class T> +//using WPtr = smartPointerNamespace::weak_ptr<T>; +// +////template <class T> +////using UPtr = smartPointerNamespace::unique_ptr<T>; +// +//template <class T> +//using enableSharedFromThis = smartPointerNamespace::enable_shared_from_this<T>; +// +//#define dynamicPointerCast smartPointerNamespace::dynamic_pointer_cast +// +//template <class T> +//using RPtr = T*; +// +//#endif +#ifndef VF_BOOST + #include <memory> + #define smartPointerNamespace std #else - #define smartPointerNamespace boost + #include <boost/enable_shared_from_this.hpp> + #include <boost/pointer_cast.hpp> + #include <boost/shared_ptr.hpp> + #define smartPointerNamespace boost #endif +#define SPtr smartPointerNamespace::shared_ptr -template <class T> -using SPtr = smartPointerNamespace::shared_ptr<T>; - -template <class T> -using WPtr = smartPointerNamespace::weak_ptr<T>; +#define WPtr smartPointerNamespace::weak_ptr -template <class T> -using UPtr = smartPointerNamespace::unique_ptr<T>; - -template <class T> -using enableSharedFromThis = smartPointerNamespace::enable_shared_from_this<T>; +#define enableSharedFromThis smartPointerNamespace::enable_shared_from_this #define dynamicPointerCast smartPointerNamespace::dynamic_pointer_cast -template <class T> -using RPtr = T*; - -#endif +#endif \ No newline at end of file diff --git a/source/VirtualFluidsCore/Utilities/ConfigurationFile.hpp b/source/VirtualFluidsCore/Utilities/ConfigurationFile.hpp index d0b18c7b4..32492e04c 100644 --- a/source/VirtualFluidsCore/Utilities/ConfigurationFile.hpp +++ b/source/VirtualFluidsCore/Utilities/ConfigurationFile.hpp @@ -2,6 +2,7 @@ #define Configuration_h__ #include <map> +#include <vector> #include <sstream> #include <string> #include <fstream> @@ -65,6 +66,8 @@ private: template<class T> T fromString(const std::string& str) const; + + std::vector<std::string> split(const std::string &s, char delim) const; }; @@ -175,7 +178,7 @@ std::vector<T> ConfigurationFile::getVector(const std::string& key) const return v; } ////////////////////////////////////////////////////////////////////////// -std::vector<std::string> split(const std::string &s, char delim) +std::vector<std::string> ConfigurationFile::split(const std::string &s, char delim) const { std::vector<std::string> result; std::stringstream ss(s); -- GitLab