diff --git a/apps/cpu/HerschelBulkleySphere/hbsphere.cpp b/apps/cpu/HerschelBulkleySphere/hbsphere.cpp index f4b50325da703381b9c09b36c18741f7f1c04cc5..38affd7e570c78efe738e70c6a25a9a98ff3af65 100644 --- a/apps/cpu/HerschelBulkleySphere/hbsphere.cpp +++ b/apps/cpu/HerschelBulkleySphere/hbsphere.cpp @@ -159,10 +159,14 @@ void bflow(string configname) GbSystem3D::writeGeoObject(sphere.get(), outputPath + "/geo/sphere", WbWriterVtkXmlBinary::getInstance()); SPtr<D3Q27Interactor> sphereInt(new D3Q27Interactor(sphere, grid, noSlipBCAdapter, Interactor3D::SOLID)); + //////////////////////////////////////////// + //METIS + SPtr<Grid3DVisitor> metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::KWAY)); + //////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// //restart SPtr<UbScheduler> mSch(new UbScheduler(cpStep, cpStart)); - SPtr<MPIIOMigrationCoProcessor> restartCoProcessor(new MPIIOMigrationCoProcessor(grid, mSch, outputPath, comm)); + SPtr<MPIIOMigrationCoProcessor> restartCoProcessor(new MPIIOMigrationCoProcessor(grid, mSch, metisVisitor, outputPath, comm)); restartCoProcessor->setLBMKernel(kernel); restartCoProcessor->setBCProcessor(bcProc); //restartCoProcessor->setNu(k); diff --git a/apps/cpu/LaminarTubeFlow/ltf.cfg b/apps/cpu/LaminarTubeFlow/ltf.cfg index 1682ec7dce9d632110ca06089693791570e7e04f..7ee23c7df4950b3476b976560fb63d5ce0f8dd35 100644 --- a/apps/cpu/LaminarTubeFlow/ltf.cfg +++ b/apps/cpu/LaminarTubeFlow/ltf.cfg @@ -16,11 +16,11 @@ Re = 10 logToFile = false -newStart = true -restartStep = 100000 +newStart = false +restartStep = 10 -cpStart = 100000 -cpStep = 100000 +cpStart = 10 +cpStep = 10 outTime = 10 endTime = 10 \ No newline at end of file diff --git a/apps/cpu/LaminarTubeFlow/ltf.cpp b/apps/cpu/LaminarTubeFlow/ltf.cpp index 9f4bf28d9dd0eba17ff55337b97d6b54534094b6..82f6c00630f06e00eb0084e818e9145b00560207 100644 --- a/apps/cpu/LaminarTubeFlow/ltf.cpp +++ b/apps/cpu/LaminarTubeFlow/ltf.cpp @@ -106,11 +106,16 @@ void run(string configname) kernel->setBCProcessor(bcProc); ////////////////////////////////////////////////////////////////////////// + SPtr<Grid3DVisitor> metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::B)); //restart SPtr<UbScheduler> mSch(new UbScheduler(cpStep, cpStart)); - SPtr<MPIIOMigrationCoProcessor> migCoProcessor(new MPIIOMigrationCoProcessor(grid, mSch, pathname + "/mig", comm)); + //SPtr<MPIIOMigrationCoProcessor> migCoProcessor(new MPIIOMigrationCoProcessor(grid, mSch, metisVisitor, pathname + "/mig", comm)); + SPtr<MPIIOMigrationBECoProcessor> migCoProcessor(new MPIIOMigrationBECoProcessor(grid, mSch, metisVisitor, pathname + "/mig", comm)); migCoProcessor->setLBMKernel(kernel); migCoProcessor->setBCProcessor(bcProc); + migCoProcessor->setNu(nuLB); + migCoProcessor->setNuLG(0.01, 0.01); + migCoProcessor->setDensityRatio(1); ////////////////////////////////////////////////////////////////////////// SPtr<D3Q27Interactor> inflowInt; @@ -213,7 +218,7 @@ void run(string configname) //outflow SPtr<D3Q27Interactor> outflowInt = SPtr<D3Q27Interactor>(new D3Q27Interactor(geoOutflow, grid, denBCAdapter, Interactor3D::SOLID)); - SPtr<Grid3DVisitor> metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::B)); + //SPtr<Grid3DVisitor> metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::B)); InteractorsHelper intHelper(grid, metisVisitor); intHelper.addInteractor(cylinderInt); intHelper.addInteractor(inflowInt); diff --git a/apps/cpu/Multiphase/Multiphase.cpp b/apps/cpu/Multiphase/Multiphase.cpp index deb2845f4278661bb970ea68b043e3cb435bffcc..964ae20fd6c83099600efa88d19eeb8a4a86bed3 100644 --- a/apps/cpu/Multiphase/Multiphase.cpp +++ b/apps/cpu/Multiphase/Multiphase.cpp @@ -10,7 +10,7 @@ void run(string configname) { try { - //Sleep(20000); + //Sleep(30000); ConfigurationFile config; config.load(configname); @@ -29,7 +29,7 @@ void run(string configname) double densityRatio = config.getValue<double>("densityRatio"); double sigma = config.getValue<double>("sigma"); int interfaceThickness = config.getValue<int>("interfaceThickness"); - double radius = config.getValue<double>("radius"); + //double radius = config.getValue<double>("radius"); double theta = config.getValue<double>("contactAngle"); double gr = config.getValue<double>("gravity"); double phiL = config.getValue<double>("phi_L"); @@ -85,9 +85,11 @@ void run(string configname) SPtr<LBMKernel> kernel; - kernel = SPtr<LBMKernel>(new MultiphaseScratchCumulantLBMKernel()); + //kernel = SPtr<LBMKernel>(new MultiphaseScratchCumulantLBMKernel()); //kernel = SPtr<LBMKernel>(new MultiphaseCumulantLBMKernel()); //kernel = SPtr<LBMKernel>(new MultiphaseTwoPhaseFieldsCumulantLBMKernel()); + //kernel = SPtr<LBMKernel>(new MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel()); + kernel = SPtr<LBMKernel>(new MultiphaseTwoPhaseFieldsPressureFilterLBMKernel()); kernel->setWithForcing(true); kernel->setForcingX1(0.0); @@ -99,6 +101,13 @@ void run(string configname) kernel->setPhaseFieldRelaxation(tauH); kernel->setMobility(mob); + //nuL, nuG, densityRatio, beta, kappa, theta, + + kernel->setCollisionFactorMultiphase(nuL, nuG); + kernel->setDensityRatio(densityRatio); + kernel->setMultiphaseModelParameters(beta, kappa); + kernel->setContactAngle(theta); + SPtr<BCProcessor> bcProc(new BCProcessor()); // BCProcessorPtr bcProc(new ThinWallBCProcessor()); @@ -108,20 +117,26 @@ void run(string configname) // grid->setPeriodicX1(true); // grid->setPeriodicX2(true); // grid->setPeriodicX3(true); + grid->setGhostLayerWidth(2); + + + SPtr<Grid3DVisitor> metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::RECURSIVE)); + ////////////////////////////////////////////////////////////////////////// // restart SPtr<UbScheduler> rSch(new UbScheduler(cpStep, cpStart)); //SPtr<MPIIORestartCoProcessor> rcp(new MPIIORestartCoProcessor(grid, rSch, pathname, comm)); - //SPtr<MPIIOMigrationCoProcessor> rcp(new MPIIOMigrationCoProcessor(grid, rSch, pathname, comm)); - SPtr<MPIIOMigrationBECoProcessor> rcp(new MPIIOMigrationBECoProcessor(grid, rSch, pathname, comm)); - rcp->setNu(nuLB); - rcp->setNuLG(nuL, nuG); - rcp->setDensityRatio(densityRatio); + SPtr<MPIIOMigrationCoProcessor> rcp(new MPIIOMigrationCoProcessor(grid, rSch, metisVisitor, pathname, comm)); + //SPtr<MPIIOMigrationBECoProcessor> rcp(new MPIIOMigrationBECoProcessor(grid, rSch, pathname, comm)); + //rcp->setNu(nuLB); + //rcp->setNuLG(nuL, nuG); + //rcp->setDensityRatio(densityRatio); rcp->setLBMKernel(kernel); rcp->setBCProcessor(bcProc); ////////////////////////////////////////////////////////////////////////// - + // BC Adapter + ////////////////////////////////////////////////////////////////////////////// mu::Parser fctF1; // fctF1.SetExpr("vy1*(1-((x1-x0)^2+(x3-z0)^2)/(R^2))"); // fctF1.SetExpr("vy1*(1-(sqrt((x1-x0)^2+(x3-z0)^2)/R))^0.1"); @@ -137,10 +152,36 @@ void run(string configname) fctF2.SetExpr("vy1"); fctF2.DefineConst("vy1", uLB); - double startTime = 500; + double startTime = 30; SPtr<BCAdapter> velBCAdapterF1(new MultiphaseVelocityBCAdapter(true, false, false, fctF1, phiH, 0.0, startTime)); SPtr<BCAdapter> velBCAdapterF2(new MultiphaseVelocityBCAdapter(true, false, false, fctF2, phiH, startTime, endTime)); + SPtr<BCAdapter> noSlipBCAdapter(new NoSlipBCAdapter()); + noSlipBCAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new MultiphaseNoSlipBCAlgorithm())); + + SPtr<BCAdapter> denBCAdapter(new DensityBCAdapter(rhoLB)); + denBCAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new MultiphaseNonReflectingOutflowBCAlgorithm())); + + mu::Parser fctPhi_F1; + fctPhi_F1.SetExpr("phiH"); + fctPhi_F1.DefineConst("phiH", phiH); + + mu::Parser fctPhi_F2; + fctPhi_F2.SetExpr("phiL"); + fctPhi_F2.DefineConst("phiL", phiL); + + mu::Parser fctvel_F2_init; + fctvel_F2_init.SetExpr("U"); + fctvel_F2_init.DefineConst("U", 0); + + velBCAdapterF1->setBcAlgorithm(SPtr<BCAlgorithm>(new MultiphaseVelocityBCAlgorithm())); + ////////////////////////////////////////////////////////////////////////////////// + // BC visitor + MultiphaseBoundaryConditionsBlockVisitor bcVisitor; + bcVisitor.addBC(noSlipBCAdapter); + bcVisitor.addBC(denBCAdapter); //Ohne das BB? + bcVisitor.addBC(velBCAdapterF1); + SPtr<D3Q27Interactor> inflowF1Int; SPtr<D3Q27Interactor> cylInt; if (newStart) { @@ -220,34 +261,6 @@ void run(string configname) GenBlocksGridVisitor genBlocks(gridCube); grid->accept(genBlocks); - // BC Adapter - ////////////////////////////////////////////////////////////////////////////// - SPtr<BCAdapter> noSlipBCAdapter(new NoSlipBCAdapter()); - noSlipBCAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new MultiphaseNoSlipBCAlgorithm())); - - SPtr<BCAdapter> denBCAdapter(new DensityBCAdapter(rhoLB)); - denBCAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new MultiphaseNonReflectingOutflowBCAlgorithm())); - - mu::Parser fctPhi_F1; - fctPhi_F1.SetExpr("phiH"); - fctPhi_F1.DefineConst("phiH", phiH); - - mu::Parser fctPhi_F2; - fctPhi_F2.SetExpr("phiL"); - fctPhi_F2.DefineConst("phiL", phiL); - - mu::Parser fctvel_F2_init; - fctvel_F2_init.SetExpr("U"); - fctvel_F2_init.DefineConst("U", 0); - - velBCAdapterF1->setBcAlgorithm(SPtr<BCAlgorithm>(new MultiphaseVelocityBCAlgorithm())); - ////////////////////////////////////////////////////////////////////////////////// - // BC visitor - MultiphaseBoundaryConditionsBlockVisitor bcVisitor; - bcVisitor.addBC(noSlipBCAdapter); - bcVisitor.addBC(denBCAdapter); //Ohne das BB? - bcVisitor.addBC(velBCAdapterF1); - SPtr<WriteBlocksCoProcessor> ppblocks(new WriteBlocksCoProcessor( grid, SPtr<UbScheduler>(new UbScheduler(1)), pathname, WbWriterVtkXmlBinary::getInstance(), comm)); @@ -286,8 +299,7 @@ void run(string configname) cylInt->addBCAdapter(velBCAdapterF2); //SPtr<D3Q27Interactor> cyl2Int(new D3Q27Interactor(cylinder2, grid, noSlipBCAdapter, Interactor3D::SOLID)); - SPtr<Grid3DVisitor> metisVisitor( - new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW)); + InteractorsHelper intHelper(grid, metisVisitor, true); intHelper.addInteractor(cylInt); intHelper.addInteractor(tubes); @@ -347,13 +359,11 @@ void run(string configname) intHelper.setBC(); - grid->accept(bcVisitor); - // initialization of distributions mu::Parser fct1; fct1.SetExpr("phiL"); fct1.DefineConst("phiL", phiL); - MultiphaseInitDistributionsBlockVisitor initVisitor(densityRatio, interfaceThickness, radius); + MultiphaseInitDistributionsBlockVisitor initVisitor(interfaceThickness); initVisitor.setPhi(fct1); grid->accept(initVisitor); @@ -388,11 +398,15 @@ void run(string configname) UBLOG(logINFO, "Restart - end"); } - TwoDistributionsSetConnectorsBlockVisitor setConnsVisitor(comm); - grid->accept(setConnsVisitor); + // TwoDistributionsSetConnectorsBlockVisitor setConnsVisitor(comm); + // grid->accept(setConnsVisitor); + + //ThreeDistributionsSetConnectorsBlockVisitor setConnsVisitor(comm); - //ThreeDistributionsSetConnectorsBlockVisitor setConnsVisitor(comm); - //grid->accept(setConnsVisitor); + grid->accept(bcVisitor); + + ThreeDistributionsDoubleGhostLayerSetConnectorsBlockVisitor setConnsVisitor(comm); + grid->accept(setConnsVisitor); SPtr<UbScheduler> visSch(new UbScheduler(outTime)); SPtr<WriteMultiphaseQuantitiesCoProcessor> pp(new WriteMultiphaseQuantitiesCoProcessor( diff --git a/apps/cpu/Multiphase/MultiphaseGeier.cfg b/apps/cpu/Multiphase/MultiphaseGeier.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d701725832cfd7337d383e9c98a60243c0c9b54e --- /dev/null +++ b/apps/cpu/Multiphase/MultiphaseGeier.cfg @@ -0,0 +1,68 @@ +#pathname = E:/Multiphase/HesamCodeWithCumulantsDensRatio +#pathname = E:/Multiphase/HesamCodeWithCumulantsQuartic +#pathname = E:/Multiphase/HesamCode +pathname = E:/Multiphase/VelocityFormSig1e-3SVarDens +pathGeo = C:/Users/geier/Documents/VirtualFluids_dev_Kostya/apps/cpu/Multiphase/backup +geoFile=tubeTransformed.stl +#geoFile = JetBreakup2.ASCII.stl +numOfThreads = 4 +availMem = 10e9 + +#Grid + +#boundingBox = -1.0 121.0 0.5 629.0 -1.0 121.0 #(Jet Breakup) (Original with inlet length) +#boundingBox = -60.5 60.5 -1.0 -201.0 -60.5 60.5 #(Jet Breakup2) (Original without inlet length) +#blocknx = 22 20 22 + +#boundingBox = -60.5 60.5 -1.0 -21.0 -60.5 60.5 #(Jet Breakup2) (Original without inlet length) +#boundingBox = -60.5 60.5 -21.0 -1.0 -60.5 60.5 #(Jet Breakup2) (Original without inlet length) +#blocknx = 22 20 22 + + +#dx = 0.5 + +#boundingBox = 6.0e-3 46.0e-3 -5e-3 5e-3 -5e-3 5e-3 +#boundingBox = 6.0e-3 86.0e-3 -5e-3 5e-3 -5e-3 5e-3 +#blocknx = 480 60 60 #20 20 20 + +boundingBox = 6.0e-3 16.0e-3 -5e-3 5e-3 -5e-3 5e-3 +blocknx = 20 20 20 + +#boundingBox = 6.0e-3 16.0e-3 -5e-3 5e-3 -5e-3 5e-3 +#blocknx = 60 60 60 #20 20 20 + + +dx = 1.66666666667e-4 + +refineLevel = 0 + +#Simulation +uLB =0.005# 0.0000005 #inlet velocity +#uLB=0.001 +uF2 = 0.0001 +Re = 10 +nuL =1e-3#1e-2# 1.0e-5 #!1e-2 +nuG =1e-6#1e-2# 1.16e-4 #!1e-2 +densityRatio = 1000#1000#1000 #30 +sigma =1e-3# 1e-4 #4.66e-3 #surface tension 1e-4 ./. 1e-5 +interfaceThickness = 5 +radius = 615.0 (Jet Breakup) +contactAngle = 110.0 +gravity = 0.0 +#gravity = -5.04e-6 +phi_L = 0.0 +phi_H = 1.0 +Phase-field Relaxation = 0.6 +Mobility = 0.1 #0.02 # 0.01 ./. 0.08, fine correction of Phase-field Relaxation parameter, to activate it need to change in kernel tauH to tauH1 + + +logToFile = false + +newStart = true +restartStep = 100000 + +cpStart = 100000 +cpStep = 100000 + +outTime = 100 +endTime = 200000000 \ No newline at end of file diff --git a/apps/cpu/MultiphaseDropletTest/DropletTest.cfg b/apps/cpu/MultiphaseDropletTest/DropletTest.cfg index 72c0144890c2fd8ba25fa0dfb7528fdbd1b889d8..174066574a3a105b3735cf3c36181326cce7d1b0 100644 --- a/apps/cpu/MultiphaseDropletTest/DropletTest.cfg +++ b/apps/cpu/MultiphaseDropletTest/DropletTest.cfg @@ -1,32 +1,33 @@ -pathname = d:/temp/MultiphaseDropletTest +#pathname = d:/temp/MultiphaseDropletTest +pathname = E:/Multiphase/DropletTestImpVel-Hesam2 numOfThreads = 4 availMem = 10e9 #Grid -boundingBox = 0 128 0 64 0 64 -blocknx = 8 8 8 +boundingBox = 0 256 512 768 0 3 +blocknx = 16 16 3 dx = 1 refineLevel = 0 #Simulation -uLB = 0.005 +uLB = 0.01#0.005#0.005 Re = 10 -nuL =1e-2# 1.0e-5 #!1e-2 -nuG =1e-2# 1.16e-4 #!1e-2 -densityRatio = 1000 -sigma = 1e-5 #4.66e-3 #surface tension 1e-4 ./. 1e-5 -interfaceThickness = 5 -radius = 16 +nuL = 1e-2 #1e-5# 1.0e-5 #!1e-2 +nuG = 0.015811388300841892 #5e-2 #1e-4 # 1e-8 # 1.16e-4 #!1e-2 +densityRatio = 10 +sigma = 1.0850694444444444e-06 #1e-10 #1e-6 # 1e-5 #4.66e-3 #surface tension 1e-4 ./. 1e-5 +interfaceThickness = 4.096 +radius = 25.6 contactAngle = 110.0 #gravity = 0.0 -gravity = -5.04e-6 +gravity = -1.0348028606838648e-08 #-5.04e-6 phi_L = 0.0 phi_H = 1.0 Phase-field Relaxation = 0.6 -Mobility = 0.02 # 0.01 ./. 0.08, fine correction of Phase-field Relaxation parameter, to activate it need to change in kernel tauH to tauH1 +Mobility = 0.056 # 0.01 ./. 0.08, fine correction of Phase-field Relaxation parameter, to activate it need to change in kernel tauH to tauH1 logToFile = false @@ -34,8 +35,10 @@ logToFile = false newStart = true restartStep = 100000 -cpStart = 100000 -cpStep = 100000 +cpStart = 1000 +cpStep = 1000 -outTime = 1 -endTime = 10000 \ No newline at end of file +outTime = 100 +endTime = 10000 + +rStep = 159990 #160000 \ No newline at end of file diff --git a/apps/cpu/MultiphaseDropletTest/droplet.cpp b/apps/cpu/MultiphaseDropletTest/droplet.cpp index 092d5a16a36b47c726f0f85463484f0c97fdecd0..2695446006d6c6cd1be439b6ffb3d7347a18ebd6 100644 --- a/apps/cpu/MultiphaseDropletTest/droplet.cpp +++ b/apps/cpu/MultiphaseDropletTest/droplet.cpp @@ -2,6 +2,11 @@ #include <string> #include <memory> +#if defined(__unix__) +#include <stdio.h> +#include <stdlib.h> +#endif + #include "VirtualFluids.h" using namespace std; @@ -24,7 +29,7 @@ void run(string configname) int interfaceThickness = config.getValue<int>("interfaceThickness"); double radius = config.getValue<double>("radius"); double theta = config.getValue<double>("contactAngle"); - double gr = config.getValue<double>("gravity"); + //double gr = config.getValue<double>("gravity"); double phiL = config.getValue<double>("phi_L"); double phiH = config.getValue<double>("phi_H"); double tauH = config.getValue<double>("Phase-field Relaxation"); @@ -37,13 +42,11 @@ void run(string configname) double Re = config.getValue<double>("Re"); double dx = config.getValue<double>("dx"); bool logToFile = config.getValue<bool>("logToFile"); - //double restartStep = config.getValue<double>("restartStep"); - //double cpStart = config.getValue<double>("cpStart"); - //double cpStep = config.getValue<double>("cpStep"); + double restartStep = config.getValue<double>("restartStep"); + double cpStart = config.getValue<double>("cpStart"); + double cpStep = config.getValue<double>("cpStep"); bool newStart = config.getValue<bool>("newStart"); - - double beta = 12 * sigma / interfaceThickness; - double kappa = 1.5 * interfaceThickness * sigma; + double rStep = config.getValue<double>("rStep"); SPtr<Communicator> comm = MPICommunicator::getInstance(); int myid = comm->getProcessID(); @@ -65,6 +68,22 @@ void run(string configname) UbLog::output_policy::setStream(logFilename.str()); } } + + std::string fileName = "./LastTimeStep" + std::to_string((int)boundingBox[1]) + ".txt"; + +#if defined(__unix__) + double lastTimeStep = 0; + if (!newStart) + { + std::ifstream ifstr(fileName); + ifstr >> lastTimeStep; + restartStep = lastTimeStep; + if(endTime >= lastTimeStep) + endTime = lastTimeStep + rStep; + else + return; + } +#endif //Sleep(30000); @@ -72,6 +91,49 @@ void run(string configname) LBMReal rhoLB = 0.0; LBMReal nuLB = nuL; //(uLB*dLB) / Re; + //diameter of circular droplet + LBMReal D = 2.0*radius; + + //density retio + LBMReal r_rho = densityRatio; + + //density of heavy fluid + LBMReal rho_h = 1.0; + //density of light fluid + LBMReal rho_l = rho_h / r_rho; + + //kinimatic viscosity + LBMReal nu_h = nuL; + //LBMReal nu_l = nuG; + //#dynamic viscosity + LBMReal mu_h = rho_h * nu_h; + + //gravity + LBMReal g_y = Re*Re*mu_h*mu_h/(rho_h*(rho_h-rho_l)*D*D*D); + //Eotvos number + LBMReal Eo = 100; + //surface tension + sigma = rho_h*g_y*D*D/Eo; + + //g_y = 0; + + double beta = 12.0 * sigma / interfaceThickness; + double kappa = 1.5 * interfaceThickness * sigma; + + if (myid == 0) { + //UBLOG(logINFO, "uLb = " << uLB); + //UBLOG(logINFO, "rho = " << rhoLB); + UBLOG(logINFO, "D = " << D); + UBLOG(logINFO, "nuL = " << nuL); + UBLOG(logINFO, "nuL = " << nuG); + UBLOG(logINFO, "Re = " << Re); + UBLOG(logINFO, "Eo = " << Eo); + UBLOG(logINFO, "g_y = " << g_y); + UBLOG(logINFO, "sigma = " << sigma); + UBLOG(logINFO, "dx = " << dx); + UBLOG(logINFO, "Preprocess - start"); + } + SPtr<LBMUnitConverter> conv(new LBMUnitConverter()); //const int baseLevel = 0; @@ -80,42 +142,64 @@ void run(string configname) //kernel = SPtr<LBMKernel>(new MultiphaseScratchCumulantLBMKernel()); kernel = SPtr<LBMKernel>(new MultiphaseCumulantLBMKernel()); - //kernel = SPtr<LBMKernel>(new MultiphaseTwoPhaseFieldsCumulantLBMKernel()); + //kernel = SPtr<LBMKernel>(new MultiphaseTwoPhaseFieldsPressureFilterLBMKernel()); - kernel->setWithForcing(true); - kernel->setForcingX1(gr); - kernel->setForcingX2(0.0); - kernel->setForcingX3(0.0); + //mu::Parser fgr; + //fgr.SetExpr("-(rho-rho_l)*g_y"); + //fgr.DefineConst("rho_l", rho_l); + //fgr.DefineConst("g_y", g_y); + + //kernel->setWithForcing(true); + //kernel->setForcingX1(0.0); + //kernel->setForcingX2(fgr); + //kernel->setForcingX3(0.0); kernel->setPhiL(phiL); kernel->setPhiH(phiH); kernel->setPhaseFieldRelaxation(tauH); kernel->setMobility(mob); + kernel->setInterfaceWidth(interfaceThickness); + + + kernel->setCollisionFactorMultiphase(nuL, nuG); + kernel->setDensityRatio(densityRatio); + kernel->setMultiphaseModelParameters(beta, kappa); + kernel->setContactAngle(theta); SPtr<BCProcessor> bcProc(new BCProcessor()); // BCProcessorPtr bcProc(new ThinWallBCProcessor()); kernel->setBCProcessor(bcProc); + SPtr<BCAdapter> noSlipBCAdapter(new NoSlipBCAdapter()); + noSlipBCAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new MultiphaseNoSlipBCAlgorithm())); + ////////////////////////////////////////////////////////////////////////////////// + // BC visitor + MultiphaseBoundaryConditionsBlockVisitor bcVisitor; + bcVisitor.addBC(noSlipBCAdapter); + SPtr<Grid3D> grid(new Grid3D(comm)); grid->setDeltaX(dx); grid->setBlockNX(blocknx[0], blocknx[1], blocknx[2]); grid->setPeriodicX1(true); grid->setPeriodicX2(true); grid->setPeriodicX3(true); + grid->setGhostLayerWidth(1); + + SPtr<Grid3DVisitor> metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::RECURSIVE)); ////////////////////////////////////////////////////////////////////////// // restart - //SPtr<UbScheduler> rSch(new UbScheduler(cpStep, cpStart)); - ////SPtr<MPIIORestartCoProcessor> rcp(new MPIIORestartCoProcessor(grid, rSch, pathname, comm)); - ////SPtr<MPIIOMigrationCoProcessor> rcp(new MPIIOMigrationCoProcessor(grid, rSch, pathname, comm)); + SPtr<UbScheduler> rSch(new UbScheduler(cpStep, cpStart)); + //SPtr<MPIIORestartCoProcessor> rcp(new MPIIORestartCoProcessor(grid, rSch, pathname, comm)); + SPtr<MPIIOMigrationCoProcessor> rcp(new MPIIOMigrationCoProcessor(grid, rSch, metisVisitor, pathname, comm)); //SPtr<MPIIOMigrationBECoProcessor> rcp(new MPIIOMigrationBECoProcessor(grid, rSch, pathname, comm)); - //rcp->setNu(nuLB); - //rcp->setNuLG(nuL, nuG); - //rcp->setDensityRatio(densityRatio); + // rcp->setNu(nuLB); + // rcp->setNuLG(nuL, nuG); + // rcp->setDensityRatio(densityRatio); - //rcp->setLBMKernel(kernel); - //rcp->setBCProcessor(bcProc); + rcp->setLBMKernel(kernel); + rcp->setBCProcessor(bcProc); ////////////////////////////////////////////////////////////////////////// if (newStart) { @@ -135,32 +219,33 @@ void run(string configname) GbSystem3D::writeGeoObject(gridCube.get(), pathname + "/geo/gridCube", WbWriterVtkXmlBinary::getInstance()); - if (myid == 0) { - UBLOG(logINFO, "uLb = " << uLB); - UBLOG(logINFO, "rho = " << rhoLB); - UBLOG(logINFO, "nuLb = " << nuLB); - UBLOG(logINFO, "Re = " << Re); - UBLOG(logINFO, "dx = " << dx); - UBLOG(logINFO, "Preprocess - start"); - } + GenBlocksGridVisitor genBlocks(gridCube); grid->accept(genBlocks); + double dx2 = 2.0 * dx; + GbCuboid3DPtr wallYmin(new GbCuboid3D(g_minX1 - dx2, g_minX2 - dx2, g_minX3 - dx2, g_maxX1 + dx2, g_minX2, g_maxX3 + dx2)); + GbSystem3D::writeGeoObject(wallYmin.get(), pathname + "/geo/wallYmin", WbWriterVtkXmlASCII::getInstance()); + GbCuboid3DPtr wallYmax(new GbCuboid3D(g_minX1 - dx2, g_maxX2, g_minX3 - dx2, g_maxX1 + dx2, g_maxX2 + dx2, g_maxX3 + dx2)); + GbSystem3D::writeGeoObject(wallYmax.get(), pathname + "/geo/wallYmax", WbWriterVtkXmlASCII::getInstance()); + + SPtr<D3Q27Interactor> wallYminInt(new D3Q27Interactor(wallYmin, grid, noSlipBCAdapter, Interactor3D::SOLID)); + SPtr<D3Q27Interactor> wallYmaxInt(new D3Q27Interactor(wallYmax, grid, noSlipBCAdapter, Interactor3D::SOLID)); SPtr<WriteBlocksCoProcessor> ppblocks(new WriteBlocksCoProcessor( grid, SPtr<UbScheduler>(new UbScheduler(1)), pathname, WbWriterVtkXmlBinary::getInstance(), comm)); - //SPtr<Grid3DVisitor> metisVisitor( - // new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW)); - //InteractorsHelper intHelper(grid, metisVisitor); - //intHelper.selectBlocks(); + InteractorsHelper intHelper(grid, metisVisitor, true); + intHelper.addInteractor(wallYminInt); + intHelper.addInteractor(wallYmaxInt); + intHelper.selectBlocks(); ppblocks->process(0); ppblocks.reset(); unsigned long long numberOfBlocks = (unsigned long long)grid->getNumberOfBlocks(); - int ghostLayer = 3; + int ghostLayer = 5; 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; @@ -196,14 +281,13 @@ void run(string configname) } - //intHelper.setBC(); - - //grid->accept(bcVisitor); + intHelper.setBC(); // initialization of distributions - LBMReal x1c = (g_maxX1 - g_minX1-1)/2; - LBMReal x2c = (g_maxX2 - g_minX2-1)/2; - LBMReal x3c = (g_maxX3 - g_minX3-1)/2; + LBMReal x1c = 2.5 * D; // (g_maxX1 - g_minX1-1)/2; // + LBMReal x2c = 12.5 * D; //(g_maxX2 - g_minX2-1)/2; + LBMReal x3c = 1.5; //2.5 * D; //(g_maxX3 - g_minX3-1)/2; + //LBMReal x3c = 2.5 * D; mu::Parser fct1; fct1.SetExpr("0.5-0.5*tanh(2*(sqrt((x1-x1c)^2+(x2-x2c)^2+(x3-x3c)^2)-radius)/interfaceThickness)"); fct1.DefineConst("x1c", x1c); @@ -221,7 +305,8 @@ void run(string configname) fct2.DefineConst("radius", radius); fct2.DefineConst("interfaceThickness", interfaceThickness); - MultiphaseInitDistributionsBlockVisitor initVisitor(densityRatio, interfaceThickness, radius); + MultiphaseInitDistributionsBlockVisitor initVisitor(densityRatio); + //MultiphaseVelocityFormInitDistributionsBlockVisitor initVisitor; initVisitor.setPhi(fct1); initVisitor.setVx1(fct2); grid->accept(initVisitor); @@ -250,33 +335,37 @@ void run(string configname) UBLOG(logINFO, "path = " << pathname); } - //rcp->restart((int)restartStep); - //grid->setTimeStep(restartStep); + rcp->restart((int)restartStep); + grid->setTimeStep(restartStep); if (myid == 0) UBLOG(logINFO, "Restart - end"); } + grid->accept(bcVisitor); + TwoDistributionsSetConnectorsBlockVisitor setConnsVisitor(comm); grid->accept(setConnsVisitor); - //ThreeDistributionsSetConnectorsBlockVisitor setConnsVisitor(comm); + //ThreeDistributionsDoubleGhostLayerSetConnectorsBlockVisitor setConnsVisitor(comm); //grid->accept(setConnsVisitor); SPtr<UbScheduler> visSch(new UbScheduler(outTime)); SPtr<WriteMultiphaseQuantitiesCoProcessor> pp(new WriteMultiphaseQuantitiesCoProcessor( grid, visSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, comm)); - //SPtr<WriteMacroscopicQuantitiesCoProcessor> pp(new WriteMacroscopicQuantitiesCoProcessor( - // grid, visSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, comm)); + if(grid->getTimeStep() == 0) + pp->process(0); SPtr<UbScheduler> nupsSch(new UbScheduler(10, 30, 100)); SPtr<NUPSCounterCoProcessor> npr(new NUPSCounterCoProcessor(grid, nupsSch, numOfThreads, comm)); + omp_set_num_threads(numOfThreads); + SPtr<UbScheduler> stepGhostLayer(new UbScheduler(1)); SPtr<Calculator> calculator(new BasicCalculator(grid, stepGhostLayer, endTime)); calculator->addCoProcessor(npr); calculator->addCoProcessor(pp); - //calculator->addCoProcessor(rcp); + calculator->addCoProcessor(rcp); @@ -285,6 +374,25 @@ void run(string configname) calculator->calculate(); if (myid == 0) UBLOG(logINFO, "Simulation-end"); + +#if defined(__unix__) + if (!newStart) + { + if (myid == 0) + { + std::ofstream ostr(fileName); + ostr << endTime; + cout << "start sbatch\n"; + //system("./start.sh"); + //system("echo test!"); + std::string str = "sbatch startJob" + std::to_string((int)boundingBox[1]) + ".sh"; + //system("sbatch startJob512.sh"); + system(str.c_str()); + } + //MPI_Barrier((MPI_Comm)comm->getNativeCommunicator()); + } +#endif + } catch (std::exception &e) { cerr << e.what() << endl << flush; } catch (std::string &s) { diff --git a/apps/cpu/PoiseuilleFlow/pf1.cpp b/apps/cpu/PoiseuilleFlow/pf1.cpp index 3880e9583dd07bdad7fcd11272f0a372155ef654..f565aad1cdd83ad4d827068d10b55caf17f2b440 100644 --- a/apps/cpu/PoiseuilleFlow/pf1.cpp +++ b/apps/cpu/PoiseuilleFlow/pf1.cpp @@ -169,7 +169,7 @@ void pf1() //grid=SPtr<Grid3D>(new Grid3D(comm)); //restartCoProcessor->restart(200); - SPtr<MPIIOMigrationBECoProcessor> migCoProcessor(new MPIIOMigrationBECoProcessor(grid, mSch, pathOut + "/mig", comm)); + SPtr<MPIIOMigrationBECoProcessor> migCoProcessor(new MPIIOMigrationBECoProcessor(grid, mSch, metisVisitor, pathOut + "/mig", comm)); migCoProcessor->setLBMKernel(kernel); migCoProcessor->setBCProcessor(bcProc); migCoProcessor->setNu(nuLB); diff --git a/apps/cpu/ViskomatXL/viskomat.cpp b/apps/cpu/ViskomatXL/viskomat.cpp index a5d5f60e1a806da4822402e4d6cd93ef7ee1168e..83a0219cc66a67e825ca429b670be108f2d70cec 100644 --- a/apps/cpu/ViskomatXL/viskomat.cpp +++ b/apps/cpu/ViskomatXL/viskomat.cpp @@ -174,10 +174,14 @@ void bflow(string configname) SPtr<GbObject3D> gridCube(new GbCuboid3D(g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3)); if (myid == 0) GbSystem3D::writeGeoObject(gridCube.get(), outputPath + "/geo/gridCube", WbWriterVtkXmlBinary::getInstance()); + //////////////////////////////////////////// + //METIS + SPtr<Grid3DVisitor> metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::RECURSIVE)); + //////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// //restart SPtr<UbScheduler> mSch(new UbScheduler(cpStep, cpStart)); - SPtr<MPIIOMigrationCoProcessor> restartCoProcessor(new MPIIOMigrationCoProcessor(grid, mSch, outputPath, comm)); + SPtr<MPIIOMigrationCoProcessor> restartCoProcessor(new MPIIOMigrationCoProcessor(grid, mSch, metisVisitor, outputPath, comm)); //SPtr<MPIIORestartCoProcessor> restartCoProcessor(new MPIIORestartCoProcessor(grid, mSch, outputPath, comm)); restartCoProcessor->setLBMKernel(kernel); restartCoProcessor->setBCProcessor(bcProc); @@ -280,10 +284,7 @@ void bflow(string configname) } - //////////////////////////////////////////// - //METIS - SPtr<Grid3DVisitor> metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::RECURSIVE)); - //////////////////////////////////////////// + /////delete solid blocks if (myid == 0) UBLOG(logINFO, "deleteSolidBlocks - start"); InteractorsHelper intHelper(grid, metisVisitor); diff --git a/apps/cpu/rheometer/rheometer.cpp b/apps/cpu/rheometer/rheometer.cpp index f6f98c122c3197f1a080fd335f8edfc9ee1f4e33..cf70525b8cc166b73a4dbf3af25e7aaf825bdcc8 100644 --- a/apps/cpu/rheometer/rheometer.cpp +++ b/apps/cpu/rheometer/rheometer.cpp @@ -221,10 +221,14 @@ void bflow(string configname) SPtr<GbObject3D> gridCube(new GbCuboid3D(g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3)); if (myid == 0) GbSystem3D::writeGeoObject(gridCube.get(), outputPath + "/geo/gridCube", WbWriterVtkXmlBinary::getInstance()); + //////////////////////////////////////////// + //METIS + SPtr<Grid3DVisitor> metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::KWAY)); + //////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// //restart SPtr<UbScheduler> mSch(new UbScheduler(cpStep, cpStart)); - SPtr<MPIIOMigrationCoProcessor> restartCoProcessor(new MPIIOMigrationCoProcessor(grid, mSch, outputPath, comm)); + SPtr<MPIIOMigrationCoProcessor> restartCoProcessor(new MPIIOMigrationCoProcessor(grid, mSch, metisVisitor, outputPath, comm)); restartCoProcessor->setLBMKernel(kernel); restartCoProcessor->setBCProcessor(bcProc); //restartCoProcessor->setNu(k); diff --git a/src/cpu/VirtualFluids.h b/src/cpu/VirtualFluids.h index 363c9c046b37a45d800ea142e79617f71a8499d3..7edd56779f580063c0b95cfc6d6ff452d7954883 100644 --- a/src/cpu/VirtualFluids.h +++ b/src/cpu/VirtualFluids.h @@ -154,6 +154,7 @@ #include <Connectors/TwoDistributionsFullDirectConnector.h> #include <Connectors/TwoDistributionsFullVectorConnector.h> + #include <Data/D3Q27EsoTwist3DSplittedVector.h> #include <Data/D3Q27EsoTwist3DSplittedVectorEx.h> #include <Data/DataSet3D.h> @@ -244,6 +245,8 @@ #include <LBM/MultiphaseCumulantLBMKernel.h> #include <LBM/MultiphaseScratchCumulantLBMKernel.h> #include <LBM/MultiphaseTwoPhaseFieldsCumulantLBMKernel.h> +#include <LBM/MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel.h> +#include <LBM/MultiphaseTwoPhaseFieldsPressureFilterLBMKernel.h> @@ -338,6 +341,7 @@ #include <Visitors/MultiphaseSetKernelBlockVisitor.h> #include <Visitors/MultiphaseBoundaryConditionsBlockVisitor.h> #include <Visitors/MultiphaseInitDistributionsBlockVisitor.h> +#include <Visitors/MultiphaseVelocityFormInitDistributionsBlockVisitor.h> #include <Visitors/SetInterpolationConnectorsBlockVisitor.h> #include <RefineAroundGbObjectHelper.h> diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.h index f59a899495c72a3f401b238de871e47a0282590b..555ef9852c0e386c4263bd6dc5d105d814583860 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.h +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.h @@ -280,30 +280,6 @@ public: void setBoundaryDensity(float density) { this->bcDensity = density; } float getBoundaryDensity() { return this->bcDensity; } - ////Lodi extension - void setDensityLodiDensity(const float &bcLodiDensity) { this->bcLodiDensity = bcLodiDensity; } - void setDensityLodiVelocityX1(const float &bcLodiVelocityX1) { this->bcLodiVelocityX1 = bcLodiVelocityX1; } - void setDensityLodiVelocityX2(const float &bcLodiVelocityX2) { this->bcLodiVelocityX2 = bcLodiVelocityX2; } - void setDensityLodiVelocityX3(const float &bcLodiVelocityX3) { this->bcLodiVelocityX3 = bcLodiVelocityX3; } - void setDensityLodiLength(const float &bcLodiLentgh) { this->bcLodiLentgh = bcLodiLentgh; } - float getDensityLodiDensity() const { return this->bcLodiDensity; } - float getDensityLodiVelocityX1() const { return this->bcLodiVelocityX1; } - float getDensityLodiVelocityX2() const { return this->bcLodiVelocityX2; } - float getDensityLodiVelocityX3() const { return this->bcLodiVelocityX3; } - float getDensityLodiLength() const { return this->bcLodiLentgh; } - - float &densityLodiDensity() { return this->bcLodiDensity; } - float &densityLodiVelocityX1() { return this->bcLodiVelocityX1; } - float &densityLodiVelocityX2() { return this->bcLodiVelocityX2; } - float &densityLodiVelocityX3() { return this->bcLodiVelocityX3; } - float &densityLodiLentgh() { return this->bcLodiLentgh; } - - const float &densityLodiDensity() const { return this->bcLodiDensity; } - const float &densityLodiVelocityX1() const { return this->bcLodiVelocityX1; } - const float &densityLodiVelocityX2() const { return this->bcLodiVelocityX2; } - const float &densityLodiVelocityX3() const { return this->bcLodiVelocityX3; } - const float &densityLodiLentgh() const { return this->bcLodiLentgh; } - /*======================= Qs =============================*/ void setQ(const float &val, const int &direction) { q[direction] = val; } float getQ(const int &direction) { return q[direction]; } @@ -354,13 +330,6 @@ protected: float bcDensity{ 0.0f }; float bcPhaseField{ 0.0f }; - //FIXME: remove LODI variables, don't forget to adjust MPIIOCoProcessors - float bcLodiDensity{ 0.0f }; - float bcLodiVelocityX1{ 0.0f }; - float bcLodiVelocityX2{ 0.0f }; - float bcLodiVelocityX3{ 0.0f }; - float bcLodiLentgh{ 0.0f }; - float nx1{ 0.0f }, nx2{ 0.0f }, nx3{ 0.0f }; char algorithmType { -1 }; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.cpp index a3572c8c40ed63144080c1803d728393eaf30547..1ef3f3bc0eed0a9ca9ecd14a019edd0cdd0729db 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.cpp @@ -55,7 +55,7 @@ MPIIOCoProcessor::MPIIOCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const //----------------------------------------------------------------------- MPI_Datatype typesBC[3] = { MPI_LONG_LONG_INT, MPI_FLOAT, MPI_CHAR }; - int blocksBC[3] = { 5, 38, 1 }; + int blocksBC[3] = { 5, 33, 1 }; MPI_Aint offsetsBC[3], lbBC, extentBC; offsetsBC[0] = 0; @@ -70,7 +70,7 @@ MPIIOCoProcessor::MPIIOCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const //--------------------------------------- - MPI_Type_contiguous(8, MPI_CHAR, &arrayPresenceType); + MPI_Type_contiguous(9, MPI_CHAR, &arrayPresenceType); MPI_Type_commit(&arrayPresenceType); } @@ -422,8 +422,7 @@ void MPIIOCoProcessor::clearAllFiles(int step) MPI_File_set_size(file_handler, new_size); MPI_File_close(&file_handler); - std::string filename6 = - path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageFluktuationsArray.bin"; + std::string filename6 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageFluktuationsArray.bin"; // MPI_File_delete(filename6.c_str(), info); int rc6 = MPI_File_open(MPI_COMM_WORLD, filename6.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); if (rc6 != MPI_SUCCESS) @@ -469,6 +468,13 @@ void MPIIOCoProcessor::clearAllFiles(int step) MPI_File_set_size(file_handler, new_size); MPI_File_close(&file_handler); + std::string filename12 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpPressureField.bin"; + int rc12 = MPI_File_open(MPI_COMM_WORLD, filename12.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); + if (rc12 != MPI_SUCCESS) + throw UbException(UB_EXARGS, "couldn't open file " + filename12); + MPI_File_set_size(file_handler, new_size); + MPI_File_close(&file_handler); + } void MPIIOCoProcessor::writeCpTimeStep(int step) diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.cpp index d82c594e6b127f2ade7979f8945b057e7ef6db6c..8e1aa0f522a783dba8a006ab31db53fb6baa7655 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.cpp @@ -25,10 +25,11 @@ using namespace MPIIODataStructures; #define MESSAGE_TAG 80 #define SEND_BLOCK_SIZE 100000 -MPIIOMigrationBECoProcessor::MPIIOMigrationBECoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, SPtr<Communicator> comm) +MPIIOMigrationBECoProcessor::MPIIOMigrationBECoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<Grid3DVisitor> mV, const std::string &path, SPtr<Communicator> comm) : MPIIOCoProcessor(grid, s, path, comm), nue(-999.999), nuL(-999.999), nuG(-999.999), densityRatio(-999.999) { memset(&boundCondParamStr, 0, sizeof(boundCondParamStr)); + metisVisitor = mV; //------------------------- define MPI types --------------------------------- @@ -116,7 +117,7 @@ void MPIIOMigrationBECoProcessor::writeDataSet(int step) int firstGlobalID; std::vector<double> doubleValuesArrayF; // double-values (arrays of f's) in all blocks Fdistribution std::vector<double> doubleValuesArrayH1; // double-values (arrays of f's) in all blocks H1distribution - // std::vector<double> doubleValuesArrayH2; // double-values (arrays of f's) in all blocks H2distribution + std::vector<double> doubleValuesArrayH2; // double-values (arrays of f's) in all blocks H2distribution if (comm->isRoot()) { @@ -124,7 +125,8 @@ void MPIIOMigrationBECoProcessor::writeDataSet(int step) UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - bool multiPhase = false; + bool multiPhase1 = false; + bool multiPhase2 = false; DSArraysPresence arrPresence; bool firstBlock = true; int doubleCountInBlock = 0; @@ -146,19 +148,20 @@ void MPIIOMigrationBECoProcessor::writeDataSet(int step) D3Q27EsoTwist3DSplittedVectorPtrH1 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(block->getKernel()->getDataSet()->getHdistributions()); if (D3Q27EsoTwist3DSplittedVectorPtrH1 != 0) { - multiPhase = true; + multiPhase1 = true; localDistributionsH1 = D3Q27EsoTwist3DSplittedVectorPtrH1->getLocalDistributions(); nonLocalDistributionsH1 = D3Q27EsoTwist3DSplittedVectorPtrH1->getNonLocalDistributions(); zeroDistributionsH1 = D3Q27EsoTwist3DSplittedVectorPtrH1->getZeroDistributions(); } - /*D3Q27EsoTwist3DSplittedVectorPtrH2 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(block->getKernel()->getDataSet()->getH2distributions()); + D3Q27EsoTwist3DSplittedVectorPtrH2 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(block->getKernel()->getDataSet()->getH2distributions()); if (D3Q27EsoTwist3DSplittedVectorPtrH2 != 0) { + multiPhase2 = true; localDistributionsH2 = D3Q27EsoTwist3DSplittedVectorPtrH2->getLocalDistributions(); nonLocalDistributionsH2 = D3Q27EsoTwist3DSplittedVectorPtrH2->getNonLocalDistributions(); zeroDistributionsH2 = D3Q27EsoTwist3DSplittedVectorPtrH2->getZeroDistributions(); - }*/ + } if (firstBlock) // && block->getKernel()) // when first (any) valid block... @@ -253,7 +256,7 @@ void MPIIOMigrationBECoProcessor::writeDataSet(int step) if (zeroDistributionsF && (dataSetParamStr3.nx[0] > 0) && (dataSetParamStr3.nx[1] > 0) && (dataSetParamStr3.nx[2] > 0)) doubleValuesArrayF.insert(doubleValuesArrayF.end(), zeroDistributionsF->getDataVector().begin(), zeroDistributionsF->getDataVector().end()); - if (multiPhase) + if (multiPhase1) { if (localDistributionsH1 && (dataSetParamStr1.nx[0] > 0) && (dataSetParamStr1.nx[1] > 0) && (dataSetParamStr1.nx[2] > 0) && (dataSetParamStr1.nx[3] > 0)) doubleValuesArrayH1.insert(doubleValuesArrayH1.end(), localDistributionsH1->getDataVector().begin(), localDistributionsH1->getDataVector().end()); @@ -263,7 +266,7 @@ void MPIIOMigrationBECoProcessor::writeDataSet(int step) doubleValuesArrayH1.insert(doubleValuesArrayH1.end(), zeroDistributionsH1->getDataVector().begin(), zeroDistributionsH1->getDataVector().end()); } - /*if (D3Q27EsoTwist3DSplittedVectorPtrH2 != 0) + if (multiPhase2) { if (localDistributionsH2 && (dataSetParamStr1.nx[0] > 0) && (dataSetParamStr1.nx[1] > 0) && (dataSetParamStr1.nx[2] > 0) && (dataSetParamStr1.nx[3] > 0)) doubleValuesArrayH2.insert(doubleValuesArrayH2.end(), localDistributionsH2->getDataVector().begin(), localDistributionsH2->getDataVector().end()); @@ -271,7 +274,7 @@ void MPIIOMigrationBECoProcessor::writeDataSet(int step) doubleValuesArrayH2.insert(doubleValuesArrayH2.end(), nonLocalDistributionsH2->getDataVector().begin(), nonLocalDistributionsH2->getDataVector().end()); if (zeroDistributionsH2 && (dataSetParamStr3.nx[0] > 0) && (dataSetParamStr3.nx[1] > 0) && (dataSetParamStr3.nx[2] > 0)) doubleValuesArrayH2.insert(doubleValuesArrayH2.end(), zeroDistributionsH2->getDataVector().begin(), zeroDistributionsH2->getDataVector().end()); - }*/ + } ic++; } @@ -316,7 +319,7 @@ void MPIIOMigrationBECoProcessor::writeDataSet(int step) MPI_File_close(&file_handler); //-------------------------------- H1 ------------------------------------------------ - if (multiPhase) + if (multiPhase1) { filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetH1.bin"; rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); @@ -331,7 +334,7 @@ void MPIIOMigrationBECoProcessor::writeDataSet(int step) } //-------------------------------- H2 -------------------------------------------------- - /*if (D3Q27EsoTwist3DSplittedVectorPtr2 != 0) + if (multiPhase2) { filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetH2.bin"; rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); @@ -343,7 +346,7 @@ void MPIIOMigrationBECoProcessor::writeDataSet(int step) MPI_File_sync(file_handler); MPI_File_close(&file_handler); - } */ + } //-------------------------------- @@ -689,11 +692,7 @@ void MPIIOMigrationBECoProcessor::writeBoundaryConds(int step) bouCond->bcVelocityX2 = (float)bcArr->bcvector[bc]->getBoundaryVelocityX2(); bouCond->bcVelocityX3 = (float)bcArr->bcvector[bc]->getBoundaryVelocityX3(); bouCond->bcDensity = (float)bcArr->bcvector[bc]->getBoundaryDensity(); - bouCond->bcLodiDensity = (float)bcArr->bcvector[bc]->getDensityLodiDensity(); - bouCond->bcLodiVelocityX1 = (float)bcArr->bcvector[bc]->getDensityLodiVelocityX1(); - bouCond->bcLodiVelocityX2 = (float)bcArr->bcvector[bc]->getDensityLodiVelocityX2(); - bouCond->bcLodiVelocityX3 = (float)bcArr->bcvector[bc]->getDensityLodiVelocityX3(); - bouCond->bcLodiLentgh = (float)bcArr->bcvector[bc]->getDensityLodiLength(); + bouCond->bcPhaseField = (float)bcArr->bcvector[bc]->getBoundaryPhaseField(); bouCond->nx1 = (float)bcArr->bcvector[bc]->nx1; bouCond->nx2 = (float)bcArr->bcvector[bc]->nx2; bouCond->nx3 = (float)bcArr->bcvector[bc]->nx3; @@ -834,8 +833,7 @@ void MPIIOMigrationBECoProcessor::restart(int step) UBLOG(logINFO, "Load check point - start"); readBlocks(step); - SPtr<Grid3DVisitor> newMetisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::KWAY)); - grid->accept(newMetisVisitor); + grid->accept(metisVisitor); readDataSet(step); readBoundaryConds(step); @@ -972,6 +970,8 @@ void MPIIOMigrationBECoProcessor::blocksExchange(int tagN, int ind1, int ind2, i MPI_Waitall(requestCount, &requests[0], MPI_STATUSES_IGNORE); + MPI_Type_free(&sendBlockDoubleType); + delete[] blocksCounterSend; delete[] blocksCounterRec; delete[] rawDataSend; @@ -1003,7 +1003,8 @@ void MPIIOMigrationBECoProcessor::readDataSet(int step) UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - bool multiPhase = false; + bool multiPhase1 = false; + bool multiPhase2 = false; dataSetParam dataSetParamStr1, dataSetParamStr2, dataSetParamStr3; int blocksCountAll = grid->getNumberOfBlocks(); // quantity of all blocks in the grid @@ -1037,7 +1038,7 @@ void MPIIOMigrationBECoProcessor::readDataSet(int step) dataSetParamStr3.nx[0] * dataSetParamStr3.nx[1] * dataSetParamStr3.nx[2] * dataSetParamStr3.nx[3]; std::vector<double> doubleValuesArrayF(size_t(myBlocksCount * doubleCountInBlock)); // double-values in all blocks Fdistributions std::vector<double> doubleValuesArrayH1; // double-values in all blocks H1distributions - //std::vector<double> doubleValuesArrayH2; // double-values in all blocks H2distributions + std::vector<double> doubleValuesArrayH2; // double-values in all blocks H2distributions MPI_Type_contiguous(int(doubleCountInBlock), MPI_DOUBLE, &dataSetDoubleType); MPI_Type_commit(&dataSetDoubleType); @@ -1057,7 +1058,7 @@ void MPIIOMigrationBECoProcessor::readDataSet(int step) MPI_File_get_size(file_handler, &fsize); if (fsize > 0) { - multiPhase = true; + multiPhase1 = true; doubleValuesArrayH1.resize(myBlocksCount * doubleCountInBlock); read_offset = (MPI_Offset)(indexB * doubleCountInBlock * sizeof(double)) ; @@ -1065,6 +1066,22 @@ void MPIIOMigrationBECoProcessor::readDataSet(int step) } MPI_File_close(&file_handler); + //--------------------------------- H2 --------------------------------------------------------- + filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetH2.bin"; + rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); + if (rc != MPI_SUCCESS) + throw UbException(UB_EXARGS, "couldn't open file " + filename); + MPI_File_get_size(file_handler, &fsize); + if (fsize > 0) + { + multiPhase2 = true; + doubleValuesArrayH2.resize(myBlocksCount * doubleCountInBlock); + + read_offset = (MPI_Offset)(indexB * doubleCountInBlock * sizeof(double)); + MPI_File_read_at(file_handler, read_offset, &doubleValuesArrayH2[0], int(myBlocksCount), dataSetDoubleType, MPI_STATUS_IGNORE); + } + MPI_File_close(&file_handler); + MPI_Type_free(&dataSetDoubleType); if (comm->isRoot()) @@ -1079,16 +1096,23 @@ void MPIIOMigrationBECoProcessor::readDataSet(int step) for (int r = 0; r < size; r++) rawDataReceiveF[r].resize(0); blocksExchange(MESSAGE_TAG, indexB, indexE, int(doubleCountInBlock), doubleValuesArrayF, rawDataReceiveF); + std::vector<double>* rawDataReceiveH1 = new std::vector<double>[size]; - for (int r = 0; r < size; r++) - rawDataReceiveH1[r].resize(0); - blocksExchange(MESSAGE_TAG, indexB, indexE, int(doubleCountInBlock), doubleValuesArrayH1, rawDataReceiveH1); + if (multiPhase1) + { + for (int r = 0; r < size; r++) + rawDataReceiveH1[r].resize(0); + blocksExchange(MESSAGE_TAG, indexB, indexE, int(doubleCountInBlock), doubleValuesArrayH1, rawDataReceiveH1); + } - /* std::vector<double>* rawDataReceiveH2 = new std::vector<double>[size]; + std::vector<double>* rawDataReceiveH2 = new std::vector<double>[size]; + if (multiPhase2) + { for (int r = 0; r < size; r++) rawDataReceiveH2[r].resize(0); - blocksExchange(MESSAGE_TAG, indexB, indexE, int(doubleCountInBlock), doubleValuesArrayH2, rawDataReceiveH2);*/ + blocksExchange(MESSAGE_TAG, indexB, indexE, int(doubleCountInBlock), doubleValuesArrayH2, rawDataReceiveH2); + } if (comm->isRoot()) { @@ -1102,7 +1126,7 @@ void MPIIOMigrationBECoProcessor::readDataSet(int step) int blockID; std::vector<double> vectorsOfValuesF1, vectorsOfValuesF2, vectorsOfValuesF3; std::vector<double> vectorsOfValuesH11, vectorsOfValuesH12, vectorsOfValuesH13; - //std::vector<double> vectorsOfValuesH21, vectorsOfValuesH22, vectorsOfValuesH23; + std::vector<double> vectorsOfValuesH21, vectorsOfValuesH22, vectorsOfValuesH23; size_t vectorSize1 = dataSetParamStr1.nx[0] * dataSetParamStr1.nx[1] * dataSetParamStr1.nx[2] * dataSetParamStr1.nx[3]; size_t vectorSize2 = dataSetParamStr2.nx[0] * dataSetParamStr2.nx[1] * dataSetParamStr2.nx[2] * dataSetParamStr2.nx[3]; @@ -1118,21 +1142,24 @@ void MPIIOMigrationBECoProcessor::readDataSet(int step) index += 1; vectorsOfValuesF1.assign(rawDataReceiveF[r].data() + index, rawDataReceiveF[r].data() + index + vectorSize1); - if(multiPhase) + if(multiPhase1) vectorsOfValuesH11.assign(rawDataReceiveH1[r].data() + index, rawDataReceiveH1[r].data() + index + vectorSize1); - //vectorsOfValuesH21.assign(rawDataReceiveH2[r].data() + index, rawDataReceiveH2[r].data() + index + vectorSize1); + if (multiPhase2) + vectorsOfValuesH21.assign(rawDataReceiveH2[r].data() + index, rawDataReceiveH2[r].data() + index + vectorSize1); index += vectorSize1; vectorsOfValuesF2.assign(rawDataReceiveF[r].data() + index, rawDataReceiveF[r].data() + index + vectorSize2); - if (multiPhase) - vectorsOfValuesH12.assign(rawDataReceiveH1[r].data() + index, rawDataReceiveH1[r].data() + index + vectorSize1); - //vectorsOfValuesH22.assign(rawDataReceiveH2[r].data() + index, rawDataReceiveH2[r].data() + index + vectorSize1); + if (multiPhase1) + vectorsOfValuesH12.assign(rawDataReceiveH1[r].data() + index, rawDataReceiveH1[r].data() + index + vectorSize2); + if (multiPhase2) + vectorsOfValuesH22.assign(rawDataReceiveH2[r].data() + index, rawDataReceiveH2[r].data() + index + vectorSize2); index += vectorSize2; vectorsOfValuesF3.assign(rawDataReceiveF[r].data() + index, rawDataReceiveF[r].data() + index + vectorSize3); - if (multiPhase) - vectorsOfValuesH13.assign(rawDataReceiveH1[r].data() + index, rawDataReceiveH1[r].data() + index + vectorSize1); - //vectorsOfValuesH23.assign(rawDataReceiveH2[r].data() + index, rawDataReceiveH2[r].data() + index + vectorSize1); + if (multiPhase1) + vectorsOfValuesH13.assign(rawDataReceiveH1[r].data() + index, rawDataReceiveH1[r].data() + index + vectorSize3); + if (multiPhase2) + vectorsOfValuesH23.assign(rawDataReceiveH2[r].data() + index, rawDataReceiveH2[r].data() + index + vectorSize3); index += vectorSize3; SPtr<DistributionArray3D> mFdistributions(new D3Q27EsoTwist3DSplittedVector()); @@ -1148,7 +1175,7 @@ void MPIIOMigrationBECoProcessor::readDataSet(int step) dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setNX3(dataSetParamStr1.nx3); SPtr<DistributionArray3D> mH1distributions(new D3Q27EsoTwist3DSplittedVector()); - if (multiPhase) + if (multiPhase1) { dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH1distributions)->setLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr( new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValuesH11, dataSetParamStr1.nx[0], dataSetParamStr1.nx[1], dataSetParamStr1.nx[2], dataSetParamStr1.nx[3]))); @@ -1162,18 +1189,20 @@ void MPIIOMigrationBECoProcessor::readDataSet(int step) dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH1distributions)->setNX3(dataSetParamStr1.nx3); } - /*SPtr<DistributionArray3D> mH2distributions(new D3Q27EsoTwist3DSplittedVector()); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr( + SPtr<DistributionArray3D> mH2distributions(new D3Q27EsoTwist3DSplittedVector()); + if (multiPhase2) + { + dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr( new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValuesH21, dataSetParamStr1.nx[0], dataSetParamStr1.nx[1], dataSetParamStr1.nx[2], dataSetParamStr1.nx[3]))); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNonLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr( - new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValuesH22, dataSetParamStr2.nx[0], dataSetParamStr2.nx[1], dataSetParamStr2.nx[2], dataSetParamStr2.nx[3]))); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setZeroDistributions(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>( - vectorsOfValuesH23, dataSetParamStr3.nx[0], dataSetParamStr3.nx[1], dataSetParamStr3.nx[2]))); - - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNX1(dataSetParamStr1.nx1); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNX2(dataSetParamStr1.nx2); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNX3(dataSetParamStr1.nx3);*/ - + dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNonLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr( + new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValuesH22, dataSetParamStr2.nx[0], dataSetParamStr2.nx[1], dataSetParamStr2.nx[2], dataSetParamStr2.nx[3]))); + dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setZeroDistributions(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>( + vectorsOfValuesH23, dataSetParamStr3.nx[0], dataSetParamStr3.nx[1], dataSetParamStr3.nx[2]))); + + dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNX1(dataSetParamStr1.nx1); + dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNX2(dataSetParamStr1.nx2); + dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNX3(dataSetParamStr1.nx3); + } // find the nesessary block and fill it SPtr<Block3D> block = grid->getBlock(blockID); @@ -1189,14 +1218,16 @@ void MPIIOMigrationBECoProcessor::readDataSet(int step) kernel->setDensityRatio(this->densityRatio); SPtr<DataSet3D> dataSetPtr = SPtr<DataSet3D>(new DataSet3D()); dataSetPtr->setFdistributions(mFdistributions); - if (multiPhase) + if (multiPhase1) dataSetPtr->setHdistributions(mH1distributions); -// dataSetPtr->setHdistributions(mH2distributions); + if (multiPhase2) + dataSetPtr->setH2distributions(mH2distributions); kernel->setDataSet(dataSetPtr); block->setKernel(kernel); } } - //if (comm->isRoot()) + + if (comm->isRoot()) { UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readDataSet end of restore of data, rank = " << rank); UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); @@ -1245,7 +1276,7 @@ void MPIIOMigrationBECoProcessor::readDataSet(int step) readArray(step, PhaseField2, std::string("/cpPhaseField2.bin")); delete[] rawDataReceiveF; -// delete[] rawDataReceiveH1; + delete[] rawDataReceiveH1; // delete[] rawDataReceiveH2; } @@ -1608,11 +1639,7 @@ void MPIIOMigrationBECoProcessor::readBoundaryConds(int step) bc->bcVelocityX2 = bcArray[ibc].bcVelocityX2; bc->bcVelocityX3 = bcArray[ibc].bcVelocityX3; bc->bcDensity = bcArray[ibc].bcDensity; - bc->bcLodiDensity = bcArray[ibc].bcLodiDensity; - bc->bcLodiVelocityX1 = bcArray[ibc].bcLodiVelocityX1; - bc->bcLodiVelocityX2 = bcArray[ibc].bcLodiVelocityX2; - bc->bcLodiVelocityX3 = bcArray[ibc].bcLodiVelocityX3; - bc->bcLodiLentgh = bcArray[ibc].bcLodiLentgh; + bc->bcPhaseField = bcArray[ibc].bcPhaseField; bc->nx1 = bcArray[ibc].nx1; bc->nx2 = bcArray[ibc].nx2; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.h index 9a89ada1ae039d10cd53b06b189e5709398911c8..ee8766eebaa5e3baa41ddb35270cdbfe4670db1f 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.h @@ -13,6 +13,7 @@ class UbScheduler; class Communicator; class BCProcessor; class LBMKernel; +class Grid3DVisitor; //! \class MPIWriteBlocksBECoProcessor //! \brief Writes the grid each timestep into the files and reads the grip from the files before regenerating @@ -30,8 +31,7 @@ class MPIIOMigrationBECoProcessor : public MPIIOCoProcessor }; public: - MPIIOMigrationBECoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - SPtr<Communicator> comm); + MPIIOMigrationBECoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<Grid3DVisitor> mV, const std::string &path, SPtr<Communicator> comm); ~MPIIOMigrationBECoProcessor() override; //! Each timestep writes the grid into the files void process(double step) override; @@ -93,11 +93,11 @@ private: MPIIODataStructures::boundCondParam boundCondParamStr; SPtr<LBMKernel> lbmKernel; SPtr<BCProcessor> bcProcessor; + SPtr<Grid3DVisitor> metisVisitor; double nue; double nuL; double nuG; double densityRatio; - }; #endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp index 2c5a547c4cca531fe50e7255b0aba6a6a4b5c6e9..7992bc08f1a9afaed8eba5d4f3d96c1137cbf89f 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp @@ -22,10 +22,11 @@ using namespace MPIIODataStructures; -MPIIOMigrationCoProcessor::MPIIOMigrationCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, SPtr<Communicator> comm) +MPIIOMigrationCoProcessor::MPIIOMigrationCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<Grid3DVisitor> mV, const std::string &path, SPtr<Communicator> comm) : MPIIOCoProcessor(grid, s, path, comm) { memset(&boundCondParamStr, 0, sizeof(boundCondParamStr)); + metisVisitor = mV; //------------------------- define MPI types --------------------------------- @@ -134,7 +135,7 @@ void MPIIOMigrationCoProcessor::writeDataSet(int step) DataSetMigration *dataSetArray = new DataSetMigration[blocksCount]; std::vector<double> doubleValuesArrayF; // double-values (arrays of f's) in all blocks Fdistribution std::vector<double> doubleValuesArrayH1; // double-values (arrays of f's) in all blocks H1distribution - // std::vector<double> doubleValuesArrayH2; // double-values (arrays of f's) in all blocks H2distribution + std::vector<double> doubleValuesArrayH2; // double-values (arrays of f's) in all blocks H2distribution if (comm->isRoot()) { @@ -142,8 +143,10 @@ void MPIIOMigrationCoProcessor::writeDataSet(int step) UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - bool multiPhase = false; + bool multiPhase1 = false; + bool multiPhase2 = false; DSArraysPresence arrPresence; + memset(&arrPresence, 0, sizeof(arrPresence)); bool firstBlock = true; size_t doubleCountInBlock = 0; int ic = 0; @@ -178,19 +181,20 @@ void MPIIOMigrationCoProcessor::writeDataSet(int step) D3Q27EsoTwist3DSplittedVectorPtrH1 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(block->getKernel()->getDataSet()->getHdistributions()); if (D3Q27EsoTwist3DSplittedVectorPtrH1 != 0) { - multiPhase = true; + multiPhase1 = true; localDistributionsH1 = D3Q27EsoTwist3DSplittedVectorPtrH1->getLocalDistributions(); nonLocalDistributionsH1 = D3Q27EsoTwist3DSplittedVectorPtrH1->getNonLocalDistributions(); zeroDistributionsH1 = D3Q27EsoTwist3DSplittedVectorPtrH1->getZeroDistributions(); } - /*D3Q27EsoTwist3DSplittedVectorPtrH2 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(block->getKernel()->getDataSet()->getH2distributions()); + D3Q27EsoTwist3DSplittedVectorPtrH2 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(block->getKernel()->getDataSet()->getH2distributions()); if (D3Q27EsoTwist3DSplittedVectorPtrH2 != 0) { + multiPhase2 = true; localDistributionsH2 = D3Q27EsoTwist3DSplittedVectorPtrH2->getLocalDistributions(); nonLocalDistributionsH2 = D3Q27EsoTwist3DSplittedVectorPtrH2->getNonLocalDistributions(); zeroDistributionsH2 = D3Q27EsoTwist3DSplittedVectorPtrH2->getZeroDistributions(); - }*/ + } if (firstBlock) // && block->getKernel()) // when first (any) valid block... { @@ -274,6 +278,12 @@ void MPIIOMigrationCoProcessor::writeDataSet(int step) else arrPresence.isPhaseField2Present = false; + SPtr<CbArray3D<LBMReal, IndexerX3X2X1>> pressureFieldPtr = block->getKernel()->getDataSet()->getPressureField(); + if (pressureFieldPtr) + arrPresence.isPressureFieldPresent = true; + else + arrPresence.isPressureFieldPresent = false; + firstBlock = false; } @@ -284,7 +294,7 @@ void MPIIOMigrationCoProcessor::writeDataSet(int step) if (zeroDistributionsF && (dataSetParamStr3.nx[0] > 0) && (dataSetParamStr3.nx[1] > 0) && (dataSetParamStr3.nx[2] > 0)) doubleValuesArrayF.insert(doubleValuesArrayF.end(), zeroDistributionsF->getDataVector().begin(), zeroDistributionsF->getDataVector().end()); - if (multiPhase) + if (multiPhase1) { if (localDistributionsH1 && (dataSetParamStr1.nx[0] > 0) && (dataSetParamStr1.nx[1] > 0) && (dataSetParamStr1.nx[2] > 0) && (dataSetParamStr1.nx[3] > 0)) doubleValuesArrayH1.insert(doubleValuesArrayH1.end(), localDistributionsH1->getDataVector().begin(), localDistributionsH1->getDataVector().end()); @@ -294,7 +304,7 @@ void MPIIOMigrationCoProcessor::writeDataSet(int step) doubleValuesArrayH1.insert(doubleValuesArrayH1.end(), zeroDistributionsH1->getDataVector().begin(), zeroDistributionsH1->getDataVector().end()); } - /*if (D3Q27EsoTwist3DSplittedVectorPtrH2 != 0) + if (multiPhase2) { if (localDistributionsH2 && (dataSetParamStr1.nx[0] > 0) && (dataSetParamStr1.nx[1] > 0) && (dataSetParamStr1.nx[2] > 0) && (dataSetParamStr1.nx[3] > 0)) doubleValuesArrayH2.insert(doubleValuesArrayH2.end(), localDistributionsH2->getDataVector().begin(), localDistributionsH2->getDataVector().end()); @@ -302,7 +312,7 @@ void MPIIOMigrationCoProcessor::writeDataSet(int step) doubleValuesArrayH2.insert(doubleValuesArrayH2.end(), nonLocalDistributionsH2->getDataVector().begin(), nonLocalDistributionsH2->getDataVector().end()); if (zeroDistributionsH2 && (dataSetParamStr3.nx[0] > 0) && (dataSetParamStr3.nx[1] > 0) && (dataSetParamStr3.nx[2] > 0)) doubleValuesArrayH2.insert(doubleValuesArrayH2.end(), zeroDistributionsH2->getDataVector().begin(), zeroDistributionsH2->getDataVector().end()); - }*/ + } ic++; } @@ -354,7 +364,7 @@ void MPIIOMigrationCoProcessor::writeDataSet(int step) MPI_File_close(&file_handler); //-------------------------------- H1 ---------------------------------------------------- - if (multiPhase) + if (multiPhase1) { filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetH1.bin"; rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); @@ -374,7 +384,7 @@ void MPIIOMigrationCoProcessor::writeDataSet(int step) } //-------------------------------- H2 ---------------------------------------------------- - /*if (D3Q27EsoTwist3DSplittedVectorPtrH2 != 0) + if (multiPhase2) { filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetH2.bin"; rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); @@ -391,7 +401,7 @@ void MPIIOMigrationCoProcessor::writeDataSet(int step) MPI_File_sync(file_handler); MPI_File_close(&file_handler); - }*/ + } //-------------------------------- MPI_Type_free(&dataSetDoubleType); @@ -415,23 +425,18 @@ void MPIIOMigrationCoProcessor::writeDataSet(int step) if (arrPresence.isAverageDensityArrayPresent) write4DArray(step, AverageDensity, std::string("/cpAverageDensityArray.bin")); - // writeAverageDensityArray(step); if (arrPresence.isAverageVelocityArrayPresent) write4DArray(step, AverageVelocity, std::string("/cpAverageVelocityArray.bin")); - // writeAverageVelocityArray(step); if (arrPresence.isAverageFluktuationsArrayPresent) write4DArray(step, AverageFluktuations, std::string("/cpAverageFluktuationsArray.bin")); - // writeAverageFluktuationsArray(step); if (arrPresence.isAverageTripleArrayPresent) write4DArray(step, AverageTriple, std::string("/cpAverageTripleArray.bin")); - // writeAverageTripleArray(step); if (arrPresence.isShearStressValArrayPresent) write4DArray(step, ShearStressVal, std::string("/cpShearStressValArray.bin")); - // writeShearStressValArray(step); if (arrPresence.isRelaxationFactorPresent) write3DArray(step, RelaxationFactor, std::string("/cpRelaxationFactor.bin")); @@ -442,6 +447,9 @@ void MPIIOMigrationCoProcessor::writeDataSet(int step) if (arrPresence.isPhaseField2Present) write3DArray(step, PhaseField2, std::string("/cpPhaseField2.bin")); + if (arrPresence.isPressureFieldPresent) + write3DArray(step, PressureField, std::string("/cpPressureField.bin")); + } void MPIIOMigrationCoProcessor::write4DArray(int step, Arrays arrayType, std::string fname) @@ -621,6 +629,9 @@ void MPIIOMigrationCoProcessor::write3DArray(int step, Arrays arrayType, std::st case PhaseField2: ___Array = block->getKernel()->getDataSet()->getPhaseField2(); break; + case PressureField: + ___Array = block->getKernel()->getDataSet()->getPressureField(); + break; default: UB_THROW(UbException(UB_EXARGS, "MPIIOMigrationCoProcessor::write3DArray : 3D array type does not exist!")); break; @@ -700,720 +711,6 @@ void MPIIOMigrationCoProcessor::write3DArray(int step, Arrays arrayType, std::st delete[] dataSetSmallArray; } -/* -void MPIIOMigrationCoProcessor::writeAverageDensityArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - std::vector<double> doubleValuesArray; // double-values of the AverageDensityArray in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageDensityArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - bool firstBlock = true; - size_t doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetSmallArray[ic].globalID = block->getGlobalID(); // id of the block needed to find it while -regenerating the grid - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > averageDensityArray = -block->getKernel()->getDataSet()->getAverageDensity(); - - if (firstBlock) // when first (any) valid block... - { - //if (averageDensityArray) - //{ - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(averageDensityArray->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(averageDensityArray->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(averageDensityArray->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(averageDensityArray->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * -dataSetParamStr.nx[3]; - //} - //else - // break; - - firstBlock = false; - } - - if (averageDensityArray && (dataSetParamStr.nx[0] > 0) && (dataSetParamStr.nx[1] > 0) && (dataSetParamStr.nx[2] -> 0) && (dataSetParamStr.nx[3] > 0)) doubleValuesArray.insert(doubleValuesArray.end(), -averageDensityArray->getDataVector().begin(), averageDensityArray->getDataVector().end()); - - ic++; - } - } - - // register new MPI-types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageDensityArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageDensityArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - MPI_Offset write_offset; - size_t sizeofOneDataSet = sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double); - - for (size_t nb = 0; nb < blocksCount; nb++) - { - write_offset = (MPI_Offset)(sizeof(dataSetParam) + dataSetSmallArray[nb].globalID * sizeofOneDataSet); - MPI_File_write_at(file_handler, write_offset, &dataSetSmallArray[nb], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[nb -* doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - } - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageDensityArray time: " << finish - start << " s"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::writeAverageVelocityArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageVelocityArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - bool firstBlock = true; - size_t doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetSmallArray[ic].globalID = block->getGlobalID(); // id of the block needed to find it while -regenerating the grid - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageVelocityArray3DPtr = -block->getKernel()->getDataSet()->getAverageVelocity(); - - if (firstBlock) // when first (any) valid block... - { - //if (AverageVelocityArray3DPtr) - //{ - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(AverageVelocityArray3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(AverageVelocityArray3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(AverageVelocityArray3DPtr->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(AverageVelocityArray3DPtr->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * -dataSetParamStr.nx[3]; - //} - //else - // break; - - firstBlock = false; - } - - if (AverageVelocityArray3DPtr && (dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && -(dataSetParamStr.nx[2]>0) && (dataSetParamStr.nx[3]>0)) doubleValuesArray.insert(doubleValuesArray.end(), -AverageVelocityArray3DPtr->getDataVector().begin(), AverageVelocityArray3DPtr->getDataVector().end()); - - ic++; - } - } - - // register new MPI-types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageVelocityArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageVelocityArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - MPI_Offset write_offset; - size_t sizeofOneDataSet = sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double); - - for (size_t nb = 0; nb < blocksCount; nb++) - { - write_offset = (MPI_Offset)(sizeof(dataSetParam) + dataSetSmallArray[nb].globalID * sizeofOneDataSet); - MPI_File_write_at(file_handler, write_offset, &dataSetSmallArray[nb], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[nb -* doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - } - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageVelocityArray time: " << finish - start << " s"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::writeAverageFluktuationsArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageFluktuationsArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - bool firstBlock = true; - size_t doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetSmallArray[ic].globalID = block->getGlobalID(); // id of the block needed to find it while -regenerating the grid - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageFluctArray3DPtr = -block->getKernel()->getDataSet()->getAverageFluctuations(); - - if (firstBlock) // when first (any) valid block... - { - //if (AverageFluctArray3DPtr) - //{ - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(AverageFluctArray3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(AverageFluctArray3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(AverageFluctArray3DPtr->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(AverageFluctArray3DPtr->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * -dataSetParamStr.nx[3]; - //} - //else - // break; - - firstBlock = false; - } - - if (AverageFluctArray3DPtr && (dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && -(dataSetParamStr.nx[2]>0) && (dataSetParamStr.nx[3]>0)) doubleValuesArray.insert(doubleValuesArray.end(), -AverageFluctArray3DPtr->getDataVector().begin(), AverageFluctArray3DPtr->getDataVector().end()); - - ic++; - } - } - - // register new MPI-types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageFluktuationsArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; -#ifdef HLRN_LUSTRE - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageFluktuationsArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - MPI_Offset write_offset; - size_t sizeofOneDataSet = sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double); - - for (size_t nb = 0; nb < blocksCount; nb++) - { - write_offset = (MPI_Offset)(sizeof(dataSetParam) + dataSetSmallArray[nb].globalID * sizeofOneDataSet); - MPI_File_write_at(file_handler, write_offset, &dataSetSmallArray[nb], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[nb -* doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - } - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageFluktuationsArray time: " << finish - start << " s"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::writeAverageTripleArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageTripleArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - bool firstBlock = true; - size_t doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetSmallArray[ic].globalID = block->getGlobalID(); // id of the block needed to find it while -regenerating the grid - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageTripleArray3DPtr = -block->getKernel()->getDataSet()->getAverageTriplecorrelations(); - - if (firstBlock) // when first (any) valid block... - { - //if (AverageTripleArray3DPtr) - //{ - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(AverageTripleArray3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(AverageTripleArray3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(AverageTripleArray3DPtr->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(AverageTripleArray3DPtr->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * -dataSetParamStr.nx[3]; - //} - //else - // break; - - firstBlock = false; - } - - if (AverageTripleArray3DPtr && (dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && -(dataSetParamStr.nx[2]>0) && (dataSetParamStr.nx[3]>0)) doubleValuesArray.insert(doubleValuesArray.end(), -AverageTripleArray3DPtr->getDataVector().begin(), AverageTripleArray3DPtr->getDataVector().end()); - - ic++; - } - } - - // register new MPI-types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageTripleArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - -#ifdef HLRN_LUSTRE - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageTripleArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - MPI_Offset write_offset; - size_t sizeofOneDataSet = sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double); - - for (size_t nb = 0; nb < blocksCount; nb++) - { - write_offset = (MPI_Offset)(sizeof(dataSetParam) + dataSetSmallArray[nb].globalID * sizeofOneDataSet); - MPI_File_write_at(file_handler, write_offset, &dataSetSmallArray[nb], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[nb -* doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - } - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageTripleArray time: " << finish - start << " s"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::writeShearStressValArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeShearStressValArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - bool firstBlock = true; - size_t doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetSmallArray[ic].globalID = block->getGlobalID(); // id of the block needed to find it while -regenerating the grid - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > ShearStressValArray3DPtr = -block->getKernel()->getDataSet()->getShearStressValues(); - - if (firstBlock) // when first (any) valid block... - { - //if (ShearStressValArray3DPtr) - //{ - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(ShearStressValArray3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(ShearStressValArray3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(ShearStressValArray3DPtr->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(ShearStressValArray3DPtr->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * -dataSetParamStr.nx[3]; - //} - //else - // break; - - firstBlock = false; - } - - if (ShearStressValArray3DPtr && (dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && -(dataSetParamStr.nx[2]>0) && (dataSetParamStr.nx[3]>0)) doubleValuesArray.insert(doubleValuesArray.end(), -ShearStressValArray3DPtr->getDataVector().begin(), ShearStressValArray3DPtr->getDataVector().end()); - - ic++; - } - } - - // register new MPI-types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeShearStressValArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - -#ifdef HLRN_LUSTRE - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpShearStressValArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - MPI_Offset write_offset; - size_t sizeofOneDataSet = sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double); - - for (size_t nb = 0; nb < blocksCount; nb++) - { - write_offset = (MPI_Offset)(sizeof(dataSetParam) + dataSetSmallArray[nb].globalID * sizeofOneDataSet); - MPI_File_write_at(file_handler, write_offset, &dataSetSmallArray[nb], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[nb -* doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - } - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeShearStressValArray time: " << finish - start << " s"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::writeRelaxationFactor(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeRelaxationFactor start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - bool firstBlock = true; - size_t doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetSmallArray[ic].globalID = block->getGlobalID(); // id of the block needed to find it while -regenerating the grid - - SPtr< CbArray3D<LBMReal, IndexerX3X2X1> > relaxationFactor3DPtr = -block->getKernel()->getDataSet()->getRelaxationFactor(); - - if (firstBlock) // when first (any) valid block... - { - //if (relaxationFactor3DPtr) - //{ - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(relaxationFactor3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(relaxationFactor3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(relaxationFactor3DPtr->getNX3()); - dataSetParamStr.nx[3] = 1; - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * -dataSetParamStr.nx[3]; - //} - //else - // break; - - firstBlock = false; - } - - if (relaxationFactor3DPtr && (dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && -(dataSetParamStr.nx[2]>0)) doubleValuesArray.insert(doubleValuesArray.end(), -relaxationFactor3DPtr->getDataVector().begin(), relaxationFactor3DPtr->getDataVector().end()); - - ic++; - } - } - - // register new MPI-types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeRelaxationFactor start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - -#ifdef HLRN_LUSTRE - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpRelaxationFactor.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - MPI_Offset write_offset; - size_t sizeofOneDataSet = sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double); - - for (size_t nb = 0; nb < blocksCount; nb++) - { - write_offset = (MPI_Offset)(sizeof(dataSetParam) + dataSetSmallArray[nb].globalID * sizeofOneDataSet); - MPI_File_write_at(file_handler, write_offset, &dataSetSmallArray[nb], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[nb -* doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - } - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeRelaxationFactor time: " << finish - start << " s"); - } - - delete[] dataSetSmallArray; -} -*/ void MPIIOMigrationCoProcessor::writeBoundaryConds(int step) { int rank, size; @@ -1480,11 +777,7 @@ void MPIIOMigrationCoProcessor::writeBoundaryConds(int step) bouCond->bcVelocityX2 = (float)bcArr->bcvector[bc]->getBoundaryVelocityX2(); bouCond->bcVelocityX3 = (float)bcArr->bcvector[bc]->getBoundaryVelocityX3(); bouCond->bcDensity = (float)bcArr->bcvector[bc]->getBoundaryDensity(); - bouCond->bcLodiDensity = (float)bcArr->bcvector[bc]->getDensityLodiDensity(); - bouCond->bcLodiVelocityX1 = (float)bcArr->bcvector[bc]->getDensityLodiVelocityX1(); - bouCond->bcLodiVelocityX2 = (float)bcArr->bcvector[bc]->getDensityLodiVelocityX2(); - bouCond->bcLodiVelocityX3 = (float)bcArr->bcvector[bc]->getDensityLodiVelocityX3(); - bouCond->bcLodiLentgh = (float)bcArr->bcvector[bc]->getDensityLodiLength(); + bouCond->bcPhaseField = (float)bcArr->bcvector[bc]->getBoundaryPhaseField(); bouCond->nx1 = (float)bcArr->bcvector[bc]->nx1; bouCond->nx2 = (float)bcArr->bcvector[bc]->nx2; bouCond->nx3 = (float)bcArr->bcvector[bc]->nx3; @@ -1617,7 +910,6 @@ void MPIIOMigrationCoProcessor::restart(int step) readBlocks(step); - SPtr<Grid3DVisitor> metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::KWAY)); grid->accept(metisVisitor); readDataSet(step); @@ -1646,7 +938,8 @@ void MPIIOMigrationCoProcessor::readDataSet(int step) if (comm->isRoot()) start = MPI_Wtime(); - bool multiPhase = false; + bool multiPhase1 = false; + bool multiPhase2 = false; size_t blocksCount = 0; // quantity of the blocks, that belong to this process dataSetParam dataSetParamStr1, dataSetParamStr2, dataSetParamStr3; @@ -1677,7 +970,7 @@ void MPIIOMigrationCoProcessor::readDataSet(int step) dataSetParamStr3.nx[0] * dataSetParamStr3.nx[1] * dataSetParamStr3.nx[2] * dataSetParamStr3.nx[3]; std::vector<double> doubleValuesArrayF(size_t(blocksCount * doubleCountInBlock)); // double-values in all blocks Fdistributions std::vector<double> doubleValuesArrayH1; // double-values in all blocks H1distributions - //std::vector<double> doubleValuesArrayH2; // double-values in all blocks H2distributions + std::vector<double> doubleValuesArrayH2; // double-values in all blocks H2distributions // define MPI_types depending on the block-specific information MPI_Type_contiguous(int(doubleCountInBlock), MPI_DOUBLE, &dataSetDoubleType); @@ -1702,6 +995,7 @@ void MPIIOMigrationCoProcessor::readDataSet(int step) MPI_File_close(&file_handler); //----------------------------------------- H1 ---------------------------------------------------- + ic = 0; MPI_Offset fsize; filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetH1.bin"; rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); @@ -1710,7 +1004,7 @@ void MPIIOMigrationCoProcessor::readDataSet(int step) MPI_File_get_size(file_handler, &fsize); if (fsize > 0) { - multiPhase = true; + multiPhase1 = true; doubleValuesArrayH1.resize(blocksCount * doubleCountInBlock); sizeofOneDataSet = size_t(doubleCountInBlock * sizeof(double)); @@ -1729,25 +1023,32 @@ void MPIIOMigrationCoProcessor::readDataSet(int step) MPI_File_close(&file_handler); //----------------------------------------- H2 ---------------------------------------------------- - /*filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetH2.bin"; + ic = 0; + filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetH2.bin"; rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - sizeofOneDataSet = size_t(doubleCountInBlock * sizeof(double)); - doubleValuesArrayH2.resize(blocksCount * doubleCountInBlock); - - for (int level = minInitLevel; level <= maxInitLevel; level++) + MPI_File_get_size(file_handler, &fsize); + if (fsize > 0) { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level + multiPhase2 = true; + doubleValuesArrayH2.resize(blocksCount * doubleCountInBlock); + + sizeofOneDataSet = size_t(doubleCountInBlock * sizeof(double)); + + for (int level = minInitLevel; level <= maxInitLevel; level++) { - read_offset = (MPI_Offset)(block->getGlobalID() * sizeofOneDataSet); - MPI_File_read_at(file_handler, read_offset, &doubleValuesArrayH2[ic * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - ic++; + for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level + { + read_offset = (MPI_Offset)(block->getGlobalID() * sizeofOneDataSet); + MPI_File_read_at(file_handler, read_offset, &doubleValuesArrayH2[ic * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); + ic++; + } } - } - MPI_File_close(&file_handler);*/ + } + MPI_File_close(&file_handler); MPI_Type_free(&dataSetDoubleType); @@ -1762,7 +1063,7 @@ void MPIIOMigrationCoProcessor::readDataSet(int step) size_t index = 0; std::vector<double> vectorsOfValuesF1, vectorsOfValuesF2, vectorsOfValuesF3; std::vector<double> vectorsOfValuesH11, vectorsOfValuesH12, vectorsOfValuesH13; - //std::vector<double> vectorsOfValuesH21, vectorsOfValuesH22, vectorsOfValuesH23; + std::vector<double> vectorsOfValuesH21, vectorsOfValuesH22, vectorsOfValuesH23; size_t vectorSize1 = dataSetParamStr1.nx[0] * dataSetParamStr1.nx[1] * dataSetParamStr1.nx[2] * dataSetParamStr1.nx[3]; size_t vectorSize2 = dataSetParamStr2.nx[0] * dataSetParamStr2.nx[1] * dataSetParamStr2.nx[2] * dataSetParamStr2.nx[3]; @@ -1771,21 +1072,24 @@ void MPIIOMigrationCoProcessor::readDataSet(int step) for (std::size_t n = 0; n < blocksCount; n++) { vectorsOfValuesF1.assign(doubleValuesArrayF.data() + index, doubleValuesArrayF.data() + index + vectorSize1); - if(multiPhase) + if(multiPhase1) vectorsOfValuesH11.assign(doubleValuesArrayH1.data() + index, doubleValuesArrayH1.data() + index + vectorSize1); - //vectorsOfValuesH21.assign(doubleValuesArrayH2.data() + index, doubleValuesArrayH2.data() + index + vectorSize1); + if (multiPhase2) + vectorsOfValuesH21.assign(doubleValuesArrayH2.data() + index, doubleValuesArrayH2.data() + index + vectorSize1); index += vectorSize1; vectorsOfValuesF2.assign(doubleValuesArrayF.data() + index, doubleValuesArrayF.data() + index + vectorSize2); - if (multiPhase) + if (multiPhase1) vectorsOfValuesH12.assign(doubleValuesArrayH1.data() + index, doubleValuesArrayH1.data() + index + vectorSize2); - //vectorsOfValuesH22.assign(doubleValuesArrayH2.data() + index, doubleValuesArrayH2.data() + index + vectorSize2); + if (multiPhase2) + vectorsOfValuesH22.assign(doubleValuesArrayH2.data() + index, doubleValuesArrayH2.data() + index + vectorSize2); index += vectorSize2; vectorsOfValuesF3.assign(doubleValuesArrayF.data() + index, doubleValuesArrayF.data() + index + vectorSize3); - if (multiPhase) + if (multiPhase1) vectorsOfValuesH13.assign(doubleValuesArrayH1.data() + index, doubleValuesArrayH1.data() + index + vectorSize3); - //vectorsOfValuesH23.assign(doubleValuesArrayH2.data() + index, doubleValuesArrayH2.data() + index + vectorSize3); + if (multiPhase2) + vectorsOfValuesH23.assign(doubleValuesArrayH2.data() + index, doubleValuesArrayH2.data() + index + vectorSize3); index += vectorSize3; SPtr<DistributionArray3D> mFdistributions(new D3Q27EsoTwist3DSplittedVector()); @@ -1801,7 +1105,7 @@ void MPIIOMigrationCoProcessor::readDataSet(int step) dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setNX3(dataSetParamStr1.nx3); SPtr<DistributionArray3D> mH1distributions(new D3Q27EsoTwist3DSplittedVector()); - if (multiPhase) + if (multiPhase1) { dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH1distributions)->setLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr( new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValuesH11, dataSetParamStr1.nx[0], dataSetParamStr1.nx[1], dataSetParamStr1.nx[2], dataSetParamStr1.nx[3]))); @@ -1815,21 +1119,26 @@ void MPIIOMigrationCoProcessor::readDataSet(int step) dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH1distributions)->setNX3(dataSetParamStr1.nx3); } - /*SPtr<DistributionArray3D> mH2distributions(new D3Q27EsoTwist3DSplittedVector()); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr( + SPtr<DistributionArray3D> mH2distributions(new D3Q27EsoTwist3DSplittedVector()); + if (multiPhase2) + { + dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr( new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValuesH21, dataSetParamStr1.nx[0], dataSetParamStr1.nx[1], dataSetParamStr1.nx[2], dataSetParamStr1.nx[3]))); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNonLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr( - new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValuesH22, dataSetParamStr2.nx[0], dataSetParamStr2.nx[1], dataSetParamStr2.nx[2], dataSetParamStr2.nx[3]))); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setZeroDistributions(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>( - vectorsOfValuesH23, dataSetParamStr3.nx[0], dataSetParamStr3.nx[1], dataSetParamStr3.nx[2]))); - - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNX1(dataSetParamStr1.nx1); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNX2(dataSetParamStr1.nx2); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNX3(dataSetParamStr1.nx3);*/ + dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNonLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr( + new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValuesH22, dataSetParamStr2.nx[0], dataSetParamStr2.nx[1], dataSetParamStr2.nx[2], dataSetParamStr2.nx[3]))); + dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setZeroDistributions(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>( + vectorsOfValuesH23, dataSetParamStr3.nx[0], dataSetParamStr3.nx[1], dataSetParamStr3.nx[2]))); + + dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNX1(dataSetParamStr1.nx1); + dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNX2(dataSetParamStr1.nx2); + dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNX3(dataSetParamStr1.nx3); + } // find the nesessary block and fill it SPtr<Block3D> block = grid->getBlock(dataSetArray[n].globalID); this->lbmKernel->setBlock(block); + UbTupleInt3 blockNX = grid->getBlockNX(); + this->lbmKernel->setNX(std::array<int, 3>{ { val<1>(blockNX), val<2>(blockNX), val<3>(blockNX) } }); SPtr<LBMKernel> kernel = this->lbmKernel->clone(); kernel->setGhostLayerWidth(dataSetArray[n].ghostLayerWidth); kernel->setCollisionFactor(dataSetArray[n].collFactor); @@ -1841,9 +1150,10 @@ void MPIIOMigrationCoProcessor::readDataSet(int step) SPtr<DataSet3D> dataSetPtr = SPtr<DataSet3D>(new DataSet3D()); dataSetPtr->setFdistributions(mFdistributions); - if (multiPhase) + if (multiPhase1) dataSetPtr->setHdistributions(mH1distributions); - //dataSetPtr->setH2distributions(mH2distributions); + if (multiPhase2) + dataSetPtr->setH2distributions(mH2distributions); kernel->setDataSet(dataSetPtr); block->setKernel(kernel); } @@ -1869,27 +1179,21 @@ void MPIIOMigrationCoProcessor::readDataSet(int step) if (arrPresence.isAverageDensityArrayPresent) readArray(step, AverageDensity, std::string("/cpAverageDensityArray.bin")); - // readAverageDensityArray(step); if (arrPresence.isAverageVelocityArrayPresent) readArray(step, AverageVelocity, std::string("/cpAverageVelocityArray.bin")); - // readAverageVelocityArray(step); if (arrPresence.isAverageFluktuationsArrayPresent) readArray(step, AverageFluktuations, std::string("/cpAverageFluktuationsArray.bin")); - // readAverageFluktuationsArray(step); if (arrPresence.isAverageTripleArrayPresent) readArray(step, AverageTriple, std::string("/cpAverageTripleArray.bin")); - // readAverageTripleArray(step); if (arrPresence.isShearStressValArrayPresent) readArray(step, ShearStressVal, std::string("/cpShearStressValArray.bin")); - // readShearStressValArray(step); if (arrPresence.isRelaxationFactorPresent) readArray(step, RelaxationFactor, std::string("/cpRelaxationFactor.bin")); - // readRelaxationFactor(step); if (arrPresence.isPhaseField1Present) readArray(step, PhaseField1, std::string("/cpPhaseField1.bin")); @@ -1897,6 +1201,9 @@ void MPIIOMigrationCoProcessor::readDataSet(int step) if (arrPresence.isPhaseField2Present) readArray(step, PhaseField2, std::string("/cpPhaseField2.bin")); + if (arrPresence.isPressureFieldPresent) + readArray(step, PressureField, std::string("/cpPressureField.bin")); + } void MPIIOMigrationCoProcessor::readArray(int step, Arrays arrType, std::string fname) @@ -2028,6 +1335,11 @@ void MPIIOMigrationCoProcessor::readArray(int step, Arrays arrType, std::string vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2])); block->getKernel()->getDataSet()->setPhaseField2(___3DArray); break; + case PressureField: + ___3DArray = CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>( + vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2])); + block->getKernel()->getDataSet()->setPressureField(___3DArray); + break; default: UB_THROW(UbException(UB_EXARGS, "MPIIOMigrationCoProcessor::readArray : array type does not exist!")); break; @@ -2043,636 +1355,6 @@ void MPIIOMigrationCoProcessor::readArray(int step, Arrays arrType, std::string delete[] dataSetSmallArray; } -/*void MPIIOMigrationCoProcessor::readAverageDensityArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageDensityArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageDensityArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - size_t blocksCount = 0; - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - - // read from the grid the blocks, that belong to this process - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - size_t doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * -dataSetParamStr.nx[3]; std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all -blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - size_t ic = 0; - MPI_Offset read_offset; - size_t sizeofOneDataSet = size_t(sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double)); - - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - read_offset = (MPI_Offset)(sizeof(dataSetParam) + block->getGlobalID() * sizeofOneDataSet); - MPI_File_read_at(file_handler, read_offset, &dataSetSmallArray[ic], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[ic -* doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); ic++; - } - } - - MPI_File_close(&file_handler); - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageDensityArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageDensityArray start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - size_t index = 0; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * -dataSetParamStr.nx[3]; std::vector<double> vectorsOfValues; for (int n = 0; n < blocksCount; n++) - { - vectorsOfValues.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + nextVectorSize); - index += nextVectorSize; - - // fill mAverageDensity arrays - SPtr<AverageValuesArray3D> mAverageDensity; - //if -((dataSetParamStr.nx[0]==0)&&(dataSetParamStr.nx[1]==0)&&(dataSetParamStr.nx[2]==0)&&(dataSetParamStr.nx[3]==0)) - // mAverageDensity = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(); - //else - mAverageDensity = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, -IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], -dataSetParamStr.nx[3])); - - //std::cout << "rank=" << rank << ", dataSetArray[n].globalID=" << dataSetSmallArray[n].globalID << std::endl; - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetSmallArray[n].globalID); - block->getKernel()->getDataSet()->setAverageDensity(mAverageDensity); - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageDensityArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::readAverageVelocityArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageVelocityArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageVelocityArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - size_t blocksCount = 0; - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - - // read from the grid the blocks, that belong to this process - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - size_t doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * -dataSetParamStr.nx[3]; std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all -blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - size_t ic = 0; - MPI_Offset read_offset; - size_t sizeofOneDataSet = size_t(sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double)); - - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - read_offset = (MPI_Offset)(sizeof(dataSetParam) + block->getGlobalID() * sizeofOneDataSet); - MPI_File_read_at(file_handler, read_offset, &dataSetSmallArray[ic], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[ic -* doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); ic++; - } - } - - MPI_File_close(&file_handler); - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageVelocityArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageVelocityArray start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - size_t index = 0; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * -dataSetParamStr.nx[3]; std::vector<double> vectorsOfValues; for (int n = 0; n < blocksCount; n++) - { - vectorsOfValues.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + nextVectorSize); - index += nextVectorSize; - - // fill mAverageVelocity array - SPtr<AverageValuesArray3D> mAverageVelocity; - //if ((dataSetParamStr.nx[0] == 0) && (dataSetParamStr.nx[1] == 0) && (dataSetParamStr.nx[2] == 0) && -(dataSetParamStr.nx[3] == 0)) - // mAverageVelocity = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(); - //else - mAverageVelocity = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, -IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], -dataSetParamStr.nx[3])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetSmallArray[n].globalID); - block->getKernel()->getDataSet()->setAverageVelocity(mAverageVelocity); - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageVelocityArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::readAverageFluktuationsArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageFluktuationsArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageFluktuationsArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - size_t blocksCount = 0; - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - - // read from the grid the blocks, that belong to this process - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - int doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * -dataSetParamStr.nx[3]; std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all -blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - size_t ic = 0; - MPI_Offset read_offset; - size_t sizeofOneDataSet = size_t(sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double)); - - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - read_offset = (MPI_Offset)(sizeof(dataSetParam) + block->getGlobalID() * sizeofOneDataSet); - MPI_File_read_at(file_handler, read_offset, &dataSetSmallArray[ic], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[ic -* doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); ic++; - } - } - - MPI_File_close(&file_handler); - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageFluktuationsArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageFluktuationsArray start of restore of data, rank = " << -rank); UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - size_t index = 0; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * -dataSetParamStr.nx[3]; std::vector<double> vectorsOfValues; for (int n = 0; n < blocksCount; n++) - { - vectorsOfValues.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + nextVectorSize); - index += nextVectorSize; - - // fill AverageFluktuations array - SPtr<AverageValuesArray3D> mAverageFluktuations; - //if ((dataSetParamStr.nx[0] == 0) && (dataSetParamStr.nx[1] == 0) && (dataSetParamStr.nx[2] == 0) && -(dataSetParamStr.nx[3] == 0)) - // mAverageFluktuations = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(); - //else - mAverageFluktuations = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, -IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], -dataSetParamStr.nx[3])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetSmallArray[n].globalID); - block->getKernel()->getDataSet()->setAverageFluctuations(mAverageFluktuations); - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageFluktuationsArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::readAverageTripleArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageTripleArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageTripleArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - size_t blocksCount = 0; - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - - // read from the grid the blocks, that belong to this process - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - size_t doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * -dataSetParamStr.nx[3]; std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all -blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - size_t ic = 0; - MPI_Offset read_offset; - size_t sizeofOneDataSet = size_t(sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double)); - - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - read_offset = (MPI_Offset)(sizeof(dataSetParam) + block->getGlobalID() * sizeofOneDataSet); - MPI_File_read_at(file_handler, read_offset, &dataSetSmallArray[ic], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[ic -* doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); ic++; - } - } - - MPI_File_close(&file_handler); - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageTripleArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageTripleArray start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - size_t index = 0; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * -dataSetParamStr.nx[3]; std::vector<double> vectorsOfValues; for (int n = 0; n < blocksCount; n++) - { - vectorsOfValues.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + nextVectorSize); - index += nextVectorSize; - - // fill AverageTriplecorrelations array - SPtr<AverageValuesArray3D> mAverageTriplecorrelations; - //if ((dataSetParamStr.nx[0] == 0) && (dataSetParamStr.nx[1] == 0) && (dataSetParamStr.nx[2] == 0) && -(dataSetParamStr.nx[3] == 0)) - // mAverageTriplecorrelations = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(); - //else - mAverageTriplecorrelations = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, -IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], -dataSetParamStr.nx[3])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetSmallArray[n].globalID); - block->getKernel()->getDataSet()->setAverageTriplecorrelations(mAverageTriplecorrelations); - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageTripleArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::readShearStressValArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readShearStressValArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpShearStressValArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - size_t blocksCount = 0; - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - - // read from the grid the blocks, that belong to this process - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - size_t doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * -dataSetParamStr.nx[3]; std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all -blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - size_t ic = 0; - MPI_Offset read_offset; - size_t sizeofOneDataSet = size_t(sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double)); - - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - read_offset = (MPI_Offset)(sizeof(dataSetParam) + block->getGlobalID() * sizeofOneDataSet); - MPI_File_read_at(file_handler, read_offset, &dataSetSmallArray[ic], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[ic -* doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); ic++; - } - } - - MPI_File_close(&file_handler); - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readShearStressValArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readShearStressValArray start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - size_t index = 0; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * -dataSetParamStr.nx[3]; std::vector<double> vectorsOfValues; for (int n = 0; n < blocksCount; n++) - { - vectorsOfValues.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + nextVectorSize); - index += nextVectorSize; - - // fill ShearStressValuesArray array - SPtr<ShearStressValuesArray3D> mShearStressValues; - //if ((dataSetParamStr.nx[0] == 0) && (dataSetParamStr.nx[1] == 0) && (dataSetParamStr.nx[2] == 0) && -(dataSetParamStr.nx[3] == 0)) - // mShearStressValues = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(); - //else - mShearStressValues = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, -IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], -dataSetParamStr.nx[3])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetSmallArray[n].globalID); - block->getKernel()->getDataSet()->setShearStressValues(mShearStressValues); - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readShearStressValArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::readRelaxationFactor(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readRelaxationFactor start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpRelaxationFactor.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - size_t blocksCount = 0; - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - - // read from the grid the blocks, that belong to this process - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - size_t doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * -dataSetParamStr.nx[3]; std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all -blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - size_t ic = 0; - MPI_Offset read_offset; - size_t sizeofOneDataSet = size_t(sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double)); - - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - read_offset = (MPI_Offset)(sizeof(dataSetParam) + block->getGlobalID() * sizeofOneDataSet); - MPI_File_read_at(file_handler, read_offset, &dataSetSmallArray[ic], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[ic -* doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); ic++; - } - } - - MPI_File_close(&file_handler); - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readRelaxationFactor time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readRelaxationFactor start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - size_t index = 0; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * -dataSetParamStr.nx[3]; std::vector<double> vectorsOfValues; for (int n = 0; n < blocksCount; n++) - { - vectorsOfValues.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + nextVectorSize); - index += nextVectorSize; - - // fill RelaxationFactor array - SPtr<RelaxationFactorArray3D> mRelaxationFactor; - //if ((dataSetParamStr.nx[0] == 0) && (dataSetParamStr.nx[1] == 0) && (dataSetParamStr.nx[2] == 0)) - // mRelaxationFactor = CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(); - //else - mRelaxationFactor = CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, -IndexerX3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetSmallArray[n].globalID); - block->getKernel()->getDataSet()->setRelaxationFactor(mRelaxationFactor); - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readRelaxationFactor end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / -1073741824.0 << " GB"); - } - - delete[] dataSetSmallArray; -} -*/ - void MPIIOMigrationCoProcessor::readBoundaryConds(int step) { int rank, size; @@ -2778,11 +1460,7 @@ void MPIIOMigrationCoProcessor::readBoundaryConds(int step) bc->bcVelocityX2 = bcArray[ibc].bcVelocityX2; bc->bcVelocityX3 = bcArray[ibc].bcVelocityX3; bc->bcDensity = bcArray[ibc].bcDensity; - bc->bcLodiDensity = bcArray[ibc].bcLodiDensity; - bc->bcLodiVelocityX1 = bcArray[ibc].bcLodiVelocityX1; - bc->bcLodiVelocityX2 = bcArray[ibc].bcLodiVelocityX2; - bc->bcLodiVelocityX3 = bcArray[ibc].bcLodiVelocityX3; - bc->bcLodiLentgh = bcArray[ibc].bcLodiLentgh; + bc->bcPhaseField = bcArray[ibc].bcPhaseField; bc->nx1 = bcArray[ibc].nx1; bc->nx2 = bcArray[ibc].nx2; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.h index ca0de8f3e7ba315bc8a870f89063ea9f38d7b59f..b2a0b029db37c4b1c6b81bf206316b03d36ab01b 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.h @@ -12,6 +12,7 @@ class UbScheduler; class Communicator; class BCProcessor; class LBMKernel; +class Grid3DVisitor; //! \class MPIWriteBlocksCoProcessor //! \brief Writes the grid each timestep into the files and reads the grip from the files before regenerating @@ -26,10 +27,11 @@ public: ShearStressVal = 5, RelaxationFactor = 6, PhaseField1 = 7, - PhaseField2 = 8 + PhaseField2 = 8, + PressureField = 9 }; - MPIIOMigrationCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, SPtr<Communicator> comm); + MPIIOMigrationCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<Grid3DVisitor> mV, const std::string &path, SPtr<Communicator> comm); ~MPIIOMigrationCoProcessor() override; //! Each timestep writes the grid into the files void process(double step) override; @@ -84,6 +86,7 @@ private: SPtr<LBMKernel> lbmKernel; SPtr<BCProcessor> bcProcessor; // double nue; + SPtr<Grid3DVisitor> metisVisitor; }; #endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.cpp index 036fea0c780bf2a74b22789ee6e0cb605ddbd065..4f7abd24116767d3fc73cedb6399d0bfbf4e0ace 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.cpp @@ -140,7 +140,7 @@ void MPIIORestartCoProcessor::writeDataSet(int step) DataSetRestart *dataSetArray = new DataSetRestart[blocksCount]; std::vector<double> doubleValuesArrayF; // double-values (arrays of f's) in all blocks Fdistribution std::vector<double> doubleValuesArrayH1; // double-values (arrays of f's) in all blocks H1distribution - // std::vector<double> doubleValuesArrayH2; // double-values (arrays of f's) in all blocks H2distribution + std::vector<double> doubleValuesArrayH2; // double-values (arrays of f's) in all blocks H2distribution if (comm->isRoot()) { @@ -148,7 +148,8 @@ void MPIIORestartCoProcessor::writeDataSet(int step) UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); } - bool multiPhase = false; + bool multiPhase1 = false; + bool multiPhase2 = false; DSArraysPresence arrPresence; bool firstBlock = true; int doubleCountInBlock = 0; @@ -188,36 +189,40 @@ void MPIIORestartCoProcessor::writeDataSet(int step) D3Q27EsoTwist3DSplittedVectorPtrH1 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(block->getKernel()->getDataSet()->getHdistributions()); if (D3Q27EsoTwist3DSplittedVectorPtrH1 != 0) { - multiPhase = true; + multiPhase1 = true; localDistributionsH1 = D3Q27EsoTwist3DSplittedVectorPtrH1->getLocalDistributions(); nonLocalDistributionsH1 = D3Q27EsoTwist3DSplittedVectorPtrH1->getNonLocalDistributions(); zeroDistributionsH1 = D3Q27EsoTwist3DSplittedVectorPtrH1->getZeroDistributions(); } - /*D3Q27EsoTwist3DSplittedVectorPtrH2 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(block->getKernel()->getDataSet()->getH2distributions()); + D3Q27EsoTwist3DSplittedVectorPtrH2 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(block->getKernel()->getDataSet()->getH2distributions()); if (D3Q27EsoTwist3DSplittedVectorPtrH2 != 0) { + multiPhase2 = true; localDistributionsH2 = D3Q27EsoTwist3DSplittedVectorPtrH2->getLocalDistributions(); nonLocalDistributionsH2 = D3Q27EsoTwist3DSplittedVectorPtrH2->getNonLocalDistributions(); zeroDistributionsH2 = D3Q27EsoTwist3DSplittedVectorPtrH2->getZeroDistributions(); - }*/ + } if (firstBlock) // when first (any) valid block... { - if (localDistributionsF) { + if (localDistributionsF) + { dataSetParamStr1.nx[0] = static_cast<int>(localDistributionsF->getNX1()); dataSetParamStr1.nx[1] = static_cast<int>(localDistributionsF->getNX2()); dataSetParamStr1.nx[2] = static_cast<int>(localDistributionsF->getNX3()); dataSetParamStr1.nx[3] = static_cast<int>(localDistributionsF->getNX4()); } - if (nonLocalDistributionsF) { + if (nonLocalDistributionsF) + { dataSetParamStr2.nx[0] = static_cast<int>(nonLocalDistributionsF->getNX1()); dataSetParamStr2.nx[1] = static_cast<int>(nonLocalDistributionsF->getNX2()); dataSetParamStr2.nx[2] = static_cast<int>(nonLocalDistributionsF->getNX3()); dataSetParamStr2.nx[3] = static_cast<int>(nonLocalDistributionsF->getNX4()); } - if (zeroDistributionsF) { + if (zeroDistributionsF) + { dataSetParamStr3.nx[0] = static_cast<int>(zeroDistributionsF->getNX1()); dataSetParamStr3.nx[1] = static_cast<int>(zeroDistributionsF->getNX2()); dataSetParamStr3.nx[2] = static_cast<int>(zeroDistributionsF->getNX3()); @@ -291,7 +296,7 @@ void MPIIORestartCoProcessor::writeDataSet(int step) if (zeroDistributionsF && (dataSetParamStr3.nx[0] > 0) && (dataSetParamStr3.nx[1] > 0) && (dataSetParamStr3.nx[2] > 0)) doubleValuesArrayF.insert(doubleValuesArrayF.end(), zeroDistributionsF->getDataVector().begin(), zeroDistributionsF->getDataVector().end()); - if (multiPhase) + if (multiPhase1) { if (localDistributionsH1 && (dataSetParamStr1.nx[0] > 0) && (dataSetParamStr1.nx[1] > 0) && (dataSetParamStr1.nx[2] > 0) && (dataSetParamStr1.nx[3] > 0)) doubleValuesArrayH1.insert(doubleValuesArrayH1.end(), localDistributionsH1->getDataVector().begin(), localDistributionsH1->getDataVector().end()); @@ -300,15 +305,17 @@ void MPIIORestartCoProcessor::writeDataSet(int step) if (zeroDistributionsH1 && (dataSetParamStr3.nx[0] > 0) && (dataSetParamStr3.nx[1] > 0) && (dataSetParamStr3.nx[2] > 0)) doubleValuesArrayH1.insert(doubleValuesArrayH1.end(), zeroDistributionsH1->getDataVector().begin(), zeroDistributionsH1->getDataVector().end()); } - - /*if (localDistributionsH2 && (dataSetParamStr1.nx[0] > 0) && (dataSetParamStr1.nx[1] > 0) && (dataSetParamStr1.nx[2] > 0) && (dataSetParamStr1.nx[3] > 0)) - doubleValuesArrayH2.insert(doubleValuesArrayH2.end(), localDistributionsH2->getDataVector().begin(), localDistributionsH2->getDataVector().end()); - if (nonLocalDistributionsH2 && (dataSetParamStr2.nx[0] > 0) && (dataSetParamStr2.nx[1] > 0) && (dataSetParamStr2.nx[2] > 0) && (dataSetParamStr2.nx[3] > 0)) - doubleValuesArrayH2.insert(doubleValuesArrayH2.end(), nonLocalDistributionsH2->getDataVector().begin(), nonLocalDistributionsH2->getDataVector().end()); - if (zeroDistributionsH2 && (dataSetParamStr3.nx[0] > 0) && (dataSetParamStr3.nx[1] > 0) && (dataSetParamStr3.nx[2] > 0)) - doubleValuesArrayH2.insert(doubleValuesArrayH2.end(), zeroDistributionsH2->getDataVector().begin(), zeroDistributionsH2->getDataVector().end());*/ - - ic++; + if (multiPhase2) + { + if (localDistributionsH2 && (dataSetParamStr1.nx[0] > 0) && (dataSetParamStr1.nx[1] > 0) && (dataSetParamStr1.nx[2] > 0) && (dataSetParamStr1.nx[3] > 0)) + doubleValuesArrayH2.insert(doubleValuesArrayH2.end(), localDistributionsH2->getDataVector().begin(), localDistributionsH2->getDataVector().end()); + if (nonLocalDistributionsH2 && (dataSetParamStr2.nx[0] > 0) && (dataSetParamStr2.nx[1] > 0) && (dataSetParamStr2.nx[2] > 0) && (dataSetParamStr2.nx[3] > 0)) + doubleValuesArrayH2.insert(doubleValuesArrayH2.end(), nonLocalDistributionsH2->getDataVector().begin(), nonLocalDistributionsH2->getDataVector().end()); + if (zeroDistributionsH2 && (dataSetParamStr3.nx[0] > 0) && (dataSetParamStr3.nx[1] > 0) && (dataSetParamStr3.nx[2] > 0)) + doubleValuesArrayH2.insert(doubleValuesArrayH2.end(), zeroDistributionsH2->getDataVector().begin(), zeroDistributionsH2->getDataVector().end()); + } + + ic++; } } @@ -379,7 +386,7 @@ void MPIIORestartCoProcessor::writeDataSet(int step) MPI_File_close(&file_handler); //------------------------------------------------------------------------------------------------------------------ - if (multiPhase) + if (multiPhase1) { filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetH1.bin"; rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); @@ -394,20 +401,23 @@ void MPIIORestartCoProcessor::writeDataSet(int step) MPI_File_close(&file_handler); } - //-------------------------------------------------------------------------------------------------------------------- - /*filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetH2.bin"; - rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) - throw UbException(UB_EXARGS, "couldn't open file " + filename); + //-------------------------------------------------------------------------------------------------------------------- + if (multiPhase2) + { + filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetH2.bin"; + rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); + if (rc != MPI_SUCCESS) + throw UbException(UB_EXARGS, "couldn't open file " + filename); - // each process writes the dataSet arrays - if (doubleValuesArrayH1.size() > 0) - MPI_File_write_at(file_handler, write_offset, &doubleValuesArrayH2[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); + // each process writes the dataSet arrays + if (doubleValuesArrayH2.size() > 0) + MPI_File_write_at(file_handler, write_offset, &doubleValuesArrayH2[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); - MPI_File_sync(file_handler); - MPI_File_close(&file_handler);*/ + MPI_File_sync(file_handler); + MPI_File_close(&file_handler); + } + //------------------------------------------------------------------------------------------------------------------------ - //-------------------------------- MPI_Type_free(&dataSetDoubleType); delete[] dataSetArray; @@ -1479,11 +1489,7 @@ void MPIIORestartCoProcessor::writeBoundaryConds(int step) bouCond->bcVelocityX2 = (float)bcArr->bcvector[bc]->getBoundaryVelocityX2(); bouCond->bcVelocityX3 = (float)bcArr->bcvector[bc]->getBoundaryVelocityX3(); bouCond->bcDensity = (float)bcArr->bcvector[bc]->getBoundaryDensity(); - bouCond->bcLodiDensity = (float)bcArr->bcvector[bc]->getDensityLodiDensity(); - bouCond->bcLodiVelocityX1 = (float)bcArr->bcvector[bc]->getDensityLodiVelocityX1(); - bouCond->bcLodiVelocityX2 = (float)bcArr->bcvector[bc]->getDensityLodiVelocityX2(); - bouCond->bcLodiVelocityX3 = (float)bcArr->bcvector[bc]->getDensityLodiVelocityX3(); - bouCond->bcLodiLentgh = (float)bcArr->bcvector[bc]->getDensityLodiLength(); + bouCond->bcPhaseField = (float)bcArr->bcvector[bc]->getBoundaryPhaseField(); bouCond->nx1 = (float)bcArr->bcvector[bc]->nx1; bouCond->nx2 = (float)bcArr->bcvector[bc]->nx2; bouCond->nx3 = (float)bcArr->bcvector[bc]->nx3; @@ -1665,7 +1671,8 @@ void MPIIORestartCoProcessor::readDataSet(int step) // calculate the read offset MPI_Offset read_offset = (MPI_Offset)(size * sizeof(int)); size_t next_read_offset = 0; - bool multiPhase = false; + bool multiPhase1 = false; + bool multiPhase2 = false; // read count of blocks int blocksCount = 0; @@ -1682,7 +1689,7 @@ void MPIIORestartCoProcessor::readDataSet(int step) dataSetParamStr3.nx[0] * dataSetParamStr3.nx[1] * dataSetParamStr3.nx[2] * dataSetParamStr3.nx[3]; std::vector<double> doubleValuesArrayF(size_t(blocksCount * doubleCountInBlock)); // double-values in all blocks Fdistributions std::vector<double> doubleValuesArrayH1; // double-values in all blocks H1distributions - //std::vector<double> doubleValuesArrayH2; // double-values in all blocks H2distributions + std::vector<double> doubleValuesArrayH2; // double-values in all blocks H2distributions // define MPI_types depending on the block-specific information MPI_Type_contiguous(int(doubleCountInBlock), MPI_DOUBLE, &dataSetDoubleType); @@ -1718,21 +1725,27 @@ void MPIIORestartCoProcessor::readDataSet(int step) MPI_File_get_size(file_handler, &fsize); if (fsize > 0) { - multiPhase = true; + multiPhase1 = true; doubleValuesArrayH1.resize(blocksCount * doubleCountInBlock); MPI_File_read_at(file_handler, read_offset, &doubleValuesArrayH1[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); } MPI_File_close(&file_handler); //-------------------------------------- H2 ----------------------------- - /*filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetH2.bin"; + filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetH2.bin"; rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - doubleValuesArrayH2.resize(blocksCount * doubleCountInBlock); - MPI_File_read_at(file_handler, read_offset, &doubleValuesArrayH2[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); - MPI_File_close(&file_handler);*/ + MPI_File_get_size(file_handler, &fsize); + if (fsize > 0) + { + multiPhase2 = true; + doubleValuesArrayH2.resize(blocksCount * doubleCountInBlock); + MPI_File_read_at(file_handler, read_offset, &doubleValuesArrayH2[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); + } + MPI_File_close(&file_handler); + //------------------------------------------------------------------- MPI_Type_free(&dataSetDoubleType); @@ -1747,7 +1760,7 @@ void MPIIORestartCoProcessor::readDataSet(int step) size_t index = 0; std::vector<double> vectorsOfValuesF1, vectorsOfValuesF2, vectorsOfValuesF3; std::vector<double> vectorsOfValuesH11, vectorsOfValuesH12, vectorsOfValuesH13; - //std::vector<double> vectorsOfValuesH21, vectorsOfValuesH22, vectorsOfValuesH23; + std::vector<double> vectorsOfValuesH21, vectorsOfValuesH22, vectorsOfValuesH23; size_t vectorSize1 = dataSetParamStr1.nx[0] * dataSetParamStr1.nx[1] * dataSetParamStr1.nx[2] * dataSetParamStr1.nx[3]; size_t vectorSize2 = dataSetParamStr2.nx[0] * dataSetParamStr2.nx[1] * dataSetParamStr2.nx[2] * dataSetParamStr2.nx[3]; size_t vectorSize3 = dataSetParamStr3.nx[0] * dataSetParamStr3.nx[1] * dataSetParamStr3.nx[2] * dataSetParamStr3.nx[3]; @@ -1755,21 +1768,24 @@ void MPIIORestartCoProcessor::readDataSet(int step) for (int n = 0; n < blocksCount; n++) { vectorsOfValuesF1.assign(doubleValuesArrayF.data() + index, doubleValuesArrayF.data() + index + vectorSize1); - if (multiPhase) + if (multiPhase1) vectorsOfValuesH11.assign(doubleValuesArrayH1.data() + index, doubleValuesArrayH1.data() + index + vectorSize1); - //vectorsOfValuesH21.assign(doubleValuesArrayH2.data() + index, doubleValuesArrayH2.data() + index + vectorSize1); + if (multiPhase2) + vectorsOfValuesH21.assign(doubleValuesArrayH2.data() + index, doubleValuesArrayH2.data() + index + vectorSize1); index += vectorSize1; vectorsOfValuesF2.assign(doubleValuesArrayF.data() + index, doubleValuesArrayF.data() + index + vectorSize2); - if (multiPhase) + if (multiPhase1) vectorsOfValuesH12.assign(doubleValuesArrayH1.data() + index, doubleValuesArrayH1.data() + index + vectorSize2); - //vectorsOfValuesH22.assign(doubleValuesArrayH2.data() + index, doubleValuesArrayH2.data() + index + vectorSize2); + if (multiPhase2) + vectorsOfValuesH22.assign(doubleValuesArrayH2.data() + index, doubleValuesArrayH2.data() + index + vectorSize2); index += vectorSize2; vectorsOfValuesF3.assign(doubleValuesArrayF.data() + index, doubleValuesArrayF.data() + index + vectorSize3); - if (multiPhase) + if (multiPhase1) vectorsOfValuesH13.assign(doubleValuesArrayH1.data() + index, doubleValuesArrayH1.data() + index + vectorSize3); - //vectorsOfValuesH23.assign(doubleValuesArrayH2.data() + index, doubleValuesArrayH2.data() + index + vectorSize3); + if (multiPhase2) + vectorsOfValuesH23.assign(doubleValuesArrayH2.data() + index, doubleValuesArrayH2.data() + index + vectorSize3); index += vectorSize3; SPtr<DistributionArray3D> mFdistributions(new D3Q27EsoTwist3DSplittedVector()); @@ -1785,7 +1801,7 @@ void MPIIORestartCoProcessor::readDataSet(int step) dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setNX3(dataSetParamStr1.nx3); SPtr<DistributionArray3D> mH1distributions(new D3Q27EsoTwist3DSplittedVector()); - if (multiPhase) + if (multiPhase1) { dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH1distributions)->setLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr( new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValuesH11, dataSetParamStr1.nx[0], dataSetParamStr1.nx[1], dataSetParamStr1.nx[2], dataSetParamStr1.nx[3]))); @@ -1798,18 +1814,22 @@ void MPIIORestartCoProcessor::readDataSet(int step) dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH1distributions)->setNX2(dataSetParamStr1.nx2); dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH1distributions)->setNX3(dataSetParamStr1.nx3); } - /*SPtr<DistributionArray3D> mH2distributions(new D3Q27EsoTwist3DSplittedVector()); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr( - new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValuesH21, dataSetParamStr1.nx[0], dataSetParamStr1.nx[1], dataSetParamStr1.nx[2], dataSetParamStr1.nx[3]))); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNonLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr( - new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValuesH22, dataSetParamStr2.nx[0], dataSetParamStr2.nx[1], dataSetParamStr2.nx[2], dataSetParamStr2.nx[3]))); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setZeroDistributions(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>( - vectorsOfValuesH23, dataSetParamStr3.nx[0], dataSetParamStr3.nx[1], dataSetParamStr3.nx[2]))); - - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNX1(dataSetParamStr1.nx1); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNX2(dataSetParamStr1.nx2); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNX3(dataSetParamStr1.nx3);*/ - + + SPtr<DistributionArray3D> mH2distributions(new D3Q27EsoTwist3DSplittedVector()); + if (multiPhase2) + { + dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr( + new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValuesH21, dataSetParamStr1.nx[0], dataSetParamStr1.nx[1], dataSetParamStr1.nx[2], dataSetParamStr1.nx[3]))); + dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNonLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr( + new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValuesH22, dataSetParamStr2.nx[0], dataSetParamStr2.nx[1], dataSetParamStr2.nx[2], dataSetParamStr2.nx[3]))); + dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setZeroDistributions(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>( + vectorsOfValuesH23, dataSetParamStr3.nx[0], dataSetParamStr3.nx[1], dataSetParamStr3.nx[2]))); + + dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNX1(dataSetParamStr1.nx1); + dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNX2(dataSetParamStr1.nx2); + dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mH2distributions)->setNX3(dataSetParamStr1.nx3); + } + // find the nesessary block and fill it SPtr<Block3D> block = grid->getBlock(dataSetArray[n].x1, dataSetArray[n].x2, dataSetArray[n].x3, dataSetArray[n].level); @@ -1825,9 +1845,10 @@ void MPIIORestartCoProcessor::readDataSet(int step) SPtr<DataSet3D> dataSetPtr = SPtr<DataSet3D>(new DataSet3D()); dataSetPtr->setFdistributions(mFdistributions); - if (multiPhase) + if (multiPhase1) dataSetPtr->setHdistributions(mH1distributions); - //dataSetPtr->setH2distributions(mH2distributions); + if (multiPhase2) + dataSetPtr->setH2distributions(mH2distributions); kernel->setDataSet(dataSetPtr); block->setKernel(kernel); } @@ -2679,11 +2700,7 @@ void MPIIORestartCoProcessor::readBoundaryConds(int step) bc->bcVelocityX2 = bcArray[index].bcVelocityX2; bc->bcVelocityX3 = bcArray[index].bcVelocityX3; bc->bcDensity = bcArray[index].bcDensity; - bc->bcLodiDensity = bcArray[index].bcLodiDensity; - bc->bcLodiVelocityX1 = bcArray[index].bcLodiVelocityX1; - bc->bcLodiVelocityX2 = bcArray[index].bcLodiVelocityX2; - bc->bcLodiVelocityX3 = bcArray[index].bcLodiVelocityX3; - bc->bcLodiLentgh = bcArray[index].bcLodiLentgh; + bc->bcPhaseField = bcArray[ibc].bcPhaseField; bc->nx1 = bcArray[index].nx1; bc->nx2 = bcArray[index].nx2; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp index 27f25fbfe54f9a48f5ce1b8403c4ce640d4d18ae..700722238b8b8a1ca99ec86b06025e51fd0e258c 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp @@ -413,7 +413,7 @@ void TimeAveragedValuesCoProcessor::calculateAverageValues(double timeSteps) (*av)(Vz, ix1, ix2, ix3) = uz; } - // fluctuations + // mean fluctuations if ((options & Fluctuations) == Fluctuations) { uxx = (*af)(Vxx, ix1, ix2, ix3) / timeSteps; uyy = (*af)(Vyy, ix1, ix2, ix3) / timeSteps; @@ -431,7 +431,7 @@ void TimeAveragedValuesCoProcessor::calculateAverageValues(double timeSteps) } if ((options & Triplecorrelations) == Triplecorrelations) { - // triple-correlations + // mean triple-correlations (*at)(Vxxx, ix1, ix2, ix3) = (*at)(Vxxx, ix1, ix2, ix3) / timeSteps - 3.0 * uxx * ux + 2.0 * ux * ux * ux; (*at)(Vxxy, ix1, ix2, ix3) = (*at)(Vxxy, ix1, ix2, ix3) / timeSteps - diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMultiphaseQuantitiesCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMultiphaseQuantitiesCoProcessor.cpp index 73034d88996a3c22d8a3aa9e86517c5cbe92ffc3..37eb51038c535fb2d6769f9252928a97aff5916a 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMultiphaseQuantitiesCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMultiphaseQuantitiesCoProcessor.cpp @@ -145,7 +145,7 @@ void WriteMultiphaseQuantitiesCoProcessor::addDataMQ(SPtr<Block3D> block) { using namespace D3Q27System; using namespace UbMath; - + SPtr<LBMKernel> kernel = dynamicPointerCast<LBMKernel>(block->getKernel()); //double level = (double)block->getLevel(); // Diese Daten werden geschrieben: @@ -155,17 +155,24 @@ void WriteMultiphaseQuantitiesCoProcessor::addDataMQ(SPtr<Block3D> block) datanames.push_back("Vy"); datanames.push_back("Vz"); datanames.push_back("P1"); + datanames.push_back("Phi2"); + if (kernel->getDataSet()->getPressureField()) datanames.push_back("Pressure"); data.resize(datanames.size()); - SPtr<LBMKernel> kernel = dynamicPointerCast<LBMKernel>(block->getKernel()); + SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); SPtr<DistributionArray3D> distributionsF = kernel->getDataSet()->getFdistributions(); SPtr<DistributionArray3D> distributionsH = kernel->getDataSet()->getHdistributions(); + SPtr<DistributionArray3D> distributionsH2 = kernel->getDataSet()->getH2distributions(); SPtr<PhaseFieldArray3D> divU = kernel->getDataSet()->getPhaseField(); + SPtr<PressureFieldArray3D> pressure; + if (kernel->getDataSet()->getPressureField()) pressure = kernel->getDataSet()->getPressureField(); + LBMReal f[D3Q27System::ENDF + 1]; LBMReal phi[D3Q27System::ENDF + 1]; + LBMReal phi2[D3Q27System::ENDF + 1]; LBMReal vx1, vx2, vx3, rho, p1, beta, kappa; LBMReal densityRatio = kernel->getDensityRatio(); @@ -193,6 +200,13 @@ void WriteMultiphaseQuantitiesCoProcessor::addDataMQ(SPtr<Block3D> block) int minX1 = 0; int minX2 = 0; int minX3 = 0; + + if (kernel->getGhostLayerWidth() == 2) + { + minX1 = 1; + minX2 = 1; + minX3 = 1; + } // int maxX1 = (int)(distributions->getNX1()); // int maxX2 = (int)(distributions->getNX2()); @@ -202,6 +216,8 @@ void WriteMultiphaseQuantitiesCoProcessor::addDataMQ(SPtr<Block3D> block) CbArray3D<int> nodeNumbers((int)maxX1, (int)maxX2, (int)maxX3, -1); CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr phaseField( new CbArray3D<LBMReal, IndexerX3X2X1>(maxX1, maxX2, maxX3, -999.0)); + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr phaseField2( + new CbArray3D<LBMReal, IndexerX3X2X1>(maxX1, maxX2, maxX3, -999.0)); for (int ix3 = minX3; ix3 < maxX3; ix3++) { for (int ix2 = minX2; ix2 < maxX2; ix2++) { @@ -211,22 +227,36 @@ void WriteMultiphaseQuantitiesCoProcessor::addDataMQ(SPtr<Block3D> block) (*phaseField)(ix1, ix2, ix3) = ((f[TNE] + f[BSW]) + (f[TSE] + f[BNW])) + ((f[BSE] + f[TNW]) + (f[TSW] + f[BNE])) + (((f[NE] + f[SW]) + (f[SE] + f[NW])) + ((f[TE] + f[BW]) + (f[BE] + f[TW])) + - ((f[BN] + f[TS]) + (f[TN] + f[BS]))) + - ((f[E] + f[W]) + (f[N] + f[S]) + (f[T] + f[B])) + f[REST]; + ((f[BN] + f[TS]) + (f[TN] + f[BS]))) + + ((f[E] + f[W]) + (f[N] + f[S]) + (f[T] + f[B])) + f[REST]; + if (distributionsH2) { + distributionsH2->getDistribution(f, ix1, ix2, ix3); + (*phaseField2)(ix1, ix2, ix3) = + ((f[TNE] + f[BSW]) + (f[TSE] + f[BNW])) + ((f[BSE] + f[TNW]) + (f[TSW] + f[BNE])) + + (((f[NE] + f[SW]) + (f[SE] + f[NW])) + ((f[TE] + f[BW]) + (f[BE] + f[TW])) + + ((f[BN] + f[TS]) + (f[TN] + f[BS]))) + + ((f[E] + f[W]) + (f[N] + f[S]) + (f[T] + f[B])) + f[REST]; + } + else { (*phaseField2)(ix1, ix2, ix3) = 999.0; } + } } } } - maxX1 -= 2; - maxX2 -= 2; - maxX3 -= 2; - - // maxX1 -= 1; - // maxX2 -= 1; - // maxX3 -= 1; + if (kernel->getGhostLayerWidth() == 1) + { + maxX1 -= 2; + maxX2 -= 2; + maxX3 -= 2; + } + else if (kernel->getGhostLayerWidth() == 2) + { + maxX1 -= 3; + maxX2 -= 3; + maxX3 -= 3; + } - // D3Q27BoundaryConditionPtr bcPtr; int nr = (int)nodes.size(); LBMReal dX1_phi; LBMReal dX2_phi; @@ -244,6 +274,7 @@ void WriteMultiphaseQuantitiesCoProcessor::addDataMQ(SPtr<Block3D> block) float(worldCoordinates[2]))); phi[REST] = (*phaseField)(ix1, ix2, ix3); + phi2[REST] = (*phaseField2)(ix1, ix2, ix3); if ((ix1 == 0) || (ix2 == 0) || (ix3 == 0)) { dX1_phi = 0.0; @@ -284,6 +315,38 @@ void WriteMultiphaseQuantitiesCoProcessor::addDataMQ(SPtr<Block3D> block) dX2_phi = 0.0 * gradX2_phi(phi); dX3_phi = 0.0 * gradX3_phi(phi); mu = 2 * beta * phi[REST] * (phi[REST] - 1) * (2 * phi[REST] - 1) - kappa * nabla2_phi(phi); + + //phi2[E] = (*phaseField2)(ix1 + DX1[E], ix2 + DX2[E], ix3 + DX3[E]); + //phi2[N] = (*phaseField2)(ix1 + DX1[N], ix2 + DX2[N], ix3 + DX3[N]); + //phi2[T] = (*phaseField2)(ix1 + DX1[T], ix2 + DX2[T], ix3 + DX3[T]); + //phi2[W] = (*phaseField2)(ix1 + DX1[W], ix2 + DX2[W], ix3 + DX3[W]); + //phi2[S] = (*phaseField2)(ix1 + DX1[S], ix2 + DX2[S], ix3 + DX3[S]); + //phi2[B] = (*phaseField2)(ix1 + DX1[B], ix2 + DX2[B], ix3 + DX3[B]); + //phi2[NE] = (*phaseField2)(ix1 + DX1[NE], ix2 + DX2[NE], ix3 + DX3[NE]); + //phi2[NW] = (*phaseField2)(ix1 + DX1[NW], ix2 + DX2[NW], ix3 + DX3[NW]); + //phi2[TE] = (*phaseField2)(ix1 + DX1[TE], ix2 + DX2[TE], ix3 + DX3[TE]); + //phi2[TW] = (*phaseField2)(ix1 + DX1[TW], ix2 + DX2[TW], ix3 + DX3[TW]); + //phi2[TN] = (*phaseField2)(ix1 + DX1[TN], ix2 + DX2[TN], ix3 + DX3[TN]); + //phi2[TS] = (*phaseField2)(ix1 + DX1[TS], ix2 + DX2[TS], ix3 + DX3[TS]); + //phi2[SW] = (*phaseField2)(ix1 + DX1[SW], ix2 + DX2[SW], ix3 + DX3[SW]); + //phi2[SE] = (*phaseField2)(ix1 + DX1[SE], ix2 + DX2[SE], ix3 + DX3[SE]); + //phi2[BW] = (*phaseField2)(ix1 + DX1[BW], ix2 + DX2[BW], ix3 + DX3[BW]); + //phi2[BE] = (*phaseField2)(ix1 + DX1[BE], ix2 + DX2[BE], ix3 + DX3[BE]); + //phi2[BS] = (*phaseField2)(ix1 + DX1[BS], ix2 + DX2[BS], ix3 + DX3[BS]); + //phi2[BN] = (*phaseField2)(ix1 + DX1[BN], ix2 + DX2[BN], ix3 + DX3[BN]); + //phi2[BSW] = (*phaseField2)(ix1 + DX1[BSW], ix2 + DX2[BSW], ix3 + DX3[BSW]); + //phi2[BSE] = (*phaseField2)(ix1 + DX1[BSE], ix2 + DX2[BSE], ix3 + DX3[BSE]); + //phi2[BNW] = (*phaseField2)(ix1 + DX1[BNW], ix2 + DX2[BNW], ix3 + DX3[BNW]); + //phi2[BNE] = (*phaseField2)(ix1 + DX1[BNE], ix2 + DX2[BNE], ix3 + DX3[BNE]); + //phi2[TNE] = (*phaseField2)(ix1 + DX1[TNE], ix2 + DX2[TNE], ix3 + DX3[TNE]); + //phi2[TNW] = (*phaseField2)(ix1 + DX1[TNW], ix2 + DX2[TNW], ix3 + DX3[TNW]); + //phi2[TSE] = (*phaseField2)(ix1 + DX1[TSE], ix2 + DX2[TSE], ix3 + DX3[TSE]); + //phi2[TSW] = (*phaseField2)(ix1 + DX1[TSW], ix2 + DX2[TSW], ix3 + DX3[TSW]); + + // mu = 2 * beta * phi[REST] * (phi[REST] - 1) * (2 * phi[REST] - 1) - kappa * nabla2_phi(phi); + + + } distributionsF->getDistribution(f, ix1, ix2, ix3); @@ -297,23 +360,40 @@ void WriteMultiphaseQuantitiesCoProcessor::addDataMQ(SPtr<Block3D> block) // rho = phi[ZERO] + (1.0 - phi[ZERO])*1.0/densityRatio; rho = rhoH + rhoToPhi * (phi[REST] - phiH); - vx1 = - ((((f[TNE] - f[BSW]) + (f[TSE] - f[BNW])) + ((f[BSE] - f[TNW]) + (f[BNE] - f[TSW]))) + - (((f[BE] - f[TW]) + (f[TE] - f[BW])) + ((f[SE] - f[NW]) + (f[NE] - f[SW]))) + (f[E] - f[W])) / - (rho * c1o3) + - mu * dX1_phi / (2 * rho); + if (pressure) { + vx1 = + ((((f[TNE] - f[BSW]) + (f[TSE] - f[BNW])) + ((f[BSE] - f[TNW]) + (f[BNE] - f[TSW]))) + + (((f[BE] - f[TW]) + (f[TE] - f[BW])) + ((f[SE] - f[NW]) + (f[NE] - f[SW]))) + (f[E] - f[W])) ; + + vx2 = + ((((f[TNE] - f[BSW]) + (f[BNW] - f[TSE])) + ((f[TNW] - f[BSE]) + (f[BNE] - f[TSW]))) + + (((f[BN] - f[TS]) + (f[TN] - f[BS])) + ((f[NW] - f[SE]) + (f[NE] - f[SW]))) + (f[N] - f[S])) ; - vx2 = - ((((f[TNE] - f[BSW]) + (f[BNW] - f[TSE])) + ((f[TNW] - f[BSE]) + (f[BNE] - f[TSW]))) + - (((f[BN] - f[TS]) + (f[TN] - f[BS])) + ((f[NW] - f[SE]) + (f[NE] - f[SW]))) + (f[N] - f[S])) / - (rho * c1o3) + - mu * dX2_phi / (2 * rho); + vx3 = + ((((f[TNE] - f[BSW]) + (f[TSE] - f[BNW])) + ((f[TNW] - f[BSE]) + (f[TSW] - f[BNE]))) + + (((f[TS] - f[BN]) + (f[TN] - f[BS])) + ((f[TW] - f[BE]) + (f[TE] - f[BW]))) + (f[T] - f[B])); - vx3 = - ((((f[TNE] - f[BSW]) + (f[TSE] - f[BNW])) + ((f[TNW] - f[BSE]) + (f[TSW] - f[BNE]))) + - (((f[TS] - f[BN]) + (f[TN] - f[BS])) + ((f[TW] - f[BE]) + (f[TE] - f[BW]))) + (f[T] - f[B])) / - (rho * c1o3) + - mu * dX3_phi / (2 * rho); + } + else { + vx1 = + ((((f[TNE] - f[BSW]) + (f[TSE] - f[BNW])) + ((f[BSE] - f[TNW]) + (f[BNE] - f[TSW]))) + + (((f[BE] - f[TW]) + (f[TE] - f[BW])) + ((f[SE] - f[NW]) + (f[NE] - f[SW]))) + (f[E] - f[W])) / + (rho * c1o3) + + mu * dX1_phi / (2 * rho); + + vx2 = + ((((f[TNE] - f[BSW]) + (f[BNW] - f[TSE])) + ((f[TNW] - f[BSE]) + (f[BNE] - f[TSW]))) + + (((f[BN] - f[TS]) + (f[TN] - f[BS])) + ((f[NW] - f[SE]) + (f[NE] - f[SW]))) + (f[N] - f[S])) / + (rho * c1o3) + + mu * dX2_phi / (2 * rho); + + vx3 = + ((((f[TNE] - f[BSW]) + (f[TSE] - f[BNW])) + ((f[TNW] - f[BSE]) + (f[TSW] - f[BNE]))) + + (((f[TS] - f[BN]) + (f[TN] - f[BS])) + ((f[TW] - f[BE]) + (f[TE] - f[BW]))) + (f[T] - f[B])) / + (rho * c1o3) + + mu * dX3_phi / (2 * rho); + + } p1 = (((f[TNE] + f[BSW]) + (f[TSE] + f[BNW])) + ((f[BSE] + f[TNW]) + (f[TSW] + f[BNE])) + (((f[NE] + f[SW]) + (f[SE] + f[NW])) + ((f[TE] + f[BW]) + (f[BE] + f[TW])) + @@ -361,6 +441,8 @@ void WriteMultiphaseQuantitiesCoProcessor::addDataMQ(SPtr<Block3D> block) data[index++].push_back(vx2); data[index++].push_back(vx3); data[index++].push_back(p1); + data[index++].push_back(phi2[REST]); + if (pressure) data[index++].push_back((*pressure)(ix1, ix2, ix3)); } } } diff --git a/src/cpu/VirtualFluidsCore/Connectors/FullDirectConnector.h b/src/cpu/VirtualFluidsCore/Connectors/FullDirectConnector.h index fb04de68aaa4ab360e38ae83c9d47d077c05e59f..81984eee943bf2548a4c8f49527f9a41178d5f71 100644 --- a/src/cpu/VirtualFluidsCore/Connectors/FullDirectConnector.h +++ b/src/cpu/VirtualFluidsCore/Connectors/FullDirectConnector.h @@ -49,7 +49,7 @@ public: protected: virtual void updatePointers() = 0; - void exchangeData(); + virtual void exchangeData(); virtual void exchangeData(int x1From, int x2From, int x3From, int x1To, int x2To, int x3To) = 0; int maxX1; diff --git a/src/cpu/VirtualFluidsCore/Connectors/FullVectorConnector.h b/src/cpu/VirtualFluidsCore/Connectors/FullVectorConnector.h index 39fc3d1afa3fb958b09d128bd67a5aca42acbc03..802a91290cfc0994e1ef2ae33fce78c6a6a4964e 100644 --- a/src/cpu/VirtualFluidsCore/Connectors/FullVectorConnector.h +++ b/src/cpu/VirtualFluidsCore/Connectors/FullVectorConnector.h @@ -56,8 +56,8 @@ public: protected: virtual void updatePointers() = 0; - void fillData(); - void distributeData(); + virtual void fillData(); + virtual void distributeData(); virtual void fillData(vector_type &sdata, int &index, int x1, int x2, int x3) = 0; virtual void distributeData(vector_type &rdata, int &index, int x1, int x2, int x3) = 0; diff --git a/src/cpu/VirtualFluidsCore/Connectors/ThreeDistributionsDoubleGhostLayerFullDirectConnector.cpp b/src/cpu/VirtualFluidsCore/Connectors/ThreeDistributionsDoubleGhostLayerFullDirectConnector.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d0ff594f75efa3bfd12f1cbee9629f41e6f86dc3 --- /dev/null +++ b/src/cpu/VirtualFluidsCore/Connectors/ThreeDistributionsDoubleGhostLayerFullDirectConnector.cpp @@ -0,0 +1,317 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file ThreeDistributionsDoubleGhostLayerFullDirectConnector.cpp +//! \ingroup Connectors +//! \author Konstantin Kutscher +//======================================================================================= + +#include "ThreeDistributionsDoubleGhostLayerFullDirectConnector.h" +#include "LBMKernel.h" +#include "DataSet3D.h" + +ThreeDistributionsDoubleGhostLayerFullDirectConnector::ThreeDistributionsDoubleGhostLayerFullDirectConnector(SPtr<Block3D> from, SPtr<Block3D> to, int sendDir) + : FullDirectConnector(from, to, sendDir) +{ + +} +////////////////////////////////////////////////////////////////////////// +void ThreeDistributionsDoubleGhostLayerFullDirectConnector::init() +{ + FullDirectConnector::init(); + + fFrom =dynamicPointerCast<EsoTwist3D>(from.lock()->getKernel()->getDataSet()->getFdistributions()); + fTo = dynamicPointerCast<EsoTwist3D>(to.lock()->getKernel()->getDataSet()->getFdistributions()); + hFrom = dynamicPointerCast<EsoTwist3D>(from.lock()->getKernel()->getDataSet()->getHdistributions()); + hTo = dynamicPointerCast<EsoTwist3D>(to.lock()->getKernel()->getDataSet()->getHdistributions()); + hFrom2 = dynamicPointerCast<EsoTwist3D>(from.lock()->getKernel()->getDataSet()->getH2distributions()); + hTo2 = dynamicPointerCast<EsoTwist3D>(to.lock()->getKernel()->getDataSet()->getH2distributions()); + pressureFrom = from.lock()->getKernel()->getDataSet()->getPressureField(); + pressureTo = to.lock()->getKernel()->getDataSet()->getPressureField(); +} +////////////////////////////////////////////////////////////////////////// +void ThreeDistributionsDoubleGhostLayerFullDirectConnector::sendVectors() +{ + updatePointers(); + exchangeData(); +} +////////////////////////////////////////////////////////////////////////// +void ThreeDistributionsDoubleGhostLayerFullDirectConnector::exchangeData() +{ + //////////////////////////////////////////////////////////// + // relation between ghost layer and regular nodes + // maxX1m3 maxX1m2 ... minX1p2 minX1p3 - regular nodes + // minX1 minX1p1 ... maxX1m1 maxX1 - ghost layer + //////////////////////////////////////////////////////////// + + int minX1 = 0; + int minX1p1 = minX1 + 1; + int minX1p2 = minX1 + 2; + int minX1p3 = minX1 + 3; + int maxX1m1 = maxX1 - 1; + int maxX1m2 = maxX1 - 2; + int maxX1m3 = maxX1 - 3; + + int minX2 = 0; + int minX2p1 = minX2 + 1; + int minX2p2 = minX2 + 2; + int minX2p3 = minX2 + 3; + int maxX2m1 = maxX2 - 1; + int maxX2m2 = maxX2 - 2; + int maxX2m3 = maxX2 - 3; + + int minX3 = 0; + int minX3p1 = minX3 + 1; + int minX3p2 = minX3 + 2; + int minX3p3 = minX3 + 3; + int maxX3m1 = maxX3 - 1; + int maxX3m2 = maxX3 - 2; + int maxX3m3 = maxX3 - 3; + + // EAST + if (sendDir == D3Q27System::E) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + exchangeData(maxX1m3, x2, x3, minX1, x2, x3); + exchangeData(maxX1m2, x2, x3, minX1p1, x2, x3); + } + } + } + // WEST + else if (sendDir == D3Q27System::W) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + exchangeData(minX1p3, x2, x3, maxX1, x2, x3); + exchangeData(minX1p2, x2, x3, maxX1m1, x2, x3); + } + } + } + // NORTH + else if (sendDir == D3Q27System::N) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + exchangeData(x1, maxX2m3, x3, x1, minX2, x3); + exchangeData(x1, maxX2m2, x3, x1, minX2p1, x3); + } + } + } + // SOUTH + else if (sendDir == D3Q27System::S) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + exchangeData(x1, minX2p3, x3, x1, maxX2, x3); + exchangeData(x1, minX2p2, x3, x1, maxX2m1, x3); + } + } + } + + // TOP + else if (sendDir == D3Q27System::T) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + exchangeData(x1, x2, maxX3m3, x1, x2, minX3); + exchangeData(x1, x2, maxX3m2, x1, x2, minX3p1); + } + } + } + // BOTTOM + else if (sendDir == D3Q27System::B) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + exchangeData(x1, x2, minX3p3, x1, x2, maxX3); + exchangeData(x1, x2, minX3p2, x1, x2, maxX3m1); + } + } + } + // NORTHEAST + else if (sendDir == D3Q27System::NE) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + exchangeData(maxX1m3, maxX2m3, x3, minX1, minX2, x3); + exchangeData(maxX1m2, maxX2m2, x3, minX1p1, minX2p1, x3); + exchangeData(maxX1m3, maxX2m2, x3, minX1, minX2p1, x3); + exchangeData(maxX1m2, maxX2m3, x3, minX1p1, minX2, x3); + } + } + // NORTHWEST + else if (sendDir == D3Q27System::NW) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + exchangeData(minX1p3, maxX2m3, x3, maxX1, minX2, x3); + exchangeData(minX1p2, maxX2m2, x3, maxX1m1, minX2p1, x3); + exchangeData(minX1p3, maxX2m2, x3, maxX1, minX2p1, x3); + exchangeData(minX1p2, maxX2m3, x3, maxX1m1, minX2, x3); + } + } + // SOUTHWEST + else if (sendDir == D3Q27System::SW) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + exchangeData(minX1p3, minX2p3, x3, maxX1, maxX2, x3); + exchangeData(minX1p2, minX2p2, x3, maxX1m1, maxX2m1, x3); + exchangeData(minX1p3, minX2p2, x3, maxX1, maxX2m1, x3); + exchangeData(minX1p2, minX2p3, x3, maxX1m1, maxX2, x3); + } + } + // SOUTHEAST + else if (sendDir == D3Q27System::SE) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + exchangeData(maxX1m3, minX2p3, x3, minX1, maxX2, x3); + exchangeData(maxX1m2, minX2p2, x3, minX1p1, maxX2m1, x3); + exchangeData(maxX1m3, minX2p2, x3, minX1, maxX2m1, x3); + exchangeData(maxX1m2, minX2p3, x3, minX1p1, maxX2, x3); + } + } else if (sendDir == D3Q27System::TE) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + exchangeData(maxX1m3, x2, maxX3m3, minX1, x2, minX3); + exchangeData(maxX1m2, x2, maxX3m2, minX1p1, x2, minX3p1); + exchangeData(maxX1m3, x2, maxX3m2, minX1, x2, minX3p1); + exchangeData(maxX1m2, x2, maxX3m3, minX1p1, x2, minX3); + } + else if (sendDir == D3Q27System::BW) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + exchangeData(minX1p3, x2, minX3p3, maxX1, x2, maxX3); + exchangeData(minX1p2, x2, minX3p2, maxX1m1, x2, maxX3m1); + exchangeData(minX1p3, x2, minX3p2, maxX1, x2, maxX3m1); + exchangeData(minX1p2, x2, minX3p3, maxX1m1, x2, maxX3); + } + else if (sendDir == D3Q27System::BE) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + exchangeData(maxX1m3, x2, minX3p3, minX1, x2, maxX3); + exchangeData(maxX1m2, x2, minX3p2, minX1p1, x2, maxX3m1); + exchangeData(maxX1m3, x2, minX3p2, minX1, x2, maxX3m1); + exchangeData(maxX1m2, x2, minX3p3, minX1p1, x2, maxX3); + } + else if (sendDir == D3Q27System::TW) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + exchangeData(minX1p3, x2, maxX3m3, maxX1, x2, minX3); + exchangeData(minX1p2, x2, maxX3m2, maxX1m1, x2, minX3p1); + exchangeData(minX1p3, x2, maxX3m2, maxX1, x2, minX3p1); + exchangeData(minX1p2, x2, maxX3m3, maxX1m1, x2, minX3); + } + else if (sendDir == D3Q27System::TN) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + exchangeData(x1, maxX2m3, maxX3m3, x1, minX2, minX3); + exchangeData(x1, maxX2m2, maxX3m2, x1, minX2p1, minX3p1); + exchangeData(x1, maxX2m3, maxX3m2, x1, minX2, minX3p1); + exchangeData(x1, maxX2m2, maxX3m3, x1, minX2p1, minX3); + } + else if (sendDir == D3Q27System::BS) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + exchangeData(x1, minX2p3, minX3p3, x1, maxX2, maxX3); + exchangeData(x1, minX2p2, minX3p2, x1, maxX2m1, maxX3m1); + exchangeData(x1, minX2p3, minX3p2, x1, maxX2, maxX3m1); + exchangeData(x1, minX2p2, minX3p3, x1, maxX2m1, maxX3); + } + else if (sendDir == D3Q27System::BN) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + exchangeData(x1, maxX2m3, minX3p3, x1, minX2, maxX3); + exchangeData(x1, maxX2m2, minX3p2, x1, minX2p1, maxX3m1); + exchangeData(x1, maxX2m3, minX3p2, x1, minX2, maxX3m1); + exchangeData(x1, maxX2m2, minX3p3, x1, minX2p1, maxX3); + } + else if (sendDir == D3Q27System::TS) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + exchangeData(x1, minX2p3, maxX3m3, x1, maxX2, minX3); + exchangeData(x1, minX2p2, maxX3m2, x1, maxX2m1, minX3p1); + exchangeData(x1, minX2p3, maxX3m2, x1, maxX2, minX3p1); + exchangeData(x1, minX2p2, maxX3m3, x1, maxX2m1, minX3); + } + else if (sendDir == D3Q27System::TSW) { + exchangeData(minX1p3, minX2p3, maxX3m3, maxX1, maxX2, minX3); + exchangeData(minX1p2, minX2p2, maxX3m2, maxX1m1, maxX2m1, minX3p1); + exchangeData(minX1p3, minX2p2, maxX3m2, maxX1, maxX2m1, minX3p1); + exchangeData(minX1p2, minX2p3, maxX3m2, maxX1m1, maxX2, minX3p1); + exchangeData(minX1p2, minX2p2, maxX3m3, maxX1m1, maxX2m1, minX3); + exchangeData(minX1p3, minX2p3, maxX3m2, maxX1, maxX2, minX3p1); + exchangeData(minX1p3, minX2p2, maxX3m3, maxX1, maxX2m1, minX3); + exchangeData(minX1p2, minX2p3, maxX3m3, maxX1m1, maxX2, minX3); + } else if (sendDir == D3Q27System::TSE) { + exchangeData(maxX1m3, minX1p3, maxX3m3, minX1, maxX2, minX3); + exchangeData(maxX1m2, minX1p2, maxX3m2, minX1p1, maxX2m1, minX3p1); + exchangeData(maxX1m3, minX1p2, maxX3m2, minX1, maxX2m1, minX3p1); + exchangeData(maxX1m2, minX1p3, maxX3m2, minX1p1, maxX2, minX3p1); + exchangeData(maxX1m2, minX1p2, maxX3m3, minX1p1, maxX2m1, minX3); + exchangeData(maxX1m3, minX1p3, maxX3m2, minX1, maxX2, minX3p1); + exchangeData(maxX1m3, minX1p2, maxX3m3, minX1, maxX2m1, minX3); + exchangeData(maxX1m2, minX1p3, maxX3m3, minX1p1, maxX2, minX3); + } else if (sendDir == D3Q27System::TNW) { + exchangeData(minX1p3, maxX2m3, maxX3m3, maxX1, minX2, minX3); + exchangeData(minX1p2, maxX2m2, maxX3m2, maxX1m1, minX2p1, minX3p1); + exchangeData(minX1p3, maxX2m2, maxX3m2, maxX1, minX2p1, minX3p1); + exchangeData(minX1p2, maxX2m3, maxX3m2, maxX1m1, minX2, minX3p1); + exchangeData(minX1p2, maxX2m2, maxX3m3, maxX1m1, minX2p1, minX3); + exchangeData(minX1p3, maxX2m3, maxX3m2, maxX1, minX2, minX3p1); + exchangeData(minX1p3, maxX2m2, maxX3m3, maxX1, minX2p1, minX3); + exchangeData(minX1p2, maxX2m3, maxX3m3, maxX1m1, minX2, minX3); + } else if (sendDir == D3Q27System::TNE) { + exchangeData(maxX1m3, maxX2m3, maxX3m3, minX1, minX2, minX3); + exchangeData(maxX1m2, maxX2m2, maxX3m2, minX1p1, minX2p1, minX3p1); + exchangeData(maxX1m3, maxX2m2, maxX3m2, minX1, minX2p1, minX3p1); + exchangeData(maxX1m2, maxX2m3, maxX3m2, minX1p1, minX2, minX3p1); + exchangeData(maxX1m2, maxX2m2, maxX3m3, minX1p1, minX2p1, minX3); + exchangeData(maxX1m3, maxX2m3, maxX3m2, minX1, minX2, minX3p1); + exchangeData(maxX1m3, maxX2m2, maxX3m3, minX1, minX2p1, minX3); + exchangeData(maxX1m2, maxX2m3, maxX3m3, minX1p1, minX2, minX3); + } else if (sendDir == D3Q27System::BSW) { + exchangeData(minX1p3, minX2p3, minX3p3, maxX1, maxX2, maxX3); + exchangeData(minX1p2, minX2p2, minX3p2, maxX1m1, maxX2m1, maxX3m1); + exchangeData(minX1p3, minX2p2, minX3p2, maxX1, maxX2m1, maxX3m1); + exchangeData(minX1p2, minX2p3, minX3p2, maxX1m1, maxX2, maxX3m1); + exchangeData(minX1p2, minX2p2, minX3p3, maxX1m1, maxX2m1, maxX3); + exchangeData(minX1p3, minX2p3, minX3p2, maxX1, maxX2, maxX3m1); + exchangeData(minX1p3, minX2p2, minX3p3, maxX1, maxX2m1, maxX3); + exchangeData(minX1p2, minX2p3, minX3p3, maxX1m1, maxX2, maxX3); + } else if (sendDir == D3Q27System::BSE) { + exchangeData(maxX1m3, minX2p3, minX3p3, minX1, maxX2, maxX3); + exchangeData(maxX1m2, minX2p2, minX3p2, minX1p1, maxX2m1, maxX3m1); + exchangeData(maxX1m3, minX2p2, minX3p2, minX1, maxX2m1, maxX3m1); + exchangeData(maxX1m2, minX2p3, minX3p2, minX1p1, maxX2, maxX3m1); + exchangeData(maxX1m2, minX2p2, minX3p3, minX1p1, maxX2m1, maxX3); + exchangeData(maxX1m3, minX2p3, minX3p2, minX1, maxX2, maxX3m1); + exchangeData(maxX1m3, minX2p2, minX3p3, minX1, maxX2m1, maxX3); + exchangeData(maxX1m2, minX2p3, minX3p3, minX1p1, maxX2, maxX3); + } else if (sendDir == D3Q27System::BNW) { + exchangeData(minX1p3, maxX2m3, minX3p3, maxX1, minX2, maxX3); + exchangeData(minX1p2, maxX2m2, minX3p2, maxX1m1, minX2p1, maxX3m1); + exchangeData(minX1p3, maxX2m2, minX3p2, maxX1, minX2p1, maxX3m1); + exchangeData(minX1p2, maxX2m3, minX3p2, maxX1m1, minX2, maxX3m1); + exchangeData(minX1p2, maxX2m2, minX3p3, maxX1m1, minX2p1, maxX3); + exchangeData(minX1p3, maxX2m3, minX3p2, maxX1, minX2, maxX3m1); + exchangeData(minX1p3, maxX2m2, minX3p3, maxX1, minX2p1, maxX3); + exchangeData(minX1p2, maxX2m3, minX3p3, maxX1m1, minX2, maxX3); + } else if (sendDir == D3Q27System::BNE) { + exchangeData(maxX1m3, maxX2m3, minX3p3, minX1, minX2, maxX3); + exchangeData(maxX1m2, maxX2m2, minX3p2, minX1p1, minX2p1, maxX3m1); + exchangeData(maxX1m3, maxX2m2, minX3p2, minX1, minX2p1, maxX3m1); + exchangeData(maxX1m2, maxX2m3, minX3p2, minX1p1, minX2, maxX3m1); + exchangeData(maxX1m2, maxX2m2, minX3p3, minX1p1, minX2p1, maxX3); + exchangeData(maxX1m3, maxX2m3, minX3p2, minX1, minX2, maxX3m1); + exchangeData(maxX1m3, maxX2m2, minX3p3, minX1, minX2p1, maxX3); + exchangeData(maxX1m2, maxX2m3, minX3p3, minX1p1, minX2, maxX3); + } else + UB_THROW(UbException(UB_EXARGS, "unknown dir")); + +} diff --git a/src/cpu/VirtualFluidsCore/Connectors/ThreeDistributionsDoubleGhostLayerFullDirectConnector.h b/src/cpu/VirtualFluidsCore/Connectors/ThreeDistributionsDoubleGhostLayerFullDirectConnector.h new file mode 100644 index 0000000000000000000000000000000000000000..1f53ca70aecd3531c986edb8a3933e9d4c5c5ba7 --- /dev/null +++ b/src/cpu/VirtualFluidsCore/Connectors/ThreeDistributionsDoubleGhostLayerFullDirectConnector.h @@ -0,0 +1,239 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file ThreeDistributionsDoubleGhostLayerFullDirectConnector.h +//! \ingroup Connectors +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef ThreeDistributionsDoubleGhostLayerFullDirectConnector_H +#define ThreeDistributionsDoubleGhostLayerFullDirectConnector_H + +#include "FullDirectConnector.h" +#include "Block3D.h" +#include "D3Q27System.h" +#include "D3Q27EsoTwist3DSplittedVector.h" +#include "basics/container/CbArray3D.h" +#include "basics/container/CbArray4D.h" +#include "DataSet3D.h" + +//! \brief Exchange data between blocks. +//! \details Connector send and receive full distributions between two blocks in shared memory. + +class ThreeDistributionsDoubleGhostLayerFullDirectConnector : public FullDirectConnector +{ +public: + ThreeDistributionsDoubleGhostLayerFullDirectConnector(SPtr<Block3D> from, SPtr<Block3D> to, int sendDir); + void init() override; + void sendVectors() override; + +protected: + inline void updatePointers() override; + void exchangeData() override; + inline void exchangeData(int x1From, int x2From, int x3From, int x1To, int x2To, int x3To) override; + +private: + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributionsFromf; + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsFromf; + CbArray3D <LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributionsFromf; + + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributionsTof; + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsTof; + CbArray3D <LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributionsTof; + + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributionsFromh; + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsFromh; + CbArray3D <LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributionsFromh; + + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributionsToh; + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsToh; + CbArray3D <LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributionsToh; + + CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributionsFromh2; + CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsFromh2; + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributionsFromh2; + + CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributionsToh2; + CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsToh2; + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributionsToh2; + + SPtr<EsoTwist3D> fFrom, hFrom, hFrom2; + SPtr<EsoTwist3D> fTo, hTo, hTo2; + + SPtr<PressureFieldArray3D> pressureFrom, pressureTo; +}; +////////////////////////////////////////////////////////////////////////// +inline void ThreeDistributionsDoubleGhostLayerFullDirectConnector::updatePointers() +{ + localDistributionsFromf = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fFrom)->getLocalDistributions(); + nonLocalDistributionsFromf = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fFrom)->getNonLocalDistributions(); + zeroDistributionsFromf = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fFrom)->getZeroDistributions(); + + localDistributionsTof = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fTo)->getLocalDistributions(); + nonLocalDistributionsTof = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fTo)->getNonLocalDistributions(); + zeroDistributionsTof = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fTo)->getZeroDistributions(); + + localDistributionsFromh = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hFrom)->getLocalDistributions(); + nonLocalDistributionsFromh = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hFrom)->getNonLocalDistributions(); + zeroDistributionsFromh = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hFrom)->getZeroDistributions(); + + localDistributionsToh = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hTo)->getLocalDistributions(); + nonLocalDistributionsToh = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hTo)->getNonLocalDistributions(); + zeroDistributionsToh = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hTo)->getZeroDistributions(); + + localDistributionsFromh2 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hFrom2)->getLocalDistributions(); + nonLocalDistributionsFromh2 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hFrom2)->getNonLocalDistributions(); + zeroDistributionsFromh2 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hFrom2)->getZeroDistributions(); + + localDistributionsToh2 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hTo2)->getLocalDistributions(); + nonLocalDistributionsToh2 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hTo2)->getNonLocalDistributions(); + zeroDistributionsToh2 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hTo2)->getZeroDistributions(); +} +////////////////////////////////////////////////////////////////////////// +inline void ThreeDistributionsDoubleGhostLayerFullDirectConnector::exchangeData(int x1From, int x2From, int x3From, int x1To, int x2To, int x3To) +{ + (*this->localDistributionsTof)(D3Q27System::ET_E, x1To, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_E, x1From, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_N, x1To, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_N, x1From, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_T, x1To, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_T, x1From, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_NE, x1To, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_NE, x1From, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_NW, x1To + 1, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_NW, x1From + 1, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_TE, x1To, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_TE, x1From, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_TW, x1To + 1, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_TW, x1From + 1, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_TN, x1To, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_TN, x1From, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_TS, x1To, x2To + 1, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_TS, x1From, x2From + 1, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_TNE, x1To, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_TNE, x1From, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_TNW, x1To + 1, x2To, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_TNW, x1From + 1, x2From, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_TSE, x1To, x2To + 1, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_TSE, x1From, x2From + 1, x3From); + (*this->localDistributionsTof)(D3Q27System::ET_TSW, x1To + 1, x2To + 1, x3To) = (*this->localDistributionsFromf)(D3Q27System::ET_TSW, x1From + 1, x2From + 1, x3From); + + (*this->nonLocalDistributionsTof)(D3Q27System::ET_W, x1To + 1, x2To, x3To) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_W, x1From + 1, x2From, x3From); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_S, x1To, x2To + 1, x3To) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_S, x1From, x2From + 1, x3From); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_B, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_B, x1From, x2From, x3From + 1); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_SW, x1To + 1, x2To + 1, x3To) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_SW, x1From + 1, x2From + 1, x3From); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_SE, x1To, x2To + 1, x3To) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_SE, x1From, x2From + 1, x3From); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_BW, x1To + 1, x2To, x3To + 1) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_BW, x1From + 1, x2From, x3From + 1); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_BE, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_BE, x1From, x2From, x3From + 1); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_BS, x1To, x2To + 1, x3To + 1) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_BS, x1From, x2From + 1, x3From + 1); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_BN, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_BN, x1From, x2From, x3From + 1); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_BSW, x1To + 1, x2To + 1, x3To + 1) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_BSW, x1From + 1, x2From + 1, x3From + 1); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_BSE, x1To, x2To + 1, x3To + 1) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_BSE, x1From, x2From + 1, x3From + 1); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_BNW, x1To + 1, x2To, x3To + 1) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_BNW, x1From + 1, x2From, x3From + 1); + (*this->nonLocalDistributionsTof)(D3Q27System::ET_BNE, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFromf)(D3Q27System::ET_BNE, x1From, x2From, x3From + 1); + + (*this->zeroDistributionsTof)(x1To, x2To, x3To) = (*this->zeroDistributionsFromf)(x1From, x2From, x3From); + + + (*this->localDistributionsToh)(D3Q27System::ET_E, x1To, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_E, x1From, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_N, x1To, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_N, x1From, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_T, x1To, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_T, x1From, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_NE, x1To, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_NE, x1From, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_NW, x1To + 1, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_NW, x1From + 1, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_TE, x1To, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_TE, x1From, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_TW, x1To + 1, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_TW, x1From + 1, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_TN, x1To, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_TN, x1From, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_TS, x1To, x2To + 1, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_TS, x1From, x2From + 1, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_TNE, x1To, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_TNE, x1From, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_TNW, x1To + 1, x2To, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_TNW, x1From + 1, x2From, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_TSE, x1To, x2To + 1, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_TSE, x1From, x2From + 1, x3From); + (*this->localDistributionsToh)(D3Q27System::ET_TSW, x1To + 1, x2To + 1, x3To) = (*this->localDistributionsFromh)(D3Q27System::ET_TSW, x1From + 1, x2From + 1, x3From); + + (*this->nonLocalDistributionsToh)(D3Q27System::ET_W, x1To + 1, x2To, x3To) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_W, x1From + 1, x2From, x3From); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_S, x1To, x2To + 1, x3To) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_S, x1From, x2From + 1, x3From); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_B, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_B, x1From, x2From, x3From + 1); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_SW, x1To + 1, x2To + 1, x3To) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_SW, x1From + 1, x2From + 1, x3From); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_SE, x1To, x2To + 1, x3To) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_SE, x1From, x2From + 1, x3From); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_BW, x1To + 1, x2To, x3To + 1) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_BW, x1From + 1, x2From, x3From + 1); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_BE, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_BE, x1From, x2From, x3From + 1); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_BS, x1To, x2To + 1, x3To + 1) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_BS, x1From, x2From + 1, x3From + 1); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_BN, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_BN, x1From, x2From, x3From + 1); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_BSW, x1To + 1, x2To + 1, x3To + 1) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_BSW, x1From + 1, x2From + 1, x3From + 1); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_BSE, x1To, x2To + 1, x3To + 1) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_BSE, x1From, x2From + 1, x3From + 1); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_BNW, x1To + 1, x2To, x3To + 1) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_BNW, x1From + 1, x2From, x3From + 1); + (*this->nonLocalDistributionsToh)(D3Q27System::ET_BNE, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFromh)(D3Q27System::ET_BNE, x1From, x2From, x3From + 1); + + (*this->zeroDistributionsToh)(x1To, x2To, x3To) = (*this->zeroDistributionsFromh)(x1From, x2From, x3From); + + (*this->localDistributionsToh2)(D3Q27System::ET_E, x1To, x2To, x3To) = + (*this->localDistributionsFromh2)(D3Q27System::ET_E, x1From, x2From, x3From); + (*this->localDistributionsToh2)(D3Q27System::ET_N, x1To, x2To, x3To) = + (*this->localDistributionsFromh2)(D3Q27System::ET_N, x1From, x2From, x3From); + (*this->localDistributionsToh2)(D3Q27System::ET_T, x1To, x2To, x3To) = + (*this->localDistributionsFromh2)(D3Q27System::ET_T, x1From, x2From, x3From); + (*this->localDistributionsToh2)(D3Q27System::ET_NE, x1To, x2To, x3To) = + (*this->localDistributionsFromh2)(D3Q27System::ET_NE, x1From, x2From, x3From); + (*this->localDistributionsToh2)(D3Q27System::ET_NW, x1To + 1, x2To, x3To) = + (*this->localDistributionsFromh2)(D3Q27System::ET_NW, x1From + 1, x2From, x3From); + (*this->localDistributionsToh2)(D3Q27System::ET_TE, x1To, x2To, x3To) = + (*this->localDistributionsFromh2)(D3Q27System::ET_TE, x1From, x2From, x3From); + (*this->localDistributionsToh2)(D3Q27System::ET_TW, x1To + 1, x2To, x3To) = + (*this->localDistributionsFromh2)(D3Q27System::ET_TW, x1From + 1, x2From, x3From); + (*this->localDistributionsToh2)(D3Q27System::ET_TN, x1To, x2To, x3To) = + (*this->localDistributionsFromh2)(D3Q27System::ET_TN, x1From, x2From, x3From); + (*this->localDistributionsToh2)(D3Q27System::ET_TS, x1To, x2To + 1, x3To) = + (*this->localDistributionsFromh2)(D3Q27System::ET_TS, x1From, x2From + 1, x3From); + (*this->localDistributionsToh2)(D3Q27System::ET_TNE, x1To, x2To, x3To) = + (*this->localDistributionsFromh2)(D3Q27System::ET_TNE, x1From, x2From, x3From); + (*this->localDistributionsToh2)(D3Q27System::ET_TNW, x1To + 1, x2To, x3To) = + (*this->localDistributionsFromh2)(D3Q27System::ET_TNW, x1From + 1, x2From, x3From); + (*this->localDistributionsToh2)(D3Q27System::ET_TSE, x1To, x2To + 1, x3To) = + (*this->localDistributionsFromh2)(D3Q27System::ET_TSE, x1From, x2From + 1, x3From); + (*this->localDistributionsToh2)(D3Q27System::ET_TSW, x1To + 1, x2To + 1, x3To) = + (*this->localDistributionsFromh2)(D3Q27System::ET_TSW, x1From + 1, x2From + 1, x3From); + + (*this->nonLocalDistributionsToh2)(D3Q27System::ET_W, x1To + 1, x2To, x3To) = + (*this->nonLocalDistributionsFromh2)(D3Q27System::ET_W, x1From + 1, x2From, x3From); + (*this->nonLocalDistributionsToh2)(D3Q27System::ET_S, x1To, x2To + 1, x3To) = + (*this->nonLocalDistributionsFromh2)(D3Q27System::ET_S, x1From, x2From + 1, x3From); + (*this->nonLocalDistributionsToh2)(D3Q27System::ET_B, x1To, x2To, x3To + 1) = + (*this->nonLocalDistributionsFromh2)(D3Q27System::ET_B, x1From, x2From, x3From + 1); + (*this->nonLocalDistributionsToh2)(D3Q27System::ET_SW, x1To + 1, x2To + 1, x3To) = + (*this->nonLocalDistributionsFromh2)(D3Q27System::ET_SW, x1From + 1, x2From + 1, x3From); + (*this->nonLocalDistributionsToh2)(D3Q27System::ET_SE, x1To, x2To + 1, x3To) = + (*this->nonLocalDistributionsFromh2)(D3Q27System::ET_SE, x1From, x2From + 1, x3From); + (*this->nonLocalDistributionsToh2)(D3Q27System::ET_BW, x1To + 1, x2To, x3To + 1) = + (*this->nonLocalDistributionsFromh2)(D3Q27System::ET_BW, x1From + 1, x2From, x3From + 1); + (*this->nonLocalDistributionsToh2)(D3Q27System::ET_BE, x1To, x2To, x3To + 1) = + (*this->nonLocalDistributionsFromh2)(D3Q27System::ET_BE, x1From, x2From, x3From + 1); + (*this->nonLocalDistributionsToh2)(D3Q27System::ET_BS, x1To, x2To + 1, x3To + 1) = + (*this->nonLocalDistributionsFromh2)(D3Q27System::ET_BS, x1From, x2From + 1, x3From + 1); + (*this->nonLocalDistributionsToh2)(D3Q27System::ET_BN, x1To, x2To, x3To + 1) = + (*this->nonLocalDistributionsFromh2)(D3Q27System::ET_BN, x1From, x2From, x3From + 1); + (*this->nonLocalDistributionsToh2)(D3Q27System::ET_BSW, x1To + 1, x2To + 1, x3To + 1) = + (*this->nonLocalDistributionsFromh2)(D3Q27System::ET_BSW, x1From + 1, x2From + 1, x3From + 1); + (*this->nonLocalDistributionsToh2)(D3Q27System::ET_BSE, x1To, x2To + 1, x3To + 1) = + (*this->nonLocalDistributionsFromh2)(D3Q27System::ET_BSE, x1From, x2From + 1, x3From + 1); + (*this->nonLocalDistributionsToh2)(D3Q27System::ET_BNW, x1To + 1, x2To, x3To + 1) = + (*this->nonLocalDistributionsFromh2)(D3Q27System::ET_BNW, x1From + 1, x2From, x3From + 1); + (*this->nonLocalDistributionsToh2)(D3Q27System::ET_BNE, x1To, x2To, x3To + 1) = + (*this->nonLocalDistributionsFromh2)(D3Q27System::ET_BNE, x1From, x2From, x3From + 1); + + (*this->zeroDistributionsToh2)(x1To, x2To, x3To) = (*this->zeroDistributionsFromh2)(x1From, x2From, x3From); + + (*this->pressureTo)(x1To, x2To, x3To) = (*this->pressureFrom)(x1From, x2From, x3From); +} +#endif \ No newline at end of file diff --git a/src/cpu/VirtualFluidsCore/Connectors/ThreeDistributionsDoubleGhostLayerFullVectorConnector.cpp b/src/cpu/VirtualFluidsCore/Connectors/ThreeDistributionsDoubleGhostLayerFullVectorConnector.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3e314fbce45e8d29affa09777a7cbeb1b92ca2ac --- /dev/null +++ b/src/cpu/VirtualFluidsCore/Connectors/ThreeDistributionsDoubleGhostLayerFullVectorConnector.cpp @@ -0,0 +1,616 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file ThreeDistributionsDoubleGhostLayerFullVectorConnector.cpp +//! \ingroup Connectors +//! \author Konstantin Kutscher +//======================================================================================= + +#include "ThreeDistributionsDoubleGhostLayerFullVectorConnector.h" +#include "Block3D.h" +#include "LBMKernel.h" +#include "EsoTwist3D.h" +#include "DataSet3D.h" + +////////////////////////////////////////////////////////////////////////// +ThreeDistributionsDoubleGhostLayerFullVectorConnector::ThreeDistributionsDoubleGhostLayerFullVectorConnector(SPtr<Block3D> block, + VectorTransmitterPtr sender, + VectorTransmitterPtr receiver, int sendDir) + : FullVectorConnector(block, sender, receiver, sendDir) +{ + if (!block || !sender || !receiver) + UB_THROW(UbException(UB_EXARGS, "sender or receiver == NULL!!")); + +} +////////////////////////////////////////////////////////////////////////// +void ThreeDistributionsDoubleGhostLayerFullVectorConnector::init() +{ + FullVectorConnector::init(); + + fDis = dynamicPointerCast<EsoTwist3D>(block.lock()->getKernel()->getDataSet()->getFdistributions()); + hDis = dynamicPointerCast<EsoTwist3D>(block.lock()->getKernel()->getDataSet()->getHdistributions()); + h2Dis = dynamicPointerCast<EsoTwist3D>(block.lock()->getKernel()->getDataSet()->getH2distributions()); + pressure = block.lock()->getKernel()->getDataSet()->getPressureField(); + + int anz = 3*27+1; + switch (sendDir) + { + case D3Q27System::REST: UB_THROW(UbException(UB_EXARGS, "ZERO not allowed")); break; + case D3Q27System::E: + case D3Q27System::W: sender->getData().resize(maxX2*maxX3*anz*2, 0.0); break; + case D3Q27System::N: + case D3Q27System::S: sender->getData().resize(maxX1*maxX3*anz*2, 0.0); break; + case D3Q27System::T: + case D3Q27System::B: sender->getData().resize(maxX1*maxX2*anz*2, 0.0); break; + + case D3Q27System::NE: + case D3Q27System::SW: + case D3Q27System::SE: + case D3Q27System::NW: sender->getData().resize(maxX3*anz*4, 0.0); break; + + case D3Q27System::TE: + case D3Q27System::BW: + case D3Q27System::BE: + case D3Q27System::TW: sender->getData().resize(maxX2*anz*4, 0.0); break; + + case D3Q27System::TN: + case D3Q27System::BS: + case D3Q27System::BN: + case D3Q27System::TS: sender->getData().resize(maxX1*anz*4, 0.0); break; + + case D3Q27System::TNE: + case D3Q27System::BSW: + case D3Q27System::BNE: + case D3Q27System::TSW: + case D3Q27System::TSE: + case D3Q27System::BNW: + case D3Q27System::BSE: + case D3Q27System::TNW: sender->getData().resize(anz*8, 0.0); break; + + default: UB_THROW(UbException(UB_EXARGS, "unknown sendDir")); + } +} +////////////////////////////////////////////////////////////////////////// +void ThreeDistributionsDoubleGhostLayerFullVectorConnector::fillSendVectors() +{ + updatePointers(); + fillData(); +} +//////////////////////////////////////////////////////////////////////// +void ThreeDistributionsDoubleGhostLayerFullVectorConnector::fillData() +{ + //////////////////////////////////////////////////////////// + // relation between ghost layer and regular nodes + // maxX1m3 maxX1m2 ... minX1p2 minX1p3 - regular nodes + // minX1 minX1p1 ... maxX1m1 maxX1 - ghost layer + //////////////////////////////////////////////////////////// + + int minX1 = 0; + //int minX1p1 = minX1 + 1; + int minX1p2 = minX1 + 2; + int minX1p3 = minX1 + 3; + //int maxX1m1 = maxX1 - 1; + int maxX1m2 = maxX1 - 2; + int maxX1m3 = maxX1 - 3; + + int minX2 = 0; + //int minX2p1 = minX2 + 1; + int minX2p2 = minX2 + 2; + int minX2p3 = minX2 + 3; + //int maxX2m1 = maxX2 - 1; + int maxX2m2 = maxX2 - 2; + int maxX2m3 = maxX2 - 3; + + int minX3 = 0; + //int minX3p1 = minX3 + 1; + int minX3p2 = minX3 + 2; + int minX3p3 = minX3 + 3; + //int maxX3m1 = maxX3 - 1; + int maxX3m2 = maxX3 - 2; + int maxX3m3 = maxX3 - 3; + + vector_type &sdata = sender->getData(); + + int index = 0; + // EAST + if (sendDir == D3Q27System::E) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + fillData(sdata, index, maxX1m3, x2, x3); + fillData(sdata, index, maxX1m2, x2, x3); + } + } + } + // WEST + else if (sendDir == D3Q27System::W) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + fillData(sdata, index, minX1p3, x2, x3); + fillData(sdata, index, minX1p2, x2, x3); + } + } + } + // NORTH + else if (sendDir == D3Q27System::N) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + fillData(sdata, index, x1, maxX2m3, x3); + fillData(sdata, index, x1, maxX2m2, x3); + } + } + } + // SOUTH + else if (sendDir == D3Q27System::S) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + fillData(sdata, index, x1, minX2p3, x3); + fillData(sdata, index, x1, minX2p2, x3); + } + } + } + + // TOP + else if (sendDir == D3Q27System::T) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + fillData(sdata, index, x1, x2, maxX3m3); + fillData(sdata, index, x1, x2, maxX3m2); + } + } + } + // BOTTOM + else if (sendDir == D3Q27System::B) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + fillData(sdata, index, x1, x2, minX3p3); + fillData(sdata, index, x1, x2, minX3p2); + } + } + } + // NORTHEAST + else if (sendDir == D3Q27System::NE) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + fillData(sdata, index, maxX1m3, maxX2m3, x3); + fillData(sdata, index, maxX1m2, maxX2m2, x3); + fillData(sdata, index, maxX1m3, maxX2m2, x3); + fillData(sdata, index, maxX1m2, maxX2m3, x3); + } + } + // NORTHWEST + else if (sendDir == D3Q27System::NW) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + fillData(sdata, index, minX1p3, maxX2m3, x3); + fillData(sdata, index, minX1p2, maxX2m2, x3); + fillData(sdata, index, minX1p3, maxX2m2, x3); + fillData(sdata, index, minX1p2, maxX2m3, x3); + } + } + // SOUTHWEST + else if (sendDir == D3Q27System::SW) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + fillData(sdata, index, minX1p3, minX2p3, x3); + fillData(sdata, index, minX1p2, minX2p2, x3); + fillData(sdata, index, minX1p3, minX2p2, x3); + fillData(sdata, index, minX1p2, minX2p3, x3); + } + } + // SOUTHEAST + else if (sendDir == D3Q27System::SE) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + fillData(sdata, index, maxX1m3, minX2p3, x3); + fillData(sdata, index, maxX1m2, minX2p2, x3); + fillData(sdata, index, maxX1m3, minX2p2, x3); + fillData(sdata, index, maxX1m2, minX2p3, x3); + } + } else if (sendDir == D3Q27System::TE) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + fillData(sdata, index, maxX1m3, x2, maxX3m3); + fillData(sdata, index, maxX1m2, x2, maxX3m2); + fillData(sdata, index, maxX1m3, x2, maxX3m2); + fillData(sdata, index, maxX1m2, x2, maxX3m3); + } + else if (sendDir == D3Q27System::BW) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + fillData(sdata, index, minX1p3, x2, minX3p3); + fillData(sdata, index, minX1p2, x2, minX3p2); + fillData(sdata, index, minX1p3, x2, minX3p2); + fillData(sdata, index, minX1p2, x2, minX3p3); + } + else if (sendDir == D3Q27System::BE) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + fillData(sdata, index, maxX1m3, x2, minX3p3); + fillData(sdata, index, maxX1m2, x2, minX3p2); + fillData(sdata, index, maxX1m3, x2, minX3p2); + fillData(sdata, index, maxX1m2, x2, minX3p3); + } + else if (sendDir == D3Q27System::TW) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + fillData(sdata, index, minX1p3, x2, maxX3m3); + fillData(sdata, index, minX1p2, x2, maxX3m2); + fillData(sdata, index, minX1p3, x2, maxX3m2); + fillData(sdata, index, minX1p2, x2, maxX3m3); + } + else if (sendDir == D3Q27System::TN) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + fillData(sdata, index, x1, maxX2m3, maxX3m3); + fillData(sdata, index, x1, maxX2m2, maxX3m2); + fillData(sdata, index, x1, maxX2m3, maxX3m2); + fillData(sdata, index, x1, maxX2m2, maxX3m3); + } + else if (sendDir == D3Q27System::BS) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + fillData(sdata, index, x1, minX2p3, minX3p3); + fillData(sdata, index, x1, minX2p2, minX3p2); + fillData(sdata, index, x1, minX2p3, minX3p2); + fillData(sdata, index, x1, minX2p2, minX3p3); + } + else if (sendDir == D3Q27System::BN) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + fillData(sdata, index, x1, maxX2m3, minX3p3); + fillData(sdata, index, x1, maxX2m2, minX3p2); + fillData(sdata, index, x1, maxX2m3, minX3p2); + fillData(sdata, index, x1, maxX2m2, minX3p3); + } + else if (sendDir == D3Q27System::TS) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + fillData(sdata, index, x1, minX2p3, maxX3m3); + fillData(sdata, index, x1, minX2p2, maxX3m2); + fillData(sdata, index, x1, minX2p3, maxX3m2); + fillData(sdata, index, x1, minX2p2, maxX3m3); + } + else if (sendDir == D3Q27System::TSW) { + fillData(sdata, index, minX1p3, minX2p3, maxX3m3); + fillData(sdata, index, minX1p2, minX2p2, maxX3m2); + fillData(sdata, index, minX1p3, minX2p2, maxX3m2); + fillData(sdata, index, minX1p2, minX2p3, maxX3m2); + fillData(sdata, index, minX1p2, minX2p2, maxX3m3); + fillData(sdata, index, minX1p3, minX2p3, maxX3m2); + fillData(sdata, index, minX1p3, minX2p2, maxX3m3); + fillData(sdata, index, minX1p2, minX2p3, maxX3m3); + } else if (sendDir == D3Q27System::TSE) { + fillData(sdata, index, maxX1m3, minX1p3, maxX3m3); + fillData(sdata, index, maxX1m2, minX1p2, maxX3m2); + fillData(sdata, index, maxX1m3, minX1p2, maxX3m2); + fillData(sdata, index, maxX1m2, minX1p3, maxX3m2); + fillData(sdata, index, maxX1m2, minX1p2, maxX3m3); + fillData(sdata, index, maxX1m3, minX1p3, maxX3m2); + fillData(sdata, index, maxX1m3, minX1p2, maxX3m3); + fillData(sdata, index, maxX1m2, minX1p3, maxX3m3); + } else if (sendDir == D3Q27System::TNW) { + fillData(sdata, index, minX1p3, maxX2m3, maxX3m3); + fillData(sdata, index, minX1p2, maxX2m2, maxX3m2); + fillData(sdata, index, minX1p3, maxX2m2, maxX3m2); + fillData(sdata, index, minX1p2, maxX2m3, maxX3m2); + fillData(sdata, index, minX1p2, maxX2m2, maxX3m3); + fillData(sdata, index, minX1p3, maxX2m3, maxX3m2); + fillData(sdata, index, minX1p3, maxX2m2, maxX3m3); + fillData(sdata, index, minX1p2, maxX2m3, maxX3m3); + } else if (sendDir == D3Q27System::TNE) { + fillData(sdata, index, maxX1m3, maxX2m3, maxX3m3); + fillData(sdata, index, maxX1m2, maxX2m2, maxX3m2); + fillData(sdata, index, maxX1m3, maxX2m2, maxX3m2); + fillData(sdata, index, maxX1m2, maxX2m3, maxX3m2); + fillData(sdata, index, maxX1m2, maxX2m2, maxX3m3); + fillData(sdata, index, maxX1m3, maxX2m3, maxX3m2); + fillData(sdata, index, maxX1m3, maxX2m2, maxX3m3); + fillData(sdata, index, maxX1m2, maxX2m3, maxX3m3); + } else if (sendDir == D3Q27System::BSW) { + fillData(sdata, index, minX1p3, minX2p3, minX3p3); + fillData(sdata, index, minX1p2, minX2p2, minX3p2); + fillData(sdata, index, minX1p3, minX2p2, minX3p2); + fillData(sdata, index, minX1p2, minX2p3, minX3p2); + fillData(sdata, index, minX1p2, minX2p2, minX3p3); + fillData(sdata, index, minX1p3, minX2p3, minX3p2); + fillData(sdata, index, minX1p3, minX2p2, minX3p3); + fillData(sdata, index, minX1p2, minX2p3, minX3p3); + } else if (sendDir == D3Q27System::BSE) { + fillData(sdata, index, maxX1m3, minX2p3, minX3p3); + fillData(sdata, index, maxX1m2, minX2p2, minX3p2); + fillData(sdata, index, maxX1m3, minX2p2, minX3p2); + fillData(sdata, index, maxX1m2, minX2p3, minX3p2); + fillData(sdata, index, maxX1m2, minX2p2, minX3p3); + fillData(sdata, index, maxX1m3, minX2p3, minX3p2); + fillData(sdata, index, maxX1m3, minX2p2, minX3p3); + fillData(sdata, index, maxX1m2, minX2p3, minX3p3); + } else if (sendDir == D3Q27System::BNW) { + fillData(sdata, index, minX1p3, maxX2m3, minX3p3); + fillData(sdata, index, minX1p2, maxX2m2, minX3p2); + fillData(sdata, index, minX1p3, maxX2m2, minX3p2); + fillData(sdata, index, minX1p2, maxX2m3, minX3p2); + fillData(sdata, index, minX1p2, maxX2m2, minX3p3); + fillData(sdata, index, minX1p3, maxX2m3, minX3p2); + fillData(sdata, index, minX1p3, maxX2m2, minX3p3); + fillData(sdata, index, minX1p2, maxX2m3, minX3p3); + } else if (sendDir == D3Q27System::BNE) { + fillData(sdata, index, maxX1m3, maxX2m3, minX3p3); + fillData(sdata, index, maxX1m2, maxX2m2, minX3p2); + fillData(sdata, index, maxX1m3, maxX2m2, minX3p2); + fillData(sdata, index, maxX1m2, maxX2m3, minX3p2); + fillData(sdata, index, maxX1m2, maxX2m2, minX3p3); + fillData(sdata, index, maxX1m3, maxX2m3, minX3p2); + fillData(sdata, index, maxX1m3, maxX2m2, minX3p3); + fillData(sdata, index, maxX1m2, maxX2m3, minX3p3); + } else + UB_THROW(UbException(UB_EXARGS, "unknown dir")); +} +//////////////////////////////////////////////////////////////////////// +void ThreeDistributionsDoubleGhostLayerFullVectorConnector::distributeReceiveVectors() +{ + updatePointers(); + distributeData(); +} +//////////////////////////////////////////////////////////////////////// +void ThreeDistributionsDoubleGhostLayerFullVectorConnector::distributeData() +{ + vector_type &rdata = receiver->getData(); + + int index = 0; + //////////////////////////////////////////////////////////// + // relation between ghost layer and regular nodes + // maxX1m3 maxX1m2 ... minX1p2 minX1p3 - regular nodes + // minX1 minX1p1 ... maxX1m1 maxX1 - ghost layer + //////////////////////////////////////////////////////////// + + int minX1 = 0; + int minX1p1 = minX1 + 1; + int minX1p2 = minX1 + 2; + //int minX1p3 = minX1 + 3; + int maxX1m1 = maxX1 - 1; + int maxX1m2 = maxX1 - 2; + //int maxX1m3 = maxX1 - 3; + + int minX2 = 0; + int minX2p1 = minX2 + 1; + int minX2p2 = minX2 + 2; + //int minX2p3 = minX2 + 3; + int maxX2m1 = maxX2 - 1; + int maxX2m2 = maxX2 - 2; + //int maxX2m3 = maxX2 - 3; + + int minX3 = 0; + int minX3p1 = minX3 + 1; + int minX3p2 = minX3 + 2; + //int minX3p3 = minX3 + 3; + int maxX3m1 = maxX3 - 1; + int maxX3m2 = maxX3 - 2; + //int maxX3m3 = maxX3 - 3; + + if (sendDir == D3Q27System::W) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + distributeData(rdata, index, minX1, x2, x3); + distributeData(rdata, index, minX1p1, x2, x3); + } + } + } + else if (sendDir == D3Q27System::E) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + distributeData(rdata, index, maxX1, x2, x3); + distributeData(rdata, index, maxX1m1, x2, x3); + } + } + } + else if (sendDir == D3Q27System::S) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + distributeData(rdata, index, x1, minX2, x3); + distributeData(rdata, index, x1, minX2p1, x3); + } + } + } + else if (sendDir == D3Q27System::N) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + distributeData(rdata, index, x1, maxX2, x3); + distributeData(rdata, index, x1, maxX2m1, x3); + } + } + } + else if (sendDir == D3Q27System::B) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + distributeData(rdata, index, x1, x2, minX3); + distributeData(rdata, index, x1, x2, minX3p1); + } + } + } + else if (sendDir == D3Q27System::T) { + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + distributeData(rdata, index, x1, x2, maxX3); + distributeData(rdata, index, x1, x2, maxX3m1); + } + } + } + else if (sendDir == D3Q27System::SW) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + distributeData(rdata, index, minX1, minX2, x3); + distributeData(rdata, index, minX1p1, minX2p1, x3); + distributeData(rdata, index, minX1, minX2p1, x3); + distributeData(rdata, index, minX1p1, minX2, x3); + } + } + else if (sendDir == D3Q27System::SE) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + distributeData(rdata, index, maxX1, minX2, x3); + distributeData(rdata, index, maxX1m1, minX2p1, x3); + distributeData(rdata, index, maxX1, minX2p1, x3); + distributeData(rdata, index, maxX1m1, minX2, x3); + } + } + else if (sendDir == D3Q27System::NE) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + distributeData(rdata, index, maxX1, maxX2, x3); + distributeData(rdata, index, maxX1m1, maxX2m1, x3); + distributeData(rdata, index, maxX1, maxX2m1, x3); + distributeData(rdata, index, maxX1m1, maxX2, x3); + } + } + else if (sendDir == D3Q27System::NW) { + for (int x3 = minX3p2; x3 <= maxX3m2; x3++) { + distributeData(rdata, index, minX1, maxX2, x3); + distributeData(rdata, index, minX1p1, maxX2m1, x3); + distributeData(rdata, index, minX1, maxX2m1, x3); + distributeData(rdata, index, minX1p1, maxX2, x3); + } + } else if (sendDir == D3Q27System::BW) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + distributeData(rdata, index, minX1, x2, minX3); + distributeData(rdata, index, minX1p1, x2, minX3p1); + distributeData(rdata, index, minX1, x2, minX3p1); + distributeData(rdata, index, minX1p1, x2, minX3); + } + else if (sendDir == D3Q27System::TE) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + distributeData(rdata, index, maxX1, x2, maxX3); + distributeData(rdata, index, maxX1m1, x2, maxX3m1); + distributeData(rdata, index, maxX1, x2, maxX3m1); + distributeData(rdata, index, maxX1m1, x2, maxX3); + } + else if (sendDir == D3Q27System::TW) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + distributeData(rdata, index, minX1, x2, maxX3); + distributeData(rdata, index, minX1p1, x2, maxX3m1); + distributeData(rdata, index, minX1, x2, maxX3m1); + distributeData(rdata, index, minX1p1, x2, maxX3); + } + else if (sendDir == D3Q27System::BE) + for (int x2 = minX2p2; x2 <= maxX2m2; x2++) { + distributeData(rdata, index, maxX1, x2, minX3); + distributeData(rdata, index, maxX1m1, x2, minX3p1); + distributeData(rdata, index, maxX1, x2, minX3p1); + distributeData(rdata, index, maxX1m1, x2, minX3); + } + else if (sendDir == D3Q27System::BS) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + distributeData(rdata, index, x1, minX2, minX3); + distributeData(rdata, index, x1, minX2p1, minX3p1); + distributeData(rdata, index, x1, minX2, minX3p1); + distributeData(rdata, index, x1, minX2p1, minX3); + } + else if (sendDir == D3Q27System::TN) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + distributeData(rdata, index, x1, maxX2, maxX3); + distributeData(rdata, index, x1, maxX2m1, maxX3m1); + distributeData(rdata, index, x1, maxX2, maxX3m1); + distributeData(rdata, index, x1, maxX2m1, maxX3); + } + else if (sendDir == D3Q27System::TS) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + distributeData(rdata, index, x1, minX2, maxX3); + distributeData(rdata, index, x1, minX2p1, maxX3m1); + distributeData(rdata, index, x1, minX2, maxX3m1); + distributeData(rdata, index, x1, minX2p1, maxX3); + } + else if (sendDir == D3Q27System::BN) + for (int x1 = minX1p2; x1 <= maxX1m2; x1++) { + distributeData(rdata, index, x1, maxX2, minX3); + distributeData(rdata, index, x1, maxX2m1, minX3p1); + distributeData(rdata, index, x1, maxX2, minX3p1); + distributeData(rdata, index, x1, maxX2m1, minX3); + } + else if (sendDir == D3Q27System::BNE) { + distributeData(rdata, index, maxX1, maxX2, minX3); + distributeData(rdata, index, maxX1m1, maxX2m1, minX3p1); + distributeData(rdata, index, maxX1, maxX2m1, minX3p1); + distributeData(rdata, index, maxX1m1, maxX2, minX3p1); + distributeData(rdata, index, maxX1m1, maxX2m1, minX3); + distributeData(rdata, index, maxX1, maxX2, minX3p1); + distributeData(rdata, index, maxX1, maxX2m1, minX3); + distributeData(rdata, index, maxX1m1, maxX2, minX3); + } else if (sendDir == D3Q27System::BNW) { + distributeData(rdata, index, minX1, maxX2, minX3); + distributeData(rdata, index, minX1p1, maxX2m1, minX3p1); + distributeData(rdata, index, minX1, maxX2m1, minX3p1); + distributeData(rdata, index, minX1p1, maxX2, minX3p1); + distributeData(rdata, index, minX1p1, maxX2m1, minX3); + distributeData(rdata, index, minX1, maxX2, minX3p1); + distributeData(rdata, index, minX1, maxX2m1, minX3); + distributeData(rdata, index, minX1p1, maxX2, minX3); + } else if (sendDir == D3Q27System::BSE) { + distributeData(rdata, index, maxX1, minX2, minX3); + distributeData(rdata, index, maxX1m1, minX2p1, minX3p1); + distributeData(rdata, index, maxX1, minX2p1, minX3p1); + distributeData(rdata, index, maxX1m1, minX2, minX3p1); + distributeData(rdata, index, maxX1m1, minX2p1, minX3); + distributeData(rdata, index, maxX1, minX2, minX3p1); + distributeData(rdata, index, maxX1, minX2p1, minX3); + distributeData(rdata, index, maxX1m1, minX2, minX3); + } else if (sendDir == D3Q27System::BSW) { + distributeData(rdata, index, minX1, minX2, minX3); + distributeData(rdata, index, minX1p1, minX2p1, minX3p1); + distributeData(rdata, index, minX1, minX2p1, minX3p1); + distributeData(rdata, index, minX1p1, minX2, minX3p1); + distributeData(rdata, index, minX1p1, minX2p1, minX3); + distributeData(rdata, index, minX1, minX2, minX3p1); + distributeData(rdata, index, minX1, minX2p1, minX3); + distributeData(rdata, index, minX1p1, minX2, minX3); + } else if (sendDir == D3Q27System::TNE) { + distributeData(rdata, index, maxX1, maxX2, maxX3); + distributeData(rdata, index, maxX1m1, maxX2m1, maxX3m1); + distributeData(rdata, index, maxX1, maxX2m1, maxX3m1); + distributeData(rdata, index, maxX1m1, maxX2, maxX3m1); + distributeData(rdata, index, maxX1m1, maxX2m1, maxX3); + distributeData(rdata, index, maxX1, maxX2, maxX3m1); + distributeData(rdata, index, maxX1, maxX2m1, maxX3); + distributeData(rdata, index, maxX1m1, maxX2, maxX3); + } else if (sendDir == D3Q27System::TNW) { + distributeData(rdata, index, minX1, maxX2, maxX3); + distributeData(rdata, index, minX1p1, maxX2m1, maxX3m1); + distributeData(rdata, index, minX1, maxX2m1, maxX3m1); + distributeData(rdata, index, minX1p1, maxX2, maxX3m1); + distributeData(rdata, index, minX1p1, maxX2m1, maxX3); + distributeData(rdata, index, minX1, maxX2, maxX3m1); + distributeData(rdata, index, minX1, maxX2m1, maxX3); + distributeData(rdata, index, minX1p1, maxX2, maxX3); + } else if (sendDir == D3Q27System::TSE) { + distributeData(rdata, index, maxX1, minX2, maxX3); + distributeData(rdata, index, maxX1m1, minX2p1, maxX3m1); + distributeData(rdata, index, maxX1, minX2p1, maxX3m1); + distributeData(rdata, index, maxX1m1, minX2, maxX3m1); + distributeData(rdata, index, maxX1m1, minX2p1, maxX3); + distributeData(rdata, index, maxX1, minX2, maxX3m1); + distributeData(rdata, index, maxX1, minX2p1, maxX3); + distributeData(rdata, index, maxX1m1, minX2, maxX3); + } else if (sendDir == D3Q27System::TSW) { + distributeData(rdata, index, minX1, minX2, maxX3); + distributeData(rdata, index, minX1p1, minX2p1, maxX3m1); + distributeData(rdata, index, minX1, minX2p1, maxX3m1); + distributeData(rdata, index, minX1p1, minX2, maxX3m1); + distributeData(rdata, index, minX1p1, minX2p1, maxX3); + distributeData(rdata, index, minX1, minX2, maxX3m1); + distributeData(rdata, index, minX1, minX2p1, maxX3); + distributeData(rdata, index, minX1p1, minX2, maxX3); + } else + UB_THROW(UbException(UB_EXARGS, "unknown dir")); + +} +////////////////////////////////////////////////////////////////////////// + + diff --git a/src/cpu/VirtualFluidsCore/Connectors/ThreeDistributionsDoubleGhostLayerFullVectorConnector.h b/src/cpu/VirtualFluidsCore/Connectors/ThreeDistributionsDoubleGhostLayerFullVectorConnector.h new file mode 100644 index 0000000000000000000000000000000000000000..408a8e79d8a22ae71f0f03d51205b6c01a391aae --- /dev/null +++ b/src/cpu/VirtualFluidsCore/Connectors/ThreeDistributionsDoubleGhostLayerFullVectorConnector.h @@ -0,0 +1,302 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file ThreeDistributionsDoubleGhostLayerFullVectorConnector.h +//! \ingroup Connectors +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef ThreeDistributionsDoubleGhostLayerFullVectorConnector_H +#define ThreeDistributionsDoubleGhostLayerFullVectorConnector_H + +#include <vector> + +#include "FullVectorConnector.h" +#include "D3Q27System.h" +#include "D3Q27EsoTwist3DSplittedVector.h" +#include "basics/container/CbArray3D.h" +#include "basics/container/CbArray4D.h" +#include "DataSet3D.h" + +class EsoTwist3D; +class Block3D; + +//daten werden in einen vector (dieser befindet sich im transmitter) kopiert +//der vector wird via transmitter uebertragen +//transmitter kann ein lokal, MPI, RCG, CTL oder was auch immer fuer ein +//transmitter sein, der von Transmitter abgeleitet ist ;-) +class ThreeDistributionsDoubleGhostLayerFullVectorConnector : public FullVectorConnector +{ +public: + ThreeDistributionsDoubleGhostLayerFullVectorConnector(SPtr<Block3D> block, VectorTransmitterPtr sender, VectorTransmitterPtr receiver, int sendDir); + + void init() override; + + void fillSendVectors() override; + void distributeReceiveVectors() override; + +protected: + inline void updatePointers() override; + void fillData() override; + void distributeData() override; + inline void fillData(vector_type &sdata, int &index, int x1, int x2, int x3) override; + inline void distributeData(vector_type &rdata, int &index, int x1, int x2, int x3) override; + +private: + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributions; + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions; + CbArray3D <LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributions; + + SPtr<EsoTwist3D> fDis; + + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localHdistributions; + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalHdistributions; + CbArray3D <LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroHdistributions; + + SPtr<EsoTwist3D> hDis; + + CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localH2distributions; + CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalH2distributions; + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroH2distributions; + + SPtr<EsoTwist3D> h2Dis; + + SPtr<PressureFieldArray3D> pressure; + +}; +////////////////////////////////////////////////////////////////////////// +inline void ThreeDistributionsDoubleGhostLayerFullVectorConnector::updatePointers() +{ + localDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fDis)->getLocalDistributions(); + nonLocalDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fDis)->getNonLocalDistributions(); + zeroDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fDis)->getZeroDistributions(); + + localHdistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hDis)->getLocalDistributions(); + nonLocalHdistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hDis)->getNonLocalDistributions(); + zeroHdistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->hDis)->getZeroDistributions(); + + localH2distributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->h2Dis)->getLocalDistributions(); + nonLocalH2distributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->h2Dis)->getNonLocalDistributions(); + zeroH2distributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->h2Dis)->getZeroDistributions(); +} +////////////////////////////////////////////////////////////////////////// +inline void ThreeDistributionsDoubleGhostLayerFullVectorConnector::fillData(vector_type& sdata, int& index, int x1, int x2, int x3) +{ + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_NW, x1 + 1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TW, x1 + 1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TS, x1, x2 + 1, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TNW, x1 + 1, x2, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2 + 1, x3); + sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TSW, x1 + 1, x2 + 1, x3); + + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_W, x1 + 1, x2, x3); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2 + 1, x3); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1 + 1, x2 + 1, x3); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2 + 1, x3); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1 + 1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2 + 1, x3 + 1); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1 + 1, x2 + 1, x3 + 1); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2 + 1, x3 + 1); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1 + 1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3 + 1); + + sdata[index++] = (*this->zeroDistributions)(x1, x2, x3); + + + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_E, x1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_N, x1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_T, x1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_NE, x1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_NW, x1 + 1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_TE, x1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_TW, x1 + 1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_TN, x1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_TS, x1, x2 + 1, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_TNE, x1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_TNW, x1 + 1, x2, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_TSE, x1, x2 + 1, x3); + sdata[index++] = (*this->localHdistributions)(D3Q27System::ET_TSW, x1 + 1, x2 + 1, x3); + + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_W, x1 + 1, x2, x3); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_S, x1, x2 + 1, x3); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_B, x1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_SW, x1 + 1, x2 + 1, x3); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_SE, x1, x2 + 1, x3); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_BW, x1 + 1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_BE, x1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_BS, x1, x2 + 1, x3 + 1); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_BN, x1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_BSW, x1 + 1, x2 + 1, x3 + 1); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_BSE, x1, x2 + 1, x3 + 1); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_BNW, x1 + 1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalHdistributions)(D3Q27System::ET_BNE, x1, x2, x3 + 1); + + sdata[index++] = (*this->zeroHdistributions)(x1, x2, x3); + + sdata[index++] = (*this->localH2distributions)(D3Q27System::ET_E, x1, x2, x3); + sdata[index++] = (*this->localH2distributions)(D3Q27System::ET_N, x1, x2, x3); + sdata[index++] = (*this->localH2distributions)(D3Q27System::ET_T, x1, x2, x3); + sdata[index++] = (*this->localH2distributions)(D3Q27System::ET_NE, x1, x2, x3); + sdata[index++] = (*this->localH2distributions)(D3Q27System::ET_NW, x1 + 1, x2, x3); + sdata[index++] = (*this->localH2distributions)(D3Q27System::ET_TE, x1, x2, x3); + sdata[index++] = (*this->localH2distributions)(D3Q27System::ET_TW, x1 + 1, x2, x3); + sdata[index++] = (*this->localH2distributions)(D3Q27System::ET_TN, x1, x2, x3); + sdata[index++] = (*this->localH2distributions)(D3Q27System::ET_TS, x1, x2 + 1, x3); + sdata[index++] = (*this->localH2distributions)(D3Q27System::ET_TNE, x1, x2, x3); + sdata[index++] = (*this->localH2distributions)(D3Q27System::ET_TNW, x1 + 1, x2, x3); + sdata[index++] = (*this->localH2distributions)(D3Q27System::ET_TSE, x1, x2 + 1, x3); + sdata[index++] = (*this->localH2distributions)(D3Q27System::ET_TSW, x1 + 1, x2 + 1, x3); + + sdata[index++] = (*this->nonLocalH2distributions)(D3Q27System::ET_W, x1 + 1, x2, x3); + sdata[index++] = (*this->nonLocalH2distributions)(D3Q27System::ET_S, x1, x2 + 1, x3); + sdata[index++] = (*this->nonLocalH2distributions)(D3Q27System::ET_B, x1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalH2distributions)(D3Q27System::ET_SW, x1 + 1, x2 + 1, x3); + sdata[index++] = (*this->nonLocalH2distributions)(D3Q27System::ET_SE, x1, x2 + 1, x3); + sdata[index++] = (*this->nonLocalH2distributions)(D3Q27System::ET_BW, x1 + 1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalH2distributions)(D3Q27System::ET_BE, x1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalH2distributions)(D3Q27System::ET_BS, x1, x2 + 1, x3 + 1); + sdata[index++] = (*this->nonLocalH2distributions)(D3Q27System::ET_BN, x1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalH2distributions)(D3Q27System::ET_BSW, x1 + 1, x2 + 1, x3 + 1); + sdata[index++] = (*this->nonLocalH2distributions)(D3Q27System::ET_BSE, x1, x2 + 1, x3 + 1); + sdata[index++] = (*this->nonLocalH2distributions)(D3Q27System::ET_BNW, x1 + 1, x2, x3 + 1); + sdata[index++] = (*this->nonLocalH2distributions)(D3Q27System::ET_BNE, x1, x2, x3 + 1); + + sdata[index++] = (*this->zeroH2distributions)(x1, x2, x3); + + sdata[index++] = (*this->pressure)(x1, x2, x3); +} +////////////////////////////////////////////////////////////////////////// +inline void ThreeDistributionsDoubleGhostLayerFullVectorConnector::distributeData(vector_type& rdata, int& index, int x1, int x2, int x3) +{ + (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_NW, x1 + 1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_TW, x1 + 1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_TS, x1, x2 + 1, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_TNW, x1 + 1, x2, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2 + 1, x3) = rdata[index++]; + (*this->localDistributions)(D3Q27System::ET_TSW, x1 + 1, x2 + 1, x3) = rdata[index++]; + + (*this->nonLocalDistributions)(D3Q27System::ET_W, x1 + 1, x2, x3) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2 + 1, x3) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1 + 1, x2 + 1, x3) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2 + 1, x3) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1 + 1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2 + 1, x3 + 1) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1 + 1, x2 + 1, x3 + 1) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2 + 1, x3 + 1) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1 + 1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3 + 1) = rdata[index++]; + + (*this->zeroDistributions)(x1, x2, x3) = rdata[index++]; + + + (*this->localHdistributions)(D3Q27System::ET_E, x1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_N, x1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_T, x1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_NE, x1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_NW, x1 + 1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_TE, x1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_TW, x1 + 1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_TN, x1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_TS, x1, x2 + 1, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_TNE, x1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_TNW, x1 + 1, x2, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_TSE, x1, x2 + 1, x3) = rdata[index++]; + (*this->localHdistributions)(D3Q27System::ET_TSW, x1 + 1, x2 + 1, x3) = rdata[index++]; + + (*this->nonLocalHdistributions)(D3Q27System::ET_W, x1 + 1, x2, x3) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_S, x1, x2 + 1, x3) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_B, x1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_SW, x1 + 1, x2 + 1, x3) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_SE, x1, x2 + 1, x3) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_BW, x1 + 1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_BE, x1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_BS, x1, x2 + 1, x3 + 1) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_BN, x1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_BSW, x1 + 1, x2 + 1, x3 + 1) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_BSE, x1, x2 + 1, x3 + 1) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_BNW, x1 + 1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalHdistributions)(D3Q27System::ET_BNE, x1, x2, x3 + 1) = rdata[index++]; + + (*this->zeroHdistributions)(x1, x2, x3) = rdata[index++]; + + (*this->localH2distributions)(D3Q27System::ET_E, x1, x2, x3) = rdata[index++]; + (*this->localH2distributions)(D3Q27System::ET_N, x1, x2, x3) = rdata[index++]; + (*this->localH2distributions)(D3Q27System::ET_T, x1, x2, x3) = rdata[index++]; + (*this->localH2distributions)(D3Q27System::ET_NE, x1, x2, x3) = rdata[index++]; + (*this->localH2distributions)(D3Q27System::ET_NW, x1 + 1, x2, x3) = rdata[index++]; + (*this->localH2distributions)(D3Q27System::ET_TE, x1, x2, x3) = rdata[index++]; + (*this->localH2distributions)(D3Q27System::ET_TW, x1 + 1, x2, x3) = rdata[index++]; + (*this->localH2distributions)(D3Q27System::ET_TN, x1, x2, x3) = rdata[index++]; + (*this->localH2distributions)(D3Q27System::ET_TS, x1, x2 + 1, x3) = rdata[index++]; + (*this->localH2distributions)(D3Q27System::ET_TNE, x1, x2, x3) = rdata[index++]; + (*this->localH2distributions)(D3Q27System::ET_TNW, x1 + 1, x2, x3) = rdata[index++]; + (*this->localH2distributions)(D3Q27System::ET_TSE, x1, x2 + 1, x3) = rdata[index++]; + (*this->localH2distributions)(D3Q27System::ET_TSW, x1 + 1, x2 + 1, x3) = rdata[index++]; + + (*this->nonLocalH2distributions)(D3Q27System::ET_W, x1 + 1, x2, x3) = rdata[index++]; + (*this->nonLocalH2distributions)(D3Q27System::ET_S, x1, x2 + 1, x3) = rdata[index++]; + (*this->nonLocalH2distributions)(D3Q27System::ET_B, x1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalH2distributions)(D3Q27System::ET_SW, x1 + 1, x2 + 1, x3) = rdata[index++]; + (*this->nonLocalH2distributions)(D3Q27System::ET_SE, x1, x2 + 1, x3) = rdata[index++]; + (*this->nonLocalH2distributions)(D3Q27System::ET_BW, x1 + 1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalH2distributions)(D3Q27System::ET_BE, x1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalH2distributions)(D3Q27System::ET_BS, x1, x2 + 1, x3 + 1) = rdata[index++]; + (*this->nonLocalH2distributions)(D3Q27System::ET_BN, x1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalH2distributions)(D3Q27System::ET_BSW, x1 + 1, x2 + 1, x3 + 1) = rdata[index++]; + (*this->nonLocalH2distributions)(D3Q27System::ET_BSE, x1, x2 + 1, x3 + 1) = rdata[index++]; + (*this->nonLocalH2distributions)(D3Q27System::ET_BNW, x1 + 1, x2, x3 + 1) = rdata[index++]; + (*this->nonLocalH2distributions)(D3Q27System::ET_BNE, x1, x2, x3 + 1) = rdata[index++]; + + (*this->zeroH2distributions)(x1, x2, x3) = rdata[index++]; + + (*this->pressure)(x1, x2, x3) = rdata[index++]; +} + + +#endif + diff --git a/src/cpu/VirtualFluidsCore/Data/DataSet3D.h b/src/cpu/VirtualFluidsCore/Data/DataSet3D.h index e53e38a74daea2a2a40ca53eff1aa1f4febcc27a..12b9e57489e39c15e912b5b679b768c16b89a83b 100644 --- a/src/cpu/VirtualFluidsCore/Data/DataSet3D.h +++ b/src/cpu/VirtualFluidsCore/Data/DataSet3D.h @@ -44,6 +44,7 @@ using AverageValuesArray3D = CbArray4D<LBMReal, IndexerX4X3X2X1>; using ShearStressValuesArray3D = CbArray4D<LBMReal, IndexerX4X3X2X1>; using RelaxationFactorArray3D = CbArray3D<LBMReal, IndexerX3X2X1>; using PhaseFieldArray3D = CbArray3D<LBMReal, IndexerX3X2X1>; +using PressureFieldArray3D = CbArray3D<LBMReal, IndexerX3X2X1>; //! A class provides an interface for data structures in the kernel. class DataSet3D @@ -88,6 +89,9 @@ public: SPtr<PhaseFieldArray3D> getPhaseField2() const; void setPhaseField2(SPtr<PhaseFieldArray3D> values); + SPtr<PressureFieldArray3D> getPressureField() const; + void setPressureField(SPtr<PressureFieldArray3D> values); + protected: private: SPtr<DistributionArray3D> fdistributions; @@ -103,8 +107,10 @@ private: SPtr<ShearStressValuesArray3D> shearStressValues; SPtr<RelaxationFactorArray3D> relaxationFactor; + SPtr<PhaseFieldArray3D> phaseField; SPtr<PhaseFieldArray3D> phaseField2; + SPtr<PressureFieldArray3D> pressureField; }; inline SPtr<DistributionArray3D> DataSet3D::getFdistributions() const { return fdistributions; } @@ -162,4 +168,8 @@ inline SPtr<PhaseFieldArray3D> DataSet3D::getPhaseField2() const { return phaseF inline void DataSet3D::setPhaseField2(SPtr<PhaseFieldArray3D> values) { phaseField2 = values; } +inline SPtr<PressureFieldArray3D> DataSet3D::getPressureField() const { return pressureField; } + +inline void DataSet3D::setPressureField(SPtr<PressureFieldArray3D> values) { pressureField = values; } + #endif diff --git a/src/cpu/VirtualFluidsCore/Grid/Grid3D.cpp b/src/cpu/VirtualFluidsCore/Grid/Grid3D.cpp index 1d37e4a09f5c45967a76eb7ff1abc7999788c8b9..361b06a5dd1c549b059cc1db87b7d9c1ce384f5b 100644 --- a/src/cpu/VirtualFluidsCore/Grid/Grid3D.cpp +++ b/src/cpu/VirtualFluidsCore/Grid/Grid3D.cpp @@ -501,7 +501,7 @@ double Grid3D::getDeltaX(SPtr<Block3D> block) const { return getDeltaX(block->ge UbTupleDouble3 Grid3D::getNodeOffset(SPtr<Block3D> block) const { double delta = this->getDeltaX(block); - return makeUbTuple(OFFSET * delta, OFFSET * delta, OFFSET * delta); + return makeUbTuple(offset * delta, offset * delta, offset * delta); } //////////////////////////////////////////////////////////////////////////// Vector3D Grid3D::getNodeCoordinates(SPtr<Block3D> block, int ix1, int ix2, int ix3) const @@ -2221,6 +2221,16 @@ void Grid3D::calcStartCoordinatesWithOutOverlap(SPtr<Block3D> block, double &wor } } ////////////////////////////////////////////////////////////////////////// +int Grid3D::getGhostLayerWidth() const +{ + return static_cast<int>(offset + 0.5); +} +////////////////////////////////////////////////////////////////////////// +void Grid3D::setGhostLayerWidth(int ghostLayerWidth) +{ + this->offset = static_cast<double>(ghostLayerWidth) - 0.5; +} +////////////////////////////////////////////////////////////////////////// void Grid3D::setTimeStep(double step) { timeStep = step; } ////////////////////////////////////////////////////////////////////////// double Grid3D::getTimeStep() const { return timeStep; } diff --git a/src/cpu/VirtualFluidsCore/Grid/Grid3D.h b/src/cpu/VirtualFluidsCore/Grid/Grid3D.h index f3aa968316fcc74f77584ad58ae7114dcab0840c..5e1eb0da8de21a500b750777db7a1a7cd7f8d050 100644 --- a/src/cpu/VirtualFluidsCore/Grid/Grid3D.h +++ b/src/cpu/VirtualFluidsCore/Grid/Grid3D.h @@ -51,8 +51,6 @@ class Communicator; class Block3D; class Interactor3D; -#define OFFSET 0.5 - //! A class implements block grid ////////////////////////////////////////////////////////////////////////// class Grid3D : public enableSharedFromThis<Grid3D> @@ -214,9 +212,10 @@ public: int getNX1() const; int getNX2() const; int getNX3() const; - void calcStartCoordinatesAndDelta(SPtr<Block3D> block, double &worldX1, double &worldX2, double &worldX3, - double &deltaX); + void calcStartCoordinatesAndDelta(SPtr<Block3D> block, double &worldX1, double &worldX2, double &worldX3, double &deltaX); void calcStartCoordinatesWithOutOverlap(SPtr<Block3D> block, double &worldX1, double &worldX2, double &worldX3); + int getGhostLayerWidth() const; + void setGhostLayerWidth(int ghostLayerWidth); ////////////////////////////////////////////////////////////////////////// // LBM // double getDeltaT(SPtr<Block3D>) const; @@ -313,6 +312,8 @@ private: double orgDeltaX{ 1.0 }; double timeStep{ 0.0 }; + + double offset{ 0.5 }; }; #endif diff --git a/src/cpu/VirtualFluidsCore/Interactors/InteractorsHelper.cpp b/src/cpu/VirtualFluidsCore/Interactors/InteractorsHelper.cpp index d8ee6593400e8bc89dde7d2708f31595e86f1a5b..6739e5599c4c21fc1d91b8144686631fede40913 100644 --- a/src/cpu/VirtualFluidsCore/Interactors/InteractorsHelper.cpp +++ b/src/cpu/VirtualFluidsCore/Interactors/InteractorsHelper.cpp @@ -80,7 +80,7 @@ void InteractorsHelper::deleteSolidBlocks() } } - if (deleteBlocks) + if (interactors.size() > 0 && deleteBlocks) updateGrid(); } ////////////////////////////////////////////////////////////////////////// diff --git a/src/cpu/VirtualFluidsCore/LBM/LBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/LBMKernel.cpp index f3d168733db86ea03a72a9741ba819ed6874a0c1..92a475c1ea4de06abb3f66bf42924273904f84cc 100644 --- a/src/cpu/VirtualFluidsCore/LBM/LBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/LBMKernel.cpp @@ -111,12 +111,13 @@ void LBMKernel::setForcingX3(const std::string &muParserString) ////////////////////////////////////////////////////////////////////////// void LBMKernel::checkFunction(mu::Parser fct) { - double x1 = 1.0, x2 = 1.0, x3 = 1.0, dt = 1.0, nue = 1.0; + double x1 = 1.0, x2 = 1.0, x3 = 1.0, dt = 1.0, nue = 1.0, rho = 1.0; fct.DefineVar("x1", &x1); fct.DefineVar("x2", &x2); fct.DefineVar("x3", &x3); fct.DefineVar("dt", &dt); fct.DefineVar("nue", &nue); + fct.DefineVar("rho", &rho); try { fct.Eval(); @@ -231,3 +232,5 @@ double LBMKernel::getPhaseFieldRelaxation() const { return tauH; } ////////////////////////////////////////////////////////////////////////// void LBMKernel::setMobility(double mob) { this->mob = mob; } ////////////////////////////////////////////////////////////////////////// +void LBMKernel::setInterfaceWidth(double w) { this->interfaceWidth = w; } +////////////////////////////////////////////////////////////////////////// diff --git a/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h index 5c3e067656e2fc5cb06046e28c0442b15c180050..2c65e4d761cff39e638eb9c66d73a489b387b70c 100644 --- a/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h +++ b/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h @@ -128,6 +128,7 @@ public: void setPhaseFieldRelaxation(double tauH); double getPhaseFieldRelaxation() const; void setMobility(double mob); + void setInterfaceWidth(double w); protected: SPtr<DataSet3D> dataSet; @@ -163,6 +164,7 @@ protected: LBMReal phiH; LBMReal tauH; LBMReal mob; + LBMReal interfaceWidth; private: void checkFunction(mu::Parser fct); diff --git a/src/cpu/VirtualFluidsCore/LBM/MultiphaseCumulantLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/MultiphaseCumulantLBMKernel.cpp index e092301175713d16e9397cb1a5890967f83cb1c2..5cfee04e4a26129d0c27bc0d98c70a5ae64c3825 100644 --- a/src/cpu/VirtualFluidsCore/LBM/MultiphaseCumulantLBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/MultiphaseCumulantLBMKernel.cpp @@ -248,6 +248,12 @@ void MultiphaseCumulantLBMKernel::calculate(int step) // muX2 = static_cast<double>(x2-1+ix2*maxX2); // muX3 = static_cast<double>(x3-1+ix3*maxX3); + muForcingX1.DefineVar("rho",&muRho); + muForcingX2.DefineVar("rho",&muRho); + muForcingX3.DefineVar("rho",&muRho); + + muRho = rho; + forcingX1 = muForcingX1.Eval(); forcingX2 = muForcingX2.Eval(); forcingX3 = muForcingX3.Eval(); diff --git a/src/cpu/VirtualFluidsCore/LBM/MultiphaseCumulantLBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/MultiphaseCumulantLBMKernel.h index 0985242ba6b79dc03e7940498f24c542f475a64a..fdc47f340dbfaadfd40f4f62885350a82f2cc202 100644 --- a/src/cpu/VirtualFluidsCore/LBM/MultiphaseCumulantLBMKernel.h +++ b/src/cpu/VirtualFluidsCore/LBM/MultiphaseCumulantLBMKernel.h @@ -91,6 +91,7 @@ protected: mu::value_type muX1,muX2,muX3; mu::value_type muDeltaT; mu::value_type muNu; + mu::value_type muRho; LBMReal forcingX1; LBMReal forcingX2; LBMReal forcingX3; diff --git a/src/cpu/VirtualFluidsCore/LBM/MultiphaseScratchCumulantLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/MultiphaseScratchCumulantLBMKernel.cpp index 505007e0cc2c7ef8238956568224125e046aafa1..77695179c9d3750eed80f0bf56e57103a691df9c 100644 --- a/src/cpu/VirtualFluidsCore/LBM/MultiphaseScratchCumulantLBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/MultiphaseScratchCumulantLBMKernel.cpp @@ -39,6 +39,7 @@ #include "DataSet3D.h" #include "LBMKernel.h" #include <cmath> +#include <iostream> #define PROOF_CORRECTNESS @@ -163,6 +164,16 @@ void MultiphaseScratchCumulantLBMKernel::calculate(int step) new CbArray3D<LBMReal, IndexerX3X2X1>(bcArrayMaxX1, bcArrayMaxX2, bcArrayMaxX3, 0.0)); + /////For velocity filter + + //CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr velocityX( + // new CbArray3D<LBMReal, IndexerX3X2X1>(bcArrayMaxX1, bcArrayMaxX2, bcArrayMaxX3, 0.0)); + //CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr velocityY( + // new CbArray3D<LBMReal, IndexerX3X2X1>(bcArrayMaxX1, bcArrayMaxX2, bcArrayMaxX3, 0.0)); + //CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr velocityZ( + // new CbArray3D<LBMReal, IndexerX3X2X1>(bcArrayMaxX1, bcArrayMaxX2, bcArrayMaxX3, 0.0)); + + for (int x3 = 0; x3 <= maxX3; x3++) { for (int x2 = 0; x2 <= maxX2; x2++) { for (int x1 = 0; x1 <= maxX1; x1++) { @@ -207,7 +218,63 @@ void MultiphaseScratchCumulantLBMKernel::calculate(int step) // (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + // (mfbaa + mfbac + mfbca + mfbcc) + (mfabb + mfcbb) + // (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; + + ///Velocity filter + + + LBMReal rhoH = 1.0; + LBMReal rhoL = 1.0 / densityRatio; + + LBMReal rhoToPhi = (rhoH - rhoL) / (phiH - phiL); + + + LBMReal rho = rhoH + rhoToPhi * ((*phaseField)(x1, x2, x3) - phiH); + + mfbbc = (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3) / rho * c3; + mfbcb = (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3) / rho * c3; + mfccb = (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3) / rho * c3; + mfacb = (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3) / rho * c3; + mfcbb = (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3) / rho * c3; + mfcbc = (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3) / rho * c3; + mfabc = (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3) / rho * c3; + mfbcc = (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3) / rho * c3; + mfbac = (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3) / rho * c3; + mfccc = (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3) / rho * c3; + mfacc = (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3) / rho * c3; + mfcac = (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3) / rho * c3; + mfaac = (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3) / rho * c3; + + mfabb = (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3) / rho * c3; + mfbab = (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3) / rho * c3; + mfbba = (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p) / rho * c3; + mfaab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3) / rho * c3; + mfcab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3) / rho * c3; + mfaba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p) / rho * c3; + mfcba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p) / rho * c3; + mfbaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p) / rho * c3; + mfbca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p) / rho * c3; + mfaaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p) / rho * c3; + mfcaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p) / rho * c3; + mfaca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p) / rho * c3; + mfcca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p) / rho * c3; + + mfbbb = (*this->zeroDistributionsF)(x1, x2, x3) / rho * c3; + + //(*velocityX)(x1, x2, x3) = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + + // (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + + // (mfcbb - mfabb)) ; + //(*velocityY)(x1, x2, x3) = ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + + // (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + + // (mfbcb - mfbab)) ; + //(*velocityZ)(x1, x2, x3) = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + + // (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + + // (mfbbc - mfbba)) ; + + + + } + else { (*phaseField)(x1, x2, x3) = 0; } } } } @@ -218,6 +285,10 @@ void MultiphaseScratchCumulantLBMKernel::calculate(int step) for (int x3 = minX3; x3 < maxX3; x3++) { for (int x2 = minX2; x2 < maxX2; x2++) { for (int x1 = minX1; x1 < maxX1; x1++) { + + //for (int x3 = minX3+1; x3 < maxX3-1; x3++) { + // for (int x2 = minX2+1; x2 < maxX2-1; x2++) { + // for (int x1 = minX1+1; x1 < maxX1-1; x1++) { if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) { int x1p = x1 + 1; int x2p = x2 + 1; @@ -245,7 +316,7 @@ void MultiphaseScratchCumulantLBMKernel::calculate(int step) //-1 0 1 findNeighbors(phaseField, x1, x2, x3); - + //// reading distributions here appears to be unnecessary! LBMReal mfcbb = (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3); LBMReal mfbcb = (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3); LBMReal mfbbc = (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3); @@ -284,6 +355,62 @@ void MultiphaseScratchCumulantLBMKernel::calculate(int step) LBMReal dX2_phi = gradX2_phi(); LBMReal dX3_phi = gradX3_phi(); + //LBMReal dX1_phi = 3.0*(( + // WEIGTH[TNE]*((((*phaseField)(x1 + 1, x2+1, x3+1)- (*phaseField)(x1 - 1, x2 - 1, x3 - 1))+ ((*phaseField)(x1 + 1, x2 - 1, x3 + 1) - (*phaseField)(x1 - 1, x2 + 1, x3 - 1))) + // + (((*phaseField)(x1 + 1, x2 - 1, x3 - 1) - (*phaseField)(x1 - 1, x2 + 1, x3 + 1)) + ((*phaseField)(x1 + 1, x2 + 1, x3 - 1) - (*phaseField)(x1 - 1, x2 - 1, x3 + 1)))) + // +WEIGTH[NE]* ((((*phaseField)(x1 + 1, x2 + 1, x3) - (*phaseField)(x1 - 1, x2 - 1, x3)) + ((*phaseField)(x1 + 1, x2 - 1, x3) - (*phaseField)(x1 - 1, x2 + 1, x3 ))) + // + (((*phaseField)(x1 + 1, x2, x3 - 1) - (*phaseField)(x1 - 1, x2, x3 + 1)) + ((*phaseField)(x1 + 1, x2, x3 + 1) - (*phaseField)(x1 - 1, x2, x3 - 1))))) + // +WEIGTH[N]*((*phaseField)(x1 + 1, x2, x3 ) - (*phaseField)(x1 - 1, x2, x3)) + // ); + ////if (dX1_phi != NdX1_phi) {std::cout<<dX1_phi<<" "<< NdX1_phi<<std::endl;} + + //LBMReal dX2_phi = 3.0 * (( + // WEIGTH[TNE] * ((((*phaseField)(x1 + 1, x2 + 1, x3 + 1) - (*phaseField)(x1 - 1, x2 - 1, x3 - 1)) + ((*phaseField)(x1 -1, x2 + 1, x3 + 1) - (*phaseField)(x1 + 1, x2 - 1, x3 - 1))) + // + (((*phaseField)(x1 - 1, x2 + 1, x3 - 1) - (*phaseField)(x1 + 1, x2 - 1, x3 + 1)) + ((*phaseField)(x1 + 1, x2 + 1, x3 - 1) - (*phaseField)(x1 - 1, x2 - 1, x3 + 1)))) + // + WEIGTH[NE] * ((((*phaseField)(x1 + 1, x2 + 1, x3) - (*phaseField)(x1 - 1, x2 - 1, x3)) + ((*phaseField)(x1 - 1, x2 + 1, x3) - (*phaseField)(x1 + 1, x2 - 1, x3))) + // + (((*phaseField)(x1, x2+1, x3 - 1) - (*phaseField)(x1 , x2-1, x3 + 1)) + ((*phaseField)(x1 , x2+1, x3 + 1) - (*phaseField)(x1 , x2-1, x3 - 1))))) + // + WEIGTH[N] * ((*phaseField)(x1 , x2+1, x3) - (*phaseField)(x1 , x2-1, x3)) + // ); + + //LBMReal dX3_phi = 3.0 * (( + // WEIGTH[TNE] * ((((*phaseField)(x1 + 1, x2 + 1, x3 + 1) - (*phaseField)(x1 - 1, x2 - 1, x3 - 1)) + ((*phaseField)(x1 - 1, x2 + 1, x3 + 1) - (*phaseField)(x1 + 1, x2 - 1, x3 - 1))) + // + (((*phaseField)(x1 - 1, x2 - 1, x3 + 1) - (*phaseField)(x1 + 1, x2 + 1, x3 - 1)) + ((*phaseField)(x1 + 1, x2 - 1, x3 + 1) - (*phaseField)(x1 - 1, x2 + 1, x3 - 1)))) + // + WEIGTH[NE] * ((((*phaseField)(x1 + 1, x2, x3+1) - (*phaseField)(x1 - 1, x2, x3-1)) + ((*phaseField)(x1 - 1, x2, x3+1) - (*phaseField)(x1 + 1, x2, x3-1))) + // + (((*phaseField)(x1, x2 - 1, x3 + 1) - (*phaseField)(x1, x2 + 1, x3 - 1)) + ((*phaseField)(x1, x2 + 1, x3 + 1) - (*phaseField)(x1, x2 - 1, x3 - 1))))) + // + WEIGTH[N] * ((*phaseField)(x1, x2, x3+1) - (*phaseField)(x1, x2, x3-1)) + // ); + + /////////////////////////////////////// + + //LBMReal dX1_phi2 = 1.5 * (( + // WEIGTH[TNE] * ((((*phaseField)(x1 + 2, x2 + 2, x3 + 2) - (*phaseField)(x1 - 2, x2 - 2, x3 - 2)) + ((*phaseField)(x1 + 2, x2 - 2, x3 + 2) - (*phaseField)(x1 - 2, x2 + 2, x3 - 2))) + // + (((*phaseField)(x1 + 2, x2 - 2, x3 - 2) - (*phaseField)(x1 - 2, x2 + 2, x3 + 2)) + ((*phaseField)(x1 + 2, x2 + 2, x3 - 2) - (*phaseField)(x1 - 2, x2 - 2, x3 + 2)))) + // + WEIGTH[NE] * ((((*phaseField)(x1 + 2, x2 + 2, x3) - (*phaseField)(x1 - 2, x2 - 2, x3)) + ((*phaseField)(x1 + 2, x2 - 2, x3) - (*phaseField)(x1 - 2, x2 + 2, x3))) + // + (((*phaseField)(x1 + 2, x2, x3 - 2) - (*phaseField)(x1 - 2, x2, x3 + 2)) + ((*phaseField)(x1 + 2, x2, x3 + 2) - (*phaseField)(x1 - 2, x2, x3 - 2))))) + // + WEIGTH[N] * ((*phaseField)(x1 + 2, x2, x3) - (*phaseField)(x1 - 2, x2, x3)) + // ); + ////if (dX1_phi != NdX1_phi) {std::cout<<dX1_phi<<" "<< NdX1_phi<<std::endl;} + + //LBMReal dX2_phi2 = 1.5 * (( + // WEIGTH[TNE] * ((((*phaseField)(x1 + 2, x2 + 2, x3 + 2) - (*phaseField)(x1 - 2, x2 - 2, x3 - 2)) + ((*phaseField)(x1 - 2, x2 + 2, x3 + 2) - (*phaseField)(x1 + 2, x2 - 2, x3 - 2))) + // + (((*phaseField)(x1 - 2, x2 + 2, x3 - 2) - (*phaseField)(x1 + 2, x2 - 2, x3 + 2)) + ((*phaseField)(x1 + 2, x2 + 2, x3 - 2) - (*phaseField)(x1 - 2, x2 - 2, x3 + 2)))) + // + WEIGTH[NE] * ((((*phaseField)(x1 + 2, x2 + 2, x3) - (*phaseField)(x1 - 2, x2 - 2, x3)) + ((*phaseField)(x1 - 2, x2 + 2, x3) - (*phaseField)(x1 + 2, x2 - 2, x3))) + // + (((*phaseField)(x1, x2 + 2, x3 - 2) - (*phaseField)(x1, x2 - 2, x3 + 2)) + ((*phaseField)(x1, x2 + 2, x3 + 2) - (*phaseField)(x1, x2 - 2, x3 - 2))))) + // + WEIGTH[N] * ((*phaseField)(x1, x2 + 2, x3) - (*phaseField)(x1, x2 - 2, x3)) + // ); + + //LBMReal dX3_phi2 = 1.5 * (( + // WEIGTH[TNE] * ((((*phaseField)(x1 + 2, x2 + 2, x3 + 2) - (*phaseField)(x1 - 2, x2 - 2, x3 - 2)) + ((*phaseField)(x1 - 2, x2 + 2, x3 + 2) - (*phaseField)(x1 + 2, x2 - 2, x3 - 2))) + // + (((*phaseField)(x1 - 2, x2 - 2, x3 + 2) - (*phaseField)(x1 + 2, x2 + 2, x3 - 2)) + ((*phaseField)(x1 + 2, x2 - 2, x3 + 2) - (*phaseField)(x1 - 2, x2 + 2, x3 - 2)))) + // + WEIGTH[NE] * ((((*phaseField)(x1 + 2, x2, x3 + 2) - (*phaseField)(x1 - 2, x2, x3 - 2)) + ((*phaseField)(x1 - 2, x2, x3 + 2) - (*phaseField)(x1 + 2, x2, x3 - 2))) + // + (((*phaseField)(x1, x2 - 2, x3 + 2) - (*phaseField)(x1, x2 + 2, x3 - 2)) + ((*phaseField)(x1, x2 + 2, x3 + 2) - (*phaseField)(x1, x2 - 2, x3 - 2))))) + // + WEIGTH[N] * ((*phaseField)(x1, x2, x3 + 2) - (*phaseField)(x1, x2, x3 - 2)) + // ); + + //dX1_phi = (2*dX1_phi -1*dX1_phi2);// 2 * dX1_phi - dX1_phi2; + //dX2_phi = (2*dX2_phi -1*dX2_phi2);// 2 * dX2_phi - dX2_phi2; + //dX3_phi = (2*dX3_phi -1*dX3_phi2);// 2 * dX3_phi - dX3_phi2; + LBMReal denom = sqrt(dX1_phi * dX1_phi + dX2_phi * dX2_phi + dX3_phi * dX3_phi) + 1e-9; LBMReal normX1 = dX1_phi/denom; @@ -312,20 +439,20 @@ void MultiphaseScratchCumulantLBMKernel::calculate(int step) //----------- Calculating Macroscopic Values ------------- LBMReal rho = rhoH + rhoToPhi * (phi[REST] - phiH); - if (withForcing) { - // muX1 = static_cast<double>(x1-1+ix1*maxX1); - // muX2 = static_cast<double>(x2-1+ix2*maxX2); - // muX3 = static_cast<double>(x3-1+ix3*maxX3); - - forcingX1 = muForcingX1.Eval(); - forcingX2 = muForcingX2.Eval(); - forcingX3 = muForcingX3.Eval(); + if (withForcing) { + // muX1 = static_cast<double>(x1-1+ix1*maxX1); + // muX2 = static_cast<double>(x2-1+ix2*maxX2); + // muX3 = static_cast<double>(x3-1+ix3*maxX3); - LBMReal rho_m = 1.0 / densityRatio; - forcingX1 = forcingX1 * (rho - rho_m); - forcingX2 = forcingX2 * (rho - rho_m); - forcingX3 = forcingX3 * (rho - rho_m); + forcingX1 = muForcingX1.Eval(); + forcingX2 = muForcingX2.Eval(); + forcingX3 = muForcingX3.Eval(); + LBMReal rho_m = 1.0 / densityRatio; + forcingX1 = forcingX1 * (rho - rho_m); + forcingX2 = forcingX2 * (rho - rho_m); + forcingX3 = forcingX3 * (rho - rho_m); + } ////Incompressible Kernal mfbbc = (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3)/rho*c3; @@ -387,69 +514,272 @@ void MultiphaseScratchCumulantLBMKernel::calculate(int step) vvz += mu * dX3_phi * c1o2; + + ////Velocity filter 14.04.2021 + // LBMReal lap_vx, lap_vy,lap_vz; + // { + // LBMReal sum = 0.0; + // sum += WEIGTH[TNE] * (((((*velocityX)(x1+1, x2+1, x3+1) - (*velocityX)(x1, x2, x3)) + ((*velocityX)(x1 - 1, x2 - 1, x3 - 1) - (*velocityX)(x1, x2, x3))) + (((*velocityX)(x1 + 1, x2 + 1, x3 - 1) - (*velocityX)(x1, x2, x3)) + ((*velocityX)(x1 + 1, x2 - 1, x3 + 1) - (*velocityX)(x1, x2, x3)))) + // + ((((*velocityX)(x1 + 1, x2 - 1, x3 + 1) - (*velocityX)(x1, x2, x3)) + ((*velocityX)(x1 - 1, x2 + 1, x3 - 1) - (*velocityX)(x1, x2, x3))) + (((*velocityX)(x1 - 1, x2 + 1, x3 + 1) - (*velocityX)(x1, x2, x3)) + ((*velocityX)(x1 + 1, x2 - 1, x3 - 1) - (*velocityX)(x1, x2, x3))))); + // sum += WEIGTH[TN] * ( + // ((((*velocityX)(x1 + 1, x2 + 1, x3 ) - (*velocityX)(x1, x2, x3)) + ((*velocityX)(x1 - 1, x2 - 1, x3) - (*velocityX)(x1, x2, x3))) + (((*velocityX)(x1 + 1, x2 - 1, x3) - (*velocityX)(x1, x2, x3)) + ((*velocityX)(x1 - 1, x2 + 1, x3) - (*velocityX)(x1, x2, x3)))) + // + ((((*velocityX)(x1 + 1, x2 , x3+1) - (*velocityX)(x1, x2, x3)) + ((*velocityX)(x1 - 1, x2 , x3-1) - (*velocityX)(x1, x2, x3))) + (((*velocityX)(x1 +1 , x2 , x3-1) - (*velocityX)(x1, x2, x3)) + ((*velocityX)(x1 - 1, x2, x3 + 1) - (*velocityX)(x1, x2, x3)))) + // + ((((*velocityX)(x1 , x2+1, x3 + 1) - (*velocityX)(x1, x2, x3)) + ((*velocityX)(x1, x2 - 1, x3 - 1) - (*velocityX)(x1, x2, x3))) + (((*velocityX)(x1, x2 + 1, x3 - 1) - (*velocityX)(x1, x2, x3)) + ((*velocityX)(x1, x2 - 1, x3 + 1) - (*velocityX)(x1, x2, x3)))) + // ); + // sum += WEIGTH[T] * ( + // (((*velocityX)(x1-1, x2 , x3 ) - (*velocityX)(x1, x2, x3)) + ((*velocityX)(x1 + 1, x2, x3) - (*velocityX)(x1, x2, x3))) + // + (((*velocityX)(x1 , x2-1, x3) - (*velocityX)(x1, x2, x3)) + ((*velocityX)(x1, x2 + 1, x3) - (*velocityX)(x1, x2, x3))) + // + (((*velocityX)(x1, x2, x3-1) - (*velocityX)(x1, x2, x3)) + ((*velocityX)(x1, x2, x3+1) - (*velocityX)(x1, x2, x3))) + // ); + // //for (int k = FSTARTDIR; k <= FENDDIR; k++) { + // // sum += WEIGTH[k] * (phi[k] - phi[REST]); + // //} + // lap_vx=6.0 * sum; + + //sum = 0.0; + //sum += WEIGTH[TNE] * (((((*velocityY)(x1 + 1, x2 + 1, x3 + 1) - (*velocityY)(x1, x2, x3)) + ((*velocityY)(x1 - 1, x2 - 1, x3 - 1) - (*velocityY)(x1, x2, x3))) + (((*velocityY)(x1 + 1, x2 + 1, x3 - 1) - (*velocityY)(x1, x2, x3)) + ((*velocityY)(x1 + 1, x2 - 1, x3 + 1) - (*velocityY)(x1, x2, x3)))) + // + ((((*velocityY)(x1 + 1, x2 - 1, x3 + 1) - (*velocityY)(x1, x2, x3)) + ((*velocityY)(x1 - 1, x2 + 1, x3 - 1) - (*velocityY)(x1, x2, x3))) + (((*velocityY)(x1 - 1, x2 + 1, x3 + 1) - (*velocityY)(x1, x2, x3)) + ((*velocityY)(x1 + 1, x2 - 1, x3 - 1) - (*velocityY)(x1, x2, x3))))); + //sum += WEIGTH[TN] * ( + // ((((*velocityY)(x1 + 1, x2 + 1, x3) - (*velocityY)(x1, x2, x3)) + ((*velocityY)(x1 - 1, x2 - 1, x3) - (*velocityY)(x1, x2, x3))) + (((*velocityY)(x1 + 1, x2 - 1, x3) - (*velocityY)(x1, x2, x3)) + ((*velocityY)(x1 - 1, x2 + 1, x3) - (*velocityY)(x1, x2, x3)))) + // + ((((*velocityY)(x1 + 1, x2, x3 + 1) - (*velocityY)(x1, x2, x3)) + ((*velocityY)(x1 - 1, x2, x3 - 1) - (*velocityY)(x1, x2, x3))) + (((*velocityY)(x1 + 1, x2, x3 - 1) - (*velocityY)(x1, x2, x3)) + ((*velocityY)(x1 - 1, x2, x3 + 1) - (*velocityY)(x1, x2, x3)))) + // + ((((*velocityY)(x1, x2 + 1, x3 + 1) - (*velocityY)(x1, x2, x3)) + ((*velocityY)(x1, x2 - 1, x3 - 1) - (*velocityY)(x1, x2, x3))) + (((*velocityY)(x1, x2 + 1, x3 - 1) - (*velocityY)(x1, x2, x3)) + ((*velocityY)(x1, x2 - 1, x3 + 1) - (*velocityY)(x1, x2, x3)))) + // ); + //sum += WEIGTH[T] * ( + // (((*velocityY)(x1 - 1, x2, x3) - (*velocityY)(x1, x2, x3)) + ((*velocityY)(x1 + 1, x2, x3) - (*velocityY)(x1, x2, x3))) + // + (((*velocityY)(x1, x2 - 1, x3) - (*velocityY)(x1, x2, x3)) + ((*velocityY)(x1, x2 + 1, x3) - (*velocityY)(x1, x2, x3))) + // + (((*velocityY)(x1, x2, x3 - 1) - (*velocityY)(x1, x2, x3)) + ((*velocityY)(x1, x2, x3 + 1) - (*velocityY)(x1, x2, x3))) + // ); + + //lap_vy = 6.0 * sum; + + //sum = 0.0; + //sum += WEIGTH[TNE] * (((((*velocityZ)(x1 + 1, x2 + 1, x3 + 1) - (*velocityZ)(x1, x2, x3)) + ((*velocityZ)(x1 - 1, x2 - 1, x3 - 1) - (*velocityZ)(x1, x2, x3))) + (((*velocityZ)(x1 + 1, x2 + 1, x3 - 1) - (*velocityZ)(x1, x2, x3)) + ((*velocityZ)(x1 + 1, x2 - 1, x3 + 1) - (*velocityZ)(x1, x2, x3)))) + // + ((((*velocityZ)(x1 + 1, x2 - 1, x3 + 1) - (*velocityZ)(x1, x2, x3)) + ((*velocityZ)(x1 - 1, x2 + 1, x3 - 1) - (*velocityZ)(x1, x2, x3))) + (((*velocityZ)(x1 - 1, x2 + 1, x3 + 1) - (*velocityZ)(x1, x2, x3)) + ((*velocityZ)(x1 + 1, x2 - 1, x3 - 1) - (*velocityZ)(x1, x2, x3))))); + //sum += WEIGTH[TN] * ( + // ((((*velocityZ)(x1 + 1, x2 + 1, x3) - (*velocityZ)(x1, x2, x3)) + ((*velocityZ)(x1 - 1, x2 - 1, x3) - (*velocityZ)(x1, x2, x3))) + (((*velocityZ)(x1 + 1, x2 - 1, x3) - (*velocityZ)(x1, x2, x3)) + ((*velocityZ)(x1 - 1, x2 + 1, x3) - (*velocityZ)(x1, x2, x3)))) + // + ((((*velocityZ)(x1 + 1, x2, x3 + 1) - (*velocityZ)(x1, x2, x3)) + ((*velocityZ)(x1 - 1, x2, x3 - 1) - (*velocityZ)(x1, x2, x3))) + (((*velocityZ)(x1 + 1, x2, x3 - 1) - (*velocityZ)(x1, x2, x3)) + ((*velocityZ)(x1 - 1, x2, x3 + 1) - (*velocityZ)(x1, x2, x3)))) + // + ((((*velocityZ)(x1, x2 + 1, x3 + 1) - (*velocityZ)(x1, x2, x3)) + ((*velocityZ)(x1, x2 - 1, x3 - 1) - (*velocityZ)(x1, x2, x3))) + (((*velocityZ)(x1, x2 + 1, x3 - 1) - (*velocityZ)(x1, x2, x3)) + ((*velocityZ)(x1, x2 - 1, x3 + 1) - (*velocityZ)(x1, x2, x3)))) + // ); + //sum += WEIGTH[T] * ( + // (((*velocityZ)(x1 - 1, x2, x3) - (*velocityZ)(x1, x2, x3)) + ((*velocityZ)(x1 + 1, x2, x3) - (*velocityZ)(x1, x2, x3))) + // + (((*velocityZ)(x1, x2 - 1, x3) - (*velocityZ)(x1, x2, x3)) + ((*velocityZ)(x1, x2 + 1, x3) - (*velocityZ)(x1, x2, x3))) + // + (((*velocityZ)(x1, x2, x3 - 1) - (*velocityZ)(x1, x2, x3)) + ((*velocityZ)(x1, x2, x3 + 1) - (*velocityZ)(x1, x2, x3))) + // ); + + //lap_vz = 6.0 * sum; + + // } + + // if (lap_vx != 0.0) { + // lap_vx = lap_vx; + // } + ///----Classic source term 8.4.2021 + LBMReal vvxF, vvyF, vvzF; + vvxF = vvx;//-2*c1o24 * lap_vx;// + vvyF = vvy;//-2*c1o24 * lap_vy;// + vvzF = vvz;//-2*c1o24 * lap_vz;// + +// vvxF = 1.2* vvx- 0.2*0.5 * ((*velocityX)(x1 - 1, x2, x3) + (*velocityX)(x1 + 1, x2, x3)); +// vvyF = 1.2 *vvy- 0.2*0.5* ((*velocityY)(x1 , x2-1, x3) + (*velocityY)(x1 , x2+1, x3)); +// vvzF = 1.2 *vvz-0.2*0.5* ((*velocityZ)(x1 , x2, x3-1) + (*velocityZ)(x1 , x2, x3+1)); + //if (vvxF != vvx) { + // vvxF = vvxF; + //} + LBMReal weightGrad = 1.0-denom*denom/(denom*denom+0.0001*0.001); + LBMReal dX1_phiF = dX1_phi * weightGrad + (1.0 - weightGrad) * (1.0 - phi[REST]) * (phi[REST]) * normX1; + LBMReal dX2_phiF = dX2_phi * weightGrad + (1.0 - weightGrad) * (1.0 - phi[REST]) * (phi[REST]) * normX2; + LBMReal dX3_phiF = dX3_phi * weightGrad + (1.0 - weightGrad) * (1.0 - phi[REST]) * (phi[REST]) * normX3; + + //dX1_phiF *= 1.2; + //dX2_phiF *= 1.2; + //dX3_phiF *= 1.2; + + //LBMReal gradFD = sqrt(dX1_phi * dX1_phi + dX2_phi * dX2_phi + dX3_phi * dX3_phi); + //LBMReal gradPhi = (1.0 - phi[REST]) * (phi[REST]); + //gradPhi = (gradPhi > gradFD) ? gradPhi : gradFD; + //dX1_phiF = gradPhi * normX1; + // dX2_phiF = gradPhi * normX2; + // dX3_phiF = gradPhi * normX3; + LBMReal ux2; LBMReal uy2; LBMReal uz2; - ux2 = vvx * vvx; - uy2 = vvy * vvy; - uz2 = vvz * vvz; + ux2 = vvxF * vvxF; + uy2 = vvyF * vvyF; + uz2 = vvzF * vvzF; LBMReal forcingTerm[D3Q27System::ENDF + 1]; for (int dir = STARTF; dir <= (FENDDIR); dir++) { - LBMReal velProd = DX1[dir] * vvx + DX2[dir] * vvy + DX3[dir] * vvz; + LBMReal velProd = DX1[dir] * vvxF + DX2[dir] * vvyF + DX3[dir] * vvzF; LBMReal velSq1 = velProd * velProd; - LBMReal gamma = WEIGTH[dir] * (1.0 + 3 * velProd + 4.5 * velSq1 - 1.5 * (ux2 + uy2 + uz2)); + LBMReal gamma = WEIGTH[dir] * (1.0 + 3 * velProd + (4.5 * velSq1 - 1.5 * (ux2 + uy2 + uz2))); LBMReal fac1 = (gamma - WEIGTH[dir]) * c1o3 * rhoToPhi; forcingTerm[dir] = - (-vvx) * (fac1 * dX1_phi ) + - (-vvy) * (fac1 * dX2_phi ) + - (-vvz) * (fac1 * dX3_phi ) + - (DX1[dir]) * (fac1 * dX1_phi ) + - (DX2[dir]) * (fac1 * dX2_phi ) + - (DX3[dir]) * (fac1 * dX3_phi ); + (-vvxF) * (fac1 * dX1_phiF ) + + (-vvyF) * (fac1 * dX2_phiF ) + + (-vvzF) * (fac1 * dX3_phiF ) + + (DX1[dir]) * (fac1 * dX1_phiF ) + + (DX2[dir]) * (fac1 * dX2_phiF ) + + (DX3[dir]) * (fac1 * dX3_phiF ); + + //LBMReal biDif= (-((*phaseField)(x1 + 2 * DX1[dir], x2 + 2 * DX2[dir], x3 + 2 * DX3[dir])) + 4 * ((*phaseField)(x1 + DX1[dir], x2 + DX2[dir], x3 + DX3[dir])) + // - 3*((*phaseField)(x1 , x2 , x3 )) )*0.5; + //LBMReal ceDif = (((*phaseField)(x1 + DX1[dir], x2 + DX2[dir], x3 + DX3[dir])) - ((*phaseField)(x1 - DX1[dir], x2 - DX2[dir], x3 - DX3[dir]))) * 0.5; + + ////ceDif = ((((*phaseField)(x1 + 2*DX1[dir], x2 + 2*DX2[dir], x3 + 2*DX3[dir])) - ((*phaseField)(x1 , x2 , x3 ))) * biDif < 0) ? + //// (!bcArray->isSolid(x1+2*DX1[dir], x2+2*DX2[dir], x3+2*DX3[dir]) && !bcArray->isUndefined(x1 + 2 * DX1[dir], x2 + 2 * DX2[dir], x3 + 2 * DX3[dir]) && !bcArray->isSolid(x1 + DX1[dir], x2 + DX2[dir], x3 + DX3[dir]) && !bcArray->isUndefined(x1 + DX1[dir], x2 + DX2[dir], x3 + DX3[dir]) && !bcArray->isSolid(x1 - DX1[dir], x2 - DX2[dir], x3 - DX3[dir]) && !bcArray->isUndefined(x1 - DX1[dir], x2 - DX2[dir], x3 - DX3[dir])) ? + //// (biDif+ceDif)*0.5 : ceDif: ceDif; + + //ceDif = ((((*phaseField)(x1 + 2 * DX1[dir], x2 + 2 * DX2[dir], x3 + 2 * DX3[dir])) - ((*phaseField)(x1, x2, x3))) * biDif < 0) ? biDif : ceDif; + + //forcingTerm[dir] = + // (-vvxF) * (fac1 * dX1_phiF) + + // (-vvyF) * (fac1 * dX2_phiF) + + // (-vvzF) * (fac1 * dX3_phiF) + + // fac1 * ceDif;//(((*phaseField)(x1 + DX1[dir], x2 + DX2[dir], x3 + DX3[dir])) - ((*phaseField)(x1 - DX1[dir], x2 - DX2[dir], x3 - DX3[dir]))) * 0.5; + // //( -((*phaseField)(x1 +2* DX1[dir], x2 + 2 * DX2[dir], x3 + 2 * DX3[dir])) + 5*((*phaseField)(x1 + DX1[dir], x2 + DX2[dir], x3 + DX3[dir])) + // //- 3*((*phaseField)(x1 , x2 , x3 )) - ((*phaseField)(x1 - DX1[dir], x2 - DX2[dir], x3 - DX3[dir])) )*0.25; + + } LBMReal gamma = WEIGTH[REST] * (1.0 - 1.5 * (ux2 + uy2 + uz2)); LBMReal fac1 = (gamma - WEIGTH[REST]) * c1o3 * rhoToPhi; - forcingTerm[REST] = (-vvx) * (fac1 * dX1_phi ) + - (-vvy) * (fac1 * dX2_phi ) + - (-vvz) * (fac1 * dX3_phi ); - - mfcbb += 3.0 * ( 0.5 * forcingTerm[E]) / rho; //-(3.0*p1 - rho)*WEIGTH[E ]; - mfbcb += 3.0 * ( 0.5 * forcingTerm[N]) / rho; //-(3.0*p1 - rho)*WEIGTH[N ]; - mfbbc += 3.0 * ( 0.5 * forcingTerm[T]) / rho; //-(3.0*p1 - rho)*WEIGTH[T ]; - mfccb += 3.0 * ( 0.5 * forcingTerm[NE]) / rho; //-(3.0*p1 - rho)*WEIGTH[NE ]; - mfacb += 3.0 * ( 0.5 * forcingTerm[NW]) / rho; //-(3.0*p1 - rho)*WEIGTH[NW ]; - mfcbc += 3.0 * ( 0.5 * forcingTerm[TE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TE ]; - mfabc += 3.0 * ( 0.5 * forcingTerm[TW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TW ]; - mfbcc += 3.0 * ( 0.5 * forcingTerm[TN]) / rho; //-(3.0*p1 - rho)*WEIGTH[TN ]; - mfbac += 3.0 * ( 0.5 * forcingTerm[TS]) / rho; //-(3.0*p1 - rho)*WEIGTH[TS ]; - mfccc += 3.0 * ( 0.5 * forcingTerm[TNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNE]; - mfacc += 3.0 * ( 0.5 * forcingTerm[TNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNW]; - mfcac += 3.0 * ( 0.5 * forcingTerm[TSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSE]; - mfaac += 3.0 * ( 0.5 * forcingTerm[TSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSW]; - mfabb += 3.0 * ( 0.5 * forcingTerm[W]) / rho; //-(3.0*p1 - rho)*WEIGTH[W ]; - mfbab += 3.0 * ( 0.5 * forcingTerm[S]) / rho; //-(3.0*p1 - rho)*WEIGTH[S ]; - mfbba += 3.0 * ( 0.5 * forcingTerm[B]) / rho; //-(3.0*p1 - rho)*WEIGTH[B ]; - mfaab += 3.0 * ( 0.5 * forcingTerm[SW]) / rho; //-(3.0*p1 - rho)*WEIGTH[SW ]; - mfcab += 3.0 * ( 0.5 * forcingTerm[SE]) / rho; //-(3.0*p1 - rho)*WEIGTH[SE ]; - mfaba += 3.0 * ( 0.5 * forcingTerm[BW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BW ]; - mfcba += 3.0 * ( 0.5 * forcingTerm[BE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BE ]; - mfbaa += 3.0 * ( 0.5 * forcingTerm[BS]) / rho; //-(3.0*p1 - rho)*WEIGTH[BS ]; - mfbca += 3.0 * ( 0.5 * forcingTerm[BN]) / rho; //-(3.0*p1 - rho)*WEIGTH[BN ]; - mfaaa += 3.0 * ( 0.5 * forcingTerm[BSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSW]; - mfcaa += 3.0 * ( 0.5 * forcingTerm[BSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSE]; - mfaca += 3.0 * ( 0.5 * forcingTerm[BNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNW]; - mfcca += 3.0 * ( 0.5 * forcingTerm[BNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNE]; - mfbbb += 3.0 * ( 0.5 * forcingTerm[REST]) / rho; //- (3.0*p1 - rho)*WEIGTH[REST] + forcingTerm[REST] = (-vvxF) * (fac1 * dX1_phiF ) + + (-vvyF) * (fac1 * dX2_phiF ) + + (-vvzF) * (fac1 * dX3_phiF ); - //-------------------------------------------------------- + //////// + // LBMReal divAfterSource= + //( mfcbb + 3.0 * (0.5 * forcingTerm[E]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF) *(vvyF) +(vvzF) *(vvzF)-1)+ + //( mfbcb + 3.0 * (0.5 * forcingTerm[N]) / rho ) *((vvxF) *(vvxF) +(vvyF-1)*(vvyF-1)+(vvzF) *(vvzF)-1)+ + //( mfbbc + 3.0 * (0.5 * forcingTerm[T]) / rho ) *((vvxF) *(vvxF) +(vvyF) *(vvyF) +(vvzF-1)*(vvzF-1)-1)+ + //( mfccb + 3.0 * (0.5 * forcingTerm[NE]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF-1)*(vvyF-1)+(vvzF) *(vvzF)-1)+ + //( mfacb + 3.0 * (0.5 * forcingTerm[NW]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF-1)*(vvyF-1)+(vvzF) *(vvzF)-1)+ + //( mfcbc + 3.0 * (0.5 * forcingTerm[TE]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF) *(vvyF) +(vvzF-1)*(vvzF-1)-1)+ + //( mfabc + 3.0 * (0.5 * forcingTerm[TW]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF) *(vvyF) +(vvzF-1)*(vvzF-1)-1)+ + //( mfbcc + 3.0 * (0.5 * forcingTerm[TN]) / rho ) *((vvxF) *(vvxF) +(vvyF-1)*(vvyF-1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfbac + 3.0 * (0.5 * forcingTerm[TS]) / rho ) *((vvxF) *(vvxF) +(vvyF+1)*(vvyF+1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfccc + 3.0 * (0.5 * forcingTerm[TNE]) / rho) *((vvxF-1)*(vvxF-1)+(vvyF-1)*(vvyF-1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfacc + 3.0 * (0.5 * forcingTerm[TNW]) / rho) *((vvxF+1)*(vvxF+1)+(vvyF-1)*(vvyF-1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfcac + 3.0 * (0.5 * forcingTerm[TSE]) / rho) *((vvxF-1)*(vvxF-1)+(vvyF+1)*(vvyF+1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfaac + 3.0 * (0.5 * forcingTerm[TSW]) / rho) *((vvxF+1)*(vvxF+1)+(vvyF+1)*(vvyF+1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfabb + 3.0 * (0.5 * forcingTerm[W]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF) *(vvyF) +(vvzF) *(vvzF)-1)+ + //( mfbab + 3.0 * (0.5 * forcingTerm[S]) / rho ) *((vvxF) *(vvxF) +(vvyF+1)*(vvyF+1)+(vvzF) *(vvzF)-1)+ + //( mfbba + 3.0 * (0.5 * forcingTerm[B]) / rho ) *((vvxF) *(vvxF) +(vvyF) *(vvyF) +(vvzF+1)*(vvzF+1)-1)+ + //( mfaab + 3.0 * (0.5 * forcingTerm[SW]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF+1)*(vvyF+1)+(vvzF) *(vvzF)-1)+ + //( mfcab + 3.0 * (0.5 * forcingTerm[SE]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF+1)*(vvyF+1)+(vvzF) *(vvzF)-1)+ + //( mfaba + 3.0 * (0.5 * forcingTerm[BW]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF) *(vvyF) +(vvzF+1)*(vvzF+1)-1)+ + //( mfcba + 3.0 * (0.5 * forcingTerm[BE]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF) *(vvyF) +(vvzF+1)*(vvzF+1)-1)+ + //( mfbaa + 3.0 * (0.5 * forcingTerm[BS]) / rho ) *((vvxF) *(vvxF) +(vvyF+1)*(vvyF+1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfbca + 3.0 * (0.5 * forcingTerm[BN]) / rho ) *((vvxF) *(vvxF) +(vvyF-1)*(vvyF-1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfaaa + 3.0 * (0.5 * forcingTerm[BSW]) / rho) *((vvxF+1)*(vvxF+1)+(vvyF+1)*(vvyF+1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfcaa + 3.0 * (0.5 * forcingTerm[BSE]) / rho) *((vvxF-1)*(vvxF-1)+(vvyF+1)*(vvyF+1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfaca + 3.0 * (0.5 * forcingTerm[BNW]) / rho) *((vvxF+1)*(vvxF+1)+(vvyF-1)*(vvyF-1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfcca + 3.0 * (0.5 * forcingTerm[BNE]) / rho) *((vvxF-1)*(vvxF-1)+(vvyF-1)*(vvyF-1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfbbb + 3.0 * (0.5 * forcingTerm[REST]) / rho)*((vvxF)*(vvxF)+(vvyF)*(vvyF)+(vvzF)*(vvzF)-1); + + // LBMReal divBeforeSource = + // (mfcbb) * ((vvxF - 1) * (vvxF - 1) + (vvyF) * (vvyF)+(vvzF) * (vvzF)-1) + + // (mfbcb) * ((vvxF) * (vvxF)+(vvyF - 1) * (vvyF - 1) + (vvzF) * (vvzF)-1) + + // (mfbbc) * ((vvxF) * (vvxF)+(vvyF) * (vvyF)+(vvzF - 1) * (vvzF - 1)-1) + + // (mfccb) * ((vvxF - 1) * (vvxF - 1) + (vvyF - 1) * (vvyF - 1) + (vvzF) * (vvzF)-1) + + // (mfacb) * ((vvxF + 1) * (vvxF + 1) + (vvyF - 1) * (vvyF - 1) + (vvzF) * (vvzF)-1) + + // (mfcbc) * ((vvxF - 1) * (vvxF - 1) + (vvyF) * (vvyF)+(vvzF - 1) * (vvzF - 1)-1) + + // (mfabc) * ((vvxF + 1) * (vvxF + 1) + (vvyF) * (vvyF)+(vvzF - 1) * (vvzF - 1)-1) + + // (mfbcc) * ((vvxF) * (vvxF)+(vvyF - 1) * (vvyF - 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfbac) * ((vvxF) * (vvxF)+(vvyF + 1) * (vvyF + 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfccc) * ((vvxF - 1) * (vvxF - 1) + (vvyF - 1) * (vvyF - 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfacc) * ((vvxF + 1) * (vvxF + 1) + (vvyF - 1) * (vvyF - 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfcac) * ((vvxF - 1) * (vvxF - 1) + (vvyF + 1) * (vvyF + 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfaac) * ((vvxF + 1) * (vvxF + 1) + (vvyF + 1) * (vvyF + 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfabb) * ((vvxF + 1) * (vvxF + 1) + (vvyF) * (vvyF)+(vvzF) * (vvzF)-1) + + // (mfbab) * ((vvxF) * (vvxF)+(vvyF + 1) * (vvyF + 1) + (vvzF) * (vvzF)-1) + + // (mfbba) * ((vvxF) * (vvxF)+(vvyF) * (vvyF)+(vvzF + 1) * (vvzF + 1)-1) + + // (mfaab) * ((vvxF + 1) * (vvxF + 1) + (vvyF + 1) * (vvyF + 1) + (vvzF) * (vvzF)-1) + + // (mfcab) * ((vvxF - 1) * (vvxF - 1) + (vvyF + 1) * (vvyF + 1) + (vvzF) * (vvzF)-1) + + // (mfaba) * ((vvxF + 1) * (vvxF + 1) + (vvyF) * (vvyF)+(vvzF + 1) * (vvzF + 1)-1) + + // (mfcba) * ((vvxF - 1) * (vvxF - 1) + (vvyF) * (vvyF)+(vvzF + 1) * (vvzF + 1)-1) + + // (mfbaa) * ((vvxF) * (vvxF)+(vvyF + 1) * (vvyF + 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfbca) * ((vvxF) * (vvxF)+(vvyF - 1) * (vvyF - 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfaaa) * ((vvxF + 1) * (vvxF + 1) + (vvyF + 1) * (vvyF + 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfcaa) * ((vvxF - 1) * (vvxF - 1) + (vvyF + 1) * (vvyF + 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfaca) * ((vvxF + 1) * (vvxF + 1) + (vvyF - 1) * (vvyF - 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfcca) * ((vvxF - 1) * (vvxF - 1) + (vvyF - 1) * (vvyF - 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfbbb) * ((vvxF) * (vvxF)+(vvyF) * (vvyF)+(vvzF) * (vvzF)-1); + //if (divAfterSource - divBeforeSource != 0 && phi[REST]>0.0001 && phi[REST]<0.999) { + // std::cout << phi[REST]<<" "<< divAfterSource << " " << divBeforeSource <<" "<< divAfterSource/ divBeforeSource << std::endl; + //} + + //if (fabs(divAfterSource - divBeforeSource)/(fabs(divAfterSource) + fabs(divBeforeSource)+1e-10) > 1e-5) { + // LBMReal scaleDiv =0.95+(1-0.95)* (divBeforeSource) / (divBeforeSource - divAfterSource); + + // forcingTerm[E] *=scaleDiv; + // forcingTerm[N] *=scaleDiv; + // forcingTerm[T] *=scaleDiv; + // forcingTerm[NE] *=scaleDiv; + // forcingTerm[NW] *=scaleDiv; + // forcingTerm[TE] *=scaleDiv; + // forcingTerm[TW] *=scaleDiv; + // forcingTerm[TN] *=scaleDiv; + // forcingTerm[TS] *=scaleDiv; + // forcingTerm[TNE] *=scaleDiv; + // forcingTerm[TNW] *=scaleDiv; + // forcingTerm[TSE] *=scaleDiv; + // forcingTerm[TSW] *=scaleDiv; + // forcingTerm[W] *=scaleDiv; + // forcingTerm[S] *=scaleDiv; + // forcingTerm[B] *=scaleDiv; + // forcingTerm[SW] *=scaleDiv; + // forcingTerm[SE] *=scaleDiv; + // forcingTerm[BW] *=scaleDiv; + // forcingTerm[BE] *=scaleDiv; + // forcingTerm[BS] *=scaleDiv; + // forcingTerm[BN] *=scaleDiv; + // forcingTerm[BSW] *=scaleDiv; + // forcingTerm[BSE] *=scaleDiv; + // forcingTerm[BNW] *=scaleDiv; + // forcingTerm[BNE] *=scaleDiv; + // forcingTerm[REST] *=scaleDiv; + //} + //////// + + + mfcbb +=3.0 * ( 0.5 * forcingTerm[E]) / rho; //-(3.0*p1 - rho)*WEIGTH[E ]; + mfbcb +=3.0 * ( 0.5 * forcingTerm[N]) / rho; //-(3.0*p1 - rho)*WEIGTH[N ]; + mfbbc +=3.0 * ( 0.5 * forcingTerm[T]) / rho; //-(3.0*p1 - rho)*WEIGTH[T ]; + mfccb +=3.0 * ( 0.5 * forcingTerm[NE]) / rho; //-(3.0*p1 - rho)*WEIGTH[NE ]; + mfacb +=3.0 * ( 0.5 * forcingTerm[NW]) / rho; //-(3.0*p1 - rho)*WEIGTH[NW ]; + mfcbc +=3.0 * ( 0.5 * forcingTerm[TE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TE ]; + mfabc +=3.0 * ( 0.5 * forcingTerm[TW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TW ]; + mfbcc +=3.0 * ( 0.5 * forcingTerm[TN]) / rho; //-(3.0*p1 - rho)*WEIGTH[TN ]; + mfbac +=3.0 * ( 0.5 * forcingTerm[TS]) / rho; //-(3.0*p1 - rho)*WEIGTH[TS ]; + mfccc +=3.0 * ( 0.5 * forcingTerm[TNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNE]; + mfacc +=3.0 * ( 0.5 * forcingTerm[TNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNW]; + mfcac +=3.0 * ( 0.5 * forcingTerm[TSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSE]; + mfaac +=3.0 * ( 0.5 * forcingTerm[TSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSW]; + mfabb +=3.0 * ( 0.5 * forcingTerm[W]) / rho; //-(3.0*p1 - rho)*WEIGTH[W ]; + mfbab +=3.0 * ( 0.5 * forcingTerm[S]) / rho; //-(3.0*p1 - rho)*WEIGTH[S ]; + mfbba +=3.0 * ( 0.5 * forcingTerm[B]) / rho; //-(3.0*p1 - rho)*WEIGTH[B ]; + mfaab +=3.0 * ( 0.5 * forcingTerm[SW]) / rho; //-(3.0*p1 - rho)*WEIGTH[SW ]; + mfcab +=3.0 * ( 0.5 * forcingTerm[SE]) / rho; //-(3.0*p1 - rho)*WEIGTH[SE ]; + mfaba +=3.0 * ( 0.5 * forcingTerm[BW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BW ]; + mfcba +=3.0 * ( 0.5 * forcingTerm[BE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BE ]; + mfbaa +=3.0 * ( 0.5 * forcingTerm[BS]) / rho; //-(3.0*p1 - rho)*WEIGTH[BS ]; + mfbca +=3.0 * ( 0.5 * forcingTerm[BN]) / rho; //-(3.0*p1 - rho)*WEIGTH[BN ]; + mfaaa +=3.0 * ( 0.5 * forcingTerm[BSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSW]; + mfcaa +=3.0 * ( 0.5 * forcingTerm[BSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSE]; + mfaca +=3.0 * ( 0.5 * forcingTerm[BNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNW]; + mfcca +=3.0 * ( 0.5 * forcingTerm[BNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNE]; + mfbbb +=3.0 * ( 0.5 * forcingTerm[REST]) / rho; //- (3.0*p1 - rho)*WEIGTH[REST] + //-------------------------------------------------------- + //////////End classic source term //forcing /////////////////////////////////////////////////////////////////////////////////////////// if (withForcing) @@ -753,11 +1083,11 @@ void MultiphaseScratchCumulantLBMKernel::calculate(int step) /////fourth order parameters; here only for test. Move out of loop! LBMReal OxyyPxzz = 8.0 * (collFactorM - 2.0) * (OxxPyyPzz * (3.0 * collFactorM - 1.0) - 5.0 * collFactorM) / (8.0 * (5.0 - 2.0 * collFactorM) * collFactorM + OxxPyyPzz * (8.0 + collFactorM * (9.0 * collFactorM - 26.0))); - LBMReal OxyyMxzz = 8.0 * (collFactorM - 2.0) * (collFactorM + OxxPyyPzz * (3.0 * collFactorM - 7.0)) / (OxxPyyPzz * (56.0 - 42.0 * collFactorM + 9.0 * collFactorM * collFactorM) - 8.0 * collFactorM); - LBMReal Oxyz = 24.0 * (collFactorM - 2.0) * (4.0 * collFactorM * collFactorM + collFactorM * OxxPyyPzz * (18.0 - 13.0 * collFactorM) + OxxPyyPzz * OxxPyyPzz * (2.0 + collFactorM * (6.0 * collFactorM - 11.0))) / (16.0 * collFactorM * collFactorM * (collFactorM - 6.0) - 2.0 * collFactorM * OxxPyyPzz * (216.0 + 5.0 * collFactorM * (9.0 * collFactorM - 46.0)) + OxxPyyPzz * OxxPyyPzz * (collFactorM * (3.0 * collFactorM - 10.0) * (15.0 * collFactorM - 28.0) - 48.0)); - LBMReal A = (4.0 * collFactorM * collFactorM + 2.0 * collFactorM * OxxPyyPzz * (collFactorM - 6.0) + OxxPyyPzz * OxxPyyPzz * (collFactorM * (10.0 - 3.0 * collFactorM) - 4.0)) / ((collFactorM - OxxPyyPzz) * (OxxPyyPzz * (2.0 + 3.0 * collFactorM) - 8.0 * collFactorM)); + LBMReal OxyyMxzz = 8.0 * (collFactorM - 2.0) * (collFactorM + OxxPyyPzz * (3.0 * collFactorM - 7.0)) / (OxxPyyPzz * (56.0 - 42.0 * collFactorM + 9.0 * collFactorM * collFactorM) - 8.0 * collFactorM); + LBMReal Oxyz = 24.0 * (collFactorM - 2.0) * (4.0 * collFactorM * collFactorM + collFactorM * OxxPyyPzz * (18.0 - 13.0 * collFactorM) + OxxPyyPzz * OxxPyyPzz * (2.0 + collFactorM * (6.0 * collFactorM - 11.0))) / (16.0 * collFactorM * collFactorM * (collFactorM - 6.0) - 2.0 * collFactorM * OxxPyyPzz * (216.0 + 5.0 * collFactorM * (9.0 * collFactorM - 46.0)) + OxxPyyPzz * OxxPyyPzz * (collFactorM * (3.0 * collFactorM - 10.0) * (15.0 * collFactorM - 28.0) - 48.0)); + LBMReal A = (4.0 * collFactorM * collFactorM + 2.0 * collFactorM * OxxPyyPzz * (collFactorM - 6.0) + OxxPyyPzz * OxxPyyPzz * (collFactorM * (10.0 - 3.0 * collFactorM) - 4.0)) / ((collFactorM - OxxPyyPzz) * (OxxPyyPzz * (2.0 + 3.0 * collFactorM) - 8.0 * collFactorM)); //FIXME: warning C4459: declaration of 'B' hides global declaration (message : see declaration of 'D3Q27System::B' ) - LBMReal BB = (4.0 * collFactorM * OxxPyyPzz * (9.0 * collFactorM - 16.0) - 4.0 * collFactorM * collFactorM - 2.0 * OxxPyyPzz * OxxPyyPzz * (2.0 + 9.0 * collFactorM * (collFactorM - 2.0))) / (3.0 * (collFactorM - OxxPyyPzz) * (OxxPyyPzz * (2.0 + 3.0 * collFactorM) - 8.0 * collFactorM)); + LBMReal BB = (4.0 * collFactorM * OxxPyyPzz * (9.0 * collFactorM - 16.0) - 4.0 * collFactorM * collFactorM - 2.0 * OxxPyyPzz * OxxPyyPzz * (2.0 + 9.0 * collFactorM * (collFactorM - 2.0))) / (3.0 * (collFactorM - OxxPyyPzz) * (OxxPyyPzz * (2.0 + 3.0 * collFactorM) - 8.0 * collFactorM)); //Cum 4. @@ -802,13 +1132,25 @@ void MultiphaseScratchCumulantLBMKernel::calculate(int step) // mxxPyyPzz += c2o3 * rhoToPhi * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz); //17.03.2021 attempt for statililization by assymptotically vanishing bias - LBMReal correctionScaling =0.0* rhoToPhi /rho;// +0.5;// (vx2 + vy2 + vz2) * 100;// +0.5;//(vx2 + vy2 + vz2)*1000; - mxxPyyPzz += (1.0/3.0) * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz)* correctionScaling; // As in Hesam's code - mxxMyy += c1o3 * (dX1_phi * vvx - dX2_phi * vvy)* correctionScaling; - mxxMzz += c1o3 * (dX1_phi * vvx - dX3_phi * vvz) * correctionScaling; - mfabb += c1o6 * (dX2_phi * vvz + dX3_phi * vvy) * correctionScaling; - mfbab += c1o6 * (dX1_phi * vvz + dX3_phi * vvx) * correctionScaling; - mfbba += c1o6 * (dX1_phi * vvy + dX2_phi * vvx) * correctionScaling; + //LBMReal correctionScaling = rhoToPhi /rho;// +0.5;// (vx2 + vy2 + vz2) * 100;// +0.5;//(vx2 + vy2 + vz2)*1000; + //mxxPyyPzz += (1.0/3.0) * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz)* correctionScaling; // As in Hesam's code + //mxxMyy += c1o3 * (dX1_phi * vvx - dX2_phi * vvy)* correctionScaling; + //mxxMzz += c1o3 * (dX1_phi * vvx - dX3_phi * vvz) * correctionScaling; + //mfabb += c1o6 * (dX2_phi * vvz + dX3_phi * vvy) * correctionScaling; + //mfbab += c1o6 * (dX1_phi * vvz + dX3_phi * vvx) * correctionScaling; + //mfbba += c1o6 * (dX1_phi * vvy + dX2_phi * vvx) * correctionScaling; + + + //14.04.2021 filtered velocity + + //LBMReal correctionScaling = rhoToPhi / rho;// +0.5;// (vx2 + vy2 + vz2) * 100;// +0.5;//(vx2 + vy2 + vz2)*1000; + //mxxPyyPzz += (1.0 / 3.0) * (dX1_phi * vvxF + dX2_phi * vvyF + dX3_phi * vvzF) * correctionScaling; // As in Hesam's code + //mxxMyy += c1o3 * (dX1_phi * vvxF - dX2_phi * vvyF) * correctionScaling; + //mxxMzz += c1o3 * (dX1_phi * vvxF - dX3_phi * vvzF) * correctionScaling; + //mfabb += c1o6 * (dX2_phi * vvzF + dX3_phi * vvyF) * correctionScaling; + //mfbab += c1o6 * (dX1_phi * vvzF + dX3_phi * vvxF) * correctionScaling; + //mfbba += c1o6 * (dX1_phi * vvyF + dX2_phi * vvxF) * correctionScaling; + LBMReal dxux = -c1o2 * collFactorM * (mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz * (/*mfaaa*/ -mxxPyyPzz); LBMReal dyuy = dxux + collFactorM * c3o2 * mxxMyy; @@ -819,6 +1161,20 @@ void MultiphaseScratchCumulantLBMKernel::calculate(int step) LBMReal Dyz = -three * collFactorM * mfabb; ////relax unfiltered + //! divergenceFilter 10.05.2021 + LBMReal divMag= (1.0 - phi[REST]) * (phi[REST])*10*5*sqrt(fabs((OxxPyyPzz * (/*mfaaa*/ -mxxPyyPzz) - 3. * (1. - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz)))); + // LBMReal divMag = 500 *500* 50*(fabs((OxxPyyPzz * (/*mfaaa*/ -mxxPyyPzz) - 3. * (1. - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz))))* (fabs((OxxPyyPzz * (/*mfaaa*/ -mxxPyyPzz) - 3. * (1. - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz)))); + //LBMReal divMag = (dX1_phi * dxux) > 0 ? (dX1_phi * dxux) : 0; + //divMag += (dX2_phi * dyuy) > 0 ? (dX2_phi * dyuy) : 0; + //divMag += (dX3_phi * dzuz) > 0 ? (dX3_phi * dzuz) : 0; + //divMag *= 5000; + //divMag+= denom * 10 * 5 * sqrt(fabs((OxxPyyPzz * (/*mfaaa*/ -mxxPyyPzz) - 3. * (1. - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz)))); + //LBMReal divMag = 5000 * (fabs(dX1_phi * dxux)+fabs(dX2_phi * dyuy)+fabs(dX3_phi * dzuz)); + collFactorM = collFactorM / (1.0 + 3.0 * divMag); + + collFactorM = (collFactorM > 1.0) ? collFactorM : 1.0; + + mxxPyyPzz += OxxPyyPzz * (/*mfaaa*/ - mxxPyyPzz) - 3. * (1. - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz); mxxMyy += collFactorM * (-mxxMyy) - 3. * (1. - c1o2 * collFactorM) * (vx2 * dxux - vy2 * dyuy); mxxMzz += collFactorM * (-mxxMzz) - 3. * (1. - c1o2 * collFactorM) * (vx2 * dxux - vz2 * dzuz); @@ -848,15 +1204,29 @@ void MultiphaseScratchCumulantLBMKernel::calculate(int step) //applying phase field gradients second part: //mxxPyyPzz += c2o3 * rhoToPhi * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz); - mxxPyyPzz += (1.0 / 3.0) * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * correctionScaling; // As in Hesam's code - mxxMyy += c1o3 * (dX1_phi * vvx - dX2_phi * vvy) * correctionScaling; - mxxMzz += c1o3 * (dX1_phi * vvx - dX3_phi * vvz) * correctionScaling; - mfabb += c1o6 * (dX2_phi * vvz + dX3_phi * vvy) * correctionScaling; - mfbab += c1o6 * (dX1_phi * vvz + dX3_phi * vvx) * correctionScaling; - mfbba += c1o6 * (dX1_phi * vvy + dX2_phi * vvx) * correctionScaling; + //mxxPyyPzz += (1.0 / 3.0) * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * correctionScaling; // As in Hesam's code + //mxxMyy += c1o3 * (dX1_phi * vvx - dX2_phi * vvy) * correctionScaling; + //mxxMzz += c1o3 * (dX1_phi * vvx - dX3_phi * vvz) * correctionScaling; + //mfabb += c1o6 * (dX2_phi * vvz + dX3_phi * vvy) * correctionScaling; + //mfbab += c1o6 * (dX1_phi * vvz + dX3_phi * vvx) * correctionScaling; + //mfbba += c1o6 * (dX1_phi * vvy + dX2_phi * vvx) * correctionScaling; + + + //////updated pressure + //mfaaa += (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * correctionScaling; + + + //mxxPyyPzz += (1.0 / 3.0) * (dX1_phi * vvxF + dX2_phi * vvyF + dX3_phi * vvzF) * correctionScaling; // As in Hesam's code + //mxxMyy += c1o3 * (dX1_phi * vvxF - dX2_phi * vvyF) * correctionScaling; + //mxxMzz += c1o3 * (dX1_phi * vvxF - dX3_phi * vvzF) * correctionScaling; + //mfabb += c1o6 * (dX2_phi * vvzF + dX3_phi * vvyF) * correctionScaling; + //mfbab += c1o6 * (dX1_phi * vvzF + dX3_phi * vvxF) * correctionScaling; + //mfbba += c1o6 * (dX1_phi * vvyF + dX2_phi * vvxF) * correctionScaling; + + + //////updated pressure + //mfaaa += (dX1_phi * vvxF + dX2_phi * vvyF + dX3_phi * vvzF) * correctionScaling; - ////updated pressure - mfaaa += (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * correctionScaling; mxxPyyPzz += mfaaa;//12.03.21 shifted by mfaaa // mxxPyyPzz = mfaaa; //12.03.21 reguarized pressure !? @@ -2542,7 +2912,7 @@ void MultiphaseScratchCumulantLBMKernel::calculate(int step) } } } - } + dataSet->setPhaseField(divU); } } diff --git a/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsCumulantLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsCumulantLBMKernel.cpp index 102af60353833207231451f55acda91d03efbdd4..f226b8ecfa3c5654801561248f09e0251d2fa2ac 100644 --- a/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsCumulantLBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsCumulantLBMKernel.cpp @@ -289,6 +289,7 @@ void MultiphaseTwoPhaseFieldsCumulantLBMKernel::calculate(int step) //-1 0 1 findNeighbors(phaseField, x1, x2, x3); + findNeighbors2(phaseField2, x1, x2, x3); LBMReal mfcbb = (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3); LBMReal mfbcb = (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3); @@ -328,10 +329,22 @@ void MultiphaseTwoPhaseFieldsCumulantLBMKernel::calculate(int step) LBMReal dX2_phi = gradX2_phi(); LBMReal dX3_phi = gradX3_phi(); - LBMReal denom = sqrt(dX1_phi * dX1_phi + dX2_phi * dX2_phi + dX3_phi * dX3_phi) + 1e-9; - LBMReal normX1 = dX1_phi/denom; - LBMReal normX2 = dX2_phi/denom; - LBMReal normX3 = dX3_phi/denom; + LBMReal dX1_phi2 = gradX1_phi2(); + LBMReal dX2_phi2 = gradX2_phi2(); + LBMReal dX3_phi2 = gradX3_phi2(); + + + LBMReal denom2 = sqrt(dX1_phi * dX1_phi+ dX1_phi2 * dX1_phi2 + dX2_phi * dX2_phi + dX2_phi2 * dX2_phi2 + dX3_phi * dX3_phi+ dX3_phi2 * dX3_phi2) + 1e-9; + LBMReal normX1 = (dX1_phi-dX1_phi2)/denom2; + LBMReal normX2 = (dX2_phi-dX2_phi2)/denom2; + LBMReal normX3 = (dX3_phi-dX3_phi2)/denom2; + + //LBMReal denom = sqrt(dX1_phi * dX1_phi + dX2_phi * dX2_phi + dX3_phi * dX3_phi) + 1e-9; + //LBMReal normX1 = dX1_phi / denom; + //LBMReal normX2 = dX2_phi / denom; + //LBMReal normX3 = dX3_phi / denom; + + collFactorM = collFactorL + (collFactorL - collFactorG) * (phi[REST] - phiH) / (phiH - phiL); @@ -341,59 +354,46 @@ void MultiphaseTwoPhaseFieldsCumulantLBMKernel::calculate(int step) //----------- Calculating Macroscopic Values ------------- LBMReal rho = rhoH + rhoToPhi * (phi[REST] - phiH); - if (withForcing) { - // muX1 = static_cast<double>(x1-1+ix1*maxX1); - // muX2 = static_cast<double>(x2-1+ix2*maxX2); - // muX3 = static_cast<double>(x3-1+ix3*maxX3); - - forcingX1 = muForcingX1.Eval(); - forcingX2 = muForcingX2.Eval(); - forcingX3 = muForcingX3.Eval(); - - LBMReal rho_m = 1.0 / densityRatio; - forcingX1 = forcingX1 * (rho - rho_m); - forcingX2 = forcingX2 * (rho - rho_m); - forcingX3 = forcingX3 * (rho - rho_m); - ////Incompressible Kernal - mfbbc = (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3)/rho; - mfbcb = (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3) / rho; - mfccb = (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3) / rho; - mfacb = (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3) / rho; - mfcbb = (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3) / rho; - mfcbc = (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3) / rho; - mfabc = (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3) / rho; - mfbcc = (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3) / rho; - mfbac = (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3) / rho; - mfccc = (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3) / rho; - mfacc = (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3) / rho; - mfcac = (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3) / rho; - mfaac = (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3) / rho; - - mfabb = (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3) / rho; - mfbab = (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3) / rho; - mfbba = (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p) / rho; - mfaab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3) / rho; - mfcab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3) / rho; - mfaba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p) / rho; - mfcba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p) / rho; - mfbaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p) / rho; - mfbca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p) / rho; - mfaaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p) / rho; - mfcaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p) / rho; - mfaca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p) / rho; - mfcca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p) / rho; - - mfbbb = (*this->zeroDistributionsF)(x1, x2, x3) / rho; + mfbbc = (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3) / rho * c3; + mfbcb = (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3) / rho * c3; + mfccb = (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3) / rho * c3; + mfacb = (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3) / rho * c3; + mfcbb = (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3) / rho * c3; + mfcbc = (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3) / rho * c3; + mfabc = (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3) / rho * c3; + mfbcc = (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3) / rho * c3; + mfbac = (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3) / rho * c3; + mfccc = (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3) / rho * c3; + mfacc = (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3) / rho * c3; + mfcac = (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3) / rho * c3; + mfaac = (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3) / rho * c3; + + mfabb = (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3) / rho * c3; + mfbab = (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3) / rho * c3; + mfbba = (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p) / rho * c3; + mfaab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3) / rho * c3; + mfcab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3) / rho * c3; + mfaba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p) / rho * c3; + mfcba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p) / rho * c3; + mfbaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p) / rho * c3; + mfbca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p) / rho * c3; + mfaaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p) / rho * c3; + mfcaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p) / rho * c3; + mfaca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p) / rho * c3; + mfcca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p) / rho * c3; + + mfbbb = (*this->zeroDistributionsF)(x1, x2, x3) / rho * c3; + LBMReal m0, m1, m2; LBMReal rhoRef=c1; //LBMReal - LBMReal drho = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) - + (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + (mfbaa + mfbac + mfbca + mfbcc) - + (mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; + // LBMReal drho = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) + // + (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + (mfbaa + mfbac + mfbca + mfbcc) + // + (mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; LBMReal vvx = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + @@ -405,11 +405,240 @@ void MultiphaseTwoPhaseFieldsCumulantLBMKernel::calculate(int step) (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + (mfbbc - mfbba))/rhoRef; + + if (withForcing) { + // muX1 = static_cast<double>(x1-1+ix1*maxX1); + // muX2 = static_cast<double>(x2-1+ix2*maxX2); + // muX3 = static_cast<double>(x3-1+ix3*maxX3); + + forcingX1 = muForcingX1.Eval(); + forcingX2 = muForcingX2.Eval(); + forcingX3 = muForcingX3.Eval(); + + //LBMReal rho_m = 1.0 / densityRatio; + //forcingX1 = forcingX1 * (rho - rho_m); + //forcingX2 = forcingX2 * (rho - rho_m); + //forcingX3 = forcingX3 * (rho - rho_m); + vvx += forcingX1 * deltaT * 0.5; // X + vvy += forcingX2 * deltaT * 0.5; // Y + vvz += forcingX3 * deltaT * 0.5; // Z + + } + + ///surface tension force vvx += mu * dX1_phi*c1o2; - vvy += mu * dX2_phi * c1o2; + vvy += mu * dX2_phi * c1o2 ; vvz += mu * dX3_phi * c1o2; + //////classic source term + ///----Classic source term 8.4.2021 + + LBMReal vvxF, vvyF, vvzF; + vvxF = vvx;//-2*c1o24 * lap_vx;// + vvyF = vvy;//-2*c1o24 * lap_vy;// + vvzF = vvz;//-2*c1o24 * lap_vz;// + +// vvxF = 1.2* vvx- 0.2*0.5 * ((*velocityX)(x1 - 1, x2, x3) + (*velocityX)(x1 + 1, x2, x3)); +// vvyF = 1.2 *vvy- 0.2*0.5* ((*velocityY)(x1 , x2-1, x3) + (*velocityY)(x1 , x2+1, x3)); +// vvzF = 1.2 *vvz-0.2*0.5* ((*velocityZ)(x1 , x2, x3-1) + (*velocityZ)(x1 , x2, x3+1)); + //if (vvxF != vvx) { + // vvxF = vvxF; + //} + LBMReal weightGrad = 1.0;// -denom * denom / (denom * denom + 0.0001 * 0.001); + LBMReal dX1_phiF = dX1_phi * weightGrad + (1.0 - weightGrad) * (1.0 - phi[REST]) * (phi[REST]) * normX1; + LBMReal dX2_phiF = dX2_phi * weightGrad + (1.0 - weightGrad) * (1.0 - phi[REST]) * (phi[REST]) * normX2; + LBMReal dX3_phiF = dX3_phi * weightGrad + (1.0 - weightGrad) * (1.0 - phi[REST]) * (phi[REST]) * normX3; + + //dX1_phiF *= 1.2; + //dX2_phiF *= 1.2; + //dX3_phiF *= 1.2; + + //LBMReal gradFD = sqrt(dX1_phi * dX1_phi + dX2_phi * dX2_phi + dX3_phi * dX3_phi); + //LBMReal gradPhi = (1.0 - phi[REST]) * (phi[REST]); + //gradPhi = (gradPhi > gradFD) ? gradPhi : gradFD; + //dX1_phiF = gradPhi * normX1; + // dX2_phiF = gradPhi * normX2; + // dX3_phiF = gradPhi * normX3; + + LBMReal ux2; + LBMReal uy2; + LBMReal uz2; + ux2 = vvxF * vvxF; + uy2 = vvyF * vvyF; + uz2 = vvzF * vvzF; + LBMReal forcingTerm[D3Q27System::ENDF + 1]; + for (int dir = STARTF; dir <= (FENDDIR); dir++) { + LBMReal velProd = DX1[dir] * vvxF + DX2[dir] * vvyF + DX3[dir] * vvzF; + LBMReal velSq1 = velProd * velProd; + LBMReal gamma = WEIGTH[dir] * (1.0 + 3 * velProd + (4.5 * velSq1 - 1.5 * (ux2 + uy2 + uz2))); + + //LBMReal fac1 = (gamma - WEIGTH[dir]) * c1o3 * rhoToPhi; + + //forcingTerm[dir] = + // (-vvxF) * (fac1 * dX1_phiF) + + // (-vvyF) * (fac1 * dX2_phiF) + + // (-vvzF) * (fac1 * dX3_phiF) + + // (DX1[dir]) * (fac1 * dX1_phiF) + + // (DX2[dir]) * (fac1 * dX2_phiF) + + // (DX3[dir]) * (fac1 * dX3_phiF); + + + LBMReal fac1 = (gamma - WEIGTH[dir]) * c1o3 ; + + forcingTerm[dir] = + (-vvxF) * (fac1 * (dX1_phiF * rhoH + dX2_phi2 * rhoL)) + + (-vvyF) * (fac1 * (dX2_phiF * rhoH + dX2_phi2 * rhoL)) + + (-vvzF) * (fac1 * (dX3_phiF * rhoH + dX3_phi2 * rhoL)) + + (DX1[dir]) * (fac1 * (dX1_phiF * rhoH + dX2_phi2 * rhoL)) + + (DX2[dir]) * (fac1 * (dX2_phiF * rhoH + dX2_phi2 * rhoL)) + + (DX3[dir]) * (fac1 * (dX3_phiF * rhoH + dX3_phi2 * rhoL)); + + + + } + + LBMReal gamma = WEIGTH[REST] * (1.0 - 1.5 * (ux2 + uy2 + uz2)); + LBMReal fac1 = (gamma - WEIGTH[REST]) * c1o3 * rhoToPhi; + forcingTerm[REST] = (-vvxF) * (fac1 * (dX1_phiF * rhoH + dX2_phi2 * rhoL)) + + (-vvyF) * (fac1 * (dX2_phiF * rhoH + dX2_phi2 * rhoL)) + + (-vvzF) * (fac1 * (dX3_phiF * rhoH + dX3_phi2 * rhoL)); + + //////// + // LBMReal divAfterSource= + //( mfcbb + 3.0 * (0.5 * forcingTerm[E]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF) *(vvyF) +(vvzF) *(vvzF)-1)+ + //( mfbcb + 3.0 * (0.5 * forcingTerm[N]) / rho ) *((vvxF) *(vvxF) +(vvyF-1)*(vvyF-1)+(vvzF) *(vvzF)-1)+ + //( mfbbc + 3.0 * (0.5 * forcingTerm[T]) / rho ) *((vvxF) *(vvxF) +(vvyF) *(vvyF) +(vvzF-1)*(vvzF-1)-1)+ + //( mfccb + 3.0 * (0.5 * forcingTerm[NE]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF-1)*(vvyF-1)+(vvzF) *(vvzF)-1)+ + //( mfacb + 3.0 * (0.5 * forcingTerm[NW]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF-1)*(vvyF-1)+(vvzF) *(vvzF)-1)+ + //( mfcbc + 3.0 * (0.5 * forcingTerm[TE]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF) *(vvyF) +(vvzF-1)*(vvzF-1)-1)+ + //( mfabc + 3.0 * (0.5 * forcingTerm[TW]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF) *(vvyF) +(vvzF-1)*(vvzF-1)-1)+ + //( mfbcc + 3.0 * (0.5 * forcingTerm[TN]) / rho ) *((vvxF) *(vvxF) +(vvyF-1)*(vvyF-1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfbac + 3.0 * (0.5 * forcingTerm[TS]) / rho ) *((vvxF) *(vvxF) +(vvyF+1)*(vvyF+1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfccc + 3.0 * (0.5 * forcingTerm[TNE]) / rho) *((vvxF-1)*(vvxF-1)+(vvyF-1)*(vvyF-1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfacc + 3.0 * (0.5 * forcingTerm[TNW]) / rho) *((vvxF+1)*(vvxF+1)+(vvyF-1)*(vvyF-1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfcac + 3.0 * (0.5 * forcingTerm[TSE]) / rho) *((vvxF-1)*(vvxF-1)+(vvyF+1)*(vvyF+1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfaac + 3.0 * (0.5 * forcingTerm[TSW]) / rho) *((vvxF+1)*(vvxF+1)+(vvyF+1)*(vvyF+1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfabb + 3.0 * (0.5 * forcingTerm[W]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF) *(vvyF) +(vvzF) *(vvzF)-1)+ + //( mfbab + 3.0 * (0.5 * forcingTerm[S]) / rho ) *((vvxF) *(vvxF) +(vvyF+1)*(vvyF+1)+(vvzF) *(vvzF)-1)+ + //( mfbba + 3.0 * (0.5 * forcingTerm[B]) / rho ) *((vvxF) *(vvxF) +(vvyF) *(vvyF) +(vvzF+1)*(vvzF+1)-1)+ + //( mfaab + 3.0 * (0.5 * forcingTerm[SW]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF+1)*(vvyF+1)+(vvzF) *(vvzF)-1)+ + //( mfcab + 3.0 * (0.5 * forcingTerm[SE]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF+1)*(vvyF+1)+(vvzF) *(vvzF)-1)+ + //( mfaba + 3.0 * (0.5 * forcingTerm[BW]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF) *(vvyF) +(vvzF+1)*(vvzF+1)-1)+ + //( mfcba + 3.0 * (0.5 * forcingTerm[BE]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF) *(vvyF) +(vvzF+1)*(vvzF+1)-1)+ + //( mfbaa + 3.0 * (0.5 * forcingTerm[BS]) / rho ) *((vvxF) *(vvxF) +(vvyF+1)*(vvyF+1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfbca + 3.0 * (0.5 * forcingTerm[BN]) / rho ) *((vvxF) *(vvxF) +(vvyF-1)*(vvyF-1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfaaa + 3.0 * (0.5 * forcingTerm[BSW]) / rho) *((vvxF+1)*(vvxF+1)+(vvyF+1)*(vvyF+1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfcaa + 3.0 * (0.5 * forcingTerm[BSE]) / rho) *((vvxF-1)*(vvxF-1)+(vvyF+1)*(vvyF+1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfaca + 3.0 * (0.5 * forcingTerm[BNW]) / rho) *((vvxF+1)*(vvxF+1)+(vvyF-1)*(vvyF-1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfcca + 3.0 * (0.5 * forcingTerm[BNE]) / rho) *((vvxF-1)*(vvxF-1)+(vvyF-1)*(vvyF-1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfbbb + 3.0 * (0.5 * forcingTerm[REST]) / rho)*((vvxF)*(vvxF)+(vvyF)*(vvyF)+(vvzF)*(vvzF)-1); + + // LBMReal divBeforeSource = + // (mfcbb) * ((vvxF - 1) * (vvxF - 1) + (vvyF) * (vvyF)+(vvzF) * (vvzF)-1) + + // (mfbcb) * ((vvxF) * (vvxF)+(vvyF - 1) * (vvyF - 1) + (vvzF) * (vvzF)-1) + + // (mfbbc) * ((vvxF) * (vvxF)+(vvyF) * (vvyF)+(vvzF - 1) * (vvzF - 1)-1) + + // (mfccb) * ((vvxF - 1) * (vvxF - 1) + (vvyF - 1) * (vvyF - 1) + (vvzF) * (vvzF)-1) + + // (mfacb) * ((vvxF + 1) * (vvxF + 1) + (vvyF - 1) * (vvyF - 1) + (vvzF) * (vvzF)-1) + + // (mfcbc) * ((vvxF - 1) * (vvxF - 1) + (vvyF) * (vvyF)+(vvzF - 1) * (vvzF - 1)-1) + + // (mfabc) * ((vvxF + 1) * (vvxF + 1) + (vvyF) * (vvyF)+(vvzF - 1) * (vvzF - 1)-1) + + // (mfbcc) * ((vvxF) * (vvxF)+(vvyF - 1) * (vvyF - 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfbac) * ((vvxF) * (vvxF)+(vvyF + 1) * (vvyF + 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfccc) * ((vvxF - 1) * (vvxF - 1) + (vvyF - 1) * (vvyF - 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfacc) * ((vvxF + 1) * (vvxF + 1) + (vvyF - 1) * (vvyF - 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfcac) * ((vvxF - 1) * (vvxF - 1) + (vvyF + 1) * (vvyF + 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfaac) * ((vvxF + 1) * (vvxF + 1) + (vvyF + 1) * (vvyF + 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfabb) * ((vvxF + 1) * (vvxF + 1) + (vvyF) * (vvyF)+(vvzF) * (vvzF)-1) + + // (mfbab) * ((vvxF) * (vvxF)+(vvyF + 1) * (vvyF + 1) + (vvzF) * (vvzF)-1) + + // (mfbba) * ((vvxF) * (vvxF)+(vvyF) * (vvyF)+(vvzF + 1) * (vvzF + 1)-1) + + // (mfaab) * ((vvxF + 1) * (vvxF + 1) + (vvyF + 1) * (vvyF + 1) + (vvzF) * (vvzF)-1) + + // (mfcab) * ((vvxF - 1) * (vvxF - 1) + (vvyF + 1) * (vvyF + 1) + (vvzF) * (vvzF)-1) + + // (mfaba) * ((vvxF + 1) * (vvxF + 1) + (vvyF) * (vvyF)+(vvzF + 1) * (vvzF + 1)-1) + + // (mfcba) * ((vvxF - 1) * (vvxF - 1) + (vvyF) * (vvyF)+(vvzF + 1) * (vvzF + 1)-1) + + // (mfbaa) * ((vvxF) * (vvxF)+(vvyF + 1) * (vvyF + 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfbca) * ((vvxF) * (vvxF)+(vvyF - 1) * (vvyF - 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfaaa) * ((vvxF + 1) * (vvxF + 1) + (vvyF + 1) * (vvyF + 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfcaa) * ((vvxF - 1) * (vvxF - 1) + (vvyF + 1) * (vvyF + 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfaca) * ((vvxF + 1) * (vvxF + 1) + (vvyF - 1) * (vvyF - 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfcca) * ((vvxF - 1) * (vvxF - 1) + (vvyF - 1) * (vvyF - 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfbbb) * ((vvxF) * (vvxF)+(vvyF) * (vvyF)+(vvzF) * (vvzF)-1); + //if (divAfterSource - divBeforeSource != 0 && phi[REST]>0.0001 && phi[REST]<0.999) { + // std::cout << phi[REST]<<" "<< divAfterSource << " " << divBeforeSource <<" "<< divAfterSource/ divBeforeSource << std::endl; + //} + + //if (fabs(divAfterSource - divBeforeSource)/(fabs(divAfterSource) + fabs(divBeforeSource)+1e-10) > 1e-5) { + // LBMReal scaleDiv =0.95+(1-0.95)* (divBeforeSource) / (divBeforeSource - divAfterSource); + + // forcingTerm[E] *=scaleDiv; + // forcingTerm[N] *=scaleDiv; + // forcingTerm[T] *=scaleDiv; + // forcingTerm[NE] *=scaleDiv; + // forcingTerm[NW] *=scaleDiv; + // forcingTerm[TE] *=scaleDiv; + // forcingTerm[TW] *=scaleDiv; + // forcingTerm[TN] *=scaleDiv; + // forcingTerm[TS] *=scaleDiv; + // forcingTerm[TNE] *=scaleDiv; + // forcingTerm[TNW] *=scaleDiv; + // forcingTerm[TSE] *=scaleDiv; + // forcingTerm[TSW] *=scaleDiv; + // forcingTerm[W] *=scaleDiv; + // forcingTerm[S] *=scaleDiv; + // forcingTerm[B] *=scaleDiv; + // forcingTerm[SW] *=scaleDiv; + // forcingTerm[SE] *=scaleDiv; + // forcingTerm[BW] *=scaleDiv; + // forcingTerm[BE] *=scaleDiv; + // forcingTerm[BS] *=scaleDiv; + // forcingTerm[BN] *=scaleDiv; + // forcingTerm[BSW] *=scaleDiv; + // forcingTerm[BSE] *=scaleDiv; + // forcingTerm[BNW] *=scaleDiv; + // forcingTerm[BNE] *=scaleDiv; + // forcingTerm[REST] *=scaleDiv; + //} + //////// + + + mfcbb += 3.0 * (0.5 * forcingTerm[E]) / rho; //-(3.0*p1 - rho)*WEIGTH[E ]; + mfbcb += 3.0 * (0.5 * forcingTerm[N]) / rho; //-(3.0*p1 - rho)*WEIGTH[N ]; + mfbbc += 3.0 * (0.5 * forcingTerm[T]) / rho; //-(3.0*p1 - rho)*WEIGTH[T ]; + mfccb += 3.0 * (0.5 * forcingTerm[NE]) / rho; //-(3.0*p1 - rho)*WEIGTH[NE ]; + mfacb += 3.0 * (0.5 * forcingTerm[NW]) / rho; //-(3.0*p1 - rho)*WEIGTH[NW ]; + mfcbc += 3.0 * (0.5 * forcingTerm[TE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TE ]; + mfabc += 3.0 * (0.5 * forcingTerm[TW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TW ]; + mfbcc += 3.0 * (0.5 * forcingTerm[TN]) / rho; //-(3.0*p1 - rho)*WEIGTH[TN ]; + mfbac += 3.0 * (0.5 * forcingTerm[TS]) / rho; //-(3.0*p1 - rho)*WEIGTH[TS ]; + mfccc += 3.0 * (0.5 * forcingTerm[TNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNE]; + mfacc += 3.0 * (0.5 * forcingTerm[TNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNW]; + mfcac += 3.0 * (0.5 * forcingTerm[TSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSE]; + mfaac += 3.0 * (0.5 * forcingTerm[TSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSW]; + mfabb += 3.0 * (0.5 * forcingTerm[W]) / rho; //-(3.0*p1 - rho)*WEIGTH[W ]; + mfbab += 3.0 * (0.5 * forcingTerm[S]) / rho; //-(3.0*p1 - rho)*WEIGTH[S ]; + mfbba += 3.0 * (0.5 * forcingTerm[B]) / rho; //-(3.0*p1 - rho)*WEIGTH[B ]; + mfaab += 3.0 * (0.5 * forcingTerm[SW]) / rho; //-(3.0*p1 - rho)*WEIGTH[SW ]; + mfcab += 3.0 * (0.5 * forcingTerm[SE]) / rho; //-(3.0*p1 - rho)*WEIGTH[SE ]; + mfaba += 3.0 * (0.5 * forcingTerm[BW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BW ]; + mfcba += 3.0 * (0.5 * forcingTerm[BE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BE ]; + mfbaa += 3.0 * (0.5 * forcingTerm[BS]) / rho; //-(3.0*p1 - rho)*WEIGTH[BS ]; + mfbca += 3.0 * (0.5 * forcingTerm[BN]) / rho; //-(3.0*p1 - rho)*WEIGTH[BN ]; + mfaaa += 3.0 * (0.5 * forcingTerm[BSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSW]; + mfcaa += 3.0 * (0.5 * forcingTerm[BSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSE]; + mfaca += 3.0 * (0.5 * forcingTerm[BNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNW]; + mfcca += 3.0 * (0.5 * forcingTerm[BNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNE]; + mfbbb += 3.0 * (0.5 * forcingTerm[REST]) / rho; //- (3.0*p1 - rho)*WEIGTH[REST] + + //-------------------------------------------------------- + + + + + + //////end classic source term + + + + //forcing /////////////////////////////////////////////////////////////////////////////////////////// if (withForcing) @@ -418,13 +647,13 @@ void MultiphaseTwoPhaseFieldsCumulantLBMKernel::calculate(int step) muX2 = static_cast<double>(x2 - 1 + ix2 * maxX2); muX3 = static_cast<double>(x3 - 1 + ix3 * maxX3); - forcingX1 = muForcingX1.Eval(); - forcingX2 = muForcingX2.Eval(); - forcingX3 = muForcingX3.Eval(); + //forcingX1 = muForcingX1.Eval(); + //forcingX2 = muForcingX2.Eval(); + //forcingX3 = muForcingX3.Eval(); - vvx += forcingX1 * deltaT * 0.5; // X - vvy += forcingX2 * deltaT * 0.5; // Y - vvz += forcingX3 * deltaT * 0.5; // Z + //vvx += forcingX1 * deltaT * 0.5; // X + //vvy += forcingX2 * deltaT * 0.5; // Y + //vvz += forcingX3 * deltaT * 0.5; // Z } LBMReal vx2; @@ -697,12 +926,24 @@ void MultiphaseTwoPhaseFieldsCumulantLBMKernel::calculate(int step) // Cumulants //////////////////////////////////////////////////////////////////////////////////// LBMReal OxxPyyPzz = 1.; //omega2 or bulk viscosity - LBMReal OxyyPxzz = 1.;//-s9;//2+s9;// - LBMReal OxyyMxzz = 1.;//2+s9;// + // LBMReal OxyyPxzz = 1.;//-s9;//2+s9;// + // LBMReal OxyyMxzz = 1.;//2+s9;// LBMReal O4 = 1.; LBMReal O5 = 1.; LBMReal O6 = 1.; + + + /////fourth order parameters; here only for test. Move out of loop! + + LBMReal OxyyPxzz = 8.0 * (collFactorM - 2.0) * (OxxPyyPzz * (3.0 * collFactorM - 1.0) - 5.0 * collFactorM) / (8.0 * (5.0 - 2.0 * collFactorM) * collFactorM + OxxPyyPzz * (8.0 + collFactorM * (9.0 * collFactorM - 26.0))); + LBMReal OxyyMxzz = 8.0 * (collFactorM - 2.0) * (collFactorM + OxxPyyPzz * (3.0 * collFactorM - 7.0)) / (OxxPyyPzz * (56.0 - 42.0 * collFactorM + 9.0 * collFactorM * collFactorM) - 8.0 * collFactorM); + // LBMReal Oxyz = 24.0 * (collFactorM - 2.0) * (4.0 * collFactorM * collFactorM + collFactorM * OxxPyyPzz * (18.0 - 13.0 * collFactorM) + OxxPyyPzz * OxxPyyPzz * (2.0 + collFactorM * (6.0 * collFactorM - 11.0))) / (16.0 * collFactorM * collFactorM * (collFactorM - 6.0) - 2.0 * collFactorM * OxxPyyPzz * (216.0 + 5.0 * collFactorM * (9.0 * collFactorM - 46.0)) + OxxPyyPzz * OxxPyyPzz * (collFactorM * (3.0 * collFactorM - 10.0) * (15.0 * collFactorM - 28.0) - 48.0)); + LBMReal A = (4.0 * collFactorM * collFactorM + 2.0 * collFactorM * OxxPyyPzz * (collFactorM - 6.0) + OxxPyyPzz * OxxPyyPzz * (collFactorM * (10.0 - 3.0 * collFactorM) - 4.0)) / ((collFactorM - OxxPyyPzz) * (OxxPyyPzz * (2.0 + 3.0 * collFactorM) - 8.0 * collFactorM)); + //FIXME: warning C4459: declaration of 'B' hides global declaration (message : see declaration of 'D3Q27System::B' ) + LBMReal BB = (4.0 * collFactorM * OxxPyyPzz * (9.0 * collFactorM - 16.0) - 4.0 * collFactorM * collFactorM - 2.0 * OxxPyyPzz * OxxPyyPzz * (2.0 + 9.0 * collFactorM * (collFactorM - 2.0))) / (3.0 * (collFactorM - OxxPyyPzz) * (OxxPyyPzz * (2.0 + 3.0 * collFactorM) - 8.0 * collFactorM)); + + //Cum 4. //LBMReal CUMcbb = mfcbb - ((mfcaa + c1o3 * oMdrho) * mfabb + 2. * mfbba * mfbab); // till 18.05.2015 //LBMReal CUMbcb = mfbcb - ((mfaca + c1o3 * oMdrho) * mfbab + 2. * mfbba * mfabb); // till 18.05.2015 @@ -744,19 +985,24 @@ void MultiphaseTwoPhaseFieldsCumulantLBMKernel::calculate(int step) //applying phase field gradients first part: // mxxPyyPzz += c2o3 * rhoToPhi * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz); // 17.03.2021 attempt for statililization by assymptotically vanishing bias - LBMReal correctionScaling = - rhoToPhi / rho; // +0.5;// (vx2 + vy2 + vz2) * 100;// +0.5;//(vx2 + vy2 + vz2)*1000; - mxxPyyPzz += (1.0 / 6.0) * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * - correctionScaling; // As in Hesam's code - mxxMyy += c1o3 * (dX1_phi * vvx - dX2_phi * vvy) * correctionScaling; - mxxMzz += c1o3 * (dX1_phi * vvx - dX3_phi * vvz) * correctionScaling; - mfabb += c1o6 * (dX2_phi * vvz + dX3_phi * vvy) * correctionScaling; - mfbab += c1o6 * (dX1_phi * vvz + dX3_phi * vvx) * correctionScaling; - mfbba += c1o6 * (dX1_phi * vvy + dX2_phi * vvx) * correctionScaling; - - LBMReal dxux = 0.0;// -c1o2 * collFactorM * (mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz * (/*mfaaa*/ -mxxPyyPzz); - LBMReal dyuy = 0.0;// dxux + collFactorM * c3o2 * mxxMyy; - LBMReal dzuz = 0.0;// dxux + collFactorM * c3o2 * mxxMzz; + //LBMReal correctionScaling = + // rhoToPhi / rho; // +0.5;// (vx2 + vy2 + vz2) * 100;// +0.5;//(vx2 + vy2 + vz2)*1000; + //mxxPyyPzz += (1.0 / 6.0) * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * + // correctionScaling; // As in Hesam's code + //mxxMyy += c1o3 * (dX1_phi * vvx - dX2_phi * vvy) * correctionScaling; + //mxxMzz += c1o3 * (dX1_phi * vvx - dX3_phi * vvz) * correctionScaling; + //mfabb += c1o6 * (dX2_phi * vvz + dX3_phi * vvy) * correctionScaling; + //mfbab += c1o6 * (dX1_phi * vvz + dX3_phi * vvx) * correctionScaling; + //mfbba += c1o6 * (dX1_phi * vvy + dX2_phi * vvx) * correctionScaling; + + LBMReal dxux = -c1o2 * collFactorM * (mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz * (/*mfaaa*/ -mxxPyyPzz); + LBMReal dyuy = dxux + collFactorM * c3o2 * mxxMyy; + LBMReal dzuz = dxux + collFactorM * c3o2 * mxxMzz; + + LBMReal Dxy = -three * collFactorM * mfbba; + LBMReal Dxz = -three * collFactorM * mfbab; + LBMReal Dyz = -three * collFactorM * mfabb; + //relax mxxPyyPzz += OxxPyyPzz * (/*mfaaa*/ - mxxPyyPzz) - 3. * (1. - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz); @@ -769,16 +1015,16 @@ void MultiphaseTwoPhaseFieldsCumulantLBMKernel::calculate(int step) //applying phase field gradients second part: //mxxPyyPzz += c2o3 * rhoToPhi * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz); - mxxPyyPzz += (1.0 / 6.0) * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * - correctionScaling; // As in Hesam's code - mxxMyy += c1o3 * (dX1_phi * vvx - dX2_phi * vvy) * correctionScaling; - mxxMzz += c1o3 * (dX1_phi * vvx - dX3_phi * vvz) * correctionScaling; - mfabb += c1o6 * (dX2_phi * vvz + dX3_phi * vvy) * correctionScaling; - mfbab += c1o6 * (dX1_phi * vvz + dX3_phi * vvx) * correctionScaling; - mfbba += c1o6 * (dX1_phi * vvy + dX2_phi * vvx) * correctionScaling; + //mxxPyyPzz += (1.0 / 6.0) * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * + // correctionScaling; // As in Hesam's code + //mxxMyy += c1o3 * (dX1_phi * vvx - dX2_phi * vvy) * correctionScaling; + //mxxMzz += c1o3 * (dX1_phi * vvx - dX3_phi * vvz) * correctionScaling; + //mfabb += c1o6 * (dX2_phi * vvz + dX3_phi * vvy) * correctionScaling; + //mfbab += c1o6 * (dX1_phi * vvz + dX3_phi * vvx) * correctionScaling; + //mfbba += c1o6 * (dX1_phi * vvy + dX2_phi * vvx) * correctionScaling; ////updated pressure - mfaaa += (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * correctionScaling; + //mfaaa += (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * correctionScaling; mxxPyyPzz += mfaaa; // 12.03.21 shifted by mfaaa // linear combinations back @@ -822,13 +1068,19 @@ void MultiphaseTwoPhaseFieldsCumulantLBMKernel::calculate(int step) mfbac = (-mxyyMxzz + mxyyPxzz) * c1o2; //4. - CUMacc += O4 * (-CUMacc); - CUMcac += O4 * (-CUMcac); - CUMcca += O4 * (-CUMcca); - - CUMbbc += O4 * (-CUMbbc); - CUMbcb += O4 * (-CUMbcb); - CUMcbb += O4 * (-CUMcbb); + //CUMacc += O4 * (-CUMacc); + //CUMcac += O4 * (-CUMcac); + //CUMcca += O4 * (-CUMcca); + + //CUMbbc += O4 * (-CUMbbc); + //CUMbcb += O4 * (-CUMbcb); + //CUMcbb += O4 * (-CUMcbb); + CUMacc = -O4 * (one / collFactorM - c1o2) * (dyuy + dzuz) * c2o3 * A + (one - O4) * (CUMacc); + CUMcac = -O4 * (one / collFactorM - c1o2) * (dxux + dzuz) * c2o3 * A + (one - O4) * (CUMcac); + CUMcca = -O4 * (one / collFactorM - c1o2) * (dyuy + dxux) * c2o3 * A + (one - O4) * (CUMcca); + CUMbbc = -O4 * (one / collFactorM - c1o2) * Dxy * c1o3 * BB + (one - O4) * (CUMbbc); + CUMbcb = -O4 * (one / collFactorM - c1o2) * Dxz * c1o3 * BB + (one - O4) * (CUMbcb); + CUMcbb = -O4 * (one / collFactorM - c1o2) * Dyz * c1o3 * BB + (one - O4) * (CUMcbb); //5. CUMbcc += O5 * (-CUMbcc); @@ -1090,60 +1342,92 @@ void MultiphaseTwoPhaseFieldsCumulantLBMKernel::calculate(int step) mfbcc = m1; mfccc = m2; + /////classical source term 8.4.2021 + + mfcbb += 3.0 * (0.5 * forcingTerm[E]) / rho; //-(3.0*p1 - rho)*WEIGTH[E ]; + mfbcb += 3.0 * (0.5 * forcingTerm[N]) / rho; //-(3.0*p1 - rho)*WEIGTH[N ]; + mfbbc += 3.0 * (0.5 * forcingTerm[T]) / rho; //-(3.0*p1 - rho)*WEIGTH[T ]; + mfccb += 3.0 * (0.5 * forcingTerm[NE]) / rho; //-(3.0*p1 - rho)*WEIGTH[NE ]; + mfacb += 3.0 * (0.5 * forcingTerm[NW]) / rho; //-(3.0*p1 - rho)*WEIGTH[NW ]; + mfcbc += 3.0 * (0.5 * forcingTerm[TE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TE ]; + mfabc += 3.0 * (0.5 * forcingTerm[TW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TW ]; + mfbcc += 3.0 * (0.5 * forcingTerm[TN]) / rho; //-(3.0*p1 - rho)*WEIGTH[TN ]; + mfbac += 3.0 * (0.5 * forcingTerm[TS]) / rho; //-(3.0*p1 - rho)*WEIGTH[TS ]; + mfccc += 3.0 * (0.5 * forcingTerm[TNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNE]; + mfacc += 3.0 * (0.5 * forcingTerm[TNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNW]; + mfcac += 3.0 * (0.5 * forcingTerm[TSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSE]; + mfaac += 3.0 * (0.5 * forcingTerm[TSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSW]; + mfabb += 3.0 * (0.5 * forcingTerm[W]) / rho; //-(3.0*p1 - rho)*WEIGTH[W ]; + mfbab += 3.0 * (0.5 * forcingTerm[S]) / rho; //-(3.0*p1 - rho)*WEIGTH[S ]; + mfbba += 3.0 * (0.5 * forcingTerm[B]) / rho; //-(3.0*p1 - rho)*WEIGTH[B ]; + mfaab += 3.0 * (0.5 * forcingTerm[SW]) / rho; //-(3.0*p1 - rho)*WEIGTH[SW ]; + mfcab += 3.0 * (0.5 * forcingTerm[SE]) / rho; //-(3.0*p1 - rho)*WEIGTH[SE ]; + mfaba += 3.0 * (0.5 * forcingTerm[BW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BW ]; + mfcba += 3.0 * (0.5 * forcingTerm[BE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BE ]; + mfbaa += 3.0 * (0.5 * forcingTerm[BS]) / rho; //-(3.0*p1 - rho)*WEIGTH[BS ]; + mfbca += 3.0 * (0.5 * forcingTerm[BN]) / rho; //-(3.0*p1 - rho)*WEIGTH[BN ]; + mfaaa += 3.0 * (0.5 * forcingTerm[BSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSW]; + mfcaa += 3.0 * (0.5 * forcingTerm[BSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSE]; + mfaca += 3.0 * (0.5 * forcingTerm[BNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNW]; + mfcca += 3.0 * (0.5 * forcingTerm[BNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNE]; + mfbbb += 3.0 * (0.5 * forcingTerm[REST]) / rho; //- (3.0*p1 - rho)*WEIGTH[REST] + + + ////////////////////////////////////////////////////////////////////////// //proof correctness ////////////////////////////////////////////////////////////////////////// -#ifdef PROOF_CORRECTNESS - LBMReal rho_post = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) - + (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + (mfbaa + mfbac + mfbca + mfbcc) - + (mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; - //LBMReal dif = fabs(drho - rho_post); - LBMReal dif = drho + (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * correctionScaling - rho_post; -#ifdef SINGLEPRECISION - if (dif > 10.0E-7 || dif < -10.0E-7) -#else - if (dif > 10.0E-15 || dif < -10.0E-15) -#endif - { - UB_THROW(UbException(UB_EXARGS, "drho=" + UbSystem::toString(drho) + ", rho_post=" + UbSystem::toString(rho_post) - + " dif=" + UbSystem::toString(dif) - + " drho is not correct for node " + UbSystem::toString(x1) + "," + UbSystem::toString(x2) + "," + UbSystem::toString(x3))); - //UBLOG(logERROR,"LBMKernelETD3Q27CCLB::collideAll(): drho is not correct for node "+UbSystem::toString(x1)+","+UbSystem::toString(x2)+","+UbSystem::toString(x3)); - //exit(EXIT_FAILURE); - } -#endif +//#ifdef PROOF_CORRECTNESS +// LBMReal rho_post = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) +// + (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + (mfbaa + mfbac + mfbca + mfbcc) +// + (mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; +// //LBMReal dif = fabs(drho - rho_post); +// LBMReal dif = drho + (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * correctionScaling - rho_post; +//#ifdef SINGLEPRECISION +// if (dif > 10.0E-7 || dif < -10.0E-7) +//#else +// if (dif > 10.0E-15 || dif < -10.0E-15) +//#endif +// { +// UB_THROW(UbException(UB_EXARGS, "drho=" + UbSystem::toString(drho) + ", rho_post=" + UbSystem::toString(rho_post) +// + " dif=" + UbSystem::toString(dif) +// + " drho is not correct for node " + UbSystem::toString(x1) + "," + UbSystem::toString(x2) + "," + UbSystem::toString(x3))); +// //UBLOG(logERROR,"LBMKernelETD3Q27CCLB::collideAll(): drho is not correct for node "+UbSystem::toString(x1)+","+UbSystem::toString(x2)+","+UbSystem::toString(x3)); +// //exit(EXIT_FAILURE); +// } +//#endif ////////////////////////////////////////////////////////////////////////// //write distribution ////////////////////////////////////////////////////////////////////////// - (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3) = mfabb * rho; - (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3) = mfbab * rho; - (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3) = mfbba * rho; - (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3) = mfaab * rho; - (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab * rho; - (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3) = mfaba * rho; - (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba * rho; - (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa * rho; - (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca * rho; - (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa * rho; - (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa * rho; - (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca * rho; - (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca * rho; - - (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3) = mfcbb * rho; - (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3) = mfbcb * rho; - (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc * rho; - (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3) = mfccb * rho; - (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3) = mfacb * rho; - (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc * rho; - (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc * rho; - (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc * rho; - (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac * rho; - (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc * rho; - (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc * rho; - (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac * rho; - (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac * rho; - - (*this->zeroDistributionsF)(x1, x2, x3) = mfbbb * rho; + (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3) = mfabb * rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3) = mfbab * rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3) = mfbba * rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3) = mfaab * rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab * rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3) = mfaba * rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba * rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa * rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca * rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa * rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa * rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca * rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca * rho * c1o3; + + (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3) = mfcbb * rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3) = mfbcb * rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc * rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3) = mfccb * rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3) = mfacb * rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc * rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc * rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc * rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac * rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc * rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc * rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac * rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac * rho * c1o3; + + (*this->zeroDistributionsF)(x1, x2, x3) = mfbbb * rho * c1o3; ////////////////////////////////////////////////////////////////////////// ////!Incompressible Kernal @@ -1977,7 +2261,7 @@ void MultiphaseTwoPhaseFieldsCumulantLBMKernel::calculate(int step) //////////////////////////////////////////// /////CUMULANT PHASE-FIELD LBMReal omegaD =1.0/( 3.0 * mob + 0.5); - + { mfcbb = (*this->localDistributionsH1)(D3Q27System::ET_E, x1, x2, x3); mfbcb = (*this->localDistributionsH1)(D3Q27System::ET_N, x1, x2, x3); mfbbc = (*this->localDistributionsH1)(D3Q27System::ET_T, x1, x2, x3); @@ -2134,6 +2418,9 @@ void MultiphaseTwoPhaseFieldsCumulantLBMKernel::calculate(int step) LBMReal Mccb = mfccb - mfaab * c1o9; // collision of 1st order moments + // LBMReal ccx, ccy, ccz; + + cx = cx * (c1 - omegaD) + omegaD * vvx * concentration + normX1 * (c1 - 0.5 * omegaD) * (1.0 - phi[REST]) * (phi[REST]) * c1o3 * oneOverInterfaceScale; cy = cy * (c1 - omegaD) + omegaD * vvy * concentration + @@ -2281,6 +2568,323 @@ void MultiphaseTwoPhaseFieldsCumulantLBMKernel::calculate(int step) (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac; (*this->zeroDistributionsH1)(x1,x2,x3) = mfbbb; + } + + ////Phasefield 2: + + { + + normX1 *= -1; + normX2 *= -1; + normX3 *= -1; + + mfcbb = (*this->localDistributionsH2)(D3Q27System::ET_E, x1, x2, x3); + mfbcb = (*this->localDistributionsH2)(D3Q27System::ET_N, x1, x2, x3); + mfbbc = (*this->localDistributionsH2)(D3Q27System::ET_T, x1, x2, x3); + mfccb = (*this->localDistributionsH2)(D3Q27System::ET_NE, x1, x2, x3); + mfacb = (*this->localDistributionsH2)(D3Q27System::ET_NW, x1p, x2, x3); + mfcbc = (*this->localDistributionsH2)(D3Q27System::ET_TE, x1, x2, x3); + mfabc = (*this->localDistributionsH2)(D3Q27System::ET_TW, x1p, x2, x3); + mfbcc = (*this->localDistributionsH2)(D3Q27System::ET_TN, x1, x2, x3); + mfbac = (*this->localDistributionsH2)(D3Q27System::ET_TS, x1, x2p, x3); + mfccc = (*this->localDistributionsH2)(D3Q27System::ET_TNE, x1, x2, x3); + mfacc = (*this->localDistributionsH2)(D3Q27System::ET_TNW, x1p, x2, x3); + mfcac = (*this->localDistributionsH2)(D3Q27System::ET_TSE, x1, x2p, x3); + mfaac = (*this->localDistributionsH2)(D3Q27System::ET_TSW, x1p, x2p, x3); + mfabb = (*this->nonLocalDistributionsH2)(D3Q27System::ET_W, x1p, x2, x3); + mfbab = (*this->nonLocalDistributionsH2)(D3Q27System::ET_S, x1, x2p, x3); + mfbba = (*this->nonLocalDistributionsH2)(D3Q27System::ET_B, x1, x2, x3p); + mfaab = (*this->nonLocalDistributionsH2)(D3Q27System::ET_SW, x1p, x2p, x3); + mfcab = (*this->nonLocalDistributionsH2)(D3Q27System::ET_SE, x1, x2p, x3); + mfaba = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BW, x1p, x2, x3p); + mfcba = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BE, x1, x2, x3p); + mfbaa = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BS, x1, x2p, x3p); + mfbca = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BN, x1, x2, x3p); + mfaaa = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BSW, x1p, x2p, x3p); + mfcaa = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BSE, x1, x2p, x3p); + mfaca = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BNW, x1p, x2, x3p); + mfcca = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BNE, x1, x2, x3p); + mfbbb = (*this->zeroDistributionsH2)(x1, x2, x3); + + + //////////////////////////////////////////////////////////////////////////////////// +//! - Calculate density and velocity using pyramid summation for low round-off errors as in Eq. (J1)-(J3) \ref +//! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> +//! +//////////////////////////////////////////////////////////////////////////////////// +// fluid component + //LBMReal drhoFluid = + // ((((fccc + faaa) + (faca + fcac)) + ((facc + fcaa) + (faac + fcca))) + + // (((fbac + fbca) + (fbaa + fbcc)) + ((fabc + fcba) + (faba + fcbc)) + ((facb + fcab) + (faab + fccb))) + + // ((fabb + fcbb) + (fbab + fbcb) + (fbba + fbbc))) + fbbb; + + //LBMReal rhoFluid = c1 + drhoFluid; + //LBMReal OOrhoFluid = c1 / rhoFluid; + + + //LBMReal vvx = + // ((((fccc - faaa) + (fcac - faca)) + ((fcaa - facc) + (fcca - faac))) + + // (((fcba - fabc) + (fcbc - faba)) + ((fcab - facb) + (fccb - faab))) + + // (fcbb - fabb)) * OOrhoFluid; + //LBMReal vvy = + // ((((fccc - faaa) + (faca - fcac)) + ((facc - fcaa) + (fcca - faac))) + + // (((fbca - fbac) + (fbcc - fbaa)) + ((facb - fcab) + (fccb - faab))) + + // (fbcb - fbab)) * OOrhoFluid; + //LBMReal vvz = + // ((((fccc - faaa) + (fcac - faca)) + ((facc - fcaa) + (faac - fcca))) + + // (((fbac - fbca) + (fbcc - fbaa)) + ((fabc - fcba) + (fcbc - faba))) + + // (fbbc - fbba)) * OOrhoFluid; + + // LBMReal vvx = ux; + // LBMReal vvy = uy; + // LBMReal vvz = uz; + //////////////////////////////////////////////////////////////////////////////////// + // second component + LBMReal concentration = + ((((mfccc + mfaaa) + (mfaca + mfcac)) + ((mfacc + mfcaa) + (mfaac + mfcca))) + + (((mfbac + mfbca) + (mfbaa + mfbcc)) + ((mfabc + mfcba) + (mfaba + mfcbc)) + ((mfacb + mfcab) + (mfaab + mfccb))) + + ((mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc))) + mfbbb; + //////////////////////////////////////////////////////////////////////////////////// + //! - Add half of the acceleration (body force) to the velocity as in Eq. (42) \ref + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! + // LBMReal fx = forces[0]; + // LBMReal fy = forces[1]; + // LBMReal fz = -concentration * forces[2]; + // vvx += fx * c1o2; + // vvy += fy * c1o2; + // vvz += fz * c1o2; + //////////////////////////////////////////////////////////////////////////////////// + LBMReal oneMinusRho = c1 - concentration; + + LBMReal cx = + ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + + (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + + (mfcbb - mfabb)); + LBMReal cy = + ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + + (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + + (mfbcb - mfbab)); + LBMReal cz = + ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + + (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + + (mfbbc - mfbba)); + + //////////////////////////////////////////////////////////////////////////////////// + // calculate the square of velocities for this lattice node + LBMReal cx2 = cx * cx; + LBMReal cy2 = cy * cy; + LBMReal cz2 = cz * cz; + //////////////////////////////////////////////////////////////////////////////////// + //! - Chimera transform from well conditioned distributions to central moments as defined in Appendix J in \ref + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! see also Eq. (6)-(14) in \ref + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + forwardInverseChimeraWithKincompressible(mfaaa, mfaab, mfaac, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfaba, mfabb, mfabc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfaca, mfacb, mfacc, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbaa, mfbab, mfbac, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbba, mfbbb, mfbbc, cz, cz2, c9o4, c4o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbca, mfbcb, mfbcc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcaa, mfcab, mfcac, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcba, mfcbb, mfcbc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcca, mfccb, mfccc, cz, cz2, c36, c1o36, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + forwardInverseChimeraWithKincompressible(mfaaa, mfaba, mfaca, cy, cy2, c6, c1o6, oneMinusRho); + forwardChimera(mfaab, mfabb, mfacb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfaac, mfabc, mfacc, cy, cy2, c18, c1o18, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbaa, mfbba, mfbca, cy, cy2, c3o2, c2o3, oneMinusRho); + forwardChimera(mfbab, mfbbb, mfbcb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfbac, mfbbc, mfbcc, cy, cy2, c9o2, c2o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcaa, mfcba, mfcca, cy, cy2, c6, c1o6, oneMinusRho); + forwardChimera(mfcab, mfcbb, mfccb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfcac, mfcbc, mfccc, cy, cy2, c18, c1o18, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + forwardInverseChimeraWithKincompressible(mfaaa, mfbaa, mfcaa, cx, cx2, c1, c1, oneMinusRho); + forwardChimera(mfaba, mfbba, mfcba, cx, cx2); + forwardInverseChimeraWithKincompressible(mfaca, mfbca, mfcca, cx, cx2, c3, c1o3, oneMinusRho); + forwardChimera(mfaab, mfbab, mfcab, cx, cx2); + forwardChimera(mfabb, mfbbb, mfcbb, cx, cx2); + forwardChimera(mfacb, mfbcb, mfccb, cx, cx2); + forwardInverseChimeraWithKincompressible(mfaac, mfbac, mfcac, cx, cx2, c3, c1o3, oneMinusRho); + forwardChimera(mfabc, mfbbc, mfcbc, cx, cx2); + forwardInverseChimeraWithKincompressible(mfacc, mfbcc, mfccc, cx, cx2, c3, c1o9, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + //! - experimental Cumulant ... to be published ... hopefully + //! + + // linearized orthogonalization of 3rd order central moments + LBMReal Mabc = mfabc - mfaba * c1o3; + LBMReal Mbca = mfbca - mfbaa * c1o3; + LBMReal Macb = mfacb - mfaab * c1o3; + LBMReal Mcba = mfcba - mfaba * c1o3; + LBMReal Mcab = mfcab - mfaab * c1o3; + LBMReal Mbac = mfbac - mfbaa * c1o3; + // linearized orthogonalization of 5th order central moments + LBMReal Mcbc = mfcbc - mfaba * c1o9; + LBMReal Mbcc = mfbcc - mfbaa * c1o9; + LBMReal Mccb = mfccb - mfaab * c1o9; + + // collision of 1st order moments + cx = cx * (c1 - omegaD) + omegaD * vvx * concentration + + normX1 * (c1 - 0.5 * omegaD) * ( phi[REST]) * (phi2[REST]) * c1o3 * oneOverInterfaceScale; + cy = cy * (c1 - omegaD) + omegaD * vvy * concentration + + normX2 * (c1 - 0.5 * omegaD) * ( phi[REST]) * (phi2[REST]) * c1o3 * oneOverInterfaceScale; + cz = cz * (c1 - omegaD) + omegaD * vvz * concentration + + normX3 * (c1 - 0.5 * omegaD) * ( phi[REST]) * (phi2[REST]) * c1o3 * oneOverInterfaceScale; + + //mhx = (ux * phi[REST] + normX1 * (tauH - 0.5) * (1.0 - phi[REST]) * (phi[REST])) / tauH + (1.0 - 1.0 / tauH) * mhx; + //mhy = (uy * phi[REST] + normX2 * (tauH - 0.5) * (1.0 - phi[REST]) * (phi[REST])) / tauH + (1.0 - 1.0 / tauH) * mhy; +//mhz = (uz * phi[REST] + normX3 * (tauH - 0.5) * (1.0 - phi[REST]) * (phi[REST])) / tauH + (1.0 - 1.0 / tauH) * mhz; + + + cx2 = cx * cx; + cy2 = cy * cy; + cz2 = cz * cz; + + // equilibration of 2nd order moments + mfbba = zeroReal; + mfbab = zeroReal; + mfabb = zeroReal; + + mfcaa = c1o3 * concentration; + mfaca = c1o3 * concentration; + mfaac = c1o3 * concentration; + + + //LBMReal omega2 = 1.0f;// omegaD; + //mfbba *= (c1 - omega2); + //mfbab *= (c1 - omega2); + //mfabb *= (c1 - omega2); + + //mfcaa = mfcaa*(c1 - omega2) + omega2*c1o3 * concentration; + //mfaca = mfaca*(c1 - omega2) + omega2*c1o3 * concentration; + //mfaac = mfaac*(c1 - omega2) + omega2*c1o3 * concentration; + + // equilibration of 3rd order moments + Mabc = zeroReal; + Mbca = zeroReal; + Macb = zeroReal; + Mcba = zeroReal; + Mcab = zeroReal; + Mbac = zeroReal; + mfbbb = zeroReal; + + // from linearized orthogonalization 3rd order central moments to central moments + mfabc = Mabc + mfaba * c1o3; + mfbca = Mbca + mfbaa * c1o3; + mfacb = Macb + mfaab * c1o3; + mfcba = Mcba + mfaba * c1o3; + mfcab = Mcab + mfaab * c1o3; + mfbac = Mbac + mfbaa * c1o3; + + // equilibration of 4th order moments + mfacc = c1o9 * concentration; + mfcac = c1o9 * concentration; + mfcca = c1o9 * concentration; + + mfcbb = zeroReal; + mfbcb = zeroReal; + mfbbc = zeroReal; + + // equilibration of 5th order moments + Mcbc = zeroReal; + Mbcc = zeroReal; + Mccb = zeroReal; + + // from linearized orthogonalization 5th order central moments to central moments + mfcbc = Mcbc + mfaba * c1o9; + mfbcc = Mbcc + mfbaa * c1o9; + mfccb = Mccb + mfaab * c1o9; + + // equilibration of 6th order moment + mfccc = c1o27 * concentration; + + //////////////////////////////////////////////////////////////////////////////////// + //! - Chimera transform from central moments to well conditioned distributions as defined in Appendix J in + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! see also Eq. (88)-(96) in + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + backwardInverseChimeraWithKincompressible(mfaaa, mfbaa, mfcaa, cx, cx2, c1, c1, oneMinusRho); + backwardChimera(mfaba, mfbba, mfcba, cx, cx2); + backwardInverseChimeraWithKincompressible(mfaca, mfbca, mfcca, cx, cx2, c3, c1o3, oneMinusRho); + backwardChimera(mfaab, mfbab, mfcab, cx, cx2); + backwardChimera(mfabb, mfbbb, mfcbb, cx, cx2); + backwardChimera(mfacb, mfbcb, mfccb, cx, cx2); + backwardInverseChimeraWithKincompressible(mfaac, mfbac, mfcac, cx, cx2, c3, c1o3, oneMinusRho); + backwardChimera(mfabc, mfbbc, mfcbc, cx, cx2); + backwardInverseChimeraWithKincompressible(mfacc, mfbcc, mfccc, cx, cx2, c9, c1o9, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + backwardInverseChimeraWithKincompressible(mfaaa, mfaba, mfaca, cy, cy2, c6, c1o6, oneMinusRho); + backwardChimera(mfaab, mfabb, mfacb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfaac, mfabc, mfacc, cy, cy2, c18, c1o18, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbaa, mfbba, mfbca, cy, cy2, c3o2, c2o3, oneMinusRho); + backwardChimera(mfbab, mfbbb, mfbcb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfbac, mfbbc, mfbcc, cy, cy2, c9o2, c2o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcaa, mfcba, mfcca, cy, cy2, c6, c1o6, oneMinusRho); + backwardChimera(mfcab, mfcbb, mfccb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfcac, mfcbc, mfccc, cy, cy2, c18, c1o18, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + backwardInverseChimeraWithKincompressible(mfaaa, mfaab, mfaac, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfaba, mfabb, mfabc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfaca, mfacb, mfacc, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbaa, mfbab, mfbac, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbba, mfbbb, mfbbc, cz, cz2, c9o4, c4o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbca, mfbcb, mfbcc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcaa, mfcab, mfcac, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcba, mfcbb, mfcbc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcca, mfccb, mfccc, cz, cz2, c36, c1o36, oneMinusRho); + + + + (*this->localDistributionsH2)(D3Q27System::ET_E, x1, x2, x3) = mfabb; + (*this->localDistributionsH2)(D3Q27System::ET_N, x1, x2, x3) = mfbab; + (*this->localDistributionsH2)(D3Q27System::ET_T, x1, x2, x3) = mfbba; + (*this->localDistributionsH2)(D3Q27System::ET_NE, x1, x2, x3) = mfaab; + (*this->localDistributionsH2)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab; + (*this->localDistributionsH2)(D3Q27System::ET_TE, x1, x2, x3) = mfaba; + (*this->localDistributionsH2)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba; + (*this->localDistributionsH2)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa; + (*this->localDistributionsH2)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca; + (*this->localDistributionsH2)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa; + (*this->localDistributionsH2)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa; + (*this->localDistributionsH2)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca; + (*this->localDistributionsH2)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca; + + (*this->nonLocalDistributionsH2)(D3Q27System::ET_W, x1p, x2, x3) = mfcbb; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_S, x1, x2p, x3) = mfbcb; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_SW, x1p, x2p, x3) = mfccb; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_SE, x1, x2p, x3) = mfacb; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac; + + (*this->zeroDistributionsH2)(x1, x2, x3) = mfbbb; + + } + + /////!CUMULANT PHASE-FIELD @@ -2371,8 +2975,8 @@ void MultiphaseTwoPhaseFieldsCumulantLBMKernel::calculate(int step) } } } - } - dataSet->setPhaseField(divU); + + // dataSet->setPhaseField(divU); } } ////////////////////////////////////////////////////////////////////////// @@ -2416,6 +3020,49 @@ LBMReal MultiphaseTwoPhaseFieldsCumulantLBMKernel::gradX3_phi() //return 3.0 * sum; } +LBMReal MultiphaseTwoPhaseFieldsCumulantLBMKernel::gradX1_phi2() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi2[TNE] - phi2[BSW]) + (phi2[BSE] - phi2[TNW])) + ((phi2[TSE] - phi2[BNW]) + (phi2[BNE] - phi2[TSW]))) + + WEIGTH[NE] * (((phi2[TE] - phi2[BW]) + (phi2[BE] - phi2[TW])) + ((phi2[SE] - phi2[NW]) + (phi2[NE] - phi2[SW])))) + + +WEIGTH[N] * (phi2[E] - phi2[W])); + //LBMReal sum = 0.0; + //for (int k = FSTARTDIR; k <= FENDDIR; k++) { + // sum += WEIGTH[k] * DX1[k] * phi2[k]; + //} + //return 3.0 * sum; +} + +LBMReal MultiphaseTwoPhaseFieldsCumulantLBMKernel::gradX2_phi2() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi2[TNE] - phi2[BSW]) - (phi2[BSE] - phi2[TNW])) + ((phi2[BNE] - phi2[TSW]) - (phi2[TSE] - phi2[BNW]))) + + WEIGTH[NE] * (((phi2[TN] - phi2[BS]) + (phi2[BN] - phi2[TS])) + ((phi2[NE] - phi2[SW]) - (phi2[SE] - phi2[NW])))) + + +WEIGTH[N] * (phi2[N] - phi2[S])); + //LBMReal sum = 0.0; + //for (int k = FSTARTDIR; k <= FENDDIR; k++) { + // sum += WEIGTH[k] * DX2[k] * phi2[k]; + //} + //return 3.0 * sum; +} + +LBMReal MultiphaseTwoPhaseFieldsCumulantLBMKernel::gradX3_phi2() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi2[TNE] - phi2[BSW]) - (phi2[BSE] - phi2[TNW])) + ((phi2[TSE] - phi2[BNW]) - (phi2[BNE] - phi2[TSW]))) + + WEIGTH[NE] * (((phi2[TE] - phi2[BW]) - (phi2[BE] - phi2[TW])) + ((phi2[TS] - phi2[BN]) + (phi2[TN] - phi2[BS])))) + + +WEIGTH[N] * (phi2[T] - phi2[B])); + //LBMReal sum = 0.0; + //for (int k = FSTARTDIR; k <= FENDDIR; k++) { + // sum += WEIGTH[k] * DX3[k] * phi2[k]; + //} + //return 3.0 * sum; +} + + + + + LBMReal MultiphaseTwoPhaseFieldsCumulantLBMKernel::nabla2_phi() { using namespace D3Q27System; @@ -2504,6 +3151,7 @@ void MultiphaseTwoPhaseFieldsCumulantLBMKernel::findNeighbors(CbArray3D<LBMReal, phi[REST] = (*ph)(x1, x2, x3); + for (int k = FSTARTDIR; k <= FENDDIR; k++) { if (!bcArray->isSolid(x1 + DX1[k], x2 + DX2[k], x3 + DX3[k])) { @@ -2514,8 +3162,30 @@ void MultiphaseTwoPhaseFieldsCumulantLBMKernel::findNeighbors(CbArray3D<LBMReal, } } +void MultiphaseTwoPhaseFieldsCumulantLBMKernel::findNeighbors2(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr ph, int x1, int x2, + int x3) +{ + using namespace D3Q27System; + + SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); + + phi2[REST] = (*ph)(x1, x2, x3); + + + for (int k = FSTARTDIR; k <= FENDDIR; k++) { + + if (!bcArray->isSolid(x1 + DX1[k], x2 + DX2[k], x3 + DX3[k])) { + phi2[k] = (*ph)(x1 + DX1[k], x2 + DX2[k], x3 + DX3[k]); + } + else { + phi2[k] = 0.0; + } + } +} + void MultiphaseTwoPhaseFieldsCumulantLBMKernel::swapDistributions() { LBMKernel::swapDistributions(); dataSet->getHdistributions()->swap(); + dataSet->getH2distributions()->swap(); } \ No newline at end of file diff --git a/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsCumulantLBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsCumulantLBMKernel.h index bc7609a2903948e6362a91e863cd10c9376a37be..a65fe073fc18258f518f72df97e6e8751adc4479 100644 --- a/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsCumulantLBMKernel.h +++ b/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsCumulantLBMKernel.h @@ -80,18 +80,23 @@ protected: LBMReal h2[D3Q27System::ENDF + 1]; LBMReal g [D3Q27System::ENDF+1]; LBMReal phi[D3Q27System::ENDF+1]; + LBMReal phi2[D3Q27System::ENDF + 1]; LBMReal pr1[D3Q27System::ENDF+1]; LBMReal phi_cutoff[D3Q27System::ENDF+1]; LBMReal gradX1_phi(); LBMReal gradX2_phi(); LBMReal gradX3_phi(); + LBMReal gradX1_phi2(); + LBMReal gradX2_phi2(); + LBMReal gradX3_phi2(); //LBMReal gradX1_pr1(); //LBMReal gradX2_pr1(); //LBMReal gradX3_pr1(); //LBMReal dirgradC_phi(int n, int k); void computePhasefield(); void findNeighbors(CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr ph /*Phase-Field*/, int x1, int x2, int x3); + void findNeighbors2(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr ph, int x1, int x2, int x3); //void findNeighbors(CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr ph /*Phase-Field*/, CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr pf /*Pressure-Field*/, int x1, int x2, int x3); //void pressureFiltering(CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr pf /*Pressure-Field*/, CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr pf_filtered /*Pressure-Field*/); diff --git a/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsPressureFilterLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsPressureFilterLBMKernel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..846dd82724bc78320b09a5e4e1fccf98d53d4d99 --- /dev/null +++ b/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsPressureFilterLBMKernel.cpp @@ -0,0 +1,3541 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file MultiphaseTwoPhaseFieldsPressureFilterLBMKernel.cpp +//! \ingroup LBMKernel +//! \author Hesameddin Safari +//======================================================================================= + +#include "MultiphaseTwoPhaseFieldsPressureFilterLBMKernel.h" +#include "BCArray3D.h" +#include "Block3D.h" +#include "D3Q27EsoTwist3DSplittedVector.h" +#include "D3Q27System.h" +#include "DataSet3D.h" +#include "LBMKernel.h" +#include <cmath> + +#define PROOF_CORRECTNESS + +////////////////////////////////////////////////////////////////////////// +MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::MultiphaseTwoPhaseFieldsPressureFilterLBMKernel() { this->compressible = false; } +////////////////////////////////////////////////////////////////////////// +void MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::initDataSet() +{ + SPtr<DistributionArray3D> f(new D3Q27EsoTwist3DSplittedVector( nx[0] + 4, nx[1] + 4, nx[2] + 4, -999.9)); + SPtr<DistributionArray3D> h(new D3Q27EsoTwist3DSplittedVector( nx[0] + 4, nx[1] + 4, nx[2] + 4, -999.9)); // For phase-field + SPtr<DistributionArray3D> h2(new D3Q27EsoTwist3DSplittedVector(nx[0] + 4, nx[1] + 4, nx[2] + 4, -999.9)); // For phase-field + SPtr<PhaseFieldArray3D> divU(new PhaseFieldArray3D( nx[0] + 4, nx[1] + 4, nx[2] + 4, 0.0)); + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr pressure(new CbArray3D<LBMReal, IndexerX3X2X1>( nx[0] + 4, nx[1] + 4, nx[2] + 4, 0.0)); + pressureOld = CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>(nx[0] + 4, nx[1] + 4, nx[2] + 4, 0.0)); + dataSet->setFdistributions(f); + dataSet->setHdistributions(h); // For phase-field + dataSet->setH2distributions(h2); // For phase-field + dataSet->setPhaseField(divU); + dataSet->setPressureField(pressure); +} +////////////////////////////////////////////////////////////////////////// +SPtr<LBMKernel> MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::clone() +{ + SPtr<LBMKernel> kernel(new MultiphaseTwoPhaseFieldsPressureFilterLBMKernel()); + kernel->setNX(nx); + dynamicPointerCast<MultiphaseTwoPhaseFieldsPressureFilterLBMKernel>(kernel)->initDataSet(); + kernel->setCollisionFactorMultiphase(this->collFactorL, this->collFactorG); + kernel->setDensityRatio(this->densityRatio); + kernel->setMultiphaseModelParameters(this->beta, this->kappa); + kernel->setContactAngle(this->contactAngle); + kernel->setPhiL(this->phiL); + kernel->setPhiH(this->phiH); + kernel->setPhaseFieldRelaxation(this->tauH); + kernel->setMobility(this->mob); + kernel->setInterfaceWidth(this->interfaceWidth); + + kernel->setBCProcessor(bcProcessor->clone(kernel)); + kernel->setWithForcing(withForcing); + kernel->setForcingX1(muForcingX1); + kernel->setForcingX2(muForcingX2); + kernel->setForcingX3(muForcingX3); + kernel->setIndex(ix1, ix2, ix3); + kernel->setDeltaT(deltaT); + kernel->setGhostLayerWidth(2); + + return kernel; +} +////////////////////////////////////////////////////////////////////////// + void MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::forwardInverseChimeraWithKincompressible(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K, LBMReal oneMinusRho) { + using namespace UbMath; + LBMReal m2 = mfa + mfc; + LBMReal m1 = mfc - mfa; + LBMReal m0 = m2 + mfb; + mfa = m0; + m0 *= Kinverse; + m0 += oneMinusRho; + mfb = (m1 * Kinverse - m0 * vv) * K; + mfc = ((m2 - c2 * m1 * vv) * Kinverse + v2 * m0) * K; +} + +//////////////////////////////////////////////////////////////////////////////// + void MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::backwardInverseChimeraWithKincompressible(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K, LBMReal oneMinusRho) { + using namespace UbMath; + LBMReal m0 = (((mfc - mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (v2 - vv) * c1o2) * K; + LBMReal m1 = (((mfa - mfc) - c2 * mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (-v2)) * K; + mfc = (((mfc + mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (v2 + vv) * c1o2) * K; + mfa = m0; + mfb = m1; +} + + +//////////////////////////////////////////////////////////////////////////////// + void MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::forwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2) { + using namespace UbMath; + LBMReal m1 = (mfa + mfc) + mfb; + LBMReal m2 = mfc - mfa; + mfc = (mfc + mfa) + (v2 * m1 - c2 * vv * m2); + mfb = m2 - vv * m1; + mfa = m1; +} + + + void MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::backwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2) { + using namespace UbMath; + LBMReal ma = (mfc + mfa * (v2 - vv)) * c1o2 + mfb * (vv - c1o2); + LBMReal mb = ((mfa - mfc) - mfa * v2) - c2 * mfb * vv; + mfc = (mfc + mfa * (v2 + vv)) * c1o2 + mfb * (vv + c1o2); + mfb = mb; + mfa = ma; +} + + +void MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::calculate(int step) +{ + using namespace D3Q27System; + using namespace UbMath; + + forcingX1 = 0.0; + forcingX2 = 0.0; + forcingX3 = 0.0; + + LBMReal oneOverInterfaceScale = c4 / interfaceWidth; //1.0;//1.5; + ///////////////////////////////////// + + localDistributionsF = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getLocalDistributions(); + nonLocalDistributionsF = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getNonLocalDistributions(); + zeroDistributionsF = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getZeroDistributions(); + + localDistributionsH1 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getHdistributions())->getLocalDistributions(); + nonLocalDistributionsH1 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getHdistributions())->getNonLocalDistributions(); + zeroDistributionsH1 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getHdistributions())->getZeroDistributions(); + + localDistributionsH2 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getH2distributions())->getLocalDistributions(); + nonLocalDistributionsH2 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getH2distributions())->getNonLocalDistributions(); + zeroDistributionsH2 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getH2distributions())->getZeroDistributions(); + + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr pressure = dataSet->getPressureField(); + + SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); + + const int bcArrayMaxX1 = (int)bcArray->getNX1(); + const int bcArrayMaxX2 = (int)bcArray->getNX2(); + const int bcArrayMaxX3 = (int)bcArray->getNX3(); + + int minX1 = ghostLayerWidth; + int minX2 = ghostLayerWidth; + int minX3 = ghostLayerWidth; + int maxX1 = bcArrayMaxX1 - ghostLayerWidth; + int maxX2 = bcArrayMaxX2 - ghostLayerWidth; + int maxX3 = bcArrayMaxX3 - ghostLayerWidth; + + //TODO + //very expensive !!!!! + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr phaseField( + new CbArray3D<LBMReal, IndexerX3X2X1>(bcArrayMaxX1, bcArrayMaxX2, bcArrayMaxX3, -999.0)); + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr phaseField2( + new CbArray3D<LBMReal, IndexerX3X2X1>(bcArrayMaxX1, bcArrayMaxX2, bcArrayMaxX3, -999.0)); + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr divU( + new CbArray3D<LBMReal, IndexerX3X2X1>(bcArrayMaxX1, bcArrayMaxX2, bcArrayMaxX3, 0.0)); + +//#pragma omp parallel for + for (int x3 = minX3-ghostLayerWidth; x3 < maxX3+ghostLayerWidth; x3++) { + for (int x2 = minX2-ghostLayerWidth; x2 < maxX2+ghostLayerWidth; x2++) { + for (int x1 = minX1-ghostLayerWidth; x1 < maxX1+ghostLayerWidth; x1++) { + if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) { + int x1p = x1 + 1; + int x2p = x2 + 1; + int x3p = x3 + 1; + + LBMReal mfcbb = (*this->localDistributionsH1)(D3Q27System::ET_E, x1, x2, x3); + LBMReal mfbcb = (*this->localDistributionsH1)(D3Q27System::ET_N, x1, x2, x3); + LBMReal mfbbc = (*this->localDistributionsH1)(D3Q27System::ET_T, x1, x2, x3); + LBMReal mfccb = (*this->localDistributionsH1)(D3Q27System::ET_NE, x1, x2, x3); + LBMReal mfacb = (*this->localDistributionsH1)(D3Q27System::ET_NW, x1p, x2, x3); + LBMReal mfcbc = (*this->localDistributionsH1)(D3Q27System::ET_TE, x1, x2, x3); + LBMReal mfabc = (*this->localDistributionsH1)(D3Q27System::ET_TW, x1p, x2, x3); + LBMReal mfbcc = (*this->localDistributionsH1)(D3Q27System::ET_TN, x1, x2, x3); + LBMReal mfbac = (*this->localDistributionsH1)(D3Q27System::ET_TS, x1, x2p, x3); + LBMReal mfccc = (*this->localDistributionsH1)(D3Q27System::ET_TNE, x1, x2, x3); + LBMReal mfacc = (*this->localDistributionsH1)(D3Q27System::ET_TNW, x1p, x2, x3); + LBMReal mfcac = (*this->localDistributionsH1)(D3Q27System::ET_TSE, x1, x2p, x3); + LBMReal mfaac = (*this->localDistributionsH1)(D3Q27System::ET_TSW, x1p, x2p, x3); + LBMReal mfabb = (*this->nonLocalDistributionsH1)(D3Q27System::ET_W, x1p, x2, x3); + LBMReal mfbab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_S, x1, x2p, x3); + LBMReal mfbba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_B, x1, x2, x3p); + LBMReal mfaab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SW, x1p, x2p, x3); + LBMReal mfcab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SE, x1, x2p, x3); + LBMReal mfaba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BW, x1p, x2, x3p); + LBMReal mfcba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BE, x1, x2, x3p); + LBMReal mfbaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BS, x1, x2p, x3p); + LBMReal mfbca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BN, x1, x2, x3p); + LBMReal mfaaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSW, x1p, x2p, x3p); + LBMReal mfcaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSE, x1, x2p, x3p); + LBMReal mfaca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNW, x1p, x2, x3p); + LBMReal mfcca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNE, x1, x2, x3p); + + LBMReal mfbbb = (*this->zeroDistributionsH1)(x1, x2, x3); + (*phaseField)(x1, x2, x3) = (((mfaaa + mfccc) + (mfaca + mfcac)) + ((mfaac + mfcca) + (mfcaa + mfacc)) ) + + (((mfaab + mfacb) + (mfcab + mfccb)) + ((mfaba + mfabc) + (mfcba + mfcbc)) + + ((mfbaa + mfbac) + (mfbca + mfbcc))) + ((mfabb + mfcbb) + + (mfbab + mfbcb) + (mfbba + mfbbc)) + mfbbb; + + mfcbb = (*this->localDistributionsH2)(D3Q27System::ET_E, x1, x2, x3); + mfbcb = (*this->localDistributionsH2)(D3Q27System::ET_N, x1, x2, x3); + mfbbc = (*this->localDistributionsH2)(D3Q27System::ET_T, x1, x2, x3); + mfccb = (*this->localDistributionsH2)(D3Q27System::ET_NE, x1, x2, x3); + mfacb = (*this->localDistributionsH2)(D3Q27System::ET_NW, x1p, x2, x3); + mfcbc = (*this->localDistributionsH2)(D3Q27System::ET_TE, x1, x2, x3); + mfabc = (*this->localDistributionsH2)(D3Q27System::ET_TW, x1p, x2, x3); + mfbcc = (*this->localDistributionsH2)(D3Q27System::ET_TN, x1, x2, x3); + mfbac = (*this->localDistributionsH2)(D3Q27System::ET_TS, x1, x2p, x3); + mfccc = (*this->localDistributionsH2)(D3Q27System::ET_TNE, x1, x2, x3); + mfacc = (*this->localDistributionsH2)(D3Q27System::ET_TNW, x1p, x2, x3); + mfcac = (*this->localDistributionsH2)(D3Q27System::ET_TSE, x1, x2p, x3); + mfaac = (*this->localDistributionsH2)(D3Q27System::ET_TSW, x1p, x2p, x3); + mfabb = (*this->nonLocalDistributionsH2)(D3Q27System::ET_W, x1p, x2, x3); + mfbab = (*this->nonLocalDistributionsH2)(D3Q27System::ET_S, x1, x2p, x3); + mfbba = (*this->nonLocalDistributionsH2)(D3Q27System::ET_B, x1, x2, x3p); + mfaab = (*this->nonLocalDistributionsH2)(D3Q27System::ET_SW, x1p, x2p, x3); + mfcab = (*this->nonLocalDistributionsH2)(D3Q27System::ET_SE, x1, x2p, x3); + mfaba = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BW, x1p, x2, x3p); + mfcba = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BE, x1, x2, x3p); + mfbaa = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BS, x1, x2p, x3p); + mfbca = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BN, x1, x2, x3p); + mfaaa = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BSW, x1p, x2p, x3p); + mfcaa = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BSE, x1, x2p, x3p); + mfaca = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BNW, x1p, x2, x3p); + mfcca = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BNE, x1, x2, x3p); + + mfbbb = (*this->zeroDistributionsH2)(x1, x2, x3); + (*phaseField2)(x1, x2, x3) = + (((mfaaa + mfccc) + (mfaca + mfcac)) + ((mfaac + mfcca) + (mfcaa + mfacc))) + + (((mfaab + mfacb) + (mfcab + mfccb)) + ((mfaba + mfabc) + (mfcba + mfcbc)) + + ((mfbaa + mfbac) + (mfbca + mfbcc))) + + ((mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc)) + mfbbb; + //(*phaseField)(x1, x2, x3) = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) + + // (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + + // (mfbaa + mfbac + mfbca + mfbcc) + (mfabb + mfcbb) + + // (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; + +////// read F-distributions for velocity formalism + + + mfcbb = (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3); + mfbcb = (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3); + mfbbc = (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3); + mfccb = (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3); + mfacb = (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3); + mfcbc = (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3); + mfabc = (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3); + mfbcc = (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3); + mfbac = (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3); + mfccc = (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3); + mfacc = (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3); + mfcac = (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3); + mfaac = (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3); + mfabb = (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3); + mfbab = (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3); + mfbba = (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p); + mfaab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3); + mfcab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3); + mfaba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p); + mfcba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p); + mfbaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p); + mfbca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p); + mfaaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p); + mfcaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p); + mfaca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p); + mfcca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p); + + mfbbb = (*this->zeroDistributionsF)(x1, x2, x3); + + LBMReal rhoH = 1.0; + LBMReal rhoL = 1.0 / densityRatio; + + LBMReal rhoToPhi = (rhoH - rhoL) / (phiH - phiL); + + LBMReal drho = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) + + (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + (mfbaa + mfbac + mfbca + mfbcc) + + (mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; + + LBMReal rho = rhoH + rhoToPhi * ((*pressure)(x1, x2, x3) - phiH); + //! variable density -> TRANSFER! + //LBMReal rho = rhoH * ((*phaseField)(x1, x2, x3)) + rhoL * ((*phaseField2)(x1, x2, x3)); + + (*pressure)(x1, x2, x3) = (*pressure)(x1, x2, x3) + rho * c1o3 * drho; + + //(*pressure)(x1, x2, x3) = (((*phaseField)(x1, x2, x3)) + ((*phaseField2)(x1, x2, x3)) - c1) * c1o3; + ////!!!!!! relplace by pointer swap! + //(*pressureOld)(x1, x2, x3) = (*pressure)(x1, x2, x3); + } + } + } + } + + LBMReal collFactorM; + //LBMReal forcingTerm[D3Q27System::ENDF + 1]; + + ////filter + + //for (int x3 = minX3; x3 < maxX3; x3++) { + // for (int x2 = minX2; x2 < maxX2; x2++) { + // for (int x1 = minX1; x1 < maxX1; x1++) { + // if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) { + + // LBMReal sum = 0.; + + // //Lapalce pressure + // //sum += WEIGTH[TNE] * (((((*pressure)(x1+1, x2+1, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2-1, x3-1) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1+1, x2+1, x3-1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2-1, x3+1) - (*pressure)(x1, x2, x3)))) + // // + ((((*pressure)(x1+1, x2-1, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2+1, x3-1) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1+1, x2-1, x3-1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2+1, x3+1) - (*pressure)(x1, x2, x3))))); + // //sum += WEIGTH[TN] * ( + // // ((((*pressure)(x1+1, x2+1, x3) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2-1, x3) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1+1, x2-1, x3) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2+1, x3) - (*pressure)(x1, x2, x3)))) + // // + ((((*pressure)(x1+1, x2, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2, x3-1) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1+1, x2, x3-1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2, x3+1) - (*pressure)(x1, x2, x3)))) + // // + ((((*pressure)(x1, x2+1, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2-1, x3-1) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1, x2+1, x3-1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2-1, x3+1) - (*pressure)(x1, x2, x3)))) + // // ); + // //sum += WEIGTH[T] * ( + // // (((*pressure)(x1+1, x2, x3) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2, x3) - (*pressure)(x1, x2, x3))) + // // + (((*pressure)(x1, x2+1, x3) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2-1, x3) - (*pressure)(x1, x2, x3))) + // // + (((*pressure)(x1, x2, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2, x3-1) - (*pressure)(x1, x2, x3))) + // // ); + + + // //LBMReal pressureFilter = 100; + // //(*pressureOld)(x1, x2, x3) = (*pressure)(x1, x2, x3) + pressureFilter * sum * (sqrt(fabs(sum))); + + // //Situpol Eq. 81 + // sum += WEIGTH[TNE] * (((((*pressure)(x1+1, x2+1, x3+1)) + ((*pressure)(x1-1, x2-1, x3-1) )) + (((*pressure)(x1+1, x2+1, x3-1) ) + ((*pressure)(x1-1, x2-1, x3+1) ))) + // + ((((*pressure)(x1+1, x2-1, x3+1) ) + ((*pressure)(x1-1, x2+1, x3-1) )) + (((*pressure)(x1+1, x2-1, x3-1) ) + ((*pressure)(x1-1, x2+1, x3+1) )))); + // sum += WEIGTH[TN] * ( + // ((((*pressure)(x1+1, x2+1, x3) ) + ((*pressure)(x1-1, x2-1, x3) )) + (((*pressure)(x1+1, x2-1, x3) ) + ((*pressure)(x1-1, x2+1, x3) ))) + // + ((((*pressure)(x1+1, x2, x3+1) ) + ((*pressure)(x1-1, x2, x3-1) )) + (((*pressure)(x1+1, x2, x3-1) ) + ((*pressure)(x1-1, x2, x3+1) ))) + // + ((((*pressure)(x1, x2+1, x3+1) ) + ((*pressure)(x1, x2-1, x3-1) )) + (((*pressure)(x1, x2+1, x3-1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2-1, x3+1) ))) + // ); + // sum += WEIGTH[T] * ( + // (((*pressure)(x1+1, x2, x3) ) + ((*pressure)(x1-1, x2, x3) )) + // + (((*pressure)(x1, x2+1, x3) ) + ((*pressure)(x1, x2-1, x3) )) + // + (((*pressure)(x1, x2, x3+1)) + ((*pressure)(x1, x2, x3-1) )) + // ); + // sum += WEIGTH[REST] * (*pressure)(x1, x2, x3); + // (*pressureOld)(x1, x2, x3) = sum; + + + + + // } + // } + // } + //} + + ////Periodic Filter +//#pragma omp parallel for + for (int x3 = minX3-1; x3 <= maxX3; x3++) { + for (int x2 = minX2-1; x2 <= maxX2; x2++) { + for (int x1 = minX1-1; x1 <= maxX1; x1++) { + if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) { + + LBMReal sum = 0.; + + + + //Lapalce pressure + //sum += WEIGTH[TNE] * (((((*pressure)(x1+1, x2+1, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2-1, x3-1) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1+1, x2+1, x3-1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2-1, x3+1) - (*pressure)(x1, x2, x3)))) + // + ((((*pressure)(x1+1, x2-1, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2+1, x3-1) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1+1, x2-1, x3-1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2+1, x3+1) - (*pressure)(x1, x2, x3))))); + //sum += WEIGTH[TN] * ( + // ((((*pressure)(x1+1, x2+1, x3) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2-1, x3) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1+1, x2-1, x3) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2+1, x3) - (*pressure)(x1, x2, x3)))) + // + ((((*pressure)(x1+1, x2, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2, x3-1) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1+1, x2, x3-1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2, x3+1) - (*pressure)(x1, x2, x3)))) + // + ((((*pressure)(x1, x2+1, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2-1, x3-1) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1, x2+1, x3-1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2-1, x3+1) - (*pressure)(x1, x2, x3)))) + // ); + //sum += WEIGTH[T] * ( + // (((*pressure)(x1+1, x2, x3) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2, x3) - (*pressure)(x1, x2, x3))) + // + (((*pressure)(x1, x2+1, x3) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2-1, x3) - (*pressure)(x1, x2, x3))) + // + (((*pressure)(x1, x2, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2, x3-1) - (*pressure)(x1, x2, x3))) + // ); + + + //LBMReal pressureFilter = 100; + //(*pressureOld)(x1, x2, x3) = (*pressure)(x1, x2, x3) + pressureFilter * sum * (sqrt(fabs(sum))); + + //Situpol Eq. 81 + + //int x1p = (x1 < maxX1) ? x1 + 1 : 0; + //int x1m = (x1 > 0) ? x1 - 1 : maxX1; + //int x2p = (x2 < maxX2) ? x2 + 1 : 0; + //int x2m = (x2 > 0) ? x2 - 1 : maxX2; + //int x3p = (x3 < maxX3) ? x3 + 1 : 0; + //int x3m = (x3 > 0) ? x3 - 1 : maxX3; + //sum += WEIGTH[TNE] * (((((*pressure)(x1p, x2p, x3p)) + ((*pressure)(x1m, x2m, x3m))) + (((*pressure)(x1p, x2p, x3m)) + ((*pressure)(x1m, x2m, x3p)))) + // + ((((*pressure)(x1p, x2m, x3p)) + ((*pressure)(x1m, x2p, x3m))) + (((*pressure)(x1p, x2m, x3m)) + ((*pressure)(x1m, x2p, x3p))))); + //sum += WEIGTH[TN] * ( + // ((((*pressure)(x1p, x2p, x3)) + ((*pressure)(x1m, x2m, x3))) + (((*pressure)(x1p, x2m, x3)) + ((*pressure)(x1m, x2p, x3)))) + // + ((((*pressure)(x1p, x2, x3p)) + ((*pressure)(x1m, x2, x3m))) + (((*pressure)(x1p, x2, x3m)) + ((*pressure)(x1m, x2, x3p)))) + // + ((((*pressure)(x1, x2p, x3p)) + ((*pressure)(x1, x2m, x3m))) + (((*pressure)(x1, x2p, x3m) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2m, x3p)))) + // ); + //sum += WEIGTH[T] * ( + // (((*pressure)(x1p, x2, x3)) + ((*pressure)(x1m, x2, x3))) + // + (((*pressure)(x1, x2p, x3)) + ((*pressure)(x1, x2m, x3))) + // + (((*pressure)(x1, x2, x3p)) + ((*pressure)(x1, x2, x3m))) + // ); + //sum += WEIGTH[REST] * (*pressure)(x1, x2, x3); + //(*pressureOld)(x1, x2, x3) = sum; + + ///Version for boundaries + for (int xx = -1; xx <= 1; xx++) { + //int xxx = (xx+x1 <= maxX1) ? ((xx + x1 > 0) ? xx + x1 : maxX1) : 0; + int xxx = xx + x1; + + for (int yy = -1; yy <= 1; yy++) { + //int yyy = (yy+x2 <= maxX2) ?( (yy + x2 > 0) ? yy + x2 : maxX2) : 0; + int yyy = yy + x2; + + for (int zz = -1; zz <= 1; zz++) { + //int zzz = (zz+x3 <= maxX3) ? zzz = ((zz + x3 > 0) ? zz + x3 : maxX3 ): 0; + int zzz = zz + x3; + + if (!bcArray->isSolid(xxx, yyy, zzz) && !bcArray->isUndefined(xxx, yyy, zzz)) { + sum+= 64.0/(216.0*(c1+c3*abs(xx))* (c1 + c3 * abs(yy))* (c1 + c3 * abs(zz)))*(*pressure)(xxx, yyy, zzz); + } + else{ sum+= 64.0 / (216.0 * (c1 + c3 * abs(xx)) * (c1 + c3 * abs(yy)) * (c1 + c3 * abs(zz))) * (*pressure)(x1, x2, x3); + } + + + } + } + } + (*pressureOld)(x1, x2, x3) = sum; + + + + } + } + } + } + +//#pragma omp parallel for + for (int x3 = minX3-1; x3 <= maxX3; x3++) { + for (int x2 = minX2-1; x2 <= maxX2; x2++) { + for (int x1 = minX1-1; x1 <= maxX1; x1++) { + if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) { + ///filter! + + (*pressure)(x1, x2, x3) = (*pressureOld)(x1, x2, x3); + } + } + } + } + ////!filter + + +//#pragma omp parallel for + for (int x3 = minX3; x3 < maxX3; x3++) { + for (int x2 = minX2; x2 < maxX2; x2++) { + for (int x1 = minX1; x1 < maxX1; x1++) { + if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) { + int x1p = x1 + 1; + int x2p = x2 + 1; + int x3p = x3 + 1; + + + + ////////////////////////////////////////////////////////////////////////// + // Read distributions and phase field + //////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + + // E N T + // c c c + ////////// + // W S B + // a a a + + // Rest ist b + + // mfxyz + // a - negative + // b - null + // c - positive + + // a b c + //-1 0 1 + + findNeighbors(phaseField, x1, x2, x3); + findNeighbors2(phaseField2, x1, x2, x3); + + LBMReal mfcbb = (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3); + LBMReal mfbcb = (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3); + LBMReal mfbbc = (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3); + LBMReal mfccb = (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3); + LBMReal mfacb = (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3); + LBMReal mfcbc = (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3); + LBMReal mfabc = (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3); + LBMReal mfbcc = (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3); + LBMReal mfbac = (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3); + LBMReal mfccc = (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3); + LBMReal mfacc = (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3); + LBMReal mfcac = (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3); + LBMReal mfaac = (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3); + LBMReal mfabb = (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3); + LBMReal mfbab = (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3); + LBMReal mfbba = (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p); + LBMReal mfaab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3); + LBMReal mfcab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3); + LBMReal mfaba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p); + LBMReal mfcba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p); + LBMReal mfbaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p); + LBMReal mfbca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p); + LBMReal mfaaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p); + LBMReal mfcaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p); + LBMReal mfaca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p); + LBMReal mfcca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p); + + LBMReal mfbbb = (*this->zeroDistributionsF)(x1, x2, x3); + + LBMReal rhoH = 1.0; + LBMReal rhoL = 1.0 / densityRatio; + + LBMReal rhoToPhi = (rhoH - rhoL) / (phiH - phiL); + + LBMReal dX1_phi = gradX1_phi(); + LBMReal dX2_phi = gradX2_phi(); + LBMReal dX3_phi = gradX3_phi(); + + //LBMReal dX1_phi2 = gradX1_phi2(); + //LBMReal dX2_phi2 = gradX2_phi2(); + //LBMReal dX3_phi2 = gradX3_phi2(); + + + // LBMReal denom2 = sqrt(dX1_phi * dX1_phi+ dX1_phi2 * dX1_phi2 + dX2_phi * dX2_phi + dX2_phi2 * dX2_phi2 + dX3_phi * dX3_phi+ dX3_phi2 * dX3_phi2) + 1e-9; + // LBMReal normX1 = (dX1_phi-dX1_phi2)/denom2; + //LBMReal normX2 = (dX2_phi-dX2_phi2)/denom2; + //LBMReal normX3 = (dX3_phi-dX3_phi2)/denom2; + + LBMReal denom = sqrt(dX1_phi * dX1_phi + dX2_phi * dX2_phi + dX3_phi * dX3_phi) + 1e-9; + LBMReal normX1 = dX1_phi / denom; + LBMReal normX2 = dX2_phi / denom; + LBMReal normX3 = dX3_phi / denom; + + + + collFactorM = collFactorL + (collFactorL - collFactorG) * (phi[REST] - phiH) / (phiH - phiL); + + + LBMReal mu = 2 * beta * phi[REST] * (phi[REST] - 1) * (2 * phi[REST] - 1) - kappa * nabla2_phi(); + + //----------- Calculating Macroscopic Values ------------- + LBMReal rho = rhoH + rhoToPhi * (phi[REST] - phiH); + + //! variable density -> TRANSFER! + //LBMReal rho = rhoH * ((*phaseField)(x1, x2, x3)) + rhoL * ((*phaseField2)(x1, x2, x3)); + + + ////Incompressible Kernal + + //mfbbc = (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3) ;// / rho * c3; + //mfbcb = (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3) ;// / rho * c3; + //mfccb = (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3) ;// / rho * c3; + //mfacb = (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3) ;// / rho * c3; + //mfcbb = (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3) ;// / rho * c3; + //mfcbc = (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3) ;// / rho * c3; + //mfabc = (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3) ;// / rho * c3; + //mfbcc = (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3) ;// / rho * c3; + //mfbac = (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3) ;// / rho * c3; + //mfccc = (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3) ;// / rho * c3; + //mfacc = (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3) ;// / rho * c3; + //mfcac = (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3) ;// / rho * c3; + //mfaac = (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3) ;// / rho * c3; + //mfabb = (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3) ;// / rho * c3; + //mfbab = (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3) ;// / rho * c3; + //mfbba = (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p) ;// / rho * c3; + //mfaab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3) ;// / rho * c3; + //mfcab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3) ;// / rho * c3; + //mfaba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p) ;// / rho * c3; + //mfcba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p) ;// / rho * c3; + //mfbaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p) ;// / rho * c3; + //mfbca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p) ;// / rho * c3; + //mfaaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p) ;// / rho * c3; + //mfcaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p) ;// / rho * c3; + //mfaca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p) ;// / rho * c3; + //mfcca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p) ;// / rho * c3; + + //mfbbb = (*this->zeroDistributionsF)(x1, x2, x3);// / rho * c3; + + + LBMReal m0, m1, m2; + LBMReal rhoRef=c1; + + //LBMReal + // LBMReal drho = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) + // + (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + (mfbaa + mfbac + mfbca + mfbcc) + // + (mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; + + LBMReal vvx = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + + (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + + (mfcbb - mfabb))/rhoRef; + LBMReal vvy = ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + + (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + + (mfbcb - mfbab))/rhoRef; + LBMReal vvz = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + + (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + + (mfbbc - mfbba))/rhoRef; + + // (*pressure)(x1, x2, x3) = (*pressureOld)(x1, x2, x3)+rho*c1o3*drho; + + //LBMReal gradPx = c1o2 * ((*pressure)(x1 + 1, x2, x3) - (*pressure)(x1 - 1, x2, x3)); + //LBMReal gradPy = c1o2 * ((*pressure)(x1, x2 + 1, x3) - (*pressure)(x1, x2 - 1, x3)); + //LBMReal gradPz = c1o2 * ((*pressure)(x1, x2, x3 + 1) - (*pressure)(x1, x2, x3 - 1)); + + //LBMReal gradPx = 3.0 * (WEIGTH[TNE] * ( + // (((*pressure)(x1 + 1, x2 + 1, x3 + 1) - (*pressure)(x1 - 1, x2 - 1, x3 - 1)) + ((*pressure)(x1 + 1, x2 - 1, x3 + 1) - (*pressure)(x1 - 1, x2 + 1, x3 - 1))) + // + (((*pressure)(x1 + 1, x2 - 1, x3 - 1) - (*pressure)(x1 - 1, x2 + 1, x3 + 1)) + ((*pressure)(x1 + 1, x2 + 1, x3 - 1) - (*pressure)(x1 - 1, x2 - 1, x3 + 1)))) + // + WEIGTH[NE] * ( + // (((*pressure)(x1 + 1, x2 + 1, x3) - (*pressure)(x1 - 1, x2 - 1, x3)) + ((*pressure)(x1 + 1, x2 - 1, x3) - (*pressure)(x1 - 1, x2 + 1, x3))) + // + (((*pressure)(x1 + 1, x2, x3 - 1) - (*pressure)(x1 - 1, x2, x3 + 1)) + ((*pressure)(x1 + 1, x2, x3 + 1) - (*pressure)(x1 - 1, x2, x3 - 1)))) + // + WEIGTH[E] * ((*pressure)(x1 + 1, x2, x3) - (*pressure)(x1 - 1, x2, x3))); + + //LBMReal gradPy = 3.0 * (WEIGTH[TNE] * ( + // (((*pressure)(x1 + 1, x2 + 1, x3 + 1) - (*pressure)(x1 - 1, x2 - 1, x3 - 1)) + ((*pressure)(x1 - 1, x2 + 1, x3 + 1) - (*pressure)(x1 + 1, x2 - 1, x3 - 1))) + // + (((*pressure)(x1 - 1, x2 + 1, x3 - 1) - (*pressure)(x1 + 1, x2 - 1, x3 + 1)) + ((*pressure)(x1 + 1, x2 + 1, x3 - 1) - (*pressure)(x1 - 1, x2 - 1, x3 + 1)))) + // + WEIGTH[NE] * ( + // (((*pressure)(x1 + 1, x2 + 1, x3) - (*pressure)(x1 - 1, x2 - 1, x3)) + ((*pressure)(x1 - 1, x2 + 1, x3) - (*pressure)(x1 + 1, x2 - 1, x3))) + // + (((*pressure)(x1, x2+1, x3 - 1) - (*pressure)(x1, x2-1, x3 + 1)) + ((*pressure)(x1, x2+1, x3 + 1) - (*pressure)(x1, x2-1, x3 - 1)))) + // + WEIGTH[E] * ((*pressure)(x1, x2+1, x3) - (*pressure)(x1, x2-1, x3))); + + //LBMReal gradPz = 3.0 * (WEIGTH[TNE] * ( + // (((*pressure)(x1 + 1, x2 + 1, x3 + 1) - (*pressure)(x1 - 1, x2 - 1, x3 - 1)) + ((*pressure)(x1 - 1, x2 + 1, x3 + 1) - (*pressure)(x1 + 1, x2 - 1, x3 - 1))) + // + (((*pressure)(x1 - 1, x2 - 1, x3 + 1) - (*pressure)(x1 + 1, x2 + 1, x3 - 1)) + ((*pressure)(x1 + 1, x2 - 1, x3 + 1) - (*pressure)(x1 - 1, x2 + 1, x3 - 1)))) + // + WEIGTH[NE] * ( + // (((*pressure)(x1 + 1, x2, x3+1) - (*pressure)(x1 - 1, x2, x3-1)) + ((*pressure)(x1 - 1, x2, x3+1) - (*pressure)(x1 + 1, x2, x3-1))) + // + (((*pressure)(x1, x2 - 1, x3 + 1) - (*pressure)(x1, x2 + 1, x3 - 1)) + ((*pressure)(x1, x2 + 1, x3 + 1) - (*pressure)(x1, x2 - 1, x3 - 1)))) + // + WEIGTH[E] * ((*pressure)(x1, x2, x3+1) - (*pressure)(x1, x2, x3-1))); + + + LBMReal gradPx = 0.0; + LBMReal gradPy = 0.0; + LBMReal gradPz = 0.0; + for (int dir1 = -1; dir1 <= 1; dir1++) { + for (int dir2 = -1; dir2 <= 1; dir2++) { + int yyy = x2 + dir1; + int zzz = x3 + dir2; + if (!bcArray->isSolid(x1-1, yyy, zzz) && !bcArray->isUndefined(x1-1, yyy, zzz)) { + gradPx -= (*pressure)(x1 - 1, yyy, zzz) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPx -= (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + if (!bcArray->isSolid(x1 + 1, yyy, zzz) && !bcArray->isUndefined(x1 + 1, yyy, zzz)) { + gradPx += (*pressure)(x1 + 1, yyy, zzz) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPx += (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + + int xxx = x1 + dir1; + if (!bcArray->isSolid(xxx, x2-1, zzz) && !bcArray->isUndefined(xxx, x2-1, zzz)) { + gradPy -= (*pressure)(xxx, x2-1, zzz) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPy -= (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + if (!bcArray->isSolid(xxx, x2+1, zzz) && !bcArray->isUndefined(xxx, x2+1, zzz)) { + gradPy += (*pressure)(xxx, x2+1, zzz) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPy += (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + + yyy = x2 + dir2; + if (!bcArray->isSolid(xxx, yyy, x3-1) && !bcArray->isUndefined(xxx, yyy, x3-1)) { + gradPz -= (*pressure)(xxx, yyy, x3-1) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPz -= (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + if (!bcArray->isSolid(xxx, yyy, x3+1) && !bcArray->isUndefined(xxx, yyy, x3+1)) { + gradPz += (*pressure)(xxx, yyy, x3+1) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPz += (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + + } + } + + //Viscosity increase by pressure gradient + LBMReal errPhi = (((1.0 - phi[REST]) * (phi[REST]) * oneOverInterfaceScale)- denom); + //LBMReal limVis = 0.0000001*10;//0.01; + // collFactorM =collFactorM/(c1+limVis*(errPhi*errPhi)*collFactorM); + // collFactorM = (collFactorM < 1.8) ? 1.8 : collFactorM; + errPhi = errPhi * errPhi* errPhi * errPhi * errPhi * errPhi; + //collFactorM = collFactorM + (1.8 - collFactorM) * errPhi / (errPhi + limVis); + + //3.0 * ((WEIGTH[TNE] * (((phi2[TNE] - phi2[BSW]) - (phi2[BSE] - phi2[TNW])) + ((phi2[TSE] - phi2[BNW]) - (phi2[BNE] - phi2[TSW]))) + //+WEIGTH[NE] * (((phi2[TE] - phi2[BW]) - (phi2[BE] - phi2[TW])) + ((phi2[TS] - phi2[BN]) + (phi2[TN] - phi2[BS])))) + + //+WEIGTH[N] * (phi2[T] - phi2[B])); + + if (withForcing) { + // muX1 = static_cast<double>(x1-1+ix1*maxX1); + // muX2 = static_cast<double>(x2-1+ix2*maxX2); + // muX3 = static_cast<double>(x3-1+ix3*maxX3); + + // forcingX1 = muForcingX1.Eval()+c1o3*drho*dX1_phi*rhoToPhi/rho;//-gradPx/rho; + // forcingX2 = muForcingX2.Eval() + c1o3*drho*dX2_phi * rhoToPhi / rho;//-gradPy/rho; + //forcingX3 = muForcingX3.Eval() + c1o3*drho*dX3_phi * rhoToPhi / rho;//-gradPz/rho; + + muForcingX1.DefineVar("rho",&muRho); + muForcingX2.DefineVar("rho",&muRho); + muForcingX3.DefineVar("rho",&muRho); + + muRho = rho; + + forcingX1 = muForcingX1.Eval()/rho - gradPx/rho; + forcingX2 = muForcingX2.Eval()/rho - gradPy/rho; + forcingX3 = muForcingX3.Eval()/rho - gradPz/rho; + + //LBMReal rho_m = 1.0 / densityRatio; + //forcingX1 = forcingX1 * (rho - rho_m); + //forcingX2 = forcingX2 * (rho - rho_m); + //forcingX3 = forcingX3 * (rho - rho_m); + vvx += forcingX1 * deltaT * 0.5; // X + vvy += forcingX2 * deltaT * 0.5; // Y + vvz += forcingX3 * deltaT * 0.5; // Z + + } + + + ///surface tension force + vvx += mu * dX1_phi * c1o2 / rho; + vvy += mu * dX2_phi * c1o2 / rho ; + vvz += mu * dX3_phi * c1o2 / rho; + + //////classic source term + ///----Classic source term 8.4.2021 + + //LBMReal vvxF, vvyF, vvzF; + //vvxF = vvx;//-2*c1o24 * lap_vx;// + //vvyF = vvy;//-2*c1o24 * lap_vy;// + //vvzF = vvz;//-2*c1o24 * lap_vz;// + +// vvxF = 1.2* vvx- 0.2*0.5 * ((*velocityX)(x1 - 1, x2, x3) + (*velocityX)(x1 + 1, x2, x3)); +// vvyF = 1.2 *vvy- 0.2*0.5* ((*velocityY)(x1 , x2-1, x3) + (*velocityY)(x1 , x2+1, x3)); +// vvzF = 1.2 *vvz-0.2*0.5* ((*velocityZ)(x1 , x2, x3-1) + (*velocityZ)(x1 , x2, x3+1)); + //if (vvxF != vvx) { + // vvxF = vvxF; + //} + //LBMReal weightGrad = 1.0;// -denom * denom / (denom * denom + 0.0001 * 0.001); + //LBMReal dX1_phiF = dX1_phi * weightGrad + (1.0 - weightGrad) * (1.0 - phi[REST]) * (phi[REST]) * normX1; + //LBMReal dX2_phiF = dX2_phi * weightGrad + (1.0 - weightGrad) * (1.0 - phi[REST]) * (phi[REST]) * normX2; + //LBMReal dX3_phiF = dX3_phi * weightGrad + (1.0 - weightGrad) * (1.0 - phi[REST]) * (phi[REST]) * normX3; + + //dX1_phiF *= 1.2; + //dX2_phiF *= 1.2; + //dX3_phiF *= 1.2; + + //LBMReal gradFD = sqrt(dX1_phi * dX1_phi + dX2_phi * dX2_phi + dX3_phi * dX3_phi); + //LBMReal gradPhi = (1.0 - phi[REST]) * (phi[REST]); + //gradPhi = (gradPhi > gradFD) ? gradPhi : gradFD; + //dX1_phiF = gradPhi * normX1; + // dX2_phiF = gradPhi * normX2; + // dX3_phiF = gradPhi * normX3; + + //LBMReal ux2; + //LBMReal uy2; + //LBMReal uz2; + //ux2 = vvxF * vvxF; + //uy2 = vvyF * vvyF; + //uz2 = vvzF * vvzF; + //LBMReal forcingTerm[D3Q27System::ENDF + 1]; + //for (int dir = STARTF; dir <= (FENDDIR); dir++) { + // LBMReal velProd = DX1[dir] * vvxF + DX2[dir] * vvyF + DX3[dir] * vvzF; + // LBMReal velSq1 = velProd * velProd; + // LBMReal gamma = WEIGTH[dir] * (1.0 + 3 * velProd + (4.5 * velSq1 - 1.5 * (ux2 + uy2 + uz2))); + + // //LBMReal fac1 = (gamma - WEIGTH[dir]) * c1o3 * rhoToPhi; + + // //forcingTerm[dir] = + // // (-vvxF) * (fac1 * dX1_phiF) + + // // (-vvyF) * (fac1 * dX2_phiF) + + // // (-vvzF) * (fac1 * dX3_phiF) + + // // (DX1[dir]) * (fac1 * dX1_phiF) + + // // (DX2[dir]) * (fac1 * dX2_phiF) + + // // (DX3[dir]) * (fac1 * dX3_phiF); + + + // //LBMReal fac1 = (gamma - WEIGTH[dir]) * c1o3 ; + + // //forcingTerm[dir] = + // // (-vvxF) * (fac1 * (dX1_phiF * rhoH + dX2_phi2 * rhoL)) + + // // (-vvyF) * (fac1 * (dX2_phiF * rhoH + dX2_phi2 * rhoL)) + + // // (-vvzF) * (fac1 * (dX3_phiF * rhoH + dX3_phi2 * rhoL)) + + // // (DX1[dir]) * (fac1 * (dX1_phiF * rhoH + dX2_phi2 * rhoL)) + + // // (DX2[dir]) * (fac1 * (dX2_phiF * rhoH + dX2_phi2 * rhoL)) + + // // (DX3[dir]) * (fac1 * (dX3_phiF * rhoH + dX3_phi2 * rhoL)); + + + + //} + + //LBMReal gamma = WEIGTH[REST] * (1.0 - 1.5 * (ux2 + uy2 + uz2)); + //LBMReal fac1 = (gamma - WEIGTH[REST]) * c1o3 * rhoToPhi; + //forcingTerm[REST] = (-vvxF) * (fac1 * (dX1_phiF * rhoH + dX2_phi2 * rhoL)) + + // (-vvyF) * (fac1 * (dX2_phiF * rhoH + dX2_phi2 * rhoL)) + + // (-vvzF) * (fac1 * (dX3_phiF * rhoH + dX3_phi2 * rhoL)); + + //////// + // LBMReal divAfterSource= + //( mfcbb + 3.0 * (0.5 * forcingTerm[E]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF) *(vvyF) +(vvzF) *(vvzF)-1)+ + //( mfbcb + 3.0 * (0.5 * forcingTerm[N]) / rho ) *((vvxF) *(vvxF) +(vvyF-1)*(vvyF-1)+(vvzF) *(vvzF)-1)+ + //( mfbbc + 3.0 * (0.5 * forcingTerm[T]) / rho ) *((vvxF) *(vvxF) +(vvyF) *(vvyF) +(vvzF-1)*(vvzF-1)-1)+ + //( mfccb + 3.0 * (0.5 * forcingTerm[NE]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF-1)*(vvyF-1)+(vvzF) *(vvzF)-1)+ + //( mfacb + 3.0 * (0.5 * forcingTerm[NW]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF-1)*(vvyF-1)+(vvzF) *(vvzF)-1)+ + //( mfcbc + 3.0 * (0.5 * forcingTerm[TE]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF) *(vvyF) +(vvzF-1)*(vvzF-1)-1)+ + //( mfabc + 3.0 * (0.5 * forcingTerm[TW]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF) *(vvyF) +(vvzF-1)*(vvzF-1)-1)+ + //( mfbcc + 3.0 * (0.5 * forcingTerm[TN]) / rho ) *((vvxF) *(vvxF) +(vvyF-1)*(vvyF-1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfbac + 3.0 * (0.5 * forcingTerm[TS]) / rho ) *((vvxF) *(vvxF) +(vvyF+1)*(vvyF+1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfccc + 3.0 * (0.5 * forcingTerm[TNE]) / rho) *((vvxF-1)*(vvxF-1)+(vvyF-1)*(vvyF-1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfacc + 3.0 * (0.5 * forcingTerm[TNW]) / rho) *((vvxF+1)*(vvxF+1)+(vvyF-1)*(vvyF-1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfcac + 3.0 * (0.5 * forcingTerm[TSE]) / rho) *((vvxF-1)*(vvxF-1)+(vvyF+1)*(vvyF+1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfaac + 3.0 * (0.5 * forcingTerm[TSW]) / rho) *((vvxF+1)*(vvxF+1)+(vvyF+1)*(vvyF+1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfabb + 3.0 * (0.5 * forcingTerm[W]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF) *(vvyF) +(vvzF) *(vvzF)-1)+ + //( mfbab + 3.0 * (0.5 * forcingTerm[S]) / rho ) *((vvxF) *(vvxF) +(vvyF+1)*(vvyF+1)+(vvzF) *(vvzF)-1)+ + //( mfbba + 3.0 * (0.5 * forcingTerm[B]) / rho ) *((vvxF) *(vvxF) +(vvyF) *(vvyF) +(vvzF+1)*(vvzF+1)-1)+ + //( mfaab + 3.0 * (0.5 * forcingTerm[SW]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF+1)*(vvyF+1)+(vvzF) *(vvzF)-1)+ + //( mfcab + 3.0 * (0.5 * forcingTerm[SE]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF+1)*(vvyF+1)+(vvzF) *(vvzF)-1)+ + //( mfaba + 3.0 * (0.5 * forcingTerm[BW]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF) *(vvyF) +(vvzF+1)*(vvzF+1)-1)+ + //( mfcba + 3.0 * (0.5 * forcingTerm[BE]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF) *(vvyF) +(vvzF+1)*(vvzF+1)-1)+ + //( mfbaa + 3.0 * (0.5 * forcingTerm[BS]) / rho ) *((vvxF) *(vvxF) +(vvyF+1)*(vvyF+1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfbca + 3.0 * (0.5 * forcingTerm[BN]) / rho ) *((vvxF) *(vvxF) +(vvyF-1)*(vvyF-1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfaaa + 3.0 * (0.5 * forcingTerm[BSW]) / rho) *((vvxF+1)*(vvxF+1)+(vvyF+1)*(vvyF+1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfcaa + 3.0 * (0.5 * forcingTerm[BSE]) / rho) *((vvxF-1)*(vvxF-1)+(vvyF+1)*(vvyF+1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfaca + 3.0 * (0.5 * forcingTerm[BNW]) / rho) *((vvxF+1)*(vvxF+1)+(vvyF-1)*(vvyF-1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfcca + 3.0 * (0.5 * forcingTerm[BNE]) / rho) *((vvxF-1)*(vvxF-1)+(vvyF-1)*(vvyF-1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfbbb + 3.0 * (0.5 * forcingTerm[REST]) / rho)*((vvxF)*(vvxF)+(vvyF)*(vvyF)+(vvzF)*(vvzF)-1); + + // LBMReal divBeforeSource = + // (mfcbb) * ((vvxF - 1) * (vvxF - 1) + (vvyF) * (vvyF)+(vvzF) * (vvzF)-1) + + // (mfbcb) * ((vvxF) * (vvxF)+(vvyF - 1) * (vvyF - 1) + (vvzF) * (vvzF)-1) + + // (mfbbc) * ((vvxF) * (vvxF)+(vvyF) * (vvyF)+(vvzF - 1) * (vvzF - 1)-1) + + // (mfccb) * ((vvxF - 1) * (vvxF - 1) + (vvyF - 1) * (vvyF - 1) + (vvzF) * (vvzF)-1) + + // (mfacb) * ((vvxF + 1) * (vvxF + 1) + (vvyF - 1) * (vvyF - 1) + (vvzF) * (vvzF)-1) + + // (mfcbc) * ((vvxF - 1) * (vvxF - 1) + (vvyF) * (vvyF)+(vvzF - 1) * (vvzF - 1)-1) + + // (mfabc) * ((vvxF + 1) * (vvxF + 1) + (vvyF) * (vvyF)+(vvzF - 1) * (vvzF - 1)-1) + + // (mfbcc) * ((vvxF) * (vvxF)+(vvyF - 1) * (vvyF - 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfbac) * ((vvxF) * (vvxF)+(vvyF + 1) * (vvyF + 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfccc) * ((vvxF - 1) * (vvxF - 1) + (vvyF - 1) * (vvyF - 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfacc) * ((vvxF + 1) * (vvxF + 1) + (vvyF - 1) * (vvyF - 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfcac) * ((vvxF - 1) * (vvxF - 1) + (vvyF + 1) * (vvyF + 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfaac) * ((vvxF + 1) * (vvxF + 1) + (vvyF + 1) * (vvyF + 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfabb) * ((vvxF + 1) * (vvxF + 1) + (vvyF) * (vvyF)+(vvzF) * (vvzF)-1) + + // (mfbab) * ((vvxF) * (vvxF)+(vvyF + 1) * (vvyF + 1) + (vvzF) * (vvzF)-1) + + // (mfbba) * ((vvxF) * (vvxF)+(vvyF) * (vvyF)+(vvzF + 1) * (vvzF + 1)-1) + + // (mfaab) * ((vvxF + 1) * (vvxF + 1) + (vvyF + 1) * (vvyF + 1) + (vvzF) * (vvzF)-1) + + // (mfcab) * ((vvxF - 1) * (vvxF - 1) + (vvyF + 1) * (vvyF + 1) + (vvzF) * (vvzF)-1) + + // (mfaba) * ((vvxF + 1) * (vvxF + 1) + (vvyF) * (vvyF)+(vvzF + 1) * (vvzF + 1)-1) + + // (mfcba) * ((vvxF - 1) * (vvxF - 1) + (vvyF) * (vvyF)+(vvzF + 1) * (vvzF + 1)-1) + + // (mfbaa) * ((vvxF) * (vvxF)+(vvyF + 1) * (vvyF + 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfbca) * ((vvxF) * (vvxF)+(vvyF - 1) * (vvyF - 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfaaa) * ((vvxF + 1) * (vvxF + 1) + (vvyF + 1) * (vvyF + 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfcaa) * ((vvxF - 1) * (vvxF - 1) + (vvyF + 1) * (vvyF + 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfaca) * ((vvxF + 1) * (vvxF + 1) + (vvyF - 1) * (vvyF - 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfcca) * ((vvxF - 1) * (vvxF - 1) + (vvyF - 1) * (vvyF - 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfbbb) * ((vvxF) * (vvxF)+(vvyF) * (vvyF)+(vvzF) * (vvzF)-1); + //if (divAfterSource - divBeforeSource != 0 && phi[REST]>0.0001 && phi[REST]<0.999) { + // std::cout << phi[REST]<<" "<< divAfterSource << " " << divBeforeSource <<" "<< divAfterSource/ divBeforeSource << std::endl; + //} + + //if (fabs(divAfterSource - divBeforeSource)/(fabs(divAfterSource) + fabs(divBeforeSource)+1e-10) > 1e-5) { + // LBMReal scaleDiv =0.95+(1-0.95)* (divBeforeSource) / (divBeforeSource - divAfterSource); + + // forcingTerm[E] *=scaleDiv; + // forcingTerm[N] *=scaleDiv; + // forcingTerm[T] *=scaleDiv; + // forcingTerm[NE] *=scaleDiv; + // forcingTerm[NW] *=scaleDiv; + // forcingTerm[TE] *=scaleDiv; + // forcingTerm[TW] *=scaleDiv; + // forcingTerm[TN] *=scaleDiv; + // forcingTerm[TS] *=scaleDiv; + // forcingTerm[TNE] *=scaleDiv; + // forcingTerm[TNW] *=scaleDiv; + // forcingTerm[TSE] *=scaleDiv; + // forcingTerm[TSW] *=scaleDiv; + // forcingTerm[W] *=scaleDiv; + // forcingTerm[S] *=scaleDiv; + // forcingTerm[B] *=scaleDiv; + // forcingTerm[SW] *=scaleDiv; + // forcingTerm[SE] *=scaleDiv; + // forcingTerm[BW] *=scaleDiv; + // forcingTerm[BE] *=scaleDiv; + // forcingTerm[BS] *=scaleDiv; + // forcingTerm[BN] *=scaleDiv; + // forcingTerm[BSW] *=scaleDiv; + // forcingTerm[BSE] *=scaleDiv; + // forcingTerm[BNW] *=scaleDiv; + // forcingTerm[BNE] *=scaleDiv; + // forcingTerm[REST] *=scaleDiv; + //} + //////// + + + //mfcbb += 3.0 * (0.5 * forcingTerm[E]) / rho; //-(3.0*p1 - rho)*WEIGTH[E ]; + //mfbcb += 3.0 * (0.5 * forcingTerm[N]) / rho; //-(3.0*p1 - rho)*WEIGTH[N ]; + //mfbbc += 3.0 * (0.5 * forcingTerm[T]) / rho; //-(3.0*p1 - rho)*WEIGTH[T ]; + //mfccb += 3.0 * (0.5 * forcingTerm[NE]) / rho; //-(3.0*p1 - rho)*WEIGTH[NE ]; + //mfacb += 3.0 * (0.5 * forcingTerm[NW]) / rho; //-(3.0*p1 - rho)*WEIGTH[NW ]; + //mfcbc += 3.0 * (0.5 * forcingTerm[TE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TE ]; + //mfabc += 3.0 * (0.5 * forcingTerm[TW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TW ]; + //mfbcc += 3.0 * (0.5 * forcingTerm[TN]) / rho; //-(3.0*p1 - rho)*WEIGTH[TN ]; + //mfbac += 3.0 * (0.5 * forcingTerm[TS]) / rho; //-(3.0*p1 - rho)*WEIGTH[TS ]; + //mfccc += 3.0 * (0.5 * forcingTerm[TNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNE]; + //mfacc += 3.0 * (0.5 * forcingTerm[TNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNW]; + //mfcac += 3.0 * (0.5 * forcingTerm[TSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSE]; + //mfaac += 3.0 * (0.5 * forcingTerm[TSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSW]; + //mfabb += 3.0 * (0.5 * forcingTerm[W]) / rho; //-(3.0*p1 - rho)*WEIGTH[W ]; + //mfbab += 3.0 * (0.5 * forcingTerm[S]) / rho; //-(3.0*p1 - rho)*WEIGTH[S ]; + //mfbba += 3.0 * (0.5 * forcingTerm[B]) / rho; //-(3.0*p1 - rho)*WEIGTH[B ]; + //mfaab += 3.0 * (0.5 * forcingTerm[SW]) / rho; //-(3.0*p1 - rho)*WEIGTH[SW ]; + //mfcab += 3.0 * (0.5 * forcingTerm[SE]) / rho; //-(3.0*p1 - rho)*WEIGTH[SE ]; + //mfaba += 3.0 * (0.5 * forcingTerm[BW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BW ]; + //mfcba += 3.0 * (0.5 * forcingTerm[BE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BE ]; + //mfbaa += 3.0 * (0.5 * forcingTerm[BS]) / rho; //-(3.0*p1 - rho)*WEIGTH[BS ]; + //mfbca += 3.0 * (0.5 * forcingTerm[BN]) / rho; //-(3.0*p1 - rho)*WEIGTH[BN ]; + //mfaaa += 3.0 * (0.5 * forcingTerm[BSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSW]; + //mfcaa += 3.0 * (0.5 * forcingTerm[BSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSE]; + //mfaca += 3.0 * (0.5 * forcingTerm[BNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNW]; + //mfcca += 3.0 * (0.5 * forcingTerm[BNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNE]; + //mfbbb += 3.0 * (0.5 * forcingTerm[REST]) / rho; //- (3.0*p1 - rho)*WEIGTH[REST] + + //-------------------------------------------------------- + + + + + + //////end classic source term + + + + + //forcing + /////////////////////////////////////////////////////////////////////////////////////////// + if (withForcing) + { + muX1 = static_cast<double>(x1 - 1 + ix1 * maxX1); + muX2 = static_cast<double>(x2 - 1 + ix2 * maxX2); + muX3 = static_cast<double>(x3 - 1 + ix3 * maxX3); + + //forcingX1 = muForcingX1.Eval(); + //forcingX2 = muForcingX2.Eval(); + //forcingX3 = muForcingX3.Eval(); + + //vvx += forcingX1 * deltaT * 0.5; // X + //vvy += forcingX2 * deltaT * 0.5; // Y + //vvz += forcingX3 * deltaT * 0.5; // Z + } + + LBMReal vx2; + LBMReal vy2; + LBMReal vz2; + vx2 = vvx * vvx; + vy2 = vvy * vvy; + vz2 = vvz * vvz; + /////////////////////////////////////////////////////////////////////////////////////////// + LBMReal oMdrho; + + + oMdrho = mfccc + mfaaa; + m0 = mfaca + mfcac; + m1 = mfacc + mfcaa; + m2 = mfaac + mfcca; + oMdrho += m0; + m1 += m2; + oMdrho += m1; + m0 = mfbac + mfbca; + m1 = mfbaa + mfbcc; + m0 += m1; + m1 = mfabc + mfcba; + m2 = mfaba + mfcbc; + m1 += m2; + m0 += m1; + m1 = mfacb + mfcab; + m2 = mfaab + mfccb; + m1 += m2; + m0 += m1; + oMdrho += m0; + m0 = mfabb + mfcbb; + m1 = mfbab + mfbcb; + m2 = mfbba + mfbbc; + m0 += m1 + m2; + m0 += mfbbb; //hat gefehlt + oMdrho = (rhoRef - (oMdrho + m0))/rhoRef;// 12.03.21 check derivation!!!! + + //////////////////////////////////////////////////////////////////////////////////// + LBMReal wadjust; + LBMReal qudricLimit = 0.01; + //////////////////////////////////////////////////////////////////////////////////// + //Hin + //////////////////////////////////////////////////////////////////////////////////// + // mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + m2 = mfaaa + mfaac; + m1 = mfaac - mfaaa; + m0 = m2 + mfaab; + mfaaa = m0; + m0 += c1o36 * oMdrho; + mfaab = m1 - m0 * vvz; + mfaac = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaba + mfabc; + m1 = mfabc - mfaba; + m0 = m2 + mfabb; + mfaba = m0; + m0 += c1o9 * oMdrho; + mfabb = m1 - m0 * vvz; + mfabc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaca + mfacc; + m1 = mfacc - mfaca; + m0 = m2 + mfacb; + mfaca = m0; + m0 += c1o36 * oMdrho; + mfacb = m1 - m0 * vvz; + mfacc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbaa + mfbac; + m1 = mfbac - mfbaa; + m0 = m2 + mfbab; + mfbaa = m0; + m0 += c1o9 * oMdrho; + mfbab = m1 - m0 * vvz; + mfbac = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbba + mfbbc; + m1 = mfbbc - mfbba; + m0 = m2 + mfbbb; + mfbba = m0; + m0 += c4o9 * oMdrho; + mfbbb = m1 - m0 * vvz; + mfbbc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbca + mfbcc; + m1 = mfbcc - mfbca; + m0 = m2 + mfbcb; + mfbca = m0; + m0 += c1o9 * oMdrho; + mfbcb = m1 - m0 * vvz; + mfbcc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcaa + mfcac; + m1 = mfcac - mfcaa; + m0 = m2 + mfcab; + mfcaa = m0; + m0 += c1o36 * oMdrho; + mfcab = m1 - m0 * vvz; + mfcac = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcba + mfcbc; + m1 = mfcbc - mfcba; + m0 = m2 + mfcbb; + mfcba = m0; + m0 += c1o9 * oMdrho; + mfcbb = m1 - m0 * vvz; + mfcbc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcca + mfccc; + m1 = mfccc - mfcca; + m0 = m2 + mfccb; + mfcca = m0; + m0 += c1o36 * oMdrho; + mfccb = m1 - m0 * vvz; + mfccc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + // mit 1/6, 0, 1/18, 2/3, 0, 2/9, 1/6, 0, 1/18 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + m2 = mfaaa + mfaca; + m1 = mfaca - mfaaa; + m0 = m2 + mfaba; + mfaaa = m0; + m0 += c1o6 * oMdrho; + mfaba = m1 - m0 * vvy; + mfaca = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaab + mfacb; + m1 = mfacb - mfaab; + m0 = m2 + mfabb; + mfaab = m0; + mfabb = m1 - m0 * vvy; + mfacb = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaac + mfacc; + m1 = mfacc - mfaac; + m0 = m2 + mfabc; + mfaac = m0; + m0 += c1o18 * oMdrho; + mfabc = m1 - m0 * vvy; + mfacc = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbaa + mfbca; + m1 = mfbca - mfbaa; + m0 = m2 + mfbba; + mfbaa = m0; + m0 += c2o3 * oMdrho; + mfbba = m1 - m0 * vvy; + mfbca = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbab + mfbcb; + m1 = mfbcb - mfbab; + m0 = m2 + mfbbb; + mfbab = m0; + mfbbb = m1 - m0 * vvy; + mfbcb = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbac + mfbcc; + m1 = mfbcc - mfbac; + m0 = m2 + mfbbc; + mfbac = m0; + m0 += c2o9 * oMdrho; + mfbbc = m1 - m0 * vvy; + mfbcc = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcaa + mfcca; + m1 = mfcca - mfcaa; + m0 = m2 + mfcba; + mfcaa = m0; + m0 += c1o6 * oMdrho; + mfcba = m1 - m0 * vvy; + mfcca = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcab + mfccb; + m1 = mfccb - mfcab; + m0 = m2 + mfcbb; + mfcab = m0; + mfcbb = m1 - m0 * vvy; + mfccb = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcac + mfccc; + m1 = mfccc - mfcac; + m0 = m2 + mfcbc; + mfcac = m0; + m0 += c1o18 * oMdrho; + mfcbc = m1 - m0 * vvy; + mfccc = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + // mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + m2 = mfaaa + mfcaa; + m1 = mfcaa - mfaaa; + m0 = m2 + mfbaa; + mfaaa = m0; + m0 += 1. * oMdrho; + mfbaa = m1 - m0 * vvx; + mfcaa = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaba + mfcba; + m1 = mfcba - mfaba; + m0 = m2 + mfbba; + mfaba = m0; + mfbba = m1 - m0 * vvx; + mfcba = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaca + mfcca; + m1 = mfcca - mfaca; + m0 = m2 + mfbca; + mfaca = m0; + m0 += c1o3 * oMdrho; + mfbca = m1 - m0 * vvx; + mfcca = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaab + mfcab; + m1 = mfcab - mfaab; + m0 = m2 + mfbab; + mfaab = m0; + mfbab = m1 - m0 * vvx; + mfcab = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfabb + mfcbb; + m1 = mfcbb - mfabb; + m0 = m2 + mfbbb; + mfabb = m0; + mfbbb = m1 - m0 * vvx; + mfcbb = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfacb + mfccb; + m1 = mfccb - mfacb; + m0 = m2 + mfbcb; + mfacb = m0; + mfbcb = m1 - m0 * vvx; + mfccb = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaac + mfcac; + m1 = mfcac - mfaac; + m0 = m2 + mfbac; + mfaac = m0; + m0 += c1o3 * oMdrho; + mfbac = m1 - m0 * vvx; + mfcac = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfabc + mfcbc; + m1 = mfcbc - mfabc; + m0 = m2 + mfbbc; + mfabc = m0; + mfbbc = m1 - m0 * vvx; + mfcbc = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfacc + mfccc; + m1 = mfccc - mfacc; + m0 = m2 + mfbcc; + mfacc = m0; + m0 += c1o9 * oMdrho; + mfbcc = m1 - m0 * vvx; + mfccc = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + // Cumulants + //////////////////////////////////////////////////////////////////////////////////// + + + // mfaaa = 0.0; + LBMReal OxxPyyPzz = 1.; //omega2 or bulk viscosity + // LBMReal OxyyPxzz = 1.;//-s9;//2+s9;// + // LBMReal OxyyMxzz = 1.;//2+s9;// + LBMReal O4 = 1.; + LBMReal O5 = 1.; + LBMReal O6 = 1.; + + + + /////fourth order parameters; here only for test. Move out of loop! + + LBMReal OxyyPxzz = 8.0 * (collFactorM - 2.0) * (OxxPyyPzz * (3.0 * collFactorM - 1.0) - 5.0 * collFactorM) / (8.0 * (5.0 - 2.0 * collFactorM) * collFactorM + OxxPyyPzz * (8.0 + collFactorM * (9.0 * collFactorM - 26.0))); + LBMReal OxyyMxzz = 8.0 * (collFactorM - 2.0) * (collFactorM + OxxPyyPzz * (3.0 * collFactorM - 7.0)) / (OxxPyyPzz * (56.0 - 42.0 * collFactorM + 9.0 * collFactorM * collFactorM) - 8.0 * collFactorM); + // LBMReal Oxyz = 24.0 * (collFactorM - 2.0) * (4.0 * collFactorM * collFactorM + collFactorM * OxxPyyPzz * (18.0 - 13.0 * collFactorM) + OxxPyyPzz * OxxPyyPzz * (2.0 + collFactorM * (6.0 * collFactorM - 11.0))) / (16.0 * collFactorM * collFactorM * (collFactorM - 6.0) - 2.0 * collFactorM * OxxPyyPzz * (216.0 + 5.0 * collFactorM * (9.0 * collFactorM - 46.0)) + OxxPyyPzz * OxxPyyPzz * (collFactorM * (3.0 * collFactorM - 10.0) * (15.0 * collFactorM - 28.0) - 48.0)); + LBMReal A = (4.0 * collFactorM * collFactorM + 2.0 * collFactorM * OxxPyyPzz * (collFactorM - 6.0) + OxxPyyPzz * OxxPyyPzz * (collFactorM * (10.0 - 3.0 * collFactorM) - 4.0)) / ((collFactorM - OxxPyyPzz) * (OxxPyyPzz * (2.0 + 3.0 * collFactorM) - 8.0 * collFactorM)); + //FIXME: warning C4459: declaration of 'B' hides global declaration (message : see declaration of 'D3Q27System::B' ) + LBMReal BB = (4.0 * collFactorM * OxxPyyPzz * (9.0 * collFactorM - 16.0) - 4.0 * collFactorM * collFactorM - 2.0 * OxxPyyPzz * OxxPyyPzz * (2.0 + 9.0 * collFactorM * (collFactorM - 2.0))) / (3.0 * (collFactorM - OxxPyyPzz) * (OxxPyyPzz * (2.0 + 3.0 * collFactorM) - 8.0 * collFactorM)); + + + //Cum 4. + //LBMReal CUMcbb = mfcbb - ((mfcaa + c1o3 * oMdrho) * mfabb + 2. * mfbba * mfbab); // till 18.05.2015 + //LBMReal CUMbcb = mfbcb - ((mfaca + c1o3 * oMdrho) * mfbab + 2. * mfbba * mfabb); // till 18.05.2015 + //LBMReal CUMbbc = mfbbc - ((mfaac + c1o3 * oMdrho) * mfbba + 2. * mfbab * mfabb); // till 18.05.2015 + + LBMReal CUMcbb = mfcbb - ((mfcaa + c1o3) * mfabb + 2. * mfbba * mfbab); + LBMReal CUMbcb = mfbcb - ((mfaca + c1o3) * mfbab + 2. * mfbba * mfabb); + LBMReal CUMbbc = mfbbc - ((mfaac + c1o3) * mfbba + 2. * mfbab * mfabb); + + LBMReal CUMcca = mfcca - ((mfcaa * mfaca + 2. * mfbba * mfbba) + c1o3 * (mfcaa + mfaca) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho); + LBMReal CUMcac = mfcac - ((mfcaa * mfaac + 2. * mfbab * mfbab) + c1o3 * (mfcaa + mfaac) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho); + LBMReal CUMacc = mfacc - ((mfaac * mfaca + 2. * mfabb * mfabb) + c1o3 * (mfaac + mfaca) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho); + + //Cum 5. + LBMReal CUMbcc = mfbcc - (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + 2. * (mfbab * mfacb + mfbba * mfabc)) - c1o3 * (mfbca + mfbac) * oMdrho; + LBMReal CUMcbc = mfcbc - (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + 2. * (mfabb * mfcab + mfbba * mfbac)) - c1o3 * (mfcba + mfabc) * oMdrho; + LBMReal CUMccb = mfccb - (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + 2. * (mfbab * mfbca + mfabb * mfcba)) - c1o3 * (mfacb + mfcab) * oMdrho; + + //Cum 6. + LBMReal CUMccc = mfccc + ((-4. * mfbbb * mfbbb + - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) + - 4. * (mfabb * mfcbb + mfbab * mfbcb + mfbba * mfbbc) + - 2. * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) + + (4. * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + + 2. * (mfcaa * mfaca * mfaac) + + 16. * mfbba * mfbab * mfabb) + - c1o3 * (mfacc + mfcac + mfcca) * oMdrho - c1o9 * oMdrho * oMdrho + - c1o9 * (mfcaa + mfaca + mfaac) * oMdrho * (1. - 2. * oMdrho) - c1o27 * oMdrho * oMdrho * (-2. * oMdrho) + + (2. * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa)) * c2o3 * oMdrho) + c1o27 * oMdrho; + + ///storing pre collision second moments + LBMReal mbxx = mfcaa; + LBMReal mbyy = mfaca; + LBMReal mbzz = mfaac; + LBMReal mbxy = mfbba; + LBMReal mbxz = mfbab; + LBMReal mbyz = mfabb; + + //2. + // linear combinations + LBMReal mxxPyyPzz = mfcaa + mfaca + mfaac; + + // LBMReal mfaaaS = (mfaaa * (-4 - 3 * OxxPyyPzz * (-1 + rho)) + 6 * mxxPyyPzz * OxxPyyPzz * (-1 + rho)) / (-4 + 3 * OxxPyyPzz * (-1 + rho)); + mxxPyyPzz -= mfaaa ;//12.03.21 shifted by mfaaa + //mxxPyyPzz-=(mfaaa+mfaaaS)*c1o2;//12.03.21 shifted by mfaaa + LBMReal mxxMyy = mfcaa - mfaca; + LBMReal mxxMzz = mfcaa - mfaac; + + //applying phase field gradients first part: + // mxxPyyPzz += c2o3 * rhoToPhi * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz); + // 17.03.2021 attempt for statililization by assymptotically vanishing bias + //LBMReal correctionScaling = + // rhoToPhi / rho; // +0.5;// (vx2 + vy2 + vz2) * 100;// +0.5;//(vx2 + vy2 + vz2)*1000; + //mxxPyyPzz += (1.0 / 6.0) * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * + // correctionScaling; // As in Hesam's code + //mxxMyy += c1o3 * (dX1_phi * vvx - dX2_phi * vvy) * correctionScaling; + //mxxMzz += c1o3 * (dX1_phi * vvx - dX3_phi * vvz) * correctionScaling; + //mfabb += c1o6 * (dX2_phi * vvz + dX3_phi * vvy) * correctionScaling; + //mfbab += c1o6 * (dX1_phi * vvz + dX3_phi * vvx) * correctionScaling; + //mfbba += c1o6 * (dX1_phi * vvy + dX2_phi * vvx) * correctionScaling; + + LBMReal dxux = -c1o2 * collFactorM * (mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz * (/*mfaaa*/ -mxxPyyPzz); + LBMReal dyuy = dxux + collFactorM * c3o2 * mxxMyy; + LBMReal dzuz = dxux + collFactorM * c3o2 * mxxMzz; + + LBMReal Dxy = -three * collFactorM * mfbba; + LBMReal Dxz = -three * collFactorM * mfbab; + LBMReal Dyz = -three * collFactorM * mfabb; + + + //relax + mxxPyyPzz += OxxPyyPzz * (/*mfaaa*/ - mxxPyyPzz) - 3. * (1. - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz); + mxxMyy += collFactorM * (-mxxMyy) - 3. * (1. - c1o2 * collFactorM) * (vx2 * dxux - vy2 * dyuy); + mxxMzz += collFactorM * (-mxxMzz) - 3. * (1. - c1o2 * collFactorM) * (vx2 * dxux - vz2 * dzuz); + + mfabb += collFactorM * (-mfabb); + mfbab += collFactorM * (-mfbab); + mfbba += collFactorM * (-mfbba); + + //applying phase field gradients second part: + //mxxPyyPzz += c2o3 * rhoToPhi * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz); + //mxxPyyPzz += (1.0 / 6.0) * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * + // correctionScaling; // As in Hesam's code + //mxxMyy += c1o3 * (dX1_phi * vvx - dX2_phi * vvy) * correctionScaling; + //mxxMzz += c1o3 * (dX1_phi * vvx - dX3_phi * vvz) * correctionScaling; + //mfabb += c1o6 * (dX2_phi * vvz + dX3_phi * vvy) * correctionScaling; + //mfbab += c1o6 * (dX1_phi * vvz + dX3_phi * vvx) * correctionScaling; + //mfbba += c1o6 * (dX1_phi * vvy + dX2_phi * vvx) * correctionScaling; + + ////updated pressure + //mfaaa += (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * correctionScaling; + mfaaa = 0.0; // Pressure elimination as in standard velocity model + // mfaaa += (rho - c1) * (dxux + dyuy + dzuz); + + mxxPyyPzz += mfaaa; // 12.03.21 shifted by mfaaa + + // mxxPyyPzz += (mfaaa + mfaaaS) * c1o2; + //mfaaa = mfaaaS; + // linear combinations back + mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); + mfaca = c1o3 * (-2. * mxxMyy + mxxMzz + mxxPyyPzz); + mfaac = c1o3 * (mxxMyy - 2. * mxxMzz + mxxPyyPzz); + + //3. + // linear combinations + LBMReal mxxyPyzz = mfcba + mfabc; + LBMReal mxxyMyzz = mfcba - mfabc; + + LBMReal mxxzPyyz = mfcab + mfacb; + LBMReal mxxzMyyz = mfcab - mfacb; + + LBMReal mxyyPxzz = mfbca + mfbac; + LBMReal mxyyMxzz = mfbca - mfbac; + + //relax + wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mfbbb) / (fabs(mfbbb) + qudricLimit); + mfbbb += wadjust * (-mfbbb); + wadjust = OxyyPxzz + (1. - OxyyPxzz) * fabs(mxxyPyzz) / (fabs(mxxyPyzz) + qudricLimit); + mxxyPyzz += wadjust * (-mxxyPyzz); + wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mxxyMyzz) / (fabs(mxxyMyzz) + qudricLimit); + mxxyMyzz += wadjust * (-mxxyMyzz); + wadjust = OxyyPxzz + (1. - OxyyPxzz) * fabs(mxxzPyyz) / (fabs(mxxzPyyz) + qudricLimit); + mxxzPyyz += wadjust * (-mxxzPyyz); + wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mxxzMyyz) / (fabs(mxxzMyyz) + qudricLimit); + mxxzMyyz += wadjust * (-mxxzMyyz); + wadjust = OxyyPxzz + (1. - OxyyPxzz) * fabs(mxyyPxzz) / (fabs(mxyyPxzz) + qudricLimit); + mxyyPxzz += wadjust * (-mxyyPxzz); + wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mxyyMxzz) / (fabs(mxyyMxzz) + qudricLimit); + mxyyMxzz += wadjust * (-mxyyMxzz); + + // linear combinations back + mfcba = (mxxyMyzz + mxxyPyzz) * c1o2; + mfabc = (-mxxyMyzz + mxxyPyzz) * c1o2; + mfcab = (mxxzMyyz + mxxzPyyz) * c1o2; + mfacb = (-mxxzMyyz + mxxzPyyz) * c1o2; + mfbca = (mxyyMxzz + mxyyPxzz) * c1o2; + mfbac = (-mxyyMxzz + mxyyPxzz) * c1o2; + + //4. + //CUMacc += O4 * (-CUMacc); + //CUMcac += O4 * (-CUMcac); + //CUMcca += O4 * (-CUMcca); + + //CUMbbc += O4 * (-CUMbbc); + //CUMbcb += O4 * (-CUMbcb); + //CUMcbb += O4 * (-CUMcbb); + CUMacc = -O4 * (one / collFactorM - c1o2) * (dyuy + dzuz) * c2o3 * A + (one - O4) * (CUMacc); + CUMcac = -O4 * (one / collFactorM - c1o2) * (dxux + dzuz) * c2o3 * A + (one - O4) * (CUMcac); + CUMcca = -O4 * (one / collFactorM - c1o2) * (dyuy + dxux) * c2o3 * A + (one - O4) * (CUMcca); + CUMbbc = -O4 * (one / collFactorM - c1o2) * Dxy * c1o3 * BB + (one - O4) * (CUMbbc); + CUMbcb = -O4 * (one / collFactorM - c1o2) * Dxz * c1o3 * BB + (one - O4) * (CUMbcb); + CUMcbb = -O4 * (one / collFactorM - c1o2) * Dyz * c1o3 * BB + (one - O4) * (CUMcbb); + + //5. + CUMbcc += O5 * (-CUMbcc); + CUMcbc += O5 * (-CUMcbc); + CUMccb += O5 * (-CUMccb); + + //6. + CUMccc += O6 * (-CUMccc); + + //back cumulants to central moments + //4. + //mfcbb = CUMcbb + ((mfcaa + c1o3 * oMdrho) * mfabb + 2. * mfbba * mfbab); // till 18.05.2015 + //mfbcb = CUMbcb + ((mfaca + c1o3 * oMdrho) * mfbab + 2. * mfbba * mfabb); // till 18.05.2015 + //mfbbc = CUMbbc + ((mfaac + c1o3 * oMdrho) * mfbba + 2. * mfbab * mfabb); // till 18.05.2015 + + mfcbb = CUMcbb + ((mfcaa + c1o3) * mfabb + 2. * mfbba * mfbab); + mfbcb = CUMbcb + ((mfaca + c1o3) * mfbab + 2. * mfbba * mfabb); + mfbbc = CUMbbc + ((mfaac + c1o3) * mfbba + 2. * mfbab * mfabb); + + mfcca = CUMcca + (mfcaa * mfaca + 2. * mfbba * mfbba) + c1o3 * (mfcaa + mfaca) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho; + mfcac = CUMcac + (mfcaa * mfaac + 2. * mfbab * mfbab) + c1o3 * (mfcaa + mfaac) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho; + mfacc = CUMacc + (mfaac * mfaca + 2. * mfabb * mfabb) + c1o3 * (mfaac + mfaca) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho; + + //5. + mfbcc = CUMbcc + (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + 2. * (mfbab * mfacb + mfbba * mfabc)) + c1o3 * (mfbca + mfbac) * oMdrho; + mfcbc = CUMcbc + (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + 2. * (mfabb * mfcab + mfbba * mfbac)) + c1o3 * (mfcba + mfabc) * oMdrho; + mfccb = CUMccb + (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + 2. * (mfbab * mfbca + mfabb * mfcba)) + c1o3 * (mfacb + mfcab) * oMdrho; + + //6. + mfccc = CUMccc - ((-4. * mfbbb * mfbbb + - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) + - 4. * (mfabb * mfcbb + mfbac * mfbca + mfbba * mfbbc) + - 2. * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) + + (4. * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + + 2. * (mfcaa * mfaca * mfaac) + + 16. * mfbba * mfbab * mfabb) + - c1o3 * (mfacc + mfcac + mfcca) * oMdrho - c1o9 * oMdrho * oMdrho + - c1o9 * (mfcaa + mfaca + mfaac) * oMdrho * (1. - 2. * oMdrho) - c1o27 * oMdrho * oMdrho * (-2. * oMdrho) + + (2. * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa)) * c2o3 * oMdrho) - c1o27 * oMdrho; + + + //////// + + + //////////////////////////////////////////////////////////////////////////////////// + //forcing + mfbaa = -mfbaa; + mfaba = -mfaba; + mfaab = -mfaab; + ////////////////////////////////////////////////////////////////////////////////////// + mfbaa += -rho * rhoToPhi * c1o2 * ((mbxx + mfcaa) * dX1_phi + (mbxy + mfbba) * dX2_phi + (mbxz + mfbab) * dX3_phi); + mfaba += -rho * rhoToPhi * c1o2 * ((mbxy + mfbba) * dX1_phi + (mbyy + mfaca) * dX2_phi + (mbyz + mfabb) * dX3_phi); + mfaab += -rho * rhoToPhi * c1o2 * ((mbxz + mfbab) * dX1_phi + (mbyz + mfabb) * dX2_phi + (mbzz + mfaac) * dX3_phi); + //////////////////////////////////////////////////////////////////////////////////// + //back + //////////////////////////////////////////////////////////////////////////////////// + //mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + m0 = mfaac * c1o2 + mfaab * (vvz - c1o2) + (mfaaa + 1. * oMdrho) * (vz2 - vvz) * c1o2; + m1 = -mfaac - 2. * mfaab * vvz + mfaaa * (1. - vz2) - 1. * oMdrho * vz2; + m2 = mfaac * c1o2 + mfaab * (vvz + c1o2) + (mfaaa + 1. * oMdrho) * (vz2 + vvz) * c1o2; + mfaaa = m0; + mfaab = m1; + mfaac = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfabc * c1o2 + mfabb * (vvz - c1o2) + mfaba * (vz2 - vvz) * c1o2; + m1 = -mfabc - 2. * mfabb * vvz + mfaba * (1. - vz2); + m2 = mfabc * c1o2 + mfabb * (vvz + c1o2) + mfaba * (vz2 + vvz) * c1o2; + mfaba = m0; + mfabb = m1; + mfabc = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfacc * c1o2 + mfacb * (vvz - c1o2) + (mfaca + c1o3 * oMdrho) * (vz2 - vvz) * c1o2; + m1 = -mfacc - 2. * mfacb * vvz + mfaca * (1. - vz2) - c1o3 * oMdrho * vz2; + m2 = mfacc * c1o2 + mfacb * (vvz + c1o2) + (mfaca + c1o3 * oMdrho) * (vz2 + vvz) * c1o2; + mfaca = m0; + mfacb = m1; + mfacc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfbac * c1o2 + mfbab * (vvz - c1o2) + mfbaa * (vz2 - vvz) * c1o2; + m1 = -mfbac - 2. * mfbab * vvz + mfbaa * (1. - vz2); + m2 = mfbac * c1o2 + mfbab * (vvz + c1o2) + mfbaa * (vz2 + vvz) * c1o2; + mfbaa = m0; + mfbab = m1; + mfbac = m2; + /////////b////////////////////////////////////////////////////////////////////////// + m0 = mfbbc * c1o2 + mfbbb * (vvz - c1o2) + mfbba * (vz2 - vvz) * c1o2; + m1 = -mfbbc - 2. * mfbbb * vvz + mfbba * (1. - vz2); + m2 = mfbbc * c1o2 + mfbbb * (vvz + c1o2) + mfbba * (vz2 + vvz) * c1o2; + mfbba = m0; + mfbbb = m1; + mfbbc = m2; + /////////b////////////////////////////////////////////////////////////////////////// + m0 = mfbcc * c1o2 + mfbcb * (vvz - c1o2) + mfbca * (vz2 - vvz) * c1o2; + m1 = -mfbcc - 2. * mfbcb * vvz + mfbca * (1. - vz2); + m2 = mfbcc * c1o2 + mfbcb * (vvz + c1o2) + mfbca * (vz2 + vvz) * c1o2; + mfbca = m0; + mfbcb = m1; + mfbcc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcac * c1o2 + mfcab * (vvz - c1o2) + (mfcaa + c1o3 * oMdrho) * (vz2 - vvz) * c1o2; + m1 = -mfcac - 2. * mfcab * vvz + mfcaa * (1. - vz2) - c1o3 * oMdrho * vz2; + m2 = mfcac * c1o2 + mfcab * (vvz + c1o2) + (mfcaa + c1o3 * oMdrho) * (vz2 + vvz) * c1o2; + mfcaa = m0; + mfcab = m1; + mfcac = m2; + /////////c////////////////////////////////////////////////////////////////////////// + m0 = mfcbc * c1o2 + mfcbb * (vvz - c1o2) + mfcba * (vz2 - vvz) * c1o2; + m1 = -mfcbc - 2. * mfcbb * vvz + mfcba * (1. - vz2); + m2 = mfcbc * c1o2 + mfcbb * (vvz + c1o2) + mfcba * (vz2 + vvz) * c1o2; + mfcba = m0; + mfcbb = m1; + mfcbc = m2; + /////////c////////////////////////////////////////////////////////////////////////// + m0 = mfccc * c1o2 + mfccb * (vvz - c1o2) + (mfcca + c1o9 * oMdrho) * (vz2 - vvz) * c1o2; + m1 = -mfccc - 2. * mfccb * vvz + mfcca * (1. - vz2) - c1o9 * oMdrho * vz2; + m2 = mfccc * c1o2 + mfccb * (vvz + c1o2) + (mfcca + c1o9 * oMdrho) * (vz2 + vvz) * c1o2; + mfcca = m0; + mfccb = m1; + mfccc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + //mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + m0 = mfaca * c1o2 + mfaba * (vvy - c1o2) + (mfaaa + c1o6 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfaca - 2. * mfaba * vvy + mfaaa * (1. - vy2) - c1o6 * oMdrho * vy2; + m2 = mfaca * c1o2 + mfaba * (vvy + c1o2) + (mfaaa + c1o6 * oMdrho) * (vy2 + vvy) * c1o2; + mfaaa = m0; + mfaba = m1; + mfaca = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfacb * c1o2 + mfabb * (vvy - c1o2) + (mfaab + c2o3 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfacb - 2. * mfabb * vvy + mfaab * (1. - vy2) - c2o3 * oMdrho * vy2; + m2 = mfacb * c1o2 + mfabb * (vvy + c1o2) + (mfaab + c2o3 * oMdrho) * (vy2 + vvy) * c1o2; + mfaab = m0; + mfabb = m1; + mfacb = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfacc * c1o2 + mfabc * (vvy - c1o2) + (mfaac + c1o6 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfacc - 2. * mfabc * vvy + mfaac * (1. - vy2) - c1o6 * oMdrho * vy2; + m2 = mfacc * c1o2 + mfabc * (vvy + c1o2) + (mfaac + c1o6 * oMdrho) * (vy2 + vvy) * c1o2; + mfaac = m0; + mfabc = m1; + mfacc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfbca * c1o2 + mfbba * (vvy - c1o2) + mfbaa * (vy2 - vvy) * c1o2; + m1 = -mfbca - 2. * mfbba * vvy + mfbaa * (1. - vy2); + m2 = mfbca * c1o2 + mfbba * (vvy + c1o2) + mfbaa * (vy2 + vvy) * c1o2; + mfbaa = m0; + mfbba = m1; + mfbca = m2; + /////////b////////////////////////////////////////////////////////////////////////// + m0 = mfbcb * c1o2 + mfbbb * (vvy - c1o2) + mfbab * (vy2 - vvy) * c1o2; + m1 = -mfbcb - 2. * mfbbb * vvy + mfbab * (1. - vy2); + m2 = mfbcb * c1o2 + mfbbb * (vvy + c1o2) + mfbab * (vy2 + vvy) * c1o2; + mfbab = m0; + mfbbb = m1; + mfbcb = m2; + /////////b////////////////////////////////////////////////////////////////////////// + m0 = mfbcc * c1o2 + mfbbc * (vvy - c1o2) + mfbac * (vy2 - vvy) * c1o2; + m1 = -mfbcc - 2. * mfbbc * vvy + mfbac * (1. - vy2); + m2 = mfbcc * c1o2 + mfbbc * (vvy + c1o2) + mfbac * (vy2 + vvy) * c1o2; + mfbac = m0; + mfbbc = m1; + mfbcc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcca * c1o2 + mfcba * (vvy - c1o2) + (mfcaa + c1o18 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfcca - 2. * mfcba * vvy + mfcaa * (1. - vy2) - c1o18 * oMdrho * vy2; + m2 = mfcca * c1o2 + mfcba * (vvy + c1o2) + (mfcaa + c1o18 * oMdrho) * (vy2 + vvy) * c1o2; + mfcaa = m0; + mfcba = m1; + mfcca = m2; + /////////c////////////////////////////////////////////////////////////////////////// + m0 = mfccb * c1o2 + mfcbb * (vvy - c1o2) + (mfcab + c2o9 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfccb - 2. * mfcbb * vvy + mfcab * (1. - vy2) - c2o9 * oMdrho * vy2; + m2 = mfccb * c1o2 + mfcbb * (vvy + c1o2) + (mfcab + c2o9 * oMdrho) * (vy2 + vvy) * c1o2; + mfcab = m0; + mfcbb = m1; + mfccb = m2; + /////////c////////////////////////////////////////////////////////////////////////// + m0 = mfccc * c1o2 + mfcbc * (vvy - c1o2) + (mfcac + c1o18 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfccc - 2. * mfcbc * vvy + mfcac * (1. - vy2) - c1o18 * oMdrho * vy2; + m2 = mfccc * c1o2 + mfcbc * (vvy + c1o2) + (mfcac + c1o18 * oMdrho) * (vy2 + vvy) * c1o2; + mfcac = m0; + mfcbc = m1; + mfccc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + //mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + m0 = mfcaa * c1o2 + mfbaa * (vvx - c1o2) + (mfaaa + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcaa - 2. * mfbaa * vvx + mfaaa * (1. - vx2) - c1o36 * oMdrho * vx2; + m2 = mfcaa * c1o2 + mfbaa * (vvx + c1o2) + (mfaaa + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; + mfaaa = m0; + mfbaa = m1; + mfcaa = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcba * c1o2 + mfbba * (vvx - c1o2) + (mfaba + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcba - 2. * mfbba * vvx + mfaba * (1. - vx2) - c1o9 * oMdrho * vx2; + m2 = mfcba * c1o2 + mfbba * (vvx + c1o2) + (mfaba + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfaba = m0; + mfbba = m1; + mfcba = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcca * c1o2 + mfbca * (vvx - c1o2) + (mfaca + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcca - 2. * mfbca * vvx + mfaca * (1. - vx2) - c1o36 * oMdrho * vx2; + m2 = mfcca * c1o2 + mfbca * (vvx + c1o2) + (mfaca + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; + mfaca = m0; + mfbca = m1; + mfcca = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcab * c1o2 + mfbab * (vvx - c1o2) + (mfaab + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcab - 2. * mfbab * vvx + mfaab * (1. - vx2) - c1o9 * oMdrho * vx2; + m2 = mfcab * c1o2 + mfbab * (vvx + c1o2) + (mfaab + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfaab = m0; + mfbab = m1; + mfcab = m2; + ///////////b//////////////////////////////////////////////////////////////////////// + m0 = mfcbb * c1o2 + mfbbb * (vvx - c1o2) + (mfabb + c4o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcbb - 2. * mfbbb * vvx + mfabb * (1. - vx2) - c4o9 * oMdrho * vx2; + m2 = mfcbb * c1o2 + mfbbb * (vvx + c1o2) + (mfabb + c4o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfabb = m0; + mfbbb = m1; + mfcbb = m2; + ///////////b//////////////////////////////////////////////////////////////////////// + m0 = mfccb * c1o2 + mfbcb * (vvx - c1o2) + (mfacb + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfccb - 2. * mfbcb * vvx + mfacb * (1. - vx2) - c1o9 * oMdrho * vx2; + m2 = mfccb * c1o2 + mfbcb * (vvx + c1o2) + (mfacb + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfacb = m0; + mfbcb = m1; + mfccb = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcac * c1o2 + mfbac * (vvx - c1o2) + (mfaac + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcac - 2. * mfbac * vvx + mfaac * (1. - vx2) - c1o36 * oMdrho * vx2; + m2 = mfcac * c1o2 + mfbac * (vvx + c1o2) + (mfaac + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; + mfaac = m0; + mfbac = m1; + mfcac = m2; + ///////////c//////////////////////////////////////////////////////////////////////// + m0 = mfcbc * c1o2 + mfbbc * (vvx - c1o2) + (mfabc + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcbc - 2. * mfbbc * vvx + mfabc * (1. - vx2) - c1o9 * oMdrho * vx2; + m2 = mfcbc * c1o2 + mfbbc * (vvx + c1o2) + (mfabc + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfabc = m0; + mfbbc = m1; + mfcbc = m2; + ///////////c//////////////////////////////////////////////////////////////////////// + m0 = mfccc * c1o2 + mfbcc * (vvx - c1o2) + (mfacc + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfccc - 2. * mfbcc * vvx + mfacc * (1. - vx2) - c1o36 * oMdrho * vx2; + m2 = mfccc * c1o2 + mfbcc * (vvx + c1o2) + (mfacc + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; + mfacc = m0; + mfbcc = m1; + mfccc = m2; + + /////classical source term 8.4.2021 + + //mfcbb += 3.0 * (0.5 * forcingTerm[E]) / rho; //-(3.0*p1 - rho)*WEIGTH[E ]; + //mfbcb += 3.0 * (0.5 * forcingTerm[N]) / rho; //-(3.0*p1 - rho)*WEIGTH[N ]; + //mfbbc += 3.0 * (0.5 * forcingTerm[T]) / rho; //-(3.0*p1 - rho)*WEIGTH[T ]; + //mfccb += 3.0 * (0.5 * forcingTerm[NE]) / rho; //-(3.0*p1 - rho)*WEIGTH[NE ]; + //mfacb += 3.0 * (0.5 * forcingTerm[NW]) / rho; //-(3.0*p1 - rho)*WEIGTH[NW ]; + //mfcbc += 3.0 * (0.5 * forcingTerm[TE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TE ]; + //mfabc += 3.0 * (0.5 * forcingTerm[TW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TW ]; + //mfbcc += 3.0 * (0.5 * forcingTerm[TN]) / rho; //-(3.0*p1 - rho)*WEIGTH[TN ]; + //mfbac += 3.0 * (0.5 * forcingTerm[TS]) / rho; //-(3.0*p1 - rho)*WEIGTH[TS ]; + //mfccc += 3.0 * (0.5 * forcingTerm[TNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNE]; + //mfacc += 3.0 * (0.5 * forcingTerm[TNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNW]; + //mfcac += 3.0 * (0.5 * forcingTerm[TSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSE]; + //mfaac += 3.0 * (0.5 * forcingTerm[TSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSW]; + //mfabb += 3.0 * (0.5 * forcingTerm[W]) / rho; //-(3.0*p1 - rho)*WEIGTH[W ]; + //mfbab += 3.0 * (0.5 * forcingTerm[S]) / rho; //-(3.0*p1 - rho)*WEIGTH[S ]; + //mfbba += 3.0 * (0.5 * forcingTerm[B]) / rho; //-(3.0*p1 - rho)*WEIGTH[B ]; + //mfaab += 3.0 * (0.5 * forcingTerm[SW]) / rho; //-(3.0*p1 - rho)*WEIGTH[SW ]; + //mfcab += 3.0 * (0.5 * forcingTerm[SE]) / rho; //-(3.0*p1 - rho)*WEIGTH[SE ]; + //mfaba += 3.0 * (0.5 * forcingTerm[BW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BW ]; + //mfcba += 3.0 * (0.5 * forcingTerm[BE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BE ]; + //mfbaa += 3.0 * (0.5 * forcingTerm[BS]) / rho; //-(3.0*p1 - rho)*WEIGTH[BS ]; + //mfbca += 3.0 * (0.5 * forcingTerm[BN]) / rho; //-(3.0*p1 - rho)*WEIGTH[BN ]; + //mfaaa += 3.0 * (0.5 * forcingTerm[BSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSW]; + //mfcaa += 3.0 * (0.5 * forcingTerm[BSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSE]; + //mfaca += 3.0 * (0.5 * forcingTerm[BNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNW]; + //mfcca += 3.0 * (0.5 * forcingTerm[BNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNE]; + //mfbbb += 3.0 * (0.5 * forcingTerm[REST]) / rho; //- (3.0*p1 - rho)*WEIGTH[REST] + + + + ////////////////////////////////////////////////////////////////////////// + //proof correctness + ////////////////////////////////////////////////////////////////////////// +//#ifdef PROOF_CORRECTNESS + LBMReal rho_post = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) + + (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + (mfbaa + mfbac + mfbca + mfbcc) + + (mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; +// //LBMReal dif = fabs(drho - rho_post); +// LBMReal dif = drho + (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * correctionScaling - rho_post; +//#ifdef SINGLEPRECISION +// if (dif > 10.0E-7 || dif < -10.0E-7) +//#else +// if (dif > 10.0E-15 || dif < -10.0E-15) +//#endif +// { +// UB_THROW(UbException(UB_EXARGS, "drho=" + UbSystem::toString(drho) + ", rho_post=" + UbSystem::toString(rho_post) +// + " dif=" + UbSystem::toString(dif) +// + " drho is not correct for node " + UbSystem::toString(x1) + "," + UbSystem::toString(x2) + "," + UbSystem::toString(x3))); +// //UBLOG(logERROR,"LBMKernelETD3Q27CCLB::collideAll(): drho is not correct for node "+UbSystem::toString(x1)+","+UbSystem::toString(x2)+","+UbSystem::toString(x3)); +// //exit(EXIT_FAILURE); +// } +//#endif + + if (UbMath::isNaN(rho_post) || UbMath::isInfinity(rho_post)) + UB_THROW(UbException( + UB_EXARGS, "rho_post is not a number (nan or -1.#IND) or infinity number -1.#INF, node=" + UbSystem::toString(x1) + "," + + UbSystem::toString(x2) + "," + UbSystem::toString(x3))); + + ////////////////////////////////////////////////////////////////////////// + //write distribution + ////////////////////////////////////////////////////////////////////////// + (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3) = mfabb ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3) = mfbab ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3) = mfbba ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3) = mfaab ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3) = mfaba ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3) = mfcbb ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3) = mfbcb ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3) = mfccb ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3) = mfacb ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac ;//* rho * c1o3; + + (*this->zeroDistributionsF)(x1, x2, x3) = mfbbb;// *rho* c1o3; + ////////////////////////////////////////////////////////////////////////// + + ////!Incompressible Kernal + + +// ///////Old Kernel \|/ +// // ux += forcingX1*deltaT*0.5; // X +// // uy += forcingX2*deltaT*0.5; // Y +// // uz += forcingX3*deltaT*0.5; // Z +// } +// +// LBMReal ux = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + +// (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + +// (mfcbb - mfabb)) / +// (rho * c1o3) + +// (mu * dX1_phi + forcingX1) / (2 * rho); +// +// LBMReal uy = ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + +// (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + +// (mfbcb - mfbab)) / +// (rho * c1o3) + +// (mu * dX2_phi + forcingX2) / (2 * rho); +// +// LBMReal uz = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + +// (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + +// (mfbbc - mfbba)) / +// (rho * c1o3) + +// (mu * dX3_phi + forcingX3) / (2 * rho); +// +// //-------------------------------------------------------- +// +// LBMReal ux2 = ux * ux; +// LBMReal uy2 = uy * uy; +// LBMReal uz2 = uz * uz; +// +// //----------- Calculating Forcing Terms * ------------- +// for (int dir = STARTF; dir <= (FENDDIR); dir++) { +// LBMReal velProd = DX1[dir] * ux + DX2[dir] * uy + DX3[dir] * uz; +// LBMReal velSq1 = velProd * velProd; +// LBMReal gamma = WEIGTH[dir] * (1.0 + 3 * velProd + 4.5 * velSq1 - 1.5 * (ux2 + uy2 + uz2)); +// +// LBMReal fac1 = (gamma - WEIGTH[dir]) * c1o3 * rhoToPhi; +// +// forcingTerm[dir] = ((-ux) * (fac1 * dX1_phi + gamma * (mu * dX1_phi + forcingX1)) + +// (-uy) * (fac1 * dX2_phi + gamma * (mu * dX2_phi + forcingX2)) + +// (-uz) * (fac1 * dX3_phi + gamma * (mu * dX3_phi + forcingX3))) + +// (DX1[dir]) * (fac1 * dX1_phi + gamma * (mu * dX1_phi + forcingX1)) + +// (DX2[dir]) * (fac1 * dX2_phi + gamma * (mu * dX2_phi + forcingX2)) + +// (DX3[dir]) * (fac1 * dX3_phi + gamma * (mu * dX3_phi + forcingX3)); +// } +// +// LBMReal gamma = WEIGTH[REST] * (1.0 - 1.5 * (ux2 + uy2 + uz2)); +// LBMReal fac1 = (gamma - WEIGTH[REST]) * c1o3 * rhoToPhi; +// forcingTerm[REST] = (-ux) * (fac1 * dX1_phi + gamma * (mu * dX1_phi + forcingX1)) + +// (-uy) * (fac1 * dX2_phi + gamma * (mu * dX2_phi + forcingX2)) + +// (-uz) * (fac1 * dX3_phi + gamma * (mu * dX3_phi + forcingX3)); +// +// //-------------------------------------------------------- +// +// mfcbb = 3.0 * (mfcbb + 0.5 * forcingTerm[E]) / rho; //-(3.0*p1 - rho)*WEIGTH[E ]; +// mfbcb = 3.0 * (mfbcb + 0.5 * forcingTerm[N]) / rho; //-(3.0*p1 - rho)*WEIGTH[N ]; +// mfbbc = 3.0 * (mfbbc + 0.5 * forcingTerm[T]) / rho; //-(3.0*p1 - rho)*WEIGTH[T ]; +// mfccb = 3.0 * (mfccb + 0.5 * forcingTerm[NE]) / rho; //-(3.0*p1 - rho)*WEIGTH[NE ]; +// mfacb = 3.0 * (mfacb + 0.5 * forcingTerm[NW]) / rho; //-(3.0*p1 - rho)*WEIGTH[NW ]; +// mfcbc = 3.0 * (mfcbc + 0.5 * forcingTerm[TE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TE ]; +// mfabc = 3.0 * (mfabc + 0.5 * forcingTerm[TW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TW ]; +// mfbcc = 3.0 * (mfbcc + 0.5 * forcingTerm[TN]) / rho; //-(3.0*p1 - rho)*WEIGTH[TN ]; +// mfbac = 3.0 * (mfbac + 0.5 * forcingTerm[TS]) / rho; //-(3.0*p1 - rho)*WEIGTH[TS ]; +// mfccc = 3.0 * (mfccc + 0.5 * forcingTerm[TNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNE]; +// mfacc = 3.0 * (mfacc + 0.5 * forcingTerm[TNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNW]; +// mfcac = 3.0 * (mfcac + 0.5 * forcingTerm[TSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSE]; +// mfaac = 3.0 * (mfaac + 0.5 * forcingTerm[TSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSW]; +// mfabb = 3.0 * (mfabb + 0.5 * forcingTerm[W]) / rho; //-(3.0*p1 - rho)*WEIGTH[W ]; +// mfbab = 3.0 * (mfbab + 0.5 * forcingTerm[S]) / rho; //-(3.0*p1 - rho)*WEIGTH[S ]; +// mfbba = 3.0 * (mfbba + 0.5 * forcingTerm[B]) / rho; //-(3.0*p1 - rho)*WEIGTH[B ]; +// mfaab = 3.0 * (mfaab + 0.5 * forcingTerm[SW]) / rho; //-(3.0*p1 - rho)*WEIGTH[SW ]; +// mfcab = 3.0 * (mfcab + 0.5 * forcingTerm[SE]) / rho; //-(3.0*p1 - rho)*WEIGTH[SE ]; +// mfaba = 3.0 * (mfaba + 0.5 * forcingTerm[BW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BW ]; +// mfcba = 3.0 * (mfcba + 0.5 * forcingTerm[BE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BE ]; +// mfbaa = 3.0 * (mfbaa + 0.5 * forcingTerm[BS]) / rho; //-(3.0*p1 - rho)*WEIGTH[BS ]; +// mfbca = 3.0 * (mfbca + 0.5 * forcingTerm[BN]) / rho; //-(3.0*p1 - rho)*WEIGTH[BN ]; +// mfaaa = 3.0 * (mfaaa + 0.5 * forcingTerm[BSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSW]; +// mfcaa = 3.0 * (mfcaa + 0.5 * forcingTerm[BSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSE]; +// mfaca = 3.0 * (mfaca + 0.5 * forcingTerm[BNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNW]; +// mfcca = 3.0 * (mfcca + 0.5 * forcingTerm[BNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNE]; +// mfbbb = 3.0 * (mfbbb + 0.5 * forcingTerm[REST]) / rho; //- (3.0*p1 - rho)*WEIGTH[REST]; +// +// LBMReal rho1 = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) + +// (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + +// (mfbaa + mfbac + mfbca + mfbcc) + (mfabb + mfcbb) + (mfbab + mfbcb) + +// (mfbba + mfbbc) + mfbbb; +// +// +// LBMReal oMdrho, m0, m1, m2; +// +// oMdrho = mfccc + mfaaa; +// m0 = mfaca + mfcac; +// m1 = mfacc + mfcaa; +// m2 = mfaac + mfcca; +// oMdrho += m0; +// m1 += m2; +// oMdrho += m1; +// m0 = mfbac + mfbca; +// m1 = mfbaa + mfbcc; +// m0 += m1; +// m1 = mfabc + mfcba; +// m2 = mfaba + mfcbc; +// m1 += m2; +// m0 += m1; +// m1 = mfacb + mfcab; +// m2 = mfaab + mfccb; +// m1 += m2; +// m0 += m1; +// oMdrho += m0; +// m0 = mfabb + mfcbb; +// m1 = mfbab + mfbcb; +// m2 = mfbba + mfbbc; +// m0 += m1 + m2; +// m0 += mfbbb; // hat gefehlt +// oMdrho = 1. - (oMdrho + m0); +// // oMdrho = rho - (oMdrho + m0); +// +// //////////////////////////////////////////////////////////////////////////////////// +// LBMReal wadjust; +// LBMReal qudricLimit = 0.01; +// //////////////////////////////////////////////////////////////////////////////////// +// // Hin +// //////////////////////////////////////////////////////////////////////////////////// +// // mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren +// //////////////////////////////////////////////////////////////////////////////////// +// // Z - Dir +// m2 = mfaaa + mfaac; +// m1 = mfaac - mfaaa; +// m0 = m2 + mfaab; +// mfaaa = m0; +// m0 += c1o36 * oMdrho; +// mfaab = m1 - m0 * uz; +// mfaac = m2 - 2. * m1 * uz + uz2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfaba + mfabc; +// m1 = mfabc - mfaba; +// m0 = m2 + mfabb; +// mfaba = m0; +// m0 += c1o9 * oMdrho; +// mfabb = m1 - m0 * uz; +// mfabc = m2 - 2. * m1 * uz + uz2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfaca + mfacc; +// m1 = mfacc - mfaca; +// m0 = m2 + mfacb; +// mfaca = m0; +// m0 += c1o36 * oMdrho; +// mfacb = m1 - m0 * uz; +// mfacc = m2 - 2. * m1 * uz + uz2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfbaa + mfbac; +// m1 = mfbac - mfbaa; +// m0 = m2 + mfbab; +// mfbaa = m0; +// m0 += c1o9 * oMdrho; +// mfbab = m1 - m0 * uz; +// mfbac = m2 - 2. * m1 * uz + uz2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfbba + mfbbc; +// m1 = mfbbc - mfbba; +// m0 = m2 + mfbbb; +// mfbba = m0; +// m0 += c4o9 * oMdrho; +// mfbbb = m1 - m0 * uz; +// mfbbc = m2 - 2. * m1 * uz + uz2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfbca + mfbcc; +// m1 = mfbcc - mfbca; +// m0 = m2 + mfbcb; +// mfbca = m0; +// m0 += c1o9 * oMdrho; +// mfbcb = m1 - m0 * uz; +// mfbcc = m2 - 2. * m1 * uz + uz2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfcaa + mfcac; +// m1 = mfcac - mfcaa; +// m0 = m2 + mfcab; +// mfcaa = m0; +// m0 += c1o36 * oMdrho; +// mfcab = m1 - m0 * uz; +// mfcac = m2 - 2. * m1 * uz + uz2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfcba + mfcbc; +// m1 = mfcbc - mfcba; +// m0 = m2 + mfcbb; +// mfcba = m0; +// m0 += c1o9 * oMdrho; +// mfcbb = m1 - m0 * uz; +// mfcbc = m2 - 2. * m1 * uz + uz2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfcca + mfccc; +// m1 = mfccc - mfcca; +// m0 = m2 + mfccb; +// mfcca = m0; +// m0 += c1o36 * oMdrho; +// mfccb = m1 - m0 * uz; +// mfccc = m2 - 2. * m1 * uz + uz2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// // mit 1/6, 0, 1/18, 2/3, 0, 2/9, 1/6, 0, 1/18 Konditionieren +// //////////////////////////////////////////////////////////////////////////////////// +// // Y - Dir +// m2 = mfaaa + mfaca; +// m1 = mfaca - mfaaa; +// m0 = m2 + mfaba; +// mfaaa = m0; +// m0 += c1o6 * oMdrho; +// mfaba = m1 - m0 * uy; +// mfaca = m2 - 2. * m1 * uy + uy2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfaab + mfacb; +// m1 = mfacb - mfaab; +// m0 = m2 + mfabb; +// mfaab = m0; +// mfabb = m1 - m0 * uy; +// mfacb = m2 - 2. * m1 * uy + uy2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfaac + mfacc; +// m1 = mfacc - mfaac; +// m0 = m2 + mfabc; +// mfaac = m0; +// m0 += c1o18 * oMdrho; +// mfabc = m1 - m0 * uy; +// mfacc = m2 - 2. * m1 * uy + uy2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfbaa + mfbca; +// m1 = mfbca - mfbaa; +// m0 = m2 + mfbba; +// mfbaa = m0; +// m0 += c2o3 * oMdrho; +// mfbba = m1 - m0 * uy; +// mfbca = m2 - 2. * m1 * uy + uy2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfbab + mfbcb; +// m1 = mfbcb - mfbab; +// m0 = m2 + mfbbb; +// mfbab = m0; +// mfbbb = m1 - m0 * uy; +// mfbcb = m2 - 2. * m1 * uy + uy2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfbac + mfbcc; +// m1 = mfbcc - mfbac; +// m0 = m2 + mfbbc; +// mfbac = m0; +// m0 += c2o9 * oMdrho; +// mfbbc = m1 - m0 * uy; +// mfbcc = m2 - 2. * m1 * uy + uy2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfcaa + mfcca; +// m1 = mfcca - mfcaa; +// m0 = m2 + mfcba; +// mfcaa = m0; +// m0 += c1o6 * oMdrho; +// mfcba = m1 - m0 * uy; +// mfcca = m2 - 2. * m1 * uy + uy2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfcab + mfccb; +// m1 = mfccb - mfcab; +// m0 = m2 + mfcbb; +// mfcab = m0; +// mfcbb = m1 - m0 * uy; +// mfccb = m2 - 2. * m1 * uy + uy2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfcac + mfccc; +// m1 = mfccc - mfcac; +// m0 = m2 + mfcbc; +// mfcac = m0; +// m0 += c1o18 * oMdrho; +// mfcbc = m1 - m0 * uy; +// mfccc = m2 - 2. * m1 * uy + uy2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// // mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren +// //////////////////////////////////////////////////////////////////////////////////// +// // X - Dir +// m2 = mfaaa + mfcaa; +// m1 = mfcaa - mfaaa; +// m0 = m2 + mfbaa; +// mfaaa = m0; +// m0 += 1. * oMdrho; +// mfbaa = m1 - m0 * ux; +// mfcaa = m2 - 2. * m1 * ux + ux2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfaba + mfcba; +// m1 = mfcba - mfaba; +// m0 = m2 + mfbba; +// mfaba = m0; +// mfbba = m1 - m0 * ux; +// mfcba = m2 - 2. * m1 * ux + ux2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfaca + mfcca; +// m1 = mfcca - mfaca; +// m0 = m2 + mfbca; +// mfaca = m0; +// m0 += c1o3 * oMdrho; +// mfbca = m1 - m0 * ux; +// mfcca = m2 - 2. * m1 * ux + ux2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfaab + mfcab; +// m1 = mfcab - mfaab; +// m0 = m2 + mfbab; +// mfaab = m0; +// mfbab = m1 - m0 * ux; +// mfcab = m2 - 2. * m1 * ux + ux2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfabb + mfcbb; +// m1 = mfcbb - mfabb; +// m0 = m2 + mfbbb; +// mfabb = m0; +// mfbbb = m1 - m0 * ux; +// mfcbb = m2 - 2. * m1 * ux + ux2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfacb + mfccb; +// m1 = mfccb - mfacb; +// m0 = m2 + mfbcb; +// mfacb = m0; +// mfbcb = m1 - m0 * ux; +// mfccb = m2 - 2. * m1 * ux + ux2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfaac + mfcac; +// m1 = mfcac - mfaac; +// m0 = m2 + mfbac; +// mfaac = m0; +// m0 += c1o3 * oMdrho; +// mfbac = m1 - m0 * ux; +// mfcac = m2 - 2. * m1 * ux + ux2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfabc + mfcbc; +// m1 = mfcbc - mfabc; +// m0 = m2 + mfbbc; +// mfabc = m0; +// mfbbc = m1 - m0 * ux; +// mfcbc = m2 - 2. * m1 * ux + ux2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfacc + mfccc; +// m1 = mfccc - mfacc; +// m0 = m2 + mfbcc; +// mfacc = m0; +// m0 += c1o9 * oMdrho; +// mfbcc = m1 - m0 * ux; +// mfccc = m2 - 2. * m1 * ux + ux2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// // Cumulants +// //////////////////////////////////////////////////////////////////////////////////// +// LBMReal OxxPyyPzz = 1.; // omega2 or bulk viscosity +// LBMReal OxyyPxzz = 1.; //-s9;//2+s9;// +// LBMReal OxyyMxzz = 1.; // 2+s9;// +// LBMReal O4 = 1.; +// LBMReal O5 = 1.; +// LBMReal O6 = 1.; +// +// // Cum 4. +// LBMReal CUMcbb = mfcbb - ((mfcaa + c1o3) * mfabb + 2. * mfbba * mfbab); +// LBMReal CUMbcb = mfbcb - ((mfaca + c1o3) * mfbab + 2. * mfbba * mfabb); +// LBMReal CUMbbc = mfbbc - ((mfaac + c1o3) * mfbba + 2. * mfbab * mfabb); +// +// LBMReal CUMcca = mfcca - ((mfcaa * mfaca + 2. * mfbba * mfbba) + +// c1o3 * (mfcaa + mfaca) * oMdrho + c1o9 * (oMdrho - 1) * oMdrho); +// LBMReal CUMcac = mfcac - ((mfcaa * mfaac + 2. * mfbab * mfbab) + +// c1o3 * (mfcaa + mfaac) * oMdrho + c1o9 * (oMdrho - 1) * oMdrho); +// LBMReal CUMacc = mfacc - ((mfaac * mfaca + 2. * mfabb * mfabb) + +// c1o3 * (mfaac + mfaca) * oMdrho + c1o9 * (oMdrho - 1) * oMdrho); +// +// // Cum 5. +// LBMReal CUMbcc = mfbcc - +// (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + +// 2. * (mfbab * mfacb + mfbba * mfabc)) - +// c1o3 * (mfbca + mfbac) * oMdrho; +// LBMReal CUMcbc = mfcbc - +// (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + +// 2. * (mfabb * mfcab + mfbba * mfbac)) - +// c1o3 * (mfcba + mfabc) * oMdrho; +// LBMReal CUMccb = mfccb - +// (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + +// 2. * (mfbab * mfbca + mfabb * mfcba)) - +// c1o3 * (mfacb + mfcab) * oMdrho; +// +// // Cum 6. +// LBMReal CUMccc = +// mfccc + +// ((-4. * mfbbb * mfbbb - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) - +// 4. * (mfabb * mfcbb + mfbab * mfbcb + mfbba * mfbbc) - +// 2. * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) + +// (4. * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + +// 2. * (mfcaa * mfaca * mfaac) + 16. * mfbba * mfbab * mfabb) - +// c1o3 * (mfacc + mfcac + mfcca) * oMdrho - c1o9 * oMdrho * oMdrho - +// c1o9 * (mfcaa + mfaca + mfaac) * oMdrho * (1. - 2. * oMdrho) - +// c1o27 * oMdrho * oMdrho * (-2. * oMdrho) + +// (2. * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + +// (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa)) * +// c2o3 * oMdrho) + +// c1o27 * oMdrho; +// +// // 2. +// // linear combinations +// LBMReal mxxPyyPzz = mfcaa + mfaca + mfaac; +// LBMReal mxxMyy = mfcaa - mfaca; +// LBMReal mxxMzz = mfcaa - mfaac; +// +// LBMReal dxux = -c1o2 * collFactorM * (mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz * (mfaaa - mxxPyyPzz); +// LBMReal dyuy = dxux + collFactorM * c3o2 * mxxMyy; +// LBMReal dzuz = dxux + collFactorM * c3o2 * mxxMzz; +// +// (*divU)(x1, x2, x3) = dxux + dyuy + dzuz; +// +// // relax +// mxxPyyPzz += OxxPyyPzz * (mfaaa - mxxPyyPzz) - +// 3. * (1. - c1o2 * OxxPyyPzz) * (ux2 * dxux + uy2 * dyuy + uz2 * dzuz); +// mxxMyy += collFactorM * (-mxxMyy) - 3. * (1. - c1o2 * collFactorM) * (ux2 * dxux - uy2 * dyuy); +// mxxMzz += collFactorM * (-mxxMzz) - 3. * (1. - c1o2 * collFactorM) * (ux2 * dxux - uz2 * dzuz); +// +// mfabb += collFactorM * (-mfabb); +// mfbab += collFactorM * (-mfbab); +// mfbba += collFactorM * (-mfbba); +// +// // linear combinations back +// mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); +// mfaca = c1o3 * (-2. * mxxMyy + mxxMzz + mxxPyyPzz); +// mfaac = c1o3 * (mxxMyy - 2. * mxxMzz + mxxPyyPzz); +// +// // 3. +// // linear combinations +// LBMReal mxxyPyzz = mfcba + mfabc; +// LBMReal mxxyMyzz = mfcba - mfabc; +// +// LBMReal mxxzPyyz = mfcab + mfacb; +// LBMReal mxxzMyyz = mfcab - mfacb; +// +// LBMReal mxyyPxzz = mfbca + mfbac; +// LBMReal mxyyMxzz = mfbca - mfbac; +// +// // relax +// wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mfbbb) / (fabs(mfbbb) + qudricLimit); +// mfbbb += wadjust * (-mfbbb); +// wadjust = OxyyPxzz + (1. - OxyyPxzz) * fabs(mxxyPyzz) / (fabs(mxxyPyzz) + qudricLimit); +// mxxyPyzz += wadjust * (-mxxyPyzz); +// wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mxxyMyzz) / (fabs(mxxyMyzz) + qudricLimit); +// mxxyMyzz += wadjust * (-mxxyMyzz); +// wadjust = OxyyPxzz + (1. - OxyyPxzz) * fabs(mxxzPyyz) / (fabs(mxxzPyyz) + qudricLimit); +// mxxzPyyz += wadjust * (-mxxzPyyz); +// wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mxxzMyyz) / (fabs(mxxzMyyz) + qudricLimit); +// mxxzMyyz += wadjust * (-mxxzMyyz); +// wadjust = OxyyPxzz + (1. - OxyyPxzz) * fabs(mxyyPxzz) / (fabs(mxyyPxzz) + qudricLimit); +// mxyyPxzz += wadjust * (-mxyyPxzz); +// wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mxyyMxzz) / (fabs(mxyyMxzz) + qudricLimit); +// mxyyMxzz += wadjust * (-mxyyMxzz); +// +// // linear combinations back +// mfcba = (mxxyMyzz + mxxyPyzz) * c1o2; +// mfabc = (-mxxyMyzz + mxxyPyzz) * c1o2; +// mfcab = (mxxzMyyz + mxxzPyyz) * c1o2; +// mfacb = (-mxxzMyyz + mxxzPyyz) * c1o2; +// mfbca = (mxyyMxzz + mxyyPxzz) * c1o2; +// mfbac = (-mxyyMxzz + mxyyPxzz) * c1o2; +// +// // 4. +// CUMacc += O4 * (-CUMacc); +// CUMcac += O4 * (-CUMcac); +// CUMcca += O4 * (-CUMcca); +// +// CUMbbc += O4 * (-CUMbbc); +// CUMbcb += O4 * (-CUMbcb); +// CUMcbb += O4 * (-CUMcbb); +// +// // 5. +// CUMbcc += O5 * (-CUMbcc); +// CUMcbc += O5 * (-CUMcbc); +// CUMccb += O5 * (-CUMccb); +// +// // 6. +// CUMccc += O6 * (-CUMccc); +// +// // back cumulants to central moments +// // 4. +// mfcbb = CUMcbb + ((mfcaa + c1o3) * mfabb + 2. * mfbba * mfbab); +// mfbcb = CUMbcb + ((mfaca + c1o3) * mfbab + 2. * mfbba * mfabb); +// mfbbc = CUMbbc + ((mfaac + c1o3) * mfbba + 2. * mfbab * mfabb); +// +// mfcca = CUMcca + (mfcaa * mfaca + 2. * mfbba * mfbba) + c1o3 * (mfcaa + mfaca) * oMdrho + +// c1o9 * (oMdrho - 1) * oMdrho; +// mfcac = CUMcac + (mfcaa * mfaac + 2. * mfbab * mfbab) + c1o3 * (mfcaa + mfaac) * oMdrho + +// c1o9 * (oMdrho - 1) * oMdrho; +// mfacc = CUMacc + (mfaac * mfaca + 2. * mfabb * mfabb) + c1o3 * (mfaac + mfaca) * oMdrho + +// c1o9 * (oMdrho - 1) * oMdrho; +// +// // 5. +// mfbcc = CUMbcc + +// (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + +// 2. * (mfbab * mfacb + mfbba * mfabc)) + +// c1o3 * (mfbca + mfbac) * oMdrho; +// mfcbc = CUMcbc + +// (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + +// 2. * (mfabb * mfcab + mfbba * mfbac)) + +// c1o3 * (mfcba + mfabc) * oMdrho; +// mfccb = CUMccb + +// (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + +// 2. * (mfbab * mfbca + mfabb * mfcba)) + +// c1o3 * (mfacb + mfcab) * oMdrho; +// +// // 6. +// mfccc = CUMccc - +// ((-4. * mfbbb * mfbbb - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) - +// 4. * (mfabb * mfcbb + mfbac * mfbca + mfbba * mfbbc) - +// 2. * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) + +// (4. * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + +// 2. * (mfcaa * mfaca * mfaac) + 16. * mfbba * mfbab * mfabb) - +// c1o3 * (mfacc + mfcac + mfcca) * oMdrho - c1o9 * oMdrho * oMdrho - +// c1o9 * (mfcaa + mfaca + mfaac) * oMdrho * (1. - 2. * oMdrho) - +// c1o27 * oMdrho * oMdrho * (-2. * oMdrho) + +// (2. * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + +// (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa)) * +// c2o3 * oMdrho) - +// c1o27 * oMdrho; +// +// //////////////////////////////////////////////////////////////////////////////////// +// // forcing +// mfbaa = -mfbaa; +// mfaba = -mfaba; +// mfaab = -mfaab; +// ////////////////////////////////////////////////////////////////////////////////////// +// +// //////////////////////////////////////////////////////////////////////////////////// +// // back +// //////////////////////////////////////////////////////////////////////////////////// +// // mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren +// //////////////////////////////////////////////////////////////////////////////////// +// // Z - Dir +// m0 = mfaac * c1o2 + mfaab * (uz - c1o2) + (mfaaa + 1. * oMdrho) * (uz2 - uz) * c1o2; +// m1 = -mfaac - 2. * mfaab * uz + mfaaa * (1. - uz2) - 1. * oMdrho * uz2; +// m2 = mfaac * c1o2 + mfaab * (uz + c1o2) + (mfaaa + 1. * oMdrho) * (uz2 + uz) * c1o2; +// mfaaa = m0; +// mfaab = m1; +// mfaac = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfabc * c1o2 + mfabb * (uz - c1o2) + mfaba * (uz2 - uz) * c1o2; +// m1 = -mfabc - 2. * mfabb * uz + mfaba * (1. - uz2); +// m2 = mfabc * c1o2 + mfabb * (uz + c1o2) + mfaba * (uz2 + uz) * c1o2; +// mfaba = m0; +// mfabb = m1; +// mfabc = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfacc * c1o2 + mfacb * (uz - c1o2) + (mfaca + c1o3 * oMdrho) * (uz2 - uz) * c1o2; +// m1 = -mfacc - 2. * mfacb * uz + mfaca * (1. - uz2) - c1o3 * oMdrho * uz2; +// m2 = mfacc * c1o2 + mfacb * (uz + c1o2) + (mfaca + c1o3 * oMdrho) * (uz2 + uz) * c1o2; +// mfaca = m0; +// mfacb = m1; +// mfacc = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfbac * c1o2 + mfbab * (uz - c1o2) + mfbaa * (uz2 - uz) * c1o2; +// m1 = -mfbac - 2. * mfbab * uz + mfbaa * (1. - uz2); +// m2 = mfbac * c1o2 + mfbab * (uz + c1o2) + mfbaa * (uz2 + uz) * c1o2; +// mfbaa = m0; +// mfbab = m1; +// mfbac = m2; +// /////////b////////////////////////////////////////////////////////////////////////// +// m0 = mfbbc * c1o2 + mfbbb * (uz - c1o2) + mfbba * (uz2 - uz) * c1o2; +// m1 = -mfbbc - 2. * mfbbb * uz + mfbba * (1. - uz2); +// m2 = mfbbc * c1o2 + mfbbb * (uz + c1o2) + mfbba * (uz2 + uz) * c1o2; +// mfbba = m0; +// mfbbb = m1; +// mfbbc = m2; +// /////////b////////////////////////////////////////////////////////////////////////// +// m0 = mfbcc * c1o2 + mfbcb * (uz - c1o2) + mfbca * (uz2 - uz) * c1o2; +// m1 = -mfbcc - 2. * mfbcb * uz + mfbca * (1. - uz2); +// m2 = mfbcc * c1o2 + mfbcb * (uz + c1o2) + mfbca * (uz2 + uz) * c1o2; +// mfbca = m0; +// mfbcb = m1; +// mfbcc = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfcac * c1o2 + mfcab * (uz - c1o2) + (mfcaa + c1o3 * oMdrho) * (uz2 - uz) * c1o2; +// m1 = -mfcac - 2. * mfcab * uz + mfcaa * (1. - uz2) - c1o3 * oMdrho * uz2; +// m2 = mfcac * c1o2 + mfcab * (uz + c1o2) + (mfcaa + c1o3 * oMdrho) * (uz2 + uz) * c1o2; +// mfcaa = m0; +// mfcab = m1; +// mfcac = m2; +// /////////c////////////////////////////////////////////////////////////////////////// +// m0 = mfcbc * c1o2 + mfcbb * (uz - c1o2) + mfcba * (uz2 - uz) * c1o2; +// m1 = -mfcbc - 2. * mfcbb * uz + mfcba * (1. - uz2); +// m2 = mfcbc * c1o2 + mfcbb * (uz + c1o2) + mfcba * (uz2 + uz) * c1o2; +// mfcba = m0; +// mfcbb = m1; +// mfcbc = m2; +// /////////c////////////////////////////////////////////////////////////////////////// +// m0 = mfccc * c1o2 + mfccb * (uz - c1o2) + (mfcca + c1o9 * oMdrho) * (uz2 - uz) * c1o2; +// m1 = -mfccc - 2. * mfccb * uz + mfcca * (1. - uz2) - c1o9 * oMdrho * uz2; +// m2 = mfccc * c1o2 + mfccb * (uz + c1o2) + (mfcca + c1o9 * oMdrho) * (uz2 + uz) * c1o2; +// mfcca = m0; +// mfccb = m1; +// mfccc = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// // mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren +// //////////////////////////////////////////////////////////////////////////////////// +// // Y - Dir +// m0 = mfaca * c1o2 + mfaba * (uy - c1o2) + (mfaaa + c1o6 * oMdrho) * (uy2 - uy) * c1o2; +// m1 = -mfaca - 2. * mfaba * uy + mfaaa * (1. - uy2) - c1o6 * oMdrho * uy2; +// m2 = mfaca * c1o2 + mfaba * (uy + c1o2) + (mfaaa + c1o6 * oMdrho) * (uy2 + uy) * c1o2; +// mfaaa = m0; +// mfaba = m1; +// mfaca = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfacb * c1o2 + mfabb * (uy - c1o2) + (mfaab + c2o3 * oMdrho) * (uy2 - uy) * c1o2; +// m1 = -mfacb - 2. * mfabb * uy + mfaab * (1. - uy2) - c2o3 * oMdrho * uy2; +// m2 = mfacb * c1o2 + mfabb * (uy + c1o2) + (mfaab + c2o3 * oMdrho) * (uy2 + uy) * c1o2; +// mfaab = m0; +// mfabb = m1; +// mfacb = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfacc * c1o2 + mfabc * (uy - c1o2) + (mfaac + c1o6 * oMdrho) * (uy2 - uy) * c1o2; +// m1 = -mfacc - 2. * mfabc * uy + mfaac * (1. - uy2) - c1o6 * oMdrho * uy2; +// m2 = mfacc * c1o2 + mfabc * (uy + c1o2) + (mfaac + c1o6 * oMdrho) * (uy2 + uy) * c1o2; +// mfaac = m0; +// mfabc = m1; +// mfacc = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfbca * c1o2 + mfbba * (uy - c1o2) + mfbaa * (uy2 - uy) * c1o2; +// m1 = -mfbca - 2. * mfbba * uy + mfbaa * (1. - uy2); +// m2 = mfbca * c1o2 + mfbba * (uy + c1o2) + mfbaa * (uy2 + uy) * c1o2; +// mfbaa = m0; +// mfbba = m1; +// mfbca = m2; +// /////////b////////////////////////////////////////////////////////////////////////// +// m0 = mfbcb * c1o2 + mfbbb * (uy - c1o2) + mfbab * (uy2 - uy) * c1o2; +// m1 = -mfbcb - 2. * mfbbb * uy + mfbab * (1. - uy2); +// m2 = mfbcb * c1o2 + mfbbb * (uy + c1o2) + mfbab * (uy2 + uy) * c1o2; +// mfbab = m0; +// mfbbb = m1; +// mfbcb = m2; +// /////////b////////////////////////////////////////////////////////////////////////// +// m0 = mfbcc * c1o2 + mfbbc * (uy - c1o2) + mfbac * (uy2 - uy) * c1o2; +// m1 = -mfbcc - 2. * mfbbc * uy + mfbac * (1. - uy2); +// m2 = mfbcc * c1o2 + mfbbc * (uy + c1o2) + mfbac * (uy2 + uy) * c1o2; +// mfbac = m0; +// mfbbc = m1; +// mfbcc = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfcca * c1o2 + mfcba * (uy - c1o2) + (mfcaa + c1o18 * oMdrho) * (uy2 - uy) * c1o2; +// m1 = -mfcca - 2. * mfcba * uy + mfcaa * (1. - uy2) - c1o18 * oMdrho * uy2; +// m2 = mfcca * c1o2 + mfcba * (uy + c1o2) + (mfcaa + c1o18 * oMdrho) * (uy2 + uy) * c1o2; +// mfcaa = m0; +// mfcba = m1; +// mfcca = m2; +// /////////c////////////////////////////////////////////////////////////////////////// +// m0 = mfccb * c1o2 + mfcbb * (uy - c1o2) + (mfcab + c2o9 * oMdrho) * (uy2 - uy) * c1o2; +// m1 = -mfccb - 2. * mfcbb * uy + mfcab * (1. - uy2) - c2o9 * oMdrho * uy2; +// m2 = mfccb * c1o2 + mfcbb * (uy + c1o2) + (mfcab + c2o9 * oMdrho) * (uy2 + uy) * c1o2; +// mfcab = m0; +// mfcbb = m1; +// mfccb = m2; +// /////////c////////////////////////////////////////////////////////////////////////// +// m0 = mfccc * c1o2 + mfcbc * (uy - c1o2) + (mfcac + c1o18 * oMdrho) * (uy2 - uy) * c1o2; +// m1 = -mfccc - 2. * mfcbc * uy + mfcac * (1. - uy2) - c1o18 * oMdrho * uy2; +// m2 = mfccc * c1o2 + mfcbc * (uy + c1o2) + (mfcac + c1o18 * oMdrho) * (uy2 + uy) * c1o2; +// mfcac = m0; +// mfcbc = m1; +// mfccc = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// // mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren +// //////////////////////////////////////////////////////////////////////////////////// +// // X - Dir +// m0 = mfcaa * c1o2 + mfbaa * (ux - c1o2) + (mfaaa + c1o36 * oMdrho) * (ux2 - ux) * c1o2; +// m1 = -mfcaa - 2. * mfbaa * ux + mfaaa * (1. - ux2) - c1o36 * oMdrho * ux2; +// m2 = mfcaa * c1o2 + mfbaa * (ux + c1o2) + (mfaaa + c1o36 * oMdrho) * (ux2 + ux) * c1o2; +// mfaaa = m0; +// mfbaa = m1; +// mfcaa = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfcba * c1o2 + mfbba * (ux - c1o2) + (mfaba + c1o9 * oMdrho) * (ux2 - ux) * c1o2; +// m1 = -mfcba - 2. * mfbba * ux + mfaba * (1. - ux2) - c1o9 * oMdrho * ux2; +// m2 = mfcba * c1o2 + mfbba * (ux + c1o2) + (mfaba + c1o9 * oMdrho) * (ux2 + ux) * c1o2; +// mfaba = m0; +// mfbba = m1; +// mfcba = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfcca * c1o2 + mfbca * (ux - c1o2) + (mfaca + c1o36 * oMdrho) * (ux2 - ux) * c1o2; +// m1 = -mfcca - 2. * mfbca * ux + mfaca * (1. - ux2) - c1o36 * oMdrho * ux2; +// m2 = mfcca * c1o2 + mfbca * (ux + c1o2) + (mfaca + c1o36 * oMdrho) * (ux2 + ux) * c1o2; +// mfaca = m0; +// mfbca = m1; +// mfcca = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfcab * c1o2 + mfbab * (ux - c1o2) + (mfaab + c1o9 * oMdrho) * (ux2 - ux) * c1o2; +// m1 = -mfcab - 2. * mfbab * ux + mfaab * (1. - ux2) - c1o9 * oMdrho * ux2; +// m2 = mfcab * c1o2 + mfbab * (ux + c1o2) + (mfaab + c1o9 * oMdrho) * (ux2 + ux) * c1o2; +// mfaab = m0; +// mfbab = m1; +// mfcab = m2; +// ///////////b//////////////////////////////////////////////////////////////////////// +// m0 = mfcbb * c1o2 + mfbbb * (ux - c1o2) + (mfabb + c4o9 * oMdrho) * (ux2 - ux) * c1o2; +// m1 = -mfcbb - 2. * mfbbb * ux + mfabb * (1. - ux2) - c4o9 * oMdrho * ux2; +// m2 = mfcbb * c1o2 + mfbbb * (ux + c1o2) + (mfabb + c4o9 * oMdrho) * (ux2 + ux) * c1o2; +// mfabb = m0; +// mfbbb = m1; +// mfcbb = m2; +// ///////////b//////////////////////////////////////////////////////////////////////// +// m0 = mfccb * c1o2 + mfbcb * (ux - c1o2) + (mfacb + c1o9 * oMdrho) * (ux2 - ux) * c1o2; +// m1 = -mfccb - 2. * mfbcb * ux + mfacb * (1. - ux2) - c1o9 * oMdrho * ux2; +// m2 = mfccb * c1o2 + mfbcb * (ux + c1o2) + (mfacb + c1o9 * oMdrho) * (ux2 + ux) * c1o2; +// mfacb = m0; +// mfbcb = m1; +// mfccb = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfcac * c1o2 + mfbac * (ux - c1o2) + (mfaac + c1o36 * oMdrho) * (ux2 - ux) * c1o2; +// m1 = -mfcac - 2. * mfbac * ux + mfaac * (1. - ux2) - c1o36 * oMdrho * ux2; +// m2 = mfcac * c1o2 + mfbac * (ux + c1o2) + (mfaac + c1o36 * oMdrho) * (ux2 + ux) * c1o2; +// mfaac = m0; +// mfbac = m1; +// mfcac = m2; +// ///////////c//////////////////////////////////////////////////////////////////////// +// m0 = mfcbc * c1o2 + mfbbc * (ux - c1o2) + (mfabc + c1o9 * oMdrho) * (ux2 - ux) * c1o2; +// m1 = -mfcbc - 2. * mfbbc * ux + mfabc * (1. - ux2) - c1o9 * oMdrho * ux2; +// m2 = mfcbc * c1o2 + mfbbc * (ux + c1o2) + (mfabc + c1o9 * oMdrho) * (ux2 + ux) * c1o2; +// mfabc = m0; +// mfbbc = m1; +// mfcbc = m2; +// ///////////c//////////////////////////////////////////////////////////////////////// +// m0 = mfccc * c1o2 + mfbcc * (ux - c1o2) + (mfacc + c1o36 * oMdrho) * (ux2 - ux) * c1o2; +// m1 = -mfccc - 2. * mfbcc * ux + mfacc * (1. - ux2) - c1o36 * oMdrho * ux2; +// m2 = mfccc * c1o2 + mfbcc * (ux + c1o2) + (mfacc + c1o36 * oMdrho) * (ux2 + ux) * c1o2; +// mfacc = m0; +// mfbcc = m1; +// mfccc = m2; +// +// /////////////////////////////////////////////////////////////////////////// +// +// ////////////////////////////////////////////////////////////////////////// +// // proof correctness +// ////////////////////////////////////////////////////////////////////////// +//#ifdef PROOF_CORRECTNESS +// LBMReal rho_post = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) + +// (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + +// (mfbaa + mfbac + mfbca + mfbcc) + (mfabb + mfcbb) + (mfbab + mfbcb) + +// (mfbba + mfbbc) + mfbbb; +// +// LBMReal dif = rho1 - rho_post; +//#ifdef SINGLEPRECISION +// if (dif > 10.0E-7 || dif < -10.0E-7) +//#else +// if (dif > 10.0E-15 || dif < -10.0E-15) +//#endif +// { +// UB_THROW(UbException(UB_EXARGS, +// "rho=" + UbSystem::toString(rho) + ", rho_post=" + +// UbSystem::toString(rho_post) + " dif=" + UbSystem::toString(dif) + +// " rho is not correct for node " + UbSystem::toString(x1) + "," + +// UbSystem::toString(x2) + "," + UbSystem::toString(x3))); +// } +//#endif +// +// mfcbb = rho * c1o3 * (mfcbb) + 0.5 * forcingTerm[E]; +// mfbcb = rho * c1o3 * (mfbcb) + 0.5 * forcingTerm[N]; +// mfbbc = rho * c1o3 * (mfbbc) + 0.5 * forcingTerm[T]; +// mfccb = rho * c1o3 * (mfccb) + 0.5 * forcingTerm[NE]; +// mfacb = rho * c1o3 * (mfacb) + 0.5 * forcingTerm[NW]; +// mfcbc = rho * c1o3 * (mfcbc) + 0.5 * forcingTerm[TE]; +// mfabc = rho * c1o3 * (mfabc) + 0.5 * forcingTerm[TW]; +// mfbcc = rho * c1o3 * (mfbcc) + 0.5 * forcingTerm[TN]; +// mfbac = rho * c1o3 * (mfbac) + 0.5 * forcingTerm[TS]; +// mfccc = rho * c1o3 * (mfccc) + 0.5 * forcingTerm[TNE]; +// mfacc = rho * c1o3 * (mfacc) + 0.5 * forcingTerm[TNW]; +// mfcac = rho * c1o3 * (mfcac) + 0.5 * forcingTerm[TSE]; +// mfaac = rho * c1o3 * (mfaac) + 0.5 * forcingTerm[TSW]; +// mfabb = rho * c1o3 * (mfabb) + 0.5 * forcingTerm[W]; +// mfbab = rho * c1o3 * (mfbab) + 0.5 * forcingTerm[S]; +// mfbba = rho * c1o3 * (mfbba) + 0.5 * forcingTerm[B]; +// mfaab = rho * c1o3 * (mfaab) + 0.5 * forcingTerm[SW]; +// mfcab = rho * c1o3 * (mfcab) + 0.5 * forcingTerm[SE]; +// mfaba = rho * c1o3 * (mfaba) + 0.5 * forcingTerm[BW]; +// mfcba = rho * c1o3 * (mfcba) + 0.5 * forcingTerm[BE]; +// mfbaa = rho * c1o3 * (mfbaa) + 0.5 * forcingTerm[BS]; +// mfbca = rho * c1o3 * (mfbca) + 0.5 * forcingTerm[BN]; +// mfaaa = rho * c1o3 * (mfaaa) + 0.5 * forcingTerm[BSW]; +// mfcaa = rho * c1o3 * (mfcaa) + 0.5 * forcingTerm[BSE]; +// mfaca = rho * c1o3 * (mfaca) + 0.5 * forcingTerm[BNW]; +// mfcca = rho * c1o3 * (mfcca) + 0.5 * forcingTerm[BNE]; +// mfbbb = rho * c1o3 * (mfbbb) + 0.5 * forcingTerm[REST]; +// +// ////////////////////////////////////////////////////////////////////////// +// // write distribution for F +// ////////////////////////////////////////////////////////////////////////// +// +// (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3) = mfabb; +// (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3) = mfbab; +// (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3) = mfbba; +// (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3) = mfaab; +// (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab; +// (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3) = mfaba; +// (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba; +// (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa; +// (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca; +// (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa; +// (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa; +// (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca; +// (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca; +// +// (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3) = mfcbb; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3) = mfbcb; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3) = mfccb; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3) = mfacb; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac; +// +// (*this->zeroDistributionsF)(x1, x2, x3) = mfbbb; +// !Old Kernel + ///////////////////// P H A S E - F I E L D S O L V E R + //////////////////////////////////////////// + /////CUMULANT PHASE-FIELD + LBMReal omegaD =1.0/( 3.0 * mob + 0.5); + { + mfcbb = (*this->localDistributionsH1)(D3Q27System::ET_E, x1, x2, x3); + mfbcb = (*this->localDistributionsH1)(D3Q27System::ET_N, x1, x2, x3); + mfbbc = (*this->localDistributionsH1)(D3Q27System::ET_T, x1, x2, x3); + mfccb = (*this->localDistributionsH1)(D3Q27System::ET_NE, x1, x2, x3); + mfacb = (*this->localDistributionsH1)(D3Q27System::ET_NW, x1p, x2, x3); + mfcbc = (*this->localDistributionsH1)(D3Q27System::ET_TE, x1, x2, x3); + mfabc = (*this->localDistributionsH1)(D3Q27System::ET_TW, x1p, x2, x3); + mfbcc = (*this->localDistributionsH1)(D3Q27System::ET_TN, x1, x2, x3); + mfbac = (*this->localDistributionsH1)(D3Q27System::ET_TS, x1, x2p, x3); + mfccc = (*this->localDistributionsH1)(D3Q27System::ET_TNE, x1, x2, x3); + mfacc = (*this->localDistributionsH1)(D3Q27System::ET_TNW, x1p, x2, x3); + mfcac = (*this->localDistributionsH1)(D3Q27System::ET_TSE, x1, x2p, x3); + mfaac = (*this->localDistributionsH1)(D3Q27System::ET_TSW, x1p, x2p, x3); + mfabb = (*this->nonLocalDistributionsH1)(D3Q27System::ET_W, x1p, x2, x3); + mfbab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_S, x1, x2p, x3); + mfbba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_B, x1, x2, x3p); + mfaab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SW, x1p, x2p, x3); + mfcab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SE, x1, x2p, x3); + mfaba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BW, x1p, x2, x3p); + mfcba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BE, x1, x2, x3p); + mfbaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BS, x1, x2p, x3p); + mfbca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BN, x1, x2, x3p); + mfaaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSW, x1p, x2p, x3p); + mfcaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSE, x1, x2p, x3p); + mfaca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNW, x1p, x2, x3p); + mfcca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNE, x1, x2, x3p); + mfbbb = (*this->zeroDistributionsH1)(x1, x2, x3); + + + //////////////////////////////////////////////////////////////////////////////////// + //! - Calculate density and velocity using pyramid summation for low round-off errors as in Eq. (J1)-(J3) \ref + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! + //////////////////////////////////////////////////////////////////////////////////// + // fluid component + //LBMReal drhoFluid = + // ((((fccc + faaa) + (faca + fcac)) + ((facc + fcaa) + (faac + fcca))) + + // (((fbac + fbca) + (fbaa + fbcc)) + ((fabc + fcba) + (faba + fcbc)) + ((facb + fcab) + (faab + fccb))) + + // ((fabb + fcbb) + (fbab + fbcb) + (fbba + fbbc))) + fbbb; + + //LBMReal rhoFluid = c1 + drhoFluid; + //LBMReal OOrhoFluid = c1 / rhoFluid; + + + //LBMReal vvx = + // ((((fccc - faaa) + (fcac - faca)) + ((fcaa - facc) + (fcca - faac))) + + // (((fcba - fabc) + (fcbc - faba)) + ((fcab - facb) + (fccb - faab))) + + // (fcbb - fabb)) * OOrhoFluid; + //LBMReal vvy = + // ((((fccc - faaa) + (faca - fcac)) + ((facc - fcaa) + (fcca - faac))) + + // (((fbca - fbac) + (fbcc - fbaa)) + ((facb - fcab) + (fccb - faab))) + + // (fbcb - fbab)) * OOrhoFluid; + //LBMReal vvz = + // ((((fccc - faaa) + (fcac - faca)) + ((facc - fcaa) + (faac - fcca))) + + // (((fbac - fbca) + (fbcc - fbaa)) + ((fabc - fcba) + (fcbc - faba))) + + // (fbbc - fbba)) * OOrhoFluid; + + // LBMReal vvx = ux; + // LBMReal vvy = uy; + // LBMReal vvz = uz; + //////////////////////////////////////////////////////////////////////////////////// + // second component + LBMReal concentration = + ((((mfccc + mfaaa) + (mfaca + mfcac)) + ((mfacc + mfcaa) + (mfaac + mfcca))) + + (((mfbac + mfbca) + (mfbaa + mfbcc)) + ((mfabc + mfcba) + (mfaba + mfcbc)) + ((mfacb + mfcab) + (mfaab + mfccb))) + + ((mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc))) + mfbbb; + //////////////////////////////////////////////////////////////////////////////////// + //! - Add half of the acceleration (body force) to the velocity as in Eq. (42) \ref + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! + // LBMReal fx = forces[0]; + // LBMReal fy = forces[1]; + // LBMReal fz = -concentration * forces[2]; + // vvx += fx * c1o2; + // vvy += fy * c1o2; + // vvz += fz * c1o2; + //////////////////////////////////////////////////////////////////////////////////// + LBMReal oneMinusRho = c1- concentration; + + LBMReal cx = + ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + + (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + + (mfcbb - mfabb)); + LBMReal cy = + ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + + (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + + (mfbcb - mfbab)); + LBMReal cz = + ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + + (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + + (mfbbc - mfbba)); + + //////////////////////////////////////////////////////////////////////////////////// + // calculate the square of velocities for this lattice node + LBMReal cx2 = cx * cx; + LBMReal cy2 = cy * cy; + LBMReal cz2 = cz * cz; + //////////////////////////////////////////////////////////////////////////////////// + //! - Chimera transform from well conditioned distributions to central moments as defined in Appendix J in \ref + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! see also Eq. (6)-(14) in \ref + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + forwardInverseChimeraWithKincompressible(mfaaa, mfaab, mfaac, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfaba, mfabb, mfabc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfaca, mfacb, mfacc, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbaa, mfbab, mfbac, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbba, mfbbb, mfbbc, cz, cz2, c9o4, c4o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbca, mfbcb, mfbcc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcaa, mfcab, mfcac, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcba, mfcbb, mfcbc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcca, mfccb, mfccc, cz, cz2, c36, c1o36, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + forwardInverseChimeraWithKincompressible(mfaaa, mfaba, mfaca, cy, cy2, c6, c1o6, oneMinusRho); + forwardChimera(mfaab, mfabb, mfacb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfaac, mfabc, mfacc, cy, cy2, c18, c1o18, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbaa, mfbba, mfbca, cy, cy2, c3o2, c2o3, oneMinusRho); + forwardChimera(mfbab, mfbbb, mfbcb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfbac, mfbbc, mfbcc, cy, cy2, c9o2, c2o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcaa, mfcba, mfcca, cy, cy2, c6, c1o6, oneMinusRho); + forwardChimera(mfcab, mfcbb, mfccb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfcac, mfcbc, mfccc, cy, cy2, c18, c1o18, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + forwardInverseChimeraWithKincompressible(mfaaa, mfbaa, mfcaa, cx, cx2, c1, c1, oneMinusRho); + forwardChimera(mfaba, mfbba, mfcba, cx, cx2); + forwardInverseChimeraWithKincompressible(mfaca, mfbca, mfcca, cx, cx2, c3, c1o3, oneMinusRho); + forwardChimera(mfaab, mfbab, mfcab, cx, cx2); + forwardChimera(mfabb, mfbbb, mfcbb, cx, cx2); + forwardChimera(mfacb, mfbcb, mfccb, cx, cx2); + forwardInverseChimeraWithKincompressible(mfaac, mfbac, mfcac, cx, cx2, c3, c1o3, oneMinusRho); + forwardChimera(mfabc, mfbbc, mfcbc, cx, cx2); + forwardInverseChimeraWithKincompressible(mfacc, mfbcc, mfccc, cx, cx2, c3, c1o9, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + //! - experimental Cumulant ... to be published ... hopefully + //! + + // linearized orthogonalization of 3rd order central moments + LBMReal Mabc = mfabc - mfaba * c1o3; + LBMReal Mbca = mfbca - mfbaa * c1o3; + LBMReal Macb = mfacb - mfaab * c1o3; + LBMReal Mcba = mfcba - mfaba * c1o3; + LBMReal Mcab = mfcab - mfaab * c1o3; + LBMReal Mbac = mfbac - mfbaa * c1o3; + // linearized orthogonalization of 5th order central moments + LBMReal Mcbc = mfcbc - mfaba * c1o9; + LBMReal Mbcc = mfbcc - mfbaa * c1o9; + LBMReal Mccb = mfccb - mfaab * c1o9; + + // collision of 1st order moments + // LBMReal ccx, ccy, ccz; + + + cx = cx * (c1 - omegaD) + omegaD * vvx * concentration + + normX1 * (c1 - 0.5 * omegaD) * (1.0 - phi[REST]) * (phi[REST]) * c1o3 * oneOverInterfaceScale; + cy = cy * (c1 - omegaD) + omegaD * vvy * concentration + + normX2 * (c1 - 0.5 * omegaD) * (1.0 - phi[REST]) * (phi[REST]) * c1o3 * oneOverInterfaceScale; + cz = cz * (c1 - omegaD) + omegaD * vvz * concentration + + normX3 * (c1 - 0.5 * omegaD) * (1.0 - phi[REST]) * (phi[REST]) * c1o3 * oneOverInterfaceScale; + + //cx = cx * (c1 - omegaD) + omegaD * vvx * concentration + + // normX1 * (c1 - 0.5 * omegaD) * (1.0 - phi[REST]) * (phi[REST])*(phi[REST]+phi2[REST]) * c1o3 * oneOverInterfaceScale; + //cy = cy * (c1 - omegaD) + omegaD * vvy * concentration + + // normX2 * (c1 - 0.5 * omegaD) * (1.0 - phi[REST]) * (phi[REST]) * (phi[REST] + phi2[REST]) * c1o3 * oneOverInterfaceScale; + //cz = cz * (c1 - omegaD) + omegaD * vvz * concentration + + // normX3 * (c1 - 0.5 * omegaD) * (1.0 - phi[REST]) * (phi[REST]) * (phi[REST] + phi2[REST]) * c1o3 * oneOverInterfaceScale; + + //mhx = (ux * phi[REST] + normX1 * (tauH - 0.5) * (1.0 - phi[REST]) * (phi[REST])) / tauH + (1.0 - 1.0 / tauH) * mhx; + //mhy = (uy * phi[REST] + normX2 * (tauH - 0.5) * (1.0 - phi[REST]) * (phi[REST])) / tauH + (1.0 - 1.0 / tauH) * mhy; + //mhz = (uz * phi[REST] + normX3 * (tauH - 0.5) * (1.0 - phi[REST]) * (phi[REST])) / tauH + (1.0 - 1.0 / tauH) * mhz; + + + cx2 = cx * cx; + cy2 = cy * cy; + cz2 = cz * cz; + + // equilibration of 2nd order moments + mfbba = zeroReal; + mfbab = zeroReal; + mfabb = zeroReal; + + mfcaa = c1o3 * concentration; + mfaca = c1o3 * concentration; + mfaac = c1o3 * concentration; + + + //LBMReal omega2 = 1.0f;// omegaD; + //mfbba *= (c1 - omega2); + //mfbab *= (c1 - omega2); + //mfabb *= (c1 - omega2); + + //mfcaa = mfcaa*(c1 - omega2) + omega2*c1o3 * concentration; + //mfaca = mfaca*(c1 - omega2) + omega2*c1o3 * concentration; + //mfaac = mfaac*(c1 - omega2) + omega2*c1o3 * concentration; + + // equilibration of 3rd order moments + Mabc = zeroReal; + Mbca = zeroReal; + Macb = zeroReal; + Mcba = zeroReal; + Mcab = zeroReal; + Mbac = zeroReal; + mfbbb = zeroReal; + + // from linearized orthogonalization 3rd order central moments to central moments + mfabc = Mabc + mfaba * c1o3; + mfbca = Mbca + mfbaa * c1o3; + mfacb = Macb + mfaab * c1o3; + mfcba = Mcba + mfaba * c1o3; + mfcab = Mcab + mfaab * c1o3; + mfbac = Mbac + mfbaa * c1o3; + + // equilibration of 4th order moments + mfacc = c1o9 * concentration; + mfcac = c1o9 * concentration; + mfcca = c1o9 * concentration; + + mfcbb = zeroReal; + mfbcb = zeroReal; + mfbbc = zeroReal; + + // equilibration of 5th order moments + Mcbc = zeroReal; + Mbcc = zeroReal; + Mccb = zeroReal; + + // from linearized orthogonalization 5th order central moments to central moments + mfcbc = Mcbc + mfaba * c1o9; + mfbcc = Mbcc + mfbaa * c1o9; + mfccb = Mccb + mfaab * c1o9; + + // equilibration of 6th order moment + mfccc = c1o27 * concentration; + + //////////////////////////////////////////////////////////////////////////////////// + //! - Chimera transform from central moments to well conditioned distributions as defined in Appendix J in + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! see also Eq. (88)-(96) in + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + backwardInverseChimeraWithKincompressible(mfaaa, mfbaa, mfcaa, cx, cx2, c1, c1, oneMinusRho); + backwardChimera(mfaba, mfbba, mfcba, cx, cx2); + backwardInverseChimeraWithKincompressible(mfaca, mfbca, mfcca, cx, cx2, c3, c1o3, oneMinusRho); + backwardChimera(mfaab, mfbab, mfcab, cx, cx2); + backwardChimera(mfabb, mfbbb, mfcbb, cx, cx2); + backwardChimera(mfacb, mfbcb, mfccb, cx, cx2); + backwardInverseChimeraWithKincompressible(mfaac, mfbac, mfcac, cx, cx2, c3, c1o3, oneMinusRho); + backwardChimera(mfabc, mfbbc, mfcbc, cx, cx2); + backwardInverseChimeraWithKincompressible(mfacc, mfbcc, mfccc, cx, cx2, c9, c1o9, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + backwardInverseChimeraWithKincompressible(mfaaa, mfaba, mfaca, cy, cy2, c6, c1o6, oneMinusRho); + backwardChimera(mfaab, mfabb, mfacb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfaac, mfabc, mfacc, cy, cy2, c18, c1o18, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbaa, mfbba, mfbca, cy, cy2, c3o2, c2o3, oneMinusRho); + backwardChimera(mfbab, mfbbb, mfbcb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfbac, mfbbc, mfbcc, cy, cy2, c9o2, c2o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcaa, mfcba, mfcca, cy, cy2, c6, c1o6, oneMinusRho); + backwardChimera(mfcab, mfcbb, mfccb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfcac, mfcbc, mfccc, cy, cy2, c18, c1o18, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + backwardInverseChimeraWithKincompressible(mfaaa, mfaab, mfaac, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfaba, mfabb, mfabc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfaca, mfacb, mfacc, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbaa, mfbab, mfbac, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbba, mfbbb, mfbbc, cz, cz2, c9o4, c4o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbca, mfbcb, mfbcc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcaa, mfcab, mfcac, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcba, mfcbb, mfcbc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcca, mfccb, mfccc, cz, cz2, c36, c1o36, oneMinusRho); + + + + (*this->localDistributionsH1)(D3Q27System::ET_E, x1, x2, x3) = mfabb; + (*this->localDistributionsH1)(D3Q27System::ET_N, x1, x2, x3) = mfbab; + (*this->localDistributionsH1)(D3Q27System::ET_T, x1, x2, x3) = mfbba; + (*this->localDistributionsH1)(D3Q27System::ET_NE, x1, x2, x3) = mfaab; + (*this->localDistributionsH1)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab; + (*this->localDistributionsH1)(D3Q27System::ET_TE, x1, x2, x3) = mfaba; + (*this->localDistributionsH1)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba; + (*this->localDistributionsH1)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa; + (*this->localDistributionsH1)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca; + (*this->localDistributionsH1)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa; + (*this->localDistributionsH1)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa; + (*this->localDistributionsH1)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca; + (*this->localDistributionsH1)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca; + + (*this->nonLocalDistributionsH1)(D3Q27System::ET_W, x1p, x2, x3 ) = mfcbb; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_S, x1, x2p, x3 ) = mfbcb; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_SW, x1p, x2p, x3 ) = mfccb; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_SE, x1, x2p, x3 ) = mfacb; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac; + + (*this->zeroDistributionsH1)(x1,x2,x3) = mfbbb; + } + + ////Phasefield 2: + + { + + normX1 *= -1; + normX2 *= -1; + normX3 *= -1; + + mfcbb = (*this->localDistributionsH2)(D3Q27System::ET_E, x1, x2, x3); + mfbcb = (*this->localDistributionsH2)(D3Q27System::ET_N, x1, x2, x3); + mfbbc = (*this->localDistributionsH2)(D3Q27System::ET_T, x1, x2, x3); + mfccb = (*this->localDistributionsH2)(D3Q27System::ET_NE, x1, x2, x3); + mfacb = (*this->localDistributionsH2)(D3Q27System::ET_NW, x1p, x2, x3); + mfcbc = (*this->localDistributionsH2)(D3Q27System::ET_TE, x1, x2, x3); + mfabc = (*this->localDistributionsH2)(D3Q27System::ET_TW, x1p, x2, x3); + mfbcc = (*this->localDistributionsH2)(D3Q27System::ET_TN, x1, x2, x3); + mfbac = (*this->localDistributionsH2)(D3Q27System::ET_TS, x1, x2p, x3); + mfccc = (*this->localDistributionsH2)(D3Q27System::ET_TNE, x1, x2, x3); + mfacc = (*this->localDistributionsH2)(D3Q27System::ET_TNW, x1p, x2, x3); + mfcac = (*this->localDistributionsH2)(D3Q27System::ET_TSE, x1, x2p, x3); + mfaac = (*this->localDistributionsH2)(D3Q27System::ET_TSW, x1p, x2p, x3); + mfabb = (*this->nonLocalDistributionsH2)(D3Q27System::ET_W, x1p, x2, x3); + mfbab = (*this->nonLocalDistributionsH2)(D3Q27System::ET_S, x1, x2p, x3); + mfbba = (*this->nonLocalDistributionsH2)(D3Q27System::ET_B, x1, x2, x3p); + mfaab = (*this->nonLocalDistributionsH2)(D3Q27System::ET_SW, x1p, x2p, x3); + mfcab = (*this->nonLocalDistributionsH2)(D3Q27System::ET_SE, x1, x2p, x3); + mfaba = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BW, x1p, x2, x3p); + mfcba = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BE, x1, x2, x3p); + mfbaa = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BS, x1, x2p, x3p); + mfbca = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BN, x1, x2, x3p); + mfaaa = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BSW, x1p, x2p, x3p); + mfcaa = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BSE, x1, x2p, x3p); + mfaca = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BNW, x1p, x2, x3p); + mfcca = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BNE, x1, x2, x3p); + mfbbb = (*this->zeroDistributionsH2)(x1, x2, x3); + + + //////////////////////////////////////////////////////////////////////////////////// +//! - Calculate density and velocity using pyramid summation for low round-off errors as in Eq. (J1)-(J3) \ref +//! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> +//! +//////////////////////////////////////////////////////////////////////////////////// +// fluid component + //LBMReal drhoFluid = + // ((((fccc + faaa) + (faca + fcac)) + ((facc + fcaa) + (faac + fcca))) + + // (((fbac + fbca) + (fbaa + fbcc)) + ((fabc + fcba) + (faba + fcbc)) + ((facb + fcab) + (faab + fccb))) + + // ((fabb + fcbb) + (fbab + fbcb) + (fbba + fbbc))) + fbbb; + + //LBMReal rhoFluid = c1 + drhoFluid; + //LBMReal OOrhoFluid = c1 / rhoFluid; + + + //LBMReal vvx = + // ((((fccc - faaa) + (fcac - faca)) + ((fcaa - facc) + (fcca - faac))) + + // (((fcba - fabc) + (fcbc - faba)) + ((fcab - facb) + (fccb - faab))) + + // (fcbb - fabb)) * OOrhoFluid; + //LBMReal vvy = + // ((((fccc - faaa) + (faca - fcac)) + ((facc - fcaa) + (fcca - faac))) + + // (((fbca - fbac) + (fbcc - fbaa)) + ((facb - fcab) + (fccb - faab))) + + // (fbcb - fbab)) * OOrhoFluid; + //LBMReal vvz = + // ((((fccc - faaa) + (fcac - faca)) + ((facc - fcaa) + (faac - fcca))) + + // (((fbac - fbca) + (fbcc - fbaa)) + ((fabc - fcba) + (fcbc - faba))) + + // (fbbc - fbba)) * OOrhoFluid; + + // LBMReal vvx = ux; + // LBMReal vvy = uy; + // LBMReal vvz = uz; + //////////////////////////////////////////////////////////////////////////////////// + // second component + LBMReal concentration = + ((((mfccc + mfaaa) + (mfaca + mfcac)) + ((mfacc + mfcaa) + (mfaac + mfcca))) + + (((mfbac + mfbca) + (mfbaa + mfbcc)) + ((mfabc + mfcba) + (mfaba + mfcbc)) + ((mfacb + mfcab) + (mfaab + mfccb))) + + ((mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc))) + mfbbb; + //////////////////////////////////////////////////////////////////////////////////// + //! - Add half of the acceleration (body force) to the velocity as in Eq. (42) \ref + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! + // LBMReal fx = forces[0]; + // LBMReal fy = forces[1]; + // LBMReal fz = -concentration * forces[2]; + // vvx += fx * c1o2; + // vvy += fy * c1o2; + // vvz += fz * c1o2; + //////////////////////////////////////////////////////////////////////////////////// + LBMReal oneMinusRho = c1 - concentration; + + LBMReal cx = + ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + + (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + + (mfcbb - mfabb)); + LBMReal cy = + ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + + (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + + (mfbcb - mfbab)); + LBMReal cz = + ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + + (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + + (mfbbc - mfbba)); + + //////////////////////////////////////////////////////////////////////////////////// + // calculate the square of velocities for this lattice node + LBMReal cx2 = cx * cx; + LBMReal cy2 = cy * cy; + LBMReal cz2 = cz * cz; + //////////////////////////////////////////////////////////////////////////////////// + //! - Chimera transform from well conditioned distributions to central moments as defined in Appendix J in \ref + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! see also Eq. (6)-(14) in \ref + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + forwardInverseChimeraWithKincompressible(mfaaa, mfaab, mfaac, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfaba, mfabb, mfabc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfaca, mfacb, mfacc, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbaa, mfbab, mfbac, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbba, mfbbb, mfbbc, cz, cz2, c9o4, c4o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbca, mfbcb, mfbcc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcaa, mfcab, mfcac, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcba, mfcbb, mfcbc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcca, mfccb, mfccc, cz, cz2, c36, c1o36, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + forwardInverseChimeraWithKincompressible(mfaaa, mfaba, mfaca, cy, cy2, c6, c1o6, oneMinusRho); + forwardChimera(mfaab, mfabb, mfacb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfaac, mfabc, mfacc, cy, cy2, c18, c1o18, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbaa, mfbba, mfbca, cy, cy2, c3o2, c2o3, oneMinusRho); + forwardChimera(mfbab, mfbbb, mfbcb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfbac, mfbbc, mfbcc, cy, cy2, c9o2, c2o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcaa, mfcba, mfcca, cy, cy2, c6, c1o6, oneMinusRho); + forwardChimera(mfcab, mfcbb, mfccb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfcac, mfcbc, mfccc, cy, cy2, c18, c1o18, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + forwardInverseChimeraWithKincompressible(mfaaa, mfbaa, mfcaa, cx, cx2, c1, c1, oneMinusRho); + forwardChimera(mfaba, mfbba, mfcba, cx, cx2); + forwardInverseChimeraWithKincompressible(mfaca, mfbca, mfcca, cx, cx2, c3, c1o3, oneMinusRho); + forwardChimera(mfaab, mfbab, mfcab, cx, cx2); + forwardChimera(mfabb, mfbbb, mfcbb, cx, cx2); + forwardChimera(mfacb, mfbcb, mfccb, cx, cx2); + forwardInverseChimeraWithKincompressible(mfaac, mfbac, mfcac, cx, cx2, c3, c1o3, oneMinusRho); + forwardChimera(mfabc, mfbbc, mfcbc, cx, cx2); + forwardInverseChimeraWithKincompressible(mfacc, mfbcc, mfccc, cx, cx2, c3, c1o9, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + //! - experimental Cumulant ... to be published ... hopefully + //! + + // linearized orthogonalization of 3rd order central moments + LBMReal Mabc = mfabc - mfaba * c1o3; + LBMReal Mbca = mfbca - mfbaa * c1o3; + LBMReal Macb = mfacb - mfaab * c1o3; + LBMReal Mcba = mfcba - mfaba * c1o3; + LBMReal Mcab = mfcab - mfaab * c1o3; + LBMReal Mbac = mfbac - mfbaa * c1o3; + // linearized orthogonalization of 5th order central moments + LBMReal Mcbc = mfcbc - mfaba * c1o9; + LBMReal Mbcc = mfbcc - mfbaa * c1o9; + LBMReal Mccb = mfccb - mfaab * c1o9; + + // collision of 1st order moments + cx = cx * (c1 - omegaD) + omegaD * vvx * concentration + + normX1 * (c1 - 0.5 * omegaD) * ( phi[REST]) * (phi2[REST]) * c1o3 * oneOverInterfaceScale; + cy = cy * (c1 - omegaD) + omegaD * vvy * concentration + + normX2 * (c1 - 0.5 * omegaD) * ( phi[REST]) * (phi2[REST]) * c1o3 * oneOverInterfaceScale; + cz = cz * (c1 - omegaD) + omegaD * vvz * concentration + + normX3 * (c1 - 0.5 * omegaD) * ( phi[REST]) * (phi2[REST]) * c1o3 * oneOverInterfaceScale; + + //mhx = (ux * phi[REST] + normX1 * (tauH - 0.5) * (1.0 - phi[REST]) * (phi[REST])) / tauH + (1.0 - 1.0 / tauH) * mhx; + //mhy = (uy * phi[REST] + normX2 * (tauH - 0.5) * (1.0 - phi[REST]) * (phi[REST])) / tauH + (1.0 - 1.0 / tauH) * mhy; +//mhz = (uz * phi[REST] + normX3 * (tauH - 0.5) * (1.0 - phi[REST]) * (phi[REST])) / tauH + (1.0 - 1.0 / tauH) * mhz; + + + cx2 = cx * cx; + cy2 = cy * cy; + cz2 = cz * cz; + + // equilibration of 2nd order moments + mfbba = zeroReal; + mfbab = zeroReal; + mfabb = zeroReal; + + mfcaa = c1o3 * concentration; + mfaca = c1o3 * concentration; + mfaac = c1o3 * concentration; + + + //LBMReal omega2 = 1.0f;// omegaD; + //mfbba *= (c1 - omega2); + //mfbab *= (c1 - omega2); + //mfabb *= (c1 - omega2); + + //mfcaa = mfcaa*(c1 - omega2) + omega2*c1o3 * concentration; + //mfaca = mfaca*(c1 - omega2) + omega2*c1o3 * concentration; + //mfaac = mfaac*(c1 - omega2) + omega2*c1o3 * concentration; + + // equilibration of 3rd order moments + Mabc = zeroReal; + Mbca = zeroReal; + Macb = zeroReal; + Mcba = zeroReal; + Mcab = zeroReal; + Mbac = zeroReal; + mfbbb = zeroReal; + + // from linearized orthogonalization 3rd order central moments to central moments + mfabc = Mabc + mfaba * c1o3; + mfbca = Mbca + mfbaa * c1o3; + mfacb = Macb + mfaab * c1o3; + mfcba = Mcba + mfaba * c1o3; + mfcab = Mcab + mfaab * c1o3; + mfbac = Mbac + mfbaa * c1o3; + + // equilibration of 4th order moments + mfacc = c1o9 * concentration; + mfcac = c1o9 * concentration; + mfcca = c1o9 * concentration; + + mfcbb = zeroReal; + mfbcb = zeroReal; + mfbbc = zeroReal; + + // equilibration of 5th order moments + Mcbc = zeroReal; + Mbcc = zeroReal; + Mccb = zeroReal; + + // from linearized orthogonalization 5th order central moments to central moments + mfcbc = Mcbc + mfaba * c1o9; + mfbcc = Mbcc + mfbaa * c1o9; + mfccb = Mccb + mfaab * c1o9; + + // equilibration of 6th order moment + mfccc = c1o27 * concentration; + + //////////////////////////////////////////////////////////////////////////////////// + //! - Chimera transform from central moments to well conditioned distributions as defined in Appendix J in + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! see also Eq. (88)-(96) in + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + backwardInverseChimeraWithKincompressible(mfaaa, mfbaa, mfcaa, cx, cx2, c1, c1, oneMinusRho); + backwardChimera(mfaba, mfbba, mfcba, cx, cx2); + backwardInverseChimeraWithKincompressible(mfaca, mfbca, mfcca, cx, cx2, c3, c1o3, oneMinusRho); + backwardChimera(mfaab, mfbab, mfcab, cx, cx2); + backwardChimera(mfabb, mfbbb, mfcbb, cx, cx2); + backwardChimera(mfacb, mfbcb, mfccb, cx, cx2); + backwardInverseChimeraWithKincompressible(mfaac, mfbac, mfcac, cx, cx2, c3, c1o3, oneMinusRho); + backwardChimera(mfabc, mfbbc, mfcbc, cx, cx2); + backwardInverseChimeraWithKincompressible(mfacc, mfbcc, mfccc, cx, cx2, c9, c1o9, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + backwardInverseChimeraWithKincompressible(mfaaa, mfaba, mfaca, cy, cy2, c6, c1o6, oneMinusRho); + backwardChimera(mfaab, mfabb, mfacb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfaac, mfabc, mfacc, cy, cy2, c18, c1o18, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbaa, mfbba, mfbca, cy, cy2, c3o2, c2o3, oneMinusRho); + backwardChimera(mfbab, mfbbb, mfbcb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfbac, mfbbc, mfbcc, cy, cy2, c9o2, c2o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcaa, mfcba, mfcca, cy, cy2, c6, c1o6, oneMinusRho); + backwardChimera(mfcab, mfcbb, mfccb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfcac, mfcbc, mfccc, cy, cy2, c18, c1o18, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + backwardInverseChimeraWithKincompressible(mfaaa, mfaab, mfaac, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfaba, mfabb, mfabc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfaca, mfacb, mfacc, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbaa, mfbab, mfbac, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbba, mfbbb, mfbbc, cz, cz2, c9o4, c4o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbca, mfbcb, mfbcc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcaa, mfcab, mfcac, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcba, mfcbb, mfcbc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcca, mfccb, mfccc, cz, cz2, c36, c1o36, oneMinusRho); + + + + (*this->localDistributionsH2)(D3Q27System::ET_E, x1, x2, x3) = mfabb; + (*this->localDistributionsH2)(D3Q27System::ET_N, x1, x2, x3) = mfbab; + (*this->localDistributionsH2)(D3Q27System::ET_T, x1, x2, x3) = mfbba; + (*this->localDistributionsH2)(D3Q27System::ET_NE, x1, x2, x3) = mfaab; + (*this->localDistributionsH2)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab; + (*this->localDistributionsH2)(D3Q27System::ET_TE, x1, x2, x3) = mfaba; + (*this->localDistributionsH2)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba; + (*this->localDistributionsH2)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa; + (*this->localDistributionsH2)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca; + (*this->localDistributionsH2)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa; + (*this->localDistributionsH2)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa; + (*this->localDistributionsH2)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca; + (*this->localDistributionsH2)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca; + + (*this->nonLocalDistributionsH2)(D3Q27System::ET_W, x1p, x2, x3) = mfcbb; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_S, x1, x2p, x3) = mfbcb; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_SW, x1p, x2p, x3) = mfccb; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_SE, x1, x2p, x3) = mfacb; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac; + + (*this->zeroDistributionsH2)(x1, x2, x3) = mfbbb; + + } + + + + /////!CUMULANT PHASE-FIELD + + + + ///////////////////// PHASE-FIELD BGK SOLVER /////////////////////////////// + + //h[E] = (*this->localDistributionsH)(D3Q27System::ET_E, x1, x2, x3); + //h[N] = (*this->localDistributionsH)(D3Q27System::ET_N, x1, x2, x3); + //h[T] = (*this->localDistributionsH)(D3Q27System::ET_T, x1, x2, x3); + //h[NE] = (*this->localDistributionsH)(D3Q27System::ET_NE, x1, x2, x3); + //h[NW] = (*this->localDistributionsH)(D3Q27System::ET_NW, x1p, x2, x3); + //h[TE] = (*this->localDistributionsH)(D3Q27System::ET_TE, x1, x2, x3); + //h[TW] = (*this->localDistributionsH)(D3Q27System::ET_TW, x1p, x2, x3); + //h[TN] = (*this->localDistributionsH)(D3Q27System::ET_TN, x1, x2, x3); + //h[TS] = (*this->localDistributionsH)(D3Q27System::ET_TS, x1, x2p, x3); + //h[TNE] = (*this->localDistributionsH)(D3Q27System::ET_TNE, x1, x2, x3); + //h[TNW] = (*this->localDistributionsH)(D3Q27System::ET_TNW, x1p, x2, x3); + //h[TSE] = (*this->localDistributionsH)(D3Q27System::ET_TSE, x1, x2p, x3); + //h[TSW] = (*this->localDistributionsH)(D3Q27System::ET_TSW, x1p, x2p, x3); + + //h[W] = (*this->nonLocalDistributionsH)(D3Q27System::ET_W, x1p, x2, x3); + //h[S] = (*this->nonLocalDistributionsH)(D3Q27System::ET_S, x1, x2p, x3); + //h[B] = (*this->nonLocalDistributionsH)(D3Q27System::ET_B, x1, x2, x3p); + //h[SW] = (*this->nonLocalDistributionsH)(D3Q27System::ET_SW, x1p, x2p, x3); + //h[SE] = (*this->nonLocalDistributionsH)(D3Q27System::ET_SE, x1, x2p, x3); + //h[BW] = (*this->nonLocalDistributionsH)(D3Q27System::ET_BW, x1p, x2, x3p); + //h[BE] = (*this->nonLocalDistributionsH)(D3Q27System::ET_BE, x1, x2, x3p); + //h[BS] = (*this->nonLocalDistributionsH)(D3Q27System::ET_BS, x1, x2p, x3p); + //h[BN] = (*this->nonLocalDistributionsH)(D3Q27System::ET_BN, x1, x2, x3p); + //h[BSW] = (*this->nonLocalDistributionsH)(D3Q27System::ET_BSW, x1p, x2p, x3p); + //h[BSE] = (*this->nonLocalDistributionsH)(D3Q27System::ET_BSE, x1, x2p, x3p); + //h[BNW] = (*this->nonLocalDistributionsH)(D3Q27System::ET_BNW, x1p, x2, x3p); + //h[BNE] = (*this->nonLocalDistributionsH)(D3Q27System::ET_BNE, x1, x2, x3p); + + //h[REST] = (*this->zeroDistributionsH)(x1, x2, x3); + + //for (int dir = STARTF; dir < (ENDF + 1); dir++) { + // LBMReal velProd = DX1[dir] * ux + DX2[dir] * uy + DX3[dir] * uz; + // LBMReal velSq1 = velProd * velProd; + // LBMReal hEq; //, gEq; + + // if (dir != REST) { + // LBMReal dirGrad_phi = (phi[dir] - phi[INVDIR[dir]]) / 2.0; + // LBMReal hSource = (tauH - 0.5) * (1.0 - phi[REST]) * (phi[REST]) * (dirGrad_phi) / denom; + // hEq = phi[REST] * WEIGTH[dir] * (1.0 + 3.0 * velProd + 4.5 * velSq1 - 1.5 * (ux2 + uy2 + uz2)) + hSource * WEIGTH[dir]; + + // // This corresponds with the collision factor of 1.0 which equals (tauH + 0.5). + // h[dir] = h[dir] - (h[dir] - hEq) / (tauH); + + // } else { + // hEq = phi[REST] * WEIGTH[REST] * (1.0 - 1.5 * (ux2 + uy2 + uz2)); + // h[REST] = h[REST] - (h[REST] - hEq) / (tauH); + // } + //} + + //(*this->localDistributionsH)(D3Q27System::ET_E, x1, x2, x3) = h[D3Q27System::INV_E]; + //(*this->localDistributionsH)(D3Q27System::ET_N, x1, x2, x3) = h[D3Q27System::INV_N]; + //(*this->localDistributionsH)(D3Q27System::ET_T, x1, x2, x3) = h[D3Q27System::INV_T]; + //(*this->localDistributionsH)(D3Q27System::ET_NE, x1, x2, x3) = h[D3Q27System::INV_NE]; + //(*this->localDistributionsH)(D3Q27System::ET_NW, x1p, x2, x3) = h[D3Q27System::INV_NW]; + //(*this->localDistributionsH)(D3Q27System::ET_TE, x1, x2, x3) = h[D3Q27System::INV_TE]; + //(*this->localDistributionsH)(D3Q27System::ET_TW, x1p, x2, x3) = h[D3Q27System::INV_TW]; + //(*this->localDistributionsH)(D3Q27System::ET_TN, x1, x2, x3) = h[D3Q27System::INV_TN]; + //(*this->localDistributionsH)(D3Q27System::ET_TS, x1, x2p, x3) = h[D3Q27System::INV_TS]; + //(*this->localDistributionsH)(D3Q27System::ET_TNE, x1, x2, x3) = h[D3Q27System::INV_TNE]; + //(*this->localDistributionsH)(D3Q27System::ET_TNW, x1p, x2, x3) = h[D3Q27System::INV_TNW]; + //(*this->localDistributionsH)(D3Q27System::ET_TSE, x1, x2p, x3) = h[D3Q27System::INV_TSE]; + //(*this->localDistributionsH)(D3Q27System::ET_TSW, x1p, x2p, x3) = h[D3Q27System::INV_TSW]; + + //(*this->nonLocalDistributionsH)(D3Q27System::ET_W, x1p, x2, x3) = h[D3Q27System::INV_W]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_S, x1, x2p, x3) = h[D3Q27System::INV_S]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_B, x1, x2, x3p) = h[D3Q27System::INV_B]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_SW, x1p, x2p, x3) = h[D3Q27System::INV_SW]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_SE, x1, x2p, x3) = h[D3Q27System::INV_SE]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_BW, x1p, x2, x3p) = h[D3Q27System::INV_BW]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_BE, x1, x2, x3p) = h[D3Q27System::INV_BE]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_BS, x1, x2p, x3p) = h[D3Q27System::INV_BS]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_BN, x1, x2, x3p) = h[D3Q27System::INV_BN]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_BSW, x1p, x2p, x3p) = h[D3Q27System::INV_BSW]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_BSE, x1, x2p, x3p) = h[D3Q27System::INV_BSE]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_BNW, x1p, x2, x3p) = h[D3Q27System::INV_BNW]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_BNE, x1, x2, x3p) = h[D3Q27System::INV_BNE]; + + //(*this->zeroDistributionsH)(x1, x2, x3) = h[D3Q27System::REST]; + + ///////////////////// END OF OLD BGK SOLVER /////////////////////////////// + } + } + } + + // dataSet->setPhaseField(divU); + } +} +////////////////////////////////////////////////////////////////////////// + +LBMReal MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::gradX1_phi() +{ + using namespace D3Q27System; + return 3.0* ((WEIGTH[TNE] * (((phi[TNE] - phi[BSW]) + (phi[BSE] - phi[TNW])) + ((phi[TSE] - phi[BNW]) + (phi[BNE] - phi[TSW]))) + + WEIGTH[NE] * (((phi[TE] - phi[BW]) + (phi[BE] - phi[TW])) + ((phi[SE] - phi[NW]) + (phi[NE] - phi[SW])))) + + +WEIGTH[N] * (phi[E] - phi[W])); + //LBMReal sum = 0.0; + //for (int k = FSTARTDIR; k <= FENDDIR; k++) { + // sum += WEIGTH[k] * DX1[k] * phi[k]; + //} + //return 3.0 * sum; +} + +LBMReal MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::gradX2_phi() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi[TNE] - phi[BSW]) - (phi[BSE] - phi[TNW])) + ((phi[BNE] - phi[TSW])- (phi[TSE] - phi[BNW]))) + + WEIGTH[NE] * (((phi[TN] - phi[BS]) + (phi[BN] - phi[TS])) + ((phi[NE] - phi[SW])- (phi[SE] - phi[NW])))) + + +WEIGTH[N] * (phi[N] - phi[S])); + //LBMReal sum = 0.0; + //for (int k = FSTARTDIR; k <= FENDDIR; k++) { + // sum += WEIGTH[k] * DX2[k] * phi[k]; + //} + //return 3.0 * sum; +} + +LBMReal MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::gradX3_phi() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi[TNE] - phi[BSW]) - (phi[BSE] - phi[TNW])) + ((phi[TSE] - phi[BNW]) - (phi[BNE] - phi[TSW]))) + + WEIGTH[NE] * (((phi[TE] - phi[BW]) - (phi[BE] - phi[TW])) + ((phi[TS] - phi[BN]) + (phi[TN] - phi[BS])))) + + +WEIGTH[N] * (phi[T] - phi[B])); + //LBMReal sum = 0.0; + //for (int k = FSTARTDIR; k <= FENDDIR; k++) { + // sum += WEIGTH[k] * DX3[k] * phi[k]; + //} + //return 3.0 * sum; +} + +LBMReal MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::gradX1_phi2() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi2[TNE] - phi2[BSW]) + (phi2[BSE] - phi2[TNW])) + ((phi2[TSE] - phi2[BNW]) + (phi2[BNE] - phi2[TSW]))) + + WEIGTH[NE] * (((phi2[TE] - phi2[BW]) + (phi2[BE] - phi2[TW])) + ((phi2[SE] - phi2[NW]) + (phi2[NE] - phi2[SW])))) + + +WEIGTH[N] * (phi2[E] - phi2[W])); + //LBMReal sum = 0.0; + //for (int k = FSTARTDIR; k <= FENDDIR; k++) { + // sum += WEIGTH[k] * DX1[k] * phi2[k]; + //} + //return 3.0 * sum; +} + +LBMReal MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::gradX2_phi2() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi2[TNE] - phi2[BSW]) - (phi2[BSE] - phi2[TNW])) + ((phi2[BNE] - phi2[TSW]) - (phi2[TSE] - phi2[BNW]))) + + WEIGTH[NE] * (((phi2[TN] - phi2[BS]) + (phi2[BN] - phi2[TS])) + ((phi2[NE] - phi2[SW]) - (phi2[SE] - phi2[NW])))) + + +WEIGTH[N] * (phi2[N] - phi2[S])); + //LBMReal sum = 0.0; + //for (int k = FSTARTDIR; k <= FENDDIR; k++) { + // sum += WEIGTH[k] * DX2[k] * phi2[k]; + //} + //return 3.0 * sum; +} + +LBMReal MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::gradX3_phi2() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi2[TNE] - phi2[BSW]) - (phi2[BSE] - phi2[TNW])) + ((phi2[TSE] - phi2[BNW]) - (phi2[BNE] - phi2[TSW]))) + + WEIGTH[NE] * (((phi2[TE] - phi2[BW]) - (phi2[BE] - phi2[TW])) + ((phi2[TS] - phi2[BN]) + (phi2[TN] - phi2[BS])))) + + +WEIGTH[N] * (phi2[T] - phi2[B])); + //LBMReal sum = 0.0; + //for (int k = FSTARTDIR; k <= FENDDIR; k++) { + // sum += WEIGTH[k] * DX3[k] * phi2[k]; + //} + //return 3.0 * sum; +} + + + + + +LBMReal MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::nabla2_phi() +{ + using namespace D3Q27System; + LBMReal sum = 0.0; + sum += WEIGTH[TNE] * ((((phi[TNE] - phi[REST]) + (phi[BSW] - phi[REST])) + ((phi[TSW] - phi[REST]) + (phi[BNE] - phi[REST]))) + + (((phi[TNW] - phi[REST]) + (phi[BSE] - phi[REST])) + ((phi[TSE] - phi[REST]) + (phi[BNW] - phi[REST])))); + sum += WEIGTH[TN] * ( + (((phi[TN] - phi[REST]) + (phi[BS] - phi[REST])) + ((phi[TS] - phi[REST]) + (phi[BN] - phi[REST]))) + + (((phi[TE] - phi[REST]) + (phi[BW] - phi[REST])) + ((phi[TW] - phi[REST]) + (phi[BE] - phi[REST]))) + + (((phi[NE] - phi[REST]) + (phi[SW] - phi[REST])) + ((phi[NW] - phi[REST]) + (phi[SE] - phi[REST]))) + ); + sum += WEIGTH[T] * ( + ((phi[T] - phi[REST]) + (phi[B] - phi[REST])) + + ((phi[N] - phi[REST]) + (phi[S] - phi[REST])) + + ((phi[E] - phi[REST]) + (phi[W] - phi[REST])) + ); + //for (int k = FSTARTDIR; k <= FENDDIR; k++) { + // sum += WEIGTH[k] * (phi[k] - phi[REST]); + //} + return 6.0 * sum; +} + +void MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::computePhasefield() +{ + using namespace D3Q27System; + SPtr<DistributionArray3D> distributionsH = dataSet->getHdistributions(); + + int minX1 = ghostLayerWidth; + int minX2 = ghostLayerWidth; + int minX3 = ghostLayerWidth; + int maxX1 = (int)distributionsH->getNX1() - ghostLayerWidth; + int maxX2 = (int)distributionsH->getNX2() - ghostLayerWidth; + int maxX3 = (int)distributionsH->getNX3() - ghostLayerWidth; + + //------------- Computing the phase-field ------------------ + for (int x3 = minX3; x3 < maxX3; x3++) { + for (int x2 = minX2; x2 < maxX2; x2++) { + for (int x1 = minX1; x1 < maxX1; x1++) { + // if(!bcArray->isSolid(x1,x2,x3) && !bcArray->isUndefined(x1,x2,x3)) + { + int x1p = x1 + 1; + int x2p = x2 + 1; + int x3p = x3 + 1; + + h[E] = (*this->localDistributionsH1)(D3Q27System::ET_E, x1, x2, x3); + h[N] = (*this->localDistributionsH1)(D3Q27System::ET_N, x1, x2, x3); + h[T] = (*this->localDistributionsH1)(D3Q27System::ET_T, x1, x2, x3); + h[NE] = (*this->localDistributionsH1)(D3Q27System::ET_NE, x1, x2, x3); + h[NW] = (*this->localDistributionsH1)(D3Q27System::ET_NW, x1p, x2, x3); + h[TE] = (*this->localDistributionsH1)(D3Q27System::ET_TE, x1, x2, x3); + h[TW] = (*this->localDistributionsH1)(D3Q27System::ET_TW, x1p, x2, x3); + h[TN] = (*this->localDistributionsH1)(D3Q27System::ET_TN, x1, x2, x3); + h[TS] = (*this->localDistributionsH1)(D3Q27System::ET_TS, x1, x2p, x3); + h[TNE] = (*this->localDistributionsH1)(D3Q27System::ET_TNE, x1, x2, x3); + h[TNW] = (*this->localDistributionsH1)(D3Q27System::ET_TNW, x1p, x2, x3); + h[TSE] = (*this->localDistributionsH1)(D3Q27System::ET_TSE, x1, x2p, x3); + h[TSW] = (*this->localDistributionsH1)(D3Q27System::ET_TSW, x1p, x2p, x3); + + h[W] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_W, x1p, x2, x3); + h[S] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_S, x1, x2p, x3); + h[B] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_B, x1, x2, x3p); + h[SW] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SW, x1p, x2p, x3); + h[SE] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SE, x1, x2p, x3); + h[BW] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BW, x1p, x2, x3p); + h[BE] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BE, x1, x2, x3p); + h[BS] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BS, x1, x2p, x3p); + h[BN] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BN, x1, x2, x3p); + h[BSW] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSW, x1p, x2p, x3p); + h[BSE] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSE, x1, x2p, x3p); + h[BNW] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNW, x1p, x2, x3p); + h[BNE] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNE, x1, x2, x3p); + + h[REST] = (*this->zeroDistributionsH1)(x1, x2, x3); + } + } + } + } +} + +void MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::findNeighbors(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr ph, int x1, int x2, + int x3) +{ + using namespace D3Q27System; + + SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); + + phi[REST] = (*ph)(x1, x2, x3); + + + for (int k = FSTARTDIR; k <= FENDDIR; k++) { + + if (!bcArray->isSolid(x1 + DX1[k], x2 + DX2[k], x3 + DX3[k])) { + phi[k] = (*ph)(x1 + DX1[k], x2 + DX2[k], x3 + DX3[k]); + } else { + phi[k] = 0.0; + } + } +} + +void MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::findNeighbors2(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr ph, int x1, int x2, + int x3) +{ + using namespace D3Q27System; + + SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); + + phi2[REST] = (*ph)(x1, x2, x3); + + + for (int k = FSTARTDIR; k <= FENDDIR; k++) { + + if (!bcArray->isSolid(x1 + DX1[k], x2 + DX2[k], x3 + DX3[k])) { + phi2[k] = (*ph)(x1 + DX1[k], x2 + DX2[k], x3 + DX3[k]); + } + else { + phi2[k] = 0.0; + } + } +} + +void MultiphaseTwoPhaseFieldsPressureFilterLBMKernel::swapDistributions() +{ + LBMKernel::swapDistributions(); + dataSet->getHdistributions()->swap(); + dataSet->getH2distributions()->swap(); +} \ No newline at end of file diff --git a/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsPressureFilterLBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsPressureFilterLBMKernel.h new file mode 100644 index 0000000000000000000000000000000000000000..302aaf5083acd089f482ecc4cf12a6f1e48306c8 --- /dev/null +++ b/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsPressureFilterLBMKernel.h @@ -0,0 +1,121 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file MultiphaseTwoPhaseFieldsPressureFilterLBMKernel.h +//! \ingroup LBMKernel +//! \author Hesameddin Safari +//======================================================================================= + +#ifndef MultiphaseTwoPhaseFieldsPressureFilterLBMKernel_H +#define MultiphaseTwoPhaseFieldsPressureFilterLBMKernel_H + +#include "LBMKernel.h" +#include "BCProcessor.h" +#include "D3Q27System.h" +#include "basics/utilities/UbTiming.h" +#include "basics/container/CbArray4D.h" +#include "basics/container/CbArray3D.h" + +//! \brief Multiphase Cascaded Cumulant LBM kernel. +//! \details CFD solver that use Cascaded Cumulant Lattice Boltzmann method for D3Q27 model +//! \author H. Safari, K. Kutscher, M. Geier +class MultiphaseTwoPhaseFieldsPressureFilterLBMKernel : public LBMKernel +{ +public: + MultiphaseTwoPhaseFieldsPressureFilterLBMKernel(); + virtual ~MultiphaseTwoPhaseFieldsPressureFilterLBMKernel(void) = default; + void calculate(int step) override; + SPtr<LBMKernel> clone() override; + void forwardInverseChimeraWithKincompressible(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K, LBMReal oneMinusRho); + void backwardInverseChimeraWithKincompressible(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K, LBMReal oneMinusRho); + void forwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2); + void backwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2); + + ///refactor + //CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr pressure; + + + double getCalculationTime() override { return .0; } +protected: + virtual void initDataSet(); + void swapDistributions() override; + LBMReal f1[D3Q27System::ENDF+1]; + + CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr localDistributionsF; + CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsF; + CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr zeroDistributionsF; + + CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr localDistributionsH1; + CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsH1; + CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr zeroDistributionsH1; + + CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributionsH2; + CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsH2; + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributionsH2; + + //CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr phaseField; + + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr pressureOld; + + LBMReal h [D3Q27System::ENDF+1]; + LBMReal h2[D3Q27System::ENDF + 1]; + LBMReal g [D3Q27System::ENDF+1]; + LBMReal phi[D3Q27System::ENDF+1]; + LBMReal phi2[D3Q27System::ENDF + 1]; + LBMReal pr1[D3Q27System::ENDF+1]; + LBMReal phi_cutoff[D3Q27System::ENDF+1]; + + LBMReal gradX1_phi(); + LBMReal gradX2_phi(); + LBMReal gradX3_phi(); + LBMReal gradX1_phi2(); + LBMReal gradX2_phi2(); + LBMReal gradX3_phi2(); + //LBMReal gradX1_pr1(); + //LBMReal gradX2_pr1(); + //LBMReal gradX3_pr1(); + //LBMReal dirgradC_phi(int n, int k); + void computePhasefield(); + void findNeighbors(CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr ph /*Phase-Field*/, int x1, int x2, int x3); + void findNeighbors2(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr ph, int x1, int x2, int x3); + //void findNeighbors(CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr ph /*Phase-Field*/, CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr pf /*Pressure-Field*/, int x1, int x2, int x3); + //void pressureFiltering(CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr pf /*Pressure-Field*/, CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr pf_filtered /*Pressure-Field*/); + + LBMReal nabla2_phi(); + + + mu::value_type muX1,muX2,muX3; + mu::value_type muDeltaT; + mu::value_type muNu; + mu::value_type muRho; + LBMReal forcingX1; + LBMReal forcingX2; + LBMReal forcingX3; +}; + +#endif diff --git a/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..294568b4f8b845e3c510e77e50eb780c1a739e4b --- /dev/null +++ b/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel.cpp @@ -0,0 +1,3488 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel.cpp +//! \ingroup LBMKernel +//! \author Hesameddin Safari +//======================================================================================= + +#include "MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel.h" +#include "BCArray3D.h" +#include "Block3D.h" +#include "D3Q27EsoTwist3DSplittedVector.h" +#include "D3Q27System.h" +#include "DataSet3D.h" +#include "LBMKernel.h" +#include <cmath> + +#define PROOF_CORRECTNESS + +////////////////////////////////////////////////////////////////////////// +MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel() { this->compressible = false; } +////////////////////////////////////////////////////////////////////////// +void MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::initDataSet() +{ + SPtr<DistributionArray3D> f(new D3Q27EsoTwist3DSplittedVector(nx[0] + 2, nx[1] + 2, nx[2] + 2, -999.9)); + SPtr<DistributionArray3D> h(new D3Q27EsoTwist3DSplittedVector(nx[0] + 2, nx[1] + 2, nx[2] + 2, -999.9)); // For phase-field + SPtr<DistributionArray3D> h2(new D3Q27EsoTwist3DSplittedVector(nx[0] + 2, nx[1] + 2, nx[2] + 2, -999.9)); // For phase-field + SPtr<PhaseFieldArray3D> divU(new PhaseFieldArray3D(nx[0] + 2, nx[1] + 2, nx[2] + 2, 0.0)); + pressure= CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>(nx[0] + 2, nx[1] + 2, nx[2] + 2, 0.0)); + pressureOld = CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>(nx[0] + 2, nx[1] + 2, nx[2] + 2, 0.0)); + dataSet->setFdistributions(f); + dataSet->setHdistributions(h); // For phase-field + dataSet->setH2distributions(h2); // For phase-field + dataSet->setPhaseField(divU); +} +////////////////////////////////////////////////////////////////////////// +SPtr<LBMKernel> MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::clone() +{ + SPtr<LBMKernel> kernel(new MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel()); + kernel->setNX(nx); + dynamicPointerCast<MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel>(kernel)->initDataSet(); + kernel->setCollisionFactorMultiphase(this->collFactorL, this->collFactorG); + kernel->setDensityRatio(this->densityRatio); + kernel->setMultiphaseModelParameters(this->beta, this->kappa); + kernel->setContactAngle(this->contactAngle); + kernel->setPhiL(this->phiL); + kernel->setPhiH(this->phiH); + kernel->setPhaseFieldRelaxation(this->tauH); + kernel->setMobility(this->mob); + + kernel->setBCProcessor(bcProcessor->clone(kernel)); + kernel->setWithForcing(withForcing); + kernel->setForcingX1(muForcingX1); + kernel->setForcingX2(muForcingX2); + kernel->setForcingX3(muForcingX3); + kernel->setIndex(ix1, ix2, ix3); + kernel->setDeltaT(deltaT); + + return kernel; +} +////////////////////////////////////////////////////////////////////////// + void MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::forwardInverseChimeraWithKincompressible(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K, LBMReal oneMinusRho) { + using namespace UbMath; + LBMReal m2 = mfa + mfc; + LBMReal m1 = mfc - mfa; + LBMReal m0 = m2 + mfb; + mfa = m0; + m0 *= Kinverse; + m0 += oneMinusRho; + mfb = (m1 * Kinverse - m0 * vv) * K; + mfc = ((m2 - c2 * m1 * vv) * Kinverse + v2 * m0) * K; +} + +//////////////////////////////////////////////////////////////////////////////// + void MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::backwardInverseChimeraWithKincompressible(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K, LBMReal oneMinusRho) { + using namespace UbMath; + LBMReal m0 = (((mfc - mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (v2 - vv) * c1o2) * K; + LBMReal m1 = (((mfa - mfc) - c2 * mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (-v2)) * K; + mfc = (((mfc + mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + oneMinusRho) * (v2 + vv) * c1o2) * K; + mfa = m0; + mfb = m1; +} + + +//////////////////////////////////////////////////////////////////////////////// + void MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::forwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2) { + using namespace UbMath; + LBMReal m1 = (mfa + mfc) + mfb; + LBMReal m2 = mfc - mfa; + mfc = (mfc + mfa) + (v2 * m1 - c2 * vv * m2); + mfb = m2 - vv * m1; + mfa = m1; +} + + + void MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::backwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2) { + using namespace UbMath; + LBMReal ma = (mfc + mfa * (v2 - vv)) * c1o2 + mfb * (vv - c1o2); + LBMReal mb = ((mfa - mfc) - mfa * v2) - c2 * mfb * vv; + mfc = (mfc + mfa * (v2 + vv)) * c1o2 + mfb * (vv + c1o2); + mfb = mb; + mfa = ma; +} + + +void MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::calculate(int step) +{ + using namespace D3Q27System; + using namespace UbMath; + + forcingX1 = 0.0; + forcingX2 = 0.0; + forcingX3 = 0.0; + + LBMReal oneOverInterfaceScale = 1.0; + ///////////////////////////////////// + + localDistributionsF = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getLocalDistributions(); + nonLocalDistributionsF = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getNonLocalDistributions(); + zeroDistributionsF = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getZeroDistributions(); + + localDistributionsH1 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getHdistributions())->getLocalDistributions(); + nonLocalDistributionsH1 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getHdistributions())->getNonLocalDistributions(); + zeroDistributionsH1 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getHdistributions())->getZeroDistributions(); + + localDistributionsH2 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getH2distributions())->getLocalDistributions(); + nonLocalDistributionsH2 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getH2distributions())->getNonLocalDistributions(); + zeroDistributionsH2 = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getH2distributions())->getZeroDistributions(); + + SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); + + const int bcArrayMaxX1 = (int)bcArray->getNX1(); + const int bcArrayMaxX2 = (int)bcArray->getNX2(); + const int bcArrayMaxX3 = (int)bcArray->getNX3(); + + int minX1 = ghostLayerWidth; + int minX2 = ghostLayerWidth; + int minX3 = ghostLayerWidth; + int maxX1 = bcArrayMaxX1 - ghostLayerWidth; + int maxX2 = bcArrayMaxX2 - ghostLayerWidth; + int maxX3 = bcArrayMaxX3 - ghostLayerWidth; + + //TODO + //very expensive !!!!! + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr phaseField( + new CbArray3D<LBMReal, IndexerX3X2X1>(bcArrayMaxX1, bcArrayMaxX2, bcArrayMaxX3, -999.0)); + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr phaseField2( + new CbArray3D<LBMReal, IndexerX3X2X1>(bcArrayMaxX1, bcArrayMaxX2, bcArrayMaxX3, -999.0)); + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr divU( + new CbArray3D<LBMReal, IndexerX3X2X1>(bcArrayMaxX1, bcArrayMaxX2, bcArrayMaxX3, 0.0)); + +#pragma omp parallel for + for (int x3 = 0; x3 <= maxX3; x3++) { + for (int x2 = 0; x2 <= maxX2; x2++) { + for (int x1 = 0; x1 <= maxX1; x1++) { + if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) { + int x1p = x1 + 1; + int x2p = x2 + 1; + int x3p = x3 + 1; + + LBMReal mfcbb = (*this->localDistributionsH1)(D3Q27System::ET_E, x1, x2, x3); + LBMReal mfbcb = (*this->localDistributionsH1)(D3Q27System::ET_N, x1, x2, x3); + LBMReal mfbbc = (*this->localDistributionsH1)(D3Q27System::ET_T, x1, x2, x3); + LBMReal mfccb = (*this->localDistributionsH1)(D3Q27System::ET_NE, x1, x2, x3); + LBMReal mfacb = (*this->localDistributionsH1)(D3Q27System::ET_NW, x1p, x2, x3); + LBMReal mfcbc = (*this->localDistributionsH1)(D3Q27System::ET_TE, x1, x2, x3); + LBMReal mfabc = (*this->localDistributionsH1)(D3Q27System::ET_TW, x1p, x2, x3); + LBMReal mfbcc = (*this->localDistributionsH1)(D3Q27System::ET_TN, x1, x2, x3); + LBMReal mfbac = (*this->localDistributionsH1)(D3Q27System::ET_TS, x1, x2p, x3); + LBMReal mfccc = (*this->localDistributionsH1)(D3Q27System::ET_TNE, x1, x2, x3); + LBMReal mfacc = (*this->localDistributionsH1)(D3Q27System::ET_TNW, x1p, x2, x3); + LBMReal mfcac = (*this->localDistributionsH1)(D3Q27System::ET_TSE, x1, x2p, x3); + LBMReal mfaac = (*this->localDistributionsH1)(D3Q27System::ET_TSW, x1p, x2p, x3); + LBMReal mfabb = (*this->nonLocalDistributionsH1)(D3Q27System::ET_W, x1p, x2, x3); + LBMReal mfbab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_S, x1, x2p, x3); + LBMReal mfbba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_B, x1, x2, x3p); + LBMReal mfaab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SW, x1p, x2p, x3); + LBMReal mfcab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SE, x1, x2p, x3); + LBMReal mfaba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BW, x1p, x2, x3p); + LBMReal mfcba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BE, x1, x2, x3p); + LBMReal mfbaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BS, x1, x2p, x3p); + LBMReal mfbca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BN, x1, x2, x3p); + LBMReal mfaaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSW, x1p, x2p, x3p); + LBMReal mfcaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSE, x1, x2p, x3p); + LBMReal mfaca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNW, x1p, x2, x3p); + LBMReal mfcca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNE, x1, x2, x3p); + + LBMReal mfbbb = (*this->zeroDistributionsH1)(x1, x2, x3); + (*phaseField)(x1, x2, x3) = (((mfaaa + mfccc) + (mfaca + mfcac)) + ((mfaac + mfcca) + (mfcaa + mfacc)) ) + + (((mfaab + mfacb) + (mfcab + mfccb)) + ((mfaba + mfabc) + (mfcba + mfcbc)) + + ((mfbaa + mfbac) + (mfbca + mfbcc))) + ((mfabb + mfcbb) + + (mfbab + mfbcb) + (mfbba + mfbbc)) + mfbbb; + + mfcbb = (*this->localDistributionsH2)(D3Q27System::ET_E, x1, x2, x3); + mfbcb = (*this->localDistributionsH2)(D3Q27System::ET_N, x1, x2, x3); + mfbbc = (*this->localDistributionsH2)(D3Q27System::ET_T, x1, x2, x3); + mfccb = (*this->localDistributionsH2)(D3Q27System::ET_NE, x1, x2, x3); + mfacb = (*this->localDistributionsH2)(D3Q27System::ET_NW, x1p, x2, x3); + mfcbc = (*this->localDistributionsH2)(D3Q27System::ET_TE, x1, x2, x3); + mfabc = (*this->localDistributionsH2)(D3Q27System::ET_TW, x1p, x2, x3); + mfbcc = (*this->localDistributionsH2)(D3Q27System::ET_TN, x1, x2, x3); + mfbac = (*this->localDistributionsH2)(D3Q27System::ET_TS, x1, x2p, x3); + mfccc = (*this->localDistributionsH2)(D3Q27System::ET_TNE, x1, x2, x3); + mfacc = (*this->localDistributionsH2)(D3Q27System::ET_TNW, x1p, x2, x3); + mfcac = (*this->localDistributionsH2)(D3Q27System::ET_TSE, x1, x2p, x3); + mfaac = (*this->localDistributionsH2)(D3Q27System::ET_TSW, x1p, x2p, x3); + mfabb = (*this->nonLocalDistributionsH2)(D3Q27System::ET_W, x1p, x2, x3); + mfbab = (*this->nonLocalDistributionsH2)(D3Q27System::ET_S, x1, x2p, x3); + mfbba = (*this->nonLocalDistributionsH2)(D3Q27System::ET_B, x1, x2, x3p); + mfaab = (*this->nonLocalDistributionsH2)(D3Q27System::ET_SW, x1p, x2p, x3); + mfcab = (*this->nonLocalDistributionsH2)(D3Q27System::ET_SE, x1, x2p, x3); + mfaba = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BW, x1p, x2, x3p); + mfcba = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BE, x1, x2, x3p); + mfbaa = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BS, x1, x2p, x3p); + mfbca = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BN, x1, x2, x3p); + mfaaa = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BSW, x1p, x2p, x3p); + mfcaa = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BSE, x1, x2p, x3p); + mfaca = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BNW, x1p, x2, x3p); + mfcca = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BNE, x1, x2, x3p); + + mfbbb = (*this->zeroDistributionsH2)(x1, x2, x3); + (*phaseField2)(x1, x2, x3) = + (((mfaaa + mfccc) + (mfaca + mfcac)) + ((mfaac + mfcca) + (mfcaa + mfacc))) + + (((mfaab + mfacb) + (mfcab + mfccb)) + ((mfaba + mfabc) + (mfcba + mfcbc)) + + ((mfbaa + mfbac) + (mfbca + mfbcc))) + + ((mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc)) + mfbbb; + //(*phaseField)(x1, x2, x3) = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) + + // (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + + // (mfbaa + mfbac + mfbca + mfbcc) + (mfabb + mfcbb) + + // (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; + +////// read F-distributions for velocity formalism + + + mfcbb = (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3); + mfbcb = (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3); + mfbbc = (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3); + mfccb = (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3); + mfacb = (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3); + mfcbc = (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3); + mfabc = (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3); + mfbcc = (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3); + mfbac = (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3); + mfccc = (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3); + mfacc = (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3); + mfcac = (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3); + mfaac = (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3); + mfabb = (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3); + mfbab = (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3); + mfbba = (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p); + mfaab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3); + mfcab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3); + mfaba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p); + mfcba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p); + mfbaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p); + mfbca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p); + mfaaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p); + mfcaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p); + mfaca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p); + mfcca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p); + + mfbbb = (*this->zeroDistributionsF)(x1, x2, x3); + + LBMReal rhoH = 1.0; + LBMReal rhoL = 1.0 / densityRatio; + + LBMReal rhoToPhi = (rhoH - rhoL) / (phiH - phiL); + + LBMReal drho = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) + + (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + (mfbaa + mfbac + mfbca + mfbcc) + + (mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; + + LBMReal rho = rhoH + rhoToPhi * (phi[REST] - phiH); + (*pressure)(x1, x2, x3) = (*pressure)(x1, x2, x3) + rho * c1o3 * drho; + + ////!!!!!! relplace by pointer swap! + (*pressureOld)(x1, x2, x3) = (*pressure)(x1, x2, x3); + } + } + } + } + + LBMReal collFactorM; + //LBMReal forcingTerm[D3Q27System::ENDF + 1]; + + ////filter + + //for (int x3 = minX3; x3 < maxX3; x3++) { + // for (int x2 = minX2; x2 < maxX2; x2++) { + // for (int x1 = minX1; x1 < maxX1; x1++) { + // if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) { + + // LBMReal sum = 0.; + + // //Lapalce pressure + // //sum += WEIGTH[TNE] * (((((*pressure)(x1+1, x2+1, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2-1, x3-1) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1+1, x2+1, x3-1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2-1, x3+1) - (*pressure)(x1, x2, x3)))) + // // + ((((*pressure)(x1+1, x2-1, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2+1, x3-1) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1+1, x2-1, x3-1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2+1, x3+1) - (*pressure)(x1, x2, x3))))); + // //sum += WEIGTH[TN] * ( + // // ((((*pressure)(x1+1, x2+1, x3) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2-1, x3) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1+1, x2-1, x3) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2+1, x3) - (*pressure)(x1, x2, x3)))) + // // + ((((*pressure)(x1+1, x2, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2, x3-1) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1+1, x2, x3-1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2, x3+1) - (*pressure)(x1, x2, x3)))) + // // + ((((*pressure)(x1, x2+1, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2-1, x3-1) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1, x2+1, x3-1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2-1, x3+1) - (*pressure)(x1, x2, x3)))) + // // ); + // //sum += WEIGTH[T] * ( + // // (((*pressure)(x1+1, x2, x3) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2, x3) - (*pressure)(x1, x2, x3))) + // // + (((*pressure)(x1, x2+1, x3) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2-1, x3) - (*pressure)(x1, x2, x3))) + // // + (((*pressure)(x1, x2, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2, x3-1) - (*pressure)(x1, x2, x3))) + // // ); + + + // //LBMReal pressureFilter = 100; + // //(*pressureOld)(x1, x2, x3) = (*pressure)(x1, x2, x3) + pressureFilter * sum * (sqrt(fabs(sum))); + + // //Situpol Eq. 81 + // sum += WEIGTH[TNE] * (((((*pressure)(x1+1, x2+1, x3+1)) + ((*pressure)(x1-1, x2-1, x3-1) )) + (((*pressure)(x1+1, x2+1, x3-1) ) + ((*pressure)(x1-1, x2-1, x3+1) ))) + // + ((((*pressure)(x1+1, x2-1, x3+1) ) + ((*pressure)(x1-1, x2+1, x3-1) )) + (((*pressure)(x1+1, x2-1, x3-1) ) + ((*pressure)(x1-1, x2+1, x3+1) )))); + // sum += WEIGTH[TN] * ( + // ((((*pressure)(x1+1, x2+1, x3) ) + ((*pressure)(x1-1, x2-1, x3) )) + (((*pressure)(x1+1, x2-1, x3) ) + ((*pressure)(x1-1, x2+1, x3) ))) + // + ((((*pressure)(x1+1, x2, x3+1) ) + ((*pressure)(x1-1, x2, x3-1) )) + (((*pressure)(x1+1, x2, x3-1) ) + ((*pressure)(x1-1, x2, x3+1) ))) + // + ((((*pressure)(x1, x2+1, x3+1) ) + ((*pressure)(x1, x2-1, x3-1) )) + (((*pressure)(x1, x2+1, x3-1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2-1, x3+1) ))) + // ); + // sum += WEIGTH[T] * ( + // (((*pressure)(x1+1, x2, x3) ) + ((*pressure)(x1-1, x2, x3) )) + // + (((*pressure)(x1, x2+1, x3) ) + ((*pressure)(x1, x2-1, x3) )) + // + (((*pressure)(x1, x2, x3+1)) + ((*pressure)(x1, x2, x3-1) )) + // ); + // sum += WEIGTH[REST] * (*pressure)(x1, x2, x3); + // (*pressureOld)(x1, x2, x3) = sum; + + + + + // } + // } + // } + //} + + ////Periodic Filter +#pragma omp parallel for + for (int x3 = 0; x3 <= maxX3; x3++) { + for (int x2 = 0; x2 <= maxX2; x2++) { + for (int x1 = 0; x1 <= maxX1; x1++) { + if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) { + + LBMReal sum = 0.; + + + + //Lapalce pressure + //sum += WEIGTH[TNE] * (((((*pressure)(x1+1, x2+1, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2-1, x3-1) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1+1, x2+1, x3-1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2-1, x3+1) - (*pressure)(x1, x2, x3)))) + // + ((((*pressure)(x1+1, x2-1, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2+1, x3-1) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1+1, x2-1, x3-1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2+1, x3+1) - (*pressure)(x1, x2, x3))))); + //sum += WEIGTH[TN] * ( + // ((((*pressure)(x1+1, x2+1, x3) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2-1, x3) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1+1, x2-1, x3) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2+1, x3) - (*pressure)(x1, x2, x3)))) + // + ((((*pressure)(x1+1, x2, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2, x3-1) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1+1, x2, x3-1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2, x3+1) - (*pressure)(x1, x2, x3)))) + // + ((((*pressure)(x1, x2+1, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2-1, x3-1) - (*pressure)(x1, x2, x3))) + (((*pressure)(x1, x2+1, x3-1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2-1, x3+1) - (*pressure)(x1, x2, x3)))) + // ); + //sum += WEIGTH[T] * ( + // (((*pressure)(x1+1, x2, x3) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1-1, x2, x3) - (*pressure)(x1, x2, x3))) + // + (((*pressure)(x1, x2+1, x3) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2-1, x3) - (*pressure)(x1, x2, x3))) + // + (((*pressure)(x1, x2, x3+1) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2, x3-1) - (*pressure)(x1, x2, x3))) + // ); + + + //LBMReal pressureFilter = 100; + //(*pressureOld)(x1, x2, x3) = (*pressure)(x1, x2, x3) + pressureFilter * sum * (sqrt(fabs(sum))); + + //Situpol Eq. 81 + + //int x1p = (x1 < maxX1) ? x1 + 1 : 0; + //int x1m = (x1 > 0) ? x1 - 1 : maxX1; + //int x2p = (x2 < maxX2) ? x2 + 1 : 0; + //int x2m = (x2 > 0) ? x2 - 1 : maxX2; + //int x3p = (x3 < maxX3) ? x3 + 1 : 0; + //int x3m = (x3 > 0) ? x3 - 1 : maxX3; + //sum += WEIGTH[TNE] * (((((*pressure)(x1p, x2p, x3p)) + ((*pressure)(x1m, x2m, x3m))) + (((*pressure)(x1p, x2p, x3m)) + ((*pressure)(x1m, x2m, x3p)))) + // + ((((*pressure)(x1p, x2m, x3p)) + ((*pressure)(x1m, x2p, x3m))) + (((*pressure)(x1p, x2m, x3m)) + ((*pressure)(x1m, x2p, x3p))))); + //sum += WEIGTH[TN] * ( + // ((((*pressure)(x1p, x2p, x3)) + ((*pressure)(x1m, x2m, x3))) + (((*pressure)(x1p, x2m, x3)) + ((*pressure)(x1m, x2p, x3)))) + // + ((((*pressure)(x1p, x2, x3p)) + ((*pressure)(x1m, x2, x3m))) + (((*pressure)(x1p, x2, x3m)) + ((*pressure)(x1m, x2, x3p)))) + // + ((((*pressure)(x1, x2p, x3p)) + ((*pressure)(x1, x2m, x3m))) + (((*pressure)(x1, x2p, x3m) - (*pressure)(x1, x2, x3)) + ((*pressure)(x1, x2m, x3p)))) + // ); + //sum += WEIGTH[T] * ( + // (((*pressure)(x1p, x2, x3)) + ((*pressure)(x1m, x2, x3))) + // + (((*pressure)(x1, x2p, x3)) + ((*pressure)(x1, x2m, x3))) + // + (((*pressure)(x1, x2, x3p)) + ((*pressure)(x1, x2, x3m))) + // ); + //sum += WEIGTH[REST] * (*pressure)(x1, x2, x3); + //(*pressureOld)(x1, x2, x3) = sum; + + ///Version for boundaries + for (int xx = -1; xx <= 1; xx++) { + int xxx = (xx+x1 <= maxX1) ? ((xx + x1 > 0) ? xx + x1 : maxX1) : 0; + + for (int yy = -1; yy <= 1; yy++) { + int yyy = (yy+x2 <= maxX2) ? ((yy + x2 > 0) ? yy + x2 : maxX2) : 0; + + for (int zz = -1; zz <= 1; zz++) { + int zzz = (zz+x3 <= maxX3) ? ((zz + x3 > 0) ? zz + x3 : maxX3 ): 0; + + if (!bcArray->isSolid(xxx, yyy, zzz) && !bcArray->isUndefined(xxx, yyy, zzz)) { + sum+= 64.0/(216.0*(c1+c3*abs(xx))* (c1 + c3 * abs(yy))* (c1 + c3 * abs(zz)))*(*pressure)(xxx, yyy, zzz); + } + else{ sum+= 64.0 / (216.0 * (c1 + c3 * abs(xx)) * (c1 + c3 * abs(yy)) * (c1 + c3 * abs(zz))) * (*pressure)(x1, x2, x3); + } + + + } + } + } + (*pressureOld)(x1, x2, x3) = sum; + + + + } + } + } + } + +#pragma omp parallel for + for (int x3 = 0; x3 <= maxX3; x3++) { + for (int x2 = 0; x2 <= maxX2; x2++) { + for (int x1 = 0; x1 <= maxX1; x1++) { + if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) { + ///filter! + + (*pressure)(x1, x2, x3) = (*pressureOld)(x1, x2, x3); + } + } + } + } + ////!filter + + +#pragma omp parallel for + for (int x3 = minX3; x3 < maxX3; x3++) { + for (int x2 = minX2; x2 < maxX2; x2++) { + for (int x1 = minX1; x1 < maxX1; x1++) { + if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) { + int x1p = x1 + 1; + int x2p = x2 + 1; + int x3p = x3 + 1; + + + + ////////////////////////////////////////////////////////////////////////// + // Read distributions and phase field + //////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + + // E N T + // c c c + ////////// + // W S B + // a a a + + // Rest ist b + + // mfxyz + // a - negative + // b - null + // c - positive + + // a b c + //-1 0 1 + + findNeighbors(phaseField, x1, x2, x3); + findNeighbors2(phaseField2, x1, x2, x3); + + LBMReal mfcbb = (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3); + LBMReal mfbcb = (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3); + LBMReal mfbbc = (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3); + LBMReal mfccb = (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3); + LBMReal mfacb = (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3); + LBMReal mfcbc = (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3); + LBMReal mfabc = (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3); + LBMReal mfbcc = (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3); + LBMReal mfbac = (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3); + LBMReal mfccc = (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3); + LBMReal mfacc = (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3); + LBMReal mfcac = (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3); + LBMReal mfaac = (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3); + LBMReal mfabb = (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3); + LBMReal mfbab = (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3); + LBMReal mfbba = (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p); + LBMReal mfaab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3); + LBMReal mfcab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3); + LBMReal mfaba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p); + LBMReal mfcba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p); + LBMReal mfbaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p); + LBMReal mfbca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p); + LBMReal mfaaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p); + LBMReal mfcaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p); + LBMReal mfaca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p); + LBMReal mfcca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p); + + LBMReal mfbbb = (*this->zeroDistributionsF)(x1, x2, x3); + + LBMReal rhoH = 1.0; + LBMReal rhoL = 1.0 / densityRatio; + + LBMReal rhoToPhi = (rhoH - rhoL) / (phiH - phiL); + + LBMReal dX1_phi = gradX1_phi(); + LBMReal dX2_phi = gradX2_phi(); + LBMReal dX3_phi = gradX3_phi(); + + //LBMReal dX1_phi2 = gradX1_phi2(); + //LBMReal dX2_phi2 = gradX2_phi2(); + //LBMReal dX3_phi2 = gradX3_phi2(); + + + // LBMReal denom2 = sqrt(dX1_phi * dX1_phi+ dX1_phi2 * dX1_phi2 + dX2_phi * dX2_phi + dX2_phi2 * dX2_phi2 + dX3_phi * dX3_phi+ dX3_phi2 * dX3_phi2) + 1e-9; + // LBMReal normX1 = (dX1_phi-dX1_phi2)/denom2; + //LBMReal normX2 = (dX2_phi-dX2_phi2)/denom2; + //LBMReal normX3 = (dX3_phi-dX3_phi2)/denom2; + + LBMReal denom = sqrt(dX1_phi * dX1_phi + dX2_phi * dX2_phi + dX3_phi * dX3_phi) + 1e-9; + LBMReal normX1 = dX1_phi / denom; + LBMReal normX2 = dX2_phi / denom; + LBMReal normX3 = dX3_phi / denom; + + + + collFactorM = collFactorL + (collFactorL - collFactorG) * (phi[REST] - phiH) / (phiH - phiL); + + + LBMReal mu = 2 * beta * phi[REST] * (phi[REST] - 1) * (2 * phi[REST] - 1) - kappa * nabla2_phi(); + + //----------- Calculating Macroscopic Values ------------- + LBMReal rho = rhoH + rhoToPhi * (phi[REST] - phiH); + + ////Incompressible Kernal + + //mfbbc = (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3) ;// / rho * c3; + //mfbcb = (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3) ;// / rho * c3; + //mfccb = (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3) ;// / rho * c3; + //mfacb = (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3) ;// / rho * c3; + //mfcbb = (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3) ;// / rho * c3; + //mfcbc = (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3) ;// / rho * c3; + //mfabc = (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3) ;// / rho * c3; + //mfbcc = (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3) ;// / rho * c3; + //mfbac = (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3) ;// / rho * c3; + //mfccc = (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3) ;// / rho * c3; + //mfacc = (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3) ;// / rho * c3; + //mfcac = (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3) ;// / rho * c3; + //mfaac = (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3) ;// / rho * c3; + //mfabb = (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3) ;// / rho * c3; + //mfbab = (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3) ;// / rho * c3; + //mfbba = (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p) ;// / rho * c3; + //mfaab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3) ;// / rho * c3; + //mfcab = (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3) ;// / rho * c3; + //mfaba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p) ;// / rho * c3; + //mfcba = (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p) ;// / rho * c3; + //mfbaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p) ;// / rho * c3; + //mfbca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p) ;// / rho * c3; + //mfaaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p) ;// / rho * c3; + //mfcaa = (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p) ;// / rho * c3; + //mfaca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p) ;// / rho * c3; + //mfcca = (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p) ;// / rho * c3; + + //mfbbb = (*this->zeroDistributionsF)(x1, x2, x3);// / rho * c3; + + + LBMReal m0, m1, m2; + LBMReal rhoRef=c1; + + //LBMReal + // LBMReal drho = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) + // + (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + (mfbaa + mfbac + mfbca + mfbcc) + // + (mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; + + LBMReal vvx = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + + (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + + (mfcbb - mfabb))/rhoRef; + LBMReal vvy = ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + + (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + + (mfbcb - mfbab))/rhoRef; + LBMReal vvz = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + + (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + + (mfbbc - mfbba))/rhoRef; + + // (*pressure)(x1, x2, x3) = (*pressureOld)(x1, x2, x3)+rho*c1o3*drho; + + //LBMReal gradPx = c1o2 * ((*pressure)(x1 + 1, x2, x3) - (*pressure)(x1 - 1, x2, x3)); + //LBMReal gradPy = c1o2 * ((*pressure)(x1, x2 + 1, x3) - (*pressure)(x1, x2 - 1, x3)); + //LBMReal gradPz = c1o2 * ((*pressure)(x1, x2, x3 + 1) - (*pressure)(x1, x2, x3 - 1)); + + //LBMReal gradPx = 3.0 * (WEIGTH[TNE] * ( + // (((*pressure)(x1 + 1, x2 + 1, x3 + 1) - (*pressure)(x1 - 1, x2 - 1, x3 - 1)) + ((*pressure)(x1 + 1, x2 - 1, x3 + 1) - (*pressure)(x1 - 1, x2 + 1, x3 - 1))) + // + (((*pressure)(x1 + 1, x2 - 1, x3 - 1) - (*pressure)(x1 - 1, x2 + 1, x3 + 1)) + ((*pressure)(x1 + 1, x2 + 1, x3 - 1) - (*pressure)(x1 - 1, x2 - 1, x3 + 1)))) + // + WEIGTH[NE] * ( + // (((*pressure)(x1 + 1, x2 + 1, x3) - (*pressure)(x1 - 1, x2 - 1, x3)) + ((*pressure)(x1 + 1, x2 - 1, x3) - (*pressure)(x1 - 1, x2 + 1, x3))) + // + (((*pressure)(x1 + 1, x2, x3 - 1) - (*pressure)(x1 - 1, x2, x3 + 1)) + ((*pressure)(x1 + 1, x2, x3 + 1) - (*pressure)(x1 - 1, x2, x3 - 1)))) + // + WEIGTH[E] * ((*pressure)(x1 + 1, x2, x3) - (*pressure)(x1 - 1, x2, x3))); + + //LBMReal gradPy = 3.0 * (WEIGTH[TNE] * ( + // (((*pressure)(x1 + 1, x2 + 1, x3 + 1) - (*pressure)(x1 - 1, x2 - 1, x3 - 1)) + ((*pressure)(x1 - 1, x2 + 1, x3 + 1) - (*pressure)(x1 + 1, x2 - 1, x3 - 1))) + // + (((*pressure)(x1 - 1, x2 + 1, x3 - 1) - (*pressure)(x1 + 1, x2 - 1, x3 + 1)) + ((*pressure)(x1 + 1, x2 + 1, x3 - 1) - (*pressure)(x1 - 1, x2 - 1, x3 + 1)))) + // + WEIGTH[NE] * ( + // (((*pressure)(x1 + 1, x2 + 1, x3) - (*pressure)(x1 - 1, x2 - 1, x3)) + ((*pressure)(x1 - 1, x2 + 1, x3) - (*pressure)(x1 + 1, x2 - 1, x3))) + // + (((*pressure)(x1, x2+1, x3 - 1) - (*pressure)(x1, x2-1, x3 + 1)) + ((*pressure)(x1, x2+1, x3 + 1) - (*pressure)(x1, x2-1, x3 - 1)))) + // + WEIGTH[E] * ((*pressure)(x1, x2+1, x3) - (*pressure)(x1, x2-1, x3))); + + //LBMReal gradPz = 3.0 * (WEIGTH[TNE] * ( + // (((*pressure)(x1 + 1, x2 + 1, x3 + 1) - (*pressure)(x1 - 1, x2 - 1, x3 - 1)) + ((*pressure)(x1 - 1, x2 + 1, x3 + 1) - (*pressure)(x1 + 1, x2 - 1, x3 - 1))) + // + (((*pressure)(x1 - 1, x2 - 1, x3 + 1) - (*pressure)(x1 + 1, x2 + 1, x3 - 1)) + ((*pressure)(x1 + 1, x2 - 1, x3 + 1) - (*pressure)(x1 - 1, x2 + 1, x3 - 1)))) + // + WEIGTH[NE] * ( + // (((*pressure)(x1 + 1, x2, x3+1) - (*pressure)(x1 - 1, x2, x3-1)) + ((*pressure)(x1 - 1, x2, x3+1) - (*pressure)(x1 + 1, x2, x3-1))) + // + (((*pressure)(x1, x2 - 1, x3 + 1) - (*pressure)(x1, x2 + 1, x3 - 1)) + ((*pressure)(x1, x2 + 1, x3 + 1) - (*pressure)(x1, x2 - 1, x3 - 1)))) + // + WEIGTH[E] * ((*pressure)(x1, x2, x3+1) - (*pressure)(x1, x2, x3-1))); + + + LBMReal gradPx = 0.0; + LBMReal gradPy = 0.0; + LBMReal gradPz = 0.0; + for (int dir1 = -1; dir1 <= 1; dir1++) { + for (int dir2 = -1; dir2 <= 1; dir2++) { + int yyy = x2 + dir1; + int zzz = x3 + dir2; + if (!bcArray->isSolid(x1-1, yyy, zzz) && !bcArray->isUndefined(x1-1, yyy, zzz)) { + gradPx -= (*pressure)(x1 - 1, yyy, zzz) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPx -= (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + if (!bcArray->isSolid(x1 + 1, yyy, zzz) && !bcArray->isUndefined(x1 - 1, yyy, zzz)) { + gradPx += (*pressure)(x1 + 1, yyy, zzz) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPx += (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + + int xxx = x1 + dir1; + if (!bcArray->isSolid(xxx, x2-1, zzz) && !bcArray->isUndefined(xxx, x2-1, zzz)) { + gradPy -= (*pressure)(xxx, x2-1, zzz) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPy -= (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + if (!bcArray->isSolid(xxx, x2+1, zzz) && !bcArray->isUndefined(xxx, x2-1, zzz)) { + gradPy += (*pressure)(xxx, x2+1, zzz) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPy += (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + + yyy = x2 + dir2; + if (!bcArray->isSolid(xxx, yyy, x3-1) && !bcArray->isUndefined(xxx, yyy, x3-1)) { + gradPz -= (*pressure)(xxx, yyy, x3-1) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPz -= (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + if (!bcArray->isSolid(xxx, yyy, x3+1) && !bcArray->isUndefined(xxx, yyy, x3+1)) { + gradPz += (*pressure)(xxx, yyy, x3+1) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + else { + gradPz += (*pressure)(x1, x2, x3) * c2o9 / ((c1 + c3 * abs(dir1)) * (c1 + c3 * abs(dir2))); + } + + } + } + + //3.0 * ((WEIGTH[TNE] * (((phi2[TNE] - phi2[BSW]) - (phi2[BSE] - phi2[TNW])) + ((phi2[TSE] - phi2[BNW]) - (phi2[BNE] - phi2[TSW]))) + //+WEIGTH[NE] * (((phi2[TE] - phi2[BW]) - (phi2[BE] - phi2[TW])) + ((phi2[TS] - phi2[BN]) + (phi2[TN] - phi2[BS])))) + + //+WEIGTH[N] * (phi2[T] - phi2[B])); + + if (withForcing) { + // muX1 = static_cast<double>(x1-1+ix1*maxX1); + // muX2 = static_cast<double>(x2-1+ix2*maxX2); + // muX3 = static_cast<double>(x3-1+ix3*maxX3); + + // forcingX1 = muForcingX1.Eval()+c1o3*drho*dX1_phi*rhoToPhi/rho;//-gradPx/rho; + // forcingX2 = muForcingX2.Eval() + c1o3*drho*dX2_phi * rhoToPhi / rho;//-gradPy/rho; + //forcingX3 = muForcingX3.Eval() + c1o3*drho*dX3_phi * rhoToPhi / rho;//-gradPz/rho; + + forcingX1 = muForcingX1.Eval() -gradPx/rho; + forcingX2 = muForcingX2.Eval() -gradPy/rho; + forcingX3 = muForcingX3.Eval() -gradPz/rho; + + //LBMReal rho_m = 1.0 / densityRatio; + //forcingX1 = forcingX1 * (rho - rho_m); + //forcingX2 = forcingX2 * (rho - rho_m); + //forcingX3 = forcingX3 * (rho - rho_m); + vvx += forcingX1 * deltaT * 0.5; // X + vvy += forcingX2 * deltaT * 0.5; // Y + vvz += forcingX3 * deltaT * 0.5; // Z + + } + + + ///surface tension force + vvx += mu * dX1_phi * c1o2; + vvy += mu * dX2_phi * c1o2 ; + vvz += mu * dX3_phi * c1o2; + + //////classic source term + ///----Classic source term 8.4.2021 + + //LBMReal vvxF, vvyF, vvzF; + //vvxF = vvx;//-2*c1o24 * lap_vx;// + //vvyF = vvy;//-2*c1o24 * lap_vy;// + //vvzF = vvz;//-2*c1o24 * lap_vz;// + +// vvxF = 1.2* vvx- 0.2*0.5 * ((*velocityX)(x1 - 1, x2, x3) + (*velocityX)(x1 + 1, x2, x3)); +// vvyF = 1.2 *vvy- 0.2*0.5* ((*velocityY)(x1 , x2-1, x3) + (*velocityY)(x1 , x2+1, x3)); +// vvzF = 1.2 *vvz-0.2*0.5* ((*velocityZ)(x1 , x2, x3-1) + (*velocityZ)(x1 , x2, x3+1)); + //if (vvxF != vvx) { + // vvxF = vvxF; + //} + //LBMReal weightGrad = 1.0;// -denom * denom / (denom * denom + 0.0001 * 0.001); + //LBMReal dX1_phiF = dX1_phi * weightGrad + (1.0 - weightGrad) * (1.0 - phi[REST]) * (phi[REST]) * normX1; + //LBMReal dX2_phiF = dX2_phi * weightGrad + (1.0 - weightGrad) * (1.0 - phi[REST]) * (phi[REST]) * normX2; + //LBMReal dX3_phiF = dX3_phi * weightGrad + (1.0 - weightGrad) * (1.0 - phi[REST]) * (phi[REST]) * normX3; + + //dX1_phiF *= 1.2; + //dX2_phiF *= 1.2; + //dX3_phiF *= 1.2; + + //LBMReal gradFD = sqrt(dX1_phi * dX1_phi + dX2_phi * dX2_phi + dX3_phi * dX3_phi); + //LBMReal gradPhi = (1.0 - phi[REST]) * (phi[REST]); + //gradPhi = (gradPhi > gradFD) ? gradPhi : gradFD; + //dX1_phiF = gradPhi * normX1; + // dX2_phiF = gradPhi * normX2; + // dX3_phiF = gradPhi * normX3; + + //LBMReal ux2; + //LBMReal uy2; + //LBMReal uz2; + //ux2 = vvxF * vvxF; + //uy2 = vvyF * vvyF; + //uz2 = vvzF * vvzF; + //LBMReal forcingTerm[D3Q27System::ENDF + 1]; + //for (int dir = STARTF; dir <= (FENDDIR); dir++) { + // LBMReal velProd = DX1[dir] * vvxF + DX2[dir] * vvyF + DX3[dir] * vvzF; + // LBMReal velSq1 = velProd * velProd; + // LBMReal gamma = WEIGTH[dir] * (1.0 + 3 * velProd + (4.5 * velSq1 - 1.5 * (ux2 + uy2 + uz2))); + + // //LBMReal fac1 = (gamma - WEIGTH[dir]) * c1o3 * rhoToPhi; + + // //forcingTerm[dir] = + // // (-vvxF) * (fac1 * dX1_phiF) + + // // (-vvyF) * (fac1 * dX2_phiF) + + // // (-vvzF) * (fac1 * dX3_phiF) + + // // (DX1[dir]) * (fac1 * dX1_phiF) + + // // (DX2[dir]) * (fac1 * dX2_phiF) + + // // (DX3[dir]) * (fac1 * dX3_phiF); + + + // //LBMReal fac1 = (gamma - WEIGTH[dir]) * c1o3 ; + + // //forcingTerm[dir] = + // // (-vvxF) * (fac1 * (dX1_phiF * rhoH + dX2_phi2 * rhoL)) + + // // (-vvyF) * (fac1 * (dX2_phiF * rhoH + dX2_phi2 * rhoL)) + + // // (-vvzF) * (fac1 * (dX3_phiF * rhoH + dX3_phi2 * rhoL)) + + // // (DX1[dir]) * (fac1 * (dX1_phiF * rhoH + dX2_phi2 * rhoL)) + + // // (DX2[dir]) * (fac1 * (dX2_phiF * rhoH + dX2_phi2 * rhoL)) + + // // (DX3[dir]) * (fac1 * (dX3_phiF * rhoH + dX3_phi2 * rhoL)); + + + + //} + + //LBMReal gamma = WEIGTH[REST] * (1.0 - 1.5 * (ux2 + uy2 + uz2)); + //LBMReal fac1 = (gamma - WEIGTH[REST]) * c1o3 * rhoToPhi; + //forcingTerm[REST] = (-vvxF) * (fac1 * (dX1_phiF * rhoH + dX2_phi2 * rhoL)) + + // (-vvyF) * (fac1 * (dX2_phiF * rhoH + dX2_phi2 * rhoL)) + + // (-vvzF) * (fac1 * (dX3_phiF * rhoH + dX3_phi2 * rhoL)); + + //////// + // LBMReal divAfterSource= + //( mfcbb + 3.0 * (0.5 * forcingTerm[E]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF) *(vvyF) +(vvzF) *(vvzF)-1)+ + //( mfbcb + 3.0 * (0.5 * forcingTerm[N]) / rho ) *((vvxF) *(vvxF) +(vvyF-1)*(vvyF-1)+(vvzF) *(vvzF)-1)+ + //( mfbbc + 3.0 * (0.5 * forcingTerm[T]) / rho ) *((vvxF) *(vvxF) +(vvyF) *(vvyF) +(vvzF-1)*(vvzF-1)-1)+ + //( mfccb + 3.0 * (0.5 * forcingTerm[NE]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF-1)*(vvyF-1)+(vvzF) *(vvzF)-1)+ + //( mfacb + 3.0 * (0.5 * forcingTerm[NW]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF-1)*(vvyF-1)+(vvzF) *(vvzF)-1)+ + //( mfcbc + 3.0 * (0.5 * forcingTerm[TE]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF) *(vvyF) +(vvzF-1)*(vvzF-1)-1)+ + //( mfabc + 3.0 * (0.5 * forcingTerm[TW]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF) *(vvyF) +(vvzF-1)*(vvzF-1)-1)+ + //( mfbcc + 3.0 * (0.5 * forcingTerm[TN]) / rho ) *((vvxF) *(vvxF) +(vvyF-1)*(vvyF-1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfbac + 3.0 * (0.5 * forcingTerm[TS]) / rho ) *((vvxF) *(vvxF) +(vvyF+1)*(vvyF+1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfccc + 3.0 * (0.5 * forcingTerm[TNE]) / rho) *((vvxF-1)*(vvxF-1)+(vvyF-1)*(vvyF-1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfacc + 3.0 * (0.5 * forcingTerm[TNW]) / rho) *((vvxF+1)*(vvxF+1)+(vvyF-1)*(vvyF-1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfcac + 3.0 * (0.5 * forcingTerm[TSE]) / rho) *((vvxF-1)*(vvxF-1)+(vvyF+1)*(vvyF+1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfaac + 3.0 * (0.5 * forcingTerm[TSW]) / rho) *((vvxF+1)*(vvxF+1)+(vvyF+1)*(vvyF+1)+(vvzF-1)*(vvzF-1)-1)+ + //( mfabb + 3.0 * (0.5 * forcingTerm[W]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF) *(vvyF) +(vvzF) *(vvzF)-1)+ + //( mfbab + 3.0 * (0.5 * forcingTerm[S]) / rho ) *((vvxF) *(vvxF) +(vvyF+1)*(vvyF+1)+(vvzF) *(vvzF)-1)+ + //( mfbba + 3.0 * (0.5 * forcingTerm[B]) / rho ) *((vvxF) *(vvxF) +(vvyF) *(vvyF) +(vvzF+1)*(vvzF+1)-1)+ + //( mfaab + 3.0 * (0.5 * forcingTerm[SW]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF+1)*(vvyF+1)+(vvzF) *(vvzF)-1)+ + //( mfcab + 3.0 * (0.5 * forcingTerm[SE]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF+1)*(vvyF+1)+(vvzF) *(vvzF)-1)+ + //( mfaba + 3.0 * (0.5 * forcingTerm[BW]) / rho ) *((vvxF+1)*(vvxF+1)+(vvyF) *(vvyF) +(vvzF+1)*(vvzF+1)-1)+ + //( mfcba + 3.0 * (0.5 * forcingTerm[BE]) / rho ) *((vvxF-1)*(vvxF-1)+(vvyF) *(vvyF) +(vvzF+1)*(vvzF+1)-1)+ + //( mfbaa + 3.0 * (0.5 * forcingTerm[BS]) / rho ) *((vvxF) *(vvxF) +(vvyF+1)*(vvyF+1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfbca + 3.0 * (0.5 * forcingTerm[BN]) / rho ) *((vvxF) *(vvxF) +(vvyF-1)*(vvyF-1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfaaa + 3.0 * (0.5 * forcingTerm[BSW]) / rho) *((vvxF+1)*(vvxF+1)+(vvyF+1)*(vvyF+1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfcaa + 3.0 * (0.5 * forcingTerm[BSE]) / rho) *((vvxF-1)*(vvxF-1)+(vvyF+1)*(vvyF+1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfaca + 3.0 * (0.5 * forcingTerm[BNW]) / rho) *((vvxF+1)*(vvxF+1)+(vvyF-1)*(vvyF-1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfcca + 3.0 * (0.5 * forcingTerm[BNE]) / rho) *((vvxF-1)*(vvxF-1)+(vvyF-1)*(vvyF-1)+(vvzF+1)*(vvzF+1)-1)+ + //( mfbbb + 3.0 * (0.5 * forcingTerm[REST]) / rho)*((vvxF)*(vvxF)+(vvyF)*(vvyF)+(vvzF)*(vvzF)-1); + + // LBMReal divBeforeSource = + // (mfcbb) * ((vvxF - 1) * (vvxF - 1) + (vvyF) * (vvyF)+(vvzF) * (vvzF)-1) + + // (mfbcb) * ((vvxF) * (vvxF)+(vvyF - 1) * (vvyF - 1) + (vvzF) * (vvzF)-1) + + // (mfbbc) * ((vvxF) * (vvxF)+(vvyF) * (vvyF)+(vvzF - 1) * (vvzF - 1)-1) + + // (mfccb) * ((vvxF - 1) * (vvxF - 1) + (vvyF - 1) * (vvyF - 1) + (vvzF) * (vvzF)-1) + + // (mfacb) * ((vvxF + 1) * (vvxF + 1) + (vvyF - 1) * (vvyF - 1) + (vvzF) * (vvzF)-1) + + // (mfcbc) * ((vvxF - 1) * (vvxF - 1) + (vvyF) * (vvyF)+(vvzF - 1) * (vvzF - 1)-1) + + // (mfabc) * ((vvxF + 1) * (vvxF + 1) + (vvyF) * (vvyF)+(vvzF - 1) * (vvzF - 1)-1) + + // (mfbcc) * ((vvxF) * (vvxF)+(vvyF - 1) * (vvyF - 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfbac) * ((vvxF) * (vvxF)+(vvyF + 1) * (vvyF + 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfccc) * ((vvxF - 1) * (vvxF - 1) + (vvyF - 1) * (vvyF - 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfacc) * ((vvxF + 1) * (vvxF + 1) + (vvyF - 1) * (vvyF - 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfcac) * ((vvxF - 1) * (vvxF - 1) + (vvyF + 1) * (vvyF + 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfaac) * ((vvxF + 1) * (vvxF + 1) + (vvyF + 1) * (vvyF + 1) + (vvzF - 1) * (vvzF - 1)-1) + + // (mfabb) * ((vvxF + 1) * (vvxF + 1) + (vvyF) * (vvyF)+(vvzF) * (vvzF)-1) + + // (mfbab) * ((vvxF) * (vvxF)+(vvyF + 1) * (vvyF + 1) + (vvzF) * (vvzF)-1) + + // (mfbba) * ((vvxF) * (vvxF)+(vvyF) * (vvyF)+(vvzF + 1) * (vvzF + 1)-1) + + // (mfaab) * ((vvxF + 1) * (vvxF + 1) + (vvyF + 1) * (vvyF + 1) + (vvzF) * (vvzF)-1) + + // (mfcab) * ((vvxF - 1) * (vvxF - 1) + (vvyF + 1) * (vvyF + 1) + (vvzF) * (vvzF)-1) + + // (mfaba) * ((vvxF + 1) * (vvxF + 1) + (vvyF) * (vvyF)+(vvzF + 1) * (vvzF + 1)-1) + + // (mfcba) * ((vvxF - 1) * (vvxF - 1) + (vvyF) * (vvyF)+(vvzF + 1) * (vvzF + 1)-1) + + // (mfbaa) * ((vvxF) * (vvxF)+(vvyF + 1) * (vvyF + 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfbca) * ((vvxF) * (vvxF)+(vvyF - 1) * (vvyF - 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfaaa) * ((vvxF + 1) * (vvxF + 1) + (vvyF + 1) * (vvyF + 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfcaa) * ((vvxF - 1) * (vvxF - 1) + (vvyF + 1) * (vvyF + 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfaca) * ((vvxF + 1) * (vvxF + 1) + (vvyF - 1) * (vvyF - 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfcca) * ((vvxF - 1) * (vvxF - 1) + (vvyF - 1) * (vvyF - 1) + (vvzF + 1) * (vvzF + 1)-1) + + // (mfbbb) * ((vvxF) * (vvxF)+(vvyF) * (vvyF)+(vvzF) * (vvzF)-1); + //if (divAfterSource - divBeforeSource != 0 && phi[REST]>0.0001 && phi[REST]<0.999) { + // std::cout << phi[REST]<<" "<< divAfterSource << " " << divBeforeSource <<" "<< divAfterSource/ divBeforeSource << std::endl; + //} + + //if (fabs(divAfterSource - divBeforeSource)/(fabs(divAfterSource) + fabs(divBeforeSource)+1e-10) > 1e-5) { + // LBMReal scaleDiv =0.95+(1-0.95)* (divBeforeSource) / (divBeforeSource - divAfterSource); + + // forcingTerm[E] *=scaleDiv; + // forcingTerm[N] *=scaleDiv; + // forcingTerm[T] *=scaleDiv; + // forcingTerm[NE] *=scaleDiv; + // forcingTerm[NW] *=scaleDiv; + // forcingTerm[TE] *=scaleDiv; + // forcingTerm[TW] *=scaleDiv; + // forcingTerm[TN] *=scaleDiv; + // forcingTerm[TS] *=scaleDiv; + // forcingTerm[TNE] *=scaleDiv; + // forcingTerm[TNW] *=scaleDiv; + // forcingTerm[TSE] *=scaleDiv; + // forcingTerm[TSW] *=scaleDiv; + // forcingTerm[W] *=scaleDiv; + // forcingTerm[S] *=scaleDiv; + // forcingTerm[B] *=scaleDiv; + // forcingTerm[SW] *=scaleDiv; + // forcingTerm[SE] *=scaleDiv; + // forcingTerm[BW] *=scaleDiv; + // forcingTerm[BE] *=scaleDiv; + // forcingTerm[BS] *=scaleDiv; + // forcingTerm[BN] *=scaleDiv; + // forcingTerm[BSW] *=scaleDiv; + // forcingTerm[BSE] *=scaleDiv; + // forcingTerm[BNW] *=scaleDiv; + // forcingTerm[BNE] *=scaleDiv; + // forcingTerm[REST] *=scaleDiv; + //} + //////// + + + //mfcbb += 3.0 * (0.5 * forcingTerm[E]) / rho; //-(3.0*p1 - rho)*WEIGTH[E ]; + //mfbcb += 3.0 * (0.5 * forcingTerm[N]) / rho; //-(3.0*p1 - rho)*WEIGTH[N ]; + //mfbbc += 3.0 * (0.5 * forcingTerm[T]) / rho; //-(3.0*p1 - rho)*WEIGTH[T ]; + //mfccb += 3.0 * (0.5 * forcingTerm[NE]) / rho; //-(3.0*p1 - rho)*WEIGTH[NE ]; + //mfacb += 3.0 * (0.5 * forcingTerm[NW]) / rho; //-(3.0*p1 - rho)*WEIGTH[NW ]; + //mfcbc += 3.0 * (0.5 * forcingTerm[TE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TE ]; + //mfabc += 3.0 * (0.5 * forcingTerm[TW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TW ]; + //mfbcc += 3.0 * (0.5 * forcingTerm[TN]) / rho; //-(3.0*p1 - rho)*WEIGTH[TN ]; + //mfbac += 3.0 * (0.5 * forcingTerm[TS]) / rho; //-(3.0*p1 - rho)*WEIGTH[TS ]; + //mfccc += 3.0 * (0.5 * forcingTerm[TNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNE]; + //mfacc += 3.0 * (0.5 * forcingTerm[TNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNW]; + //mfcac += 3.0 * (0.5 * forcingTerm[TSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSE]; + //mfaac += 3.0 * (0.5 * forcingTerm[TSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSW]; + //mfabb += 3.0 * (0.5 * forcingTerm[W]) / rho; //-(3.0*p1 - rho)*WEIGTH[W ]; + //mfbab += 3.0 * (0.5 * forcingTerm[S]) / rho; //-(3.0*p1 - rho)*WEIGTH[S ]; + //mfbba += 3.0 * (0.5 * forcingTerm[B]) / rho; //-(3.0*p1 - rho)*WEIGTH[B ]; + //mfaab += 3.0 * (0.5 * forcingTerm[SW]) / rho; //-(3.0*p1 - rho)*WEIGTH[SW ]; + //mfcab += 3.0 * (0.5 * forcingTerm[SE]) / rho; //-(3.0*p1 - rho)*WEIGTH[SE ]; + //mfaba += 3.0 * (0.5 * forcingTerm[BW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BW ]; + //mfcba += 3.0 * (0.5 * forcingTerm[BE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BE ]; + //mfbaa += 3.0 * (0.5 * forcingTerm[BS]) / rho; //-(3.0*p1 - rho)*WEIGTH[BS ]; + //mfbca += 3.0 * (0.5 * forcingTerm[BN]) / rho; //-(3.0*p1 - rho)*WEIGTH[BN ]; + //mfaaa += 3.0 * (0.5 * forcingTerm[BSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSW]; + //mfcaa += 3.0 * (0.5 * forcingTerm[BSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSE]; + //mfaca += 3.0 * (0.5 * forcingTerm[BNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNW]; + //mfcca += 3.0 * (0.5 * forcingTerm[BNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNE]; + //mfbbb += 3.0 * (0.5 * forcingTerm[REST]) / rho; //- (3.0*p1 - rho)*WEIGTH[REST] + + //-------------------------------------------------------- + + + + + + //////end classic source term + + + + + //forcing + /////////////////////////////////////////////////////////////////////////////////////////// + if (withForcing) + { + muX1 = static_cast<double>(x1 - 1 + ix1 * maxX1); + muX2 = static_cast<double>(x2 - 1 + ix2 * maxX2); + muX3 = static_cast<double>(x3 - 1 + ix3 * maxX3); + + //forcingX1 = muForcingX1.Eval(); + //forcingX2 = muForcingX2.Eval(); + //forcingX3 = muForcingX3.Eval(); + + //vvx += forcingX1 * deltaT * 0.5; // X + //vvy += forcingX2 * deltaT * 0.5; // Y + //vvz += forcingX3 * deltaT * 0.5; // Z + } + + LBMReal vx2; + LBMReal vy2; + LBMReal vz2; + vx2 = vvx * vvx; + vy2 = vvy * vvy; + vz2 = vvz * vvz; + /////////////////////////////////////////////////////////////////////////////////////////// + LBMReal oMdrho; + + + oMdrho = mfccc + mfaaa; + m0 = mfaca + mfcac; + m1 = mfacc + mfcaa; + m2 = mfaac + mfcca; + oMdrho += m0; + m1 += m2; + oMdrho += m1; + m0 = mfbac + mfbca; + m1 = mfbaa + mfbcc; + m0 += m1; + m1 = mfabc + mfcba; + m2 = mfaba + mfcbc; + m1 += m2; + m0 += m1; + m1 = mfacb + mfcab; + m2 = mfaab + mfccb; + m1 += m2; + m0 += m1; + oMdrho += m0; + m0 = mfabb + mfcbb; + m1 = mfbab + mfbcb; + m2 = mfbba + mfbbc; + m0 += m1 + m2; + m0 += mfbbb; //hat gefehlt + oMdrho = (rhoRef - (oMdrho + m0))/rhoRef;// 12.03.21 check derivation!!!! + + //////////////////////////////////////////////////////////////////////////////////// + LBMReal wadjust; + LBMReal qudricLimit = 0.01; + //////////////////////////////////////////////////////////////////////////////////// + //Hin + //////////////////////////////////////////////////////////////////////////////////// + // mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + m2 = mfaaa + mfaac; + m1 = mfaac - mfaaa; + m0 = m2 + mfaab; + mfaaa = m0; + m0 += c1o36 * oMdrho; + mfaab = m1 - m0 * vvz; + mfaac = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaba + mfabc; + m1 = mfabc - mfaba; + m0 = m2 + mfabb; + mfaba = m0; + m0 += c1o9 * oMdrho; + mfabb = m1 - m0 * vvz; + mfabc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaca + mfacc; + m1 = mfacc - mfaca; + m0 = m2 + mfacb; + mfaca = m0; + m0 += c1o36 * oMdrho; + mfacb = m1 - m0 * vvz; + mfacc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbaa + mfbac; + m1 = mfbac - mfbaa; + m0 = m2 + mfbab; + mfbaa = m0; + m0 += c1o9 * oMdrho; + mfbab = m1 - m0 * vvz; + mfbac = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbba + mfbbc; + m1 = mfbbc - mfbba; + m0 = m2 + mfbbb; + mfbba = m0; + m0 += c4o9 * oMdrho; + mfbbb = m1 - m0 * vvz; + mfbbc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbca + mfbcc; + m1 = mfbcc - mfbca; + m0 = m2 + mfbcb; + mfbca = m0; + m0 += c1o9 * oMdrho; + mfbcb = m1 - m0 * vvz; + mfbcc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcaa + mfcac; + m1 = mfcac - mfcaa; + m0 = m2 + mfcab; + mfcaa = m0; + m0 += c1o36 * oMdrho; + mfcab = m1 - m0 * vvz; + mfcac = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcba + mfcbc; + m1 = mfcbc - mfcba; + m0 = m2 + mfcbb; + mfcba = m0; + m0 += c1o9 * oMdrho; + mfcbb = m1 - m0 * vvz; + mfcbc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcca + mfccc; + m1 = mfccc - mfcca; + m0 = m2 + mfccb; + mfcca = m0; + m0 += c1o36 * oMdrho; + mfccb = m1 - m0 * vvz; + mfccc = m2 - 2. * m1 * vvz + vz2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + // mit 1/6, 0, 1/18, 2/3, 0, 2/9, 1/6, 0, 1/18 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + m2 = mfaaa + mfaca; + m1 = mfaca - mfaaa; + m0 = m2 + mfaba; + mfaaa = m0; + m0 += c1o6 * oMdrho; + mfaba = m1 - m0 * vvy; + mfaca = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaab + mfacb; + m1 = mfacb - mfaab; + m0 = m2 + mfabb; + mfaab = m0; + mfabb = m1 - m0 * vvy; + mfacb = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaac + mfacc; + m1 = mfacc - mfaac; + m0 = m2 + mfabc; + mfaac = m0; + m0 += c1o18 * oMdrho; + mfabc = m1 - m0 * vvy; + mfacc = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbaa + mfbca; + m1 = mfbca - mfbaa; + m0 = m2 + mfbba; + mfbaa = m0; + m0 += c2o3 * oMdrho; + mfbba = m1 - m0 * vvy; + mfbca = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbab + mfbcb; + m1 = mfbcb - mfbab; + m0 = m2 + mfbbb; + mfbab = m0; + mfbbb = m1 - m0 * vvy; + mfbcb = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfbac + mfbcc; + m1 = mfbcc - mfbac; + m0 = m2 + mfbbc; + mfbac = m0; + m0 += c2o9 * oMdrho; + mfbbc = m1 - m0 * vvy; + mfbcc = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcaa + mfcca; + m1 = mfcca - mfcaa; + m0 = m2 + mfcba; + mfcaa = m0; + m0 += c1o6 * oMdrho; + mfcba = m1 - m0 * vvy; + mfcca = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcab + mfccb; + m1 = mfccb - mfcab; + m0 = m2 + mfcbb; + mfcab = m0; + mfcbb = m1 - m0 * vvy; + mfccb = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfcac + mfccc; + m1 = mfccc - mfcac; + m0 = m2 + mfcbc; + mfcac = m0; + m0 += c1o18 * oMdrho; + mfcbc = m1 - m0 * vvy; + mfccc = m2 - 2. * m1 * vvy + vy2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + // mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + m2 = mfaaa + mfcaa; + m1 = mfcaa - mfaaa; + m0 = m2 + mfbaa; + mfaaa = m0; + m0 += 1. * oMdrho; + mfbaa = m1 - m0 * vvx; + mfcaa = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaba + mfcba; + m1 = mfcba - mfaba; + m0 = m2 + mfbba; + mfaba = m0; + mfbba = m1 - m0 * vvx; + mfcba = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaca + mfcca; + m1 = mfcca - mfaca; + m0 = m2 + mfbca; + mfaca = m0; + m0 += c1o3 * oMdrho; + mfbca = m1 - m0 * vvx; + mfcca = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaab + mfcab; + m1 = mfcab - mfaab; + m0 = m2 + mfbab; + mfaab = m0; + mfbab = m1 - m0 * vvx; + mfcab = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfabb + mfcbb; + m1 = mfcbb - mfabb; + m0 = m2 + mfbbb; + mfabb = m0; + mfbbb = m1 - m0 * vvx; + mfcbb = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfacb + mfccb; + m1 = mfccb - mfacb; + m0 = m2 + mfbcb; + mfacb = m0; + mfbcb = m1 - m0 * vvx; + mfccb = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfaac + mfcac; + m1 = mfcac - mfaac; + m0 = m2 + mfbac; + mfaac = m0; + m0 += c1o3 * oMdrho; + mfbac = m1 - m0 * vvx; + mfcac = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfabc + mfcbc; + m1 = mfcbc - mfabc; + m0 = m2 + mfbbc; + mfabc = m0; + mfbbc = m1 - m0 * vvx; + mfcbc = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + m2 = mfacc + mfccc; + m1 = mfccc - mfacc; + m0 = m2 + mfbcc; + mfacc = m0; + m0 += c1o9 * oMdrho; + mfbcc = m1 - m0 * vvx; + mfccc = m2 - 2. * m1 * vvx + vx2 * m0; + //////////////////////////////////////////////////////////////////////////////////// + // Cumulants + //////////////////////////////////////////////////////////////////////////////////// + + + // mfaaa = 0.0; + LBMReal OxxPyyPzz = 1.; //omega2 or bulk viscosity + // LBMReal OxyyPxzz = 1.;//-s9;//2+s9;// + // LBMReal OxyyMxzz = 1.;//2+s9;// + LBMReal O4 = 1.; + LBMReal O5 = 1.; + LBMReal O6 = 1.; + + + + /////fourth order parameters; here only for test. Move out of loop! + + LBMReal OxyyPxzz = 8.0 * (collFactorM - 2.0) * (OxxPyyPzz * (3.0 * collFactorM - 1.0) - 5.0 * collFactorM) / (8.0 * (5.0 - 2.0 * collFactorM) * collFactorM + OxxPyyPzz * (8.0 + collFactorM * (9.0 * collFactorM - 26.0))); + LBMReal OxyyMxzz = 8.0 * (collFactorM - 2.0) * (collFactorM + OxxPyyPzz * (3.0 * collFactorM - 7.0)) / (OxxPyyPzz * (56.0 - 42.0 * collFactorM + 9.0 * collFactorM * collFactorM) - 8.0 * collFactorM); + // LBMReal Oxyz = 24.0 * (collFactorM - 2.0) * (4.0 * collFactorM * collFactorM + collFactorM * OxxPyyPzz * (18.0 - 13.0 * collFactorM) + OxxPyyPzz * OxxPyyPzz * (2.0 + collFactorM * (6.0 * collFactorM - 11.0))) / (16.0 * collFactorM * collFactorM * (collFactorM - 6.0) - 2.0 * collFactorM * OxxPyyPzz * (216.0 + 5.0 * collFactorM * (9.0 * collFactorM - 46.0)) + OxxPyyPzz * OxxPyyPzz * (collFactorM * (3.0 * collFactorM - 10.0) * (15.0 * collFactorM - 28.0) - 48.0)); + LBMReal A = (4.0 * collFactorM * collFactorM + 2.0 * collFactorM * OxxPyyPzz * (collFactorM - 6.0) + OxxPyyPzz * OxxPyyPzz * (collFactorM * (10.0 - 3.0 * collFactorM) - 4.0)) / ((collFactorM - OxxPyyPzz) * (OxxPyyPzz * (2.0 + 3.0 * collFactorM) - 8.0 * collFactorM)); + //FIXME: warning C4459: declaration of 'B' hides global declaration (message : see declaration of 'D3Q27System::B' ) + LBMReal BB = (4.0 * collFactorM * OxxPyyPzz * (9.0 * collFactorM - 16.0) - 4.0 * collFactorM * collFactorM - 2.0 * OxxPyyPzz * OxxPyyPzz * (2.0 + 9.0 * collFactorM * (collFactorM - 2.0))) / (3.0 * (collFactorM - OxxPyyPzz) * (OxxPyyPzz * (2.0 + 3.0 * collFactorM) - 8.0 * collFactorM)); + + + //Cum 4. + //LBMReal CUMcbb = mfcbb - ((mfcaa + c1o3 * oMdrho) * mfabb + 2. * mfbba * mfbab); // till 18.05.2015 + //LBMReal CUMbcb = mfbcb - ((mfaca + c1o3 * oMdrho) * mfbab + 2. * mfbba * mfabb); // till 18.05.2015 + //LBMReal CUMbbc = mfbbc - ((mfaac + c1o3 * oMdrho) * mfbba + 2. * mfbab * mfabb); // till 18.05.2015 + + LBMReal CUMcbb = mfcbb - ((mfcaa + c1o3) * mfabb + 2. * mfbba * mfbab); + LBMReal CUMbcb = mfbcb - ((mfaca + c1o3) * mfbab + 2. * mfbba * mfabb); + LBMReal CUMbbc = mfbbc - ((mfaac + c1o3) * mfbba + 2. * mfbab * mfabb); + + LBMReal CUMcca = mfcca - ((mfcaa * mfaca + 2. * mfbba * mfbba) + c1o3 * (mfcaa + mfaca) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho); + LBMReal CUMcac = mfcac - ((mfcaa * mfaac + 2. * mfbab * mfbab) + c1o3 * (mfcaa + mfaac) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho); + LBMReal CUMacc = mfacc - ((mfaac * mfaca + 2. * mfabb * mfabb) + c1o3 * (mfaac + mfaca) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho); + + //Cum 5. + LBMReal CUMbcc = mfbcc - (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + 2. * (mfbab * mfacb + mfbba * mfabc)) - c1o3 * (mfbca + mfbac) * oMdrho; + LBMReal CUMcbc = mfcbc - (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + 2. * (mfabb * mfcab + mfbba * mfbac)) - c1o3 * (mfcba + mfabc) * oMdrho; + LBMReal CUMccb = mfccb - (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + 2. * (mfbab * mfbca + mfabb * mfcba)) - c1o3 * (mfacb + mfcab) * oMdrho; + + //Cum 6. + LBMReal CUMccc = mfccc + ((-4. * mfbbb * mfbbb + - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) + - 4. * (mfabb * mfcbb + mfbab * mfbcb + mfbba * mfbbc) + - 2. * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) + + (4. * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + + 2. * (mfcaa * mfaca * mfaac) + + 16. * mfbba * mfbab * mfabb) + - c1o3 * (mfacc + mfcac + mfcca) * oMdrho - c1o9 * oMdrho * oMdrho + - c1o9 * (mfcaa + mfaca + mfaac) * oMdrho * (1. - 2. * oMdrho) - c1o27 * oMdrho * oMdrho * (-2. * oMdrho) + + (2. * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa)) * c2o3 * oMdrho) + c1o27 * oMdrho; + + //2. + // linear combinations + LBMReal mxxPyyPzz = mfcaa + mfaca + mfaac; + + // LBMReal mfaaaS = (mfaaa * (-4 - 3 * OxxPyyPzz * (-1 + rho)) + 6 * mxxPyyPzz * OxxPyyPzz * (-1 + rho)) / (-4 + 3 * OxxPyyPzz * (-1 + rho)); + mxxPyyPzz -= mfaaa ;//12.03.21 shifted by mfaaa + //mxxPyyPzz-=(mfaaa+mfaaaS)*c1o2;//12.03.21 shifted by mfaaa + LBMReal mxxMyy = mfcaa - mfaca; + LBMReal mxxMzz = mfcaa - mfaac; + + //applying phase field gradients first part: + // mxxPyyPzz += c2o3 * rhoToPhi * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz); + // 17.03.2021 attempt for statililization by assymptotically vanishing bias + //LBMReal correctionScaling = + // rhoToPhi / rho; // +0.5;// (vx2 + vy2 + vz2) * 100;// +0.5;//(vx2 + vy2 + vz2)*1000; + //mxxPyyPzz += (1.0 / 6.0) * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * + // correctionScaling; // As in Hesam's code + //mxxMyy += c1o3 * (dX1_phi * vvx - dX2_phi * vvy) * correctionScaling; + //mxxMzz += c1o3 * (dX1_phi * vvx - dX3_phi * vvz) * correctionScaling; + //mfabb += c1o6 * (dX2_phi * vvz + dX3_phi * vvy) * correctionScaling; + //mfbab += c1o6 * (dX1_phi * vvz + dX3_phi * vvx) * correctionScaling; + //mfbba += c1o6 * (dX1_phi * vvy + dX2_phi * vvx) * correctionScaling; + + LBMReal dxux = -c1o2 * collFactorM * (mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz * (/*mfaaa*/ -mxxPyyPzz); + LBMReal dyuy = dxux + collFactorM * c3o2 * mxxMyy; + LBMReal dzuz = dxux + collFactorM * c3o2 * mxxMzz; + + LBMReal Dxy = -three * collFactorM * mfbba; + LBMReal Dxz = -three * collFactorM * mfbab; + LBMReal Dyz = -three * collFactorM * mfabb; + + + //relax + mxxPyyPzz += OxxPyyPzz * (/*mfaaa*/ - mxxPyyPzz) - 3. * (1. - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz); + mxxMyy += collFactorM * (-mxxMyy) - 3. * (1. - c1o2 * collFactorM) * (vx2 * dxux - vy2 * dyuy); + mxxMzz += collFactorM * (-mxxMzz) - 3. * (1. - c1o2 * collFactorM) * (vx2 * dxux - vz2 * dzuz); + + mfabb += collFactorM * (-mfabb); + mfbab += collFactorM * (-mfbab); + mfbba += collFactorM * (-mfbba); + + //applying phase field gradients second part: + //mxxPyyPzz += c2o3 * rhoToPhi * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz); + //mxxPyyPzz += (1.0 / 6.0) * (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * + // correctionScaling; // As in Hesam's code + //mxxMyy += c1o3 * (dX1_phi * vvx - dX2_phi * vvy) * correctionScaling; + //mxxMzz += c1o3 * (dX1_phi * vvx - dX3_phi * vvz) * correctionScaling; + //mfabb += c1o6 * (dX2_phi * vvz + dX3_phi * vvy) * correctionScaling; + //mfbab += c1o6 * (dX1_phi * vvz + dX3_phi * vvx) * correctionScaling; + //mfbba += c1o6 * (dX1_phi * vvy + dX2_phi * vvx) * correctionScaling; + + ////updated pressure + //mfaaa += (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * correctionScaling; + mfaaa = 0.0; // Pressure elimination as in standard velocity model + // mfaaa += (rho - c1) * (dxux + dyuy + dzuz); + + mxxPyyPzz += mfaaa; // 12.03.21 shifted by mfaaa + + // mxxPyyPzz += (mfaaa + mfaaaS) * c1o2; + //mfaaa = mfaaaS; + // linear combinations back + mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); + mfaca = c1o3 * (-2. * mxxMyy + mxxMzz + mxxPyyPzz); + mfaac = c1o3 * (mxxMyy - 2. * mxxMzz + mxxPyyPzz); + + //3. + // linear combinations + LBMReal mxxyPyzz = mfcba + mfabc; + LBMReal mxxyMyzz = mfcba - mfabc; + + LBMReal mxxzPyyz = mfcab + mfacb; + LBMReal mxxzMyyz = mfcab - mfacb; + + LBMReal mxyyPxzz = mfbca + mfbac; + LBMReal mxyyMxzz = mfbca - mfbac; + + //relax + wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mfbbb) / (fabs(mfbbb) + qudricLimit); + mfbbb += wadjust * (-mfbbb); + wadjust = OxyyPxzz + (1. - OxyyPxzz) * fabs(mxxyPyzz) / (fabs(mxxyPyzz) + qudricLimit); + mxxyPyzz += wadjust * (-mxxyPyzz); + wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mxxyMyzz) / (fabs(mxxyMyzz) + qudricLimit); + mxxyMyzz += wadjust * (-mxxyMyzz); + wadjust = OxyyPxzz + (1. - OxyyPxzz) * fabs(mxxzPyyz) / (fabs(mxxzPyyz) + qudricLimit); + mxxzPyyz += wadjust * (-mxxzPyyz); + wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mxxzMyyz) / (fabs(mxxzMyyz) + qudricLimit); + mxxzMyyz += wadjust * (-mxxzMyyz); + wadjust = OxyyPxzz + (1. - OxyyPxzz) * fabs(mxyyPxzz) / (fabs(mxyyPxzz) + qudricLimit); + mxyyPxzz += wadjust * (-mxyyPxzz); + wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mxyyMxzz) / (fabs(mxyyMxzz) + qudricLimit); + mxyyMxzz += wadjust * (-mxyyMxzz); + + // linear combinations back + mfcba = (mxxyMyzz + mxxyPyzz) * c1o2; + mfabc = (-mxxyMyzz + mxxyPyzz) * c1o2; + mfcab = (mxxzMyyz + mxxzPyyz) * c1o2; + mfacb = (-mxxzMyyz + mxxzPyyz) * c1o2; + mfbca = (mxyyMxzz + mxyyPxzz) * c1o2; + mfbac = (-mxyyMxzz + mxyyPxzz) * c1o2; + + //4. + //CUMacc += O4 * (-CUMacc); + //CUMcac += O4 * (-CUMcac); + //CUMcca += O4 * (-CUMcca); + + //CUMbbc += O4 * (-CUMbbc); + //CUMbcb += O4 * (-CUMbcb); + //CUMcbb += O4 * (-CUMcbb); + CUMacc = -O4 * (one / collFactorM - c1o2) * (dyuy + dzuz) * c2o3 * A + (one - O4) * (CUMacc); + CUMcac = -O4 * (one / collFactorM - c1o2) * (dxux + dzuz) * c2o3 * A + (one - O4) * (CUMcac); + CUMcca = -O4 * (one / collFactorM - c1o2) * (dyuy + dxux) * c2o3 * A + (one - O4) * (CUMcca); + CUMbbc = -O4 * (one / collFactorM - c1o2) * Dxy * c1o3 * BB + (one - O4) * (CUMbbc); + CUMbcb = -O4 * (one / collFactorM - c1o2) * Dxz * c1o3 * BB + (one - O4) * (CUMbcb); + CUMcbb = -O4 * (one / collFactorM - c1o2) * Dyz * c1o3 * BB + (one - O4) * (CUMcbb); + + //5. + CUMbcc += O5 * (-CUMbcc); + CUMcbc += O5 * (-CUMcbc); + CUMccb += O5 * (-CUMccb); + + //6. + CUMccc += O6 * (-CUMccc); + + //back cumulants to central moments + //4. + //mfcbb = CUMcbb + ((mfcaa + c1o3 * oMdrho) * mfabb + 2. * mfbba * mfbab); // till 18.05.2015 + //mfbcb = CUMbcb + ((mfaca + c1o3 * oMdrho) * mfbab + 2. * mfbba * mfabb); // till 18.05.2015 + //mfbbc = CUMbbc + ((mfaac + c1o3 * oMdrho) * mfbba + 2. * mfbab * mfabb); // till 18.05.2015 + + mfcbb = CUMcbb + ((mfcaa + c1o3) * mfabb + 2. * mfbba * mfbab); + mfbcb = CUMbcb + ((mfaca + c1o3) * mfbab + 2. * mfbba * mfabb); + mfbbc = CUMbbc + ((mfaac + c1o3) * mfbba + 2. * mfbab * mfabb); + + mfcca = CUMcca + (mfcaa * mfaca + 2. * mfbba * mfbba) + c1o3 * (mfcaa + mfaca) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho; + mfcac = CUMcac + (mfcaa * mfaac + 2. * mfbab * mfbab) + c1o3 * (mfcaa + mfaac) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho; + mfacc = CUMacc + (mfaac * mfaca + 2. * mfabb * mfabb) + c1o3 * (mfaac + mfaca) * oMdrho + c1o9 * (oMdrho - c1) * oMdrho; + + //5. + mfbcc = CUMbcc + (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + 2. * (mfbab * mfacb + mfbba * mfabc)) + c1o3 * (mfbca + mfbac) * oMdrho; + mfcbc = CUMcbc + (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + 2. * (mfabb * mfcab + mfbba * mfbac)) + c1o3 * (mfcba + mfabc) * oMdrho; + mfccb = CUMccb + (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + 2. * (mfbab * mfbca + mfabb * mfcba)) + c1o3 * (mfacb + mfcab) * oMdrho; + + //6. + mfccc = CUMccc - ((-4. * mfbbb * mfbbb + - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) + - 4. * (mfabb * mfcbb + mfbac * mfbca + mfbba * mfbbc) + - 2. * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) + + (4. * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + + 2. * (mfcaa * mfaca * mfaac) + + 16. * mfbba * mfbab * mfabb) + - c1o3 * (mfacc + mfcac + mfcca) * oMdrho - c1o9 * oMdrho * oMdrho + - c1o9 * (mfcaa + mfaca + mfaac) * oMdrho * (1. - 2. * oMdrho) - c1o27 * oMdrho * oMdrho * (-2. * oMdrho) + + (2. * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa)) * c2o3 * oMdrho) - c1o27 * oMdrho; + + + //////// + + + //////////////////////////////////////////////////////////////////////////////////// + //forcing + mfbaa = -mfbaa; + mfaba = -mfaba; + mfaab = -mfaab; + ////////////////////////////////////////////////////////////////////////////////////// + + //////////////////////////////////////////////////////////////////////////////////// + //back + //////////////////////////////////////////////////////////////////////////////////// + //mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + m0 = mfaac * c1o2 + mfaab * (vvz - c1o2) + (mfaaa + 1. * oMdrho) * (vz2 - vvz) * c1o2; + m1 = -mfaac - 2. * mfaab * vvz + mfaaa * (1. - vz2) - 1. * oMdrho * vz2; + m2 = mfaac * c1o2 + mfaab * (vvz + c1o2) + (mfaaa + 1. * oMdrho) * (vz2 + vvz) * c1o2; + mfaaa = m0; + mfaab = m1; + mfaac = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfabc * c1o2 + mfabb * (vvz - c1o2) + mfaba * (vz2 - vvz) * c1o2; + m1 = -mfabc - 2. * mfabb * vvz + mfaba * (1. - vz2); + m2 = mfabc * c1o2 + mfabb * (vvz + c1o2) + mfaba * (vz2 + vvz) * c1o2; + mfaba = m0; + mfabb = m1; + mfabc = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfacc * c1o2 + mfacb * (vvz - c1o2) + (mfaca + c1o3 * oMdrho) * (vz2 - vvz) * c1o2; + m1 = -mfacc - 2. * mfacb * vvz + mfaca * (1. - vz2) - c1o3 * oMdrho * vz2; + m2 = mfacc * c1o2 + mfacb * (vvz + c1o2) + (mfaca + c1o3 * oMdrho) * (vz2 + vvz) * c1o2; + mfaca = m0; + mfacb = m1; + mfacc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfbac * c1o2 + mfbab * (vvz - c1o2) + mfbaa * (vz2 - vvz) * c1o2; + m1 = -mfbac - 2. * mfbab * vvz + mfbaa * (1. - vz2); + m2 = mfbac * c1o2 + mfbab * (vvz + c1o2) + mfbaa * (vz2 + vvz) * c1o2; + mfbaa = m0; + mfbab = m1; + mfbac = m2; + /////////b////////////////////////////////////////////////////////////////////////// + m0 = mfbbc * c1o2 + mfbbb * (vvz - c1o2) + mfbba * (vz2 - vvz) * c1o2; + m1 = -mfbbc - 2. * mfbbb * vvz + mfbba * (1. - vz2); + m2 = mfbbc * c1o2 + mfbbb * (vvz + c1o2) + mfbba * (vz2 + vvz) * c1o2; + mfbba = m0; + mfbbb = m1; + mfbbc = m2; + /////////b////////////////////////////////////////////////////////////////////////// + m0 = mfbcc * c1o2 + mfbcb * (vvz - c1o2) + mfbca * (vz2 - vvz) * c1o2; + m1 = -mfbcc - 2. * mfbcb * vvz + mfbca * (1. - vz2); + m2 = mfbcc * c1o2 + mfbcb * (vvz + c1o2) + mfbca * (vz2 + vvz) * c1o2; + mfbca = m0; + mfbcb = m1; + mfbcc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcac * c1o2 + mfcab * (vvz - c1o2) + (mfcaa + c1o3 * oMdrho) * (vz2 - vvz) * c1o2; + m1 = -mfcac - 2. * mfcab * vvz + mfcaa * (1. - vz2) - c1o3 * oMdrho * vz2; + m2 = mfcac * c1o2 + mfcab * (vvz + c1o2) + (mfcaa + c1o3 * oMdrho) * (vz2 + vvz) * c1o2; + mfcaa = m0; + mfcab = m1; + mfcac = m2; + /////////c////////////////////////////////////////////////////////////////////////// + m0 = mfcbc * c1o2 + mfcbb * (vvz - c1o2) + mfcba * (vz2 - vvz) * c1o2; + m1 = -mfcbc - 2. * mfcbb * vvz + mfcba * (1. - vz2); + m2 = mfcbc * c1o2 + mfcbb * (vvz + c1o2) + mfcba * (vz2 + vvz) * c1o2; + mfcba = m0; + mfcbb = m1; + mfcbc = m2; + /////////c////////////////////////////////////////////////////////////////////////// + m0 = mfccc * c1o2 + mfccb * (vvz - c1o2) + (mfcca + c1o9 * oMdrho) * (vz2 - vvz) * c1o2; + m1 = -mfccc - 2. * mfccb * vvz + mfcca * (1. - vz2) - c1o9 * oMdrho * vz2; + m2 = mfccc * c1o2 + mfccb * (vvz + c1o2) + (mfcca + c1o9 * oMdrho) * (vz2 + vvz) * c1o2; + mfcca = m0; + mfccb = m1; + mfccc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + //mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + m0 = mfaca * c1o2 + mfaba * (vvy - c1o2) + (mfaaa + c1o6 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfaca - 2. * mfaba * vvy + mfaaa * (1. - vy2) - c1o6 * oMdrho * vy2; + m2 = mfaca * c1o2 + mfaba * (vvy + c1o2) + (mfaaa + c1o6 * oMdrho) * (vy2 + vvy) * c1o2; + mfaaa = m0; + mfaba = m1; + mfaca = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfacb * c1o2 + mfabb * (vvy - c1o2) + (mfaab + c2o3 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfacb - 2. * mfabb * vvy + mfaab * (1. - vy2) - c2o3 * oMdrho * vy2; + m2 = mfacb * c1o2 + mfabb * (vvy + c1o2) + (mfaab + c2o3 * oMdrho) * (vy2 + vvy) * c1o2; + mfaab = m0; + mfabb = m1; + mfacb = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfacc * c1o2 + mfabc * (vvy - c1o2) + (mfaac + c1o6 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfacc - 2. * mfabc * vvy + mfaac * (1. - vy2) - c1o6 * oMdrho * vy2; + m2 = mfacc * c1o2 + mfabc * (vvy + c1o2) + (mfaac + c1o6 * oMdrho) * (vy2 + vvy) * c1o2; + mfaac = m0; + mfabc = m1; + mfacc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfbca * c1o2 + mfbba * (vvy - c1o2) + mfbaa * (vy2 - vvy) * c1o2; + m1 = -mfbca - 2. * mfbba * vvy + mfbaa * (1. - vy2); + m2 = mfbca * c1o2 + mfbba * (vvy + c1o2) + mfbaa * (vy2 + vvy) * c1o2; + mfbaa = m0; + mfbba = m1; + mfbca = m2; + /////////b////////////////////////////////////////////////////////////////////////// + m0 = mfbcb * c1o2 + mfbbb * (vvy - c1o2) + mfbab * (vy2 - vvy) * c1o2; + m1 = -mfbcb - 2. * mfbbb * vvy + mfbab * (1. - vy2); + m2 = mfbcb * c1o2 + mfbbb * (vvy + c1o2) + mfbab * (vy2 + vvy) * c1o2; + mfbab = m0; + mfbbb = m1; + mfbcb = m2; + /////////b////////////////////////////////////////////////////////////////////////// + m0 = mfbcc * c1o2 + mfbbc * (vvy - c1o2) + mfbac * (vy2 - vvy) * c1o2; + m1 = -mfbcc - 2. * mfbbc * vvy + mfbac * (1. - vy2); + m2 = mfbcc * c1o2 + mfbbc * (vvy + c1o2) + mfbac * (vy2 + vvy) * c1o2; + mfbac = m0; + mfbbc = m1; + mfbcc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcca * c1o2 + mfcba * (vvy - c1o2) + (mfcaa + c1o18 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfcca - 2. * mfcba * vvy + mfcaa * (1. - vy2) - c1o18 * oMdrho * vy2; + m2 = mfcca * c1o2 + mfcba * (vvy + c1o2) + (mfcaa + c1o18 * oMdrho) * (vy2 + vvy) * c1o2; + mfcaa = m0; + mfcba = m1; + mfcca = m2; + /////////c////////////////////////////////////////////////////////////////////////// + m0 = mfccb * c1o2 + mfcbb * (vvy - c1o2) + (mfcab + c2o9 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfccb - 2. * mfcbb * vvy + mfcab * (1. - vy2) - c2o9 * oMdrho * vy2; + m2 = mfccb * c1o2 + mfcbb * (vvy + c1o2) + (mfcab + c2o9 * oMdrho) * (vy2 + vvy) * c1o2; + mfcab = m0; + mfcbb = m1; + mfccb = m2; + /////////c////////////////////////////////////////////////////////////////////////// + m0 = mfccc * c1o2 + mfcbc * (vvy - c1o2) + (mfcac + c1o18 * oMdrho) * (vy2 - vvy) * c1o2; + m1 = -mfccc - 2. * mfcbc * vvy + mfcac * (1. - vy2) - c1o18 * oMdrho * vy2; + m2 = mfccc * c1o2 + mfcbc * (vvy + c1o2) + (mfcac + c1o18 * oMdrho) * (vy2 + vvy) * c1o2; + mfcac = m0; + mfcbc = m1; + mfccc = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + //mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + m0 = mfcaa * c1o2 + mfbaa * (vvx - c1o2) + (mfaaa + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcaa - 2. * mfbaa * vvx + mfaaa * (1. - vx2) - c1o36 * oMdrho * vx2; + m2 = mfcaa * c1o2 + mfbaa * (vvx + c1o2) + (mfaaa + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; + mfaaa = m0; + mfbaa = m1; + mfcaa = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcba * c1o2 + mfbba * (vvx - c1o2) + (mfaba + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcba - 2. * mfbba * vvx + mfaba * (1. - vx2) - c1o9 * oMdrho * vx2; + m2 = mfcba * c1o2 + mfbba * (vvx + c1o2) + (mfaba + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfaba = m0; + mfbba = m1; + mfcba = m2; + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcca * c1o2 + mfbca * (vvx - c1o2) + (mfaca + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcca - 2. * mfbca * vvx + mfaca * (1. - vx2) - c1o36 * oMdrho * vx2; + m2 = mfcca * c1o2 + mfbca * (vvx + c1o2) + (mfaca + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; + mfaca = m0; + mfbca = m1; + mfcca = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcab * c1o2 + mfbab * (vvx - c1o2) + (mfaab + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcab - 2. * mfbab * vvx + mfaab * (1. - vx2) - c1o9 * oMdrho * vx2; + m2 = mfcab * c1o2 + mfbab * (vvx + c1o2) + (mfaab + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfaab = m0; + mfbab = m1; + mfcab = m2; + ///////////b//////////////////////////////////////////////////////////////////////// + m0 = mfcbb * c1o2 + mfbbb * (vvx - c1o2) + (mfabb + c4o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcbb - 2. * mfbbb * vvx + mfabb * (1. - vx2) - c4o9 * oMdrho * vx2; + m2 = mfcbb * c1o2 + mfbbb * (vvx + c1o2) + (mfabb + c4o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfabb = m0; + mfbbb = m1; + mfcbb = m2; + ///////////b//////////////////////////////////////////////////////////////////////// + m0 = mfccb * c1o2 + mfbcb * (vvx - c1o2) + (mfacb + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfccb - 2. * mfbcb * vvx + mfacb * (1. - vx2) - c1o9 * oMdrho * vx2; + m2 = mfccb * c1o2 + mfbcb * (vvx + c1o2) + (mfacb + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfacb = m0; + mfbcb = m1; + mfccb = m2; + //////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + m0 = mfcac * c1o2 + mfbac * (vvx - c1o2) + (mfaac + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcac - 2. * mfbac * vvx + mfaac * (1. - vx2) - c1o36 * oMdrho * vx2; + m2 = mfcac * c1o2 + mfbac * (vvx + c1o2) + (mfaac + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; + mfaac = m0; + mfbac = m1; + mfcac = m2; + ///////////c//////////////////////////////////////////////////////////////////////// + m0 = mfcbc * c1o2 + mfbbc * (vvx - c1o2) + (mfabc + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfcbc - 2. * mfbbc * vvx + mfabc * (1. - vx2) - c1o9 * oMdrho * vx2; + m2 = mfcbc * c1o2 + mfbbc * (vvx + c1o2) + (mfabc + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; + mfabc = m0; + mfbbc = m1; + mfcbc = m2; + ///////////c//////////////////////////////////////////////////////////////////////// + m0 = mfccc * c1o2 + mfbcc * (vvx - c1o2) + (mfacc + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; + m1 = -mfccc - 2. * mfbcc * vvx + mfacc * (1. - vx2) - c1o36 * oMdrho * vx2; + m2 = mfccc * c1o2 + mfbcc * (vvx + c1o2) + (mfacc + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; + mfacc = m0; + mfbcc = m1; + mfccc = m2; + + /////classical source term 8.4.2021 + + //mfcbb += 3.0 * (0.5 * forcingTerm[E]) / rho; //-(3.0*p1 - rho)*WEIGTH[E ]; + //mfbcb += 3.0 * (0.5 * forcingTerm[N]) / rho; //-(3.0*p1 - rho)*WEIGTH[N ]; + //mfbbc += 3.0 * (0.5 * forcingTerm[T]) / rho; //-(3.0*p1 - rho)*WEIGTH[T ]; + //mfccb += 3.0 * (0.5 * forcingTerm[NE]) / rho; //-(3.0*p1 - rho)*WEIGTH[NE ]; + //mfacb += 3.0 * (0.5 * forcingTerm[NW]) / rho; //-(3.0*p1 - rho)*WEIGTH[NW ]; + //mfcbc += 3.0 * (0.5 * forcingTerm[TE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TE ]; + //mfabc += 3.0 * (0.5 * forcingTerm[TW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TW ]; + //mfbcc += 3.0 * (0.5 * forcingTerm[TN]) / rho; //-(3.0*p1 - rho)*WEIGTH[TN ]; + //mfbac += 3.0 * (0.5 * forcingTerm[TS]) / rho; //-(3.0*p1 - rho)*WEIGTH[TS ]; + //mfccc += 3.0 * (0.5 * forcingTerm[TNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNE]; + //mfacc += 3.0 * (0.5 * forcingTerm[TNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNW]; + //mfcac += 3.0 * (0.5 * forcingTerm[TSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSE]; + //mfaac += 3.0 * (0.5 * forcingTerm[TSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSW]; + //mfabb += 3.0 * (0.5 * forcingTerm[W]) / rho; //-(3.0*p1 - rho)*WEIGTH[W ]; + //mfbab += 3.0 * (0.5 * forcingTerm[S]) / rho; //-(3.0*p1 - rho)*WEIGTH[S ]; + //mfbba += 3.0 * (0.5 * forcingTerm[B]) / rho; //-(3.0*p1 - rho)*WEIGTH[B ]; + //mfaab += 3.0 * (0.5 * forcingTerm[SW]) / rho; //-(3.0*p1 - rho)*WEIGTH[SW ]; + //mfcab += 3.0 * (0.5 * forcingTerm[SE]) / rho; //-(3.0*p1 - rho)*WEIGTH[SE ]; + //mfaba += 3.0 * (0.5 * forcingTerm[BW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BW ]; + //mfcba += 3.0 * (0.5 * forcingTerm[BE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BE ]; + //mfbaa += 3.0 * (0.5 * forcingTerm[BS]) / rho; //-(3.0*p1 - rho)*WEIGTH[BS ]; + //mfbca += 3.0 * (0.5 * forcingTerm[BN]) / rho; //-(3.0*p1 - rho)*WEIGTH[BN ]; + //mfaaa += 3.0 * (0.5 * forcingTerm[BSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSW]; + //mfcaa += 3.0 * (0.5 * forcingTerm[BSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSE]; + //mfaca += 3.0 * (0.5 * forcingTerm[BNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNW]; + //mfcca += 3.0 * (0.5 * forcingTerm[BNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNE]; + //mfbbb += 3.0 * (0.5 * forcingTerm[REST]) / rho; //- (3.0*p1 - rho)*WEIGTH[REST] + + + + ////////////////////////////////////////////////////////////////////////// + //proof correctness + ////////////////////////////////////////////////////////////////////////// +//#ifdef PROOF_CORRECTNESS +// LBMReal rho_post = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) +// + (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + (mfbaa + mfbac + mfbca + mfbcc) +// + (mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; +// //LBMReal dif = fabs(drho - rho_post); +// LBMReal dif = drho + (dX1_phi * vvx + dX2_phi * vvy + dX3_phi * vvz) * correctionScaling - rho_post; +//#ifdef SINGLEPRECISION +// if (dif > 10.0E-7 || dif < -10.0E-7) +//#else +// if (dif > 10.0E-15 || dif < -10.0E-15) +//#endif +// { +// UB_THROW(UbException(UB_EXARGS, "drho=" + UbSystem::toString(drho) + ", rho_post=" + UbSystem::toString(rho_post) +// + " dif=" + UbSystem::toString(dif) +// + " drho is not correct for node " + UbSystem::toString(x1) + "," + UbSystem::toString(x2) + "," + UbSystem::toString(x3))); +// //UBLOG(logERROR,"LBMKernelETD3Q27CCLB::collideAll(): drho is not correct for node "+UbSystem::toString(x1)+","+UbSystem::toString(x2)+","+UbSystem::toString(x3)); +// //exit(EXIT_FAILURE); +// } +//#endif + ////////////////////////////////////////////////////////////////////////// + //write distribution + ////////////////////////////////////////////////////////////////////////// + (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3) = mfabb ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3) = mfbab ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3) = mfbba ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3) = mfaab ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3) = mfaba ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca ;//* rho * c1o3; + (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3) = mfcbb ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3) = mfbcb ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3) = mfccb ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3) = mfacb ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac ;//* rho * c1o3; + (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac ;//* rho * c1o3; + + (*this->zeroDistributionsF)(x1, x2, x3) = mfbbb;// *rho* c1o3; + ////////////////////////////////////////////////////////////////////////// + + ////!Incompressible Kernal + + +// ///////Old Kernel \|/ +// // ux += forcingX1*deltaT*0.5; // X +// // uy += forcingX2*deltaT*0.5; // Y +// // uz += forcingX3*deltaT*0.5; // Z +// } +// +// LBMReal ux = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + +// (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + +// (mfcbb - mfabb)) / +// (rho * c1o3) + +// (mu * dX1_phi + forcingX1) / (2 * rho); +// +// LBMReal uy = ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + +// (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + +// (mfbcb - mfbab)) / +// (rho * c1o3) + +// (mu * dX2_phi + forcingX2) / (2 * rho); +// +// LBMReal uz = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + +// (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + +// (mfbbc - mfbba)) / +// (rho * c1o3) + +// (mu * dX3_phi + forcingX3) / (2 * rho); +// +// //-------------------------------------------------------- +// +// LBMReal ux2 = ux * ux; +// LBMReal uy2 = uy * uy; +// LBMReal uz2 = uz * uz; +// +// //----------- Calculating Forcing Terms * ------------- +// for (int dir = STARTF; dir <= (FENDDIR); dir++) { +// LBMReal velProd = DX1[dir] * ux + DX2[dir] * uy + DX3[dir] * uz; +// LBMReal velSq1 = velProd * velProd; +// LBMReal gamma = WEIGTH[dir] * (1.0 + 3 * velProd + 4.5 * velSq1 - 1.5 * (ux2 + uy2 + uz2)); +// +// LBMReal fac1 = (gamma - WEIGTH[dir]) * c1o3 * rhoToPhi; +// +// forcingTerm[dir] = ((-ux) * (fac1 * dX1_phi + gamma * (mu * dX1_phi + forcingX1)) + +// (-uy) * (fac1 * dX2_phi + gamma * (mu * dX2_phi + forcingX2)) + +// (-uz) * (fac1 * dX3_phi + gamma * (mu * dX3_phi + forcingX3))) + +// (DX1[dir]) * (fac1 * dX1_phi + gamma * (mu * dX1_phi + forcingX1)) + +// (DX2[dir]) * (fac1 * dX2_phi + gamma * (mu * dX2_phi + forcingX2)) + +// (DX3[dir]) * (fac1 * dX3_phi + gamma * (mu * dX3_phi + forcingX3)); +// } +// +// LBMReal gamma = WEIGTH[REST] * (1.0 - 1.5 * (ux2 + uy2 + uz2)); +// LBMReal fac1 = (gamma - WEIGTH[REST]) * c1o3 * rhoToPhi; +// forcingTerm[REST] = (-ux) * (fac1 * dX1_phi + gamma * (mu * dX1_phi + forcingX1)) + +// (-uy) * (fac1 * dX2_phi + gamma * (mu * dX2_phi + forcingX2)) + +// (-uz) * (fac1 * dX3_phi + gamma * (mu * dX3_phi + forcingX3)); +// +// //-------------------------------------------------------- +// +// mfcbb = 3.0 * (mfcbb + 0.5 * forcingTerm[E]) / rho; //-(3.0*p1 - rho)*WEIGTH[E ]; +// mfbcb = 3.0 * (mfbcb + 0.5 * forcingTerm[N]) / rho; //-(3.0*p1 - rho)*WEIGTH[N ]; +// mfbbc = 3.0 * (mfbbc + 0.5 * forcingTerm[T]) / rho; //-(3.0*p1 - rho)*WEIGTH[T ]; +// mfccb = 3.0 * (mfccb + 0.5 * forcingTerm[NE]) / rho; //-(3.0*p1 - rho)*WEIGTH[NE ]; +// mfacb = 3.0 * (mfacb + 0.5 * forcingTerm[NW]) / rho; //-(3.0*p1 - rho)*WEIGTH[NW ]; +// mfcbc = 3.0 * (mfcbc + 0.5 * forcingTerm[TE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TE ]; +// mfabc = 3.0 * (mfabc + 0.5 * forcingTerm[TW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TW ]; +// mfbcc = 3.0 * (mfbcc + 0.5 * forcingTerm[TN]) / rho; //-(3.0*p1 - rho)*WEIGTH[TN ]; +// mfbac = 3.0 * (mfbac + 0.5 * forcingTerm[TS]) / rho; //-(3.0*p1 - rho)*WEIGTH[TS ]; +// mfccc = 3.0 * (mfccc + 0.5 * forcingTerm[TNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNE]; +// mfacc = 3.0 * (mfacc + 0.5 * forcingTerm[TNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TNW]; +// mfcac = 3.0 * (mfcac + 0.5 * forcingTerm[TSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSE]; +// mfaac = 3.0 * (mfaac + 0.5 * forcingTerm[TSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[TSW]; +// mfabb = 3.0 * (mfabb + 0.5 * forcingTerm[W]) / rho; //-(3.0*p1 - rho)*WEIGTH[W ]; +// mfbab = 3.0 * (mfbab + 0.5 * forcingTerm[S]) / rho; //-(3.0*p1 - rho)*WEIGTH[S ]; +// mfbba = 3.0 * (mfbba + 0.5 * forcingTerm[B]) / rho; //-(3.0*p1 - rho)*WEIGTH[B ]; +// mfaab = 3.0 * (mfaab + 0.5 * forcingTerm[SW]) / rho; //-(3.0*p1 - rho)*WEIGTH[SW ]; +// mfcab = 3.0 * (mfcab + 0.5 * forcingTerm[SE]) / rho; //-(3.0*p1 - rho)*WEIGTH[SE ]; +// mfaba = 3.0 * (mfaba + 0.5 * forcingTerm[BW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BW ]; +// mfcba = 3.0 * (mfcba + 0.5 * forcingTerm[BE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BE ]; +// mfbaa = 3.0 * (mfbaa + 0.5 * forcingTerm[BS]) / rho; //-(3.0*p1 - rho)*WEIGTH[BS ]; +// mfbca = 3.0 * (mfbca + 0.5 * forcingTerm[BN]) / rho; //-(3.0*p1 - rho)*WEIGTH[BN ]; +// mfaaa = 3.0 * (mfaaa + 0.5 * forcingTerm[BSW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSW]; +// mfcaa = 3.0 * (mfcaa + 0.5 * forcingTerm[BSE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BSE]; +// mfaca = 3.0 * (mfaca + 0.5 * forcingTerm[BNW]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNW]; +// mfcca = 3.0 * (mfcca + 0.5 * forcingTerm[BNE]) / rho; //-(3.0*p1 - rho)*WEIGTH[BNE]; +// mfbbb = 3.0 * (mfbbb + 0.5 * forcingTerm[REST]) / rho; //- (3.0*p1 - rho)*WEIGTH[REST]; +// +// LBMReal rho1 = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) + +// (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + +// (mfbaa + mfbac + mfbca + mfbcc) + (mfabb + mfcbb) + (mfbab + mfbcb) + +// (mfbba + mfbbc) + mfbbb; +// +// +// LBMReal oMdrho, m0, m1, m2; +// +// oMdrho = mfccc + mfaaa; +// m0 = mfaca + mfcac; +// m1 = mfacc + mfcaa; +// m2 = mfaac + mfcca; +// oMdrho += m0; +// m1 += m2; +// oMdrho += m1; +// m0 = mfbac + mfbca; +// m1 = mfbaa + mfbcc; +// m0 += m1; +// m1 = mfabc + mfcba; +// m2 = mfaba + mfcbc; +// m1 += m2; +// m0 += m1; +// m1 = mfacb + mfcab; +// m2 = mfaab + mfccb; +// m1 += m2; +// m0 += m1; +// oMdrho += m0; +// m0 = mfabb + mfcbb; +// m1 = mfbab + mfbcb; +// m2 = mfbba + mfbbc; +// m0 += m1 + m2; +// m0 += mfbbb; // hat gefehlt +// oMdrho = 1. - (oMdrho + m0); +// // oMdrho = rho - (oMdrho + m0); +// +// //////////////////////////////////////////////////////////////////////////////////// +// LBMReal wadjust; +// LBMReal qudricLimit = 0.01; +// //////////////////////////////////////////////////////////////////////////////////// +// // Hin +// //////////////////////////////////////////////////////////////////////////////////// +// // mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren +// //////////////////////////////////////////////////////////////////////////////////// +// // Z - Dir +// m2 = mfaaa + mfaac; +// m1 = mfaac - mfaaa; +// m0 = m2 + mfaab; +// mfaaa = m0; +// m0 += c1o36 * oMdrho; +// mfaab = m1 - m0 * uz; +// mfaac = m2 - 2. * m1 * uz + uz2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfaba + mfabc; +// m1 = mfabc - mfaba; +// m0 = m2 + mfabb; +// mfaba = m0; +// m0 += c1o9 * oMdrho; +// mfabb = m1 - m0 * uz; +// mfabc = m2 - 2. * m1 * uz + uz2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfaca + mfacc; +// m1 = mfacc - mfaca; +// m0 = m2 + mfacb; +// mfaca = m0; +// m0 += c1o36 * oMdrho; +// mfacb = m1 - m0 * uz; +// mfacc = m2 - 2. * m1 * uz + uz2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfbaa + mfbac; +// m1 = mfbac - mfbaa; +// m0 = m2 + mfbab; +// mfbaa = m0; +// m0 += c1o9 * oMdrho; +// mfbab = m1 - m0 * uz; +// mfbac = m2 - 2. * m1 * uz + uz2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfbba + mfbbc; +// m1 = mfbbc - mfbba; +// m0 = m2 + mfbbb; +// mfbba = m0; +// m0 += c4o9 * oMdrho; +// mfbbb = m1 - m0 * uz; +// mfbbc = m2 - 2. * m1 * uz + uz2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfbca + mfbcc; +// m1 = mfbcc - mfbca; +// m0 = m2 + mfbcb; +// mfbca = m0; +// m0 += c1o9 * oMdrho; +// mfbcb = m1 - m0 * uz; +// mfbcc = m2 - 2. * m1 * uz + uz2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfcaa + mfcac; +// m1 = mfcac - mfcaa; +// m0 = m2 + mfcab; +// mfcaa = m0; +// m0 += c1o36 * oMdrho; +// mfcab = m1 - m0 * uz; +// mfcac = m2 - 2. * m1 * uz + uz2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfcba + mfcbc; +// m1 = mfcbc - mfcba; +// m0 = m2 + mfcbb; +// mfcba = m0; +// m0 += c1o9 * oMdrho; +// mfcbb = m1 - m0 * uz; +// mfcbc = m2 - 2. * m1 * uz + uz2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfcca + mfccc; +// m1 = mfccc - mfcca; +// m0 = m2 + mfccb; +// mfcca = m0; +// m0 += c1o36 * oMdrho; +// mfccb = m1 - m0 * uz; +// mfccc = m2 - 2. * m1 * uz + uz2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// // mit 1/6, 0, 1/18, 2/3, 0, 2/9, 1/6, 0, 1/18 Konditionieren +// //////////////////////////////////////////////////////////////////////////////////// +// // Y - Dir +// m2 = mfaaa + mfaca; +// m1 = mfaca - mfaaa; +// m0 = m2 + mfaba; +// mfaaa = m0; +// m0 += c1o6 * oMdrho; +// mfaba = m1 - m0 * uy; +// mfaca = m2 - 2. * m1 * uy + uy2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfaab + mfacb; +// m1 = mfacb - mfaab; +// m0 = m2 + mfabb; +// mfaab = m0; +// mfabb = m1 - m0 * uy; +// mfacb = m2 - 2. * m1 * uy + uy2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfaac + mfacc; +// m1 = mfacc - mfaac; +// m0 = m2 + mfabc; +// mfaac = m0; +// m0 += c1o18 * oMdrho; +// mfabc = m1 - m0 * uy; +// mfacc = m2 - 2. * m1 * uy + uy2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfbaa + mfbca; +// m1 = mfbca - mfbaa; +// m0 = m2 + mfbba; +// mfbaa = m0; +// m0 += c2o3 * oMdrho; +// mfbba = m1 - m0 * uy; +// mfbca = m2 - 2. * m1 * uy + uy2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfbab + mfbcb; +// m1 = mfbcb - mfbab; +// m0 = m2 + mfbbb; +// mfbab = m0; +// mfbbb = m1 - m0 * uy; +// mfbcb = m2 - 2. * m1 * uy + uy2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfbac + mfbcc; +// m1 = mfbcc - mfbac; +// m0 = m2 + mfbbc; +// mfbac = m0; +// m0 += c2o9 * oMdrho; +// mfbbc = m1 - m0 * uy; +// mfbcc = m2 - 2. * m1 * uy + uy2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfcaa + mfcca; +// m1 = mfcca - mfcaa; +// m0 = m2 + mfcba; +// mfcaa = m0; +// m0 += c1o6 * oMdrho; +// mfcba = m1 - m0 * uy; +// mfcca = m2 - 2. * m1 * uy + uy2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfcab + mfccb; +// m1 = mfccb - mfcab; +// m0 = m2 + mfcbb; +// mfcab = m0; +// mfcbb = m1 - m0 * uy; +// mfccb = m2 - 2. * m1 * uy + uy2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfcac + mfccc; +// m1 = mfccc - mfcac; +// m0 = m2 + mfcbc; +// mfcac = m0; +// m0 += c1o18 * oMdrho; +// mfcbc = m1 - m0 * uy; +// mfccc = m2 - 2. * m1 * uy + uy2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// // mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren +// //////////////////////////////////////////////////////////////////////////////////// +// // X - Dir +// m2 = mfaaa + mfcaa; +// m1 = mfcaa - mfaaa; +// m0 = m2 + mfbaa; +// mfaaa = m0; +// m0 += 1. * oMdrho; +// mfbaa = m1 - m0 * ux; +// mfcaa = m2 - 2. * m1 * ux + ux2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfaba + mfcba; +// m1 = mfcba - mfaba; +// m0 = m2 + mfbba; +// mfaba = m0; +// mfbba = m1 - m0 * ux; +// mfcba = m2 - 2. * m1 * ux + ux2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfaca + mfcca; +// m1 = mfcca - mfaca; +// m0 = m2 + mfbca; +// mfaca = m0; +// m0 += c1o3 * oMdrho; +// mfbca = m1 - m0 * ux; +// mfcca = m2 - 2. * m1 * ux + ux2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfaab + mfcab; +// m1 = mfcab - mfaab; +// m0 = m2 + mfbab; +// mfaab = m0; +// mfbab = m1 - m0 * ux; +// mfcab = m2 - 2. * m1 * ux + ux2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfabb + mfcbb; +// m1 = mfcbb - mfabb; +// m0 = m2 + mfbbb; +// mfabb = m0; +// mfbbb = m1 - m0 * ux; +// mfcbb = m2 - 2. * m1 * ux + ux2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfacb + mfccb; +// m1 = mfccb - mfacb; +// m0 = m2 + mfbcb; +// mfacb = m0; +// mfbcb = m1 - m0 * ux; +// mfccb = m2 - 2. * m1 * ux + ux2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfaac + mfcac; +// m1 = mfcac - mfaac; +// m0 = m2 + mfbac; +// mfaac = m0; +// m0 += c1o3 * oMdrho; +// mfbac = m1 - m0 * ux; +// mfcac = m2 - 2. * m1 * ux + ux2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfabc + mfcbc; +// m1 = mfcbc - mfabc; +// m0 = m2 + mfbbc; +// mfabc = m0; +// mfbbc = m1 - m0 * ux; +// mfcbc = m2 - 2. * m1 * ux + ux2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// m2 = mfacc + mfccc; +// m1 = mfccc - mfacc; +// m0 = m2 + mfbcc; +// mfacc = m0; +// m0 += c1o9 * oMdrho; +// mfbcc = m1 - m0 * ux; +// mfccc = m2 - 2. * m1 * ux + ux2 * m0; +// //////////////////////////////////////////////////////////////////////////////////// +// // Cumulants +// //////////////////////////////////////////////////////////////////////////////////// +// LBMReal OxxPyyPzz = 1.; // omega2 or bulk viscosity +// LBMReal OxyyPxzz = 1.; //-s9;//2+s9;// +// LBMReal OxyyMxzz = 1.; // 2+s9;// +// LBMReal O4 = 1.; +// LBMReal O5 = 1.; +// LBMReal O6 = 1.; +// +// // Cum 4. +// LBMReal CUMcbb = mfcbb - ((mfcaa + c1o3) * mfabb + 2. * mfbba * mfbab); +// LBMReal CUMbcb = mfbcb - ((mfaca + c1o3) * mfbab + 2. * mfbba * mfabb); +// LBMReal CUMbbc = mfbbc - ((mfaac + c1o3) * mfbba + 2. * mfbab * mfabb); +// +// LBMReal CUMcca = mfcca - ((mfcaa * mfaca + 2. * mfbba * mfbba) + +// c1o3 * (mfcaa + mfaca) * oMdrho + c1o9 * (oMdrho - 1) * oMdrho); +// LBMReal CUMcac = mfcac - ((mfcaa * mfaac + 2. * mfbab * mfbab) + +// c1o3 * (mfcaa + mfaac) * oMdrho + c1o9 * (oMdrho - 1) * oMdrho); +// LBMReal CUMacc = mfacc - ((mfaac * mfaca + 2. * mfabb * mfabb) + +// c1o3 * (mfaac + mfaca) * oMdrho + c1o9 * (oMdrho - 1) * oMdrho); +// +// // Cum 5. +// LBMReal CUMbcc = mfbcc - +// (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + +// 2. * (mfbab * mfacb + mfbba * mfabc)) - +// c1o3 * (mfbca + mfbac) * oMdrho; +// LBMReal CUMcbc = mfcbc - +// (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + +// 2. * (mfabb * mfcab + mfbba * mfbac)) - +// c1o3 * (mfcba + mfabc) * oMdrho; +// LBMReal CUMccb = mfccb - +// (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + +// 2. * (mfbab * mfbca + mfabb * mfcba)) - +// c1o3 * (mfacb + mfcab) * oMdrho; +// +// // Cum 6. +// LBMReal CUMccc = +// mfccc + +// ((-4. * mfbbb * mfbbb - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) - +// 4. * (mfabb * mfcbb + mfbab * mfbcb + mfbba * mfbbc) - +// 2. * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) + +// (4. * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + +// 2. * (mfcaa * mfaca * mfaac) + 16. * mfbba * mfbab * mfabb) - +// c1o3 * (mfacc + mfcac + mfcca) * oMdrho - c1o9 * oMdrho * oMdrho - +// c1o9 * (mfcaa + mfaca + mfaac) * oMdrho * (1. - 2. * oMdrho) - +// c1o27 * oMdrho * oMdrho * (-2. * oMdrho) + +// (2. * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + +// (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa)) * +// c2o3 * oMdrho) + +// c1o27 * oMdrho; +// +// // 2. +// // linear combinations +// LBMReal mxxPyyPzz = mfcaa + mfaca + mfaac; +// LBMReal mxxMyy = mfcaa - mfaca; +// LBMReal mxxMzz = mfcaa - mfaac; +// +// LBMReal dxux = -c1o2 * collFactorM * (mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz * (mfaaa - mxxPyyPzz); +// LBMReal dyuy = dxux + collFactorM * c3o2 * mxxMyy; +// LBMReal dzuz = dxux + collFactorM * c3o2 * mxxMzz; +// +// (*divU)(x1, x2, x3) = dxux + dyuy + dzuz; +// +// // relax +// mxxPyyPzz += OxxPyyPzz * (mfaaa - mxxPyyPzz) - +// 3. * (1. - c1o2 * OxxPyyPzz) * (ux2 * dxux + uy2 * dyuy + uz2 * dzuz); +// mxxMyy += collFactorM * (-mxxMyy) - 3. * (1. - c1o2 * collFactorM) * (ux2 * dxux - uy2 * dyuy); +// mxxMzz += collFactorM * (-mxxMzz) - 3. * (1. - c1o2 * collFactorM) * (ux2 * dxux - uz2 * dzuz); +// +// mfabb += collFactorM * (-mfabb); +// mfbab += collFactorM * (-mfbab); +// mfbba += collFactorM * (-mfbba); +// +// // linear combinations back +// mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); +// mfaca = c1o3 * (-2. * mxxMyy + mxxMzz + mxxPyyPzz); +// mfaac = c1o3 * (mxxMyy - 2. * mxxMzz + mxxPyyPzz); +// +// // 3. +// // linear combinations +// LBMReal mxxyPyzz = mfcba + mfabc; +// LBMReal mxxyMyzz = mfcba - mfabc; +// +// LBMReal mxxzPyyz = mfcab + mfacb; +// LBMReal mxxzMyyz = mfcab - mfacb; +// +// LBMReal mxyyPxzz = mfbca + mfbac; +// LBMReal mxyyMxzz = mfbca - mfbac; +// +// // relax +// wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mfbbb) / (fabs(mfbbb) + qudricLimit); +// mfbbb += wadjust * (-mfbbb); +// wadjust = OxyyPxzz + (1. - OxyyPxzz) * fabs(mxxyPyzz) / (fabs(mxxyPyzz) + qudricLimit); +// mxxyPyzz += wadjust * (-mxxyPyzz); +// wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mxxyMyzz) / (fabs(mxxyMyzz) + qudricLimit); +// mxxyMyzz += wadjust * (-mxxyMyzz); +// wadjust = OxyyPxzz + (1. - OxyyPxzz) * fabs(mxxzPyyz) / (fabs(mxxzPyyz) + qudricLimit); +// mxxzPyyz += wadjust * (-mxxzPyyz); +// wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mxxzMyyz) / (fabs(mxxzMyyz) + qudricLimit); +// mxxzMyyz += wadjust * (-mxxzMyyz); +// wadjust = OxyyPxzz + (1. - OxyyPxzz) * fabs(mxyyPxzz) / (fabs(mxyyPxzz) + qudricLimit); +// mxyyPxzz += wadjust * (-mxyyPxzz); +// wadjust = OxyyMxzz + (1. - OxyyMxzz) * fabs(mxyyMxzz) / (fabs(mxyyMxzz) + qudricLimit); +// mxyyMxzz += wadjust * (-mxyyMxzz); +// +// // linear combinations back +// mfcba = (mxxyMyzz + mxxyPyzz) * c1o2; +// mfabc = (-mxxyMyzz + mxxyPyzz) * c1o2; +// mfcab = (mxxzMyyz + mxxzPyyz) * c1o2; +// mfacb = (-mxxzMyyz + mxxzPyyz) * c1o2; +// mfbca = (mxyyMxzz + mxyyPxzz) * c1o2; +// mfbac = (-mxyyMxzz + mxyyPxzz) * c1o2; +// +// // 4. +// CUMacc += O4 * (-CUMacc); +// CUMcac += O4 * (-CUMcac); +// CUMcca += O4 * (-CUMcca); +// +// CUMbbc += O4 * (-CUMbbc); +// CUMbcb += O4 * (-CUMbcb); +// CUMcbb += O4 * (-CUMcbb); +// +// // 5. +// CUMbcc += O5 * (-CUMbcc); +// CUMcbc += O5 * (-CUMcbc); +// CUMccb += O5 * (-CUMccb); +// +// // 6. +// CUMccc += O6 * (-CUMccc); +// +// // back cumulants to central moments +// // 4. +// mfcbb = CUMcbb + ((mfcaa + c1o3) * mfabb + 2. * mfbba * mfbab); +// mfbcb = CUMbcb + ((mfaca + c1o3) * mfbab + 2. * mfbba * mfabb); +// mfbbc = CUMbbc + ((mfaac + c1o3) * mfbba + 2. * mfbab * mfabb); +// +// mfcca = CUMcca + (mfcaa * mfaca + 2. * mfbba * mfbba) + c1o3 * (mfcaa + mfaca) * oMdrho + +// c1o9 * (oMdrho - 1) * oMdrho; +// mfcac = CUMcac + (mfcaa * mfaac + 2. * mfbab * mfbab) + c1o3 * (mfcaa + mfaac) * oMdrho + +// c1o9 * (oMdrho - 1) * oMdrho; +// mfacc = CUMacc + (mfaac * mfaca + 2. * mfabb * mfabb) + c1o3 * (mfaac + mfaca) * oMdrho + +// c1o9 * (oMdrho - 1) * oMdrho; +// +// // 5. +// mfbcc = CUMbcc + +// (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + +// 2. * (mfbab * mfacb + mfbba * mfabc)) + +// c1o3 * (mfbca + mfbac) * oMdrho; +// mfcbc = CUMcbc + +// (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + +// 2. * (mfabb * mfcab + mfbba * mfbac)) + +// c1o3 * (mfcba + mfabc) * oMdrho; +// mfccb = CUMccb + +// (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + +// 2. * (mfbab * mfbca + mfabb * mfcba)) + +// c1o3 * (mfacb + mfcab) * oMdrho; +// +// // 6. +// mfccc = CUMccc - +// ((-4. * mfbbb * mfbbb - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) - +// 4. * (mfabb * mfcbb + mfbac * mfbca + mfbba * mfbbc) - +// 2. * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) + +// (4. * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + +// 2. * (mfcaa * mfaca * mfaac) + 16. * mfbba * mfbab * mfabb) - +// c1o3 * (mfacc + mfcac + mfcca) * oMdrho - c1o9 * oMdrho * oMdrho - +// c1o9 * (mfcaa + mfaca + mfaac) * oMdrho * (1. - 2. * oMdrho) - +// c1o27 * oMdrho * oMdrho * (-2. * oMdrho) + +// (2. * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + +// (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa)) * +// c2o3 * oMdrho) - +// c1o27 * oMdrho; +// +// //////////////////////////////////////////////////////////////////////////////////// +// // forcing +// mfbaa = -mfbaa; +// mfaba = -mfaba; +// mfaab = -mfaab; +// ////////////////////////////////////////////////////////////////////////////////////// +// +// //////////////////////////////////////////////////////////////////////////////////// +// // back +// //////////////////////////////////////////////////////////////////////////////////// +// // mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren +// //////////////////////////////////////////////////////////////////////////////////// +// // Z - Dir +// m0 = mfaac * c1o2 + mfaab * (uz - c1o2) + (mfaaa + 1. * oMdrho) * (uz2 - uz) * c1o2; +// m1 = -mfaac - 2. * mfaab * uz + mfaaa * (1. - uz2) - 1. * oMdrho * uz2; +// m2 = mfaac * c1o2 + mfaab * (uz + c1o2) + (mfaaa + 1. * oMdrho) * (uz2 + uz) * c1o2; +// mfaaa = m0; +// mfaab = m1; +// mfaac = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfabc * c1o2 + mfabb * (uz - c1o2) + mfaba * (uz2 - uz) * c1o2; +// m1 = -mfabc - 2. * mfabb * uz + mfaba * (1. - uz2); +// m2 = mfabc * c1o2 + mfabb * (uz + c1o2) + mfaba * (uz2 + uz) * c1o2; +// mfaba = m0; +// mfabb = m1; +// mfabc = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfacc * c1o2 + mfacb * (uz - c1o2) + (mfaca + c1o3 * oMdrho) * (uz2 - uz) * c1o2; +// m1 = -mfacc - 2. * mfacb * uz + mfaca * (1. - uz2) - c1o3 * oMdrho * uz2; +// m2 = mfacc * c1o2 + mfacb * (uz + c1o2) + (mfaca + c1o3 * oMdrho) * (uz2 + uz) * c1o2; +// mfaca = m0; +// mfacb = m1; +// mfacc = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfbac * c1o2 + mfbab * (uz - c1o2) + mfbaa * (uz2 - uz) * c1o2; +// m1 = -mfbac - 2. * mfbab * uz + mfbaa * (1. - uz2); +// m2 = mfbac * c1o2 + mfbab * (uz + c1o2) + mfbaa * (uz2 + uz) * c1o2; +// mfbaa = m0; +// mfbab = m1; +// mfbac = m2; +// /////////b////////////////////////////////////////////////////////////////////////// +// m0 = mfbbc * c1o2 + mfbbb * (uz - c1o2) + mfbba * (uz2 - uz) * c1o2; +// m1 = -mfbbc - 2. * mfbbb * uz + mfbba * (1. - uz2); +// m2 = mfbbc * c1o2 + mfbbb * (uz + c1o2) + mfbba * (uz2 + uz) * c1o2; +// mfbba = m0; +// mfbbb = m1; +// mfbbc = m2; +// /////////b////////////////////////////////////////////////////////////////////////// +// m0 = mfbcc * c1o2 + mfbcb * (uz - c1o2) + mfbca * (uz2 - uz) * c1o2; +// m1 = -mfbcc - 2. * mfbcb * uz + mfbca * (1. - uz2); +// m2 = mfbcc * c1o2 + mfbcb * (uz + c1o2) + mfbca * (uz2 + uz) * c1o2; +// mfbca = m0; +// mfbcb = m1; +// mfbcc = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfcac * c1o2 + mfcab * (uz - c1o2) + (mfcaa + c1o3 * oMdrho) * (uz2 - uz) * c1o2; +// m1 = -mfcac - 2. * mfcab * uz + mfcaa * (1. - uz2) - c1o3 * oMdrho * uz2; +// m2 = mfcac * c1o2 + mfcab * (uz + c1o2) + (mfcaa + c1o3 * oMdrho) * (uz2 + uz) * c1o2; +// mfcaa = m0; +// mfcab = m1; +// mfcac = m2; +// /////////c////////////////////////////////////////////////////////////////////////// +// m0 = mfcbc * c1o2 + mfcbb * (uz - c1o2) + mfcba * (uz2 - uz) * c1o2; +// m1 = -mfcbc - 2. * mfcbb * uz + mfcba * (1. - uz2); +// m2 = mfcbc * c1o2 + mfcbb * (uz + c1o2) + mfcba * (uz2 + uz) * c1o2; +// mfcba = m0; +// mfcbb = m1; +// mfcbc = m2; +// /////////c////////////////////////////////////////////////////////////////////////// +// m0 = mfccc * c1o2 + mfccb * (uz - c1o2) + (mfcca + c1o9 * oMdrho) * (uz2 - uz) * c1o2; +// m1 = -mfccc - 2. * mfccb * uz + mfcca * (1. - uz2) - c1o9 * oMdrho * uz2; +// m2 = mfccc * c1o2 + mfccb * (uz + c1o2) + (mfcca + c1o9 * oMdrho) * (uz2 + uz) * c1o2; +// mfcca = m0; +// mfccb = m1; +// mfccc = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// // mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren +// //////////////////////////////////////////////////////////////////////////////////// +// // Y - Dir +// m0 = mfaca * c1o2 + mfaba * (uy - c1o2) + (mfaaa + c1o6 * oMdrho) * (uy2 - uy) * c1o2; +// m1 = -mfaca - 2. * mfaba * uy + mfaaa * (1. - uy2) - c1o6 * oMdrho * uy2; +// m2 = mfaca * c1o2 + mfaba * (uy + c1o2) + (mfaaa + c1o6 * oMdrho) * (uy2 + uy) * c1o2; +// mfaaa = m0; +// mfaba = m1; +// mfaca = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfacb * c1o2 + mfabb * (uy - c1o2) + (mfaab + c2o3 * oMdrho) * (uy2 - uy) * c1o2; +// m1 = -mfacb - 2. * mfabb * uy + mfaab * (1. - uy2) - c2o3 * oMdrho * uy2; +// m2 = mfacb * c1o2 + mfabb * (uy + c1o2) + (mfaab + c2o3 * oMdrho) * (uy2 + uy) * c1o2; +// mfaab = m0; +// mfabb = m1; +// mfacb = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfacc * c1o2 + mfabc * (uy - c1o2) + (mfaac + c1o6 * oMdrho) * (uy2 - uy) * c1o2; +// m1 = -mfacc - 2. * mfabc * uy + mfaac * (1. - uy2) - c1o6 * oMdrho * uy2; +// m2 = mfacc * c1o2 + mfabc * (uy + c1o2) + (mfaac + c1o6 * oMdrho) * (uy2 + uy) * c1o2; +// mfaac = m0; +// mfabc = m1; +// mfacc = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfbca * c1o2 + mfbba * (uy - c1o2) + mfbaa * (uy2 - uy) * c1o2; +// m1 = -mfbca - 2. * mfbba * uy + mfbaa * (1. - uy2); +// m2 = mfbca * c1o2 + mfbba * (uy + c1o2) + mfbaa * (uy2 + uy) * c1o2; +// mfbaa = m0; +// mfbba = m1; +// mfbca = m2; +// /////////b////////////////////////////////////////////////////////////////////////// +// m0 = mfbcb * c1o2 + mfbbb * (uy - c1o2) + mfbab * (uy2 - uy) * c1o2; +// m1 = -mfbcb - 2. * mfbbb * uy + mfbab * (1. - uy2); +// m2 = mfbcb * c1o2 + mfbbb * (uy + c1o2) + mfbab * (uy2 + uy) * c1o2; +// mfbab = m0; +// mfbbb = m1; +// mfbcb = m2; +// /////////b////////////////////////////////////////////////////////////////////////// +// m0 = mfbcc * c1o2 + mfbbc * (uy - c1o2) + mfbac * (uy2 - uy) * c1o2; +// m1 = -mfbcc - 2. * mfbbc * uy + mfbac * (1. - uy2); +// m2 = mfbcc * c1o2 + mfbbc * (uy + c1o2) + mfbac * (uy2 + uy) * c1o2; +// mfbac = m0; +// mfbbc = m1; +// mfbcc = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfcca * c1o2 + mfcba * (uy - c1o2) + (mfcaa + c1o18 * oMdrho) * (uy2 - uy) * c1o2; +// m1 = -mfcca - 2. * mfcba * uy + mfcaa * (1. - uy2) - c1o18 * oMdrho * uy2; +// m2 = mfcca * c1o2 + mfcba * (uy + c1o2) + (mfcaa + c1o18 * oMdrho) * (uy2 + uy) * c1o2; +// mfcaa = m0; +// mfcba = m1; +// mfcca = m2; +// /////////c////////////////////////////////////////////////////////////////////////// +// m0 = mfccb * c1o2 + mfcbb * (uy - c1o2) + (mfcab + c2o9 * oMdrho) * (uy2 - uy) * c1o2; +// m1 = -mfccb - 2. * mfcbb * uy + mfcab * (1. - uy2) - c2o9 * oMdrho * uy2; +// m2 = mfccb * c1o2 + mfcbb * (uy + c1o2) + (mfcab + c2o9 * oMdrho) * (uy2 + uy) * c1o2; +// mfcab = m0; +// mfcbb = m1; +// mfccb = m2; +// /////////c////////////////////////////////////////////////////////////////////////// +// m0 = mfccc * c1o2 + mfcbc * (uy - c1o2) + (mfcac + c1o18 * oMdrho) * (uy2 - uy) * c1o2; +// m1 = -mfccc - 2. * mfcbc * uy + mfcac * (1. - uy2) - c1o18 * oMdrho * uy2; +// m2 = mfccc * c1o2 + mfcbc * (uy + c1o2) + (mfcac + c1o18 * oMdrho) * (uy2 + uy) * c1o2; +// mfcac = m0; +// mfcbc = m1; +// mfccc = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// // mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren +// //////////////////////////////////////////////////////////////////////////////////// +// // X - Dir +// m0 = mfcaa * c1o2 + mfbaa * (ux - c1o2) + (mfaaa + c1o36 * oMdrho) * (ux2 - ux) * c1o2; +// m1 = -mfcaa - 2. * mfbaa * ux + mfaaa * (1. - ux2) - c1o36 * oMdrho * ux2; +// m2 = mfcaa * c1o2 + mfbaa * (ux + c1o2) + (mfaaa + c1o36 * oMdrho) * (ux2 + ux) * c1o2; +// mfaaa = m0; +// mfbaa = m1; +// mfcaa = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfcba * c1o2 + mfbba * (ux - c1o2) + (mfaba + c1o9 * oMdrho) * (ux2 - ux) * c1o2; +// m1 = -mfcba - 2. * mfbba * ux + mfaba * (1. - ux2) - c1o9 * oMdrho * ux2; +// m2 = mfcba * c1o2 + mfbba * (ux + c1o2) + (mfaba + c1o9 * oMdrho) * (ux2 + ux) * c1o2; +// mfaba = m0; +// mfbba = m1; +// mfcba = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfcca * c1o2 + mfbca * (ux - c1o2) + (mfaca + c1o36 * oMdrho) * (ux2 - ux) * c1o2; +// m1 = -mfcca - 2. * mfbca * ux + mfaca * (1. - ux2) - c1o36 * oMdrho * ux2; +// m2 = mfcca * c1o2 + mfbca * (ux + c1o2) + (mfaca + c1o36 * oMdrho) * (ux2 + ux) * c1o2; +// mfaca = m0; +// mfbca = m1; +// mfcca = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfcab * c1o2 + mfbab * (ux - c1o2) + (mfaab + c1o9 * oMdrho) * (ux2 - ux) * c1o2; +// m1 = -mfcab - 2. * mfbab * ux + mfaab * (1. - ux2) - c1o9 * oMdrho * ux2; +// m2 = mfcab * c1o2 + mfbab * (ux + c1o2) + (mfaab + c1o9 * oMdrho) * (ux2 + ux) * c1o2; +// mfaab = m0; +// mfbab = m1; +// mfcab = m2; +// ///////////b//////////////////////////////////////////////////////////////////////// +// m0 = mfcbb * c1o2 + mfbbb * (ux - c1o2) + (mfabb + c4o9 * oMdrho) * (ux2 - ux) * c1o2; +// m1 = -mfcbb - 2. * mfbbb * ux + mfabb * (1. - ux2) - c4o9 * oMdrho * ux2; +// m2 = mfcbb * c1o2 + mfbbb * (ux + c1o2) + (mfabb + c4o9 * oMdrho) * (ux2 + ux) * c1o2; +// mfabb = m0; +// mfbbb = m1; +// mfcbb = m2; +// ///////////b//////////////////////////////////////////////////////////////////////// +// m0 = mfccb * c1o2 + mfbcb * (ux - c1o2) + (mfacb + c1o9 * oMdrho) * (ux2 - ux) * c1o2; +// m1 = -mfccb - 2. * mfbcb * ux + mfacb * (1. - ux2) - c1o9 * oMdrho * ux2; +// m2 = mfccb * c1o2 + mfbcb * (ux + c1o2) + (mfacb + c1o9 * oMdrho) * (ux2 + ux) * c1o2; +// mfacb = m0; +// mfbcb = m1; +// mfccb = m2; +// //////////////////////////////////////////////////////////////////////////////////// +// //////////////////////////////////////////////////////////////////////////////////// +// m0 = mfcac * c1o2 + mfbac * (ux - c1o2) + (mfaac + c1o36 * oMdrho) * (ux2 - ux) * c1o2; +// m1 = -mfcac - 2. * mfbac * ux + mfaac * (1. - ux2) - c1o36 * oMdrho * ux2; +// m2 = mfcac * c1o2 + mfbac * (ux + c1o2) + (mfaac + c1o36 * oMdrho) * (ux2 + ux) * c1o2; +// mfaac = m0; +// mfbac = m1; +// mfcac = m2; +// ///////////c//////////////////////////////////////////////////////////////////////// +// m0 = mfcbc * c1o2 + mfbbc * (ux - c1o2) + (mfabc + c1o9 * oMdrho) * (ux2 - ux) * c1o2; +// m1 = -mfcbc - 2. * mfbbc * ux + mfabc * (1. - ux2) - c1o9 * oMdrho * ux2; +// m2 = mfcbc * c1o2 + mfbbc * (ux + c1o2) + (mfabc + c1o9 * oMdrho) * (ux2 + ux) * c1o2; +// mfabc = m0; +// mfbbc = m1; +// mfcbc = m2; +// ///////////c//////////////////////////////////////////////////////////////////////// +// m0 = mfccc * c1o2 + mfbcc * (ux - c1o2) + (mfacc + c1o36 * oMdrho) * (ux2 - ux) * c1o2; +// m1 = -mfccc - 2. * mfbcc * ux + mfacc * (1. - ux2) - c1o36 * oMdrho * ux2; +// m2 = mfccc * c1o2 + mfbcc * (ux + c1o2) + (mfacc + c1o36 * oMdrho) * (ux2 + ux) * c1o2; +// mfacc = m0; +// mfbcc = m1; +// mfccc = m2; +// +// /////////////////////////////////////////////////////////////////////////// +// +// ////////////////////////////////////////////////////////////////////////// +// // proof correctness +// ////////////////////////////////////////////////////////////////////////// +//#ifdef PROOF_CORRECTNESS +// LBMReal rho_post = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) + +// (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + +// (mfbaa + mfbac + mfbca + mfbcc) + (mfabb + mfcbb) + (mfbab + mfbcb) + +// (mfbba + mfbbc) + mfbbb; +// +// LBMReal dif = rho1 - rho_post; +//#ifdef SINGLEPRECISION +// if (dif > 10.0E-7 || dif < -10.0E-7) +//#else +// if (dif > 10.0E-15 || dif < -10.0E-15) +//#endif +// { +// UB_THROW(UbException(UB_EXARGS, +// "rho=" + UbSystem::toString(rho) + ", rho_post=" + +// UbSystem::toString(rho_post) + " dif=" + UbSystem::toString(dif) + +// " rho is not correct for node " + UbSystem::toString(x1) + "," + +// UbSystem::toString(x2) + "," + UbSystem::toString(x3))); +// } +//#endif +// +// mfcbb = rho * c1o3 * (mfcbb) + 0.5 * forcingTerm[E]; +// mfbcb = rho * c1o3 * (mfbcb) + 0.5 * forcingTerm[N]; +// mfbbc = rho * c1o3 * (mfbbc) + 0.5 * forcingTerm[T]; +// mfccb = rho * c1o3 * (mfccb) + 0.5 * forcingTerm[NE]; +// mfacb = rho * c1o3 * (mfacb) + 0.5 * forcingTerm[NW]; +// mfcbc = rho * c1o3 * (mfcbc) + 0.5 * forcingTerm[TE]; +// mfabc = rho * c1o3 * (mfabc) + 0.5 * forcingTerm[TW]; +// mfbcc = rho * c1o3 * (mfbcc) + 0.5 * forcingTerm[TN]; +// mfbac = rho * c1o3 * (mfbac) + 0.5 * forcingTerm[TS]; +// mfccc = rho * c1o3 * (mfccc) + 0.5 * forcingTerm[TNE]; +// mfacc = rho * c1o3 * (mfacc) + 0.5 * forcingTerm[TNW]; +// mfcac = rho * c1o3 * (mfcac) + 0.5 * forcingTerm[TSE]; +// mfaac = rho * c1o3 * (mfaac) + 0.5 * forcingTerm[TSW]; +// mfabb = rho * c1o3 * (mfabb) + 0.5 * forcingTerm[W]; +// mfbab = rho * c1o3 * (mfbab) + 0.5 * forcingTerm[S]; +// mfbba = rho * c1o3 * (mfbba) + 0.5 * forcingTerm[B]; +// mfaab = rho * c1o3 * (mfaab) + 0.5 * forcingTerm[SW]; +// mfcab = rho * c1o3 * (mfcab) + 0.5 * forcingTerm[SE]; +// mfaba = rho * c1o3 * (mfaba) + 0.5 * forcingTerm[BW]; +// mfcba = rho * c1o3 * (mfcba) + 0.5 * forcingTerm[BE]; +// mfbaa = rho * c1o3 * (mfbaa) + 0.5 * forcingTerm[BS]; +// mfbca = rho * c1o3 * (mfbca) + 0.5 * forcingTerm[BN]; +// mfaaa = rho * c1o3 * (mfaaa) + 0.5 * forcingTerm[BSW]; +// mfcaa = rho * c1o3 * (mfcaa) + 0.5 * forcingTerm[BSE]; +// mfaca = rho * c1o3 * (mfaca) + 0.5 * forcingTerm[BNW]; +// mfcca = rho * c1o3 * (mfcca) + 0.5 * forcingTerm[BNE]; +// mfbbb = rho * c1o3 * (mfbbb) + 0.5 * forcingTerm[REST]; +// +// ////////////////////////////////////////////////////////////////////////// +// // write distribution for F +// ////////////////////////////////////////////////////////////////////////// +// +// (*this->localDistributionsF)(D3Q27System::ET_E, x1, x2, x3) = mfabb; +// (*this->localDistributionsF)(D3Q27System::ET_N, x1, x2, x3) = mfbab; +// (*this->localDistributionsF)(D3Q27System::ET_T, x1, x2, x3) = mfbba; +// (*this->localDistributionsF)(D3Q27System::ET_NE, x1, x2, x3) = mfaab; +// (*this->localDistributionsF)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab; +// (*this->localDistributionsF)(D3Q27System::ET_TE, x1, x2, x3) = mfaba; +// (*this->localDistributionsF)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba; +// (*this->localDistributionsF)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa; +// (*this->localDistributionsF)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca; +// (*this->localDistributionsF)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa; +// (*this->localDistributionsF)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa; +// (*this->localDistributionsF)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca; +// (*this->localDistributionsF)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca; +// +// (*this->nonLocalDistributionsF)(D3Q27System::ET_W, x1p, x2, x3) = mfcbb; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_S, x1, x2p, x3) = mfbcb; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_SW, x1p, x2p, x3) = mfccb; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_SE, x1, x2p, x3) = mfacb; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac; +// (*this->nonLocalDistributionsF)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac; +// +// (*this->zeroDistributionsF)(x1, x2, x3) = mfbbb; +// !Old Kernel + ///////////////////// P H A S E - F I E L D S O L V E R + //////////////////////////////////////////// + /////CUMULANT PHASE-FIELD + LBMReal omegaD =1.0/( 3.0 * mob + 0.5); + { + mfcbb = (*this->localDistributionsH1)(D3Q27System::ET_E, x1, x2, x3); + mfbcb = (*this->localDistributionsH1)(D3Q27System::ET_N, x1, x2, x3); + mfbbc = (*this->localDistributionsH1)(D3Q27System::ET_T, x1, x2, x3); + mfccb = (*this->localDistributionsH1)(D3Q27System::ET_NE, x1, x2, x3); + mfacb = (*this->localDistributionsH1)(D3Q27System::ET_NW, x1p, x2, x3); + mfcbc = (*this->localDistributionsH1)(D3Q27System::ET_TE, x1, x2, x3); + mfabc = (*this->localDistributionsH1)(D3Q27System::ET_TW, x1p, x2, x3); + mfbcc = (*this->localDistributionsH1)(D3Q27System::ET_TN, x1, x2, x3); + mfbac = (*this->localDistributionsH1)(D3Q27System::ET_TS, x1, x2p, x3); + mfccc = (*this->localDistributionsH1)(D3Q27System::ET_TNE, x1, x2, x3); + mfacc = (*this->localDistributionsH1)(D3Q27System::ET_TNW, x1p, x2, x3); + mfcac = (*this->localDistributionsH1)(D3Q27System::ET_TSE, x1, x2p, x3); + mfaac = (*this->localDistributionsH1)(D3Q27System::ET_TSW, x1p, x2p, x3); + mfabb = (*this->nonLocalDistributionsH1)(D3Q27System::ET_W, x1p, x2, x3); + mfbab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_S, x1, x2p, x3); + mfbba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_B, x1, x2, x3p); + mfaab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SW, x1p, x2p, x3); + mfcab = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SE, x1, x2p, x3); + mfaba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BW, x1p, x2, x3p); + mfcba = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BE, x1, x2, x3p); + mfbaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BS, x1, x2p, x3p); + mfbca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BN, x1, x2, x3p); + mfaaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSW, x1p, x2p, x3p); + mfcaa = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSE, x1, x2p, x3p); + mfaca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNW, x1p, x2, x3p); + mfcca = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNE, x1, x2, x3p); + mfbbb = (*this->zeroDistributionsH1)(x1, x2, x3); + + + //////////////////////////////////////////////////////////////////////////////////// + //! - Calculate density and velocity using pyramid summation for low round-off errors as in Eq. (J1)-(J3) \ref + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! + //////////////////////////////////////////////////////////////////////////////////// + // fluid component + //LBMReal drhoFluid = + // ((((fccc + faaa) + (faca + fcac)) + ((facc + fcaa) + (faac + fcca))) + + // (((fbac + fbca) + (fbaa + fbcc)) + ((fabc + fcba) + (faba + fcbc)) + ((facb + fcab) + (faab + fccb))) + + // ((fabb + fcbb) + (fbab + fbcb) + (fbba + fbbc))) + fbbb; + + //LBMReal rhoFluid = c1 + drhoFluid; + //LBMReal OOrhoFluid = c1 / rhoFluid; + + + //LBMReal vvx = + // ((((fccc - faaa) + (fcac - faca)) + ((fcaa - facc) + (fcca - faac))) + + // (((fcba - fabc) + (fcbc - faba)) + ((fcab - facb) + (fccb - faab))) + + // (fcbb - fabb)) * OOrhoFluid; + //LBMReal vvy = + // ((((fccc - faaa) + (faca - fcac)) + ((facc - fcaa) + (fcca - faac))) + + // (((fbca - fbac) + (fbcc - fbaa)) + ((facb - fcab) + (fccb - faab))) + + // (fbcb - fbab)) * OOrhoFluid; + //LBMReal vvz = + // ((((fccc - faaa) + (fcac - faca)) + ((facc - fcaa) + (faac - fcca))) + + // (((fbac - fbca) + (fbcc - fbaa)) + ((fabc - fcba) + (fcbc - faba))) + + // (fbbc - fbba)) * OOrhoFluid; + + // LBMReal vvx = ux; + // LBMReal vvy = uy; + // LBMReal vvz = uz; + //////////////////////////////////////////////////////////////////////////////////// + // second component + LBMReal concentration = + ((((mfccc + mfaaa) + (mfaca + mfcac)) + ((mfacc + mfcaa) + (mfaac + mfcca))) + + (((mfbac + mfbca) + (mfbaa + mfbcc)) + ((mfabc + mfcba) + (mfaba + mfcbc)) + ((mfacb + mfcab) + (mfaab + mfccb))) + + ((mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc))) + mfbbb; + //////////////////////////////////////////////////////////////////////////////////// + //! - Add half of the acceleration (body force) to the velocity as in Eq. (42) \ref + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! + // LBMReal fx = forces[0]; + // LBMReal fy = forces[1]; + // LBMReal fz = -concentration * forces[2]; + // vvx += fx * c1o2; + // vvy += fy * c1o2; + // vvz += fz * c1o2; + //////////////////////////////////////////////////////////////////////////////////// + LBMReal oneMinusRho = c1- concentration; + + LBMReal cx = + ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + + (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + + (mfcbb - mfabb)); + LBMReal cy = + ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + + (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + + (mfbcb - mfbab)); + LBMReal cz = + ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + + (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + + (mfbbc - mfbba)); + + //////////////////////////////////////////////////////////////////////////////////// + // calculate the square of velocities for this lattice node + LBMReal cx2 = cx * cx; + LBMReal cy2 = cy * cy; + LBMReal cz2 = cz * cz; + //////////////////////////////////////////////////////////////////////////////////// + //! - Chimera transform from well conditioned distributions to central moments as defined in Appendix J in \ref + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! see also Eq. (6)-(14) in \ref + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + forwardInverseChimeraWithKincompressible(mfaaa, mfaab, mfaac, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfaba, mfabb, mfabc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfaca, mfacb, mfacc, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbaa, mfbab, mfbac, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbba, mfbbb, mfbbc, cz, cz2, c9o4, c4o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbca, mfbcb, mfbcc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcaa, mfcab, mfcac, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcba, mfcbb, mfcbc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcca, mfccb, mfccc, cz, cz2, c36, c1o36, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + forwardInverseChimeraWithKincompressible(mfaaa, mfaba, mfaca, cy, cy2, c6, c1o6, oneMinusRho); + forwardChimera(mfaab, mfabb, mfacb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfaac, mfabc, mfacc, cy, cy2, c18, c1o18, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbaa, mfbba, mfbca, cy, cy2, c3o2, c2o3, oneMinusRho); + forwardChimera(mfbab, mfbbb, mfbcb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfbac, mfbbc, mfbcc, cy, cy2, c9o2, c2o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcaa, mfcba, mfcca, cy, cy2, c6, c1o6, oneMinusRho); + forwardChimera(mfcab, mfcbb, mfccb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfcac, mfcbc, mfccc, cy, cy2, c18, c1o18, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + forwardInverseChimeraWithKincompressible(mfaaa, mfbaa, mfcaa, cx, cx2, c1, c1, oneMinusRho); + forwardChimera(mfaba, mfbba, mfcba, cx, cx2); + forwardInverseChimeraWithKincompressible(mfaca, mfbca, mfcca, cx, cx2, c3, c1o3, oneMinusRho); + forwardChimera(mfaab, mfbab, mfcab, cx, cx2); + forwardChimera(mfabb, mfbbb, mfcbb, cx, cx2); + forwardChimera(mfacb, mfbcb, mfccb, cx, cx2); + forwardInverseChimeraWithKincompressible(mfaac, mfbac, mfcac, cx, cx2, c3, c1o3, oneMinusRho); + forwardChimera(mfabc, mfbbc, mfcbc, cx, cx2); + forwardInverseChimeraWithKincompressible(mfacc, mfbcc, mfccc, cx, cx2, c3, c1o9, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + //! - experimental Cumulant ... to be published ... hopefully + //! + + // linearized orthogonalization of 3rd order central moments + LBMReal Mabc = mfabc - mfaba * c1o3; + LBMReal Mbca = mfbca - mfbaa * c1o3; + LBMReal Macb = mfacb - mfaab * c1o3; + LBMReal Mcba = mfcba - mfaba * c1o3; + LBMReal Mcab = mfcab - mfaab * c1o3; + LBMReal Mbac = mfbac - mfbaa * c1o3; + // linearized orthogonalization of 5th order central moments + LBMReal Mcbc = mfcbc - mfaba * c1o9; + LBMReal Mbcc = mfbcc - mfbaa * c1o9; + LBMReal Mccb = mfccb - mfaab * c1o9; + + // collision of 1st order moments + // LBMReal ccx, ccy, ccz; + + + cx = cx * (c1 - omegaD) + omegaD * vvx * concentration + + normX1 * (c1 - 0.5 * omegaD) * (1.0 - phi[REST]) * (phi[REST]) * c1o3 * oneOverInterfaceScale; + cy = cy * (c1 - omegaD) + omegaD * vvy * concentration + + normX2 * (c1 - 0.5 * omegaD) * (1.0 - phi[REST]) * (phi[REST]) * c1o3 * oneOverInterfaceScale; + cz = cz * (c1 - omegaD) + omegaD * vvz * concentration + + normX3 * (c1 - 0.5 * omegaD) * (1.0 - phi[REST]) * (phi[REST]) * c1o3 * oneOverInterfaceScale; + + //mhx = (ux * phi[REST] + normX1 * (tauH - 0.5) * (1.0 - phi[REST]) * (phi[REST])) / tauH + (1.0 - 1.0 / tauH) * mhx; + //mhy = (uy * phi[REST] + normX2 * (tauH - 0.5) * (1.0 - phi[REST]) * (phi[REST])) / tauH + (1.0 - 1.0 / tauH) * mhy; + //mhz = (uz * phi[REST] + normX3 * (tauH - 0.5) * (1.0 - phi[REST]) * (phi[REST])) / tauH + (1.0 - 1.0 / tauH) * mhz; + + + cx2 = cx * cx; + cy2 = cy * cy; + cz2 = cz * cz; + + // equilibration of 2nd order moments + mfbba = zeroReal; + mfbab = zeroReal; + mfabb = zeroReal; + + mfcaa = c1o3 * concentration; + mfaca = c1o3 * concentration; + mfaac = c1o3 * concentration; + + + //LBMReal omega2 = 1.0f;// omegaD; + //mfbba *= (c1 - omega2); + //mfbab *= (c1 - omega2); + //mfabb *= (c1 - omega2); + + //mfcaa = mfcaa*(c1 - omega2) + omega2*c1o3 * concentration; + //mfaca = mfaca*(c1 - omega2) + omega2*c1o3 * concentration; + //mfaac = mfaac*(c1 - omega2) + omega2*c1o3 * concentration; + + // equilibration of 3rd order moments + Mabc = zeroReal; + Mbca = zeroReal; + Macb = zeroReal; + Mcba = zeroReal; + Mcab = zeroReal; + Mbac = zeroReal; + mfbbb = zeroReal; + + // from linearized orthogonalization 3rd order central moments to central moments + mfabc = Mabc + mfaba * c1o3; + mfbca = Mbca + mfbaa * c1o3; + mfacb = Macb + mfaab * c1o3; + mfcba = Mcba + mfaba * c1o3; + mfcab = Mcab + mfaab * c1o3; + mfbac = Mbac + mfbaa * c1o3; + + // equilibration of 4th order moments + mfacc = c1o9 * concentration; + mfcac = c1o9 * concentration; + mfcca = c1o9 * concentration; + + mfcbb = zeroReal; + mfbcb = zeroReal; + mfbbc = zeroReal; + + // equilibration of 5th order moments + Mcbc = zeroReal; + Mbcc = zeroReal; + Mccb = zeroReal; + + // from linearized orthogonalization 5th order central moments to central moments + mfcbc = Mcbc + mfaba * c1o9; + mfbcc = Mbcc + mfbaa * c1o9; + mfccb = Mccb + mfaab * c1o9; + + // equilibration of 6th order moment + mfccc = c1o27 * concentration; + + //////////////////////////////////////////////////////////////////////////////////// + //! - Chimera transform from central moments to well conditioned distributions as defined in Appendix J in + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! see also Eq. (88)-(96) in + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + backwardInverseChimeraWithKincompressible(mfaaa, mfbaa, mfcaa, cx, cx2, c1, c1, oneMinusRho); + backwardChimera(mfaba, mfbba, mfcba, cx, cx2); + backwardInverseChimeraWithKincompressible(mfaca, mfbca, mfcca, cx, cx2, c3, c1o3, oneMinusRho); + backwardChimera(mfaab, mfbab, mfcab, cx, cx2); + backwardChimera(mfabb, mfbbb, mfcbb, cx, cx2); + backwardChimera(mfacb, mfbcb, mfccb, cx, cx2); + backwardInverseChimeraWithKincompressible(mfaac, mfbac, mfcac, cx, cx2, c3, c1o3, oneMinusRho); + backwardChimera(mfabc, mfbbc, mfcbc, cx, cx2); + backwardInverseChimeraWithKincompressible(mfacc, mfbcc, mfccc, cx, cx2, c9, c1o9, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + backwardInverseChimeraWithKincompressible(mfaaa, mfaba, mfaca, cy, cy2, c6, c1o6, oneMinusRho); + backwardChimera(mfaab, mfabb, mfacb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfaac, mfabc, mfacc, cy, cy2, c18, c1o18, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbaa, mfbba, mfbca, cy, cy2, c3o2, c2o3, oneMinusRho); + backwardChimera(mfbab, mfbbb, mfbcb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfbac, mfbbc, mfbcc, cy, cy2, c9o2, c2o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcaa, mfcba, mfcca, cy, cy2, c6, c1o6, oneMinusRho); + backwardChimera(mfcab, mfcbb, mfccb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfcac, mfcbc, mfccc, cy, cy2, c18, c1o18, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + backwardInverseChimeraWithKincompressible(mfaaa, mfaab, mfaac, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfaba, mfabb, mfabc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfaca, mfacb, mfacc, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbaa, mfbab, mfbac, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbba, mfbbb, mfbbc, cz, cz2, c9o4, c4o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbca, mfbcb, mfbcc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcaa, mfcab, mfcac, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcba, mfcbb, mfcbc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcca, mfccb, mfccc, cz, cz2, c36, c1o36, oneMinusRho); + + + + (*this->localDistributionsH1)(D3Q27System::ET_E, x1, x2, x3) = mfabb; + (*this->localDistributionsH1)(D3Q27System::ET_N, x1, x2, x3) = mfbab; + (*this->localDistributionsH1)(D3Q27System::ET_T, x1, x2, x3) = mfbba; + (*this->localDistributionsH1)(D3Q27System::ET_NE, x1, x2, x3) = mfaab; + (*this->localDistributionsH1)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab; + (*this->localDistributionsH1)(D3Q27System::ET_TE, x1, x2, x3) = mfaba; + (*this->localDistributionsH1)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba; + (*this->localDistributionsH1)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa; + (*this->localDistributionsH1)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca; + (*this->localDistributionsH1)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa; + (*this->localDistributionsH1)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa; + (*this->localDistributionsH1)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca; + (*this->localDistributionsH1)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca; + + (*this->nonLocalDistributionsH1)(D3Q27System::ET_W, x1p, x2, x3 ) = mfcbb; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_S, x1, x2p, x3 ) = mfbcb; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_SW, x1p, x2p, x3 ) = mfccb; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_SE, x1, x2p, x3 ) = mfacb; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac; + (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac; + + (*this->zeroDistributionsH1)(x1,x2,x3) = mfbbb; + } + + ////Phasefield 2: + + { + + normX1 *= -1; + normX2 *= -1; + normX3 *= -1; + + mfcbb = (*this->localDistributionsH2)(D3Q27System::ET_E, x1, x2, x3); + mfbcb = (*this->localDistributionsH2)(D3Q27System::ET_N, x1, x2, x3); + mfbbc = (*this->localDistributionsH2)(D3Q27System::ET_T, x1, x2, x3); + mfccb = (*this->localDistributionsH2)(D3Q27System::ET_NE, x1, x2, x3); + mfacb = (*this->localDistributionsH2)(D3Q27System::ET_NW, x1p, x2, x3); + mfcbc = (*this->localDistributionsH2)(D3Q27System::ET_TE, x1, x2, x3); + mfabc = (*this->localDistributionsH2)(D3Q27System::ET_TW, x1p, x2, x3); + mfbcc = (*this->localDistributionsH2)(D3Q27System::ET_TN, x1, x2, x3); + mfbac = (*this->localDistributionsH2)(D3Q27System::ET_TS, x1, x2p, x3); + mfccc = (*this->localDistributionsH2)(D3Q27System::ET_TNE, x1, x2, x3); + mfacc = (*this->localDistributionsH2)(D3Q27System::ET_TNW, x1p, x2, x3); + mfcac = (*this->localDistributionsH2)(D3Q27System::ET_TSE, x1, x2p, x3); + mfaac = (*this->localDistributionsH2)(D3Q27System::ET_TSW, x1p, x2p, x3); + mfabb = (*this->nonLocalDistributionsH2)(D3Q27System::ET_W, x1p, x2, x3); + mfbab = (*this->nonLocalDistributionsH2)(D3Q27System::ET_S, x1, x2p, x3); + mfbba = (*this->nonLocalDistributionsH2)(D3Q27System::ET_B, x1, x2, x3p); + mfaab = (*this->nonLocalDistributionsH2)(D3Q27System::ET_SW, x1p, x2p, x3); + mfcab = (*this->nonLocalDistributionsH2)(D3Q27System::ET_SE, x1, x2p, x3); + mfaba = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BW, x1p, x2, x3p); + mfcba = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BE, x1, x2, x3p); + mfbaa = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BS, x1, x2p, x3p); + mfbca = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BN, x1, x2, x3p); + mfaaa = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BSW, x1p, x2p, x3p); + mfcaa = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BSE, x1, x2p, x3p); + mfaca = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BNW, x1p, x2, x3p); + mfcca = (*this->nonLocalDistributionsH2)(D3Q27System::ET_BNE, x1, x2, x3p); + mfbbb = (*this->zeroDistributionsH2)(x1, x2, x3); + + + //////////////////////////////////////////////////////////////////////////////////// +//! - Calculate density and velocity using pyramid summation for low round-off errors as in Eq. (J1)-(J3) \ref +//! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> +//! +//////////////////////////////////////////////////////////////////////////////////// +// fluid component + //LBMReal drhoFluid = + // ((((fccc + faaa) + (faca + fcac)) + ((facc + fcaa) + (faac + fcca))) + + // (((fbac + fbca) + (fbaa + fbcc)) + ((fabc + fcba) + (faba + fcbc)) + ((facb + fcab) + (faab + fccb))) + + // ((fabb + fcbb) + (fbab + fbcb) + (fbba + fbbc))) + fbbb; + + //LBMReal rhoFluid = c1 + drhoFluid; + //LBMReal OOrhoFluid = c1 / rhoFluid; + + + //LBMReal vvx = + // ((((fccc - faaa) + (fcac - faca)) + ((fcaa - facc) + (fcca - faac))) + + // (((fcba - fabc) + (fcbc - faba)) + ((fcab - facb) + (fccb - faab))) + + // (fcbb - fabb)) * OOrhoFluid; + //LBMReal vvy = + // ((((fccc - faaa) + (faca - fcac)) + ((facc - fcaa) + (fcca - faac))) + + // (((fbca - fbac) + (fbcc - fbaa)) + ((facb - fcab) + (fccb - faab))) + + // (fbcb - fbab)) * OOrhoFluid; + //LBMReal vvz = + // ((((fccc - faaa) + (fcac - faca)) + ((facc - fcaa) + (faac - fcca))) + + // (((fbac - fbca) + (fbcc - fbaa)) + ((fabc - fcba) + (fcbc - faba))) + + // (fbbc - fbba)) * OOrhoFluid; + + // LBMReal vvx = ux; + // LBMReal vvy = uy; + // LBMReal vvz = uz; + //////////////////////////////////////////////////////////////////////////////////// + // second component + LBMReal concentration = + ((((mfccc + mfaaa) + (mfaca + mfcac)) + ((mfacc + mfcaa) + (mfaac + mfcca))) + + (((mfbac + mfbca) + (mfbaa + mfbcc)) + ((mfabc + mfcba) + (mfaba + mfcbc)) + ((mfacb + mfcab) + (mfaab + mfccb))) + + ((mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc))) + mfbbb; + //////////////////////////////////////////////////////////////////////////////////// + //! - Add half of the acceleration (body force) to the velocity as in Eq. (42) \ref + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! + // LBMReal fx = forces[0]; + // LBMReal fy = forces[1]; + // LBMReal fz = -concentration * forces[2]; + // vvx += fx * c1o2; + // vvy += fy * c1o2; + // vvz += fz * c1o2; + //////////////////////////////////////////////////////////////////////////////////// + LBMReal oneMinusRho = c1 - concentration; + + LBMReal cx = + ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + + (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + + (mfcbb - mfabb)); + LBMReal cy = + ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + + (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + + (mfbcb - mfbab)); + LBMReal cz = + ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + + (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + + (mfbbc - mfbba)); + + //////////////////////////////////////////////////////////////////////////////////// + // calculate the square of velocities for this lattice node + LBMReal cx2 = cx * cx; + LBMReal cy2 = cy * cy; + LBMReal cz2 = cz * cz; + //////////////////////////////////////////////////////////////////////////////////// + //! - Chimera transform from well conditioned distributions to central moments as defined in Appendix J in \ref + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! see also Eq. (6)-(14) in \ref + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + forwardInverseChimeraWithKincompressible(mfaaa, mfaab, mfaac, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfaba, mfabb, mfabc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfaca, mfacb, mfacc, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbaa, mfbab, mfbac, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbba, mfbbb, mfbbc, cz, cz2, c9o4, c4o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbca, mfbcb, mfbcc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcaa, mfcab, mfcac, cz, cz2, c36, c1o36, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcba, mfcbb, mfcbc, cz, cz2, c9, c1o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcca, mfccb, mfccc, cz, cz2, c36, c1o36, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + forwardInverseChimeraWithKincompressible(mfaaa, mfaba, mfaca, cy, cy2, c6, c1o6, oneMinusRho); + forwardChimera(mfaab, mfabb, mfacb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfaac, mfabc, mfacc, cy, cy2, c18, c1o18, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfbaa, mfbba, mfbca, cy, cy2, c3o2, c2o3, oneMinusRho); + forwardChimera(mfbab, mfbbb, mfbcb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfbac, mfbbc, mfbcc, cy, cy2, c9o2, c2o9, oneMinusRho); + forwardInverseChimeraWithKincompressible(mfcaa, mfcba, mfcca, cy, cy2, c6, c1o6, oneMinusRho); + forwardChimera(mfcab, mfcbb, mfccb, cy, cy2); + forwardInverseChimeraWithKincompressible(mfcac, mfcbc, mfccc, cy, cy2, c18, c1o18, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + forwardInverseChimeraWithKincompressible(mfaaa, mfbaa, mfcaa, cx, cx2, c1, c1, oneMinusRho); + forwardChimera(mfaba, mfbba, mfcba, cx, cx2); + forwardInverseChimeraWithKincompressible(mfaca, mfbca, mfcca, cx, cx2, c3, c1o3, oneMinusRho); + forwardChimera(mfaab, mfbab, mfcab, cx, cx2); + forwardChimera(mfabb, mfbbb, mfcbb, cx, cx2); + forwardChimera(mfacb, mfbcb, mfccb, cx, cx2); + forwardInverseChimeraWithKincompressible(mfaac, mfbac, mfcac, cx, cx2, c3, c1o3, oneMinusRho); + forwardChimera(mfabc, mfbbc, mfcbc, cx, cx2); + forwardInverseChimeraWithKincompressible(mfacc, mfbcc, mfccc, cx, cx2, c3, c1o9, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + //! - experimental Cumulant ... to be published ... hopefully + //! + + // linearized orthogonalization of 3rd order central moments + LBMReal Mabc = mfabc - mfaba * c1o3; + LBMReal Mbca = mfbca - mfbaa * c1o3; + LBMReal Macb = mfacb - mfaab * c1o3; + LBMReal Mcba = mfcba - mfaba * c1o3; + LBMReal Mcab = mfcab - mfaab * c1o3; + LBMReal Mbac = mfbac - mfbaa * c1o3; + // linearized orthogonalization of 5th order central moments + LBMReal Mcbc = mfcbc - mfaba * c1o9; + LBMReal Mbcc = mfbcc - mfbaa * c1o9; + LBMReal Mccb = mfccb - mfaab * c1o9; + + // collision of 1st order moments + cx = cx * (c1 - omegaD) + omegaD * vvx * concentration + + normX1 * (c1 - 0.5 * omegaD) * ( phi[REST]) * (phi2[REST]) * c1o3 * oneOverInterfaceScale; + cy = cy * (c1 - omegaD) + omegaD * vvy * concentration + + normX2 * (c1 - 0.5 * omegaD) * ( phi[REST]) * (phi2[REST]) * c1o3 * oneOverInterfaceScale; + cz = cz * (c1 - omegaD) + omegaD * vvz * concentration + + normX3 * (c1 - 0.5 * omegaD) * ( phi[REST]) * (phi2[REST]) * c1o3 * oneOverInterfaceScale; + + //mhx = (ux * phi[REST] + normX1 * (tauH - 0.5) * (1.0 - phi[REST]) * (phi[REST])) / tauH + (1.0 - 1.0 / tauH) * mhx; + //mhy = (uy * phi[REST] + normX2 * (tauH - 0.5) * (1.0 - phi[REST]) * (phi[REST])) / tauH + (1.0 - 1.0 / tauH) * mhy; +//mhz = (uz * phi[REST] + normX3 * (tauH - 0.5) * (1.0 - phi[REST]) * (phi[REST])) / tauH + (1.0 - 1.0 / tauH) * mhz; + + + cx2 = cx * cx; + cy2 = cy * cy; + cz2 = cz * cz; + + // equilibration of 2nd order moments + mfbba = zeroReal; + mfbab = zeroReal; + mfabb = zeroReal; + + mfcaa = c1o3 * concentration; + mfaca = c1o3 * concentration; + mfaac = c1o3 * concentration; + + + //LBMReal omega2 = 1.0f;// omegaD; + //mfbba *= (c1 - omega2); + //mfbab *= (c1 - omega2); + //mfabb *= (c1 - omega2); + + //mfcaa = mfcaa*(c1 - omega2) + omega2*c1o3 * concentration; + //mfaca = mfaca*(c1 - omega2) + omega2*c1o3 * concentration; + //mfaac = mfaac*(c1 - omega2) + omega2*c1o3 * concentration; + + // equilibration of 3rd order moments + Mabc = zeroReal; + Mbca = zeroReal; + Macb = zeroReal; + Mcba = zeroReal; + Mcab = zeroReal; + Mbac = zeroReal; + mfbbb = zeroReal; + + // from linearized orthogonalization 3rd order central moments to central moments + mfabc = Mabc + mfaba * c1o3; + mfbca = Mbca + mfbaa * c1o3; + mfacb = Macb + mfaab * c1o3; + mfcba = Mcba + mfaba * c1o3; + mfcab = Mcab + mfaab * c1o3; + mfbac = Mbac + mfbaa * c1o3; + + // equilibration of 4th order moments + mfacc = c1o9 * concentration; + mfcac = c1o9 * concentration; + mfcca = c1o9 * concentration; + + mfcbb = zeroReal; + mfbcb = zeroReal; + mfbbc = zeroReal; + + // equilibration of 5th order moments + Mcbc = zeroReal; + Mbcc = zeroReal; + Mccb = zeroReal; + + // from linearized orthogonalization 5th order central moments to central moments + mfcbc = Mcbc + mfaba * c1o9; + mfbcc = Mbcc + mfbaa * c1o9; + mfccb = Mccb + mfaab * c1o9; + + // equilibration of 6th order moment + mfccc = c1o27 * concentration; + + //////////////////////////////////////////////////////////////////////////////////// + //! - Chimera transform from central moments to well conditioned distributions as defined in Appendix J in + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! see also Eq. (88)-(96) in + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + backwardInverseChimeraWithKincompressible(mfaaa, mfbaa, mfcaa, cx, cx2, c1, c1, oneMinusRho); + backwardChimera(mfaba, mfbba, mfcba, cx, cx2); + backwardInverseChimeraWithKincompressible(mfaca, mfbca, mfcca, cx, cx2, c3, c1o3, oneMinusRho); + backwardChimera(mfaab, mfbab, mfcab, cx, cx2); + backwardChimera(mfabb, mfbbb, mfcbb, cx, cx2); + backwardChimera(mfacb, mfbcb, mfccb, cx, cx2); + backwardInverseChimeraWithKincompressible(mfaac, mfbac, mfcac, cx, cx2, c3, c1o3, oneMinusRho); + backwardChimera(mfabc, mfbbc, mfcbc, cx, cx2); + backwardInverseChimeraWithKincompressible(mfacc, mfbcc, mfccc, cx, cx2, c9, c1o9, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + backwardInverseChimeraWithKincompressible(mfaaa, mfaba, mfaca, cy, cy2, c6, c1o6, oneMinusRho); + backwardChimera(mfaab, mfabb, mfacb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfaac, mfabc, mfacc, cy, cy2, c18, c1o18, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbaa, mfbba, mfbca, cy, cy2, c3o2, c2o3, oneMinusRho); + backwardChimera(mfbab, mfbbb, mfbcb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfbac, mfbbc, mfbcc, cy, cy2, c9o2, c2o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcaa, mfcba, mfcca, cy, cy2, c6, c1o6, oneMinusRho); + backwardChimera(mfcab, mfcbb, mfccb, cy, cy2); + backwardInverseChimeraWithKincompressible(mfcac, mfcbc, mfccc, cy, cy2, c18, c1o18, oneMinusRho); + + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + backwardInverseChimeraWithKincompressible(mfaaa, mfaab, mfaac, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfaba, mfabb, mfabc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfaca, mfacb, mfacc, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbaa, mfbab, mfbac, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbba, mfbbb, mfbbc, cz, cz2, c9o4, c4o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfbca, mfbcb, mfbcc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcaa, mfcab, mfcac, cz, cz2, c36, c1o36, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcba, mfcbb, mfcbc, cz, cz2, c9, c1o9, oneMinusRho); + backwardInverseChimeraWithKincompressible(mfcca, mfccb, mfccc, cz, cz2, c36, c1o36, oneMinusRho); + + + + (*this->localDistributionsH2)(D3Q27System::ET_E, x1, x2, x3) = mfabb; + (*this->localDistributionsH2)(D3Q27System::ET_N, x1, x2, x3) = mfbab; + (*this->localDistributionsH2)(D3Q27System::ET_T, x1, x2, x3) = mfbba; + (*this->localDistributionsH2)(D3Q27System::ET_NE, x1, x2, x3) = mfaab; + (*this->localDistributionsH2)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab; + (*this->localDistributionsH2)(D3Q27System::ET_TE, x1, x2, x3) = mfaba; + (*this->localDistributionsH2)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba; + (*this->localDistributionsH2)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa; + (*this->localDistributionsH2)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca; + (*this->localDistributionsH2)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa; + (*this->localDistributionsH2)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa; + (*this->localDistributionsH2)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca; + (*this->localDistributionsH2)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca; + + (*this->nonLocalDistributionsH2)(D3Q27System::ET_W, x1p, x2, x3) = mfcbb; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_S, x1, x2p, x3) = mfbcb; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_SW, x1p, x2p, x3) = mfccb; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_SE, x1, x2p, x3) = mfacb; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac; + (*this->nonLocalDistributionsH2)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac; + + (*this->zeroDistributionsH2)(x1, x2, x3) = mfbbb; + + } + + + + /////!CUMULANT PHASE-FIELD + + + + ///////////////////// PHASE-FIELD BGK SOLVER /////////////////////////////// + + //h[E] = (*this->localDistributionsH)(D3Q27System::ET_E, x1, x2, x3); + //h[N] = (*this->localDistributionsH)(D3Q27System::ET_N, x1, x2, x3); + //h[T] = (*this->localDistributionsH)(D3Q27System::ET_T, x1, x2, x3); + //h[NE] = (*this->localDistributionsH)(D3Q27System::ET_NE, x1, x2, x3); + //h[NW] = (*this->localDistributionsH)(D3Q27System::ET_NW, x1p, x2, x3); + //h[TE] = (*this->localDistributionsH)(D3Q27System::ET_TE, x1, x2, x3); + //h[TW] = (*this->localDistributionsH)(D3Q27System::ET_TW, x1p, x2, x3); + //h[TN] = (*this->localDistributionsH)(D3Q27System::ET_TN, x1, x2, x3); + //h[TS] = (*this->localDistributionsH)(D3Q27System::ET_TS, x1, x2p, x3); + //h[TNE] = (*this->localDistributionsH)(D3Q27System::ET_TNE, x1, x2, x3); + //h[TNW] = (*this->localDistributionsH)(D3Q27System::ET_TNW, x1p, x2, x3); + //h[TSE] = (*this->localDistributionsH)(D3Q27System::ET_TSE, x1, x2p, x3); + //h[TSW] = (*this->localDistributionsH)(D3Q27System::ET_TSW, x1p, x2p, x3); + + //h[W] = (*this->nonLocalDistributionsH)(D3Q27System::ET_W, x1p, x2, x3); + //h[S] = (*this->nonLocalDistributionsH)(D3Q27System::ET_S, x1, x2p, x3); + //h[B] = (*this->nonLocalDistributionsH)(D3Q27System::ET_B, x1, x2, x3p); + //h[SW] = (*this->nonLocalDistributionsH)(D3Q27System::ET_SW, x1p, x2p, x3); + //h[SE] = (*this->nonLocalDistributionsH)(D3Q27System::ET_SE, x1, x2p, x3); + //h[BW] = (*this->nonLocalDistributionsH)(D3Q27System::ET_BW, x1p, x2, x3p); + //h[BE] = (*this->nonLocalDistributionsH)(D3Q27System::ET_BE, x1, x2, x3p); + //h[BS] = (*this->nonLocalDistributionsH)(D3Q27System::ET_BS, x1, x2p, x3p); + //h[BN] = (*this->nonLocalDistributionsH)(D3Q27System::ET_BN, x1, x2, x3p); + //h[BSW] = (*this->nonLocalDistributionsH)(D3Q27System::ET_BSW, x1p, x2p, x3p); + //h[BSE] = (*this->nonLocalDistributionsH)(D3Q27System::ET_BSE, x1, x2p, x3p); + //h[BNW] = (*this->nonLocalDistributionsH)(D3Q27System::ET_BNW, x1p, x2, x3p); + //h[BNE] = (*this->nonLocalDistributionsH)(D3Q27System::ET_BNE, x1, x2, x3p); + + //h[REST] = (*this->zeroDistributionsH)(x1, x2, x3); + + //for (int dir = STARTF; dir < (ENDF + 1); dir++) { + // LBMReal velProd = DX1[dir] * ux + DX2[dir] * uy + DX3[dir] * uz; + // LBMReal velSq1 = velProd * velProd; + // LBMReal hEq; //, gEq; + + // if (dir != REST) { + // LBMReal dirGrad_phi = (phi[dir] - phi[INVDIR[dir]]) / 2.0; + // LBMReal hSource = (tauH - 0.5) * (1.0 - phi[REST]) * (phi[REST]) * (dirGrad_phi) / denom; + // hEq = phi[REST] * WEIGTH[dir] * (1.0 + 3.0 * velProd + 4.5 * velSq1 - 1.5 * (ux2 + uy2 + uz2)) + hSource * WEIGTH[dir]; + + // // This corresponds with the collision factor of 1.0 which equals (tauH + 0.5). + // h[dir] = h[dir] - (h[dir] - hEq) / (tauH); + + // } else { + // hEq = phi[REST] * WEIGTH[REST] * (1.0 - 1.5 * (ux2 + uy2 + uz2)); + // h[REST] = h[REST] - (h[REST] - hEq) / (tauH); + // } + //} + + //(*this->localDistributionsH)(D3Q27System::ET_E, x1, x2, x3) = h[D3Q27System::INV_E]; + //(*this->localDistributionsH)(D3Q27System::ET_N, x1, x2, x3) = h[D3Q27System::INV_N]; + //(*this->localDistributionsH)(D3Q27System::ET_T, x1, x2, x3) = h[D3Q27System::INV_T]; + //(*this->localDistributionsH)(D3Q27System::ET_NE, x1, x2, x3) = h[D3Q27System::INV_NE]; + //(*this->localDistributionsH)(D3Q27System::ET_NW, x1p, x2, x3) = h[D3Q27System::INV_NW]; + //(*this->localDistributionsH)(D3Q27System::ET_TE, x1, x2, x3) = h[D3Q27System::INV_TE]; + //(*this->localDistributionsH)(D3Q27System::ET_TW, x1p, x2, x3) = h[D3Q27System::INV_TW]; + //(*this->localDistributionsH)(D3Q27System::ET_TN, x1, x2, x3) = h[D3Q27System::INV_TN]; + //(*this->localDistributionsH)(D3Q27System::ET_TS, x1, x2p, x3) = h[D3Q27System::INV_TS]; + //(*this->localDistributionsH)(D3Q27System::ET_TNE, x1, x2, x3) = h[D3Q27System::INV_TNE]; + //(*this->localDistributionsH)(D3Q27System::ET_TNW, x1p, x2, x3) = h[D3Q27System::INV_TNW]; + //(*this->localDistributionsH)(D3Q27System::ET_TSE, x1, x2p, x3) = h[D3Q27System::INV_TSE]; + //(*this->localDistributionsH)(D3Q27System::ET_TSW, x1p, x2p, x3) = h[D3Q27System::INV_TSW]; + + //(*this->nonLocalDistributionsH)(D3Q27System::ET_W, x1p, x2, x3) = h[D3Q27System::INV_W]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_S, x1, x2p, x3) = h[D3Q27System::INV_S]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_B, x1, x2, x3p) = h[D3Q27System::INV_B]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_SW, x1p, x2p, x3) = h[D3Q27System::INV_SW]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_SE, x1, x2p, x3) = h[D3Q27System::INV_SE]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_BW, x1p, x2, x3p) = h[D3Q27System::INV_BW]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_BE, x1, x2, x3p) = h[D3Q27System::INV_BE]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_BS, x1, x2p, x3p) = h[D3Q27System::INV_BS]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_BN, x1, x2, x3p) = h[D3Q27System::INV_BN]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_BSW, x1p, x2p, x3p) = h[D3Q27System::INV_BSW]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_BSE, x1, x2p, x3p) = h[D3Q27System::INV_BSE]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_BNW, x1p, x2, x3p) = h[D3Q27System::INV_BNW]; + //(*this->nonLocalDistributionsH)(D3Q27System::ET_BNE, x1, x2, x3p) = h[D3Q27System::INV_BNE]; + + //(*this->zeroDistributionsH)(x1, x2, x3) = h[D3Q27System::REST]; + + ///////////////////// END OF OLD BGK SOLVER /////////////////////////////// + } + } + } + + // dataSet->setPhaseField(divU); + } +} +////////////////////////////////////////////////////////////////////////// + +LBMReal MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::gradX1_phi() +{ + using namespace D3Q27System; + return 3.0* ((WEIGTH[TNE] * (((phi[TNE] - phi[BSW]) + (phi[BSE] - phi[TNW])) + ((phi[TSE] - phi[BNW]) + (phi[BNE] - phi[TSW]))) + + WEIGTH[NE] * (((phi[TE] - phi[BW]) + (phi[BE] - phi[TW])) + ((phi[SE] - phi[NW]) + (phi[NE] - phi[SW])))) + + +WEIGTH[N] * (phi[E] - phi[W])); + //LBMReal sum = 0.0; + //for (int k = FSTARTDIR; k <= FENDDIR; k++) { + // sum += WEIGTH[k] * DX1[k] * phi[k]; + //} + //return 3.0 * sum; +} + +LBMReal MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::gradX2_phi() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi[TNE] - phi[BSW]) - (phi[BSE] - phi[TNW])) + ((phi[BNE] - phi[TSW])- (phi[TSE] - phi[BNW]))) + + WEIGTH[NE] * (((phi[TN] - phi[BS]) + (phi[BN] - phi[TS])) + ((phi[NE] - phi[SW])- (phi[SE] - phi[NW])))) + + +WEIGTH[N] * (phi[N] - phi[S])); + //LBMReal sum = 0.0; + //for (int k = FSTARTDIR; k <= FENDDIR; k++) { + // sum += WEIGTH[k] * DX2[k] * phi[k]; + //} + //return 3.0 * sum; +} + +LBMReal MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::gradX3_phi() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi[TNE] - phi[BSW]) - (phi[BSE] - phi[TNW])) + ((phi[TSE] - phi[BNW]) - (phi[BNE] - phi[TSW]))) + + WEIGTH[NE] * (((phi[TE] - phi[BW]) - (phi[BE] - phi[TW])) + ((phi[TS] - phi[BN]) + (phi[TN] - phi[BS])))) + + +WEIGTH[N] * (phi[T] - phi[B])); + //LBMReal sum = 0.0; + //for (int k = FSTARTDIR; k <= FENDDIR; k++) { + // sum += WEIGTH[k] * DX3[k] * phi[k]; + //} + //return 3.0 * sum; +} + +LBMReal MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::gradX1_phi2() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi2[TNE] - phi2[BSW]) + (phi2[BSE] - phi2[TNW])) + ((phi2[TSE] - phi2[BNW]) + (phi2[BNE] - phi2[TSW]))) + + WEIGTH[NE] * (((phi2[TE] - phi2[BW]) + (phi2[BE] - phi2[TW])) + ((phi2[SE] - phi2[NW]) + (phi2[NE] - phi2[SW])))) + + +WEIGTH[N] * (phi2[E] - phi2[W])); + //LBMReal sum = 0.0; + //for (int k = FSTARTDIR; k <= FENDDIR; k++) { + // sum += WEIGTH[k] * DX1[k] * phi2[k]; + //} + //return 3.0 * sum; +} + +LBMReal MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::gradX2_phi2() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi2[TNE] - phi2[BSW]) - (phi2[BSE] - phi2[TNW])) + ((phi2[BNE] - phi2[TSW]) - (phi2[TSE] - phi2[BNW]))) + + WEIGTH[NE] * (((phi2[TN] - phi2[BS]) + (phi2[BN] - phi2[TS])) + ((phi2[NE] - phi2[SW]) - (phi2[SE] - phi2[NW])))) + + +WEIGTH[N] * (phi2[N] - phi2[S])); + //LBMReal sum = 0.0; + //for (int k = FSTARTDIR; k <= FENDDIR; k++) { + // sum += WEIGTH[k] * DX2[k] * phi2[k]; + //} + //return 3.0 * sum; +} + +LBMReal MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::gradX3_phi2() +{ + using namespace D3Q27System; + return 3.0 * ((WEIGTH[TNE] * (((phi2[TNE] - phi2[BSW]) - (phi2[BSE] - phi2[TNW])) + ((phi2[TSE] - phi2[BNW]) - (phi2[BNE] - phi2[TSW]))) + + WEIGTH[NE] * (((phi2[TE] - phi2[BW]) - (phi2[BE] - phi2[TW])) + ((phi2[TS] - phi2[BN]) + (phi2[TN] - phi2[BS])))) + + +WEIGTH[N] * (phi2[T] - phi2[B])); + //LBMReal sum = 0.0; + //for (int k = FSTARTDIR; k <= FENDDIR; k++) { + // sum += WEIGTH[k] * DX3[k] * phi2[k]; + //} + //return 3.0 * sum; +} + + + + + +LBMReal MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::nabla2_phi() +{ + using namespace D3Q27System; + LBMReal sum = 0.0; + sum += WEIGTH[TNE] * ((((phi[TNE] - phi[REST]) + (phi[BSW] - phi[REST])) + ((phi[TSW] - phi[REST]) + (phi[BNE] - phi[REST]))) + + (((phi[TNW] - phi[REST]) + (phi[BSE] - phi[REST])) + ((phi[TSE] - phi[REST]) + (phi[BNW] - phi[REST])))); + sum += WEIGTH[TN] * ( + (((phi[TN] - phi[REST]) + (phi[BS] - phi[REST])) + ((phi[TS] - phi[REST]) + (phi[BN] - phi[REST]))) + + (((phi[TE] - phi[REST]) + (phi[BW] - phi[REST])) + ((phi[TW] - phi[REST]) + (phi[BE] - phi[REST]))) + + (((phi[NE] - phi[REST]) + (phi[SW] - phi[REST])) + ((phi[NW] - phi[REST]) + (phi[SE] - phi[REST]))) + ); + sum += WEIGTH[T] * ( + ((phi[T] - phi[REST]) + (phi[B] - phi[REST])) + + ((phi[N] - phi[REST]) + (phi[S] - phi[REST])) + + ((phi[E] - phi[REST]) + (phi[W] - phi[REST])) + ); + //for (int k = FSTARTDIR; k <= FENDDIR; k++) { + // sum += WEIGTH[k] * (phi[k] - phi[REST]); + //} + return 6.0 * sum; +} + +void MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::computePhasefield() +{ + using namespace D3Q27System; + SPtr<DistributionArray3D> distributionsH = dataSet->getHdistributions(); + + int minX1 = ghostLayerWidth; + int minX2 = ghostLayerWidth; + int minX3 = ghostLayerWidth; + int maxX1 = (int)distributionsH->getNX1() - ghostLayerWidth; + int maxX2 = (int)distributionsH->getNX2() - ghostLayerWidth; + int maxX3 = (int)distributionsH->getNX3() - ghostLayerWidth; + + //------------- Computing the phase-field ------------------ + for (int x3 = minX3; x3 < maxX3; x3++) { + for (int x2 = minX2; x2 < maxX2; x2++) { + for (int x1 = minX1; x1 < maxX1; x1++) { + // if(!bcArray->isSolid(x1,x2,x3) && !bcArray->isUndefined(x1,x2,x3)) + { + int x1p = x1 + 1; + int x2p = x2 + 1; + int x3p = x3 + 1; + + h[E] = (*this->localDistributionsH1)(D3Q27System::ET_E, x1, x2, x3); + h[N] = (*this->localDistributionsH1)(D3Q27System::ET_N, x1, x2, x3); + h[T] = (*this->localDistributionsH1)(D3Q27System::ET_T, x1, x2, x3); + h[NE] = (*this->localDistributionsH1)(D3Q27System::ET_NE, x1, x2, x3); + h[NW] = (*this->localDistributionsH1)(D3Q27System::ET_NW, x1p, x2, x3); + h[TE] = (*this->localDistributionsH1)(D3Q27System::ET_TE, x1, x2, x3); + h[TW] = (*this->localDistributionsH1)(D3Q27System::ET_TW, x1p, x2, x3); + h[TN] = (*this->localDistributionsH1)(D3Q27System::ET_TN, x1, x2, x3); + h[TS] = (*this->localDistributionsH1)(D3Q27System::ET_TS, x1, x2p, x3); + h[TNE] = (*this->localDistributionsH1)(D3Q27System::ET_TNE, x1, x2, x3); + h[TNW] = (*this->localDistributionsH1)(D3Q27System::ET_TNW, x1p, x2, x3); + h[TSE] = (*this->localDistributionsH1)(D3Q27System::ET_TSE, x1, x2p, x3); + h[TSW] = (*this->localDistributionsH1)(D3Q27System::ET_TSW, x1p, x2p, x3); + + h[W] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_W, x1p, x2, x3); + h[S] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_S, x1, x2p, x3); + h[B] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_B, x1, x2, x3p); + h[SW] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SW, x1p, x2p, x3); + h[SE] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_SE, x1, x2p, x3); + h[BW] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BW, x1p, x2, x3p); + h[BE] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BE, x1, x2, x3p); + h[BS] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BS, x1, x2p, x3p); + h[BN] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BN, x1, x2, x3p); + h[BSW] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSW, x1p, x2p, x3p); + h[BSE] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BSE, x1, x2p, x3p); + h[BNW] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNW, x1p, x2, x3p); + h[BNE] = (*this->nonLocalDistributionsH1)(D3Q27System::ET_BNE, x1, x2, x3p); + + h[REST] = (*this->zeroDistributionsH1)(x1, x2, x3); + } + } + } + } +} + +void MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::findNeighbors(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr ph, int x1, int x2, + int x3) +{ + using namespace D3Q27System; + + SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); + + phi[REST] = (*ph)(x1, x2, x3); + + + for (int k = FSTARTDIR; k <= FENDDIR; k++) { + + if (!bcArray->isSolid(x1 + DX1[k], x2 + DX2[k], x3 + DX3[k])) { + phi[k] = (*ph)(x1 + DX1[k], x2 + DX2[k], x3 + DX3[k]); + } else { + phi[k] = 0.0; + } + } +} + +void MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::findNeighbors2(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr ph, int x1, int x2, + int x3) +{ + using namespace D3Q27System; + + SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); + + phi2[REST] = (*ph)(x1, x2, x3); + + + for (int k = FSTARTDIR; k <= FENDDIR; k++) { + + if (!bcArray->isSolid(x1 + DX1[k], x2 + DX2[k], x3 + DX3[k])) { + phi2[k] = (*ph)(x1 + DX1[k], x2 + DX2[k], x3 + DX3[k]); + } + else { + phi2[k] = 0.0; + } + } +} + +void MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel::swapDistributions() +{ + LBMKernel::swapDistributions(); + dataSet->getHdistributions()->swap(); + dataSet->getH2distributions()->swap(); +} \ No newline at end of file diff --git a/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel.h new file mode 100644 index 0000000000000000000000000000000000000000..070aff23ff78d079d12806b529a750b007ae7137 --- /dev/null +++ b/src/cpu/VirtualFluidsCore/LBM/MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel.h @@ -0,0 +1,119 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel.h +//! \ingroup LBMKernel +//! \author Hesameddin Safari +//======================================================================================= + +#ifndef MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel_H +#define MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel_H + +#include "LBMKernel.h" +#include "BCProcessor.h" +#include "D3Q27System.h" +#include "basics/utilities/UbTiming.h" +#include "basics/container/CbArray4D.h" +#include "basics/container/CbArray3D.h" + +//! \brief Multiphase Cascaded Cumulant LBM kernel. +//! \details CFD solver that use Cascaded Cumulant Lattice Boltzmann method for D3Q27 model +//! \author H. Safari, K. Kutscher, M. Geier +class MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel : public LBMKernel +{ +public: + MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel(); + virtual ~MultiphaseTwoPhaseFieldsVelocityCumulantLBMKernel(void) = default; + void calculate(int step) override; + SPtr<LBMKernel> clone() override; + void forwardInverseChimeraWithKincompressible(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K, LBMReal oneMinusRho); + void backwardInverseChimeraWithKincompressible(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K, LBMReal oneMinusRho); + void forwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2); + void backwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2); + + ///refactor + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr pressure; + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr pressureOld; + + double getCalculationTime() override { return .0; } +protected: + virtual void initDataSet(); + void swapDistributions() override; + LBMReal f1[D3Q27System::ENDF+1]; + + CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr localDistributionsF; + CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsF; + CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr zeroDistributionsF; + + CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr localDistributionsH1; + CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsH1; + CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr zeroDistributionsH1; + + CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributionsH2; + CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsH2; + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributionsH2; + + //CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr phaseField; + + + LBMReal h [D3Q27System::ENDF+1]; + LBMReal h2[D3Q27System::ENDF + 1]; + LBMReal g [D3Q27System::ENDF+1]; + LBMReal phi[D3Q27System::ENDF+1]; + LBMReal phi2[D3Q27System::ENDF + 1]; + LBMReal pr1[D3Q27System::ENDF+1]; + LBMReal phi_cutoff[D3Q27System::ENDF+1]; + + LBMReal gradX1_phi(); + LBMReal gradX2_phi(); + LBMReal gradX3_phi(); + LBMReal gradX1_phi2(); + LBMReal gradX2_phi2(); + LBMReal gradX3_phi2(); + //LBMReal gradX1_pr1(); + //LBMReal gradX2_pr1(); + //LBMReal gradX3_pr1(); + //LBMReal dirgradC_phi(int n, int k); + void computePhasefield(); + void findNeighbors(CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr ph /*Phase-Field*/, int x1, int x2, int x3); + void findNeighbors2(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr ph, int x1, int x2, int x3); + //void findNeighbors(CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr ph /*Phase-Field*/, CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr pf /*Pressure-Field*/, int x1, int x2, int x3); + //void pressureFiltering(CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr pf /*Pressure-Field*/, CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr pf_filtered /*Pressure-Field*/); + + LBMReal nabla2_phi(); + + + mu::value_type muX1,muX2,muX3; + mu::value_type muDeltaT; + mu::value_type muNu; + LBMReal forcingX1; + LBMReal forcingX2; + LBMReal forcingX3; +}; + +#endif diff --git a/src/cpu/VirtualFluidsCore/Parallel/MPICommunicator.h b/src/cpu/VirtualFluidsCore/Parallel/MPICommunicator.h index 3c25cc78f74e7a4efbca436bc0dc07b62ce4fa6e..19ad23a537ce580f11bc107dcede0cad64f69fc3 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/MPICommunicator.h +++ b/src/cpu/VirtualFluidsCore/Parallel/MPICommunicator.h @@ -139,16 +139,23 @@ void MPICommunicator::allGather(std::vector<T> &svalues, std::vector<T> &rvalues rvalues.resize(displs[numprocs - 1] + rcounts[numprocs - 1]); - if (rvalues.size() == 0) { - rvalues.resize(1); - rvalues[0] = 999; + T* sval = NULL; + T* rval = NULL; + + if (svalues.size() > 0) { + //svalues.resize(1); + //svalues[0] = 999; + sval = &svalues[0]; } - if (scount == 0) { - svalues.resize(1); - svalues[0] = 999; + + if (rvalues.size() > 0) { + //rvalues.resize(1); + //rvalues[0] = 999; + rval = &rvalues[0]; } - MPI_Allgatherv(&svalues[0], scount, mpiDataType, &rvalues[0], &rcounts[0], &displs[0], mpiDataType, comm); + //MPI_Allgatherv(&svalues[0], scount, mpiDataType, &rvalues[0], &rcounts[0], &displs[0], mpiDataType, comm); + MPI_Allgatherv(sval, scount, mpiDataType, rval, &rcounts[0], &displs[0], mpiDataType, comm); } ////////////////////////////////////////////////////////////////////////// template <class T> diff --git a/src/cpu/VirtualFluidsCore/Parallel/MPIIODataStructures.h b/src/cpu/VirtualFluidsCore/Parallel/MPIIODataStructures.h index c8bd2d0797af86858b40a1a29a154107f04e46c8..74627f6181cd02002e2bc2c7a2d284ff288f3c59 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/MPIIODataStructures.h +++ b/src/cpu/VirtualFluidsCore/Parallel/MPIIODataStructures.h @@ -117,12 +117,7 @@ struct BoundaryCondition { float bcVelocityX2; float bcVelocityX3; float bcDensity; - - float bcLodiDensity; - float bcLodiVelocityX1; - float bcLodiVelocityX2; - float bcLodiVelocityX3; - float bcLodiLentgh; + float bcPhaseField; float nx1, nx2, nx3; float q[26]; @@ -172,6 +167,7 @@ struct DSArraysPresence { bool isRelaxationFactorPresent; bool isPhaseField1Present; bool isPhaseField2Present; + bool isPressureFieldPresent; }; } // namespace MPIIODataStructures #endif \ No newline at end of file diff --git a/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.cpp b/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.cpp index b66eff480e99102edf332cfd750e0d2b6965ba83..caad0f726762e3ffafe2b657516bd305de61b603 100644 --- a/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.cpp +++ b/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.cpp @@ -77,7 +77,7 @@ CheckpointConverter::CheckpointConverter(SPtr<Grid3D> grid, const std::string &p //--------------------------------------- MPI_Datatype typesDataSetRead[3] = { MPI_DOUBLE, MPI_INT, MPI_CHAR }; - int blocksDataSetRead[3] = { 3, 5, 2 }; + int blocksDataSetRead[3] = { 5, 5, 2 }; MPI_Aint offsetsDataSetRead[3], lbDataSetRead, extentDataSetRead; offsetsDataSetRead[0] = 0; @@ -93,7 +93,7 @@ CheckpointConverter::CheckpointConverter(SPtr<Grid3D> grid, const std::string &p //----------------------------------------------------------------------- MPI_Datatype typesDataSetWrite[3] = { MPI_DOUBLE, MPI_INT, MPI_CHAR }; - int blocksDataSetWrite[3] = { 2, 2, 2 }; + int blocksDataSetWrite[3] = { 5, 2, 2 }; MPI_Aint offsetsDataSetWrite[3], lbDataSetWrite, extentDataSetWrite; offsetsDataSetWrite[0] = 0; @@ -147,8 +147,7 @@ void CheckpointConverter::convertBlocks(int step, int procCount) MPI_File file_handlerW; UbSystem::makeDirectory(path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step)); std::string filenameW = path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBlocks.bin"; - int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, - &file_handlerW); + int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handlerW); if (rcW != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filenameW); @@ -159,21 +158,21 @@ void CheckpointConverter::convertBlocks(int step, int procCount) GridParam *gridParameters = new GridParam; // calculate the read offset - procCount = - 1; // readBlocks and writeBlocks in both MPIIORestartCoProcessor and MPIIOMigrationCoProcessor have size == 1! + procCount = 1; // readBlocks and writeBlocks in both MPIIORestartCoProcessor and MPIIOMigrationCoProcessor have size == 1! MPI_Offset read_offset = (MPI_Offset)(procCount * sizeof(int)); // read parameters of the grid and blocks MPI_File_read_at(file_handlerR, read_offset, gridParameters, 1, gridParamType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + sizeof(GridParam)), &block3dArray[0], blocksCount, - block3dType, MPI_STATUS_IGNORE); + MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + sizeof(GridParam)), &block3dArray[0], blocksCount, block3dType, MPI_STATUS_IGNORE); // clear the grid std::vector<SPtr<Block3D>> blocksVector[25]; int minInitLevel = this->grid->getCoarsestInitializedLevel(); - if (minInitLevel > -1) { + if (minInitLevel > -1) + { int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) { + for (int level = minInitLevel; level <= maxInitLevel; level++) + { grid->getBlocks(level, blocksVector[level]); for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level grid->deleteBlock(block); @@ -233,9 +232,9 @@ void CheckpointConverter::convertBlocks(int step, int procCount) grid->setPeriodicX3(gridParameters->periodicX3); // regenerate blocks - for (int n = 0; n < blocksCount; n++) { - SPtr<Block3D> block( - new Block3D(block3dArray[n].x1, block3dArray[n].x2, block3dArray[n].x3, block3dArray[n].level)); + for (int n = 0; n < blocksCount; n++) + { + SPtr<Block3D> block(new Block3D(block3dArray[n].x1, block3dArray[n].x2, block3dArray[n].x3, block3dArray[n].level)); block->setActive(block3dArray[n].active); block->setBundle(block3dArray[n].bundle); block->setRank(block3dArray[n].rank); @@ -255,7 +254,8 @@ void CheckpointConverter::convertBlocks(int step, int procCount) // refresh globalID in all the blocks SPtr<Block3D> block; - for (int n = 0; n < blocksCount; n++) { + for (int n = 0; n < blocksCount; n++) + { block = grid->getBlock(block3dArray[n].x1, block3dArray[n].x2, block3dArray[n].x3, block3dArray[n].level); block3dArray[n].globalID = block->getGlobalID(); } @@ -265,8 +265,7 @@ void CheckpointConverter::convertBlocks(int step, int procCount) MPI_File_write_at(file_handlerW, 0, &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); MPI_File_write_at(file_handlerW, write_offset, gridParameters, 1, gridParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handlerW, (MPI_Offset)(write_offset + sizeof(GridParam)), &block3dArray[0], blocksCount, - block3dType, MPI_STATUS_IGNORE); + MPI_File_write_at(file_handlerW, (MPI_Offset)(write_offset + sizeof(GridParam)), &block3dArray[0], blocksCount, block3dType, MPI_STATUS_IGNORE); MPI_File_close(&file_handlerR); MPI_File_close(&file_handlerW); @@ -282,19 +281,31 @@ void CheckpointConverter::convertDataSet(int step, int procCount) { // file to read from MPI_File file_handlerR; - std::string filenameR = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSet.bin"; + std::string filenameR = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetF.bin"; int rcR = MPI_File_open(MPI_COMM_WORLD, filenameR.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handlerR); if (rcR != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filenameR); // file to write to MPI_File file_handlerW; - std::string filenameW = path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSet.bin"; - int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, - &file_handlerW); + std::string filenameW = path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetF.bin"; + int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handlerW); if (rcW != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filenameW); + MPI_File file_handlerR1; + std::string filenameR1 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetH1.bin"; + rcR = MPI_File_open(MPI_COMM_WORLD, filenameR1.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handlerR1); + if (rcR != MPI_SUCCESS) + throw UbException(UB_EXARGS, "couldn't open file " + filenameR1); + + MPI_File file_handlerW1; + std::string filenameW1 = path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSetH1.bin"; + rcW = MPI_File_open(MPI_COMM_WORLD, filenameW1.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handlerW1); + if (rcW != MPI_SUCCESS) + throw UbException(UB_EXARGS, "couldn't open file " + filenameW1); + + MPI_Offset fsize; double start, finish; start = MPI_Wtime(); @@ -304,22 +315,21 @@ void CheckpointConverter::convertDataSet(int step, int procCount) DataSetMigration *dataSetWriteArray; size_t doubleCountInBlock; std::vector<double> doubleValuesArray; + std::vector<double> doubleValuesArrayH1; // double-values in all blocks H1distributions size_t sizeofOneDataSet; // calculate the read offset MPI_Offset read_offset = (MPI_Offset)(procCount * sizeof(int)); MPI_Offset write_offset; - for (int pc = 0; pc < procCount; pc++) { + for (int pc = 0; pc < procCount; pc++) + { // read count of blocks and parameters of data arrays MPI_File_read_at(file_handlerR, (MPI_Offset)(pc * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); MPI_File_read_at(file_handlerR, read_offset, &dataSetParamStr1, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + sizeof(dataSetParam)), &dataSetParamStr2, 1, - dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + 2 * sizeof(dataSetParam)), &dataSetParamStr3, 1, - dataSetParamType, MPI_STATUS_IGNORE); - doubleCountInBlock = - dataSetParamStr1.nx[0] * dataSetParamStr1.nx[1] * dataSetParamStr1.nx[2] * dataSetParamStr1.nx[3] + + MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + sizeof(dataSetParam)), &dataSetParamStr2, 1, dataSetParamType, MPI_STATUS_IGNORE); + MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + 2 * sizeof(dataSetParam)), &dataSetParamStr3, 1, dataSetParamType, MPI_STATUS_IGNORE); + doubleCountInBlock = dataSetParamStr1.nx[0] * dataSetParamStr1.nx[1] * dataSetParamStr1.nx[2] * dataSetParamStr1.nx[3] + dataSetParamStr2.nx[0] * dataSetParamStr2.nx[1] * dataSetParamStr2.nx[2] * dataSetParamStr2.nx[3] + dataSetParamStr3.nx[0] * dataSetParamStr3.nx[1] * dataSetParamStr3.nx[2] * dataSetParamStr3.nx[3]; @@ -327,56 +337,77 @@ void CheckpointConverter::convertDataSet(int step, int procCount) dataSetWriteArray = new DataSetMigration[blocksCount]; doubleValuesArray.resize(blocksCount * doubleCountInBlock); + MPI_Type_contiguous(int(doubleCountInBlock), MPI_DOUBLE, &dataSetDoubleType); + MPI_Type_commit(&dataSetDoubleType); + // read data MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + 3 * sizeof(dataSetParam)), dataSetReadArray, blocksCount, dataSetTypeRead, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, - (MPI_Offset)(read_offset + 3 * sizeof(dataSetParam) + blocksCount * sizeof(DataSetRestart)), - &doubleValuesArray[0], int(blocksCount * doubleCountInBlock), MPI_DOUBLE, MPI_STATUS_IGNORE); + MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + 3 * sizeof(dataSetParam) + blocksCount * sizeof(DataSetRestart)), + &doubleValuesArray[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); // offset to read the data of the next process - read_offset = - read_offset + (MPI_Offset)(3 * sizeof(dataSetParam) + - blocksCount * (sizeof(DataSetRestart) + doubleCountInBlock * sizeof(double))); + read_offset = read_offset + (MPI_Offset)(3 * sizeof(dataSetParam) + blocksCount * (sizeof(DataSetRestart) + doubleCountInBlock * sizeof(double))); // write parameters of data arrays MPI_File_write_at(file_handlerW, (MPI_Offset)0, &dataSetParamStr1, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handlerW, (MPI_Offset)(sizeof(dataSetParam)), &dataSetParamStr2, 1, dataSetParamType, - MPI_STATUS_IGNORE); - MPI_File_write_at(file_handlerW, (MPI_Offset)(2 * sizeof(dataSetParam)), &dataSetParamStr3, 1, dataSetParamType, - MPI_STATUS_IGNORE); + MPI_File_write_at(file_handlerW, (MPI_Offset)(sizeof(dataSetParam)), &dataSetParamStr2, 1, dataSetParamType, MPI_STATUS_IGNORE); + MPI_File_write_at(file_handlerW, (MPI_Offset)(2 * sizeof(dataSetParam)), &dataSetParamStr3, 1, dataSetParamType, MPI_STATUS_IGNORE); sizeofOneDataSet = sizeof(DataSetMigration) + doubleCountInBlock * sizeof(double); // write blocks and their data arrays - for (int nb = 0; nb < blocksCount; nb++) { - SPtr<Block3D> block = grid->getBlock(dataSetReadArray[nb].x1, dataSetReadArray[nb].x2, - dataSetReadArray[nb].x3, dataSetReadArray[nb].level); + for (int nb = 0; nb < blocksCount; nb++) + { + SPtr<Block3D> block = grid->getBlock(dataSetReadArray[nb].x1, dataSetReadArray[nb].x2, dataSetReadArray[nb].x3, dataSetReadArray[nb].level); dataSetWriteArray[nb].globalID = block->getGlobalID(); dataSetWriteArray[nb].ghostLayerWidth = dataSetReadArray[nb].ghostLayerWidth; dataSetWriteArray[nb].collFactor = dataSetReadArray[nb].collFactor; dataSetWriteArray[nb].deltaT = dataSetReadArray[nb].deltaT; dataSetWriteArray[nb].compressible = dataSetReadArray[nb].compressible; dataSetWriteArray[nb].withForcing = dataSetReadArray[nb].withForcing; -// dataSetWriteArray[nb].densityRatio = dataSetReadArray[nb].densityRatio; + dataSetWriteArray[nb].collFactorL = dataSetReadArray[nb].collFactorL; // for Multiphase model + dataSetWriteArray[nb].collFactorG = dataSetReadArray[nb].collFactorG; // for Multiphase model + dataSetWriteArray[nb].densityRatio = dataSetReadArray[nb].densityRatio;// for Multiphase model write_offset = (MPI_Offset)(3 * sizeof(dataSetParam) + dataSetWriteArray[nb].globalID * sizeofOneDataSet); - MPI_File_write_at(file_handlerW, write_offset, &dataSetWriteArray[nb], 1, dataSetTypeWrite, - MPI_STATUS_IGNORE); + MPI_File_write_at(file_handlerW, write_offset, &dataSetWriteArray[nb], 1, dataSetTypeWrite, MPI_STATUS_IGNORE); MPI_File_write_at(file_handlerW, (MPI_Offset)(write_offset + sizeof(DataSetMigration)), - &doubleValuesArray[nb * doubleCountInBlock], int(doubleCountInBlock), MPI_DOUBLE, - MPI_STATUS_IGNORE); + &doubleValuesArray[nb * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); } + //-------------------------------------- H1 ----------------------------- + MPI_File_get_size(file_handlerR1, &fsize); + if (fsize > 0) + { + doubleValuesArrayH1.resize(blocksCount * doubleCountInBlock); + MPI_File_read_at(file_handlerR1, read_offset, &doubleValuesArrayH1[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); + + sizeofOneDataSet = doubleCountInBlock * sizeof(double); + + for (int nb = 0; nb < blocksCount; nb++) + { + write_offset = (MPI_Offset)(dataSetWriteArray[nb].globalID * sizeofOneDataSet); + MPI_File_write_at(file_handlerW1, write_offset, &doubleValuesArrayH1[nb * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); + } + + } + + MPI_Type_free(&dataSetDoubleType); + delete[] dataSetReadArray; delete[] dataSetWriteArray; } - MPI_File_close(&file_handlerR); + MPI_File_close(&file_handlerR1); + MPI_File_sync(file_handlerW1); + MPI_File_close(&file_handlerW1); + MPI_File_close(&file_handlerR); MPI_File_sync(file_handlerW); MPI_File_close(&file_handlerW); +//-------------------------------------------------------------------------------- DSArraysPresence arrPresence; MPI_File file_handler1; std::string filename1 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpArrays.bin"; @@ -400,28 +431,22 @@ void CheckpointConverter::convertDataSet(int step, int procCount) std::string filenameWW = path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step); if (arrPresence.isAverageDensityArrayPresent) - convert___Array(step, procCount, filenameRR + "/cpAverageDensityArray.bin", - filenameWW + "/cpAverageDensityArray.bin"); + convert___Array(step, procCount, filenameRR + "/cpAverageDensityArray.bin", filenameWW + "/cpAverageDensityArray.bin"); if (arrPresence.isAverageVelocityArrayPresent) - convert___Array(step, procCount, filenameRR + "/cpAverageVelocityArray.bin", - filenameWW + "/cpAverageVelocityArray.bin"); + convert___Array(step, procCount, filenameRR + "/cpAverageVelocityArray.bin", filenameWW + "/cpAverageVelocityArray.bin"); if (arrPresence.isAverageFluktuationsArrayPresent) - convert___Array(step, procCount, filenameRR + "/cpAverageFluktuationsArray.bin", - filenameWW + "/cpAverageFluktuationsArray.bin"); + convert___Array(step, procCount, filenameRR + "/cpAverageFluktuationsArray.bin", filenameWW + "/cpAverageFluktuationsArray.bin"); if (arrPresence.isAverageTripleArrayPresent) - convert___Array(step, procCount, filenameRR + "/cpAverageTripleArray.bin", - filenameWW + "/cpAverageTripleArray.bin"); + convert___Array(step, procCount, filenameRR + "/cpAverageTripleArray.bin", filenameWW + "/cpAverageTripleArray.bin"); if (arrPresence.isShearStressValArrayPresent) - convert___Array(step, procCount, filenameRR + "/cpShearStressValArray.bin", - filenameWW + "/cpShearStressValArray.bin"); + convert___Array(step, procCount, filenameRR + "/cpShearStressValArray.bin", filenameWW + "/cpShearStressValArray.bin"); if (arrPresence.isRelaxationFactorPresent) - convert___Array(step, procCount, filenameRR + "/cpRelaxationFactor.bin", - filenameWW + "/cpRelaxationFactor.bin"); + convert___Array(step, procCount, filenameRR + "/cpRelaxationFactor.bin", filenameWW + "/cpRelaxationFactor.bin"); finish = MPI_Wtime(); UBLOG(logINFO, "UtilConvertor::convertDataSet time: " << finish - start << " s"); @@ -439,8 +464,7 @@ void CheckpointConverter::convert___Array(int /*step*/, int procCount, std::stri throw UbException(UB_EXARGS, "couldn't open file " + filenameR); MPI_File file_handlerW; - int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, - &file_handlerW); + int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handlerW); if (rcW != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filenameW); @@ -457,32 +481,29 @@ void CheckpointConverter::convert___Array(int /*step*/, int procCount, std::stri MPI_Offset write_offset; size_t sizeofOneDataSet; - for (int pc = 0; pc < procCount; pc++) { + for (int pc = 0; pc < procCount; pc++) + { MPI_File_read_at(file_handlerR, (MPI_Offset)(pc * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); MPI_File_read_at(file_handlerR, read_offset, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); dataSetSmallReadArray = new DataSetSmallRestart[blocksCount]; dataSetSmallWriteArray = new DataSetSmallMigration[blocksCount]; - doubleCountInBlock = - dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; + doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; doubleValuesArray.resize(blocksCount * doubleCountInBlock); - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + sizeof(dataSetParam)), dataSetSmallReadArray, - blocksCount * 4, MPI_INT, MPI_STATUS_IGNORE); + MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + sizeof(dataSetParam)), dataSetSmallReadArray, blocksCount * 4, MPI_INT, MPI_STATUS_IGNORE); if (doubleCountInBlock > 0) - MPI_File_read_at( - file_handlerR, - (MPI_Offset)(read_offset + sizeof(dataSetParam) + blocksCount * sizeof(DataSetSmallRestart)), + MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + sizeof(dataSetParam) + blocksCount * sizeof(DataSetSmallRestart)), &doubleValuesArray[0], blocksCount * doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - read_offset = read_offset + sizeof(dataSetParam) + - blocksCount * (sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); + read_offset = read_offset + sizeof(dataSetParam) + blocksCount * (sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); sizeofOneDataSet = sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double); MPI_File_write_at(file_handlerW, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - for (int nb = 0; nb < blocksCount; nb++) { + for (int nb = 0; nb < blocksCount; nb++) + { SPtr<Block3D> block = grid->getBlock(dataSetSmallReadArray[nb].x1, dataSetSmallReadArray[nb].x2, dataSetSmallReadArray[nb].x3, dataSetSmallReadArray[nb].level); dataSetSmallWriteArray[nb].globalID = block->getGlobalID(); @@ -490,8 +511,7 @@ void CheckpointConverter::convert___Array(int /*step*/, int procCount, std::stri write_offset = (MPI_Offset)(sizeof(dataSetParam) + dataSetSmallWriteArray[nb].globalID * sizeofOneDataSet); MPI_File_write_at(file_handlerW, write_offset, &dataSetSmallWriteArray[nb], 1, MPI_INT, MPI_STATUS_IGNORE); MPI_File_write_at(file_handlerW, (MPI_Offset)(write_offset + sizeof(DataSetSmallMigration)), - &doubleValuesArray[nb * doubleCountInBlock], doubleCountInBlock, MPI_DOUBLE, - MPI_STATUS_IGNORE); + &doubleValuesArray[nb * doubleCountInBlock], doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); } delete[] dataSetSmallReadArray; @@ -518,8 +538,7 @@ void CheckpointConverter::convertBC(int step, int procCount) // file to write to MPI_File file_handlerW; std::string filenameW = path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBC.bin"; - int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, - &file_handlerW); + int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handlerW); if (rcW != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filenameW); @@ -546,7 +565,8 @@ void CheckpointConverter::convertBC(int step, int procCount) MPI_Offset write_offset = (MPI_Offset)(sizeof(boundCondParam) + grid->getNumberOfBlocks() * sizeof(size_t)); MPI_Offset write_offsetIndex; - for (int pc = 0; pc < procCount; pc++) { + for (int pc = 0; pc < procCount; pc++) + { read_offset = (MPI_Offset)(pc * (3 * sizeof(int) + sizeof(boundCondParam))); // read count of blocks @@ -574,15 +594,10 @@ void CheckpointConverter::convertBC(int step, int procCount) MPI_File_read_at(file_handlerR, read_offset1, bcAddReadArray, blocksCount * 6, MPI_INT, MPI_STATUS_IGNORE); MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset1 + blocksCount * sizeof(BCAddRestart)), &bcArray[0], dataCount1000, boundCondType1000, MPI_STATUS_IGNORE); - MPI_File_read_at( - file_handlerR, - (MPI_Offset)(read_offset1 + blocksCount * sizeof(BCAddRestart) + dataCount * sizeof(BoundaryCondition)), - &intArray1[0], blocksCount * boundCondParamStr.bcindexmatrixCount, MPI_INT, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, - (MPI_Offset)(read_offset1 + blocksCount * sizeof(BCAddRestart) + - dataCount * sizeof(BoundaryCondition) + - blocksCount * boundCondParamStr.bcindexmatrixCount * sizeof(int)), - &intArray2[0], dataCount2, MPI_INT, MPI_STATUS_IGNORE); + MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset1 + blocksCount * sizeof(BCAddRestart) + dataCount * sizeof(BoundaryCondition)), + &intArray1[0], blocksCount * boundCondParamStr.bcindexmatrixCount, MPI_INT, MPI_STATUS_IGNORE); + MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset1 + blocksCount * sizeof(BCAddRestart) + dataCount * sizeof(BoundaryCondition) + + blocksCount * boundCondParamStr.bcindexmatrixCount * sizeof(int)), &intArray2[0], dataCount2, MPI_INT, MPI_STATUS_IGNORE); // offset to read the data of the next process read_offset1 = read_offset1 + blocksCount * sizeof(BCAddRestart) + dataCount * sizeof(BoundaryCondition) + @@ -593,14 +608,12 @@ void CheckpointConverter::convertBC(int step, int procCount) indexBC = 0; indexC = 0; // write blocks and their BC data arrays - for (int nb = 0; nb < blocksCount; nb++) { - SPtr<Block3D> block = grid->getBlock(bcAddReadArray[nb].x1, bcAddReadArray[nb].x2, bcAddReadArray[nb].x3, - bcAddReadArray[nb].level); + for (int nb = 0; nb < blocksCount; nb++) + { + SPtr<Block3D> block = grid->getBlock(bcAddReadArray[nb].x1, bcAddReadArray[nb].x2, bcAddReadArray[nb].x3, bcAddReadArray[nb].level); bcAddWriteArray[nb].globalID = block->getGlobalID(); - bcAddWriteArray[nb].boundCond_count = - bcAddReadArray[nb].boundCond_count; // how many BoundaryConditions in this block - bcAddWriteArray[nb].indexContainer_count = - bcAddReadArray[nb].indexContainer_count; // how many indexContainer-values in this block + bcAddWriteArray[nb].boundCond_count = bcAddReadArray[nb].boundCond_count; // how many BoundaryConditions in this block + bcAddWriteArray[nb].indexContainer_count = bcAddReadArray[nb].indexContainer_count; // how many indexContainer-values in this block write_offsetIndex = (MPI_Offset)(sizeof(boundCondParam) + bcAddWriteArray[nb].globalID * sizeof(size_t)); MPI_File_write_at(file_handlerW, write_offsetIndex, &write_offset, 1, MPI_LONG_LONG_INT, MPI_STATUS_IGNORE); @@ -612,24 +625,16 @@ void CheckpointConverter::convertBC(int step, int procCount) indexBC += bcAddWriteArray[nb].boundCond_count; if (boundCondParamStr.bcindexmatrixCount > 0) - MPI_File_write_at(file_handlerW, - (MPI_Offset)(write_offset + sizeof(BCAddMigration) + - bcAddWriteArray[nb].boundCond_count * sizeof(BoundaryCondition)), - &intArray1[nb * boundCondParamStr.bcindexmatrixCount], - boundCondParamStr.bcindexmatrixCount, MPI_INT, MPI_STATUS_IGNORE); + MPI_File_write_at(file_handlerW, (MPI_Offset)(write_offset + sizeof(BCAddMigration) + bcAddWriteArray[nb].boundCond_count * sizeof(BoundaryCondition)), + &intArray1[nb * boundCondParamStr.bcindexmatrixCount], boundCondParamStr.bcindexmatrixCount, MPI_INT, MPI_STATUS_IGNORE); if (bcAddWriteArray[nb].indexContainer_count > 0) - MPI_File_write_at(file_handlerW, - (MPI_Offset)(write_offset + sizeof(BCAddMigration) + - bcAddWriteArray[nb].boundCond_count * sizeof(BoundaryCondition) + - boundCondParamStr.bcindexmatrixCount * sizeof(int)), - &intArray2[indexC], bcAddWriteArray[nb].indexContainer_count, MPI_INT, - MPI_STATUS_IGNORE); + MPI_File_write_at(file_handlerW, (MPI_Offset)(write_offset + sizeof(BCAddMigration) + bcAddWriteArray[nb].boundCond_count * sizeof(BoundaryCondition) + + boundCondParamStr.bcindexmatrixCount * sizeof(int)), &intArray2[indexC], bcAddWriteArray[nb].indexContainer_count, MPI_INT, MPI_STATUS_IGNORE); indexC += bcAddWriteArray[nb].indexContainer_count; write_offset += sizeof(BCAddMigration) + bcAddWriteArray[nb].boundCond_count * sizeof(BoundaryCondition) + - boundCondParamStr.bcindexmatrixCount * sizeof(int) + - bcAddWriteArray[nb].indexContainer_count * sizeof(int); + boundCondParamStr.bcindexmatrixCount * sizeof(int) + bcAddWriteArray[nb].indexContainer_count * sizeof(int); } delete[] bcAddReadArray; diff --git a/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.h b/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.h index bad6116ccf8e1ebc32b8f7d6e12c3d36bc1b4e46..294081a4fe6265a1aa8ef74c5ec79cb8a13efedf 100644 --- a/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.h +++ b/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.h @@ -32,7 +32,7 @@ protected: private: MPI_Datatype gridParamType, block3dType; MPI_Datatype dataSetParamType, dataSetTypeRead, dataSetTypeWrite; - MPI_Datatype boundCondType, boundCondType1000; + MPI_Datatype boundCondType, boundCondType1000, dataSetDoubleType; MPIIODataStructures::boundCondParam boundCondParamStr; }; diff --git a/src/cpu/VirtualFluidsCore/Visitors/MultiphaseInitDistributionsBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/MultiphaseInitDistributionsBlockVisitor.cpp index 4213e2b79a83107a8a545e5daa3001c5a86af35d..3df7fbcc90c551876b4886e44c85d0bd965346ef 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/MultiphaseInitDistributionsBlockVisitor.cpp +++ b/src/cpu/VirtualFluidsCore/Visitors/MultiphaseInitDistributionsBlockVisitor.cpp @@ -50,16 +50,13 @@ MultiphaseInitDistributionsBlockVisitor::MultiphaseInitDistributionsBlockVisitor this->setRho(0.0); } ////////////////////////////////////////////////////////////////////////// -MultiphaseInitDistributionsBlockVisitor::MultiphaseInitDistributionsBlockVisitor( LBMReal densityRatio, LBMReal intThickness, LBMReal radius, LBMReal vx1, LBMReal vx2, LBMReal vx3) - : Block3DVisitor(0, Grid3DSystem::MAXLEVEL), densityRatio(densityRatio) /*, intThickness(intThickness), radius(radius) */ +MultiphaseInitDistributionsBlockVisitor::MultiphaseInitDistributionsBlockVisitor( LBMReal densityRatio, LBMReal vx1, LBMReal vx2, LBMReal vx3, LBMReal rho) + : Block3DVisitor(0, Grid3DSystem::MAXLEVEL), densityRatio(densityRatio) { - (void) intThickness; - (void) radius; - this->setVx1(vx1); this->setVx2(vx2); this->setVx3(vx3); -} + this->setRho(rho);} ////////////////////////////////////////////////////////////////////////// void MultiphaseInitDistributionsBlockVisitor::setVx1( const mu::Parser& parser) { @@ -197,7 +194,7 @@ void MultiphaseInitDistributionsBlockVisitor::visit(const SPtr<Grid3D> grid, SPt p1 = 0.0; - //p1 = muRho.Eval(); + p1 = muRho.Eval(); vx1 = muVx1.Eval(); vx2 = muVx2.Eval(); vx3 = muVx3.Eval(); @@ -223,8 +220,10 @@ void MultiphaseInitDistributionsBlockVisitor::visit(const SPtr<Grid3D> grid, SPt LBMReal gamma = WEIGTH[dir]*(3*velProd + 4.5*velSq1 - 1.5*(vx1Sq+vx2Sq+vx3Sq)); feq[dir] = rho*WEIGTH[dir]*(1 + 3*velProd + 4.5*velSq1 - 1.5*(vx1Sq+vx2Sq+vx3Sq)); - //geq[dir] = p1*WEIGTH1[dir] + gamma; - geq[dir] = p1*WEIGTH[dir]/(rho*UbMath::c1o3) + gamma; + //geq[dir] = p1*WEIGTH[dir] + gamma; + //geq[dir] = p1*WEIGTH[dir]/(rho*UbMath::c1o3) + gamma*rho; + //geq[dir] = (p1*WEIGTH[dir]/(rho*UbMath::c1o3) + gamma*rho)*UbMath::c1o3; + geq[dir] = (gamma*rho)*UbMath::c1o3; } @@ -291,6 +290,35 @@ void MultiphaseInitDistributionsBlockVisitor::visit(const SPtr<Grid3D> grid, SPt distributionsH->setDistributionInv(f, ix1, ix2, ix3); if (distributionsH2) { + + f[E] = (1.-phi) * feq[E] / rho; + f[W] = (1.-phi) * feq[W] / rho; + f[N] = (1.-phi) * feq[N] / rho; + f[S] = (1.-phi) * feq[S] / rho; + f[T] = (1.-phi) * feq[T] / rho; + f[B] = (1.-phi) * feq[B] / rho; + f[NE] = (1.-phi) * feq[NE] / rho; + f[SW] = (1.-phi) * feq[SW] / rho; + f[SE] = (1.-phi) * feq[SE] / rho; + f[NW] = (1.-phi) * feq[NW] / rho; + f[TE] = (1.-phi) * feq[TE] / rho; + f[BW] = (1.-phi) * feq[BW] / rho; + f[BE] = (1.-phi) * feq[BE] / rho; + f[TW] = (1.-phi) * feq[TW] / rho; + f[TN] = (1.-phi) * feq[TN] / rho; + f[BS] = (1.-phi) * feq[BS] / rho; + f[BN] = (1.-phi) * feq[BN] / rho; + f[TS] = (1.-phi) * feq[TS] / rho; + f[TNE] = (1.-phi) * feq[TNE] / rho; + f[TNW] = (1.-phi) * feq[TNW] / rho; + f[TSE] = (1.-phi) * feq[TSE] / rho; + f[TSW] = (1.-phi) * feq[TSW] / rho; + f[BNE] = (1.-phi) * feq[BNE] / rho; + f[BNW] = (1.-phi) * feq[BNW] / rho; + f[BSE] = (1.-phi) * feq[BSE] / rho; + f[BSW] = (1.-phi) * feq[BSW] / rho; + f[REST] = (1.-phi) * feq[REST] / rho; + distributionsH2->setDistribution(f, ix1, ix2, ix3); distributionsH2->setDistributionInv(f, ix1, ix2, ix3); } diff --git a/src/cpu/VirtualFluidsCore/Visitors/MultiphaseInitDistributionsBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/MultiphaseInitDistributionsBlockVisitor.h index f94167040ad2f1f8b3cdb1f1e1d4f970d80c8877..6ff60387daeef966da6143ef459fa7b7d247fbd5 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/MultiphaseInitDistributionsBlockVisitor.h +++ b/src/cpu/VirtualFluidsCore/Visitors/MultiphaseInitDistributionsBlockVisitor.h @@ -56,7 +56,7 @@ public: //! \param vx1 - velocity in x //! \param vx2 - velocity in y //! \param vx3 - velocity in z - MultiphaseInitDistributionsBlockVisitor( LBMReal densityRatio, LBMReal intThickness, LBMReal radius, LBMReal vx1=0.0, LBMReal vx2=0.0, LBMReal vx3=0.0); + MultiphaseInitDistributionsBlockVisitor( LBMReal densityRatio, LBMReal vx1=0.0, LBMReal vx2=0.0, LBMReal vx3=0.0, LBMReal rho=0.0); ////////////////////////////////////////////////////////////////////////// //automatic vars are: x1,x2, x3 //ussage example: setVx1("x1*0.01+x2*0.003") @@ -95,8 +95,6 @@ private: LBMReal nu; LBMReal densityRatio; - //LBMReal intThickness; - //LBMReal radius; }; #endif //D3Q27INITDISTRIBUTIONSPATCHVISITOR_H diff --git a/src/cpu/VirtualFluidsCore/Visitors/MultiphaseSetKernelBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/MultiphaseSetKernelBlockVisitor.cpp index 733c7177dd7624ac78c6a8d30681f20cdedb456b..11863b6912dee88a161db75ba81db44c5ec586de 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/MultiphaseSetKernelBlockVisitor.cpp +++ b/src/cpu/VirtualFluidsCore/Visitors/MultiphaseSetKernelBlockVisitor.cpp @@ -35,11 +35,11 @@ void MultiphaseSetKernelBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> blo { LBMReal collFactorL = LBMSystem::calcCollisionFactor(nuL, block->getLevel()); LBMReal collFactorG = LBMSystem::calcCollisionFactor(nuG, block->getLevel()); - kernel->setCollisionFactorMultiphase(collFactorL, collFactorG); - kernel->setDensityRatio(densityRatio); - kernel->setMultiphaseModelParameters(beta, kappa); - kernel->setContactAngle(contactAngle); + + //kernel->setDensityRatio(densityRatio); + //kernel->setMultiphaseModelParameters(beta, kappa); + //kernel->setContactAngle(contactAngle); kernel->setIndex(block->getX1(), block->getX2(), block->getX3()); kernel->setDeltaT(LBMSystem::getDeltaT(block->getLevel())); diff --git a/src/cpu/VirtualFluidsCore/Visitors/MultiphaseVelocityFormInitDistributionsBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/MultiphaseVelocityFormInitDistributionsBlockVisitor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8a201fa3e7236572ca94c83c72ee90149d676390 --- /dev/null +++ b/src/cpu/VirtualFluidsCore/Visitors/MultiphaseVelocityFormInitDistributionsBlockVisitor.cpp @@ -0,0 +1,351 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file MultiphaseVelocityFormInitDistributionsBlockVisitor.cpp +//! \ingroup Visitors +//! \author Hesameddin Safari +//======================================================================================= + +#include "MultiphaseVelocityFormInitDistributionsBlockVisitor.h" +#include "BCArray3D.h" +#include "BCProcessor.h" +#include "Block3D.h" +#include "DataSet3D.h" +#include "EsoTwist3D.h" +#include "Grid3D.h" +#include "Grid3DSystem.h" +#include "LBMKernel.h" + +MultiphaseVelocityFormInitDistributionsBlockVisitor::MultiphaseVelocityFormInitDistributionsBlockVisitor() + : Block3DVisitor(0, Grid3DSystem::MAXLEVEL) +{ + this->setVx1(0.0); + this->setVx2(0.0); + this->setVx3(0.0); + this->setRho(0.0); +} +////////////////////////////////////////////////////////////////////////// +void MultiphaseVelocityFormInitDistributionsBlockVisitor::setVx1( const mu::Parser& parser) +{ + this->checkFunction(parser); + this->muVx1 = parser; +} +////////////////////////////////////////////////////////////////////////// +void MultiphaseVelocityFormInitDistributionsBlockVisitor::setVx2( const mu::Parser& parser) +{ + this->checkFunction(parser); + this->muVx2 = parser; +} +////////////////////////////////////////////////////////////////////////// +void MultiphaseVelocityFormInitDistributionsBlockVisitor::setVx3( const mu::Parser& parser) +{ + this->checkFunction(parser); + this->muVx3 = parser; +} +////////////////////////////////////////////////////////////////////////// +void MultiphaseVelocityFormInitDistributionsBlockVisitor::setRho( const mu::Parser& parser) +{ + this->checkFunction(parser); + this->muRho = parser; +} +////////////////////////////////////////////////////////////////////////// +void MultiphaseVelocityFormInitDistributionsBlockVisitor::setPhi( const mu::Parser& parser) +{ + this->checkFunction(parser); + this->muPhi = parser; +} +////////////////////////////////////////////////////////////////////////// +void MultiphaseVelocityFormInitDistributionsBlockVisitor::setVx1( const std::string& muParserString) +{ + this->muVx1.SetExpr(muParserString); + this->checkFunction(muVx1); +} +////////////////////////////////////////////////////////////////////////// +void MultiphaseVelocityFormInitDistributionsBlockVisitor::setVx2( const std::string& muParserString) +{ + this->muVx2.SetExpr(muParserString); + this->checkFunction(muVx2); +} +////////////////////////////////////////////////////////////////////////// +void MultiphaseVelocityFormInitDistributionsBlockVisitor::setVx3( const std::string& muParserString) +{ + this->muVx3.SetExpr(muParserString); + this->checkFunction(muVx3); +} +////////////////////////////////////////////////////////////////////////// +void MultiphaseVelocityFormInitDistributionsBlockVisitor::setRho( const std::string& muParserString) +{ + this->muRho.SetExpr(muParserString); + this->checkFunction(muRho); +} +////////////////////////////////////////////////////////////////////////// +void MultiphaseVelocityFormInitDistributionsBlockVisitor::setPhi( const std::string& muParserString) +{ + this->muPhi.SetExpr(muParserString); + this->checkFunction(muPhi); +} +////////////////////////////////////////////////////////////////////////// +void MultiphaseVelocityFormInitDistributionsBlockVisitor::setVx1( LBMReal vx1 ) +{ + this->muVx1.SetExpr( UbSystem::toString(vx1,D3Q27RealLim::digits10) ); + this->checkFunction(muVx1); +} +////////////////////////////////////////////////////////////////////////// +void MultiphaseVelocityFormInitDistributionsBlockVisitor::setVx2( LBMReal vx2 ) +{ + this->muVx2.SetExpr( UbSystem::toString(vx2,D3Q27RealLim::digits10) ); + this->checkFunction(muVx2); +} +////////////////////////////////////////////////////////////////////////// +void MultiphaseVelocityFormInitDistributionsBlockVisitor::setVx3( LBMReal vx3 ) +{ + this->muVx3.SetExpr( UbSystem::toString(vx3,D3Q27RealLim::digits10) ); + this->checkFunction(muVx3); +} +////////////////////////////////////////////////////////////////////////// +void MultiphaseVelocityFormInitDistributionsBlockVisitor::setRho( LBMReal rho ) +{ + this->muRho.SetExpr( UbSystem::toString(rho,D3Q27RealLim::digits10) ); + this->checkFunction(muRho); +} +////////////////////////////////////////////////////////////////////////// +void MultiphaseVelocityFormInitDistributionsBlockVisitor::setPhi( LBMReal phi ) +{ + this->muPhi.SetExpr( UbSystem::toString(phi,D3Q27RealLim::digits10) ); + this->checkFunction(muPhi); +} +////////////////////////////////////////////////////////////////////////// +void MultiphaseVelocityFormInitDistributionsBlockVisitor::visit(const SPtr<Grid3D> grid, SPtr<Block3D> block) +{ + using namespace D3Q27System; + + if(!block) UB_THROW( UbException(UB_EXARGS,"block is not exist") ); + + //define vars for functions + mu::value_type x1,x2,x3; + this->muVx1.DefineVar("x1",&x1); this->muVx1.DefineVar("x2",&x2); this->muVx1.DefineVar("x3",&x3); + this->muVx2.DefineVar("x1",&x1); this->muVx2.DefineVar("x2",&x2); this->muVx2.DefineVar("x3",&x3); + this->muVx3.DefineVar("x1",&x1); this->muVx3.DefineVar("x2",&x2); this->muVx3.DefineVar("x3",&x3); + this->muRho.DefineVar("x1",&x1); this->muRho.DefineVar("x2",&x2); this->muRho.DefineVar("x3",&x3); + this->muPhi.DefineVar("x1",&x1); this->muPhi.DefineVar("x2",&x2); this->muPhi.DefineVar("x3",&x3); + + + + int gridRank = grid->getRank(); + int blockRank = block->getRank(); + + if (blockRank == gridRank && block->isActive()) + { + SPtr<LBMKernel> kernel = dynamicPointerCast<LBMKernel>(block->getKernel()); + if (!kernel) + throw UbException(UB_EXARGS, "The LBM kernel isn't exist in block: "+block->toString()); + + SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); + SPtr<EsoTwist3D> distributionsF = dynamicPointerCast<EsoTwist3D>(kernel->getDataSet()->getFdistributions()); + SPtr<EsoTwist3D> distributionsH = dynamicPointerCast<EsoTwist3D>(kernel->getDataSet()->getHdistributions()); + SPtr<EsoTwist3D> distributionsH2 = dynamicPointerCast<EsoTwist3D>(kernel->getDataSet()->getH2distributions()); + + //LBMReal phiL = kernel->getPhiL(); + //LBMReal phiH = kernel->getPhiH(); + + LBMReal f[D3Q27System::ENDF+1]; + + for(int ix3=0; ix3<(int)bcArray->getNX3(); ix3++) + for (int ix2 = 0; ix2 < (int)bcArray->getNX2(); ix2++) + for (int ix1 = 0; ix1 < (int)bcArray->getNX1(); ix1++) + { + Vector3D coords = grid->getNodeCoordinates(block, ix1, ix2, ix3); + x1 = coords[0]; + x2 = coords[1]; + x3 = coords[2]; + + LBMReal vx1 = 0, vx2 = 0, vx3 = 0, p1 = 0, phi = 0; + p1 = 0.0; + //p1 = muRho.Eval(); + vx1 = muVx1.Eval(); + vx2 = muVx2.Eval(); + vx3 = muVx3.Eval(); + phi = muPhi.Eval(); + + //rho = phi*1.0 + (1.0-phi)/densityRatio; + //LBMReal rhoH = 1.0; + //LBMReal rhoL = 1.0/densityRatio; + //LBMReal rho = rhoH + (rhoH - rhoL)*(phi - phiH)/(phiH - phiL); + + + LBMReal feq[27]; + LBMReal geq[27]; + + //calcFeqsFct(feq,rho,vx1,vx2,vx3); + LBMReal vx1Sq = vx1*vx1; + LBMReal vx2Sq = vx2*vx2; + LBMReal vx3Sq = vx3*vx3; + for (int dir = STARTF; dir < (ENDF+1); dir++) + { + LBMReal velProd = DX1[dir]*vx1 + DX2[dir]*vx2 + DX3[dir]*vx3; + LBMReal velSq1 = velProd*velProd; + LBMReal gamma = WEIGTH[dir]*(3*velProd + 4.5*velSq1 - 1.5*(vx1Sq+vx2Sq+vx3Sq)); + + //feq[dir] = rho*WEIGTH[dir]*(1 + 3*velProd + 4.5*velSq1 - 1.5*(vx1Sq+vx2Sq+vx3Sq)); + feq[dir] = WEIGTH[dir] * (1 + 3 * velProd + 4.5 * velSq1 - 1.5 * (vx1Sq + vx2Sq + vx3Sq)); + //geq[dir] = p1*WEIGTH1[dir] + gamma; + //geq[dir] = p1*WEIGTH[dir]/(rho*UbMath::c1o3) + gamma*rho; + geq[dir] = p1 * WEIGTH[dir] / ( UbMath::c1o3) + gamma ; + } + + + f[E] = geq[E] ; + f[W] = geq[W] ; + f[N] = geq[N] ; + f[S] = geq[S] ; + f[T] = geq[T] ; + f[B] = geq[B] ; + f[NE] = geq[NE] ; + f[SW] = geq[SW] ; + f[SE] = geq[SE] ; + f[NW] = geq[NW] ; + f[TE] = geq[TE] ; + f[BW] = geq[BW] ; + f[BE] = geq[BE] ; + f[TW] = geq[TW] ; + f[TN] = geq[TN] ; + f[BS] = geq[BS] ; + f[BN] = geq[BN] ; + f[TS] = geq[TS] ; + f[TNE] = geq[TNE] ; + f[TNW] = geq[TNW] ; + f[TSE] = geq[TSE] ; + f[TSW] = geq[TSW] ; + f[BNE] = geq[BNE] ; + f[BNW] = geq[BNW] ; + f[BSE] = geq[BSE] ; + f[BSW] = geq[BSW] ; + f[REST] = geq[REST] ; + + distributionsF->setDistribution(f, ix1, ix2, ix3); + distributionsF->setDistributionInv(f, ix1, ix2, ix3); + + f[E] = phi * feq[E] ;// / rho; + f[W] = phi * feq[W] ;// / rho; + f[N] = phi * feq[N] ;// / rho; + f[S] = phi * feq[S] ;// / rho; + f[T] = phi * feq[T] ;// / rho; + f[B] = phi * feq[B] ;// / rho; + f[NE] = phi * feq[NE] ;// / rho; + f[SW] = phi * feq[SW] ;// / rho; + f[SE] = phi * feq[SE] ;// / rho; + f[NW] = phi * feq[NW] ;// / rho; + f[TE] = phi * feq[TE] ;// / rho; + f[BW] = phi * feq[BW] ;// / rho; + f[BE] = phi * feq[BE] ;// / rho; + f[TW] = phi * feq[TW] ;// / rho; + f[TN] = phi * feq[TN] ;// / rho; + f[BS] = phi * feq[BS] ;// / rho; + f[BN] = phi * feq[BN] ;// / rho; + f[TS] = phi * feq[TS] ;// / rho; + f[TNE] = phi * feq[TNE] ;// / rho; + f[TNW] = phi * feq[TNW] ;// / rho; + f[TSE] = phi * feq[TSE] ;// / rho; + f[TSW] = phi * feq[TSW] ;// / rho; + f[BNE] = phi * feq[BNE] ;// / rho; + f[BNW] = phi * feq[BNW] ;// / rho; + f[BSE] = phi * feq[BSE] ;// / rho; + f[BSW] = phi * feq[BSW] ;// / rho; + f[REST] = phi * feq[REST] ;// / rho; + + distributionsH->setDistribution(f, ix1, ix2, ix3); + distributionsH->setDistributionInv(f, ix1, ix2, ix3); + + if (distributionsH2) { + + f[E] = (1.-phi) * feq[E] ;// / rho; + f[W] = (1.-phi) * feq[W] ;// / rho; + f[N] = (1.-phi) * feq[N] ;// / rho; + f[S] = (1.-phi) * feq[S] ;// / rho; + f[T] = (1.-phi) * feq[T] ;// / rho; + f[B] = (1.-phi) * feq[B] ;// / rho; + f[NE] = (1.-phi) * feq[NE] ;// / rho; + f[SW] = (1.-phi) * feq[SW] ;// / rho; + f[SE] = (1.-phi) * feq[SE] ;// / rho; + f[NW] = (1.-phi) * feq[NW] ;// / rho; + f[TE] = (1.-phi) * feq[TE] ;// / rho; + f[BW] = (1.-phi) * feq[BW] ;// / rho; + f[BE] = (1.-phi) * feq[BE] ;// / rho; + f[TW] = (1.-phi) * feq[TW] ;// / rho; + f[TN] = (1.-phi) * feq[TN] ;// / rho; + f[BS] = (1.-phi) * feq[BS] ;// / rho; + f[BN] = (1.-phi) * feq[BN] ;// / rho; + f[TS] = (1.-phi) * feq[TS] ;// / rho; + f[TNE] = (1.-phi) * feq[TNE] ;// / rho; + f[TNW] = (1.-phi) * feq[TNW] ;// / rho; + f[TSE] = (1.-phi) * feq[TSE] ;// / rho; + f[TSW] = (1.-phi) * feq[TSW] ;// / rho; + f[BNE] = (1.-phi) * feq[BNE] ;// / rho; + f[BNW] = (1.-phi) * feq[BNW] ;// / rho; + f[BSE] = (1.-phi) * feq[BSE] ;// / rho; + f[BSW] = (1.-phi) * feq[BSW] ;// / rho; + f[REST] = (1.-phi) * feq[REST];// / rho; + + distributionsH2->setDistribution(f, ix1, ix2, ix3); + distributionsH2->setDistributionInv(f, ix1, ix2, ix3); + } + } + } + + //variablen der functions loeschen, da die verwiesenen Objecte nach dem verlassen des scopes ungueltig sind! + this->muVx1.ClearVar(); + this->muVx2.ClearVar(); + this->muVx3.ClearVar(); + this->muRho.ClearVar(); + +} +////////////////////////////////////////////////////////////////////////// +void MultiphaseVelocityFormInitDistributionsBlockVisitor::checkFunction(mu::Parser fct) +{ + double x1=1.0,x2=1.0,x3=1.0; + fct.DefineVar("x1",&x1); + fct.DefineVar("x2",&x2); + fct.DefineVar("x3",&x3); + + try + { + fct.Eval(); + fct.ClearVar(); + } + catch(mu::ParserError& e) + { + throw UbException(UB_EXARGS,"function: "+e.GetExpr() + (std::string)"error: "+e.GetMsg() + +(std::string)", only x1,x2,x3 are allowed as variables" ); + } +} +////////////////////////////////////////////////////////////////////////// +void MultiphaseVelocityFormInitDistributionsBlockVisitor::setNu( LBMReal nu ) +{ + this->nu = nu; +} + diff --git a/src/cpu/VirtualFluidsCore/Visitors/MultiphaseVelocityFormInitDistributionsBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/MultiphaseVelocityFormInitDistributionsBlockVisitor.h new file mode 100644 index 0000000000000000000000000000000000000000..72841a7c5e4915a1a69cb221b7a9d3d0142f0e52 --- /dev/null +++ b/src/cpu/VirtualFluidsCore/Visitors/MultiphaseVelocityFormInitDistributionsBlockVisitor.h @@ -0,0 +1,98 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file MultiphaseVelocityFormInitDistributionsBlockVisitor.h +//! \ingroup Visitors +//! \author Hesameddin Safari, Martin Geier, Konstantin Kutscher +//======================================================================================= + +#ifndef MultiphaseVelocityFormInitDistributionsBlockVisitor_H +#define MultiphaseVelocityFormInitDistributionsBlockVisitor_H + +#include "Block3DVisitor.h" +#include "D3Q27System.h" +#include "Block3D.h" + +#include <muParser.h> + + + +class MultiphaseVelocityFormInitDistributionsBlockVisitor : public Block3DVisitor +{ +public: + typedef std::numeric_limits<LBMReal> D3Q27RealLim; + +public: + MultiphaseVelocityFormInitDistributionsBlockVisitor(); + //D3Q27ETInitDistributionsBlockVisitor(LBMReal rho, LBMReal vx1=0.0, LBMReal vx2=0.0, LBMReal vx3=0.0); + //! Constructor + //! \param nu - viscosity + //! \param rho - density + //! \param vx1 - velocity in x + //! \param vx2 - velocity in y + //! \param vx3 - velocity in z + ////////////////////////////////////////////////////////////////////////// + //automatic vars are: x1,x2, x3 + //ussage example: setVx1("x1*0.01+x2*0.003") + ////////////////////////////////////////////////////////////////////////// + void setVx1( const mu::Parser& parser); + void setVx2( const mu::Parser& parser); + void setVx3( const mu::Parser& parser); + void setRho( const mu::Parser& parser); + void setPhi( const mu::Parser& parser); + + void setVx1( const std::string& muParserString); + void setVx2( const std::string& muParserString); + void setVx3( const std::string& muParserString); + void setRho( const std::string& muParserString); + void setPhi( const std::string& muParserString); + + ////////////////////////////////////////////////////////////////////////// + void setVx1( LBMReal vx1 ); + void setVx2( LBMReal vx2 ); + void setVx3( LBMReal vx3 ); + void setRho( LBMReal rho ); + void setPhi( LBMReal rho ); + void setNu( LBMReal nu ); + + void visit(SPtr<Grid3D> grid, SPtr<Block3D> block); + +protected: + void checkFunction(mu::Parser fct); + +private: + mu::Parser muVx1; + mu::Parser muVx2; + mu::Parser muVx3; + mu::Parser muRho; + mu::Parser muPhi; + + LBMReal nu; +}; + +#endif //D3Q27INITDISTRIBUTIONSPATCHVISITOR_H diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.h index 827a8263a3b4bf0f013dc7b1be7f597ce5ccb82e..c9fa88791e23f35fafa14fb2e20272f0bae04b56 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.h +++ b/src/cpu/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.h @@ -47,7 +47,9 @@ #include "TwoDistributionsFullDirectConnector.h" #include "TwoDistributionsFullVectorConnector.h" #include "ThreeDistributionsFullDirectConnector.h" +#include "ThreeDistributionsDoubleGhostLayerFullDirectConnector.h" #include "ThreeDistributionsFullVectorConnector.h" +#include "ThreeDistributionsDoubleGhostLayerFullVectorConnector.h" #include <basics/transmitter/TbTransmitterLocal.h> //! \brief A class sets connectors between blocks. @@ -158,5 +160,6 @@ void SetConnectorsBlockVisitor<T1, T2>::setRemoteConnectors(SPtr<Block3D> sblock using OneDistributionSetConnectorsBlockVisitor = SetConnectorsBlockVisitor<OneDistributionFullDirectConnector, OneDistributionFullVectorConnector>; using TwoDistributionsSetConnectorsBlockVisitor = SetConnectorsBlockVisitor<TwoDistributionsFullDirectConnector, TwoDistributionsFullVectorConnector>; using ThreeDistributionsSetConnectorsBlockVisitor = SetConnectorsBlockVisitor<ThreeDistributionsFullDirectConnector, ThreeDistributionsFullVectorConnector>; +using ThreeDistributionsDoubleGhostLayerSetConnectorsBlockVisitor = SetConnectorsBlockVisitor<ThreeDistributionsDoubleGhostLayerFullDirectConnector, ThreeDistributionsDoubleGhostLayerFullVectorConnector>; #endif // SETCONNECTORSBLOCKVISITOR_H