From a4999f8551a889e10aa7c2b4164c7e6b3f5b3063 Mon Sep 17 00:00:00 2001 From: Konstantin Kutscher <kutscher@irmb.tu-bs.de> Date: Tue, 4 Apr 2017 11:13:02 +0000 Subject: [PATCH] new boundary conditions --- source/Applications.cmake | 8 +- source/Applications/DHIT/dhit.cfg | 10 +- source/Applications/DHIT/dhit.cpp | 49 +- source/Applications/DLR-F16/Bombadil.cfg | 27 + source/Applications/DLR-F16/CMakeLists.txt | 25 + source/Applications/DLR-F16/F16Bombadil.cfg | 39 + .../Applications/DLR-F16/F16BombadilTest.cfg | 51 ++ .../DLR-F16/F16BombadilTest10e-6.cfg | 55 ++ .../DLR-F16/F16BombadilTestSmall.cfg | 53 ++ source/Applications/DLR-F16/f16.cpp | 669 ++++++++++++++ .../FlowAroundCylinder/CMakeLists.txt | 4 +- .../FlowAroundCylinder/cylinder.cpp | 675 ++++----------- .../FlowAroundCylinder/cylinder.cpp.old | 755 ++++++++++++++++ .../Hagen_Poiseuille_flow/pfDP.cfg | 18 + .../Hagen_Poiseuille_flow/pflow.cpp | 818 ++++++++---------- source/Applications/LaminarTubeFlow/ltf.cfg | 6 +- source/Applications/LaminarTubeFlow/ltf.cpp | 86 +- .../aperm/PA200-250-50_800MPI.cfg | 53 ++ .../aperm/PA80-110+120-150_MPI.cfg | 59 ++ .../aperm/PA80-110+120-150_dx80.cfg | 63 ++ source/Applications/aperm/aperm.cpp | 379 ++++---- source/Applications/aperm/aperm.cpp.old | 573 ++++++++++++ source/Applications/aperm/configBombadil2.txt | 77 +- .../aperm/configBombadilSBP120s500.txt | 6 +- source/Applications/f16Test/CMakeLists.txt | 25 + .../f16Test/F16BombadilTestSmall.cfg | 55 ++ source/Applications/f16Test/f16test.cpp | 669 ++++++++++++++ source/Applications/mirror/CMakeLists.txt | 25 + source/Applications/mirror/mirror.cfg | 60 ++ source/Applications/mirror/mirror.cpp | 577 ++++++++++++ source/Applications/mirror/mirrorV1.cfg | 60 ++ .../cmake_config_files/GOTTFRIED.config.cmake | 6 +- .../cmake_config_files/KONRAD.config.cmake | 6 +- source/CMake/compilerflags/gcc62.cmake | 50 ++ source/IncludsList.cmake | 2 +- .../numerics/geometry3d/GbVoxelMatrix3D.cpp | 810 ++++++++--------- .../numerics/geometry3d/GbVoxelMatrix3D.h | 118 +-- source/VirtualFluids.h | 78 +- .../BoundaryConditions/BCAdapter.h | 100 +++ .../BoundaryConditions/BCAlgorithm.cpp | 103 +++ .../BoundaryConditions/BCAlgorithm.h | 88 ++ .../BoundaryConditions/BCArray3D.cpp | 196 +++++ .../BoundaryConditions/BCArray3D.h | 185 ++++ .../BoundaryConditions/BCFunction.cpp | 5 + .../BoundaryConditions/BCFunction.h | 117 +++ .../BoundaryConditions/BCProcessor.cpp | 64 ++ .../BoundaryConditions/BCProcessor.h | 48 + .../BoundaryConditions/BoundaryConditions.cpp | 4 + .../BoundaryConditions/BoundaryConditions.h | 292 +++++++ .../BoundaryConditions/CMakePackage.txt | 2 + .../BoundaryConditions/DensityBCAdapter.cpp | 157 ++++ .../BoundaryConditions/DensityBCAdapter.h | 81 ++ .../EqDensityBCAlgorithm.cpp | 58 ++ .../BoundaryConditions/EqDensityBCAlgorithm.h | 26 + .../HighViscosityNoSlipBCAlgorithm.cpp | 45 + .../HighViscosityNoSlipBCAlgorithm.h | 27 + .../BoundaryConditions/NoSlipBCAdapter.cpp | 1 + .../BoundaryConditions/NoSlipBCAdapter.h | 52 ++ .../BoundaryConditions/NoSlipBCAlgorithm.cpp | 45 + .../BoundaryConditions/NoSlipBCAlgorithm.h | 26 + .../NonEqDensityBCAlgorithm.cpp | 59 ++ .../NonEqDensityBCAlgorithm.h | 26 + .../NonReflectingDensityBCAlgorithm.cpp | 192 ++++ .../NonReflectingDensityBCAlgorithm.h | 26 + .../NonReflectingVelocityBCAlgorithm.cpp | 59 ++ .../NonReflectingVelocityBCAlgorithm.h | 32 + .../BoundaryConditions/SlipBCAdapter.cpp | 35 + .../BoundaryConditions/SlipBCAdapter.h | 94 ++ .../BoundaryConditions/SlipBCAlgorithm.cpp | 84 ++ .../BoundaryConditions/SlipBCAlgorithm.h | 26 + .../ThinWallBCProcessor.cpp | 41 + .../BoundaryConditions/ThinWallBCProcessor.h | 34 + .../ThinWallNoSlipBCAlgorithm.cpp | 66 ++ .../ThinWallNoSlipBCAlgorithm.h | 31 + .../BoundaryConditions/VelocityBCAdapter.cpp | 306 +++++++ .../BoundaryConditions/VelocityBCAdapter.h | 156 ++++ .../VelocityBCAlgorithm.cpp | 49 ++ .../BoundaryConditions/VelocityBCAlgorithm.h | 28 + source/VirtualFluidsCore/CMakeLists.txt | 2 +- .../CoProcessors/AdjustForcingCoProcessor.cpp | 2 +- .../CoProcessors/AdjustForcingCoProcessor.h | 6 +- .../CoProcessors/AverageValuesCoProcessor.cpp | 20 +- .../CoProcessors/AverageValuesCoProcessor.h | 2 +- .../CalculateForcesCoProcessor.cpp | 10 +- .../CoProcessors/CalculateForcesCoProcessor.h | 2 +- .../DecreaseViscosityCoProcessor.cpp | 4 +- .../DecreaseViscosityCoProcessor.h | 2 +- .../InSituCatalystCoProcessor.cpp | 12 +- .../CoProcessors/InSituVTKCoProcessor.cpp | 8 +- .../IntegrateValuesHelper.cpp} | 48 +- .../IntegrateValuesHelper.h} | 16 +- .../LineTimeSeriesCoProcessor.cpp | 16 +- .../PressureDifferenceCoProcessor.cpp | 2 +- .../PressureDifferenceCoProcessor.h | 6 +- .../CoProcessors/QCriterionCoProcessor.cpp | 24 +- .../CoProcessors/ShearStressCoProcessor.cpp | 92 +- .../CoProcessors/ShearStressCoProcessor.h | 4 +- .../TimeAveragedValuesCoProcessor.cpp | 18 +- .../TimeAveragedValuesCoProcessor.h | 2 +- .../CoProcessors/TimeseriesCoProcessor.cpp | 2 +- .../CoProcessors/TimeseriesCoProcessor.h | 6 +- .../TurbulenceIntensityCoProcessor.cpp | 12 +- .../WriteBoundaryConditionsCoProcessor.cpp | 219 +++++ .../WriteBoundaryConditionsCoProcessor.h | 58 ++ ...WriteMacroscopicQuantitiesCoProcessor.cpp} | 190 +--- ...> WriteMacroscopicQuantitiesCoProcessor.h} | 15 +- .../Connectors/Block3DConnectorFactory.cpp | 4 +- .../Connectors/Block3DConnectorFactory.h | 4 +- .../CoarseToFineBlock3DConnector.cpp | 2 +- .../Connectors/CoarseToFineBlock3DConnector.h | 6 +- .../CoarseToFineNodeSetBlock3DConnector.cpp | 4 +- .../CoarseToFineNodeSetBlock3DConnector.h | 7 +- .../Connectors/ConnectorFactory.h | 6 +- .../Connectors/D3Q27ETCFOffVectorConnector.h | 18 +- .../Connectors/D3Q27ETFCOffVectorConnector.h | 17 +- .../Connectors/D3Q27ETFullDirectConnector.cpp | 2 +- .../Connectors/D3Q27ETFullVectorConnector.cpp | 2 +- .../Connectors/D3Q27ETFullVectorConnector.h | 2 +- .../FineToCoarseBlock3DConnector.cpp | 2 +- .../Connectors/FineToCoarseBlock3DConnector.h | 8 +- .../FineToCoarseNodeSetBlock3DConnector.cpp | 5 +- .../FineToCoarseNodeSetBlock3DConnector.h | 6 +- .../Connectors/RemoteBlock3DConnector.h | 2 +- .../FETOL/FETOLSetConnectorsBlockVisitor.h | 2 +- source/VirtualFluidsCore/Grid/Block3D.cpp | 6 +- source/VirtualFluidsCore/Grid/Block3D.h | 8 +- .../BoostSerializationClassExportHelper.h | 83 +- source/VirtualFluidsCore/Grid/Grid3D.cpp | 73 +- source/VirtualFluidsCore/Grid/Grid3D.h | 1 + .../Interactors/D3Q27Interactor.cpp | 40 +- .../Interactors/D3Q27Interactor.h | 14 +- .../D3Q27TriFaceMeshInteractor.cpp | 66 +- .../Interactors/D3Q27TriFaceMeshInteractor.h | 4 +- .../LBM/CompressibleCumulantLBMKernel.cpp | 14 +- .../LBM/CompressibleCumulantLBMKernel.h | 10 +- ...mpressibleOffsetInterpolationProcessor.cpp | 4 +- ...CompressibleOffsetInterpolationProcessor.h | 6 +- .../D3Q27CompactInterpolationProcessor.cpp | 370 -------- .../LBM/D3Q27CompactInterpolationProcessor.h | 60 -- .../LBM/D3Q27InterpolationProcessor.h | 69 -- .../LBM/D3Q27OffsetInterpolationProcessor.cpp | 609 ------------- .../LBM/D3Q27OffsetInterpolationProcessor.h | 81 -- ...pp => IncompressibleCumulantLBMKernel.cpp} | 36 +- ...LB.h => IncompressibleCumulantLBMKernel.h} | 26 +- ...sibleCumulantWithSpongeLayerLBMKernel.cpp} | 32 +- ...essibleCumulantWithSpongeLayerLBMKernel.h} | 24 +- ...pressibleOffsetInterpolationProcessor.cpp} | 48 +- ...ompressibleOffsetInterpolationProcessor.h} | 24 +- .../LBM/InitDensityLBMKernel.cpp | 16 +- .../LBM/InitDensityLBMKernel.h | 6 +- ...tionHelper.cpp => InterpolationHelper.cpp} | 12 +- ...polationHelper.h => InterpolationHelper.h} | 14 +- ...ocessor.cpp => InterpolationProcessor.cpp} | 18 +- .../LBM/InterpolationProcessor.h | 55 +- .../LBM/{LBMKernel3D.cpp => LBMKernel.cpp} | 71 +- .../LBM/{LBMKernel3D.h => LBMKernel.h} | 21 +- .../LBM/LBMKernelETD3Q27.cpp | 25 - .../VirtualFluidsCore/LBM/LBMKernelETD3Q27.h | 31 - .../VirtualFluidsCore/LBM/VoidLBMKernel.cpp | 4 +- source/VirtualFluidsCore/LBM/VoidLBMKernel.h | 8 +- .../Utilities/ChangeRandomQs.hpp | 20 +- .../Utilities/VoxelMatrixUtil.hpp | 4 +- .../BoundaryConditionBlockVisitor.cpp | 122 --- .../Visitors/BoundaryConditionBlockVisitor.h | 19 - .../BoundaryConditionsBlockVisitor.cpp | 85 ++ .../Visitors/BoundaryConditionsBlockVisitor.h | 19 + .../ChangeBoundaryDensityBlockVisitor.cpp | 9 +- .../ChangeBoundaryDensityBlockVisitor.h | 4 +- ...rsenCrossAndInsideGbObjectBlockVisitor.cpp | 38 + ...oarsenCrossAndInsideGbObjectBlockVisitor.h | 28 + .../Visitors/ConnectorBlockVisitor.cpp | 12 +- .../Visitors/ConnectorBlockVisitor.h | 6 +- .../D3Q27SetUndefinedNodesBlockVisitor.h | 22 - ....cpp => InitDistributionsBlockVisitor.cpp} | 46 +- ...itor.h => InitDistributionsBlockVisitor.h} | 10 +- .../InitDistributionsFromFileBlockVisitor.cpp | 14 +- .../Visitors/RenumberBlockVisitor.h | 2 +- ...itor.cpp => SetConnectorsBlockVisitor.cpp} | 30 +- ...kVisitor.h => SetConnectorsBlockVisitor.h} | 14 +- .../Visitors/SetForcingBlockVisitor.h | 2 +- .../SetInterpolationDirsBlockVisitor.h | 2 +- .../Visitors/SetKernelBlockVisitor.cpp | 10 +- .../Visitors/SetKernelBlockVisitor.h | 8 +- .../Visitors/SetSpongeLayerBlockVisitor.h | 2 +- ....cpp => SetUndefinedNodesBlockVisitor.cpp} | 16 +- .../Visitors/SetUndefinedNodesBlockVisitor.h | 22 + .../Visitors/SpongeLayerBlockVisitor.cpp | 2 +- .../Visitors/SpongeLayerBlockVisitor.h | 2 +- .../Visitors/ViscosityBlockVisitor.h | 2 +- 189 files changed, 9668 insertions(+), 3957 deletions(-) create mode 100644 source/Applications/DLR-F16/Bombadil.cfg create mode 100644 source/Applications/DLR-F16/CMakeLists.txt create mode 100644 source/Applications/DLR-F16/F16Bombadil.cfg create mode 100644 source/Applications/DLR-F16/F16BombadilTest.cfg create mode 100644 source/Applications/DLR-F16/F16BombadilTest10e-6.cfg create mode 100644 source/Applications/DLR-F16/F16BombadilTestSmall.cfg create mode 100644 source/Applications/DLR-F16/f16.cpp create mode 100644 source/Applications/FlowAroundCylinder/cylinder.cpp.old create mode 100644 source/Applications/Hagen_Poiseuille_flow/pfDP.cfg create mode 100644 source/Applications/aperm/PA200-250-50_800MPI.cfg create mode 100644 source/Applications/aperm/PA80-110+120-150_MPI.cfg create mode 100644 source/Applications/aperm/PA80-110+120-150_dx80.cfg create mode 100644 source/Applications/aperm/aperm.cpp.old create mode 100644 source/Applications/f16Test/CMakeLists.txt create mode 100644 source/Applications/f16Test/F16BombadilTestSmall.cfg create mode 100644 source/Applications/f16Test/f16test.cpp create mode 100644 source/Applications/mirror/CMakeLists.txt create mode 100644 source/Applications/mirror/mirror.cfg create mode 100644 source/Applications/mirror/mirror.cpp create mode 100644 source/Applications/mirror/mirrorV1.cfg create mode 100644 source/CMake/compilerflags/gcc62.cmake create mode 100644 source/VirtualFluidsCore/BoundaryConditions/BCAdapter.h create mode 100644 source/VirtualFluidsCore/BoundaryConditions/BCAlgorithm.cpp create mode 100644 source/VirtualFluidsCore/BoundaryConditions/BCAlgorithm.h create mode 100644 source/VirtualFluidsCore/BoundaryConditions/BCArray3D.cpp create mode 100644 source/VirtualFluidsCore/BoundaryConditions/BCArray3D.h create mode 100644 source/VirtualFluidsCore/BoundaryConditions/BCFunction.cpp create mode 100644 source/VirtualFluidsCore/BoundaryConditions/BCFunction.h create mode 100644 source/VirtualFluidsCore/BoundaryConditions/BCProcessor.cpp create mode 100644 source/VirtualFluidsCore/BoundaryConditions/BCProcessor.h create mode 100644 source/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.cpp create mode 100644 source/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.h create mode 100644 source/VirtualFluidsCore/BoundaryConditions/CMakePackage.txt create mode 100644 source/VirtualFluidsCore/BoundaryConditions/DensityBCAdapter.cpp create mode 100644 source/VirtualFluidsCore/BoundaryConditions/DensityBCAdapter.h create mode 100644 source/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.cpp create mode 100644 source/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.h create mode 100644 source/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.cpp create mode 100644 source/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.h create mode 100644 source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAdapter.cpp create mode 100644 source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAdapter.h create mode 100644 source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.cpp create mode 100644 source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.h create mode 100644 source/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.cpp create mode 100644 source/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.h create mode 100644 source/VirtualFluidsCore/BoundaryConditions/NonReflectingDensityBCAlgorithm.cpp create mode 100644 source/VirtualFluidsCore/BoundaryConditions/NonReflectingDensityBCAlgorithm.h create mode 100644 source/VirtualFluidsCore/BoundaryConditions/NonReflectingVelocityBCAlgorithm.cpp create mode 100644 source/VirtualFluidsCore/BoundaryConditions/NonReflectingVelocityBCAlgorithm.h create mode 100644 source/VirtualFluidsCore/BoundaryConditions/SlipBCAdapter.cpp create mode 100644 source/VirtualFluidsCore/BoundaryConditions/SlipBCAdapter.h create mode 100644 source/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.cpp create mode 100644 source/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.h create mode 100644 source/VirtualFluidsCore/BoundaryConditions/ThinWallBCProcessor.cpp create mode 100644 source/VirtualFluidsCore/BoundaryConditions/ThinWallBCProcessor.h create mode 100644 source/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.cpp create mode 100644 source/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.h create mode 100644 source/VirtualFluidsCore/BoundaryConditions/VelocityBCAdapter.cpp create mode 100644 source/VirtualFluidsCore/BoundaryConditions/VelocityBCAdapter.h create mode 100644 source/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.cpp create mode 100644 source/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.h rename source/VirtualFluidsCore/{LBM/D3Q27IntegrateValuesHelper.cpp => CoProcessors/IntegrateValuesHelper.cpp} (88%) rename source/VirtualFluidsCore/{LBM/D3Q27IntegrateValuesHelper.h => CoProcessors/IntegrateValuesHelper.h} (85%) create mode 100644 source/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.cpp create mode 100644 source/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.h rename source/VirtualFluidsCore/CoProcessors/{MacroscopicQuantitiesCoProcessor.cpp => WriteMacroscopicQuantitiesCoProcessor.cpp} (56%) rename source/VirtualFluidsCore/CoProcessors/{MacroscopicQuantitiesCoProcessor.h => WriteMacroscopicQuantitiesCoProcessor.h} (72%) delete mode 100644 source/VirtualFluidsCore/LBM/D3Q27CompactInterpolationProcessor.cpp delete mode 100644 source/VirtualFluidsCore/LBM/D3Q27CompactInterpolationProcessor.h delete mode 100644 source/VirtualFluidsCore/LBM/D3Q27InterpolationProcessor.h delete mode 100644 source/VirtualFluidsCore/LBM/D3Q27OffsetInterpolationProcessor.cpp delete mode 100644 source/VirtualFluidsCore/LBM/D3Q27OffsetInterpolationProcessor.h rename source/VirtualFluidsCore/LBM/{LBMKernelETD3Q27CCLB.cpp => IncompressibleCumulantLBMKernel.cpp} (96%) rename source/VirtualFluidsCore/LBM/{LBMKernelETD3Q27CCLB.h => IncompressibleCumulantLBMKernel.h} (69%) rename source/VirtualFluidsCore/LBM/{LBMKernelETD3Q27CCLBWithSpongeLayer.cpp => IncompressibleCumulantWithSpongeLayerLBMKernel.cpp} (95%) rename source/VirtualFluidsCore/LBM/{LBMKernelETD3Q27CCLBWithSpongeLayer.h => IncompressibleCumulantWithSpongeLayerLBMKernel.h} (65%) rename source/VirtualFluidsCore/LBM/{D3Q27IncompressibleOffsetInterpolationProcessor.cpp => IncompressibleOffsetInterpolationProcessor.cpp} (92%) rename source/VirtualFluidsCore/LBM/{D3Q27IncompressibleOffsetInterpolationProcessor.h => IncompressibleOffsetInterpolationProcessor.h} (77%) rename source/VirtualFluidsCore/LBM/{D3Q27InterpolationHelper.cpp => InterpolationHelper.cpp} (63%) rename source/VirtualFluidsCore/LBM/{D3Q27InterpolationHelper.h => InterpolationHelper.h} (66%) rename source/VirtualFluidsCore/LBM/{D3Q27InterpolationProcessor.cpp => InterpolationProcessor.cpp} (88%) rename source/VirtualFluidsCore/LBM/{LBMKernel3D.cpp => LBMKernel.cpp} (70%) rename source/VirtualFluidsCore/LBM/{LBMKernel3D.h => LBMKernel.h} (85%) delete mode 100644 source/VirtualFluidsCore/LBM/LBMKernelETD3Q27.cpp delete mode 100644 source/VirtualFluidsCore/LBM/LBMKernelETD3Q27.h delete mode 100644 source/VirtualFluidsCore/Visitors/BoundaryConditionBlockVisitor.cpp delete mode 100644 source/VirtualFluidsCore/Visitors/BoundaryConditionBlockVisitor.h create mode 100644 source/VirtualFluidsCore/Visitors/BoundaryConditionsBlockVisitor.cpp create mode 100644 source/VirtualFluidsCore/Visitors/BoundaryConditionsBlockVisitor.h create mode 100644 source/VirtualFluidsCore/Visitors/CoarsenCrossAndInsideGbObjectBlockVisitor.cpp create mode 100644 source/VirtualFluidsCore/Visitors/CoarsenCrossAndInsideGbObjectBlockVisitor.h delete mode 100644 source/VirtualFluidsCore/Visitors/D3Q27SetUndefinedNodesBlockVisitor.h rename source/VirtualFluidsCore/Visitors/{D3Q27ETInitDistributionsBlockVisitor.cpp => InitDistributionsBlockVisitor.cpp} (83%) rename source/VirtualFluidsCore/Visitors/{D3Q27ETInitDistributionsBlockVisitor.h => InitDistributionsBlockVisitor.h} (86%) rename source/VirtualFluidsCore/Visitors/{D3Q27SetConnectorsBlockVisitor.cpp => SetConnectorsBlockVisitor.cpp} (93%) rename source/VirtualFluidsCore/Visitors/{D3Q27SetConnectorsBlockVisitor.h => SetConnectorsBlockVisitor.h} (70%) rename source/VirtualFluidsCore/Visitors/{D3Q27SetUndefinedNodesBlockVisitor.cpp => SetUndefinedNodesBlockVisitor.cpp} (94%) create mode 100644 source/VirtualFluidsCore/Visitors/SetUndefinedNodesBlockVisitor.h diff --git a/source/Applications.cmake b/source/Applications.cmake index 7d3766f69..9ac634932 100644 --- a/source/Applications.cmake +++ b/source/Applications.cmake @@ -11,7 +11,7 @@ add_subdirectory(Applications/sphere) #add_subdirectory(Applications/bananas2) # add_subdirectory(Applications/plate) # add_subdirectory(Applications/plate2) -# add_subdirectory(Applications/FlowAroundCylinder) +add_subdirectory(Applications/FlowAroundCylinder) add_subdirectory(Applications/LaminarTubeFlow) # add_subdirectory(Applications/LaminarTubeFlowConv) #add_subdirectory(Applications/cylinderSt) @@ -44,5 +44,7 @@ add_subdirectory(Applications/pChannel) #add_subdirectory(Applications/pDisk) add_subdirectory(Applications/BoxBenchmark) add_subdirectory(Applications/DHIT) -add_subdirectory(Applications/FNG) -add_subdirectory(Applications/aperm) \ No newline at end of file +add_subdirectory(Applications/DLR-F16) +add_subdirectory(Applications/aperm) +add_subdirectory(Applications/f16test) +add_subdirectory(Applications/mirror) \ No newline at end of file diff --git a/source/Applications/DHIT/dhit.cfg b/source/Applications/DHIT/dhit.cfg index 1585f232d..d7c0cfd4f 100644 --- a/source/Applications/DHIT/dhit.cfg +++ b/source/Applications/DHIT/dhit.cfg @@ -1,4 +1,4 @@ -pathname = d:/temp/DHIT_128_2 +pathname = d:/temp/DHIT_Green numOfThreads = 4 availMem = 11e9 @@ -6,15 +6,15 @@ availMem = 11e9 length = 128 128 128 blocknx = 32 32 32 -initTime = 10000 +initTime = 10 -outTime = 100 -endTime = 1000000 +outTime = 1 +endTime = 10 logToFile = false #Simulation -initFile = d:/Projects/DHIT/Velocities_128_2.txt +initFile = d:/Projects/DHIT/Velocities.txt nuLB = 1.2395e-2 uRMS = 0.0234 lambda = 0.1 diff --git a/source/Applications/DHIT/dhit.cpp b/source/Applications/DHIT/dhit.cpp index 850c34019..3211d71ff 100644 --- a/source/Applications/DHIT/dhit.cpp +++ b/source/Applications/DHIT/dhit.cpp @@ -10,6 +10,8 @@ void run(string configname) { try { + //Sleep(30000); + ConfigurationFile config; config.load(configname); @@ -115,8 +117,8 @@ void run(string configname) ppblocks.reset(); //set connectors - D3Q27InterpolationProcessorPtr iProcessor(new D3Q27IncompressibleOffsetInterpolationProcessor()); - D3Q27SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); + InterpolationProcessorPtr iProcessor(new IncompressibleOffsetInterpolationProcessor()); + SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); grid->accept(setConnsVisitor); //domain decomposition for threads @@ -148,12 +150,12 @@ void run(string configname) UBLOG(logINFO, "Available memory per process = " << availMem << " bytes"); } - LBMKernel3DPtr kernel; + LBMKernelPtr kernel; //kernel = LBMKernel3DPtr(new LBMKernelETD3Q27CCLB(blocknx[0], blocknx[1], blocknx[2], LBMKernelETD3Q27CCLB::NORMAL)); - kernel = LBMKernel3DPtr(new InitDensityLBMKernel(blocknx[0], blocknx[1], blocknx[2])); + kernel = LBMKernelPtr(new InitDensityLBMKernel(blocknx[0], blocknx[1], blocknx[2])); - BCProcessorPtr bcProc(new D3Q27ETBCProcessor()); + BCProcessorPtr bcProc(new BCProcessor()); kernel->setBCProcessor(bcProc); SetKernelBlockVisitor kernelVisitor(kernel, nuLB, availMem, needMem); @@ -162,15 +164,38 @@ void run(string configname) intHelper.setBC(); //initialization of distributions - //D3Q27ETInitDistributionsBlockVisitor initVisitor(nuLB, rhoLB, uLB, uLB, uLB); - InitDistributionsFromFileBlockVisitor initVisitor(nuLB, rhoLB, initFile); + InitDistributionsBlockVisitor initVisitor(nuLB, rhoLB); + double u_LB = 0.01; + mu::Parser inflowProfileVx1, inflowProfileVx2, inflowProfileVx3; + inflowProfileVx1.DefineConst("U", u_LB); + inflowProfileVx1.DefineConst("PI", PI); + inflowProfileVx1.DefineConst("L1", g_maxX1-g_minX1); + inflowProfileVx1.DefineConst("L2", g_maxX2-g_minX2); + inflowProfileVx1.DefineConst("L3", g_maxX3-g_minX3); + inflowProfileVx1.SetExpr("U*cos(2.0*PI*x1/L1)*sin(2.0*PI*x2/L2)*sin(2.0*PI*x3/L3)"); + inflowProfileVx2.DefineConst("U", u_LB); + inflowProfileVx2.DefineConst("PI", PI); + inflowProfileVx2.DefineConst("L1", g_maxX1-g_minX1); + inflowProfileVx2.DefineConst("L2", g_maxX2-g_minX2); + inflowProfileVx2.DefineConst("L3", g_maxX3-g_minX3); + inflowProfileVx2.SetExpr("-U*cos(2.0*PI*x1/L1)*sin(2.0*PI*x2/L2)*cos(2.0*PI*x3/L3)"); + inflowProfileVx3.DefineConst("U", u_LB); + inflowProfileVx3.DefineConst("PI", PI); + inflowProfileVx3.DefineConst("L1", g_maxX1-g_minX1); + inflowProfileVx3.DefineConst("L2", g_maxX2-g_minX2); + inflowProfileVx3.DefineConst("L3", g_maxX3-g_minX3); + inflowProfileVx3.SetExpr("-U/2.0*sin(8.0*PI*(x1)/(L1))*cos(8.0*PI*(x3)/L3)"); + initVisitor.setVx1(inflowProfileVx1); + initVisitor.setVx2(inflowProfileVx2); + initVisitor.setVx3(inflowProfileVx3); + //InitDistributionsFromFileBlockVisitor initVisitor(nuLB, rhoLB, initFile); grid->accept(initVisitor); //boundary conditions grid { UbSchedulerPtr geoSch(new UbScheduler(1)); - MacroscopicQuantitiesCoProcessorPtr ppgeo( - new MacroscopicQuantitiesCoProcessor(grid, geoSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, true)); + WriteBoundaryConditionsCoProcessorPtr ppgeo( + new WriteBoundaryConditionsCoProcessor(grid, geoSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, comm)); grid->coProcess(0); } @@ -184,7 +209,7 @@ void run(string configname) } UbSchedulerPtr outputSch(new UbScheduler(outTime)); - MacroscopicQuantitiesCoProcessor pp(grid, outputSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv); + WriteMacroscopicQuantitiesCoProcessor pp(grid, outputSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, comm); UbSchedulerPtr nupsSch(new UbScheduler(10, 30, 100)); NUPSCounterCoProcessor npr(grid, nupsSch, numOfThreads, comm); @@ -195,9 +220,9 @@ void run(string configname) if (myid == 0) UBLOG(logINFO, "Initialisation-end"); - kernel = LBMKernel3DPtr(new LBMKernelETD3Q27CCLB(blocknx[0], blocknx[1], blocknx[2], LBMKernelETD3Q27CCLB::NORMAL)); + kernel = LBMKernelPtr(new IncompressibleCumulantLBMKernel(blocknx[0], blocknx[1], blocknx[2], IncompressibleCumulantLBMKernel::NORMAL)); kernel->setBCProcessor(bcProc); - SetKernelBlockVisitor kernelVisitor2(kernel, nuLB, availMem, needMem, SetKernelBlockVisitor::Change); + SetKernelBlockVisitor kernelVisitor2(kernel, nuLB, availMem, needMem, SetKernelBlockVisitor::ChangeKernel); grid->accept(kernelVisitor2); UbSchedulerPtr visSch(new UbScheduler(outTime)); diff --git a/source/Applications/DLR-F16/Bombadil.cfg b/source/Applications/DLR-F16/Bombadil.cfg new file mode 100644 index 000000000..0196e80f4 --- /dev/null +++ b/source/Applications/DLR-F16/Bombadil.cfg @@ -0,0 +1,27 @@ +pathOut = d:/temp/fng +pathGeo = d:/Projects/SFB880/FNG/A1_Forschungsdaten_Profilgeometrie_STL_CATIA_Rossian +fngFileWhole = f16-ascii.stl +fngFileBodyPart = f16-body-part-ascii.stl +fngFileTrailingEdge = f16-trailing-edge-ascii.stl + +numOfThreads = 1 +availMem = 20e9 +refineLevel = 3 +blockNx = 16 16 16 +uLB = 0.1 + +#x1min x1max x2min x2max x3min x3max [mm] +boundingBox = -50 400 45 55 -60 80 +deltaXfine = 0.1 + +restartStep = 10000 +restartStepStart = 10000 + +outTime = 1000 +endTime = 1000 + +logToFile = false + +porousTralingEdge = false + +thinWall = false \ No newline at end of file diff --git a/source/Applications/DLR-F16/CMakeLists.txt b/source/Applications/DLR-F16/CMakeLists.txt new file mode 100644 index 000000000..ca92147af --- /dev/null +++ b/source/Applications/DLR-F16/CMakeLists.txt @@ -0,0 +1,25 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +######################################################## +## C++ PROJECT ### +######################################################## +PROJECT(f16) + +INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) + +################################################################# +### LOCAL FILES ### +################################################################# +FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp ) + +SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES}) +SOURCE_GROUP(src FILES ${SPECIFIC_FILES}) + +SET(CAB_ADDITIONAL_LINK_LIBRARIES VirtualFluids) + +################################################################# +### CREATE PROJECT ### +################################################################# +CREATE_CAB_PROJECT(f16 BINARY) diff --git a/source/Applications/DLR-F16/F16Bombadil.cfg b/source/Applications/DLR-F16/F16Bombadil.cfg new file mode 100644 index 000000000..a27fbb5cf --- /dev/null +++ b/source/Applications/DLR-F16/F16Bombadil.cfg @@ -0,0 +1,39 @@ +pathOut = d:/temp/fngPorous +pathGeo = d:/Projects/SFB880/FNG/A1_Forschungsdaten_Profilgeometrie_STL_CATIA_Rossian +#fngFileWhole = f16-ascii.stl +fngFileWhole = grundgeometrie-direkter-export.stl +fngFileBodyPart = f16-body-part-ascii.stl +fngFileTrailingEdge = f16-trailing-edge-ascii.stl +zigZagTape = 2zackenbaender0.stl + +numOfThreads = 4 +availMem = 20e9 +refineLevel = 8 +#blockNx = 8 4 8 +blockNx = 21 6 13 +uLB = 0.1 + +#x1min x1max x2min x2max x3min x3max [m] +boundingBox = -0.90 1.20 0.035 0.065 -0.65 0.65 + +#deltaXfine = 0.001 +#deltaXfine = 0.00375 +#deltaXfine = 1.46484375e-5 +#deltaXfine = 0.00001171875 +#deltaXfine = 9.765625e-6 +deltaXfine = 19.53125e-6 +#10e-6 + +refineDistance = 0.3 + +restartStep = 10000 +restartStepStart = 10000 + +outTime = 1 +endTime = 2000 + +logToFile = false + +porousTralingEdge = true + +thinWall = false diff --git a/source/Applications/DLR-F16/F16BombadilTest.cfg b/source/Applications/DLR-F16/F16BombadilTest.cfg new file mode 100644 index 000000000..4ee554a1c --- /dev/null +++ b/source/Applications/DLR-F16/F16BombadilTest.cfg @@ -0,0 +1,51 @@ +pathOut = d:/temp/f16Grid_x21 +pathGeo = d:/Projects/SFB880/DLR-F16/A1_Forschungsdaten_Profilgeometrie_STL_CATIA_Rossian +#fngFileWhole = f16-ascii.stl +fngFileWhole = grundgeometrie-direkter-export.stl +#fngFileWhole = grundgeometrie-mittel.stl +fngFileBodyPart = f16-body-part-ascii.stl +fngFileTrailingEdge = f16-trailing-edge-ascii.stl +zigZagTape = 2zackenbaender0.stl + +numOfThreads = 4 +availMem = 10e9 +refineLevel = 8 +blockNx = 21 6 6 +#blockNx = 21 6 13 +#blockNx = 294 12 247 +uLB = 0.1 + +#x1min x1max x2min x2max x3min x3max [m] +boundingBox = -0.90 1.20 0.035 0.065 -0.65 0.65 +#boundingBox = -0.90 1.20 0.035 0.065 -0.65 0.65048 +#boundingBox = -0.1 0.60 0.035 0.065 -0.3 0.3 +#boundingBox = -10e-3 310e-3 0.035 0.065 -21e-3 21e-3 + +#deltaXfine = 0.005 #level 0 +#deltaXfine = 0.0025 #level 1 +#deltaXfine = 0.00125 #level 2 +#deltaXfine = 0.000625 #level 3 +#deltaXfine = 0.0003125 #level 4 +#deltaXfine = 0.00015625 #level 5 +#deltaXfine = 0.000078125 #level 6 +#deltaXfine = 0.0000390625 #level 7 +deltaXfine = 0.00001953125 #level 8 + + +refineDistance = 0.3 + +restartStep = 100000 +restartStepStart = 100000 + +outTime = 1000 +endTime = 200000 + +logToFile = false + +porousTralingEdge = false + +thinWall = false + +testBox=false + +nupsStep = 10 10 10000000 \ No newline at end of file diff --git a/source/Applications/DLR-F16/F16BombadilTest10e-6.cfg b/source/Applications/DLR-F16/F16BombadilTest10e-6.cfg new file mode 100644 index 000000000..de3da9c76 --- /dev/null +++ b/source/Applications/DLR-F16/F16BombadilTest10e-6.cfg @@ -0,0 +1,55 @@ +pathOut = d:/temp/f16Grid +pathGeo = d:/Projects/SFB880/DLR-F16/A1_Forschungsdaten_Profilgeometrie_STL_CATIA_Rossian +#fngFileWhole = f16-ascii.stl +fngFileWhole = grundgeometrie-direkter-export.stl +#fngFileWhole = grundgeometrie-mittel.stl +fngFileBodyPart = f16-body-part-ascii.stl +fngFileTrailingEdge = f16-trailing-edge-ascii.stl +zigZagTape = 2zackenbaender0.stl + +numOfThreads = 4 +availMem = 10e9 +refineLevel = 8 #10 +#blockNx = 8 8 8 +blockNx = 6 6 6 +#blockNx = 294 12 247 +uLB = 0.1 + +#x1min x1max x2min x2max x3min x3max [m] +boundingBox = -0.90 1.20 0.035 0.065 -0.65 0.65 + +#boundingBox = -0.90 1.1992 0.035 0.065 -0.65 0.65 +#boundingBox = -0.1 0.60 0.035 0.065 -0.3 0.3 +#boundingBox = -10e-3 310e-3 0.035 0.065 -21e-3 25e-3 + + +#deltaXfine = 5120e-6 #level 0 +#deltaXfine = 2560e-6 #level 1 +#deltaXfine = 1280e-6 #level 2 +#deltaXfine = 640e-6 #level 3 +#deltaXfine = 320e-6 #level 4 +#deltaXfine = 160e-6 #level 5 +#deltaXfine = 80e-6 #level 6 +#deltaXfine = 40e-6 #level 7 +deltaXfine = 20e-6 #level 8 +#deltaXfine = 10e-6 #level 9 +#deltaXfine = 0.000009765625 + +#deltaXfine = 6.5e-6 + +refineDistance = 0.1 #0.3 + +restartStep = 100000 +restartStepStart = 100000 + +outTime = 1000 +endTime = 200000 + +logToFile = false + +porousTralingEdge = false + +thinWall = false + + +nupsStep = 10 10 10000000 \ No newline at end of file diff --git a/source/Applications/DLR-F16/F16BombadilTestSmall.cfg b/source/Applications/DLR-F16/F16BombadilTestSmall.cfg new file mode 100644 index 000000000..cce67bbcf --- /dev/null +++ b/source/Applications/DLR-F16/F16BombadilTestSmall.cfg @@ -0,0 +1,53 @@ +pathOut = d:/temp/fng6 +pathGeo = d:/Projects/SFB880/FNG/A1_Forschungsdaten_Profilgeometrie_STL_CATIA_Rossian +#fngFileWhole = f16-ascii.stl +fngFileWhole = grundgeometrie-direkter-export.stl +#fngFileWhole = grundgeometrie-mittel.stl +fngFileBodyPart = f16-body-part-ascii.stl +fngFileTrailingEdge = f16-trailing-edge-ascii.stl +zigZagTape = 2zackenbaender0.stl + +numOfThreads = 1 +availMem = 10e9 +refineLevel = 1 +#blockNx = 8 4 8 +blockNx = 21 6 13 +#blockNx = 294 12 247 +uLB = 0.1 + +#x1min x1max x2min x2max x3min x3max [m] +#boundingBox = -0.90 1.20 0.035 0.065 -0.65 0.65 +#boundingBox = -0.1 0.60 0.035 0.065 -0.3 0.3 +#boundingBox = -10e-3 310e-3 0.035 0.065 -21e-3 21e-3 + +boundingBox = -0.360 0.660 0.035 0.065 -0.30 0.30 + + +#deltaXfine = 0.005 #level 0 +#deltaXfine = 0.0025 #level 1 +#deltaXfine = 0.00125 #level 2 +#deltaXfine = 0.000625 #level 3 +#deltaXfine = 0.0003125 #level 4 +#deltaXfine = 0.00015625 #level 5 +#deltaXfine = 0.000078125 #level 6 +#deltaXfine = 0.0000390625 #level 7 +deltaXfine = 0.00001953125 #level 8 + + +refineDistance = 0.3 + +restartStep = 100 +restartStepStart = 100 + +outTime = 100 +endTime = 100 + +logToFile = false + +porousTralingEdge = false + +thinWall = false + +testBox=true + +nupsStep = 10 10 10000000 \ No newline at end of file diff --git a/source/Applications/DLR-F16/f16.cpp b/source/Applications/DLR-F16/f16.cpp new file mode 100644 index 000000000..c4a1afff9 --- /dev/null +++ b/source/Applications/DLR-F16/f16.cpp @@ -0,0 +1,669 @@ +#include <iostream> +#include <string> + +#include <boost/pointer_cast.hpp> + +#include "VirtualFluids.h" +#include <omp.h> +using namespace std; + +double rangeRandom1() +{ + return (2.0*rand())/RAND_MAX-1.0; +} + +void run(string configname) +{ + try + { +#pragma omp parallel //num_threads(3) +#pragma omp master + { + printf_s("%d\n", omp_get_num_threads()); + } +printf_s("num_threads=%d\n", omp_get_num_threads( )); + + ConfigurationFile config; + config.load(configname); + + string pathOut = config.getString("pathOut"); + string pathGeo = config.getString("pathGeo"); + string fngFileWhole = config.getString("fngFileWhole"); + string fngFileTrailingEdge = config.getString("fngFileTrailingEdge"); + string fngFileBodyPart = config.getString("fngFileBodyPart"); + string zigZagTape = config.getString("zigZagTape"); + int numOfThreads = config.getInt("numOfThreads"); + vector<int> blockNx = config.getVector<int>("blockNx"); + vector<double> boundingBox = config.getVector<double>("boundingBox"); + double uLB = config.getDouble("uLB"); + double restartStep = config.getDouble("restartStep"); + double restartStepStart = config.getDouble("restartStepStart"); + double endTime = config.getDouble("endTime"); + double outTime = config.getDouble("outTime"); + double availMem = config.getDouble("availMem"); + int refineLevel = config.getInt("refineLevel"); + bool logToFile = config.getBool("logToFile"); + bool porousTralingEdge = config.getBool("porousTralingEdge"); + double deltaXfine = config.getDouble("deltaXfine")*1000.0; + bool thinWall = config.getBool("thinWall"); + double refineDistance = config.getDouble("refineDistance"); + vector<double> nupsStep = config.getVector<double>("nupsStep"); + + CommunicatorPtr comm = MPICommunicator::getInstance(); + int myid = comm->getProcessID(); + + if (logToFile) + { +#if defined(__unix__) + if (myid == 0) + { + const char* str = pathOut.c_str(); + mkdir(str, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + } +#endif + + if (myid == 0) + { + stringstream logFilename; + logFilename << pathOut + "/logfile" + UbSystem::toString(UbSystem::getTimeStamp()) + ".txt"; + UbLog::output_policy::setStream(logFilename.str()); + } + } + + //the geometry is in mm + + double g_minX1 = boundingBox[0]*1000.0; + double g_minX2 = boundingBox[2]*1000.0; + double g_minX3 = boundingBox[4]*1000.0; + + double g_maxX1 = boundingBox[1]*1000.0; + double g_maxX2 = boundingBox[3]*1000.0; + double g_maxX3 = boundingBox[5]*1000.0; + + ////////////////////////////////////////////////////////////////////////// + double deltaXcoarse = deltaXfine*(double)(1 << refineLevel); + //double nx2_temp = floor((g_maxX2 - g_minX2) / (deltaXcoarse*(double)blockNx[0])); + + //deltaXcoarse = (g_maxX2 - g_minX2) / (nx2_temp*(double)blockNx[0]); + //UBLOG(logINFO, "nx2_temp:"<<nx2_temp); + //g_maxX2 -= 0.5* deltaXcoarse; + ////////////////////////////////////////////////////////////////////////// + double blockLength = (double)blockNx[0] * deltaXcoarse; + + //########################################################################## + //## physical parameters + //########################################################################## + double Re = 1e6; + + double rhoLB = 0.0; + double rhoReal = 1.2041; //(kg/m3) + double nueReal = 153.5e-7; //m^2/s + + double lReal = 0.3;//m + double uReal = Re*nueReal / lReal; + + //##Machzahl: + //#Ma = uReal/csReal + double Ma = 0.15;//Ma-Real! + //double csReal = uReal / Ma; + //double hLB = lReal / deltaXcoarse; + + //LBMUnitConverter unitConverter(lReal, csReal, rhoReal, hLB); + + //double u_LB = uReal * unitConverter.getFactorVelocityWToLb(); + //double nu_LB = nueReal * unitConverter.getFactorViscosityWToLb(); + double l_LB = lReal*1000.0 / deltaXcoarse; + double nuLB = (uLB*l_LB) / Re; //0.005; + //double nuLB = 0.005; + + LBMUnitConverterPtr conv = LBMUnitConverterPtr(new LBMUnitConverter()); + + const int baseLevel = 0; + + //////////////////////////////////////////////////////////////////////// + //Grid + ////////////////////////////////////////////////////////////////////////// + Grid3DPtr grid(new Grid3D(comm)); + grid->setDeltaX(deltaXcoarse); + grid->setBlockNX(blockNx[0], blockNx[1], blockNx[2]); + + GbObject3DPtr gridCube(new GbCuboid3D(g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3)); + //gridCube->setCenterCoordinates(geo->getX1Centroid(), geo->getX2Centroid(), geo->getX3Centroid()); + if (myid == 0) GbSystem3D::writeGeoObject(gridCube.get(), pathOut + "/geo/gridCube", WbWriterVtkXmlASCII::getInstance()); + GenBlocksGridVisitor genBlocks(gridCube); + grid->accept(genBlocks); + + grid->setPeriodicX1(false); + grid->setPeriodicX2(true); + grid->setPeriodicX3(false); + + //BC adapters + BCAdapterPtr noSlipBCAdapter(new NoSlipBCAdapter()); + if (thinWall) + { + noSlipBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new ThinWallNoSlipBCAlgorithm())); + } + else + { + noSlipBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new NoSlipBCAlgorithm())); + } + + BCAdapterPtr slipBCAdapter(new SlipBCAdapter()); + slipBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new SlipBCAlgorithm())); + + mu::Parser fct; + fct.SetExpr("U"); + fct.DefineConst("U", uLB); + BCAdapterPtr velBCAdapter(new VelocityBCAdapter(true, false, false, fct, 0, BCFunction::INFCONST)); + velBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new NonReflectingVelocityBCAlgorithm())); + + BCAdapterPtr denBCAdapter(new DensityBCAdapter(rhoLB)); + denBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new NonReflectingDensityBCAlgorithm())); + + BoundaryConditionsBlockVisitor bcVisitor; + bcVisitor.addBC(noSlipBCAdapter); + bcVisitor.addBC(slipBCAdapter); + bcVisitor.addBC(velBCAdapter); + bcVisitor.addBC(denBCAdapter); + + ////////////////////////////////////////////////////////////////////////// + //restart + UbSchedulerPtr rSch(new UbScheduler(restartStep, restartStep)); + RestartCoProcessor rp(grid, rSch, comm, pathOut, RestartCoProcessor::BINARY); + ////////////////////////////////////////////////////////////////////////// + + + if (grid->getTimeStep() == 0) + { + if (myid == 0) + { + UBLOG(logINFO, "Parameters:"); + UBLOG(logINFO, "* Re = "<<Re); + UBLOG(logINFO, "* Ma = "<<Ma); + UBLOG(logINFO, "* velocity (uReal) = "<<uReal<<" m/s"); + UBLOG(logINFO, "* viscosity (nuReal) = "<<nueReal<<" m^2/s"); + UBLOG(logINFO, "* velocity LB (uLB) = "<<uLB); + UBLOG(logINFO, "* viscosity LB (nuLB) = "<<nuLB); + UBLOG(logINFO, "* dx_base = "<<deltaXcoarse/1000<<" m"); + UBLOG(logINFO, "* dx_refine = "<<deltaXfine/1000<<" m"); + UBLOG(logINFO, "* number of levels = " << refineLevel + 1); + UBLOG(logINFO, "* number of threads = " << numOfThreads); + UBLOG(logINFO, "* number of processes = " << comm->getNumberOfProcesses()); + UBLOG(logINFO, "Preprozess - start"); + } + + GbTriFaceMesh3DPtr fngMeshWhole; + GbTriFaceMesh3DPtr fngMeshBodyPart; + GbTriFaceMesh3DPtr fngMeshTrailingEdge; + if (porousTralingEdge) + { + if (myid==0) UBLOG(logINFO, "Read fngFileBodyPart:start"); + fngMeshBodyPart = GbTriFaceMesh3DPtr(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(pathGeo+"/"+fngFileBodyPart, "fngMeshBody", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); + if (myid==0) UBLOG(logINFO, "Read fngFileBodyPart:end"); + fngMeshBodyPart->rotate(0.0, 0.5, 0.0); + if (myid==0) GbSystem3D::writeGeoObject(fngMeshBodyPart.get(), pathOut+"/geo/fngMeshBody", WbWriterVtkXmlBinary::getInstance()); + + if (myid==0) UBLOG(logINFO, "Read fngFileTrailingEdge:start"); + fngMeshTrailingEdge = GbTriFaceMesh3DPtr(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(pathGeo+"/"+fngFileTrailingEdge, "fngMeshTrailingEdge", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); + if (myid==0) UBLOG(logINFO, "Read fngFileTrailingEdge:end"); + fngMeshTrailingEdge->rotate(0.0, 0.5, 0.0); + fngMeshTrailingEdge->translate(0,0,1.3); + if (myid==0) GbSystem3D::writeGeoObject(fngMeshTrailingEdge.get(), pathOut+"/geo/fngMeshTrailingEdge", WbWriterVtkXmlBinary::getInstance()); + } + else + { + if (myid==0) UBLOG(logINFO, "Read fngFileWhole:start"); + fngMeshWhole = GbTriFaceMesh3DPtr(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(pathGeo+"/"+fngFileWhole, "fngMeshWhole", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); + if (myid==0) UBLOG(logINFO, "Read fngFileWhole:end"); + fngMeshWhole->rotate(0.0, 0.5, 0.0); + if (myid==0) GbSystem3D::writeGeoObject(fngMeshWhole.get(), pathOut+"/geo/fngMeshWhole", WbWriterVtkXmlBinary::getInstance()); + } + + ////////////////////////////////////////////////////////////////////////// + // Zackenband + ////////////////////////////////////////////////////////////////////////// + //top + ////////////////////////////////////////////////////////////////////////// + if (myid==0) UBLOG(logINFO, "Read zigZagTape:start"); + string ZckbndFilename = pathGeo+"/"+zigZagTape; + GbTriFaceMesh3DPtr meshBand1(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape1")); + meshBand1->rotate(0.0, 5, 0.0); + meshBand1->translate(15, 0, -12.850); + if (myid==0) GbSystem3D::writeGeoObject(meshBand1.get(), pathOut+"/geo/zigZagTape1", WbWriterVtkXmlASCII::getInstance()); + // Zackenband2 + GbTriFaceMesh3DPtr meshBand2(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape2")); + meshBand2->rotate(0.0, 5, 0.0); + meshBand2->translate(15, 5, -12.850); + if (myid==0) GbSystem3D::writeGeoObject(meshBand2.get(), pathOut+"/geo/zigZagTape2", WbWriterVtkXmlASCII::getInstance()); + //// Zackenband3 + //GbTriFaceMesh3DPtr meshBand3(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape3")); + //meshBand3->rotate(0.0, 5, 0.0); + //meshBand3->translate(15, 0, -12.35); + //if (myid==0) GbSystem3D::writeGeoObject(meshBand3.get(), pathOut+"/geo/zigZagTape3", WbWriterVtkXmlASCII::getInstance()); + //// Zackenband4 + //GbTriFaceMesh3DPtr meshBand4(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape4")); + //meshBand4->rotate(0.0, 5, 0.0); + //meshBand4->translate(15, 5, -12.35); + //if (myid==0) GbSystem3D::writeGeoObject(meshBand4.get(), pathOut+"/geo/zigZagTape4", WbWriterVtkXmlASCII::getInstance()); + + //bottom + GbTriFaceMesh3DPtr meshBand5(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape5")); + meshBand5->rotate(0.0, -1, 0.0); + meshBand5->rotate(0.0, 0.0,180.0); + //meshBand5->translate(30, 0, -37.3); + meshBand5->translate(30, 0, -37.2); + if (myid==0) GbSystem3D::writeGeoObject(meshBand5.get(), pathOut+"/geo/zigZagTape5", WbWriterVtkXmlASCII::getInstance()); + // Zackenband6 + GbTriFaceMesh3DPtr meshBand6(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape6")); + meshBand6->rotate(0.0, -1, 0.0); + meshBand6->rotate(0.0, 0.0, 180.0); + //meshBand6->translate(30, 5, -37.3); + meshBand6->translate(30, 5, -37.0); + if (myid==0) GbSystem3D::writeGeoObject(meshBand6.get(), pathOut+"/geo/zigZagTape6", WbWriterVtkXmlASCII::getInstance()); + //// Zackenband7 + //GbTriFaceMesh3DPtr meshBand7(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape7")); + //meshBand7->rotate(0.0, 5, 0.0); + //meshBand7->translate(15, 0, -12.35); + //if (myid==0) GbSystem3D::writeGeoObject(meshBand7.get(), pathOut+"/geo/zigZagTape7", WbWriterVtkXmlASCII::getInstance()); + //// Zackenband8 + //GbTriFaceMesh3DPtr meshBan8(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape8")); + //meshBan8->rotate(0.0, 5, 0.0); + //meshBan8->translate(15, 5, -12.35); + //if (myid==0) GbSystem3D::writeGeoObject(meshBan8.get(), pathOut+"/geo/zigZagTape8", WbWriterVtkXmlASCII::getInstance()); + if (myid==0) UBLOG(logINFO, "Read zigZagTape:end"); + + return; + + ////////////////////////////////////////////////////////////////////////// + + Interactor3DPtr fngIntrWhole; + Interactor3DPtr fngIntrBodyPart; + Interactor3DPtr fngIntrTrailingEdge; + if (porousTralingEdge) + { + fngIntrBodyPart = D3Q27TriFaceMeshInteractorPtr(new D3Q27TriFaceMeshInteractor(fngMeshBodyPart, grid, noSlipBCAdapter, Interactor3D::SOLID)); + fngIntrTrailingEdge = D3Q27TriFaceMeshInteractorPtr(new D3Q27TriFaceMeshInteractor(fngMeshTrailingEdge, grid, noSlipBCAdapter, Interactor3D::SOLID)); + } + else + { + fngIntrWhole = D3Q27TriFaceMeshInteractorPtr(new D3Q27TriFaceMeshInteractor(fngMeshWhole, grid, noSlipBCAdapter, Interactor3D::SOLID));//, Interactor3D::EDGES)); + } + + D3Q27TriFaceMeshInteractorPtr triBand1Interactor(new D3Q27TriFaceMeshInteractor(meshBand1, grid, noSlipBCAdapter, Interactor3D::SOLID));//, Interactor3D::EDGES)); + D3Q27TriFaceMeshInteractorPtr triBand2Interactor(new D3Q27TriFaceMeshInteractor(meshBand2, grid, noSlipBCAdapter, Interactor3D::SOLID));//, Interactor3D::EDGES)); + D3Q27TriFaceMeshInteractorPtr triBand3Interactor(new D3Q27TriFaceMeshInteractor(meshBand5, grid, noSlipBCAdapter, Interactor3D::SOLID));//, Interactor3D::EDGES)); + D3Q27TriFaceMeshInteractorPtr triBand4Interactor(new D3Q27TriFaceMeshInteractor(meshBand6, grid, noSlipBCAdapter, Interactor3D::SOLID));//, Interactor3D::EDGES)); + + if (refineLevel > 0 && myid == 0) + { + if (myid == 0) UBLOG(logINFO, "Refinement - start"); + //RefineCrossAndInsideGbObjectHelper refineHelper(grid, refineLevel); + //refineHelper.addGbObject(geo, refineLevel); + //refineHelper.refine(); + + //RefineAroundGbObjectHelper refineHelper1(grid, refineLevel-1, boost::dynamic_pointer_cast<D3Q27TriFaceMeshInteractor>(geoIntr1), 0.0, 10.0, comm); + //refineHelper1.refine(); + //RefineAroundGbObjectHelper refineHelper2(grid, refineLevel, boost::dynamic_pointer_cast<D3Q27TriFaceMeshInteractor>(geoIntr2), -1.0, 5.0, comm); + //refineHelper2.refine(); + + + int rank = grid->getRank(); + grid->setRank(0); + boost::dynamic_pointer_cast<D3Q27TriFaceMeshInteractor>(triBand1Interactor)->refineBlockGridToLevel(refineLevel, 0.0, refineDistance); + boost::dynamic_pointer_cast<D3Q27TriFaceMeshInteractor>(triBand2Interactor)->refineBlockGridToLevel(refineLevel, 0.0, refineDistance); + boost::dynamic_pointer_cast<D3Q27TriFaceMeshInteractor>(triBand3Interactor)->refineBlockGridToLevel(refineLevel, 0.0, refineDistance); + boost::dynamic_pointer_cast<D3Q27TriFaceMeshInteractor>(triBand4Interactor)->refineBlockGridToLevel(refineLevel, 0.0, refineDistance); + grid->setRank(rank); + + if (porousTralingEdge) + { + int rank = grid->getRank(); + grid->setRank(0); + boost::dynamic_pointer_cast<D3Q27TriFaceMeshInteractor>(fngIntrBodyPart)->refineBlockGridToLevel(refineLevel, 0.0, refineDistance); + grid->setRank(rank); + } + else + { + int rank = grid->getRank(); + grid->setRank(0); + boost::dynamic_pointer_cast<D3Q27TriFaceMeshInteractor>(fngIntrWhole)->refineBlockGridToLevel(refineLevel, 0.0, refineDistance); + grid->setRank(rank); + } + + + { + WriteBlocksCoProcessor ppblocks(grid, UbSchedulerPtr(new UbScheduler(1)), pathOut, WbWriterVtkXmlBinary::getInstance(), comm); + ppblocks.process(0); + } + + + //////////////////////////////////////////// + //METIS + //Grid3DVisitorPtr metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::KWAY)); + //////////////////////////////////////////// + /////delete solid blocks + if (myid == 0) UBLOG(logINFO, "deleteSolidBlocks - start"); + //InteractorsHelper intHelper(grid, metisVisitor); + //if (porousTralingEdge) + //{ + // intHelper.addInteractor(fngIntrBodyPart); + //} + //else + //{ + // intHelper.addInteractor(fngIntrWhole); + //} + ////////////////////////////////////////////////////////////////////////// + + //intHelper.selectBlocks(); + + if (porousTralingEdge) + { + SetSolidOrTransBlockVisitor v(fngIntrBodyPart, SetSolidOrTransBlockVisitor::SOLID); + grid->accept(v); + std::vector<Block3DPtr>& sb = fngIntrBodyPart->getSolidBlockSet(); + BOOST_FOREACH(Block3DPtr block, sb) + { + grid->deleteBlock(block); + } + fngIntrBodyPart->removeSolidBlocks(); + fngIntrBodyPart->removeTransBlocks(); + } + else + { + SetSolidOrTransBlockVisitor v(fngIntrWhole, SetSolidOrTransBlockVisitor::SOLID); + grid->accept(v); + std::vector<Block3DPtr>& sb = fngIntrWhole->getSolidBlockSet(); + BOOST_FOREACH(Block3DPtr block, sb) + { + grid->deleteBlock(block); + } + fngIntrWhole->removeSolidBlocks(); + fngIntrWhole->removeTransBlocks(); + } + + if (myid == 0) UBLOG(logINFO, "deleteSolidBlocks - end"); + ////////////////////////////////////// + + if (porousTralingEdge) + { + grid->setRank(0); + boost::dynamic_pointer_cast<D3Q27TriFaceMeshInteractor>(fngIntrTrailingEdge)->refineBlockGridToLevel(refineLevel, -2.0, refineDistance); + grid->setRank(rank); + + //GbObject3DPtr trailingEdgeCube(new GbCuboid3D(fngMeshTrailingEdge->getX1Minimum()-blockLength, fngMeshTrailingEdge->getX2Minimum(), fngMeshTrailingEdge->getX3Minimum()-blockLength/2.0, + // fngMeshTrailingEdge->getX1Maximum()+blockLength, fngMeshTrailingEdge->getX2Maximum(), fngMeshTrailingEdge->getX3Maximum()+blockLength/2.0)); + //if (myid == 0) GbSystem3D::writeGeoObject(trailingEdgeCube.get(), pathOut + "/geo/trailingEdgeCube", WbWriterVtkXmlASCII::getInstance()); + + //RefineCrossAndInsideGbObjectBlockVisitor refVisitor(trailingEdgeCube, refineLevel); + //grid->accept(refVisitor); + } + + RatioBlockVisitor ratioVisitor(refineLevel); + CheckRatioBlockVisitor checkRatio(refineLevel); + int count = 0; + + do { + grid->accept(ratioVisitor); + checkRatio.resetState(); + grid->accept(checkRatio); + if (myid == 0) UBLOG(logINFO, "count ="<<count++<<" state="<<checkRatio.getState()); + } while (!checkRatio.getState()); + + //RatioSmoothBlockVisitor ratioSmoothVisitor(refineLevel); + //grid->accept(ratioSmoothVisitor); + + { + WriteBlocksCoProcessor ppblocks(grid, UbSchedulerPtr(new UbScheduler(1)), pathOut, WbWriterVtkXmlBinary::getInstance(), comm); + ppblocks.process(1); + } + + OverlapBlockVisitor overlapVisitor(refineLevel, false); + grid->accept(overlapVisitor); + + //std::vector<int> dirs; + //for (int i = D3Q27System::E; i <= D3Q27System::TS; i++) + //{ + // dirs.push_back(i); + //} + //SetInterpolationDirsBlockVisitor interDirsVisitor(dirs); + //grid->accept(interDirsVisitor); + + if (myid == 0) UBLOG(logINFO, "Refinement - end"); + } + + grid->updateDistributedBlocks(comm); + + + //return; + + std::vector<int> dirs; + for (int i = D3Q27System::E; i<=D3Q27System::TS; i++) + { + dirs.push_back(i); + } + SetInterpolationDirsBlockVisitor interDirsVisitor(dirs); + grid->accept(interDirsVisitor); + + //walls + GbCuboid3DPtr addWallZmin(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_minX3)); + if (myid==0) GbSystem3D::writeGeoObject(addWallZmin.get(), pathOut+"/geo/addWallZmin", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr addWallZmax(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_maxX3, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); + if (myid==0) GbSystem3D::writeGeoObject(addWallZmax.get(), pathOut+"/geo/addWallZmax", WbWriterVtkXmlASCII::getInstance()); + + + + //wall interactors + D3Q27InteractorPtr addWallZminInt(new D3Q27Interactor(addWallZmin, grid, slipBCAdapter, Interactor3D::SOLID)); + D3Q27InteractorPtr addWallZmaxInt(new D3Q27Interactor(addWallZmax, grid, slipBCAdapter, Interactor3D::SOLID)); + + //inflow + GbCuboid3DPtr geoInflow(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_minX1, g_maxX2+blockLength, g_maxX3+blockLength)); + if (myid==0) GbSystem3D::writeGeoObject(geoInflow.get(), pathOut+"/geo/geoInflow", WbWriterVtkXmlASCII::getInstance()); + + //outflow + GbCuboid3DPtr geoOutflow(new GbCuboid3D(g_maxX1, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); + if (myid==0) GbSystem3D::writeGeoObject(geoOutflow.get(), pathOut+"/geo/geoOutflow", WbWriterVtkXmlASCII::getInstance()); + + //inflow + D3Q27InteractorPtr inflowIntr = D3Q27InteractorPtr(new D3Q27Interactor(geoInflow, grid, velBCAdapter, Interactor3D::SOLID)); + + //outflow + D3Q27InteractorPtr outflowIntr = D3Q27InteractorPtr(new D3Q27Interactor(geoOutflow, grid, denBCAdapter, Interactor3D::SOLID)); + + //////////////////////////////////////////// + //METIS + Grid3DVisitorPtr metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::KWAY)); + //////////////////////////////////////////// + /////delete solid blocks + if (myid == 0) UBLOG(logINFO, "deleteSolidBlocks - start"); + InteractorsHelper intHelper(grid, metisVisitor); + intHelper.addInteractor(inflowIntr); + intHelper.addInteractor(outflowIntr); + intHelper.addInteractor(addWallZminInt); + intHelper.addInteractor(addWallZmaxInt); + intHelper.addInteractor(triBand1Interactor); + intHelper.addInteractor(triBand2Interactor); + intHelper.addInteractor(triBand3Interactor); + intHelper.addInteractor(triBand4Interactor); + + if (porousTralingEdge) + { + intHelper.addInteractor(fngIntrBodyPart); + //intHelper.addInteractor(fngIntrTrailingEdge); + } + else + { + intHelper.addInteractor(fngIntrWhole); + } + + ////////////////////////////////////////////////////////////////////////// + intHelper.selectBlocks(); + + if (myid == 0) UBLOG(logINFO, "deleteSolidBlocks - end"); + ////////////////////////////////////// + + { + WriteBlocksCoProcessor ppblocks(grid, UbSchedulerPtr(new UbScheduler(1)), pathOut, WbWriterVtkXmlBinary::getInstance(), comm); + ppblocks.process(2); + } + + unsigned long long numberOfBlocks = (unsigned long long)grid->getNumberOfBlocks(); + int ghostLayer = 3; + unsigned long long numberOfNodesPerBlock = (unsigned long long)(blockNx[0])* (unsigned long long)(blockNx[1])* (unsigned long long)(blockNx[2]); + unsigned long long numberOfNodes = numberOfBlocks * numberOfNodesPerBlock; + unsigned long long numberOfNodesPerBlockWithGhostLayer = numberOfBlocks * (blockNx[0] + ghostLayer) * (blockNx[1] + ghostLayer) * (blockNx[2] + ghostLayer); + double needMemAll = double(numberOfNodesPerBlockWithGhostLayer*(27 * sizeof(double) + sizeof(int) + sizeof(float) * 4)); + double needMem = needMemAll / double(comm->getNumberOfProcesses()); + + if (myid == 0) + { + UBLOG(logINFO, "Number of blocks = " << numberOfBlocks); + UBLOG(logINFO, "Number of nodes = " << numberOfNodes); + int minInitLevel = grid->getCoarsestInitializedLevel(); + int maxInitLevel = grid->getFinestInitializedLevel(); + for (int level = minInitLevel; level <= maxInitLevel; level++) + { + int nobl = grid->getNumberOfBlocks(level); + UBLOG(logINFO, "Number of blocks for level " << level << " = " << nobl); + UBLOG(logINFO, "Number of nodes for level " << level << " = " << nobl*numberOfNodesPerBlock); + } + UBLOG(logINFO, "Necessary memory = " << needMemAll << " bytes"); + UBLOG(logINFO, "Necessary memory per process = " << needMem << " bytes"); + UBLOG(logINFO, "Available memory per process = " << availMem << " bytes"); + } + + LBMKernelPtr kernel = LBMKernelPtr(new CompressibleCumulantLBMKernel(blockNx[0], blockNx[1], blockNx[2], CompressibleCumulantLBMKernel::NORMAL)); + + BCProcessorPtr bcProc; + + if (thinWall) + { + bcProc = BCProcessorPtr(new ThinWallBCProcessor()); + } + else + { + bcProc = BCProcessorPtr(new BCProcessor()); + } + + kernel->setBCProcessor(bcProc); + + SetKernelBlockVisitor kernelVisitor(kernel, nuLB, availMem, needMem); + grid->accept(kernelVisitor); + + if (refineLevel > 0) + { + SetUndefinedNodesBlockVisitor undefNodesVisitor; + grid->accept(undefNodesVisitor); + } + + //BC + intHelper.setBC(); + + grid->accept(bcVisitor); + + //initialization of distributions + mu::Parser inflowProfileVx1, inflowProfileVx2, inflowProfileVx3; + inflowProfileVx1.SetExpr("U*rangeRandom1()"); + inflowProfileVx1.DefineConst("U", uLB); + inflowProfileVx1.DefineFun("rangeRandom1", rangeRandom1); + inflowProfileVx2.SetExpr("0.1*U*rangeRandom1()"); + inflowProfileVx2.DefineConst("U", uLB); + inflowProfileVx2.DefineFun("rangeRandom1", rangeRandom1); + inflowProfileVx3.SetExpr("0.1*U*rangeRandom1()"); + inflowProfileVx3.DefineConst("U", uLB); + inflowProfileVx3.DefineFun("rangeRandom1", rangeRandom1); + + InitDistributionsBlockVisitor initVisitor(nuLB, rhoLB); + initVisitor.setVx1(fct); + //initVisitor.setVx1(inflowProfileVx1); + //initVisitor.setVx2(inflowProfileVx2); + //initVisitor.setVx3(inflowProfileVx3); + initVisitor.setNu(nuLB); + grid->accept(initVisitor); + + ////set connectors + InterpolationProcessorPtr iProcessor(new CompressibleOffsetInterpolationProcessor()); + SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); + grid->accept(setConnsVisitor); + + //domain decomposition for threads + PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); + grid->accept(pqPartVisitor); + + //Postrozess + UbSchedulerPtr geoSch(new UbScheduler(1)); + WriteBoundaryConditionsCoProcessorPtr ppgeo( + new WriteBoundaryConditionsCoProcessor(grid, geoSch, pathOut, WbWriterVtkXmlBinary::getInstance(), conv, comm)); + ppgeo->process(0); + ppgeo.reset(); + + if (myid == 0) UBLOG(logINFO, "Preprozess - end"); + } + else + { + InterpolationProcessorPtr iProcessor(new CompressibleOffsetInterpolationProcessor()); + SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); + grid->accept(setConnsVisitor); + + //domain decomposition for threads + PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); + grid->accept(pqPartVisitor); + + grid->accept(bcVisitor); + } + + UbSchedulerPtr nupsSch(new UbScheduler(nupsStep[0], nupsStep[1], nupsStep[2])); + NUPSCounterCoProcessor npr(grid, nupsSch, numOfThreads, comm); + + UbSchedulerPtr stepSch(new UbScheduler(outTime)); + + WriteMacroscopicQuantitiesCoProcessor pp(grid, stepSch, pathOut, WbWriterVtkXmlBinary::getInstance(), conv,comm); + + if (myid == 0) + { + UBLOG(logINFO, "PID = " << myid << " Total Physical Memory (RAM): " << Utilities::getTotalPhysMem()); + UBLOG(logINFO, "PID = " << myid << " Physical Memory currently used: " << Utilities::getPhysMemUsed()); + UBLOG(logINFO, "PID = " << myid << " Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe()); + } + + CalculationManagerPtr calculation(new CalculationManager(grid, numOfThreads, endTime, stepSch)); + //CalculationManagerPtr calculation(new CalculationManager(grid, numOfThreads, endTime, stepSch, CalculationManager::PrePostBc)); + //calculation->setTimeAveragedValuesCoProcessor(tav); + if (myid == 0) UBLOG(logINFO, "Simulation-start"); + calculation->calculate(); + if (myid == 0) UBLOG(logINFO, "Simulation-end"); + } + catch (std::exception& e) + { + cerr << e.what() << endl << flush; + } + catch (std::string& s) + { + cerr << s << endl; + } + catch (...) + { + cerr << "unknown exception" << endl; + } + +} + +int main(int argc, char* argv[]) +{ + + if (argv != NULL) + { + if (argv[1] != NULL) + { + run(string(argv[1])); + } + else + { + cout << "Configuration file must be set!: " << argv[0] << " <config file>" << endl << std::flush; + } + } + + return 0; +} + diff --git a/source/Applications/FlowAroundCylinder/CMakeLists.txt b/source/Applications/FlowAroundCylinder/CMakeLists.txt index 528f72a6d..505649ac5 100644 --- a/source/Applications/FlowAroundCylinder/CMakeLists.txt +++ b/source/Applications/FlowAroundCylinder/CMakeLists.txt @@ -5,7 +5,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) ######################################################## PROJECT(cylinder) -INCLUDE(${SOURCE_ROOT}/lib/IncludsList.txt) +INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) ################################################################# ### LOCAL FILES ### @@ -17,7 +17,7 @@ FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES}) SOURCE_GROUP(src FILES ${SPECIFIC_FILES}) -SET(CAB_ADDITIONAL_LINK_LIBRARIES vfluids) +SET(CAB_ADDITIONAL_LINK_LIBRARIES VirtualFluids) ################################################################# ### CREATE PROJECT ### diff --git a/source/Applications/FlowAroundCylinder/cylinder.cpp b/source/Applications/FlowAroundCylinder/cylinder.cpp index ea310c84f..51856c0eb 100644 --- a/source/Applications/FlowAroundCylinder/cylinder.cpp +++ b/source/Applications/FlowAroundCylinder/cylinder.cpp @@ -1,388 +1,23 @@ #include <iostream> #include <string> -#include <vfluids.h> +#include "VirtualFluids.h" using namespace std; -void run(const char *cstr) -{ - try - { - string machine = QUOTEME(CAB_MACHINE); - string pathname; - int numOfThreads = 1; - double availMem = 0; - - CommunicatorPtr comm = MPICommunicator::getInstance(); - int myid = comm->getProcessID(); - - if(machine == "BOMBADIL") - { - pathname = "d:/temp/cylinder_20nu"; - numOfThreads = 4; - availMem = 10.0e9; - } - else if(machine == "M01" || machine == "M02") - { - pathname = "/work/koskuche/scratch/cylinder_Re20nu2l"; - numOfThreads = 1; - availMem = 12.0e9; - - if(myid ==0) - { - stringstream logFilename; - logFilename << pathname + "/logfile"+UbSystem::toString(UbSystem::getTimeStamp())+".txt"; - UbLog::output_policy::setStream(logFilename.str()); - } - } - else throw UbException(UB_EXARGS, "unknown CAB_MACHINE"); - - double dx = 0.1; - - double L1 = 2.5; - double L2, L3, H; - L2 = L3 = H = 0.41; - - LBMReal radius = 0.05; - LBMReal rhoReal = 1.0; //kg/m^3 - LBMReal uReal = 0.45;//m/s - LBMReal uLB = 0.05; - LBMReal Re = 20.0; - LBMReal rhoLB = 0.0; - LBMReal l = L2 / dx; - - //LBMUnitConverterPtr conv = LBMUnitConverterPtr(new LBMUnitConverter(1.0, 1/sqrt(3.0)*(uReal/uLB), 1.0, 1.0/dx, dx*dx*dx)); - LBMUnitConverterPtr conv = LBMUnitConverterPtr(new LBMUnitConverter()); - - const int baseLevel = 0; - const int refineLevel = 3; - - //obstacle - GbObject3DPtr cylinder(new GbCylinder3D(0.5, 0.2, -0.1, 0.5, 0.2, L3+0.1, radius)); - GbSystem3D::writeGeoObject(cylinder.get(),pathname + "/geo/cylinder", WbWriterVtkXmlBinary::getInstance()); - - GbObject3DPtr refCylinder(new GbCylinder3D(0.5, 0.2, -0.1, 0.5, 0.2, L3+0.1, radius+2.0*dx/(1<<refineLevel))); - GbSystem3D::writeGeoObject(refCylinder.get(),pathname + "/geo/refCylinder", WbWriterVtkXmlBinary::getInstance()); - - D3Q27InteractorPtr cylinderInt; - - //bounding box - double d_minX1 = 0.0; - double d_minX2 = 0.0; - double d_minX3 = 0.0; - - double d_maxX1 = L1; - double d_maxX2 = L2; - double d_maxX3 = L3; - - double offs = dx; - - //double g_minX1 = d_minX1-offs-0.499999*dx; - double g_minX1 = d_minX1-offs; - double g_minX2 = d_minX2-offs; - double g_minX3 = d_minX3-offs; - - double g_maxX1 = d_maxX1+offs; - double g_maxX2 = d_maxX2+offs; - double g_maxX3 = d_maxX3+offs; - - GbObject3DPtr gridCube(new GbCuboid3D(g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3)); - - const int blocknx1 = 8; - const int blocknx2 = 8; - const int blocknx3 = 8; - - dx = (0.41+2.0*dx)/(10.0*(int)blocknx2); - - LBMReal nueLB = (((4.0/9.0)*uLB)*2.0*(radius/dx))/Re; - - double blockLength = blocknx1*dx; - - //refinement area - double rf = cylinder->getLengthX1()/4; - GbObject3DPtr refineCube(new GbCuboid3D(cylinder->getX1Minimum()-rf, cylinder->getX2Minimum()-rf, cylinder->getX3Minimum(), - cylinder->getX1Maximum()+rf, cylinder->getX2Maximum()+rf, cylinder->getX3Maximum())); -// GbObject3DPtr refineCube(new GbCuboid3D(g_minX1 + 7.05*blockLength, g_minX2 + 3.05*blockLength, cylinder->getX3Minimum(), -// g_minX1 + 12.95*blockLength, g_maxX2 - 3.05*blockLength, cylinder->getX3Maximum())); - - Grid3DPtr grid(new Grid3D(comm)); - - UbSchedulerPtr rSch(new UbScheduler(100000, 100000)); - //RestartPostprocessorPtr rp(new RestartPostprocessor(grid, rSch, comm, pathname+"/checkpoints", RestartPostprocessor::BINARY)); - - //UbSchedulerPtr emSch(new UbScheduler(1000, 1000)); - //EmergencyExitPostprocessor em(grid, emSch, pathname+"/checkpoints/emex.txt", rp, comm); - - std::string opt; - - if(cstr!= NULL) - opt = std::string(cstr); - - if/*(cstr== NULL)*/(cstr!= NULL) - { - opt = std::string(cstr); - - if(myid==0) UBLOG(logINFO,"Restart step: " << opt); - - //grid = rp->restart(UbSystem::stringTo<int>(opt)); - //rp->reconnect(); - - //cylinderInt = - - //set connectors - D3Q27InterpolationProcessorPtr iProcessor(new D3Q27OffsetInterpolationProcessor()); - D3Q27SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nueLB, iProcessor); - grid->accept( setConnsVisitor ); - - //domain decomposition - PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); - grid->accept(pqPartVisitor); - } - else - { - if(myid ==0) - { - UBLOG(logINFO,"Number of processes = " << comm->getNumberOfProcesses() ); - UBLOG(logINFO,"path = " << pathname ); - UBLOG(logINFO,"L = " << L1/dx ); - UBLOG(logINFO,"H = " << H/dx ); - UBLOG(logINFO,"v = " << uLB ); - UBLOG(logINFO,"rho = " << rhoLB ); - UBLOG(logINFO,"nue = " << nueLB ); - UBLOG(logINFO,"Re = " << Re ); - UBLOG(logINFO,"dx = " << dx ); - UBLOG(logINFO,"Number of level = " << refineLevel+1 ); - //UBLOG(logINFO,conv->toString() ); - UBLOG(logINFO,"Preprozess - start"); - } - - grid->setDeltaX(dx); - grid->setBlockNX(blocknx1, blocknx2, blocknx3); - - // UbTupleDouble6 bouningBox(gridCube->getX1Minimum(),gridCube->getX2Minimum(),gridCube->getX3Minimum(), - // gridCube->getX1Maximum(),gridCube->getX2Maximum(),gridCube->getX3Maximum()); - // UbTupleInt3 blockNx(blocknx1, blocknx2, blocknx3); - // UbTupleInt3 gridNx(8, 16, 16); - // grid = Grid3DPtr(new Grid3D(bouningBox, blockNx, gridNx)); - - if(myid ==0) GbSystem3D::writeGeoObject(gridCube.get(),pathname + "/geo/gridCube", WbWriterVtkXmlBinary::getInstance()); - if(myid ==0) GbSystem3D::writeGeoObject(refineCube.get(),pathname + "/geo/refineCube", WbWriterVtkXmlBinary::getInstance()); - - GenBlocksGridVisitor genBlocks; - genBlocks.addGeoObject(gridCube); - grid->accept(genBlocks); - - //walls - GbCuboid3DPtr addWallYmin (new GbCuboid3D(d_minX1-4.0*blockLength, d_minX2-4.0*blockLength, d_minX3-4.0*blockLength, d_maxX1+4.0*blockLength, d_minX2, d_maxX3+4.0*blockLength)); - if(myid == 0) GbSystem3D::writeGeoObject(addWallYmin.get(), pathname+"/geo/addWallYmin", WbWriterVtkXmlASCII::getInstance()); - - GbCuboid3DPtr addWallZmin (new GbCuboid3D(d_minX1-4.0*blockLength, d_minX2-4.0*blockLength, d_minX3-4.0*blockLength, d_maxX1+4.0*blockLength, d_maxX2+4.0*blockLength, d_minX3)); - if(myid == 0) GbSystem3D::writeGeoObject(addWallZmin.get(), pathname+"/geo/addWallZmin", WbWriterVtkXmlASCII::getInstance()); - - GbCuboid3DPtr addWallYmax (new GbCuboid3D(d_minX1-4.0*blockLength, d_maxX2, d_minX3-4.0*blockLength, d_maxX1+4.0*blockLength, d_maxX2+4.0*blockLength, d_maxX3+4.0*blockLength)); - if(myid == 0) GbSystem3D::writeGeoObject(addWallYmax.get(), pathname+"/geo/addWallYmax", WbWriterVtkXmlASCII::getInstance()); - - GbCuboid3DPtr addWallZmax (new GbCuboid3D(d_minX1-4.0*blockLength, d_minX2-4.0*blockLength, d_maxX3, d_maxX1+4.0*blockLength, d_maxX2+4.0*blockLength, d_maxX3+4.0*blockLength)); - if(myid == 0) GbSystem3D::writeGeoObject(addWallZmax.get(), pathname+"/geo/addWallZmax", WbWriterVtkXmlASCII::getInstance()); - - //inflow - GbCuboid3DPtr geoInflow (new GbCuboid3D(d_minX1-4.0*blockLength, d_minX2-4.0*blockLength, d_minX3-4.0*blockLength, d_minX1, d_maxX2+4.0*blockLength, d_maxX3+4.0*blockLength)); - if(myid == 0) GbSystem3D::writeGeoObject(geoInflow.get(), pathname+"/geo/geoInflow", WbWriterVtkXmlASCII::getInstance()); - - //outflow - GbCuboid3DPtr geoOutflow (new GbCuboid3D(d_maxX1, d_minX2-4.0*blockLength, d_minX3-4.0*blockLength, d_maxX1+4.0*blockLength, d_maxX2+4.0*blockLength, d_maxX3+4.0*blockLength)); - if(myid == 0) GbSystem3D::writeGeoObject(geoOutflow.get(), pathname+"/geo/geoOutflow", WbWriterVtkXmlASCII::getInstance()); - - BlocksPostprocessorPtr ppblocks(new BlocksPostprocessor(grid, UbSchedulerPtr(new UbScheduler(1)), pathname + "/grid/blocks", WbWriterVtkXmlBinary::getInstance(), comm)); - - if (refineLevel > 0) - { - if(myid == 0) UBLOG(logINFO,"Refinement - start"); - RefineCrossAndInsideGbObjectHelper refineHelper(grid, refineLevel); - //refineHelper.addGbObject(refineCube, refineLevel); - refineHelper.addGbObject(refCylinder, refineLevel); - refineHelper.refine(); - if(myid == 0) UBLOG(logINFO,"Refinement - end"); - } - - MetisPartitioningGridVisitor metisVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::B); - grid->accept( metisVisitor ); - - SolidBlocksHelper sd(grid, comm); - - int bbOption = 1; //0=simple Bounce Back, 1=quadr. BB - D3Q27BoundaryConditionAdapterPtr bcObst(new D3Q27NoSlipBCAdapter(bbOption)); - cylinderInt = D3Q27InteractorPtr ( new D3Q27Interactor(cylinder, grid, bcObst,Interactor3D::SOLID)); - - //walls - D3Q27InteractorPtr addWallYminInt(new D3Q27Interactor(addWallYmin, grid, bcObst,Interactor3D::SOLID)); - D3Q27InteractorPtr addWallZminInt(new D3Q27Interactor(addWallZmin, grid, bcObst,Interactor3D::SOLID)); - D3Q27InteractorPtr addWallYmaxInt(new D3Q27Interactor(addWallYmax, grid, bcObst,Interactor3D::SOLID)); - D3Q27InteractorPtr addWallZmaxInt(new D3Q27Interactor(addWallZmax, grid, bcObst,Interactor3D::SOLID)); - - mu::Parser fct; - fct.SetExpr("16*U*x2*x3*(H-x2)*(H-x3)/H^4"); - fct.DefineConst("U", uLB); - fct.DefineConst("H", H); - - //inflow - D3Q27BoundaryConditionAdapterPtr velBCAdapter(new D3Q27VelocityBCAdapter (true, false ,false ,fct, 0, D3Q27BCFunction::INFCONST)); - velBCAdapter->setSecondaryBcOption(2); - D3Q27InteractorPtr inflowInt = D3Q27InteractorPtr( new D3Q27Interactor(geoInflow, grid, velBCAdapter, Interactor3D::SOLID)); - - //outflow - D3Q27BoundaryConditionAdapterPtr denBCAdapter(new D3Q27DensityBCAdapter(rhoLB)); - D3Q27InteractorPtr outflowInt = D3Q27InteractorPtr( new D3Q27Interactor(geoOutflow, grid, denBCAdapter,Interactor3D::SOLID)); - - sd.addInteractor(cylinderInt); - sd.addInteractor(addWallYminInt); - sd.addInteractor(addWallZminInt); - sd.addInteractor(addWallYmaxInt); - sd.addInteractor(addWallZmaxInt); - sd.addInteractor(inflowInt); - sd.addInteractor(outflowInt); - - sd.deleteSolidBlocks(); - - grid->accept( metisVisitor ); - - sd.setTransBlocks(); - - ppblocks->update(0); - ppblocks.reset(); - - //set connectors - D3Q27InterpolationProcessorPtr iProcessor(new D3Q27IncompressibleOffsetInterpolationProcessor()); - D3Q27SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nueLB, iProcessor); - grid->accept( setConnsVisitor ); - - unsigned long nob = grid->getNumberOfBlocks(); - int gl = 3; - unsigned long nod = nob * (blocknx1+gl) * (blocknx2+gl) * (blocknx3+gl); - - double needMemAll = double(nod*(27*sizeof(double) + sizeof(int) + sizeof(float)*4)); - double needMem = needMemAll / double(comm->getNumberOfProcesses()); - - if(myid == 0) - { - UBLOG(logINFO,"Number of blocks = " << nob); - UBLOG(logINFO,"Number of nodes = " << nod); - UBLOG(logINFO,"Necessary memory = " << needMemAll << " bytes"); - UBLOG(logINFO,"Necessary memory per process = " << needMem << " bytes"); - UBLOG(logINFO,"Available memory per process = " << availMem << " bytes"); - } - - LBMKernel3DPtr kernel(new LBMKernelETD3Q27CCLB(blocknx1, blocknx2, blocknx3, LBMKernelETD3Q27CCLB::NORMAL)); - - BCProcessorPtr bcProc(new D3Q27ETBCProcessor()); - kernel->setBCProcessor(bcProc); - - SetKernelBlockVisitor kernelVisitor(kernel, nueLB, availMem, needMem); - grid->accept(kernelVisitor); - - if (refineLevel > 0) - { - D3Q27SetUndefinedNodesBlockVisitor undefNodesVisitor; - grid->accept(undefNodesVisitor); - } - - //walls - grid->addAndInitInteractor(addWallYminInt); - grid->addAndInitInteractor(addWallZminInt); - grid->addAndInitInteractor(addWallYmaxInt); - grid->addAndInitInteractor(addWallZmaxInt); - - //obstacle - grid->addAndInitInteractor(cylinderInt); - - //inflow - grid->addAndInitInteractor(inflowInt); - - //outflow - grid->addAndInitInteractor(outflowInt); - - //domain decomposition - PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); - grid->accept(pqPartVisitor); - - //initialization of distributions - D3Q27ETInitDistributionsBlockVisitor initVisitor(nueLB, rhoLB); - initVisitor.setVx1(fct); - grid->accept(initVisitor); - - //Postrozess - UbSchedulerPtr geoSch(new UbScheduler(1)); - D3Q27MacroscopicQuantitiesPostprocessorPtr ppgeo( - new D3Q27MacroscopicQuantitiesPostprocessor(grid, geoSch, pathname + "/grid/nodes", WbWriterVtkXmlBinary::getInstance(), conv, comm, true)); - ppgeo->update(0); - ppgeo.reset(); - - if(myid == 0) UBLOG(logINFO,"Preprozess - end"); - } - - double outTime = 10000.0; - UbSchedulerPtr visSch(new UbScheduler(outTime)); - //visSch->addSchedule(1000, 1000, 10000); - //visSch->addSchedule(10000, 10000, 50000); - //visSch->addSchedule(100, 100, 10000); - - D3Q27MacroscopicQuantitiesPostprocessor pp(grid, visSch, pathname + "/steps/step", WbWriterVtkXmlBinary::getInstance(), conv, comm); - - double fdx = grid->getDeltaX(grid->getFinestInitializedLevel()); - double point1[3] = {0.45, 0.20, 0.205}; - double point2[3] = {0.55, 0.20, 0.205}; - - D3Q27IntegrateValuesHelperPtr h1(new D3Q27IntegrateValuesHelper(grid, comm, - point1[0]-1.0*fdx, point1[1]-1.0*fdx, point1[2]-1.0*fdx, - point1[0], point1[1], point1[2])); - if(myid ==0) GbSystem3D::writeGeoObject(h1->getBoundingBox().get(),pathname + "/geo/iv1", WbWriterVtkXmlBinary::getInstance()); - D3Q27IntegrateValuesHelperPtr h2(new D3Q27IntegrateValuesHelper(grid, comm, - point2[0], point2[1]-1.0*fdx, point2[2]-1.0*fdx, - point2[0]+1.0*fdx, point2[1], point2[2])); - if(myid ==0) GbSystem3D::writeGeoObject(h2->getBoundingBox().get(),pathname + "/geo/iv2", WbWriterVtkXmlBinary::getInstance()); - //D3Q27PressureDifferencePostprocessor rhopp(grid, visSch, pathname + "/results/rho_diff.txt", h1, h2, conv, comm); - D3Q27PressureDifferencePostprocessor rhopp(grid, visSch, pathname + "/results/rho_diff.txt", h1, h2, rhoReal, uReal, uLB, comm); - - double area = (2.0*radius*H)/(dx*dx); - double v = 4.0*uLB/9.0; - D3Q27ForcesPostprocessor fp(grid, visSch, pathname + "/results/forces.txt", comm, v, area); - fp.addInteractor(cylinderInt); - - UbSchedulerPtr nupsSch(new UbScheduler(10, 10, 40)); - NUPSCounterPostprocessor npr(grid, nupsSch, pathname + "/results/nups.txt", comm); - - double endTime = 100001.0; - CalculationManagerPtr calculation(new CalculationManager(grid, numOfThreads, endTime, visSch)); - if(myid == 0) UBLOG(logINFO,"Simulation-start"); - calculation->calculate(); - if(myid == 0) UBLOG(logINFO,"Simulation-end"); - } - catch(std::exception& e) - { - cerr << e.what() << endl << flush; - } - catch(std::string& s) - { - cerr << s << endl; - } - catch(...) - { - cerr << "unknown exception" << endl; - } - -} - ////////////////////////////////////////////////////////////////////////// -void run2(const char *cstr) +void run() { try { - Sleep(30000); + //DEBUG/////////////////////////////////////// + //Sleep(30000); + ///////////////////////////////////////////// + string machine = QUOTEME(CAB_MACHINE); string pathname; - int numOfThreads = 1; + int numOfThreads = 4; double availMem = 0; CommunicatorPtr comm = MPICommunicator::getInstance(); @@ -390,8 +25,8 @@ void run2(const char *cstr) if(machine == "BOMBADIL") { - pathname = "d:/temp/cylinder_20nu"; - numOfThreads = 4; + pathname = "d:/temp/cylinderComp"; + numOfThreads = 1; availMem = 10.0e9; } else if(machine == "M01" || machine == "M02") @@ -409,7 +44,9 @@ void run2(const char *cstr) } else throw UbException(UB_EXARGS, "unknown CAB_MACHINE"); - double dx = 0.01; + UBLOG(logINFO, "Test case: flow around cylinder"); + + double dx = 0.04; double L1 = 2.5*2.0; double L2, L3, H; @@ -418,8 +55,8 @@ void run2(const char *cstr) LBMReal radius = 0.05*2.0; LBMReal rhoReal = 1.0; //kg/m^3 LBMReal uReal = 0.45;//m/s - LBMReal uLB = 0.05; - LBMReal Re = 20.0; + LBMReal uLB = 0.1; + LBMReal Re = 20000.0; LBMReal rhoLB = 0.0; LBMReal l = L2 / dx; @@ -486,51 +123,49 @@ void run2(const char *cstr) //UbSchedulerPtr emSch(new UbScheduler(1000, 1000)); //EmergencyExitPostprocessor em(grid, emSch, pathname+"/checkpoints/emex.txt", rp, comm); - std::string opt; - if(cstr!= NULL) - opt = std::string(cstr); + //BC + BCAdapterPtr noSlipAdapter(new NoSlipBCAdapter()); + noSlipAdapter->setBcAlgorithm(BCAlgorithmPtr(new NoSlipBCAlgorithm())); - if/*(cstr== NULL)*/(cstr!= NULL) - { - opt = std::string(cstr); - - if(myid==0) UBLOG(logINFO,"Restart step: " << opt); + mu::Parser fct; + fct.SetExpr("16*U*x2*x3*(H-x2)*(H-x3)/H^4"); + fct.DefineConst("U", uLB); + fct.DefineConst("H", H); + BCAdapterPtr velBCAdapter(new VelocityBCAdapter(true, false, false, fct, 0, BCFunction::INFCONST)); + velBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new NonReflectingVelocityBCAlgorithm())); - //grid = rp->restart(UbSystem::stringTo<int>(opt)); - //rp->reconnect(); + BCAdapterPtr denBCAdapter(new DensityBCAdapter(rhoLB)); + denBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new NonReflectingDensityBCAlgorithm())); + + BoundaryConditionsBlockVisitor bcVisitor; + bcVisitor.addBC(noSlipAdapter); + bcVisitor.addBC(velBCAdapter); + bcVisitor.addBC(denBCAdapter); - //cylinderInt = - //set connectors - D3Q27InterpolationProcessorPtr iProcessor(new D3Q27OffsetInterpolationProcessor()); - D3Q27SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nueLB, iProcessor); - grid->accept( setConnsVisitor ); - - //domain decomposition - PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); - grid->accept(pqPartVisitor); - } - else + if (grid->getTimeStep() == 0) { - if(myid ==0) + if (myid==0) { - UBLOG(logINFO,"Number of processes = " << comm->getNumberOfProcesses() ); - UBLOG(logINFO,"path = " << pathname ); - UBLOG(logINFO,"L = " << L1/dx ); - UBLOG(logINFO,"H = " << H/dx ); - UBLOG(logINFO,"v = " << uLB ); - UBLOG(logINFO,"rho = " << rhoLB ); - UBLOG(logINFO,"nue = " << nueLB ); - UBLOG(logINFO,"Re = " << Re ); - UBLOG(logINFO,"dx = " << dx ); - UBLOG(logINFO,"Number of level = " << refineLevel+1 ); + UBLOG(logINFO, "Number of processes = "<<comm->getNumberOfProcesses()); + UBLOG(logINFO, "Number of threads = "<<numOfThreads); + UBLOG(logINFO, "path = "<<pathname); + UBLOG(logINFO, "L = "<<L1/dx); + UBLOG(logINFO, "H = "<<H/dx); + UBLOG(logINFO, "v = "<<uLB); + UBLOG(logINFO, "rho = "<<rhoLB); + UBLOG(logINFO, "nue = "<<nueLB); + UBLOG(logINFO, "Re = "<<Re); + UBLOG(logINFO, "dx = "<<dx); + UBLOG(logINFO, "Number of level = "<<refineLevel+1); //UBLOG(logINFO,conv->toString() ); - UBLOG(logINFO,"Preprozess - start"); + UBLOG(logINFO, "Preprozess - start"); } grid->setDeltaX(dx); grid->setBlockNX(blocknx1, blocknx2, blocknx3); + grid->setPeriodicX3(true); // UbTupleDouble6 bouningBox(gridCube->getX1Minimum(),gridCube->getX2Minimum(),gridCube->getX3Minimum(), // gridCube->getX1Maximum(),gridCube->getX2Maximum(),gridCube->getX3Maximum()); @@ -538,194 +173,184 @@ void run2(const char *cstr) // UbTupleInt3 gridNx(8, 16, 16); // grid = Grid3DPtr(new Grid3D(bouningBox, blockNx, gridNx)); - if(myid ==0) GbSystem3D::writeGeoObject(gridCube.get(),pathname + "/geo/gridCube", WbWriterVtkXmlBinary::getInstance()); - if(myid ==0) GbSystem3D::writeGeoObject(refineCube.get(),pathname + "/geo/refineCube", WbWriterVtkXmlBinary::getInstance()); + if (myid==0) GbSystem3D::writeGeoObject(gridCube.get(), pathname+"/geo/gridCube", WbWriterVtkXmlBinary::getInstance()); + if (myid==0) GbSystem3D::writeGeoObject(refineCube.get(), pathname+"/geo/refineCube", WbWriterVtkXmlBinary::getInstance()); - GenBlocksGridVisitor genBlocks; - genBlocks.addGeoObject(gridCube); + GenBlocksGridVisitor genBlocks(gridCube); grid->accept(genBlocks); //walls - GbCuboid3DPtr addWallYmin (new GbCuboid3D(d_minX1-blockLength, d_minX2-blockLength, d_minX3-blockLength, d_maxX1+blockLength, d_minX2, d_maxX3+blockLength)); - if(myid == 0) GbSystem3D::writeGeoObject(addWallYmin.get(), pathname+"/geo/addWallYmin", WbWriterVtkXmlASCII::getInstance()); + GbCuboid3DPtr addWallYmin(new GbCuboid3D(d_minX1-blockLength, d_minX2-blockLength, d_minX3-blockLength, d_maxX1+blockLength, d_minX2, d_maxX3+blockLength)); + if (myid==0) GbSystem3D::writeGeoObject(addWallYmin.get(), pathname+"/geo/addWallYmin", WbWriterVtkXmlASCII::getInstance()); - GbCuboid3DPtr addWallZmin (new GbCuboid3D(d_minX1-blockLength, d_minX2-blockLength, d_minX3-blockLength, d_maxX1+blockLength, d_maxX2+blockLength, d_minX3)); - if(myid == 0) GbSystem3D::writeGeoObject(addWallZmin.get(), pathname+"/geo/addWallZmin", WbWriterVtkXmlASCII::getInstance()); + GbCuboid3DPtr addWallYmax(new GbCuboid3D(d_minX1-blockLength, d_maxX2, d_minX3-blockLength, d_maxX1+blockLength, d_maxX2+blockLength, d_maxX3+blockLength)); + if (myid==0) GbSystem3D::writeGeoObject(addWallYmax.get(), pathname+"/geo/addWallYmax", WbWriterVtkXmlASCII::getInstance()); - GbCuboid3DPtr addWallYmax (new GbCuboid3D(d_minX1-blockLength, d_maxX2, d_minX3-blockLength, d_maxX1+blockLength, d_maxX2+blockLength, d_maxX3+blockLength)); - if(myid == 0) GbSystem3D::writeGeoObject(addWallYmax.get(), pathname+"/geo/addWallYmax", WbWriterVtkXmlASCII::getInstance()); + //GbCuboid3DPtr addWallZmin(new GbCuboid3D(d_minX1-blockLength, d_minX2-blockLength, d_minX3-blockLength, d_maxX1+blockLength, d_maxX2+blockLength, d_minX3)); + //if (myid==0) GbSystem3D::writeGeoObject(addWallZmin.get(), pathname+"/geo/addWallZmin", WbWriterVtkXmlASCII::getInstance()); - GbCuboid3DPtr addWallZmax (new GbCuboid3D(d_minX1-blockLength, d_minX2-blockLength, d_maxX3, d_maxX1+blockLength, d_maxX2+blockLength, d_maxX3+blockLength)); - if(myid == 0) GbSystem3D::writeGeoObject(addWallZmax.get(), pathname+"/geo/addWallZmax", WbWriterVtkXmlASCII::getInstance()); + //GbCuboid3DPtr addWallZmax(new GbCuboid3D(d_minX1-blockLength, d_minX2-blockLength, d_maxX3, d_maxX1+blockLength, d_maxX2+blockLength, d_maxX3+blockLength)); + //if (myid==0) GbSystem3D::writeGeoObject(addWallZmax.get(), pathname+"/geo/addWallZmax", WbWriterVtkXmlASCII::getInstance()); //inflow - GbCuboid3DPtr geoInflow (new GbCuboid3D(d_minX1-blockLength, d_minX2-blockLength, d_minX3-blockLength, d_minX1, d_maxX2+blockLength, d_maxX3+blockLength)); - if(myid == 0) GbSystem3D::writeGeoObject(geoInflow.get(), pathname+"/geo/geoInflow", WbWriterVtkXmlASCII::getInstance()); + GbCuboid3DPtr geoInflow(new GbCuboid3D(d_minX1-blockLength, d_minX2-blockLength, d_minX3-blockLength, d_minX1, d_maxX2+blockLength, d_maxX3+blockLength)); + if (myid==0) GbSystem3D::writeGeoObject(geoInflow.get(), pathname+"/geo/geoInflow", WbWriterVtkXmlASCII::getInstance()); //outflow - GbCuboid3DPtr geoOutflow (new GbCuboid3D(d_maxX1, d_minX2-blockLength, d_minX3-blockLength, d_maxX1+blockLength, d_maxX2+blockLength, d_maxX3+blockLength)); - if(myid == 0) GbSystem3D::writeGeoObject(geoOutflow.get(), pathname+"/geo/geoOutflow", WbWriterVtkXmlASCII::getInstance()); + GbCuboid3DPtr geoOutflow(new GbCuboid3D(d_maxX1, d_minX2-blockLength, d_minX3-blockLength, d_maxX1+blockLength, d_maxX2+blockLength, d_maxX3+blockLength)); + if (myid==0) GbSystem3D::writeGeoObject(geoOutflow.get(), pathname+"/geo/geoOutflow", WbWriterVtkXmlASCII::getInstance()); - BlocksPostprocessorPtr ppblocks(new BlocksPostprocessor(grid, UbSchedulerPtr(new UbScheduler(1)), pathname + "/grid/blocks", WbWriterVtkXmlBinary::getInstance(), comm)); + WriteBlocksCoProcessorPtr ppblocks(new WriteBlocksCoProcessor(grid, UbSchedulerPtr(new UbScheduler(1)), pathname, WbWriterVtkXmlBinary::getInstance(), comm)); - if (refineLevel > 0) + if (refineLevel>0) { - if(myid == 0) UBLOG(logINFO,"Refinement - start"); + if (myid==0) UBLOG(logINFO, "Refinement - start"); RefineCrossAndInsideGbObjectHelper refineHelper(grid, refineLevel); //refineHelper.addGbObject(refineCube, refineLevel); refineHelper.addGbObject(refCylinder, refineLevel); refineHelper.refine(); - if(myid == 0) UBLOG(logINFO,"Refinement - end"); + if (myid==0) UBLOG(logINFO, "Refinement - end"); } - MetisPartitioningGridVisitor metisVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::B); - grid->accept( metisVisitor ); - - SolidBlocksHelper sd(grid, comm); - - int bbOption = 1; //0=simple Bounce Back, 1=quadr. BB - D3Q27BoundaryConditionAdapterPtr bcObst(new D3Q27NoSlipBCAdapter(bbOption)); - cylinderInt = D3Q27InteractorPtr ( new D3Q27Interactor(cylinder, grid, bcObst,Interactor3D::SOLID)); + //cylinder + cylinderInt = D3Q27InteractorPtr(new D3Q27Interactor(cylinder, grid, noSlipAdapter, Interactor3D::SOLID)); //walls - D3Q27InteractorPtr addWallYminInt(new D3Q27Interactor(addWallYmin, grid, bcObst,Interactor3D::SOLID)); - D3Q27InteractorPtr addWallZminInt(new D3Q27Interactor(addWallZmin, grid, bcObst,Interactor3D::SOLID)); - D3Q27InteractorPtr addWallYmaxInt(new D3Q27Interactor(addWallYmax, grid, bcObst,Interactor3D::SOLID)); - D3Q27InteractorPtr addWallZmaxInt(new D3Q27Interactor(addWallZmax, grid, bcObst,Interactor3D::SOLID)); - - mu::Parser fct; - fct.SetExpr("16*U*x2*x3*(H-x2)*(H-x3)/H^4"); - fct.DefineConst("U", uLB); - fct.DefineConst("H", H); + D3Q27InteractorPtr addWallYminInt(new D3Q27Interactor(addWallYmin, grid, noSlipAdapter, Interactor3D::SOLID)); + D3Q27InteractorPtr addWallYmaxInt(new D3Q27Interactor(addWallYmax, grid, noSlipAdapter, Interactor3D::SOLID)); + //D3Q27InteractorPtr addWallZminInt(new D3Q27Interactor(addWallZmin, grid, noSlipAdapter, Interactor3D::SOLID)); + //D3Q27InteractorPtr addWallZmaxInt(new D3Q27Interactor(addWallZmax, grid, noSlipAdapter, Interactor3D::SOLID)); //inflow - D3Q27BoundaryConditionAdapterPtr velBCAdapter(new D3Q27VelocityBCAdapter (true, false ,false ,fct, 0, D3Q27BCFunction::INFCONST)); - velBCAdapter->setSecondaryBcOption(2); - D3Q27InteractorPtr inflowInt = D3Q27InteractorPtr( new D3Q27Interactor(geoInflow, grid, velBCAdapter, Interactor3D::SOLID)); + D3Q27InteractorPtr inflowInt = D3Q27InteractorPtr(new D3Q27Interactor(geoInflow, grid, velBCAdapter, Interactor3D::SOLID)); //outflow - D3Q27BoundaryConditionAdapterPtr denBCAdapter(new D3Q27DensityBCAdapter(rhoLB)); - D3Q27InteractorPtr outflowInt = D3Q27InteractorPtr( new D3Q27Interactor(geoOutflow, grid, denBCAdapter,Interactor3D::SOLID)); - - sd.addInteractor(cylinderInt); - sd.addInteractor(addWallYminInt); - sd.addInteractor(addWallZminInt); - sd.addInteractor(addWallYmaxInt); - sd.addInteractor(addWallZmaxInt); - sd.addInteractor(inflowInt); - sd.addInteractor(outflowInt); - - sd.deleteSolidBlocks(); - - grid->accept( metisVisitor ); - - sd.setTransBlocks(); - - ppblocks->update(0); + D3Q27InteractorPtr outflowInt = D3Q27InteractorPtr(new D3Q27Interactor(geoOutflow, grid, denBCAdapter, Interactor3D::SOLID)); + + //D3Q27InteractorPtr addWallYminInt(new D3Q27Interactor(addWallYmin, grid, denBCAdapter, Interactor3D::SOLID)); + //D3Q27InteractorPtr addWallYmaxInt(new D3Q27Interactor(addWallYmax, grid, denBCAdapter, Interactor3D::SOLID)); + + Grid3DVisitorPtr metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::B)); + InteractorsHelper intHelper(grid, metisVisitor); + intHelper.addInteractor(cylinderInt); + intHelper.addInteractor(addWallYminInt); + intHelper.addInteractor(addWallYmaxInt); + //intHelper.addInteractor(addWallZminInt); + //intHelper.addInteractor(addWallZmaxInt); + intHelper.addInteractor(inflowInt); + intHelper.addInteractor(outflowInt); + intHelper.selectBlocks(); + + + ppblocks->process(0); ppblocks.reset(); //set connectors - D3Q27InterpolationProcessorPtr iProcessor(new D3Q27IncompressibleOffsetInterpolationProcessor()); - D3Q27SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nueLB, iProcessor); - grid->accept( setConnsVisitor ); + //D3Q27InterpolationProcessorPtr iProcessor(new D3Q27IncompressibleOffsetInterpolationProcessor()); + InterpolationProcessorPtr iProcessor(new CompressibleOffsetInterpolationProcessor()); + SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nueLB, iProcessor); + grid->accept(setConnsVisitor); unsigned long nob = grid->getNumberOfBlocks(); int gl = 3; unsigned long nod = nob * (blocknx1+gl) * (blocknx2+gl) * (blocknx3+gl); - double needMemAll = double(nod*(27*sizeof(double) + sizeof(int) + sizeof(float)*4)); - double needMem = needMemAll / double(comm->getNumberOfProcesses()); + double needMemAll = double(nod*(27*sizeof(double)+sizeof(int)+sizeof(float)*4)); + double needMem = needMemAll/double(comm->getNumberOfProcesses()); - if(myid == 0) + if (myid==0) { - UBLOG(logINFO,"Number of blocks = " << nob); - UBLOG(logINFO,"Number of nodes = " << nod); - UBLOG(logINFO,"Necessary memory = " << needMemAll << " bytes"); - UBLOG(logINFO,"Necessary memory per process = " << needMem << " bytes"); - UBLOG(logINFO,"Available memory per process = " << availMem << " bytes"); - } + UBLOG(logINFO, "Number of blocks = "<<nob); + UBLOG(logINFO, "Number of nodes = "<<nod); + UBLOG(logINFO, "Necessary memory = "<<needMemAll<<" bytes"); + UBLOG(logINFO, "Necessary memory per process = "<<needMem<<" bytes"); + UBLOG(logINFO, "Available memory per process = "<<availMem<<" bytes"); + } - LBMKernel3DPtr kernel(new LBMKernelETD3Q27CCLB(blocknx1, blocknx2, blocknx3, LBMKernelETD3Q27CCLB::NORMAL)); + //LBMKernel3DPtr kernel(new LBMKernelETD3Q27CCLB(blocknx1, blocknx2, blocknx3, LBMKernelETD3Q27CCLB::NORMAL)); + LBMKernelPtr kernel(new CompressibleCumulantLBMKernel(blocknx1, blocknx2, blocknx3, CompressibleCumulantLBMKernel::NORMAL)); - BCProcessorPtr bcProc(new D3Q27ETBCProcessor()); + BCProcessorPtr bcProc(new BCProcessor()); kernel->setBCProcessor(bcProc); SetKernelBlockVisitor kernelVisitor(kernel, nueLB, availMem, needMem); grid->accept(kernelVisitor); - if (refineLevel > 0) + if (refineLevel>0) { - D3Q27SetUndefinedNodesBlockVisitor undefNodesVisitor; + SetUndefinedNodesBlockVisitor undefNodesVisitor; grid->accept(undefNodesVisitor); } - //walls - grid->addAndInitInteractor(addWallYminInt); - grid->addAndInitInteractor(addWallZminInt); - grid->addAndInitInteractor(addWallYmaxInt); - grid->addAndInitInteractor(addWallZmaxInt); - - //obstacle - grid->addAndInitInteractor(cylinderInt); - - //inflow - grid->addAndInitInteractor(inflowInt); + intHelper.setBC(); - //outflow - grid->addAndInitInteractor(outflowInt); + grid->accept(bcVisitor); //domain decomposition PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); grid->accept(pqPartVisitor); //initialization of distributions - D3Q27ETInitDistributionsBlockVisitor initVisitor(nueLB, rhoLB); - initVisitor.setVx1(fct); + InitDistributionsBlockVisitor initVisitor(nueLB, rhoLB); + //initVisitor.setVx1(fct); grid->accept(initVisitor); //Postrozess UbSchedulerPtr geoSch(new UbScheduler(1)); - D3Q27MacroscopicQuantitiesPostprocessorPtr ppgeo( - new D3Q27MacroscopicQuantitiesPostprocessor(grid, geoSch, pathname + "/grid/nodes", WbWriterVtkXmlBinary::getInstance(), conv, comm, true)); - ppgeo->update(0); + WriteBoundaryConditionsCoProcessorPtr ppgeo( + new WriteBoundaryConditionsCoProcessor(grid, geoSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, comm)); + ppgeo->process(0); ppgeo.reset(); - if(myid == 0) UBLOG(logINFO,"Preprozess - end"); + if (myid==0) UBLOG(logINFO, "Preprozess - end"); + } + else + { + //set connectors + InterpolationProcessorPtr iProcessor(new CompressibleOffsetInterpolationProcessor()); + SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nueLB, iProcessor); + grid->accept(setConnsVisitor); + + //domain decomposition + PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); + grid->accept(pqPartVisitor); + } - double outTime = 100.0; + double outTime = 10.0; UbSchedulerPtr visSch(new UbScheduler(outTime)); //visSch->addSchedule(1000, 1000, 10000); //visSch->addSchedule(10000, 10000, 50000); //visSch->addSchedule(100, 100, 10000); - D3Q27MacroscopicQuantitiesPostprocessor pp(grid, visSch, pathname + "/steps/step", WbWriterVtkXmlBinary::getInstance(), conv, comm); + WriteMacroscopicQuantitiesCoProcessor pp(grid, visSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, comm); double fdx = grid->getDeltaX(grid->getFinestInitializedLevel()); double point1[3] = {0.45, 0.20, 0.205}; double point2[3] = {0.55, 0.20, 0.205}; - D3Q27IntegrateValuesHelperPtr h1(new D3Q27IntegrateValuesHelper(grid, comm, - point1[0]-1.0*fdx, point1[1]-1.0*fdx, point1[2]-1.0*fdx, - point1[0], point1[1], point1[2])); - if(myid ==0) GbSystem3D::writeGeoObject(h1->getBoundingBox().get(),pathname + "/geo/iv1", WbWriterVtkXmlBinary::getInstance()); - D3Q27IntegrateValuesHelperPtr h2(new D3Q27IntegrateValuesHelper(grid, comm, - point2[0], point2[1]-1.0*fdx, point2[2]-1.0*fdx, - point2[0]+1.0*fdx, point2[1], point2[2])); - if(myid ==0) GbSystem3D::writeGeoObject(h2->getBoundingBox().get(),pathname + "/geo/iv2", WbWriterVtkXmlBinary::getInstance()); - //D3Q27PressureDifferencePostprocessor rhopp(grid, visSch, pathname + "/results/rho_diff.txt", h1, h2, conv, comm); - D3Q27PressureDifferencePostprocessor rhopp(grid, visSch, pathname + "/results/rho_diff.txt", h1, h2, rhoReal, uReal, uLB, comm); - - double area = (2.0*radius*H)/(dx*dx); - double v = 4.0*uLB/9.0; - D3Q27ForcesPostprocessor fp(grid, visSch, pathname + "/results/forces.txt", comm, v, area); - fp.addInteractor(cylinderInt); + //D3Q27IntegrateValuesHelperPtr h1(new D3Q27IntegrateValuesHelper(grid, comm, + // point1[0]-1.0*fdx, point1[1]-1.0*fdx, point1[2]-1.0*fdx, + // point1[0], point1[1], point1[2])); + //if(myid ==0) GbSystem3D::writeGeoObject(h1->getBoundingBox().get(),pathname + "/geo/iv1", WbWriterVtkXmlBinary::getInstance()); + //D3Q27IntegrateValuesHelperPtr h2(new D3Q27IntegrateValuesHelper(grid, comm, + // point2[0], point2[1]-1.0*fdx, point2[2]-1.0*fdx, + // point2[0]+1.0*fdx, point2[1], point2[2])); + //if(myid ==0) GbSystem3D::writeGeoObject(h2->getBoundingBox().get(),pathname + "/geo/iv2", WbWriterVtkXmlBinary::getInstance()); + ////D3Q27PressureDifferencePostprocessor rhopp(grid, visSch, pathname + "/results/rho_diff.txt", h1, h2, conv, comm); + //D3Q27PressureDifferencePostprocessor rhopp(grid, visSch, pathname + "/results/rho_diff.txt", h1, h2, rhoReal, uReal, uLB, comm); + + //double area = (2.0*radius*H)/(dx*dx); + //double v = 4.0*uLB/9.0; + //CalculateForcesCoProcessor fp(grid, visSch, pathname + "/results/forces.txt", comm, v, area); + //fp.addInteractor(cylinderInt); UbSchedulerPtr nupsSch(new UbScheduler(10, 10, 40)); - NUPSCounterPostprocessor npr(grid, nupsSch, pathname + "/results/nups.txt", comm); + NUPSCounterCoProcessor npr(grid, nupsSch, numOfThreads, comm); - double endTime = 100001.0; - CalculationManagerPtr calculation(new CalculationManager(grid, numOfThreads, endTime, visSch)); + double endTime = 100000; + //CalculationManagerPtr calculation(new CalculationManager(grid, numOfThreads, endTime, visSch)); + CalculationManagerPtr calculation(new CalculationManager(grid, numOfThreads, endTime, visSch, CalculationManager::PrePostBc)); if(myid == 0) UBLOG(logINFO,"Simulation-start"); calculation->calculate(); if(myid == 0) UBLOG(logINFO,"Simulation-end"); @@ -747,9 +372,7 @@ void run2(const char *cstr) ////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { - - run2(argv[1]); - + run(); return 0; } diff --git a/source/Applications/FlowAroundCylinder/cylinder.cpp.old b/source/Applications/FlowAroundCylinder/cylinder.cpp.old new file mode 100644 index 000000000..ea310c84f --- /dev/null +++ b/source/Applications/FlowAroundCylinder/cylinder.cpp.old @@ -0,0 +1,755 @@ +#include <iostream> +#include <string> + +#include <vfluids.h> + +using namespace std; + + +void run(const char *cstr) +{ + try + { + string machine = QUOTEME(CAB_MACHINE); + string pathname; + int numOfThreads = 1; + double availMem = 0; + + CommunicatorPtr comm = MPICommunicator::getInstance(); + int myid = comm->getProcessID(); + + if(machine == "BOMBADIL") + { + pathname = "d:/temp/cylinder_20nu"; + numOfThreads = 4; + availMem = 10.0e9; + } + else if(machine == "M01" || machine == "M02") + { + pathname = "/work/koskuche/scratch/cylinder_Re20nu2l"; + numOfThreads = 1; + availMem = 12.0e9; + + if(myid ==0) + { + stringstream logFilename; + logFilename << pathname + "/logfile"+UbSystem::toString(UbSystem::getTimeStamp())+".txt"; + UbLog::output_policy::setStream(logFilename.str()); + } + } + else throw UbException(UB_EXARGS, "unknown CAB_MACHINE"); + + double dx = 0.1; + + double L1 = 2.5; + double L2, L3, H; + L2 = L3 = H = 0.41; + + LBMReal radius = 0.05; + LBMReal rhoReal = 1.0; //kg/m^3 + LBMReal uReal = 0.45;//m/s + LBMReal uLB = 0.05; + LBMReal Re = 20.0; + LBMReal rhoLB = 0.0; + LBMReal l = L2 / dx; + + //LBMUnitConverterPtr conv = LBMUnitConverterPtr(new LBMUnitConverter(1.0, 1/sqrt(3.0)*(uReal/uLB), 1.0, 1.0/dx, dx*dx*dx)); + LBMUnitConverterPtr conv = LBMUnitConverterPtr(new LBMUnitConverter()); + + const int baseLevel = 0; + const int refineLevel = 3; + + //obstacle + GbObject3DPtr cylinder(new GbCylinder3D(0.5, 0.2, -0.1, 0.5, 0.2, L3+0.1, radius)); + GbSystem3D::writeGeoObject(cylinder.get(),pathname + "/geo/cylinder", WbWriterVtkXmlBinary::getInstance()); + + GbObject3DPtr refCylinder(new GbCylinder3D(0.5, 0.2, -0.1, 0.5, 0.2, L3+0.1, radius+2.0*dx/(1<<refineLevel))); + GbSystem3D::writeGeoObject(refCylinder.get(),pathname + "/geo/refCylinder", WbWriterVtkXmlBinary::getInstance()); + + D3Q27InteractorPtr cylinderInt; + + //bounding box + double d_minX1 = 0.0; + double d_minX2 = 0.0; + double d_minX3 = 0.0; + + double d_maxX1 = L1; + double d_maxX2 = L2; + double d_maxX3 = L3; + + double offs = dx; + + //double g_minX1 = d_minX1-offs-0.499999*dx; + double g_minX1 = d_minX1-offs; + double g_minX2 = d_minX2-offs; + double g_minX3 = d_minX3-offs; + + double g_maxX1 = d_maxX1+offs; + double g_maxX2 = d_maxX2+offs; + double g_maxX3 = d_maxX3+offs; + + GbObject3DPtr gridCube(new GbCuboid3D(g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3)); + + const int blocknx1 = 8; + const int blocknx2 = 8; + const int blocknx3 = 8; + + dx = (0.41+2.0*dx)/(10.0*(int)blocknx2); + + LBMReal nueLB = (((4.0/9.0)*uLB)*2.0*(radius/dx))/Re; + + double blockLength = blocknx1*dx; + + //refinement area + double rf = cylinder->getLengthX1()/4; + GbObject3DPtr refineCube(new GbCuboid3D(cylinder->getX1Minimum()-rf, cylinder->getX2Minimum()-rf, cylinder->getX3Minimum(), + cylinder->getX1Maximum()+rf, cylinder->getX2Maximum()+rf, cylinder->getX3Maximum())); +// GbObject3DPtr refineCube(new GbCuboid3D(g_minX1 + 7.05*blockLength, g_minX2 + 3.05*blockLength, cylinder->getX3Minimum(), +// g_minX1 + 12.95*blockLength, g_maxX2 - 3.05*blockLength, cylinder->getX3Maximum())); + + Grid3DPtr grid(new Grid3D(comm)); + + UbSchedulerPtr rSch(new UbScheduler(100000, 100000)); + //RestartPostprocessorPtr rp(new RestartPostprocessor(grid, rSch, comm, pathname+"/checkpoints", RestartPostprocessor::BINARY)); + + //UbSchedulerPtr emSch(new UbScheduler(1000, 1000)); + //EmergencyExitPostprocessor em(grid, emSch, pathname+"/checkpoints/emex.txt", rp, comm); + + std::string opt; + + if(cstr!= NULL) + opt = std::string(cstr); + + if/*(cstr== NULL)*/(cstr!= NULL) + { + opt = std::string(cstr); + + if(myid==0) UBLOG(logINFO,"Restart step: " << opt); + + //grid = rp->restart(UbSystem::stringTo<int>(opt)); + //rp->reconnect(); + + //cylinderInt = + + //set connectors + D3Q27InterpolationProcessorPtr iProcessor(new D3Q27OffsetInterpolationProcessor()); + D3Q27SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nueLB, iProcessor); + grid->accept( setConnsVisitor ); + + //domain decomposition + PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); + grid->accept(pqPartVisitor); + } + else + { + if(myid ==0) + { + UBLOG(logINFO,"Number of processes = " << comm->getNumberOfProcesses() ); + UBLOG(logINFO,"path = " << pathname ); + UBLOG(logINFO,"L = " << L1/dx ); + UBLOG(logINFO,"H = " << H/dx ); + UBLOG(logINFO,"v = " << uLB ); + UBLOG(logINFO,"rho = " << rhoLB ); + UBLOG(logINFO,"nue = " << nueLB ); + UBLOG(logINFO,"Re = " << Re ); + UBLOG(logINFO,"dx = " << dx ); + UBLOG(logINFO,"Number of level = " << refineLevel+1 ); + //UBLOG(logINFO,conv->toString() ); + UBLOG(logINFO,"Preprozess - start"); + } + + grid->setDeltaX(dx); + grid->setBlockNX(blocknx1, blocknx2, blocknx3); + + // UbTupleDouble6 bouningBox(gridCube->getX1Minimum(),gridCube->getX2Minimum(),gridCube->getX3Minimum(), + // gridCube->getX1Maximum(),gridCube->getX2Maximum(),gridCube->getX3Maximum()); + // UbTupleInt3 blockNx(blocknx1, blocknx2, blocknx3); + // UbTupleInt3 gridNx(8, 16, 16); + // grid = Grid3DPtr(new Grid3D(bouningBox, blockNx, gridNx)); + + if(myid ==0) GbSystem3D::writeGeoObject(gridCube.get(),pathname + "/geo/gridCube", WbWriterVtkXmlBinary::getInstance()); + if(myid ==0) GbSystem3D::writeGeoObject(refineCube.get(),pathname + "/geo/refineCube", WbWriterVtkXmlBinary::getInstance()); + + GenBlocksGridVisitor genBlocks; + genBlocks.addGeoObject(gridCube); + grid->accept(genBlocks); + + //walls + GbCuboid3DPtr addWallYmin (new GbCuboid3D(d_minX1-4.0*blockLength, d_minX2-4.0*blockLength, d_minX3-4.0*blockLength, d_maxX1+4.0*blockLength, d_minX2, d_maxX3+4.0*blockLength)); + if(myid == 0) GbSystem3D::writeGeoObject(addWallYmin.get(), pathname+"/geo/addWallYmin", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr addWallZmin (new GbCuboid3D(d_minX1-4.0*blockLength, d_minX2-4.0*blockLength, d_minX3-4.0*blockLength, d_maxX1+4.0*blockLength, d_maxX2+4.0*blockLength, d_minX3)); + if(myid == 0) GbSystem3D::writeGeoObject(addWallZmin.get(), pathname+"/geo/addWallZmin", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr addWallYmax (new GbCuboid3D(d_minX1-4.0*blockLength, d_maxX2, d_minX3-4.0*blockLength, d_maxX1+4.0*blockLength, d_maxX2+4.0*blockLength, d_maxX3+4.0*blockLength)); + if(myid == 0) GbSystem3D::writeGeoObject(addWallYmax.get(), pathname+"/geo/addWallYmax", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr addWallZmax (new GbCuboid3D(d_minX1-4.0*blockLength, d_minX2-4.0*blockLength, d_maxX3, d_maxX1+4.0*blockLength, d_maxX2+4.0*blockLength, d_maxX3+4.0*blockLength)); + if(myid == 0) GbSystem3D::writeGeoObject(addWallZmax.get(), pathname+"/geo/addWallZmax", WbWriterVtkXmlASCII::getInstance()); + + //inflow + GbCuboid3DPtr geoInflow (new GbCuboid3D(d_minX1-4.0*blockLength, d_minX2-4.0*blockLength, d_minX3-4.0*blockLength, d_minX1, d_maxX2+4.0*blockLength, d_maxX3+4.0*blockLength)); + if(myid == 0) GbSystem3D::writeGeoObject(geoInflow.get(), pathname+"/geo/geoInflow", WbWriterVtkXmlASCII::getInstance()); + + //outflow + GbCuboid3DPtr geoOutflow (new GbCuboid3D(d_maxX1, d_minX2-4.0*blockLength, d_minX3-4.0*blockLength, d_maxX1+4.0*blockLength, d_maxX2+4.0*blockLength, d_maxX3+4.0*blockLength)); + if(myid == 0) GbSystem3D::writeGeoObject(geoOutflow.get(), pathname+"/geo/geoOutflow", WbWriterVtkXmlASCII::getInstance()); + + BlocksPostprocessorPtr ppblocks(new BlocksPostprocessor(grid, UbSchedulerPtr(new UbScheduler(1)), pathname + "/grid/blocks", WbWriterVtkXmlBinary::getInstance(), comm)); + + if (refineLevel > 0) + { + if(myid == 0) UBLOG(logINFO,"Refinement - start"); + RefineCrossAndInsideGbObjectHelper refineHelper(grid, refineLevel); + //refineHelper.addGbObject(refineCube, refineLevel); + refineHelper.addGbObject(refCylinder, refineLevel); + refineHelper.refine(); + if(myid == 0) UBLOG(logINFO,"Refinement - end"); + } + + MetisPartitioningGridVisitor metisVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::B); + grid->accept( metisVisitor ); + + SolidBlocksHelper sd(grid, comm); + + int bbOption = 1; //0=simple Bounce Back, 1=quadr. BB + D3Q27BoundaryConditionAdapterPtr bcObst(new D3Q27NoSlipBCAdapter(bbOption)); + cylinderInt = D3Q27InteractorPtr ( new D3Q27Interactor(cylinder, grid, bcObst,Interactor3D::SOLID)); + + //walls + D3Q27InteractorPtr addWallYminInt(new D3Q27Interactor(addWallYmin, grid, bcObst,Interactor3D::SOLID)); + D3Q27InteractorPtr addWallZminInt(new D3Q27Interactor(addWallZmin, grid, bcObst,Interactor3D::SOLID)); + D3Q27InteractorPtr addWallYmaxInt(new D3Q27Interactor(addWallYmax, grid, bcObst,Interactor3D::SOLID)); + D3Q27InteractorPtr addWallZmaxInt(new D3Q27Interactor(addWallZmax, grid, bcObst,Interactor3D::SOLID)); + + mu::Parser fct; + fct.SetExpr("16*U*x2*x3*(H-x2)*(H-x3)/H^4"); + fct.DefineConst("U", uLB); + fct.DefineConst("H", H); + + //inflow + D3Q27BoundaryConditionAdapterPtr velBCAdapter(new D3Q27VelocityBCAdapter (true, false ,false ,fct, 0, D3Q27BCFunction::INFCONST)); + velBCAdapter->setSecondaryBcOption(2); + D3Q27InteractorPtr inflowInt = D3Q27InteractorPtr( new D3Q27Interactor(geoInflow, grid, velBCAdapter, Interactor3D::SOLID)); + + //outflow + D3Q27BoundaryConditionAdapterPtr denBCAdapter(new D3Q27DensityBCAdapter(rhoLB)); + D3Q27InteractorPtr outflowInt = D3Q27InteractorPtr( new D3Q27Interactor(geoOutflow, grid, denBCAdapter,Interactor3D::SOLID)); + + sd.addInteractor(cylinderInt); + sd.addInteractor(addWallYminInt); + sd.addInteractor(addWallZminInt); + sd.addInteractor(addWallYmaxInt); + sd.addInteractor(addWallZmaxInt); + sd.addInteractor(inflowInt); + sd.addInteractor(outflowInt); + + sd.deleteSolidBlocks(); + + grid->accept( metisVisitor ); + + sd.setTransBlocks(); + + ppblocks->update(0); + ppblocks.reset(); + + //set connectors + D3Q27InterpolationProcessorPtr iProcessor(new D3Q27IncompressibleOffsetInterpolationProcessor()); + D3Q27SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nueLB, iProcessor); + grid->accept( setConnsVisitor ); + + unsigned long nob = grid->getNumberOfBlocks(); + int gl = 3; + unsigned long nod = nob * (blocknx1+gl) * (blocknx2+gl) * (blocknx3+gl); + + double needMemAll = double(nod*(27*sizeof(double) + sizeof(int) + sizeof(float)*4)); + double needMem = needMemAll / double(comm->getNumberOfProcesses()); + + if(myid == 0) + { + UBLOG(logINFO,"Number of blocks = " << nob); + UBLOG(logINFO,"Number of nodes = " << nod); + UBLOG(logINFO,"Necessary memory = " << needMemAll << " bytes"); + UBLOG(logINFO,"Necessary memory per process = " << needMem << " bytes"); + UBLOG(logINFO,"Available memory per process = " << availMem << " bytes"); + } + + LBMKernel3DPtr kernel(new LBMKernelETD3Q27CCLB(blocknx1, blocknx2, blocknx3, LBMKernelETD3Q27CCLB::NORMAL)); + + BCProcessorPtr bcProc(new D3Q27ETBCProcessor()); + kernel->setBCProcessor(bcProc); + + SetKernelBlockVisitor kernelVisitor(kernel, nueLB, availMem, needMem); + grid->accept(kernelVisitor); + + if (refineLevel > 0) + { + D3Q27SetUndefinedNodesBlockVisitor undefNodesVisitor; + grid->accept(undefNodesVisitor); + } + + //walls + grid->addAndInitInteractor(addWallYminInt); + grid->addAndInitInteractor(addWallZminInt); + grid->addAndInitInteractor(addWallYmaxInt); + grid->addAndInitInteractor(addWallZmaxInt); + + //obstacle + grid->addAndInitInteractor(cylinderInt); + + //inflow + grid->addAndInitInteractor(inflowInt); + + //outflow + grid->addAndInitInteractor(outflowInt); + + //domain decomposition + PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); + grid->accept(pqPartVisitor); + + //initialization of distributions + D3Q27ETInitDistributionsBlockVisitor initVisitor(nueLB, rhoLB); + initVisitor.setVx1(fct); + grid->accept(initVisitor); + + //Postrozess + UbSchedulerPtr geoSch(new UbScheduler(1)); + D3Q27MacroscopicQuantitiesPostprocessorPtr ppgeo( + new D3Q27MacroscopicQuantitiesPostprocessor(grid, geoSch, pathname + "/grid/nodes", WbWriterVtkXmlBinary::getInstance(), conv, comm, true)); + ppgeo->update(0); + ppgeo.reset(); + + if(myid == 0) UBLOG(logINFO,"Preprozess - end"); + } + + double outTime = 10000.0; + UbSchedulerPtr visSch(new UbScheduler(outTime)); + //visSch->addSchedule(1000, 1000, 10000); + //visSch->addSchedule(10000, 10000, 50000); + //visSch->addSchedule(100, 100, 10000); + + D3Q27MacroscopicQuantitiesPostprocessor pp(grid, visSch, pathname + "/steps/step", WbWriterVtkXmlBinary::getInstance(), conv, comm); + + double fdx = grid->getDeltaX(grid->getFinestInitializedLevel()); + double point1[3] = {0.45, 0.20, 0.205}; + double point2[3] = {0.55, 0.20, 0.205}; + + D3Q27IntegrateValuesHelperPtr h1(new D3Q27IntegrateValuesHelper(grid, comm, + point1[0]-1.0*fdx, point1[1]-1.0*fdx, point1[2]-1.0*fdx, + point1[0], point1[1], point1[2])); + if(myid ==0) GbSystem3D::writeGeoObject(h1->getBoundingBox().get(),pathname + "/geo/iv1", WbWriterVtkXmlBinary::getInstance()); + D3Q27IntegrateValuesHelperPtr h2(new D3Q27IntegrateValuesHelper(grid, comm, + point2[0], point2[1]-1.0*fdx, point2[2]-1.0*fdx, + point2[0]+1.0*fdx, point2[1], point2[2])); + if(myid ==0) GbSystem3D::writeGeoObject(h2->getBoundingBox().get(),pathname + "/geo/iv2", WbWriterVtkXmlBinary::getInstance()); + //D3Q27PressureDifferencePostprocessor rhopp(grid, visSch, pathname + "/results/rho_diff.txt", h1, h2, conv, comm); + D3Q27PressureDifferencePostprocessor rhopp(grid, visSch, pathname + "/results/rho_diff.txt", h1, h2, rhoReal, uReal, uLB, comm); + + double area = (2.0*radius*H)/(dx*dx); + double v = 4.0*uLB/9.0; + D3Q27ForcesPostprocessor fp(grid, visSch, pathname + "/results/forces.txt", comm, v, area); + fp.addInteractor(cylinderInt); + + UbSchedulerPtr nupsSch(new UbScheduler(10, 10, 40)); + NUPSCounterPostprocessor npr(grid, nupsSch, pathname + "/results/nups.txt", comm); + + double endTime = 100001.0; + CalculationManagerPtr calculation(new CalculationManager(grid, numOfThreads, endTime, visSch)); + if(myid == 0) UBLOG(logINFO,"Simulation-start"); + calculation->calculate(); + if(myid == 0) UBLOG(logINFO,"Simulation-end"); + } + catch(std::exception& e) + { + cerr << e.what() << endl << flush; + } + catch(std::string& s) + { + cerr << s << endl; + } + catch(...) + { + cerr << "unknown exception" << endl; + } + +} + +////////////////////////////////////////////////////////////////////////// +void run2(const char *cstr) +{ + try + { + Sleep(30000); + string machine = QUOTEME(CAB_MACHINE); + string pathname; + int numOfThreads = 1; + double availMem = 0; + + CommunicatorPtr comm = MPICommunicator::getInstance(); + int myid = comm->getProcessID(); + + if(machine == "BOMBADIL") + { + pathname = "d:/temp/cylinder_20nu"; + numOfThreads = 4; + availMem = 10.0e9; + } + else if(machine == "M01" || machine == "M02") + { + pathname = "/work/koskuche/scratch/cylinder_Re20nu4l"; + numOfThreads = 1; + availMem = 12.0e9; + + if(myid ==0) + { + stringstream logFilename; + logFilename << pathname + "/logfile"+UbSystem::toString(UbSystem::getTimeStamp())+".txt"; + UbLog::output_policy::setStream(logFilename.str()); + } + } + else throw UbException(UB_EXARGS, "unknown CAB_MACHINE"); + + double dx = 0.01; + + double L1 = 2.5*2.0; + double L2, L3, H; + L2 = L3 = H = 0.41*2.0; + + LBMReal radius = 0.05*2.0; + LBMReal rhoReal = 1.0; //kg/m^3 + LBMReal uReal = 0.45;//m/s + LBMReal uLB = 0.05; + LBMReal Re = 20.0; + LBMReal rhoLB = 0.0; + LBMReal l = L2 / dx; + + //LBMUnitConverterPtr conv = LBMUnitConverterPtr(new LBMUnitConverter(1.0, 1/sqrt(3.0)*(uReal/uLB), 1.0, 1.0/dx, dx*dx*dx)); + LBMUnitConverterPtr conv = LBMUnitConverterPtr(new LBMUnitConverter()); + + const int baseLevel = 0; + const int refineLevel = 1; + + //obstacle + GbObject3DPtr cylinder(new GbCylinder3D(0.5*2.0, 0.2*2.0, -0.1, 0.5*2.0, 0.2*2.0, L3+0.1, radius)); + GbSystem3D::writeGeoObject(cylinder.get(),pathname + "/geo/cylinder", WbWriterVtkXmlBinary::getInstance()); + + GbObject3DPtr refCylinder(new GbCylinder3D(0.5*2.0, 0.2*2.0, -0.1, 0.5*2.0, 0.2*2.0, L3+0.1, radius+7.0*dx/(1<<refineLevel))); + GbSystem3D::writeGeoObject(refCylinder.get(),pathname + "/geo/refCylinder", WbWriterVtkXmlBinary::getInstance()); + + D3Q27InteractorPtr cylinderInt; + + //bounding box + double d_minX1 = 0.0; + double d_minX2 = 0.0; + double d_minX3 = 0.0; + + double d_maxX1 = L1; + double d_maxX2 = L2; + double d_maxX3 = L3; + + //double offs = dx; + double offs = 0; + + //double g_minX1 = d_minX1-offs-0.499999*dx; + double g_minX1 = d_minX1; + double g_minX2 = d_minX2-7.0*dx; + double g_minX3 = d_minX3; + + double g_maxX1 = d_maxX1; + double g_maxX2 = d_maxX2; + double g_maxX3 = d_maxX3; + + GbObject3DPtr gridCube(new GbCuboid3D(g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3)); + + const int blocknx1 = 8; + const int blocknx2 = 8; + const int blocknx3 = 8; + + //dx = (0.41+2.0*dx)/(10.0*(int)blocknx2); + + LBMReal nueLB = (((4.0/9.0)*uLB)*2.0*(radius/dx))/Re; + + double blockLength = blocknx1*dx; + + //refinement area + double rf = cylinder->getLengthX1()/4; + GbObject3DPtr refineCube(new GbCuboid3D(cylinder->getX1Minimum()-rf, cylinder->getX2Minimum()-rf, cylinder->getX3Minimum(), + cylinder->getX1Maximum()+rf, cylinder->getX2Maximum()+rf, cylinder->getX3Maximum())); + // GbObject3DPtr refineCube(new GbCuboid3D(g_minX1 + 7.05*blockLength, g_minX2 + 3.05*blockLength, cylinder->getX3Minimum(), + // g_minX1 + 12.95*blockLength, g_maxX2 - 3.05*blockLength, cylinder->getX3Maximum())); + + Grid3DPtr grid(new Grid3D(comm)); + + UbSchedulerPtr rSch(new UbScheduler(100000, 100000)); + //RestartPostprocessorPtr rp(new RestartPostprocessor(grid, rSch, comm, pathname+"/checkpoints", RestartPostprocessor::BINARY)); + + //UbSchedulerPtr emSch(new UbScheduler(1000, 1000)); + //EmergencyExitPostprocessor em(grid, emSch, pathname+"/checkpoints/emex.txt", rp, comm); + + std::string opt; + + if(cstr!= NULL) + opt = std::string(cstr); + + if/*(cstr== NULL)*/(cstr!= NULL) + { + opt = std::string(cstr); + + if(myid==0) UBLOG(logINFO,"Restart step: " << opt); + + //grid = rp->restart(UbSystem::stringTo<int>(opt)); + //rp->reconnect(); + + //cylinderInt = + + //set connectors + D3Q27InterpolationProcessorPtr iProcessor(new D3Q27OffsetInterpolationProcessor()); + D3Q27SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nueLB, iProcessor); + grid->accept( setConnsVisitor ); + + //domain decomposition + PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); + grid->accept(pqPartVisitor); + } + else + { + if(myid ==0) + { + UBLOG(logINFO,"Number of processes = " << comm->getNumberOfProcesses() ); + UBLOG(logINFO,"path = " << pathname ); + UBLOG(logINFO,"L = " << L1/dx ); + UBLOG(logINFO,"H = " << H/dx ); + UBLOG(logINFO,"v = " << uLB ); + UBLOG(logINFO,"rho = " << rhoLB ); + UBLOG(logINFO,"nue = " << nueLB ); + UBLOG(logINFO,"Re = " << Re ); + UBLOG(logINFO,"dx = " << dx ); + UBLOG(logINFO,"Number of level = " << refineLevel+1 ); + //UBLOG(logINFO,conv->toString() ); + UBLOG(logINFO,"Preprozess - start"); + } + + grid->setDeltaX(dx); + grid->setBlockNX(blocknx1, blocknx2, blocknx3); + + // UbTupleDouble6 bouningBox(gridCube->getX1Minimum(),gridCube->getX2Minimum(),gridCube->getX3Minimum(), + // gridCube->getX1Maximum(),gridCube->getX2Maximum(),gridCube->getX3Maximum()); + // UbTupleInt3 blockNx(blocknx1, blocknx2, blocknx3); + // UbTupleInt3 gridNx(8, 16, 16); + // grid = Grid3DPtr(new Grid3D(bouningBox, blockNx, gridNx)); + + if(myid ==0) GbSystem3D::writeGeoObject(gridCube.get(),pathname + "/geo/gridCube", WbWriterVtkXmlBinary::getInstance()); + if(myid ==0) GbSystem3D::writeGeoObject(refineCube.get(),pathname + "/geo/refineCube", WbWriterVtkXmlBinary::getInstance()); + + GenBlocksGridVisitor genBlocks; + genBlocks.addGeoObject(gridCube); + grid->accept(genBlocks); + + //walls + GbCuboid3DPtr addWallYmin (new GbCuboid3D(d_minX1-blockLength, d_minX2-blockLength, d_minX3-blockLength, d_maxX1+blockLength, d_minX2, d_maxX3+blockLength)); + if(myid == 0) GbSystem3D::writeGeoObject(addWallYmin.get(), pathname+"/geo/addWallYmin", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr addWallZmin (new GbCuboid3D(d_minX1-blockLength, d_minX2-blockLength, d_minX3-blockLength, d_maxX1+blockLength, d_maxX2+blockLength, d_minX3)); + if(myid == 0) GbSystem3D::writeGeoObject(addWallZmin.get(), pathname+"/geo/addWallZmin", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr addWallYmax (new GbCuboid3D(d_minX1-blockLength, d_maxX2, d_minX3-blockLength, d_maxX1+blockLength, d_maxX2+blockLength, d_maxX3+blockLength)); + if(myid == 0) GbSystem3D::writeGeoObject(addWallYmax.get(), pathname+"/geo/addWallYmax", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr addWallZmax (new GbCuboid3D(d_minX1-blockLength, d_minX2-blockLength, d_maxX3, d_maxX1+blockLength, d_maxX2+blockLength, d_maxX3+blockLength)); + if(myid == 0) GbSystem3D::writeGeoObject(addWallZmax.get(), pathname+"/geo/addWallZmax", WbWriterVtkXmlASCII::getInstance()); + + //inflow + GbCuboid3DPtr geoInflow (new GbCuboid3D(d_minX1-blockLength, d_minX2-blockLength, d_minX3-blockLength, d_minX1, d_maxX2+blockLength, d_maxX3+blockLength)); + if(myid == 0) GbSystem3D::writeGeoObject(geoInflow.get(), pathname+"/geo/geoInflow", WbWriterVtkXmlASCII::getInstance()); + + //outflow + GbCuboid3DPtr geoOutflow (new GbCuboid3D(d_maxX1, d_minX2-blockLength, d_minX3-blockLength, d_maxX1+blockLength, d_maxX2+blockLength, d_maxX3+blockLength)); + if(myid == 0) GbSystem3D::writeGeoObject(geoOutflow.get(), pathname+"/geo/geoOutflow", WbWriterVtkXmlASCII::getInstance()); + + BlocksPostprocessorPtr ppblocks(new BlocksPostprocessor(grid, UbSchedulerPtr(new UbScheduler(1)), pathname + "/grid/blocks", WbWriterVtkXmlBinary::getInstance(), comm)); + + if (refineLevel > 0) + { + if(myid == 0) UBLOG(logINFO,"Refinement - start"); + RefineCrossAndInsideGbObjectHelper refineHelper(grid, refineLevel); + //refineHelper.addGbObject(refineCube, refineLevel); + refineHelper.addGbObject(refCylinder, refineLevel); + refineHelper.refine(); + if(myid == 0) UBLOG(logINFO,"Refinement - end"); + } + + MetisPartitioningGridVisitor metisVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::B); + grid->accept( metisVisitor ); + + SolidBlocksHelper sd(grid, comm); + + int bbOption = 1; //0=simple Bounce Back, 1=quadr. BB + D3Q27BoundaryConditionAdapterPtr bcObst(new D3Q27NoSlipBCAdapter(bbOption)); + cylinderInt = D3Q27InteractorPtr ( new D3Q27Interactor(cylinder, grid, bcObst,Interactor3D::SOLID)); + + //walls + D3Q27InteractorPtr addWallYminInt(new D3Q27Interactor(addWallYmin, grid, bcObst,Interactor3D::SOLID)); + D3Q27InteractorPtr addWallZminInt(new D3Q27Interactor(addWallZmin, grid, bcObst,Interactor3D::SOLID)); + D3Q27InteractorPtr addWallYmaxInt(new D3Q27Interactor(addWallYmax, grid, bcObst,Interactor3D::SOLID)); + D3Q27InteractorPtr addWallZmaxInt(new D3Q27Interactor(addWallZmax, grid, bcObst,Interactor3D::SOLID)); + + mu::Parser fct; + fct.SetExpr("16*U*x2*x3*(H-x2)*(H-x3)/H^4"); + fct.DefineConst("U", uLB); + fct.DefineConst("H", H); + + //inflow + D3Q27BoundaryConditionAdapterPtr velBCAdapter(new D3Q27VelocityBCAdapter (true, false ,false ,fct, 0, D3Q27BCFunction::INFCONST)); + velBCAdapter->setSecondaryBcOption(2); + D3Q27InteractorPtr inflowInt = D3Q27InteractorPtr( new D3Q27Interactor(geoInflow, grid, velBCAdapter, Interactor3D::SOLID)); + + //outflow + D3Q27BoundaryConditionAdapterPtr denBCAdapter(new D3Q27DensityBCAdapter(rhoLB)); + D3Q27InteractorPtr outflowInt = D3Q27InteractorPtr( new D3Q27Interactor(geoOutflow, grid, denBCAdapter,Interactor3D::SOLID)); + + sd.addInteractor(cylinderInt); + sd.addInteractor(addWallYminInt); + sd.addInteractor(addWallZminInt); + sd.addInteractor(addWallYmaxInt); + sd.addInteractor(addWallZmaxInt); + sd.addInteractor(inflowInt); + sd.addInteractor(outflowInt); + + sd.deleteSolidBlocks(); + + grid->accept( metisVisitor ); + + sd.setTransBlocks(); + + ppblocks->update(0); + ppblocks.reset(); + + //set connectors + D3Q27InterpolationProcessorPtr iProcessor(new D3Q27IncompressibleOffsetInterpolationProcessor()); + D3Q27SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nueLB, iProcessor); + grid->accept( setConnsVisitor ); + + unsigned long nob = grid->getNumberOfBlocks(); + int gl = 3; + unsigned long nod = nob * (blocknx1+gl) * (blocknx2+gl) * (blocknx3+gl); + + double needMemAll = double(nod*(27*sizeof(double) + sizeof(int) + sizeof(float)*4)); + double needMem = needMemAll / double(comm->getNumberOfProcesses()); + + if(myid == 0) + { + UBLOG(logINFO,"Number of blocks = " << nob); + UBLOG(logINFO,"Number of nodes = " << nod); + UBLOG(logINFO,"Necessary memory = " << needMemAll << " bytes"); + UBLOG(logINFO,"Necessary memory per process = " << needMem << " bytes"); + UBLOG(logINFO,"Available memory per process = " << availMem << " bytes"); + } + + LBMKernel3DPtr kernel(new LBMKernelETD3Q27CCLB(blocknx1, blocknx2, blocknx3, LBMKernelETD3Q27CCLB::NORMAL)); + + BCProcessorPtr bcProc(new D3Q27ETBCProcessor()); + kernel->setBCProcessor(bcProc); + + SetKernelBlockVisitor kernelVisitor(kernel, nueLB, availMem, needMem); + grid->accept(kernelVisitor); + + if (refineLevel > 0) + { + D3Q27SetUndefinedNodesBlockVisitor undefNodesVisitor; + grid->accept(undefNodesVisitor); + } + + //walls + grid->addAndInitInteractor(addWallYminInt); + grid->addAndInitInteractor(addWallZminInt); + grid->addAndInitInteractor(addWallYmaxInt); + grid->addAndInitInteractor(addWallZmaxInt); + + //obstacle + grid->addAndInitInteractor(cylinderInt); + + //inflow + grid->addAndInitInteractor(inflowInt); + + //outflow + grid->addAndInitInteractor(outflowInt); + + //domain decomposition + PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); + grid->accept(pqPartVisitor); + + //initialization of distributions + D3Q27ETInitDistributionsBlockVisitor initVisitor(nueLB, rhoLB); + initVisitor.setVx1(fct); + grid->accept(initVisitor); + + //Postrozess + UbSchedulerPtr geoSch(new UbScheduler(1)); + D3Q27MacroscopicQuantitiesPostprocessorPtr ppgeo( + new D3Q27MacroscopicQuantitiesPostprocessor(grid, geoSch, pathname + "/grid/nodes", WbWriterVtkXmlBinary::getInstance(), conv, comm, true)); + ppgeo->update(0); + ppgeo.reset(); + + if(myid == 0) UBLOG(logINFO,"Preprozess - end"); + } + + double outTime = 100.0; + UbSchedulerPtr visSch(new UbScheduler(outTime)); + //visSch->addSchedule(1000, 1000, 10000); + //visSch->addSchedule(10000, 10000, 50000); + //visSch->addSchedule(100, 100, 10000); + + D3Q27MacroscopicQuantitiesPostprocessor pp(grid, visSch, pathname + "/steps/step", WbWriterVtkXmlBinary::getInstance(), conv, comm); + + double fdx = grid->getDeltaX(grid->getFinestInitializedLevel()); + double point1[3] = {0.45, 0.20, 0.205}; + double point2[3] = {0.55, 0.20, 0.205}; + + D3Q27IntegrateValuesHelperPtr h1(new D3Q27IntegrateValuesHelper(grid, comm, + point1[0]-1.0*fdx, point1[1]-1.0*fdx, point1[2]-1.0*fdx, + point1[0], point1[1], point1[2])); + if(myid ==0) GbSystem3D::writeGeoObject(h1->getBoundingBox().get(),pathname + "/geo/iv1", WbWriterVtkXmlBinary::getInstance()); + D3Q27IntegrateValuesHelperPtr h2(new D3Q27IntegrateValuesHelper(grid, comm, + point2[0], point2[1]-1.0*fdx, point2[2]-1.0*fdx, + point2[0]+1.0*fdx, point2[1], point2[2])); + if(myid ==0) GbSystem3D::writeGeoObject(h2->getBoundingBox().get(),pathname + "/geo/iv2", WbWriterVtkXmlBinary::getInstance()); + //D3Q27PressureDifferencePostprocessor rhopp(grid, visSch, pathname + "/results/rho_diff.txt", h1, h2, conv, comm); + D3Q27PressureDifferencePostprocessor rhopp(grid, visSch, pathname + "/results/rho_diff.txt", h1, h2, rhoReal, uReal, uLB, comm); + + double area = (2.0*radius*H)/(dx*dx); + double v = 4.0*uLB/9.0; + D3Q27ForcesPostprocessor fp(grid, visSch, pathname + "/results/forces.txt", comm, v, area); + fp.addInteractor(cylinderInt); + + UbSchedulerPtr nupsSch(new UbScheduler(10, 10, 40)); + NUPSCounterPostprocessor npr(grid, nupsSch, pathname + "/results/nups.txt", comm); + + double endTime = 100001.0; + CalculationManagerPtr calculation(new CalculationManager(grid, numOfThreads, endTime, visSch)); + if(myid == 0) UBLOG(logINFO,"Simulation-start"); + calculation->calculate(); + if(myid == 0) UBLOG(logINFO,"Simulation-end"); + } + catch(std::exception& e) + { + cerr << e.what() << endl << flush; + } + catch(std::string& s) + { + cerr << s << endl; + } + catch(...) + { + cerr << "unknown exception" << endl; + } + +} +////////////////////////////////////////////////////////////////////////// +int main(int argc, char* argv[]) +{ + + run2(argv[1]); + + return 0; +} + diff --git a/source/Applications/Hagen_Poiseuille_flow/pfDP.cfg b/source/Applications/Hagen_Poiseuille_flow/pfDP.cfg new file mode 100644 index 000000000..f8fe50979 --- /dev/null +++ b/source/Applications/Hagen_Poiseuille_flow/pfDP.cfg @@ -0,0 +1,18 @@ +pathname = d:/temp/pflowDP2 +numOfThreads = 4 +availMem = 8e9 +logToFile = false +blocknx = 10 10 10 +gridnx = 2 1 2 +nuLB = 1e-2 +dpLB = 1e-7 +deltax = 0.1 + +refineLevel = 0 +logToFile=false +thinWall = false + +restartStep = 100000 + +endTime = 100000 +outTime = 100000 \ No newline at end of file diff --git a/source/Applications/Hagen_Poiseuille_flow/pflow.cpp b/source/Applications/Hagen_Poiseuille_flow/pflow.cpp index a905c5d46..f76187532 100644 --- a/source/Applications/Hagen_Poiseuille_flow/pflow.cpp +++ b/source/Applications/Hagen_Poiseuille_flow/pflow.cpp @@ -6,7 +6,298 @@ using namespace std; -void pflowForcing(string configname) +//void pflowForcing(string configname) +//{ +// try +// { +// ConfigurationFile config; +// config.load(configname); +// +// string pathname = config.getString("pathname"); +// int numOfThreads = config.getInt("numOfThreads"); +// vector<int> blocknx = config.getVector<int>("blocknx"); +// vector<double> gridnx = config.getVector<double>("gridnx"); +// double nuLB = config.getDouble("nuLB"); +// double endTime = config.getDouble("endTime"); +// double outTime = config.getDouble("outTime"); +// double availMem = config.getDouble("availMem"); +// int refineLevel = config.getInt("refineLevel"); +// bool logToFile = config.getBool("logToFile"); +// double restartStep = config.getDouble("restartStep"); +// double forcing = config.getDouble("forcing"); +// bool thinWall = config.getBool("thinWall"); +// double deltax = config.getDouble("deltax"); +// +// +// CommunicatorPtr comm = MPICommunicator::getInstance(); +// int myid = comm->getProcessID(); +// +// if (logToFile) +// { +//#if defined(__unix__) +// if (myid == 0) +// { +// const char* str = pathname.c_str(); +// mkdir(str, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); +// } +//#endif +// +// if (myid == 0) +// { +// stringstream logFilename; +// logFilename << pathname + "/logfile" + UbSystem::toString(UbSystem::getTimeStamp()) + ".txt"; +// UbLog::output_policy::setStream(logFilename.str()); +// } +// } +// +// double dx = deltax; +// +// const int blocknx1 = blocknx[0]; +// const int blocknx2 = blocknx[1]; +// const int blocknx3 = blocknx[2]; +// +// LBMReal rhoLB = 0.0; +// +// LBMUnitConverterPtr conv = LBMUnitConverterPtr(new LBMUnitConverter()); +// +// const int baseLevel = 0; +// +// //bounding box +// double g_minX1 = 0; +// double g_minX2 = 0; +// double g_minX3 = 0; +// +// double g_maxX1 = gridnx[0]; +// double g_maxX2 = gridnx[1]; +// double g_maxX3 = gridnx[2]; +// +// double blockLength = blocknx1*dx; +// +// Grid3DPtr grid(new Grid3D(comm)); +// grid->setPeriodicX1(true); +// grid->setPeriodicX2(true); +// grid->setPeriodicX3(false); +// grid->setDeltaX(dx); +// grid->setBlockNX(blocknx1, blocknx2, blocknx3); +// +// GbObject3DPtr gridCube(new GbCuboid3D(g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3)); +// if (myid == 0) GbSystem3D::writeGeoObject(gridCube.get(), pathname + "/geo/gridCube", WbWriterVtkXmlBinary::getInstance()); +// +// ////////////////////////////////////////////////////////////////////////// +// //restart +// UbSchedulerPtr rSch(new UbScheduler(restartStep, restartStep)); +// RestartCoProcessor rp(grid, rSch, comm, pathname, RestartCoProcessor::TXT); +// ////////////////////////////////////////////////////////////////////////// +// +// if (grid->getTimeStep() == 0) +// { +// GenBlocksGridVisitor genBlocks(gridCube); +// grid->accept(genBlocks); +// +// if (myid == 0) +// { +// UBLOG(logINFO, "Parameters:"); +// UBLOG(logINFO, "forcing = " << forcing); +// UBLOG(logINFO, "rho = " << rhoLB); +// UBLOG(logINFO, "nu = " << nuLB); +// UBLOG(logINFO, "dx = " << dx); +// UBLOG(logINFO, "number of levels = " << refineLevel + 1); +// UBLOG(logINFO, "numOfThreads = " << numOfThreads); +// UBLOG(logINFO, "Preprozess - start"); +// } +// +// ////////////////////////////////////////////////////////////////////////// +// //refinement +// double blockLengthX3Fine = grid->getDeltaX(refineLevel) * blocknx[2]; +// +// GbCuboid3DPtr refineBoxTop(new GbCuboid3D(g_minX1 - blockLength, g_minX2 - blockLength, g_maxX3 - blockLengthX3Fine, g_maxX1 + blockLength, g_maxX2 + blockLength, g_maxX3 + blockLength)); +// if (myid == 0) GbSystem3D::writeGeoObject(refineBoxTop.get(), pathname + "/geo/refineBoxTop", WbWriterVtkXmlASCII::getInstance()); +// +// //GbCuboid3DPtr refineBoxBottom(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3, g_maxX1+blockLength, g_maxX2+blockLength, g_minX3+offsetMinX3+blockLengthX3Fine)); +// GbCuboid3DPtr refineBoxBottom(new GbCuboid3D(g_minX1 - blockLength, g_minX2 - blockLength, g_minX3 - blockLengthX3Fine, g_maxX1 + blockLength, g_maxX2 + blockLength, g_minX3 + blockLengthX3Fine)); +// if (myid == 0) GbSystem3D::writeGeoObject(refineBoxBottom.get(), pathname + "/geo/refineBoxBottom", WbWriterVtkXmlASCII::getInstance()); +// +// if (refineLevel > 0) +// { +// if (myid == 0) UBLOG(logINFO, "Refinement - start"); +// RefineCrossAndInsideGbObjectHelper refineHelper(grid, refineLevel); +// refineHelper.addGbObject(refineBoxTop, refineLevel); +// refineHelper.addGbObject(refineBoxBottom, refineLevel); +// refineHelper.refine(); +// if (myid == 0) UBLOG(logINFO, "Refinement - end"); +// } +// ////////////////////////////////////////////////////////////////////////// +// +// //walls +// GbCuboid3DPtr addWallZmin(new GbCuboid3D(g_minX1 - blockLength, g_minX2 - blockLength, g_minX3 - blockLength, g_maxX1 + blockLength, g_maxX2 + blockLength, g_minX3)); +// if (myid == 0) GbSystem3D::writeGeoObject(addWallZmin.get(), pathname + "/geo/addWallZmin", WbWriterVtkXmlASCII::getInstance()); +// +// GbCuboid3DPtr addWallZmax(new GbCuboid3D(g_minX1 - blockLength, g_minX2 - blockLength, g_maxX3, g_maxX1 + blockLength, g_maxX2 + blockLength, g_maxX3 + blockLength)); +// if (myid == 0) GbSystem3D::writeGeoObject(addWallZmax.get(), pathname + "/geo/addWallZmax", WbWriterVtkXmlASCII::getInstance()); +// +// //wall interactors +// int bbOption = 1; +// D3Q27BoundaryConditionAdapterPtr bcNoSlip(new D3Q27NoSlipBCAdapter(bbOption)); +// D3Q27InteractorPtr addWallZminInt(new D3Q27Interactor(addWallZmin, grid, bcNoSlip, Interactor3D::SOLID)); +// D3Q27InteractorPtr addWallZmaxInt(new D3Q27Interactor(addWallZmax, grid, bcNoSlip, Interactor3D::SOLID)); +// +// //////////////////////////////////////////// +// //METIS +// Grid3DVisitorPtr metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::KWAY)); +// //////////////////////////////////////////// +// /////delete solid blocks +// if (myid == 0) UBLOG(logINFO, "deleteSolidBlocks - start"); +// InteractorsHelper intHelper(grid, metisVisitor); +// intHelper.addInteractor(addWallZminInt); +// intHelper.addInteractor(addWallZmaxInt); +// intHelper.selectBlocks(); +// if (myid == 0) UBLOG(logINFO, "deleteSolidBlocks - end"); +// ////////////////////////////////////// +// +// //set connectors +// D3Q27InterpolationProcessorPtr iProcessor(new D3Q27IncompressibleOffsetInterpolationProcessor()); +// D3Q27SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); +// grid->accept(setConnsVisitor); +// +// //domain decomposition for threads +// PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); +// grid->accept(pqPartVisitor); +// +// WriteBlocksCoProcessorPtr ppblocks(new WriteBlocksCoProcessor(grid, UbSchedulerPtr(new UbScheduler(1)), pathname, WbWriterVtkXmlBinary::getInstance(), comm)); +// ppblocks->process(0); +// ppblocks.reset(); +// +// unsigned long nob = grid->getNumberOfBlocks(); +// int gl = 3; +// unsigned long nodb = (blocknx1) * (blocknx2) * (blocknx3); +// unsigned long nod = nob * (blocknx1) * (blocknx2) * (blocknx3); +// unsigned long nodg = nob * (blocknx1 + gl) * (blocknx2 + gl) * (blocknx3 + gl); +// double needMemAll = double(nodg*(27 * sizeof(double) + sizeof(int) + sizeof(float) * 4)); +// double needMem = needMemAll / double(comm->getNumberOfProcesses()); +// +// if (myid == 0) +// { +// UBLOG(logINFO, "Number of blocks = " << nob); +// UBLOG(logINFO, "Number of nodes = " << nod); +// int minInitLevel = grid->getCoarsestInitializedLevel(); +// int maxInitLevel = grid->getFinestInitializedLevel(); +// for (int level = minInitLevel; level <= maxInitLevel; level++) +// { +// int nobl = grid->getNumberOfBlocks(level); +// UBLOG(logINFO, "Number of blocks for level " << level << " = " << nob); +// UBLOG(logINFO, "Number of nodes for level " << level << " = " << nob*nodb); +// } +// UBLOG(logINFO, "Necessary memory = " << needMemAll << " bytes"); +// UBLOG(logINFO, "Necessary memory per process = " << needMem << " bytes"); +// UBLOG(logINFO, "Available memory per process = " << availMem << " bytes"); +// } +// +// LBMKernel3DPtr kernel = LBMKernel3DPtr(new LBMKernelETD3Q27CCLB(blocknx[0], blocknx[1], blocknx[2], LBMKernelETD3Q27CCLB::NORMAL)); +// +// mu::Parser fctForcingX1; +// fctForcingX1.SetExpr("Fx1"); +// fctForcingX1.DefineConst("Fx1", forcing); +// +// kernel->setWithForcing(true); +// kernel->setForcingX1(fctForcingX1); +// +// BCProcessorPtr bcProc; +// BoundaryConditionPtr noSlipBC; +// +// if (thinWall) +// { +// bcProc = BCProcessorPtr(new D3Q27ETForThinWallBCProcessor()); +// noSlipBC = BoundaryConditionPtr(new ThinWallNoSlipBoundaryCondition()); +// } +// else +// { +// bcProc = BCProcessorPtr(new D3Q27ETBCProcessor()); +// noSlipBC = BoundaryConditionPtr(new NoSlipBoundaryCondition()); +// } +// +// bcProc->addBC(noSlipBC); +// +// kernel->setBCProcessor(bcProc); +// +// SetKernelBlockVisitor kernelVisitor(kernel, nuLB, availMem, needMem); +// grid->accept(kernelVisitor); +// +// ////////////////////////////////// +// //undef nodes for refinement +// if (refineLevel > 0) +// { +// D3Q27SetUndefinedNodesBlockVisitor undefNodesVisitor; +// grid->accept(undefNodesVisitor); +// } +// +// //BC +// intHelper.setBC(); +// BoundaryConditionBlockVisitor bcVisitor; +// grid->accept(bcVisitor); +// +// //initialization of distributions +// D3Q27ETInitDistributionsBlockVisitor initVisitor(nuLB, rhoLB); +// grid->accept(initVisitor); +// +// //Postrozess +// UbSchedulerPtr geoSch(new UbScheduler(1)); +// MacroscopicQuantitiesCoProcessorPtr ppgeo( +// new MacroscopicQuantitiesCoProcessor(grid, geoSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, true)); +// ppgeo->process(0); +// ppgeo.reset(); +// +// if (myid == 0) UBLOG(logINFO, "Preprozess - end"); +// } +// else +// { +// mu::Parser fctForcingX1; +// mu::Parser fctForcingX2; +// mu::Parser fctForcingX3; +// fctForcingX1.SetExpr("Fx1"); +// fctForcingX1.DefineConst("Fx1", forcing); +// fctForcingX2.SetExpr("0.0"); +// fctForcingX3.SetExpr("0.0"); +// +// SetForcingBlockVisitor forcingVisitor(fctForcingX1, fctForcingX2, fctForcingX3); +// grid->accept(forcingVisitor); +// +// D3Q27InterpolationProcessorPtr iProcessor(new D3Q27IncompressibleOffsetInterpolationProcessor()); +// D3Q27SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); +// grid->accept(setConnsVisitor); +// +// //domain decomposition for threads +// PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); +// grid->accept(pqPartVisitor); +// } +// +// UbSchedulerPtr nupsSch(new UbScheduler(10, 30, 100)); +// NUPSCounterCoProcessor npr(grid, nupsSch, numOfThreads, comm); +// +// UbSchedulerPtr stepSch(new UbScheduler(outTime)); +// +// MacroscopicQuantitiesCoProcessor pp(grid, stepSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv); +// +// CalculationManagerPtr calculation(new CalculationManager(grid, numOfThreads, endTime, stepSch)); +// if (myid == 0) UBLOG(logINFO, "Simulation-start"); +// calculation->calculate(); +// if (myid == 0) UBLOG(logINFO, "Simulation-end"); +// } +// catch (std::exception& e) +// { +// cerr << e.what() << endl << flush; +// } +// catch (std::string& s) +// { +// cerr << s << endl; +// } +// catch (...) +// { +// cerr << "unknown exception" << endl; +// } +// +//} +////////////////////////////////////////////////////////////////////////// +void pflowdp(string configname) { try { @@ -24,7 +315,7 @@ void pflowForcing(string configname) int refineLevel = config.getInt("refineLevel"); bool logToFile = config.getBool("logToFile"); double restartStep = config.getDouble("restartStep"); - double forcing = config.getDouble("forcing"); + double dpLB = config.getDouble("dpLB"); bool thinWall = config.getBool("thinWall"); double deltax = config.getDouble("deltax"); @@ -32,355 +323,51 @@ void pflowForcing(string configname) CommunicatorPtr comm = MPICommunicator::getInstance(); int myid = comm->getProcessID(); - if (logToFile) - { -#if defined(__unix__) - if (myid == 0) - { - const char* str = pathname.c_str(); - mkdir(str, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); - } -#endif - - if (myid == 0) - { - stringstream logFilename; - logFilename << pathname + "/logfile" + UbSystem::toString(UbSystem::getTimeStamp()) + ".txt"; - UbLog::output_policy::setStream(logFilename.str()); - } - } - - double dx = deltax; - - const int blocknx1 = blocknx[0]; - const int blocknx2 = blocknx[1]; - const int blocknx3 = blocknx[2]; - LBMReal rhoLB = 0.0; + double rhoLBinflow = dpLB*3.0; LBMUnitConverterPtr conv = LBMUnitConverterPtr(new LBMUnitConverter()); const int baseLevel = 0; - //bounding box - double g_minX1 = 0; - double g_minX2 = 0; - double g_minX3 = 0; - - double g_maxX1 = gridnx[0]; - double g_maxX2 = gridnx[1]; - double g_maxX3 = gridnx[2]; - - double blockLength = blocknx1*dx; - - Grid3DPtr grid(new Grid3D(comm)); - grid->setPeriodicX1(true); - grid->setPeriodicX2(true); - grid->setPeriodicX3(false); - grid->setDeltaX(dx); - grid->setBlockNX(blocknx1, blocknx2, blocknx3); - - GbObject3DPtr gridCube(new GbCuboid3D(g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3)); - if (myid == 0) GbSystem3D::writeGeoObject(gridCube.get(), pathname + "/geo/gridCube", WbWriterVtkXmlBinary::getInstance()); - - ////////////////////////////////////////////////////////////////////////// - //restart - UbSchedulerPtr rSch(new UbScheduler(restartStep, restartStep)); - RestartCoProcessor rp(grid, rSch, comm, pathname, RestartCoProcessor::TXT); - ////////////////////////////////////////////////////////////////////////// - - if (grid->getTimeStep() == 0) - { - GenBlocksGridVisitor genBlocks(gridCube); - grid->accept(genBlocks); - - if (myid == 0) - { - UBLOG(logINFO, "Parameters:"); - UBLOG(logINFO, "forcing = " << forcing); - UBLOG(logINFO, "rho = " << rhoLB); - UBLOG(logINFO, "nu = " << nuLB); - UBLOG(logINFO, "dx = " << dx); - UBLOG(logINFO, "number of levels = " << refineLevel + 1); - UBLOG(logINFO, "numOfThreads = " << numOfThreads); - UBLOG(logINFO, "Preprozess - start"); - } - - ////////////////////////////////////////////////////////////////////////// - //refinement - double blockLengthX3Fine = grid->getDeltaX(refineLevel) * blocknx[2]; - - GbCuboid3DPtr refineBoxTop(new GbCuboid3D(g_minX1 - blockLength, g_minX2 - blockLength, g_maxX3 - blockLengthX3Fine, g_maxX1 + blockLength, g_maxX2 + blockLength, g_maxX3 + blockLength)); - if (myid == 0) GbSystem3D::writeGeoObject(refineBoxTop.get(), pathname + "/geo/refineBoxTop", WbWriterVtkXmlASCII::getInstance()); - - //GbCuboid3DPtr refineBoxBottom(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3, g_maxX1+blockLength, g_maxX2+blockLength, g_minX3+offsetMinX3+blockLengthX3Fine)); - GbCuboid3DPtr refineBoxBottom(new GbCuboid3D(g_minX1 - blockLength, g_minX2 - blockLength, g_minX3 - blockLengthX3Fine, g_maxX1 + blockLength, g_maxX2 + blockLength, g_minX3 + blockLengthX3Fine)); - if (myid == 0) GbSystem3D::writeGeoObject(refineBoxBottom.get(), pathname + "/geo/refineBoxBottom", WbWriterVtkXmlASCII::getInstance()); - - if (refineLevel > 0) - { - if (myid == 0) UBLOG(logINFO, "Refinement - start"); - RefineCrossAndInsideGbObjectHelper refineHelper(grid, refineLevel); - refineHelper.addGbObject(refineBoxTop, refineLevel); - refineHelper.addGbObject(refineBoxBottom, refineLevel); - refineHelper.refine(); - if (myid == 0) UBLOG(logINFO, "Refinement - end"); - } - ////////////////////////////////////////////////////////////////////////// - - //walls - GbCuboid3DPtr addWallZmin(new GbCuboid3D(g_minX1 - blockLength, g_minX2 - blockLength, g_minX3 - blockLength, g_maxX1 + blockLength, g_maxX2 + blockLength, g_minX3)); - if (myid == 0) GbSystem3D::writeGeoObject(addWallZmin.get(), pathname + "/geo/addWallZmin", WbWriterVtkXmlASCII::getInstance()); - - GbCuboid3DPtr addWallZmax(new GbCuboid3D(g_minX1 - blockLength, g_minX2 - blockLength, g_maxX3, g_maxX1 + blockLength, g_maxX2 + blockLength, g_maxX3 + blockLength)); - if (myid == 0) GbSystem3D::writeGeoObject(addWallZmax.get(), pathname + "/geo/addWallZmax", WbWriterVtkXmlASCII::getInstance()); - - //wall interactors - int bbOption = 1; - D3Q27BoundaryConditionAdapterPtr bcNoSlip(new D3Q27NoSlipBCAdapter(bbOption)); - D3Q27InteractorPtr addWallZminInt(new D3Q27Interactor(addWallZmin, grid, bcNoSlip, Interactor3D::SOLID)); - D3Q27InteractorPtr addWallZmaxInt(new D3Q27Interactor(addWallZmax, grid, bcNoSlip, Interactor3D::SOLID)); - - //////////////////////////////////////////// - //METIS - Grid3DVisitorPtr metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::KWAY)); - //////////////////////////////////////////// - /////delete solid blocks - if (myid == 0) UBLOG(logINFO, "deleteSolidBlocks - start"); - InteractorsHelper intHelper(grid, metisVisitor); - intHelper.addInteractor(addWallZminInt); - intHelper.addInteractor(addWallZmaxInt); - intHelper.selectBlocks(); - if (myid == 0) UBLOG(logINFO, "deleteSolidBlocks - end"); - ////////////////////////////////////// - - //set connectors - D3Q27InterpolationProcessorPtr iProcessor(new D3Q27IncompressibleOffsetInterpolationProcessor()); - D3Q27SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); - grid->accept(setConnsVisitor); - - //domain decomposition for threads - PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); - grid->accept(pqPartVisitor); - - WriteBlocksCoProcessorPtr ppblocks(new WriteBlocksCoProcessor(grid, UbSchedulerPtr(new UbScheduler(1)), pathname, WbWriterVtkXmlBinary::getInstance(), comm)); - ppblocks->process(0); - ppblocks.reset(); - - unsigned long nob = grid->getNumberOfBlocks(); - int gl = 3; - unsigned long nodb = (blocknx1) * (blocknx2) * (blocknx3); - unsigned long nod = nob * (blocknx1) * (blocknx2) * (blocknx3); - unsigned long nodg = nob * (blocknx1 + gl) * (blocknx2 + gl) * (blocknx3 + gl); - double needMemAll = double(nodg*(27 * sizeof(double) + sizeof(int) + sizeof(float) * 4)); - double needMem = needMemAll / double(comm->getNumberOfProcesses()); - - if (myid == 0) - { - UBLOG(logINFO, "Number of blocks = " << nob); - UBLOG(logINFO, "Number of nodes = " << nod); - int minInitLevel = grid->getCoarsestInitializedLevel(); - int maxInitLevel = grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - int nobl = grid->getNumberOfBlocks(level); - UBLOG(logINFO, "Number of blocks for level " << level << " = " << nob); - UBLOG(logINFO, "Number of nodes for level " << level << " = " << nob*nodb); - } - UBLOG(logINFO, "Necessary memory = " << needMemAll << " bytes"); - UBLOG(logINFO, "Necessary memory per process = " << needMem << " bytes"); - UBLOG(logINFO, "Available memory per process = " << availMem << " bytes"); - } - - LBMKernel3DPtr kernel = LBMKernel3DPtr(new LBMKernelETD3Q27CCLB(blocknx[0], blocknx[1], blocknx[2], LBMKernelETD3Q27CCLB::NORMAL)); - - mu::Parser fctForcingX1; - fctForcingX1.SetExpr("Fx1"); - fctForcingX1.DefineConst("Fx1", forcing); - - kernel->setWithForcing(true); - kernel->setForcingX1(fctForcingX1); - - BCProcessorPtr bcProc; - BoundaryConditionPtr noSlipBC; - - if (thinWall) - { - bcProc = BCProcessorPtr(new D3Q27ETForThinWallBCProcessor()); - noSlipBC = BoundaryConditionPtr(new ThinWallNoSlipBoundaryCondition()); - } - else - { - bcProc = BCProcessorPtr(new D3Q27ETBCProcessor()); - noSlipBC = BoundaryConditionPtr(new NoSlipBoundaryCondition()); - } - - bcProc->addBC(noSlipBC); - - kernel->setBCProcessor(bcProc); - - SetKernelBlockVisitor kernelVisitor(kernel, nuLB, availMem, needMem); - grid->accept(kernelVisitor); - - ////////////////////////////////// - //undef nodes for refinement - if (refineLevel > 0) - { - D3Q27SetUndefinedNodesBlockVisitor undefNodesVisitor; - grid->accept(undefNodesVisitor); - } - - //BC - intHelper.setBC(); - BoundaryConditionBlockVisitor bcVisitor; - grid->accept(bcVisitor); - - //initialization of distributions - D3Q27ETInitDistributionsBlockVisitor initVisitor(nuLB, rhoLB); - grid->accept(initVisitor); - - //Postrozess - UbSchedulerPtr geoSch(new UbScheduler(1)); - MacroscopicQuantitiesCoProcessorPtr ppgeo( - new MacroscopicQuantitiesCoProcessor(grid, geoSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, true)); - ppgeo->process(0); - ppgeo.reset(); - - if (myid == 0) UBLOG(logINFO, "Preprozess - end"); - } - else - { - mu::Parser fctForcingX1; - mu::Parser fctForcingX2; - mu::Parser fctForcingX3; - fctForcingX1.SetExpr("Fx1"); - fctForcingX1.DefineConst("Fx1", forcing); - fctForcingX2.SetExpr("0.0"); - fctForcingX3.SetExpr("0.0"); - - SetForcingBlockVisitor forcingVisitor(fctForcingX1, fctForcingX2, fctForcingX3); - grid->accept(forcingVisitor); - - D3Q27InterpolationProcessorPtr iProcessor(new D3Q27IncompressibleOffsetInterpolationProcessor()); - D3Q27SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); - grid->accept(setConnsVisitor); - - //domain decomposition for threads - PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); - grid->accept(pqPartVisitor); - } - - UbSchedulerPtr nupsSch(new UbScheduler(10, 30, 100)); - NUPSCounterCoProcessor npr(grid, nupsSch, numOfThreads, comm); - - UbSchedulerPtr stepSch(new UbScheduler(outTime)); - - MacroscopicQuantitiesCoProcessor pp(grid, stepSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv); - - CalculationManagerPtr calculation(new CalculationManager(grid, numOfThreads, endTime, stepSch)); - if (myid == 0) UBLOG(logINFO, "Simulation-start"); - calculation->calculate(); - if (myid == 0) UBLOG(logINFO, "Simulation-end"); - } - catch (std::exception& e) - { - cerr << e.what() << endl << flush; - } - catch (std::string& s) - { - cerr << s << endl; - } - catch (...) - { - cerr << "unknown exception" << endl; - } - -} -////////////////////////////////////////////////////////////////////////// -void pflowdp(const char *cstr) -{ - try - { - - string machine = QUOTEME(CAB_MACHINE); - string pathname; - int numOfThreads = 1; - double availMem = 0; - - CommunicatorPtr comm = MPICommunicator::getInstance(); - int myid = comm->getProcessID(); - - if (machine == "BOMBADIL") - { - pathname = "d:/temp/Hagen_Poiseuille_flow_tube_testC"; - availMem = 4.0e9; - } - else if (machine == "M01" || machine == "M02") - { - pathname = "/work/koskuche/scratch/Hagen_Poiseuille_flow_tube5"; - availMem = 10.0e9; - numOfThreads = 8; - - if (myid == 0) - { - stringstream logFilename; - logFilename << pathname + "/logfile" + UbSystem::toString(UbSystem::getTimeStamp()) + ".txt"; - UbLog::output_policy::setStream(logFilename.str()); - } - } - else throw UbException(UB_EXARGS, "unknown CAB_MACHINE"); - - double dx = 1; - - const int blocknx1 = 16; - const int blocknx2 = 16; - const int blocknx3 = 16; - - LBMReal rhoLB = 0.0;//1.4e-7; //0.0; - LBMReal nuLB = 0.168666666667; - - double coord[6]; - - LBMUnitConverterPtr conv = LBMUnitConverterPtr(new LBMUnitConverter()); - - const int baseLevel = 0; - const int refineLevel = 0; - - double Ri = 16; - double f = 1; - double r = f*Ri; - - //bounding box - double g_minX1 = 0; - double g_minX2 = 0; - double g_minX3 = 0; + //bounding box + double g_minX1 = 0; + double g_minX2 = 0; + double g_minX3 = 0; + + double g_maxX1 = gridnx[0]; + double g_maxX2 = gridnx[1]; + double g_maxX3 = gridnx[2]; - double g_maxX1 = 2.0*r*4.0; - double g_maxX2 = 2.0*r; - double g_maxX3 = 2.0*r; - - double blockLength = (double)blocknx1*dx; + double blockLength = (double)blocknx[0]*deltax; double h = (g_maxX2) / 2.0; + double dex = g_maxX1; + double Umax = (1.0 / (4.0*nuLB))*(dpLB / dex)*(h*h); + double Re = (4 * h*Umax) / (3 * nuLB); - double rhoLBinflow = 0.003;//9e-7; - - // rhoLBinflow/=1000.0; - - double dpLB = (rhoLBinflow - rhoLB) / 3.0; + //bc + BCAdapterPtr noSlipBCAdapter(new NoSlipBCAdapter()); + noSlipBCAdapter->setBcAlgorithm(NoSlipBCAlgorithmPtr(new NoSlipBCAlgorithm())); + BCAdapterPtr denBCAdapterInflow(new DensityBCAdapter(rhoLBinflow)); + denBCAdapterInflow->setBcAlgorithm(BCAlgorithmPtr(new EqDensityBCAlgorithm())); - double dex = g_maxX1; - double Umax = (1.0 / (4.0*nuLB))*(dpLB / dex)*(h*h); + BCAdapterPtr denBCAdapterOutflow(new DensityBCAdapter(rhoLB)); + denBCAdapterOutflow->setBcAlgorithm(BCAlgorithmPtr(new EqDensityBCAlgorithm())); - double Re = (4 * h*Umax) / (3 * nuLB); + //BS visitor + BoundaryConditionsBlockVisitor bcVisitor; + bcVisitor.addBC(noSlipBCAdapter); + bcVisitor.addBC(denBCAdapterInflow); + bcVisitor.addBC(denBCAdapterOutflow); Grid3DPtr grid(new Grid3D(comm)); - grid->setPeriodicX1(true); + grid->setPeriodicX1(false); grid->setPeriodicX2(false); - grid->setPeriodicX3(false); - grid->setDeltaX(dx); - grid->setBlockNX(blocknx1, blocknx2, blocknx3); + grid->setPeriodicX3(true); + grid->setDeltaX(deltax); + grid->setBlockNX(blocknx[0], blocknx[1], blocknx[2]); GbObject3DPtr gridCube(new GbCuboid3D(g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3)); if (myid == 0) GbSystem3D::writeGeoObject(gridCube.get(), pathname + "/geo/gridCube", WbWriterVtkXmlBinary::getInstance()); @@ -394,28 +381,17 @@ void pflowdp(const char *cstr) GbObject3DPtr refineCube1_2(new GbCuboid3D(g_minX1, g_maxX2 - g_maxX2 / k1 + 1.0, g_minX3, g_maxX1, g_maxX2, g_maxX3)); if (myid == 0) GbSystem3D::writeGeoObject(refineCube1_2.get(), pathname + "/geo/refineCube1_2", WbWriterVtkXmlBinary::getInstance()); - GbObject3DPtr refineCube2_1(new GbCuboid3D(g_minX1 + 2 * blockLength + 2 * dx, g_minX2, g_minX3, g_maxX1 - 2 * blockLength - 2 * dx, g_maxX2 / k2 - 1.0, g_maxX3)); + GbObject3DPtr refineCube2_1(new GbCuboid3D(g_minX1 + 2 * blockLength + 2 * deltax, g_minX2, g_minX3, g_maxX1 - 2 * blockLength - 2 * deltax, g_maxX2 / k2 - 1.0, g_maxX3)); if (myid == 0) GbSystem3D::writeGeoObject(refineCube2_1.get(), pathname + "/geo/refineCube2_1", WbWriterVtkXmlBinary::getInstance()); - GbObject3DPtr refineCube2_2(new GbCuboid3D(g_minX1 + 2 * blockLength + 2 * dx, g_maxX2 - g_maxX2 / k2 + 1.0, g_minX3, g_maxX1 - 2 * blockLength - 2 * dx, g_maxX2, g_maxX3)); + GbObject3DPtr refineCube2_2(new GbCuboid3D(g_minX1 + 2 * blockLength + 2 * deltax, g_maxX2 - g_maxX2 / k2 + 1.0, g_minX3, g_maxX1 - 2 * blockLength - 2 * deltax, g_maxX2, g_maxX3)); if (myid == 0) GbSystem3D::writeGeoObject(refineCube2_2.get(), pathname + "/geo/refineCube2_2", WbWriterVtkXmlBinary::getInstance()); - GbObject3DPtr refineCube2_3(new GbCuboid3D(g_minX1 + blockLength + 2 * dx, g_minX2 + blockLength + 2 * dx, g_minX3 + blockLength + 2 * dx, g_maxX1 - blockLength - 2 * dx, g_maxX2 - blockLength - 2 * dx, g_maxX3 - blockLength - 2 * dx)); + GbObject3DPtr refineCube2_3(new GbCuboid3D(g_minX1 + blockLength + 2 * deltax, g_minX2 + blockLength + 2 * deltax, g_minX3 + blockLength + 2 * deltax, g_maxX1 - blockLength - 2 * deltax, g_maxX2 - blockLength - 2 * deltax, g_maxX3 - blockLength - 2 * deltax)); if (myid == 0) GbSystem3D::writeGeoObject(refineCube2_3.get(), pathname + "/geo/refineCube2_3", WbWriterVtkXmlBinary::getInstance()); - //UbSchedulerPtr rSch(new UbScheduler()); - //rSch->addSchedule(50, 50, 50); - //RestartPostprocessorPtr rp(new RestartPostprocessor(grid, rSch, comm, pathname+"/checkpoints", RestartPostprocessor::BINARY)); - - std::string opt; - - if (cstr != NULL) - opt = std::string(cstr); - ////////////////////////////////////////////////////////////////////////// //restart - double restartStep = 300000; - double restartStart = 200000; UbSchedulerPtr rSch(new UbScheduler(restartStep)); RestartCoProcessor rp(grid, rSch, comm, pathname, RestartCoProcessor::TXT); ////////////////////////////////////////////////////////////////////////// @@ -432,7 +408,7 @@ void pflowdp(const char *cstr) UBLOG(logINFO, "rho = " << rhoLB); UBLOG(logINFO, "nue = " << nuLB); UBLOG(logINFO, "Re = " << Re); - UBLOG(logINFO, "dx = " << dx); + UBLOG(logINFO, "dx = " << deltax); UBLOG(logINFO, "dpLB = " << dpLB); UBLOG(logINFO, "Umax = " << Umax); UBLOG(logINFO, "number of levels = " << refineLevel + 1); @@ -441,23 +417,12 @@ void pflowdp(const char *cstr) UBLOG(logINFO, "Preprozess - start"); } - //tube - GbCylinder3DPtr tube(new GbCylinder3D(gridCube->getX1Minimum(), gridCube->getX2Centroid(), gridCube->getX3Centroid(), - gridCube->getX1Maximum(), gridCube->getX2Centroid(), gridCube->getX3Centroid(), g_maxX3 / 2.0)); - - coord[0] = tube->getX1Minimum(); - coord[1] = tube->getX2Minimum(); - coord[2] = tube->getX3Minimum(); - coord[3] = tube->getX1Maximum(); - coord[4] = tube->getX2Maximum(); - coord[5] = tube->getX3Maximum(); - - ////walls - //GbCuboid3DPtr addWallYmin (new GbCuboid3D(g_minX1-4.0*blockLength, g_minX2-4.0*blockLength, g_minX3-4.0*blockLength, g_maxX1+4.0*blockLength, g_minX2, g_maxX3+4.0*blockLength)); - //if(myid == 0) GbSystem3D::writeGeoObject(addWallYmin.get(), pathname+"/geo/addWallYmin", WbWriterVtkXmlASCII::getInstance()); + //walls + GbCuboid3DPtr addWallYmin (new GbCuboid3D(g_minX1-4.0*blockLength, g_minX2-4.0*blockLength, g_minX3-4.0*blockLength, g_maxX1+4.0*blockLength, g_minX2, g_maxX3+4.0*blockLength)); + if(myid == 0) GbSystem3D::writeGeoObject(addWallYmin.get(), pathname+"/geo/addWallYmin", WbWriterVtkXmlASCII::getInstance()); - //GbCuboid3DPtr addWallYmax (new GbCuboid3D(g_minX1-4.0*blockLength, g_maxX2, g_minX3-4.0*blockLength, g_maxX1+4.0*blockLength, g_maxX2+4.0*blockLength, g_maxX3+4.0*blockLength)); - //if(myid == 0) GbSystem3D::writeGeoObject(addWallYmax.get(), pathname+"/geo/addWallYmax", WbWriterVtkXmlASCII::getInstance()); + GbCuboid3DPtr addWallYmax (new GbCuboid3D(g_minX1-4.0*blockLength, g_maxX2, g_minX3-4.0*blockLength, g_maxX1+4.0*blockLength, g_maxX2+4.0*blockLength, g_maxX3+4.0*blockLength)); + if(myid == 0) GbSystem3D::writeGeoObject(addWallYmax.get(), pathname+"/geo/addWallYmax", WbWriterVtkXmlASCII::getInstance()); //inflow GbCuboid3DPtr geoInflow(new GbCuboid3D(g_minX1 - 4.0*blockLength, g_minX2 - 4.0*blockLength, g_minX3 - 4.0*blockLength, g_minX1, g_maxX2 + 4.0*blockLength, g_maxX3 + 4.0*blockLength)); @@ -490,36 +455,14 @@ void pflowdp(const char *cstr) if (myid == 0) UBLOG(logINFO, "Refinement - end"); } - int bbOption = 0; //0=simple Bounce Back, 1=quadr. BB - D3Q27BoundaryConditionAdapterPtr bcObst(new D3Q27NoSlipBCAdapter(bbOption)); - D3Q27BoundaryConditionAdapterPtr bcObst2(new D3Q27SlipBCAdapter(bbOption)); - - mu::Parser fct0; - fct0.SetExpr("0.0001"); - D3Q27BoundaryConditionAdapterPtr velBCAdapter(new D3Q27VelocityBCAdapter(true, false, false, fct0, 0, D3Q27BCFunction::INFCONST)); - velBCAdapter->setSecondaryBcOption(2); - - D3Q27InteractorPtr tubeInt(new D3Q27Interactor(tube, grid, bcObst, Interactor3D::INVERSESOLID)); - //walls - //D3Q27InteractorPtr addWallYminInt(new D3Q27Interactor(addWallYmin, grid, bcObst,Interactor3D::SOLID)); - //D3Q27InteractorPtr addWallYmaxInt(new D3Q27Interactor(addWallYmax, grid, bcObst,Interactor3D::SOLID)); - //D3Q27InteractorPtr addWallYmaxInt(new D3Q27Interactor(addWallYmax, grid, velBCAdapter,Interactor3D::SOLID)); + D3Q27InteractorPtr addWallYminInt(new D3Q27Interactor(addWallYmin, grid, noSlipBCAdapter,Interactor3D::SOLID)); + D3Q27InteractorPtr addWallYmaxInt(new D3Q27Interactor(addWallYmax, grid, noSlipBCAdapter,Interactor3D::SOLID)); - //inflow - //double dp_Ph=0.1*10000.0;//dp in Bar - //double dp_lb=dp_Ph*0.001*(nueLB*dx)*(nueLB*dx);//nue_ph=10e-6 - //if(myid == 0) UBLOG(logINFO,"dp_lb = " << dp_lb ); - //double rhoLBinflow = 3.0*(dp_lb-rhoLB); - - D3Q27BoundaryConditionAdapterPtr denBCAdapterFront(new D3Q27DensityBCAdapter(rhoLBinflow)); - denBCAdapterFront->setSecondaryBcOption(0); - D3Q27InteractorPtr inflowInt = D3Q27InteractorPtr(new D3Q27Interactor(geoInflow, grid, denBCAdapterFront, Interactor3D::SOLID)); + D3Q27InteractorPtr inflowInt = D3Q27InteractorPtr(new D3Q27Interactor(geoInflow, grid, denBCAdapterInflow, Interactor3D::SOLID)); //outflow - D3Q27BoundaryConditionAdapterPtr denBCAdapter(new D3Q27DensityBCAdapter(rhoLB)); - denBCAdapter->setSecondaryBcOption(0); - D3Q27InteractorPtr outflowInt = D3Q27InteractorPtr(new D3Q27Interactor(geoOutflow, grid, denBCAdapter, Interactor3D::SOLID)); + D3Q27InteractorPtr outflowInt = D3Q27InteractorPtr(new D3Q27Interactor(geoOutflow, grid, denBCAdapterOutflow, Interactor3D::SOLID)); //////////////////////////////////////////// //METIS @@ -528,9 +471,8 @@ void pflowdp(const char *cstr) /////delete solid blocks if (myid == 0) UBLOG(logINFO, "deleteSolidBlocks - start"); InteractorsHelper intHelper(grid, metisVisitor); - intHelper.addInteractor(tubeInt); - //intHelper.addInteractor(addWallYminInt); - //intHelper.addInteractor(addWallYmaxInt); + intHelper.addInteractor(addWallYminInt); + intHelper.addInteractor(addWallYmaxInt); intHelper.addInteractor(inflowInt); intHelper.addInteractor(outflowInt); intHelper.selectBlocks(); @@ -538,8 +480,8 @@ void pflowdp(const char *cstr) ////////////////////////////////////// //set connectors - D3Q27InterpolationProcessorPtr iProcessor(new D3Q27IncompressibleOffsetInterpolationProcessor()); - D3Q27SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); + InterpolationProcessorPtr iProcessor(new IncompressibleOffsetInterpolationProcessor()); + SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); grid->accept(setConnsVisitor); //domain decomposition for threads @@ -551,9 +493,9 @@ void pflowdp(const char *cstr) unsigned long nob = grid->getNumberOfBlocks(); int gl = 3; - unsigned long nodb = (blocknx1) * (blocknx2) * (blocknx3); - unsigned long nod = nob * (blocknx1) * (blocknx2) * (blocknx3); - unsigned long nodg = nob * (blocknx1 + gl) * (blocknx2 + gl) * (blocknx3 + gl); + unsigned long nodb = (blocknx[0]) * (blocknx[1]) * (blocknx[2]); + unsigned long nod = nob * (blocknx[0]) * (blocknx[1]) * (blocknx[2]); + unsigned long nodg = nob * (blocknx[0] + gl) * (blocknx[1] + gl) * (blocknx[1] + gl); double needMemAll = double(nodg*(27 * sizeof(double) + sizeof(int) + sizeof(float) * 4)); double needMem = needMemAll / double(comm->getNumberOfProcesses()); @@ -575,33 +517,11 @@ void pflowdp(const char *cstr) } int kernelType = 2; - LBMKernel3DPtr kernel; - //if (kernelType == 0) - //{ - // rhoLB = 1.0; - // kernel = LBMKernel3DPtr(new LBMKernelETD3Q27BGK(blocknx1, blocknx2, blocknx3, true)); - //} - //else if (kernelType == 1) - //{ - // rhoLB = 1.0; - // kernel = LBMKernel3DPtr(new LBMKernelETD3Q27Cascaded(blocknx1, blocknx2, blocknx3)); + LBMKernelPtr kernel; + kernel = LBMKernelPtr(new IncompressibleCumulantLBMKernel(blocknx[0], blocknx[1], blocknx[2], IncompressibleCumulantLBMKernel::NORMAL)); //} - //else if (kernelType == 2) - //{ - // rhoLB = 0.0; - kernel = LBMKernel3DPtr(new LBMKernelETD3Q27CCLB(blocknx1, blocknx2, blocknx3, LBMKernelETD3Q27CCLB::NORMAL)); - //} - - BCProcessorPtr bcProc(new D3Q27ETBCProcessor()); - - BoundaryConditionPtr densityBC(new NonEqDensityBoundaryCondition()); - //BoundaryConditionPtr densityBC(new NonReflectingDensityBoundaryCondition()); - //BoundaryConditionPtr noSlipBC(new HighViscosityNoSlipBoundaryCondition()); - BoundaryConditionPtr noSlipBC(new NoSlipBoundaryCondition()); - - bcProc->addBC(densityBC); - bcProc->addBC(noSlipBC); + BCProcessorPtr bcProc(new BCProcessor()); kernel->setBCProcessor(bcProc); SetKernelBlockVisitor kernelVisitor(kernel, nuLB, availMem, needMem); @@ -609,14 +529,13 @@ void pflowdp(const char *cstr) if (refineLevel > 0) { - D3Q27SetUndefinedNodesBlockVisitor undefNodesVisitor; + SetUndefinedNodesBlockVisitor undefNodesVisitor; grid->accept(undefNodesVisitor); } //walls intHelper.setBC(); - BoundaryConditionBlockVisitor bcVisitor; grid->accept(bcVisitor); //initialization of distributions @@ -627,7 +546,7 @@ void pflowdp(const char *cstr) fct.DefineConst("h", h); fct.DefineConst("nu", nuLB); - D3Q27ETInitDistributionsBlockVisitor initVisitor(nuLB, rhoLB); + InitDistributionsBlockVisitor initVisitor(nuLB, rhoLB); //initVisitor.setVx1(fct); initVisitor.setVx1(0.0); //initVisitor.setVx3(fct); @@ -635,37 +554,20 @@ void pflowdp(const char *cstr) //Postrozess UbSchedulerPtr geoSch(new UbScheduler(1)); - MacroscopicQuantitiesCoProcessorPtr ppgeo( - new MacroscopicQuantitiesCoProcessor(grid, geoSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, true)); + WriteBoundaryConditionsCoProcessorPtr ppgeo( + new WriteBoundaryConditionsCoProcessor(grid, geoSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, comm)); ppgeo->process(0); ppgeo.reset(); - //grid->addInteractor(inflowInt); - //grid->addInteractor(outflowInt); - if (myid == 0) UBLOG(logINFO, "Preprozess - end"); } else { - Grid3D::Interactor3DSet interactors = grid->getInteractors(); - interactors[0]->setGrid3D(grid); - boost::dynamic_pointer_cast<D3Q27Interactor>(interactors[0])->deleteBCAdapter(); - D3Q27BoundaryConditionAdapterPtr denBCAdapterFront(new D3Q27DensityBCAdapter(rhoLBinflow)); - boost::dynamic_pointer_cast<D3Q27Interactor>(interactors[0])->addBCAdapter(denBCAdapterFront); - interactors[0]->updateInteractor(); - - //BOOST_FOREACH(Interactor3DPtr i, interactors) - //{ - // i->setGrid3D(grid); - // i->updateInteractor(); - //} - - BoundaryConditionBlockVisitor bcVisitor; grid->accept(bcVisitor); //set connectors - D3Q27InterpolationProcessorPtr iProcessor(new D3Q27IncompressibleOffsetInterpolationProcessor()); - D3Q27SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); + InterpolationProcessorPtr iProcessor(new IncompressibleOffsetInterpolationProcessor()); + SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); grid->accept(setConnsVisitor); if (myid == 0) UBLOG(logINFO, "Restart - end"); @@ -673,21 +575,9 @@ void pflowdp(const char *cstr) UbSchedulerPtr nupsSch(new UbScheduler(10, 30, 100)); NUPSCounterCoProcessor npr(grid, nupsSch, numOfThreads, comm); - D3Q27IntegrateValuesHelperPtr ih1(new D3Q27IntegrateValuesHelper(grid, comm, coord[0], coord[1], coord[2], coord[3], coord[4], coord[5])); - if (myid == 0) GbSystem3D::writeGeoObject(ih1->getBoundingBox().get(), pathname + "/geo/ih1", WbWriterVtkXmlBinary::getInstance()); - - UbSchedulerPtr stepMV(new UbScheduler(5)); - - TimeseriesCoProcessor tsp(grid, stepMV, ih1, pathname + "/ts/ts1", comm); - - double outTime = 100; UbSchedulerPtr stepSch(new UbScheduler(outTime)); - stepSch->addSchedule(1000, 1000, 1000); - stepSch->addSchedule(384000, 384000, 384000); - - MacroscopicQuantitiesCoProcessor pp(grid, stepSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv); - double endTime = 400000;//10001.0; + WriteMacroscopicQuantitiesCoProcessor pp(grid, stepSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, comm); CalculationManagerPtr calculation(new CalculationManager(grid, numOfThreads, endTime, stepSch)); if (myid == 0) UBLOG(logINFO, "Simulation-start"); @@ -715,8 +605,8 @@ int main(int argc, char* argv[]) { if (argv[1] != NULL) { - pflowForcing(string(argv[1])); - //pflowdp(string(argv[1])); + //pflowForcing(string(argv[1])); + pflowdp(string(argv[1])); } else { diff --git a/source/Applications/LaminarTubeFlow/ltf.cfg b/source/Applications/LaminarTubeFlow/ltf.cfg index 237763f79..b44b01feb 100644 --- a/source/Applications/LaminarTubeFlow/ltf.cfg +++ b/source/Applications/LaminarTubeFlow/ltf.cfg @@ -1,5 +1,5 @@ pathname = d:/temp/LaminarTubeFlow1 -numOfThreads = 1 +numOfThreads = 4 availMem = 10e9 #Grid @@ -13,8 +13,8 @@ uLB = 0.001 Re = 10 -outTime = 10 -endTime = 500 +outTime = 1 +endTime = 5000 logToFile = false diff --git a/source/Applications/LaminarTubeFlow/ltf.cpp b/source/Applications/LaminarTubeFlow/ltf.cpp index 7189cd9b3..67284b5b0 100644 --- a/source/Applications/LaminarTubeFlow/ltf.cpp +++ b/source/Applications/LaminarTubeFlow/ltf.cpp @@ -56,6 +56,25 @@ void run(string configname) const int baseLevel = 0; + //BC Adapter + ////////////////////////////////////////////////////////////////////////////// + BCAdapterPtr noSlipBCAdapter(new NoSlipBCAdapter()); + //noSlipBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new ThinWallNoSlipBCAlgorithm())); + //BCAdapterPtr denBCAdapter(new DensityBCAdapter(rhoLB)); + //denBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new EqDensityBCAlgorithm())); + + noSlipBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new NoSlipBCAlgorithm())); + + BCAdapterPtr denBCAdapter(new DensityBCAdapter(rhoLB)); + denBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new NonReflectingDensityBCAlgorithm())); + + + ////////////////////////////////////////////////////////////////////////////////// + //BS visitor + BoundaryConditionsBlockVisitor bcVisitor; + bcVisitor.addBC(noSlipBCAdapter); + bcVisitor.addBC(denBCAdapter); + Grid3DPtr grid(new Grid3D(comm)); ////////////////////////////////////////////////////////////////////////// @@ -77,6 +96,9 @@ void run(string configname) double g_maxX3 = length[2] / 2.0; //geometry + //x + //GbObject3DPtr cylinder(new GbCylinder3D(g_minX1 - 2.0*dx, 0.0, 0.0, g_maxX1 + 2.0*dx, 0.0, 0.0, dLB / 2.0)); + //y GbObject3DPtr cylinder(new GbCylinder3D(g_minX1 - 2.0*dx, 0.0, 0.0, g_maxX1 + 2.0*dx, 0.0, 0.0, dLB / 2.0)); GbSystem3D::writeGeoObject(cylinder.get(), pathname + "/geo/cylinder", WbWriterVtkXmlBinary::getInstance()); @@ -118,14 +140,13 @@ void run(string configname) ppblocks->process(0); - int bbOption = 1; //0=simple Bounce Back, 1=quadr. BB - D3Q27BoundaryConditionAdapterPtr bcObst(new D3Q27NoSlipBCAdapter(bbOption)); - D3Q27InteractorPtr cylinderInt(new D3Q27Interactor(cylinder, grid, bcObst, Interactor3D::INVERSESOLID)); + D3Q27InteractorPtr cylinderInt(new D3Q27Interactor(cylinder, grid, noSlipBCAdapter, Interactor3D::INVERSESOLID)); double r = boost::dynamic_pointer_cast<GbCylinder3D>(cylinder)->getRadius(); double cx1 = g_minX1; double cx2 = cylinder->getX2Centroid(); double cx3 = cylinder->getX3Centroid(); + mu::Parser fct; fct.SetExpr("vx1*(1-((x2-y0)^2+(x3-z0)^2)/(R^2))"); fct.DefineConst("x2Vmax", 0.0); //x2-Pos fuer vmax @@ -136,12 +157,13 @@ void run(string configname) fct.DefineConst("y0", cx2); fct.DefineConst("z0", cx3); fct.DefineConst("nue", nuLB); + BCAdapterPtr velBCAdapter(new VelocityBCAdapter(true, false, false, fct, 0, BCFunction::INFCONST)); + //velBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new VelocityBCAlgorithm())); + velBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new NonReflectingVelocityBCAlgorithm())); - D3Q27BoundaryConditionAdapterPtr velBCAdapter(new D3Q27VelocityBCAdapter(true, false, false, fct, 0, D3Q27BCFunction::INFCONST)); D3Q27InteractorPtr inflowInt = D3Q27InteractorPtr(new D3Q27Interactor(geoInflow, grid, velBCAdapter, Interactor3D::SOLID)); //outflow - D3Q27BoundaryConditionAdapterPtr denBCAdapter(new D3Q27DensityBCAdapter(rhoLB)); D3Q27InteractorPtr outflowInt = D3Q27InteractorPtr(new D3Q27Interactor(geoOutflow, grid, denBCAdapter, Interactor3D::SOLID)); @@ -153,8 +175,9 @@ void run(string configname) intHelper.selectBlocks(); //set connectors - D3Q27InterpolationProcessorPtr iProcessor(new D3Q27IncompressibleOffsetInterpolationProcessor()); - D3Q27SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); + //InterpolationProcessorPtr iProcessor(new IncompressibleOffsetInterpolationProcessor()); + InterpolationProcessorPtr iProcessor(new CompressibleOffsetInterpolationProcessor()); + SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); //ConnectorFactoryPtr factory(new Block3DConnectorFactory()); //ConnectorBlockVisitor setConnsVisitor(comm, nuLB, iProcessor, factory); grid->accept(setConnsVisitor); @@ -191,23 +214,14 @@ void run(string configname) UBLOG(logINFO, "Available memory per process = " << availMem << " bytes"); } - LBMKernel3DPtr kernel; + LBMKernelPtr kernel; - kernel = LBMKernel3DPtr(new LBMKernelETD3Q27CCLB(blocknx[0], blocknx[1], blocknx[2], LBMKernelETD3Q27CCLB::NORMAL)); + //kernel = LBMKernelPtr(new IncompressibleCumulantLBMKernel(blocknx[0], blocknx[1], blocknx[2], IncompressibleCumulantLBMKernel::NORMAL)); + kernel = LBMKernelPtr(new CompressibleCumulantLBMKernel(blocknx[0], blocknx[1], blocknx[2], CompressibleCumulantLBMKernel::NORMAL)); // - //BCProcessorPtr bcProc(new D3Q27ETBCProcessor()); - BCProcessorPtr bcProc(new D3Q27ETForThinWallBCProcessor()); - BoundaryConditionPtr noSlipBC; - BoundaryConditionPtr velBC; - BoundaryConditionPtr denBC; - //noSlipBC = BoundaryConditionPtr(new NoSlipBoundaryCondition()); - noSlipBC = BoundaryConditionPtr(new ThinWallNoSlipBoundaryCondition()); - velBC = BoundaryConditionPtr(new VelocityBoundaryCondition()); - denBC = BoundaryConditionPtr(new NonEqDensityBoundaryCondition()); - bcProc->addBC(noSlipBC); - bcProc->addBC(velBC); - bcProc->addBC(denBC); + BCProcessorPtr bcProc(new BCProcessor()); + //BCProcessorPtr bcProc(new ThinWallBCProcessor()); kernel->setBCProcessor(bcProc); @@ -216,26 +230,25 @@ void run(string configname) if (refineLevel > 0) { - D3Q27SetUndefinedNodesBlockVisitor undefNodesVisitor; + SetUndefinedNodesBlockVisitor undefNodesVisitor; grid->accept(undefNodesVisitor); } intHelper.setBC(); - BoundaryConditionBlockVisitor bcVisitor; + bcVisitor.addBC(velBCAdapter); grid->accept(bcVisitor); //initialization of distributions - D3Q27ETInitDistributionsBlockVisitor initVisitor(nuLB, rhoLB); + InitDistributionsBlockVisitor initVisitor(nuLB, rhoLB); grid->accept(initVisitor); //boundary conditions grid - //{ - // UbSchedulerPtr geoSch(new UbScheduler(1)); - // MacroscopicQuantitiesCoProcessorPtr ppgeo( - // new MacroscopicQuantitiesCoProcessor(grid, geoSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, true)); - // grid->coProcess(0); - //} + { + UbSchedulerPtr geoSch(new UbScheduler(1)); + WriteBoundaryConditionsCoProcessor(grid, geoSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, comm); + grid->coProcess(0); + } if (myid == 0) UBLOG(logINFO, "Preprocess - end"); } @@ -254,22 +267,25 @@ void run(string configname) UBLOG(logINFO, "path = " << pathname); } - //BoundaryConditionBlockVisitor bcVisitor; - //grid->accept(bcVisitor); + BCAdapterPtr velBCAdapter(new VelocityBCAdapter()); + velBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new VelocityBCAlgorithm())); + bcVisitor.addBC(velBCAdapter); + grid->accept(bcVisitor); //set connectors - D3Q27InterpolationProcessorPtr iProcessor(new D3Q27IncompressibleOffsetInterpolationProcessor()); - D3Q27SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); + InterpolationProcessorPtr iProcessor(new IncompressibleOffsetInterpolationProcessor()); + SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); grid->accept(setConnsVisitor); if (myid == 0) UBLOG(logINFO, "Restart - end"); } UbSchedulerPtr visSch(new UbScheduler(outTime)); - MacroscopicQuantitiesCoProcessor pp(grid, visSch, pathname, WbWriterVtkXmlASCII::getInstance(), conv); + WriteMacroscopicQuantitiesCoProcessor pp(grid, visSch, pathname, WbWriterVtkXmlASCII::getInstance(), conv, comm); UbSchedulerPtr nupsSch(new UbScheduler(10, 30, 100)); NUPSCounterCoProcessor npr(grid, nupsSch, numOfThreads, comm); + //CalculationManagerPtr calculation(new CalculationManager(grid, numOfThreads, endTime, visSch,CalculationManager::PrePostBc)); CalculationManagerPtr calculation(new CalculationManager(grid, numOfThreads, endTime, visSch)); if (myid == 0) UBLOG(logINFO, "Simulation-start"); calculation->calculate(); diff --git a/source/Applications/aperm/PA200-250-50_800MPI.cfg b/source/Applications/aperm/PA200-250-50_800MPI.cfg new file mode 100644 index 000000000..71251b1dd --- /dev/null +++ b/source/Applications/aperm/PA200-250-50_800MPI.cfg @@ -0,0 +1,53 @@ +pathname = /hpc3lustre/work/koskuche/SFB880/Permeability/anisotropic/PA200-250-50_800MPI +pathGeo = /hpc3lustre/work/koskuche/SFB880/Materials/anisotropic + +numOfThreads = 1 +availMem = 11e9 +logToFile = true + +#porous media +rawFile = true +sampleFilename = /PA_200-250-50%_gewalzt_1575x1616x1643_32922.raw + +#diminsions [voxel] +pmNX1 = 1575 +pmNX2 = 1616 +pmNX3 = 1643 + +#threshold +lthreshold = 32922 +uthreshold = 65535 + +#diminsions [m] +pmL1 = 15.75e-3 +pmL2 = 16.16e-3 +pmL3 = 16.43e-3 + +#grid +blocknx = 32 +nx3 = 10 +deltax = 20e-6 +spongeLayer=false + +#physic +newPressure = false +dp_LB = 1e-7 +newViscosity = false +nu_LB = 0.0005 + +timeSeriesFile = /timeseries/1 +timeSeriesOutTime = 1000 + +gridPrepare = true +numOfParts = 800 + +restartStep = 50000 +restartStepStart=50000 +flowInit = true + +endTime = 800000 +outTime = 50000 + +nupsStep = 1000 1000 10000000 + + diff --git a/source/Applications/aperm/PA80-110+120-150_MPI.cfg b/source/Applications/aperm/PA80-110+120-150_MPI.cfg new file mode 100644 index 000000000..5439c48c6 --- /dev/null +++ b/source/Applications/aperm/PA80-110+120-150_MPI.cfg @@ -0,0 +1,59 @@ +pathname = /hpc3lustre/work/koskuche/SFB880/Permeability/anisotropic/PA80-110+120-150_MPI +pathGeo = /hpc3lustre/work/koskuche/SFB880/Materials/anisotropic + +numOfThreads = 1 +availMem = 11e9 +logToFile = true + +#porous media +rawFile = false +#sampleFilename = /PA_80-110+120-150_1824x1735x1603_8656.raw +sampleFilename = /vtk/PA80-110+120-150_1600x1600x1600_8656.vti + +#diminsions [voxel] +pmNX1 = 1600 +pmNX2 = 1600 +pmNX3 = 1600 + +#threshold +lthreshold = 8656 +uthreshold = 30294 + +#diminsions [m] +pmL1 = 16e-3 +pmL2 = 16e-3 +pmL3 = 16e-3 + +pmDeltas = true + +#deltas [m] +pmDeltaX1 = 0.01e-3 +pmDeltaX2 = 0.01e-3 +pmDeltaX3 = 0.01e-3 + +yDir = false +zDir = false + +#grid +blocknx = 32 +nx3 = 10 +deltax = 16e-6 +spongeLayer=false + +#physic +dp_LB = 1e-6 +nu_LB = 0.0005 + +timeSeriesFile = /timeseries/1 +timeSeriesOutTime = 1000 + +restartStep = 50000 +restartStepStart=50000 + +endTime = 800000 +outTime = 50000 + +nupsStep = 1000 1000 10000000 + +gridPrepare = false +numOfParts = 800 diff --git a/source/Applications/aperm/PA80-110+120-150_dx80.cfg b/source/Applications/aperm/PA80-110+120-150_dx80.cfg new file mode 100644 index 000000000..6ef5c8894 --- /dev/null +++ b/source/Applications/aperm/PA80-110+120-150_dx80.cfg @@ -0,0 +1,63 @@ +pathname = d:/temp/apermPA80-110+120-150 +pathGeo = f:/ + +numOfThreads = 4 +availMem = 11e9 +logToFile = flse + +#porous media +rawFile = false +sampleFilename = /PA80-110+120-150_1600x1600x1600_8656.vti + +#diminsions [voxel] +pmNX1 = 1600 +pmNX2 = 1600 +pmNX3 = 1600 + +#threshold +lthreshold = 8656 +uthreshold = 30294 + +#diminsions [m] +pmL1 = 16e-3 +pmL2 = 16e-3 +pmL3 = 16e-3 + +pmDeltas = true + +#deltas [m] +pmDeltaX1 = 0.01e-3 +pmDeltaX2 = 0.01e-3 +pmDeltaX3 = 0.01e-3 + +yDir = false +zDir = false + +#grid +blocknx = 32 +nx3 = 10 +deltax = 80e-6 +spongeLayer=false + +#physic +newPressure = false +dp_LB = 1e-6 + +newViscosity = false +nu_LB = 0.0005 + +vx1=0 +vx2=0 +vx3=0 + +timeSeriesFile = /timeseries/1 +timeSeriesOutTime = 1000 + +restartStep = 50000 +restartStepStart=50000 + +endTime = 800000 +outTime = 50000 + +nupsStep = 1000 1000 10000000 + diff --git a/source/Applications/aperm/aperm.cpp b/source/Applications/aperm/aperm.cpp index 327d63564..c549e58f0 100644 --- a/source/Applications/aperm/aperm.cpp +++ b/source/Applications/aperm/aperm.cpp @@ -42,9 +42,18 @@ void run(string configname) bool logToFile = config.getBool("logToFile"); bool spongeLayer = config.getBool("spongeLayer"); vector<double> nupsStep = config.getVector<double>("nupsStep"); - int numOfParts = config.getInt("numOfParts"); - bool gridPrepare = config.getBool("gridPrepare"); double deltax = config.getDouble("deltax"); + bool newViscosity = config.getBool("newViscosity"); + bool newPressure = config.getBool("newPressure"); + bool pmDeltas = config.getBool("pmDeltas"); + double pmDeltaX1 = config.getDouble("pmDeltaX1"); + double pmDeltaX2 = config.getDouble("pmDeltaX2"); + double pmDeltaX3 = config.getDouble("pmDeltaX3"); + double vx1 = config.getDouble("vx1"); + double vx2 = config.getDouble("vx2"); + double vx3 = config.getDouble("vx3"); + bool yDir = config.getBool("yDir"); + bool zDir = config.getBool("zDir"); CommunicatorPtr comm = MPICommunicator::getInstance(); int myid = comm->getProcessID(); @@ -52,30 +61,30 @@ void run(string configname) if (logToFile) { #if defined(__unix__) - if (myid == 0) + if (myid==0) { const char* str = pathname.c_str(); - int status = mkdir(str, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + int status = mkdir(str, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH); } #endif - if (myid == 0) + if (myid==0) { stringstream logFilename; - logFilename << pathname + "/logfile" + UbSystem::toString(UbSystem::getTimeStamp()) + ".txt"; + logFilename<<pathname+"/logfile"+UbSystem::toString(UbSystem::getTimeStamp())+".txt"; UbLog::output_policy::setStream(logFilename.str()); } } - Sleep(30000); + //Sleep(30000); - if (myid == 0) UBLOG(logINFO, "Testcase permeability"); + if (myid==0) UBLOG(logINFO, "Testcase permeability"); string machinename = UbSystem::getMachineName(); - UBLOG(logINFO, "PID = " << myid << " Hostname: " << machinename); - UBLOG(logINFO, "PID = " << myid << " Total Physical Memory (RAM): " << Utilities::getTotalPhysMem()); - UBLOG(logINFO, "PID = " << myid << " Physical Memory currently used: " << Utilities::getPhysMemUsed()); - UBLOG(logINFO, "PID = " << myid << " Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe()); + //UBLOG(logINFO, "PID = " << myid << " Hostname: " << machinename); + //UBLOG(logINFO, "PID = " << myid << " Total Physical Memory (RAM): " << Utilities::getTotalPhysMem()); + //UBLOG(logINFO, "PID = " << myid << " Physical Memory currently used: " << Utilities::getPhysMemUsed()); + //UBLOG(logINFO, "PID = " << myid << " Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe()); int blocknx1 = blocknx; int blocknx2 = blocknx; @@ -99,21 +108,48 @@ void run(string configname) RestartCoProcessor rp(grid, rSch, comm, pathname, RestartCoProcessor::TXT); ////////////////////////////////////////////////////////////////////////// - if (gridPrepare) + //BC Adapter + ////////////////////////////////////////////////////////////////////////////// + BCAdapterPtr noSlipBCAdapter(new NoSlipBCAdapter()); + noSlipBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new ThinWallNoSlipBCAlgorithm())); + //noSlipBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new NoSlipBCAlgorithm())); + + BCAdapterPtr denBCAdapterInflow(new DensityBCAdapter(rhoLBinflow)); + denBCAdapterInflow->setBcAlgorithm(BCAlgorithmPtr(new NonEqDensityBCAlgorithm())); + + BCAdapterPtr denBCAdapterOutflow(new DensityBCAdapter(rho_LB)); + denBCAdapterOutflow->setBcAlgorithm(BCAlgorithmPtr(new NonEqDensityBCAlgorithm())); + ////////////////////////////////////////////////////////////////////////////////// + //BS visitor + BoundaryConditionsBlockVisitor bcVisitor; + bcVisitor.addBC(noSlipBCAdapter); + bcVisitor.addBC(denBCAdapterInflow); + bcVisitor.addBC(denBCAdapterOutflow); + + if (grid->getTimeStep() == 0) { - if (myid == 0) UBLOG(logINFO, "new start.."); + if (myid==0) UBLOG(logINFO, "new start.."); + if (myid==0) UBLOG(logINFO, "preprocess start.."); - UBLOG(logINFO, "new start PID = " << myid << " Hostname: " << machinename); - UBLOG(logINFO, "new start PID = " << myid << " Total Physical Memory (RAM): " << Utilities::getTotalPhysMem()); - UBLOG(logINFO, "new start PID = " << myid << " Physical Memory currently used: " << Utilities::getPhysMemUsed()); - UBLOG(logINFO, "new start PID = " << myid << " Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe()); + //UBLOG(logINFO, "new start PID = " << myid << " Hostname: " << machinename); + //UBLOG(logINFO, "new start PID = " << myid << " Total Physical Memory (RAM): " << Utilities::getTotalPhysMem()); + //UBLOG(logINFO, "new start PID = " << myid << " Physical Memory currently used: " << Utilities::getPhysMemUsed()); + //UBLOG(logINFO, "new start PID = " << myid << " Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe()); - string samplePathname = pathGeo + sampleFilename; + string samplePathname = pathGeo+sampleFilename; double deltaVoxelX1 = pmL1/(double)pmNX1; double deltaVoxelX2 = pmL2/(double)pmNX2; double deltaVoxelX3 = pmL3/(double)pmNX3; + if (pmDeltas) + { + deltaVoxelX1 = pmDeltaX1; + deltaVoxelX2 = pmDeltaX2; + deltaVoxelX3 = pmDeltaX3; + } + + if (myid==0) UBLOG(logINFO, "read voxel matrix: start"); GbVoxelMatrix3DPtr sample(new GbVoxelMatrix3D(pmNX1, pmNX2, pmNX3, 0, lthreshold, uthreshold)); if (rawFile) { @@ -126,33 +162,49 @@ void run(string configname) sample->setVoxelMatrixDelta((float)deltaVoxelX1, (float)deltaVoxelX2, (float)deltaVoxelX3); sample->setVoxelMatrixMininum(0.0, 0.0, 0.0); + if (myid==0) UBLOG(logINFO, "read voxel matrix: end"); + - if (myid == 0) sample->writeToVTKImageDataASCII(pathname + "/geo/sample"); + if (myid==0) UBLOG(logINFO, "rotate voxel matrix: start"); + if (yDir) + { + sample->rotate90aroundZ(); + //sample->rotate90aroundZ(); + //sample->rotate90aroundZ(); + } + if (zDir) + { + sample->rotate90aroundY(); + } + if (myid==0) UBLOG(logINFO, "rotate voxel matrix: end"); + if (myid==0) sample->writeToVTKImageDataASCII(pathname+"/geo/sample"); + /////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// double offset1 = sample->getLengthX1()/10.0; double offset2 = 2.0*offset1; + //double offset2 = offset1; //bounding box - double g_minX1 = sample->getX1Minimum() - offset1; + double g_minX1 = sample->getX1Minimum()-offset1; double g_minX2 = sample->getX2Minimum(); double g_minX3 = sample->getX3Minimum(); - double g_maxX1 = sample->getX1Maximum() + offset2; + double g_maxX1 = sample->getX1Maximum()+offset2; double g_maxX2 = sample->getX2Maximum(); double g_maxX3 = sample->getX3Maximum(); - ////////////////////////////////////////////////////////////////////////// - double nx3_temp = floor((g_maxX3-g_minX3)/(deltax*(double)blocknx3)); + //////////////////////////////////////////////////////////////////////////// + double nx1_temp = floor((g_maxX1-g_minX1)/(deltax*(double)blocknx)); - deltax = (g_maxX3-g_minX3)/(nx3_temp*(double)blocknx3); + deltax = (g_maxX1-g_minX1)/(nx1_temp*(double)blocknx); - //g_maxX3 -= 0.5* deltax; - ////////////////////////////////////////////////////////////////////////// + // g_maxX3 -= 0.5* deltax; + //////////////////////////////////////////////////////////////////////////// - //deltax = (g_maxX3-g_minX3) /(nx3*blocknx3); + ////deltax = (g_maxX3-g_minX3) /(nx3*blocknx3); double blockLength = (double)blocknx1*deltax; @@ -163,72 +215,68 @@ void run(string configname) grid->setBlockNX(blocknx1, blocknx2, blocknx3); GbObject3DPtr gridCube(new GbCuboid3D(g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3)); - if (myid == 0) GbSystem3D::writeGeoObject(gridCube.get(), pathname + "/geo/gridCube", WbWriterVtkXmlBinary::getInstance()); + if (myid==0) GbSystem3D::writeGeoObject(gridCube.get(), pathname+"/geo/gridCube", WbWriterVtkXmlBinary::getInstance()); GenBlocksGridVisitor genBlocks(gridCube); grid->accept(genBlocks); - if (myid == 0) + if (myid==0) { UBLOG(logINFO, "Parameters:"); - UBLOG(logINFO, "rho_LB = " << rho_LB); - UBLOG(logINFO, "nu_LB = " << nu_LB); - UBLOG(logINFO, "dp_LB = " << dp_LB); - UBLOG(logINFO, "dx = " << deltax << " m"); - UBLOG(logINFO, "numOfThreads = " << numOfThreads); - UBLOG(logINFO, "path = " << pathname); + UBLOG(logINFO, "rho_LB = "<<rho_LB); + UBLOG(logINFO, "nu_LB = "<<nu_LB); + UBLOG(logINFO, "dp_LB = "<<dp_LB); + UBLOG(logINFO, "dx = "<<deltax<<" m"); + UBLOG(logINFO, "numOfThreads = "<<numOfThreads); + UBLOG(logINFO, "path = "<<pathname); UBLOG(logINFO, "Preprozess - start"); } //walls GbCuboid3DPtr addWallYmin(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_minX2, g_maxX3+blockLength)); - if (myid == 0) GbSystem3D::writeGeoObject(addWallYmin.get(), pathname+"/geo/addWallYmin", WbWriterVtkXmlASCII::getInstance()); + if (myid==0) GbSystem3D::writeGeoObject(addWallYmin.get(), pathname+"/geo/addWallYmin", WbWriterVtkXmlASCII::getInstance()); GbCuboid3DPtr addWallZmin(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_minX3)); - if (myid == 0) GbSystem3D::writeGeoObject(addWallZmin.get(), pathname+"/geo/addWallZmin", WbWriterVtkXmlASCII::getInstance()); + if (myid==0) GbSystem3D::writeGeoObject(addWallZmin.get(), pathname+"/geo/addWallZmin", WbWriterVtkXmlASCII::getInstance()); GbCuboid3DPtr addWallYmax(new GbCuboid3D(g_minX1-blockLength, g_maxX2, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); - if (myid == 0) GbSystem3D::writeGeoObject(addWallYmax.get(), pathname+"/geo/addWallYmax", WbWriterVtkXmlASCII::getInstance()); + if (myid==0) GbSystem3D::writeGeoObject(addWallYmax.get(), pathname+"/geo/addWallYmax", WbWriterVtkXmlASCII::getInstance()); GbCuboid3DPtr addWallZmax(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_maxX3, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); - if (myid == 0) GbSystem3D::writeGeoObject(addWallZmax.get(), pathname+"/geo/addWallZmax", WbWriterVtkXmlASCII::getInstance()); + if (myid==0) GbSystem3D::writeGeoObject(addWallZmax.get(), pathname+"/geo/addWallZmax", WbWriterVtkXmlASCII::getInstance()); //inflow GbCuboid3DPtr geoInflow(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_minX1, g_maxX2+blockLength, g_maxX3+blockLength)); - if (myid == 0) GbSystem3D::writeGeoObject(geoInflow.get(), pathname + "/geo/geoInflow", WbWriterVtkXmlASCII::getInstance()); + if (myid==0) GbSystem3D::writeGeoObject(geoInflow.get(), pathname+"/geo/geoInflow", WbWriterVtkXmlASCII::getInstance()); //outflow GbCuboid3DPtr geoOutflow(new GbCuboid3D(g_maxX1, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); - if (myid == 0) GbSystem3D::writeGeoObject(geoOutflow.get(), pathname + "/geo/geoOutflow", WbWriterVtkXmlASCII::getInstance()); + if (myid==0) GbSystem3D::writeGeoObject(geoOutflow.get(), pathname+"/geo/geoOutflow", WbWriterVtkXmlASCII::getInstance()); WriteBlocksCoProcessorPtr ppblocks(new WriteBlocksCoProcessor(grid, UbSchedulerPtr(new UbScheduler(1)), pathname, WbWriterVtkXmlBinary::getInstance(), comm)); - //bone interactor - int bcOptionNoSlip = 1; //0=simple Bounce Back, 1=quadr. BB, 2=thin wall - D3Q27BoundaryConditionAdapterPtr bcNoSlip(new D3Q27NoSlipBCAdapter(bcOptionNoSlip)); - D3Q27InteractorPtr sampleInt(new D3Q27Interactor(sample, grid, bcNoSlip, Interactor3D::SOLID)); + + //PM interactor + D3Q27InteractorPtr sampleInt(new D3Q27Interactor(sample, grid, noSlipBCAdapter, Interactor3D::SOLID)); //wall interactors - D3Q27InteractorPtr addWallYminInt(new D3Q27Interactor(addWallYmin, grid, bcNoSlip, Interactor3D::SOLID)); - D3Q27InteractorPtr addWallZminInt(new D3Q27Interactor(addWallZmin, grid, bcNoSlip, Interactor3D::SOLID)); - D3Q27InteractorPtr addWallYmaxInt(new D3Q27Interactor(addWallYmax, grid, bcNoSlip, Interactor3D::SOLID)); - D3Q27InteractorPtr addWallZmaxInt(new D3Q27Interactor(addWallZmax, grid, bcNoSlip, Interactor3D::SOLID)); + D3Q27InteractorPtr addWallYminInt(new D3Q27Interactor(addWallYmin, grid, noSlipBCAdapter, Interactor3D::SOLID)); + D3Q27InteractorPtr addWallZminInt(new D3Q27Interactor(addWallZmin, grid, noSlipBCAdapter, Interactor3D::SOLID)); + D3Q27InteractorPtr addWallYmaxInt(new D3Q27Interactor(addWallYmax, grid, noSlipBCAdapter, Interactor3D::SOLID)); + D3Q27InteractorPtr addWallZmaxInt(new D3Q27Interactor(addWallZmax, grid, noSlipBCAdapter, Interactor3D::SOLID)); + - D3Q27BoundaryConditionAdapterPtr denBCAdapterInflow(new D3Q27DensityBCAdapter(rhoLBinflow)); - denBCAdapterInflow->setSecondaryBcOption(0); D3Q27InteractorPtr inflowInt = D3Q27InteractorPtr(new D3Q27Interactor(geoInflow, grid, denBCAdapterInflow, Interactor3D::SOLID)); //outflow - D3Q27BoundaryConditionAdapterPtr denBCAdapterOutflow(new D3Q27DensityBCAdapter(rho_LB)); - denBCAdapterOutflow->setSecondaryBcOption(0); D3Q27InteractorPtr outflowInt = D3Q27InteractorPtr(new D3Q27Interactor(geoOutflow, grid, denBCAdapterOutflow, Interactor3D::SOLID)); - - UBLOG(logINFO, "PID = " << myid << " Hostname: " << machinename); - UBLOG(logINFO, "PID = " << myid << " Total Physical Memory (RAM): " << Utilities::getTotalPhysMem()); - UBLOG(logINFO, "PID = " << myid << " Physical Memory currently used: " << Utilities::getPhysMemUsed()); - UBLOG(logINFO, "PID = " << myid << " Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe()); + + //UBLOG(logINFO, "PID = "<<myid<<" Hostname: "<<machinename); + //UBLOG(logINFO, "PID = "<<myid<<" Total Physical Memory (RAM): "<<Utilities::getTotalPhysMem()); + //UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used: "<<Utilities::getPhysMemUsed()); + //UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()); //////////////////////////////////////////// @@ -240,7 +288,7 @@ void run(string configname) //grid->accept(zoltanVisitor); /////delete solid blocks - if (myid == 0) UBLOG(logINFO, "deleteSolidBlocks - start"); + if (myid==0) UBLOG(logINFO, "deleteSolidBlocks - start"); InteractorsHelper intHelper(grid, metisVisitor); intHelper.addInteractor(addWallYminInt); intHelper.addInteractor(addWallZminInt); @@ -250,12 +298,12 @@ void run(string configname) intHelper.addInteractor(outflowInt); intHelper.addInteractor(sampleInt); intHelper.selectBlocks(); - if (myid == 0) UBLOG(logINFO, "deleteSolidBlocks - end"); + if (myid==0) UBLOG(logINFO, "deleteSolidBlocks - end"); ////////////////////////////////////// //set connectors - D3Q27InterpolationProcessorPtr iProcessor(new D3Q27IncompressibleOffsetInterpolationProcessor()); - D3Q27SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nu_LB, iProcessor); + InterpolationProcessorPtr iProcessor(new IncompressibleOffsetInterpolationProcessor()); + SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nu_LB, iProcessor); grid->accept(setConnsVisitor); //domain decomposition for threads @@ -264,44 +312,38 @@ void run(string configname) ppblocks->process(0); ppblocks.reset(); - + unsigned long nob = grid->getNumberOfBlocks(); int gl = 3; unsigned long nodb = (blocknx1)* (blocknx2)* (blocknx3); unsigned long nod = nob * (blocknx1)* (blocknx2)* (blocknx3); - unsigned long nodg = nob * (blocknx1 + gl) * (blocknx2 + gl) * (blocknx3 + gl); - double needMemAll = double(nodg*(27 * sizeof(double) + sizeof(int) + sizeof(float) * 4)); - double needMem = needMemAll / double(comm->getNumberOfProcesses()); + unsigned long nodg = nob * (blocknx1+gl) * (blocknx2+gl) * (blocknx3+gl); + double needMemAll = double(nodg*(27*sizeof(double)+sizeof(int)+sizeof(float)*4)); + double needMem = needMemAll/double(comm->getNumberOfProcesses()); - if (myid == 0) + if (myid==0) { - UBLOG(logINFO, "Number of blocks = " << nob); - UBLOG(logINFO, "Number of nodes = " << nod); + UBLOG(logINFO, "Number of blocks = "<<nob); + UBLOG(logINFO, "Number of nodes = "<<nod); int minInitLevel = grid->getCoarsestInitializedLevel(); int maxInitLevel = grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) + for (int level = minInitLevel; level<=maxInitLevel; level++) { int nobl = grid->getNumberOfBlocks(level); - UBLOG(logINFO, "Number of blocks for level " << level << " = " << nobl); - UBLOG(logINFO, "Number of nodes for level " << level << " = " << nobl*nodb); + UBLOG(logINFO, "Number of blocks for level "<<level<<" = "<<nobl); + UBLOG(logINFO, "Number of nodes for level "<<level<<" = "<<nobl*nodb); } - UBLOG(logINFO, "Necessary memory = " << needMemAll << " bytes"); - UBLOG(logINFO, "Necessary memory per process = " << needMem << " bytes"); - UBLOG(logINFO, "Available memory per process = " << availMem << " bytes"); + UBLOG(logINFO, "Necessary memory = "<<needMemAll<<" bytes"); + UBLOG(logINFO, "Necessary memory per process = "<<needMem<<" bytes"); + UBLOG(logINFO, "Available memory per process = "<<availMem<<" bytes"); } - LBMKernel3DPtr kernel; - //kernel = LBMKernel3DPtr(new LBMKernelETD3Q27CCLB(blocknx1, blocknx2, blocknx3, LBMKernelETD3Q27CCLB::NORMAL)); - kernel = LBMKernel3DPtr(new VoidLBMKernel(blocknx1, blocknx2, blocknx3)); - BCProcessorPtr bcProc(new D3Q27ETBCProcessor()); - - BoundaryConditionPtr densityBC(new NonEqDensityBoundaryCondition()); - BoundaryConditionPtr noSlipBC(new NoSlipBoundaryCondition()); - - bcProc->addBC(densityBC); - bcProc->addBC(noSlipBC); + LBMKernelPtr kernel; + kernel = LBMKernelPtr(new IncompressibleCumulantLBMKernel(blocknx1, blocknx2, blocknx3, IncompressibleCumulantLBMKernel::NORMAL)); + //BCProcessorPtr bcProc(new BCProcessor()); + BCProcessorPtr bcProc = BCProcessorPtr(new ThinWallBCProcessor()); kernel->setBCProcessor(bcProc); SetKernelBlockVisitor kernelVisitor(kernel, nu_LB, availMem, needMem); @@ -310,27 +352,27 @@ void run(string configname) //BC intHelper.setBC(); - //BoundaryConditionBlockVisitor bcVisitor; - //grid->accept(bcVisitor); + //BS visitor + grid->accept(bcVisitor); //Press*1.6e8+(14.76-coordsX)/3.5*5000 //initialization of distributions - //mu::Parser fct; - //fct.SetExpr("(x1max-x1)/l*dp*3.0"); - //fct.DefineConst("dp", dp_LB); - //fct.DefineConst("x1max", g_maxX1); - //fct.DefineConst("l", g_maxX1-g_minX1); + mu::Parser fct; + fct.SetExpr("(x1max-x1)/l*dp*3.0"); + fct.DefineConst("dp", dp_LB); + fct.DefineConst("x1max", g_maxX1); + fct.DefineConst("l", g_maxX1-g_minX1); - //D3Q27ETInitDistributionsBlockVisitor initVisitor(nu_LB, rho_LB); - //initVisitor.setRho(fct); - //grid->accept(initVisitor); + InitDistributionsBlockVisitor initVisitor(nu_LB, rho_LB); + initVisitor.setRho(fct); + grid->accept(initVisitor); //Postrozess - //UbSchedulerPtr geoSch(new UbScheduler(1)); - //MacroscopicQuantitiesCoProcessorPtr ppgeo( - // new MacroscopicQuantitiesCoProcessor(grid, geoSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, true)); - //ppgeo->process(0); - //ppgeo.reset(); + UbSchedulerPtr geoSch(new UbScheduler(1)); + WriteBoundaryConditionsCoProcessorPtr ppgeo( + new WriteBoundaryConditionsCoProcessor(grid, geoSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, comm)); + ppgeo->process(0); + ppgeo.reset(); coord[0] = sample->getX1Minimum(); coord[1] = sample->getX2Minimum(); @@ -340,7 +382,7 @@ void run(string configname) coord[5] = sample->getX3Maximum(); //////////////////////////////////////////////////////// - UbFileOutputASCII outf(pathname + "/checkpoints/coord.txt"); + UbFileOutputASCII outf(pathname+"/checkpoints/coord.txt"); outf.writeDouble(deltax); outf.writeDouble(coord[0]); outf.writeDouble(coord[1]); @@ -356,22 +398,13 @@ void run(string configname) grid->addInteractor(inflowInt); - - if (myid == 0) UBLOG(logINFO, "Preprozess - end"); - - if (comm->getNumberOfProcesses() == 1) - { - UBLOG(logINFO, "Prepare grid - start"); - rp.writeDistributedGrid(grid, numOfParts); - UBLOG(logINFO, "Prepare grid - end"); - return; - } + if (myid==0) UBLOG(logINFO, "Preprozess - end"); } else { //////////////////////////////////////////////////////// UbFileInputASCII inf(pathname+"/checkpoints/coord.txt"); - deltax = inf.readDouble(); + deltax = inf.readDouble(); coord[0] = inf.readDouble(); coord[1] = inf.readDouble(); coord[2] = inf.readDouble(); @@ -384,119 +417,105 @@ void run(string configname) double needMem = inf.readDouble(); //////////////////////////////////////////////////////// - LBMKernel3DPtr kernel = LBMKernel3DPtr(new LBMKernelETD3Q27CCLB(blocknx1, blocknx2, blocknx3, LBMKernelETD3Q27CCLB::NORMAL)); - BCProcessorPtr bcProc(new D3Q27ETBCProcessor()); - kernel->setBCProcessor(bcProc); - SetKernelBlockVisitor kernelVisitor(kernel, nu_LB, availMem, needMem, SetKernelBlockVisitor::ChangeBC); - grid->accept(kernelVisitor); - - BoundaryConditionBlockVisitor bcVisitor; - grid->accept(bcVisitor); - - //Press*1.6e8+(14.76-coordsX)/3.5*5000 - //initialization of distributions - mu::Parser fct; - fct.SetExpr("(x1max-x1)/l*dp*3.0"); - fct.DefineConst("dp", dp_LB); - fct.DefineConst("x1max", g_maxX1); - fct.DefineConst("l", g_maxX1-g_minX1); - - D3Q27ETInitDistributionsBlockVisitor initVisitor(nu_LB, rho_LB); - initVisitor.setRho(fct); - grid->accept(initVisitor); - //new nu - //ViscosityBlockVisitor nuVisitor(nu_LB); - //grid->accept(nuVisitor); + if (newViscosity) + { + ViscosityBlockVisitor nuVisitor(nu_LB); + grid->accept(nuVisitor); + } //new dp - Grid3D::Interactor3DSet interactors = grid->getInteractors(); - interactors[0]->setGrid3D(grid); - boost::dynamic_pointer_cast<D3Q27Interactor>(interactors[0])->deleteBCAdapter(); - D3Q27BoundaryConditionAdapterPtr denBCAdapterFront(new D3Q27DensityBCAdapter(rhoLBinflow)); - boost::dynamic_pointer_cast<D3Q27Interactor>(interactors[0])->addBCAdapter(denBCAdapterFront); - interactors[0]->updateInteractor(); - - if (myid == 0) + if (newPressure) { - UBLOG(logINFO, "Parameters:"); - UBLOG(logINFO, "rho_LB = " << rho_LB); - UBLOG(logINFO, "nu_LB = " << nu_LB); - UBLOG(logINFO, "dp_LB = " << dp_LB); - UBLOG(logINFO, "dx = " << deltax << " m"); + Grid3D::Interactor3DSet interactors = grid->getInteractors(); + interactors[0]->setGrid3D(grid); + boost::dynamic_pointer_cast<D3Q27Interactor>(interactors[0])->deleteBCAdapter(); + BCAdapterPtr denBCAdapterFront(new DensityBCAdapter(rhoLBinflow)); + denBCAdapterFront->setBcAlgorithm(BCAlgorithmPtr(new EqDensityBCAlgorithm())); + boost::dynamic_pointer_cast<D3Q27Interactor>(interactors[0])->addBCAdapter(denBCAdapterFront); + interactors[0]->updateInteractor(); + } + + if (myid==0) + { + UBLOG(logINFO, "Parameters:"); + UBLOG(logINFO, "rho_LB = "<<rho_LB); + UBLOG(logINFO, "nu_LB = "<<nu_LB); + UBLOG(logINFO, "dp_LB = "<<dp_LB); + UBLOG(logINFO, "dx = "<<deltax<<" m"); } //set connectors - D3Q27InterpolationProcessorPtr iProcessor(new D3Q27IncompressibleOffsetInterpolationProcessor()); - D3Q27SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nu_LB, iProcessor); + InterpolationProcessorPtr iProcessor(new IncompressibleOffsetInterpolationProcessor()); + SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nu_LB, iProcessor); grid->accept(setConnsVisitor); - //Postrozess - UbSchedulerPtr geoSch(new UbScheduler(1)); - MacroscopicQuantitiesCoProcessorPtr ppgeo( - new MacroscopicQuantitiesCoProcessor(grid, geoSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, true)); - ppgeo->process(0); - ppgeo.reset(); + //domain decomposition for threads + PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); + grid->accept(pqPartVisitor); - if (myid == 0) UBLOG(logINFO, "Restart - end"); + //BS visitor + grid->accept(bcVisitor); + + if (myid==0) UBLOG(logINFO, "Restart - end"); } + UbSchedulerPtr nupsSch(new UbScheduler(nupsStep[0], nupsStep[1], nupsStep[2])); - //nupsSch->addSchedule(nupsStep[0], nupsStep[1], nupsStep[2]); NUPSCounterCoProcessor npr(grid, nupsSch, numOfThreads, comm); UbSchedulerPtr stepSch(new UbScheduler(outTime)); - MacroscopicQuantitiesCoProcessor pp(grid, stepSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv); + WriteMacroscopicQuantitiesCoProcessor pp(grid, stepSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, comm); deltax = grid->getDeltaX(baseLevel); - double dxd2 = deltax / 2.0; + double dxd2 = deltax/2.0; - D3Q27IntegrateValuesHelperPtr ih1(new D3Q27IntegrateValuesHelper(grid, comm, coord[0] - dxd2*10.0, coord[1] - dxd2, coord[2] - dxd2, - coord[0] - dxd2*10.0 - 2.0*dxd2, coord[4] + dxd2, coord[5] + dxd2)); + IntegrateValuesHelperPtr ih1(new IntegrateValuesHelper(grid, comm, coord[0]-dxd2*10.0, coord[1]-dxd2, coord[2]-dxd2, + coord[0]-dxd2*10.0-2.0*dxd2, coord[4]+dxd2, coord[5]+dxd2)); //D3Q27IntegrateValuesHelperPtr ih2(new D3Q27IntegrateValuesHelper(grid, comm, coord[3]/2.0, coord[1] - dxd2, coord[2] - dxd2, // coord[3]/2.0 + 2.0*dxd2, coord[4] + dxd2, coord[5] + dxd2)); - D3Q27IntegrateValuesHelperPtr ih2(new D3Q27IntegrateValuesHelper(grid, comm, coord[0], coord[1], coord[2], coord[3], coord[4], coord[5])); + IntegrateValuesHelperPtr ih2(new IntegrateValuesHelper(grid, comm, coord[0], coord[1], coord[2], coord[3], coord[4], coord[5])); - D3Q27IntegrateValuesHelperPtr ih3(new D3Q27IntegrateValuesHelper(grid, comm, coord[3] + dxd2*10.0, coord[1] - dxd2, coord[2] - dxd2, - coord[3] + dxd2*10.0 + 2.0*dxd2, coord[4] + dxd2, coord[5] + dxd2)); + IntegrateValuesHelperPtr ih3(new IntegrateValuesHelper(grid, comm, coord[3]+dxd2*10.0, coord[1]-dxd2, coord[2]-dxd2, + coord[3]+dxd2*10.0+2.0*dxd2, coord[4]+dxd2, coord[5]+dxd2)); //D3Q27IntegrateValuesHelperPtr ih1(new D3Q27IntegrateValuesHelper(grid, comm, coord[0], coord[1], coord[2], coord[3], coord[4], coord[5])); - if (myid == 0) GbSystem3D::writeGeoObject(ih1->getBoundingBox().get(), pathname + "/geo/ih1", WbWriterVtkXmlBinary::getInstance()); - if (myid == 0) GbSystem3D::writeGeoObject(ih2->getBoundingBox().get(), pathname + "/geo/ih2", WbWriterVtkXmlBinary::getInstance()); - if (myid == 0) GbSystem3D::writeGeoObject(ih3->getBoundingBox().get(), pathname + "/geo/ih3", WbWriterVtkXmlBinary::getInstance()); + if (myid==0) GbSystem3D::writeGeoObject(ih1->getBoundingBox().get(), pathname+"/geo/ih1", WbWriterVtkXmlBinary::getInstance()); + if (myid==0) GbSystem3D::writeGeoObject(ih2->getBoundingBox().get(), pathname+"/geo/ih2", WbWriterVtkXmlBinary::getInstance()); + if (myid==0) GbSystem3D::writeGeoObject(ih3->getBoundingBox().get(), pathname+"/geo/ih3", WbWriterVtkXmlBinary::getInstance()); double factorp = 1; // dp_real / dp_LB; double factorv = 1;// dx / dt; UbSchedulerPtr stepMV(new UbScheduler(timeSeriesOutTime)); - + TimeseriesCoProcessor tsp1(grid, stepMV, ih1, pathname+timeSeriesFile+"_1", comm); TimeseriesCoProcessor tsp2(grid, stepMV, ih2, pathname+timeSeriesFile+"_2", comm); TimeseriesCoProcessor tsp3(grid, stepMV, ih3, pathname+timeSeriesFile+"_3", comm); - if (myid == 0) + if (myid==0) { - UBLOG(logINFO, "PID = " << myid << " Total Physical Memory (RAM): " << Utilities::getTotalPhysMem()); - UBLOG(logINFO, "PID = " << myid << " Physical Memory currently used: " << Utilities::getPhysMemUsed()); - UBLOG(logINFO, "PID = " << myid << " Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe()); + UBLOG(logINFO, "PID = "<<myid<<" Total Physical Memory (RAM): "<<Utilities::getTotalPhysMem()); + UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used: "<<Utilities::getPhysMemUsed()); + UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()); } - CalculationManagerPtr calculation(new CalculationManager(grid, numOfThreads, endTime, stepMV)); - if (myid == 0) UBLOG(logINFO, "Simulation-start"); + CalculationManagerPtr calculation(new CalculationManager(grid, numOfThreads, endTime, stepSch)); + if (myid==0) UBLOG(logINFO, "Simulation-start"); calculation->calculate(); - if (myid == 0) UBLOG(logINFO, "Simulation-end"); + if (myid==0) UBLOG(logINFO, "Simulation-end"); } catch (exception& e) { - cerr << e.what() << endl << flush; + cerr<<e.what()<<endl<<flush; } catch (string& s) { - cerr << s << endl; + cerr<<s<<endl; } catch (...) { - cerr << "unknown exception" << endl; + cerr<<"unknown exception"<<endl; } } diff --git a/source/Applications/aperm/aperm.cpp.old b/source/Applications/aperm/aperm.cpp.old new file mode 100644 index 000000000..107294e3d --- /dev/null +++ b/source/Applications/aperm/aperm.cpp.old @@ -0,0 +1,573 @@ +#include <iostream> +#include <string> +#include <VirtualFluids.h> + +using namespace std; + +void changeDP() +{ +} +////////////////////////////////////////////////////////////////////////// +void run(string configname) +{ + try + { + ConfigurationFile config; + config.load(configname); + + string pathname = config.getString("pathname"); + string pathGeo = config.getString("pathGeo"); + int numOfThreads = config.getInt("numOfThreads"); + string sampleFilename = config.getString("sampleFilename"); + int pmNX1 = config.getInt("pmNX1"); + int pmNX2 = config.getInt("pmNX2"); + int pmNX3 = config.getInt("pmNX3"); + double lthreshold = config.getDouble("lthreshold"); + double uthreshold = config.getDouble("uthreshold"); + double pmL1 = config.getDouble("pmL1"); + double pmL2 = config.getDouble("pmL2"); + double pmL3 = config.getDouble("pmL3"); + int blocknx = config.getInt("blocknx"); + double nx3 = config.getDouble("nx3"); + double dp_LB = config.getDouble("dp_LB"); + double nu_LB = config.getDouble("nu_LB"); + string timeSeriesFile = config.getString("timeSeriesFile"); + double restartStep = config.getDouble("restartStep"); + double restartStepStart = config.getDouble("restartStepStart"); + double endTime = config.getDouble("endTime"); + double outTime = config.getDouble("outTime"); + double availMem = config.getDouble("availMem"); + bool rawFile = config.getBool("rawFile"); + double timeSeriesOutTime = config.getDouble("timeSeriesOutTime"); + bool logToFile = config.getBool("logToFile"); + bool spongeLayer = config.getBool("spongeLayer"); + vector<double> nupsStep = config.getVector<double>("nupsStep"); + int numOfParts = config.getInt("numOfParts"); + bool gridPrepare = config.getBool("gridPrepare"); + double deltax = config.getDouble("deltax"); + bool flowInit = config.getBool("flowInit"); + bool newViscosity = config.getBool("newViscosity"); + bool newPressure = config.getBool("newPressure"); + bool pmDeltas = config.getBool("pmDeltas"); + double pmDeltaX1 = config.getDouble("pmDeltaX1"); + double pmDeltaX2 = config.getDouble("pmDeltaX2"); + double pmDeltaX3 = config.getDouble("pmDeltaX3"); + double vx1 = config.getDouble("vx1"); + double vx2 = config.getDouble("vx2"); + double vx3 = config.getDouble("vx3"); + bool yDir = config.getBool("yDir"); + bool zDir = config.getBool("zDir"); + + CommunicatorPtr comm = MPICommunicator::getInstance(); + int myid = comm->getProcessID(); + + if (logToFile) + { +#if defined(__unix__) + if (myid == 0) + { + const char* str = pathname.c_str(); + int status = mkdir(str, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + } +#endif + + if (myid == 0) + { + stringstream logFilename; + logFilename << pathname + "/logfile" + UbSystem::toString(UbSystem::getTimeStamp()) + ".txt"; + UbLog::output_policy::setStream(logFilename.str()); + } + } + + //Sleep(30000); + + if (myid == 0) UBLOG(logINFO, "Testcase permeability"); + + string machinename = UbSystem::getMachineName(); + //UBLOG(logINFO, "PID = " << myid << " Hostname: " << machinename); + //UBLOG(logINFO, "PID = " << myid << " Total Physical Memory (RAM): " << Utilities::getTotalPhysMem()); + //UBLOG(logINFO, "PID = " << myid << " Physical Memory currently used: " << Utilities::getPhysMemUsed()); + //UBLOG(logINFO, "PID = " << myid << " Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe()); + + int blocknx1 = blocknx; + int blocknx2 = blocknx; + int blocknx3 = blocknx; + + LBMReal rho_LB = 0.0; + double rhoLBinflow = dp_LB*3.0; + + LBMUnitConverterPtr conv = LBMUnitConverterPtr(new LBMUnitConverter()); + + const int baseLevel = 0; + + double coord[6]; + //double deltax; + + Grid3DPtr grid(new Grid3D(comm)); + + ////////////////////////////////////////////////////////////////////////// + //restart + UbSchedulerPtr rSch(new UbScheduler(restartStep, restartStepStart)); + RestartCoProcessor rp(grid, rSch, comm, pathname, RestartCoProcessor::BINARY); + ////////////////////////////////////////////////////////////////////////// + + if (gridPrepare) + { + if (myid == 0) UBLOG(logINFO, "new start.."); + + UBLOG(logINFO, "new start PID = " << myid << " Hostname: " << machinename); + UBLOG(logINFO, "new start PID = " << myid << " Total Physical Memory (RAM): " << Utilities::getTotalPhysMem()); + UBLOG(logINFO, "new start PID = " << myid << " Physical Memory currently used: " << Utilities::getPhysMemUsed()); + UBLOG(logINFO, "new start PID = " << myid << " Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe()); + + string samplePathname = pathGeo + sampleFilename; + + double deltaVoxelX1 = pmL1/(double)pmNX1; + double deltaVoxelX2 = pmL2/(double)pmNX2; + double deltaVoxelX3 = pmL3/(double)pmNX3; + + if (pmDeltas) + { + deltaVoxelX1 = pmDeltaX1; + deltaVoxelX2 = pmDeltaX2; + deltaVoxelX3 = pmDeltaX3; + } + + GbVoxelMatrix3DPtr sample(new GbVoxelMatrix3D(pmNX1, pmNX2, pmNX3, 0, lthreshold, uthreshold)); + if (rawFile) + { + sample->readMatrixFromRawFile<unsigned short>(samplePathname, GbVoxelMatrix3D::BigEndian); + } + else + { + sample->readMatrixFromVtiASCIIFile(samplePathname); + } + + sample->setVoxelMatrixDelta((float)deltaVoxelX1, (float)deltaVoxelX2, (float)deltaVoxelX3); + sample->setVoxelMatrixMininum(0.0, 0.0, 0.0); + + if (yDir) + { + sample->rotate90aroundZ(); + sample->rotate90aroundZ(); + sample->rotate90aroundZ(); + } + if (zDir) + { + sample->rotate90aroundY(); + } + + if (myid == 0) sample->writeToVTKImageDataASCII(pathname + "/geo/sample"); + + /////////////////////////////////////////////////////// + + //////////////////////////////////////////////////////////////////////// + + double offset1 = sample->getLengthX1()/10.0; + double offset2 = 2.0*offset1; + //double offset2 = offset1; + //bounding box + double g_minX1 = sample->getX1Minimum() - offset1; + double g_minX2 = sample->getX2Minimum(); + double g_minX3 = sample->getX3Minimum(); + + double g_maxX1 = sample->getX1Maximum() + offset2; + double g_maxX2 = sample->getX2Maximum(); + double g_maxX3 = sample->getX3Maximum(); + + //////////////////////////////////////////////////////////////////////////// + double nx1_temp = floor((g_maxX1-g_minX1)/(deltax*(double)blocknx)); + + deltax = (g_maxX1-g_minX1)/(nx1_temp*(double)blocknx); + + // g_maxX3 -= 0.5* deltax; + //////////////////////////////////////////////////////////////////////////// + + ////deltax = (g_maxX3-g_minX3) /(nx3*blocknx3); + + double blockLength = (double)blocknx1*deltax; + + grid->setPeriodicX1(false); + grid->setPeriodicX2(false); + grid->setPeriodicX3(false); + grid->setDeltaX(deltax); + grid->setBlockNX(blocknx1, blocknx2, blocknx3); + + GbObject3DPtr gridCube(new GbCuboid3D(g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3)); + if (myid == 0) GbSystem3D::writeGeoObject(gridCube.get(), pathname + "/geo/gridCube", WbWriterVtkXmlBinary::getInstance()); + + GenBlocksGridVisitor genBlocks(gridCube); + grid->accept(genBlocks); + + if (myid == 0) + { + UBLOG(logINFO, "Parameters:"); + UBLOG(logINFO, "rho_LB = " << rho_LB); + UBLOG(logINFO, "nu_LB = " << nu_LB); + UBLOG(logINFO, "dp_LB = " << dp_LB); + UBLOG(logINFO, "dx = " << deltax << " m"); + UBLOG(logINFO, "numOfThreads = " << numOfThreads); + UBLOG(logINFO, "path = " << pathname); + UBLOG(logINFO, "Preprozess - start"); + } + + //walls + GbCuboid3DPtr addWallYmin(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_minX2, g_maxX3+blockLength)); + if (myid == 0) GbSystem3D::writeGeoObject(addWallYmin.get(), pathname+"/geo/addWallYmin", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr addWallZmin(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_minX3)); + if (myid == 0) GbSystem3D::writeGeoObject(addWallZmin.get(), pathname+"/geo/addWallZmin", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr addWallYmax(new GbCuboid3D(g_minX1-blockLength, g_maxX2, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); + if (myid == 0) GbSystem3D::writeGeoObject(addWallYmax.get(), pathname+"/geo/addWallYmax", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr addWallZmax(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_maxX3, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); + if (myid == 0) GbSystem3D::writeGeoObject(addWallZmax.get(), pathname+"/geo/addWallZmax", WbWriterVtkXmlASCII::getInstance()); + + + //inflow + GbCuboid3DPtr geoInflow(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_minX1, g_maxX2+blockLength, g_maxX3+blockLength)); + if (myid == 0) GbSystem3D::writeGeoObject(geoInflow.get(), pathname + "/geo/geoInflow", WbWriterVtkXmlASCII::getInstance()); + + //outflow + GbCuboid3DPtr geoOutflow(new GbCuboid3D(g_maxX1, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); + if (myid == 0) GbSystem3D::writeGeoObject(geoOutflow.get(), pathname + "/geo/geoOutflow", WbWriterVtkXmlASCII::getInstance()); + + WriteBlocksCoProcessorPtr ppblocks(new WriteBlocksCoProcessor(grid, UbSchedulerPtr(new UbScheduler(1)), pathname, WbWriterVtkXmlBinary::getInstance(), comm)); + + //PM interactor + BCAdapterPtr noSlipBCAdapter(new NoSlipBCAdapter()); + noSlipBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new ThinWallNoSlipBCAlgorithm())); + D3Q27InteractorPtr sampleInt(new D3Q27Interactor(sample, grid, noSlipBCAdapter, Interactor3D::SOLID)); + + //wall interactors + D3Q27InteractorPtr addWallYminInt(new D3Q27Interactor(addWallYmin, grid, noSlipBCAdapter, Interactor3D::SOLID)); + D3Q27InteractorPtr addWallZminInt(new D3Q27Interactor(addWallZmin, grid, noSlipBCAdapter, Interactor3D::SOLID)); + D3Q27InteractorPtr addWallYmaxInt(new D3Q27Interactor(addWallYmax, grid, noSlipBCAdapter, Interactor3D::SOLID)); + D3Q27InteractorPtr addWallZmaxInt(new D3Q27Interactor(addWallZmax, grid, noSlipBCAdapter, Interactor3D::SOLID)); + + BCAdapterPtr denBCAdapterInflow(new DensityBCAdapter(rhoLBinflow)); + denBCAdapterInflow->setBcAlgorithm(BCAlgorithmPtr(new EqDensityBCAlgorithm())); + D3Q27InteractorPtr inflowInt = D3Q27InteractorPtr(new D3Q27Interactor(geoInflow, grid, denBCAdapterInflow, Interactor3D::SOLID)); + + //outflow + BCAdapterPtr denBCAdapterOutflow(new DensityBCAdapter(rho_LB)); + denBCAdapterOutflow->setBcAlgorithm(BCAlgorithmPtr(new EqDensityBCAlgorithm())); + D3Q27InteractorPtr outflowInt = D3Q27InteractorPtr(new D3Q27Interactor(geoOutflow, grid, denBCAdapterOutflow, Interactor3D::SOLID)); + + + UBLOG(logINFO, "PID = " << myid << " Hostname: " << machinename); + UBLOG(logINFO, "PID = " << myid << " Total Physical Memory (RAM): " << Utilities::getTotalPhysMem()); + UBLOG(logINFO, "PID = " << myid << " Physical Memory currently used: " << Utilities::getPhysMemUsed()); + UBLOG(logINFO, "PID = " << myid << " Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe()); + + + //////////////////////////////////////////// + //METIS + Grid3DVisitorPtr metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::RECURSIVE)); + //////////////////////////////////////////// + //Zoltan + //Grid3DVisitorPtr zoltanVisitor(new ZoltanPartitioningGridVisitor(comm, D3Q27System::BSW, 1)); + //grid->accept(zoltanVisitor); + + /////delete solid blocks + if (myid == 0) UBLOG(logINFO, "deleteSolidBlocks - start"); + InteractorsHelper intHelper(grid, metisVisitor); + intHelper.addInteractor(addWallYminInt); + intHelper.addInteractor(addWallZminInt); + intHelper.addInteractor(addWallYmaxInt); + intHelper.addInteractor(addWallZmaxInt); + intHelper.addInteractor(inflowInt); + intHelper.addInteractor(outflowInt); + intHelper.addInteractor(sampleInt); + intHelper.selectBlocks(); + if (myid == 0) UBLOG(logINFO, "deleteSolidBlocks - end"); + ////////////////////////////////////// + + //set connectors + D3Q27InterpolationProcessorPtr iProcessor(new IncompressibleOffsetInterpolationProcessor()); + SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nu_LB, iProcessor); + grid->accept(setConnsVisitor); + + //domain decomposition for threads + PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); + grid->accept(pqPartVisitor); + + ppblocks->process(0); + ppblocks.reset(); + + + unsigned long nob = grid->getNumberOfBlocks(); + int gl = 3; + unsigned long nodb = (blocknx1)* (blocknx2)* (blocknx3); + unsigned long nod = nob * (blocknx1)* (blocknx2)* (blocknx3); + unsigned long nodg = nob * (blocknx1 + gl) * (blocknx2 + gl) * (blocknx3 + gl); + double needMemAll = double(nodg*(27 * sizeof(double) + sizeof(int) + sizeof(float) * 4)); + double needMem = needMemAll / double(comm->getNumberOfProcesses()); + + if (myid == 0) + { + UBLOG(logINFO, "Number of blocks = " << nob); + UBLOG(logINFO, "Number of nodes = " << nod); + int minInitLevel = grid->getCoarsestInitializedLevel(); + int maxInitLevel = grid->getFinestInitializedLevel(); + for (int level = minInitLevel; level <= maxInitLevel; level++) + { + int nobl = grid->getNumberOfBlocks(level); + UBLOG(logINFO, "Number of blocks for level " << level << " = " << nobl); + UBLOG(logINFO, "Number of nodes for level " << level << " = " << nobl*nodb); + } + UBLOG(logINFO, "Necessary memory = " << needMemAll << " bytes"); + UBLOG(logINFO, "Necessary memory per process = " << needMem << " bytes"); + UBLOG(logINFO, "Available memory per process = " << availMem << " bytes"); + } + + LBMKernelPtr kernel; + if (comm->getNumberOfProcesses()>1 && gridPrepare) + { + kernel = LBMKernelPtr(new IncompressibleCumulantLBMKernel(blocknx1, blocknx2, blocknx3, IncompressibleCumulantLBMKernel::NORMAL)); + } + else + { + kernel = LBMKernelPtr(new VoidLBMKernel(blocknx1, blocknx2, blocknx3)); + } + + //BCProcessorPtr bcProc(new D3Q27ETBCProcessor()); + BCProcessorPtr bcProc = BCProcessorPtr(new ThinWallBCProcessor()); + kernel->setBCProcessor(bcProc); + + SetKernelBlockVisitor kernelVisitor(kernel, nu_LB, availMem, needMem); + grid->accept(kernelVisitor); + + //BC + intHelper.setBC(); + + if (comm->getNumberOfProcesses()>1 && gridPrepare) + { + BoundaryConditionBlockVisitor bcVisitor; + //bcVisitor.addBC('N', BCAlgorithmPtr(new NoSlipBCAlgorithm())); + //bcVisitor.addBC('I', BCAlgorithmPtr(new EqDensityBCAlgorithm())); + //bcVisitor.addBC('O', BCAlgorithmPtr(new EqDensityBCAlgorithm())); + bcVisitor.addBC(noSlipBCAdapter); + bcVisitor.addBC(denBCAdapterInflow); + bcVisitor.addBC(denBCAdapterOutflow); + grid->accept(bcVisitor); + + //Press*1.6e8+(14.76-coordsX)/3.5*5000 + //initialization of distributions + mu::Parser fct; + fct.SetExpr("(x1max-x1)/l*dp*3.0"); + fct.DefineConst("dp", dp_LB); + fct.DefineConst("x1max", g_maxX1); + fct.DefineConst("l", g_maxX1-g_minX1); + + InitDistributionsBlockVisitor initVisitor(nu_LB, rho_LB); + initVisitor.setRho(fct); + grid->accept(initVisitor); + + //Postrozess + UbSchedulerPtr geoSch(new UbScheduler(1)); + WriteBoundaryConditionsCoProcessorPtr ppgeo( + new WriteBoundaryConditionsCoProcessor(grid, geoSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, comm)); + ppgeo->process(0); + ppgeo.reset(); + } + + + coord[0] = sample->getX1Minimum(); + coord[1] = sample->getX2Minimum(); + coord[2] = sample->getX3Minimum(); + coord[3] = sample->getX1Maximum(); + coord[4] = sample->getX2Maximum(); + coord[5] = sample->getX3Maximum(); + + //////////////////////////////////////////////////////// + UbFileOutputASCII outf(pathname + "/checkpoints/coord.txt"); + outf.writeDouble(deltax); + outf.writeDouble(coord[0]); + outf.writeDouble(coord[1]); + outf.writeDouble(coord[2]); + outf.writeDouble(coord[3]); + outf.writeDouble(coord[4]); + outf.writeDouble(coord[5]); + outf.writeDouble(g_minX1); + outf.writeDouble(g_maxX1); + outf.writeDouble(availMem); + outf.writeDouble(needMem); + //////////////////////////////////////////////////////// + + grid->addInteractor(inflowInt); + + + if (myid == 0) UBLOG(logINFO, "Preprozess - end"); + + if (comm->getNumberOfProcesses() == 1 && gridPrepare) + { + UBLOG(logINFO, "Prepare grid - start"); + rp.writeDistributedGrid(grid, numOfParts); + UBLOG(logINFO, "Prepare grid - end"); + return; + } + } + else + { + //////////////////////////////////////////////////////// + UbFileInputASCII inf(pathname+"/checkpoints/coord.txt"); + deltax = inf.readDouble(); + coord[0] = inf.readDouble(); + coord[1] = inf.readDouble(); + coord[2] = inf.readDouble(); + coord[3] = inf.readDouble(); + coord[4] = inf.readDouble(); + coord[5] = inf.readDouble(); + double g_minX1 = inf.readDouble(); + double g_maxX1 = inf.readDouble(); + double availMem = inf.readDouble(); + double needMem = inf.readDouble(); + //////////////////////////////////////////////////////// + + if (flowInit) + { + grid->setRank(myid); + LBMKernelPtr kernel = LBMKernelPtr(new IncompressibleCumulantLBMKernel(blocknx1, blocknx2, blocknx3, IncompressibleCumulantLBMKernel::NORMAL)); + BCProcessorPtr bcProc(new BCProcessor()); + kernel->setBCProcessor(bcProc); + SetKernelBlockVisitor kernelVisitor(kernel, nu_LB, availMem, needMem, SetKernelBlockVisitor::ChangeKernelWithData); + grid->accept(kernelVisitor); + + BoundaryConditionBlockVisitor bcVisitor; + grid->accept(bcVisitor); + + UbSchedulerPtr geoSch(new UbScheduler(1)); + WriteBoundaryConditionsCoProcessor pp(grid, geoSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, comm); + pp.process(0); + + //Press*1.6e8+(14.76-coordsX)/3.5*5000 + //initialization of distributions + mu::Parser fct; + fct.SetExpr("(x1max-x1)/l*dp*3.0"); + fct.DefineConst("dp", dp_LB); + fct.DefineConst("x1max", g_maxX1); + fct.DefineConst("l", g_maxX1-g_minX1); + + InitDistributionsBlockVisitor initVisitor(nu_LB, rho_LB); + initVisitor.setRho(fct); + initVisitor.setVx1(vx1); + initVisitor.setVx1(vx2); + initVisitor.setVx1(vx3); + grid->accept(initVisitor); + } + + //new nu + if (newViscosity) + { + ViscosityBlockVisitor nuVisitor(nu_LB); + grid->accept(nuVisitor); + } + + //new dp + if (newPressure) + { + Grid3D::Interactor3DSet interactors = grid->getInteractors(); + interactors[0]->setGrid3D(grid); + boost::dynamic_pointer_cast<D3Q27Interactor>(interactors[0])->deleteBCAdapter(); + BCAdapterPtr denBCAdapterFront(new DensityBCAdapter(rhoLBinflow)); + denBCAdapterFront->setBcAlgorithm(BCAlgorithmPtr(new EqDensityBCAlgorithm())); + boost::dynamic_pointer_cast<D3Q27Interactor>(interactors[0])->addBCAdapter(denBCAdapterFront); + interactors[0]->updateInteractor(); + } + + if (myid == 0) + { + UBLOG(logINFO, "Parameters:"); + UBLOG(logINFO, "rho_LB = " << rho_LB); + UBLOG(logINFO, "nu_LB = " << nu_LB); + UBLOG(logINFO, "dp_LB = " << dp_LB); + UBLOG(logINFO, "dx = " << deltax << " m"); + } + + //set connectors + D3Q27InterpolationProcessorPtr iProcessor(new IncompressibleOffsetInterpolationProcessor()); + SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nu_LB, iProcessor); + grid->accept(setConnsVisitor); + + if (myid == 0) UBLOG(logINFO, "Restart - end"); + } + UbSchedulerPtr nupsSch(new UbScheduler(nupsStep[0], nupsStep[1], nupsStep[2])); + //nupsSch->addSchedule(nupsStep[0], nupsStep[1], nupsStep[2]); + NUPSCounterCoProcessor npr(grid, nupsSch, numOfThreads, comm); + + UbSchedulerPtr stepSch(new UbScheduler(outTime)); + + WriteMacroscopicQuantitiesCoProcessor pp(grid, stepSch, pathname, WbWriterVtkXmlBinary::getInstance(), conv, comm); + + deltax = grid->getDeltaX(baseLevel); + double dxd2 = deltax / 2.0; + + IntegrateValuesHelperPtr ih1(new IntegrateValuesHelper(grid, comm, coord[0] - dxd2*10.0, coord[1] - dxd2, coord[2] - dxd2, + coord[0] - dxd2*10.0 - 2.0*dxd2, coord[4] + dxd2, coord[5] + dxd2)); + + //D3Q27IntegrateValuesHelperPtr ih2(new D3Q27IntegrateValuesHelper(grid, comm, coord[3]/2.0, coord[1] - dxd2, coord[2] - dxd2, + // coord[3]/2.0 + 2.0*dxd2, coord[4] + dxd2, coord[5] + dxd2)); + IntegrateValuesHelperPtr ih2(new IntegrateValuesHelper(grid, comm, coord[0], coord[1], coord[2], coord[3], coord[4], coord[5])); + + IntegrateValuesHelperPtr ih3(new IntegrateValuesHelper(grid, comm, coord[3] + dxd2*10.0, coord[1] - dxd2, coord[2] - dxd2, + coord[3] + dxd2*10.0 + 2.0*dxd2, coord[4] + dxd2, coord[5] + dxd2)); + + //D3Q27IntegrateValuesHelperPtr ih1(new D3Q27IntegrateValuesHelper(grid, comm, coord[0], coord[1], coord[2], coord[3], coord[4], coord[5])); + if (myid == 0) GbSystem3D::writeGeoObject(ih1->getBoundingBox().get(), pathname + "/geo/ih1", WbWriterVtkXmlBinary::getInstance()); + if (myid == 0) GbSystem3D::writeGeoObject(ih2->getBoundingBox().get(), pathname + "/geo/ih2", WbWriterVtkXmlBinary::getInstance()); + if (myid == 0) GbSystem3D::writeGeoObject(ih3->getBoundingBox().get(), pathname + "/geo/ih3", WbWriterVtkXmlBinary::getInstance()); + + double factorp = 1; // dp_real / dp_LB; + double factorv = 1;// dx / dt; + UbSchedulerPtr stepMV(new UbScheduler(timeSeriesOutTime)); + + TimeseriesCoProcessor tsp1(grid, stepMV, ih1, pathname+timeSeriesFile+"_1", comm); + TimeseriesCoProcessor tsp2(grid, stepMV, ih2, pathname+timeSeriesFile+"_2", comm); + TimeseriesCoProcessor tsp3(grid, stepMV, ih3, pathname+timeSeriesFile+"_3", comm); + + if (myid == 0) + { + UBLOG(logINFO, "PID = " << myid << " Total Physical Memory (RAM): " << Utilities::getTotalPhysMem()); + UBLOG(logINFO, "PID = " << myid << " Physical Memory currently used: " << Utilities::getPhysMemUsed()); + UBLOG(logINFO, "PID = " << myid << " Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe()); + } + + CalculationManagerPtr calculation(new CalculationManager(grid, numOfThreads, endTime, stepMV)); + if (myid == 0) UBLOG(logINFO, "Simulation-start"); + calculation->calculate(); + if (myid == 0) UBLOG(logINFO, "Simulation-end"); + } + catch (exception& e) + { + cerr << e.what() << endl << flush; + } + catch (string& s) + { + cerr << s << endl; + } + catch (...) + { + cerr << "unknown exception" << endl; + } + +} +////////////////////////////////////////////////////////////////////////// +int main(int argc, char* argv[]) +{ + + if (argv!=NULL) + { + if (argv[1]!=NULL) + { + run(string(argv[1])); + } + else + { + cout<<"Configuration file is missing!"<<endl; + } + } + + return 0; +} diff --git a/source/Applications/aperm/configBombadil2.txt b/source/Applications/aperm/configBombadil2.txt index 9528e9aa9..abb5ee3b3 100644 --- a/source/Applications/aperm/configBombadil2.txt +++ b/source/Applications/aperm/configBombadil2.txt @@ -1,50 +1,83 @@ -pathname = d:/temp/aperm -pathGeo = d:/Projects/SFB880/GeometrienPoroeseMedien/isotrop/PA80-110 -numOfThreads = 1 -availMem = 3e9 +pathname = d:/temp/apermSBP120 +#pathGeo = d:/Projects/SFB880/GeometrienPoroeseMedien/isotrop/PA80-110 +pathGeo = d:/Projects/SFB880/GeometrienPoroeseMedien/isotrop/SBP120 +numOfThreads = 4 +availMem = 5e9 logToFile = false #poroeses Medium rawFile = false -sampleFilename = /alu_80-110.vti +#sampleFilename = /alu_80-110.vti +sampleFilename = /SBP120s500_center.vti +#sampleFilename = /Sinterbronze_SBP120_1358x1376x1572_new.raw + +#sampleFilename = /1.raw #Diminsion in Voxel -pmNX1 = 200 -pmNX2 = 200 -pmNX3 = 200 +#pmNX1 = 200 +#pmNX2 = 200 +#pmNX3 = 200 + +pmNX1 = 500 +pmNX2 = 500 +pmNX3 = 500 + +#pmNX1 = 1358 +#pmNX2 = 1376 +#pmNX3 = 1572 + #Threshold -lthreshold = 29041 +#lthreshold = 29041 uthreshold = 65535 +lthreshold = 38370 + #Diminsion in m pmL1 = 0.726e-3 pmL2 = 0.75e-3 pmL3 = 0.786e-3 +pmDeltas = true + +#deltas [m] +#pmDeltaX1 = 3.6e-6 +#pmDeltaX2 = 3.6e-6 +#pmDeltaX3 = 3.6e-6 + +pmDeltaX1 = 3.75e-6 +pmDeltaX2 = 3.75e-6 +pmDeltaX3 = 3.75e-6 + +yDir = false +zDir = false + #grid -blocknx = 30 +blocknx = 10 nx3 = 5 deltax = 10e-6 spongeLayer=false +#physic +newPressure = false dp_LB = 0.001 -#nu_LB = 0.168666666667 -#nu_LB = 0.168666666667e-1 -#nu_LB = 0.168666666667e-2 -#nu_LB = 0.168666666667e-3 + +newViscosity = false nu_LB = 0.168666666667e-4 -timeSeriesFile = /timeseries/simAlu80_5 -timeSeriesOutTime = 10 +vx1=0 +vx2=0 +vx3=0 + +timeSeriesFile = /timeseries/1 +timeSeriesOutTime = 100 -restartStep = 100 -restartStepStart=100 +#restartFile = txt +restartStep = 100000 +restartStepStart=100000 -endTime = 100 -outTime = 10 +endTime = 100000 +outTime = 10000 nupsStep = 10 30 100 -gridPrepare = true -numOfParts = 4 \ No newline at end of file diff --git a/source/Applications/aperm/configBombadilSBP120s500.txt b/source/Applications/aperm/configBombadilSBP120s500.txt index 4fb351a97..2b91e335d 100644 --- a/source/Applications/aperm/configBombadilSBP120s500.txt +++ b/source/Applications/aperm/configBombadilSBP120s500.txt @@ -34,7 +34,7 @@ pmL3 = 1.87e-3 #nx3 = 5 blocknx = 50 nx3 = 10 -spongeLayer=true +spongeLayer=false #physic dp_LB = 1e-7 @@ -43,8 +43,8 @@ nu_LB = 0.01 timeSeriesFile = /timeseries/simSBP120_1 timeSeriesOutTime = 10 -restartStep = 20000 -restartStepStart=20000 +restartStep = 200 +restartStepStart=200 endTime = 60000 outTime = 100 diff --git a/source/Applications/f16Test/CMakeLists.txt b/source/Applications/f16Test/CMakeLists.txt new file mode 100644 index 000000000..d6760fe88 --- /dev/null +++ b/source/Applications/f16Test/CMakeLists.txt @@ -0,0 +1,25 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +######################################################## +## C++ PROJECT ### +######################################################## +PROJECT(f16test) + +INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) + +################################################################# +### LOCAL FILES ### +################################################################# +FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp ) + +SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES}) +SOURCE_GROUP(src FILES ${SPECIFIC_FILES}) + +SET(CAB_ADDITIONAL_LINK_LIBRARIES VirtualFluids) + +################################################################# +### CREATE PROJECT ### +################################################################# +CREATE_CAB_PROJECT(f16test BINARY) diff --git a/source/Applications/f16Test/F16BombadilTestSmall.cfg b/source/Applications/f16Test/F16BombadilTestSmall.cfg new file mode 100644 index 000000000..eec8b2855 --- /dev/null +++ b/source/Applications/f16Test/F16BombadilTestSmall.cfg @@ -0,0 +1,55 @@ +pathOut = d:/temp/f16Small +pathGeo = d:/Projects/SFB880/DLR-F16/A1_Forschungsdaten_Profilgeometrie_STL_CATIA_Rossian +#fngFileWhole = f16-ascii.stl +#fngFileWhole = grundgeometrie-direkter-export.stl +#fngFileWhole = grundgeometrie-mittel.stl + +fngFileWhole = cylinder.ASCII.stl + +fngFileBodyPart = f16-body-part-ascii.stl +fngFileTrailingEdge = f16-trailing-edge-ascii.stl +zigZagTape = 2zackenbaender0.stl + +numOfThreads = 2 +availMem = 10e9 +refineLevel = 8 +#blockNx = 8 4 8 +blockNx = 21 6 13 +#blockNx = 294 12 247 +uLB = 0.1 + +#x1min x1max x2min x2max x3min x3max [m] +#boundingBox = -0.90 1.20 0.035 0.065 -0.65 0.65 +#boundingBox = -0.1 0.60 0.035 0.065 -0.3 0.3 +#boundingBox = -10e-3 310e-3 0.035 0.065 -21e-3 21e-3 + +boundingBox = -0.255 0.27 0.035 0.065 -0.17 0.155 + +#deltaXfine = 0.005 #level 0 +#deltaXfine = 0.0025 #level 1 +#deltaXfine = 0.00125 #level 2 +#deltaXfine = 0.000625 #level 3 +#deltaXfine = 0.0003125 #level 4 +#deltaXfine = 0.00015625 #level 5 +#deltaXfine = 0.000078125 #level 6 +#deltaXfine = 0.0000390625 #level 7 +deltaXfine = 0.00001953125 #level 8 + + +refineDistance = 0.3 + +restartStep = 10 +restartStepStart = 10 + +outTime = 1 +endTime = 10 + +logToFile = false + +porousTralingEdge = false + +thinWall = false + +testBox=false + +nupsStep = 1 1 10000000 \ No newline at end of file diff --git a/source/Applications/f16Test/f16test.cpp b/source/Applications/f16Test/f16test.cpp new file mode 100644 index 000000000..e325384d0 --- /dev/null +++ b/source/Applications/f16Test/f16test.cpp @@ -0,0 +1,669 @@ +#include <iostream> +#include <string> + +#include <boost/pointer_cast.hpp> + +#include "VirtualFluids.h" + +using namespace std; + +double rangeRandom1() +{ + return (2.0*rand())/RAND_MAX-1.0; +} + +void run(string configname) +{ + try + { + ConfigurationFile config; + config.load(configname); + + string pathOut = config.getString("pathOut"); + string pathGeo = config.getString("pathGeo"); + string fngFileWhole = config.getString("fngFileWhole"); + string fngFileTrailingEdge = config.getString("fngFileTrailingEdge"); + string fngFileBodyPart = config.getString("fngFileBodyPart"); + string zigZagTape = config.getString("zigZagTape"); + int numOfThreads = config.getInt("numOfThreads"); + vector<int> blockNx = config.getVector<int>("blockNx"); + vector<double> boundingBox = config.getVector<double>("boundingBox"); + double uLB = config.getDouble("uLB"); + double restartStep = config.getDouble("restartStep"); + double restartStepStart = config.getDouble("restartStepStart"); + double endTime = config.getDouble("endTime"); + double outTime = config.getDouble("outTime"); + double availMem = config.getDouble("availMem"); + int refineLevel = config.getInt("refineLevel"); + bool logToFile = config.getBool("logToFile"); + bool porousTralingEdge = config.getBool("porousTralingEdge"); + double deltaXfine = config.getDouble("deltaXfine")*1000.0; + bool thinWall = config.getBool("thinWall"); + bool testBox = config.getBool("testBox"); + double refineDistance = config.getDouble("refineDistance"); + vector<double> nupsStep = config.getVector<double>("nupsStep"); + + CommunicatorPtr comm = MPICommunicator::getInstance(); + int myid = comm->getProcessID(); + + if (logToFile) + { +#if defined(__unix__) + if (myid == 0) + { + const char* str = pathOut.c_str(); + mkdir(str, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + } +#endif + + if (myid == 0) + { + stringstream logFilename; + logFilename << pathOut + "/logfile" + UbSystem::toString(UbSystem::getTimeStamp()) + ".txt"; + UbLog::output_policy::setStream(logFilename.str()); + } + } + + + double g_minX1 = boundingBox[0]*1000.0; + double g_minX2 = boundingBox[2]*1000.0; + double g_minX3 = boundingBox[4]*1000.0; + + double g_maxX1 = boundingBox[1]*1000.0; + double g_maxX2 = boundingBox[3]*1000.0; + double g_maxX3 = boundingBox[5]*1000.0; + + ////////////////////////////////////////////////////////////////////////// + double deltaXcoarse = deltaXfine*(double)(1 << refineLevel); + //double nx2_temp = floor((g_maxX2 - g_minX2) / (deltaXcoarse*(double)blockNx[0])); + + //deltaXcoarse = (g_maxX2 - g_minX2) / (nx2_temp*(double)blockNx[0]); + //UBLOG(logINFO, "nx2_temp:"<<nx2_temp); + //g_maxX2 -= 0.5* deltaXcoarse; + ////////////////////////////////////////////////////////////////////////// + double blockLength = (double)blockNx[0] * deltaXcoarse; + + //########################################################################## + //## physical parameters + //########################################################################## + double Re = 1e6; + + double rhoLB = 0.0; + double rhoReal = 1.2041; //(kg/m3) + double nueReal = 153.5e-7; //m^2/s + + double lReal = 3.0;//m + double uReal = Re*nueReal / lReal; + + //##Machzahl: + //#Ma = uReal/csReal + double Ma = 0.15;//Ma-Real! + //double csReal = uReal / Ma; + //double hLB = lReal / deltaXcoarse; + + //LBMUnitConverter unitConverter(lReal, csReal, rhoReal, hLB); + + //double u_LB = uReal * unitConverter.getFactorVelocityWToLb(); + //double nu_LB = nueReal * unitConverter.getFactorViscosityWToLb(); + double l_LB = 300 / deltaXcoarse; + double nuLB = (uLB*l_LB) / Re; //0.005; + //double nuLB = 0.005; + + LBMUnitConverterPtr conv = LBMUnitConverterPtr(new LBMUnitConverter()); + + const int baseLevel = 0; + + //////////////////////////////////////////////////////////////////////// + //Grid + ////////////////////////////////////////////////////////////////////////// + Grid3DPtr grid(new Grid3D(comm)); + grid->setDeltaX(deltaXcoarse); + grid->setBlockNX(blockNx[0], blockNx[1], blockNx[2]); + + GbObject3DPtr gridCube(new GbCuboid3D(g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3)); + //gridCube->setCenterCoordinates(geo->getX1Centroid(), geo->getX2Centroid(), geo->getX3Centroid()); + if (myid == 0) GbSystem3D::writeGeoObject(gridCube.get(), pathOut + "/geo/gridCube", WbWriterVtkXmlASCII::getInstance()); + GenBlocksGridVisitor genBlocks(gridCube); + grid->accept(genBlocks); + + grid->setPeriodicX1(false); + grid->setPeriodicX2(true); + grid->setPeriodicX3(false); + + //BC adapters + BCAdapterPtr noSlipBCAdapter(new NoSlipBCAdapter()); + if (thinWall) + { + noSlipBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new ThinWallNoSlipBCAlgorithm())); + } + else + { + noSlipBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new NoSlipBCAlgorithm())); + } + + BCAdapterPtr slipBCAdapter(new SlipBCAdapter()); + slipBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new SlipBCAlgorithm())); + + mu::Parser fct; + fct.SetExpr("U"); + fct.DefineConst("U", uLB); + BCAdapterPtr velBCAdapter(new VelocityBCAdapter(true, false, false, fct, 0, BCFunction::INFCONST)); + velBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new NonReflectingVelocityBCAlgorithm())); + + BCAdapterPtr denBCAdapter(new DensityBCAdapter(rhoLB)); + denBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new NonReflectingDensityBCAlgorithm())); + + BoundaryConditionsBlockVisitor bcVisitor; + bcVisitor.addBC(noSlipBCAdapter); + bcVisitor.addBC(slipBCAdapter); + bcVisitor.addBC(velBCAdapter); + bcVisitor.addBC(denBCAdapter); + + ////////////////////////////////////////////////////////////////////////// + //restart + UbSchedulerPtr rSch(new UbScheduler(restartStep, restartStep)); + RestartCoProcessor rp(grid, rSch, comm, pathOut, RestartCoProcessor::BINARY); + ////////////////////////////////////////////////////////////////////////// + + + if (grid->getTimeStep() == 0) + { + if (myid == 0) + { + UBLOG(logINFO, "Parameters:"); + UBLOG(logINFO, "* Re = "<<Re); + UBLOG(logINFO, "* Ma = "<<Ma); + UBLOG(logINFO, "* velocity (uReal) = "<<uReal<<" m/s"); + UBLOG(logINFO, "* viscosity (nuReal) = "<<nueReal<<" m^2/s"); + UBLOG(logINFO, "* velocity LB (uLB) = "<<uLB); + UBLOG(logINFO, "* viscosity LB (nuLB) = "<<nuLB); + UBLOG(logINFO, "* dx_base = "<<deltaXcoarse/1000.0<<" m"); + UBLOG(logINFO, "* dx_refine = "<<deltaXfine/1000.0<<" m"); + UBLOG(logINFO, "* number of levels = " << refineLevel + 1); + UBLOG(logINFO, "* number of threads = " << numOfThreads); + UBLOG(logINFO, "* number of processes = " << comm->getNumberOfProcesses()); + UBLOG(logINFO, "Preprozess - start"); + } + + GbTriFaceMesh3DPtr fngMeshWhole; + GbTriFaceMesh3DPtr fngMeshBodyPart; + GbTriFaceMesh3DPtr fngMeshTrailingEdge; + if (porousTralingEdge) + { + if (myid==0) UBLOG(logINFO, "Read fngFileBodyPart:start"); + fngMeshBodyPart = GbTriFaceMesh3DPtr(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(pathGeo+"/"+fngFileBodyPart, "fngMeshBody", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); + if (myid==0) UBLOG(logINFO, "Read fngFileBodyPart:end"); + fngMeshBodyPart->rotate(0.0, 0.5, 0.0); + if (myid==0) GbSystem3D::writeGeoObject(fngMeshBodyPart.get(), pathOut+"/geo/fngMeshBody", WbWriterVtkXmlBinary::getInstance()); + + if (myid==0) UBLOG(logINFO, "Read fngFileTrailingEdge:start"); + fngMeshTrailingEdge = GbTriFaceMesh3DPtr(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(pathGeo+"/"+fngFileTrailingEdge, "fngMeshTrailingEdge", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); + if (myid==0) UBLOG(logINFO, "Read fngFileTrailingEdge:end"); + fngMeshTrailingEdge->rotate(0.0, 0.5, 0.0); + fngMeshTrailingEdge->translate(0,0,1.3); + if (myid==0) GbSystem3D::writeGeoObject(fngMeshTrailingEdge.get(), pathOut+"/geo/fngMeshTrailingEdge", WbWriterVtkXmlBinary::getInstance()); + } + else + { + if (myid==0) UBLOG(logINFO, "Read fngFileWhole:start"); + fngMeshWhole = GbTriFaceMesh3DPtr(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(pathGeo+"/"+fngFileWhole, "fngMeshWhole", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); + if (myid==0) UBLOG(logINFO, "Read fngFileWhole:end"); + fngMeshWhole->rotate(0.0, 0.5, 0.0); + if (myid==0) GbSystem3D::writeGeoObject(fngMeshWhole.get(), pathOut+"/geo/fngMeshWhole", WbWriterVtkXmlBinary::getInstance()); + } + + ////////////////////////////////////////////////////////////////////////// + // Zackenband + ////////////////////////////////////////////////////////////////////////// + //top + ////////////////////////////////////////////////////////////////////////// + //if (myid==0) UBLOG(logINFO, "Read zigZagTape:start"); + //string ZckbndFilename = pathGeo+"/"+zigZagTape; + //GbTriFaceMesh3DPtr meshBand1(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape1")); + //meshBand1->rotate(0.0, 5, 0.0); + //meshBand1->translate(15, 0, -12.850); + //if (myid==0) GbSystem3D::writeGeoObject(meshBand1.get(), pathOut+"/geo/zigZagTape1", WbWriterVtkXmlASCII::getInstance()); + //// Zackenband2 + //GbTriFaceMesh3DPtr meshBand2(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape2")); + //meshBand2->rotate(0.0, 5, 0.0); + //meshBand2->translate(15, 5, -12.850); + //if (myid==0) GbSystem3D::writeGeoObject(meshBand2.get(), pathOut+"/geo/zigZagTape2", WbWriterVtkXmlASCII::getInstance()); + ////// Zackenband3 + ////GbTriFaceMesh3DPtr meshBand3(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape3")); + ////meshBand3->rotate(0.0, 5, 0.0); + ////meshBand3->translate(15, 0, -12.35); + ////if (myid==0) GbSystem3D::writeGeoObject(meshBand3.get(), pathOut+"/geo/zigZagTape3", WbWriterVtkXmlASCII::getInstance()); + ////// Zackenband4 + ////GbTriFaceMesh3DPtr meshBand4(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape4")); + ////meshBand4->rotate(0.0, 5, 0.0); + ////meshBand4->translate(15, 5, -12.35); + ////if (myid==0) GbSystem3D::writeGeoObject(meshBand4.get(), pathOut+"/geo/zigZagTape4", WbWriterVtkXmlASCII::getInstance()); + + ////bottom + //GbTriFaceMesh3DPtr meshBand5(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape5")); + //meshBand5->rotate(0.0, -1, 0.0); + //meshBand5->rotate(0.0, 0.0,180.0); + //meshBand5->translate(30, 0, -37.3); + //if (myid==0) GbSystem3D::writeGeoObject(meshBand5.get(), pathOut+"/geo/zigZagTape5", WbWriterVtkXmlASCII::getInstance()); + //// Zackenband6 + //GbTriFaceMesh3DPtr meshBand6(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape6")); + //meshBand6->rotate(0.0, -1, 0.0); + //meshBand6->rotate(0.0, 0.0, 180.0); + //meshBand6->translate(30, 5, -37.3); + //if (myid==0) GbSystem3D::writeGeoObject(meshBand6.get(), pathOut+"/geo/zigZagTape6", WbWriterVtkXmlASCII::getInstance()); + ////// Zackenband7 + ////GbTriFaceMesh3DPtr meshBand7(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape7")); + ////meshBand7->rotate(0.0, 5, 0.0); + ////meshBand7->translate(15, 0, -12.35); + ////if (myid==0) GbSystem3D::writeGeoObject(meshBand7.get(), pathOut+"/geo/zigZagTape7", WbWriterVtkXmlASCII::getInstance()); + ////// Zackenband8 + ////GbTriFaceMesh3DPtr meshBan8(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(ZckbndFilename, "zigZagTape8")); + ////meshBan8->rotate(0.0, 5, 0.0); + ////meshBan8->translate(15, 5, -12.35); + ////if (myid==0) GbSystem3D::writeGeoObject(meshBan8.get(), pathOut+"/geo/zigZagTape8", WbWriterVtkXmlASCII::getInstance()); + //if (myid==0) UBLOG(logINFO, "Read zigZagTape:end"); + + GbObject3DPtr testBoxOb; + if (testBox) + { + testBoxOb=GbObject3DPtr(new GbCuboid3D(15.0, 0, 5.0, 30.0, 100, 35.0)); + if (myid==0) GbSystem3D::writeGeoObject(testBoxOb.get(), pathOut+"/geo/gridCube", WbWriterVtkXmlASCII::getInstance()); + } + ////////////////////////////////////////////////////////////////////////// + + Interactor3DPtr fngIntrWhole; + Interactor3DPtr fngIntrBodyPart; + Interactor3DPtr fngIntrTrailingEdge; + if (porousTralingEdge) + { + fngIntrBodyPart = D3Q27TriFaceMeshInteractorPtr(new D3Q27TriFaceMeshInteractor(fngMeshBodyPart, grid, noSlipBCAdapter, Interactor3D::SOLID)); + fngIntrTrailingEdge = D3Q27TriFaceMeshInteractorPtr(new D3Q27TriFaceMeshInteractor(fngMeshTrailingEdge, grid, noSlipBCAdapter, Interactor3D::SOLID)); + } + else + { + fngIntrWhole = D3Q27TriFaceMeshInteractorPtr(new D3Q27TriFaceMeshInteractor(fngMeshWhole, grid, noSlipBCAdapter, Interactor3D::SOLID));//, Interactor3D::EDGES)); + } + + //D3Q27TriFaceMeshInteractorPtr triBand1Interactor(new D3Q27TriFaceMeshInteractor(meshBand1, grid, noSlipBCAdapter, Interactor3D::SOLID));//, Interactor3D::EDGES)); + //D3Q27TriFaceMeshInteractorPtr triBand2Interactor(new D3Q27TriFaceMeshInteractor(meshBand2, grid, noSlipBCAdapter, Interactor3D::SOLID));//, Interactor3D::EDGES)); + //D3Q27TriFaceMeshInteractorPtr triBand3Interactor(new D3Q27TriFaceMeshInteractor(meshBand3, grid, noSlipBCAdapter, Interactor3D::SOLID));//, Interactor3D::EDGES)); + //D3Q27TriFaceMeshInteractorPtr triBand4Interactor(new D3Q27TriFaceMeshInteractor(meshBand4, grid, noSlipBCAdapter, Interactor3D::SOLID));//, Interactor3D::EDGES)); + + D3Q27InteractorPtr testBoxInt; + if (testBox) + { + testBoxInt=D3Q27InteractorPtr(new D3Q27Interactor(testBoxOb, grid, noSlipBCAdapter, Interactor3D::SOLID)); + } + + if (refineLevel > 0 && myid == 0) + { + if (myid == 0) UBLOG(logINFO, "Refinement - start"); + //RefineCrossAndInsideGbObjectHelper refineHelper(grid, refineLevel); + //refineHelper.addGbObject(geo, refineLevel); + //refineHelper.refine(); + + //RefineAroundGbObjectHelper refineHelper1(grid, refineLevel-1, boost::dynamic_pointer_cast<D3Q27TriFaceMeshInteractor>(geoIntr1), 0.0, 10.0, comm); + //refineHelper1.refine(); + //RefineAroundGbObjectHelper refineHelper2(grid, refineLevel, boost::dynamic_pointer_cast<D3Q27TriFaceMeshInteractor>(geoIntr2), -1.0, 5.0, comm); + //refineHelper2.refine(); + + + int rank = grid->getRank(); + grid->setRank(0); + //boost::dynamic_pointer_cast<D3Q27TriFaceMeshInteractor>(triBand1Interactor)->refineBlockGridToLevel(refineLevel, 0.0, refineDistance); + //boost::dynamic_pointer_cast<D3Q27TriFaceMeshInteractor>(triBand2Interactor)->refineBlockGridToLevel(refineLevel, 0.0, refineDistance); + //boost::dynamic_pointer_cast<D3Q27TriFaceMeshInteractor>(triBand3Interactor)->refineBlockGridToLevel(refineLevel, 0.0, refineDistance); + //boost::dynamic_pointer_cast<D3Q27TriFaceMeshInteractor>(triBand4Interactor)->refineBlockGridToLevel(refineLevel, 0.0, refineDistance); + grid->setRank(rank); + + if (porousTralingEdge) + { + int rank = grid->getRank(); + grid->setRank(0); + boost::dynamic_pointer_cast<D3Q27TriFaceMeshInteractor>(fngIntrBodyPart)->refineBlockGridToLevel(refineLevel, 0.0, refineDistance); + grid->setRank(rank); + } + else + { + int rank = grid->getRank(); + grid->setRank(0); + boost::dynamic_pointer_cast<D3Q27TriFaceMeshInteractor>(fngIntrWhole)->refineBlockGridToLevel(refineLevel, 0.0, refineDistance); + grid->setRank(rank); + } + + + + //////////////////////////////////////////// + //METIS + //Grid3DVisitorPtr metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::KWAY)); + //////////////////////////////////////////// + /////delete solid blocks + if (myid == 0) UBLOG(logINFO, "deleteSolidBlocks - start"); + //InteractorsHelper intHelper(grid, metisVisitor); + //if (porousTralingEdge) + //{ + // intHelper.addInteractor(fngIntrBodyPart); + //} + //else + //{ + // intHelper.addInteractor(fngIntrWhole); + //} + ////////////////////////////////////////////////////////////////////////// + + //intHelper.selectBlocks(); + + if (porousTralingEdge) + { + SetSolidOrTransBlockVisitor v(fngIntrBodyPart, SetSolidOrTransBlockVisitor::SOLID); + grid->accept(v); + std::vector<Block3DPtr>& sb = fngIntrBodyPart->getSolidBlockSet(); + BOOST_FOREACH(Block3DPtr block, sb) + { + grid->deleteBlock(block); + } + fngIntrBodyPart->removeSolidBlocks(); + fngIntrBodyPart->removeTransBlocks(); + } + else + { + SetSolidOrTransBlockVisitor v(fngIntrWhole, SetSolidOrTransBlockVisitor::SOLID); + grid->accept(v); + std::vector<Block3DPtr>& sb = fngIntrWhole->getSolidBlockSet(); + BOOST_FOREACH(Block3DPtr block, sb) + { + grid->deleteBlock(block); + } + fngIntrWhole->removeSolidBlocks(); + fngIntrWhole->removeTransBlocks(); + } + + if (myid == 0) UBLOG(logINFO, "deleteSolidBlocks - end"); + ////////////////////////////////////// + + if (porousTralingEdge) + { + grid->setRank(0); + boost::dynamic_pointer_cast<D3Q27TriFaceMeshInteractor>(fngIntrTrailingEdge)->refineBlockGridToLevel(refineLevel, -2.0, refineDistance); + grid->setRank(rank); + + //GbObject3DPtr trailingEdgeCube(new GbCuboid3D(fngMeshTrailingEdge->getX1Minimum()-blockLength, fngMeshTrailingEdge->getX2Minimum(), fngMeshTrailingEdge->getX3Minimum()-blockLength/2.0, + // fngMeshTrailingEdge->getX1Maximum()+blockLength, fngMeshTrailingEdge->getX2Maximum(), fngMeshTrailingEdge->getX3Maximum()+blockLength/2.0)); + //if (myid == 0) GbSystem3D::writeGeoObject(trailingEdgeCube.get(), pathOut + "/geo/trailingEdgeCube", WbWriterVtkXmlASCII::getInstance()); + + //RefineCrossAndInsideGbObjectBlockVisitor refVisitor(trailingEdgeCube, refineLevel); + //grid->accept(refVisitor); + } + + RatioBlockVisitor ratioVisitor(refineLevel); + CheckRatioBlockVisitor checkRatio(refineLevel); + int count = 0; + + do { + grid->accept(ratioVisitor); + checkRatio.resetState(); + grid->accept(checkRatio); + if (myid == 0) UBLOG(logINFO, "count ="<<count++<<" state="<<checkRatio.getState()); + } while (!checkRatio.getState()); + + //RatioSmoothBlockVisitor ratioSmoothVisitor(refineLevel); + //grid->accept(ratioSmoothVisitor); + + { + WriteBlocksCoProcessorPtr ppblocks(new WriteBlocksCoProcessor(grid, UbSchedulerPtr(new UbScheduler(1)), pathOut, WbWriterVtkXmlBinary::getInstance(), comm)); + ppblocks->process(0); + ppblocks.reset(); + } + + OverlapBlockVisitor overlapVisitor(refineLevel, false); + grid->accept(overlapVisitor); + + //std::vector<int> dirs; + //for (int i = D3Q27System::E; i <= D3Q27System::TS; i++) + //{ + // dirs.push_back(i); + //} + //SetInterpolationDirsBlockVisitor interDirsVisitor(dirs); + //grid->accept(interDirsVisitor); + + if (myid == 0) UBLOG(logINFO, "Refinement - end"); + } + + grid->updateDistributedBlocks(comm); + + + //return; + + std::vector<int> dirs; + for (int i = D3Q27System::E; i<=D3Q27System::TS; i++) + { + dirs.push_back(i); + } + SetInterpolationDirsBlockVisitor interDirsVisitor(dirs); + grid->accept(interDirsVisitor); + + //walls + GbCuboid3DPtr addWallZmin(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_minX3)); + if (myid==0) GbSystem3D::writeGeoObject(addWallZmin.get(), pathOut+"/geo/addWallZmin", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr addWallZmax(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_maxX3, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); + if (myid==0) GbSystem3D::writeGeoObject(addWallZmax.get(), pathOut+"/geo/addWallZmax", WbWriterVtkXmlASCII::getInstance()); + + + + //wall interactors + D3Q27InteractorPtr addWallZminInt(new D3Q27Interactor(addWallZmin, grid, slipBCAdapter, Interactor3D::SOLID)); + D3Q27InteractorPtr addWallZmaxInt(new D3Q27Interactor(addWallZmax, grid, slipBCAdapter, Interactor3D::SOLID)); + + //inflow + GbCuboid3DPtr geoInflow(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_minX1, g_maxX2+blockLength, g_maxX3+blockLength)); + if (myid==0) GbSystem3D::writeGeoObject(geoInflow.get(), pathOut+"/geo/geoInflow", WbWriterVtkXmlASCII::getInstance()); + + //outflow + GbCuboid3DPtr geoOutflow(new GbCuboid3D(g_maxX1, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); + if (myid==0) GbSystem3D::writeGeoObject(geoOutflow.get(), pathOut+"/geo/geoOutflow", WbWriterVtkXmlASCII::getInstance()); + + //inflow + D3Q27InteractorPtr inflowIntr = D3Q27InteractorPtr(new D3Q27Interactor(geoInflow, grid, velBCAdapter, Interactor3D::SOLID)); + + //outflow + D3Q27InteractorPtr outflowIntr = D3Q27InteractorPtr(new D3Q27Interactor(geoOutflow, grid, denBCAdapter, Interactor3D::SOLID)); + + //////////////////////////////////////////// + //METIS + Grid3DVisitorPtr metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::KWAY)); + //////////////////////////////////////////// + /////delete solid blocks + if (myid == 0) UBLOG(logINFO, "deleteSolidBlocks - start"); + InteractorsHelper intHelper(grid, metisVisitor); + intHelper.addInteractor(inflowIntr); + intHelper.addInteractor(outflowIntr); + intHelper.addInteractor(addWallZminInt); + intHelper.addInteractor(addWallZmaxInt); + //intHelper.addInteractor(triBand1Interactor); + //intHelper.addInteractor(triBand2Interactor); + //intHelper.addInteractor(triBand3Interactor); + //intHelper.addInteractor(triBand4Interactor); + if (testBox) + { + intHelper.addInteractor(testBoxInt); + } + + if (porousTralingEdge) + { + intHelper.addInteractor(fngIntrBodyPart); + //intHelper.addInteractor(fngIntrTrailingEdge); + } + else + { + intHelper.addInteractor(fngIntrWhole); + } + + ////////////////////////////////////////////////////////////////////////// + intHelper.selectBlocks(); + + if (myid == 0) UBLOG(logINFO, "deleteSolidBlocks - end"); + ////////////////////////////////////// + + WriteBlocksCoProcessorPtr ppblocks(new WriteBlocksCoProcessor(grid, UbSchedulerPtr(new UbScheduler(1)), pathOut, WbWriterVtkXmlBinary::getInstance(), comm)); + ppblocks->process(1); + ppblocks.reset(); + + unsigned long long numberOfBlocks = (unsigned long long)grid->getNumberOfBlocks(); + int ghostLayer = 3; + unsigned long long numberOfNodesPerBlock = (unsigned long long)(blockNx[0])* (unsigned long long)(blockNx[1])* (unsigned long long)(blockNx[2]); + unsigned long long numberOfNodes = numberOfBlocks * numberOfNodesPerBlock; + unsigned long long numberOfNodesPerBlockWithGhostLayer = numberOfBlocks * (blockNx[0] + ghostLayer) * (blockNx[1] + ghostLayer) * (blockNx[2] + ghostLayer); + double needMemAll = double(numberOfNodesPerBlockWithGhostLayer*(27 * sizeof(double) + sizeof(int) + sizeof(float) * 4)); + double needMem = needMemAll / double(comm->getNumberOfProcesses()); + + if (myid == 0) + { + UBLOG(logINFO, "Number of blocks = " << numberOfBlocks); + UBLOG(logINFO, "Number of nodes = " << numberOfNodes); + int minInitLevel = grid->getCoarsestInitializedLevel(); + int maxInitLevel = grid->getFinestInitializedLevel(); + for (int level = minInitLevel; level <= maxInitLevel; level++) + { + int nobl = grid->getNumberOfBlocks(level); + UBLOG(logINFO, "Number of blocks for level " << level << " = " << nobl); + UBLOG(logINFO, "Number of nodes for level " << level << " = " << nobl*numberOfNodesPerBlock); + } + UBLOG(logINFO, "Necessary memory = " << needMemAll << " bytes"); + UBLOG(logINFO, "Necessary memory per process = " << needMem << " bytes"); + UBLOG(logINFO, "Available memory per process = " << availMem << " bytes"); + } + + LBMKernelPtr kernel = LBMKernelPtr(new CompressibleCumulantLBMKernel(blockNx[0], blockNx[1], blockNx[2], CompressibleCumulantLBMKernel::NORMAL)); + + BCProcessorPtr bcProc; + + if (thinWall) + { + bcProc = BCProcessorPtr(new ThinWallBCProcessor()); + } + else + { + bcProc = BCProcessorPtr(new BCProcessor()); + } + + kernel->setBCProcessor(bcProc); + + SetKernelBlockVisitor kernelVisitor(kernel, nuLB, availMem, needMem); + grid->accept(kernelVisitor); + + if (refineLevel > 0) + { + SetUndefinedNodesBlockVisitor undefNodesVisitor; + grid->accept(undefNodesVisitor); + } + + //BC + intHelper.setBC(); + + grid->accept(bcVisitor); + + //initialization of distributions + mu::Parser inflowProfileVx1, inflowProfileVx2, inflowProfileVx3; + inflowProfileVx1.SetExpr("U*rangeRandom1()"); + inflowProfileVx1.DefineConst("U", uLB); + inflowProfileVx1.DefineFun("rangeRandom1", rangeRandom1); + inflowProfileVx2.SetExpr("0.1*U*rangeRandom1()"); + inflowProfileVx2.DefineConst("U", uLB); + inflowProfileVx2.DefineFun("rangeRandom1", rangeRandom1); + inflowProfileVx3.SetExpr("0.1*U*rangeRandom1()"); + inflowProfileVx3.DefineConst("U", uLB); + inflowProfileVx3.DefineFun("rangeRandom1", rangeRandom1); + + InitDistributionsBlockVisitor initVisitor(nuLB, rhoLB); + initVisitor.setVx1(fct); + //initVisitor.setVx1(inflowProfileVx1); + //initVisitor.setVx2(inflowProfileVx2); + //initVisitor.setVx3(inflowProfileVx3); + initVisitor.setNu(nuLB); + grid->accept(initVisitor); + + ////set connectors + InterpolationProcessorPtr iProcessor(new CompressibleOffsetInterpolationProcessor()); + SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); + grid->accept(setConnsVisitor); + + //domain decomposition for threads + PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); + grid->accept(pqPartVisitor); + + //Postrozess + UbSchedulerPtr geoSch(new UbScheduler(1)); + WriteBoundaryConditionsCoProcessorPtr ppgeo( + new WriteBoundaryConditionsCoProcessor(grid, geoSch, pathOut, WbWriterVtkXmlBinary::getInstance(), conv, comm)); + ppgeo->process(0); + ppgeo.reset(); + + if (myid == 0) UBLOG(logINFO, "Preprozess - end"); + } + else + { + InterpolationProcessorPtr iProcessor(new CompressibleOffsetInterpolationProcessor()); + SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); + grid->accept(setConnsVisitor); + + //domain decomposition for threads + PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); + grid->accept(pqPartVisitor); + + grid->accept(bcVisitor); + } + + UbSchedulerPtr nupsSch(new UbScheduler(nupsStep[0], nupsStep[1], nupsStep[2])); + NUPSCounterCoProcessor npr(grid, nupsSch, numOfThreads, comm); + + UbSchedulerPtr stepSch(new UbScheduler(outTime)); + + WriteMacroscopicQuantitiesCoProcessor pp(grid, stepSch, pathOut, WbWriterVtkXmlBinary::getInstance(), conv,comm); + + if (myid == 0) + { + UBLOG(logINFO, "PID = " << myid << " Total Physical Memory (RAM): " << Utilities::getTotalPhysMem()); + UBLOG(logINFO, "PID = " << myid << " Physical Memory currently used: " << Utilities::getPhysMemUsed()); + UBLOG(logINFO, "PID = " << myid << " Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe()); + } + + //CalculationManagerPtr calculation(new CalculationManager(grid, numOfThreads, endTime, stepSch)); + CalculationManagerPtr calculation(new CalculationManager(grid, numOfThreads, endTime, stepSch, CalculationManager::PrePostBc)); + //calculation->setTimeAveragedValuesCoProcessor(tav); + if (myid == 0) UBLOG(logINFO, "Simulation-start"); + calculation->calculate(); + if (myid == 0) UBLOG(logINFO, "Simulation-end"); + } + catch (std::exception& e) + { + cerr << e.what() << endl << flush; + } + catch (std::string& s) + { + cerr << s << endl; + } + catch (...) + { + cerr << "unknown exception" << endl; + } + +} + +int main(int argc, char* argv[]) +{ + + if (argv != NULL) + { + if (argv[1] != NULL) + { + run(string(argv[1])); + } + else + { + cout << "Configuration file must be set!: " << argv[0] << " <config file>" << endl << std::flush; + } + } + + return 0; +} + diff --git a/source/Applications/mirror/CMakeLists.txt b/source/Applications/mirror/CMakeLists.txt new file mode 100644 index 000000000..08f1c7f5c --- /dev/null +++ b/source/Applications/mirror/CMakeLists.txt @@ -0,0 +1,25 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +######################################################## +## C++ PROJECT ### +######################################################## +PROJECT(mirror) + +INCLUDE(${SOURCE_ROOT}/IncludsList.cmake) + +################################################################# +### LOCAL FILES ### +################################################################# +FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp ) + +SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES}) +SOURCE_GROUP(src FILES ${SPECIFIC_FILES}) + +SET(CAB_ADDITIONAL_LINK_LIBRARIES VirtualFluids) + +################################################################# +### CREATE PROJECT ### +################################################################# +CREATE_CAB_PROJECT(mirror BINARY) diff --git a/source/Applications/mirror/mirror.cfg b/source/Applications/mirror/mirror.cfg new file mode 100644 index 000000000..4620a2e7d --- /dev/null +++ b/source/Applications/mirror/mirror.cfg @@ -0,0 +1,60 @@ +pathOut = d:/temp/mirror5 +pathGeo = d:/Projects/Spiegelbenchmark/geometry +pathMesh = d:/Projects/Spiegelbenchmark/meshBoxes + +#geometry +SAE = SAE_GRUNDKOERPER_CFD_INPUT_VERFEINERT_in_m_SOLID.ASCII_D_0.8.stl + + +#refinement meshes +VRES0600_chopped = VRES0600_chopped.stl +VRES0700_chopped = VRES0700_chopped.stl +VRES0800_Fahrzeug = VRES0800_Fahrzeug.stl +#VRES0900 = VRES0900_Cube.stl +VRES1000_ASaeule = VRES1000_ASaeule.stl +VRES1000_Scheibe = VRES1000_Scheibe.stl +VRES1000_Spiegel = VRES1000_Spiegel.stl +VRES1100_Spiegel_fein = VRES1100_Spiegel_fein.stl + + +numOfThreads = 4 +availMem = 10e9 +refineLevel = 11 +#blockNx = 9 8 9 +blockNx = 6 6 6 + +#x1min x1max x2min x2max x3min x3max [m] +#bounding box +WTUNNEL1 = -35.8 37.4 -31.5 31.5 -0.177 32.8 + +#refinement cubes +VRES0100 = -18.4 24.5 -16.2 16.2 -0.187 16.5 +VRES0200 = -10.7 16.8 -8.56 8.56 -0.187 8.82 +VRES0300 = -6.9 13 -4.72 4.72 -0.187 4.98 +VRES0400 = -4.21 10.8 -2.8 2.8 -0.187 3.06 +VRES0500 = -2.87 8.74 -1.84 1.84 -0.187 2.1 +VRES0700 = -2.6 4.69 -1.25 1.25 -0.255 -0.125 +VRES0900 = -0.823 0.941 -1.15 -0.7 0.502 1.01 + +#deltaXcoarse = 4096e-3 #level 0 +deltaXcoarse = 2.048 #level 0 +deltaXfine = 1e-3 #level 11 + + +refineDistance = 0.3 + +restartStep = 1 +restartStepStart = 100 + +outTime = 1 +endTime = 10 + +logToFile = true + +porousTralingEdge = false + +thinWall = false + +testBox=false + +nupsStep = 1 1 10000000 \ No newline at end of file diff --git a/source/Applications/mirror/mirror.cpp b/source/Applications/mirror/mirror.cpp new file mode 100644 index 000000000..9db898a95 --- /dev/null +++ b/source/Applications/mirror/mirror.cpp @@ -0,0 +1,577 @@ +#include <iostream> +#include <string> + +#include <boost/pointer_cast.hpp> + +#include <boost/pointer_cast.hpp> + +#include "VirtualFluids.h" + +using namespace std; + +void run(string configname) +{ + try + { + ConfigurationFile config; + config.load(configname); + + string pathOut = config.getString("pathOut"); + string pathGeo = config.getString("pathGeo"); + string pathMesh = config.getString("pathMesh"); + int numOfThreads = config.getInt("numOfThreads"); + vector<int> blockNx = config.getVector<int>("blockNx"); + double restartStep = config.getDouble("restartStep"); + double restartStepStart = config.getDouble("restartStepStart"); + double endTime = config.getDouble("endTime"); + double outTime = config.getDouble("outTime"); + double availMem = config.getDouble("availMem"); + int refineLevel = config.getInt("refineLevel"); + bool logToFile = config.getBool("logToFile"); + double deltaXcoarse = config.getDouble("deltaXcoarse"); + double deltaXfine = config.getDouble("deltaXfine"); + double refineDistance = config.getDouble("refineDistance"); + vector<double> nupsStep = config.getVector<double>("nupsStep"); + + vector<double> WTUNNEL1 = config.getVector<double>("WTUNNEL1"); + vector<double> VRES0100 = config.getVector<double>("VRES0100"); + vector<double> VRES0200 = config.getVector<double>("VRES0200"); + vector<double> VRES0300 = config.getVector<double>("VRES0300"); + vector<double> VRES0400 = config.getVector<double>("VRES0400"); + vector<double> VRES0500 = config.getVector<double>("VRES0500"); + vector<double> VRES0700 = config.getVector<double>("VRES0700"); + vector<double> VRES0900 = config.getVector<double>("VRES0900"); + + string SAE = config.getString("SAE"); + string VRES0600_chopped = config.getString("VRES0600_chopped"); + string VRES0700_chopped = config.getString("VRES0700_chopped"); + string VRES0800_Fahrzeug = config.getString("VRES0800_Fahrzeug"); + //string VRES0900 = config.getString("VRES0900"); + string VRES1000_ASaeule = config.getString("VRES1000_ASaeule"); + string VRES1000_Scheibe = config.getString("VRES1000_Scheibe"); + string VRES1000_Spiegel = config.getString("VRES1000_Spiegel"); + string VRES1100_Spiegel_fein = config.getString("VRES1100_Spiegel_fein"); + + + CommunicatorPtr comm = MPICommunicator::getInstance(); + int myid = comm->getProcessID(); + + if (logToFile) + { +#if defined(__unix__) + if (myid==0) + { + const char* str = pathOut.c_str(); + mkdir(str, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH); + } +#endif + + if (myid==0) + { + stringstream logFilename; + logFilename<<pathOut+"/logfile"+UbSystem::toString(UbSystem::getTimeStamp())+".txt"; + UbLog::output_policy::setStream(logFilename.str()); + } + } + + + double g_minX1 = WTUNNEL1[0]; + double g_minX2 = WTUNNEL1[2]; + double g_minX3 = WTUNNEL1[4]; + + double g_maxX1 = WTUNNEL1[1]; + double g_maxX2 = WTUNNEL1[3]; + double g_maxX3 = WTUNNEL1[5]; + + double blockLength = (double)blockNx[0]*deltaXcoarse; + + //########################################################################## + //## physical parameters + //########################################################################## + + + double rhoLB = 0.0; + double rhoReal = 1.2041; //(kg/m3) + double nueReal = 153.5e-7; //m^2/s + + double lReal = 2.048;//m + double uReal = 140.0*3.6; + + double Re = uReal*lReal/nueReal; + + //##Machzahl: + //#Ma = uReal/csReal + double Ma = 140.0/1236.0;//Ma-Real! + + double uLB = Ma*sqrt(1.0/3.0); + double nuLB = (uLB*1.0)/Re; + + LBMUnitConverterPtr conv = LBMUnitConverterPtr(new LBMUnitConverter()); + + const int baseLevel = 0; + + //////////////////////////////////////////////////////////////////////// + //Grid + ////////////////////////////////////////////////////////////////////////// + Grid3DPtr grid(new Grid3D(comm)); + grid->setDeltaX(deltaXcoarse); + grid->setBlockNX(blockNx[0], blockNx[1], blockNx[2]); + + GbObject3DPtr gridCube(new GbCuboid3D(g_minX1, g_minX2, g_minX3, g_maxX1, g_maxX2, g_maxX3)); + if (myid==0) GbSystem3D::writeGeoObject(gridCube.get(), pathOut+"/geo/gridCube", WbWriterVtkXmlASCII::getInstance()); + GenBlocksGridVisitor genBlocks(gridCube); + grid->accept(genBlocks); + + grid->setPeriodicX1(false); + grid->setPeriodicX2(false); + grid->setPeriodicX3(false); + + //BC adapters + BCAdapterPtr noSlipBCAdapter(new NoSlipBCAdapter()); + noSlipBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new NoSlipBCAlgorithm())); + + BCAdapterPtr slipBCAdapter(new SlipBCAdapter()); + slipBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new SlipBCAlgorithm())); + + mu::Parser fct; + fct.SetExpr("U"); + fct.DefineConst("U", uLB); + BCAdapterPtr velBCAdapter(new VelocityBCAdapter(true, false, false, fct, 0, BCFunction::INFCONST)); + velBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new VelocityBCAlgorithm())); + + BCAdapterPtr denBCAdapter(new DensityBCAdapter(rhoLB)); + denBCAdapter->setBcAlgorithm(BCAlgorithmPtr(new NonEqDensityBCAlgorithm())); + + BoundaryConditionsBlockVisitor bcVisitor; + bcVisitor.addBC(noSlipBCAdapter); + bcVisitor.addBC(slipBCAdapter); + bcVisitor.addBC(velBCAdapter); + bcVisitor.addBC(denBCAdapter); + + ////////////////////////////////////////////////////////////////////////// + //restart + UbSchedulerPtr rSch(new UbScheduler(restartStep, restartStep)); + RestartCoProcessor rp(grid, rSch, comm, pathOut, RestartCoProcessor::BINARY); + ////////////////////////////////////////////////////////////////////////// + + + if (grid->getTimeStep()==0) + { + if (myid==0) + { + UBLOG(logINFO, "Parameters:"); + UBLOG(logINFO, "* Re = "<<Re); + UBLOG(logINFO, "* Ma = "<<Ma); + UBLOG(logINFO, "* velocity (uReal) = "<<uReal<<" m/s"); + UBLOG(logINFO, "* viscosity (nuReal) = "<<nueReal<<" m^2/s"); + UBLOG(logINFO, "* velocity LB (uLB) = "<<uLB); + UBLOG(logINFO, "* viscosity LB (nuLB) = "<<nuLB); + UBLOG(logINFO, "* dx_base = "<<deltaXcoarse<<" m"); + UBLOG(logINFO, "* dx_refine = "<<deltaXfine<<" m"); + UBLOG(logINFO, "* number of levels = "<<refineLevel+1); + UBLOG(logINFO, "* number of threads = "<<numOfThreads); + UBLOG(logINFO, "* number of processes = "<<comm->getNumberOfProcesses()); + UBLOG(logINFO, "Preprozess - start"); + } + + GbCuboid3DPtr geoVRES0100(new GbCuboid3D(VRES0100[0], VRES0100[2], VRES0100[4], VRES0100[1], VRES0100[3], VRES0100[5])); + if (myid==0) GbSystem3D::writeGeoObject(geoVRES0100.get(), pathOut+"/geo/geoVRES0100", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr geoVRES0200(new GbCuboid3D(VRES0200[0], VRES0200[2], VRES0200[4], VRES0200[1], VRES0200[3], VRES0200[5])); + if (myid==0) GbSystem3D::writeGeoObject(geoVRES0200.get(), pathOut+"/geo/geoVRES0200", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr geoVRES0300(new GbCuboid3D(VRES0300[0], VRES0300[2], VRES0300[4], VRES0300[1], VRES0300[3], VRES0300[5])); + if (myid==0) GbSystem3D::writeGeoObject(geoVRES0300.get(), pathOut+"/geo/geoVRES0300", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr geoVRES0400(new GbCuboid3D(VRES0400[0], VRES0400[2], VRES0400[4], VRES0400[1], VRES0400[3], VRES0400[5])); + if (myid==0) GbSystem3D::writeGeoObject(geoVRES0400.get(), pathOut+"/geo/geoVRES0400", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr geoVRES0500(new GbCuboid3D(VRES0500[0], VRES0500[2], VRES0500[4], VRES0500[1], VRES0500[3], VRES0500[5])); + if (myid==0) GbSystem3D::writeGeoObject(geoVRES0500.get(), pathOut+"/geo/geoVRES0500", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr geoVRES0700(new GbCuboid3D(VRES0700[0], VRES0700[2], VRES0700[4], VRES0700[1], VRES0700[3], VRES0700[5])); + if (myid==0) GbSystem3D::writeGeoObject(geoVRES0700.get(), pathOut+"/geo/geoVRES0700", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr geoVRES0900(new GbCuboid3D(VRES0900[0], VRES0900[2], VRES0900[4], VRES0900[1], VRES0900[3], VRES0900[5])); + if (myid==0) GbSystem3D::writeGeoObject(geoVRES0900.get(), pathOut+"/geo/geoVRES0900", WbWriterVtkXmlASCII::getInstance()); + + D3Q27InteractorPtr geoVRES0700Int(new D3Q27Interactor(geoVRES0700, grid, noSlipBCAdapter, Interactor3D::SOLID)); + + //GEO + if (myid==0) UBLOG(logINFO, "Read geoSAE:start"); + GbTriFaceMesh3DPtr geoSAE = GbTriFaceMesh3DPtr(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(pathGeo+"/"+SAE, "meshSAE", GbTriFaceMesh3D::KDTREE_SAHPLIT, true)); + if (myid==0) UBLOG(logINFO, "Read meshSAE:end"); + if (myid==0) GbSystem3D::writeGeoObject(geoSAE.get(), pathOut+"/geo/meshSAE", WbWriterVtkXmlBinary::getInstance()); + + D3Q27TriFaceMeshInteractorPtr geoSAEInteractor(new D3Q27TriFaceMeshInteractor(geoSAE, grid, noSlipBCAdapter, Interactor3D::SOLID)); + + + + if (myid==0) + { + ////////////////////////////////////////// + //meshes + if (myid==0) UBLOG(logINFO, "Read meshVRES0600:start"); + GbTriFaceMesh3DPtr meshVRES0600 = GbTriFaceMesh3DPtr(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(pathMesh+"/"+VRES0600_chopped, "meshVRES0600", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); + if (myid==0) UBLOG(logINFO, "Read meshVRES0600:end"); + if (myid==0) GbSystem3D::writeGeoObject(meshVRES0600.get(), pathOut+"/geo/meshVRES0600", WbWriterVtkXmlBinary::getInstance()); + D3Q27TriFaceMeshInteractorPtr meshVRES0600Interactor(new D3Q27TriFaceMeshInteractor(meshVRES0600, grid, noSlipBCAdapter, Interactor3D::SOLID)); + + if (myid==0) UBLOG(logINFO, "Read meshVRES0700:start"); + GbTriFaceMesh3DPtr meshVRES0700 = GbTriFaceMesh3DPtr(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(pathMesh+"/"+VRES0700_chopped, "meshVRES0700", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); + if (myid==0) UBLOG(logINFO, "Read meshVRES0700:end"); + if (myid==0) GbSystem3D::writeGeoObject(meshVRES0700.get(), pathOut+"/geo/meshVRES0700", WbWriterVtkXmlBinary::getInstance()); + D3Q27TriFaceMeshInteractorPtr meshVRES0700Interactor(new D3Q27TriFaceMeshInteractor(meshVRES0700, grid, noSlipBCAdapter, Interactor3D::SOLID)); + + if (myid==0) UBLOG(logINFO, "Read meshVRES0800:start"); + GbTriFaceMesh3DPtr meshVRES0800 = GbTriFaceMesh3DPtr(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(pathMesh+"/"+VRES0800_Fahrzeug, "meshVRES0800", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); + if (myid==0) UBLOG(logINFO, "Read meshVRES0800:end"); + if (myid==0) GbSystem3D::writeGeoObject(meshVRES0800.get(), pathOut+"/geo/meshVRES0800", WbWriterVtkXmlBinary::getInstance()); + D3Q27TriFaceMeshInteractorPtr meshVRES0800Interactor(new D3Q27TriFaceMeshInteractor(meshVRES0800, grid, noSlipBCAdapter, Interactor3D::SOLID)); + + //if (myid==0) UBLOG(logINFO, "Read meshVRES0900:start"); + //GbTriFaceMesh3DPtr meshVRES0900 = GbTriFaceMesh3DPtr(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(pathMesh+"/"+VRES0900, "meshVRES0900", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); + //if (myid==0) UBLOG(logINFO, "Read meshVRES0900:end"); + //if (myid==0) GbSystem3D::writeGeoObject(meshVRES0900.get(), pathOut+"/geo/meshVRES0900", WbWriterVtkXmlBinary::getInstance()); + //D3Q27TriFaceMeshInteractorPtr meshVRES0900Interactor(new D3Q27TriFaceMeshInteractor(meshVRES0900, grid, noSlipBCAdapter, Interactor3D::SOLID)); + + if (myid==0) UBLOG(logINFO, "Read meshVRES1000ASaeule:start"); + GbTriFaceMesh3DPtr meshVRES1000ASaeule = GbTriFaceMesh3DPtr(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(pathMesh+"/"+VRES1000_ASaeule, "meshVRES1000ASaeule", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); + if (myid==0) UBLOG(logINFO, "Read meshVRES1000ASaeule:end"); + if (myid==0) GbSystem3D::writeGeoObject(meshVRES1000ASaeule.get(), pathOut+"/geo/meshVRES1000ASaeule", WbWriterVtkXmlBinary::getInstance()); + D3Q27TriFaceMeshInteractorPtr meshVRES1000ASaeuleInteractor(new D3Q27TriFaceMeshInteractor(meshVRES1000ASaeule, grid, noSlipBCAdapter, Interactor3D::SOLID)); + + if (myid==0) UBLOG(logINFO, "Read meshVRES1000Scheibe:start"); + GbTriFaceMesh3DPtr meshVRES1000Scheibe = GbTriFaceMesh3DPtr(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(pathMesh+"/"+VRES1000_Scheibe, "meshVRES1000Scheibe", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); + if (myid==0) UBLOG(logINFO, "Read meshVRES1000Scheibe:end"); + if (myid==0) GbSystem3D::writeGeoObject(meshVRES1000Scheibe.get(), pathOut+"/geo/meshVRES1000Scheibe", WbWriterVtkXmlBinary::getInstance()); + D3Q27TriFaceMeshInteractorPtr meshVRES1000ScheibeInteractor(new D3Q27TriFaceMeshInteractor(meshVRES1000Scheibe, grid, noSlipBCAdapter, Interactor3D::SOLID)); + + if (myid==0) UBLOG(logINFO, "Read meshVRES1000Spiegel:start"); + GbTriFaceMesh3DPtr meshVRES1000Spiegel = GbTriFaceMesh3DPtr(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(pathMesh+"/"+VRES1000_Spiegel, "meshSpiegel", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); + if (myid==0) UBLOG(logINFO, "Read meshVRES1000Spiegel:end"); + if (myid==0) GbSystem3D::writeGeoObject(meshVRES1000Spiegel.get(), pathOut+"/geo/meshVRES1000Spiegel", WbWriterVtkXmlBinary::getInstance()); + D3Q27TriFaceMeshInteractorPtr meshVRES1000SpiegelInteractor(new D3Q27TriFaceMeshInteractor(meshVRES1000Spiegel, grid, noSlipBCAdapter, Interactor3D::SOLID)); + + if (myid==0) UBLOG(logINFO, "Read meshVRES1100SpiegelFine:start"); + GbTriFaceMesh3DPtr meshVRES1100SpiegelFine = GbTriFaceMesh3DPtr(GbTriFaceMesh3DCreator::getInstance()->readMeshFromSTLFile(pathMesh+"/"+VRES1100_Spiegel_fein, "meshSpiegelFine", GbTriFaceMesh3D::KDTREE_SAHPLIT, false)); + if (myid==0) UBLOG(logINFO, "Read meshVRES1100SpiegelFine:end"); + if (myid==0) GbSystem3D::writeGeoObject(meshVRES1100SpiegelFine.get(), pathOut+"/geo/meshVRES1100SpiegelFine", WbWriterVtkXmlBinary::getInstance()); + D3Q27TriFaceMeshInteractorPtr meshVRES1100SpiegelFineInteractor(new D3Q27TriFaceMeshInteractor(meshVRES1100SpiegelFine, grid, noSlipBCAdapter, Interactor3D::SOLID)); + + UBLOG(logINFO, "Refinement - start"); + RefineCrossAndInsideGbObjectHelper refineHelper(grid, refineLevel); + ////refineHelper.addGbObject(geoVRES0100, refineLevel-4); + //refineHelper.addGbObject(geoVRES0200, 1); + //refineHelper.addGbObject(geoVRES0300, 2); + //refineHelper.addGbObject(geoVRES0400, 3); + //refineHelper.addGbObject(geoVRES0500, 4); + //refineHelper.addGbObject(geoVRES0700, 7); + //refineHelper.addGbObject(geoVRES0900, 9); + //refineHelper.refine(); + + RefineCrossAndInsideGbObjectBlockVisitor geoVRES0200RefVisitor(geoVRES0200, 1); + grid->accept(geoVRES0200RefVisitor); + RefineCrossAndInsideGbObjectBlockVisitor geoVRES0300RefVisitor(geoVRES0300, 2); + grid->accept(geoVRES0300RefVisitor); + RefineCrossAndInsideGbObjectBlockVisitor geoVRES0400RefVisitor(geoVRES0400, 3); + grid->accept(geoVRES0400RefVisitor); + RefineCrossAndInsideGbObjectBlockVisitor geoVRES0500RefVisitor(geoVRES0500, 4); + grid->accept(geoVRES0500RefVisitor); + + + int rank = grid->getRank(); + grid->setRank(0); + meshVRES0600Interactor->refineBlockGridToLevel(5, 0.0, 0.0); + meshVRES0700Interactor->refineBlockGridToLevel(6, -0.6, 0.0); + + UBLOG(logINFO, "Refinement - geoVRES0700"); + RefineCrossAndInsideGbObjectBlockVisitor geoVRES0700RefVisitor(geoVRES0700, 7); + grid->accept(geoVRES0700RefVisitor); + + UBLOG(logINFO, "Refinement - geoSAEInteractor"); + meshVRES0800Interactor->refineBlockGridToLevel(8, -0.5, 0.0); + //geoSAEInteractor->refineBlockGridToLevel(8, 0.0, 0.1); + + //SetSolidOrTransBlockVisitor v(geoSAEInteractor, SetSolidOrTransBlockVisitor::SOLID); + //grid->accept(v); + //std::vector<Block3DPtr>& sb = geoSAEInteractor->getSolidBlockSet(); + //BOOST_FOREACH(Block3DPtr block, sb) + //{ + // grid->deleteBlock(block); + //} + //geoSAEInteractor->removeSolidBlocks(); + //geoSAEInteractor->removeTransBlocks(); + + UBLOG(logINFO, "Refinement - geoVRES0900RefVisitor"); + //meshVRES0900Interactor->refineBlockGridToLevel(9, 0.0, 0.0); + RefineCrossAndInsideGbObjectBlockVisitor geoVRES0900RefVisitor(geoVRES0900, 9); + grid->accept(geoVRES0900RefVisitor); + + UBLOG(logINFO, "Refinement - meshVRES1000ASaeuleInteractor"); + meshVRES1000ASaeuleInteractor->refineBlockGridToLevel(10, -0.1, 0.0); + + UBLOG(logINFO, "Refinement - meshVRES1000ScheibeInteractor"); + meshVRES1000ScheibeInteractor->refineBlockGridToLevel(10, -0.1, 0.0); + + UBLOG(logINFO, "Refinement - meshVRES1000SpiegelInteractor"); + meshVRES1000SpiegelInteractor->refineBlockGridToLevel(10, -0.12, 0.0); + + UBLOG(logINFO, "Refinement - meshVRES1100SpiegelFineInteractor"); + meshVRES1100SpiegelFineInteractor->refineBlockGridToLevel(11, -0.12, 0.0); + grid->setRank(rank); + + /////////////////////////////////////////////////////////// + ///BOX + //GbCuboid3DPtr geoBox1(new GbCuboid3D(-0.495, -0.8, 0.545, -0.045, -0.7, 0.795)); + //if (myid==0) GbSystem3D::writeGeoObject(geoBox1.get(), pathOut+"/geo/geoBox1", WbWriterVtkXmlASCII::getInstance()); + //CoarsenCrossAndInsideGbObjectBlockVisitor geoBox1Visitor(geoBox1, 11, 11); + //grid->accept(geoBox1Visitor); + ////////////////////////////////////////////////////////////////////////// + + + if (myid==0) + { + WriteBlocksCoProcessor ppblocks(grid, UbSchedulerPtr(new UbScheduler(1)), pathOut, WbWriterVtkXmlBinary::getInstance(), comm); + ppblocks.process(0); + } + + RatioBlockVisitor ratioVisitor(refineLevel); + CheckRatioBlockVisitor checkRatio(refineLevel); + int count = 0; + + do { + UBLOG(logINFO, "Refinement - RatioBlockVisitor"); + grid->accept(ratioVisitor); + checkRatio.resetState(); + UBLOG(logINFO, "Refinement - CheckRatioBlockVisitor"); + grid->accept(checkRatio); + if (myid==0) UBLOG(logINFO, "count ="<<count++<<" state="<<checkRatio.getState()); + } while (!checkRatio.getState()); + + UBLOG(logINFO, "Refinement - OverlapBlockVisitor"); + OverlapBlockVisitor overlapVisitor(refineLevel, false); + grid->accept(overlapVisitor); + + if (myid==0) UBLOG(logINFO, "Refinement - end"); + + if (myid==0) + { + WriteBlocksCoProcessor ppblocks(grid, UbSchedulerPtr(new UbScheduler(1)), pathOut, WbWriterVtkXmlBinary::getInstance(), comm); + ppblocks.process(1); + } + } + + grid->updateDistributedBlocks(comm); + + if (myid == 0) UBLOG(logINFO, "SetInterpolationDirsBlockVisitor"); + std::vector<int> dirs; + for (int i = D3Q27System::E; i<=D3Q27System::TS; i++) + { + dirs.push_back(i); + } + SetInterpolationDirsBlockVisitor interDirsVisitor(dirs); + grid->accept(interDirsVisitor); + + ////////////////////////////////////////////////////////////////////////// + + + //walls + GbCuboid3DPtr addWallYmin(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_minX2, g_maxX3+blockLength)); + if (myid==0) GbSystem3D::writeGeoObject(addWallYmin.get(), pathOut+"/geo/addWallYmin", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr addWallYmax(new GbCuboid3D(g_minX1-blockLength, g_maxX2, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); + if (myid==0) GbSystem3D::writeGeoObject(addWallYmax.get(), pathOut+"/geo/addWallYmax", WbWriterVtkXmlASCII::getInstance()); + + //wall interactors + D3Q27InteractorPtr addWallYminInt(new D3Q27Interactor(addWallYmin, grid, slipBCAdapter, Interactor3D::SOLID)); + D3Q27InteractorPtr addWallYmaxInt(new D3Q27Interactor(addWallYmax, grid, slipBCAdapter, Interactor3D::SOLID)); + + //walls + GbCuboid3DPtr addWallZmin(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_minX3)); + if (myid==0) GbSystem3D::writeGeoObject(addWallZmin.get(), pathOut+"/geo/addWallZmin", WbWriterVtkXmlASCII::getInstance()); + + GbCuboid3DPtr addWallZmax(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_maxX3, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); + if (myid==0) GbSystem3D::writeGeoObject(addWallZmax.get(), pathOut+"/geo/addWallZmax", WbWriterVtkXmlASCII::getInstance()); + + //wall interactors + D3Q27InteractorPtr addWallZminInt(new D3Q27Interactor(addWallZmin, grid, slipBCAdapter, Interactor3D::SOLID)); + D3Q27InteractorPtr addWallZmaxInt(new D3Q27Interactor(addWallZmax, grid, slipBCAdapter, Interactor3D::SOLID)); + + //inflow + GbCuboid3DPtr geoInflow(new GbCuboid3D(g_minX1-blockLength, g_minX2-blockLength, g_minX3-blockLength, g_minX1, g_maxX2+blockLength, g_maxX3+blockLength)); + if (myid==0) GbSystem3D::writeGeoObject(geoInflow.get(), pathOut+"/geo/geoInflow", WbWriterVtkXmlASCII::getInstance()); + + //outflow + GbCuboid3DPtr geoOutflow(new GbCuboid3D(g_maxX1, g_minX2-blockLength, g_minX3-blockLength, g_maxX1+blockLength, g_maxX2+blockLength, g_maxX3+blockLength)); + if (myid==0) GbSystem3D::writeGeoObject(geoOutflow.get(), pathOut+"/geo/geoOutflow", WbWriterVtkXmlASCII::getInstance()); + + //inflow + D3Q27InteractorPtr inflowIntr = D3Q27InteractorPtr(new D3Q27Interactor(geoInflow, grid, velBCAdapter, Interactor3D::SOLID)); + + //outflow + D3Q27InteractorPtr outflowIntr = D3Q27InteractorPtr(new D3Q27Interactor(geoOutflow, grid, denBCAdapter, Interactor3D::SOLID)); + + //////////////////////////////////////////// + //METIS + Grid3DVisitorPtr metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::KWAY)); + //////////////////////////////////////////// + /////delete solid blocks + if (myid==0) UBLOG(logINFO, "deleteSolidBlocks - start"); + InteractorsHelper intHelper(grid, metisVisitor); + intHelper.addInteractor(inflowIntr); + intHelper.addInteractor(outflowIntr); + intHelper.addInteractor(addWallYminInt); + intHelper.addInteractor(addWallYmaxInt); + intHelper.addInteractor(addWallZminInt); + intHelper.addInteractor(addWallZmaxInt); + intHelper.addInteractor(geoVRES0700Int); + intHelper.addInteractor(geoSAEInteractor); + ////////////////////////////////////////////////////////////////////////// + intHelper.selectBlocks(); + + if (myid==0) UBLOG(logINFO, "deleteSolidBlocks - end"); + ////////////////////////////////////// + + if (myid==0) + { + WriteBlocksCoProcessorPtr ppblocks(new WriteBlocksCoProcessor(grid, UbSchedulerPtr(new UbScheduler(1)), pathOut, WbWriterVtkXmlBinary::getInstance(), comm)); + ppblocks->process(2); + ppblocks.reset(); + } + unsigned long long numberOfBlocks = (unsigned long long)grid->getNumberOfBlocks(); + int ghostLayer = 3; + unsigned long long numberOfNodesPerBlock = (unsigned long long)(blockNx[0])* (unsigned long long)(blockNx[1])* (unsigned long long)(blockNx[2]); + unsigned long long numberOfNodes = numberOfBlocks * numberOfNodesPerBlock; + unsigned long long numberOfNodesPerBlockWithGhostLayer = numberOfBlocks * (blockNx[0]+ghostLayer) * (blockNx[1]+ghostLayer) * (blockNx[2]+ghostLayer); + double needMemAll = double(numberOfNodesPerBlockWithGhostLayer*(27*sizeof(double)+sizeof(int)+sizeof(float)*4)); + double needMem = needMemAll/double(comm->getNumberOfProcesses()); + + if (myid==0) + { + UBLOG(logINFO, "Number of blocks = "<<numberOfBlocks); + UBLOG(logINFO, "Number of nodes = "<<numberOfNodes); + int minInitLevel = grid->getCoarsestInitializedLevel(); + int maxInitLevel = grid->getFinestInitializedLevel(); + for (int level = minInitLevel; level<=maxInitLevel; level++) + { + int nobl = grid->getNumberOfBlocks(level); + UBLOG(logINFO, "Number of blocks for level "<<level<<" = "<<nobl); + UBLOG(logINFO, "Number of nodes for level "<<level<<" = "<<nobl*numberOfNodesPerBlock); + } + UBLOG(logINFO, "Necessary memory = "<<needMemAll<<" bytes"); + UBLOG(logINFO, "Necessary memory per process = "<<needMem<<" bytes"); + UBLOG(logINFO, "Available memory per process = "<<availMem<<" bytes"); + } + + LBMKernelPtr kernel = LBMKernelPtr(new CompressibleCumulantLBMKernel(blockNx[0], blockNx[1], blockNx[2], CompressibleCumulantLBMKernel::NORMAL)); + + BCProcessorPtr bcProc; + + bcProc = BCProcessorPtr(new BCProcessor()); + + kernel->setBCProcessor(bcProc); + + SetKernelBlockVisitor kernelVisitor(kernel, nuLB, availMem, needMem); + grid->accept(kernelVisitor); + + if (refineLevel>0) + { + SetUndefinedNodesBlockVisitor undefNodesVisitor; + grid->accept(undefNodesVisitor); + } + + //BC + intHelper.setBC(); + + grid->accept(bcVisitor); + + //initialization of distributions + InitDistributionsBlockVisitor initVisitor(nuLB, rhoLB); + initVisitor.setVx1(fct); + initVisitor.setNu(nuLB); + grid->accept(initVisitor); + + ////set connectors + InterpolationProcessorPtr iProcessor(new CompressibleOffsetInterpolationProcessor()); + SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); + grid->accept(setConnsVisitor); + + //domain decomposition for threads + PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); + grid->accept(pqPartVisitor); + + //Postrozess + UbSchedulerPtr geoSch(new UbScheduler(1)); + WriteBoundaryConditionsCoProcessorPtr ppgeo( + new WriteBoundaryConditionsCoProcessor(grid, geoSch, pathOut, WbWriterVtkXmlBinary::getInstance(), conv, comm)); + ppgeo->process(0); + ppgeo.reset(); + + if (myid==0) UBLOG(logINFO, "Preprozess - end"); + } + else + { + InterpolationProcessorPtr iProcessor(new CompressibleOffsetInterpolationProcessor()); + SetConnectorsBlockVisitor setConnsVisitor(comm, true, D3Q27System::ENDDIR, nuLB, iProcessor); + grid->accept(setConnsVisitor); + + //domain decomposition for threads + PQueuePartitioningGridVisitor pqPartVisitor(numOfThreads); + grid->accept(pqPartVisitor); + + grid->accept(bcVisitor); + } + + UbSchedulerPtr nupsSch(new UbScheduler(nupsStep[0], nupsStep[1], nupsStep[2])); + NUPSCounterCoProcessor npr(grid, nupsSch, numOfThreads, comm); + + UbSchedulerPtr stepSch(new UbScheduler(outTime)); + + WriteMacroscopicQuantitiesCoProcessor pp(grid, stepSch, pathOut, WbWriterVtkXmlBinary::getInstance(), conv, comm); + + if (myid==0) + { + UBLOG(logINFO, "PID = "<<myid<<" Total Physical Memory (RAM): "<<Utilities::getTotalPhysMem()); + UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used: "<<Utilities::getPhysMemUsed()); + UBLOG(logINFO, "PID = "<<myid<<" Physical Memory currently used by current process: "<<Utilities::getPhysMemUsedByMe()); + } + + CalculationManagerPtr calculation(new CalculationManager(grid, numOfThreads, endTime, stepSch)); + if (myid==0) UBLOG(logINFO, "Simulation-start"); + calculation->calculate(); + if (myid==0) UBLOG(logINFO, "Simulation-end"); + } + catch (std::exception& e) + { + cerr<<e.what()<<endl<<flush; + } + catch (std::string& s) + { + cerr<<s<<endl; + } + catch (...) + { + cerr<<"unknown exception"<<endl; + } + +} + +int main(int argc, char* argv[]) +{ + + if (argv!=NULL) + { + if (argv[1]!=NULL) + { + run(string(argv[1])); + } + else + { + cout<<"Configuration file must be set!: "<<argv[0]<<" <config file>"<<endl<<std::flush; + } + } + + return 0; +} + diff --git a/source/Applications/mirror/mirrorV1.cfg b/source/Applications/mirror/mirrorV1.cfg new file mode 100644 index 000000000..57d04a768 --- /dev/null +++ b/source/Applications/mirror/mirrorV1.cfg @@ -0,0 +1,60 @@ +pathOut = d:/temp/mirror5 +pathGeo = d:/Projects/Spiegelbenchmark/geometry +pathMesh = d:/Projects/Spiegelbenchmark/meshBoxes + +#geometry +SAE = SAE_GRUNDKOERPER_CFD_INPUT_VERFEINERT_in_m_SOLID.ASCII_D_0.8.stl + + +#refinement meshes +VRES0600_chopped = VRES0600_chopped.stl +VRES0700_chopped = VRES0700_chopped.stl +VRES0800_Fahrzeug = VRES0800_Fahrzeug.stl +#VRES0900 = VRES0900_Cube.stl +VRES1000_ASaeule = VRES1000_ASaeule.stl +VRES1000_Scheibe = VRES1000_Scheibe.stl +VRES1000_Spiegel = VRES1000_Spiegel.stl +VRES1100_Spiegel_fein = VRES1100_Spiegel_fein.stl + + +numOfThreads = 4 +availMem = 10e9 +refineLevel = 11 +#blockNx = 9 8 9 +blockNx = 5 5 5 + +#x1min x1max x2min x2max x3min x3max [m] +#bounding box +WTUNNEL1 = -35.8 37.4 -31.5 31.5 -0.177 32.8 + +#refinement cubes +VRES0100 = -18.4 24.5 -16.2 16.2 -0.187 16.5 +VRES0200 = -10.7 16.8 -8.56 8.56 -0.187 8.82 +VRES0300 = -6.9 13 -4.72 4.72 -0.187 4.98 +VRES0400 = -4.21 10.8 -2.8 2.8 -0.187 3.06 +VRES0500 = -2.87 8.74 -1.84 1.84 -0.187 2.1 +VRES0700 = -2.6 4.69 -1.25 1.25 -0.255 -0.125 +VRES0900 = -0.823 0.941 -1.15 -0.7 0.502 1.01 + +#deltaXcoarse = 4096e-3 #level 0 +deltaXcoarse = 2.048 #level 0 +deltaXfine = 1e-3 #level 11 + + +refineDistance = 0.3 + +restartStep = 1 +restartStepStart = 100 + +outTime = 1 +endTime = 10 + +logToFile = false + +porousTralingEdge = false + +thinWall = false + +testBox=false + +nupsStep = 1 1 10000000 \ No newline at end of file diff --git a/source/CMake/cmake_config_files/GOTTFRIED.config.cmake b/source/CMake/cmake_config_files/GOTTFRIED.config.cmake index 7ae33238d..2144d13c1 100644 --- a/source/CMake/cmake_config_files/GOTTFRIED.config.cmake +++ b/source/CMake/cmake_config_files/GOTTFRIED.config.cmake @@ -30,9 +30,9 @@ SET(BOOST_VERSION "1.54.0" CACHE STRING "std: 1.54.0") # METIS ################################################################################# IF(${USE_METIS}) - SET(METIS_INCLUDEDIR "/gfs1/work/niivfcpu/libs/metis/include") - SET(METIS_DEBUG_LIBRARY "/gfs1/work/niivfcpu/libs/metis/lib/libmetis.a") - SET(METIS_RELEASE_LIBRARY "/gfs1/work/niivfcpu/libs/metis/lib/libmetis.a") + SET(METIS_INCLUDEDIR "/gfs1/work/niikonst/libs/metis/include") + SET(METIS_DEBUG_LIBRARY "/gfs1/work/niikonst/libs/metis/lib/libmetis.a") + SET(METIS_RELEASE_LIBRARY "/gfs1/work/niikonst/libs/metis/lib/libmetis.a") ENDIF() # ################################################################################# diff --git a/source/CMake/cmake_config_files/KONRAD.config.cmake b/source/CMake/cmake_config_files/KONRAD.config.cmake index 7ae33238d..2144d13c1 100644 --- a/source/CMake/cmake_config_files/KONRAD.config.cmake +++ b/source/CMake/cmake_config_files/KONRAD.config.cmake @@ -30,9 +30,9 @@ SET(BOOST_VERSION "1.54.0" CACHE STRING "std: 1.54.0") # METIS ################################################################################# IF(${USE_METIS}) - SET(METIS_INCLUDEDIR "/gfs1/work/niivfcpu/libs/metis/include") - SET(METIS_DEBUG_LIBRARY "/gfs1/work/niivfcpu/libs/metis/lib/libmetis.a") - SET(METIS_RELEASE_LIBRARY "/gfs1/work/niivfcpu/libs/metis/lib/libmetis.a") + SET(METIS_INCLUDEDIR "/gfs1/work/niikonst/libs/metis/include") + SET(METIS_DEBUG_LIBRARY "/gfs1/work/niikonst/libs/metis/lib/libmetis.a") + SET(METIS_RELEASE_LIBRARY "/gfs1/work/niikonst/libs/metis/lib/libmetis.a") ENDIF() # ################################################################################# diff --git a/source/CMake/compilerflags/gcc62.cmake b/source/CMake/compilerflags/gcc62.cmake new file mode 100644 index 000000000..5e80808ac --- /dev/null +++ b/source/CMake/compilerflags/gcc62.cmake @@ -0,0 +1,50 @@ +############################################################################################################### +## +## gcc62 +## +############################################################################################################### + +MACRO(SET_COMPILER_SPECIFIC_FLAGS_INTERN build_type use64BitOptions) + ############################################################################################################# + # Flags + ############################################################################################################# + LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-O3 -fomit-frame-pointer -finline-functions -funroll-all-loops -fPIC") + LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-Wno-deprecated") #deprecated header warning (jarl benutzt sstream weil schneller und so) + + LIST(APPEND CAB_COMPILER_ADDTIONAL_C_COMPILER_FLAGS "-O3 -fomit-frame-pointer -finline-functions -funroll-all-loops -fPIC") + + ############################################################################################################# + # 64Bit support + ############################################################################################################# + IF( ${use64BitOptions} ) + LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-m64" ) + LIST(APPEND CAB_COMPILER_ADDTIONAL_C_COMPILER_FLAGS "-m64" ) + ENDIF() + + ############################################################################################################# + # OpenMP support + ############################################################################################################# + IF(USE_OPENMP) + LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-fopenmp") + LIST(APPEND CAB_COMPILER_ADDTIONAL_C_COMPILER_FLAGS "-fopenmp") + ENDIF() + + ############################################################################################################# + # mt support + ############################################################################################################# + LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-pthread") + LIST(APPEND CAB_COMPILER_ADDTIONAL_C_COMPILER_FLAGS "-pthread") + + ############################################################################################################# + # c++ 11 support + ############################################################################################################# + LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-std=c++11") + LIST(APPEND CAB_COMPILER_ADDTIONAL_C_COMPILER_FLAGS "-std=c++11") + + + + IF(NOT APPLE) + LIST(APPEND CAB_ADDITIONAL_LINK_PROPS "-lrt") + ENDIF() + +ENDMACRO(SET_COMPILER_SPECIFIC_FLAGS_INTERN build_type use64BitOptions) diff --git a/source/IncludsList.cmake b/source/IncludsList.cmake index 730ed546d..32719390c 100644 --- a/source/IncludsList.cmake +++ b/source/IncludsList.cmake @@ -2,7 +2,7 @@ INCLUDE_DIRECTORIES(${SOURCE_ROOT}) INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore) -INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/BoundaryCondition ) +INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/BoundaryConditions) INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/Connectors) INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/Data) INCLUDE_DIRECTORIES(${SOURCE_ROOT}/VirtualFluidsCore/Interactors) diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.cpp b/source/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.cpp index c7823d0da..5a88c38b7 100644 --- a/source/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.cpp +++ b/source/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.cpp @@ -10,7 +10,7 @@ #include <basics/utilities/UbSystem.h> #ifdef MC_CUBES - #include <MarchingCubes/MarchingCubes.h> +#include <MarchingCubes/MarchingCubes.h> #endif // MC_CUBES using namespace std; @@ -46,41 +46,41 @@ GbVoxelMatrix3D::GbVoxelMatrix3D(int nx1, int nx2, int nx3, float initVal, doubl this->setName("VoxelMatrix3D"); } /*=======================================================*/ -GbVoxelMatrix3D::GbVoxelMatrix3D() - : GbObject3D() - , minX1(0.0) - , minX2(0.0) - , minX3(0.0) - , nodesX1(0) - , nodesX2(0) - , nodesX3(0) - , lowerThreshold(0.0) - , upperThreshold(0.0) - , deltaX1(1.0) - , deltaX2(1.0) - , deltaX3(1.0) - , transferViaFilename(false) - , addSurfaceTriangleSetFlag(true) +GbVoxelMatrix3D::GbVoxelMatrix3D() + : GbObject3D() + , minX1(0.0) + , minX2(0.0) + , minX3(0.0) + , nodesX1(0) + , nodesX2(0) + , nodesX3(0) + , lowerThreshold(0.0) + , upperThreshold(0.0) + , deltaX1(1.0) + , deltaX2(1.0) + , deltaX3(1.0) + , transferViaFilename(false) + , addSurfaceTriangleSetFlag(true) { this->setName("VoxelMatrix3D"); } /*=======================================================*/ GbVoxelMatrix3D::GbVoxelMatrix3D(const Matrix3D& voxelMatrix, double lowerThreshold, double upperThreshold) - : GbObject3D() - , minX1(0.0) - , minX2(0.0) - , minX3(0.0) - , nodesX1((int)voxelMatrix.getNX1()) - , nodesX2((int)voxelMatrix.getNX2()) - , nodesX3((int)voxelMatrix.getNX3()) - , lowerThreshold(lowerThreshold) - , upperThreshold(upperThreshold) - , deltaX1(1.0) - , deltaX2(1.0) - , deltaX3(1.0) - , transferViaFilename(false) - , addSurfaceTriangleSetFlag(true) - , voxelMatrix(voxelMatrix) + : GbObject3D() + , minX1(0.0) + , minX2(0.0) + , minX3(0.0) + , nodesX1((int)voxelMatrix.getNX1()) + , nodesX2((int)voxelMatrix.getNX2()) + , nodesX3((int)voxelMatrix.getNX3()) + , lowerThreshold(lowerThreshold) + , upperThreshold(upperThreshold) + , deltaX1(1.0) + , deltaX2(1.0) + , deltaX3(1.0) + , transferViaFilename(false) + , addSurfaceTriangleSetFlag(true) + , voxelMatrix(voxelMatrix) { this->setName("VoxelMatrix3D"); } @@ -93,13 +93,13 @@ GbVoxelMatrix3D* GbVoxelMatrix3D::clone() return vm; } /*=======================================================*/ -void GbVoxelMatrix3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3) +void GbVoxelMatrix3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3) { - this->translate(x1-getX1Centroid(), x2-getX2Centroid(), x3-getX3Centroid() ); + this->translate(x1-getX1Centroid(), x2-getX2Centroid(), x3-getX3Centroid()); } /*=======================================================*/ void GbVoxelMatrix3D::translate(const double& tx1, const double& tx2, const double& tx3) -{ +{ this->minX1 += tx1; this->minX2 += tx2; this->minX3 += tx3; @@ -124,9 +124,9 @@ void GbVoxelMatrix3D::setClosedVoidSpaceToSolid() x2Nbr.push_back(x2); x3Nbr.push_back(x3); int size = (int)x1Nbr.size(); - while (size > 0) + while (size>0) { - for (int i = 0; i < size; i++) + for (int i = 0; i<size; i++) { findFluidNeighbor(x1Nbr[i], x2Nbr[i], x3Nbr[i]); } @@ -161,11 +161,11 @@ void GbVoxelMatrix3D::findFluidNeighbor(int x1, int x2, int x3) int j1 = x1+k1; int j2 = x2+k2; int j3 = x3+k3; - if (j1>=0 && j1<nodesX1 && j2>=0 && j2<nodesX2 && j3>=0 && j3<nodesX3) + if (j1>=0&&j1<nodesX1 && j2>=0&&j2<nodesX2 && j3>=0&&j3<nodesX3) { if (voxelMatrix(j1, j2, j3)==FLUID) { - if (flagMatrix(j1, j2, j3) == 0) + if (flagMatrix(j1, j2, j3)==0) { voxelMatrixTemp(j1, j2, j3) = FLUID; flagMatrix(j1, j2, j3) = 1; @@ -188,13 +188,13 @@ void GbVoxelMatrix3D::calculateNumberOfSolidAndFluid() for (int x2 = 0; x2<nodesX2; x2++) for (int x1 = 0; x1<nodesX1; x1++) { - if (voxelMatrix(x1, x2, x3) == GbVoxelMatrix3D::SOLID) + if (voxelMatrix(x1, x2, x3)==GbVoxelMatrix3D::SOLID) { numberOfSolid++; } } - numberOfFluid = (long)nodesX1*(long)nodesX2*(long)nodesX3 - numberOfSolid; + numberOfFluid = (long)nodesX1*(long)nodesX2*(long)nodesX3-numberOfSolid; } /*=======================================================*/ long GbVoxelMatrix3D::getNumberOfSolid() @@ -209,11 +209,11 @@ long GbVoxelMatrix3D::getNumberOfFluid() /*=======================================================*/ double GbVoxelMatrix3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) { - if( !( (UbMath::equal(rx1,0.0) || UbMath::equal(fabs(rx1),1.0) || UbMath::equal(fabs(rx1),UbMath::one_over_sqrt2) ) - && (UbMath::equal(rx2,0.0) || UbMath::equal(fabs(rx2),1.0) || UbMath::equal(fabs(rx2),UbMath::one_over_sqrt2) ) - && (UbMath::equal(rx3,0.0) || UbMath::equal(fabs(rx3),1.0) || UbMath::equal(fabs(rx3),UbMath::one_over_sqrt2) ) ) ) + if (!((UbMath::equal(rx1, 0.0)||UbMath::equal(fabs(rx1), 1.0)||UbMath::equal(fabs(rx1), UbMath::one_over_sqrt2)) + &&(UbMath::equal(rx2, 0.0)||UbMath::equal(fabs(rx2), 1.0)||UbMath::equal(fabs(rx2), UbMath::one_over_sqrt2)) + &&(UbMath::equal(rx3, 0.0)||UbMath::equal(fabs(rx3), 1.0)||UbMath::equal(fabs(rx3), UbMath::one_over_sqrt2)))) { - throw UbException(UB_EXARGS,"nur fuer diskrete Boltzmannrichungen implementiert!!!"); + throw UbException(UB_EXARGS, "nur fuer diskrete Boltzmannrichungen implementiert!!!"); } //nachbarindex ermitteln @@ -225,43 +225,43 @@ double GbVoxelMatrix3D::getIntersectionRaytraceFactor(const double& x1, const do if (UbMath::greater(rx3, 0.0)) ndx3 = 1; else if (UbMath::less(rx3, 0.0)) ndx3 = -1; - int nix1 = UbMath::integerRounding( (x1-minX1)/deltaX1 )+ndx1; - int nix2 = UbMath::integerRounding( (x2-minX2)/deltaX2 )+ndx2; - int nix3 = UbMath::integerRounding( (x3-minX3)/deltaX3 )+ndx3; + int nix1 = UbMath::integerRounding((x1-minX1)/deltaX1)+ndx1; + int nix2 = UbMath::integerRounding((x2-minX2)/deltaX2)+ndx2; + int nix3 = UbMath::integerRounding((x3-minX3)/deltaX3)+ndx3; //test ob nachbar solid - if( nix1>=0 - && nix2>=0 - && nix3>=0 - && nix1<voxelMatrix.getNX1() - && nix2<voxelMatrix.getNX2() - && nix3<voxelMatrix.getNX3() ) + if (nix1>=0 + &&nix2>=0 + &&nix3>=0 + &&nix1<voxelMatrix.getNX1() + &&nix2<voxelMatrix.getNX2() + &&nix3<voxelMatrix.getNX3()) { - if( UbMath::equal(voxelMatrix(nix1,nix2,nix3), SOLID) ) + if (UbMath::equal(voxelMatrix(nix1, nix2, nix3), SOLID)) { //return halber abstand der beiden knoten - return 0.5*sqrt( (ndx1*deltaX1)*(ndx1*deltaX1) - + (ndx2*deltaX2)*(ndx2*deltaX2) - + (ndx3*deltaX3)*(ndx3*deltaX3) ); + return 0.5*sqrt((ndx1*deltaX1)*(ndx1*deltaX1) + +(ndx2*deltaX2)*(ndx2*deltaX2) + +(ndx3*deltaX3)*(ndx3*deltaX3)); } } return 0.0; -} +} /*=======================================================*/ bool GbVoxelMatrix3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p) { //index ermitteln - int ix1 = UbMath::integerRounding( (x1p-minX1)/deltaX1 ); - int ix2 = UbMath::integerRounding( (x2p-minX2)/deltaX2 ); - int ix3 = UbMath::integerRounding( (x3p-minX3)/deltaX3 ); - - if( ix1>=0 - && ix2>=0 - && ix3>=0 - && ix1<voxelMatrix.getNX1() - && ix2<voxelMatrix.getNX2() - && ix3<voxelMatrix.getNX3() ) + int ix1 = UbMath::integerRounding((x1p-minX1)/deltaX1); + int ix2 = UbMath::integerRounding((x2p-minX2)/deltaX2); + int ix3 = UbMath::integerRounding((x3p-minX3)/deltaX3); + + if (ix1>=0 + &&ix2>=0 + &&ix3>=0 + &&ix1<voxelMatrix.getNX1() + &&ix2<voxelMatrix.getNX2() + &&ix3<voxelMatrix.getNX3()) { if (UbMath::equal(voxelMatrix(ix1, ix2, ix3), SOLID)) return true; } @@ -272,45 +272,45 @@ bool GbVoxelMatrix3D::isPointInGbObject3D(const double& x1p, const double& x2p, bool GbVoxelMatrix3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary) { pointIsOnBoundary = false; - - return isPointInGbObject3D(x1p,x2p,x3p); + + return isPointInGbObject3D(x1p, x2p, x3p); } /*=======================================================*/ -bool GbVoxelMatrix3D::isCellInsideGbObject3D(const double& x1p1,const double& x2p1,const double& x3p1,const double& x1p2,const double& x2p2,const double& x3p2) +bool GbVoxelMatrix3D::isCellInsideGbObject3D(const double& x1p1, const double& x2p1, const double& x3p1, const double& x1p2, const double& x2p2, const double& x3p2) { return false; -//dass hängt von der Konfigration ab, aber meist ist der Block grösser wie etliche Poren ... + //dass hängt von der Konfigration ab, aber meist ist der Block grösser wie etliche Poren ... - //indizes ermitteln - int startix1 = (int)std::floor( (x1p1-minX1)/deltaX1+1E-13 ); - int startix2 = (int)std::floor( (x2p1-minX2)/deltaX2+1E-13 ); - int startix3 = (int)std::floor( (x3p1-minX3)/deltaX3+1E-13 ); + //indizes ermitteln + int startix1 = (int)std::floor((x1p1-minX1)/deltaX1+1E-13); + int startix2 = (int)std::floor((x2p1-minX2)/deltaX2+1E-13); + int startix3 = (int)std::floor((x3p1-minX3)/deltaX3+1E-13); - if(startix1<0 ) return false; - if(startix2<0 ) return false; - if(startix3<0 ) return false; + if (startix1<0) return false; + if (startix2<0) return false; + if (startix3<0) return false; int maxiX1 = (int)voxelMatrix.getNX1()-1; int maxiX2 = (int)voxelMatrix.getNX2()-1; int maxiX3 = (int)voxelMatrix.getNX3()-1; - int endix1 = (int)std::ceil( (x1p2-minX1)/deltaX1-1E-13 ); - int endix2 = (int)std::ceil( (x2p2-minX2)/deltaX2-1E-13 ); - int endix3 = (int)std::ceil( (x3p2-minX3)/deltaX3-1E-13 ); + int endix1 = (int)std::ceil((x1p2-minX1)/deltaX1-1E-13); + int endix2 = (int)std::ceil((x2p2-minX2)/deltaX2-1E-13); + int endix3 = (int)std::ceil((x3p2-minX3)/deltaX3-1E-13); - if(endix1>maxiX1 ) return false; - if(endix2>maxiX2 ) return false; - if(endix3>maxiX3 ) return false; + if (endix1>maxiX1) return false; + if (endix2>maxiX2) return false; + if (endix3>maxiX3) return false; - for(int ix3=startix3; ix3<=endix3; ix3++) - for(int ix2=startix2; ix2<=endix2; ix2++) - for(int ix1=startix1; ix1<=endix1; ix1++) - if( UbMath::equal(voxelMatrix(ix1,ix2,ix3), FLUID ) ) + for (int ix3 = startix3; ix3<=endix3; ix3++) + for (int ix2 = startix2; ix2<=endix2; ix2++) + for (int ix1 = startix1; ix1<=endix1; ix1++) + if (UbMath::equal(voxelMatrix(ix1, ix2, ix3), FLUID)) return false; return true; } /*=======================================================*/ -bool GbVoxelMatrix3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) +bool GbVoxelMatrix3D::isCellCuttingGbObject3D(const double& x1a, const double& x2a, const double& x3a, const double& x1b, const double& x2b, const double& x3b) //Merksatz: cell oder deren Volumen schneidet oder beinhaltet komplette oder Teile der CuboidUmrandung //returns true: // - cell cuts GbVoxelMatrix3D @@ -320,8 +320,8 @@ bool GbVoxelMatrix3D::isCellCuttingGbObject3D(const double& x1a,const double& x2 // - cell und cuboid3D haben kein gemeinsames Volumen { //erstmal die dumm Loesung - if( !( this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) ) - && this->isCellInsideOrCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) ) + if (!(this->isCellInsideGbObject3D(x1a, x2a, x3a, x1b, x2b, x3b)) + &&this->isCellInsideOrCuttingGbObject3D(x1a, x2a, x3a, x1b, x2b, x3b)) { return true; } @@ -329,7 +329,7 @@ bool GbVoxelMatrix3D::isCellCuttingGbObject3D(const double& x1a,const double& x2 return false; } /*=======================================================*/ -bool GbVoxelMatrix3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) +bool GbVoxelMatrix3D::isCellInsideOrCuttingGbObject3D(const double& x1a, const double& x2a, const double& x3a, const double& x1b, const double& x2b, const double& x3b) //returns true: // - cell completely inside cuboid3D ( = cuboid3D boxes cell) // - cell cuts cuboid3D @@ -337,157 +337,157 @@ bool GbVoxelMatrix3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const do //returns false: // - cell und cuboid3D haben kein gemeinsames Volumen { - //simpler check, da unser GbCuboid3D ein AABB is: - // anfA midA endA anfB midB endB - // | x<-- dxA -->| |<-dxB->x | - // |<----------------- T --------------->| - //ist |T| <= dxA + dxB -> overlap! + //simpler check, da unser GbCuboid3D ein AABB is: + // anfA midA endA anfB midB endB + // | x<-- dxA -->| |<-dxB->x | + // |<----------------- T --------------->| + //ist |T| <= dxA + dxB -> overlap! - if( UbMath::lessEqual( std::fabs( this->getX1Centroid() - 0.5*(x1b+x1a) /*Tx1*/ ) - , 0.5*( this->getLengthX1() + std::fabs(x1b-x1a) /*dx1A+dx1B*/) ) + if (UbMath::lessEqual(std::fabs(this->getX1Centroid()-0.5*(x1b+x1a) /*Tx1*/) + , 0.5*(this->getLengthX1()+std::fabs(x1b-x1a) /*dx1A+dx1B*/)) - && UbMath::lessEqual( std::fabs( this->getX2Centroid() - 0.5*(x2b+x2a) /*Tx2*/ ) - , 0.5*( this->getLengthX2() + std::fabs(x2b-x2a) /*dx2A+dx2B*/) ) + &&UbMath::lessEqual(std::fabs(this->getX2Centroid()-0.5*(x2b+x2a) /*Tx2*/) + , 0.5*(this->getLengthX2()+std::fabs(x2b-x2a) /*dx2A+dx2B*/)) - && UbMath::lessEqual( std::fabs( this->getX3Centroid() - 0.5*(x3b+x3a) /*Tx3*/ ) - , 0.5*( this->getLengthX3() + std::fabs(x3b-x3a) /*dx3A+dx3B*/) ) ) - { - return true; - } + &&UbMath::lessEqual(std::fabs(this->getX3Centroid()-0.5*(x3b+x3a) /*Tx3*/) + , 0.5*(this->getLengthX3()+std::fabs(x3b-x3a) /*dx3A+dx3B*/))) + { + return true; + } - return false; + return false; } /*=======================================================*/ vector<GbTriangle3D*> GbVoxelMatrix3D::getSurfaceTriangleSet() { vector<GbTriangle3D*> triangles; - - #ifdef MC_CUBES - //MC - typedef McCubes::Matrix3DWrapper< Matrix3D > McMatrixWrapper; - typedef McCubes::MarchingCubes< McMatrixWrapper > McMarchingCubesGenerator; - typedef McMarchingCubesGenerator::Vertex McVertex; - typedef McMarchingCubesGenerator::Triangle McTriangle; - McMatrixWrapper wrapper(&voxelMatrix);//,0,0,0,voxelMatrix.getNX1()-1,voxelMatrix.getNX2()-1,voxelMatrix.getNX3()-1); - McMarchingCubesGenerator mc(wrapper); +#ifdef MC_CUBES + //MC + typedef McCubes::Matrix3DWrapper< Matrix3D > McMatrixWrapper; + typedef McCubes::MarchingCubes< McMatrixWrapper > McMarchingCubesGenerator; + typedef McMarchingCubesGenerator::Vertex McVertex; + typedef McMarchingCubesGenerator::Triangle McTriangle; - mc.init_all(); - mc.run(0.5); + McMatrixWrapper wrapper(&voxelMatrix);//,0,0,0,voxelMatrix.getNX1()-1,voxelMatrix.getNX2()-1,voxelMatrix.getNX3()-1); + McMarchingCubesGenerator mc(wrapper); - //const int nofVertices = mc.nverts(); - const int nofTriangles = mc.ntrigs(); + mc.init_all(); + mc.run(0.5); - McVertex* mcvertices = mc.vertices(); - McTriangle* mctriangles = mc.triangles(); + //const int nofVertices = mc.nverts(); + const int nofTriangles = mc.ntrigs(); - for(int t=0; t<nofTriangles; t++) - { - triangles.push_back(new GbTriangle3D( new GbPoint3D( minX1 + deltaX1 * (mcvertices[mctriangles[t].v1].x /*-1*/) - , minX2 + deltaX2 * (mcvertices[mctriangles[t].v1].y /*-1*/) - , minX3 + deltaX3 * (mcvertices[mctriangles[t].v1].z /*-1*/) ) - ,new GbPoint3D( minX1 + deltaX1 * (mcvertices[mctriangles[t].v2].x /*-1*/) - , minX2 + deltaX2 * (mcvertices[mctriangles[t].v2].y /*-1*/) - , minX3 + deltaX3 * (mcvertices[mctriangles[t].v2].z /*-1*/) ) - ,new GbPoint3D( minX1 + deltaX1 * (mcvertices[mctriangles[t].v3].x /*-1*/) - , minX2 + deltaX2 * (mcvertices[mctriangles[t].v3].y /*-1*/) - , minX3 + deltaX3 * (mcvertices[mctriangles[t].v3].z /*-1*/) ) ) ); - } - #else - cerr<<"vector<GbTriangle3D*> GbVoxelMatrix3D::getSurfaceTriangleSet() - benoetigt MARCHING_CUBE paket aus 3rdParty"<<endl; - #endif // MC_CUBES + McVertex* mcvertices = mc.vertices(); + McTriangle* mctriangles = mc.triangles(); + + for (int t = 0; t<nofTriangles; t++) + { + triangles.push_back(new GbTriangle3D(new GbPoint3D(minX1+deltaX1 * (mcvertices[mctriangles[t].v1].x /*-1*/) + , minX2+deltaX2 * (mcvertices[mctriangles[t].v1].y /*-1*/) + , minX3+deltaX3 * (mcvertices[mctriangles[t].v1].z /*-1*/)) + , new GbPoint3D(minX1+deltaX1 * (mcvertices[mctriangles[t].v2].x /*-1*/) + , minX2+deltaX2 * (mcvertices[mctriangles[t].v2].y /*-1*/) + , minX3+deltaX3 * (mcvertices[mctriangles[t].v2].z /*-1*/)) + , new GbPoint3D(minX1+deltaX1 * (mcvertices[mctriangles[t].v3].x /*-1*/) + , minX2+deltaX2 * (mcvertices[mctriangles[t].v3].y /*-1*/) + , minX3+deltaX3 * (mcvertices[mctriangles[t].v3].z /*-1*/)))); + } +#else + cerr<<"vector<GbTriangle3D*> GbVoxelMatrix3D::getSurfaceTriangleSet() - benoetigt MARCHING_CUBE paket aus 3rdParty"<<endl; +#endif // MC_CUBES return triangles; } /*=======================================================*/ void GbVoxelMatrix3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles) { - UBLOG(logINFO," GbVoxelMatrix3D addSurfaceTriangleSet start") - if(!this->addSurfaceTriangleSetFlag) - { - UBLOG(logINFO," GbVoxelMatrix3D addSurfaceTriangleSet end without TriangleSetCreation") - return; - } - #ifdef MC_CUBES - UBLOG(logDEBUG1," GbVoxelMatrix3D addSurfaceTriangleSet MC defined") + UBLOG(logINFO, " GbVoxelMatrix3D addSurfaceTriangleSet start") + if (!this->addSurfaceTriangleSetFlag) + { + UBLOG(logINFO, " GbVoxelMatrix3D addSurfaceTriangleSet end without TriangleSetCreation") + return; + } +#ifdef MC_CUBES + UBLOG(logDEBUG1, " GbVoxelMatrix3D addSurfaceTriangleSet MC defined") typedef McCubes::Matrix3DWrapper< Matrix3D > McMatrixWrapper; - typedef McCubes::MarchingCubes< McMatrixWrapper > McMarchingCubesGenerator; - typedef McMarchingCubesGenerator::Vertex McVertex; - typedef McMarchingCubesGenerator::Triangle McTriangle; - - //MC - { //standard( fuer voxelmatrix) - McMatrixWrapper wrapper(&voxelMatrix); - McMarchingCubesGenerator mc(wrapper); - - UBLOG(logDEBUG1," GbVoxelMatrix3D addSurfaceTriangleSet McMarchingCubesGenerator") - - UBLOG(logDEBUG1," GbVoxelMatrix3D addSurfaceTriangleSet mc.init") + typedef McCubes::MarchingCubes< McMatrixWrapper > McMarchingCubesGenerator; + typedef McMarchingCubesGenerator::Vertex McVertex; + typedef McMarchingCubesGenerator::Triangle McTriangle; + + //MC + { //standard( fuer voxelmatrix) + McMatrixWrapper wrapper(&voxelMatrix); + McMarchingCubesGenerator mc(wrapper); + + UBLOG(logDEBUG1, " GbVoxelMatrix3D addSurfaceTriangleSet McMarchingCubesGenerator") + + UBLOG(logDEBUG1, " GbVoxelMatrix3D addSurfaceTriangleSet mc.init") mc.init_all(); - UBLOG(logDEBUG1," GbVoxelMatrix3D addSurfaceTriangleSet mc.run") + UBLOG(logDEBUG1, " GbVoxelMatrix3D addSurfaceTriangleSet mc.run") mc.run(0.5); - UBLOG(logDEBUG1," GbVoxelMatrix3D addSurfaceTriangleSet mc.run done") - - const int nofVertices = mc.nverts(); - const int nofTriangles = mc.ntrigs(); - - McVertex* mcvertices = mc.vertices(); - McTriangle* mctriangles = mc.triangles(); - -UBLOG(logDEBUG1," GbVoxelMatrix3D node tuple") - for(int n=0; n<nofVertices; n++) - nodes.push_back( makeUbTuple( (float)(minX1 + deltaX1 * (mcvertices[n].x /*-1*/)), //Anm: kein -1, da man durch manipulation der indices die dreiecke um eins versetzt bekommt - (float)(minX2 + deltaX2 * (mcvertices[n].y /*-1*/)), - (float)(minX3 + deltaX3 * (mcvertices[n].z /*-1*/)) ) ); -UBLOG(logDEBUG1," GbVoxelMatrix3D triangles tuple") - for(int t=0; t<nofTriangles; t++) - triangles.push_back( makeUbTuple( mctriangles[t].v1, mctriangles[t].v2, mctriangles[t].v3 ) ); -UBLOG(logDEBUG1," GbVoxelMatrix3D triangles tuple done") - } - - //false - das scheint probleme bei der asphaltprobe zu machen 1500x600x100 - // da lief es bis C - evtl. memory voll - if(false) //extension... um die raender koerrekt abzubilden muesste man eine dummy FLUID reihe um - { //die matrix legen( lsg1: temp matrix mit 2 reihen pro richtung mehr -> zuviel speicher, 500^3 = 500MB - // lsg2: fuer jede flaeche eine dummy matrix -> wie folgt: - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); -UBLOG(logINFO," A ") - Matrix3D tmpX1Min( 2, nx2+2, nx3+2, FLUID ); - Matrix3D tmpX1Max( 2, nx2+2, nx3+2, FLUID ); - for(int x3=0; x3<nx3; x3++ ) - for(int x2=0; x2<nx2; x2++ ) - { - tmpX1Min(1, x2+1, x3+1) = voxelMatrix(0 , x2, x3); - tmpX1Max(0, x2+1, x3+1) = voxelMatrix(nx1-1, x2, x3); - } -UBLOG(logINFO," B") - Matrix3D tmpX2Min(nx1+2, 2, nx3+2, FLUID ); - Matrix3D tmpX2Max(nx1+2, 2, nx3+2, FLUID ); - for(int x3=0; x3<nx3; x3++ ) - for(int x1=0; x1<nx1; x1++ ) - { - tmpX2Min(x1+1, 1, x3+1) = voxelMatrix(x1, 0 , x3); - tmpX2Max(x1+1, 0, x3+1) = voxelMatrix(x1, nx2-1, x3); - } -UBLOG(logINFO," C ") - Matrix3D tmpX3Min(nx1+2, nx3+2, 2, FLUID ); - Matrix3D tmpX3Max(nx1+2, nx3+2, 2, FLUID ); - for(int x2=0; x2<nx2; x2++ ) - for(int x1=0; x1<nx1; x1++ ) - { - tmpX3Min(x1+1, x2+1, 1) = voxelMatrix(x1, x2, 0 ); - tmpX3Max(x1+1, x2+1, 0) = voxelMatrix(x1, x2, nx3-1); - } -UBLOG(logINFO," D") + UBLOG(logDEBUG1, " GbVoxelMatrix3D addSurfaceTriangleSet mc.run done") + + const int nofVertices = mc.nverts(); + const int nofTriangles = mc.ntrigs(); + + McVertex* mcvertices = mc.vertices(); + McTriangle* mctriangles = mc.triangles(); + + UBLOG(logDEBUG1, " GbVoxelMatrix3D node tuple") + for (int n = 0; n<nofVertices; n++) + nodes.push_back(makeUbTuple((float)(minX1+deltaX1 * (mcvertices[n].x /*-1*/)), //Anm: kein -1, da man durch manipulation der indices die dreiecke um eins versetzt bekommt + (float)(minX2+deltaX2 * (mcvertices[n].y /*-1*/)), + (float)(minX3+deltaX3 * (mcvertices[n].z /*-1*/)))); + UBLOG(logDEBUG1, " GbVoxelMatrix3D triangles tuple") + for (int t = 0; t<nofTriangles; t++) + triangles.push_back(makeUbTuple(mctriangles[t].v1, mctriangles[t].v2, mctriangles[t].v3)); + UBLOG(logDEBUG1, " GbVoxelMatrix3D triangles tuple done") + } + + //false - das scheint probleme bei der asphaltprobe zu machen 1500x600x100 + // da lief es bis C - evtl. memory voll + if (false) //extension... um die raender koerrekt abzubilden muesste man eine dummy FLUID reihe um + { //die matrix legen( lsg1: temp matrix mit 2 reihen pro richtung mehr -> zuviel speicher, 500^3 = 500MB + // lsg2: fuer jede flaeche eine dummy matrix -> wie folgt: + int nx1 = (int)voxelMatrix.getNX1(); + int nx2 = (int)voxelMatrix.getNX2(); + int nx3 = (int)voxelMatrix.getNX3(); + UBLOG(logINFO, " A ") + Matrix3D tmpX1Min(2, nx2+2, nx3+2, FLUID); + Matrix3D tmpX1Max(2, nx2+2, nx3+2, FLUID); + for (int x3 = 0; x3<nx3; x3++) + for (int x2 = 0; x2<nx2; x2++) + { + tmpX1Min(1, x2+1, x3+1) = voxelMatrix(0, x2, x3); + tmpX1Max(0, x2+1, x3+1) = voxelMatrix(nx1-1, x2, x3); + } + UBLOG(logINFO, " B") + Matrix3D tmpX2Min(nx1+2, 2, nx3+2, FLUID); + Matrix3D tmpX2Max(nx1+2, 2, nx3+2, FLUID); + for (int x3 = 0; x3<nx3; x3++) + for (int x1 = 0; x1<nx1; x1++) + { + tmpX2Min(x1+1, 1, x3+1) = voxelMatrix(x1, 0, x3); + tmpX2Max(x1+1, 0, x3+1) = voxelMatrix(x1, nx2-1, x3); + } + UBLOG(logINFO, " C ") + Matrix3D tmpX3Min(nx1+2, nx3+2, 2, FLUID); + Matrix3D tmpX3Max(nx1+2, nx3+2, 2, FLUID); + for (int x2 = 0; x2<nx2; x2++) + for (int x1 = 0; x1<nx1; x1++) + { + tmpX3Min(x1+1, x2+1, 1) = voxelMatrix(x1, x2, 0); + tmpX3Max(x1+1, x2+1, 0) = voxelMatrix(x1, x2, nx3-1); + } + UBLOG(logINFO, " D") Matrix3D* matrices[] = { &tmpX1Min, &tmpX1Max, &tmpX2Min, &tmpX2Max, &tmpX3Min, &tmpX3Max }; - int dx1[] = { -1, nx1-1, -1, -1, -1, -1 }; - int dx2[] = { -1, -1, -1, nx2-1, -1, -1 }; - int dx3[] = { -1, -1, -1, -1, -1, nx3-1 }; -UBLOG(logINFO," E") - for(int i=0; i<6; i++) + int dx1[] = { -1, nx1-1, -1, -1, -1, -1 }; + int dx2[] = { -1, -1, -1, nx2-1, -1, -1 }; + int dx3[] = { -1, -1, -1, -1, -1, nx3-1 }; + UBLOG(logINFO, " E") + for (int i = 0; i<6; i++) { McMatrixWrapper wrapper(matrices[i]); McMarchingCubesGenerator mc(wrapper); @@ -495,33 +495,33 @@ UBLOG(logINFO," E") mc.init_all(); mc.run(0.5); - McVertex* mcvertices = mc.vertices(); - McTriangle* mctriangles = mc.triangles(); + McVertex* mcvertices = mc.vertices(); + McTriangle* mctriangles = mc.triangles(); int deltaNodeNr = (int)nodes.size(); -UBLOG(logINFO," GbVoxelMatrix3D node tuple") - for(int n=0; n<mc.nverts(); n++) - nodes.push_back( makeUbTuple( (float)(minX1 + deltaX1 * (mcvertices[n].x + dx1[i])), //Anm: kein -1, da man durch manipulation der indices die dreiecke um eins versetzt bekommt - (float)(minX2 + deltaX2 * (mcvertices[n].y + dx2[i])), - (float)(minX3 + deltaX3 * (mcvertices[n].z + dx3[i])) ) ); - for(int t=0; t<mc.ntrigs(); t++) - triangles.push_back( makeUbTuple( deltaNodeNr+mctriangles[t].v1, deltaNodeNr+mctriangles[t].v2, deltaNodeNr+mctriangles[t].v3 ) ); + UBLOG(logINFO, " GbVoxelMatrix3D node tuple") + for (int n = 0; n<mc.nverts(); n++) + nodes.push_back(makeUbTuple((float)(minX1+deltaX1 * (mcvertices[n].x+dx1[i])), //Anm: kein -1, da man durch manipulation der indices die dreiecke um eins versetzt bekommt + (float)(minX2+deltaX2 * (mcvertices[n].y+dx2[i])), + (float)(minX3+deltaX3 * (mcvertices[n].z+dx3[i])))); + for (int t = 0; t<mc.ntrigs(); t++) + triangles.push_back(makeUbTuple(deltaNodeNr+mctriangles[t].v1, deltaNodeNr+mctriangles[t].v2, deltaNodeNr+mctriangles[t].v3)); } - } - #else - cerr<<"void GbVoxelMatrix3D.addSurfaceTriangleSet - benoetigt MARCHING_CUBE paket aus 3rdParty"<<endl; - #endif // MC_CUBES + } +#else + cerr<<"void GbVoxelMatrix3D.addSurfaceTriangleSet - benoetigt MARCHING_CUBE paket aus 3rdParty"<<endl; +#endif // MC_CUBES - UBLOG(logINFO," GbVoxelMatrix3D addSurfaceTriangleSet end") + UBLOG(logINFO, " GbVoxelMatrix3D addSurfaceTriangleSet end") } /*=======================================================*/ -string GbVoxelMatrix3D::toString() +string GbVoxelMatrix3D::toString() { return "GbVoxelMatrix3D"; } /*=======================================================*/ -void GbVoxelMatrix3D::write(UbFileOutput* out) -{ +void GbVoxelMatrix3D::write(UbFileOutput* out) +{ out->writeString(this->getCreator()->getTypeID()); out->writeDouble(minX1); out->writeDouble(minX2); @@ -536,30 +536,30 @@ void GbVoxelMatrix3D::write(UbFileOutput* out) out->writeDouble(upperThreshold); out->writeBool(addSurfaceTriangleSetFlag); out->writeBool(transferViaFilename); - if(!transferViaFilename) + if (!transferViaFilename) { - throw UbException(UB_EXARGS,"void GbVoxelMatrix3D::write(UbFileOutput* out) - geht ned"); + throw UbException(UB_EXARGS, "void GbVoxelMatrix3D::write(UbFileOutput* out) - geht ned"); } else { out->writeString(filename); } - + //CbUniformMatrix3D<float> voxelMatrix; } /*=======================================================*/ -void GbVoxelMatrix3D::read(UbFileInput* in) -{ +void GbVoxelMatrix3D::read(UbFileInput* in) +{ #ifdef CAB_RCF try { #endif //!!! den string nimmt er vorher um das Object zu erstellen //in->readString(); - minX1 = in->readDouble(); - minX2 = in->readDouble(); - minX3 = in->readDouble(); + minX1 = in->readDouble(); + minX2 = in->readDouble(); + minX3 = in->readDouble(); deltaX1 = in->readDouble(); deltaX2 = in->readDouble(); deltaX3 = in->readDouble(); @@ -570,9 +570,9 @@ void GbVoxelMatrix3D::read(UbFileInput* in) upperThreshold = in->readDouble(); addSurfaceTriangleSetFlag = in->readBool(); transferViaFilename = in->readBool(); - if(!transferViaFilename) + if (!transferViaFilename) { - throw UbException(UB_EXARGS,"void GbVoxelMatrix3D::read(UbFileOutput* out) - geht ned"); + throw UbException(UB_EXARGS, "void GbVoxelMatrix3D::read(UbFileOutput* out) - geht ned"); } else { @@ -581,58 +581,58 @@ void GbVoxelMatrix3D::read(UbFileInput* in) } #ifdef CAB_RCF } - catch(std::exception& e) { UBLOGML(logERROR, UB_FUNCTION + (std::string)e.what()); throw RCF::Exception(1002, UB_FUNCTION + (std::string)e.what() ); } - catch(...) { UBLOGML(logERROR, UB_FUNCTION + (std::string)"unknown error"); throw RCF::Exception(1002, UB_FUNCTION + (std::string)"unknown error" ); } + catch (std::exception& e) { UBLOGML(logERROR, UB_FUNCTION+(std::string)e.what()); throw RCF::Exception(1002, UB_FUNCTION+(std::string)e.what()); } + catch (...) { UBLOGML(logERROR, UB_FUNCTION+(std::string)"unknown error"); throw RCF::Exception(1002, UB_FUNCTION+(std::string)"unknown error"); } #endif } /*=======================================================*/ void GbVoxelMatrix3D::readMatrixFromVtiASCIIFile(std::string filename) { - UBLOG(logINFO," - create GbVoxelMatrix3D"); + //UBLOG(logINFO," - create GbVoxelMatrix3D"); UbFileInputASCII in(filename); //ifstream in(filename.c_str(), ios::binary); - if(!in) throw UbException(UB_EXARGS,"could not open file "+filename); + if (!in) throw UbException(UB_EXARGS, "could not open file "+filename); in.readLine(); in.readLine(); in.readLine(); in.readLine(); in.readLine(); - voxelMatrix = Matrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID); + voxelMatrix = Matrix3D(nodesX1, nodesX2, nodesX3, GbVoxelMatrix3D::FLUID); - UBLOG(logINFO," - init values"); + //UBLOG(logINFO," - init values"); int val; - int u=0; - for(int x3=0; x3<nodesX3; x3++) - for(int x2=0; x2<nodesX2; x2++) - for(int x1=0; x1<nodesX1; x1++) + int u = 0; + for (int x3 = 0; x3<nodesX3; x3++) + for (int x2 = 0; x2<nodesX2; x2++) + for (int x1 = 0; x1<nodesX1; x1++) { val = in.readInteger(); //if( !UbMath::equal(val, 0.0f) ) //if( UbMath::greater(val, threshold) ) - if( (double)val >= lowerThreshold && (double)val <= upperThreshold ) + if ((double)val>=lowerThreshold&&(double)val<=upperThreshold) { - (voxelMatrix)(x1,x2,x3) = GbVoxelMatrix3D::SOLID; + (voxelMatrix)(x1, x2, x3) = GbVoxelMatrix3D::SOLID; } } - UBLOG(logINFO," - create GbVoxelMatrix3D done"); + //UBLOG(logINFO," - create GbVoxelMatrix3D done"); } ////////////////////////////////////////////////////////////////////////// void GbVoxelMatrix3D::rotate90aroundX(double cX1, double cX2, double cX3) { - double tempMinPunktX1 = minX1 - cX1; - double tempMinPunktX2 = minX2 - cX2; - double tempMinPunktX3 = getX3Maximum() - cX3; + double tempMinPunktX1 = minX1-cX1; + double tempMinPunktX2 = minX2-cX2; + double tempMinPunktX3 = getX3Maximum()-cX3; double tempMinPunktX1tf = tempMinPunktX1; double tempMinPunktX2tf = -tempMinPunktX3; double tempMinPunktX3tf = tempMinPunktX2; - double minX1_temp = tempMinPunktX1tf + cX1; - double minX2_temp = tempMinPunktX2tf + cX2; - double minX3_temp = tempMinPunktX3tf + cX3; + double minX1_temp = tempMinPunktX1tf+cX1; + double minX2_temp = tempMinPunktX2tf+cX2; + double minX3_temp = tempMinPunktX3tf+cX3; minX2 = minX2_temp; minX3 = minX3_temp; @@ -641,7 +641,7 @@ void GbVoxelMatrix3D::rotate90aroundX(double cX1, double cX2, double cX3) int nx2 = (int)voxelMatrix.getNX2(); int nx3 = (int)voxelMatrix.getNX3(); - int nx1_new = nx1; + int nx1_new = nx1; int nx2_new = nx3; int nx3_new = nx2; @@ -651,11 +651,11 @@ void GbVoxelMatrix3D::rotate90aroundX(double cX1, double cX2, double cX3) GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1_new, nx2_new, nx3_new); - for (int x3=0; x3<nx3;x3++){ - for (int x2=0; x2<nx2;x2++){ - for(int x1=0; x1<nx1;x1++) + for (int x3 = 0; x3<nx3; x3++) { + for (int x2 = 0; x2<nx2; x2++) { + for (int x1 = 0; x1<nx1; x1++) { - voxelMatrix_temp(x1,nx3-x3-1,x2) = this->voxelMatrix(x1,x2,x3); + voxelMatrix_temp(x1, nx3-x3-1, x2) = this->voxelMatrix(x1, x2, x3); } } } @@ -673,17 +673,17 @@ void GbVoxelMatrix3D::rotate90aroundX() ////////////////////////////////////////////////////////////////////////// void GbVoxelMatrix3D::rotate90aroundY(double cX1, double cX2, double cX3) { - double tempMinPunktX1 = getX1Maximum() - cX1; - double tempMinPunktX2 = minX2 - cX2; - double tempMinPunktX3 = minX3 - cX3; + double tempMinPunktX1 = getX1Maximum()-cX1; + double tempMinPunktX2 = minX2-cX2; + double tempMinPunktX3 = minX3-cX3; double tempMinPunktX1tf = tempMinPunktX3; double tempMinPunktX2tf = tempMinPunktX2; double tempMinPunktX3tf = -tempMinPunktX1; - double minX1_temp = tempMinPunktX1tf + cX1; - double minX2_temp = tempMinPunktX2tf + cX2; - double minX3_temp = tempMinPunktX3tf + cX3; + double minX1_temp = tempMinPunktX1tf+cX1; + double minX2_temp = tempMinPunktX2tf+cX2; + double minX3_temp = tempMinPunktX3tf+cX3; minX1 = minX1_temp; minX3 = minX3_temp; @@ -692,7 +692,7 @@ void GbVoxelMatrix3D::rotate90aroundY(double cX1, double cX2, double cX3) int nx2 = (int)voxelMatrix.getNX2(); int nx3 = (int)voxelMatrix.getNX3(); - int nx1_new = nx3; + int nx1_new = nx3; int nx2_new = nx2; int nx3_new = nx1; @@ -702,11 +702,11 @@ void GbVoxelMatrix3D::rotate90aroundY(double cX1, double cX2, double cX3) GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1_new, nx2_new, nx3_new); - for (int x3=0; x3<nx3;x3++){ - for (int x2=0; x2<nx2;x2++){ - for(int x1=0; x1<nx1;x1++) + for (int x3 = 0; x3<nx3; x3++) { + for (int x2 = 0; x2<nx2; x2++) { + for (int x1 = 0; x1<nx1; x1++) { - voxelMatrix_temp(x3,x2,nx1-x1-1) = this->voxelMatrix(x1,x2,x3); + voxelMatrix_temp(x3, x2, nx1-x1-1) = this->voxelMatrix(x1, x2, x3); } } } @@ -718,23 +718,23 @@ void GbVoxelMatrix3D::rotate90aroundY() double cX1 = this->getX1Centroid(); double cX2 = this->getX2Centroid(); double cX3 = this->getX3Centroid(); - + rotate90aroundY(cX1, cX2, cX3); } ////////////////////////////////////////////////////////////////////////// void GbVoxelMatrix3D::rotate90aroundZ(double cX1, double cX2, double cX3) { - double tempMinPunktX1 = minX1 - cX1; - double tempMinPunktX2 = getX2Maximum() - cX2; - double tempMinPunktX3 = minX3 - cX3; + double tempMinPunktX1 = minX1-cX1; + double tempMinPunktX2 = getX2Maximum()-cX2; + double tempMinPunktX3 = minX3-cX3; double tempMinPunktX1tf = -tempMinPunktX2; double tempMinPunktX2tf = tempMinPunktX1; double tempMinPunktX3tf = tempMinPunktX3; - double minX1_temp = tempMinPunktX1tf + cX1; - double minX2_temp = tempMinPunktX2tf + cX2; - double minX3_temp = tempMinPunktX3tf + cX3; + double minX1_temp = tempMinPunktX1tf+cX1; + double minX2_temp = tempMinPunktX2tf+cX2; + double minX3_temp = tempMinPunktX3tf+cX3; minX1 = minX1_temp; minX2 = minX2_temp; @@ -743,7 +743,7 @@ void GbVoxelMatrix3D::rotate90aroundZ(double cX1, double cX2, double cX3) int nx2 = (int)voxelMatrix.getNX2(); int nx3 = (int)voxelMatrix.getNX3(); - int nx1_new = nx2; + int nx1_new = nx2; int nx2_new = nx1; int nx3_new = nx3; @@ -753,11 +753,11 @@ void GbVoxelMatrix3D::rotate90aroundZ(double cX1, double cX2, double cX3) GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1_new, nx2_new, nx3_new); - for (int x3=0; x3<nx3;x3++){ - for (int x2=0; x2<nx2;x2++){ - for(int x1=0; x1<nx1;x1++) + for (int x3 = 0; x3<nx3; x3++) { + for (int x2 = 0; x2<nx2; x2++) { + for (int x1 = 0; x1<nx1; x1++) { - voxelMatrix_temp(nx2-x2-1,x1,x3) = this->voxelMatrix(x1,x2,x3); + voxelMatrix_temp(nx2-x2-1, x1, x3) = this->voxelMatrix(x1, x2, x3); } } } @@ -781,11 +781,11 @@ void GbVoxelMatrix3D::mirrorX() GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1, nx2, nx3); - for (int x3=0; x3<nx3;x3++){ - for (int x2=0; x2<nx2;x2++){ - for(int x1=0; x1<nx1;x1++) + for (int x3 = 0; x3<nx3; x3++) { + for (int x2 = 0; x2<nx2; x2++) { + for (int x1 = 0; x1<nx1; x1++) { - voxelMatrix_temp(nx1-x1-1,x2,x3) = this->voxelMatrix(x1,x2,x3); + voxelMatrix_temp(nx1-x1-1, x2, x3) = this->voxelMatrix(x1, x2, x3); } } } @@ -800,11 +800,11 @@ void GbVoxelMatrix3D::mirrorY() GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1, nx2, nx3); - for (int x3=0; x3<nx3;x3++){ - for (int x2=0; x2<nx2;x2++){ - for(int x1=0; x1<nx1;x1++) + for (int x3 = 0; x3<nx3; x3++) { + for (int x2 = 0; x2<nx2; x2++) { + for (int x1 = 0; x1<nx1; x1++) { - voxelMatrix_temp(x1,nx2-x2-1,x3) = this->voxelMatrix(x1,x2,x3); + voxelMatrix_temp(x1, nx2-x2-1, x3) = this->voxelMatrix(x1, x2, x3); } } } @@ -819,33 +819,33 @@ void GbVoxelMatrix3D::mirrorZ() GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1, nx2, nx3); - for (int x3=0; x3<nx3;x3++){ - for (int x2=0; x2<nx2;x2++){ - for(int x1=0; x1<nx1;x1++) + for (int x3 = 0; x3<nx3; x3++) { + for (int x2 = 0; x2<nx2; x2++) { + for (int x1 = 0; x1<nx1; x1++) { - voxelMatrix_temp(x1,x2,nx3-x3-1) = this->voxelMatrix(x1,x2,x3); + voxelMatrix_temp(x1, x2, nx3-x3-1) = this->voxelMatrix(x1, x2, x3); } } } std::swap(this->voxelMatrix, voxelMatrix_temp); } ////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::writeToLegacyVTKASCII( const std::string& fileName ) +void GbVoxelMatrix3D::writeToLegacyVTKASCII(const std::string& fileName) { - string fn = fileName +".ascii.vtk"; + string fn = fileName+".ascii.vtk"; - FILE *file; - file = fopen(fn.c_str(),"w"); + FILE *file; + file = fopen(fn.c_str(), "w"); - if (file == NULL) + if (file==NULL) { std::string pathf = UbSystem::getPathFromString(fn); if (fn.size()>0) { UbSystem::makeDirectory(pathf); file = fopen(fn.c_str(), "w"); } - if (file == NULL) throw UbException(UB_EXARGS, "can not open " + fn); + if (file==NULL) throw UbException(UB_EXARGS, "can not open "+fn); } - if(file == NULL) - throw UbException(UB_EXARGS,"can not open "+fn); + if (file==NULL) + throw UbException(UB_EXARGS, "can not open "+fn); int nx1 = (int)voxelMatrix.getNX1(); int nx2 = (int)voxelMatrix.getNX2(); @@ -853,42 +853,42 @@ void GbVoxelMatrix3D::writeToLegacyVTKASCII( const std::string& fileName ) int nn = nx1*nx2*nx3; - fprintf(file,"# vtk DataFile Version 2.0\n"); - fprintf(file,"vtk output\n"); - fprintf(file,"ASCII\n"); - fprintf(file,"DATASET STRUCTURED_POINTS\n"); - fprintf(file,"DIMENSIONS %d %d %d\n", nx1, nx2, nx3); - fprintf(file,"ORIGIN %g %g %g\n", minX1, minX2, minX3); - fprintf(file,"SPACING %g %g %g\n", deltaX1, deltaX2, deltaX3); - fprintf(file,"POINT_DATA %d\n", nn); - fprintf(file,"SCALARS Geo float\n"); - fprintf(file,"LOOKUP_TABLE default\n"); - - for(int k=0 ; k<nx3 ; k++){ - for(int j=0 ; j<nx2 ; j++){ - for(int i=0 ; i<nx1 ; i++){ - fprintf(file,"%g ", voxelMatrix(i,j,k)); + fprintf(file, "# vtk DataFile Version 2.0\n"); + fprintf(file, "vtk output\n"); + fprintf(file, "ASCII\n"); + fprintf(file, "DATASET STRUCTURED_POINTS\n"); + fprintf(file, "DIMENSIONS %d %d %d\n", nx1, nx2, nx3); + fprintf(file, "ORIGIN %g %g %g\n", minX1, minX2, minX3); + fprintf(file, "SPACING %g %g %g\n", deltaX1, deltaX2, deltaX3); + fprintf(file, "POINT_DATA %d\n", nn); + fprintf(file, "SCALARS Geo float\n"); + fprintf(file, "LOOKUP_TABLE default\n"); + + for (int k = 0; k<nx3; k++) { + for (int j = 0; j<nx2; j++) { + for (int i = 0; i<nx1; i++) { + fprintf(file, "%g ", voxelMatrix(i, j, k)); } } } - fprintf(file,"\n"); + fprintf(file, "\n"); fclose(file); } ////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::writeToLegacyVTKBinary( const std::string& fileName ) +void GbVoxelMatrix3D::writeToLegacyVTKBinary(const std::string& fileName) { - string fn = fileName +".binary.vtk"; - - FILE *file; - file = fopen(fn.c_str(),"w"); + string fn = fileName+".binary.vtk"; - if (file == NULL) + FILE *file; + file = fopen(fn.c_str(), "w"); + + if (file==NULL) { std::string pathf = UbSystem::getPathFromString(fn); if (fn.size()>0) { UbSystem::makeDirectory(pathf); file = fopen(fn.c_str(), "w"); } - if (file == NULL) throw UbException(UB_EXARGS, "can not open " + fn); + if (file==NULL) throw UbException(UB_EXARGS, "can not open "+fn); } int nx1 = (int)voxelMatrix.getNX1(); @@ -899,129 +899,129 @@ void GbVoxelMatrix3D::writeToLegacyVTKBinary( const std::string& fileName ) char LF = 0x0A; - fprintf(file,"# vtk DataFile Version 3.0\n"); - fprintf(file,"vtk output\n"); - fprintf(file,"BINARY\n"); - fprintf(file,"DATASET STRUCTURED_POINTS\n"); - fprintf(file,"DIMENSIONS %d %d %d\n", nx1, nx2, nx3); - fprintf(file,"ORIGIN %g %g %g\n", minX1, minX2, minX3); - fprintf(file,"SPACING %g %g %g\n", deltaX1, deltaX2, deltaX3); - fprintf(file,"POINT_DATA %d\n", nn); - fprintf(file,"SCALARS Geo float\n"); - fprintf(file,"LOOKUP_TABLE default"); + fprintf(file, "# vtk DataFile Version 3.0\n"); + fprintf(file, "vtk output\n"); + fprintf(file, "BINARY\n"); + fprintf(file, "DATASET STRUCTURED_POINTS\n"); + fprintf(file, "DIMENSIONS %d %d %d\n", nx1, nx2, nx3); + fprintf(file, "ORIGIN %g %g %g\n", minX1, minX2, minX3); + fprintf(file, "SPACING %g %g %g\n", deltaX1, deltaX2, deltaX3); + fprintf(file, "POINT_DATA %d\n", nn); + fprintf(file, "SCALARS Geo float\n"); + fprintf(file, "LOOKUP_TABLE default"); fclose(file); GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1, nx2, nx3); if (UbSystem::isLittleEndian()) { - for (int x3=0; x3<nx3;x3++){ - for (int x2=0; x2<nx2;x2++){ - for(int x1=0; x1<nx1;x1++) + for (int x3 = 0; x3<nx3; x3++) { + for (int x2 = 0; x2<nx2; x2++) { + for (int x1 = 0; x1<nx1; x1++) { - float tmp = this->voxelMatrix(x1,x2,x3); + float tmp = this->voxelMatrix(x1, x2, x3); UbSystem::swapByteOrder((unsigned char*)(&(tmp)), sizeof(float)); - voxelMatrix_temp(x1,x2,x3) = tmp; + voxelMatrix_temp(x1, x2, x3) = tmp; } } } } file = fopen(fn.c_str(), "ab"); - - fwrite (&LF, sizeof(char), 1, file); - fwrite(voxelMatrix_temp.getStartAdressOfSortedArray(0,0,0), sizeof(float), voxelMatrix_temp.getDataVector().size(), file); - fwrite (&LF, sizeof(char), 1, file); + + fwrite(&LF, sizeof(char), 1, file); + fwrite(voxelMatrix_temp.getStartAdressOfSortedArray(0, 0, 0), sizeof(float), voxelMatrix_temp.getDataVector().size(), file); + fwrite(&LF, sizeof(char), 1, file); fclose(file); } ////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::writeToVTKImageDataASCII( const std::string& fileName ) +void GbVoxelMatrix3D::writeToVTKImageDataASCII(const std::string& fileName) { int nx1 = (int)voxelMatrix.getNX1(); int nx2 = (int)voxelMatrix.getNX2(); int nx3 = (int)voxelMatrix.getNX3(); - string fn = fileName +".ascii.vti"; + string fn = fileName+".ascii.vti"; - FILE *file; - file = fopen(fn.c_str(),"w"); + FILE *file; + file = fopen(fn.c_str(), "w"); - if (file == NULL) + if (file==NULL) { std::string pathf = UbSystem::getPathFromString(fn); if (fn.size()>0) { UbSystem::makeDirectory(pathf); file = fopen(fn.c_str(), "w"); } - if (file == NULL) throw UbException(UB_EXARGS, "can not open " + fn); + if (file==NULL) throw UbException(UB_EXARGS, "can not open "+fn); } - fprintf(file,"<VTKFile type=\"ImageData\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n"); //paraview 4.1 + fprintf(file, "<VTKFile type=\"ImageData\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n"); //paraview 4.1 //fprintf(file,"<VTKFile type=\"ImageData\" version=\"0.1\" byte_order=\"LittleEndian\">\n"); //paraview 3.1 - fprintf(file," <ImageData WholeExtent=\"%d %d %d %d %d %d\" Origin=\"%g %g %g\" Spacing=\"%g %g %g\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1, minX1, minX2, minX3, deltaX1, deltaX2, deltaX3); - fprintf(file," <Piece Extent=\"%d %d %d %d %d %d\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1); - fprintf(file," <PointData Scalars=\"VoxelMatrix\">\n"); - fprintf(file," <DataArray type=\"Float32\" Name=\"VoxelMatrix\" format=\"ascii\" RangeMin=\"0\" RangeMax=\"1\">\n "); - - for(int k=0 ; k<nx3 ; k++){ - for(int j=0 ; j<nx2 ; j++){ - for(int i=0 ; i<nx1 ; i++){ - fprintf(file,"%g ",voxelMatrix(i,j,k)); + fprintf(file, " <ImageData WholeExtent=\"%d %d %d %d %d %d\" Origin=\"%g %g %g\" Spacing=\"%g %g %g\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1, minX1, minX2, minX3, deltaX1, deltaX2, deltaX3); + fprintf(file, " <Piece Extent=\"%d %d %d %d %d %d\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1); + fprintf(file, " <PointData Scalars=\"VoxelMatrix\">\n"); + fprintf(file, " <DataArray type=\"Float32\" Name=\"VoxelMatrix\" format=\"ascii\" RangeMin=\"0\" RangeMax=\"1\">\n "); + + for (int k = 0; k<nx3; k++) { + for (int j = 0; j<nx2; j++) { + for (int i = 0; i<nx1; i++) { + fprintf(file, "%g ", voxelMatrix(i, j, k)); } } } - fprintf(file,"\n </DataArray>\n"); - fprintf(file," </PointData>\n"); - fprintf(file," <CellData>\n"); - fprintf(file," </CellData>\n"); - fprintf(file," </Piece>\n"); - fprintf(file," </ImageData>\n"); - fprintf(file,"</VTKFile>\n"); + fprintf(file, "\n </DataArray>\n"); + fprintf(file, " </PointData>\n"); + fprintf(file, " <CellData>\n"); + fprintf(file, " </CellData>\n"); + fprintf(file, " </Piece>\n"); + fprintf(file, " </ImageData>\n"); + fprintf(file, "</VTKFile>\n"); - fclose(file); + fclose(file); } ////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::writeToVTKImageDataAppended( const std::string& fileName ) +void GbVoxelMatrix3D::writeToVTKImageDataAppended(const std::string& fileName) { int nx1 = (int)voxelMatrix.getNX1(); int nx2 = (int)voxelMatrix.getNX2(); int nx3 = (int)voxelMatrix.getNX3(); - string fn = fileName +".appended.vti"; + string fn = fileName+".appended.vti"; - FILE *file; - file = fopen(fn.c_str(),"w"); + FILE *file; + file = fopen(fn.c_str(), "w"); - if (file == NULL) + if (file==NULL) { std::string pathf = UbSystem::getPathFromString(fn); if (fn.size()>0) { UbSystem::makeDirectory(pathf); file = fopen(fn.c_str(), "w"); } - if (file == NULL) throw UbException(UB_EXARGS, "can not open " + fn); + if (file==NULL) throw UbException(UB_EXARGS, "can not open "+fn); } - fprintf(file,"<VTKFile type=\"ImageData\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n"); //paraview 4.1 - fprintf(file," <ImageData WholeExtent=\"%d %d %d %d %d %d\" Origin=\"%g %g %g\" Spacing=\"%g %g %g\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1, minX1, minX2, minX3, deltaX1, deltaX2, deltaX3); - fprintf(file," <Piece Extent=\"%d %d %d %d %d %d\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1); - fprintf(file," <PointData Scalars=\"VoxelMatrix\">\n"); - fprintf(file," <DataArray type=\"Float32\" Name=\"VoxelMatrix\" format=\"appended\" RangeMin=\"0\" RangeMax=\"1\" offset=\"0\" />\n"); - fprintf(file," </PointData>\n"); - fprintf(file," <CellData>\n"); - fprintf(file," </CellData>\n"); - fprintf(file," </Piece>\n"); - fprintf(file," </ImageData>\n"); - fprintf(file," <AppendedData encoding=\"raw\">\n"); - fprintf(file," _"); + fprintf(file, "<VTKFile type=\"ImageData\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n"); //paraview 4.1 + fprintf(file, " <ImageData WholeExtent=\"%d %d %d %d %d %d\" Origin=\"%g %g %g\" Spacing=\"%g %g %g\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1, minX1, minX2, minX3, deltaX1, deltaX2, deltaX3); + fprintf(file, " <Piece Extent=\"%d %d %d %d %d %d\">\n", 0, nx1-1, 0, nx2-1, 0, nx3-1); + fprintf(file, " <PointData Scalars=\"VoxelMatrix\">\n"); + fprintf(file, " <DataArray type=\"Float32\" Name=\"VoxelMatrix\" format=\"appended\" RangeMin=\"0\" RangeMax=\"1\" offset=\"0\" />\n"); + fprintf(file, " </PointData>\n"); + fprintf(file, " <CellData>\n"); + fprintf(file, " </CellData>\n"); + fprintf(file, " </Piece>\n"); + fprintf(file, " </ImageData>\n"); + fprintf(file, " <AppendedData encoding=\"raw\">\n"); + fprintf(file, " _"); fclose(file); file = fopen(fn.c_str(), "ab"); - int size = (int)voxelMatrix.getDataVector().size() * sizeof(float); - fwrite (&size, sizeof(int), 1, file); - fwrite(voxelMatrix.getStartAdressOfSortedArray(0,0,0), sizeof(float), voxelMatrix.getDataVector().size(), file); + int size = (int)voxelMatrix.getDataVector().size()*sizeof(float); + fwrite(&size, sizeof(int), 1, file); + fwrite(voxelMatrix.getStartAdressOfSortedArray(0, 0, 0), sizeof(float), voxelMatrix.getDataVector().size(), file); fclose(file); - file = fopen(fn.c_str(),"a"); - fprintf(file,"\n"); - fprintf(file," </AppendedData>\n"); - fprintf(file,"</VTKFile>\n"); - fclose(file); + file = fopen(fn.c_str(), "a"); + fprintf(file, "\n"); + fprintf(file, " </AppendedData>\n"); + fprintf(file, "</VTKFile>\n"); + fclose(file); } diff --git a/source/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.h b/source/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.h index 7eaace198..d95ae2915 100644 --- a/source/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.h +++ b/source/ThirdParty/Library/numerics/geometry3d/GbVoxelMatrix3D.h @@ -8,7 +8,7 @@ #define GBVOXELMATRIX3D_H #ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> +#include <3rdParty/rcf/RcfSerializationIncludes.h> #endif //CAB_RCF #include <vector> @@ -23,35 +23,35 @@ class GbVoxelMatrix3D; typedef VFSharedPtr<GbVoxelMatrix3D> GbVoxelMatrix3DPtr; -class GbLine3D; -class GbTriangle3D; +class GbLine3D; +class GbTriangle3D; class GbObject3DCreator; class GbVoxelMatrix3D : public GbObject3D, public UbObserver { -public: +public: typedef CbArray3D<float> Matrix3D; - static const float SOLID; - static const float FLUID; - enum Endian {BigEndian, LittleEndian}; + static const float SOLID; + static const float FLUID; + enum Endian { BigEndian, LittleEndian }; GbVoxelMatrix3D(); - GbVoxelMatrix3D(int nx1, int nx2, int nx3, float initVal, double lowerThreshold=0, double upperThreshold=0); - GbVoxelMatrix3D(const Matrix3D& voxelMatrix, double lowerThreshold=0, double upperThreshold=0); - ~GbVoxelMatrix3D() {} + GbVoxelMatrix3D(int nx1, int nx2, int nx3, float initVal, double lowerThreshold = 0, double upperThreshold = 0); + GbVoxelMatrix3D(const Matrix3D& voxelMatrix, double lowerThreshold = 0, double upperThreshold = 0); + ~GbVoxelMatrix3D() {} void finalize() {}; - GbVoxelMatrix3D* clone(); + GbVoxelMatrix3D* clone(); /*=======================================================================*/ Matrix3D::reference operator() (const Matrix3D::size_type& x1, const Matrix3D::size_type& x2, const Matrix3D::size_type& x3) { - return voxelMatrix(x1,x2,x3); + return voxelMatrix(x1, x2, x3); } /*=======================================================================*/ Matrix3D::const_reference operator() (const Matrix3D::size_type& x1, const Matrix3D::size_type& x2, const Matrix3D::size_type& x3) const { - return voxelMatrix(x1,x2,x3); + return voxelMatrix(x1, x2, x3); } /*=======================================================================*/ void setTransferViaFilename(bool transferViaFilename, std::string filename) @@ -67,7 +67,7 @@ public: void setVoxelMatrixMinX1(double minX1) { this->minX1 = minX1; } void setVoxelMatrixMinX2(double minX2) { this->minX2 = minX2; } void setVoxelMatrixMinX3(double minX3) { this->minX3 = minX3; } - + /*=======================================================================*/ void setVoxelMatrixDelta(double deltaX1, double deltaX2, double deltaX3) { this->deltaX1 = deltaX1; this->deltaX2 = deltaX2; this->deltaX3 = deltaX3; } void setVoxelMatrixDeltaX1(double deltaX1) { this->deltaX1 = deltaX1; } @@ -75,34 +75,34 @@ public: void setVoxelMatrixDeltaX3(double deltaX3) { this->deltaX3 = deltaX3; } /*=======================================================================*/ - double getX1Centroid() { return 0.5 * ( minX1 + this->getX1Maximum() ); } - double getX1Minimum() { return minX1; } - double getX1Maximum() { return minX1 + deltaX1*voxelMatrix.getNX1(); } + double getX1Centroid() { return 0.5 * (minX1+this->getX1Maximum()); } + double getX1Minimum() { return minX1; } + double getX1Maximum() { return minX1+deltaX1*voxelMatrix.getNX1(); } - double getX2Centroid() { return 0.5 * ( minX2 + this->getX2Maximum() ); } - double getX2Minimum() { return minX2; } - double getX2Maximum() { return minX2 + deltaX2*voxelMatrix.getNX2(); } + double getX2Centroid() { return 0.5 * (minX2+this->getX2Maximum()); } + double getX2Minimum() { return minX2; } + double getX2Maximum() { return minX2+deltaX2*voxelMatrix.getNX2(); } - double getX3Centroid() { return 0.5 * ( this->getX3Minimum() + this->getX3Maximum() ); } - double getX3Minimum() { return minX3; } - double getX3Maximum() { return minX3 + deltaX3*voxelMatrix.getNX3(); } + double getX3Centroid() { return 0.5 * (this->getX3Minimum()+this->getX3Maximum()); } + double getX3Minimum() { return minX3; } + double getX3Maximum() { return minX3+deltaX3*voxelMatrix.getNX3(); } - double getLengthX1() { return this->getX1Maximum() - minX1; } - double getLengthX2() { return this->getX2Maximum() - minX2; } - double getLengthX3() { return this->getX3Maximum() - minX3; } + double getLengthX1() { return this->getX1Maximum()-minX1; } + double getLengthX2() { return this->getX2Maximum()-minX2; } + double getLengthX3() { return this->getX3Maximum()-minX3; } void setCenterCoordinates(const double& x1, const double& x2, const double& x3); void translate(const double& tx1, const double& tx2, const double& tx3); bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p); - bool isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - bool isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - bool isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); + bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p); + bool isCellInsideGbObject3D(const double& x1a, const double& x2a, const double& x3a, const double& x1b, const double& x2b, const double& x3b); + bool isCellCuttingGbObject3D(const double& x1a, const double& x2a, const double& x3a, const double& x1b, const double& x2b, const double& x3b); + bool isCellInsideOrCuttingGbObject3D(const double& x1a, const double& x2a, const double& x3a, const double& x1b, const double& x2b, const double& x3b); //double getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - GbPoint3D* calculateInterSectionPoint3D(GbPoint3D& point1, GbPoint3D &point2) { throw UbException(__FILE__,__LINE__, UB_FUNCTION,"not implemented");} - GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2){ throw UbException(__FILE__,__LINE__, UB_FUNCTION,"not implemented");} + GbPoint3D* calculateInterSectionPoint3D(GbPoint3D& point1, GbPoint3D &point2) { throw UbException(__FILE__, __LINE__, UB_FUNCTION, "not implemented"); } + GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2) { throw UbException(__FILE__, __LINE__, UB_FUNCTION, "not implemented"); } std::vector<GbTriangle3D*> getSurfaceTriangleSet(); void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles); @@ -138,7 +138,7 @@ public: void mirrorZ(); void writeToLegacyVTKASCII(const std::string& fileName); - void writeToLegacyVTKBinary( const std::string& fileName ); + void writeToLegacyVTKBinary(const std::string& fileName); void writeToVTKImageDataASCII(const std::string& fileName); void writeToVTKImageDataAppended(const std::string& fileName); @@ -180,14 +180,14 @@ protected: ar & threshold; ar & transferViaFilename; ar & addSurfaceTriangleSetFlag; - if(!transferViaFilename) + if (!transferViaFilename) { ar & voxelMatrix; } else { ar & filename; - if(ArchiveTools::isReading(ar) ) + if (ArchiveTools::isReading(ar)) { this->readMatrixFromVtiASCIIFile(filename); } @@ -226,47 +226,47 @@ template <class T> void GbVoxelMatrix3D::readMatrixFromRawFile(std::string filename, GbVoxelMatrix3D::Endian endian) { using namespace std; - UBLOG(logINFO,"GbVoxelMatrix3D::readMatrixFromFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start"); + //UBLOG(logINFO,"GbVoxelMatrix3D::readMatrixFromFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start"); ifstream in(filename.c_str(), ios::binary); - if(!in) throw UbException(UB_EXARGS,"could not open file "+filename); + if (!in) throw UbException(UB_EXARGS, "could not open file "+filename); - in.seekg( 0, ios::end ); //Ende springen + in.seekg(0, ios::end); //Ende springen fstream::off_type length = in.tellg(); //Position abfragen - in.seekg( 0, ios::beg ); //An den Anfang springen + in.seekg(0, ios::beg); //An den Anfang springen //UBLOG(logINFO,"number of nodes = "<<nodesX1*nodesX2*nodesX3*sizeof(T)<<" file size = "<<(long)length); //if( (nodesX1*nodesX2*nodesX3)*sizeof(float) != (long)length ) unsigned long long nofn = (unsigned long long)nodesX1*(unsigned long long)nodesX2*(unsigned long long)nodesX3*(unsigned long long)sizeof(T); - if (nofn != (unsigned long long)length) + if (nofn!=(unsigned long long)length) { - throw UbException(UB_EXARGS,"number of nodes("+UbSystem::toString(nofn)+") doesn't match file size("+UbSystem::toString((long)length)+")"); + throw UbException(UB_EXARGS, "number of nodes("+UbSystem::toString(nofn)+") doesn't match file size("+UbSystem::toString((long)length)+")"); } - UBLOG(logINFO," - create GbVoxelMatrix3D"); + //UBLOG(logINFO," - create GbVoxelMatrix3D"); //GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID); - voxelMatrix = Matrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID); + voxelMatrix = Matrix3D(nodesX1, nodesX2, nodesX3, GbVoxelMatrix3D::FLUID); - UBLOG(logINFO," - init values"); + //UBLOG(logINFO," - init values"); //float val; T val; - for(int x3=0; x3<nodesX3; x3++) - for(int x2=0; x2<nodesX2; x2++) - for(int x1=0; x1<nodesX1; x1++) + for (int x3 = 0; x3<nodesX3; x3++) + for (int x2 = 0; x2<nodesX2; x2++) + for (int x1 = 0; x1<nodesX1; x1++) { //in.read((char*)&val,sizeof(float)); - in.read((char*)&val,sizeof(T)); - if (endian == BigEndian) + in.read((char*)&val, sizeof(T)); + if (endian==BigEndian) UbSystem::swapByteOrder((unsigned char*)(&(val)), sizeof(T)); //if( UbMath::equal((double)val, threshold) ) //if( UbMath::greater((double)val, threshold) ) - if( (double)val >= lowerThreshold && (double)val <= upperThreshold ) + if ((double)val>=lowerThreshold&&(double)val<=upperThreshold) { - (voxelMatrix)(x1,x2,x3) = GbVoxelMatrix3D::SOLID; + (voxelMatrix)(x1, x2, x3) = GbVoxelMatrix3D::SOLID; } //(voxelMatrix)(x1, x2, x3) = (float)val; } - UBLOG(logINFO,"GbVoxelMatrix3D::readMatrixFromFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end"); + //UBLOG(logINFO,"GbVoxelMatrix3D::readMatrixFromFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end"); } ////////////////////////////////////////////////////////////////////////// @@ -289,9 +289,9 @@ void GbVoxelMatrix3D::readBufferedMatrixFromRawFile(std::string filename, GbVoxe rewind(file); UBLOG(logINFO, "number of nodes = "<<(long)nodesX1*(long)nodesX2*(long)nodesX3<<" file size = "<<length); - + unsigned long int nofn = (long)nodesX1*(long)nodesX2*(long)nodesX3*(long)sizeof(T); - if (nofn != length) + if (nofn!=length) { //throw UbException(UB_EXARGS, "number of nodes("+UbSystem::toString(nofn)+") doesn't match file size("+UbSystem::toString(length)+")"); } @@ -315,12 +315,12 @@ void GbVoxelMatrix3D::readBufferedMatrixFromRawFile(std::string filename, GbVoxe { val = readMatrix(x1, x2, x3); - if (endian == BigEndian) + if (endian==BigEndian) { UbSystem::swapByteOrder((unsigned char*)(&(val)), sizeof(T)); } - if ((double)val >= lowerThreshold && (double)val <= upperThreshold) + if ((double)val>=lowerThreshold&&(double)val<=upperThreshold) { voxelMatrix(x1, x2, x3) = GbVoxelMatrix3D::SOLID; } @@ -331,9 +331,9 @@ void GbVoxelMatrix3D::readBufferedMatrixFromRawFile(std::string filename, GbVoxe #if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - UB_AUTO_RUN_NAMED( SF::registerType<GbVoxelMatrix3D>("GbVoxelMatrix3D") , SF_GbVoxelMatrix3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbVoxelMatrix3D >()), SF_GbVoxelMatrix3D_BD1 ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbVoxelMatrix3D>() ), SF_GbVoxelMatrix3D_BD2 ); +UB_AUTO_RUN_NAMED(SF::registerType<GbVoxelMatrix3D>("GbVoxelMatrix3D"), SF_GbVoxelMatrix3D); +UB_AUTO_RUN_NAMED((SF::registerBaseAndDerived< GbObject3D, GbVoxelMatrix3D >()), SF_GbVoxelMatrix3D_BD1); +UB_AUTO_RUN_NAMED((SF::registerBaseAndDerived< UbObserver, GbVoxelMatrix3D>()), SF_GbVoxelMatrix3D_BD2); #endif //RCF_USE_SF_SERIALIZATION diff --git a/source/VirtualFluids.h b/source/VirtualFluids.h index 6fb6880b1..43c809702 100644 --- a/source/VirtualFluids.h +++ b/source/VirtualFluids.h @@ -79,30 +79,30 @@ #include <basics/writer/WbWriterVtkXmlBinary.h> #include <basics/writer/WbWriterX3D.h> // #include <BoundaryCondition/BCArray.h> -#include <BoundaryCondition/BCArray3D.h> -#include <BoundaryCondition/BCProcessor.h> -#include <BoundaryCondition/BoundaryCondition.h> -#include <BoundaryCondition/D3Q27BCFunction.h> -#include <BoundaryCondition/D3Q27BoundaryCondition.h> -#include <BoundaryCondition/D3Q27BoundaryConditionAdapter.h> -#include <BoundaryCondition/D3Q27DensityBCAdapter.h> -#include <BoundaryCondition/D3Q27ETBCProcessor.h> -#include <BoundaryCondition/D3Q27ETForThinWallBCProcessor.h> -#include <BoundaryCondition/D3Q27NoSlipBCAdapter.h> -#include <BoundaryCondition/D3Q27SlipBCAdapter.h> -#include <BoundaryCondition/D3Q27VelocityBCAdapter.h> +#include <BoundaryConditions/BCArray3D.h> +#include <BoundaryConditions/BCProcessor.h> +#include <BoundaryConditions/BCAlgorithm.h> +#include <BoundaryConditions/BCFunction.h> +#include <BoundaryConditions/BoundaryConditions.h> +#include <BoundaryConditions/BCAdapter.h> +#include <BoundaryConditions/DensityBCAdapter.h> +#include <BoundaryConditions/BCProcessor.h> +#include <BoundaryConditions/ThinWallBCProcessor.h> +#include <BoundaryConditions/NoSlipBCAdapter.h> +#include <BoundaryConditions/SlipBCAdapter.h> +#include <BoundaryConditions/VelocityBCAdapter.h> //#include <BoundaryCondition/BoundaryConditionProcessor.h> -#include <BoundaryCondition/BoundaryCondition.h> -#include <BoundaryCondition/VelocityBoundaryCondition.h> -#include <BoundaryCondition/NonEqDensityBoundaryCondition.h> -#include <BoundaryCondition/EqDensityBoundaryCondition.h> -#include <BoundaryCondition/NoSlipBoundaryCondition.h> -#include <BoundaryCondition/ThinWallNoSlipBoundaryCondition.h> -#include <BoundaryCondition/HighViscosityNoSlipBoundaryCondition.h> -#include <BoundaryCondition/SlipBoundaryCondition.h> -#include <BoundaryCondition/NonReflectingDensityBoundaryCondition.h> -#include <BoundaryCondition/NonReflectingVelocityBoundaryCondition.h> +#include <BoundaryConditions/BCAlgorithm.h> +#include <BoundaryConditions/VelocityBCAlgorithm.h> +#include <BoundaryConditions/NonEqDensityBCAlgorithm.h> +#include <BoundaryConditions/EqDensityBCAlgorithm.h> +#include <BoundaryConditions/NoSlipBCAlgorithm.h> +#include <BoundaryConditions/ThinWallNoSlipBCAlgorithm.h> +#include <BoundaryConditions/HighViscosityNoSlipBCAlgorithm.h> +#include <BoundaryConditions/SlipBCAlgorithm.h> +#include <BoundaryConditions/NonReflectingDensityBCAlgorithm.h> +#include <BoundaryConditions/NonReflectingVelocityBCAlgorithm.h> #include <Connectors/Block3DConnector.h> #include <Connectors/D3Q27ETCFOffVectorConnector.h> @@ -139,7 +139,8 @@ #include <CoProcessors/WriteBlocksCoProcessor.h> #include <CoProcessors/AdjustForcingCoProcessor.h> #include <CoProcessors/CalculateForcesCoProcessor.h> -#include <CoProcessors/MacroscopicQuantitiesCoProcessor.h> +#include <CoProcessors/WriteMacroscopicQuantitiesCoProcessor.h> +#include <CoProcessors/WriteBoundaryConditionsCoProcessor.h> //#include <CoProcessors/PathLineCoProcessor.h> //#include <CoProcessors/PathLineCoProcessorMcpart.h> #include <CoProcessors/PressureDifferenceCoProcessor.h> @@ -159,19 +160,20 @@ #include <CoProcessors/TimeAveragedValuesCoProcessor.h> #include <CoProcessors/InSituCatalystCoProcessor.h> #include <LineTimeSeriesCoProcessor.h> -#include <LBM/D3Q27CompactInterpolationProcessor.h> -#include <LBM/D3Q27IncompressibleOffsetInterpolationProcessor.h> -#include <LBM/D3Q27IntegrateValuesHelper.h> -#include <LBM/D3Q27InterpolationHelper.h> -#include <LBM/D3Q27InterpolationProcessor.h> -#include <LBM/D3Q27OffsetInterpolationProcessor.h> +#include <IntegrateValuesHelper.h> +//#include <LBM/D3Q27CompactInterpolationProcessor.h> +#include <LBM/IncompressibleOffsetInterpolationProcessor.h> +#include <LBM/CompressibleOffsetInterpolationProcessor.h> +#include <LBM/InterpolationHelper.h> +#include <LBM/InterpolationProcessor.h> +//#include <LBM/D3Q27OffsetInterpolationProcessor.h> #include <LBM/D3Q27System.h> #include <LBM/ICell.h> #include <LBM/InterpolationProcessor.h> -#include <LBM/LBMKernel3D.h> -#include <LBMKernelETD3Q27CCLBWithSpongeLayer.h> -#include <LBM/LBMKernelETD3Q27.h> -#include <LBM/LBMKernelETD3Q27CCLB.h> +#include <LBM/LBMKernel.h> +#include <IncompressibleCumulantWithSpongeLayerLBMKernel.h> +#include <LBM/LBMKernel.h> +#include <LBM/IncompressibleCumulantLBMKernel.h> #include <LBM/CompressibleCumulantLBMKernel.h> #include <LBM/InitDensityLBMKernel.h> #include <LBM/VoidLBMKernel.h> @@ -263,9 +265,9 @@ #include <Utilities/ConfigFileReader.h> #include <Visitors/Block3DVisitor.h> #include <Visitors/CreateTransmittersHelper.h> -#include <Visitors/D3Q27ETInitDistributionsBlockVisitor.h> -#include <Visitors/D3Q27SetConnectorsBlockVisitor.h> -#include <Visitors/D3Q27SetUndefinedNodesBlockVisitor.h> +#include <Visitors/InitDistributionsBlockVisitor.h> +#include <Visitors/SetConnectorsBlockVisitor.h> +#include <Visitors/SetUndefinedNodesBlockVisitor.h> #include <Visitors/GenBlocksGridVisitor.h> #include <Visitors/Grid3DVisitor.h> #include <Visitors/MetisPartitioningGridVisitor.h> @@ -275,6 +277,7 @@ #include <Visitors/RatioSmoothBlockVisitor.h> #include <Visitors/RefineCrossAndInsideGbObjectBlockVisitor.h> #include <Visitors/RefineInterGbObjectsVisitor.h> +#include <Visitors/CoarsenCrossAndInsideGbObjectBlockVisitor.h> #include <Visitors/SetInterpolationDirsBlockVisitor.h> #include <Visitors/SetKernelBlockVisitor.h> #include <Visitors/SetForcingBlockVisitor.h> @@ -283,7 +286,8 @@ #include <Visitors/RenumberBlockVisitor.h> #include <Visitors/ConnectorBlockVisitor.h> #include <Visitors/ViscosityBlockVisitor.h> -#include <Visitors/BoundaryConditionBlockVisitor.h> +#include <Visitors/BoundaryConditionsBlockVisitor.h> +#include <Visitors/BoundaryConditionsBlockVisitor.h> #include <Visitors/ChangeBoundaryDensityBlockVisitor.h> #include <InitDistributionsFromFileBlockVisitor.h> #include <CheckRatioBlockVisitor.h> diff --git a/source/VirtualFluidsCore/BoundaryConditions/BCAdapter.h b/source/VirtualFluidsCore/BoundaryConditions/BCAdapter.h new file mode 100644 index 000000000..c8e29bfc7 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/BCAdapter.h @@ -0,0 +1,100 @@ +// _ ___ __ __________ _ __ +// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ +// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ +// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) +// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +// +#ifndef D3Q27BOUNDARYCONDITIONADAPTER_H +#define D3Q27BOUNDARYCONDITIONADAPTER_H + +#ifdef CAB_RCF + #include <3rdParty/rcf/RcfSerializationIncludes.h> +#endif + +#include <boost/serialization/serialization.hpp> +#include <boost/serialization/base_object.hpp> +#include <boost/serialization/export.hpp> +#include <boost/shared_ptr.hpp> + +class BCAdapter; +typedef boost::shared_ptr<BCAdapter> BCAdapterPtr; + +#include "BoundaryConditions.h" +#include "basics/objects/ObObject.h" +#include "basics/objects/ObObjectCreator.h" +#include "basics/utilities/UbFileOutput.h" +#include "basics/utilities/UbFileInput.h" +#include "basics/utilities/UbAutoRun.hpp" +#include "BCAlgorithm.h" + + +/*=========================================================================*/ +/* D3Q27BoundaryConditionAdapter */ +/* */ +/** +<BR><BR> +@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> +@version 1.0 - 06.09.06 +*/ + +/* +usage: ... +*/ + +class D3Q27Interactor; + +class BCAdapter +{ +public: + BCAdapter() + : secondaryBcOption(0) + , type(0) + , algorithmType(-1) + { + } + BCAdapter(const short& secondaryBcOption) + : secondaryBcOption(secondaryBcOption) + , type(0) + , algorithmType(-1) + { + } + virtual ~BCAdapter() {} + + //methods + bool isTimeDependent() { return((this->type & TIMEDEPENDENT) == TIMEDEPENDENT); } + + virtual short getSecondaryBcOption() { return this->secondaryBcOption; } + virtual void setSecondaryBcOption(const short& val) { this->secondaryBcOption=val; } + + virtual void init(const D3Q27Interactor* const& interactor, const double& time=0) = 0; + virtual void update(const D3Q27Interactor* const& interactor, const double& time=0) = 0; + + virtual void adaptBC( const D3Q27Interactor& interactor, BoundaryConditionsPtr bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& time=0 ) = 0; + virtual void adaptBCForDirection( const D3Q27Interactor& interactor, BoundaryConditionsPtr bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& q, const int& fdirection, const double& time=0 ) = 0; + + void setBcAlgorithm(BCAlgorithmPtr alg) {algorithmType = alg->getType(); algorithm = alg;} + BCAlgorithmPtr getAlgorithm() {return algorithm;} + char getBcAlgorithmType() {return algorithmType;} + +protected: + short secondaryBcOption; + + char type; + + BCAlgorithmPtr algorithm; + char algorithmType; + + static const char TIMEDEPENDENT = 1<<0;//'1'; + static const char TIMEPERIODIC = 1<<1;//'2'; + +private: + friend class boost::serialization::access; + template<class Archive> + void serialize(Archive & ar, const unsigned int version) + { + ar & secondaryBcOption; + } +}; + + +#endif //D3Q27BOUNDARYCONDITIONADAPTER_H diff --git a/source/VirtualFluidsCore/BoundaryConditions/BCAlgorithm.cpp b/source/VirtualFluidsCore/BoundaryConditions/BCAlgorithm.cpp new file mode 100644 index 000000000..8c4e11096 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/BCAlgorithm.cpp @@ -0,0 +1,103 @@ +#include "BCAlgorithm.h" + +BCAlgorithm::BCAlgorithm() : compressible(false) +{ + +} +////////////////////////////////////////////////////////////////////////// +void BCAlgorithm::apply() +{ + //if (this->compressible) + //{ + // calcFeqsForDirFct = &D3Q27System::getCompFeqForDirection; + // calcMacrosFct = &D3Q27System::calcCompMacroscopicValues; + // calcFeqFct = &D3Q27System::calcCompFeq; + //} + //else + //{ + // calcFeqsForDirFct = &D3Q27System::getIncompFeqForDirection; + // calcMacrosFct = &D3Q27System::calcIncompMacroscopicValues; + // calcFeqFct = &D3Q27System::calcIncompFeq; + //} + + int cbc = 0; + int cn = 0; + int j; + + int nsize = (int)nodeVector.size(); + + for (j = cn; j < nsize;) + { + x1 = nodeVector[j++]; + x2 = nodeVector[j++]; + x3 = nodeVector[j++]; + + bcPtr = bcVector[cbc]; + cbc++; + + applyBC(); + } + cn = j; +} +//////////////////////////////////////////////////////////////////////////// +//void BoundaryCondition::addDistributions(EsoTwist3DPtr distributions) +//{ +// this->distributions = distributions; +//} +////////////////////////////////////////////////////////////////////////// +void BCAlgorithm::addNode(int x1, int x2, int x3) +{ + nodeVector.push_back(x1); + nodeVector.push_back(x2); + nodeVector.push_back(x3); +} +////////////////////////////////////////////////////////////////////////// +void BCAlgorithm::addBcPointer(BoundaryConditionsPtr bcPtr) +{ + bcVector.push_back(bcPtr); +} +////////////////////////////////////////////////////////////////////////// +void BCAlgorithm::setCompressible(bool c) +{ + compressible = c; + + if (this->compressible) + { + calcFeqsForDirFct = &D3Q27System::getCompFeqForDirection; + calcMacrosFct = &D3Q27System::calcCompMacroscopicValues; + calcFeqFct = &D3Q27System::calcCompFeq; + compressibleFactor = 1.0; + } + else + { + calcFeqsForDirFct = &D3Q27System::getIncompFeqForDirection; + calcMacrosFct = &D3Q27System::calcIncompMacroscopicValues; + calcFeqFct = &D3Q27System::calcIncompFeq; + compressibleFactor = 0.0; + } +} +////////////////////////////////////////////////////////////////////////// +void BCAlgorithm::setCollFactor(LBMReal cf) +{ + collFactor = cf; +} + +////////////////////////////////////////////////////////////////////////// +char BCAlgorithm::getType() +{ + return type; +} +////////////////////////////////////////////////////////////////////////// +bool BCAlgorithm::isPreCollision() +{ + return preCollision; +} +////////////////////////////////////////////////////////////////////////// +void BCAlgorithm::clearData() +{ + nodeVector.clear(); + bcVector.clear(); +} + + + diff --git a/source/VirtualFluidsCore/BoundaryConditions/BCAlgorithm.h b/source/VirtualFluidsCore/BoundaryConditions/BCAlgorithm.h new file mode 100644 index 000000000..7306dab2e --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/BCAlgorithm.h @@ -0,0 +1,88 @@ + +#ifndef BOUNDARYCONDITIONS_H +#define BOUNDARYCONDITIONS_H + +#include <vector> +#include <string> + +#include "BoundaryConditions.h" +#include "D3Q27System.h" +#include "EsoTwist3D.h" + +#include <boost/serialization/serialization.hpp> +#include <boost/serialization/base_object.hpp> +#include <boost/serialization/export.hpp> + +#include <boost/shared_ptr.hpp> + +class BCAlgorithm; +typedef boost::shared_ptr<BCAlgorithm> BCAlgorithmPtr; + +class BCAlgorithm +{ +public: + static const char VelocityBCAlgorithm = 0; + static const char EqDensityBCAlgorithm = 1; + static const char NonEqDensityBCAlgorithm = 2; + static const char NoSlipBCAlgorithm = 3; + static const char SlipBCAlgorithm = 4; + static const char HighViscosityNoSlipBCAlgorithm = 5; + static const char ThinWallNoSlipBCAlgorithm = 6; + static const char NonReflectingVelocityBCAlgorithm = 7; + static const char NonReflectingDensityBCAlgorithm = 8; +public: + BCAlgorithm(); + virtual ~BCAlgorithm() {} + + void apply(); + virtual void addDistributions(DistributionArray3DPtr distributions) = 0; + void addNode(int x1, int x2, int x3); + void addBcPointer(BoundaryConditionsPtr bcPtr); + void setCompressible(bool c); + void setCollFactor(LBMReal cf); + char getType(); + bool isPreCollision(); + virtual BCAlgorithmPtr clone()=0; + void clearData(); +protected: + virtual void applyBC() = 0; + + std::vector <int> nodeVector; + std::vector <BoundaryConditionsPtr> bcVector; + + bool compressible; + char type; + bool preCollision; + + BoundaryConditionsPtr bcPtr; + DistributionArray3DPtr distributions; + + LBMReal collFactor; + int x1, x2, x3; + + LBMReal compressibleFactor; + + typedef void(*CalcMacrosFct)(const LBMReal* const& /*f[27]*/, LBMReal& /*rho*/, LBMReal& /*vx1*/, LBMReal& /*vx2*/, LBMReal& /*vx3*/); + typedef LBMReal(*CalcFeqForDirFct)(const int& /*direction*/, const LBMReal& /*(d)rho*/, const LBMReal& /*vx1*/, const LBMReal& /*vx2*/, const LBMReal& /*vx3*/); + typedef void(*CalcFeqFct)(LBMReal* const& /*feq/*[27]*/, const LBMReal& /*rho*/, const LBMReal& /*vx1*/, const LBMReal& /*vx2*/, const LBMReal& /*vx3*/); + + CalcFeqForDirFct calcFeqsForDirFct ; + CalcMacrosFct calcMacrosFct; + CalcFeqFct calcFeqFct; + +private: + //friend class boost::serialization::access; + //template<class Archive> + //void serialize(Archive & ar, const unsigned int version) + //{ + // ar & nodeVector; + // ar & bcVector; + // ar & compressible; + // ar & type; + // ar & distributions; + // ar & collFactor; + //} +}; + + +#endif diff --git a/source/VirtualFluidsCore/BoundaryConditions/BCArray3D.cpp b/source/VirtualFluidsCore/BoundaryConditions/BCArray3D.cpp new file mode 100644 index 000000000..22df9daf1 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/BCArray3D.cpp @@ -0,0 +1,196 @@ +#include "BCArray3D.h" + + +const int BCArray3D::SOLID = -1; +const int BCArray3D::FLUID = -2; +const int BCArray3D::INTERFACECF = -3; +const int BCArray3D::INTERFACEFC = -4; +const int BCArray3D::UNDEFINED = -5; + +////////////////////////////////////////////////////////////////////////// +BCArray3D::BCArray3D() {} +////////////////////////////////////////////////////////////////////////// +BCArray3D::BCArray3D(std::size_t nx1, std::size_t nx2, std::size_t nx3) +{ + bcindexmatrix.resize(nx1, nx2, nx3, UNDEFINED); +} +////////////////////////////////////////////////////////////////////////// +BCArray3D::BCArray3D(std::size_t nx1, std::size_t nx2, std::size_t nx3, int val) +{ + bcindexmatrix.resize(nx1, nx2, nx3, val); +} +////////////////////////////////////////////////////////////////////////// +BCArray3D::~BCArray3D() {} +////////////////////////////////////////////////////////////////////////// +void BCArray3D::resize(std::size_t nx1, std::size_t nx2, std::size_t nx3) +{ + bcindexmatrix.resize(nx1, nx2, nx3); +} +////////////////////////////////////////////////////////////////////////// +void BCArray3D::resize(std::size_t nx1, std::size_t nx2, std::size_t nx3, int val) +{ + bcindexmatrix.resize(nx1, nx2, nx3, val); +} +////////////////////////////////////////////////////////////////////////// +bool BCArray3D::validIndices(std::size_t x1, std::size_t x2, std::size_t x3) const +{ + if (x1 < 0 || x1 >= this->bcindexmatrix.getNX1()) return false; + if (x2 < 0 || x2 >= this->bcindexmatrix.getNX2()) return false; + if (x3 < 0 || x3 >= this->bcindexmatrix.getNX3()) return false; + return true; +} +////////////////////////////////////////////////////////////////////////// +void BCArray3D::setBC(std::size_t x1, std::size_t x2, std::size_t x3, BCClassPtr const& bc) +{ + if (this->hasBC(x1, x2, x3)) + { + if (this->getBC(x1, x2, x3) == bc) return; + else this->deleteBC(x1, x2, x3); + } + + //wenn keine frei gewordene BCs vorhanden + if (indexContainer.empty()) + { + bcvector.push_back(bc); + bcindexmatrix(x1, x2, x3) = (int)bcvector.size() - 1; + } + else + { + int index = indexContainer.back(); + bcindexmatrix(x1, x2, x3) = index; + bcvector[index] = bc; + indexContainer.pop_back(); + } +} +////////////////////////////////////////////////////////////////////////// +void BCArray3D::setSolid(std::size_t x1, std::size_t x2, std::size_t x3) +{ + if (this->hasBC(x1, x2, x3)) this->deleteBC(x1, x2, x3); + bcindexmatrix(x1, x2, x3) = SOLID; +} +////////////////////////////////////////////////////////////////////////// +void BCArray3D::setFluid(std::size_t x1, std::size_t x2, std::size_t x3) +{ + if (this->hasBC(x1, x2, x3)) this->deleteBC(x1, x2, x3); + bcindexmatrix(x1, x2, x3) = FLUID; +} +////////////////////////////////////////////////////////////////////////// +void BCArray3D::setUndefined(std::size_t x1, std::size_t x2, std::size_t x3) +{ + if (this->hasBC(x1, x2, x3)) this->deleteBC(x1, x2, x3); + bcindexmatrix(x1, x2, x3) = UNDEFINED; +} +////////////////////////////////////////////////////////////////////////// +std::size_t BCArray3D::getNumberOfSolidEntries() const +{ + const std::vector<int>& data = bcindexmatrix.getDataVector(); + std::size_t counter = 0; + for (std::size_t i = 0; i < data.size(); i++) + if (data[i] == SOLID) counter++; + return counter; +} +////////////////////////////////////////////////////////////////////////// +std::size_t BCArray3D::getNumberOfFluidEntries() const +{ + const std::vector<int>& data = bcindexmatrix.getDataVector(); + std::size_t counter = 0; + for (std::size_t i = 0; i < data.size(); i++) + { + int tmp = data[i]; + if (tmp == FLUID || tmp >= 0) counter++; + } + return counter; +} +////////////////////////////////////////////////////////////////////////// +std::size_t BCArray3D::getNumberOfFluidWithoutBCEntries() const +{ + const std::vector<int>& data = bcindexmatrix.getDataVector(); + std::size_t counter = 0; + for (std::size_t i = 0; i < data.size(); i++) + if (data[i] == FLUID) counter++; + return counter; +} +////////////////////////////////////////////////////////////////////////// +std::size_t BCArray3D::getNumberOfBCEntries() const +{ + const std::vector<int>& data = bcindexmatrix.getDataVector(); + std::size_t counter = 0; + for (std::size_t i = 0; i < data.size(); i++) + if (data[i] >= 0) counter++; + return counter; +} +////////////////////////////////////////////////////////////////////////// +std::size_t BCArray3D::getNumberOfUndefinedEntries() const +{ + const std::vector<int>& data = bcindexmatrix.getDataVector(); + std::size_t counter = 0; + for (std::size_t i = 0; i < data.size(); i++) + if (data[i] == UNDEFINED) counter++; + return counter; +} +////////////////////////////////////////////////////////////////////////// +std::size_t BCArray3D::getBCVectorSize() const +{ + return this->bcvector.size(); +} +////////////////////////////////////////////////////////////////////////// +std::string BCArray3D::toString() const +{ + std::size_t solidCounter = 0; + std::size_t fluidCounter = 0; + std::size_t bcCounter = 0; + std::size_t undefCounter = 0; + + for (int x1 = 0; x1 < bcindexmatrix.getNX1(); x1++) + { + for (int x2 = 0; x2 < bcindexmatrix.getNX2(); x2++) + { + for (int x3 = 0; x3 < bcindexmatrix.getNX3(); x3++) + { + if (bcindexmatrix(x1, x2, x3) >= 0) bcCounter++; + else if (bcindexmatrix(x1, x2, x3) == FLUID) fluidCounter++; + else if (bcindexmatrix(x1, x2, x3) == SOLID) solidCounter++; + else if (bcindexmatrix(x1, x2, x3) == UNDEFINED) undefCounter++; + else throw UbException(UB_EXARGS, "invalid matrixEntry"); + } + } + } + + std::size_t unrefEntriesInBcVector = 0; + for (std::size_t i = 0; i < bcvector.size(); i++) if (!bcvector[i]) unrefEntriesInBcVector++; + + std::stringstream text; + text << "BCArray<" << typeid(BCClassPtr).name() << "," << typeid(int).name() << ">"; + text << "[ entries: " << bcindexmatrix.getNX1() << "x" << bcindexmatrix.getNX2(); + text << "x" << bcindexmatrix.getNX3() << "="; + text << bcindexmatrix.getNX1()*bcindexmatrix.getNX2()*bcindexmatrix.getNX3() << " ]:\n"; + text << " - #fluid entries : " << fluidCounter << std::endl; + text << " - #bc entries : " << bcCounter << std::endl; + text << " - #solid entries : " << solidCounter << std::endl; + text << " - #undef entries : " << undefCounter << std::endl; + text << " - bcvector-entries : " << bcvector.size() << " (empty ones: " << unrefEntriesInBcVector << ")\n"; + text << " - indexContainer-entries: " << indexContainer.size() << std::endl; + + return text.str(); +} +////////////////////////////////////////////////////////////////////////// +void BCArray3D::deleteBCAndSetType(std::size_t x1, std::size_t x2, std::size_t x3, int type) + { + this->deleteBC(x1, x2, x3); + + //matrix neuen Typ zuweisen + bcindexmatrix(x1, x2, x3) = type; + } +////////////////////////////////////////////////////////////////////////// +void BCArray3D::deleteBC(std::size_t x1, std::size_t x2, std::size_t x3) + { + //ueberpruefen, ob ueberhaupt BC vorhanden + int index = bcindexmatrix(x1, x2, x3); + if (index < 0) return; + + //frei gewordenen Index in den Indexcontainer schieben + indexContainer.push_back(index); + + //element "loeschen" + bcvector[index] = BCClassPtr(); + } \ No newline at end of file diff --git a/source/VirtualFluidsCore/BoundaryConditions/BCArray3D.h b/source/VirtualFluidsCore/BoundaryConditions/BCArray3D.h new file mode 100644 index 000000000..649584ae5 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/BCArray3D.h @@ -0,0 +1,185 @@ +#ifndef BCArray_H +#define BCArray_H + +#include "BoundaryConditions.h" +#include "basics/container/CbArray3D.h" + +#include <typeinfo> + +#include <boost/serialization/serialization.hpp> +#include <boost/shared_ptr.hpp> + +typedef boost::shared_ptr<BoundaryConditions> BCClassPtr; + +class BCArray3D; +typedef boost::shared_ptr<BCArray3D> BCArray3DPtr; + +class BCArray3D +{ +public: + ////////////////////////////////////////////////////////////////////////// + BCArray3D(); + ////////////////////////////////////////////////////////////////////////// + BCArray3D(std::size_t nx1, std::size_t nx2, std::size_t nx3); + ////////////////////////////////////////////////////////////////////////// + BCArray3D(std::size_t nx1, std::size_t nx2, std::size_t nx3, int val); + ////////////////////////////////////////////////////////////////////////// + virtual ~BCArray3D(); + ////////////////////////////////////////////////////////////////////////// + inline std::size_t getNX1() const; + ////////////////////////////////////////////////////////////////////////// + inline std::size_t getNX2() const; + ////////////////////////////////////////////////////////////////////////// + inline std::size_t getNX3() const; + ////////////////////////////////////////////////////////////////////////// + void resize(std::size_t nx1, std::size_t nx2, std::size_t nx3); + ////////////////////////////////////////////////////////////////////////// + void resize(std::size_t nx1, std::size_t nx2, std::size_t nx3, int val); + ////////////////////////////////////////////////////////////////////////// + bool validIndices(std::size_t x1, std::size_t x2, std::size_t x3) const; + ////////////////////////////////////////////////////////////////////////// + inline bool hasBC(std::size_t x1, std::size_t x2, std::size_t x3) const; + ////////////////////////////////////////////////////////////////////////// + void setBC(std::size_t x1, std::size_t x2, std::size_t x3, BCClassPtr const& bc); + ////////////////////////////////////////////////////////////////////////// + inline int getBCVectorIndex(std::size_t x1, std::size_t x2, std::size_t x3) const; + ////////////////////////////////////////////////////////////////////////// + inline const BCClassPtr getBC(std::size_t x1, std::size_t x2, std::size_t x3) const; + ////////////////////////////////////////////////////////////////////////// + inline BCClassPtr getBC(std::size_t x1, std::size_t x2, std::size_t x3); + ////////////////////////////////////////////////////////////////////////// + void setSolid(std::size_t x1, std::size_t x2, std::size_t x3); + ////////////////////////////////////////////////////////////////////////// + inline bool isSolid(std::size_t x1, std::size_t x2, std::size_t x3) const; + ////////////////////////////////////////////////////////////////////////// + void setFluid(std::size_t x1, std::size_t x2, std::size_t x3); + ////////////////////////////////////////////////////////////////////////// + //true : FLUID or BC + //false: UNDEFINED or SOLID + inline bool isFluid(std::size_t x1, std::size_t x2, std::size_t x3) const; + ////////////////////////////////////////////////////////////////////////// + inline bool isFluidWithoutBC(std::size_t x1, std::size_t x2, std::size_t x3) const; + ////////////////////////////////////////////////////////////////////////// + inline bool isUndefined(std::size_t x1, std::size_t x2, std::size_t x3) const; + ////////////////////////////////////////////////////////////////////////// + void setUndefined(std::size_t x1, std::size_t x2, std::size_t x3); + ////////////////////////////////////////////////////////////////////////// + inline bool isInterfaceCF(std::size_t x1, std::size_t x2, std::size_t x3) const; + ////////////////////////////////////////////////////////////////////////// + void setInterfaceCF(std::size_t x1, std::size_t x2, std::size_t x3); + ////////////////////////////////////////////////////////////////////////// + inline bool isInterfaceFC(std::size_t x1, std::size_t x2, std::size_t x3) const; + ////////////////////////////////////////////////////////////////////////// + void setInterfaceFC(std::size_t x1, std::size_t x2, std::size_t x3); + ////////////////////////////////////////////////////////////////////////// + std::size_t getNumberOfSolidEntries() const; + ////////////////////////////////////////////////////////////////////////// + std::size_t getNumberOfFluidEntries() const; + ////////////////////////////////////////////////////////////////////////// + std::size_t getNumberOfFluidWithoutBCEntries() const; + ////////////////////////////////////////////////////////////////////////// + std::size_t getNumberOfBCEntries() const; + ////////////////////////////////////////////////////////////////////////// + std::size_t getNumberOfUndefinedEntries() const; + ////////////////////////////////////////////////////////////////////////// + std::size_t getBCVectorSize() const; + ////////////////////////////////////////////////////////////////////////// + std::string toString() const; + ////////////////////////////////////////////////////////////////////////// + + static const int SOLID; + static const int FLUID; + static const int INTERFACECF; + static const int INTERFACEFC; + static const int UNDEFINED; + +private: + ////////////////////////////////////////////////////////////////////////// + void deleteBCAndSetType(std::size_t x1, std::size_t x2, std::size_t x3, int type); + ////////////////////////////////////////////////////////////////////////// + void deleteBC(std::size_t x1, std::size_t x2, std::size_t x3); + + friend class boost::serialization::access; + template<class Archive> + void serialize(Archive & ar, const unsigned int version) + { + ar & bcindexmatrix; + ar & bcvector; + ar & indexContainer; + } +protected: + ////////////////////////////////////////////////////////////////////////// + //-1 solid // -2 fluid -... + CbArray3D<int, IndexerX3X2X1> bcindexmatrix; + std::vector<BCClassPtr> bcvector; + std::vector<int> indexContainer; +}; + + +////////////////////////////////////////////////////////////////////////// +inline std::size_t BCArray3D::getNX1() const { return bcindexmatrix.getNX1(); } +////////////////////////////////////////////////////////////////////////// +inline std::size_t BCArray3D::getNX2() const { return bcindexmatrix.getNX2(); } +////////////////////////////////////////////////////////////////////////// +inline std::size_t BCArray3D::getNX3() const { return bcindexmatrix.getNX3(); } +////////////////////////////////////////////////////////////////////////// +inline bool BCArray3D::hasBC(std::size_t x1, std::size_t x2, std::size_t x3) const +{ + return bcindexmatrix(x1, x2, x3) >= 0; +} +////////////////////////////////////////////////////////////////////////// +inline int BCArray3D::getBCVectorIndex(std::size_t x1, std::size_t x2, std::size_t x3) const +{ + return bcindexmatrix(x1, x2, x3); +} +////////////////////////////////////////////////////////////////////////// +inline const BCClassPtr BCArray3D::getBC(std::size_t x1, std::size_t x2, std::size_t x3) const +{ + int index = bcindexmatrix(x1, x2, x3); + if (index < 0) return BCClassPtr(); //=> NULL Pointer + + return bcvector[index]; +} +////////////////////////////////////////////////////////////////////////// +inline BCClassPtr BCArray3D::getBC(std::size_t x1, std::size_t x2, std::size_t x3) +{ + int index = bcindexmatrix(x1, x2, x3); + if (index < 0) return BCClassPtr(); //=> NULL Pointer + + return bcvector[index]; +} +////////////////////////////////////////////////////////////////////////// +inline bool BCArray3D::isSolid(std::size_t x1, std::size_t x2, std::size_t x3) const +{ + return bcindexmatrix(x1, x2, x3) == SOLID; +} +////////////////////////////////////////////////////////////////////////// +//true : FLUID or BC +//false: UNDEFINED or SOLID +inline bool BCArray3D::isFluid(std::size_t x1, std::size_t x2, std::size_t x3) const +{ + int tmp = bcindexmatrix(x1, x2, x3); + return (tmp == FLUID || tmp >= 0); +} +////////////////////////////////////////////////////////////////////////// +inline bool BCArray3D::isFluidWithoutBC(std::size_t x1, std::size_t x2, std::size_t x3) const +{ + return bcindexmatrix(x1, x2, x3) == FLUID; +} +////////////////////////////////////////////////////////////////////////// +inline bool BCArray3D::isUndefined(std::size_t x1, std::size_t x2, std::size_t x3) const +{ + return bcindexmatrix(x1, x2, x3) == UNDEFINED; +} +////////////////////////////////////////////////////////////////////////// +inline bool BCArray3D::isInterfaceCF(std::size_t x1, std::size_t x2, std::size_t x3) const +{ + return bcindexmatrix(x1, x2, x3) == INTERFACECF; +} +////////////////////////////////////////////////////////////////////////// +inline bool BCArray3D::isInterfaceFC(std::size_t x1, std::size_t x2, std::size_t x3) const +{ + return bcindexmatrix(x1, x2, x3) == INTERFACEFC; +} + +#endif diff --git a/source/VirtualFluidsCore/BoundaryConditions/BCFunction.cpp b/source/VirtualFluidsCore/BoundaryConditions/BCFunction.cpp new file mode 100644 index 000000000..d2ca1b159 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/BCFunction.cpp @@ -0,0 +1,5 @@ +#include "BCFunction.h" + +const double BCFunction::INFTIMEDEPENDENT = -1.0; +const double BCFunction::INFCONST = -10.0; + diff --git a/source/VirtualFluidsCore/BoundaryConditions/BCFunction.h b/source/VirtualFluidsCore/BoundaryConditions/BCFunction.h new file mode 100644 index 000000000..6bfd021d4 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/BCFunction.h @@ -0,0 +1,117 @@ +// _ ___ __ __________ _ __ +// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ +// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ +// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) +// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +// +#ifndef D3Q27BCFUNCTION_H +#define D3Q27BCFUNCTION_H + +#include <boost/serialization/serialization.hpp> +#include <boost/serialization/split_member.hpp> + +#include <basics/utilities/UbInfinity.h> + +#include <MuParser/include/muParser.h> + + +class BCFunction +{ +public: + static const double INFTIMEDEPENDENT; + static const double INFCONST; + +public: + BCFunction() + : starttime(-Ub::inf ), endtime(-Ub::inf ) + { + + } + BCFunction( const mu::Parser& function, const double& starttime, const double& endtime ) + : function(function), starttime(starttime), endtime(endtime) + { + + } + BCFunction( const std::string& functionstring, const double& starttime, const double& endtime ) + : starttime(starttime), endtime(endtime) + { + this->setFunction(functionstring); + } + BCFunction( const double& velocity, const double& starttime, const double& endtime ) + : starttime(starttime), endtime(endtime) + { + this->setFunction(velocity); + } + + void setFunction(const mu::Parser& function) { this->function = function; } + void setFunction(const std::string& functionstring) { this->function.SetExpr(functionstring); } + void setFunction(const double& constVelocity) { std::stringstream dummy; dummy<<constVelocity; function.SetExpr(dummy.str()); } + void setStartTime(const double& starttime) {this->starttime = starttime; } + void setEndTime(const double& starttime) {this->endtime = endtime; } + + mu::Parser& getFunction() { return function; } + const mu::Parser& getFunction() const { return function; } + const double& getStartTime() const { return starttime; } + const double& getEndTime() const { return endtime; } + + std::string toString() const + { + std::stringstream info; + if (starttime==INFTIMEDEPENDENT) info<<"start=inf. timedep., "; + else if(starttime==INFCONST ) info<<"start=inf. const., "; + else info<<"start="<<starttime<<", "; + if (endtime==INFTIMEDEPENDENT) info<<"end=inf. timedep."<<std::endl; + else if(endtime==INFCONST ) info<<"end=inf. const."<<std::endl; + else info<<"end="<<endtime<<std::endl; + info<<"expr="<<function.GetExpr()<<std::endl; + info<<"with constants: "; + mu::valmap_type cmap = function.GetConst(); + for(mu::valmap_type::const_iterator item = cmap.begin(); item!=cmap.end(); ++item) + info<<item->first<<"="<<item->second<<", "; + return info.str(); + } + /*==========================================================*/ + friend inline std::ostream& operator << (std::ostream& os, const BCFunction& bc) + { + os<<bc.toString(); + return os; + } + +protected: + mu::Parser function; + double starttime; + double endtime; + +private: + friend class boost::serialization::access; + template<class Archive> + void save(Archive & ar, const unsigned int version) const + { + mu::string_type expr = function.GetExpr(); + mu::valmap_type constants = function.GetConst(); + ar & expr; + ar & constants; + + ar & starttime; + ar & endtime; + } + template<class Archive> + void load(Archive & ar, const unsigned int version) + { + mu::string_type expr; + mu::valmap_type constants; + ar & expr; + ar & constants; + function.SetExpr(expr); + for (mu::valmap_type::iterator pos = constants.begin(); pos!=constants.end(); ++pos) + function.DefineConst(pos->first, pos->second); + + function.InitConst(); + + ar & starttime; + ar & endtime; + } + BOOST_SERIALIZATION_SPLIT_MEMBER() +}; + +#endif //D3Q27BCFUNCTION_H diff --git a/source/VirtualFluidsCore/BoundaryConditions/BCProcessor.cpp b/source/VirtualFluidsCore/BoundaryConditions/BCProcessor.cpp new file mode 100644 index 000000000..aa6708c17 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/BCProcessor.cpp @@ -0,0 +1,64 @@ +#include "BCProcessor.h" +#include "D3Q27EsoTwist3DSplittedVector.h" + +BCProcessor::BCProcessor() +{ + +} +////////////////////////////////////////////////////////////////////////// +BCProcessor::BCProcessor(LBMKernelPtr kernel) +{ + DistributionArray3DPtr distributions = boost::dynamic_pointer_cast<EsoTwist3D>(kernel->getDataSet()->getFdistributions()); + bcArray.resize( distributions->getNX1(), distributions->getNX2(), distributions->getNX3(), BCArray3D::FLUID); +} +////////////////////////////////////////////////////////////////////////// +BCProcessor::~BCProcessor() +{ + +} +////////////////////////////////////////////////////////////////////////// +BCProcessorPtr BCProcessor::clone(LBMKernelPtr kernel) +{ + BCProcessorPtr bcProcessor(new BCProcessor(kernel)); + return bcProcessor; +} +////////////////////////////////////////////////////////////////////////// +BCArray3D& BCProcessor::getBCArray() +{ + return this->bcArray; +} +////////////////////////////////////////////////////////////////////////// +void BCProcessor::addBC(BCAlgorithmPtr bc) +{ + if (bc->isPreCollision()) + { + preBC.push_back(bc); + } + else + { + postBC.push_back(bc); + } +} +////////////////////////////////////////////////////////////////////////// +void BCProcessor::applyPreCollisionBC() +{ + BOOST_FOREACH(BCAlgorithmPtr bc, preBC) + { + bc->apply(); + } +} +////////////////////////////////////////////////////////////////////////// +void BCProcessor::applyPostCollisionBC() +{ + BOOST_FOREACH(BCAlgorithmPtr bc, postBC) + { + bc->apply(); + } +} +////////////////////////////////////////////////////////////////////////// +void BCProcessor::clearBC() +{ + preBC.clear(); + postBC.clear(); +} + diff --git a/source/VirtualFluidsCore/BoundaryConditions/BCProcessor.h b/source/VirtualFluidsCore/BoundaryConditions/BCProcessor.h new file mode 100644 index 000000000..a901e7a53 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/BCProcessor.h @@ -0,0 +1,48 @@ +#ifndef BCPROCESSSOR_H +#define BCPROCESSSOR_H + +#include "BCAlgorithm.h" +#include "EsoTwist3D.h" +#include "BCArray3D.h" +#include "basics/container/CbArray4D.h" +#include "basics/container/CbArray3D.h" + +#include <vector> + +#include <boost/serialization/base_object.hpp> + +class BCProcessor; +typedef boost::shared_ptr<BCProcessor> BCProcessorPtr; + +#include "LBMKernel.h" + +class BCProcessor +{ +public: + BCProcessor(); + BCProcessor(LBMKernelPtr kernel); + virtual ~BCProcessor(); + virtual BCArray3D& getBCArray(); + virtual BCProcessorPtr clone(LBMKernelPtr kernel); + + void addBC(BCAlgorithmPtr bc); + void applyPreCollisionBC(); + void applyPostCollisionBC(); + void clearBC(); +protected: + std::vector<BCAlgorithmPtr> preBC; + std::vector<BCAlgorithmPtr> postBC; + BCArray3D bcArray; + +private: + friend class boost::serialization::access; + template<class Archive> + void serialize(Archive & ar, const unsigned int version) + { + ar & bcArray; + //ar & preBC; + //ar & postBC; + } +}; + +#endif diff --git a/source/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.cpp b/source/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.cpp new file mode 100644 index 000000000..4a384f865 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.cpp @@ -0,0 +1,4 @@ +#include "BoundaryConditions.h" + +const long long BoundaryConditions::maxOptionVal = ( 1<<optionDigits ) - 1; //2^3-1 -> 7 + diff --git a/source/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.h b/source/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.h new file mode 100644 index 000000000..edbf155ce --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.h @@ -0,0 +1,292 @@ +// _ ___ __ __________ _ __ +// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ +// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ +// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) +// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +// +#ifndef BoundaryConditions_H +#define BoundaryConditions_H + +#include <vector> +#include <string> + +#include <basics/utilities/UbException.h> +#include <basics/utilities/UbSystem.h> +#include <basics/utilities/UbTuple.h> +#include "D3Q27System.h" + +#include <boost/serialization/serialization.hpp> + +class BoundaryConditions; +typedef boost::shared_ptr<BoundaryConditions> BoundaryConditionsPtr; + +class BoundaryConditions +{ +//public: +// enum BcAlgorithm{VelocityBC, SlipBC, NoSlipBC, ThinWallNoSlipBC, HighViscosityNoSlipBC, EqDensityBC, NonEqDensityBC, NonReflectingVelocityBC, NonReflectingDensityBC}; +public: + BoundaryConditions() + : noslipBoundaryFlags(0) + , slipBoundaryFlags(0) + , velocityBoundaryFlags(0) + , densityBoundaryFlags(0) + , wallModelBoundaryFlags(0) + , bcVelocityX1(0.0f) + , bcVelocityX2(0.0f) + , bcVelocityX3(0.0f) + , bcDensity(0.0f) + , bcLodiDensity(0.0f) + , bcLodiVelocityX1(0.0f) + , bcLodiVelocityX2(0.0f) + , bcLodiVelocityX3(0.0f) + , bcLodiLentgh(0.0f) + , nx1(0.0f) + , nx2(0.0f) + , nx3(0.0f) + , algorithmType(-1) + { + //wenn folgendes nicht geht, dann hat man weiter unten bei der bit-geschichte ein ernstes problem!!! + UB_STATIC_ASSERT( sizeof(long long) >= 8); + //UB_STATIC_ASSERT( sizeof(double) >= 16); + //UB_STATIC_ASSERT( sizeof(long long) == 32); + UB_STATIC_ASSERT( (sizeof(long long)*8) >= (D3Q27System::FENDDIR+1)*BoundaryConditions::optionDigits ); + + for(int fdir=D3Q27System::FSTARTDIR; fdir<=D3Q27System::FENDDIR; fdir++) + q[fdir] = -999.; + } + virtual ~BoundaryConditions() {} + + virtual bool isEmpty() { return (noslipBoundaryFlags&slipBoundaryFlags&velocityBoundaryFlags&densityBoundaryFlags)==0;} + virtual bool hasBoundaryCondition() + { + return ( hasNoSlipBoundary() || hasSlipBoundary() + || hasDensityBoundary() || hasVelocityBoundary() || hasWallModelBoundary() ); + } + + virtual bool hasBoundaryConditionFlag(const int& direction) + { + assert( direction >= D3Q27System::FSTARTDIR && direction <= D3Q27System::FENDDIR ); + + return ( hasNoSlipBoundaryFlag(direction) || hasSlipBoundaryFlag(direction) + || hasDensityBoundaryFlag(direction) || hasVelocityBoundaryFlag(direction) || hasWallModelBoundaryFlag(direction)); + } +protected: + void setFlagBits(long long& flag, const int& direction, const short& secOpt) + { + if( (secOpt+1)>maxOptionVal ) + throw UbException(UB_EXARGS,"error: option > "+UbSystem::toString(maxOptionVal-1)); + + //alle digits an den betreffenden postionen auf "0" + flag &= ~( maxOptionVal<<(direction*optionDigits) ); + //alle digitsan den betreffenden postionen entsprechend der marke setzen + flag |= ((long long)(secOpt+1)<<(direction*optionDigits)); + } +public: + /*===================== NoSlip Boundary ==================================================*/ + void setNoSlipBoundaryFlag(const int& direction, const short& secOpt=0) { this->setFlagBits(noslipBoundaryFlags,direction,secOpt); } + void unsetNoSlipBoundaryFlag(const int& direction) { this->noslipBoundaryFlags &= ~( maxOptionVal<<(direction*optionDigits) ); } + void unsetNoSlipBoundary() { this->noslipBoundaryFlags = 0; } + long long getNoSlipBoundary() { return this->noslipBoundaryFlags; } + bool hasNoSlipBoundary() { return (noslipBoundaryFlags!=0); } + bool hasNoSlipBoundaryFlag(const int& direction) { return ( ( ( noslipBoundaryFlags>>(optionDigits*direction) ) & maxOptionVal ) != 0); } + short getNoSlipSecondaryOption(const int& direction) { return (short)( ( ( noslipBoundaryFlags>>(optionDigits*direction) ) & maxOptionVal ) - 1 ); } + /*===================== WallModel Boundary ==================================================*/ + void setWallModelBoundaryFlag(const int& direction, const short& secOpt=0) { this->setFlagBits(wallModelBoundaryFlags,direction,secOpt); } + void unsetWallModelBoundaryFlag(const int& direction) { this->wallModelBoundaryFlags &= ~( maxOptionVal<<(direction*optionDigits) ); } + void unsetWallModelBoundary() { this->wallModelBoundaryFlags = 0; } + long long getWallModelBoundary() { return this->wallModelBoundaryFlags; } + bool hasWallModelBoundary() { return (wallModelBoundaryFlags!=0); } + bool hasWallModelBoundaryFlag(const int& direction) { return ( ( ( wallModelBoundaryFlags>>(optionDigits*direction) ) & maxOptionVal ) != 0); } + short getWallModelSecondaryOption(const int& direction) { return (short)( ( ( wallModelBoundaryFlags>>(optionDigits*direction) ) & maxOptionVal ) - 1 ); } + /*===================== Slip-Solid Boundary ==================================================*/ + void setSlipBoundaryFlag(const int& direction, const short& secOpt=0) { this->setFlagBits(slipBoundaryFlags,direction,secOpt); } + void unsetSlipBoundaryFlag(const int& direction) { this->slipBoundaryFlags &= ~( maxOptionVal<<(direction*optionDigits) ); } + void unsetSlipBoundary() { this->slipBoundaryFlags = 0; } + long long getSlipBoundary() { return this->slipBoundaryFlags; } + bool hasSlipBoundary() { return (slipBoundaryFlags!=0); } + bool hasSlipBoundaryFlag(const int& direction) { return ( ( ( slipBoundaryFlags>>(optionDigits*direction) ) & maxOptionVal ) != 0); } + short getSlipSecondaryOption(const int& direction) { return (short)( ( ( slipBoundaryFlags>>(optionDigits*direction) ) & maxOptionVal ) - 1 ); } + void setNormalVector(const float& nx1,const float& nx2,const float& nx3) { this->nx1 = nx1; this->nx2 = nx2; this->nx3 = nx3;} + UbTupleFloat3 getNormalVector() { return makeUbTuple(nx1,nx2,nx3); } + + /*============== Velocity Boundary ========================*/ + void setVelocityBoundaryFlag(const int& direction, const short& secOpt=0) { this->setFlagBits(velocityBoundaryFlags,direction,secOpt); } + void unsetVelocityBoundaryFlag(const int& direction) { this->velocityBoundaryFlags &= ~( maxOptionVal<<(direction*optionDigits) ); } + void unsetVelocityBoundary() { this->velocityBoundaryFlags = 0; } + long long getVelocityBoundary() { return this->velocityBoundaryFlags; } + bool hasVelocityBoundary() { return this->velocityBoundaryFlags!=0; } + bool hasVelocityBoundaryFlag(const int& direction) { return ( ( ( velocityBoundaryFlags>>(optionDigits*direction) ) & maxOptionVal ) != 0); } + short getVelocitySecondaryOption(const int& direction) { return (short)( ( ( velocityBoundaryFlags>>(optionDigits*direction) ) & maxOptionVal ) - 1 ); } + + void setBoundaryVelocityX1(const float& vx1) { this->bcVelocityX1 = vx1; } + void setBoundaryVelocityX2(const float& vx2) { this->bcVelocityX2 = vx2; } + void setBoundaryVelocityX3(const float& vx3) { this->bcVelocityX3 = vx3; } + float getBoundaryVelocityX1() { return this->bcVelocityX1; } + float getBoundaryVelocityX2() { return this->bcVelocityX2; } + float getBoundaryVelocityX3() { return this->bcVelocityX3; } + float getBoundaryVelocity(const int& direction) + { + switch(direction) + { + case D3Q27System::E : return (float)( UbMath::c4o9*(+bcVelocityX1) ); //(2/cs^2)(=6)*rho_0(=1 bei inkompr)*wi*u*ei mit cs=1/sqrt(3) + case D3Q27System::W : return (float)( UbMath::c4o9*(-bcVelocityX1) ); //z.B. aus paper manfred MRT LB models in three dimensions (2002) + case D3Q27System::N : return (float)( UbMath::c4o9*(+bcVelocityX2) ); + case D3Q27System::S : return (float)( UbMath::c4o9*(-bcVelocityX2) ); + case D3Q27System::T : return (float)( UbMath::c4o9*(+bcVelocityX3) ); + case D3Q27System::B : return (float)( UbMath::c4o9*(-bcVelocityX3) ); + case D3Q27System::NE: return (float)( UbMath::c1o9*(+bcVelocityX1+bcVelocityX2 ) ); + case D3Q27System::SW: return (float)( UbMath::c1o9*(-bcVelocityX1-bcVelocityX2 ) ); + case D3Q27System::SE: return (float)( UbMath::c1o9*(+bcVelocityX1-bcVelocityX2 ) ); + case D3Q27System::NW: return (float)( UbMath::c1o9*(-bcVelocityX1+bcVelocityX2 ) ); + case D3Q27System::TE: return (float)( UbMath::c1o9*(+bcVelocityX1 +bcVelocityX3) ); + case D3Q27System::BW: return (float)( UbMath::c1o9*(-bcVelocityX1 -bcVelocityX3) ); + case D3Q27System::BE: return (float)( UbMath::c1o9*(+bcVelocityX1 -bcVelocityX3) ); + case D3Q27System::TW: return (float)( UbMath::c1o9*(-bcVelocityX1 +bcVelocityX3) ); + case D3Q27System::TN: return (float)( UbMath::c1o9*( +bcVelocityX2+bcVelocityX3) ); + case D3Q27System::BS: return (float)( UbMath::c1o9*( -bcVelocityX2-bcVelocityX3) ); + case D3Q27System::BN: return (float)( UbMath::c1o9*( +bcVelocityX2-bcVelocityX3) ); + case D3Q27System::TS: return (float)( UbMath::c1o9*( -bcVelocityX2+bcVelocityX3) ); + case D3Q27System::TNE: return (float)( UbMath::c1o36*(+bcVelocityX1+bcVelocityX2+bcVelocityX3) ); + case D3Q27System::BSW: return (float)( UbMath::c1o36*(-bcVelocityX1-bcVelocityX2-bcVelocityX3) ); + case D3Q27System::BNE: return (float)( UbMath::c1o36*(+bcVelocityX1+bcVelocityX2-bcVelocityX3) ); + case D3Q27System::TSW: return (float)( UbMath::c1o36*(-bcVelocityX1-bcVelocityX2+bcVelocityX3) ); + case D3Q27System::TSE: return (float)( UbMath::c1o36*(+bcVelocityX1-bcVelocityX2+bcVelocityX3) ); + case D3Q27System::BNW: return (float)( UbMath::c1o36*(-bcVelocityX1+bcVelocityX2-bcVelocityX3) ); + case D3Q27System::BSE: return (float)( UbMath::c1o36*(+bcVelocityX1-bcVelocityX2-bcVelocityX3) ); + case D3Q27System::TNW: return (float)( UbMath::c1o36*(-bcVelocityX1+bcVelocityX2+bcVelocityX3) ); + default: throw UbException(UB_EXARGS,"unknown error"); + } + } + + /*============== Density Boundary ========================*/ + void setDensityBoundaryFlag(const int& direction, const short& secOpt=0) { this->setFlagBits(densityBoundaryFlags,direction,secOpt); } + void unsetDensityBoundaryFlag(const int& direction) { this->densityBoundaryFlags &= ~( maxOptionVal<<(direction*optionDigits) ); } + void unsetDensityBoundary() { this->densityBoundaryFlags = 0; } + long long getDensityBoundary() { return this->densityBoundaryFlags; } + bool hasDensityBoundary() { return (this->densityBoundaryFlags!=0); } + bool hasDensityBoundaryFlag(const int& direction) { return ( ( ( densityBoundaryFlags>>(optionDigits*direction) ) & maxOptionVal ) != 0); } + short getDensitySecondaryOption(const int& direction) { return (short)( ( ( densityBoundaryFlags>>(optionDigits*direction) ) & maxOptionVal ) - 1 ); } + + 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]; } + + virtual std::vector< std::string > getBCNames() + { + std::vector< std::string > tmp; + tmp.push_back( "NoSlipBC" ); + tmp.push_back( "SlipBC" ); + tmp.push_back( "VelocityBC" ); + tmp.push_back( "DensityBC" ); + return tmp; + } + virtual std::vector< long long > getBCFlags() + { + std::vector< long long > tmp; + tmp.push_back( noslipBoundaryFlags ); + tmp.push_back( slipBoundaryFlags ); + tmp.push_back( velocityBoundaryFlags ); + tmp.push_back( densityBoundaryFlags ); + return tmp; + } + + static bool hasFlagForDirection(const long long& flag, const int& direction) + { + return ( ( ( flag>>(optionDigits*direction) ) & maxOptionVal ) != 0); + } + + void setBcAlgorithmType(char alg) { algorithmType = alg; } + char getBcAlgorithmType() { return algorithmType; } + +public: + static const int optionDigits = 2; //--> 3 bits für secondary Option --> maxOptionVal = 7, da man mit drei Digits max die 7 darstellen kann + static const long long maxOptionVal;// = ( 1<<optionDigits ) - 1; //2^3-1 -> 7 + +protected: + float q[D3Q27System::FENDDIR+1]; + //float q[D3Q27System::STARTF+1]; + + long long noslipBoundaryFlags; + long long slipBoundaryFlags; + long long velocityBoundaryFlags; + long long densityBoundaryFlags; + long long wallModelBoundaryFlags; + + float bcVelocityX1; + float bcVelocityX2; + float bcVelocityX3; + float bcDensity; + + float bcLodiDensity; + float bcLodiVelocityX1; + float bcLodiVelocityX2; + float bcLodiVelocityX3; + float bcLodiLentgh; + + float nx1,nx2,nx3; + + char algorithmType; + +private: + friend class boost::serialization::access; + template<class Archive> + void serialize(Archive & ar, const unsigned int version) + { + ar & q; + + ar & noslipBoundaryFlags; + ar & slipBoundaryFlags; + ar & velocityBoundaryFlags; + ar & densityBoundaryFlags; + + ar & bcVelocityX1; + ar & bcVelocityX2; + ar & bcVelocityX3; + ar & bcDensity; + + ar & bcLodiDensity; + ar & bcLodiVelocityX1; + ar & bcLodiVelocityX2; + ar & bcLodiVelocityX3; + ar & bcLodiLentgh; + + ar & wallModelBoundaryFlags; + + ar & nx1; + ar & nx2; + ar & nx3; + + ar & algorithmType; + } + +}; + +#endif //D3Q27BOUNDARYCONDITION_H diff --git a/source/VirtualFluidsCore/BoundaryConditions/CMakePackage.txt b/source/VirtualFluidsCore/BoundaryConditions/CMakePackage.txt new file mode 100644 index 000000000..de1dc5a88 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/CMakePackage.txt @@ -0,0 +1,2 @@ +GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) \ No newline at end of file diff --git a/source/VirtualFluidsCore/BoundaryConditions/DensityBCAdapter.cpp b/source/VirtualFluidsCore/BoundaryConditions/DensityBCAdapter.cpp new file mode 100644 index 000000000..d3554773d --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/DensityBCAdapter.cpp @@ -0,0 +1,157 @@ +#include "DensityBCAdapter.h" +#include "basics/utilities/UbLogger.h" +#include "basics/utilities/UbInfinity.h" + +using namespace std; +/*==========================================================*/ +DensityBCAdapter::DensityBCAdapter(const double& dens, const double& startTime, const double& endTime ) +{ + this->densBCs.push_back( BCFunction(dens,startTime,endTime) ); + this->init(); +} +/*==========================================================*/ +DensityBCAdapter::DensityBCAdapter(const BCFunction& densBC ) +{ + this->densBCs.push_back(densBC); + this->init(); +} +/*==========================================================*/ +DensityBCAdapter::DensityBCAdapter(const std::vector< BCFunction >& densBCs) +{ + this->densBCs = densBCs; + this->init(); +} +/*==========================================================*/ +DensityBCAdapter::DensityBCAdapter(const mu::Parser& function, const double& startTime, const double& endTime ) +{ + this->densBCs.push_back(BCFunction(function,startTime,endTime)); + this->init(); +} +/*==========================================================*/ +void DensityBCAdapter::init() +{ + this->timeStep = 0.0; + + this->x1 = 0.0; + this->x2 = 0.0; + this->x3 = 0.0; + + this->tmpDensityFunction = NULL; + + try //initilialization and validation of functions + { + for(size_t pos=0; pos<densBCs.size(); ++pos) + { + if( !( UbMath::equal( BCFunction::INFCONST, densBCs[pos].getEndTime() ) + && UbMath::greaterEqual( this->timeStep, densBCs[pos].getStartTime() ) ) ) + { + this->setTimeDependent(); + } + + densBCs[pos].getFunction().DefineVar("t" , &this->timeStep); + densBCs[pos].getFunction().DefineVar("x1", &this->x1 ); + densBCs[pos].getFunction().DefineVar("x2", &this->x2 ); + densBCs[pos].getFunction().DefineVar("x3", &this->x3 ); + + densBCs[pos].getFunction().Eval(); //<-- validation + } + } + catch(mu::Parser::exception_type& e){ stringstream error; error<<"mu::parser exception occurs, message("<<e.GetMsg()<<"), formula("<<e.GetExpr()+"), token("+e.GetToken()<<")" + <<", pos("<<e.GetPos()<<"), error code("<<e.GetCode(); throw UbException(error.str()); } + catch(...) { throw UbException(UB_EXARGS,"unknown exception" ); } +} +/*==========================================================*/ +void DensityBCAdapter::init(const D3Q27Interactor* const& interactor, const double& time) +{ + this->timeStep = time; + this->tmpDensityFunction = NULL; + double maxEndtime = -Ub::inf; + + //aktuelle Densityfunction bestimmen + for(size_t pos=0; pos<densBCs.size(); ++pos) + { + if( UbMath::equal(densBCs[pos].getEndTime(),BCFunction::INFTIMEDEPENDENT)) maxEndtime=Ub::inf; + maxEndtime = UbMath::max(maxEndtime,densBCs[pos].getStartTime(),densBCs[pos].getEndTime()); //startTime abfragen, da INFCONST=-10 + + if( UbMath::greaterEqual(this->timeStep,densBCs[pos].getStartTime()) ) + { + if( UbMath::lessEqual(this->timeStep,densBCs[pos].getEndTime()) + || UbMath::equal(densBCs[pos].getEndTime(),(double)BCFunction::INFCONST) + || UbMath::equal(densBCs[pos].getEndTime(),(double)BCFunction::INFTIMEDEPENDENT) ) + { + tmpDensityFunction = &densBCs[pos].getFunction(); + break; + } + } + } + + //wenn funktionen zweitlich konstant sind und bis t=unendlich gelten + //kann man zeitabhaengigkeit deaktivieren + if( UbMath::greaterEqual(time,maxEndtime) ) this->unsetTimeDependent(); + + UBLOG(logDEBUG4,"D3Q27DensityBCAdapter::init(time="<<time<<") " + <<", rho= \""<<(tmpDensityFunction ? tmpDensityFunction->GetExpr() : "-") + <<"\", timedependant="<<(this->isTimeDependent() ? "true" : "false") ); +} +/*==========================================================*/ +void DensityBCAdapter::update( const D3Q27Interactor* const& interactor, const double& time ) +{ + this->init(interactor,time); +} +/*==========================================================*/ +void DensityBCAdapter::adaptBCForDirection( const D3Q27Interactor& interactor, BoundaryConditionsPtr bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& q, const int& fdirection, const double& time ) +{ + bc->setDensityBoundaryFlag(D3Q27System::INVDIR[fdirection],secondaryBcOption); + bc->setQ((float)q,fdirection); +} +/*==========================================================*/ +void DensityBCAdapter::adaptBC( const D3Q27Interactor& interactor, BoundaryConditionsPtr bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& time ) +{ + this->setNodeDensity(interactor,bc,worldX1,worldX2,worldX3,time); + bc->setBcAlgorithmType(algorithmType); +} +/*==========================================================*/ +void DensityBCAdapter::setNodeDensity( const D3Q27Interactor& interactor, BoundaryConditionsPtr bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& timestep) +{ + //Geschwindigkeiten setzen + try + { + //PunktKoordinaten bestimmen + this->x1 = worldX1; + this->x2 = worldX2; + this->x3 = worldX3; + this->timeStep = timestep; + + if(tmpDensityFunction) bc->setBoundaryDensity((float)tmpDensityFunction->Eval()); + } + catch(mu::Parser::exception_type& e){ stringstream error; error<<"mu::parser exception occurs, message("<<e.GetMsg()<<"), formula("<<e.GetExpr()+"), token("+e.GetToken()<<")" + <<", pos("<<e.GetPos()<<"), error code("<<e.GetCode(); throw UbException(error.str()); } + catch(...) { throw UbException(UB_EXARGS,"unknown exception" ); } +} +/*==========================================================*/ +double DensityBCAdapter::getDensity(const double& x1, const double& x2, const double& x3, const double& timeStep) +{ + this->x1 = x1; + this->x2 = x2; + this->x3 = x3; + this->timeStep = timeStep; + + if(!tmpDensityFunction) return 0.0; + + return tmpDensityFunction->Eval(); +} +/*==========================================================*/ +string DensityBCAdapter::toString() +{ + stringstream info; + info<<"D3Q27DensityBCAdapter:\n"; + info<<" #dens-functions = "<<(int)densBCs.size()<<endl; + info<<" protected variables: x1, x2, x3, t"<<endl; + + for(size_t i=0; i<densBCs.size(); ++i) + { + info<<"\n dens-function nr."<<i<<":"<<endl; + info<<densBCs[i].toString()<<endl; + } + return info.str(); +} diff --git a/source/VirtualFluidsCore/BoundaryConditions/DensityBCAdapter.h b/source/VirtualFluidsCore/BoundaryConditions/DensityBCAdapter.h new file mode 100644 index 000000000..423cb82a7 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/DensityBCAdapter.h @@ -0,0 +1,81 @@ +#ifndef DensityBCAdapter_H +#define DensityBCAdapter_H + +#include <iostream> +#include <string> +#include <sstream> +#include <vector> + +#include "basics/utilities/UbMath.h" +#include "basics/utilities/UbTuple.h" + +#include "BCAdapter.h" +#include "BCFunction.h" + +//* DensityBCAdapter */ +//* */ +//** +//<BR><BR> +//@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> +//@version 1.0 - 06.09.06 +//*/ +// +//* +//usage: ... +//*/ + + +class DensityBCAdapter : public BCAdapter +{ +public: + //constructors + DensityBCAdapter() { this->init(); } + DensityBCAdapter(const double& dens, const double& startTime=0.0, const double& endTime = BCFunction::INFCONST ); + DensityBCAdapter(const BCFunction& densBC ); + DensityBCAdapter(const std::vector< BCFunction >& densBCs); + DensityBCAdapter(const mu::Parser& function, const double& startTime=0.0, const double& endTime = BCFunction::INFCONST ); + + //------------- implements D3Q27BoundaryConditionAdapter ----- start + std::string toString(); + ObObjectCreator* getCreator(); + + void init(const D3Q27Interactor* const& interactor, const double& time=0); + void update(const D3Q27Interactor* const& interactor, const double& time=0); + + void adaptBCForDirection( const D3Q27Interactor& interactor, BoundaryConditionsPtr bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& q, const int& fdirection, const double& time=0 ); + void adaptBC( const D3Q27Interactor& interactor, BoundaryConditionsPtr bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& time=0 ); + + double getDensity(const double& x1, const double& x2, const double& x3, const double& timeStep); + + //------------- implements D3Q27BoundaryConditionAdapter ----- end + + +protected: + void init(); + + //time dependency wird automatisch ueber D3Q27BCFunction Intervalle ermittelt! + void setTimeDependent() { (this->type |= TIMEDEPENDENT);} + void unsetTimeDependent() { (this->type &= ~TIMEDEPENDENT);} + + void clear() { densBCs.clear(); } + void setNodeDensity(const D3Q27Interactor& interactor, BoundaryConditionsPtr bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& timestep); + +private: + mu::value_type x1, x2, x3; //brauch man nicht serialisieren! + mu::value_type timeStep; //brauch man nicht serialisieren! + + mu::Parser* tmpDensityFunction; //brauch man nicht serialisieren! + + std::vector<BCFunction> densBCs; + +private: + friend class boost::serialization::access; + template<class Archive> + void serialize(Archive & ar, const unsigned int version) + { + ar & boost::serialization::base_object<BCAdapter>(*this); + ar & densBCs; + } +}; + +#endif diff --git a/source/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.cpp b/source/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.cpp new file mode 100644 index 000000000..4ef545ab6 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.cpp @@ -0,0 +1,58 @@ +#include "EqDensityBCAlgorithm.h" +#include <boost/pointer_cast.hpp> + +EqDensityBCAlgorithm::EqDensityBCAlgorithm() +{ + BCAlgorithm::type = BCAlgorithm::EqDensityBCAlgorithm; + BCAlgorithm::preCollision = false; +} +////////////////////////////////////////////////////////////////////////// +EqDensityBCAlgorithm::~EqDensityBCAlgorithm() +{ +} +////////////////////////////////////////////////////////////////////////// +BCAlgorithmPtr EqDensityBCAlgorithm::clone() +{ + BCAlgorithmPtr bc(new EqDensityBCAlgorithm()); + return bc; +} +////////////////////////////////////////////////////////////////////////// +void EqDensityBCAlgorithm::addDistributions(DistributionArray3DPtr distributions) +{ + this->distributions = distributions; +} +////////////////////////////////////////////////////////////////////////// +void EqDensityBCAlgorithm::applyBC() +{ + LBMReal f[D3Q27System::ENDF+1]; + + distributions->getDistributionInv(f, x1, x2, x3); + int nx1 = x1; + int nx2 = x2; + int nx3 = x3; + int direction = -1; + + //flag points in direction of fluid + if (bcPtr->hasDensityBoundaryFlag(D3Q27System::E)) { nx1 -= 1; direction = D3Q27System::E; } + else if (bcPtr->hasDensityBoundaryFlag(D3Q27System::W)) { nx1 += 1; direction = D3Q27System::W; } + else if (bcPtr->hasDensityBoundaryFlag(D3Q27System::N)) { nx2 -= 1; direction = D3Q27System::N; } + else if (bcPtr->hasDensityBoundaryFlag(D3Q27System::S)) { nx2 += 1; direction = D3Q27System::S; } + else if (bcPtr->hasDensityBoundaryFlag(D3Q27System::T)) { nx3 -= 1; direction = D3Q27System::T; } + else if (bcPtr->hasDensityBoundaryFlag(D3Q27System::B)) { nx3 += 1; direction = D3Q27System::B; } + else UB_THROW(UbException(UB_EXARGS, "Danger...no orthogonal BC-Flag on density boundary...")); + + LBMReal rho, vx1, vx2, vx3; + calcMacrosFct(f, rho, vx1, vx2, vx3); + LBMReal rhoBC = bcPtr->getBoundaryDensity(); + for (int fdir = D3Q27System::STARTF; fdir<=D3Q27System::ENDF; fdir++) + { + if (bcPtr->hasDensityBoundaryFlag(fdir)) + { + //Ehsan: 15.2.2013: + LBMReal ftemp = calcFeqsForDirFct(fdir, rhoBC, vx1, vx2, vx3); + distributions->setDistributionForDirection(ftemp, nx1, nx2, nx3, fdir); + } + } + +} + diff --git a/source/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.h b/source/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.h new file mode 100644 index 000000000..c37b7b5a5 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.h @@ -0,0 +1,26 @@ +#ifndef EqDensityBCAlgorithm_h__ +#define EqDensityBCAlgorithm_h__ + +#include "BCAlgorithm.h" + +class EqDensityBCAlgorithm; +typedef boost::shared_ptr<EqDensityBCAlgorithm> EqDensityBCAlgorithmPtr; + +class EqDensityBCAlgorithm : public BCAlgorithm +{ +public: + EqDensityBCAlgorithm(); + ~EqDensityBCAlgorithm(); + BCAlgorithmPtr clone(); + void addDistributions(DistributionArray3DPtr distributions); +protected: + void applyBC(); +private: + //friend class boost::serialization::access; + //template<class Archive> + //void serialize(Archive & ar, const unsigned int version) + //{ + // ar & boost::serialization::base_object<BCAlgorithm>(*this); + //} +}; +#endif // EqDensityBCAlgorithm_h__ diff --git a/source/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.cpp b/source/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.cpp new file mode 100644 index 000000000..187c7045c --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.cpp @@ -0,0 +1,45 @@ +#include "HighViscosityNoSlipBCAlgorithm.h" + +HighViscosityNoSlipBCAlgorithm::HighViscosityNoSlipBCAlgorithm() +{ + BCAlgorithm::type = BCAlgorithm::HighViscosityNoSlipBCAlgorithm; + BCAlgorithm::preCollision = true; +} +////////////////////////////////////////////////////////////////////////// +HighViscosityNoSlipBCAlgorithm::~HighViscosityNoSlipBCAlgorithm() +{ +} +////////////////////////////////////////////////////////////////////////// +BCAlgorithmPtr HighViscosityNoSlipBCAlgorithm::clone() +{ + BCAlgorithmPtr bc(new HighViscosityNoSlipBCAlgorithm()); + return bc; +} +////////////////////////////////////////////////////////////////////////// +void HighViscosityNoSlipBCAlgorithm::addDistributions(DistributionArray3DPtr distributions) +{ + this->distributions = distributions; +} +////////////////////////////////////////////////////////////////////////// +void HighViscosityNoSlipBCAlgorithm::applyBC() +{ + LBMReal f[D3Q27System::ENDF+1]; + LBMReal feq[D3Q27System::ENDF+1]; + distributions->getDistribution(f, x1, x2, x3); + LBMReal rho, vx1, vx2, vx3; + calcMacrosFct(f, rho, vx1, vx2, vx3); + calcFeqFct(feq, rho, vx1, vx2, vx3); + + for (int fDir = D3Q27System::FSTARTDIR; fDir<=D3Q27System::FENDDIR; fDir++) + { + if (bcPtr->hasNoSlipBoundaryFlag(fDir)) + { + //quadratic bounce back + const int invDir = D3Q27System::INVDIR[fDir]; + LBMReal q = bcPtr->getQ(invDir); + LBMReal fReturn = (f[invDir]+q*f[fDir]+q*collFactor*(feq[invDir]-f[invDir]+feq[fDir]-f[fDir]))/(1.0+q); + distributions->setDistributionInvForDirection(fReturn, x1+D3Q27System::DX1[invDir], x2+D3Q27System::DX2[invDir], x3+D3Q27System::DX3[invDir], invDir); + } + } +} + diff --git a/source/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.h b/source/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.h new file mode 100644 index 000000000..c7d0d3587 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.h @@ -0,0 +1,27 @@ +#ifndef HighViscosityNoSlipBCAlgorithm_h__ +#define HighViscosityNoSlipBCAlgorithm_h__ + +#include "BCAlgorithm.h" + +class HighViscosityNoSlipBCAlgorithm; +typedef boost::shared_ptr<HighViscosityNoSlipBCAlgorithm> HighViscosityNoSlipBCAlgorithmPtr; + +class HighViscosityNoSlipBCAlgorithm : public BCAlgorithm +{ +public: + HighViscosityNoSlipBCAlgorithm(); + ~HighViscosityNoSlipBCAlgorithm(); + BCAlgorithmPtr clone(); + void addDistributions(DistributionArray3DPtr distributions); +protected: + void applyBC(); +private: + //friend class boost::serialization::access; + //template<class Archive> + //void serialize(Archive & ar, const unsigned int version) + //{ + // ar & boost::serialization::base_object<BCAlgorithm>(*this); + //} +}; +#endif // HighViscosityNoSlipBCAlgorithm_h__ + diff --git a/source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAdapter.cpp b/source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAdapter.cpp new file mode 100644 index 000000000..24bc5794c --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAdapter.cpp @@ -0,0 +1 @@ +#include "NoSlipBCAdapter.h" diff --git a/source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAdapter.h b/source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAdapter.h new file mode 100644 index 000000000..bdcf0f063 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAdapter.h @@ -0,0 +1,52 @@ +#ifndef NoSlipBCAdapter_H +#define NoSlipBCAdapter_H + +#include "BCAdapter.h" + +/*=========================================================================*/ +/* D3Q27NoSlipBCAdapter */ +/* */ +/** +<BR><BR> +@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> +@version 1.0 - 06.09.06 +*/ + +/* +usage: ... +*/ + +class NoSlipBCAdapter : public BCAdapter +{ +public: + NoSlipBCAdapter() + : BCAdapter() + { + } + NoSlipBCAdapter(const short& secondaryBcOption) + : BCAdapter(secondaryBcOption) + { + } + + void init(const D3Q27Interactor* const& interactor, const double& time=0) {} + void update(const D3Q27Interactor* const& interactor, const double& time=0) {} + + void adaptBCForDirection( const D3Q27Interactor& interactor, BoundaryConditionsPtr bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& q, const int& fdirection, const double& time=0 ) + { + bc->setNoSlipBoundaryFlag(D3Q27System::INVDIR[fdirection],secondaryBcOption); + bc->setQ((float)q,fdirection); + } + void adaptBC( const D3Q27Interactor& interactor, BoundaryConditionsPtr bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& time=0 ) + { + bc->setBcAlgorithmType(algorithmType); + } + +private: + friend class boost::serialization::access; + template<class Archive> + void serialize(Archive & ar, const unsigned int version) + { + ar & boost::serialization::base_object<BCAdapter>(*this); + } +}; +#endif //NoSlipBCAdapter_H diff --git a/source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.cpp b/source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.cpp new file mode 100644 index 000000000..2c00cbce5 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.cpp @@ -0,0 +1,45 @@ +#include "NoSlipBCAlgorithm.h" + +NoSlipBCAlgorithm::NoSlipBCAlgorithm() +{ + BCAlgorithm::type = BCAlgorithm::NoSlipBCAlgorithm; + BCAlgorithm::preCollision = false; +} +////////////////////////////////////////////////////////////////////////// +NoSlipBCAlgorithm::~NoSlipBCAlgorithm() +{ + +} +////////////////////////////////////////////////////////////////////////// +BCAlgorithmPtr NoSlipBCAlgorithm::clone() +{ + BCAlgorithmPtr bc(new NoSlipBCAlgorithm()); + return bc; +} +////////////////////////////////////////////////////////////////////////// +void NoSlipBCAlgorithm::addDistributions(DistributionArray3DPtr distributions) +{ + this->distributions = distributions; +} +////////////////////////////////////////////////////////////////////////// +void NoSlipBCAlgorithm::applyBC() +{ + LBMReal f[D3Q27System::ENDF+1]; + LBMReal feq[D3Q27System::ENDF+1]; + distributions->getDistributionInv(f, x1, x2, x3); + LBMReal rho, vx1, vx2, vx3; + calcMacrosFct(f, rho, vx1, vx2, vx3); + calcFeqFct(feq, rho, vx1, vx2, vx3); + + for (int fdir = D3Q27System::FSTARTDIR; fdir<=D3Q27System::FENDDIR; fdir++) + { + if (bcPtr->hasNoSlipBoundaryFlag(fdir)) + { + //quadratic bounce back + const int invDir = D3Q27System::INVDIR[fdir]; + LBMReal q = bcPtr->getQ(invDir); + LBMReal fReturn = ((1.0-q)/(1.0+q))*((f[invDir]-feq[invDir])/(1.0-collFactor)+feq[invDir])+((q/(1.0+q))*(f[invDir]+f[fdir])); + distributions->setDistributionForDirection(fReturn, x1+D3Q27System::DX1[invDir], x2+D3Q27System::DX2[invDir], x3+D3Q27System::DX3[invDir], fdir); + } + } +} diff --git a/source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.h b/source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.h new file mode 100644 index 000000000..30012852f --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.h @@ -0,0 +1,26 @@ +#ifndef NoSlipBCAlgorithm_h__ +#define NoSlipBCAlgorithm_h__ + +#include "BCAlgorithm.h" + +class NoSlipBCAlgorithm; +typedef boost::shared_ptr<NoSlipBCAlgorithm> NoSlipBCAlgorithmPtr; + +class NoSlipBCAlgorithm : public BCAlgorithm +{ +public: + NoSlipBCAlgorithm(); + virtual ~NoSlipBCAlgorithm(); + BCAlgorithmPtr clone(); + void addDistributions(DistributionArray3DPtr distributions); +protected: + void applyBC(); +private: + //friend class boost::serialization::access; + //template<class Archive> + //void serialize(Archive & ar, const unsigned int version) + //{ + // ar & boost::serialization::base_object<BCAlgorithm>(*this); + //} +}; +#endif // NoSlipBCAlgorithm_h__ diff --git a/source/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.cpp b/source/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.cpp new file mode 100644 index 000000000..ca7bcc7f5 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.cpp @@ -0,0 +1,59 @@ +#include "NonEqDensityBCAlgorithm.h" +#include <boost/pointer_cast.hpp> + +NonEqDensityBCAlgorithm::NonEqDensityBCAlgorithm() +{ + BCAlgorithm::type = BCAlgorithm::NonEqDensityBCAlgorithm; + BCAlgorithm::preCollision = false; +} +////////////////////////////////////////////////////////////////////////// +NonEqDensityBCAlgorithm::~NonEqDensityBCAlgorithm() +{ +} +////////////////////////////////////////////////////////////////////////// +BCAlgorithmPtr NonEqDensityBCAlgorithm::clone() +{ + BCAlgorithmPtr bc(new NonEqDensityBCAlgorithm()); + return bc; +} +////////////////////////////////////////////////////////////////////////// +void NonEqDensityBCAlgorithm::addDistributions(DistributionArray3DPtr distributions) +{ + this->distributions = distributions; +} +////////////////////////////////////////////////////////////////////////// +void NonEqDensityBCAlgorithm::applyBC() +{ + LBMReal f[D3Q27System::ENDF+1]; + distributions->getDistributionInv(f, x1, x2, x3); + int nx1 = x1; + int nx2 = x2; + int nx3 = x3; + int direction = -1; + + //flag points in direction of fluid + if (bcPtr->hasDensityBoundaryFlag(D3Q27System::E)) { nx1 -= 1; direction = D3Q27System::E; } + else if (bcPtr->hasDensityBoundaryFlag(D3Q27System::W)) { nx1 += 1; direction = D3Q27System::W; } + else if (bcPtr->hasDensityBoundaryFlag(D3Q27System::N)) { nx2 -= 1; direction = D3Q27System::N; } + else if (bcPtr->hasDensityBoundaryFlag(D3Q27System::S)) { nx2 += 1; direction = D3Q27System::S; } + else if (bcPtr->hasDensityBoundaryFlag(D3Q27System::T)) { nx3 -= 1; direction = D3Q27System::T; } + else if (bcPtr->hasDensityBoundaryFlag(D3Q27System::B)) { nx3 += 1; direction = D3Q27System::B; } + else UB_THROW(UbException(UB_EXARGS, "Danger...no orthogonal BC-Flag on density boundary...")); + + LBMReal rho, vx1, vx2, vx3; + calcMacrosFct(f, rho, vx1, vx2, vx3); + LBMReal rhoBC = bcPtr->getBoundaryDensity(); + for (int fdir = D3Q27System::STARTF; fdir<=D3Q27System::ENDF; fdir++) + { + if (bcPtr->hasDensityBoundaryFlag(fdir)) + { + // Martins NEQ ADDON + ////original: 15.2.2013: + LBMReal ftemp = calcFeqsForDirFct(fdir, rho, vx1, vx2, vx3); + ftemp = calcFeqsForDirFct(fdir, rhoBC, vx1, vx2, vx3)+f[fdir]-ftemp; + distributions->setDistributionForDirection(ftemp, nx1, nx2, nx3, fdir); + } + } + +} + diff --git a/source/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.h b/source/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.h new file mode 100644 index 000000000..e206fa7ea --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.h @@ -0,0 +1,26 @@ +#ifndef NonEqDensityBCAlgorithm_h__ +#define NonEqDensityBCAlgorithm_h__ + +#include "BCAlgorithm.h" + +class NonEqDensityBCAlgorithm; +typedef boost::shared_ptr<NonEqDensityBCAlgorithm> NonEqDensityBCAlgorithmPtr; + +class NonEqDensityBCAlgorithm : public BCAlgorithm +{ +public: + NonEqDensityBCAlgorithm(); + ~NonEqDensityBCAlgorithm(); + BCAlgorithmPtr clone(); + void addDistributions(DistributionArray3DPtr distributions); +protected: + void applyBC(); +private: + //friend class boost::serialization::access; + //template<class Archive> + //void serialize(Archive & ar, const unsigned int version) + //{ + // ar & boost::serialization::base_object<BCAlgorithm>(*this); + //} +}; +#endif // NonEqDensityBCAlgorithm_h__ diff --git a/source/VirtualFluidsCore/BoundaryConditions/NonReflectingDensityBCAlgorithm.cpp b/source/VirtualFluidsCore/BoundaryConditions/NonReflectingDensityBCAlgorithm.cpp new file mode 100644 index 000000000..3ef5e9264 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/NonReflectingDensityBCAlgorithm.cpp @@ -0,0 +1,192 @@ +#include "NonReflectingDensityBCAlgorithm.h" +#include <boost/pointer_cast.hpp> +#include "D3Q27System.h" + +NonReflectingDensityBCAlgorithm::NonReflectingDensityBCAlgorithm() +{ + BCAlgorithm::type = BCAlgorithm::NonReflectingDensityBCAlgorithm; + BCAlgorithm::preCollision = false; +} +////////////////////////////////////////////////////////////////////////// +NonReflectingDensityBCAlgorithm::~NonReflectingDensityBCAlgorithm() +{ +} +////////////////////////////////////////////////////////////////////////// +BCAlgorithmPtr NonReflectingDensityBCAlgorithm::clone() +{ + BCAlgorithmPtr bc(new NonReflectingDensityBCAlgorithm()); + return bc; +} +////////////////////////////////////////////////////////////////////////// +void NonReflectingDensityBCAlgorithm::addDistributions(DistributionArray3DPtr distributions) +{ + this->distributions = distributions; +} +////////////////////////////////////////////////////////////////////////// +void NonReflectingDensityBCAlgorithm::applyBC() +{ + distributions->swap(); + LBMReal f[D3Q27System::ENDF+1]; + LBMReal ftemp[D3Q27System::ENDF+1]; + distributions->getDistribution(f, x1, x2, x3); + int nx1 = x1; + int nx2 = x2; + int nx3 = x3; + int direction = -1; + + //flag points in direction of fluid + if (bcPtr->hasDensityBoundaryFlag(D3Q27System::E)) { nx1 += 1; direction = D3Q27System::E; } + else if (bcPtr->hasDensityBoundaryFlag(D3Q27System::W)) { nx1 -= 1; direction = D3Q27System::W; } + else if (bcPtr->hasDensityBoundaryFlag(D3Q27System::N)) { nx2 += 1; direction = D3Q27System::N; } + else if (bcPtr->hasDensityBoundaryFlag(D3Q27System::S)) { nx2 -= 1; direction = D3Q27System::S; } + else if (bcPtr->hasDensityBoundaryFlag(D3Q27System::T)) { nx3 += 1; direction = D3Q27System::T; } + else if (bcPtr->hasDensityBoundaryFlag(D3Q27System::B)) { nx3 -= 1; direction = D3Q27System::B; } + else UB_THROW(UbException(UB_EXARGS, "Danger...no orthogonal BC-Flag on density boundary...")); + + //#ifdef _DEBUG + // if (nx1<0 || nx1>maxX1) UB_THROW(UbException(UB_EXARGS, "nx1<0 || nx1>=lengthX1")); + // if (nx2<0 || nx2>maxX2) UB_THROW(UbException(UB_EXARGS, "nx2<0 || nx2>=lengthX2")); + // if (nx3<0 || nx3>maxX3) UB_THROW(UbException(UB_EXARGS, "nx3<0 || nx3>=lengthX3")); + //#endif + + distributions->getDistribution(ftemp, nx1, nx2, nx3); + LBMReal rho, vx1, vx2, vx3; + calcMacrosFct(f, rho, vx1, vx2, vx3); + + distributions->swap(); + + double dim = 0.01; + + switch (direction) + { + case D3Q27System::E: + f[D3Q27System::E] = ftemp[D3Q27System::E] * (one_over_sqrt3 + vx1) + (1.0 - one_over_sqrt3 - vx1)*f[D3Q27System::E] ;// - rho*dim*D3Q27System::WEIGTH[D3Q27System::E]; + f[D3Q27System::NE] = ftemp[D3Q27System::NE] * (one_over_sqrt3 + vx1) + (1.0 - one_over_sqrt3 - vx1)*f[D3Q27System::NE] ;// - rho*dim*D3Q27System::WEIGTH[D3Q27System::NE]; + f[D3Q27System::SE] = ftemp[D3Q27System::SE] * (one_over_sqrt3 + vx1) + (1.0 - one_over_sqrt3 - vx1)*f[D3Q27System::SE] ;// - rho*dim*D3Q27System::WEIGTH[D3Q27System::SE]; + f[D3Q27System::TE] = ftemp[D3Q27System::TE] * (one_over_sqrt3 + vx1) + (1.0 - one_over_sqrt3 - vx1)*f[D3Q27System::TE] ;// - rho*dim*D3Q27System::WEIGTH[D3Q27System::TE]; + f[D3Q27System::BE] = ftemp[D3Q27System::BE] * (one_over_sqrt3 + vx1) + (1.0 - one_over_sqrt3 - vx1)*f[D3Q27System::BE] ;// - rho*dim*D3Q27System::WEIGTH[D3Q27System::BE]; + f[D3Q27System::TNE] = ftemp[D3Q27System::TNE] * (one_over_sqrt3 + vx1) + (1.0 - one_over_sqrt3 - vx1)*f[D3Q27System::TNE];// - rho*dim*D3Q27System::WEIGTH[D3Q27System::TNE]; + f[D3Q27System::TSE] = ftemp[D3Q27System::TSE] * (one_over_sqrt3 + vx1) + (1.0 - one_over_sqrt3 - vx1)*f[D3Q27System::TSE];// - rho*dim*D3Q27System::WEIGTH[D3Q27System::TSE]; + f[D3Q27System::BNE] = ftemp[D3Q27System::BNE] * (one_over_sqrt3 + vx1) + (1.0 - one_over_sqrt3 - vx1)*f[D3Q27System::BNE];// - rho*dim*D3Q27System::WEIGTH[D3Q27System::BNE]; + f[D3Q27System::BSE] = ftemp[D3Q27System::BSE] * (one_over_sqrt3 + vx1) + (1.0 - one_over_sqrt3 - vx1)*f[D3Q27System::BSE];// - rho*dim*D3Q27System::WEIGTH[D3Q27System::BSE]; + + distributions->setDistributionInvForDirection(f[D3Q27System::E], x1, x2, x3, D3Q27System::E); + distributions->setDistributionInvForDirection(f[D3Q27System::NE], x1, x2, x3, D3Q27System::NE); + distributions->setDistributionInvForDirection(f[D3Q27System::SE], x1, x2, x3, D3Q27System::SE); + distributions->setDistributionInvForDirection(f[D3Q27System::TE], x1, x2, x3, D3Q27System::TE); + distributions->setDistributionInvForDirection(f[D3Q27System::BE], x1, x2, x3, D3Q27System::BE); + distributions->setDistributionInvForDirection(f[D3Q27System::TNE], x1, x2, x3, D3Q27System::TNE); + distributions->setDistributionInvForDirection(f[D3Q27System::TSE], x1, x2, x3, D3Q27System::TSE); + distributions->setDistributionInvForDirection(f[D3Q27System::BNE], x1, x2, x3, D3Q27System::BNE); + distributions->setDistributionInvForDirection(f[D3Q27System::BSE], x1, x2, x3, D3Q27System::BSE); + break; + case D3Q27System::W: + f[D3Q27System::W] = ftemp[D3Q27System::W] * (one_over_sqrt3 - vx1) + (1.0 - one_over_sqrt3 + vx1)*f[D3Q27System::W] ;// - rho*dim*D3Q27System::WEIGTH[D3Q27System::W]; + f[D3Q27System::NW] = ftemp[D3Q27System::NW] * (one_over_sqrt3 - vx1) + (1.0 - one_over_sqrt3 + vx1)*f[D3Q27System::NW] ;// - rho*dim*D3Q27System::WEIGTH[D3Q27System::NW]; + f[D3Q27System::SW] = ftemp[D3Q27System::SW] * (one_over_sqrt3 - vx1) + (1.0 - one_over_sqrt3 + vx1)*f[D3Q27System::SW] ;// - rho*dim*D3Q27System::WEIGTH[D3Q27System::SW]; + f[D3Q27System::TW] = ftemp[D3Q27System::TW] * (one_over_sqrt3 - vx1) + (1.0 - one_over_sqrt3 + vx1)*f[D3Q27System::TW] ;// - rho*dim*D3Q27System::WEIGTH[D3Q27System::TW]; + f[D3Q27System::BW] = ftemp[D3Q27System::BW] * (one_over_sqrt3 - vx1) + (1.0 - one_over_sqrt3 + vx1)*f[D3Q27System::BW] ;// - rho*dim*D3Q27System::WEIGTH[D3Q27System::BW]; + f[D3Q27System::TNW] = ftemp[D3Q27System::TNW] * (one_over_sqrt3 - vx1) + (1.0 - one_over_sqrt3 + vx1)*f[D3Q27System::TNW];// - rho*dim*D3Q27System::WEIGTH[D3Q27System::TNW]; + f[D3Q27System::TSW] = ftemp[D3Q27System::TSW] * (one_over_sqrt3 - vx1) + (1.0 - one_over_sqrt3 + vx1)*f[D3Q27System::TSW];// - rho*dim*D3Q27System::WEIGTH[D3Q27System::TSW]; + f[D3Q27System::BNW] = ftemp[D3Q27System::BNW] * (one_over_sqrt3 - vx1) + (1.0 - one_over_sqrt3 + vx1)*f[D3Q27System::BNW];// - rho*dim*D3Q27System::WEIGTH[D3Q27System::BNW]; + f[D3Q27System::BSW] = ftemp[D3Q27System::BSW] * (one_over_sqrt3 - vx1) + (1.0 - one_over_sqrt3 + vx1)*f[D3Q27System::BSW];// - rho*dim*D3Q27System::WEIGTH[D3Q27System::BSW]; + + distributions->setDistributionInvForDirection(f[D3Q27System::W], x1, x2, x3, D3Q27System::W); + distributions->setDistributionInvForDirection(f[D3Q27System::NW], x1, x2, x3, D3Q27System::NW); + distributions->setDistributionInvForDirection(f[D3Q27System::SW], x1, x2, x3, D3Q27System::SW); + distributions->setDistributionInvForDirection(f[D3Q27System::TW], x1, x2, x3, D3Q27System::TW); + distributions->setDistributionInvForDirection(f[D3Q27System::BW], x1, x2, x3, D3Q27System::BW); + distributions->setDistributionInvForDirection(f[D3Q27System::TNW], x1, x2, x3, D3Q27System::TNW); + distributions->setDistributionInvForDirection(f[D3Q27System::TSW], x1, x2, x3, D3Q27System::TSW); + distributions->setDistributionInvForDirection(f[D3Q27System::BNW], x1, x2, x3, D3Q27System::BNW); + distributions->setDistributionInvForDirection(f[D3Q27System::BSW], x1, x2, x3, D3Q27System::BSW); + break; + case D3Q27System::N: + f[D3Q27System::N] = ftemp[D3Q27System::N] * (one_over_sqrt3 + vx2) + (1.0 - one_over_sqrt3 - vx2)*f[D3Q27System::N] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::N]; + f[D3Q27System::NE] = ftemp[D3Q27System::NE] * (one_over_sqrt3 + vx2) + (1.0 - one_over_sqrt3 - vx2)*f[D3Q27System::NE] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::NE]; + f[D3Q27System::NW] = ftemp[D3Q27System::NW] * (one_over_sqrt3 + vx2) + (1.0 - one_over_sqrt3 - vx2)*f[D3Q27System::NW] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::NW]; + f[D3Q27System::TN] = ftemp[D3Q27System::TN] * (one_over_sqrt3 + vx2) + (1.0 - one_over_sqrt3 - vx2)*f[D3Q27System::TN] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::TN]; + f[D3Q27System::BN] = ftemp[D3Q27System::BN] * (one_over_sqrt3 + vx2) + (1.0 - one_over_sqrt3 - vx2)*f[D3Q27System::BN] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::BN]; + f[D3Q27System::TNE] = ftemp[D3Q27System::TNE] * (one_over_sqrt3 + vx2) + (1.0 - one_over_sqrt3 - vx2)*f[D3Q27System::TNE] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::TNE]; + f[D3Q27System::TNW] = ftemp[D3Q27System::TNW] * (one_over_sqrt3 + vx2) + (1.0 - one_over_sqrt3 - vx2)*f[D3Q27System::TNW] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::TNW]; + f[D3Q27System::BNE] = ftemp[D3Q27System::BNE] * (one_over_sqrt3 + vx2) + (1.0 - one_over_sqrt3 - vx2)*f[D3Q27System::BNE] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::BNE]; + f[D3Q27System::BNW] = ftemp[D3Q27System::BNW] * (one_over_sqrt3 + vx2) + (1.0 - one_over_sqrt3 - vx2)*f[D3Q27System::BNW] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::BNW]; + + distributions->setDistributionInvForDirection(f[D3Q27System::N], x1, x2, x3, D3Q27System::N); + distributions->setDistributionInvForDirection(f[D3Q27System::NE], x1, x2, x3, D3Q27System::NE); + distributions->setDistributionInvForDirection(f[D3Q27System::NW], x1, x2, x3, D3Q27System::NW); + distributions->setDistributionInvForDirection(f[D3Q27System::TN], x1, x2, x3, D3Q27System::TN); + distributions->setDistributionInvForDirection(f[D3Q27System::BN], x1, x2, x3, D3Q27System::BN); + distributions->setDistributionInvForDirection(f[D3Q27System::TNE], x1, x2, x3, D3Q27System::TNE); + distributions->setDistributionInvForDirection(f[D3Q27System::TNW], x1, x2, x3, D3Q27System::TNW); + distributions->setDistributionInvForDirection(f[D3Q27System::BNE], x1, x2, x3, D3Q27System::BNE); + distributions->setDistributionInvForDirection(f[D3Q27System::BNW], x1, x2, x3, D3Q27System::BNW); + break; + case D3Q27System::S: + f[D3Q27System::S] = ftemp[D3Q27System::S] * (one_over_sqrt3 - vx2) + (1.0 - one_over_sqrt3 + vx2)*f[D3Q27System::S] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::S]; + f[D3Q27System::SE] = ftemp[D3Q27System::SE] * (one_over_sqrt3 - vx2) + (1.0 - one_over_sqrt3 + vx2)*f[D3Q27System::SE] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::SE]; + f[D3Q27System::SW] = ftemp[D3Q27System::SW] * (one_over_sqrt3 - vx2) + (1.0 - one_over_sqrt3 + vx2)*f[D3Q27System::SW] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::SW]; + f[D3Q27System::TS] = ftemp[D3Q27System::TS] * (one_over_sqrt3 - vx2) + (1.0 - one_over_sqrt3 + vx2)*f[D3Q27System::TS] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::TS]; + f[D3Q27System::BS] = ftemp[D3Q27System::BS] * (one_over_sqrt3 - vx2) + (1.0 - one_over_sqrt3 + vx2)*f[D3Q27System::BS] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::BS]; + f[D3Q27System::TSE] = ftemp[D3Q27System::TSE] * (one_over_sqrt3 - vx2) + (1.0 - one_over_sqrt3 + vx2)*f[D3Q27System::TSE] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::TSE]; + f[D3Q27System::TSW] = ftemp[D3Q27System::TSW] * (one_over_sqrt3 - vx2) + (1.0 - one_over_sqrt3 + vx2)*f[D3Q27System::TSW] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::TSW]; + f[D3Q27System::BSE] = ftemp[D3Q27System::BSE] * (one_over_sqrt3 - vx2) + (1.0 - one_over_sqrt3 + vx2)*f[D3Q27System::BSE] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::BSE]; + f[D3Q27System::BSW] = ftemp[D3Q27System::BSW] * (one_over_sqrt3 - vx2) + (1.0 - one_over_sqrt3 + vx2)*f[D3Q27System::BSW] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::BSW]; + + distributions->setDistributionInvForDirection(f[D3Q27System::S], x1, x2, x3, D3Q27System::S); + distributions->setDistributionInvForDirection(f[D3Q27System::SE], x1, x2, x3, D3Q27System::SE); + distributions->setDistributionInvForDirection(f[D3Q27System::SW], x1, x2, x3, D3Q27System::SW); + distributions->setDistributionInvForDirection(f[D3Q27System::TS], x1, x2, x3, D3Q27System::TS); + distributions->setDistributionInvForDirection(f[D3Q27System::BS], x1, x2, x3, D3Q27System::BS); + distributions->setDistributionInvForDirection(f[D3Q27System::TSE], x1, x2, x3, D3Q27System::TSE); + distributions->setDistributionInvForDirection(f[D3Q27System::TSW], x1, x2, x3, D3Q27System::TSW); + distributions->setDistributionInvForDirection(f[D3Q27System::BSE], x1, x2, x3, D3Q27System::BSE); + distributions->setDistributionInvForDirection(f[D3Q27System::BSW], x1, x2, x3, D3Q27System::BSW); + break; + case D3Q27System::T: + f[D3Q27System::T] = ftemp[D3Q27System::T] * (one_over_sqrt3 + vx3) + (1.0 - one_over_sqrt3 - vx3)*f[D3Q27System::T] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::T]; + f[D3Q27System::TE] = ftemp[D3Q27System::TE] * (one_over_sqrt3 + vx3) + (1.0 - one_over_sqrt3 - vx3)*f[D3Q27System::TE] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::TE]; + f[D3Q27System::TW] = ftemp[D3Q27System::TW] * (one_over_sqrt3 + vx3) + (1.0 - one_over_sqrt3 - vx3)*f[D3Q27System::TW] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::TW]; + f[D3Q27System::TN] = ftemp[D3Q27System::TN] * (one_over_sqrt3 + vx3) + (1.0 - one_over_sqrt3 - vx3)*f[D3Q27System::TN] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::TN]; + f[D3Q27System::TS] = ftemp[D3Q27System::TS] * (one_over_sqrt3 + vx3) + (1.0 - one_over_sqrt3 - vx3)*f[D3Q27System::TS] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::TS]; + f[D3Q27System::TNE] = ftemp[D3Q27System::TNE] * (one_over_sqrt3 + vx3) + (1.0 - one_over_sqrt3 - vx3)*f[D3Q27System::TNE] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::TNE]; + f[D3Q27System::TNW] = ftemp[D3Q27System::TNW] * (one_over_sqrt3 + vx3) + (1.0 - one_over_sqrt3 - vx3)*f[D3Q27System::TNW] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::TNW]; + f[D3Q27System::TSE] = ftemp[D3Q27System::TSE] * (one_over_sqrt3 + vx3) + (1.0 - one_over_sqrt3 - vx3)*f[D3Q27System::TSE] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::TSE]; + f[D3Q27System::TSW] = ftemp[D3Q27System::TSW] * (one_over_sqrt3 + vx3) + (1.0 - one_over_sqrt3 - vx3)*f[D3Q27System::TSW] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::TSW]; + + distributions->setDistributionInvForDirection(f[D3Q27System::T], x1, x2, x3, D3Q27System::T); + distributions->setDistributionInvForDirection(f[D3Q27System::TE], x1, x2, x3, D3Q27System::TE); + distributions->setDistributionInvForDirection(f[D3Q27System::TW], x1, x2, x3, D3Q27System::TW); + distributions->setDistributionInvForDirection(f[D3Q27System::TN], x1, x2, x3, D3Q27System::TN); + distributions->setDistributionInvForDirection(f[D3Q27System::TS], x1, x2, x3, D3Q27System::TS); + distributions->setDistributionInvForDirection(f[D3Q27System::TNE], x1, x2, x3, D3Q27System::TNE); + distributions->setDistributionInvForDirection(f[D3Q27System::TNW], x1, x2, x3, D3Q27System::TNW); + distributions->setDistributionInvForDirection(f[D3Q27System::TSE], x1, x2, x3, D3Q27System::TSE); + distributions->setDistributionInvForDirection(f[D3Q27System::TSW], x1, x2, x3, D3Q27System::TSW); + break; + case D3Q27System::B: + f[D3Q27System::B] = ftemp[D3Q27System::B] * (one_over_sqrt3 - vx3) + (1.0 - one_over_sqrt3 + vx3)*f[D3Q27System::B] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::B]; + f[D3Q27System::BE] = ftemp[D3Q27System::BE] * (one_over_sqrt3 - vx3) + (1.0 - one_over_sqrt3 + vx3)*f[D3Q27System::BE] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::BE]; + f[D3Q27System::BW] = ftemp[D3Q27System::BW] * (one_over_sqrt3 - vx3) + (1.0 - one_over_sqrt3 + vx3)*f[D3Q27System::BW] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::BW]; + f[D3Q27System::BN] = ftemp[D3Q27System::BN] * (one_over_sqrt3 - vx3) + (1.0 - one_over_sqrt3 + vx3)*f[D3Q27System::BN] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::BN]; + f[D3Q27System::BS] = ftemp[D3Q27System::BS] * (one_over_sqrt3 - vx3) + (1.0 - one_over_sqrt3 + vx3)*f[D3Q27System::BS] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::BS]; + f[D3Q27System::BNE] = ftemp[D3Q27System::BNE] * (one_over_sqrt3 - vx3) + (1.0 - one_over_sqrt3 + vx3)*f[D3Q27System::BNE] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::BNE]; + f[D3Q27System::BNW] = ftemp[D3Q27System::BNW] * (one_over_sqrt3 - vx3) + (1.0 - one_over_sqrt3 + vx3)*f[D3Q27System::BNW] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::BNW]; + f[D3Q27System::BSE] = ftemp[D3Q27System::BSE] * (one_over_sqrt3 - vx3) + (1.0 - one_over_sqrt3 + vx3)*f[D3Q27System::BSE] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::BSE]; + f[D3Q27System::BSW] = ftemp[D3Q27System::BSW] * (one_over_sqrt3 - vx3) + (1.0 - one_over_sqrt3 + vx3)*f[D3Q27System::BSW] ;//- rho*dim*D3Q27System::WEIGTH[D3Q27System::BSW]; + + distributions->setDistributionInvForDirection(f[D3Q27System::B], x1, x2, x3, D3Q27System::B); + distributions->setDistributionInvForDirection(f[D3Q27System::BE], x1, x2, x3, D3Q27System::BE); + distributions->setDistributionInvForDirection(f[D3Q27System::BW], x1, x2, x3, D3Q27System::BW); + distributions->setDistributionInvForDirection(f[D3Q27System::BN], x1, x2, x3, D3Q27System::BN); + distributions->setDistributionInvForDirection(f[D3Q27System::BS], x1, x2, x3, D3Q27System::BS); + distributions->setDistributionInvForDirection(f[D3Q27System::BNE], x1, x2, x3, D3Q27System::BNE); + distributions->setDistributionInvForDirection(f[D3Q27System::BNW], x1, x2, x3, D3Q27System::BNW); + distributions->setDistributionInvForDirection(f[D3Q27System::BSE], x1, x2, x3, D3Q27System::BSE); + distributions->setDistributionInvForDirection(f[D3Q27System::BSW], x1, x2, x3, D3Q27System::BSW); + break; + default: + UB_THROW(UbException(UB_EXARGS, "It isn't implemented non reflecting density boundary for this direction!")); + } +} + diff --git a/source/VirtualFluidsCore/BoundaryConditions/NonReflectingDensityBCAlgorithm.h b/source/VirtualFluidsCore/BoundaryConditions/NonReflectingDensityBCAlgorithm.h new file mode 100644 index 000000000..69365de31 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/NonReflectingDensityBCAlgorithm.h @@ -0,0 +1,26 @@ +#ifndef NonReflectingDensityBCAlgorithm_h__ +#define NonReflectingDensityBCAlgorithm_h__ + +#include "BCAlgorithm.h" + +class NonReflectingDensityBCAlgorithm; +typedef boost::shared_ptr<NonReflectingDensityBCAlgorithm> NonReflectingDensityBCAlgorithmPtr; + +class NonReflectingDensityBCAlgorithm : public BCAlgorithm +{ +public: + NonReflectingDensityBCAlgorithm(); + ~NonReflectingDensityBCAlgorithm(); + BCAlgorithmPtr clone(); + void addDistributions(DistributionArray3DPtr distributions); +protected: + void applyBC(); +private: + //friend class boost::serialization::access; + //template<class Archive> + //void serialize(Archive & ar, const unsigned int version) + //{ + // ar & boost::serialization::base_object<BCAlgorithm>(*this); + //} +}; +#endif // NonReflectingDensityBCAlgorithm_h__ diff --git a/source/VirtualFluidsCore/BoundaryConditions/NonReflectingVelocityBCAlgorithm.cpp b/source/VirtualFluidsCore/BoundaryConditions/NonReflectingVelocityBCAlgorithm.cpp new file mode 100644 index 000000000..0c6ad8db8 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/NonReflectingVelocityBCAlgorithm.cpp @@ -0,0 +1,59 @@ +#include "NonReflectingVelocityBCAlgorithm.h" + +NonReflectingVelocityBCAlgorithm::NonReflectingVelocityBCAlgorithm() +{ + BCAlgorithm::type = BCAlgorithm::NonReflectingVelocityBCAlgorithm; + BCAlgorithm::preCollision = false; +} +////////////////////////////////////////////////////////////////////////// +NonReflectingVelocityBCAlgorithm::~NonReflectingVelocityBCAlgorithm() +{ + +} +////////////////////////////////////////////////////////////////////////// +BCAlgorithmPtr NonReflectingVelocityBCAlgorithm::clone() +{ + BCAlgorithmPtr bc(new NonReflectingVelocityBCAlgorithm()); + return bc; +} +////////////////////////////////////////////////////////////////////////// +void NonReflectingVelocityBCAlgorithm::addDistributions(DistributionArray3DPtr distributions) +{ + this->distributions = distributions; +} +////////////////////////////////////////////////////////////////////////// +void NonReflectingVelocityBCAlgorithm::applyBC() +{ + //velocity bc for non reflecting pressure bc + LBMReal f[D3Q27System::ENDF+1]; + LBMReal feq[D3Q27System::ENDF+1]; + distributions->getDistributionInv(f, x1, x2, x3); + LBMReal rho, vx1, vx2, vx3, drho; + calcMacrosFct(f, drho, vx1, vx2, vx3); + calcFeqFct(feq, drho, vx1, vx2, vx3); + + //if (compressible) + //{ + // rho = 1.0+drho; + //} + //else + //{ + // rho = 1.0; + //} + + rho = 1.0+drho*compressibleFactor; + + for (int fdir = D3Q27System::FSTARTDIR; fdir <= D3Q27System::FENDDIR; fdir++) + { + if (bcPtr->hasVelocityBoundaryFlag(fdir)) + { + const int invDir = D3Q27System::INVDIR[fdir]; + LBMReal q = 1.0;//bcPtr->getQ(invDir);// m+m q=0 stabiler + LBMReal velocity = bcPtr->getBoundaryVelocity(invDir); + //LBMReal fReturn = ((1.0-q)/(1.0+q))*((ftemp[invDir]-feq[invDir]*collFactor)/(1.0-collFactor))+((q*(ftemp[invDir]+ftemp[fdir])-velocity)/(1.0+q)); + //LBMReal fReturn = ((1.0 - q) / (1.0 + q))*((f[invDir] - feq[invDir]) / (1.0 - collFactor) + feq[invDir]) + ((q*(f[invDir] + f[fdir]) - velocity) / (1.0 + q))-drho*D3Q27System::WEIGTH[invDir]; + LBMReal fReturn = ((1.0 - q) / (1.0 + q))*((f[invDir] - feq[invDir]) / (1.0 - collFactor) + feq[invDir]) + ((q*(f[invDir] + f[fdir]) - velocity*rho) / (1.0 + q))-drho*D3Q27System::WEIGTH[invDir]; + distributions->setDistributionForDirection(fReturn, x1 + D3Q27System::DX1[invDir], x2 + D3Q27System::DX2[invDir], x3 + D3Q27System::DX3[invDir], fdir); + } + } +} diff --git a/source/VirtualFluidsCore/BoundaryConditions/NonReflectingVelocityBCAlgorithm.h b/source/VirtualFluidsCore/BoundaryConditions/NonReflectingVelocityBCAlgorithm.h new file mode 100644 index 000000000..d2bb80487 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/NonReflectingVelocityBCAlgorithm.h @@ -0,0 +1,32 @@ +//! \file NonReflectingVelocityBCAlgorithm.h +//! \brief Class implements velocity bc for non reflecting pressure bc. +//! \author Konstantin Kutscher + +#ifndef NonReflectingVelocityBCAlgorithm_h__ +#define NonReflectingVelocityBCAlgorithm_h__ + +#include "BCAlgorithm.h" + +class NonReflectingVelocityBCAlgorithm; +typedef boost::shared_ptr<NonReflectingVelocityBCAlgorithm> NonReflectingVelocityBCAlgorithmPtr; + +//! \brief Class implements velocity boundary condition for non reflecting pressure boundary condition + +class NonReflectingVelocityBCAlgorithm : public BCAlgorithm +{ +public: + NonReflectingVelocityBCAlgorithm(); + ~NonReflectingVelocityBCAlgorithm(); + BCAlgorithmPtr clone(); + void addDistributions(DistributionArray3DPtr distributions); +protected: + void applyBC(); +private: + //friend class boost::serialization::access; + //template<class Archive> + //void serialize(Archive & ar, const unsigned int version) + //{ + // ar & boost::serialization::base_object<BCAlgorithm>(*this); + //} +}; +#endif // NonReflectingVelocityBCAlgorithm_h__ diff --git a/source/VirtualFluidsCore/BoundaryConditions/SlipBCAdapter.cpp b/source/VirtualFluidsCore/BoundaryConditions/SlipBCAdapter.cpp new file mode 100644 index 000000000..71c273d53 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/SlipBCAdapter.cpp @@ -0,0 +1,35 @@ +#include "SlipBCAdapter.h" +#include "D3Q27System.h" +#include "D3Q27Interactor.h" +#include "numerics/geometry3d/GbCuboid3D.h" +#include <boost/pointer_cast.hpp> + +//*==========================================================*/ +//ObObject* D3Q27SlipBCAdapterCreator::createObObject() +//{ +// return new D3Q27SlipBCAdapter; +//} +//*==========================================================*/ +//ObObjectCreator* D3Q27SlipBCAdapter::getCreator() +//{ +// return D3Q27SlipBCAdapterCreator::getInstance(); +//} +//*==========================================================*/ +void SlipBCAdapter::adaptBC(const D3Q27Interactor& interactor, BoundaryConditionsPtr bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& time) +{ + ////////////////////////////////////////////////////////////////////////// + //>>> nur workaround! -> Hendrick nach normalen berechnung aus qs fragen + + GbCuboid3DPtr geo = boost::dynamic_pointer_cast<GbCuboid3D>(interactor.getGbObject3D()); + if(!geo) throw UbException(UB_EXARGS,"derzeit nur fuer Cubes valide"); + + if ( bc->hasSlipBoundaryFlag(D3Q27System::E) ) bc->setNormalVector( 1.0, 0.0, 0.0); + else if( bc->hasSlipBoundaryFlag(D3Q27System::W) ) bc->setNormalVector(-1.0, 0.0, 0.0); + else if( bc->hasSlipBoundaryFlag(D3Q27System::N) ) bc->setNormalVector( 0.0, 1.0, 0.0); + else if( bc->hasSlipBoundaryFlag(D3Q27System::S) ) bc->setNormalVector( 0.0,-1.0, 0.0); + else if( bc->hasSlipBoundaryFlag(D3Q27System::T) ) bc->setNormalVector( 0.0, 0.0, 1.0); + else if( bc->hasSlipBoundaryFlag(D3Q27System::B) ) bc->setNormalVector( 0.0, 0.0,-1.0); + + bc->setBcAlgorithmType(algorithmType); +} + diff --git a/source/VirtualFluidsCore/BoundaryConditions/SlipBCAdapter.h b/source/VirtualFluidsCore/BoundaryConditions/SlipBCAdapter.h new file mode 100644 index 000000000..0d2ca1921 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/SlipBCAdapter.h @@ -0,0 +1,94 @@ +// _ ___ __ __________ _ __ +// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ +// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ +// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) +// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +// +#ifndef SlipBCAdapter_H +#define SlipBCAdapter_H + +#ifdef CAB_RCF + #include <3rdParty/rcf/RcfSerializationIncludes.h> +#endif + +#include "BCAdapter.h" + + +/*=======================================================*/ +//D3Q27SlipBCAdapterCreator +//class D3Q27SlipBCAdapterCreator : public ObObjectCreator +//{ +//public: +// static D3Q27SlipBCAdapterCreator* getInstance() +// { +// static D3Q27SlipBCAdapterCreator instance; +// return &instance; +// } +// +// ObObject* createObObject(); +// +// std::string getTypeID() { return "D3Q27SlipBCAdapter";} +// std::string toString() { return "D3Q27SlipBCAdapterCreator"; } +// +//private: +// D3Q27SlipBCAdapterCreator( const D3Q27SlipBCAdapterCreator& ); //no copy allowed +// const D3Q27SlipBCAdapterCreator& operator=( const D3Q27SlipBCAdapterCreator& ); //no copy allowed +// D3Q27SlipBCAdapterCreator() : ObObjectCreator() {} +//}; +// +//#ifndef SWIG +//UB_AUTO_RUN_NAMED( D3Q27BCAdapterFactory::getInstance()->addObObjectCreator(D3Q27SlipBCAdapterCreator::getInstance()), CAB_D3Q27SlipBCAdapterCreator); +//#endif + +/*=========================================================================*/ +/* D3Q27SlipBCAdapter */ +/* */ +/** +<BR><BR> +@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> +@version 1.0 - 06.09.06 +*/ + +/* +usage: ... +*/ + +class SlipBCAdapter : public BCAdapter +{ +public: + SlipBCAdapter() + : BCAdapter() + { + } + SlipBCAdapter(const short& secondaryBcOption) + : BCAdapter(secondaryBcOption) + { + } + + //------------- implements D3Q27BoundaryConditionAdapter ----- start + ObObjectCreator* getCreator(); + + void init(const D3Q27Interactor* const& interactor, const double& timestep=0) {} + void update(const D3Q27Interactor* const& interactor, const double& timestep=0) {} + + void adaptBCForDirection( const D3Q27Interactor& interactor, BoundaryConditionsPtr bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& q, const int& fdirection, const double& time=0 ) + { + bc->setSlipBoundaryFlag(D3Q27System::INVDIR[fdirection],secondaryBcOption); + bc->setQ((float)q,fdirection); + } + void adaptBC(const D3Q27Interactor& interactor, BoundaryConditionsPtr bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& time=0); + + //------------- implements D3Q27BoundaryConditionAdapter ----- end + +private: + friend class boost::serialization::access; + template<class Archive> + void serialize(Archive & ar, const unsigned int version) + { + ar & boost::serialization::base_object<BCAdapter>(*this); +} + +}; + +#endif + diff --git a/source/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.cpp b/source/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.cpp new file mode 100644 index 000000000..e60abfdd7 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.cpp @@ -0,0 +1,84 @@ +#include "SlipBCAlgorithm.h" + +SlipBCAlgorithm::SlipBCAlgorithm() +{ + BCAlgorithm::type = BCAlgorithm::SlipBCAlgorithm; + BCAlgorithm::preCollision = false; +} +////////////////////////////////////////////////////////////////////////// +SlipBCAlgorithm::~SlipBCAlgorithm() +{ + +} +////////////////////////////////////////////////////////////////////////// +BCAlgorithmPtr SlipBCAlgorithm::clone() +{ + BCAlgorithmPtr bc(new SlipBCAlgorithm()); + return bc; +} +////////////////////////////////////////////////////////////////////////// +void SlipBCAlgorithm::addDistributions(DistributionArray3DPtr distributions) +{ + this->distributions = distributions; +} +////////////////////////////////////////////////////////////////////////// +void SlipBCAlgorithm::applyBC() +{ + LBMReal f[D3Q27System::ENDF+1]; + LBMReal feq[D3Q27System::ENDF+1]; + distributions->getDistributionInv(f, x1, x2, x3); + LBMReal rho, vx1, vx2, vx3; + calcMacrosFct(f, rho, vx1, vx2, vx3); + calcFeqFct(feq, rho, vx1, vx2, vx3); + + UbTupleFloat3 normale = bcPtr->getNormalVector(); + LBMReal amp = vx1*val<1>(normale)+vx2*val<2>(normale)+vx3*val<3>(normale); + + vx1 = vx1 - amp * val<1>(normale); //normale zeigt von struktur weg! + vx2 = vx2 - amp * val<2>(normale); //normale zeigt von struktur weg! + vx3 = vx3 - amp * val<3>(normale); //normale zeigt von struktur weg! + + for (int fdir = D3Q27System::FSTARTDIR; fdir<=D3Q27System::FENDDIR; fdir++) + { + if (bcPtr->hasSlipBoundaryFlag(fdir)) + { + //quadratic bounce back + const int invDir = D3Q27System::INVDIR[fdir]; + LBMReal q = 1.0;//bcPtr->getQ(invDir);// m+m q=0 stabiler + //vx3=0; + LBMReal velocity = 0.0; + switch (invDir) + { + case D3Q27System::E: velocity = (UbMath::c4o9*(+vx1)); break; //(2/cs^2)(=6)*rho_0(=1 bei imkompr)*wi*u*ei mit cs=1/sqrt(3) + case D3Q27System::W: velocity = (UbMath::c4o9*(-vx1)); break; //z.B. aus paper manfred MRT LB models in three dimensions (2002) + case D3Q27System::N: velocity = (UbMath::c4o9*(+vx2)); break; + case D3Q27System::S: velocity = (UbMath::c4o9*(-vx2)); break; + case D3Q27System::T: velocity = (UbMath::c4o9*(+vx3)); break; + case D3Q27System::B: velocity = (UbMath::c4o9*(-vx3)); break; + case D3Q27System::NE: velocity = (UbMath::c1o9*(+vx1+vx2)); break; + case D3Q27System::SW: velocity = (UbMath::c1o9*(-vx1-vx2)); break; + case D3Q27System::SE: velocity = (UbMath::c1o9*(+vx1-vx2)); break; + case D3Q27System::NW: velocity = (UbMath::c1o9*(-vx1+vx2)); break; + case D3Q27System::TE: velocity = (UbMath::c1o9*(+vx1 +vx3)); break; + case D3Q27System::BW: velocity = (UbMath::c1o9*(-vx1 -vx3)); break; + case D3Q27System::BE: velocity = (UbMath::c1o9*(+vx1 -vx3)); break; + case D3Q27System::TW: velocity = (UbMath::c1o9*(-vx1 +vx3)); break; + case D3Q27System::TN: velocity = (UbMath::c1o9*(+vx2+vx3)); break; + case D3Q27System::BS: velocity = (UbMath::c1o9*(-vx2-vx3)); break; + case D3Q27System::BN: velocity = (UbMath::c1o9*(+vx2-vx3)); break; + case D3Q27System::TS: velocity = (UbMath::c1o9*(-vx2+vx3)); break; + case D3Q27System::TNE: velocity = (UbMath::c1o36*(+vx1+vx2+vx3)); break; + case D3Q27System::BSW: velocity = (UbMath::c1o36*(-vx1-vx2-vx3)); break; + case D3Q27System::BNE: velocity = (UbMath::c1o36*(+vx1+vx2-vx3)); break; + case D3Q27System::TSW: velocity = (UbMath::c1o36*(-vx1-vx2+vx3)); break; + case D3Q27System::TSE: velocity = (UbMath::c1o36*(+vx1-vx2+vx3)); break; + case D3Q27System::BNW: velocity = (UbMath::c1o36*(-vx1+vx2-vx3)); break; + case D3Q27System::BSE: velocity = (UbMath::c1o36*(+vx1-vx2-vx3)); break; + case D3Q27System::TNW: velocity = (UbMath::c1o36*(-vx1+vx2+vx3)); break; + default: throw UbException(UB_EXARGS, "unknown error"); + } + LBMReal fReturn = ((1.0-q)/(1.0+q))*((f[invDir]-feq[invDir])/(1.0-collFactor)+feq[invDir])+((q*(f[invDir]+f[fdir])-velocity)/(1.0+q)); + distributions->setDistributionForDirection(fReturn, x1+D3Q27System::DX1[invDir], x2+D3Q27System::DX2[invDir], x3+D3Q27System::DX3[invDir], fdir); + } + } +} \ No newline at end of file diff --git a/source/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.h b/source/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.h new file mode 100644 index 000000000..ffe061523 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.h @@ -0,0 +1,26 @@ +#ifndef SlipBCAlgorithm_h__ +#define SlipBCAlgorithm_h__ + +#include "BCAlgorithm.h" + +class SlipBCAlgorithm; +typedef boost::shared_ptr<SlipBCAlgorithm> SlipBCAlgorithmPtr; + +class SlipBCAlgorithm : public BCAlgorithm +{ +public: + SlipBCAlgorithm(); + virtual ~SlipBCAlgorithm(); + BCAlgorithmPtr clone(); + void addDistributions(DistributionArray3DPtr distributions); +protected: + void applyBC(); +private: + //friend class boost::serialization::access; + //template<class Archive> + //void serialize(Archive & ar, const unsigned int version) + //{ + // ar & boost::serialization::base_object<BCAlgorithm>(*this); + //} +}; +#endif // SlipBCAlgorithm_h__ diff --git a/source/VirtualFluidsCore/BoundaryConditions/ThinWallBCProcessor.cpp b/source/VirtualFluidsCore/BoundaryConditions/ThinWallBCProcessor.cpp new file mode 100644 index 000000000..c5366bc6d --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/ThinWallBCProcessor.cpp @@ -0,0 +1,41 @@ +#include "ThinWallBCProcessor.h" + +#include "ThinWallNoSlipBCAlgorithm.h" + +ThinWallBCProcessor::ThinWallBCProcessor() +{ + +} +////////////////////////////////////////////////////////////////////////// +ThinWallBCProcessor::ThinWallBCProcessor(LBMKernelPtr kernel) : BCProcessor(kernel) +{ + +} +////////////////////////////////////////////////////////////////////////// +ThinWallBCProcessor::~ThinWallBCProcessor() +{ + +} +////////////////////////////////////////////////////////////////////////// +BCProcessorPtr ThinWallBCProcessor::clone(LBMKernelPtr kernel) +{ + BCProcessorPtr bcProcessor(new ThinWallBCProcessor(kernel)); + return bcProcessor; +} +////////////////////////////////////////////////////////////////////////// +void ThinWallBCProcessor::applyPostCollisionBC() +{ + BCProcessor::applyPostCollisionBC(); + + BOOST_FOREACH(BCAlgorithmPtr bc, postBC) + { + if (bc->getType() == BCAlgorithm::ThinWallNoSlipBCAlgorithm) + { + boost::dynamic_pointer_cast<ThinWallNoSlipBCAlgorithm>(bc)->setPass(2); + bc->apply(); + boost::dynamic_pointer_cast<ThinWallNoSlipBCAlgorithm>(bc)->setPass(1); + } + } +} + + diff --git a/source/VirtualFluidsCore/BoundaryConditions/ThinWallBCProcessor.h b/source/VirtualFluidsCore/BoundaryConditions/ThinWallBCProcessor.h new file mode 100644 index 000000000..a0a04f40b --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/ThinWallBCProcessor.h @@ -0,0 +1,34 @@ +#ifndef ThinWallBCProcessor_H +#define ThinWallBCProcessor_H + +#include "BCProcessor.h" +#include "BoundaryConditions.h" +#include "EsoTwist3D.h" +#include "BCArray3D.h" +#include "basics/container/CbArray4D.h" +#include "basics/container/CbArray3D.h" + +#include <boost/serialization/base_object.hpp> + +class ThinWallBCProcessor; +typedef boost::shared_ptr<ThinWallBCProcessor> ThinWallBCProcessorPtr; + +class ThinWallBCProcessor : public BCProcessor +{ +public: + ThinWallBCProcessor(); + ThinWallBCProcessor(LBMKernelPtr kernel); + ~ThinWallBCProcessor(); + BCProcessorPtr clone(LBMKernelPtr kernel); + void applyPostCollisionBC(); +protected: +private: + friend class boost::serialization::access; + template<class Archive> + void serialize(Archive & ar, const unsigned int version) + { + ar & boost::serialization::base_object<BCProcessor>(*this); + } +}; + +#endif diff --git a/source/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.cpp b/source/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.cpp new file mode 100644 index 000000000..dbe5be4d7 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.cpp @@ -0,0 +1,66 @@ +#include "ThinWallNoSlipBCAlgorithm.h" + +#include "D3Q27EsoTwist3DSplittedVector.h" + + +ThinWallNoSlipBCAlgorithm::ThinWallNoSlipBCAlgorithm() +{ + BCAlgorithm::type = BCAlgorithm::ThinWallNoSlipBCAlgorithm; + BCAlgorithm::preCollision = false; + pass = 1; +} +////////////////////////////////////////////////////////////////////////// +ThinWallNoSlipBCAlgorithm::~ThinWallNoSlipBCAlgorithm() +{ + +} +////////////////////////////////////////////////////////////////////////// +BCAlgorithmPtr ThinWallNoSlipBCAlgorithm::clone() +{ + BCAlgorithmPtr bc(new ThinWallNoSlipBCAlgorithm()); + return bc; +} +////////////////////////////////////////////////////////////////////////// +void ThinWallNoSlipBCAlgorithm::applyBC() +{ + LBMReal f[D3Q27System::ENDF + 1]; + LBMReal feq[D3Q27System::ENDF + 1]; + distributions->getDistributionInv(f, x1, x2, x3); + LBMReal rho, vx1, vx2, vx3; + calcMacrosFct(f, rho, vx1, vx2, vx3); + calcFeqFct(feq, rho, vx1, vx2, vx3); + + LBMReal fReturn; + + for (int fdir = D3Q27System::FSTARTDIR; fdir<=D3Q27System::FENDDIR; fdir++) + { + if (bcPtr->hasNoSlipBoundaryFlag(fdir)) + { + const int invDir = D3Q27System::INVDIR[fdir]; + if (pass == 1) + { + LBMReal q = bcPtr->getQ(invDir); + LBMReal fReturn = ((1.0 - q) / (1.0 + q))*0.5*(f[invDir] - f[fdir] + (f[invDir] + f[fdir] - collFactor*(feq[fdir] + feq[invDir])) / (1.0 - collFactor)); + //distributionsTemp->setDistributionForDirection(fReturn, x1 + D3Q27System::DX1[invDir], x2 + D3Q27System::DX2[invDir], x3 + D3Q27System::DX3[invDir], fdir); + fTemp[fdir] = fReturn; + } + else + { + //quadratic bounce back with for thin walls + //fReturn = distributionsTemp->getDistributionInvForDirection(x1 + D3Q27System::DX1[invDir], x2 + D3Q27System::DX2[invDir], x3 + D3Q27System::DX3[invDir], fdir); + fReturn = fTemp[fdir]; + distributions->setDistributionForDirection(fReturn, x1 + D3Q27System::DX1[invDir], x2 + D3Q27System::DX2[invDir], x3 + D3Q27System::DX3[invDir], fdir); + } + } + } +} +////////////////////////////////////////////////////////////////////////// +void ThinWallNoSlipBCAlgorithm::addDistributions(DistributionArray3DPtr distributions) +{ + this->distributions = distributions; +} +////////////////////////////////////////////////////////////////////////// +void ThinWallNoSlipBCAlgorithm::setPass(int pass) +{ + this->pass = pass; +} diff --git a/source/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.h b/source/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.h new file mode 100644 index 000000000..94e462b50 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.h @@ -0,0 +1,31 @@ +#ifndef ThinWallNoSlipBCAlgorithm_h__ +#define ThinWallNoSlipBCAlgorithm_h__ + +#include "NoSlipBCAlgorithm.h" + +class ThinWallNoSlipBCAlgorithm; +typedef boost::shared_ptr<ThinWallNoSlipBCAlgorithm> ThinWallNoSlipBCAlgorithmPtr; + +class ThinWallNoSlipBCAlgorithm : public BCAlgorithm +{ +public: + ThinWallNoSlipBCAlgorithm(); + virtual ~ThinWallNoSlipBCAlgorithm(); + BCAlgorithmPtr clone(); + void addDistributions(DistributionArray3DPtr distributions); + void setPass(int pass); +protected: + void applyBC(); + DistributionArray3DPtr distributionsTemp; +private: + int pass; + LBMReal fTemp[D3Q27System::ENDF + 1]; + + //friend class boost::serialization::access; + //template<class Archive> + //void serialize(Archive & ar, const unsigned int version) + //{ + // ar & boost::serialization::base_object<BCAlgorithm>(*this); + //} +}; +#endif // ThinWallNoSlipBCAlgorithm_h__ diff --git a/source/VirtualFluidsCore/BoundaryConditions/VelocityBCAdapter.cpp b/source/VirtualFluidsCore/BoundaryConditions/VelocityBCAdapter.cpp new file mode 100644 index 000000000..687d51e40 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/VelocityBCAdapter.cpp @@ -0,0 +1,306 @@ +#include "VelocityBCAdapter.h" +#include "basics/utilities/UbLogger.h" +#include "basics/utilities/UbMath.h" +#include "basics/utilities/UbTuple.h" + +using namespace std; + + +VelocityBCAdapter::VelocityBCAdapter(const bool& vx1, const bool& vx2, const bool& vx3, const BCFunction& velVxBC) +{ + if(vx1) this->vx1BCs.push_back(velVxBC); + if(vx2) this->vx2BCs.push_back(velVxBC); + if(vx3) this->vx3BCs.push_back(velVxBC); + this->init(); +} +/*==========================================================*/ +VelocityBCAdapter::VelocityBCAdapter(const bool& vx1, const bool& vx2, const bool& vx3, const mu::Parser& function, const double& startTime, const double& endTime ) +{ + if(vx1) this->vx1BCs.push_back(BCFunction(function,startTime,endTime)); + if(vx2) this->vx2BCs.push_back(BCFunction(function,startTime,endTime)); + if(vx3) this->vx3BCs.push_back(BCFunction(function,startTime,endTime)); + this->init(); +} +/*==========================================================*/ +VelocityBCAdapter::VelocityBCAdapter(const bool& vx1, const bool& vx2, const bool& vx3, const mu::Parser& function1, const mu::Parser& function2, const mu::Parser& function3, const double& startTime, const double& endTime ) +{ + if(vx1) this->vx1BCs.push_back(BCFunction(function1,startTime,endTime)); + if(vx2) this->vx2BCs.push_back(BCFunction(function2,startTime,endTime)); + if(vx3) this->vx3BCs.push_back(BCFunction(function3,startTime,endTime)); + this->init(); +} +/*==========================================================*/ +VelocityBCAdapter::VelocityBCAdapter(const bool& vx1, const bool& vx2, const bool& vx3, const string& functionstring, const double& startTime, const double& endTime ) +{ + if(vx1) this->vx1BCs.push_back(BCFunction(functionstring,startTime,endTime)); + if(vx2) this->vx2BCs.push_back(BCFunction(functionstring,startTime,endTime)); + if(vx3) this->vx3BCs.push_back(BCFunction(functionstring,startTime,endTime)); + this->init(); +} +/*==========================================================*/ +VelocityBCAdapter::VelocityBCAdapter(const BCFunction& velBC, bool x1Dir, bool x2Dir, bool x3Dir) +{ + if(x1Dir) this->vx1BCs.push_back(velBC); + if(x2Dir) this->vx2BCs.push_back(velBC); + if(x3Dir) this->vx3BCs.push_back(velBC); + this->init(); +} +/*==========================================================*/ +VelocityBCAdapter::VelocityBCAdapter(const BCFunction& velVx1BC, const BCFunction& velVx2BC, const BCFunction& velVx3BC) +{ + if( velVx1BC.getEndTime()!=-Ub::inf ) this->vx1BCs.push_back(velVx1BC); + if( velVx2BC.getEndTime()!=-Ub::inf ) this->vx2BCs.push_back(velVx2BC); + if( velVx3BC.getEndTime()!=-Ub::inf ) this->vx3BCs.push_back(velVx3BC); + this->init(); +} +/*==========================================================*/ +VelocityBCAdapter::VelocityBCAdapter(const vector< BCFunction >& velVx1BCs, const vector< BCFunction >& velVx2BCs, const vector< BCFunction >& velVx3BCs) +{ + this->vx1BCs = velVx1BCs; + this->vx2BCs = velVx2BCs; + this->vx3BCs = velVx3BCs; + this->init(); +} +/*==========================================================*/ +VelocityBCAdapter::VelocityBCAdapter(const double& vx1, const double& vx1StartTime, const double& vx1EndTime, + const double& vx2, const double& vx2StartTime, const double& vx2EndTime, + const double& vx3, const double& vx3StartTime, const double& vx3EndTime ) +{ + this->vx1BCs.push_back(BCFunction(vx1,vx1StartTime,vx1EndTime)); + this->vx2BCs.push_back(BCFunction(vx2,vx2StartTime,vx2EndTime)); + this->vx3BCs.push_back(BCFunction(vx3,vx3StartTime,vx3EndTime)); + this->init(); +} +/*==========================================================*/ +VelocityBCAdapter::VelocityBCAdapter(const string& vx1Function, const double& vx1StartTime, const double& vx1EndTime, + const string& vx2Function, const double& vx2StartTime, const double& vx2EndTime, + const string& vx3Function, const double& vx3StartTime, const double& vx3EndTime ) +{ + if(vx1Function.size()) this->vx1BCs.push_back(BCFunction(vx1Function,vx1StartTime,vx1EndTime)); + if(vx2Function.size()) this->vx2BCs.push_back(BCFunction(vx2Function,vx2StartTime,vx2EndTime)); + if(vx3Function.size()) this->vx3BCs.push_back(BCFunction(vx3Function,vx3StartTime,vx3EndTime)); + this->init(); +} +/*==========================================================*/ +void VelocityBCAdapter::setNewVelocities(const double& vx1, const double& vx1StartTime, const double& vx1EndTime, + const double& vx2, const double& vx2StartTime, const double& vx2EndTime, + const double& vx3, const double& vx3StartTime, const double& vx3EndTime ) +{ + this->clear(); + this->vx1BCs.push_back(BCFunction(vx1,vx1StartTime,vx1EndTime)); + this->vx2BCs.push_back(BCFunction(vx2,vx2StartTime,vx2EndTime)); + this->vx3BCs.push_back(BCFunction(vx3,vx3StartTime,vx3EndTime)); + this->init(); +} +/*==========================================================*/ +void VelocityBCAdapter::init() +{ + this->unsetTimeDependent(); + + this->timeStep = 0.0; + + this->x1 = 0.0; + this->x2 = 0.0; + this->x3 = 0.0; + + this->tmpVx1Function = NULL; + this->tmpVx2Function = NULL; + this->tmpVx3Function = NULL; + + try //initilialization and validation of functions + { + this->init(vx1BCs); + this->init(vx2BCs); + this->init(vx3BCs); + } + catch(mu::Parser::exception_type& e){ stringstream error; error<<"mu::parser exception occurs, message("<<e.GetMsg()<<"), formula("<<e.GetExpr()+"), token("+e.GetToken()<<")" + <<", pos("<<e.GetPos()<<"), error code("<<e.GetCode(); throw UbException(error.str()); } + catch(...) { throw UbException(UB_EXARGS,"unknown exception" ); } +} +/*==========================================================*/ +void VelocityBCAdapter::init(std::vector<BCFunction>& vxBCs) +{ + for(size_t pos=0; pos<vxBCs.size(); ++pos) + { + if( !( UbMath::equal( BCFunction::INFCONST, vxBCs[pos].getEndTime() ) + && UbMath::greaterEqual( this->timeStep, vxBCs[pos].getStartTime() ) ) ) + { + this->setTimeDependent(); + } + + vxBCs[pos].getFunction().DefineVar("t" , &this->timeStep); + vxBCs[pos].getFunction().DefineVar("x1", &this->x1 ); + vxBCs[pos].getFunction().DefineVar("x2", &this->x2 ); + vxBCs[pos].getFunction().DefineVar("x3", &this->x3 ); + + vxBCs[pos].getFunction().Eval(); //<-- validation + } +} +/*==========================================================*/ +void VelocityBCAdapter::init(const D3Q27Interactor* const& interactor, const double& time) +{ + this->timeStep = time; + this->tmpVx1Function = this->tmpVx2Function = this->tmpVx3Function = NULL; + + //aktuelle velocityfunction bestimmen + double maxEndtime = -Ub::inf; + + for(size_t pos=0; pos<vx1BCs.size(); ++pos) + { + if( UbMath::equal(vx1BCs[pos].getEndTime(),BCFunction::INFTIMEDEPENDENT) ) maxEndtime=Ub::inf; + maxEndtime = UbMath::max(maxEndtime,vx1BCs[pos].getStartTime(),vx1BCs[pos].getEndTime()); //startTime abfragen, da INFCONST=-10 + + if( UbMath::greaterEqual(this->timeStep,vx1BCs[pos].getStartTime()) ) + { + if( UbMath::lessEqual( this->timeStep , vx1BCs[pos].getEndTime() ) + || UbMath::equal( vx1BCs[pos].getEndTime(), (double)BCFunction::INFCONST ) + || UbMath::equal( vx1BCs[pos].getEndTime(), (double)BCFunction::INFTIMEDEPENDENT) ) + { + tmpVx1Function = &vx1BCs[pos].getFunction(); + break; + } + } + } + for(size_t pos=0; pos<vx2BCs.size(); ++pos) + { + if( UbMath::equal(vx2BCs[pos].getEndTime(),BCFunction::INFTIMEDEPENDENT)) maxEndtime=Ub::inf; + maxEndtime = UbMath::max(maxEndtime,vx2BCs[pos].getStartTime(),vx2BCs[pos].getEndTime()); //startTime abfragen, da INFCONST=-10 + + if( UbMath::greaterEqual(this->timeStep,vx2BCs[pos].getStartTime()) ) + { + if( UbMath::lessEqual( this->timeStep , vx2BCs[pos].getEndTime() ) + || UbMath::equal( vx2BCs[pos].getEndTime(), (double)BCFunction::INFCONST ) + || UbMath::equal( vx2BCs[pos].getEndTime(), (double)BCFunction::INFTIMEDEPENDENT ) ) + { + tmpVx2Function = &vx2BCs[pos].getFunction(); + break; + } + } + } + for(size_t pos=0; pos<vx3BCs.size(); ++pos) + { + if( UbMath::equal(vx3BCs[pos].getEndTime(),BCFunction::INFTIMEDEPENDENT)) maxEndtime=Ub::inf; + maxEndtime = UbMath::max(maxEndtime,vx3BCs[pos].getStartTime(),vx3BCs[pos].getEndTime()); //startTime abfragen, da INFCONST=-10 + + if( UbMath::greaterEqual(this->timeStep,vx3BCs[pos].getStartTime()) ) + { + if( UbMath::lessEqual( this->timeStep , vx3BCs[pos].getEndTime() ) + || UbMath::equal( vx3BCs[pos].getEndTime(), (double)BCFunction::INFCONST ) + || UbMath::equal( vx3BCs[pos].getEndTime(), (double)BCFunction::INFTIMEDEPENDENT ) ) + { + tmpVx3Function = &vx3BCs[pos].getFunction(); + break; + } + } + } + + if( UbMath::greaterEqual(time,maxEndtime) ) + { + if( !this->isTimePeriodic() ) this->unsetTimeDependent(); + else //bei peridoic die interavalle neu setzen: + { + if( UbMath::equal(maxEndtime,BCFunction::INFCONST) ) + for(size_t pos=0; pos<vx1BCs.size(); ++pos) + { + vx1BCs[pos].setStartTime( vx1BCs[pos].getStartTime() + timeStep ); + vx1BCs[pos].setEndTime( vx1BCs[pos].getEndTime() + timeStep ); + } + if( UbMath::equal(maxEndtime,BCFunction::INFCONST) ) + for(size_t pos=0; pos<vx2BCs.size(); ++pos) + { + vx2BCs[pos].setStartTime( vx2BCs[pos].getStartTime() + timeStep ); + vx2BCs[pos].setEndTime( vx2BCs[pos].getEndTime() + timeStep ); + } + if( UbMath::equal(maxEndtime,BCFunction::INFCONST) ) + for(size_t pos=0; pos<vx3BCs.size(); ++pos) + { + vx3BCs[pos].setStartTime( vx3BCs[pos].getStartTime() + timeStep ); + vx3BCs[pos].setEndTime( vx3BCs[pos].getEndTime() + timeStep ); + } + this->init(interactor,time); + } + } + + UBLOG(logDEBUG4,"D3Q27VelocityBCAdapter::init(time="<<time<<") " + <<", vx1= \""<<(tmpVx1Function ? tmpVx1Function->GetExpr() : "-")<<"\"" + <<", vx2= \""<<(tmpVx2Function ? tmpVx2Function->GetExpr() : "-")<<"\"" + <<", vx3= \""<<(tmpVx3Function ? tmpVx3Function->GetExpr() : "-")<<"\"" + <<", timedependent="<<boolalpha<<this->isTimeDependent() ); +} +/*==========================================================*/ +void VelocityBCAdapter::update( const D3Q27Interactor* const& interactor, const double& time ) +{ + this->init(interactor,time); +} +/*==========================================================*/ +void VelocityBCAdapter::adaptBCForDirection( const D3Q27Interactor& interactor, BoundaryConditionsPtr bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& q, const int& fdirection, const double& time ) +{ + bc->setVelocityBoundaryFlag(D3Q27System::INVDIR[fdirection],secondaryBcOption); + bc->setQ((float)q,fdirection); +} +/*==========================================================*/ +void VelocityBCAdapter::adaptBC( const D3Q27Interactor& interactor, BoundaryConditionsPtr bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& time ) +{ + this->setNodeVelocity(interactor,bc,worldX1,worldX2,worldX3,time); + bc->setBcAlgorithmType(algorithmType); +} +/*==========================================================*/ +void VelocityBCAdapter::setNodeVelocity( const D3Q27Interactor& interactor, BoundaryConditionsPtr bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& timestep) +{ + //Geschwindigkeiten setzen + try + { + //PunktKoordinaten bestimmen + this->x1 = worldX1; + this->x2 = worldX2; + this->x3 = worldX3; + this->timeStep = timestep; + + if(tmpVx1Function) bc->setBoundaryVelocityX1((float)tmpVx1Function->Eval()); + if(tmpVx2Function) bc->setBoundaryVelocityX2((float)tmpVx2Function->Eval()); + if(tmpVx3Function) bc->setBoundaryVelocityX3((float)tmpVx3Function->Eval()); + } + catch(mu::Parser::exception_type& e){ stringstream error; error<<"mu::parser exception occurs, message("<<e.GetMsg()<<"), formula("<<e.GetExpr()+"), token("+e.GetToken()<<")" + <<", pos("<<e.GetPos()<<"), error code("<<e.GetCode(); throw UbException(error.str()); } + catch(...) { throw UbException(UB_EXARGS,"unknown exception" ); } +} +/*==========================================================*/ +UbTupleDouble3 VelocityBCAdapter::getVelocity(const double& x1, const double& x2, const double& x3, const double& timeStep) const +{ + double vx1 = 0.0; + double vx2 = 0.0; + double vx3 = 0.0; + this->x1 = x1; + this->x2 = x2; + this->x3 = x3; + this->timeStep = timeStep; + + if(tmpVx1Function) vx1 = tmpVx1Function->Eval(); + if(tmpVx2Function) vx2 = tmpVx2Function->Eval(); + if(tmpVx3Function) vx3 = tmpVx3Function->Eval(); + + return UbTupleDouble3(vx1,vx2,vx3); +} +/*==========================================================*/ +string VelocityBCAdapter::toString() +{ + stringstream info; + info<<"D3Q27VelocityBCAdapter:\n"; + info<<" #vx1-functions = "<<(int)vx1BCs.size()<<endl; + info<<" #vx2-functions = "<<(int)vx2BCs.size()<<endl; + info<<" #vx3-functions = "<<(int)vx3BCs.size()<<endl; + info<<" protected variables: x1, x2, x3, t"<<endl; + + const vector<BCFunction>* bcvecs[3] = { &vx1BCs, &vx2BCs, &vx3BCs }; + for(int i=0; i<3; i++) + { + for(size_t pos=0; pos<bcvecs[i]->size(); ++pos) + { + info<<"\n vx"<<(i+1)<<"-function nr."<<pos<<":"<<endl; + info<<(*bcvecs[i])[pos]<<endl; + } + } + return info.str(); +} + + diff --git a/source/VirtualFluidsCore/BoundaryConditions/VelocityBCAdapter.h b/source/VirtualFluidsCore/BoundaryConditions/VelocityBCAdapter.h new file mode 100644 index 000000000..576626041 --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/VelocityBCAdapter.h @@ -0,0 +1,156 @@ +// _ ___ __ __________ _ __ +// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ +// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ +// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) +// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +// +#ifndef VelocityBCAdapter_H +#define VelocityBCAdapter_H + +#include <iostream> +#include <string> +#include <sstream> +#include <vector> + +#ifdef CAB_RCF + #include <3rdParty/rcf/RcfSerializationIncludes.h> +#endif + +#include <basics/utilities/UbInfinity.h> +#include <basics/utilities/UbFileOutput.h> +#include <basics/utilities/UbFileInput.h> + +class UbFileOutput; +class UbFileInput; + +#include <BCAdapter.h> +#include <BCFunction.h> + +//example: +// vector<D3Q27BCFunction> vx1BCs,vx2BCs,vx3BCs; +// vx1BCs.push_back(D3Q27BCFunction(0.01 , 0 , 100) ); //t=[0 ..100[ -> vx1 = 0.01 +// vx1BCs.push_back(D3Q27BCFunction(0.004, 100, 200) ); //t=[100..200[ -> vx1 = 0.004 +// vx1BCs.push_back(D3Q27BCFunction(0.03 , 200, 400) ); //t=[200..400] -> vx1 = 0.03 +// +// vx2BCs.push_back(D3Q27BCFunction(0.02 , 0 , 200) ); //t=[0 ..200[ -> vx2 = 0.02 +// vx2BCs.push_back(D3Q27BCFunction(0.002, 200, 300) ); //t=[200..300[ -> vx2 = 0.002 +// vx2BCs.push_back(D3Q27BCFunction(0.043, 300, 600) ); //t=[300..600] -> vx2 = 0.043 +// +// D3Q27VelocityBCAdapter bcAdapter(vx1BCs,vx2BCs,vx3BCs); +// bcAdapter.setTimePeriodic(); //-> t=[0 ..100[ -> vx1 = 0.01 +// // t=[100..200[ -> vx1 = 0.004 +// // t=[200..400[ -> vx1 = 0.03 +// // t=[400..500[ -> vx1 = 0.01 +// // t=[500..600[ -> vx1 = 0.004 +// // t=[600..800[ -> vx1 = 0.03 ... +// // t=[0 ..200[ -> vx2 = 0.02 +// // t=[200..300[ -> vx2 = 0.002 +// // t=[300..600] -> vx2 = 0.043 +// // t=[600..800[ -> vx2 = 0.02 +// // t=[800..900[ -> vx2 = 0.002 +// // t=[900..1200]-> vx2 = 0.043 ... +// +// example parabolic inflow: +// mu::Parser fct; +// fct.SetExpr("max(vmax*(1.0-4.0*((x2-x2_vmax)^2+(x3-x3_vmax)^2)/H^2),0.0)"); //paraboloid (mit vmax bei (0/x2_vmax/x3_vmax) +// fct.DefineConst("x2Vmax", 0.0 ); //x2-Pos für vmax +// fct.DefineConst("x3Vmax", 0.0 ); //x3-Pos für vmax +// fct.DefineConst("H" , rohrDurchmesser); +// fct.DefineConst("vmax" , vmax ); +// D3Q27VelocityBCAdapter velBC(true, false ,false ,fct, 0, D3Q27BCFunction::INFCONST); + +/*=========================================================================*/ +/* D3Q27VelocityBCAdapter */ +/* */ +/** +<BR><BR> +@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> +@version 1.0 - 06.09.06 +*/ + +class VelocityBCAdapter : public BCAdapter +{ +public: + //constructors + VelocityBCAdapter() { this->init(); } + + VelocityBCAdapter(const bool& vx1, const bool& vx2, const bool& vx3, const BCFunction& velVxBC ); + + VelocityBCAdapter(const bool& vx1, const bool& vx2, const bool& vx3, const mu::Parser& function, const double& startTime, const double& endTime ); + + VelocityBCAdapter(const bool& vx1, const bool& vx2, const bool& vx3, const mu::Parser& function1, const mu::Parser& function2, const mu::Parser& function3, const double& startTime, const double& endTime ); + + VelocityBCAdapter(const bool& vx1, const bool& vx2, const bool& vx3, const std::string& functionstring, const double& startTime, const double& endTime ); + + VelocityBCAdapter(const BCFunction& velBC, bool x1Dir, bool x2Dir, bool x3Dir); + + VelocityBCAdapter(const BCFunction& velVx1BC, const BCFunction& velVx2BC, const BCFunction& velVx3BC); + + VelocityBCAdapter(const std::vector< BCFunction >& velVx1BCs, const std::vector< BCFunction >& velVx2BCs, const std::vector< BCFunction >& velVx3BCs); + + VelocityBCAdapter(const double& vx1, const double& vx1StartTime, const double& vx1EndTime, + const double& vx2, const double& vx2StartTime, const double& vx2EndTime, + const double& vx3, const double& vx3StartTime, const double& vx3EndTime); + + VelocityBCAdapter(const std::string& vx1Function, const double& vx1StartTime, const double& vx1EndTime, + const std::string& vx2Function, const double& vx2StartTime, const double& vx2EndTime, + const std::string& vx3Function, const double& vx3StartTime, const double& vx3EndTime ); + + //methods + void setTimePeriodic() { (this->type |= TIMEPERIODIC); } + void unsetTimePeriodic() { (this->type &= ~TIMEPERIODIC); } + bool isTimePeriodic() { return ((this->type & TIMEPERIODIC) == TIMEPERIODIC); } + + //folgendes ist fuer moving objects gedadacht... + void setNewVelocities(const double& vx1, const double& vx1StartTime, const double& vx1EndTime, + const double& vx2, const double& vx2StartTime, const double& vx2EndTime, + const double& vx3, const double& vx3StartTime, const double& vx3EndTime); + + + //------------- implements D3Q27BoundaryConditionAdapter ----- start + std::string toString(); + + void init(const D3Q27Interactor* const& interactor, const double& time=0); + void update(const D3Q27Interactor* const& interactor, const double& time=0); + + void adaptBCForDirection( const D3Q27Interactor& interactor, BoundaryConditionsPtr bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& q, const int& fdirection, const double& time=0 ); + void adaptBC( const D3Q27Interactor& interactor, BoundaryConditionsPtr bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& time=0 ); + + //------------- implements D3Q27BoundaryConditionAdapter ----- end + + UbTupleDouble3 getVelocity(const double& x1, const double& x2, const double& x3, const double& timeStep) const; + + +protected: + void init(); + void init(std::vector<BCFunction>& vxBCs); + + //time dependency wird automatisch ueber D3Q27BCFunction Intervalle ermittelt! + void setTimeDependent() { (this->type |= TIMEDEPENDENT); } + void unsetTimeDependent() { (this->type &= ~TIMEDEPENDENT); } + + void clear() { vx1BCs.clear(); vx2BCs.clear(); vx3BCs.clear(); this->init(); } + void setNodeVelocity(const D3Q27Interactor& interactor, BoundaryConditionsPtr bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& timestep); + +private: + mutable mu::value_type x1, x2, x3; + mutable mu::value_type timeStep; + + mu::Parser* tmpVx1Function; + mu::Parser* tmpVx2Function; + mu::Parser* tmpVx3Function; + + std::vector<BCFunction> vx1BCs; + std::vector<BCFunction> vx2BCs; + std::vector<BCFunction> vx3BCs; + +private: + friend class boost::serialization::access; + template<class Archive> + void serialize(Archive & ar, const unsigned int version) + { + ar & boost::serialization::base_object<BCAdapter>(*this); + } +}; + +#endif diff --git a/source/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.cpp b/source/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.cpp new file mode 100644 index 000000000..c573ae03b --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.cpp @@ -0,0 +1,49 @@ +#include "VelocityBCAlgorithm.h" +#include <boost/pointer_cast.hpp> + +VelocityBCAlgorithm::VelocityBCAlgorithm() +{ + BCAlgorithm::type = BCAlgorithm::VelocityBCAlgorithm; + BCAlgorithm::preCollision = false; +} +////////////////////////////////////////////////////////////////////////// +VelocityBCAlgorithm::~VelocityBCAlgorithm() +{ +} +////////////////////////////////////////////////////////////////////////// +BCAlgorithmPtr VelocityBCAlgorithm::clone() +{ + BCAlgorithmPtr bc(new VelocityBCAlgorithm()); + return bc; +} +////////////////////////////////////////////////////////////////////////// +void VelocityBCAlgorithm::addDistributions(DistributionArray3DPtr distributions) +{ + this->distributions = distributions; +} +////////////////////////////////////////////////////////////////////////// +void VelocityBCAlgorithm::applyBC() +{ + LBMReal f[D3Q27System::ENDF+1]; + LBMReal feq[D3Q27System::ENDF+1]; + distributions->getDistributionInv(f, x1, x2, x3); + LBMReal rho, vx1, vx2, vx3, drho; + calcMacrosFct(f, drho, vx1, vx2, vx3); + calcFeqFct(feq, drho, vx1, vx2, vx3); + + rho = 1.0+drho*compressibleFactor; + + for (int fdir = D3Q27System::FSTARTDIR; fdir<=D3Q27System::FENDDIR; fdir++) + { + if (bcPtr->hasVelocityBoundaryFlag(fdir)) + { + const int invDir = D3Q27System::INVDIR[fdir]; + LBMReal q = bcPtr->getQ(invDir);// m+m q=0 stabiler + LBMReal velocity = bcPtr->getBoundaryVelocity(invDir); + LBMReal fReturn = ((1.0-q)/(1.0+q))*((f[invDir]-feq[invDir])/(1.0-collFactor)+feq[invDir])+((q*(f[invDir]+f[fdir])-velocity*rho)/(1.0+q)); + distributions->setDistributionForDirection(fReturn, x1+D3Q27System::DX1[invDir], x2+D3Q27System::DX2[invDir], x3+D3Q27System::DX3[invDir], fdir); + } + } + +} + diff --git a/source/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.h b/source/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.h new file mode 100644 index 000000000..a231e27ca --- /dev/null +++ b/source/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.h @@ -0,0 +1,28 @@ +#ifndef VelocityBoundaryCondition_h__ +#define VelocityBoundaryCondition_h__ + +#include "BCAlgorithm.h" + +class VelocityBCAlgorithm; +typedef boost::shared_ptr<VelocityBCAlgorithm> VelocityBCAlgorithmPtr; + +class VelocityBCAlgorithm : public BCAlgorithm +{ +public: + VelocityBCAlgorithm(); + ~VelocityBCAlgorithm(); + BCAlgorithmPtr clone(); + void addDistributions(DistributionArray3DPtr distributions); +protected: + void applyBC(); +private: + //friend class boost::serialization::access; + //template<class Archive> + //void serialize(Archive & ar, const unsigned int version) + //{ + // ar & boost::serialization::base_object<BCAlgorithm>(*this); + //} +}; + +#endif // VelocityBoundaryCondition_h__ + diff --git a/source/VirtualFluidsCore/CMakeLists.txt b/source/VirtualFluidsCore/CMakeLists.txt index a2afff40e..983c8c5d7 100644 --- a/source/VirtualFluidsCore/CMakeLists.txt +++ b/source/VirtualFluidsCore/CMakeLists.txt @@ -21,7 +21,7 @@ INCLUDE(${SOURCE_ROOT}/ThirdParty/MuParser/CMakePackage.txt) # INCLUDE(${SOURCE_ROOT}/ThirdParty/Basics/transmitter/CMakePackage.txt) #new VirtualFluids -INCLUDE(${SOURCE_ROOT}/VirtualFluidsCore/BoundaryCondition/CMakePackage.txt) +INCLUDE(${SOURCE_ROOT}/VirtualFluidsCore/BoundaryConditions/CMakePackage.txt) INCLUDE(${SOURCE_ROOT}/VirtualFluidsCore/Connectors/CMakePackage.txt) INCLUDE(${SOURCE_ROOT}/VirtualFluidsCore/Data/CMakePackage.txt) INCLUDE(${SOURCE_ROOT}/VirtualFluidsCore/Interactors/CMakePackage.txt) diff --git a/source/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.cpp index 3ae67b046..ee395e288 100644 --- a/source/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.cpp +++ b/source/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.cpp @@ -18,7 +18,7 @@ using namespace std; AdjustForcingCoProcessor::AdjustForcingCoProcessor(Grid3DPtr grid, UbSchedulerPtr s, const std::string& path, - D3Q27IntegrateValuesHelperPtr integrateValues, + IntegrateValuesHelperPtr integrateValues, double vTarged, CommunicatorPtr comm) diff --git a/source/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.h b/source/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.h index 5b27ddb82..5ddbe6fe5 100644 --- a/source/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.h +++ b/source/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.h @@ -2,7 +2,7 @@ #define D3Q27ADJUSTFORCINGCoProcessor_H #include "CoProcessor.h" -#include "D3Q27IntegrateValuesHelper.h" +#include "IntegrateValuesHelper.h" #include "LBMUnitConverter.h" #include "Communicator.h" @@ -19,14 +19,14 @@ class AdjustForcingCoProcessor: public CoProcessor { public: AdjustForcingCoProcessor(Grid3DPtr grid, UbSchedulerPtr s, const std::string& path, - D3Q27IntegrateValuesHelperPtr integrateValues, + IntegrateValuesHelperPtr integrateValues, double vTarged, CommunicatorPtr comm); virtual ~AdjustForcingCoProcessor(); //!< calls collect PostprocessData void process(double step); protected: //!< object that can compute spacial average values in 3D-subdomain. - D3Q27IntegrateValuesHelperPtr integrateValues; + IntegrateValuesHelperPtr integrateValues; //!< compares velocity in integrateValues with target velocity and adjusts forcing accordingly. void collectData(double step); CommunicatorPtr comm; diff --git a/source/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.cpp index d92a60873..b5f9461b7 100644 --- a/source/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.cpp +++ b/source/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.cpp @@ -1,6 +1,6 @@ #include "AverageValuesCoProcessor.h" -#include "LBMKernel3D.h" -#include "D3Q27ETBCProcessor.h" +#include "LBMKernel.h" +#include "BCProcessor.h" #include <vector> #include <sstream> #include <string> @@ -91,8 +91,8 @@ void AverageValuesCoProcessor::resetDataRMS(double step) { if (block) { - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); AverageValuesArray3DPtr av = kernel->getDataSet()->getAverageValues(); @@ -142,8 +142,8 @@ void AverageValuesCoProcessor::resetDataMeans(double step) { if (block) { - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); AverageValuesArray3DPtr av = kernel->getDataSet()->getAverageValues(); @@ -263,8 +263,8 @@ void AverageValuesCoProcessor::addData(const Block3DPtr block) data.resize(datanames.size()); - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); AverageValuesArray3DPtr av = kernel->getDataSet()->getAverageValues(); //int ghostLayerWidth = kernel->getGhostLayerWidth(); @@ -390,8 +390,8 @@ void AverageValuesCoProcessor::calculateAverageValues(double timeStep) { if (block) { - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); AverageValuesArray3DPtr av = kernel->getDataSet()->getAverageValues(); diff --git a/source/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.h b/source/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.h index d60ecaf59..3689e0192 100644 --- a/source/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.h +++ b/source/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.h @@ -6,7 +6,7 @@ #include "Block3D.h" #include "LBMUnitConverter.h" #include "Communicator.h" -#include "D3Q27IntegrateValuesHelper.h" +#include "IntegrateValuesHelper.h" #include "WbWriter.h" diff --git a/source/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.cpp index 52ad99b2b..09546391c 100644 --- a/source/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.cpp +++ b/source/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.cpp @@ -1,5 +1,5 @@ #include "CalculateForcesCoProcessor.h" -#include "D3Q27ETBCProcessor.h" +#include "BCProcessor.h" #include <boost/foreach.hpp> CalculateForcesCoProcessor::CalculateForcesCoProcessor( Grid3DPtr grid, UbSchedulerPtr s, @@ -97,8 +97,8 @@ void CalculateForcesCoProcessor::calculateForces() Block3DPtr block = t.first; std::set< std::vector<int> >& transNodeIndicesSet = t.second; - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D &bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); distributions->swap(); @@ -121,7 +121,7 @@ void CalculateForcesCoProcessor::calculateForces() if(bcArray.isFluid(x1,x2,x3)) //es kann sein, dass der node von einem anderen interactor z.B. als solid gemarkt wurde!!! { - D3Q27BoundaryConditionPtr bc = bcArray.getBC(x1,x2,x3); + BoundaryConditionsPtr bc = bcArray.getBC(x1,x2,x3); UbTupleDouble3 forceVec = getForces(x1,x2,x3,distributions,bc); forceX1 += val<1>(forceVec); forceX2 += val<2>(forceVec); @@ -165,7 +165,7 @@ void CalculateForcesCoProcessor::calculateForces() } } ////////////////////////////////////////////////////////////////////////// -UbTupleDouble3 CalculateForcesCoProcessor::getForces(int x1, int x2, int x3, DistributionArray3DPtr distributions, D3Q27BoundaryConditionPtr bc) +UbTupleDouble3 CalculateForcesCoProcessor::getForces(int x1, int x2, int x3, DistributionArray3DPtr distributions, BoundaryConditionsPtr bc) { UbTupleDouble3 force(0.0,0.0,0.0); diff --git a/source/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.h b/source/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.h index 287f3dc9d..07688665f 100644 --- a/source/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.h +++ b/source/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.h @@ -27,7 +27,7 @@ public: protected: void collectData(double step); void calculateForces(); - UbTupleDouble3 getForces(int x1, int x2, int x3, DistributionArray3DPtr distributions, D3Q27BoundaryConditionPtr bc); + UbTupleDouble3 getForces(int x1, int x2, int x3, DistributionArray3DPtr distributions, BoundaryConditionsPtr bc); void calculateCoefficients(); void write(std::ofstream *fileObject, double value, char *separator); private: diff --git a/source/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.cpp index c9b003b0c..429bf3e6e 100644 --- a/source/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.cpp +++ b/source/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.cpp @@ -53,7 +53,7 @@ void DecreaseViscosityCoProcessor::setViscosity(double step) grid->getBlocks(level, gridRank, blockVector); BOOST_FOREACH(Block3DPtr block, blockVector) { - LBMKernel3DPtr kernel =block->getKernel(); + LBMKernelPtr kernel =block->getKernel(); } } @@ -68,7 +68,7 @@ void DecreaseViscosityCoProcessor::setViscosity(double step) grid->getBlocks(level, gridRank, blockVector); BOOST_FOREACH(Block3DPtr block, blockVector) { - LBMKernel3DPtr kernel =block->getKernel(); + LBMKernelPtr kernel =block->getKernel(); if(kernel) { LBMReal collFactor = LBMSystem::calcCollisionFactor(nue, block->getLevel()); diff --git a/source/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.h b/source/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.h index 15e373d03..515b7bf8c 100644 --- a/source/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.h +++ b/source/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.h @@ -2,7 +2,7 @@ #define DecreaseViscosityCoProcessor_H #include "CoProcessor.h" -#include "D3Q27IntegrateValuesHelper.h" +#include "IntegrateValuesHelper.h" #include "LBMUnitConverter.h" #include "Communicator.h" diff --git a/source/VirtualFluidsCore/CoProcessors/InSituCatalystCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/InSituCatalystCoProcessor.cpp index 11e646bd5..fcf1d6f31 100644 --- a/source/VirtualFluidsCore/CoProcessors/InSituCatalystCoProcessor.cpp +++ b/source/VirtualFluidsCore/CoProcessors/InSituCatalystCoProcessor.cpp @@ -1,7 +1,7 @@ #ifdef VF_CATALYST #include "InSituCatalystCoProcessor.h" -#include <LBMKernelETD3Q27.h> +#include <LBMKernel.h> #include <D3Q27ETBCProcessor.h> #include <vector> #include <string> @@ -106,8 +106,8 @@ void InSituCatalystCoProcessor::addData(Block3DPtr block) UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); double dx = grid->getDeltaX(block); - LBMKernelETD3Q27Ptr kernel = boost::dynamic_pointer_cast<LBMKernelETD3Q27>(block->getKernel()); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); LBMReal f[D3Q27System::ENDF + 1]; LBMReal vx1, vx2, vx3, rho; @@ -222,8 +222,8 @@ void InSituCatalystCoProcessor::addVTKGridData(Block3DPtr block) UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); double dx = grid->getDeltaX(block); - LBMKernelETD3Q27Ptr kernel = boost::dynamic_pointer_cast<LBMKernelETD3Q27>(block->getKernel()); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); LBMReal f[D3Q27System::ENDF + 1]; LBMReal vx1, vx2, vx3, rho; @@ -259,7 +259,7 @@ void InSituCatalystCoProcessor::addVTKGridData(Block3DPtr block) maxX2 -= 2; maxX3 -= 2; - D3Q27BoundaryConditionPtr bcPtr; + BoundaryConditionsPtr bcPtr; int nr = points->GetNumberOfPoints(); double x[3]; diff --git a/source/VirtualFluidsCore/CoProcessors/InSituVTKCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/InSituVTKCoProcessor.cpp index 365ac50e5..e6ce83541 100644 --- a/source/VirtualFluidsCore/CoProcessors/InSituVTKCoProcessor.cpp +++ b/source/VirtualFluidsCore/CoProcessors/InSituVTKCoProcessor.cpp @@ -1,7 +1,7 @@ #ifdef VF_VTK #include "InSituVTKCoProcessor.h" -#include <LBMKernelETD3Q27.h> +#include <LBMKernel.h> #include <D3Q27ETBCProcessor.h> #include <vector> #include <string> @@ -132,8 +132,8 @@ void InSituVTKCoProcessor::addData( Block3DPtr block ) UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); double dx = grid->getDeltaX(block); - LBMKernelETD3Q27Ptr kernel = boost::dynamic_pointer_cast<LBMKernelETD3Q27>(block->getKernel()); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); LBMReal f[D3Q27System::ENDF+1]; LBMReal vx1,vx2,vx3,rho; @@ -177,7 +177,7 @@ void InSituVTKCoProcessor::addData( Block3DPtr block ) maxX2 -= 2; maxX3 -= 2; - D3Q27BoundaryConditionPtr bcPtr; + BoundaryConditionsPtr bcPtr; int nr = points->GetNumberOfPoints(); double x[3]; diff --git a/source/VirtualFluidsCore/LBM/D3Q27IntegrateValuesHelper.cpp b/source/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.cpp similarity index 88% rename from source/VirtualFluidsCore/LBM/D3Q27IntegrateValuesHelper.cpp rename to source/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.cpp index b8c798c34..1fe834ad0 100644 --- a/source/VirtualFluidsCore/LBM/D3Q27IntegrateValuesHelper.cpp +++ b/source/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.cpp @@ -1,16 +1,16 @@ -#include "D3Q27IntegrateValuesHelper.h" +#include "IntegrateValuesHelper.h" #include <boost/foreach.hpp> #include <numerics/geometry3d/GbCuboid3D.h> #include <numerics/geometry3d/CoordinateTransformation3D.h> #include <vector> -#include "LBMKernelETD3Q27.h" -#include "D3Q27ETBCProcessor.h" +#include "LBMKernel.h" +#include "BCProcessor.h" using namespace std; ////////////////////////////////////////////////////////////////////////// -D3Q27IntegrateValuesHelper::D3Q27IntegrateValuesHelper(Grid3DPtr grid, CommunicatorPtr comm, +IntegrateValuesHelper::IntegrateValuesHelper(Grid3DPtr grid, CommunicatorPtr comm, double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3) : @@ -25,7 +25,7 @@ D3Q27IntegrateValuesHelper::D3Q27IntegrateValuesHelper(Grid3DPtr grid, Communica init(-1); } ////////////////////////////////////////////////////////////////////////// -D3Q27IntegrateValuesHelper::D3Q27IntegrateValuesHelper(Grid3DPtr grid, CommunicatorPtr comm, +IntegrateValuesHelper::IntegrateValuesHelper(Grid3DPtr grid, CommunicatorPtr comm, double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, @@ -41,11 +41,11 @@ D3Q27IntegrateValuesHelper::D3Q27IntegrateValuesHelper(Grid3DPtr grid, Communica init(level); } ////////////////////////////////////////////////////////////////////////// -D3Q27IntegrateValuesHelper::~D3Q27IntegrateValuesHelper() +IntegrateValuesHelper::~IntegrateValuesHelper() { } ////////////////////////////////////////////////////////////////////////// -void D3Q27IntegrateValuesHelper::init(int level) +void IntegrateValuesHelper::init(int level) { root = comm->isRoot(); @@ -80,8 +80,8 @@ void D3Q27IntegrateValuesHelper::init(int level) orgX2 = val<2>(org); orgX3 = val<3>(org); - LBMKernelETD3Q27Ptr kernel = boost::dynamic_pointer_cast<LBMKernelETD3Q27>(block->getKernel()); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = boost::dynamic_pointer_cast<LBMKernel>(block->getKernel()); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); int ghostLayerWitdh = kernel->getGhostLayerWidth(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); double internX1, internX2, internX3; @@ -138,7 +138,7 @@ void D3Q27IntegrateValuesHelper::init(int level) } ////////////////////////////////////////////////////////////////////////// -void D3Q27IntegrateValuesHelper::prepare2DMatrix(int level) +void IntegrateValuesHelper::prepare2DMatrix(int level) { root = comm->isRoot(); @@ -176,8 +176,8 @@ void D3Q27IntegrateValuesHelper::prepare2DMatrix(int level) orgX2 = val<2>(org); orgX3 = val<3>(org); - LBMKernelETD3Q27Ptr kernel = boost::dynamic_pointer_cast<LBMKernelETD3Q27>(block->getKernel()); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); int ghostLayerWitdh = kernel->getGhostLayerWidth(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); double internX1, internX2, internX3; @@ -236,13 +236,13 @@ void D3Q27IntegrateValuesHelper::prepare2DMatrix(int level) } // calculation conventional rho, velocity and averaged data -void D3Q27IntegrateValuesHelper::calculateAV() +void IntegrateValuesHelper::calculateAV() { clearData(); BOOST_FOREACH(CalcNodes cn, cnodes) { - LBMKernel3DPtr kernel = cn.block->getKernel(); + LBMKernelPtr kernel = cn.block->getKernel(); AverageValuesArray3DPtr averagedValues = kernel->getDataSet()->getAverageValues(); BOOST_FOREACH(UbTupleInt3 node, cn.nodes) @@ -297,7 +297,7 @@ void D3Q27IntegrateValuesHelper::calculateAV() } } // calculation conventional rho, velocity and averaged data -void D3Q27IntegrateValuesHelper::calculateAV2() +void IntegrateValuesHelper::calculateAV2() { saVx = 0; saVy = 0; @@ -345,7 +345,7 @@ void D3Q27IntegrateValuesHelper::calculateAV2() BOOST_FOREACH(CalcNodes cn, cnodes) { - LBMKernel3DPtr kernel = cn.block->getKernel(); + LBMKernelPtr kernel = cn.block->getKernel(); AverageValuesArray3DPtr averagedVelocity = kernel->getDataSet()->getAverageVelocity(); AverageValuesArray3DPtr averagedFluctuations = kernel->getDataSet()->getAverageFluctuations(); AverageValuesArray3DPtr averagedTriplecorrelations = kernel->getDataSet()->getAverageTriplecorrelations(); @@ -454,7 +454,7 @@ void D3Q27IntegrateValuesHelper::calculateAV2() } } ////////////////////////////////////////////////////////////////////////// -void D3Q27IntegrateValuesHelper::calculateMQ() +void IntegrateValuesHelper::calculateMQ() { LBMReal f[D3Q27System::ENDF + 1]; LBMReal vx1, vx2, vx3, rho; @@ -467,7 +467,7 @@ void D3Q27IntegrateValuesHelper::calculateMQ() BOOST_FOREACH(CalcNodes cn, cnodes) { - LBMKernel3DPtr kernel = cn.block->getKernel(); + LBMKernelPtr kernel = cn.block->getKernel(); LBMReal dx = 1.0 / (LBMReal)(1 << cn.block->getLevel()); LBMReal cellVolume = dx*dx*dx; @@ -480,7 +480,7 @@ void D3Q27IntegrateValuesHelper::calculateMQ() calcMacros = &D3Q27System::calcIncompMacroscopicValues; } - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); int ghostLayerWitdh = kernel->getGhostLayerWidth(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); BOOST_FOREACH(UbTupleInt3 node, cn.nodes) @@ -519,7 +519,7 @@ void D3Q27IntegrateValuesHelper::calculateMQ() } } ////////////////////////////////////////////////////////////////////////// -void D3Q27IntegrateValuesHelper::clearData() +void IntegrateValuesHelper::clearData() { sRho = 0.0; sVx1 = 0.0; @@ -538,22 +538,22 @@ void D3Q27IntegrateValuesHelper::clearData() sTSx1x3 = 0.0; } ////////////////////////////////////////////////////////////////////////// -LBMReal D3Q27IntegrateValuesHelper::getNumberOfFluidsNodes() +LBMReal IntegrateValuesHelper::getNumberOfFluidsNodes() { return this->numberOfFluidsNodes; } ////////////////////////////////////////////////////////////////////////// -LBMReal D3Q27IntegrateValuesHelper::getNumberOfSolidNodes() +LBMReal IntegrateValuesHelper::getNumberOfSolidNodes() { return this->numberOfSolidNodes; } ////////////////////////////////////////////////////////////////////////// -GbCuboid3DPtr D3Q27IntegrateValuesHelper::getBoundingBox() +GbCuboid3DPtr IntegrateValuesHelper::getBoundingBox() { return this->boundingBox; } ////////////////////////////////////////////////////////////////////////// -std::vector<D3Q27IntegrateValuesHelper::CalcNodes> D3Q27IntegrateValuesHelper::getCNodes() +std::vector<IntegrateValuesHelper::CalcNodes> IntegrateValuesHelper::getCNodes() { return cnodes; } diff --git a/source/VirtualFluidsCore/LBM/D3Q27IntegrateValuesHelper.h b/source/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.h similarity index 85% rename from source/VirtualFluidsCore/LBM/D3Q27IntegrateValuesHelper.h rename to source/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.h index 0ba14b1ac..3c1e1a204 100644 --- a/source/VirtualFluidsCore/LBM/D3Q27IntegrateValuesHelper.h +++ b/source/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.h @@ -1,5 +1,5 @@ -#ifndef D3Q27INTEGRATEVALUESHELPER_H -#define D3Q27INTEGRATEVALUESHELPER_H +#ifndef INTEGRATEVALUESHELPER_H +#define INTEGRATEVALUESHELPER_H #include "Grid3D.h" #include "D3Q27System.h" @@ -19,10 +19,10 @@ // UbTupleInt3 nodes; //}; -class D3Q27IntegrateValuesHelper; -typedef boost::shared_ptr<D3Q27IntegrateValuesHelper> D3Q27IntegrateValuesHelperPtr; +class IntegrateValuesHelper; +typedef boost::shared_ptr<IntegrateValuesHelper> IntegrateValuesHelperPtr; -class D3Q27IntegrateValuesHelper +class IntegrateValuesHelper { public: struct CalcNodes @@ -37,13 +37,13 @@ public: UbTupleInt3 node; }; public: - D3Q27IntegrateValuesHelper(Grid3DPtr grid, CommunicatorPtr comm, + IntegrateValuesHelper(Grid3DPtr grid, CommunicatorPtr comm, double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3); - D3Q27IntegrateValuesHelper(Grid3DPtr grid, CommunicatorPtr comm, + IntegrateValuesHelper(Grid3DPtr grid, CommunicatorPtr comm, double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, int level); - virtual ~D3Q27IntegrateValuesHelper(); + virtual ~IntegrateValuesHelper(); void calculateMQ(); void calculateAV(); diff --git a/source/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.cpp index c91876a37..8210430d2 100644 --- a/source/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.cpp +++ b/source/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.cpp @@ -1,5 +1,5 @@ #include "LineTimeSeriesCoProcessor.h" -#include "D3Q27ETBCProcessor.h" +#include "BCProcessor.h" #include "WbWriterVtkXmlASCII.h" LineTimeSeriesCoProcessor::LineTimeSeriesCoProcessor(Grid3DPtr grid, UbSchedulerPtr s, const std::string& path, GbLine3DPtr line, int level, CommunicatorPtr comm) : @@ -27,12 +27,12 @@ LineTimeSeriesCoProcessor::LineTimeSeriesCoProcessor(Grid3DPtr grid, UbScheduler double orgX3 = trafo->getX3CoordinateOffset(); - int x1min = (int)(line->getX1Minimum()-orgX1)/dx; - int x1max = (int)(line->getX1Maximum()-orgX1)/dx; - int x2min = (int)(line->getX2Minimum()-orgX2)/dx; - int x2max = (int)(line->getX2Maximum()-orgX2)/dx; - int x3min = (int)(line->getX3Minimum()-orgX3)/dx; - int x3max = (int)(line->getX3Maximum()-orgX3)/dx; + int x1min = (int)((line->getX1Minimum()-orgX1)/dx); + int x1max = (int)((line->getX1Maximum()-orgX1)/dx); + int x2min = (int)((line->getX2Minimum()-orgX2)/dx); + int x2max = (int)((line->getX2Maximum()-orgX2)/dx); + int x3min = (int)((line->getX3Minimum()-orgX3)/dx); + int x3max = (int)((line->getX3Maximum()-orgX3)/dx); UbTupleInt3 blockNx = grid->getBlockNX(); @@ -118,7 +118,7 @@ void LineTimeSeriesCoProcessor::collectData() { if (block->getRank()==gridRank) { - LBMKernel3DPtr kernel = block->getKernel(); + LBMKernelPtr kernel = block->getKernel(); calcMacros = NULL; if (kernel->getCompressible()) { diff --git a/source/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.cpp index 1c6774639..035bd7505 100644 --- a/source/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.cpp +++ b/source/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.cpp @@ -14,7 +14,7 @@ using namespace std; PressureDifferenceCoProcessor::PressureDifferenceCoProcessor(Grid3DPtr grid, UbSchedulerPtr s, const std::string& path, - D3Q27IntegrateValuesHelperPtr h1, D3Q27IntegrateValuesHelperPtr h2, + IntegrateValuesHelperPtr h1, IntegrateValuesHelperPtr h2, LBMReal rhoReal, LBMReal uReal, LBMReal uLB, CommunicatorPtr comm) diff --git a/source/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.h b/source/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.h index b966ecf01..136f2b060 100644 --- a/source/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.h +++ b/source/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.h @@ -9,20 +9,20 @@ #define D3Q27PRESSUREDIFFERENCECoProcessor_H #include "CoProcessor.h" -#include "D3Q27IntegrateValuesHelper.h" +#include "IntegrateValuesHelper.h" #include "LBMUnitConverter.h" #include "Communicator.h" class PressureDifferenceCoProcessor: public CoProcessor { public: PressureDifferenceCoProcessor(Grid3DPtr grid, UbSchedulerPtr s, const std::string& path, - D3Q27IntegrateValuesHelperPtr h1, D3Q27IntegrateValuesHelperPtr h2, + IntegrateValuesHelperPtr h1, IntegrateValuesHelperPtr h2, LBMReal rhoReal, LBMReal uReal, LBMReal uLB, /*const LBMUnitConverterPtr conv,*/ CommunicatorPtr comm); virtual ~PressureDifferenceCoProcessor(); void process(double step); protected: - D3Q27IntegrateValuesHelperPtr h1, h2; + IntegrateValuesHelperPtr h1, h2; std::string path; LBMUnitConverterPtr conv; void collectData(double step); diff --git a/source/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.cpp index 58c020145..e70c646af 100644 --- a/source/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.cpp +++ b/source/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.cpp @@ -1,7 +1,7 @@ #include "QCriterionCoProcessor.h" -#include "LBMKernel3D.h" -#include "LBMKernelETD3Q27.h" -#include "D3Q27ETBCProcessor.h" +#include "LBMKernel.h" +#include "LBMKernel.h" +#include "BCProcessor.h" #include <vector> #include <string> #include <boost/foreach.hpp> @@ -112,8 +112,8 @@ void QCriterionCoProcessor::addData(const Block3DPtr block) data.resize(datanames.size()); - LBMKernelETD3Q27Ptr kernel = boost::dynamic_pointer_cast<LBMKernelETD3Q27>(block->getKernel()); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); int SWB,SEB,NEB,NWB,SWT,SET,NET,NWT; @@ -218,8 +218,8 @@ void QCriterionCoProcessor::addData(const Block3DPtr block) void QCriterionCoProcessor::getNeighborVelocities(int offx, int offy, int offz, int ix1, int ix2, int ix3, const Block3DPtr block, LBMReal* vE, LBMReal* vW) { - LBMKernelETD3Q27Ptr kernel = boost::dynamic_pointer_cast<LBMKernelETD3Q27>(block->getKernel()); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); int minX1 = 0; @@ -235,7 +235,7 @@ void QCriterionCoProcessor::getNeighborVelocities(int offx, int offy, int offz, maxX3 -= 2; bool checkInterpolation=true; bool neighNodeIsBC=false; - D3Q27BoundaryConditionPtr bcPtr; + BoundaryConditionsPtr bcPtr; int rankSelf= block->getRank(); if (!(offx+offy+offz)==1) throw UbException(UB_EXARGS,"getNeighborVelocities called for diagonal directions!"); @@ -297,8 +297,8 @@ void QCriterionCoProcessor::getNeighborVelocities(int offx, int offy, int offz, if (checkInterpolation==false || neighNodeIsBC) { - LBMKernel3DPtr kernelW = blockNeighW->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArrayW = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernelW->getBCProcessor())->getBCArray(); + LBMKernelPtr kernelW = blockNeighW->getKernel(); + BCArray3D& bcArrayW = kernelW->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributionsW = kernelW->getDataSet()->getFdistributions(); LBMReal fW2[27]; LBMReal fW[27]; @@ -327,8 +327,8 @@ void QCriterionCoProcessor::getNeighborVelocities(int offx, int offy, int offz, } else { - LBMKernel3DPtr kernelW = blockNeighW->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArrayW = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernelW->getBCProcessor())->getBCArray(); + LBMKernelPtr kernelW = blockNeighW->getKernel(); + BCArray3D& bcArrayW = kernelW->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributionsW = kernelW->getDataSet()->getFdistributions(); LBMReal fW[27]; diff --git a/source/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.cpp index 819b9f1e8..bab963e15 100644 --- a/source/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.cpp +++ b/source/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.cpp @@ -1,5 +1,5 @@ #include "ShearStressCoProcessor.h" -#include "D3Q27ETBCProcessor.h" +#include "BCProcessor.h" #include "WbWriterVtkXmlASCII.h" @@ -139,8 +139,8 @@ void ShearStressCoProcessor::calculateShearStress(double timeStep) Block3DPtr block = t.first; std::set< std::vector<int> >& transNodeIndicesSet = t.second; - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); ShearStressValuesArray3DPtr ssv = kernel->getDataSet()->getShearStressValues(); @@ -256,8 +256,8 @@ void ShearStressCoProcessor::addData() UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); double dx = grid->getDeltaX(block); - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); ShearStressValuesArray3DPtr ssv = kernel->getDataSet()->getShearStressValues(); @@ -362,8 +362,8 @@ void ShearStressCoProcessor::resetData(double step) UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); double dx = grid->getDeltaX(block); - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); ShearStressValuesArray3DPtr ssv = kernel->getDataSet()->getShearStressValues(); @@ -416,45 +416,45 @@ void ShearStressCoProcessor::findPlane(int ix1,int ix2,int ix3,Grid3DPtr grid,Bl double x1plane=0.0,y1plane=0.0,z1plane=0.0; double x2plane=0.0,y2plane=0.0,z2plane=0.0; double x3plane=0.0,y3plane=0.0,z3plane=0.0; - D3Q27BoundaryConditionPtr bcPtr; + BoundaryConditionsPtr bcPtr; double dx = grid->getDeltaX(block); - LBMKernel3DPtr kernel = block->getKernel(); + LBMKernelPtr kernel = block->getKernel(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); - BCArray3D<D3Q27BoundaryCondition> bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); bcPtr=bcArray.getBC(ix1,ix2,ix3); int x,y,z; - if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1, ix2, ix3)) { x = ix1;y = ix2;z = ix3;} - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1 , ix2-1, ix3 )) { x = ix1+0; y = ix2-1; z = ix3+0;}//S - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1 , ix2 , ix3-1)) { x = ix1+0; y = ix2+0; z = ix3-1;}//B - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1-1, ix2 , ix3 )) { x = ix1-1; y = ix2+0; z = ix3+0;}//w - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1 , ix2-1, ix3-1)) { x = ix1+0; y = ix2-1; z = ix3-1;}//BS - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1-1, ix2 , ix3-1)) { x = ix1-1; y = ix2+0; z = ix3-1;}//BW - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1-1, ix2-1, ix3 )) { x = ix1-1; y = ix2-1; z = ix3+0;}//SW - - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1-1, ix2-1, ix3-1)) { x = ix1-1; y = ix2-1; z = ix3-1;}//BSW - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1+1, ix2 , ix3 )) { x = ix1+1; y = ix2+0; z = ix3+0;}//E - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1 , ix2+1, ix3 )) { x = ix1+0; y = ix2+1; z = ix3+0;}//N - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1 , ix2 , ix3+1)) { x = ix1+0; y = ix2+0; z = ix3+1;}//T - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1+1, ix2+1, ix3 )) { x = ix1+1; y = ix2+1; z = ix3+0;}//NE - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1+1, ix2 , ix3+1)) { x = ix1+1; y = ix2+0; z = ix3+1;}//TE - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1 , ix2+1, ix3+1)) { x = ix1+0; y = ix2+1; z = ix3+1;}//TN - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1+1, ix2+1, ix3+1)) { x = ix1+1; y = ix2+1; z = ix3+1;}//TNE - - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1+1, ix2-1, ix3 )) { x = ix1+1; y = ix2-1; z = ix3+0;}//SE - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1-1, ix2+1, ix3 )) { x = ix1-1; y = ix2+1; z = ix3+0;}//NW - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1+1, ix2 , ix3-1)) { x = ix1+1; y = ix2+0; z = ix3-1;}//BE - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1-1, ix2 , ix3+1)) { x = ix1-1; y = ix2+0; z = ix3+1;}//TW - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1+0, ix2+1, ix3-1)) { x = ix1+0; y = ix2+1; z = ix3-1;}//BN - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1+0, ix2-1, ix3+1)) { x = ix1+0; y = ix2-1; z = ix3+1;}//TS - - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1-1, ix2+1, ix3+1)) { x = ix1-1; y = ix2+1; z = ix3+1;}//TNW - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1+1, ix2-1, ix3+1)) { x = ix1+1; y = ix2-1; z = ix3+1;}//TSE - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1-1, ix2-1, ix3+1)) { x = ix1-1; y = ix2-1; z = ix3+1;}//TSW - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1+1, ix2+1, ix3-1)) { x = ix1+1; y = ix2+1; z = ix3-1;}//BNE - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1-1, ix2+1, ix3-1)) { x = ix1-1; y = ix2+1; z = ix3-1;}//BNW - else if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, ix1+1, ix2-1, ix3-1)) { x = ix1+1; y = ix2-1; z = ix3-1;}//BSE + if(InterpolationProcessor::iCellHasSolid(bcArray, ix1, ix2, ix3)) { x = ix1;y = ix2;z = ix3;} + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1 , ix2-1, ix3 )) { x = ix1+0; y = ix2-1; z = ix3+0;}//S + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1 , ix2 , ix3-1)) { x = ix1+0; y = ix2+0; z = ix3-1;}//B + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1-1, ix2 , ix3 )) { x = ix1-1; y = ix2+0; z = ix3+0;}//w + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1 , ix2-1, ix3-1)) { x = ix1+0; y = ix2-1; z = ix3-1;}//BS + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1-1, ix2 , ix3-1)) { x = ix1-1; y = ix2+0; z = ix3-1;}//BW + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1-1, ix2-1, ix3 )) { x = ix1-1; y = ix2-1; z = ix3+0;}//SW + + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1-1, ix2-1, ix3-1)) { x = ix1-1; y = ix2-1; z = ix3-1;}//BSW + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1+1, ix2 , ix3 )) { x = ix1+1; y = ix2+0; z = ix3+0;}//E + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1 , ix2+1, ix3 )) { x = ix1+0; y = ix2+1; z = ix3+0;}//N + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1 , ix2 , ix3+1)) { x = ix1+0; y = ix2+0; z = ix3+1;}//T + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1+1, ix2+1, ix3 )) { x = ix1+1; y = ix2+1; z = ix3+0;}//NE + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1+1, ix2 , ix3+1)) { x = ix1+1; y = ix2+0; z = ix3+1;}//TE + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1 , ix2+1, ix3+1)) { x = ix1+0; y = ix2+1; z = ix3+1;}//TN + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1+1, ix2+1, ix3+1)) { x = ix1+1; y = ix2+1; z = ix3+1;}//TNE + + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1+1, ix2-1, ix3 )) { x = ix1+1; y = ix2-1; z = ix3+0;}//SE + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1-1, ix2+1, ix3 )) { x = ix1-1; y = ix2+1; z = ix3+0;}//NW + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1+1, ix2 , ix3-1)) { x = ix1+1; y = ix2+0; z = ix3-1;}//BE + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1-1, ix2 , ix3+1)) { x = ix1-1; y = ix2+0; z = ix3+1;}//TW + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1+0, ix2+1, ix3-1)) { x = ix1+0; y = ix2+1; z = ix3-1;}//BN + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1+0, ix2-1, ix3+1)) { x = ix1+0; y = ix2-1; z = ix3+1;}//TS + + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1-1, ix2+1, ix3+1)) { x = ix1-1; y = ix2+1; z = ix3+1;}//TNW + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1+1, ix2-1, ix3+1)) { x = ix1+1; y = ix2-1; z = ix3+1;}//TSE + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1-1, ix2-1, ix3+1)) { x = ix1-1; y = ix2-1; z = ix3+1;}//TSW + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1+1, ix2+1, ix3-1)) { x = ix1+1; y = ix2+1; z = ix3-1;}//BNE + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1-1, ix2+1, ix3-1)) { x = ix1-1; y = ix2+1; z = ix3-1;}//BNW + else if(InterpolationProcessor::iCellHasSolid(bcArray, ix1+1, ix2-1, ix3-1)) { x = ix1+1; y = ix2-1; z = ix3-1;}//BSE else {{UB_THROW( UbException(UB_EXARGS,"there is no cell ix1="+UbSystem::toString(ix1)+"ix2="+UbSystem::toString(ix2)+"ix3="+UbSystem::toString(ix3)+"GlobalID="+UbSystem::toString(block->getGlobalID())+"dx="+UbSystem::toString(dx) @@ -471,7 +471,7 @@ void ShearStressCoProcessor::findPlane(int ix1,int ix2,int ix3,Grid3DPtr grid,Bl ) ) ;}} - if(D3Q27InterpolationProcessor::iCellHasSolid(bcArray, x, y, z)) + if(InterpolationProcessor::iCellHasSolid(bcArray, x, y, z)) { for(int i = x; i <= x + 1; i++){ for(int j = y; j <= y + 1; j++){ @@ -485,7 +485,7 @@ void ShearStressCoProcessor::findPlane(int ix1,int ix2,int ix3,Grid3DPtr grid,Bl if(!bcArray.isSolid(i, j, k)) { - D3Q27BoundaryConditionPtr bcPtrIn=bcArray.getBC(i,j,k); + BoundaryConditionsPtr bcPtrIn=bcArray.getBC(i,j,k); if(bcPtrIn) { for(int fdir=D3Q27System::FSTARTDIR; fdir<=D3Q27System::FENDDIR; fdir++) @@ -590,7 +590,7 @@ void ShearStressCoProcessor::findPlane(int ix1,int ix2,int ix3,Grid3DPtr grid,Bl } //////////////////////////////////////////////////////////////////////////////////////////////////////// -bool ShearStressCoProcessor::checkUndefindedNodes( BCArray3D<D3Q27BoundaryCondition>& bcArray,int ix1,int ix2,int ix3) +bool ShearStressCoProcessor::checkUndefindedNodes( BCArray3D& bcArray,int ix1,int ix2,int ix3) { for(int i = ix1; i <= ix1 + 1; i++){ for(int j = ix2; j <= ix2 + 1; j++){ @@ -618,8 +618,8 @@ void ShearStressCoProcessor::initDistance() UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); double dx = grid->getDeltaX(block); - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); ShearStressValuesArray3DPtr ssv = kernel->getDataSet()->getShearStressValues(); @@ -644,7 +644,7 @@ void ShearStressCoProcessor::initDistance() if(bcArray.isFluid(ix1,ix2,ix3) ) { - D3Q27BoundaryConditionPtr bc = bcArray.getBC(ix1,ix2,ix3); + BoundaryConditionsPtr bc = bcArray.getBC(ix1,ix2,ix3); if((bc->hasDensityBoundary()||bc->hasVelocityBoundary()))continue; int numberOfCorner=0; diff --git a/source/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.h b/source/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.h index 15355dc4b..7a656b39c 100644 --- a/source/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.h +++ b/source/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.h @@ -4,7 +4,7 @@ #include "CoProcessor.h" #include "Communicator.h" #include "D3Q27Interactor.h" -#include "D3Q27InterpolationProcessor.h" +#include "InterpolationProcessor.h" #include "WbWriter.h" #include <boost/shared_ptr.hpp> @@ -39,7 +39,7 @@ protected: void clearData(); void reset(double step); void findPlane(int ix1,int ix2,int ix3,Grid3DPtr grid,Block3DPtr block,double &A,double &B,double &C,double &D,double &ii); - bool checkUndefindedNodes( BCArray3D<D3Q27BoundaryCondition>& bcArray,int ix1,int ix2,int ix3); + bool checkUndefindedNodes( BCArray3D& bcArray,int ix1,int ix2,int ix3); void initDistance(); private: std::vector<UbTupleFloat3> nodes; diff --git a/source/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp index 107e2330f..69f626c60 100644 --- a/source/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp +++ b/source/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp @@ -1,6 +1,6 @@ #include "TimeAveragedValuesCoProcessor.h" -#include "LBMKernel3D.h" -#include "D3Q27ETBCProcessor.h" +#include "LBMKernel.h" +#include "BCProcessor.h" #include <vector> #include <sstream> #include <string> @@ -240,8 +240,8 @@ void TimeAveragedValuesCoProcessor::addData(const Block3DPtr block) data.resize(datanames.size()); - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); AverageValuesArray3DPtr av = kernel->getDataSet()->getAverageVelocity(); AverageValuesArray3DPtr af = kernel->getDataSet()->getAverageFluctuations(); @@ -364,8 +364,8 @@ void TimeAveragedValuesCoProcessor::calculateAverageValues(double timeSteps) Block3DPtr block = blockVector[level][i]; if (block) { - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); AverageValuesArray3DPtr av = kernel->getDataSet()->getAverageVelocity(); AverageValuesArray3DPtr af = kernel->getDataSet()->getAverageFluctuations(); @@ -478,8 +478,8 @@ void TimeAveragedValuesCoProcessor::calculateSubtotal(double step) Block3DPtr block = blockVector[level][i]; if (block) { - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); AverageValuesArray3DPtr av = kernel->getDataSet()->getAverageVelocity(); AverageValuesArray3DPtr af = kernel->getDataSet()->getAverageFluctuations(); @@ -605,7 +605,7 @@ void TimeAveragedValuesCoProcessor::planarAverage(double step) for (double j = start; j <stop; j += dx) { - D3Q27IntegrateValuesHelper intValHelp(grid, comm, + IntegrateValuesHelper intValHelp(grid, comm, bounds[0], bounds[1], j, bounds[3], bounds[4], j + dx, level); diff --git a/source/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.h b/source/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.h index 939aaab07..e7373c5af 100644 --- a/source/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.h +++ b/source/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.h @@ -6,7 +6,7 @@ #include "Block3D.h" #include "LBMUnitConverter.h" #include "Communicator.h" -#include "D3Q27IntegrateValuesHelper.h" +#include "IntegrateValuesHelper.h" #include "WbWriter.h" #include <boost/shared_ptr.hpp> diff --git a/source/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.cpp index 74c8a1039..e66f3a6ce 100644 --- a/source/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.cpp +++ b/source/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.cpp @@ -14,7 +14,7 @@ using namespace std; TimeseriesCoProcessor::TimeseriesCoProcessor(Grid3DPtr grid, UbSchedulerPtr s, - D3Q27IntegrateValuesHelperPtr h1, + IntegrateValuesHelperPtr h1, const std::string& path, CommunicatorPtr comm) : CoProcessor(grid, s), h1(h1), diff --git a/source/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.h b/source/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.h index bbea080ee..337665d8f 100644 --- a/source/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.h +++ b/source/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.h @@ -9,7 +9,7 @@ #define TimeseriesCoProcessor_H #include "CoProcessor.h" -#include "D3Q27IntegrateValuesHelper.h" +#include "IntegrateValuesHelper.h" #include "LBMUnitConverter.h" #include "Communicator.h" @@ -26,14 +26,14 @@ typedef boost::shared_ptr<TimeseriesCoProcessor> TimeseriesCoProcessorPtr; class TimeseriesCoProcessor: public CoProcessor { public: TimeseriesCoProcessor(Grid3DPtr grid, UbSchedulerPtr s, - D3Q27IntegrateValuesHelperPtr h1, + IntegrateValuesHelperPtr h1, const std::string& path, CommunicatorPtr comm); virtual ~TimeseriesCoProcessor(); //! calls collectData. void process(double step); protected: //! object that can compute spacial average values in 3D-subdomain. - D3Q27IntegrateValuesHelperPtr h1; + IntegrateValuesHelperPtr h1; void collectData(double step); CommunicatorPtr comm; private: diff --git a/source/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.cpp index 7028ab648..9d86e3eb7 100644 --- a/source/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.cpp +++ b/source/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.cpp @@ -1,6 +1,6 @@ #include "TurbulenceIntensityCoProcessor.h" -#include "LBMKernel3D.h" -#include "D3Q27ETBCProcessor.h" +#include "LBMKernel.h" +#include "BCProcessor.h" #include <vector> #include <string> #include <boost/foreach.hpp> @@ -114,8 +114,8 @@ void TurbulenceIntensityCoProcessor::addData(const Block3DPtr block) data.resize(datanames.size()); - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); AverageValuesArray3DPtr av = kernel->getDataSet()->getAverageValues(); //int ghostLayerWidth = kernel->getGhostLayerWidth(); @@ -203,8 +203,8 @@ void TurbulenceIntensityCoProcessor::calculateAverageValues(double timeStep) { if (block) { - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); AverageValuesArray3DPtr av = kernel->getDataSet()->getAverageValues(); diff --git a/source/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.cpp new file mode 100644 index 000000000..2d3b96ee5 --- /dev/null +++ b/source/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.cpp @@ -0,0 +1,219 @@ +#include "WriteBoundaryConditionsCoProcessor.h" +#include "LBMKernel.h" +#include "BCProcessor.h" +#include <vector> +#include <string> +#include <boost/foreach.hpp> +#include "basics/writer/WbWriterVtkXmlASCII.h" + +using namespace std; + +WriteBoundaryConditionsCoProcessor::WriteBoundaryConditionsCoProcessor() +{ + +} +////////////////////////////////////////////////////////////////////////// +WriteBoundaryConditionsCoProcessor::WriteBoundaryConditionsCoProcessor(Grid3DPtr grid, UbSchedulerPtr s, + const std::string& path, WbWriter* const writer, + LBMUnitConverterPtr conv, CommunicatorPtr comm) + : CoProcessor(grid, s), + path(path), + writer(writer), + conv(conv), + comm(comm) +{ + gridRank = comm->getProcessID(); + minInitLevel = this->grid->getCoarsestInitializedLevel(); + maxInitLevel = this->grid->getFinestInitializedLevel(); + + blockVector.resize(maxInitLevel+1); + + for (int level = minInitLevel; level<=maxInitLevel; level++) + { + grid->getBlocks(level, gridRank, true, blockVector[level]); + } +} +////////////////////////////////////////////////////////////////////////// +void WriteBoundaryConditionsCoProcessor::process(double step) +{ + if (scheduler->isDue(step)) + collectData(step); + + UBLOG(logDEBUG3, "WriteBoundaryConditionsCoProcessor::update:"<<step); +} +////////////////////////////////////////////////////////////////////////// +void WriteBoundaryConditionsCoProcessor::collectData(double step) +{ + int istep = static_cast<int>(step); + + for (int level = minInitLevel; level<=maxInitLevel; level++) + { + BOOST_FOREACH(Block3DPtr block, blockVector[level]) + { + if (block) + { + addDataGeo(block); + } + } + } + + string pfilePath, partPath, subfolder, cfilePath; + + subfolder = "bc"+UbSystem::toString(istep); + pfilePath = path+"/bc/"+subfolder; + cfilePath = path+"/bc/bc_collection"; + partPath = pfilePath+"/bc"+UbSystem::toString(gridRank)+"_"+UbSystem::toString(istep); + + + string partName = writer->writeOctsWithNodeData(partPath, nodes, cells, datanames, data); + size_t found = partName.find_last_of("/"); + string piece = partName.substr(found+1); + piece = subfolder+"/"+piece; + + vector<string> cellDataNames; + vector<string> pieces = comm->gather(piece); + if (comm->getProcessID()==comm->getRoot()) + { + string pname = WbWriterVtkXmlASCII::getInstance()->writeParallelFile(pfilePath, pieces, datanames, cellDataNames); + found = pname.find_last_of("/"); + piece = pname.substr(found+1); + + vector<string> filenames; + filenames.push_back(piece); + if (step==CoProcessor::scheduler->getMinBegin()) + { + WbWriterVtkXmlASCII::getInstance()->writeCollection(cfilePath, filenames, istep, false); + } + else + { + WbWriterVtkXmlASCII::getInstance()->addFilesToCollection(cfilePath, filenames, istep, false); + } + UBLOG(logINFO, "WriteBoundaryConditionsCoProcessor step: "<<istep); + } + + clearData(); +} +////////////////////////////////////////////////////////////////////////// +void WriteBoundaryConditionsCoProcessor::clearData() +{ + nodes.clear(); + cells.clear(); + datanames.clear(); + data.clear(); +} +////////////////////////////////////////////////////////////////////////// +void WriteBoundaryConditionsCoProcessor::addDataGeo(Block3DPtr block) +{ + UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); + UbTupleDouble3 blockLengths = grid->getBlockLengths(block); + UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); + double dx = grid->getDeltaX(block); + + double level = (double)block->getLevel(); + + //Diese Daten werden geschrieben: + datanames.resize(0); + datanames.push_back("Boundary Conditions"); + datanames.push_back("Geometry"); + datanames.push_back("Level"); + //datanames.push_back("Interface CF"); + + data.resize(datanames.size()); + + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); + + //knotennummerierung faengt immer bei 0 an! + int SWB, SEB, NEB, NWB, SWT, SET, NET, NWT; + + int minX1 = 0; + int minX2 = 0; + int minX3 = 0; + + int maxX1 = (int)bcArray.getNX1(); + int maxX2 = (int)bcArray.getNX2(); + int maxX3 = (int)bcArray.getNX3(); + + //nummern vergeben und node vector erstellen + daten sammeln + CbArray3D<int> nodeNumbers((int)maxX1, (int)maxX2, (int)maxX3, -1); + //D3Q27BoundaryConditionPtr bcPtr; + int nr = (int)nodes.size(); + + maxX1 -= 1; + maxX2 -= 1; + maxX3 -= 1; + + for (size_t ix3 = minX3; ix3<=maxX3; ix3++) + { + for (size_t ix2 = minX2; ix2<=maxX2; ix2++) + { + for (size_t ix1 = minX1; ix1<=maxX1; ix1++) + { + if (!bcArray.isUndefined(ix1, ix2, ix3)) + { + //int index = 0; + nodeNumbers(ix1, ix2, ix3) = nr++; + nodes.push_back(makeUbTuple(float(val<1>(org)-val<1>(nodeOffset)+ix1*dx), + float(val<2>(org)-val<2>(nodeOffset)+ix2*dx), + float(val<3>(org)-val<3>(nodeOffset)+ix3*dx))); + + if (!bcArray.hasBC(ix1, ix2, ix3)) + data[0].push_back(0.0); + else if (bcArray.getBC(ix1, ix2, ix3)->hasNoSlipBoundary()) + data[0].push_back(1.0); + else if (bcArray.getBC(ix1, ix2, ix3)->hasVelocityBoundary()) + data[0].push_back(2.0); + else if (bcArray.getBC(ix1, ix2, ix3)->hasDensityBoundary()) + data[0].push_back(3.0); + else if (bcArray.getBC(ix1, ix2, ix3)->hasSlipBoundary()) + data[0].push_back(4.0); + else + data[0].push_back(5.0); + + if (bcArray.isSolid(ix1, ix2, ix3)) + data[1].push_back(1.0); + else + data[1].push_back(0.0); + + data[2].push_back(level); + + //if (bcArray.isInterfaceCF(ix1, ix2, ix3)) + //{ + // data[3].push_back(1.0); + //} + //else + //{ + // data[3].push_back(0.0); + //} + + } + } + } + } + + maxX1 -= 1; + maxX2 -= 1; + maxX3 -= 1; + + //cell vector erstellen + for (int ix3 = minX3; ix3<=maxX3; ix3++) + { + for (int ix2 = minX2; ix2<=maxX2; ix2++) + { + for (int ix1 = minX1; ix1<=maxX1; ix1++) + { + if ((SWB = nodeNumbers(ix1, ix2, ix3))>=0 + &&(SEB = nodeNumbers(ix1+1, ix2, ix3))>=0 + &&(NEB = nodeNumbers(ix1+1, ix2+1, ix3))>=0 + &&(NWB = nodeNumbers(ix1, ix2+1, ix3))>=0 + &&(SWT = nodeNumbers(ix1, ix2, ix3+1))>=0 + &&(SET = nodeNumbers(ix1+1, ix2, ix3+1))>=0 + &&(NET = nodeNumbers(ix1+1, ix2+1, ix3+1))>=0 + &&(NWT = nodeNumbers(ix1, ix2+1, ix3+1))>=0) + { + cells.push_back(makeUbTuple(SWB, SEB, NEB, NWB, SWT, SET, NET, NWT)); + } + } + } + } +} diff --git a/source/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.h b/source/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.h new file mode 100644 index 000000000..5fa07449d --- /dev/null +++ b/source/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.h @@ -0,0 +1,58 @@ +#ifndef WriteBoundaryConditionsCoProcessor_H +#define WriteBoundaryConditionsCoProcessor_H + +#include "CoProcessor.h" +#include "Grid3D.h" +#include "Block3D.h" +#include "LBMUnitConverter.h" +#include "Communicator.h" +#include "WbWriter.h" + +#include <boost/shared_ptr.hpp> +class WriteBoundaryConditionsCoProcessor; +typedef boost::shared_ptr<WriteBoundaryConditionsCoProcessor> WriteBoundaryConditionsCoProcessorPtr; + +class WriteBoundaryConditionsCoProcessor : public CoProcessor +{ +public: + WriteBoundaryConditionsCoProcessor(); + WriteBoundaryConditionsCoProcessor(Grid3DPtr grid, UbSchedulerPtr s, + const std::string& path, WbWriter* const writer, + LBMUnitConverterPtr conv, CommunicatorPtr comm); + ~WriteBoundaryConditionsCoProcessor() {} + void process(double step); +protected: + void collectData(double step); + void addDataGeo(Block3DPtr block); + void clearData(); +private: + std::vector<UbTupleFloat3> nodes; + std::vector<UbTupleInt8> cells; + std::vector<std::string> datanames; + std::vector<std::vector<double> > data; + std::string path; + WbWriter* writer; + LBMUnitConverterPtr conv; + bool bcInformation; + std::vector<std::vector<Block3DPtr> > blockVector; + int minInitLevel; + int maxInitLevel; + int gridRank; + CommunicatorPtr comm; + + friend class boost::serialization::access; + template<class Archive> + void serialize(Archive & ar, const unsigned int version) + { + ar & boost::serialization::base_object<CoProcessor>(*this); + ar & path; + ar & conv; + ar & bcInformation; + ar & blockVector; + ar & minInitLevel; + ar & maxInitLevel; + ar & gridRank; + ar & writer; + } +}; +#endif diff --git a/source/VirtualFluidsCore/CoProcessors/MacroscopicQuantitiesCoProcessor.cpp b/source/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.cpp similarity index 56% rename from source/VirtualFluidsCore/CoProcessors/MacroscopicQuantitiesCoProcessor.cpp rename to source/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.cpp index 8ae2dc789..4ebc36eaf 100644 --- a/source/VirtualFluidsCore/CoProcessors/MacroscopicQuantitiesCoProcessor.cpp +++ b/source/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.cpp @@ -1,6 +1,6 @@ -#include "MacroscopicQuantitiesCoProcessor.h" -#include "LBMKernelETD3Q27.h" -#include "D3Q27ETBCProcessor.h" +#include "WriteMacroscopicQuantitiesCoProcessor.h" +#include "LBMKernel.h" +#include "BCProcessor.h" #include <vector> #include <string> #include <boost/foreach.hpp> @@ -8,57 +8,47 @@ using namespace std; -MacroscopicQuantitiesCoProcessor::MacroscopicQuantitiesCoProcessor() +WriteMacroscopicQuantitiesCoProcessor::WriteMacroscopicQuantitiesCoProcessor() { } ////////////////////////////////////////////////////////////////////////// -MacroscopicQuantitiesCoProcessor::MacroscopicQuantitiesCoProcessor(Grid3DPtr grid, UbSchedulerPtr s, +WriteMacroscopicQuantitiesCoProcessor::WriteMacroscopicQuantitiesCoProcessor(Grid3DPtr grid, UbSchedulerPtr s, const std::string& path, WbWriter* const writer, LBMUnitConverterPtr conv, - bool bcInformation) + CommunicatorPtr comm) : CoProcessor(grid, s), path(path), writer(writer), conv(conv), - bcInformation(bcInformation) -//D3Q27MacroscopicQuantitiesCoProcessor::D3Q27MacroscopicQuantitiesCoProcessor(Grid3DPtr grid, UbSchedulerPtr s, -// const std::string& path, WbWriter* const writer, -// const LBMUnitConverterPtr conv, CommunicatorPtr comm, -// bool bcInformation) -// : ScheduledGridObserver(grid, s), -// path(path), -// comm(comm), -// writer(writer), -// conv(conv), -// bcInformation(bcInformation) + comm(comm) { - init(); -} -////////////////////////////////////////////////////////////////////////// -void MacroscopicQuantitiesCoProcessor::init() -{ - gridRank = Communicator::getInstance()->getProcessID(); + gridRank = Communicator::getInstance()->getProcessID(); minInitLevel = this->grid->getCoarsestInitializedLevel(); maxInitLevel = this->grid->getFinestInitializedLevel(); blockVector.resize(maxInitLevel+1); - for(int level = minInitLevel; level<=maxInitLevel;level++) + for (int level = minInitLevel; level<=maxInitLevel; level++) { grid->getBlocks(level, gridRank, true, blockVector[level]); } } ////////////////////////////////////////////////////////////////////////// -void MacroscopicQuantitiesCoProcessor::process(double step) +void WriteMacroscopicQuantitiesCoProcessor::init() +{ + +} +////////////////////////////////////////////////////////////////////////// +void WriteMacroscopicQuantitiesCoProcessor::process(double step) { if(scheduler->isDue(step) ) collectData(step); - UBLOG(logDEBUG3, "MacroscopicQuantitiesCoProcessor::update:" << step); + UBLOG(logDEBUG3, "WriteMacroscopicQuantitiesCoProcessor::update:" << step); } ////////////////////////////////////////////////////////////////////////// -void MacroscopicQuantitiesCoProcessor::collectData(double step) +void WriteMacroscopicQuantitiesCoProcessor::collectData(double step) { int istep = static_cast<int>(step); @@ -68,34 +58,18 @@ void MacroscopicQuantitiesCoProcessor::collectData(double step) { if (block) { - if(!bcInformation) - { - addDataMQ(block); - } - else - { - addDataGeo(block); - } + addDataMQ(block); } } } string pfilePath, partPath, subfolder, cfilePath; - if(!bcInformation) - { subfolder = "mq"+UbSystem::toString(istep); pfilePath = path+"/mq/"+subfolder; cfilePath = path+"/mq/mq_collection"; partPath = pfilePath+"/mq"+UbSystem::toString(gridRank)+ "_" + UbSystem::toString(istep); - } - else - { - subfolder = "nodes"+UbSystem::toString(istep); - pfilePath = path+"/nodes/"+subfolder; - cfilePath = path+"/nodes/nodes_collection"; - partPath = pfilePath+"/nodes"+UbSystem::toString(gridRank)+ "_" + UbSystem::toString(istep); - } + string partName = writer->writeOctsWithNodeData(partPath,nodes,cells,datanames,data); size_t found=partName.find_last_of("/"); @@ -121,13 +95,13 @@ void MacroscopicQuantitiesCoProcessor::collectData(double step) { WbWriterVtkXmlASCII::getInstance()->addFilesToCollection(cfilePath,filenames,istep,false); } - UBLOG(logINFO,"MacroscopicQuantitiesCoProcessor step: " << istep); + UBLOG(logINFO,"WriteMacroscopicQuantitiesCoProcessor step: " << istep); } clearData(); } ////////////////////////////////////////////////////////////////////////// -void MacroscopicQuantitiesCoProcessor::clearData() +void WriteMacroscopicQuantitiesCoProcessor::clearData() { nodes.clear(); cells.clear(); @@ -135,7 +109,7 @@ void MacroscopicQuantitiesCoProcessor::clearData() data.clear(); } ////////////////////////////////////////////////////////////////////////// -void MacroscopicQuantitiesCoProcessor::addDataMQ(Block3DPtr block) +void WriteMacroscopicQuantitiesCoProcessor::addDataMQ(Block3DPtr block) { UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); UbTupleDouble3 blockLengths = grid->getBlockLengths(block); @@ -159,8 +133,8 @@ void MacroscopicQuantitiesCoProcessor::addDataMQ(Block3DPtr block) data.resize(datanames.size()); - LBMKernelETD3Q27Ptr kernel = boost::dynamic_pointer_cast<LBMKernelETD3Q27>(block->getKernel()); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); LBMReal f[D3Q27System::ENDF+1]; LBMReal vx1,vx2,vx3,rho; @@ -286,119 +260,3 @@ void MacroscopicQuantitiesCoProcessor::addDataMQ(Block3DPtr block) } } } -////////////////////////////////////////////////////////////////////////// -void MacroscopicQuantitiesCoProcessor::addDataGeo(Block3DPtr block) -{ - UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); - UbTupleDouble3 blockLengths = grid->getBlockLengths(block); - UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); - double dx = grid->getDeltaX(block); - - double level = (double)block->getLevel(); - - //Diese Daten werden geschrieben: - datanames.resize(0); - datanames.push_back("Boundary Conditions"); - datanames.push_back("Geometry"); - datanames.push_back("Level"); - //datanames.push_back("Interface CF"); - - data.resize(datanames.size()); - - LBMKernelETD3Q27Ptr kernel = boost::dynamic_pointer_cast<LBMKernelETD3Q27>(block->getKernel()); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); - - //knotennummerierung faengt immer bei 0 an! - int SWB,SEB,NEB,NWB,SWT,SET,NET,NWT; - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int maxX1 = (int)bcArray.getNX1(); - int maxX2 = (int)bcArray.getNX2(); - int maxX3 = (int)bcArray.getNX3(); - - //nummern vergeben und node vector erstellen + daten sammeln - CbArray3D<int> nodeNumbers((int)maxX1, (int)maxX2, (int)maxX3,-1); - //D3Q27BoundaryConditionPtr bcPtr; - int nr = (int)nodes.size(); - - maxX1 -= 1; - maxX2 -= 1; - maxX3 -= 1; - - for(size_t ix3=minX3; ix3<=maxX3; ix3++) - { - for(size_t ix2=minX2; ix2<=maxX2; ix2++) - { - for(size_t ix1=minX1; ix1<=maxX1; ix1++) - { - if(!bcArray.isUndefined(ix1,ix2,ix3) ) - { - //int index = 0; - nodeNumbers(ix1,ix2,ix3) = nr++; - nodes.push_back(makeUbTuple(float(val<1>(org) - val<1>(nodeOffset) + ix1*dx), - float(val<2>(org) - val<2>(nodeOffset) + ix2*dx), - float(val<3>(org) - val<3>(nodeOffset) + ix3*dx))); - - if ( !bcArray.hasBC(ix1,ix2,ix3)) - data[0].push_back( 0.0); - else if(bcArray.getBC(ix1,ix2,ix3)->hasNoSlipBoundary()) - data[0].push_back( 1.0); - else if(bcArray.getBC(ix1,ix2,ix3)->hasVelocityBoundary()) - data[0].push_back( 2.0); - else if(bcArray.getBC(ix1,ix2,ix3)->hasDensityBoundary()) - data[0].push_back( 3.0); - else if(bcArray.getBC(ix1,ix2,ix3)->hasSlipBoundary()) - data[0].push_back( 4.0); - else - data[0].push_back( 5.0); - - if( bcArray.isSolid(ix1,ix2,ix3)) - data[1].push_back(1.0); - else - data[1].push_back(0.0); - - data[2].push_back(level); - - //if (bcArray.isInterfaceCF(ix1, ix2, ix3)) - //{ - // data[3].push_back(1.0); - //} - //else - //{ - // data[3].push_back(0.0); - //} - - } - } - } - } - - maxX1 -= 1; - maxX2 -= 1; - maxX3 -= 1; - - //cell vector erstellen - for(int ix3=minX3; ix3<=maxX3; ix3++) - { - for(int ix2=minX2; ix2<=maxX2; ix2++) - { - for(int ix1=minX1; ix1<=maxX1; ix1++) - { - if( (SWB=nodeNumbers( ix1 , ix2, ix3 )) >= 0 - && (SEB=nodeNumbers( ix1+1, ix2, ix3 )) >= 0 - && (NEB=nodeNumbers( ix1+1, ix2+1, ix3 )) >= 0 - && (NWB=nodeNumbers( ix1 , ix2+1, ix3 )) >= 0 - && (SWT=nodeNumbers( ix1 , ix2, ix3+1 )) >= 0 - && (SET=nodeNumbers( ix1+1, ix2, ix3+1 )) >= 0 - && (NET=nodeNumbers( ix1+1, ix2+1, ix3+1 )) >= 0 - && (NWT=nodeNumbers( ix1 , ix2+1, ix3+1 )) >= 0 ) - { - cells.push_back( makeUbTuple(SWB,SEB,NEB,NWB,SWT,SET,NET,NWT) ); - } - } - } - } -} diff --git a/source/VirtualFluidsCore/CoProcessors/MacroscopicQuantitiesCoProcessor.h b/source/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.h similarity index 72% rename from source/VirtualFluidsCore/CoProcessors/MacroscopicQuantitiesCoProcessor.h rename to source/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.h index 2f25a109a..257023266 100644 --- a/source/VirtualFluidsCore/CoProcessors/MacroscopicQuantitiesCoProcessor.h +++ b/source/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.h @@ -9,18 +9,18 @@ #include "WbWriter.h" #include <boost/shared_ptr.hpp> -class MacroscopicQuantitiesCoProcessor; -typedef boost::shared_ptr<MacroscopicQuantitiesCoProcessor> MacroscopicQuantitiesCoProcessorPtr; +class WriteMacroscopicQuantitiesCoProcessor; +typedef boost::shared_ptr<WriteMacroscopicQuantitiesCoProcessor> MacroscopicQuantitiesCoProcessorPtr; -class MacroscopicQuantitiesCoProcessor : public CoProcessor +class WriteMacroscopicQuantitiesCoProcessor : public CoProcessor { public: - MacroscopicQuantitiesCoProcessor(); - MacroscopicQuantitiesCoProcessor(Grid3DPtr grid, UbSchedulerPtr s, + WriteMacroscopicQuantitiesCoProcessor(); + WriteMacroscopicQuantitiesCoProcessor(Grid3DPtr grid, UbSchedulerPtr s, const std::string& path, WbWriter* const writer, LBMUnitConverterPtr conv, - bool nodesInformation = false); - ~MacroscopicQuantitiesCoProcessor(){} + CommunicatorPtr comm); + ~WriteMacroscopicQuantitiesCoProcessor(){} void process(double step); protected: void collectData(double step); @@ -41,6 +41,7 @@ private: int minInitLevel; int maxInitLevel; int gridRank; + CommunicatorPtr comm; friend class boost::serialization::access; template<class Archive> diff --git a/source/VirtualFluidsCore/Connectors/Block3DConnectorFactory.cpp b/source/VirtualFluidsCore/Connectors/Block3DConnectorFactory.cpp index 44fc37843..e5d645118 100644 --- a/source/VirtualFluidsCore/Connectors/Block3DConnectorFactory.cpp +++ b/source/VirtualFluidsCore/Connectors/Block3DConnectorFactory.cpp @@ -30,7 +30,7 @@ Block3DConnectorPtr Block3DConnectorFactory::createCoarseToFineConnector(Block3D VectorTransmitterPtr sender01, VectorTransmitterPtr receiver01, VectorTransmitterPtr sender10, VectorTransmitterPtr receiver10, VectorTransmitterPtr sender11, VectorTransmitterPtr receiver11, - int sendDir, D3Q27InterpolationProcessorPtr iprocessor) + int sendDir, InterpolationProcessorPtr iprocessor) { return Block3DConnectorPtr (new CoarseToFineNodeSetBlock3DConnector(block, sender00, receiver00, sender01, receiver01, @@ -42,7 +42,7 @@ Block3DConnectorPtr Block3DConnectorFactory::createFineToCoarseConnector(Block3D VectorTransmitterPtr sender, VectorTransmitterPtr receiver, int sendDir, - D3Q27InterpolationProcessorPtr iprocessor, + InterpolationProcessorPtr iprocessor, FineToCoarseBlock3DConnector::CFconnectorType connType) { return Block3DConnectorPtr(new FineToCoarseNodeSetBlock3DConnector(block, diff --git a/source/VirtualFluidsCore/Connectors/Block3DConnectorFactory.h b/source/VirtualFluidsCore/Connectors/Block3DConnectorFactory.h index 4117a4af8..dd4df79e3 100644 --- a/source/VirtualFluidsCore/Connectors/Block3DConnectorFactory.h +++ b/source/VirtualFluidsCore/Connectors/Block3DConnectorFactory.h @@ -25,13 +25,13 @@ public: VectorTransmitterPtr sender01, VectorTransmitterPtr receiver01, VectorTransmitterPtr sender10, VectorTransmitterPtr receiver10, VectorTransmitterPtr sender11, VectorTransmitterPtr receiver11, - int sendDir, D3Q27InterpolationProcessorPtr iprocessor); + int sendDir, InterpolationProcessorPtr iprocessor); virtual Block3DConnectorPtr createFineToCoarseConnector(Block3DPtr block, VectorTransmitterPtr sender, VectorTransmitterPtr receiver, int sendDir, - D3Q27InterpolationProcessorPtr iprocessor, + InterpolationProcessorPtr iprocessor, FineToCoarseBlock3DConnector::CFconnectorType connType); private: diff --git a/source/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.cpp b/source/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.cpp index a9f30d037..c2e186f0b 100644 --- a/source/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.cpp +++ b/source/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.cpp @@ -9,7 +9,7 @@ CoarseToFineBlock3DConnector::CoarseToFineBlock3DConnector(Block3DPtr block, VectorTransmitterPtr sender01, VectorTransmitterPtr receiver01, VectorTransmitterPtr sender10, VectorTransmitterPtr receiver10, VectorTransmitterPtr sender11, VectorTransmitterPtr receiver11, - int sendDir, D3Q27InterpolationProcessorPtr iprocessor) : Block3DConnector(sendDir) + int sendDir, InterpolationProcessorPtr iprocessor) : Block3DConnector(sendDir) , block(block) , sender00(sender00) , sender01(sender01) diff --git a/source/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.h b/source/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.h index 0f1e87aa3..70cd811ee 100644 --- a/source/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.h +++ b/source/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.h @@ -10,7 +10,7 @@ #include "Block3DConnector.h" #include "D3Q27System.h" #include "Block3D.h" -#include "D3Q27InterpolationProcessor.h" +#include "InterpolationProcessor.h" #include <boost/shared_ptr.hpp> #include <boost/weak_ptr.hpp> @@ -47,7 +47,7 @@ public: VectorTransmitterPtr sender01, VectorTransmitterPtr receiver01, VectorTransmitterPtr sender10, VectorTransmitterPtr receiver10, VectorTransmitterPtr sender11, VectorTransmitterPtr receiver11, - int sendDir, D3Q27InterpolationProcessorPtr iprocessor); + int sendDir, InterpolationProcessorPtr iprocessor); virtual ~CoarseToFineBlock3DConnector() {} @@ -94,7 +94,7 @@ protected: sender10, receiver10, sender11, receiver11; - D3Q27InterpolationProcessorPtr iprocessor; + InterpolationProcessorPtr iprocessor; }; diff --git a/source/VirtualFluidsCore/Connectors/CoarseToFineNodeSetBlock3DConnector.cpp b/source/VirtualFluidsCore/Connectors/CoarseToFineNodeSetBlock3DConnector.cpp index 788a5e773..598391086 100644 --- a/source/VirtualFluidsCore/Connectors/CoarseToFineNodeSetBlock3DConnector.cpp +++ b/source/VirtualFluidsCore/Connectors/CoarseToFineNodeSetBlock3DConnector.cpp @@ -6,7 +6,7 @@ CoarseToFineNodeSetBlock3DConnector::CoarseToFineNodeSetBlock3DConnector(Block3D VectorTransmitterPtr sender01, VectorTransmitterPtr receiver01, VectorTransmitterPtr sender10, VectorTransmitterPtr receiver10, VectorTransmitterPtr sender11, VectorTransmitterPtr receiver11, - int sendDir, D3Q27InterpolationProcessorPtr iprocessor) : CoarseToFineBlock3DConnector(block, sender00, receiver00, + int sendDir, InterpolationProcessorPtr iprocessor) : CoarseToFineBlock3DConnector(block, sender00, receiver00, sender01, receiver01, sender10, receiver10, sender11, receiver11, @@ -107,7 +107,7 @@ void CoarseToFineNodeSetBlock3DConnector::findCFCells(int lMinX1, int lMinX2, in LBMReal x1off, x2off, x3off; DistributionArray3DPtr fFrom = block.lock()->getKernel()->getDataSet()->getFdistributions(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(block.lock()->getKernel()->getBCProcessor())->getBCArray(); + BCArray3D& bcArray = block.lock()->getKernel()->getBCProcessor()->getBCArray(); for (ix3 = lMinX3; ix3<=lMaxX3; ix3++) { diff --git a/source/VirtualFluidsCore/Connectors/CoarseToFineNodeSetBlock3DConnector.h b/source/VirtualFluidsCore/Connectors/CoarseToFineNodeSetBlock3DConnector.h index 488165db4..b8d95cdf6 100644 --- a/source/VirtualFluidsCore/Connectors/CoarseToFineNodeSetBlock3DConnector.h +++ b/source/VirtualFluidsCore/Connectors/CoarseToFineNodeSetBlock3DConnector.h @@ -16,8 +16,9 @@ #include "CoarseToFineBlock3DConnector.h" #include "D3Q27System.h" #include "Block3D.h" -#include "LBMKernelETD3Q27.h" -#include "D3Q27InterpolationProcessor.h" +#include "LBMKernel.h" +#include "BCProcessor.h" +#include "InterpolationProcessor.h" #include "MathUtil.hpp" #include "Grid3D.h" #include <boost/shared_ptr.hpp> @@ -47,7 +48,7 @@ public: VectorTransmitterPtr sender01, VectorTransmitterPtr receiver01, VectorTransmitterPtr sender10, VectorTransmitterPtr receiver10, VectorTransmitterPtr sender11, VectorTransmitterPtr receiver11, - int sendDir, D3Q27InterpolationProcessorPtr iprocessor); + int sendDir, InterpolationProcessorPtr iprocessor); void init(); diff --git a/source/VirtualFluidsCore/Connectors/ConnectorFactory.h b/source/VirtualFluidsCore/Connectors/ConnectorFactory.h index 9ea18fad0..b5a041798 100644 --- a/source/VirtualFluidsCore/Connectors/ConnectorFactory.h +++ b/source/VirtualFluidsCore/Connectors/ConnectorFactory.h @@ -3,7 +3,7 @@ #include "Block3DConnector.h" #include "TransmitterType.h" -#include "D3Q27InterpolationProcessor.h" +#include "InterpolationProcessor.h" #include "FineToCoarseBlock3DConnector.h" #include <boost/shared_ptr.hpp> @@ -26,12 +26,12 @@ public: VectorTransmitterPtr sender01, VectorTransmitterPtr receiver01, VectorTransmitterPtr sender10, VectorTransmitterPtr receiver10, VectorTransmitterPtr sender11, VectorTransmitterPtr receiver11, - int sendDir, D3Q27InterpolationProcessorPtr iprocessor) = 0; + int sendDir, InterpolationProcessorPtr iprocessor) = 0; virtual Block3DConnectorPtr createFineToCoarseConnector(Block3DPtr block, VectorTransmitterPtr sender, VectorTransmitterPtr receiver, int sendDir, - D3Q27InterpolationProcessorPtr iprocessor, + InterpolationProcessorPtr iprocessor, FineToCoarseBlock3DConnector::CFconnectorType connType) = 0; protected: diff --git a/source/VirtualFluidsCore/Connectors/D3Q27ETCFOffVectorConnector.h b/source/VirtualFluidsCore/Connectors/D3Q27ETCFOffVectorConnector.h index c330253d4..8ced3dd33 100644 --- a/source/VirtualFluidsCore/Connectors/D3Q27ETCFOffVectorConnector.h +++ b/source/VirtualFluidsCore/Connectors/D3Q27ETCFOffVectorConnector.h @@ -16,13 +16,14 @@ #include "Block3DConnector.h" #include "D3Q27System.h" #include "Block3D.h" -#include "LBMKernelETD3Q27.h" -#include "D3Q27InterpolationProcessor.h" +#include "LBMKernel.h" +#include "InterpolationProcessor.h" #include "MathUtil.hpp" #include "Grid3D.h" #include <boost/shared_ptr.hpp> #include <boost/weak_ptr.hpp> #include "D3Q27ETFCOffVectorConnector.h" +#include "BCProcessor.h" class Block3D; @@ -51,7 +52,7 @@ public: VectorTransmitterPtr senderEvenOddNW, VectorTransmitterPtr receiverEvenOddNW, VectorTransmitterPtr senderOddEvenSE, VectorTransmitterPtr receiverOddEvenSE, VectorTransmitterPtr senderOddOddNE, VectorTransmitterPtr receiverOddOddNE, - int sendDir, D3Q27InterpolationProcessorPtr iprocessor); + int sendDir, InterpolationProcessorPtr iprocessor); bool isLocalConnector(); bool isRemoteConnector(); @@ -97,7 +98,7 @@ protected: senderOddEvenSE, receiverOddEvenSE, senderOddOddNE, receiverOddOddNE; - D3Q27InterpolationProcessorPtr iprocessor; + InterpolationProcessorPtr iprocessor; void writeICellFtoData(vector_type& data, int& index, D3Q27ICell& icellF); void writeNodeToVector(vector_type& data, int& index, LBMReal* inode); @@ -122,7 +123,7 @@ D3Q27ETCFOffVectorConnector<VectorTransmitter>::D3Q27ETCFOffVectorConnector(Bloc VectorTransmitterPtr senderEvenOddNW, VectorTransmitterPtr receiverEvenOddNW, VectorTransmitterPtr senderOddEvenSE, VectorTransmitterPtr receiverOddEvenSE, VectorTransmitterPtr senderOddOddNE, VectorTransmitterPtr receiverOddOddNE, - int sendDir, D3Q27InterpolationProcessorPtr iprocessor) : Block3DConnector(sendDir) + int sendDir, InterpolationProcessorPtr iprocessor) : Block3DConnector(sendDir) , block(block) , senderEvenEvenSW(senderEvenEvenSW) , senderEvenOddNW(senderEvenOddNW) @@ -767,7 +768,7 @@ void D3Q27ETCFOffVectorConnector< VectorTransmitter>::fillSendVectorExt(Distribu if (data.size() == 0) return; int ix1, ix2, ix3; LBMReal xoff, yoff, zoff; - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(block.lock()->getKernel()->getBCProcessor())->getBCArray(); + BCArray3D& bcArray = block.lock()->getKernel()->getBCProcessor()->getBCArray(); for (ix3 = lMinX3; ix3 < lMaxX3; ix3++) { @@ -1879,7 +1880,7 @@ void D3Q27ETCFOffVectorConnector< VectorTransmitter>::findCFnodes(DistributionAr if (data.size() == 0) return; int ix1, ix2, ix3; LBMReal xoff, yoff, zoff; - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(block.lock()->getKernel()->getBCProcessor())->getBCArray(); + BCArray3D& bcArray = block.lock()->getKernel()->getBCProcessor()->getBCArray(); for (ix3 = lMinX3; ix3 < lMaxX3; ix3++) { @@ -1907,7 +1908,8 @@ void D3Q27ETCFOffVectorConnector< VectorTransmitter>::findCFnodes(DistributionAr " interpolation is not implemented for other direction" + " by using in: " + (std::string)typeid(*this).name() + " or maybe you have a solid on the block boundary"; - UB_THROW(UbException(UB_EXARGS, err)); + UBLOG(logINFO, err); + //UB_THROW(UbException(UB_EXARGS, err)); } } diff --git a/source/VirtualFluidsCore/Connectors/D3Q27ETFCOffVectorConnector.h b/source/VirtualFluidsCore/Connectors/D3Q27ETFCOffVectorConnector.h index ea6cea2f7..a5408d658 100644 --- a/source/VirtualFluidsCore/Connectors/D3Q27ETFCOffVectorConnector.h +++ b/source/VirtualFluidsCore/Connectors/D3Q27ETFCOffVectorConnector.h @@ -15,12 +15,12 @@ #include "D3Q27System.h" #include "Block3D.h" #include "Grid3D.h" -#include "LBMKernelETD3Q27.h" -#include "D3Q27InterpolationProcessor.h" +#include "LBMKernel.h" +#include "InterpolationProcessor.h" #include "MathUtil.hpp" #include <boost/shared_ptr.hpp> #include <boost/weak_ptr.hpp> - +#include "BCProcessor.h" class Block3D; @@ -41,7 +41,7 @@ protected: typedef boost::shared_ptr< VectorTransmitter > VectorTransmitterPtr; public: D3Q27ETFCOffVectorConnector(Block3DPtr block, VectorTransmitterPtr sender, VectorTransmitterPtr receiver, int sendDir, - D3Q27InterpolationProcessorPtr iprocessor, CFconnectorType connType); + InterpolationProcessorPtr iprocessor, CFconnectorType connType); bool isLocalConnector(); bool isRemoteConnector(); @@ -85,7 +85,7 @@ protected: //gegenstelle muss "inversen" connector besitzen VectorTransmitterPtr sender, receiver; - D3Q27InterpolationProcessorPtr iprocessor; + InterpolationProcessorPtr iprocessor; CFconnectorType connType; @@ -108,7 +108,7 @@ protected: template< typename VectorTransmitter > D3Q27ETFCOffVectorConnector<VectorTransmitter>::D3Q27ETFCOffVectorConnector(Block3DPtr block, VectorTransmitterPtr sender, VectorTransmitterPtr receiver, int sendDir, - D3Q27InterpolationProcessorPtr iprocessor, + InterpolationProcessorPtr iprocessor, CFconnectorType connType) : Block3DConnector(sendDir) , block(block) @@ -731,7 +731,7 @@ void D3Q27ETFCOffVectorConnector< VectorTransmitter>::fillSendVector(Distributio { int ix1, ix2, ix3; LBMReal xoff, yoff, zoff; - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(block.lock()->getKernel()->getBCProcessor())->getBCArray(); + BCArray3D& bcArray = block.lock()->getKernel()->getBCProcessor()->getBCArray(); for (ix3=lMinX3; ix3<lMaxX3; ix3+=2) { @@ -759,7 +759,8 @@ void D3Q27ETFCOffVectorConnector< VectorTransmitter>::fillSendVector(Distributio " interpolation is not implemented for other direction"+ " by using in: "+(std::string)typeid(*this).name()+ " or maybe you have a solid on the block boundary"; - UB_THROW(UbException(UB_EXARGS, err)); + UBLOG(logINFO, err); + //UB_THROW(UbException(UB_EXARGS, err)); } } diff --git a/source/VirtualFluidsCore/Connectors/D3Q27ETFullDirectConnector.cpp b/source/VirtualFluidsCore/Connectors/D3Q27ETFullDirectConnector.cpp index aa5122fdf..ab4b68e9c 100644 --- a/source/VirtualFluidsCore/Connectors/D3Q27ETFullDirectConnector.cpp +++ b/source/VirtualFluidsCore/Connectors/D3Q27ETFullDirectConnector.cpp @@ -1,5 +1,5 @@ #include "D3Q27ETFullDirectConnector.h" -#include "LBMKernelETD3Q27.h" +#include "LBMKernel.h" #include "D3Q27EsoTwist3DSplittedVector.h" diff --git a/source/VirtualFluidsCore/Connectors/D3Q27ETFullVectorConnector.cpp b/source/VirtualFluidsCore/Connectors/D3Q27ETFullVectorConnector.cpp index 2dcc77883..8af8a71a5 100644 --- a/source/VirtualFluidsCore/Connectors/D3Q27ETFullVectorConnector.cpp +++ b/source/VirtualFluidsCore/Connectors/D3Q27ETFullVectorConnector.cpp @@ -1,6 +1,6 @@ #include "D3Q27ETFullVectorConnector.h" #include "D3Q27EsoTwist3DSplittedVector.h" -#include "LBMKernelETD3Q27.h" +#include "LBMKernel.h" ////////////////////////////////////////////////////////////////////////// D3Q27ETFullVectorConnector::D3Q27ETFullVectorConnector(Block3DPtr block diff --git a/source/VirtualFluidsCore/Connectors/D3Q27ETFullVectorConnector.h b/source/VirtualFluidsCore/Connectors/D3Q27ETFullVectorConnector.h index 0398dd146..7247e39b9 100644 --- a/source/VirtualFluidsCore/Connectors/D3Q27ETFullVectorConnector.h +++ b/source/VirtualFluidsCore/Connectors/D3Q27ETFullVectorConnector.h @@ -6,7 +6,7 @@ #include "RemoteBlock3DConnector.h" #include "D3Q27System.h" #include "Block3D.h" -#include "LBMKernelETD3Q27.h" +#include "LBMKernel.h" #include "EsoTwistD3Q27System.h" #include "basics/container/CbArray3D.h" #include "basics/container/CbArray4D.h" diff --git a/source/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.cpp b/source/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.cpp index 6d861e19f..78e68ed4a 100644 --- a/source/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.cpp +++ b/source/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.cpp @@ -3,7 +3,7 @@ //////////////////////////////////////////////////////////////////////////// FineToCoarseBlock3DConnector::FineToCoarseBlock3DConnector(Block3DPtr block, VectorTransmitterPtr sender, VectorTransmitterPtr receiver, int sendDir, - D3Q27InterpolationProcessorPtr iprocessor, + InterpolationProcessorPtr iprocessor, CFconnectorType connType) : Block3DConnector(sendDir) , block(block) diff --git a/source/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.h b/source/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.h index c27b041d5..50bb2e78b 100644 --- a/source/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.h +++ b/source/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.h @@ -10,8 +10,8 @@ #include "Block3DConnector.h" #include "D3Q27System.h" #include "Block3D.h" -#include "LBMKernelETD3Q27.h" -#include "D3Q27InterpolationProcessor.h" +#include "LBMKernel.h" +#include "InterpolationProcessor.h" #include <boost/shared_ptr.hpp> #include <boost/weak_ptr.hpp> @@ -45,7 +45,7 @@ class FineToCoarseBlock3DConnector : public Block3DConnector public: enum CFconnectorType { Type00, Type10, Type01, Type11 }; public: - FineToCoarseBlock3DConnector(Block3DPtr block, VectorTransmitterPtr sender, VectorTransmitterPtr receiver, int sendDir, D3Q27InterpolationProcessorPtr iprocessor, CFconnectorType connType); + FineToCoarseBlock3DConnector(Block3DPtr block, VectorTransmitterPtr sender, VectorTransmitterPtr receiver, int sendDir, InterpolationProcessorPtr iprocessor, CFconnectorType connType); bool isLocalConnector(); bool isRemoteConnector(); @@ -85,7 +85,7 @@ public: protected: boost::weak_ptr<Block3D> block; VectorTransmitterPtr sender, receiver; - D3Q27InterpolationProcessorPtr iprocessor; + InterpolationProcessorPtr iprocessor; CFconnectorType connType; }; diff --git a/source/VirtualFluidsCore/Connectors/FineToCoarseNodeSetBlock3DConnector.cpp b/source/VirtualFluidsCore/Connectors/FineToCoarseNodeSetBlock3DConnector.cpp index 449ed5eb9..e66ae37bf 100644 --- a/source/VirtualFluidsCore/Connectors/FineToCoarseNodeSetBlock3DConnector.cpp +++ b/source/VirtualFluidsCore/Connectors/FineToCoarseNodeSetBlock3DConnector.cpp @@ -1,8 +1,9 @@ #include "FineToCoarseNodeSetBlock3DConnector.h" +#include "BCProcessor.h" ////////////////////////////////////////////////////////////////////////// FineToCoarseNodeSetBlock3DConnector::FineToCoarseNodeSetBlock3DConnector(Block3DPtr block, VectorTransmitterPtr sender, VectorTransmitterPtr receiver, - int sendDir, D3Q27InterpolationProcessorPtr iprocessor, CFconnectorType connType) : FineToCoarseBlock3DConnector(block, sender, receiver, sendDir, iprocessor, connType) + int sendDir, InterpolationProcessorPtr iprocessor, CFconnectorType connType) : FineToCoarseBlock3DConnector(block, sender, receiver, sendDir, iprocessor, connType) { } @@ -100,7 +101,7 @@ void FineToCoarseNodeSetBlock3DConnector::findFCCells(int lMinX1, int lMinX2, in LBMReal x1off, x2off, x3off; DistributionArray3DPtr fFrom = FineToCoarseBlock3DConnector::block.lock()->getKernel()->getDataSet()->getFdistributions(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(FineToCoarseBlock3DConnector::block.lock()->getKernel()->getBCProcessor())->getBCArray(); + BCArray3D& bcArray = FineToCoarseBlock3DConnector::block.lock()->getKernel()->getBCProcessor()->getBCArray(); for (ix3 = lMinX3; ix3<=lMaxX3; ix3 += 2) { diff --git a/source/VirtualFluidsCore/Connectors/FineToCoarseNodeSetBlock3DConnector.h b/source/VirtualFluidsCore/Connectors/FineToCoarseNodeSetBlock3DConnector.h index 73f9e9849..ea4f54bb2 100644 --- a/source/VirtualFluidsCore/Connectors/FineToCoarseNodeSetBlock3DConnector.h +++ b/source/VirtualFluidsCore/Connectors/FineToCoarseNodeSetBlock3DConnector.h @@ -12,8 +12,8 @@ #include "D3Q27System.h" #include "Block3D.h" #include "Grid3D.h" -#include "LBMKernelETD3Q27.h" -#include "D3Q27InterpolationProcessor.h" +#include "LBMKernel.h" +#include "InterpolationProcessor.h" #include "MathUtil.hpp" #include <boost/shared_ptr.hpp> #include <boost/weak_ptr.hpp> @@ -28,7 +28,7 @@ class Block3D; class FineToCoarseNodeSetBlock3DConnector : public FineToCoarseBlock3DConnector { public: - FineToCoarseNodeSetBlock3DConnector(Block3DPtr block, VectorTransmitterPtr sender, VectorTransmitterPtr receiver, int sendDir, D3Q27InterpolationProcessorPtr iprocessor, CFconnectorType connType); + FineToCoarseNodeSetBlock3DConnector(Block3DPtr block, VectorTransmitterPtr sender, VectorTransmitterPtr receiver, int sendDir, InterpolationProcessorPtr iprocessor, CFconnectorType connType); void init(); void fillSendVectors(); void distributeReceiveVectors(); diff --git a/source/VirtualFluidsCore/Connectors/RemoteBlock3DConnector.h b/source/VirtualFluidsCore/Connectors/RemoteBlock3DConnector.h index 886c9d520..c2f17557f 100644 --- a/source/VirtualFluidsCore/Connectors/RemoteBlock3DConnector.h +++ b/source/VirtualFluidsCore/Connectors/RemoteBlock3DConnector.h @@ -7,7 +7,7 @@ #include "Block3DConnector.h" #include "D3Q27System.h" #include "Block3D.h" -#include "LBMKernelETD3Q27.h" +#include "LBMKernel.h" #include "EsoTwistD3Q27System.h" diff --git a/source/VirtualFluidsCore/FETOL/FETOLSetConnectorsBlockVisitor.h b/source/VirtualFluidsCore/FETOL/FETOLSetConnectorsBlockVisitor.h index 23e2aad75..950212e14 100644 --- a/source/VirtualFluidsCore/FETOL/FETOLSetConnectorsBlockVisitor.h +++ b/source/VirtualFluidsCore/FETOL/FETOLSetConnectorsBlockVisitor.h @@ -6,7 +6,7 @@ #include "Block3DVisitor.h" #include "D3Q27System.h" #include "FETOLCommunicator.h" -#include "D3Q27InterpolationProcessor.h" +#include "InterpolationProcessor.h" #include "CreateTransmittersHelper.h" class FETOLSetConnectorsBlockVisitor : public Block3DVisitor diff --git a/source/VirtualFluidsCore/Grid/Block3D.cpp b/source/VirtualFluidsCore/Grid/Block3D.cpp index 9cabbb818..12a0edea7 100644 --- a/source/VirtualFluidsCore/Grid/Block3D.cpp +++ b/source/VirtualFluidsCore/Grid/Block3D.cpp @@ -72,19 +72,19 @@ bool Block3D::isNotActive() const return(!this->active); } ////////////////////////////////////////////////////////////////////////// -void Block3D::setKernel(LBMKernel3DPtr kernel) +void Block3D::setKernel(LBMKernelPtr kernel) { this->kernel = kernel; } ////////////////////////////////////////////////////////////////////////// -LBMKernel3DPtr Block3D::getKernel() const +LBMKernelPtr Block3D::getKernel() const { return this->kernel; } ////////////////////////////////////////////////////////////////////////// void Block3D::deleteKernel() { - this->kernel = LBMKernel3DPtr(); + this->kernel = LBMKernelPtr(); } ////////////////////////////////////////////////////////////////////////// int Block3D::getBundle() const diff --git a/source/VirtualFluidsCore/Grid/Block3D.h b/source/VirtualFluidsCore/Grid/Block3D.h index 35b08ea69..dc9cbb103 100644 --- a/source/VirtualFluidsCore/Grid/Block3D.h +++ b/source/VirtualFluidsCore/Grid/Block3D.h @@ -17,7 +17,7 @@ class Block3D; typedef boost::shared_ptr<Block3D> Block3DPtr; -#include "LBMKernel3D.h" +#include "LBMKernel.h" class Block3D { @@ -36,8 +36,8 @@ public: bool isActive() const; bool isNotActive() const; - void setKernel(LBMKernel3DPtr kernel); - LBMKernel3DPtr getKernel() const; + void setKernel(LBMKernelPtr kernel); + LBMKernelPtr getKernel() const; void deleteKernel(); void setBundle(int bundle); @@ -118,7 +118,7 @@ private: int interpolationFlagCF; int interpolationFlagFC; - LBMKernel3DPtr kernel; + LBMKernelPtr kernel; std::vector<Block3DConnectorPtr> connectors; std::map<int, int> weight; diff --git a/source/VirtualFluidsCore/Grid/BoostSerializationClassExportHelper.h b/source/VirtualFluidsCore/Grid/BoostSerializationClassExportHelper.h index ef0073a3f..f216f1c5b 100644 --- a/source/VirtualFluidsCore/Grid/BoostSerializationClassExportHelper.h +++ b/source/VirtualFluidsCore/Grid/BoostSerializationClassExportHelper.h @@ -1,19 +1,19 @@ #ifndef BOOSTSERIALIZATIONCLASSEXPORTHELPER_H #define BOOSTSERIALIZATIONCLASSEXPORTHELPER_H -#include <LBMKernelETD3Q27.h> #include <D3Q27EsoTwist3DSplittedVector.h> #include <BCProcessor.h> -#include <D3Q27ETBCProcessor.h> +#include <BCProcessor.h> #include <DataSet3D.h> -#include <LBMKernelETD3Q27CCLB.h> -#include <LBMKernelETD3Q27CCLBWithSpongeLayer.h> +#include <CompressibleCumulantLBMKernel.h> +#include <IncompressibleCumulantLBMKernel.h> +#include <IncompressibleCumulantWithSpongeLayerLBMKernel.h> #include <Interactor3D.h> #include <D3Q27Interactor.h> #include <Communicator.h> #include <MPICommunicator.h> #include <CoProcessor.h> -#include <MacroscopicQuantitiesCoProcessor.h> +#include <WriteMacroscopicQuantitiesCoProcessor.h> #include <ShearStressCoProcessor.h> #include <AverageValuesCoProcessor.h> #include <basics/container/CbArray4D.h> @@ -21,60 +21,59 @@ #include <basics/writer/WbWriterVtkXmlASCII.h> #include <basics/writer/WbWriterVtkXmlBinary.h> -#include <BoundaryCondition.h> -#include <VelocityBoundaryCondition.h> -#include <NonEqDensityBoundaryCondition.h> -#include <EqDensityBoundaryCondition.h> -#include <NoSlipBoundaryCondition.h> -#include <HighViscosityNoSlipBoundaryCondition.h> -#include <SlipBoundaryCondition.h> -#include <NonReflectingDensityBoundaryCondition.h> -#include <NonReflectingVelocityBoundaryCondition.h> +#include <BCAlgorithm.h> +#include <VelocityBCAlgorithm.h> +#include <NonEqDensityBCAlgorithm.h> +#include <EqDensityBCAlgorithm.h> +#include <NoSlipBCAlgorithm.h> +#include <HighViscosityNoSlipBCAlgorithm.h> +#include <SlipBCAlgorithm.h> +#include <NonReflectingDensityBCAlgorithm.h> +#include <NonReflectingVelocityBCAlgorithm.h> -#include <D3Q27BoundaryConditionAdapter.h> -#include <D3Q27DensityBCAdapter.h> -#include <D3Q27NoSlipBCAdapter.h> -#include <D3Q27SlipBCAdapter.h> -#include <D3Q27VelocityBCAdapter.h> -#include "ThinWallNoSlipBoundaryCondition.h" -#include "D3Q27ETForThinWallBCProcessor.h" +#include <BCAdapter.h> +#include <DensityBCAdapter.h> +#include <NoSlipBCAdapter.h> +#include <SlipBCAdapter.h> +#include <VelocityBCAdapter.h> +#include "ThinWallNoSlipBCAlgorithm.h" +#include "ThinWallBCProcessor.h" #include "VoidLBMKernel.h" #include "VoidData3D.h" #include <boost/serialization/export.hpp> -BOOST_CLASS_EXPORT(LBMKernelETD3Q27) -BOOST_CLASS_EXPORT(LBMKernelETD3Q27CCLB) -BOOST_CLASS_EXPORT(LBMKernelETD3Q27CCLBWithSpongeLayer) +BOOST_CLASS_EXPORT(CompressibleCumulantLBMKernel) +BOOST_CLASS_EXPORT(IncompressibleCumulantLBMKernel) +BOOST_CLASS_EXPORT(IncompressibleCumulantWithSpongeLayerLBMKernel) BOOST_CLASS_EXPORT(VoidLBMKernel) BOOST_CLASS_EXPORT(VoidData3D) BOOST_CLASS_EXPORT(D3Q27EsoTwist3DSplittedVector) BOOST_CLASS_EXPORT(BCProcessor) -BOOST_CLASS_EXPORT(D3Q27ETBCProcessor) -BOOST_CLASS_EXPORT(D3Q27ETForThinWallBCProcessor) +BOOST_CLASS_EXPORT(ThinWallBCProcessor) BOOST_CLASS_EXPORT(DataSet3D) BOOST_CLASS_EXPORT(Interactor3D) BOOST_CLASS_EXPORT(D3Q27Interactor) BOOST_CLASS_EXPORT(CoProcessor) -BOOST_CLASS_EXPORT(MacroscopicQuantitiesCoProcessor) +BOOST_CLASS_EXPORT(WriteMacroscopicQuantitiesCoProcessor) BOOST_CLASS_EXPORT(ShearStressCoProcessor) BOOST_CLASS_EXPORT(AverageValuesCoProcessor) BOOST_CLASS_EXPORT(WbWriterVtkXmlASCII) BOOST_CLASS_EXPORT(WbWriterVtkXmlBinary) -BOOST_CLASS_EXPORT(BoundaryCondition) -BOOST_CLASS_EXPORT(VelocityBoundaryCondition) -BOOST_CLASS_EXPORT(NonEqDensityBoundaryCondition) -BOOST_CLASS_EXPORT(EqDensityBoundaryCondition) -BOOST_CLASS_EXPORT(NoSlipBoundaryCondition) -BOOST_CLASS_EXPORT(HighViscosityNoSlipBoundaryCondition) -BOOST_CLASS_EXPORT(SlipBoundaryCondition) -BOOST_CLASS_EXPORT(NonReflectingDensityBoundaryCondition) -BOOST_CLASS_EXPORT(NonReflectingVelocityBoundaryCondition) -BOOST_CLASS_EXPORT(ThinWallNoSlipBoundaryCondition) +//BOOST_CLASS_EXPORT(BCAlgorithm) +//BOOST_CLASS_EXPORT(VelocityBCAlgorithm) +//BOOST_CLASS_EXPORT(NonEqDensityBCAlgorithm) +//BOOST_CLASS_EXPORT(EqDensityBCAlgorithm) +//BOOST_CLASS_EXPORT(NoSlipBCAlgorithm) +//BOOST_CLASS_EXPORT(HighViscosityNoSlipBCAlgorithm) +//BOOST_CLASS_EXPORT(SlipBCAlgorithm) +//BOOST_CLASS_EXPORT(NonReflectingDensityBCAlgorithm) +//BOOST_CLASS_EXPORT(NonReflectingVelocityBCAlgorithm) +//BOOST_CLASS_EXPORT(ThinWallNoSlipBCAlgorithm) -BOOST_CLASS_EXPORT(D3Q27BoundaryConditionAdapter) -BOOST_CLASS_EXPORT(D3Q27DensityBCAdapter) -BOOST_CLASS_EXPORT(D3Q27NoSlipBCAdapter) -BOOST_CLASS_EXPORT(D3Q27SlipBCAdapter) -BOOST_CLASS_EXPORT(D3Q27VelocityBCAdapter) +BOOST_CLASS_EXPORT(BCAdapter) +BOOST_CLASS_EXPORT(DensityBCAdapter) +BOOST_CLASS_EXPORT(NoSlipBCAdapter) +BOOST_CLASS_EXPORT(SlipBCAdapter) +BOOST_CLASS_EXPORT(VelocityBCAdapter) #endif diff --git a/source/VirtualFluidsCore/Grid/Grid3D.cpp b/source/VirtualFluidsCore/Grid/Grid3D.cpp index 93e9b2170..e7a01c447 100644 --- a/source/VirtualFluidsCore/Grid/Grid3D.cpp +++ b/source/VirtualFluidsCore/Grid/Grid3D.cpp @@ -103,6 +103,21 @@ void Grid3D::accept(Block3DVisitor& blockVisitor) if(dir) stopLevel += 1; else stopLevel -= 1; + +// for (int l = startLevel; l!=stopLevel;) +// { +// std::vector<Block3DPtr> blockVector; +// getBlocks(l, blockVector); +// int sizeb = (int)blockVector.size(); +//#pragma omp parallel +//#pragma omp for +// for(int i = 0; i < sizeb; i++) +// { +// blockVisitor.visit(shared_from_this(), blockVector[i]); +// } +// if (dir) l++; +// else l--; +// } for(int l=startLevel; l!=stopLevel;) { std::vector<Block3DPtr> blockVector; @@ -320,7 +335,10 @@ Block3DPtr Grid3D::collapseBlock(int fix1, int fix2, int fix3, int flevel, int l Block3DPtr fblock = this->getBlock(fix1, fix2, fix3, flevel); if( flevel < 1 ) throw UbException(UB_EXARGS,"level of block ("+toString(fix1)+","+toString(fix2)+","+toString(fix3)+","+toString(flevel)+") is < 1"); - if( !fblock ) throw UbException(UB_EXARGS,"specific block("+toString(fix1)+","+toString(fix2)+","+toString(fix3)+","+toString(flevel)+") doesn't exists"); + if( !fblock ) + { + throw UbException(UB_EXARGS,"specific block("+toString(fix1)+","+toString(fix2)+","+toString(fix3)+","+toString(flevel)+") doesn't exists"); + } if( !fblock->isActive() ) throw UbException(UB_EXARGS,"block("+toString(fix1)+","+toString(fix2)+","+toString(fix3)+","+toString(flevel)+") is not active"); //da bei periodic der eigentliche block andere indizes hat: @@ -1925,6 +1943,59 @@ void Grid3D::deleteBlockIDs() { this->blockIdMap.clear(); } +////////////////////////////////////////////////////////////////////////// +void Grid3D::updateDistributedBlocks(CommunicatorPtr comm) +{ + + std::vector<int> blocks; + + if (comm->isRoot()) + { + int startLevel = getCoarsestInitializedLevel(); + int stopLevel = getFinestInitializedLevel(); + + for (int l = startLevel; l <= stopLevel; l++) + { + std::vector<Block3DPtr> blockVector; + getBlocks(l, blockVector); + BOOST_FOREACH(Block3DPtr block, blockVector) + { + blocks.push_back(block->getX1()); + blocks.push_back(block->getX2()); + blocks.push_back(block->getX3()); + blocks.push_back(l); + blocks.push_back(block->getGlobalID()); + } + } + } + + comm->broadcast(blocks); + + if (!comm->isRoot()) + { + int startLevel = getCoarsestInitializedLevel(); + int stopLevel = getFinestInitializedLevel(); + + blockIdMap.clear(); + + for (int l = startLevel; l<=stopLevel; l++) + { + levelSet[l].clear(); + } + this->levelSet.clear(); + levelSet.resize(Grid3DSystem::MAXLEVEL+1); + + int rsize = blocks.size(); + for (int i = 0; i < rsize; i+=5) + { + Block3DPtr block(new Block3D(blocks[i], blocks[i+1], blocks[i+2], blocks[i+3])); + block->setGlobalID(blocks[i+4]); + this->addBlock(block); + } + + } + +} ////////////////////////////////////////////////////////////////////////// diff --git a/source/VirtualFluidsCore/Grid/Grid3D.h b/source/VirtualFluidsCore/Grid/Grid3D.h index 87112cfee..6abb7b2cf 100644 --- a/source/VirtualFluidsCore/Grid/Grid3D.h +++ b/source/VirtualFluidsCore/Grid/Grid3D.h @@ -75,6 +75,7 @@ public: //const Block3DMap& getBlocks(int level); const BlockIDMap& getBlockIDs(); void deleteBlockIDs(); + void updateDistributedBlocks(CommunicatorPtr comm); Block3DPtr getSuperBlock(Block3DPtr block); Block3DPtr getSuperBlock(int ix1, int ix2, int ix3, int level); void getSubBlocks(Block3DPtr block, int levelDepth, std::vector<Block3DPtr>& blocks); diff --git a/source/VirtualFluidsCore/Interactors/D3Q27Interactor.cpp b/source/VirtualFluidsCore/Interactors/D3Q27Interactor.cpp index ae529f9fa..3c420ed3c 100644 --- a/source/VirtualFluidsCore/Interactors/D3Q27Interactor.cpp +++ b/source/VirtualFluidsCore/Interactors/D3Q27Interactor.cpp @@ -11,10 +11,10 @@ #include "Block3D.h" #include "Grid3D.h" #include "BCArray3D.h" -#include "D3Q27BoundaryCondition.h" -#include "D3Q27VelocityBCAdapter.h" -#include "LBMKernelETD3Q27.h" -#include "D3Q27ETBCProcessor.h" +#include "BoundaryConditions.h" +#include "VelocityBCAdapter.h" +#include "LBMKernel.h" +#include "BCProcessor.h" //#include <3rdParty/MarchingCubes/MarchingCubes.h> @@ -39,7 +39,7 @@ D3Q27Interactor::D3Q27Interactor(GbObject3DPtr geoObject3D, Grid3DPtr grid, int this->initRayVectors(); } ////////////////////////////////////////////////////////////////////////// -D3Q27Interactor::D3Q27Interactor(GbObject3DPtr geoObject3D, Grid3DPtr grid, D3Q27BoundaryConditionAdapterPtr bcAdapter, int type) +D3Q27Interactor::D3Q27Interactor(GbObject3DPtr geoObject3D, Grid3DPtr grid, BCAdapterPtr bcAdapter, int type) : Interactor3D(geoObject3D, grid, type), relevantForForces(false) { this->reinitWithStoredQsFlag = false; @@ -47,7 +47,7 @@ D3Q27Interactor::D3Q27Interactor(GbObject3DPtr geoObject3D, Grid3DPtr grid, D3Q2 this->initRayVectors(); } ////////////////////////////////////////////////////////////////////////// -D3Q27Interactor::D3Q27Interactor(GbObject3DPtr geoObject3D, Grid3DPtr grid, D3Q27BoundaryConditionAdapterPtr bcAdapter, int type, Interactor3D::Accuracy a) +D3Q27Interactor::D3Q27Interactor(GbObject3DPtr geoObject3D, Grid3DPtr grid, BCAdapterPtr bcAdapter, int type, Interactor3D::Accuracy a) : Interactor3D(geoObject3D, grid, type, a), relevantForForces(false) { this->reinitWithStoredQsFlag = false; @@ -176,8 +176,8 @@ void D3Q27Interactor::updateInteractor(const double& timestep) if(block->isNotActive() || !block) continue; - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); set< std::vector<int> >::iterator setPos; @@ -191,7 +191,7 @@ void D3Q27Interactor::updateInteractor(const double& timestep) double worldX2 = val<2>(coords); double worldX3 = val<3>(coords); - D3Q27BoundaryConditionPtr bc = bcArray.getBC(x1,x2,x3); + BoundaryConditionsPtr bc = bcArray.getBC(x1,x2,x3); if(bc) //kann sein, dass die BC durch das solid setzen eines andern interactors geloescht wurde { for(size_t i=0; i<bcAdapterVector.size(); i++) @@ -224,10 +224,10 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const Block3DPtr block/*,const double timestep = 0; bool oneEntryGotBC = false; //ob ueberhaupt ein eintrag ein BC zugewiesen wurde bool gotQs = false; //true, wenn "difference" gesetzt wurde - D3Q27BoundaryConditionPtr bc; + BoundaryConditionsPtr bc; - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); double internX1,internX2,internX3; @@ -349,7 +349,7 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const Block3DPtr block/*,const if(!bc) { //bc = bvd->createD3Q27BoundaryCondition(); //= new D3Q27BoundaryCondition(); - bc = D3Q27BoundaryConditionPtr(new D3Q27BoundaryCondition); + bc = BoundaryConditionsPtr(new BoundaryConditions); bcArray.setBC(ix1,ix2,ix3,bc); } //TODO: man muss ueberlegen, wie kann man, dass die Geschwindigkeit auf 0.0 gesetzt werden, vermeiden @@ -509,7 +509,7 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const Block3DPtr block/*,const if(!bc) { //bc = bvd->createD3Q27BoundaryCondition(); //= new D3Q27BoundaryCondition(); - bc = D3Q27BoundaryConditionPtr(new D3Q27BoundaryCondition); + bc = BoundaryConditionsPtr(new BoundaryConditions); bcArray.setBC(ix1,ix2,ix3,bc); } for(int index=(int)bcAdapterVector.size()-1; index>=0; --index) @@ -557,8 +557,8 @@ void D3Q27Interactor::addQsLineSet(std::vector<UbTupleFloat3 >& nodes, std::vect double dx = grid.lock()->getDeltaX(block); UbTupleDouble3 orgDelta = grid.lock()->getNodeOffset(block); - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); map<Block3DPtr, set< std::vector<int> > >::iterator pos = transNodeIndicesMap.find(block); if(pos==transNodeIndicesMap.end()) @@ -581,7 +581,7 @@ void D3Q27Interactor::addQsLineSet(std::vector<UbTupleFloat3 >& nodes, std::vect if(bcArray.isFluid(ix1,ix2,ix3)) //es kann sein, dass der node von einem anderen interactor z.B. als solid gemarkt wurde!!! { if( !bcArray.hasBC(ix1,ix2,ix3) ) continue; - D3Q27BoundaryConditionPtr bc = bcArray.getBC(ix1,ix2,ix3); + BoundaryConditionsPtr bc = bcArray.getBC(ix1,ix2,ix3); double x1a = val<1>(blockOrg) - val<1>(orgDelta) + ix1 * dx; double x2a = val<2>(blockOrg) - val<2>(orgDelta) + ix2 * dx; @@ -650,8 +650,8 @@ vector< pair<GbPoint3D,GbPoint3D> > D3Q27Interactor::getQsLineSet() BOOST_FOREACH(Block3DPtr block, transBlocks) { - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcMatrix = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcMatrix = kernel->getBCProcessor()->getBCArray(); UbTupleDouble3 nodeOffset = grid.lock()->getNodeOffset(block); //double collFactor = ((LbD3Q27Calculator*)grid->getCalculator())->getCollisionsFactors()[block->getLevel()]; @@ -701,7 +701,7 @@ vector< pair<GbPoint3D,GbPoint3D> > D3Q27Interactor::getQsLineSet() if(bcMatrix.isFluid(ix1,ix2,ix3)) //es kann sein, dass der node von einem anderen interactor z.B. als solid gemarkt wurde!!! { if( !bcMatrix.hasBC(ix1,ix2,ix3) ) continue; - D3Q27BoundaryConditionPtr bc = bcMatrix.getBC(ix1,ix2,ix3); + BoundaryConditionsPtr bc = bcMatrix.getBC(ix1,ix2,ix3); double x1a = x1-val<1>(nodeOffset)+dx * ix1; double x2a = x2-val<2>(nodeOffset)+dx * ix2; double x3a = x3-val<3>(nodeOffset)+dx * ix3; diff --git a/source/VirtualFluidsCore/Interactors/D3Q27Interactor.h b/source/VirtualFluidsCore/Interactors/D3Q27Interactor.h index 1eab8ca27..7b80d3cdf 100644 --- a/source/VirtualFluidsCore/Interactors/D3Q27Interactor.h +++ b/source/VirtualFluidsCore/Interactors/D3Q27Interactor.h @@ -31,8 +31,8 @@ typedef boost::shared_ptr<D3Q27Interactor> D3Q27InteractorPtr; #include "GbPoint3D.h" #include "Interactor3D.h" #include "BCArray3D.h" -#include "D3Q27BoundaryConditionAdapter.h" -#include "D3Q27BoundaryCondition.h" +#include "BCAdapter.h" +#include "BoundaryConditions.h" #include "D3Q27System.h" class UbFileInput; @@ -45,17 +45,17 @@ class D3Q27Interactor : public Interactor3D public: D3Q27Interactor(); D3Q27Interactor(GbObject3DPtr geoObject3D, Grid3DPtr grid, int type); - D3Q27Interactor(GbObject3DPtr geoObject3D, Grid3DPtr grid, D3Q27BoundaryConditionAdapterPtr bcAdapter, int type); - D3Q27Interactor(GbObject3DPtr geoObject3D, Grid3DPtr grid, D3Q27BoundaryConditionAdapterPtr bcAdapter, int type, Interactor3D::Accuracy a); + D3Q27Interactor(GbObject3DPtr geoObject3D, Grid3DPtr grid, BCAdapterPtr bcAdapter, int type); + D3Q27Interactor(GbObject3DPtr geoObject3D, Grid3DPtr grid, BCAdapterPtr bcAdapter, int type, Interactor3D::Accuracy a); - ~D3Q27Interactor(); + virtual ~D3Q27Interactor(); void setRelevantForForces(const bool& value) { this->relevantForForces = value; } bool isRelevantForForces() { return this->relevantForForces; } //UbTupleDouble3 getForces(); //UbTupleDouble3 getForces(Patch3DPtr patch); - virtual void addBCAdapter(const D3Q27BoundaryConditionAdapterPtr bcAdapter) { bcAdapterVector.push_back(bcAdapter); } + virtual void addBCAdapter(const BCAdapterPtr bcAdapter) { bcAdapterVector.push_back(bcAdapter); } void deleteBCAdapter() { bcAdapterVector.clear(); } //virtual std::vector< MbSmartPtr<D3Q27BoundaryConditionAdapter> > getBcAdapters() { return bcAdapterVector; } @@ -94,7 +94,7 @@ protected: bool reinitWithStoredQsFlag; //std::vector< MbSmartPtr<D3Q27BoundaryConditionAdapter> > bcAdapterVector; - std::vector<D3Q27BoundaryConditionAdapterPtr> bcAdapterVector; + std::vector<BCAdapterPtr> bcAdapterVector; typedef UbTuple<int,int,int,long long> UbTupleInt3LongLong; diff --git a/source/VirtualFluidsCore/Interactors/D3Q27TriFaceMeshInteractor.cpp b/source/VirtualFluidsCore/Interactors/D3Q27TriFaceMeshInteractor.cpp index 06c6dc813..b32d91726 100644 --- a/source/VirtualFluidsCore/Interactors/D3Q27TriFaceMeshInteractor.cpp +++ b/source/VirtualFluidsCore/Interactors/D3Q27TriFaceMeshInteractor.cpp @@ -15,12 +15,14 @@ #include "Block3D.h" #include "Grid3D.h" #include "BCArray3D.h" -#include "D3Q27BoundaryCondition.h" -#include "D3Q27VelocityBCAdapter.h" -#include "LBMKernelETD3Q27.h" -#include "D3Q27ETBCProcessor.h" +#include "BoundaryConditions.h" +#include "VelocityBCAdapter.h" +#include "LBMKernel.h" +#include "BCProcessor.h" #include "basics/utilities/UbTiming.h" +#include <omp.h> + #include <stack> using namespace std; @@ -36,13 +38,13 @@ D3Q27TriFaceMeshInteractor::D3Q27TriFaceMeshInteractor(Grid3DPtr grid, std::stri this->stressMode = STRESSNORMAL; } ////////////////////////////////////////////////////////////////////////// -D3Q27TriFaceMeshInteractor::D3Q27TriFaceMeshInteractor(GbTriFaceMesh3DPtr triFaceMesh, Grid3DPtr grid, D3Q27BoundaryConditionAdapterPtr bcAdapter, int type) +D3Q27TriFaceMeshInteractor::D3Q27TriFaceMeshInteractor(GbTriFaceMesh3DPtr triFaceMesh, Grid3DPtr grid, BCAdapterPtr bcAdapter, int type) : D3Q27Interactor(triFaceMesh, grid, bcAdapter, type), forceshift(0.0), velocityshift(0.0), forceshiftpolicy(false), velocityshiftpolicy(false), useHalfSpace(true), regardPIOTest(true) { this->stressMode = STRESSNORMAL; } ////////////////////////////////////////////////////////////////////////// -D3Q27TriFaceMeshInteractor::D3Q27TriFaceMeshInteractor(GbTriFaceMesh3DPtr triFaceMesh, Grid3DPtr grid, D3Q27BoundaryConditionAdapterPtr bcAdapter, int type, Interactor3D::Accuracy a) +D3Q27TriFaceMeshInteractor::D3Q27TriFaceMeshInteractor(GbTriFaceMesh3DPtr triFaceMesh, Grid3DPtr grid, BCAdapterPtr bcAdapter, int type, Interactor3D::Accuracy a) : D3Q27Interactor(triFaceMesh, grid, bcAdapter, type, a), forceshift(0.0), velocityshift(0.0), forceshiftpolicy(false), velocityshiftpolicy(false), useHalfSpace(true), regardPIOTest(true) { this->stressMode = STRESSNORMAL; @@ -71,10 +73,10 @@ bool D3Q27TriFaceMeshInteractor::setDifferencesToGbObject3D(const Block3DPtr blo bool oneEntryGotBC = false; //ob ueberhaupt ein eintrag ein BC zugewiesen wurde bool gotQs = false; //true, wenn "difference" gesetzt wurde - D3Q27BoundaryConditionPtr bc; + BoundaryConditionsPtr bc; - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); double internX1,internX2,internX3; @@ -284,7 +286,7 @@ void D3Q27TriFaceMeshInteractor::setQs(const double& timeStep) ////////////////////////////////////////////////////////////////////////// double e1x1,e1x2,e1x3,e2x1,e2x2,e2x3,px1,px2,px3,a,f,sx1,sx2,sx3,u,qx1,qx2,qx3,v; bool gotQs = false; - D3Q27BoundaryConditionPtr bc; + BoundaryConditionsPtr bc; for(int level=coarsestInitLevel; level<=finestInitLevel; level++) { @@ -343,8 +345,8 @@ void D3Q27TriFaceMeshInteractor::setQs(const double& timeStep) ////////////////////////////////////////////////////////////////////////// bool blockGotBCs = false; - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcMatrix = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcMatrix = kernel->getBCProcessor()->getBCArray(); int indexMinX1 = 0; int indexMinX2 = 0; @@ -418,7 +420,7 @@ void D3Q27TriFaceMeshInteractor::setQs(const double& timeStep) //Raytracingfür diskrete Boltzmannrichtungen ///////////////////////////////////////////////////////////////////////////// gotQs = false; - bc = D3Q27BoundaryConditionPtr(); + bc = BoundaryConditionsPtr(); //RAYTRACING - diskrete LB-dir zu Dreick //e1 = v1 - v0 @@ -499,7 +501,7 @@ void D3Q27TriFaceMeshInteractor::setQs(const double& timeStep) //SG 26.08.2010 if(!bc && !bcMatrix.isSolid()) if(!bc) { - bc = D3Q27BoundaryConditionPtr(new D3Q27BoundaryCondition);; + bc = BoundaryConditionsPtr(new BoundaryConditions);; bcMatrix.setBC(ix1,ix2,ix3,bc); } else if( UbMath::less( bc->getQ(fdir), q ) ) //schon ein kuerzeres q voehanden? @@ -760,7 +762,7 @@ void D3Q27TriFaceMeshInteractor::initInteractor2(const double& timeStep) ////////////////////////////////////////////////////////////////////////// double e1x1,e1x2,e1x3,e2x1,e2x2,e2x3,px1,px2,px3,a,f,sx1,sx2,sx3,u,qx1,qx2,qx3,v; bool gotQs = false; - D3Q27BoundaryConditionPtr bc; + BoundaryConditionsPtr bc; for(int level=coarsestInitLevel; level<=finestInitLevel; level++) { @@ -819,8 +821,8 @@ void D3Q27TriFaceMeshInteractor::initInteractor2(const double& timeStep) ////////////////////////////////////////////////////////////////////////// bool blockGotBCs = false; - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcMatrix = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcMatrix = kernel->getBCProcessor()->getBCArray(); int indexMinX1 = 0; int indexMinX2 = 0; @@ -926,7 +928,7 @@ void D3Q27TriFaceMeshInteractor::initInteractor2(const double& timeStep) //Raytracingfür diskrete Boltzmannrichtungen ///////////////////////////////////////////////////////////////////////////// gotQs = false; - bc = D3Q27BoundaryConditionPtr(); + bc = BoundaryConditionsPtr(); //RAYTRACING - diskrete LB-dir zu Dreick //e1 = v1 - v0 @@ -1001,7 +1003,7 @@ void D3Q27TriFaceMeshInteractor::initInteractor2(const double& timeStep) //SG 26.08.2010 if(!bc && !bcMatrix.isSolid()) if(!bc) { - bc = D3Q27BoundaryConditionPtr(new D3Q27BoundaryCondition);; + bc = BoundaryConditionsPtr(new BoundaryConditions);; bcMatrix.setBC(ix1,ix2,ix3,bc); } else if( UbMath::less( bc->getQ(fdir), q ) ) //schon ein kuerzeres q voehanden? @@ -1115,9 +1117,9 @@ void D3Q27TriFaceMeshInteractor::initInteractor2(const double& timeStep) scanlineCounter++; scanLineTimer.start(); - LBMKernel3DPtr kernel = block->getKernel(); + LBMKernelPtr kernel = block->getKernel(); if(!kernel) throw UbException(UB_EXARGS,"na sowas kein kernel bzw. kernel=NULL (2)"); - BCArray3D<D3Q27BoundaryCondition>& bcMatrix = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + BCArray3D& bcMatrix = kernel->getBCProcessor()->getBCArray(); // bvd->getTimer().start(); int indexMinX1 = 0; @@ -1284,8 +1286,18 @@ void D3Q27TriFaceMeshInteractor::refineBlockGridToLevel(int level, double startD float triPoints[3][3]; size_t nofTriangles = (int)triangles.size(); + +//#pragma omp parallel +//#pragma omp for for(size_t i=0; i<nofTriangles; i++) + //for(int i=0; i<nofTriangles; i++) { +//#pragma omp master + //{ + // printf_s("num_threads=%d\n", omp_get_num_threads( )); + //} + + GbTriFaceMesh3D::TriFace& triangle = triangles[i]; GbTriFaceMesh3D::Vertex& v1 = nodes[triangle.v1]; @@ -1744,8 +1756,8 @@ void D3Q27TriFaceMeshInteractor::reinitWithStoredQs( const double& timeStep ) { Block3DPtr block = it1->first; - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcMatrix = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcMatrix = kernel->getBCProcessor()->getBCArray(); std::set< UbTupleInt3 >& indicesSet = it1->second; for( std::set< UbTupleInt3 >::iterator setIt=indicesSet.begin(); setIt!=indicesSet.end(); ++setIt ) @@ -1759,8 +1771,8 @@ void D3Q27TriFaceMeshInteractor::reinitWithStoredQs( const double& timeStep ) for( it=transNodeIndicesAndQsMap.begin(); it!=transNodeIndicesAndQsMap.end(); ++it ) { Block3DPtr block = it->first; - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcMatrix = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcMatrix = kernel->getBCProcessor()->getBCArray(); std::map< UbTupleInt3, std::vector<float> >::iterator it2; for( it2=it->second.begin(); it2!=it->second.end(); ++it2 ) @@ -1771,10 +1783,10 @@ void D3Q27TriFaceMeshInteractor::reinitWithStoredQs( const double& timeStep ) //SG_27.08.2010 if(bcMatrix.isSolid(val<1>(pos), val<2>(pos), val<3>(pos))) continue; - D3Q27BoundaryConditionPtr bc = bcMatrix.getBC( val<1>(pos), val<2>(pos), val<3>(pos) ); + BoundaryConditionsPtr bc = bcMatrix.getBC( val<1>(pos), val<2>(pos), val<3>(pos) ); if(!bc) { - bc = D3Q27BoundaryConditionPtr(new D3Q27BoundaryCondition); + bc = BoundaryConditionsPtr(new BoundaryConditions); bcMatrix.setBC( val<1>(pos), val<2>(pos), val<3>(pos), bc ); } diff --git a/source/VirtualFluidsCore/Interactors/D3Q27TriFaceMeshInteractor.h b/source/VirtualFluidsCore/Interactors/D3Q27TriFaceMeshInteractor.h index a788046eb..feb373efc 100644 --- a/source/VirtualFluidsCore/Interactors/D3Q27TriFaceMeshInteractor.h +++ b/source/VirtualFluidsCore/Interactors/D3Q27TriFaceMeshInteractor.h @@ -37,8 +37,8 @@ public: D3Q27TriFaceMeshInteractor(); D3Q27TriFaceMeshInteractor(Grid3DPtr grid, std::string name="D3Q27TriFaceMeshInteractor"); D3Q27TriFaceMeshInteractor(GbObject3DPtr geoObject3D, Grid3DPtr grid, int type); - D3Q27TriFaceMeshInteractor(GbTriFaceMesh3DPtr triFaceMesh, Grid3DPtr grid, D3Q27BoundaryConditionAdapterPtr bcAdapter, int type); - D3Q27TriFaceMeshInteractor(GbTriFaceMesh3DPtr triFaceMesh, Grid3DPtr grid, D3Q27BoundaryConditionAdapterPtr bcAdapter, int type, Interactor3D::Accuracy a); + D3Q27TriFaceMeshInteractor(GbTriFaceMesh3DPtr triFaceMesh, Grid3DPtr grid, BCAdapterPtr bcAdapter, int type); + D3Q27TriFaceMeshInteractor(GbTriFaceMesh3DPtr triFaceMesh, Grid3DPtr grid, BCAdapterPtr bcAdapter, int type, Interactor3D::Accuracy a); //D3Q27TriFaceMeshInteractor(GbTriFaceMesh3DPtr triFaceMesh, D3Q27BoundaryConditionAdapterPtr bcAdapter, int type, std::string name="D3Q27TriFaceMeshInteractor"); ~D3Q27TriFaceMeshInteractor(); diff --git a/source/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp b/source/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp index b599380e5..5b9b88c27 100644 --- a/source/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp +++ b/source/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp @@ -1,6 +1,6 @@ #include "CompressibleCumulantLBMKernel.h" #include "D3Q27System.h" -#include "D3Q27InterpolationProcessor.h" +#include "InterpolationProcessor.h" #include "D3Q27EsoTwist3DSplittedVector.h" #include <math.h> #include <omp.h> @@ -14,9 +14,11 @@ CompressibleCumulantLBMKernel::CompressibleCumulantLBMKernel() } ////////////////////////////////////////////////////////////////////////// CompressibleCumulantLBMKernel::CompressibleCumulantLBMKernel(int nx1, int nx2, int nx3, Parameter p) - : LBMKernelETD3Q27(nx1, nx2, nx3), - parameter(p) { + this->nx1 = nx1; + this->nx2 = nx2; + this->nx3 = nx3; + parameter = p; this->compressible = true; } ////////////////////////////////////////////////////////////////////////// @@ -31,9 +33,9 @@ void CompressibleCumulantLBMKernel::init() dataSet->setFdistributions(d); } ////////////////////////////////////////////////////////////////////////// -LBMKernel3DPtr CompressibleCumulantLBMKernel::clone() +LBMKernelPtr CompressibleCumulantLBMKernel::clone() { - LBMKernel3DPtr kernel(new CompressibleCumulantLBMKernel(nx1, nx2, nx3, parameter)); + LBMKernelPtr kernel(new CompressibleCumulantLBMKernel(nx1, nx2, nx3, parameter)); boost::dynamic_pointer_cast<CompressibleCumulantLBMKernel>(kernel)->init(); kernel->setCollisionFactor(this->collFactor); kernel->setBCProcessor(bcProcessor->clone(kernel)); @@ -95,7 +97,7 @@ void CompressibleCumulantLBMKernel::collideAll() nonLocalDistributions = boost::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getNonLocalDistributions(); zeroDistributions = boost::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getZeroDistributions(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(this->getBCProcessor())->getBCArray(); + BCArray3D& bcArray = this->getBCProcessor()->getBCArray(); const int bcArrayMaxX1 = (int)bcArray.getNX1(); const int bcArrayMaxX2 = (int)bcArray.getNX2(); diff --git a/source/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.h b/source/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.h index dc4073e94..23a2a056d 100644 --- a/source/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.h +++ b/source/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.h @@ -1,8 +1,8 @@ #ifndef CompressibleCumulantLBMKernel_h__ #define CompressibleCumulantLBMKernel_h__ -#include "LBMKernelETD3Q27.h" -#include "D3Q27ETBCProcessor.h" +#include "LBMKernel.h" +#include "BCProcessor.h" #include "D3Q27System.h" #include <boost/serialization/export.hpp> #include "basics/utilities/UbTiming.h" @@ -15,7 +15,7 @@ typedef boost::shared_ptr<CompressibleCumulantLBMKernel> CompressibleCumulantLBM //! \brief compressible cumulant LBM kernel. //! \details CFD solver that use Cascaded Cumulant Lattice Boltzmann method for D3Q27 model //! \author K. Kutscher, M. Geier -class CompressibleCumulantLBMKernel : public LBMKernelETD3Q27 +class CompressibleCumulantLBMKernel : public LBMKernel { public: //! This option set relaxation parameter: NORMAL @@ -30,7 +30,7 @@ public: CompressibleCumulantLBMKernel(int nx1, int nx2, int nx3, Parameter p); virtual ~CompressibleCumulantLBMKernel(void); virtual void calculate(); - virtual LBMKernel3DPtr clone(); + virtual LBMKernelPtr clone(); double getCallculationTime(); protected: @@ -38,7 +38,7 @@ protected: template<class Archive> void serialize(Archive & ar, const unsigned int version) { - ar & boost::serialization::base_object<LBMKernelETD3Q27>(*this); + ar & boost::serialization::base_object<LBMKernel>(*this); ar & OxyyMxzz; ar & parameter; } diff --git a/source/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.cpp b/source/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.cpp index 652a03988..ce211998a 100644 --- a/source/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.cpp +++ b/source/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.cpp @@ -21,9 +21,9 @@ CompressibleOffsetInterpolationProcessor::~CompressibleOffsetInterpolationProces } ////////////////////////////////////////////////////////////////////////// -D3Q27InterpolationProcessorPtr CompressibleOffsetInterpolationProcessor::clone() +InterpolationProcessorPtr CompressibleOffsetInterpolationProcessor::clone() { - D3Q27InterpolationProcessorPtr iproc = D3Q27InterpolationProcessorPtr (new CompressibleOffsetInterpolationProcessor(this->omegaC, this->omegaF)); + InterpolationProcessorPtr iproc = InterpolationProcessorPtr (new CompressibleOffsetInterpolationProcessor(this->omegaC, this->omegaF)); //boost::dynamic_pointer_cast<D3Q27IncompressibleOffsetInterpolationProcessor>(iproc)->forcingC = forcingC; //boost::dynamic_pointer_cast<D3Q27IncompressibleOffsetInterpolationProcessor>(iproc)->forcingF = forcingF; return iproc; diff --git a/source/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.h b/source/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.h index e3bea7b46..8d20c5aa0 100644 --- a/source/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.h +++ b/source/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.h @@ -1,7 +1,7 @@ #ifndef CompressibleOffsetInterpolationProcessor_H_ #define CompressibleOffsetInterpolationProcessor_H_ -#include "D3Q27InterpolationProcessor.h" +#include "InterpolationProcessor.h" #include "D3Q27System.h" ////////////////////////////////////////////////////////////////////////// @@ -12,13 +12,13 @@ class CompressibleOffsetInterpolationProcessor; typedef boost::shared_ptr<CompressibleOffsetInterpolationProcessor> CompressibleOffsetInterpolationProcessorPtr; -class CompressibleOffsetInterpolationProcessor : public D3Q27InterpolationProcessor +class CompressibleOffsetInterpolationProcessor : public InterpolationProcessor { public: CompressibleOffsetInterpolationProcessor(); CompressibleOffsetInterpolationProcessor(LBMReal omegaC, LBMReal omegaF); virtual ~CompressibleOffsetInterpolationProcessor(); - D3Q27InterpolationProcessorPtr clone(); + InterpolationProcessorPtr clone(); void setOmegas(LBMReal omegaC, LBMReal omegaF); void interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF); void interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF, LBMReal xoff, LBMReal yoff, LBMReal zoff); diff --git a/source/VirtualFluidsCore/LBM/D3Q27CompactInterpolationProcessor.cpp b/source/VirtualFluidsCore/LBM/D3Q27CompactInterpolationProcessor.cpp deleted file mode 100644 index 38b0996c6..000000000 --- a/source/VirtualFluidsCore/LBM/D3Q27CompactInterpolationProcessor.cpp +++ /dev/null @@ -1,370 +0,0 @@ -#include "D3Q27CompactInterpolationProcessor.h" - -#include <boost/foreach.hpp> - -D3Q27CompactInterpolationProcessor::D3Q27CompactInterpolationProcessor() - : omegaC(0.0), omegaF(0.0) -{ - init(); -} -////////////////////////////////////////////////////////////////////////// -D3Q27CompactInterpolationProcessor::D3Q27CompactInterpolationProcessor(LBMReal omegaC, LBMReal omegaF, bool compressible=false) - : omegaC(omegaC), omegaF(omegaF), compressible(compressible) -{ - init(); -} -////////////////////////////////////////////////////////////////////////// -D3Q27CompactInterpolationProcessor::~D3Q27CompactInterpolationProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -D3Q27InterpolationProcessorPtr D3Q27CompactInterpolationProcessor::clone() -{ - return D3Q27InterpolationProcessorPtr (new D3Q27CompactInterpolationProcessor(this->omegaC, this->omegaF)); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27CompactInterpolationProcessor::init() -{ - calcFeqsForDirFct = NULL; - calcMacrosFct = NULL; - calcFeqFct = NULL; - - if(compressible) - { - calcMacrosFct = &D3Q27System::calcCompMacroscopicValues; - calcFeqFct = &D3Q27System::calcCompFeq; - } - else - { - calcMacrosFct = &D3Q27System::calcIncompMacroscopicValues; - calcFeqFct = &D3Q27System::calcIncompFeq; - } -} -////////////////////////////////////////////////////////////////////////// -void D3Q27CompactInterpolationProcessor::setOmegas( LBMReal omegaC, LBMReal omegaF ) -{ - this->omegaC = omegaC; - this->omegaF = omegaF; -} -////////////////////////////////////////////////////////////////////////// -void D3Q27CompactInterpolationProcessor::interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF) -{ - calcInterpolatedCoefficiets(icellC, omegaC); - calcInterpolatedNode(icellF.BSW, omegaF, -0.25, -0.25, -0.25); - calcInterpolatedNode(icellF.BNE, omegaF, 0.25, 0.25, -0.25); - calcInterpolatedNode(icellF.TNW, omegaF, -0.25, 0.25, 0.25); - calcInterpolatedNode(icellF.TSE, omegaF, 0.25, -0.25, 0.25); - calcInterpolatedNode(icellF.BNW, omegaF, -0.25, 0.25, -0.25); - calcInterpolatedNode(icellF.BSE, omegaF, 0.25, -0.25, -0.25); - calcInterpolatedNode(icellF.TSW, omegaF, -0.25, -0.25, 0.25); - calcInterpolatedNode(icellF.TNE, omegaF, 0.25, 0.25, 0.25); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27CompactInterpolationProcessor::interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC) -{ - calcInterpolatedCoefficiets(icellF, omegaF); - calcInterpolatedNode(icellC, omegaC, 0.0, 0.0, 0.0); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27CompactInterpolationProcessor::interpolate8to1(D3Q27ICell& icellF, LBMReal* icellC, double x1, double x2, double x3, LBMReal omega) -{ - calcInterpolatedCoefficiets(icellF, omega); - calcInterpolatedNode(icellC, omega, x1, x2, x3); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27CompactInterpolationProcessor::calcMoments(const LBMReal* const f, LBMReal omega, LBMReal& rho, LBMReal& vx1, LBMReal& vx2, LBMReal& vx3, - LBMReal& kxy, LBMReal& kyz, LBMReal& kxz, LBMReal& kxxMyy, LBMReal& kxxMzz) -{ - using namespace D3Q27System; - - LBMReal fd[ENDF+1]; - LBMReal feq[ENDF+1]; - - calcMacrosFct(f,rho,vx1,vx2,vx3); - calcFeqFct(feq,rho,vx1,vx2,vx3); - - fd[E] = f[E] - feq[E]; - fd[W] = f[W] - feq[W]; - fd[N] = f[N] - feq[N]; - fd[S] = f[S] - feq[S]; - fd[T] = f[T] - feq[T]; - fd[B] = f[B] - feq[B]; - fd[NE] = f[NE] - feq[NE]; - fd[SW] = f[SW] - feq[SW]; - fd[SE] = f[SE] - feq[SE]; - fd[NW] = f[NW] - feq[NW]; - fd[TE] = f[TE] - feq[TE]; - fd[BW] = f[BW] - feq[BW]; - fd[BE] = f[BE] - feq[BE]; - fd[TW] = f[TW] - feq[TW]; - fd[TN] = f[TN] - feq[TN]; - fd[BS] = f[BS] - feq[BS]; - fd[BN] = f[BN] - feq[BN]; - fd[TS] = f[TS] - feq[TS]; - fd[TNE] = f[TNE] - feq[TNE]; - fd[TNW] = f[TNW] - feq[TNW]; - fd[TSE] = f[TSE] - feq[TSE]; - fd[TSW] = f[TSW] - feq[TSW]; - fd[BNE] = f[BNE] - feq[BNE]; - fd[BNW] = f[BNW] - feq[BNW]; - fd[BSE] = f[BSE] - feq[BSE]; - fd[BSW] = f[BSW] - feq[BSW]; - fd[ZERO] = f[ZERO] - feq[ZERO]; - - kxy = -3.*omega*(fd[SW]+fd[TSW]+fd[BSW]-fd[NW]-fd[TNW]-fd[BNW]-fd[SE]-fd[TSE]-fd[BSE]+fd[NE]+fd[TNE]+fd[BNE]); - kyz = -3.*omega*(fd[BS]+fd[BSW]+fd[BSE]-fd[TS]-fd[TSW]-fd[TSE]-fd[BN]-fd[BNW]-fd[BNE]+fd[TN]+fd[TNW]+fd[TNE]); - kxz = -3.*omega*(fd[BW]+fd[BNW]+fd[BSW]-fd[TW]-fd[TNW]-fd[TSW]-fd[BE]-fd[BNE]-fd[BSE]+fd[TE]+fd[TNE]+fd[TSE]); - kxxMyy = -3./2.*omega*(fd[BW]+fd[W]+fd[TW]-fd[BS]-fd[S]-fd[TS]-fd[BN]-fd[N]-fd[TN]+fd[BE]+fd[E]+fd[TE]); - kxxMzz = -3./2.*omega*(fd[SW]+fd[W]+fd[NW]-fd[BS]-fd[TS]-fd[B]-fd[T]-fd[BN]-fd[TN]+fd[SE]+fd[E]+fd[NE]); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27CompactInterpolationProcessor::calcInterpolatedCoefficiets(const D3Q27ICell& icell, LBMReal omega) -{ - LBMReal epsylon = 1.0; - - LBMReal vx1_SWT,vx2_SWT,vx3_SWT; - LBMReal vx1_NWT,vx2_NWT,vx3_NWT; - LBMReal vx1_NET,vx2_NET,vx3_NET; - LBMReal vx1_SET,vx2_SET,vx3_SET; - LBMReal vx1_SWB,vx2_SWB,vx3_SWB; - LBMReal vx1_NWB,vx2_NWB,vx3_NWB; - LBMReal vx1_NEB,vx2_NEB,vx3_NEB; - LBMReal vx1_SEB,vx2_SEB,vx3_SEB; - - LBMReal kxyFromfcNEQ_SWT, kyzFromfcNEQ_SWT, kxzFromfcNEQ_SWT, kxxMyyFromfcNEQ_SWT, kxxMzzFromfcNEQ_SWT; - LBMReal kxyFromfcNEQ_NWT, kyzFromfcNEQ_NWT, kxzFromfcNEQ_NWT, kxxMyyFromfcNEQ_NWT, kxxMzzFromfcNEQ_NWT; - LBMReal kxyFromfcNEQ_NET, kyzFromfcNEQ_NET, kxzFromfcNEQ_NET, kxxMyyFromfcNEQ_NET, kxxMzzFromfcNEQ_NET; - LBMReal kxyFromfcNEQ_SET, kyzFromfcNEQ_SET, kxzFromfcNEQ_SET, kxxMyyFromfcNEQ_SET, kxxMzzFromfcNEQ_SET; - LBMReal kxyFromfcNEQ_SWB, kyzFromfcNEQ_SWB, kxzFromfcNEQ_SWB, kxxMyyFromfcNEQ_SWB, kxxMzzFromfcNEQ_SWB; - LBMReal kxyFromfcNEQ_NWB, kyzFromfcNEQ_NWB, kxzFromfcNEQ_NWB, kxxMyyFromfcNEQ_NWB, kxxMzzFromfcNEQ_NWB; - LBMReal kxyFromfcNEQ_NEB, kyzFromfcNEQ_NEB, kxzFromfcNEQ_NEB, kxxMyyFromfcNEQ_NEB, kxxMzzFromfcNEQ_NEB; - LBMReal kxyFromfcNEQ_SEB, kyzFromfcNEQ_SEB, kxzFromfcNEQ_SEB, kxxMyyFromfcNEQ_SEB, kxxMzzFromfcNEQ_SEB; - - calcMoments(icell.TSW,omega,drho_SWT,vx1_SWT,vx2_SWT,vx3_SWT, kxyFromfcNEQ_SWT, kyzFromfcNEQ_SWT, kxzFromfcNEQ_SWT, kxxMyyFromfcNEQ_SWT, kxxMzzFromfcNEQ_SWT); - calcMoments(icell.TNW,omega,drho_NWT,vx1_NWT,vx2_NWT,vx3_NWT, kxyFromfcNEQ_NWT, kyzFromfcNEQ_NWT, kxzFromfcNEQ_NWT, kxxMyyFromfcNEQ_NWT, kxxMzzFromfcNEQ_NWT); - calcMoments(icell.TNE,omega,drho_NET,vx1_NET,vx2_NET,vx3_NET, kxyFromfcNEQ_NET, kyzFromfcNEQ_NET, kxzFromfcNEQ_NET, kxxMyyFromfcNEQ_NET, kxxMzzFromfcNEQ_NET); - calcMoments(icell.TSE,omega,drho_SET,vx1_SET,vx2_SET,vx3_SET, kxyFromfcNEQ_SET, kyzFromfcNEQ_SET, kxzFromfcNEQ_SET, kxxMyyFromfcNEQ_SET, kxxMzzFromfcNEQ_SET); - calcMoments(icell.BSW,omega,drho_SWB,vx1_SWB,vx2_SWB,vx3_SWB, kxyFromfcNEQ_SWB, kyzFromfcNEQ_SWB, kxzFromfcNEQ_SWB, kxxMyyFromfcNEQ_SWB, kxxMzzFromfcNEQ_SWB); - calcMoments(icell.BNW,omega,drho_NWB,vx1_NWB,vx2_NWB,vx3_NWB, kxyFromfcNEQ_NWB, kyzFromfcNEQ_NWB, kxzFromfcNEQ_NWB, kxxMyyFromfcNEQ_NWB, kxxMzzFromfcNEQ_NWB); - calcMoments(icell.BNE,omega,drho_NEB,vx1_NEB,vx2_NEB,vx3_NEB, kxyFromfcNEQ_NEB, kyzFromfcNEQ_NEB, kxzFromfcNEQ_NEB, kxxMyyFromfcNEQ_NEB, kxxMzzFromfcNEQ_NEB); - calcMoments(icell.BSE,omega,drho_SEB,vx1_SEB,vx2_SEB,vx3_SEB, kxyFromfcNEQ_SEB, kyzFromfcNEQ_SEB, kxzFromfcNEQ_SEB, kxxMyyFromfcNEQ_SEB, kxxMzzFromfcNEQ_SEB); - - a0 = 8.*vx1_SWB + 8.*vx1_NWT + 8.*vx1_SET + 8.*vx1_NEB + 2.*vx2_SWB - 2.*vx2_NWT - 2.*vx2_SET + 2.*vx2_NEB + 2.*vx3_SWB - 2.*vx3_NWT + 2.*vx3_SET - 2.*vx3_NEB + kxxMyyFromfcNEQ_SWB + kxxMyyFromfcNEQ_NWT - kxxMyyFromfcNEQ_SET - kxxMyyFromfcNEQ_NEB + kxxMzzFromfcNEQ_SWB + kxxMzzFromfcNEQ_NWT - kxxMzzFromfcNEQ_SET - kxxMzzFromfcNEQ_NEB + 2.*kxyFromfcNEQ_SWB - 2.*kxyFromfcNEQ_NWT + 2.*kxyFromfcNEQ_SET - 2.*kxyFromfcNEQ_NEB + 2.*kxzFromfcNEQ_SWB - 2.*kxzFromfcNEQ_NWT - 2.*kxzFromfcNEQ_SET + 2.*kxzFromfcNEQ_NEB + kyzFromfcNEQ_SWB + kyzFromfcNEQ_NWT + kyzFromfcNEQ_SET + kyzFromfcNEQ_NEB; - ax = (-4.*vx1_SWB - 4.*vx1_NWT + 4.*vx1_SET + 4.*vx1_NEB - kxyFromfcNEQ_SWB + kxyFromfcNEQ_NWT + kxyFromfcNEQ_SET - kxyFromfcNEQ_NEB - kxzFromfcNEQ_SWB + kxzFromfcNEQ_NWT - kxzFromfcNEQ_SET + kxzFromfcNEQ_NEB + kyzFromfcNEQ_SWB + kyzFromfcNEQ_NWT - kyzFromfcNEQ_SET - kyzFromfcNEQ_NEB)/epsylon; - ay = (-2.*vx1_SWB + 2.*vx1_NWT - 2.*vx1_SET + 2.*vx1_NEB + 2.*vx2_SWB + 2.*vx2_NWT - 2.*vx2_SET - 2.*vx2_NEB - kxxMyyFromfcNEQ_SWB + kxxMyyFromfcNEQ_NWT + kxxMyyFromfcNEQ_SET - kxxMyyFromfcNEQ_NEB + kxyFromfcNEQ_SWB + kxyFromfcNEQ_NWT + kxyFromfcNEQ_SET + kxyFromfcNEQ_NEB)/epsylon; - az = (-2.*vx1_SWB + 2.*vx1_NWT + 2.*vx1_SET - 2.*vx1_NEB + 2.*vx3_SWB + 2.*vx3_NWT - 2.*vx3_SET - 2.*vx3_NEB - kxxMzzFromfcNEQ_SWB + kxxMzzFromfcNEQ_NWT - kxxMzzFromfcNEQ_SET + kxxMzzFromfcNEQ_NEB + kxzFromfcNEQ_SWB + kxzFromfcNEQ_NWT + kxzFromfcNEQ_SET + kxzFromfcNEQ_NEB)/epsylon; - axx= (2.*vx2_SWB - 2.*vx2_NWT - 2.*vx2_SET + 2.*vx2_NEB + 2.*vx3_SWB - 2.*vx3_NWT + 2.*vx3_SET - 2.*vx3_NEB - kxxMyyFromfcNEQ_SWB - kxxMyyFromfcNEQ_NWT + kxxMyyFromfcNEQ_SET + kxxMyyFromfcNEQ_NEB - kxxMzzFromfcNEQ_SWB - kxxMzzFromfcNEQ_NWT + kxxMzzFromfcNEQ_SET + kxxMzzFromfcNEQ_NEB + kyzFromfcNEQ_SWB + kyzFromfcNEQ_NWT + kyzFromfcNEQ_SET + kyzFromfcNEQ_NEB)/(epsylon*epsylon); - ayy= (-2.*vx2_SWB + 2.*vx2_NWT + 2.*vx2_SET - 2.*vx2_NEB - 2.*vx3_SWB + 2.*vx3_NWT - 2.*vx3_SET + 2.*vx3_NEB - kxxMyyFromfcNEQ_SWB - kxxMyyFromfcNEQ_NWT + kxxMyyFromfcNEQ_SET + kxxMyyFromfcNEQ_NEB + kxxMzzFromfcNEQ_SWB + kxxMzzFromfcNEQ_NWT - kxxMzzFromfcNEQ_SET - kxxMzzFromfcNEQ_NEB - 2.*kxyFromfcNEQ_SWB + 2.*kxyFromfcNEQ_NWT - 2.*kxyFromfcNEQ_SET + 2.*kxyFromfcNEQ_NEB - kyzFromfcNEQ_SWB - kyzFromfcNEQ_NWT - kyzFromfcNEQ_SET - kyzFromfcNEQ_NEB)/(epsylon*epsylon); - azz= (-2.*vx2_SWB + 2.*vx2_NWT + 2.*vx2_SET - 2.*vx2_NEB - 2.*vx3_SWB + 2.*vx3_NWT - 2.*vx3_SET + 2.*vx3_NEB + kxxMyyFromfcNEQ_SWB + kxxMyyFromfcNEQ_NWT - kxxMyyFromfcNEQ_SET - kxxMyyFromfcNEQ_NEB - kxxMzzFromfcNEQ_SWB - kxxMzzFromfcNEQ_NWT + kxxMzzFromfcNEQ_SET + kxxMzzFromfcNEQ_NEB - 2.*kxzFromfcNEQ_SWB + 2.*kxzFromfcNEQ_NWT + 2.*kxzFromfcNEQ_SET - 2.*kxzFromfcNEQ_NEB - kyzFromfcNEQ_SWB - kyzFromfcNEQ_NWT - kyzFromfcNEQ_SET - kyzFromfcNEQ_NEB)/(epsylon*epsylon); - axy= (2.*vx1_SWB - 2.*vx1_NWT - 2.*vx1_SET + 2.*vx1_NEB + 2.*vx3_SWB + 2.*vx3_NWT - 2.*vx3_SET - 2.*vx3_NEB - kxxMzzFromfcNEQ_SWB + kxxMzzFromfcNEQ_NWT - kxxMzzFromfcNEQ_SET + kxxMzzFromfcNEQ_NEB + kxzFromfcNEQ_SWB + kxzFromfcNEQ_NWT + kxzFromfcNEQ_SET + kxzFromfcNEQ_NEB)/(epsylon*epsylon); - axz= (2.*vx1_SWB - 2.*vx1_NWT + 2.*vx1_SET - 2.*vx1_NEB + 2.*vx2_SWB + 2.*vx2_NWT - 2.*vx2_SET - 2.*vx2_NEB - kxxMyyFromfcNEQ_SWB + kxxMyyFromfcNEQ_NWT + kxxMyyFromfcNEQ_SET - kxxMyyFromfcNEQ_NEB + kxyFromfcNEQ_SWB + kxyFromfcNEQ_NWT + kxyFromfcNEQ_SET + kxyFromfcNEQ_NEB)/(epsylon*epsylon); - ayz= (-kxyFromfcNEQ_SWB + kxyFromfcNEQ_NWT + kxyFromfcNEQ_SET - kxyFromfcNEQ_NEB - kxzFromfcNEQ_SWB + kxzFromfcNEQ_NWT - kxzFromfcNEQ_SET + kxzFromfcNEQ_NEB + kyzFromfcNEQ_SWB + kyzFromfcNEQ_NWT - kyzFromfcNEQ_SET - kyzFromfcNEQ_NEB)/(epsylon*epsylon); - b0 = 2.*vx1_SWB - 2.*vx1_NWT - 2.*vx1_SET + 2.*vx1_NEB + 8.*vx2_SWB + 8.*vx2_NWT + 8.*vx2_SET + 8.*vx2_NEB + 2.*vx3_SWB + 2.*vx3_NWT - 2.*vx3_SET - 2.*vx3_NEB - 2.*kxxMyyFromfcNEQ_SWB + 2.*kxxMyyFromfcNEQ_NWT - 2.*kxxMyyFromfcNEQ_SET + 2.*kxxMyyFromfcNEQ_NEB + kxxMzzFromfcNEQ_SWB - kxxMzzFromfcNEQ_NWT + kxxMzzFromfcNEQ_SET - kxxMzzFromfcNEQ_NEB + 2.*kxyFromfcNEQ_SWB + 2.*kxyFromfcNEQ_NWT - 2.*kxyFromfcNEQ_SET - 2.*kxyFromfcNEQ_NEB + kxzFromfcNEQ_SWB + kxzFromfcNEQ_NWT + kxzFromfcNEQ_SET + kxzFromfcNEQ_NEB + 2.*kyzFromfcNEQ_SWB - 2.*kyzFromfcNEQ_NWT - 2.*kyzFromfcNEQ_SET + 2.*kyzFromfcNEQ_NEB; - bx = (2.*vx1_SWB - 2.*vx1_NWT + 2.*vx1_SET - 2.*vx1_NEB - 2.*vx2_SWB - 2.*vx2_NWT + 2.*vx2_SET + 2.*vx2_NEB + kxxMyyFromfcNEQ_SWB - kxxMyyFromfcNEQ_NWT - kxxMyyFromfcNEQ_SET + kxxMyyFromfcNEQ_NEB + kxyFromfcNEQ_SWB + kxyFromfcNEQ_NWT + kxyFromfcNEQ_SET + kxyFromfcNEQ_NEB)/epsylon; - by = (-4.*vx2_SWB + 4.*vx2_NWT - 4.*vx2_SET + 4.*vx2_NEB - kxyFromfcNEQ_SWB + kxyFromfcNEQ_NWT + kxyFromfcNEQ_SET - kxyFromfcNEQ_NEB + kxzFromfcNEQ_SWB - kxzFromfcNEQ_NWT + kxzFromfcNEQ_SET - kxzFromfcNEQ_NEB - kyzFromfcNEQ_SWB - kyzFromfcNEQ_NWT + kyzFromfcNEQ_SET + kyzFromfcNEQ_NEB)/epsylon; - bz = (-2.*vx2_SWB + 2.*vx2_NWT + 2.*vx2_SET - 2.*vx2_NEB + 2.*vx3_SWB - 2.*vx3_NWT + 2.*vx3_SET - 2.*vx3_NEB + kxxMyyFromfcNEQ_SWB + kxxMyyFromfcNEQ_NWT - kxxMyyFromfcNEQ_SET - kxxMyyFromfcNEQ_NEB - kxxMzzFromfcNEQ_SWB - kxxMzzFromfcNEQ_NWT + kxxMzzFromfcNEQ_SET + kxxMzzFromfcNEQ_NEB + kyzFromfcNEQ_SWB + kyzFromfcNEQ_NWT + kyzFromfcNEQ_SET + kyzFromfcNEQ_NEB)/epsylon; - bxx= (-2.*vx1_SWB + 2.*vx1_NWT + 2.*vx1_SET - 2.*vx1_NEB - 2.*vx3_SWB - 2.*vx3_NWT + 2.*vx3_SET + 2.*vx3_NEB + kxxMzzFromfcNEQ_SWB - kxxMzzFromfcNEQ_NWT + kxxMzzFromfcNEQ_SET - kxxMzzFromfcNEQ_NEB - 2.*kxyFromfcNEQ_SWB - 2.*kxyFromfcNEQ_NWT + 2.*kxyFromfcNEQ_SET + 2.*kxyFromfcNEQ_NEB - kxzFromfcNEQ_SWB - kxzFromfcNEQ_NWT - kxzFromfcNEQ_SET - kxzFromfcNEQ_NEB)/(epsylon*epsylon); - byy= (2.*vx1_SWB - 2.*vx1_NWT - 2.*vx1_SET + 2.*vx1_NEB + 2.*vx3_SWB + 2.*vx3_NWT - 2.*vx3_SET - 2.*vx3_NEB + 2.*kxxMyyFromfcNEQ_SWB - 2.*kxxMyyFromfcNEQ_NWT + 2.*kxxMyyFromfcNEQ_SET - 2.*kxxMyyFromfcNEQ_NEB - kxxMzzFromfcNEQ_SWB + kxxMzzFromfcNEQ_NWT - kxxMzzFromfcNEQ_SET + kxxMzzFromfcNEQ_NEB + kxzFromfcNEQ_SWB + kxzFromfcNEQ_NWT + kxzFromfcNEQ_SET + kxzFromfcNEQ_NEB)/(epsylon*epsylon); - bzz= (-2.*vx1_SWB + 2.*vx1_NWT + 2.*vx1_SET - 2.*vx1_NEB - 2.*vx3_SWB - 2.*vx3_NWT + 2.*vx3_SET + 2.*vx3_NEB - kxxMzzFromfcNEQ_SWB + kxxMzzFromfcNEQ_NWT - kxxMzzFromfcNEQ_SET + kxxMzzFromfcNEQ_NEB - kxzFromfcNEQ_SWB - kxzFromfcNEQ_NWT - kxzFromfcNEQ_SET - kxzFromfcNEQ_NEB - 2.*kyzFromfcNEQ_SWB + 2.*kyzFromfcNEQ_NWT + 2.*kyzFromfcNEQ_SET - 2.*kyzFromfcNEQ_NEB)/(epsylon*epsylon); - bxy= (2.*vx2_SWB - 2.*vx2_NWT - 2.*vx2_SET + 2.*vx2_NEB + 2.*vx3_SWB - 2.*vx3_NWT + 2.*vx3_SET - 2.*vx3_NEB + kxxMyyFromfcNEQ_SWB + kxxMyyFromfcNEQ_NWT - kxxMyyFromfcNEQ_SET - kxxMyyFromfcNEQ_NEB - kxxMzzFromfcNEQ_SWB - kxxMzzFromfcNEQ_NWT + kxxMzzFromfcNEQ_SET + kxxMzzFromfcNEQ_NEB + kyzFromfcNEQ_SWB + kyzFromfcNEQ_NWT + kyzFromfcNEQ_SET + kyzFromfcNEQ_NEB)/(epsylon*epsylon); - bxz= (-kxyFromfcNEQ_SWB + kxyFromfcNEQ_NWT + kxyFromfcNEQ_SET - kxyFromfcNEQ_NEB + kxzFromfcNEQ_SWB - kxzFromfcNEQ_NWT + kxzFromfcNEQ_SET - kxzFromfcNEQ_NEB - kyzFromfcNEQ_SWB - kyzFromfcNEQ_NWT + kyzFromfcNEQ_SET + kyzFromfcNEQ_NEB)/(epsylon*epsylon); - byz= (2.*vx1_SWB - 2.*vx1_NWT + 2.*vx1_SET - 2.*vx1_NEB + 2.*vx2_SWB + 2.*vx2_NWT - 2.*vx2_SET - 2.*vx2_NEB + kxxMyyFromfcNEQ_SWB - kxxMyyFromfcNEQ_NWT - kxxMyyFromfcNEQ_SET + kxxMyyFromfcNEQ_NEB + kxyFromfcNEQ_SWB + kxyFromfcNEQ_NWT + kxyFromfcNEQ_SET + kxyFromfcNEQ_NEB)/(epsylon*epsylon); - c0 = 2.*vx1_SWB - 2.*vx1_NWT + 2.*vx1_SET - 2.*vx1_NEB + 2.*vx2_SWB + 2.*vx2_NWT - 2.*vx2_SET - 2.*vx2_NEB + 8.*vx3_SWB + 8.*vx3_NWT + 8.*vx3_SET + 8.*vx3_NEB + kxxMyyFromfcNEQ_SWB - kxxMyyFromfcNEQ_NWT - kxxMyyFromfcNEQ_SET + kxxMyyFromfcNEQ_NEB - 2.*kxxMzzFromfcNEQ_SWB + 2.*kxxMzzFromfcNEQ_NWT + 2.*kxxMzzFromfcNEQ_SET - 2.*kxxMzzFromfcNEQ_NEB + kxyFromfcNEQ_SWB + kxyFromfcNEQ_NWT + kxyFromfcNEQ_SET + kxyFromfcNEQ_NEB + 2.*kxzFromfcNEQ_SWB + 2.*kxzFromfcNEQ_NWT - 2.*kxzFromfcNEQ_SET - 2.*kxzFromfcNEQ_NEB + 2.*kyzFromfcNEQ_SWB - 2.*kyzFromfcNEQ_NWT + 2.*kyzFromfcNEQ_SET - 2.*kyzFromfcNEQ_NEB; - cx = (2.*vx1_SWB - 2.*vx1_NWT - 2.*vx1_SET + 2.*vx1_NEB - 2.*vx3_SWB - 2.*vx3_NWT + 2.*vx3_SET + 2.*vx3_NEB + kxxMzzFromfcNEQ_SWB - kxxMzzFromfcNEQ_NWT + kxxMzzFromfcNEQ_SET - kxxMzzFromfcNEQ_NEB + kxzFromfcNEQ_SWB + kxzFromfcNEQ_NWT + kxzFromfcNEQ_SET + kxzFromfcNEQ_NEB)/epsylon; - cy = (2.*vx2_SWB - 2.*vx2_NWT - 2.*vx2_SET + 2.*vx2_NEB - 2.*vx3_SWB + 2.*vx3_NWT - 2.*vx3_SET + 2.*vx3_NEB - kxxMyyFromfcNEQ_SWB - kxxMyyFromfcNEQ_NWT + kxxMyyFromfcNEQ_SET + kxxMyyFromfcNEQ_NEB + kxxMzzFromfcNEQ_SWB + kxxMzzFromfcNEQ_NWT - kxxMzzFromfcNEQ_SET - kxxMzzFromfcNEQ_NEB + kyzFromfcNEQ_SWB + kyzFromfcNEQ_NWT + kyzFromfcNEQ_SET + kyzFromfcNEQ_NEB)/epsylon; - cz = (-4.*vx3_SWB + 4.*vx3_NWT + 4.*vx3_SET - 4.*vx3_NEB + kxyFromfcNEQ_SWB - kxyFromfcNEQ_NWT - kxyFromfcNEQ_SET + kxyFromfcNEQ_NEB - kxzFromfcNEQ_SWB + kxzFromfcNEQ_NWT - kxzFromfcNEQ_SET + kxzFromfcNEQ_NEB - kyzFromfcNEQ_SWB - kyzFromfcNEQ_NWT + kyzFromfcNEQ_SET + kyzFromfcNEQ_NEB)/epsylon; - cxx= (-2.*vx1_SWB + 2.*vx1_NWT - 2.*vx1_SET + 2.*vx1_NEB - 2.*vx2_SWB - 2.*vx2_NWT + 2.*vx2_SET + 2.*vx2_NEB + kxxMyyFromfcNEQ_SWB - kxxMyyFromfcNEQ_NWT - kxxMyyFromfcNEQ_SET + kxxMyyFromfcNEQ_NEB - kxyFromfcNEQ_SWB - kxyFromfcNEQ_NWT - kxyFromfcNEQ_SET - kxyFromfcNEQ_NEB - 2.*kxzFromfcNEQ_SWB - 2.*kxzFromfcNEQ_NWT + 2.*kxzFromfcNEQ_SET + 2.*kxzFromfcNEQ_NEB)/(epsylon*epsylon); - cyy= (-2.*vx1_SWB + 2.*vx1_NWT - 2.*vx1_SET + 2.*vx1_NEB - 2.*vx2_SWB - 2.*vx2_NWT + 2.*vx2_SET + 2.*vx2_NEB - kxxMyyFromfcNEQ_SWB + kxxMyyFromfcNEQ_NWT + kxxMyyFromfcNEQ_SET - kxxMyyFromfcNEQ_NEB - kxyFromfcNEQ_SWB - kxyFromfcNEQ_NWT - kxyFromfcNEQ_SET - kxyFromfcNEQ_NEB - 2.*kyzFromfcNEQ_SWB + 2.*kyzFromfcNEQ_NWT - 2.*kyzFromfcNEQ_SET + 2.*kyzFromfcNEQ_NEB)/(epsylon*epsylon); - czz= (2.*vx1_SWB - 2.*vx1_NWT + 2.*vx1_SET - 2.*vx1_NEB + 2.*vx2_SWB + 2.*vx2_NWT - 2.*vx2_SET - 2.*vx2_NEB - kxxMyyFromfcNEQ_SWB + kxxMyyFromfcNEQ_NWT + kxxMyyFromfcNEQ_SET - kxxMyyFromfcNEQ_NEB + 2.*kxxMzzFromfcNEQ_SWB - 2.*kxxMzzFromfcNEQ_NWT - 2.*kxxMzzFromfcNEQ_SET + 2.*kxxMzzFromfcNEQ_NEB + kxyFromfcNEQ_SWB + kxyFromfcNEQ_NWT + kxyFromfcNEQ_SET + kxyFromfcNEQ_NEB)/(epsylon*epsylon); - cxy= (kxyFromfcNEQ_SWB - kxyFromfcNEQ_NWT - kxyFromfcNEQ_SET + kxyFromfcNEQ_NEB - kxzFromfcNEQ_SWB + kxzFromfcNEQ_NWT - kxzFromfcNEQ_SET + kxzFromfcNEQ_NEB - kyzFromfcNEQ_SWB - kyzFromfcNEQ_NWT + kyzFromfcNEQ_SET + kyzFromfcNEQ_NEB)/(epsylon*epsylon); - cxz= (2.*vx2_SWB - 2.*vx2_NWT - 2.*vx2_SET + 2.*vx2_NEB + 2.*vx3_SWB - 2.*vx3_NWT + 2.*vx3_SET - 2.*vx3_NEB - kxxMyyFromfcNEQ_SWB - kxxMyyFromfcNEQ_NWT + kxxMyyFromfcNEQ_SET + kxxMyyFromfcNEQ_NEB + kxxMzzFromfcNEQ_SWB + kxxMzzFromfcNEQ_NWT - kxxMzzFromfcNEQ_SET - kxxMzzFromfcNEQ_NEB + kyzFromfcNEQ_SWB + kyzFromfcNEQ_NWT + kyzFromfcNEQ_SET + kyzFromfcNEQ_NEB)/(epsylon*epsylon); - cyz= (2.*vx1_SWB - 2.*vx1_NWT - 2.*vx1_SET + 2.*vx1_NEB + 2.*vx3_SWB + 2.*vx3_NWT - 2.*vx3_SET - 2.*vx3_NEB + kxxMzzFromfcNEQ_SWB - kxxMzzFromfcNEQ_NWT + kxxMzzFromfcNEQ_SET - kxxMzzFromfcNEQ_NEB + kxzFromfcNEQ_SWB + kxzFromfcNEQ_NWT + kxzFromfcNEQ_SET + kxzFromfcNEQ_NEB)/(epsylon*epsylon); - ////////////////////////////////////////////////////////////////////////// - //another 4 points - a0 += 8.*vx1_SWT + 8.*vx1_NWB + 8.*vx1_SEB + 8.*vx1_NET + 2.*vx2_SWT - 2.*vx2_NWB - 2.*vx2_SEB + 2.*vx2_NET - 2.*vx3_SWT + 2.*vx3_NWB - 2.*vx3_SEB + 2.*vx3_NET + kxxMyyFromfcNEQ_SWT + kxxMyyFromfcNEQ_NWB - 1.*kxxMyyFromfcNEQ_SEB - 1.*kxxMyyFromfcNEQ_NET + kxxMzzFromfcNEQ_SWT + kxxMzzFromfcNEQ_NWB - 1.*kxxMzzFromfcNEQ_SEB - 1.*kxxMzzFromfcNEQ_NET + 2.*kxyFromfcNEQ_SWT - 2.*kxyFromfcNEQ_NWB + 2.*kxyFromfcNEQ_SEB - 2.*kxyFromfcNEQ_NET - 2.*kxzFromfcNEQ_SWT + 2.*kxzFromfcNEQ_NWB + 2.*kxzFromfcNEQ_SEB - 2.*kxzFromfcNEQ_NET - 1.*kyzFromfcNEQ_SWT - 1.*kyzFromfcNEQ_NWB - 1.*kyzFromfcNEQ_SEB - 1.*kyzFromfcNEQ_NET; - ax += (-4.*vx1_SWT - 4.*vx1_NWB + 4.*vx1_SEB + 4.*vx1_NET - 1.*kxyFromfcNEQ_SWT + kxyFromfcNEQ_NWB + kxyFromfcNEQ_SEB - 1.*kxyFromfcNEQ_NET + kxzFromfcNEQ_SWT - 1.*kxzFromfcNEQ_NWB + kxzFromfcNEQ_SEB - 1.*kxzFromfcNEQ_NET - 1.*kyzFromfcNEQ_SWT - 1.*kyzFromfcNEQ_NWB + kyzFromfcNEQ_SEB + kyzFromfcNEQ_NET)/epsylon; - ay += (-2.*vx1_SWT + 2.*vx1_NWB - 2.*vx1_SEB + 2.*vx1_NET + 2.*vx2_SWT + 2.*vx2_NWB - 2.*vx2_SEB - 2.*vx2_NET - 1.*kxxMyyFromfcNEQ_SWT + kxxMyyFromfcNEQ_NWB + kxxMyyFromfcNEQ_SEB - 1.*kxxMyyFromfcNEQ_NET + kxyFromfcNEQ_SWT + kxyFromfcNEQ_NWB + kxyFromfcNEQ_SEB + kxyFromfcNEQ_NET)/epsylon; - az += (2.*vx1_SWT - 2.*vx1_NWB - 2.*vx1_SEB + 2.*vx1_NET + 2.*vx3_SWT + 2.*vx3_NWB - 2.*vx3_SEB - 2.*vx3_NET + kxxMzzFromfcNEQ_SWT - 1.*kxxMzzFromfcNEQ_NWB + kxxMzzFromfcNEQ_SEB - 1.*kxxMzzFromfcNEQ_NET + kxzFromfcNEQ_SWT + kxzFromfcNEQ_NWB + kxzFromfcNEQ_SEB + kxzFromfcNEQ_NET)/epsylon; - axx += (2.*vx2_SWT - 2.*vx2_NWB - 2.*vx2_SEB + 2.*vx2_NET - 2.*vx3_SWT + 2.*vx3_NWB - 2.*vx3_SEB + 2.*vx3_NET - 1.*kxxMyyFromfcNEQ_SWT - 1.*kxxMyyFromfcNEQ_NWB + kxxMyyFromfcNEQ_SEB + kxxMyyFromfcNEQ_NET - 1.*kxxMzzFromfcNEQ_SWT - 1.*kxxMzzFromfcNEQ_NWB + kxxMzzFromfcNEQ_SEB + kxxMzzFromfcNEQ_NET - 1.*kyzFromfcNEQ_SWT - 1.*kyzFromfcNEQ_NWB - 1.*kyzFromfcNEQ_SEB - 1.*kyzFromfcNEQ_NET)/(epsylon*epsylon); - ayy += (-2.*vx2_SWT + 2.*vx2_NWB + 2.*vx2_SEB - 2.*vx2_NET + 2.*vx3_SWT - 2.*vx3_NWB + 2.*vx3_SEB - 2.*vx3_NET - 1.*kxxMyyFromfcNEQ_SWT - 1.*kxxMyyFromfcNEQ_NWB + kxxMyyFromfcNEQ_SEB + kxxMyyFromfcNEQ_NET + kxxMzzFromfcNEQ_SWT + kxxMzzFromfcNEQ_NWB - 1.*kxxMzzFromfcNEQ_SEB - 1.*kxxMzzFromfcNEQ_NET - 2.*kxyFromfcNEQ_SWT + 2.*kxyFromfcNEQ_NWB - 2.*kxyFromfcNEQ_SEB + 2.*kxyFromfcNEQ_NET + kyzFromfcNEQ_SWT + kyzFromfcNEQ_NWB + kyzFromfcNEQ_SEB + kyzFromfcNEQ_NET)/(epsylon*epsylon); - azz += (-2.*vx2_SWT + 2.*vx2_NWB + 2.*vx2_SEB - 2.*vx2_NET + 2.*vx3_SWT - 2.*vx3_NWB + 2.*vx3_SEB - 2.*vx3_NET + kxxMyyFromfcNEQ_SWT + kxxMyyFromfcNEQ_NWB - 1.*kxxMyyFromfcNEQ_SEB - 1.*kxxMyyFromfcNEQ_NET - 1.*kxxMzzFromfcNEQ_SWT - 1.*kxxMzzFromfcNEQ_NWB + kxxMzzFromfcNEQ_SEB + kxxMzzFromfcNEQ_NET + 2.*kxzFromfcNEQ_SWT - 2.*kxzFromfcNEQ_NWB - 2.*kxzFromfcNEQ_SEB + 2.*kxzFromfcNEQ_NET + kyzFromfcNEQ_SWT + kyzFromfcNEQ_NWB + kyzFromfcNEQ_SEB + kyzFromfcNEQ_NET)/(epsylon*epsylon); - axy += (2.*vx1_SWT - 2.*vx1_NWB - 2.*vx1_SEB + 2.*vx1_NET - 2.*vx3_SWT - 2.*vx3_NWB + 2.*vx3_SEB + 2.*vx3_NET - 1.*kxxMzzFromfcNEQ_SWT + kxxMzzFromfcNEQ_NWB - 1.*kxxMzzFromfcNEQ_SEB + kxxMzzFromfcNEQ_NET - 1.*kxzFromfcNEQ_SWT - 1.*kxzFromfcNEQ_NWB - 1.*kxzFromfcNEQ_SEB - 1.*kxzFromfcNEQ_NET)/(epsylon*epsylon); - axz += (-2.*vx1_SWT + 2.*vx1_NWB - 2.*vx1_SEB + 2.*vx1_NET - 2.*vx2_SWT - 2.*vx2_NWB + 2.*vx2_SEB + 2.*vx2_NET + kxxMyyFromfcNEQ_SWT - 1.*kxxMyyFromfcNEQ_NWB - 1.*kxxMyyFromfcNEQ_SEB + kxxMyyFromfcNEQ_NET - 1.*kxyFromfcNEQ_SWT - 1.*kxyFromfcNEQ_NWB - 1.*kxyFromfcNEQ_SEB - 1.*kxyFromfcNEQ_NET)/(epsylon*epsylon); - ayz += (kxyFromfcNEQ_SWT - 1.*kxyFromfcNEQ_NWB - 1.*kxyFromfcNEQ_SEB + kxyFromfcNEQ_NET - 1.*kxzFromfcNEQ_SWT + kxzFromfcNEQ_NWB - 1.*kxzFromfcNEQ_SEB + kxzFromfcNEQ_NET + kyzFromfcNEQ_SWT + kyzFromfcNEQ_NWB - 1.*kyzFromfcNEQ_SEB - 1.*kyzFromfcNEQ_NET)/(epsylon*epsylon); - b0 += 2.*vx1_SWT - 2.*vx1_NWB - 2.*vx1_SEB + 2.*vx1_NET + 8.*vx2_SWT + 8.*vx2_NWB + 8.*vx2_SEB + 8.*vx2_NET - 2.*vx3_SWT - 2.*vx3_NWB + 2.*vx3_SEB + 2.*vx3_NET - 2.*kxxMyyFromfcNEQ_SWT + 2.*kxxMyyFromfcNEQ_NWB - 2.*kxxMyyFromfcNEQ_SEB + 2.*kxxMyyFromfcNEQ_NET + kxxMzzFromfcNEQ_SWT - 1.*kxxMzzFromfcNEQ_NWB + kxxMzzFromfcNEQ_SEB - 1.*kxxMzzFromfcNEQ_NET + 2.*kxyFromfcNEQ_SWT + 2.*kxyFromfcNEQ_NWB - 2.*kxyFromfcNEQ_SEB - 2.*kxyFromfcNEQ_NET - 1.*kxzFromfcNEQ_SWT - 1.*kxzFromfcNEQ_NWB - 1.*kxzFromfcNEQ_SEB - 1.*kxzFromfcNEQ_NET - 2.*kyzFromfcNEQ_SWT + 2.*kyzFromfcNEQ_NWB + 2.*kyzFromfcNEQ_SEB - 2.*kyzFromfcNEQ_NET; - bx += (2.*vx1_SWT - 2.*vx1_NWB + 2.*vx1_SEB - 2.*vx1_NET - 2.*vx2_SWT - 2.*vx2_NWB + 2.*vx2_SEB + 2.*vx2_NET + kxxMyyFromfcNEQ_SWT - 1.*kxxMyyFromfcNEQ_NWB - 1.*kxxMyyFromfcNEQ_SEB + kxxMyyFromfcNEQ_NET + kxyFromfcNEQ_SWT + kxyFromfcNEQ_NWB + kxyFromfcNEQ_SEB + kxyFromfcNEQ_NET)/epsylon; - by += (-4.*vx2_SWT + 4.*vx2_NWB - 4.*vx2_SEB + 4.*vx2_NET - 1.*kxyFromfcNEQ_SWT + kxyFromfcNEQ_NWB + kxyFromfcNEQ_SEB - 1.*kxyFromfcNEQ_NET - 1.*kxzFromfcNEQ_SWT + kxzFromfcNEQ_NWB - 1.*kxzFromfcNEQ_SEB + kxzFromfcNEQ_NET + kyzFromfcNEQ_SWT + kyzFromfcNEQ_NWB - 1.*kyzFromfcNEQ_SEB - 1.*kyzFromfcNEQ_NET)/epsylon; - bz += (2.*vx2_SWT - 2.*vx2_NWB - 2.*vx2_SEB + 2.*vx2_NET + 2.*vx3_SWT - 2.*vx3_NWB + 2.*vx3_SEB - 2.*vx3_NET - 1.*kxxMyyFromfcNEQ_SWT - 1.*kxxMyyFromfcNEQ_NWB + kxxMyyFromfcNEQ_SEB + kxxMyyFromfcNEQ_NET + kxxMzzFromfcNEQ_SWT + kxxMzzFromfcNEQ_NWB - 1.*kxxMzzFromfcNEQ_SEB - 1.*kxxMzzFromfcNEQ_NET + kyzFromfcNEQ_SWT + kyzFromfcNEQ_NWB + kyzFromfcNEQ_SEB + kyzFromfcNEQ_NET)/epsylon; - bxx += (-2.*vx1_SWT + 2.*vx1_NWB + 2.*vx1_SEB - 2.*vx1_NET + 2.*vx3_SWT + 2.*vx3_NWB - 2.*vx3_SEB - 2.*vx3_NET + kxxMzzFromfcNEQ_SWT - 1.*kxxMzzFromfcNEQ_NWB + kxxMzzFromfcNEQ_SEB - 1.*kxxMzzFromfcNEQ_NET - 2.*kxyFromfcNEQ_SWT - 2.*kxyFromfcNEQ_NWB + 2.*kxyFromfcNEQ_SEB + 2.*kxyFromfcNEQ_NET + kxzFromfcNEQ_SWT + kxzFromfcNEQ_NWB + kxzFromfcNEQ_SEB + kxzFromfcNEQ_NET)/(epsylon*epsylon); - byy += (2.*vx1_SWT - 2.*vx1_NWB - 2.*vx1_SEB + 2.*vx1_NET - 2.*vx3_SWT - 2.*vx3_NWB + 2.*vx3_SEB + 2.*vx3_NET + 2.*kxxMyyFromfcNEQ_SWT - 2.*kxxMyyFromfcNEQ_NWB + 2.*kxxMyyFromfcNEQ_SEB - 2.*kxxMyyFromfcNEQ_NET - 1.*kxxMzzFromfcNEQ_SWT + kxxMzzFromfcNEQ_NWB - 1.*kxxMzzFromfcNEQ_SEB + kxxMzzFromfcNEQ_NET - 1.*kxzFromfcNEQ_SWT - 1.*kxzFromfcNEQ_NWB - 1.*kxzFromfcNEQ_SEB - 1.*kxzFromfcNEQ_NET)/(epsylon*epsylon); - bzz += (-2.*vx1_SWT + 2.*vx1_NWB + 2.*vx1_SEB - 2.*vx1_NET + 2.*vx3_SWT + 2.*vx3_NWB - 2.*vx3_SEB - 2.*vx3_NET - 1.*kxxMzzFromfcNEQ_SWT + kxxMzzFromfcNEQ_NWB - 1.*kxxMzzFromfcNEQ_SEB + kxxMzzFromfcNEQ_NET + kxzFromfcNEQ_SWT + kxzFromfcNEQ_NWB + kxzFromfcNEQ_SEB + kxzFromfcNEQ_NET + 2.*kyzFromfcNEQ_SWT - 2.*kyzFromfcNEQ_NWB - 2.*kyzFromfcNEQ_SEB + 2.*kyzFromfcNEQ_NET)/(epsylon*epsylon); - bxy += (2.*vx2_SWT - 2.*vx2_NWB - 2.*vx2_SEB + 2.*vx2_NET - 2.*vx3_SWT + 2.*vx3_NWB - 2.*vx3_SEB + 2.*vx3_NET + kxxMyyFromfcNEQ_SWT + kxxMyyFromfcNEQ_NWB - 1.*kxxMyyFromfcNEQ_SEB - 1.*kxxMyyFromfcNEQ_NET - 1.*kxxMzzFromfcNEQ_SWT - 1.*kxxMzzFromfcNEQ_NWB + kxxMzzFromfcNEQ_SEB + kxxMzzFromfcNEQ_NET - 1.*kyzFromfcNEQ_SWT - 1.*kyzFromfcNEQ_NWB - 1.*kyzFromfcNEQ_SEB - 1.*kyzFromfcNEQ_NET)/(epsylon*epsylon); - bxz += (kxyFromfcNEQ_SWT - 1.*kxyFromfcNEQ_NWB - 1.*kxyFromfcNEQ_SEB + kxyFromfcNEQ_NET + kxzFromfcNEQ_SWT - 1.*kxzFromfcNEQ_NWB + kxzFromfcNEQ_SEB - 1.*kxzFromfcNEQ_NET - 1.*kyzFromfcNEQ_SWT - 1.*kyzFromfcNEQ_NWB + kyzFromfcNEQ_SEB + kyzFromfcNEQ_NET)/(epsylon*epsylon); - byz += (-2.*vx1_SWT + 2.*vx1_NWB - 2.*vx1_SEB + 2.*vx1_NET - 2.*vx2_SWT - 2.*vx2_NWB + 2.*vx2_SEB + 2.*vx2_NET - 1.*kxxMyyFromfcNEQ_SWT + kxxMyyFromfcNEQ_NWB + kxxMyyFromfcNEQ_SEB - 1.*kxxMyyFromfcNEQ_NET - 1.*kxyFromfcNEQ_SWT - 1.*kxyFromfcNEQ_NWB - 1.*kxyFromfcNEQ_SEB - 1.*kxyFromfcNEQ_NET)/(epsylon*epsylon); - c0 += -2.*vx1_SWT + 2.*vx1_NWB - 2.*vx1_SEB + 2.*vx1_NET - 2.*vx2_SWT - 2.*vx2_NWB + 2.*vx2_SEB + 2.*vx2_NET + 8.*vx3_SWT + 8.*vx3_NWB + 8.*vx3_SEB + 8.*vx3_NET - 1.*kxxMyyFromfcNEQ_SWT + kxxMyyFromfcNEQ_NWB + kxxMyyFromfcNEQ_SEB - 1.*kxxMyyFromfcNEQ_NET + 2.*kxxMzzFromfcNEQ_SWT - 2.*kxxMzzFromfcNEQ_NWB - 2.*kxxMzzFromfcNEQ_SEB + 2.*kxxMzzFromfcNEQ_NET - 1.*kxyFromfcNEQ_SWT - 1.*kxyFromfcNEQ_NWB - 1.*kxyFromfcNEQ_SEB - 1.*kxyFromfcNEQ_NET + 2.*kxzFromfcNEQ_SWT + 2.*kxzFromfcNEQ_NWB - 2.*kxzFromfcNEQ_SEB - 2.*kxzFromfcNEQ_NET + 2.*kyzFromfcNEQ_SWT - 2.*kyzFromfcNEQ_NWB + 2.*kyzFromfcNEQ_SEB - 2.*kyzFromfcNEQ_NET; - cx += (-2.*vx1_SWT + 2.*vx1_NWB + 2.*vx1_SEB - 2.*vx1_NET - 2.*vx3_SWT - 2.*vx3_NWB + 2.*vx3_SEB + 2.*vx3_NET - 1.*kxxMzzFromfcNEQ_SWT + kxxMzzFromfcNEQ_NWB - 1.*kxxMzzFromfcNEQ_SEB + kxxMzzFromfcNEQ_NET + kxzFromfcNEQ_SWT + kxzFromfcNEQ_NWB + kxzFromfcNEQ_SEB + kxzFromfcNEQ_NET)/epsylon; - cy += (-2.*vx2_SWT + 2.*vx2_NWB + 2.*vx2_SEB - 2.*vx2_NET - 2.*vx3_SWT + 2.*vx3_NWB - 2.*vx3_SEB + 2.*vx3_NET + kxxMyyFromfcNEQ_SWT + kxxMyyFromfcNEQ_NWB - 1.*kxxMyyFromfcNEQ_SEB - 1.*kxxMyyFromfcNEQ_NET - 1.*kxxMzzFromfcNEQ_SWT - 1.*kxxMzzFromfcNEQ_NWB + kxxMzzFromfcNEQ_SEB + kxxMzzFromfcNEQ_NET + kyzFromfcNEQ_SWT + kyzFromfcNEQ_NWB + kyzFromfcNEQ_SEB + kyzFromfcNEQ_NET)/epsylon; - cz += (4.*vx3_SWT - 4.*vx3_NWB - 4.*vx3_SEB + 4.*vx3_NET + kxyFromfcNEQ_SWT - 1.*kxyFromfcNEQ_NWB - 1.*kxyFromfcNEQ_SEB + kxyFromfcNEQ_NET + kxzFromfcNEQ_SWT - 1.*kxzFromfcNEQ_NWB + kxzFromfcNEQ_SEB - 1.*kxzFromfcNEQ_NET + kyzFromfcNEQ_SWT + kyzFromfcNEQ_NWB - 1.*kyzFromfcNEQ_SEB - 1.*kyzFromfcNEQ_NET)/epsylon; - cxx += (2.*vx1_SWT - 2.*vx1_NWB + 2.*vx1_SEB - 2.*vx1_NET + 2.*vx2_SWT + 2.*vx2_NWB - 2.*vx2_SEB - 2.*vx2_NET - 1.*kxxMyyFromfcNEQ_SWT + kxxMyyFromfcNEQ_NWB + kxxMyyFromfcNEQ_SEB - 1.*kxxMyyFromfcNEQ_NET + kxyFromfcNEQ_SWT + kxyFromfcNEQ_NWB + kxyFromfcNEQ_SEB + kxyFromfcNEQ_NET - 2.*kxzFromfcNEQ_SWT - 2.*kxzFromfcNEQ_NWB + 2.*kxzFromfcNEQ_SEB + 2.*kxzFromfcNEQ_NET)/(epsylon*epsylon); - cyy += (2.*vx1_SWT - 2.*vx1_NWB + 2.*vx1_SEB - 2.*vx1_NET + 2.*vx2_SWT + 2.*vx2_NWB - 2.*vx2_SEB - 2.*vx2_NET + kxxMyyFromfcNEQ_SWT - 1.*kxxMyyFromfcNEQ_NWB - 1.*kxxMyyFromfcNEQ_SEB + kxxMyyFromfcNEQ_NET + kxyFromfcNEQ_SWT + kxyFromfcNEQ_NWB + kxyFromfcNEQ_SEB + kxyFromfcNEQ_NET - 2.*kyzFromfcNEQ_SWT + 2.*kyzFromfcNEQ_NWB - 2.*kyzFromfcNEQ_SEB + 2.*kyzFromfcNEQ_NET)/(epsylon*epsylon); - czz += (-2.*vx1_SWT + 2.*vx1_NWB - 2.*vx1_SEB + 2.*vx1_NET - 2.*vx2_SWT - 2.*vx2_NWB + 2.*vx2_SEB + 2.*vx2_NET + kxxMyyFromfcNEQ_SWT - 1.*kxxMyyFromfcNEQ_NWB - 1.*kxxMyyFromfcNEQ_SEB + kxxMyyFromfcNEQ_NET - 2.*kxxMzzFromfcNEQ_SWT + 2.*kxxMzzFromfcNEQ_NWB + 2.*kxxMzzFromfcNEQ_SEB - 2.*kxxMzzFromfcNEQ_NET - 1.*kxyFromfcNEQ_SWT - 1.*kxyFromfcNEQ_NWB - 1.*kxyFromfcNEQ_SEB - 1.*kxyFromfcNEQ_NET)/(epsylon*epsylon); - cxy += (-1.*kxyFromfcNEQ_SWT + kxyFromfcNEQ_NWB + kxyFromfcNEQ_SEB - 1.*kxyFromfcNEQ_NET - 1.*kxzFromfcNEQ_SWT + kxzFromfcNEQ_NWB - 1.*kxzFromfcNEQ_SEB + kxzFromfcNEQ_NET - 1.*kyzFromfcNEQ_SWT - 1.*kyzFromfcNEQ_NWB + kyzFromfcNEQ_SEB + kyzFromfcNEQ_NET)/(epsylon*epsylon); - cxz += (2.*vx2_SWT - 2.*vx2_NWB - 2.*vx2_SEB + 2.*vx2_NET - 2.*vx3_SWT + 2.*vx3_NWB - 2.*vx3_SEB + 2.*vx3_NET - 1.*kxxMyyFromfcNEQ_SWT - 1.*kxxMyyFromfcNEQ_NWB + kxxMyyFromfcNEQ_SEB + kxxMyyFromfcNEQ_NET + kxxMzzFromfcNEQ_SWT + kxxMzzFromfcNEQ_NWB - 1.*kxxMzzFromfcNEQ_SEB - 1.*kxxMzzFromfcNEQ_NET - 1.*kyzFromfcNEQ_SWT - 1.*kyzFromfcNEQ_NWB - 1.*kyzFromfcNEQ_SEB - 1.*kyzFromfcNEQ_NET)/(epsylon*epsylon); - cyz += (2.*vx1_SWT - 2.*vx1_NWB - 2.*vx1_SEB + 2.*vx1_NET - 2.*vx3_SWT - 2.*vx3_NWB + 2.*vx3_SEB + 2.*vx3_NET + kxxMzzFromfcNEQ_SWT - 1.*kxxMzzFromfcNEQ_NWB + kxxMzzFromfcNEQ_SEB - 1.*kxxMzzFromfcNEQ_NET - 1.*kxzFromfcNEQ_SWT - 1.*kxzFromfcNEQ_NWB - 1.*kxzFromfcNEQ_SEB - 1.*kxzFromfcNEQ_NET)/(epsylon*epsylon); - ////////////////////////////////////////////////////////////////////////// - //normalization - a0 /= 2.; - ax /= 2.; - ay /= 2.; - az /= 2.; - axx /= 2.; - ayy /= 2.; - azz /= 2.; - axy /= 2.; - axz /= 2.; - ayz /= 2.; - b0 /= 2.; - bx /= 2.; - by /= 2.; - bz /= 2.; - bxx /= 2.; - byy /= 2.; - bzz /= 2.; - bxy /= 2.; - bxz /= 2.; - byz /= 2.; - c0 /= 2.; - cx /= 2.; - cy /= 2.; - cz /= 2.; - cxx /= 2.; - cyy /= 2.; - czz /= 2.; - cxy /= 2.; - cxz /= 2.; - cyz /= 2.; - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - a0 /= 32.; - ax /= 8.; - ay /= 8.; - az /= 8.; - axx /= 8.; - ayy /= 8.; - azz /= 8.; - axy /= 4.; - axz /= 4.; - ayz /= 4.; - b0 /= 32.; - bx /= 8.; - by /= 8.; - bz /= 8.; - bxx /= 8.; - byy /= 8.; - bzz /= 8.; - bxy /= 4.; - bxz /= 4.; - byz /= 4.; - c0 /= 32.; - cx /= 8.; - cy /= 8.; - cz /= 8.; - cxx /= 8.; - cyy /= 8.; - czz /= 8.; - cxy /= 4.; - cxz /= 4.; - cyz /= 4.; -} -////////////////////////////////////////////////////////////////////////// -void D3Q27CompactInterpolationProcessor::calcInterpolatedNode(LBMReal* f, LBMReal omega, LBMReal x, LBMReal y, LBMReal z) -{ - using namespace D3Q27System; - - LBMReal eps_new = 0.5; - LBMReal op = 1.0; - const LBMReal o = omega; - - - LBMReal drho = (drho_NEB*(1. + 2.*x + 2.*y + 4.*x*y - 2.*z - 4.*x*z - 4.*y*z - 8.*x*y*z) + - drho_SET*(1. + 2.*x - 2.*y - 4.*x*y + 2.*z + 4.*x*z - 4.*y*z - 8.*x*y*z) + - drho_NWT*(1. - 2.*x + 2.*y - 4.*x*y + 2.*z - 4.*x*z + 4.*y*z - 8.*x*y*z) + - drho_SWB*(1. - 2.*x - 2.*y + 4.*x*y - 2.*z + 4.*x*z + 4.*y*z - 8.*x*y*z) + - drho_SWT*(1. - 2.*x - 2.*y + 4.*x*y + 2.*z - 4.*x*z - 4.*y*z + 8.*x*y*z) + - drho_NWB*(1. - 2.*x + 2.*y - 4.*x*y - 2.*z + 4.*x*z - 4.*y*z + 8.*x*y*z) + - drho_SEB*(1. + 2.*x - 2.*y - 4.*x*y - 2.*z - 4.*x*z + 4.*y*z + 8.*x*y*z) + - drho_NET*(1. + 2.*x + 2.*y + 4.*x*y + 2.*z + 4.*x*z + 4.*y*z + 8.*x*y*z))/8.; - LBMReal vx1 = a0 + ax*x + ay*y + az*z + axx*x*x + ayy*y*y + azz*z*z + axy*x*y + axz*x*z + ayz*y*z; - LBMReal vx2 = b0 + bx*x + by*y + bz*z + bxx*x*x + byy*y*y + bzz*z*z + bxy*x*y + bxz*x*z + byz*y*z; - LBMReal vx3 = c0 + cx*x + cy*y + cz*z + cxx*x*x + cyy*y*y + czz*z*z + cxy*x*y + cxz*x*z + cyz*y*z; - - LBMReal feq[ENDF+1]; - calcFeqFct(feq,drho,vx1,vx2,vx3); - - f[E] = eps_new *((-5*(ax + by + cz + 2*axx*x + bxy*x + cxz*x + axy*y + 2*byy*y + cyz*y + axz*z + byz*z + 2*czz*z))/(9.*op) - - (2*(-by - cz - bxy*x - cxz*x - 2*byy*y - cyz*y - byz*z - 2*czz*z + 2*(ax + 2*axx*x + axy*y + axz*z)))/(9.*o))/2.; - f[W] = eps_new *((-5*(ax + by + cz + 2*axx*x + bxy*x + cxz*x + axy*y + 2*byy*y + cyz*y + axz*z + byz*z + 2*czz*z))/(9.*op) - - (2*(-by - cz - bxy*x - cxz*x - 2*byy*y - cyz*y - byz*z - 2*czz*z + 2*(ax + 2*axx*x + axy*y + axz*z)))/(9.*o))/2.; - f[N] = eps_new *((-5*(ax + by + cz + 2*axx*x + bxy*x + cxz*x + axy*y + 2*byy*y + cyz*y + axz*z + byz*z + 2*czz*z))/(9.*op) - - (2*(-ax - cz - 2*axx*x - cxz*x - axy*y - cyz*y - axz*z - 2*czz*z + 2*(by + bxy*x + 2*byy*y + byz*z)))/(9.*o))/2.; - f[S] = eps_new *((-5*(ax + by + cz + 2*axx*x + bxy*x + cxz*x + axy*y + 2*byy*y + cyz*y + axz*z + byz*z + 2*czz*z))/(9.*op) - - (2*(-ax - cz - 2*axx*x - cxz*x - axy*y - cyz*y - axz*z - 2*czz*z + 2*(by + bxy*x + 2*byy*y + byz*z)))/(9.*o))/2.; - f[T] = eps_new *((-5*(ax + by + cz + 2*axx*x + bxy*x + cxz*x + axy*y + 2*byy*y + cyz*y + axz*z + byz*z + 2*czz*z))/(9.*op) - - (2*(-ax - by - 2*axx*x - bxy*x - axy*y - 2*byy*y - axz*z - byz*z + 2*(cz + cxz*x + cyz*y + 2*czz*z)))/(9.*o))/2.; - f[B] = eps_new *((-5*(ax + by + cz + 2*axx*x + bxy*x + cxz*x + axy*y + 2*byy*y + cyz*y + axz*z + byz*z + 2*czz*z))/(9.*op) - - (2*(-ax - by - 2*axx*x - bxy*x - axy*y - 2*byy*y - axz*z - byz*z + 2*(cz + cxz*x + cyz*y + 2*czz*z)))/(9.*o))/2.; - f[NE] = eps_new *(-(ay + bx + axy*x + 2*bxx*x + 2*ayy*y + bxy*y + ayz*z + bxz*z)/(12.*o)); - f[SW] = eps_new *(-(ay + bx + axy*x + 2*bxx*x + 2*ayy*y + bxy*y + ayz*z + bxz*z)/(12.*o)); - f[SE] = eps_new *(ay + bx + axy*x + 2*bxx*x + 2*ayy*y + bxy*y + ayz*z + bxz*z)/(12.*o); - f[NW] = eps_new *(ay + bx + axy*x + 2*bxx*x + 2*ayy*y + bxy*y + ayz*z + bxz*z)/(12.*o); - f[TE] = eps_new *(-(az + cx + axz*x + 2*cxx*x + ayz*y + cxy*y + 2*azz*z + cxz*z)/(12.*o)); - f[BW] = eps_new *(-(az + cx + axz*x + 2*cxx*x + ayz*y + cxy*y + 2*azz*z + cxz*z)/(12.*o)); - f[BE] = eps_new *(az + cx + axz*x + 2*cxx*x + ayz*y + cxy*y + 2*azz*z + cxz*z)/(12.*o); - f[TW] = eps_new *(az + cx + axz*x + 2*cxx*x + ayz*y + cxy*y + 2*azz*z + cxz*z)/(12.*o); - f[TN] = eps_new *(-(bz + cy + bxz*x + cxy*x + byz*y + 2*cyy*y + 2*bzz*z + cyz*z)/(12.*o)); - f[BS] = eps_new *(-(bz + cy + bxz*x + cxy*x + byz*y + 2*cyy*y + 2*bzz*z + cyz*z)/(12.*o)); - f[BN] = eps_new *(bz + cy + bxz*x + cxy*x + byz*y + 2*cyy*y + 2*bzz*z + cyz*z)/(12.*o); - f[TS] = eps_new *(bz + cy + bxz*x + cxy*x + byz*y + 2*cyy*y + 2*bzz*z + cyz*z)/(12.*o); - f[ZERO] = eps_new *(5*(ax + by + cz + 2*axx*x + bxy*x + cxz*x + axy*y + 2*byy*y + cyz*y + axz*z + byz*z + 2*czz*z))/(3.*op) + - (2*(-by - cz - bxy*x - cxz*x - 2*byy*y - cyz*y - byz*z - 2*czz*z + 2*(ax + 2*axx*x + axy*y + axz*z)))/(9.*o) + - (2*(-ax - cz - 2*axx*x - cxz*x - axy*y - cyz*y - axz*z - 2*czz*z + 2*(by + bxy*x + 2*byy*y + byz*z)))/(9.*o) + - (2*(-ax - by - 2*axx*x - bxy*x - axy*y - 2*byy*y - axz*z - byz*z + 2*(cz + cxz*x + cyz*y + 2*czz*z)))/(9.*o); - f[TNE] = 0.0; - f[TNW] = 0.0; - f[TSE] = 0.0; - f[TSW] = 0.0; - f[BNE] = 0.0; - f[BNW] = 0.0; - f[BSE] = 0.0; - f[BSW] = 0.0; - - f[E] += feq[E]; - f[W] += feq[W]; - f[N] += feq[N]; - f[S] += feq[S]; - f[T] += feq[T]; - f[B] += feq[B]; - f[NE] += feq[NE]; - f[SW] += feq[SW]; - f[SE] += feq[SE]; - f[NW] += feq[NW]; - f[TE] += feq[TE]; - f[BW] += feq[BW]; - f[BE] += feq[BE]; - f[TW] += feq[TW]; - f[TN] += feq[TN]; - f[BS] += feq[BS]; - f[BN] += feq[BN]; - f[TS] += feq[TS]; - f[TNE] += feq[TNE]; - f[TNW] += feq[TNW]; - f[TSE] += feq[TSE]; - f[TSW] += feq[TSW]; - f[BNE] += feq[BNE]; - f[BNW] += feq[BNW]; - f[BSE] += feq[BSE]; - f[BSW] += feq[BSW]; - f[ZERO] += feq[ZERO]; -} -////////////////////////////////////////////////////////////////////////// - diff --git a/source/VirtualFluidsCore/LBM/D3Q27CompactInterpolationProcessor.h b/source/VirtualFluidsCore/LBM/D3Q27CompactInterpolationProcessor.h deleted file mode 100644 index e12722390..000000000 --- a/source/VirtualFluidsCore/LBM/D3Q27CompactInterpolationProcessor.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef D3Q27CompactInterpolationProcessor_H_ -#define D3Q27CompactInterpolationProcessor_H_ - -#include "D3Q27InterpolationProcessor.h" -#include "D3Q27System.h" - - -////////////////////////////////////////////////////////////////////////// -//it work only for cascaded LBM -//super compact interpolation method by Martin Geier -////////////////////////////////////////////////////////////////////////// - -class D3Q27CompactInterpolationProcessor; -typedef boost::shared_ptr<D3Q27CompactInterpolationProcessor> D3Q27CompactInterpolationProcessorPtr; - -class D3Q27CompactInterpolationProcessor : public D3Q27InterpolationProcessor -{ -public: - D3Q27CompactInterpolationProcessor(); - D3Q27CompactInterpolationProcessor(LBMReal omegaC, LBMReal omegaF, bool compressible); - virtual ~D3Q27CompactInterpolationProcessor(); - D3Q27InterpolationProcessorPtr clone(); - void setOmegas(LBMReal omegaC, LBMReal omegaF); - void interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF); - void interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF, LBMReal xoff, LBMReal yoff, LBMReal zoff); - void interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC); - void interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC, LBMReal xoff, LBMReal yoff, LBMReal zoff); - void interpolate8to1(D3Q27ICell& icellF, LBMReal* icellC, double x1, double x2, double x3, LBMReal omega); -protected: -private: - typedef void (*CalcMacrosFct)(const LBMReal* const& /*f[27]*/, LBMReal& /*rho*/, LBMReal& /*vx1*/, LBMReal& /*vx2*/, LBMReal& /*vx3*/); - typedef LBMReal (*CalcFeqForDirFct)(const int& /*direction*/,const LBMReal& /*(d)rho*/,const LBMReal& /*vx1*/,const LBMReal& /*vx2*/,const LBMReal& /*vx3*/); - typedef void (*CalcFeqFct)(LBMReal* const& /*feq/*[27]*/,const LBMReal& /*rho*/,const LBMReal& /*vx1*/,const LBMReal& /*vx2*/,const LBMReal& /*vx3*/); - - CalcFeqForDirFct calcFeqsForDirFct; - CalcMacrosFct calcMacrosFct; - CalcFeqFct calcFeqFct; - LBMReal omegaC, omegaF; - LBMReal a0, ax, ay, az, axx, ayy, azz, axy, axz, ayz, b0, bx, by, bz, bxx, byy, bzz, bxy, bxz, byz, c0, cx, cy, cz, cxx, cyy, czz, cxy, cxz, cyz; - LBMReal drho_SWT, drho_NWT, drho_NET, drho_SET, drho_SWB, drho_NWB, drho_NEB, drho_SEB; - bool compressible; - - void init(); - void calcMoments(const LBMReal* const f, LBMReal omega, LBMReal& rho, LBMReal& vx1, LBMReal& vx2, LBMReal& vx3, - LBMReal& kxy, LBMReal& kyz, LBMReal& kxz, LBMReal& kxxMyy, LBMReal& kxxMzz); - void calcInterpolatedCoefficiets(const D3Q27ICell& icell, LBMReal omega); - void calcInterpolatedNode(LBMReal* f, LBMReal omega, LBMReal x, LBMReal y, LBMReal z); -}; -////////////////////////////////////////////////////////////////////////// -inline void D3Q27CompactInterpolationProcessor::interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF, LBMReal xoff, LBMReal yoff, LBMReal zoff) -{ - this->interpolateCoarseToFine(icellC, icellF); -} -////////////////////////////////////////////////////////////////////////// -inline void D3Q27CompactInterpolationProcessor::interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC, LBMReal xoff, LBMReal yoff, LBMReal zoff) -{ - this->interpolateFineToCoarse(icellF, icellC); -} - -#endif diff --git a/source/VirtualFluidsCore/LBM/D3Q27InterpolationProcessor.h b/source/VirtualFluidsCore/LBM/D3Q27InterpolationProcessor.h deleted file mode 100644 index a207c2ea2..000000000 --- a/source/VirtualFluidsCore/LBM/D3Q27InterpolationProcessor.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef D3Q27INTRPOLATIOPROCESSOR_H_ -#define D3Q27INTRPOLATIOPROCESSOR_H_ - -#include "InterpolationProcessor.h" -#include "LBMSystem.h" -#include "Block3D.h" -#include "DistributionArray3D.h" -#include "D3Q27BoundaryCondition.h" -#include "BCArray3D.h" - - -struct D3Q27ICell -{ - LBMReal TSW[27]; - LBMReal TNW[27]; - LBMReal TNE[27]; - LBMReal TSE[27]; - LBMReal BSW[27]; - LBMReal BNW[27]; - LBMReal BNE[27]; - LBMReal BSE[27]; -}; - -class D3Q27InterpolationProcessor; -typedef boost::shared_ptr<D3Q27InterpolationProcessor> D3Q27InterpolationProcessorPtr; - -#include "D3Q27InterpolationHelper.h" - -class D3Q27InterpolationProcessor : public InterpolationProcessor -{ -public: - D3Q27InterpolationProcessor(); - virtual ~D3Q27InterpolationProcessor(); - virtual D3Q27InterpolationProcessorPtr clone() = 0; - virtual void setOmegas(LBMReal omegaC, LBMReal omegaF) = 0; - virtual void interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF) = 0; - virtual void interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF, LBMReal xoff, LBMReal yoff, LBMReal zoff) = 0; - virtual void interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC) = 0; - virtual void interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC, LBMReal xoff, LBMReal yoff, LBMReal zoff) = 0; - - static void readICell(DistributionArray3DPtr f, D3Q27ICell& icell, int x1, int x2, int x3); - static void writeICell(DistributionArray3DPtr f, const D3Q27ICell& icell, int x1, int x2, int x3); - static void writeINode(DistributionArray3DPtr f, const LBMReal* const inode, int x1, int x2, int x3); - static bool iCellHasSolid(const BCArray3D<D3Q27BoundaryCondition>& bcArray, int x1, int x2, int x3); - static int iCellHowManySolids(const BCArray3D<D3Q27BoundaryCondition>& bcArray, int x1, int x2, int x3); - - bool findNeighborICell(const BCArray3D<D3Q27BoundaryCondition>& bcArray, DistributionArray3DPtr f, - D3Q27ICell& icell, int maxX1, int maxX2, int maxX3, - int x1, int x2, int x3, LBMReal& xoff, LBMReal& yoff, LBMReal& zoff); - -protected: - virtual void calcInterpolatedCoefficiets(const D3Q27ICell& icell, LBMReal omega, LBMReal eps_new){} - virtual void calcInterpolatedNodeFC(LBMReal* f, LBMReal omega){} - virtual void calcInterpolatedVelocity(LBMReal x, LBMReal y, LBMReal z,LBMReal& vx1, LBMReal& vx2, LBMReal& vx3){} - virtual void calcInterpolatedShearStress(LBMReal x, LBMReal y, LBMReal z,LBMReal& tauxx, LBMReal& tauyy, LBMReal& tauzz,LBMReal& tauxy, LBMReal& tauxz, LBMReal& tauyz){} - virtual void setOffsets(LBMReal xoff, LBMReal yoff, LBMReal zoff){} - friend class D3Q27InterpolationHelper; -private: - bool inRange(int x1, int x2, int x3); - int m_maxX1, m_maxX2, m_maxX3; -}; - -////////////////////////////////////////////////////////////////////////// -inline bool D3Q27InterpolationProcessor::inRange(int x1, int x2, int x3) -{ - return x1 >= 0 && x1 < m_maxX1 && x2 >= 0 && x2 < m_maxX2 && x3 >= 0 && x3 < m_maxX3; -} - -#endif diff --git a/source/VirtualFluidsCore/LBM/D3Q27OffsetInterpolationProcessor.cpp b/source/VirtualFluidsCore/LBM/D3Q27OffsetInterpolationProcessor.cpp deleted file mode 100644 index f243e7e4d..000000000 --- a/source/VirtualFluidsCore/LBM/D3Q27OffsetInterpolationProcessor.cpp +++ /dev/null @@ -1,609 +0,0 @@ -#include "D3Q27OffsetInterpolationProcessor.h" - -#include <boost/foreach.hpp> - -D3Q27OffsetInterpolationProcessor::D3Q27OffsetInterpolationProcessor() - : omegaC(0.0), omegaF(0.0) -{ - init(); -} -////////////////////////////////////////////////////////////////////////// -D3Q27OffsetInterpolationProcessor::D3Q27OffsetInterpolationProcessor(LBMReal omegaC, LBMReal omegaF) - : omegaC(omegaC), omegaF(omegaF) -{ - init(); -} -////////////////////////////////////////////////////////////////////////// -D3Q27OffsetInterpolationProcessor::~D3Q27OffsetInterpolationProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -D3Q27InterpolationProcessorPtr D3Q27OffsetInterpolationProcessor::clone() -{ - return D3Q27InterpolationProcessorPtr (new D3Q27OffsetInterpolationProcessor(this->omegaC, this->omegaF)); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27OffsetInterpolationProcessor::init() -{ - calcFeqsForDirFct = NULL; - calcMacrosFct = NULL; - calcFeqFct = NULL; - //SimulationParametersPtr param = SimulationParameters::getInstanz(); - - //if(param->isCompressibleModel()) - //{ - calcMacrosFct = &D3Q27System::calcCompMacroscopicValues; - calcFeqFct = &D3Q27System::calcCompFeq; - //} - //else - //{ - // calcMacrosFct = &D3Q27System::calcIncompMacroscopicValues; - // calcFeqFct = &D3Q27System::calcIncompFeq; - //} -} -////////////////////////////////////////////////////////////////////////// -void D3Q27OffsetInterpolationProcessor::setOmegas( LBMReal omegaC, LBMReal omegaF ) -{ - this->omegaC = omegaC; - this->omegaF = omegaF; -} -////////////////////////////////////////////////////////////////////////// -void D3Q27OffsetInterpolationProcessor::setOffsets(LBMReal xoff, LBMReal yoff, LBMReal zoff) -{ - this->xoff = xoff; - this->yoff = yoff; - this->zoff = zoff; - this->xoff_sq = xoff * xoff; - this->yoff_sq = yoff * yoff; - this->zoff_sq = zoff * zoff; -} -////////////////////////////////////////////////////////////////////////// -void D3Q27OffsetInterpolationProcessor::interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF, LBMReal xoff, LBMReal yoff, LBMReal zoff) -{ - setOffsets(xoff, yoff, zoff); - calcInterpolatedCoefficiets(icellC, omegaC, 0.5); - calcInterpolatedNode(icellF.BSW, omegaF, -0.25, -0.25, -0.25, calcPressBSW(), -1, -1, -1); - calcInterpolatedNode(icellF.BNE, omegaF, 0.25, 0.25, -0.25, calcPressBNE(), 1, 1, -1); - calcInterpolatedNode(icellF.TNW, omegaF, -0.25, 0.25, 0.25, calcPressTNW(), -1, 1, 1); - calcInterpolatedNode(icellF.TSE, omegaF, 0.25, -0.25, 0.25, calcPressTSE(), 1, -1, 1); - calcInterpolatedNode(icellF.BNW, omegaF, -0.25, 0.25, -0.25, calcPressBNW(), -1, 1, -1); - calcInterpolatedNode(icellF.BSE, omegaF, 0.25, -0.25, -0.25, calcPressBSE(), 1, -1, -1); - calcInterpolatedNode(icellF.TSW, omegaF, -0.25, -0.25, 0.25, calcPressTSW(), -1, -1, 1); - calcInterpolatedNode(icellF.TNE, omegaF, 0.25, 0.25, 0.25, calcPressTNE(), 1, 1, 1); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27OffsetInterpolationProcessor::interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC, LBMReal xoff, LBMReal yoff, LBMReal zoff) -{ - setOffsets(xoff, yoff, zoff); - calcInterpolatedCoefficiets(icellF, omegaF, 2.0); - calcInterpolatedNodeFC(icellC, omegaC); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27OffsetInterpolationProcessor::calcMoments(const LBMReal* const f, LBMReal omega, LBMReal& press, LBMReal& vx1, LBMReal& vx2, LBMReal& vx3, - LBMReal& kxy, LBMReal& kyz, LBMReal& kxz, LBMReal& kxxMyy, LBMReal& kxxMzz) -{ - using namespace D3Q27System; - - LBMReal rho = 0.0; - calcMacrosFct(f,rho,vx1,vx2,vx3); - //press = D3Q27System::calcPress(f,rho,vx1,vx2,vx3); - press = rho; //interpolate rho! - - kxy = -3.*omega*(f[SW]+f[TSW]+f[BSW]-f[NW]-f[TNW]-f[BNW]-f[SE]-f[TSE]-f[BSE]+f[NE]+f[TNE]+f[BNE]-(vx1*vx2)); - kyz = -3.*omega*(f[BS]+f[BSW]+f[BSE]-f[TS]-f[TSW]-f[TSE]-f[BN]-f[BNW]-f[BNE]+f[TN]+f[TNW]+f[TNE]-(vx2*vx3)); - kxz = -3.*omega*(f[BW]+f[BNW]+f[BSW]-f[TW]-f[TNW]-f[TSW]-f[BE]-f[BNE]-f[BSE]+f[TE]+f[TNE]+f[TSE]-(vx1*vx3)); - kxxMyy = -3./2.*omega*(f[BW]+f[W]+f[TW]-f[BS]-f[S]-f[TS]-f[BN]-f[N]-f[TN]+f[BE]+f[E]+f[TE]-(vx1*vx1-vx2*vx2)); - kxxMzz = -3./2.*omega*(f[SW]+f[W]+f[NW]-f[BS]-f[TS]-f[B]-f[T]-f[BN]-f[TN]+f[SE]+f[E]+f[NE]-(vx1*vx1-vx3*vx3)); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27OffsetInterpolationProcessor::calcInterpolatedCoefficiets(const D3Q27ICell& icell, LBMReal omega, LBMReal eps_new) -{ - LBMReal vx1_SWT,vx2_SWT,vx3_SWT; - LBMReal vx1_NWT,vx2_NWT,vx3_NWT; - LBMReal vx1_NET,vx2_NET,vx3_NET; - LBMReal vx1_SET,vx2_SET,vx3_SET; - LBMReal vx1_SWB,vx2_SWB,vx3_SWB; - LBMReal vx1_NWB,vx2_NWB,vx3_NWB; - LBMReal vx1_NEB,vx2_NEB,vx3_NEB; - LBMReal vx1_SEB,vx2_SEB,vx3_SEB; - - LBMReal kxyFromfcNEQ_SWT, kyzFromfcNEQ_SWT, kxzFromfcNEQ_SWT, kxxMyyFromfcNEQ_SWT, kxxMzzFromfcNEQ_SWT; - LBMReal kxyFromfcNEQ_NWT, kyzFromfcNEQ_NWT, kxzFromfcNEQ_NWT, kxxMyyFromfcNEQ_NWT, kxxMzzFromfcNEQ_NWT; - LBMReal kxyFromfcNEQ_NET, kyzFromfcNEQ_NET, kxzFromfcNEQ_NET, kxxMyyFromfcNEQ_NET, kxxMzzFromfcNEQ_NET; - LBMReal kxyFromfcNEQ_SET, kyzFromfcNEQ_SET, kxzFromfcNEQ_SET, kxxMyyFromfcNEQ_SET, kxxMzzFromfcNEQ_SET; - LBMReal kxyFromfcNEQ_SWB, kyzFromfcNEQ_SWB, kxzFromfcNEQ_SWB, kxxMyyFromfcNEQ_SWB, kxxMzzFromfcNEQ_SWB; - LBMReal kxyFromfcNEQ_NWB, kyzFromfcNEQ_NWB, kxzFromfcNEQ_NWB, kxxMyyFromfcNEQ_NWB, kxxMzzFromfcNEQ_NWB; - LBMReal kxyFromfcNEQ_NEB, kyzFromfcNEQ_NEB, kxzFromfcNEQ_NEB, kxxMyyFromfcNEQ_NEB, kxxMzzFromfcNEQ_NEB; - LBMReal kxyFromfcNEQ_SEB, kyzFromfcNEQ_SEB, kxzFromfcNEQ_SEB, kxxMyyFromfcNEQ_SEB, kxxMzzFromfcNEQ_SEB; - - calcMoments(icell.TSW,omega,press_SWT,vx1_SWT,vx2_SWT,vx3_SWT, kxyFromfcNEQ_SWT, kyzFromfcNEQ_SWT, kxzFromfcNEQ_SWT, kxxMyyFromfcNEQ_SWT, kxxMzzFromfcNEQ_SWT); - calcMoments(icell.TNW,omega,press_NWT,vx1_NWT,vx2_NWT,vx3_NWT, kxyFromfcNEQ_NWT, kyzFromfcNEQ_NWT, kxzFromfcNEQ_NWT, kxxMyyFromfcNEQ_NWT, kxxMzzFromfcNEQ_NWT); - calcMoments(icell.TNE,omega,press_NET,vx1_NET,vx2_NET,vx3_NET, kxyFromfcNEQ_NET, kyzFromfcNEQ_NET, kxzFromfcNEQ_NET, kxxMyyFromfcNEQ_NET, kxxMzzFromfcNEQ_NET); - calcMoments(icell.TSE,omega,press_SET,vx1_SET,vx2_SET,vx3_SET, kxyFromfcNEQ_SET, kyzFromfcNEQ_SET, kxzFromfcNEQ_SET, kxxMyyFromfcNEQ_SET, kxxMzzFromfcNEQ_SET); - calcMoments(icell.BSW,omega,press_SWB,vx1_SWB,vx2_SWB,vx3_SWB, kxyFromfcNEQ_SWB, kyzFromfcNEQ_SWB, kxzFromfcNEQ_SWB, kxxMyyFromfcNEQ_SWB, kxxMzzFromfcNEQ_SWB); - calcMoments(icell.BNW,omega,press_NWB,vx1_NWB,vx2_NWB,vx3_NWB, kxyFromfcNEQ_NWB, kyzFromfcNEQ_NWB, kxzFromfcNEQ_NWB, kxxMyyFromfcNEQ_NWB, kxxMzzFromfcNEQ_NWB); - calcMoments(icell.BNE,omega,press_NEB,vx1_NEB,vx2_NEB,vx3_NEB, kxyFromfcNEQ_NEB, kyzFromfcNEQ_NEB, kxzFromfcNEQ_NEB, kxxMyyFromfcNEQ_NEB, kxxMzzFromfcNEQ_NEB); - calcMoments(icell.BSE,omega,press_SEB,vx1_SEB,vx2_SEB,vx3_SEB, kxyFromfcNEQ_SEB, kyzFromfcNEQ_SEB, kxzFromfcNEQ_SEB, kxxMyyFromfcNEQ_SEB, kxxMzzFromfcNEQ_SEB); - - a0 = (-kxxMyyFromfcNEQ_NEB - kxxMyyFromfcNEQ_NET + kxxMyyFromfcNEQ_NWB + kxxMyyFromfcNEQ_NWT - - kxxMyyFromfcNEQ_SEB - kxxMyyFromfcNEQ_SET + kxxMyyFromfcNEQ_SWB + kxxMyyFromfcNEQ_SWT - - kxxMzzFromfcNEQ_NEB - kxxMzzFromfcNEQ_NET + kxxMzzFromfcNEQ_NWB + kxxMzzFromfcNEQ_NWT - - kxxMzzFromfcNEQ_SEB - kxxMzzFromfcNEQ_SET + kxxMzzFromfcNEQ_SWB + kxxMzzFromfcNEQ_SWT - - 2.*kxyFromfcNEQ_NEB - 2.*kxyFromfcNEQ_NET - 2.*kxyFromfcNEQ_NWB - 2.*kxyFromfcNEQ_NWT + - 2.*kxyFromfcNEQ_SEB + 2.*kxyFromfcNEQ_SET + 2.*kxyFromfcNEQ_SWB + 2.*kxyFromfcNEQ_SWT + - 2.*kxzFromfcNEQ_NEB - 2.*kxzFromfcNEQ_NET + 2.*kxzFromfcNEQ_NWB - 2.*kxzFromfcNEQ_NWT + - 2.*kxzFromfcNEQ_SEB - 2.*kxzFromfcNEQ_SET + 2.*kxzFromfcNEQ_SWB - 2.*kxzFromfcNEQ_SWT + - 8.*vx1_NEB + 8.*vx1_NET + 8.*vx1_NWB + 8.*vx1_NWT + 8.*vx1_SEB + - 8.*vx1_SET + 8.*vx1_SWB + 8.*vx1_SWT + 2.*vx2_NEB + 2.*vx2_NET - - 2.*vx2_NWB - 2.*vx2_NWT - 2.*vx2_SEB - 2.*vx2_SET + 2.*vx2_SWB + - 2.*vx2_SWT - 2.*vx3_NEB + 2.*vx3_NET + 2.*vx3_NWB - 2.*vx3_NWT - - 2.*vx3_SEB + 2.*vx3_SET + 2.*vx3_SWB - 2.*vx3_SWT)/64.; - b0 = (2.*kxxMyyFromfcNEQ_NEB + 2.*kxxMyyFromfcNEQ_NET + 2.*kxxMyyFromfcNEQ_NWB + 2.*kxxMyyFromfcNEQ_NWT - - 2.*kxxMyyFromfcNEQ_SEB - 2.*kxxMyyFromfcNEQ_SET - 2.*kxxMyyFromfcNEQ_SWB - 2.*kxxMyyFromfcNEQ_SWT - - kxxMzzFromfcNEQ_NEB - kxxMzzFromfcNEQ_NET - kxxMzzFromfcNEQ_NWB - kxxMzzFromfcNEQ_NWT + - kxxMzzFromfcNEQ_SEB + kxxMzzFromfcNEQ_SET + kxxMzzFromfcNEQ_SWB + kxxMzzFromfcNEQ_SWT - - 2.*kxyFromfcNEQ_NEB - 2.*kxyFromfcNEQ_NET + 2.*kxyFromfcNEQ_NWB + 2.*kxyFromfcNEQ_NWT - - 2.*kxyFromfcNEQ_SEB - 2.*kxyFromfcNEQ_SET + 2.*kxyFromfcNEQ_SWB + 2.*kxyFromfcNEQ_SWT + - 2.*kyzFromfcNEQ_NEB - 2.*kyzFromfcNEQ_NET + 2.*kyzFromfcNEQ_NWB - 2.*kyzFromfcNEQ_NWT + - 2.*kyzFromfcNEQ_SEB - 2.*kyzFromfcNEQ_SET + 2.*kyzFromfcNEQ_SWB - 2.*kyzFromfcNEQ_SWT + - 2.*vx1_NEB + 2.*vx1_NET - 2.*vx1_NWB - 2.*vx1_NWT - - 2.*vx1_SEB - 2.*vx1_SET + 2.*vx1_SWB + 2.*vx1_SWT + - 8.*vx2_NEB + 8.*vx2_NET + 8.*vx2_NWB + 8.*vx2_NWT + - 8.*vx2_SEB + 8.*vx2_SET + 8.*vx2_SWB + 8.*vx2_SWT - - 2.*vx3_NEB + 2.*vx3_NET - 2.*vx3_NWB + 2.*vx3_NWT + - 2.*vx3_SEB - 2.*vx3_SET + 2.*vx3_SWB - 2.*vx3_SWT)/64.; - c0 = (kxxMyyFromfcNEQ_NEB - kxxMyyFromfcNEQ_NET + kxxMyyFromfcNEQ_NWB - kxxMyyFromfcNEQ_NWT + - kxxMyyFromfcNEQ_SEB - kxxMyyFromfcNEQ_SET + kxxMyyFromfcNEQ_SWB - kxxMyyFromfcNEQ_SWT - - 2.*kxxMzzFromfcNEQ_NEB + 2.*kxxMzzFromfcNEQ_NET - 2.*kxxMzzFromfcNEQ_NWB + 2.*kxxMzzFromfcNEQ_NWT - - 2.*kxxMzzFromfcNEQ_SEB + 2.*kxxMzzFromfcNEQ_SET - 2.*kxxMzzFromfcNEQ_SWB + 2.*kxxMzzFromfcNEQ_SWT - - 2.*kxzFromfcNEQ_NEB - 2.*kxzFromfcNEQ_NET + 2.*kxzFromfcNEQ_NWB + 2.*kxzFromfcNEQ_NWT - - 2.*kxzFromfcNEQ_SEB - 2.*kxzFromfcNEQ_SET + 2.*kxzFromfcNEQ_SWB + 2.*kxzFromfcNEQ_SWT - - 2.*kyzFromfcNEQ_NEB - 2.*kyzFromfcNEQ_NET - 2.*kyzFromfcNEQ_NWB - 2.*kyzFromfcNEQ_NWT + - 2.*kyzFromfcNEQ_SEB + 2.*kyzFromfcNEQ_SET + 2.*kyzFromfcNEQ_SWB + 2.*kyzFromfcNEQ_SWT - - 2.*vx1_NEB + 2.*vx1_NET + 2.*vx1_NWB - 2.*vx1_NWT - - 2.*vx1_SEB + 2.*vx1_SET + 2.*vx1_SWB - 2.*vx1_SWT - - 2.*vx2_NEB + 2.*vx2_NET - 2.*vx2_NWB + 2.*vx2_NWT + - 2.*vx2_SEB - 2.*vx2_SET + 2.*vx2_SWB - 2.*vx2_SWT + - 8.*vx3_NEB + 8.*vx3_NET + 8.*vx3_NWB + 8.*vx3_NWT + - 8.*vx3_SEB + 8.*vx3_SET + 8.*vx3_SWB + 8.*vx3_SWT)/64.; - ax = (vx1_NEB + vx1_NET - vx1_NWB - vx1_NWT + vx1_SEB + vx1_SET - vx1_SWB - vx1_SWT)/4.; - bx = (vx2_NEB + vx2_NET - vx2_NWB - vx2_NWT + vx2_SEB + vx2_SET - vx2_SWB - vx2_SWT)/4.; - cx = (vx3_NEB + vx3_NET - vx3_NWB - vx3_NWT + vx3_SEB + vx3_SET - vx3_SWB - vx3_SWT)/4.; - axx= (kxxMyyFromfcNEQ_NEB + kxxMyyFromfcNEQ_NET - kxxMyyFromfcNEQ_NWB - kxxMyyFromfcNEQ_NWT + - kxxMyyFromfcNEQ_SEB + kxxMyyFromfcNEQ_SET - kxxMyyFromfcNEQ_SWB - kxxMyyFromfcNEQ_SWT + - kxxMzzFromfcNEQ_NEB + kxxMzzFromfcNEQ_NET - kxxMzzFromfcNEQ_NWB - kxxMzzFromfcNEQ_NWT + - kxxMzzFromfcNEQ_SEB + kxxMzzFromfcNEQ_SET - kxxMzzFromfcNEQ_SWB - kxxMzzFromfcNEQ_SWT + - 2.*vx2_NEB + 2.*vx2_NET - 2.*vx2_NWB - 2.*vx2_NWT - - 2.*vx2_SEB - 2.*vx2_SET + 2.*vx2_SWB + 2.*vx2_SWT - - 2.*vx3_NEB + 2.*vx3_NET + 2.*vx3_NWB - 2.*vx3_NWT - - 2.*vx3_SEB + 2.*vx3_SET + 2.*vx3_SWB - 2.*vx3_SWT)/16.; - bxx= (kxyFromfcNEQ_NEB + kxyFromfcNEQ_NET - kxyFromfcNEQ_NWB - kxyFromfcNEQ_NWT + - kxyFromfcNEQ_SEB + kxyFromfcNEQ_SET - kxyFromfcNEQ_SWB - kxyFromfcNEQ_SWT - - 2.*vx1_NEB - 2.*vx1_NET + 2.*vx1_NWB + 2.*vx1_NWT + - 2.*vx1_SEB + 2.*vx1_SET - 2.*vx1_SWB - 2.*vx1_SWT)/8.; - cxx= (kxzFromfcNEQ_NEB + kxzFromfcNEQ_NET - kxzFromfcNEQ_NWB - kxzFromfcNEQ_NWT + - kxzFromfcNEQ_SEB + kxzFromfcNEQ_SET - kxzFromfcNEQ_SWB - kxzFromfcNEQ_SWT + - 2.*vx1_NEB - 2.*vx1_NET - 2.*vx1_NWB + 2.*vx1_NWT + - 2.*vx1_SEB - 2.*vx1_SET - 2.*vx1_SWB + 2.*vx1_SWT)/8.; - ay = (vx1_NEB + vx1_NET + vx1_NWB + vx1_NWT - vx1_SEB - vx1_SET - vx1_SWB - vx1_SWT)/4.; - by = (vx2_NEB + vx2_NET + vx2_NWB + vx2_NWT - vx2_SEB - vx2_SET - vx2_SWB - vx2_SWT)/4.; - cy = (vx3_NEB + vx3_NET + vx3_NWB + vx3_NWT - vx3_SEB - vx3_SET - vx3_SWB - vx3_SWT)/4.; - ayy= (kxyFromfcNEQ_NEB + kxyFromfcNEQ_NET + kxyFromfcNEQ_NWB + kxyFromfcNEQ_NWT - - kxyFromfcNEQ_SEB - kxyFromfcNEQ_SET - kxyFromfcNEQ_SWB - kxyFromfcNEQ_SWT - - 2.*vx2_NEB - 2.*vx2_NET + 2.*vx2_NWB + 2.*vx2_NWT + - 2.*vx2_SEB + 2.*vx2_SET - 2.*vx2_SWB - 2.*vx2_SWT)/8.; - byy= (-2.*kxxMyyFromfcNEQ_NEB - 2.*kxxMyyFromfcNEQ_NET - 2.*kxxMyyFromfcNEQ_NWB - 2.*kxxMyyFromfcNEQ_NWT + - 2.*kxxMyyFromfcNEQ_SEB + 2.*kxxMyyFromfcNEQ_SET + 2.*kxxMyyFromfcNEQ_SWB + 2.*kxxMyyFromfcNEQ_SWT + - kxxMzzFromfcNEQ_NEB + kxxMzzFromfcNEQ_NET + kxxMzzFromfcNEQ_NWB + kxxMzzFromfcNEQ_NWT - - kxxMzzFromfcNEQ_SEB - kxxMzzFromfcNEQ_SET - kxxMzzFromfcNEQ_SWB - kxxMzzFromfcNEQ_SWT + - 2.*vx1_NEB + 2.*vx1_NET - 2.*vx1_NWB - 2.*vx1_NWT - - 2.*vx1_SEB - 2.*vx1_SET + 2.*vx1_SWB + 2.*vx1_SWT - - 2.*vx3_NEB + 2.*vx3_NET - 2.*vx3_NWB + 2.*vx3_NWT + - 2.*vx3_SEB - 2.*vx3_SET + 2.*vx3_SWB - 2.*vx3_SWT)/16.; - cyy= (kyzFromfcNEQ_NEB + kyzFromfcNEQ_NET + kyzFromfcNEQ_NWB + kyzFromfcNEQ_NWT - - kyzFromfcNEQ_SEB - kyzFromfcNEQ_SET - kyzFromfcNEQ_SWB - kyzFromfcNEQ_SWT + - 2.*vx2_NEB - 2.*vx2_NET + 2.*vx2_NWB - 2.*vx2_NWT - - 2.*vx2_SEB + 2.*vx2_SET - 2.*vx2_SWB + 2.*vx2_SWT)/8.; - az = (-vx1_NEB + vx1_NET - vx1_NWB + vx1_NWT - vx1_SEB + vx1_SET - vx1_SWB + vx1_SWT)/4.; - bz = (-vx2_NEB + vx2_NET - vx2_NWB + vx2_NWT - vx2_SEB + vx2_SET - vx2_SWB + vx2_SWT)/4.; - cz = (-vx3_NEB + vx3_NET - vx3_NWB + vx3_NWT - vx3_SEB + vx3_SET - vx3_SWB + vx3_SWT)/4.; - azz= (-kxzFromfcNEQ_NEB + kxzFromfcNEQ_NET - kxzFromfcNEQ_NWB + kxzFromfcNEQ_NWT - - kxzFromfcNEQ_SEB + kxzFromfcNEQ_SET - kxzFromfcNEQ_SWB + kxzFromfcNEQ_SWT + - 2.*vx3_NEB - 2.*vx3_NET - 2.*vx3_NWB + 2.*vx3_NWT + - 2.*vx3_SEB - 2.*vx3_SET - 2.*vx3_SWB + 2.*vx3_SWT)/8.; - bzz= (-kyzFromfcNEQ_NEB + kyzFromfcNEQ_NET - kyzFromfcNEQ_NWB + kyzFromfcNEQ_NWT - - kyzFromfcNEQ_SEB + kyzFromfcNEQ_SET - kyzFromfcNEQ_SWB + kyzFromfcNEQ_SWT + - 2.*vx3_NEB - 2.*vx3_NET + 2.*vx3_NWB - 2.*vx3_NWT - - 2.*vx3_SEB + 2.*vx3_SET - 2.*vx3_SWB + 2.*vx3_SWT)/8.; - czz= (-kxxMyyFromfcNEQ_NEB + kxxMyyFromfcNEQ_NET - kxxMyyFromfcNEQ_NWB + kxxMyyFromfcNEQ_NWT - - kxxMyyFromfcNEQ_SEB + kxxMyyFromfcNEQ_SET - kxxMyyFromfcNEQ_SWB + kxxMyyFromfcNEQ_SWT + - 2.*kxxMzzFromfcNEQ_NEB - 2.*kxxMzzFromfcNEQ_NET + 2.*kxxMzzFromfcNEQ_NWB - 2.*kxxMzzFromfcNEQ_NWT + - 2.*kxxMzzFromfcNEQ_SEB - 2.*kxxMzzFromfcNEQ_SET + 2.*kxxMzzFromfcNEQ_SWB - 2.*kxxMzzFromfcNEQ_SWT - - 2.*vx1_NEB + 2.*vx1_NET + 2.*vx1_NWB - 2.*vx1_NWT - - 2.*vx1_SEB + 2.*vx1_SET + 2.*vx1_SWB - 2.*vx1_SWT - - 2.*vx2_NEB + 2.*vx2_NET - 2.*vx2_NWB + 2.*vx2_NWT + - 2.*vx2_SEB - 2.*vx2_SET + 2.*vx2_SWB - 2.*vx2_SWT)/16.; - axy= (vx1_NEB + vx1_NET - vx1_NWB - vx1_NWT - vx1_SEB - vx1_SET + vx1_SWB + vx1_SWT)/2.; - bxy= (vx2_NEB + vx2_NET - vx2_NWB - vx2_NWT - vx2_SEB - vx2_SET + vx2_SWB + vx2_SWT)/2.; - cxy= (vx3_NEB + vx3_NET - vx3_NWB - vx3_NWT - vx3_SEB - vx3_SET + vx3_SWB + vx3_SWT)/2.; - axz= (-vx1_NEB + vx1_NET + vx1_NWB - vx1_NWT - vx1_SEB + vx1_SET + vx1_SWB - vx1_SWT)/2.; - bxz= (-vx2_NEB + vx2_NET + vx2_NWB - vx2_NWT - vx2_SEB + vx2_SET + vx2_SWB - vx2_SWT)/2.; - cxz= (-vx3_NEB + vx3_NET + vx3_NWB - vx3_NWT - vx3_SEB + vx3_SET + vx3_SWB - vx3_SWT)/2.; - ayz= (-vx1_NEB + vx1_NET - vx1_NWB + vx1_NWT + vx1_SEB - vx1_SET + vx1_SWB - vx1_SWT)/2.; - byz= (-vx2_NEB + vx2_NET - vx2_NWB + vx2_NWT + vx2_SEB - vx2_SET + vx2_SWB - vx2_SWT)/2.; - cyz= (-vx3_NEB + vx3_NET - vx3_NWB + vx3_NWT + vx3_SEB - vx3_SET + vx3_SWB - vx3_SWT)/2.; - axyz=-vx1_NEB + vx1_NET + vx1_NWB - vx1_NWT + vx1_SEB - vx1_SET - vx1_SWB + vx1_SWT; - bxyz=-vx2_NEB + vx2_NET + vx2_NWB - vx2_NWT + vx2_SEB - vx2_SET - vx2_SWB + vx2_SWT; - cxyz=-vx3_NEB + vx3_NET + vx3_NWB - vx3_NWT + vx3_SEB - vx3_SET - vx3_SWB + vx3_SWT; - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // - // Bernd das Brot - // - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - a0 = a0 + xoff * ax + yoff * ay + zoff * az + xoff_sq * axx + yoff_sq * ayy + zoff_sq * azz + xoff*yoff*axy + xoff*zoff*axz + yoff*zoff*ayz + xoff*yoff*zoff*axyz ; - ax = ax + 2. * xoff * axx + yoff * axy + zoff * axz + yoff*zoff*axyz; - ay = ay + 2. * yoff * ayy + xoff * axy + zoff * ayz + xoff*zoff*axyz; - az = az + 2. * zoff * azz + xoff * axz + yoff * ayz + xoff*yoff*axyz; - b0 = b0 + xoff * bx + yoff * by + zoff * bz + xoff_sq * bxx + yoff_sq * byy + zoff_sq * bzz + xoff*yoff*bxy + xoff*zoff*bxz + yoff*zoff*byz + xoff*yoff*zoff*bxyz; - bx = bx + 2. * xoff * bxx + yoff * bxy + zoff * bxz + yoff*zoff*bxyz; - by = by + 2. * yoff * byy + xoff * bxy + zoff * byz + xoff*zoff*bxyz; - bz = bz + 2. * zoff * bzz + xoff * bxz + yoff * byz + xoff*yoff*bxyz; - c0 = c0 + xoff * cx + yoff * cy + zoff * cz + xoff_sq * cxx + yoff_sq * cyy + zoff_sq * czz + xoff*yoff*cxy + xoff*zoff*cxz + yoff*zoff*cyz + xoff*yoff*zoff*cxyz; - cx = cx + 2. * xoff * cxx + yoff * cxy + zoff * cxz + yoff*zoff*cxyz; - cy = cy + 2. * yoff * cyy + xoff * cxy + zoff * cyz + xoff*zoff*cxyz; - cz = cz + 2. * zoff * czz + xoff * cxz + yoff * cyz + xoff*yoff*cxyz; - axy= axy + zoff*axyz; - axz= axz + yoff*axyz; - ayz= ayz + xoff*axyz; - bxy= bxy + zoff*bxyz; - bxz= bxz + yoff*bxyz; - byz= byz + xoff*bxyz; - cxy= cxy + zoff*cxyz; - cxz= cxz + yoff*cxyz; - cyz= cyz + xoff*cxyz; - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - const LBMReal o = omega; - - f_E = eps_new*((2*(-2*ax + by + cz))/(27.*o)); - f_N = eps_new*((2*(ax - 2*by + cz))/(27.*o)); - f_T = eps_new*((2*(ax + by - 2*cz))/(27.*o)); - f_NE = eps_new*(-(ax + 3*ay + 3*bx + by - 2*cz)/(54.*o)); - f_SE = eps_new*(-(ax - 3*ay - 3*bx + by - 2*cz)/(54.*o)); - f_TE = eps_new*(-(ax + 3*az - 2*by + 3*cx + cz)/(54.*o)); - f_BE = eps_new*(-(ax - 3*az - 2*by - 3*cx + cz)/(54.*o)); - f_TN = eps_new*(-(-2*ax + by + 3*bz + 3*cy + cz)/(54.*o)); - f_BN = eps_new*(-(-2*ax + by - 3*bz - 3*cy + cz)/(54.*o)); - f_ZERO = 0.; - f_TNE = eps_new*(-(ay + az + bx + bz + cx + cy)/(72.*o)); - f_TSW = eps_new*((-ay + az - bx + bz + cx + cy)/(72.*o)); - f_TSE = eps_new*((ay - az + bx + bz - cx + cy)/(72.*o)); - f_TNW = eps_new*((ay + az + bx - bz + cx - cy)/(72.*o)); - - x_E = 0.25*eps_new*((2*(-4*axx + bxy + cxz))/(27.*o)); - x_N = 0.25*eps_new*((2*(2*axx - 2*bxy + cxz))/(27.*o)); - x_T = 0.25*eps_new*((2*(2*axx + bxy - 2*cxz))/(27.*o)); - x_NE = 0.25*eps_new*(-((2*axx + 3*axy + 6*bxx + bxy - 2*cxz))/(54.*o)); - x_SE = 0.25*eps_new*(-((2*axx - 3*axy - 6*bxx + bxy - 2*cxz))/(54.*o)); - x_TE = 0.25*eps_new*(-((2*axx + 3*axz - 2*bxy + 6*cxx + cxz))/(54.*o)); - x_BE = 0.25*eps_new*(-((2*axx - 3*axz - 2*bxy - 6*cxx + cxz))/(54.*o)); - x_TN = 0.25*eps_new*(-((-4*axx + bxy + 3*bxz + 3*cxy + cxz))/(54.*o)); - x_BN = 0.25*eps_new*(-((-4*axx + bxy - 3*bxz - 3*cxy + cxz))/(54.*o)); - x_ZERO = 0.; - x_TNE = 0.25*eps_new*(-((axy + axz + 2*bxx + bxz + 2*cxx + cxy))/(72.*o)); - x_TSW = 0.25*eps_new*(((-axy + axz - 2*bxx + bxz + 2*cxx + cxy))/(72.*o)); - x_TSE = 0.25*eps_new*(((axy - axz + 2*bxx + bxz - 2*cxx + cxy))/(72.*o)); - x_TNW = 0.25*eps_new*(((axy + axz + 2*bxx - bxz + 2*cxx - cxy))/(72.*o)); - - y_E = 0.25*eps_new*(2*(-2*axy + 2*byy + cyz))/(27.*o); - y_N = 0.25*eps_new*(2*(axy - 4*byy + cyz))/(27.*o); - y_T = 0.25*eps_new*(2*(axy + 2*byy - 2*cyz))/(27.*o); - y_NE = 0.25*eps_new*(-((axy + 6*ayy + 3*bxy + 2*byy - 2*cyz))/(54.*o)); - y_SE = 0.25*eps_new*(-((axy - 6*ayy - 3*bxy + 2*byy - 2*cyz))/(54.*o)); - y_TE = 0.25*eps_new*(-((axy + 3*ayz - 4*byy + 3*cxy + cyz))/(54.*o)); - y_BE = 0.25*eps_new*(-((axy - 3*ayz - 4*byy - 3*cxy + cyz))/(54.*o)); - y_TN = 0.25*eps_new*(-((-2*axy + 2*byy + 3*byz + 6*cyy + cyz))/(54.*o)); - y_BN = 0.25*eps_new*(-((-2*axy + 2*byy - 3*byz - 6*cyy + cyz))/(54.*o)); - y_ZERO = 0.; - y_TNE = 0.25*eps_new*(-((2*ayy + ayz + bxy + byz + cxy + 2*cyy))/(72.*o)); - y_TSW = 0.25*eps_new*(((-2*ayy + ayz - bxy + byz + cxy + 2*cyy))/(72.*o)); - y_TSE = 0.25*eps_new*(((2*ayy - ayz + bxy + byz - cxy + 2*cyy))/(72.*o)); - y_TNW = 0.25*eps_new*(((2*ayy + ayz + bxy - byz + cxy - 2*cyy))/(72.*o)); - - z_E = 0.25*eps_new*((2*(-2*axz + byz + 2*czz))/(27.*o)); - z_N = 0.25*eps_new*((2*(axz - 2*byz + 2*czz))/(27.*o)); - z_T = 0.25*eps_new*((2*(axz + byz - 4*czz))/(27.*o)); - z_NE = 0.25*eps_new*(-((axz + 3*ayz + 3*bxz + byz - 4*czz))/(54.*o)); - z_SE = 0.25*eps_new*(-((axz - 3*ayz - 3*bxz + byz - 4*czz))/(54.*o)); - z_TE = 0.25*eps_new*(-((axz + 6*azz - 2*byz + 3*cxz + 2*czz))/(54.*o)); - z_BE = 0.25*eps_new*(-((axz - 6*azz - 2*byz - 3*cxz + 2*czz))/(54.*o)); - z_TN = 0.25*eps_new*(-((-2*axz + byz + 6*bzz + 3*cyz + 2*czz))/(54.*o)); - z_BN = 0.25*eps_new*(-((-2*axz + byz - 6*bzz - 3*cyz + 2*czz))/(54.*o)); - z_ZERO = 0.; - z_TNE = 0.25*eps_new*(-((ayz + 2*azz + bxz + 2*bzz + cxz + cyz))/(72.*o)); - z_TSW = 0.25*eps_new*(((-ayz + 2*azz - bxz + 2*bzz + cxz + cyz))/(72.*o)); - z_TSE = 0.25*eps_new*(((ayz - 2*azz + bxz + 2*bzz - cxz + cyz))/(72.*o)); - z_TNW = 0.25*eps_new*(((ayz + 2*azz + bxz - 2*bzz + cxz - cyz))/(72.*o)); - - xy_E = 0.0625*eps_new *(( 2.*cxyz)/(27.*o)); - xy_N = 0.0625*eps_new *(( 2.*cxyz)/(27.*o)); - xy_T = -(0.0625*eps_new *(( 4.*cxyz)/(27.*o))); - xy_NE = 0.0625*eps_new *( cxyz /(27.*o)); - xy_SE = 0.0625*eps_new *( cxyz /(27.*o)); - xy_TE = -(0.0625*eps_new *(( 3.*axyz + cxyz)/(54.*o))); - xy_BE = -(0.0625*eps_new *((-3.*axyz + cxyz)/(54.*o))); - xy_TN = -(0.0625*eps_new *(( 3.*bxyz + cxyz)/(54.*o))); - xy_BN = -(0.0625*eps_new *(( - 3.*bxyz + cxyz)/(54.*o))); - //xy_ZERO= 0.0625*eps_new; - xy_TNE = -(0.0625*eps_new *(( axyz + bxyz )/(72.*o))); - xy_TSW = 0.0625*eps_new *(( axyz + bxyz )/(72.*o)); - xy_TSE = 0.0625*eps_new *((- axyz + bxyz )/(72.*o)); - xy_TNW = 0.0625*eps_new *(( axyz - bxyz )/(72.*o)); - - xz_E = 0.0625*eps_new *(( 2.*bxyz )/(27.*o)); - xz_N = -(0.0625*eps_new *(( 4.*bxyz )/(27.*o))); - xz_T = 0.0625*eps_new *(( 2.*bxyz )/(27.*o)); - xz_NE = -(0.0625*eps_new *(( 3.*axyz + bxyz )/(54.*o))); - xz_SE = -(0.0625*eps_new *((-3.*axyz + bxyz )/(54.*o))); - xz_TE = 0.0625*eps_new *(( bxyz )/(27.*o)); - xz_BE = 0.0625*eps_new *(( bxyz )/(27.*o)); - xz_TN = -(0.0625*eps_new *(( bxyz + 3.*cxyz)/(54.*o))); - xz_BN = -(0.0625*eps_new *(( bxyz - 3.*cxyz)/(54.*o))); - //xz_ZERO= 0.0625*eps_new; - xz_TNE = -(0.0625*eps_new *(( axyz + cxyz)/(72.*o))); - xz_TSW = 0.0625*eps_new *((- axyz + cxyz)/(72.*o)); - xz_TSE = 0.0625*eps_new *(( axyz + cxyz)/(72.*o)); - xz_TNW = 0.0625*eps_new *(( axyz - cxyz)/(72.*o)); - - yz_E = -(0.0625*eps_new *(( 4.*axyz )/(27.*o))); - yz_N = 0.0625*eps_new *(( 2.*axyz )/(27.*o)); - yz_T = 0.0625*eps_new *(( 2.*axyz )/(27.*o)); - yz_NE = -(0.0625*eps_new *(( axyz + 3.*bxyz )/(54.*o))); - yz_SE = -(0.0625*eps_new *(( axyz - 3.*bxyz )/(54.*o))); - yz_TE = -(0.0625*eps_new *(( axyz + 3.*cxyz)/(54.*o))); - yz_BE = -(0.0625*eps_new *(( axyz - 3.*cxyz)/(54.*o))); - yz_TN = 0.0625*eps_new *(( axyz )/(27.*o)); - yz_BN = 0.0625*eps_new *(( axyz )/(27.*o)); - //yz_ZERO= 0.0625*eps_new; - yz_TNE = -(0.0625*eps_new *(( bxyz + cxyz)/(72.*o))); - yz_TSW = 0.0625*eps_new *(( - bxyz + cxyz)/(72.*o)); - yz_TSE = 0.0625*eps_new *(( bxyz - cxyz)/(72.*o)); - yz_TNW = 0.0625*eps_new *(( bxyz + cxyz)/(72.*o)); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27OffsetInterpolationProcessor::calcInterpolatedNode(LBMReal* f, LBMReal omega, LBMReal x, LBMReal y, LBMReal z, LBMReal press, LBMReal xs, LBMReal ys, LBMReal zs) -{ - using namespace D3Q27System; - - LBMReal rho = press ;//+ (2.*axx*x+axy*y+axz*z+axyz*y*z+ax + 2.*byy*y+bxy*x+byz*z+bxyz*x*z+by + 2.*czz*z+cxz*x+cyz*y+cxyz*x*y+cz)/3.; - LBMReal vx1 = a0 + 0.25*( xs*ax + ys*ay + zs*az) + 0.0625*(axx + xs*ys*axy + xs*zs*axz + ayy + ys*zs*ayz + azz) + 0.015625*(xs*ys*zs*axyz); - LBMReal vx2 = b0 + 0.25*( xs*bx + ys*by + zs*bz) + 0.0625*(bxx + xs*ys*bxy + xs*zs*bxz + byy + ys*zs*byz + bzz) + 0.015625*(xs*ys*zs*bxyz); - LBMReal vx3 = c0 + 0.25*( xs*cx + ys*cy + zs*cz) + 0.0625*(cxx + xs*ys*cxy + xs*zs*cxz + cyy + ys*zs*cyz + czz) + 0.015625*(xs*ys*zs*cxyz); - - LBMReal feq[ENDF+1]; - calcFeqFct(feq,rho,vx1,vx2,vx3); - - f[E] = f_E + xs*x_E + ys*y_E + zs*z_E + xs*ys*xy_E + xs*zs*xz_E + ys*zs*yz_E + feq[E]; - f[W] = f_E + xs*x_E + ys*y_E + zs*z_E + xs*ys*xy_E + xs*zs*xz_E + ys*zs*yz_E + feq[W]; - f[N] = f_N + xs*x_N + ys*y_N + zs*z_N + xs*ys*xy_N + xs*zs*xz_N + ys*zs*yz_N + feq[N]; - f[S] = f_N + xs*x_N + ys*y_N + zs*z_N + xs*ys*xy_N + xs*zs*xz_N + ys*zs*yz_N + feq[S]; - f[T] = f_T + xs*x_T + ys*y_T + zs*z_T + xs*ys*xy_T + xs*zs*xz_T + ys*zs*yz_T + feq[T]; - f[B] = f_T + xs*x_T + ys*y_T + zs*z_T + xs*ys*xy_T + xs*zs*xz_T + ys*zs*yz_T + feq[B]; - f[NE] = f_NE + xs*x_NE + ys*y_NE + zs*z_NE + xs*ys*xy_NE + xs*zs*xz_NE + ys*zs*yz_NE + feq[NE]; - f[SW] = f_NE + xs*x_NE + ys*y_NE + zs*z_NE + xs*ys*xy_NE + xs*zs*xz_NE + ys*zs*yz_NE + feq[SW]; - f[SE] = f_SE + xs*x_SE + ys*y_SE + zs*z_SE + xs*ys*xy_SE + xs*zs*xz_SE + ys*zs*yz_SE + feq[SE]; - f[NW] = f_SE + xs*x_SE + ys*y_SE + zs*z_SE + xs*ys*xy_SE + xs*zs*xz_SE + ys*zs*yz_SE + feq[NW]; - f[TE] = f_TE + xs*x_TE + ys*y_TE + zs*z_TE + xs*ys*xy_TE + xs*zs*xz_TE + ys*zs*yz_TE + feq[TE]; - f[BW] = f_TE + xs*x_TE + ys*y_TE + zs*z_TE + xs*ys*xy_TE + xs*zs*xz_TE + ys*zs*yz_TE + feq[BW]; - f[BE] = f_BE + xs*x_BE + ys*y_BE + zs*z_BE + xs*ys*xy_BE + xs*zs*xz_BE + ys*zs*yz_BE + feq[BE]; - f[TW] = f_BE + xs*x_BE + ys*y_BE + zs*z_BE + xs*ys*xy_BE + xs*zs*xz_BE + ys*zs*yz_BE + feq[TW]; - f[TN] = f_TN + xs*x_TN + ys*y_TN + zs*z_TN + xs*ys*xy_TN + xs*zs*xz_TN + ys*zs*yz_TN + feq[TN]; - f[BS] = f_TN + xs*x_TN + ys*y_TN + zs*z_TN + xs*ys*xy_TN + xs*zs*xz_TN + ys*zs*yz_TN + feq[BS]; - f[BN] = f_BN + xs*x_BN + ys*y_BN + zs*z_BN + xs*ys*xy_BN + xs*zs*xz_BN + ys*zs*yz_BN + feq[BN]; - f[TS] = f_BN + xs*x_BN + ys*y_BN + zs*z_BN + xs*ys*xy_BN + xs*zs*xz_BN + ys*zs*yz_BN + feq[TS]; - f[TNE] = f_TNE + xs*x_TNE + ys*y_TNE + zs*z_TNE + xs*ys*xy_TNE + xs*zs*xz_TNE + ys*zs*yz_TNE + feq[TNE]; - f[TSW] = f_TSW + xs*x_TSW + ys*y_TSW + zs*z_TSW + xs*ys*xy_TSW + xs*zs*xz_TSW + ys*zs*yz_TSW + feq[TSW]; - f[TSE] = f_TSE + xs*x_TSE + ys*y_TSE + zs*z_TSE + xs*ys*xy_TSE + xs*zs*xz_TSE + ys*zs*yz_TSE + feq[TSE]; - f[TNW] = f_TNW + xs*x_TNW + ys*y_TNW + zs*z_TNW + xs*ys*xy_TNW + xs*zs*xz_TNW + ys*zs*yz_TNW + feq[TNW]; - f[BNE] = f_TSW + xs*x_TSW + ys*y_TSW + zs*z_TSW + xs*ys*xy_TSW + xs*zs*xz_TSW + ys*zs*yz_TSW + feq[BNE]; - f[BSW] = f_TNE + xs*x_TNE + ys*y_TNE + zs*z_TNE + xs*ys*xy_TNE + xs*zs*xz_TNE + ys*zs*yz_TNE + feq[BSW]; - f[BSE] = f_TNW + xs*x_TNW + ys*y_TNW + zs*z_TNW + xs*ys*xy_TNW + xs*zs*xz_TNW + ys*zs*yz_TNW + feq[BSE]; - f[BNW] = f_TSE + xs*x_TSE + ys*y_TSE + zs*z_TSE + xs*ys*xy_TSE + xs*zs*xz_TSE + ys*zs*yz_TSE + feq[BNW]; - f[ZERO] = f_ZERO + xs*x_ZERO + ys*y_ZERO + zs*z_ZERO + feq[ZERO]; -} -////////////////////////////////////////////////////////////////////////// -//Position SWB -0.25, -0.25, -0.25 -LBMReal D3Q27OffsetInterpolationProcessor::calcPressBSW() -{ - return press_SWT * (0.140625 + 0.1875 * xoff + 0.1875 * yoff - 0.5625 * zoff) + - press_NWT * (0.046875 + 0.0625 * xoff - 0.1875 * yoff - 0.1875 * zoff) + - press_SET * (0.046875 - 0.1875 * xoff + 0.0625 * yoff - 0.1875 * zoff) + - press_NET * (0.015625 - 0.0625 * xoff - 0.0625 * yoff - 0.0625 * zoff) + - press_NEB * (0.046875 - 0.1875 * xoff - 0.1875 * yoff + 0.0625 * zoff) + - press_NWB * (0.140625 + 0.1875 * xoff - 0.5625 * yoff + 0.1875 * zoff) + - press_SEB * (0.140625 - 0.5625 * xoff + 0.1875 * yoff + 0.1875 * zoff) + - press_SWB * (0.421875 + 0.5625 * xoff + 0.5625 * yoff + 0.5625 * zoff); -} -////////////////////////////////////////////////////////////////////////// -//Position SWT -0.25, -0.25, 0.25 -LBMReal D3Q27OffsetInterpolationProcessor::calcPressTSW() -{ - return press_SWT * (0.421875 + 0.5625 * xoff + 0.5625 * yoff - 0.5625 * zoff) + - press_NWT * (0.140625 + 0.1875 * xoff - 0.5625 * yoff - 0.1875 * zoff) + - press_SET * (0.140625 - 0.5625 * xoff + 0.1875 * yoff - 0.1875 * zoff) + - press_NET * (0.046875 - 0.1875 * xoff - 0.1875 * yoff - 0.0625 * zoff) + - press_NEB * (0.015625 - 0.0625 * xoff - 0.0625 * yoff + 0.0625 * zoff) + - press_NWB * (0.046875 + 0.0625 * xoff - 0.1875 * yoff + 0.1875 * zoff) + - press_SEB * (0.046875 - 0.1875 * xoff + 0.0625 * yoff + 0.1875 * zoff) + - press_SWB * (0.140625 + 0.1875 * xoff + 0.1875 * yoff + 0.5625 * zoff); -} -////////////////////////////////////////////////////////////////////////// -//Position SET 0.25, -0.25, 0.25 -LBMReal D3Q27OffsetInterpolationProcessor::calcPressTSE() -{ - return press_SET * (0.421875 - 0.5625 * xoff + 0.5625 * yoff - 0.5625 * zoff) + - press_NET * (0.140625 - 0.1875 * xoff - 0.5625 * yoff - 0.1875 * zoff) + - press_SWT * (0.140625 + 0.5625 * xoff + 0.1875 * yoff - 0.1875 * zoff) + - press_NWT * (0.046875 + 0.1875 * xoff - 0.1875 * yoff - 0.0625 * zoff) + - press_NWB * (0.015625 + 0.0625 * xoff - 0.0625 * yoff + 0.0625 * zoff) + - press_NEB * (0.046875 - 0.0625 * xoff - 0.1875 * yoff + 0.1875 * zoff) + - press_SWB * (0.046875 + 0.1875 * xoff + 0.0625 * yoff + 0.1875 * zoff) + - press_SEB * (0.140625 - 0.1875 * xoff + 0.1875 * yoff + 0.5625 * zoff); -} -////////////////////////////////////////////////////////////////////////// -//Position SEB 0.25, -0.25, -0.25 -LBMReal D3Q27OffsetInterpolationProcessor::calcPressBSE() -{ - return press_SET * (0.140625 - 0.1875 * xoff + 0.1875 * yoff - 0.5625 * zoff) + - press_NET * (0.046875 - 0.0625 * xoff - 0.1875 * yoff - 0.1875 * zoff) + - press_SWT * (0.046875 + 0.1875 * xoff + 0.0625 * yoff - 0.1875 * zoff) + - press_NWT * (0.015625 + 0.0625 * xoff - 0.0625 * yoff - 0.0625 * zoff) + - press_NWB * (0.046875 + 0.1875 * xoff - 0.1875 * yoff + 0.0625 * zoff) + - press_NEB * (0.140625 - 0.1875 * xoff - 0.5625 * yoff + 0.1875 * zoff) + - press_SWB * (0.140625 + 0.5625 * xoff + 0.1875 * yoff + 0.1875 * zoff) + - press_SEB * (0.421875 - 0.5625 * xoff + 0.5625 * yoff + 0.5625 * zoff); -} -////////////////////////////////////////////////////////////////////////// -//Position NWB -0.25, 0.25, -0.25 -LBMReal D3Q27OffsetInterpolationProcessor::calcPressBNW() -{ - return press_NWT * (0.140625 + 0.1875 * xoff - 0.1875 * yoff - 0.5625 * zoff) + - press_NET * (0.046875 - 0.1875 * xoff - 0.0625 * yoff - 0.1875 * zoff) + - press_SWT * (0.046875 + 0.0625 * xoff + 0.1875 * yoff - 0.1875 * zoff) + - press_SET * (0.015625 - 0.0625 * xoff + 0.0625 * yoff - 0.0625 * zoff) + - press_SEB * (0.046875 - 0.1875 * xoff + 0.1875 * yoff + 0.0625 * zoff) + - press_NEB * (0.140625 - 0.5625 * xoff - 0.1875 * yoff + 0.1875 * zoff) + - press_SWB * (0.140625 + 0.1875 * xoff + 0.5625 * yoff + 0.1875 * zoff) + - press_NWB * (0.421875 + 0.5625 * xoff - 0.5625 * yoff + 0.5625 * zoff); -} -////////////////////////////////////////////////////////////////////////// -//Position NWT -0.25, 0.25, 0.25 -LBMReal D3Q27OffsetInterpolationProcessor::calcPressTNW() -{ - return press_NWT * (0.421875 + 0.5625 * xoff - 0.5625 * yoff - 0.5625 * zoff) + - press_NET * (0.140625 - 0.5625 * xoff - 0.1875 * yoff - 0.1875 * zoff) + - press_SWT * (0.140625 + 0.1875 * xoff + 0.5625 * yoff - 0.1875 * zoff) + - press_SET * (0.046875 - 0.1875 * xoff + 0.1875 * yoff - 0.0625 * zoff) + - press_SEB * (0.015625 - 0.0625 * xoff + 0.0625 * yoff + 0.0625 * zoff) + - press_NEB * (0.046875 - 0.1875 * xoff - 0.0625 * yoff + 0.1875 * zoff) + - press_SWB * (0.046875 + 0.0625 * xoff + 0.1875 * yoff + 0.1875 * zoff) + - press_NWB * (0.140625 + 0.1875 * xoff - 0.1875 * yoff + 0.5625 * zoff); -} -////////////////////////////////////////////////////////////////////////// -//Position NET 0.25, 0.25, 0.25 -LBMReal D3Q27OffsetInterpolationProcessor::calcPressTNE() -{ - return press_NET * (0.421875 - 0.5625 * xoff - 0.5625 * yoff - 0.5625 * zoff) + - press_NWT * (0.140625 + 0.5625 * xoff - 0.1875 * yoff - 0.1875 * zoff) + - press_SET * (0.140625 - 0.1875 * xoff + 0.5625 * yoff - 0.1875 * zoff) + - press_SWT * (0.046875 + 0.1875 * xoff + 0.1875 * yoff - 0.0625 * zoff) + - press_SWB * (0.015625 + 0.0625 * xoff + 0.0625 * yoff + 0.0625 * zoff) + - press_NWB * (0.046875 + 0.1875 * xoff - 0.0625 * yoff + 0.1875 * zoff) + - press_SEB * (0.046875 - 0.0625 * xoff + 0.1875 * yoff + 0.1875 * zoff) + - press_NEB * (0.140625 - 0.1875 * xoff - 0.1875 * yoff + 0.5625 * zoff); -} -////////////////////////////////////////////////////////////////////////// -//Position NEB 0.25, 0.25, -0.25 -LBMReal D3Q27OffsetInterpolationProcessor::calcPressBNE() -{ - return press_NET * (0.140625 - 0.1875 * xoff - 0.1875 * yoff - 0.5625 * zoff) + - press_NWT * (0.046875 + 0.1875 * xoff - 0.0625 * yoff - 0.1875 * zoff) + - press_SET * (0.046875 - 0.0625 * xoff + 0.1875 * yoff - 0.1875 * zoff) + - press_SWT * (0.015625 + 0.0625 * xoff + 0.0625 * yoff - 0.0625 * zoff) + - press_SWB * (0.046875 + 0.1875 * xoff + 0.1875 * yoff + 0.0625 * zoff) + - press_NWB * (0.140625 + 0.5625 * xoff - 0.1875 * yoff + 0.1875 * zoff) + - press_SEB * (0.140625 - 0.1875 * xoff + 0.5625 * yoff + 0.1875 * zoff) + - press_NEB * (0.421875 - 0.5625 * xoff - 0.5625 * yoff + 0.5625 * zoff); -} -////////////////////////////////////////////////////////////////////////// -//Position C 0.0, 0.0, 0.0 -void D3Q27OffsetInterpolationProcessor::calcInterpolatedNodeFC(LBMReal* f, LBMReal omega) -{ - using namespace D3Q27System; - - LBMReal press = press_NET * (0.125 - 0.25 * xoff - 0.25 * yoff - 0.25 * zoff) + - press_NWT * (0.125 + 0.25 * xoff - 0.25 * yoff - 0.25 * zoff) + - press_SET * (0.125 - 0.25 * xoff + 0.25 * yoff - 0.25 * zoff) + - press_SWT * (0.125 + 0.25 * xoff + 0.25 * yoff - 0.25 * zoff) + - press_NEB * (0.125 - 0.25 * xoff - 0.25 * yoff + 0.25 * zoff) + - press_NWB * (0.125 + 0.25 * xoff - 0.25 * yoff + 0.25 * zoff) + - press_SEB * (0.125 - 0.25 * xoff + 0.25 * yoff + 0.25 * zoff) + - press_SWB * (0.125 + 0.25 * xoff + 0.25 * yoff + 0.25 * zoff); - LBMReal vx1 = a0; - LBMReal vx2 = b0; - LBMReal vx3 = c0; - - LBMReal rho = press ;//+ (ax+by+cz)/3.; - - LBMReal feq[ENDF+1]; - calcFeqFct(feq,rho,vx1,vx2,vx3); - - LBMReal eps_new = 2.; - LBMReal o = omega; - LBMReal op = 1.; - - f_E = eps_new *((5.*ax*o + 5.*by*o + 5.*cz*o - 8.*ax*op + 4.*by*op + 4.*cz*op)/(54.*o*op)); - f_N = f_E + eps_new *((2.*(ax - by))/(9.*o)); - f_T = f_E + eps_new *((2.*(ax - cz))/(9.*o)); - f_NE = eps_new *(-(5.*cz*o + 3.*(ay + bx)*op - 2.*cz*op + ax*(5.*o + op) + by*(5.*o + op))/(54.*o*op)); - f_SE = f_NE + eps_new *(( ay + bx )/(9.*o)); - f_TE = eps_new *(-(5.*cz*o + by*(5.*o - 2.*op) + 3.*(az + cx)*op + cz*op + ax*(5.*o + op))/(54.*o*op)); - f_BE = f_TE + eps_new *(( az + cx )/(9.*o)); - f_TN = eps_new *(-(5.*ax*o + 5.*by*o + 5.*cz*o - 2.*ax*op + by*op + 3.*bz*op + 3.*cy*op + cz*op)/(54.*o*op)); - f_BN = f_TN + eps_new *(( bz + cy )/(9.*o)); - f_ZERO = eps_new *((5.*(ax + by + cz))/(9.*op)); - f_TNE = eps_new *(-(ay + az + bx + bz + cx + cy)/(72.*o)); - f_TSW = - eps_new *((ay + bx)/(36.*o)) - f_TNE; - f_TSE = - eps_new *((az + cx)/(36.*o)) - f_TNE; - f_TNW = - eps_new *((bz + cy)/(36.*o)) - f_TNE; - - - f[E] = f_E + feq[E]; - f[W] = f_E + feq[W]; - f[N] = f_N + feq[N]; - f[S] = f_N + feq[S]; - f[T] = f_T + feq[T]; - f[B] = f_T + feq[B]; - f[NE] = f_NE + feq[NE]; - f[SW] = f_NE + feq[SW]; - f[SE] = f_SE + feq[SE]; - f[NW] = f_SE + feq[NW]; - f[TE] = f_TE + feq[TE]; - f[BW] = f_TE + feq[BW]; - f[BE] = f_BE + feq[BE]; - f[TW] = f_BE + feq[TW]; - f[TN] = f_TN + feq[TN]; - f[BS] = f_TN + feq[BS]; - f[BN] = f_BN + feq[BN]; - f[TS] = f_BN + feq[TS]; - f[TNE] = f_TNE + feq[TNE]; - f[TNW] = f_TNW + feq[TNW]; - f[TSE] = f_TSE + feq[TSE]; - f[TSW] = f_TSW + feq[TSW]; - f[BNE] = f_TSW + feq[BNE]; - f[BNW] = f_TSE + feq[BNW]; - f[BSE] = f_TNW + feq[BSE]; - f[BSW] = f_TNE + feq[BSW]; - f[ZERO] = f_ZERO + feq[ZERO]; -} -////////////////////////////////////////////////////////////////////////// -void D3Q27OffsetInterpolationProcessor::calcInterpolatedVelocity(LBMReal x, LBMReal y, LBMReal z, LBMReal& vx1, LBMReal& vx2, LBMReal& vx3) -{ - vx1 = a0 + ax*x + ay*y + az*z + axx*x*x + ayy*y*y + azz*z*z + axy*x*y + axz*x*z + ayz*y*z+axyz*x*y*z; - vx2 = b0 + bx*x + by*y + bz*z + bxx*x*x + byy*y*y + bzz*z*z + bxy*x*y + bxz*x*z + byz*y*z+bxyz*x*y*z; - vx3 = c0 + cx*x + cy*y + cz*z + cxx*x*x + cyy*y*y + czz*z*z + cxy*x*y + cxz*x*z + cyz*y*z+cxyz*x*y*z; -} -////////////////////////////////////////////////////////////////////////// -void D3Q27OffsetInterpolationProcessor::calcInterpolatedShearStress(LBMReal x, LBMReal y, LBMReal z,LBMReal& tauxx, LBMReal& tauyy, LBMReal& tauzz,LBMReal& tauxy, LBMReal& tauxz, LBMReal& tauyz) -{ - tauxx=ax+2*axx*x+axy*y+axz*z+axyz*y*z; - tauyy=by+2*byy*y+bxy*x+byz*z+bxyz*x*z; - tauzz=cz+2*czz*z+cxz*x+cyz*y+cxyz*x*y; - tauxy=0.5*((ay+2.0*ayy*y+axy*x+ayz*z+axyz*x*z)+(bx+2.0*bxx*x+bxy*y+bxz*z+bxyz*y*z)); - tauxz=0.5*((az+2.0*azz*z+axz*x+ayz*y+axyz*x*y)+(cx+2.0*cxx*x+cxy*y+cxz*z+cxyz*y*z)); - tauyz=0.5*((bz+2.0*bzz*z+bxz*x+byz*y+bxyz*x*y)+(cy+2.0*cyy*y+cxy*x+cyz*z+cxyz*x*z)); -} -////////////////////////////////////////////////////////////////////////// - diff --git a/source/VirtualFluidsCore/LBM/D3Q27OffsetInterpolationProcessor.h b/source/VirtualFluidsCore/LBM/D3Q27OffsetInterpolationProcessor.h deleted file mode 100644 index 29d37b810..000000000 --- a/source/VirtualFluidsCore/LBM/D3Q27OffsetInterpolationProcessor.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef D3Q27OffsetInterpolationProcessor_H_ -#define D3Q27OffsetInterpolationProcessor_H_ - -#include "D3Q27InterpolationProcessor.h" -#include "D3Q27System.h" - - -////////////////////////////////////////////////////////////////////////// -//it work only for cascaded LBM -//super compact interpolation method by Martin Geier -////////////////////////////////////////////////////////////////////////// - -class D3Q27OffsetInterpolationProcessor; -typedef boost::shared_ptr<D3Q27OffsetInterpolationProcessor> D3Q27OffsetInterpolationProcessorPtr; - -class D3Q27OffsetInterpolationProcessor : public D3Q27InterpolationProcessor -{ -public: - D3Q27OffsetInterpolationProcessor(); - D3Q27OffsetInterpolationProcessor(LBMReal omegaC, LBMReal omegaF); - virtual ~D3Q27OffsetInterpolationProcessor(); - D3Q27InterpolationProcessorPtr clone(); - void setOmegas(LBMReal omegaC, LBMReal omegaF); - void interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF); - void interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF, LBMReal xoff, LBMReal yoff, LBMReal zoff); - void interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC); - void interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC, LBMReal xoff, LBMReal yoff, LBMReal zoff); -protected: -private: - typedef void (*CalcMacrosFct)(const LBMReal* const& /*f[27]*/, LBMReal& /*rho*/, LBMReal& /*vx1*/, LBMReal& /*vx2*/, LBMReal& /*vx3*/); - typedef LBMReal (*CalcFeqForDirFct)(const int& /*direction*/,const LBMReal& /*(d)rho*/,const LBMReal& /*vx1*/,const LBMReal& /*vx2*/,const LBMReal& /*vx3*/); - typedef void (*CalcFeqFct)(LBMReal* const& /*feq/*[27]*/,const LBMReal& /*rho*/,const LBMReal& /*vx1*/,const LBMReal& /*vx2*/,const LBMReal& /*vx3*/); - - CalcFeqForDirFct calcFeqsForDirFct; - CalcMacrosFct calcMacrosFct; - CalcFeqFct calcFeqFct; - LBMReal omegaC, omegaF; - LBMReal a0, ax, ay, az, axx, ayy, azz, axy, axz, ayz, b0, bx, by, bz, bxx, byy, bzz, bxy, bxz, byz, c0, cx, cy, cz, cxx, cyy, czz, cxy, cxz, cyz, axyz, bxyz, cxyz; - LBMReal xoff, yoff, zoff; - LBMReal xoff_sq, yoff_sq, zoff_sq; - LBMReal press_SWT, press_NWT, press_NET, press_SET, press_SWB, press_NWB, press_NEB, press_SEB; - - LBMReal f_E, f_N, f_T, f_NE, f_SE, f_BE, f_TE, f_TN, f_BN, f_TNE, f_TNW, f_TSE, f_TSW, f_ZERO; - LBMReal x_E, x_N, x_T, x_NE, x_SE, x_BE, x_TE, x_TN, x_BN, x_TNE, x_TNW, x_TSE, x_TSW, x_ZERO; - LBMReal y_E, y_N, y_T, y_NE, y_SE, y_BE, y_TE, y_TN, y_BN, y_TNE, y_TNW, y_TSE, y_TSW, y_ZERO; - LBMReal z_E, z_N, z_T, z_NE, z_SE, z_BE, z_TE, z_TN, z_BN, z_TNE, z_TNW, z_TSE, z_TSW, z_ZERO; - LBMReal xy_E, xy_N, xy_T, xy_NE, xy_SE, xy_BE, xy_TE, xy_TN, xy_BN, xy_TNE, xy_TNW, xy_TSE, xy_TSW/*, xy_ZERO*/; - LBMReal xz_E, xz_N, xz_T, xz_NE, xz_SE, xz_BE, xz_TE, xz_TN, xz_BN, xz_TNE, xz_TNW, xz_TSE, xz_TSW/*, xz_ZERO*/; - LBMReal yz_E, yz_N, yz_T, yz_NE, yz_SE, yz_BE, yz_TE, yz_TN, yz_BN, yz_TNE, yz_TNW, yz_TSE, yz_TSW/*, yz_ZERO*/; - - void init(); - void setOffsets(LBMReal xoff, LBMReal yoff, LBMReal zoff); - void calcMoments(const LBMReal* const f, LBMReal omega, LBMReal& rho, LBMReal& vx1, LBMReal& vx2, LBMReal& vx3, - LBMReal& kxy, LBMReal& kyz, LBMReal& kxz, LBMReal& kxxMyy, LBMReal& kxxMzz); - void calcInterpolatedCoefficiets(const D3Q27ICell& icell, LBMReal omega, LBMReal eps_new); - void calcInterpolatedNode(LBMReal* f, LBMReal omega, LBMReal x, LBMReal y, LBMReal z, LBMReal press, LBMReal xs, LBMReal ys, LBMReal zs); - LBMReal calcPressBSW(); - LBMReal calcPressTSW(); - LBMReal calcPressTSE(); - LBMReal calcPressBSE(); - LBMReal calcPressBNW(); - LBMReal calcPressTNW(); - LBMReal calcPressTNE(); - LBMReal calcPressBNE(); - void calcInterpolatedNodeFC(LBMReal* f, LBMReal omega); - void calcInterpolatedVelocity(LBMReal x, LBMReal y, LBMReal z,LBMReal& vx1, LBMReal& vx2, LBMReal& vx3); - void calcInterpolatedShearStress(LBMReal x, LBMReal y, LBMReal z,LBMReal& tauxx, LBMReal& tauyy, LBMReal& tauzz,LBMReal& tauxy, LBMReal& tauxz, LBMReal& tauyz); -}; - -////////////////////////////////////////////////////////////////////////// -inline void D3Q27OffsetInterpolationProcessor::interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF) -{ - this->interpolateCoarseToFine(icellC, icellF, 0.0, 0.0, 0.0); -} -////////////////////////////////////////////////////////////////////////// -inline void D3Q27OffsetInterpolationProcessor::interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC) -{ - this->interpolateFineToCoarse(icellF, icellC, 0.0, 0.0, 0.0); -} - -#endif diff --git a/source/VirtualFluidsCore/LBM/LBMKernelETD3Q27CCLB.cpp b/source/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.cpp similarity index 96% rename from source/VirtualFluidsCore/LBM/LBMKernelETD3Q27CCLB.cpp rename to source/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.cpp index 343a0f2b0..cd49e8e2f 100644 --- a/source/VirtualFluidsCore/LBM/LBMKernelETD3Q27CCLB.cpp +++ b/source/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.cpp @@ -1,6 +1,6 @@ -#include "LBMKernelETD3Q27CCLB.h" +#include "IncompressibleCumulantLBMKernel.h" #include "D3Q27System.h" -#include "D3Q27InterpolationProcessor.h" +#include "InterpolationProcessor.h" #include "D3Q27EsoTwist3DSplittedVector.h" #include <math.h> #include <omp.h> @@ -8,34 +8,36 @@ #define PROOF_CORRECTNESS ////////////////////////////////////////////////////////////////////////// -LBMKernelETD3Q27CCLB::LBMKernelETD3Q27CCLB() +IncompressibleCumulantLBMKernel::IncompressibleCumulantLBMKernel() { } ////////////////////////////////////////////////////////////////////////// -LBMKernelETD3Q27CCLB::LBMKernelETD3Q27CCLB(int nx1, int nx2, int nx3, Parameter p) - : LBMKernelETD3Q27(nx1, nx2, nx3), - parameter(p) +IncompressibleCumulantLBMKernel::IncompressibleCumulantLBMKernel(int nx1, int nx2, int nx3, Parameter p) { + this->nx1 = nx1; + this->nx2 = nx2; + this->nx3 = nx3; + parameter = p; this->compressible = false; } ////////////////////////////////////////////////////////////////////////// -LBMKernelETD3Q27CCLB::~LBMKernelETD3Q27CCLB(void) +IncompressibleCumulantLBMKernel::~IncompressibleCumulantLBMKernel(void) { } ////////////////////////////////////////////////////////////////////////// -void LBMKernelETD3Q27CCLB::init() +void IncompressibleCumulantLBMKernel::init() { //DistributionArray3DPtr d(new D3Q27EsoTwist3DSplittedVector(nx1+ghostLayerWitdh*2, nx2+ghostLayerWitdh*2, nx3+ghostLayerWitdh*2, -999.0)); DistributionArray3DPtr d(new D3Q27EsoTwist3DSplittedVector(nx1+2, nx2+2, nx3+2, -999.0)); dataSet->setFdistributions(d); } ////////////////////////////////////////////////////////////////////////// -LBMKernel3DPtr LBMKernelETD3Q27CCLB::clone() +LBMKernelPtr IncompressibleCumulantLBMKernel::clone() { - LBMKernel3DPtr kernel(new LBMKernelETD3Q27CCLB(nx1, nx2, nx3, parameter)); - boost::dynamic_pointer_cast<LBMKernelETD3Q27CCLB>(kernel)->init(); + LBMKernelPtr kernel(new IncompressibleCumulantLBMKernel(nx1, nx2, nx3, parameter)); + boost::dynamic_pointer_cast<IncompressibleCumulantLBMKernel>(kernel)->init(); kernel->setCollisionFactor(this->collFactor); kernel->setBCProcessor(bcProcessor->clone(kernel)); kernel->setWithForcing(withForcing); @@ -47,23 +49,23 @@ LBMKernel3DPtr LBMKernelETD3Q27CCLB::clone() switch (parameter) { case NORMAL: - boost::dynamic_pointer_cast<LBMKernelETD3Q27CCLB>(kernel)->OxyyMxzz = 1.0; + boost::dynamic_pointer_cast<IncompressibleCumulantLBMKernel>(kernel)->OxyyMxzz = 1.0; break; case MAGIC: - boost::dynamic_pointer_cast<LBMKernelETD3Q27CCLB>(kernel)->OxyyMxzz = 2.0 +(-collFactor); + boost::dynamic_pointer_cast<IncompressibleCumulantLBMKernel>(kernel)->OxyyMxzz = 2.0 +(-collFactor); break; } return kernel; } ////////////////////////////////////////////////////////////////////////// -void LBMKernelETD3Q27CCLB::calculate() +void IncompressibleCumulantLBMKernel::calculate() { timer.resetAndStart(); collideAll(); timer.stop(); } ////////////////////////////////////////////////////////////////////////// -void LBMKernelETD3Q27CCLB::collideAll() +void IncompressibleCumulantLBMKernel::collideAll() { using namespace D3Q27System; @@ -96,7 +98,7 @@ void LBMKernelETD3Q27CCLB::collideAll() nonLocalDistributions = boost::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getNonLocalDistributions(); zeroDistributions = boost::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getZeroDistributions(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(this->getBCProcessor())->getBCArray(); + BCArray3D& bcArray = this->getBCProcessor()->getBCArray(); const int bcArrayMaxX1 = (int)bcArray.getNX1(); const int bcArrayMaxX2 = (int)bcArray.getNX2(); @@ -904,7 +906,7 @@ void LBMKernelETD3Q27CCLB::collideAll() } } ////////////////////////////////////////////////////////////////////////// -double LBMKernelETD3Q27CCLB::getCallculationTime() +double IncompressibleCumulantLBMKernel::getCallculationTime() { //return timer.getDuration(); return timer.getTotalTime(); diff --git a/source/VirtualFluidsCore/LBM/LBMKernelETD3Q27CCLB.h b/source/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.h similarity index 69% rename from source/VirtualFluidsCore/LBM/LBMKernelETD3Q27CCLB.h rename to source/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.h index fc08a8b32..ce052ff8d 100644 --- a/source/VirtualFluidsCore/LBM/LBMKernelETD3Q27CCLB.h +++ b/source/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.h @@ -1,38 +1,38 @@ //Cascaded Cumulant LBM -#ifndef LBMKernelETD3Q27CCLB_H -#define LBMKernelETD3Q27CCLB_H +#ifndef IncompressibleCumulantLBMKernel_H +#define IncompressibleCumulantLBMKernel_H -#include "LBMKernelETD3Q27.h" -#include "D3Q27ETBCProcessor.h" +#include "LBMKernel.h" +#include "BCProcessor.h" #include "D3Q27System.h" #include <boost/serialization/export.hpp> #include "basics/utilities/UbTiming.h" #include "basics/container/CbArray4D.h" #include "basics/container/CbArray3D.h" -class LBMKernelETD3Q27CCLB; -typedef boost::shared_ptr<LBMKernelETD3Q27CCLB> LBMKernelETD3Q27CCLBPtr; +class IncompressibleCumulantLBMKernel; +typedef boost::shared_ptr<IncompressibleCumulantLBMKernel> LBMKernelETD3Q27CCLBPtr; //! \brief Cascaded Cumulant LBM kernel. //! \details CFD solver that use Cascaded Cumulant Lattice Boltzmann method for D3Q27 model -//! \author K. Kucher, M. Geier -class LBMKernelETD3Q27CCLB : public LBMKernelETD3Q27 +//! \author K. Kutscher, M. Geier +class IncompressibleCumulantLBMKernel : public LBMKernel { public: //! This option set relaxation parameter: NORMAL enum Parameter{NORMAL, MAGIC}; public: - LBMKernelETD3Q27CCLB(); + IncompressibleCumulantLBMKernel(); //! Constructor //! \param nx1 number of nodes in x dimension //! \param nx2 number of nodes in y dimension //! \param nx3 number of nodes in z dimension //! \param p set relaxation parameter: NORMAL is OxyyMxzz = 1.0 and MAGIC is OxyyMxzz = 2.0 +(-collFactor) - LBMKernelETD3Q27CCLB(int nx1, int nx2, int nx3, Parameter p); - virtual ~LBMKernelETD3Q27CCLB(void); + IncompressibleCumulantLBMKernel(int nx1, int nx2, int nx3, Parameter p); + virtual ~IncompressibleCumulantLBMKernel(void); virtual void calculate(); - virtual LBMKernel3DPtr clone(); + virtual LBMKernelPtr clone(); double getCallculationTime(); protected: @@ -40,7 +40,7 @@ protected: template<class Archive> void serialize(Archive & ar, const unsigned int version) { - ar & boost::serialization::base_object<LBMKernelETD3Q27>(*this); + ar & boost::serialization::base_object<LBMKernel>(*this); ar & OxyyMxzz; ar & parameter; } diff --git a/source/VirtualFluidsCore/LBM/LBMKernelETD3Q27CCLBWithSpongeLayer.cpp b/source/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.cpp similarity index 95% rename from source/VirtualFluidsCore/LBM/LBMKernelETD3Q27CCLBWithSpongeLayer.cpp rename to source/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.cpp index d3ba6214b..84ca58f08 100644 --- a/source/VirtualFluidsCore/LBM/LBMKernelETD3Q27CCLBWithSpongeLayer.cpp +++ b/source/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.cpp @@ -1,42 +1,38 @@ -#include "LBMKernelETD3Q27CCLBWithSpongeLayer.h" +#include "IncompressibleCumulantWithSpongeLayerLBMKernel.h" #include "D3Q27System.h" -#include "D3Q27NoSlipBCAdapter.h" -#include "D3Q27DensityBCAdapter.h" -#include "D3Q27VelocityBCAdapter.h" -#include "D3Q27InterpolationProcessor.h" #include "D3Q27EsoTwist3DSplittedVector.h" #include <math.h> #define PROOF_CORRECTNESS ////////////////////////////////////////////////////////////////////////// -LBMKernelETD3Q27CCLBWithSpongeLayer::LBMKernelETD3Q27CCLBWithSpongeLayer() +IncompressibleCumulantWithSpongeLayerLBMKernel::IncompressibleCumulantWithSpongeLayerLBMKernel() { } ////////////////////////////////////////////////////////////////////////// -LBMKernelETD3Q27CCLBWithSpongeLayer::LBMKernelETD3Q27CCLBWithSpongeLayer(int nx1, int nx2, int nx3, Parameter p) - : LBMKernelETD3Q27CCLB(nx1, nx2, nx3, p) +IncompressibleCumulantWithSpongeLayerLBMKernel::IncompressibleCumulantWithSpongeLayerLBMKernel(int nx1, int nx2, int nx3, Parameter p) + : IncompressibleCumulantLBMKernel(nx1, nx2, nx3, p) { } ////////////////////////////////////////////////////////////////////////// -LBMKernelETD3Q27CCLBWithSpongeLayer::~LBMKernelETD3Q27CCLBWithSpongeLayer(void) +IncompressibleCumulantWithSpongeLayerLBMKernel::~IncompressibleCumulantWithSpongeLayerLBMKernel(void) { } ////////////////////////////////////////////////////////////////////////// -void LBMKernelETD3Q27CCLBWithSpongeLayer::init() +void IncompressibleCumulantWithSpongeLayerLBMKernel::init() { //DistributionArray3DPtr d(new D3Q27EsoTwist3DSplittedVector(nx1+ghostLayerWitdh*2, nx2+ghostLayerWitdh*2, nx3+ghostLayerWitdh*2, -999.0)); DistributionArray3DPtr d(new D3Q27EsoTwist3DSplittedVector(nx1+2, nx2+2, nx3+2, -999.0)); dataSet->setFdistributions(d); } ////////////////////////////////////////////////////////////////////////// -LBMKernel3DPtr LBMKernelETD3Q27CCLBWithSpongeLayer::clone() +LBMKernelPtr IncompressibleCumulantWithSpongeLayerLBMKernel::clone() { - LBMKernel3DPtr kernel(new LBMKernelETD3Q27CCLBWithSpongeLayer(nx1, nx2, nx3, parameter)); - boost::dynamic_pointer_cast<LBMKernelETD3Q27CCLBWithSpongeLayer>(kernel)->init(); + LBMKernelPtr kernel(new IncompressibleCumulantWithSpongeLayerLBMKernel(nx1, nx2, nx3, parameter)); + boost::dynamic_pointer_cast<IncompressibleCumulantWithSpongeLayerLBMKernel>(kernel)->init(); kernel->setCollisionFactor(this->collFactor); kernel->setBCProcessor(bcProcessor->clone(kernel)); kernel->setWithForcing(withForcing); @@ -48,10 +44,10 @@ LBMKernel3DPtr LBMKernelETD3Q27CCLBWithSpongeLayer::clone() switch (parameter) { case NORMAL: - boost::dynamic_pointer_cast<LBMKernelETD3Q27CCLBWithSpongeLayer>(kernel)->OxyyMxzz = 1.0; + boost::dynamic_pointer_cast<IncompressibleCumulantWithSpongeLayerLBMKernel>(kernel)->OxyyMxzz = 1.0; break; case MAGIC: - boost::dynamic_pointer_cast<LBMKernelETD3Q27CCLBWithSpongeLayer>(kernel)->OxyyMxzz = 2.0 +(-collFactor); + boost::dynamic_pointer_cast<IncompressibleCumulantWithSpongeLayerLBMKernel>(kernel)->OxyyMxzz = 2.0 +(-collFactor); break; } @@ -60,14 +56,14 @@ LBMKernel3DPtr LBMKernelETD3Q27CCLBWithSpongeLayer::clone() return kernel; } ////////////////////////////////////////////////////////////////////////// -void LBMKernelETD3Q27CCLBWithSpongeLayer::calculate() +void IncompressibleCumulantWithSpongeLayerLBMKernel::calculate() { timer.resetAndStart(); collideAll(); timer.stop(); } ////////////////////////////////////////////////////////////////////////// -void LBMKernelETD3Q27CCLBWithSpongeLayer::collideAll() +void IncompressibleCumulantWithSpongeLayerLBMKernel::collideAll() { using namespace D3Q27System; @@ -112,7 +108,7 @@ void LBMKernelETD3Q27CCLBWithSpongeLayer::collideAll() nonLocalDistributions = boost::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getNonLocalDistributions(); zeroDistributions = boost::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getZeroDistributions(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(this->getBCProcessor())->getBCArray(); + BCArray3D& bcArray = this->getBCProcessor()->getBCArray(); const int bcArrayMaxX1 = (int)bcArray.getNX1(); const int bcArrayMaxX2 = (int)bcArray.getNX2(); diff --git a/source/VirtualFluidsCore/LBM/LBMKernelETD3Q27CCLBWithSpongeLayer.h b/source/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.h similarity index 65% rename from source/VirtualFluidsCore/LBM/LBMKernelETD3Q27CCLBWithSpongeLayer.h rename to source/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.h index 77326dfd6..a1bb9b14f 100644 --- a/source/VirtualFluidsCore/LBM/LBMKernelETD3Q27CCLBWithSpongeLayer.h +++ b/source/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.h @@ -1,16 +1,16 @@ -#ifndef LBMKernelETD3Q27CCLBWithSpongeLayer_H -#define LBMKernelETD3Q27CCLBWithSpongeLayer_H +#ifndef IncompressibleCumulantWithSpongeLayerLBMKernel_H +#define IncompressibleCumulantWithSpongeLayerLBMKernel_H -#include "LBMKernelETD3Q27CCLB.h" -#include "D3Q27ETBCProcessor.h" +#include "IncompressibleCumulantLBMKernel.h" +#include "BCProcessor.h" #include "D3Q27System.h" #include <boost/serialization/export.hpp> #include "basics/utilities/UbTiming.h" #include "basics/container/CbArray4D.h" #include "basics/container/CbArray3D.h" -class LBMKernelETD3Q27CCLBWithSpongeLayer; -typedef boost::shared_ptr<LBMKernelETD3Q27CCLBWithSpongeLayer> LBMKernelETD3Q27CCLBWithSpongeLayerPtr; +class IncompressibleCumulantWithSpongeLayerLBMKernel; +typedef boost::shared_ptr<IncompressibleCumulantWithSpongeLayerLBMKernel> LBMKernelETD3Q27CCLBWithSpongeLayerPtr; //! \brief Cascaded Cumulant LBM kernel. //! \details CFD solver with sponge layer that use Cascaded Cumulant Lattice Boltzmann method for D3Q27 model <br> @@ -26,18 +26,18 @@ typedef boost::shared_ptr<LBMKernelETD3Q27CCLBWithSpongeLayer> LBMKernelETD3Q27C //! kernel->setSpongeLayer(spongeLayer); //! \endcode //! \author K. Kucher, M. Geier -class LBMKernelETD3Q27CCLBWithSpongeLayer : public LBMKernelETD3Q27CCLB +class IncompressibleCumulantWithSpongeLayerLBMKernel : public IncompressibleCumulantLBMKernel { public: - LBMKernelETD3Q27CCLBWithSpongeLayer(); + IncompressibleCumulantWithSpongeLayerLBMKernel(); //! Constructor //! \param nx1 number of nodes in x dimension //! \param nx2 number of nodes in y dimension //! \param nx3 number of nodes in z dimension //! \param p set relaxation parameter: NORMAL is OxyyMxzz = 1.0 and MAGIC is OxyyMxzz = 2.0 +(-collFactor) - LBMKernelETD3Q27CCLBWithSpongeLayer(int nx1, int nx2, int nx3, Parameter p); - virtual ~LBMKernelETD3Q27CCLBWithSpongeLayer(void); - LBMKernel3DPtr clone(); + IncompressibleCumulantWithSpongeLayerLBMKernel(int nx1, int nx2, int nx3, Parameter p); + virtual ~IncompressibleCumulantWithSpongeLayerLBMKernel(void); + LBMKernelPtr clone(); void calculate(); protected: void init(); @@ -47,7 +47,7 @@ protected: template<class Archive> void serialize(Archive & ar, const unsigned int version) { - ar & boost::serialization::base_object<LBMKernelETD3Q27CCLB>(*this); + ar & boost::serialization::base_object<IncompressibleCumulantLBMKernel>(*this); ar & OxyyMxzz; } diff --git a/source/VirtualFluidsCore/LBM/D3Q27IncompressibleOffsetInterpolationProcessor.cpp b/source/VirtualFluidsCore/LBM/IncompressibleOffsetInterpolationProcessor.cpp similarity index 92% rename from source/VirtualFluidsCore/LBM/D3Q27IncompressibleOffsetInterpolationProcessor.cpp rename to source/VirtualFluidsCore/LBM/IncompressibleOffsetInterpolationProcessor.cpp index ad9ce3951..d4f015730 100644 --- a/source/VirtualFluidsCore/LBM/D3Q27IncompressibleOffsetInterpolationProcessor.cpp +++ b/source/VirtualFluidsCore/LBM/IncompressibleOffsetInterpolationProcessor.cpp @@ -1,41 +1,41 @@ -#include "D3Q27IncompressibleOffsetInterpolationProcessor.h" +#include "IncompressibleOffsetInterpolationProcessor.h" #include "D3Q27System.h" #include <boost/foreach.hpp> -D3Q27IncompressibleOffsetInterpolationProcessor::D3Q27IncompressibleOffsetInterpolationProcessor() +IncompressibleOffsetInterpolationProcessor::IncompressibleOffsetInterpolationProcessor() : omegaC(0.0), omegaF(0.0) { //forcingC = 0; //9.99685e-7; //forcingF = 0; //forcingC*0.5; } ////////////////////////////////////////////////////////////////////////// -D3Q27IncompressibleOffsetInterpolationProcessor::D3Q27IncompressibleOffsetInterpolationProcessor(LBMReal omegaC, LBMReal omegaF) +IncompressibleOffsetInterpolationProcessor::IncompressibleOffsetInterpolationProcessor(LBMReal omegaC, LBMReal omegaF) : omegaC(omegaC), omegaF(omegaF) { } ////////////////////////////////////////////////////////////////////////// -D3Q27IncompressibleOffsetInterpolationProcessor::~D3Q27IncompressibleOffsetInterpolationProcessor() +IncompressibleOffsetInterpolationProcessor::~IncompressibleOffsetInterpolationProcessor() { } ////////////////////////////////////////////////////////////////////////// -D3Q27InterpolationProcessorPtr D3Q27IncompressibleOffsetInterpolationProcessor::clone() +InterpolationProcessorPtr IncompressibleOffsetInterpolationProcessor::clone() { - D3Q27InterpolationProcessorPtr iproc = D3Q27InterpolationProcessorPtr (new D3Q27IncompressibleOffsetInterpolationProcessor(this->omegaC, this->omegaF)); + InterpolationProcessorPtr iproc = InterpolationProcessorPtr (new IncompressibleOffsetInterpolationProcessor(this->omegaC, this->omegaF)); //boost::dynamic_pointer_cast<D3Q27IncompressibleOffsetInterpolationProcessor>(iproc)->forcingC = forcingC; //boost::dynamic_pointer_cast<D3Q27IncompressibleOffsetInterpolationProcessor>(iproc)->forcingF = forcingF; return iproc; } ////////////////////////////////////////////////////////////////////////// -void D3Q27IncompressibleOffsetInterpolationProcessor::setOmegas( LBMReal omegaC, LBMReal omegaF ) +void IncompressibleOffsetInterpolationProcessor::setOmegas( LBMReal omegaC, LBMReal omegaF ) { this->omegaC = omegaC; this->omegaF = omegaF; } ////////////////////////////////////////////////////////////////////////// -void D3Q27IncompressibleOffsetInterpolationProcessor::setOffsets(LBMReal xoff, LBMReal yoff, LBMReal zoff) +void IncompressibleOffsetInterpolationProcessor::setOffsets(LBMReal xoff, LBMReal yoff, LBMReal zoff) { this->xoff = xoff; this->yoff = yoff; @@ -45,7 +45,7 @@ void D3Q27IncompressibleOffsetInterpolationProcessor::setOffsets(LBMReal xoff, L this->zoff_sq = zoff * zoff; } ////////////////////////////////////////////////////////////////////////// -void D3Q27IncompressibleOffsetInterpolationProcessor::interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF, LBMReal xoff, LBMReal yoff, LBMReal zoff) +void IncompressibleOffsetInterpolationProcessor::interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF, LBMReal xoff, LBMReal yoff, LBMReal zoff) { setOffsets(xoff, yoff, zoff); calcInterpolatedCoefficiets(icellC, omegaC, 0.5); @@ -59,14 +59,14 @@ void D3Q27IncompressibleOffsetInterpolationProcessor::interpolateCoarseToFine(D3 calcInterpolatedNode(icellF.TNE, omegaF, 0.25, 0.25, 0.25, calcPressTNE(), 1, 1, 1); } ////////////////////////////////////////////////////////////////////////// -void D3Q27IncompressibleOffsetInterpolationProcessor::interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC, LBMReal xoff, LBMReal yoff, LBMReal zoff) +void IncompressibleOffsetInterpolationProcessor::interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC, LBMReal xoff, LBMReal yoff, LBMReal zoff) { setOffsets(xoff, yoff, zoff); calcInterpolatedCoefficiets(icellF, omegaF, 2.0); calcInterpolatedNodeFC(icellC, omegaC); } ////////////////////////////////////////////////////////////////////////// -void D3Q27IncompressibleOffsetInterpolationProcessor::calcMoments(const LBMReal* const f, LBMReal omega, LBMReal& press, LBMReal& vx1, LBMReal& vx2, LBMReal& vx3, +void IncompressibleOffsetInterpolationProcessor::calcMoments(const LBMReal* const f, LBMReal omega, LBMReal& press, LBMReal& vx1, LBMReal& vx2, LBMReal& vx3, LBMReal& kxy, LBMReal& kyz, LBMReal& kxz, LBMReal& kxxMyy, LBMReal& kxxMzz) { using namespace D3Q27System; @@ -110,7 +110,7 @@ void D3Q27IncompressibleOffsetInterpolationProcessor::calcMoments(const LBMReal* //UBLOG(logINFO,"f[TN] = " << f[TN] << " TN = " << TN); } ////////////////////////////////////////////////////////////////////////// -void D3Q27IncompressibleOffsetInterpolationProcessor::calcInterpolatedCoefficiets(const D3Q27ICell& icell, LBMReal omega, LBMReal eps_new) +void IncompressibleOffsetInterpolationProcessor::calcInterpolatedCoefficiets(const D3Q27ICell& icell, LBMReal omega, LBMReal eps_new) { LBMReal vx1_SWT,vx2_SWT,vx3_SWT; LBMReal vx1_NWT,vx2_NWT,vx3_NWT; @@ -491,7 +491,7 @@ void D3Q27IncompressibleOffsetInterpolationProcessor::calcInterpolatedCoefficiet yz_TNW = 0.0625*eps_new *(( bxyz + cxyz)/(72.*o)); } ////////////////////////////////////////////////////////////////////////// -void D3Q27IncompressibleOffsetInterpolationProcessor::calcInterpolatedNode(LBMReal* f, LBMReal omega, LBMReal x, LBMReal y, LBMReal z, LBMReal press, LBMReal xs, LBMReal ys, LBMReal zs) +void IncompressibleOffsetInterpolationProcessor::calcInterpolatedNode(LBMReal* f, LBMReal omega, LBMReal x, LBMReal y, LBMReal z, LBMReal press, LBMReal xs, LBMReal ys, LBMReal zs) { using namespace D3Q27System; @@ -538,7 +538,7 @@ void D3Q27IncompressibleOffsetInterpolationProcessor::calcInterpolatedNode(LBMRe } ////////////////////////////////////////////////////////////////////////// //Position SWB -0.25, -0.25, -0.25 -LBMReal D3Q27IncompressibleOffsetInterpolationProcessor::calcPressBSW() +LBMReal IncompressibleOffsetInterpolationProcessor::calcPressBSW() { return press_SWT * (0.140625 + 0.1875 * xoff + 0.1875 * yoff - 0.5625 * zoff) + press_NWT * (0.046875 + 0.0625 * xoff - 0.1875 * yoff - 0.1875 * zoff) + @@ -551,7 +551,7 @@ LBMReal D3Q27IncompressibleOffsetInterpolationProcessor::calcPressBSW() } ////////////////////////////////////////////////////////////////////////// //Position SWT -0.25, -0.25, 0.25 -LBMReal D3Q27IncompressibleOffsetInterpolationProcessor::calcPressTSW() +LBMReal IncompressibleOffsetInterpolationProcessor::calcPressTSW() { return press_SWT * (0.421875 + 0.5625 * xoff + 0.5625 * yoff - 0.5625 * zoff) + press_NWT * (0.140625 + 0.1875 * xoff - 0.5625 * yoff - 0.1875 * zoff) + @@ -564,7 +564,7 @@ LBMReal D3Q27IncompressibleOffsetInterpolationProcessor::calcPressTSW() } ////////////////////////////////////////////////////////////////////////// //Position SET 0.25, -0.25, 0.25 -LBMReal D3Q27IncompressibleOffsetInterpolationProcessor::calcPressTSE() +LBMReal IncompressibleOffsetInterpolationProcessor::calcPressTSE() { return press_SET * (0.421875 - 0.5625 * xoff + 0.5625 * yoff - 0.5625 * zoff) + press_NET * (0.140625 - 0.1875 * xoff - 0.5625 * yoff - 0.1875 * zoff) + @@ -577,7 +577,7 @@ LBMReal D3Q27IncompressibleOffsetInterpolationProcessor::calcPressTSE() } ////////////////////////////////////////////////////////////////////////// //Position SEB 0.25, -0.25, -0.25 -LBMReal D3Q27IncompressibleOffsetInterpolationProcessor::calcPressBSE() +LBMReal IncompressibleOffsetInterpolationProcessor::calcPressBSE() { return press_SET * (0.140625 - 0.1875 * xoff + 0.1875 * yoff - 0.5625 * zoff) + press_NET * (0.046875 - 0.0625 * xoff - 0.1875 * yoff - 0.1875 * zoff) + @@ -590,7 +590,7 @@ LBMReal D3Q27IncompressibleOffsetInterpolationProcessor::calcPressBSE() } ////////////////////////////////////////////////////////////////////////// //Position NWB -0.25, 0.25, -0.25 -LBMReal D3Q27IncompressibleOffsetInterpolationProcessor::calcPressBNW() +LBMReal IncompressibleOffsetInterpolationProcessor::calcPressBNW() { return press_NWT * (0.140625 + 0.1875 * xoff - 0.1875 * yoff - 0.5625 * zoff) + press_NET * (0.046875 - 0.1875 * xoff - 0.0625 * yoff - 0.1875 * zoff) + @@ -603,7 +603,7 @@ LBMReal D3Q27IncompressibleOffsetInterpolationProcessor::calcPressBNW() } ////////////////////////////////////////////////////////////////////////// //Position NWT -0.25, 0.25, 0.25 -LBMReal D3Q27IncompressibleOffsetInterpolationProcessor::calcPressTNW() +LBMReal IncompressibleOffsetInterpolationProcessor::calcPressTNW() { return press_NWT * (0.421875 + 0.5625 * xoff - 0.5625 * yoff - 0.5625 * zoff) + press_NET * (0.140625 - 0.5625 * xoff - 0.1875 * yoff - 0.1875 * zoff) + @@ -616,7 +616,7 @@ LBMReal D3Q27IncompressibleOffsetInterpolationProcessor::calcPressTNW() } ////////////////////////////////////////////////////////////////////////// //Position NET 0.25, 0.25, 0.25 -LBMReal D3Q27IncompressibleOffsetInterpolationProcessor::calcPressTNE() +LBMReal IncompressibleOffsetInterpolationProcessor::calcPressTNE() { return press_NET * (0.421875 - 0.5625 * xoff - 0.5625 * yoff - 0.5625 * zoff) + press_NWT * (0.140625 + 0.5625 * xoff - 0.1875 * yoff - 0.1875 * zoff) + @@ -629,7 +629,7 @@ LBMReal D3Q27IncompressibleOffsetInterpolationProcessor::calcPressTNE() } ////////////////////////////////////////////////////////////////////////// //Position NEB 0.25, 0.25, -0.25 -LBMReal D3Q27IncompressibleOffsetInterpolationProcessor::calcPressBNE() +LBMReal IncompressibleOffsetInterpolationProcessor::calcPressBNE() { return press_NET * (0.140625 - 0.1875 * xoff - 0.1875 * yoff - 0.5625 * zoff) + press_NWT * (0.046875 + 0.1875 * xoff - 0.0625 * yoff - 0.1875 * zoff) + @@ -642,7 +642,7 @@ LBMReal D3Q27IncompressibleOffsetInterpolationProcessor::calcPressBNE() } ////////////////////////////////////////////////////////////////////////// //Position C 0.0, 0.0, 0.0 -void D3Q27IncompressibleOffsetInterpolationProcessor::calcInterpolatedNodeFC(LBMReal* f, LBMReal omega) +void IncompressibleOffsetInterpolationProcessor::calcInterpolatedNodeFC(LBMReal* f, LBMReal omega) { using namespace D3Q27System; @@ -731,14 +731,14 @@ void D3Q27IncompressibleOffsetInterpolationProcessor::calcInterpolatedNodeFC(LBM f[ZERO] = f_ZERO + feq[ZERO]; } ////////////////////////////////////////////////////////////////////////// -void D3Q27IncompressibleOffsetInterpolationProcessor::calcInterpolatedVelocity(LBMReal x, LBMReal y, LBMReal z, LBMReal& vx1, LBMReal& vx2, LBMReal& vx3) +void IncompressibleOffsetInterpolationProcessor::calcInterpolatedVelocity(LBMReal x, LBMReal y, LBMReal z, LBMReal& vx1, LBMReal& vx2, LBMReal& vx3) { vx1 = a0 + ax*x + ay*y + az*z + axx*x*x + ayy*y*y + azz*z*z + axy*x*y + axz*x*z + ayz*y*z+axyz*x*y*z; vx2 = b0 + bx*x + by*y + bz*z + bxx*x*x + byy*y*y + bzz*z*z + bxy*x*y + bxz*x*z + byz*y*z+bxyz*x*y*z; vx3 = c0 + cx*x + cy*y + cz*z + cxx*x*x + cyy*y*y + czz*z*z + cxy*x*y + cxz*x*z + cyz*y*z+cxyz*x*y*z; } ////////////////////////////////////////////////////////////////////////// -void D3Q27IncompressibleOffsetInterpolationProcessor::calcInterpolatedShearStress(LBMReal x, LBMReal y, LBMReal z,LBMReal& tauxx, LBMReal& tauyy, LBMReal& tauzz,LBMReal& tauxy, LBMReal& tauxz, LBMReal& tauyz) +void IncompressibleOffsetInterpolationProcessor::calcInterpolatedShearStress(LBMReal x, LBMReal y, LBMReal z,LBMReal& tauxx, LBMReal& tauyy, LBMReal& tauzz,LBMReal& tauxy, LBMReal& tauxz, LBMReal& tauyz) { tauxx=ax+2*axx*x+axy*y+axz*z+axyz*y*z; tauyy=by+2*byy*y+bxy*x+byz*z+bxyz*x*z; diff --git a/source/VirtualFluidsCore/LBM/D3Q27IncompressibleOffsetInterpolationProcessor.h b/source/VirtualFluidsCore/LBM/IncompressibleOffsetInterpolationProcessor.h similarity index 77% rename from source/VirtualFluidsCore/LBM/D3Q27IncompressibleOffsetInterpolationProcessor.h rename to source/VirtualFluidsCore/LBM/IncompressibleOffsetInterpolationProcessor.h index cb2df0b66..c3df12a8a 100644 --- a/source/VirtualFluidsCore/LBM/D3Q27IncompressibleOffsetInterpolationProcessor.h +++ b/source/VirtualFluidsCore/LBM/IncompressibleOffsetInterpolationProcessor.h @@ -1,7 +1,7 @@ -#ifndef D3Q27IncompressibleOffsetInterpolationProcessor_H_ -#define D3Q27IncompressibleOffsetInterpolationProcessor_H_ +#ifndef IncompressibleOffsetInterpolationProcessor_H_ +#define IncompressibleOffsetInterpolationProcessor_H_ -#include "D3Q27InterpolationProcessor.h" +#include "InterpolationProcessor.h" #include "D3Q27System.h" ////////////////////////////////////////////////////////////////////////// @@ -9,16 +9,16 @@ //super compact interpolation method by Martin Geier ////////////////////////////////////////////////////////////////////////// -class D3Q27IncompressibleOffsetInterpolationProcessor; -typedef boost::shared_ptr<D3Q27IncompressibleOffsetInterpolationProcessor> D3Q27IncompressibleOffsetInterpolationProcessorPtr; +class IncompressibleOffsetInterpolationProcessor; +typedef boost::shared_ptr<IncompressibleOffsetInterpolationProcessor> D3Q27IncompressibleOffsetInterpolationProcessorPtr; -class D3Q27IncompressibleOffsetInterpolationProcessor : public D3Q27InterpolationProcessor +class IncompressibleOffsetInterpolationProcessor : public InterpolationProcessor { public: - D3Q27IncompressibleOffsetInterpolationProcessor(); - D3Q27IncompressibleOffsetInterpolationProcessor(LBMReal omegaC, LBMReal omegaF); - virtual ~D3Q27IncompressibleOffsetInterpolationProcessor(); - D3Q27InterpolationProcessorPtr clone(); + IncompressibleOffsetInterpolationProcessor(); + IncompressibleOffsetInterpolationProcessor(LBMReal omegaC, LBMReal omegaF); + virtual ~IncompressibleOffsetInterpolationProcessor(); + InterpolationProcessorPtr clone(); void setOmegas(LBMReal omegaC, LBMReal omegaF); void interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF); void interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF, LBMReal xoff, LBMReal yoff, LBMReal zoff); @@ -64,12 +64,12 @@ private: }; ////////////////////////////////////////////////////////////////////////// -inline void D3Q27IncompressibleOffsetInterpolationProcessor::interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF) +inline void IncompressibleOffsetInterpolationProcessor::interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF) { this->interpolateCoarseToFine(icellC, icellF, 0.0, 0.0, 0.0); } ////////////////////////////////////////////////////////////////////////// -inline void D3Q27IncompressibleOffsetInterpolationProcessor::interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC) +inline void IncompressibleOffsetInterpolationProcessor::interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC) { this->interpolateFineToCoarse(icellF, icellC, 0.0, 0.0, 0.0); } diff --git a/source/VirtualFluidsCore/LBM/InitDensityLBMKernel.cpp b/source/VirtualFluidsCore/LBM/InitDensityLBMKernel.cpp index f06861bff..7217ccdc2 100644 --- a/source/VirtualFluidsCore/LBM/InitDensityLBMKernel.cpp +++ b/source/VirtualFluidsCore/LBM/InitDensityLBMKernel.cpp @@ -1,5 +1,6 @@ #include "InitDensityLBMKernel.h" #include "D3Q27EsoTwist3DSplittedVector.h" +#include "BCProcessor.h" InitDensityLBMKernel::InitDensityLBMKernel() { @@ -9,8 +10,11 @@ InitDensityLBMKernel::~InitDensityLBMKernel() { } -InitDensityLBMKernel::InitDensityLBMKernel(int nx1, int nx2, int nx3) : LBMKernelETD3Q27(nx1, nx2, nx3) +InitDensityLBMKernel::InitDensityLBMKernel(int nx1, int nx2, int nx3) { + this->nx1 = nx1; + this->nx2 = nx2; + this->nx3 = nx3; this->compressible = false; } @@ -19,9 +23,9 @@ void InitDensityLBMKernel::calculate() collideAll(); } -LBMKernel3DPtr InitDensityLBMKernel::clone() +LBMKernelPtr InitDensityLBMKernel::clone() { - LBMKernel3DPtr kernel(new InitDensityLBMKernel(nx1, nx2, nx3)); + LBMKernelPtr kernel(new InitDensityLBMKernel(nx1, nx2, nx3)); boost::dynamic_pointer_cast<InitDensityLBMKernel>(kernel)->init(); kernel->setCollisionFactor(this->collFactor); kernel->setBCProcessor(bcProcessor->clone(kernel)); @@ -801,7 +805,7 @@ double InitDensityLBMKernel::getCallculationTime() // 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))); -// //UBLOG(logERROR,"LBMKernelETD3Q27CCLB::collideAll(): rho is not correct for node "+UbSystem::toString(x1)+","+UbSystem::toString(x2)+","+UbSystem::toString(x3)); +// //UBLOG(logERROR,"LBMKernel3DCCLB::collideAll(): rho is not correct for node "+UbSystem::toString(x1)+","+UbSystem::toString(x2)+","+UbSystem::toString(x3)); // //exit(EXIT_FAILURE); // } //#endif @@ -863,8 +867,8 @@ void InitDensityLBMKernel::collideAll() nonLocalDistributions = boost::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getNonLocalDistributions(); zeroDistributions = boost::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getZeroDistributions(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(this->getBCProcessor())->getBCArray(); - D3Q27BoundaryConditionPtr bcPtr; + BCArray3D& bcArray = this->getBCProcessor()->getBCArray(); + BoundaryConditionsPtr bcPtr; LBMReal f[D3Q27System::ENDF+1]; LBMReal feq[D3Q27System::ENDF+1]; LBMReal drho, vx1, vx2, vx3; diff --git a/source/VirtualFluidsCore/LBM/InitDensityLBMKernel.h b/source/VirtualFluidsCore/LBM/InitDensityLBMKernel.h index e73a85c4d..bf0b52614 100644 --- a/source/VirtualFluidsCore/LBM/InitDensityLBMKernel.h +++ b/source/VirtualFluidsCore/LBM/InitDensityLBMKernel.h @@ -1,17 +1,17 @@ #ifndef InitDensityLBMKernel_h__ #define InitDensityLBMKernel_h__ -#include "LBMKernelETD3Q27.h" +#include "LBMKernel.h" #include "basics/utilities/UbTiming.h" -class InitDensityLBMKernel : public LBMKernelETD3Q27 +class InitDensityLBMKernel : public LBMKernel { public: InitDensityLBMKernel(); ~InitDensityLBMKernel(); InitDensityLBMKernel(int nx1, int nx2, int nx3); void calculate(); - LBMKernel3DPtr clone(); + LBMKernelPtr clone(); void setVelocity(int x1, int x2, int x3, LBMReal vvx, LBMReal vvy, LBMReal vvz); double getCallculationTime(); protected: diff --git a/source/VirtualFluidsCore/LBM/D3Q27InterpolationHelper.cpp b/source/VirtualFluidsCore/LBM/InterpolationHelper.cpp similarity index 63% rename from source/VirtualFluidsCore/LBM/D3Q27InterpolationHelper.cpp rename to source/VirtualFluidsCore/LBM/InterpolationHelper.cpp index 643781c47..2b4176b53 100644 --- a/source/VirtualFluidsCore/LBM/D3Q27InterpolationHelper.cpp +++ b/source/VirtualFluidsCore/LBM/InterpolationHelper.cpp @@ -1,31 +1,31 @@ -#include "D3Q27InterpolationHelper.h" +#include "InterpolationHelper.h" -D3Q27InterpolationHelper::D3Q27InterpolationHelper(D3Q27InterpolationProcessorPtr iProcessor) : iProcessor(iProcessor) +InterpolationHelper::InterpolationHelper(InterpolationProcessorPtr iProcessor) : iProcessor(iProcessor) { } ////////////////////////////////////////////////////////////////////////// -D3Q27InterpolationHelper::~D3Q27InterpolationHelper() +InterpolationHelper::~InterpolationHelper() { } ////////////////////////////////////////////////////////////////////////// -void D3Q27InterpolationHelper::interpolate8to1( D3Q27ICell& icellF, LBMReal* icellC, double x1, double x2, double x3, LBMReal omega ) +void InterpolationHelper::interpolate8to1( D3Q27ICell& icellF, LBMReal* icellC, double x1, double x2, double x3, LBMReal omega ) { iProcessor->calcInterpolatedCoefficiets(icellF, omega, 1.0); iProcessor->calcInterpolatedNodeFC(icellC, omega); } ////////////////////////////////////////////////////////////////////////// -void D3Q27InterpolationHelper::interpolate8to1WithVelocity( D3Q27ICell& icellF, double x1, double x2, double x3, LBMReal omega, LBMReal &vx1, LBMReal &vx2, LBMReal &vx3 ) +void InterpolationHelper::interpolate8to1WithVelocity( D3Q27ICell& icellF, double x1, double x2, double x3, LBMReal omega, LBMReal &vx1, LBMReal &vx2, LBMReal &vx3 ) { iProcessor->setOffsets(0.0, 0.0, 0.0); iProcessor->calcInterpolatedCoefficiets(icellF, omega, 0.0); iProcessor->calcInterpolatedVelocity(x1, x2, x3, vx1, vx2, vx3); } ////////////////////////////////////////////////////////////////////////// -void D3Q27InterpolationHelper::interpolate8to1WithVelocityWithShearStress( D3Q27ICell& icellF, double x1, double x2, double x3, LBMReal omega, +void InterpolationHelper::interpolate8to1WithVelocityWithShearStress( D3Q27ICell& icellF, double x1, double x2, double x3, LBMReal omega, LBMReal &vx1, LBMReal &vx2, LBMReal &vx3, LBMReal &tauxx, LBMReal &tauyy, LBMReal &tauzz,LBMReal &tauxy, LBMReal &tauxz, LBMReal &tauyz ) { diff --git a/source/VirtualFluidsCore/LBM/D3Q27InterpolationHelper.h b/source/VirtualFluidsCore/LBM/InterpolationHelper.h similarity index 66% rename from source/VirtualFluidsCore/LBM/D3Q27InterpolationHelper.h rename to source/VirtualFluidsCore/LBM/InterpolationHelper.h index 113810c19..fe6ab190f 100644 --- a/source/VirtualFluidsCore/LBM/D3Q27InterpolationHelper.h +++ b/source/VirtualFluidsCore/LBM/InterpolationHelper.h @@ -1,16 +1,16 @@ #ifndef D3Q27InterpolationHelper_H_ #define D3Q27InterpolationHelper_H_ -#include "D3Q27InterpolationProcessor.h" +#include "InterpolationProcessor.h" -class D3Q27InterpolationHelper; -typedef boost::shared_ptr<D3Q27InterpolationHelper> D3Q27InterpolationHelperPtr; +class InterpolationHelper; +typedef boost::shared_ptr<InterpolationHelper> InterpolationHelperPtr; -class D3Q27InterpolationHelper +class InterpolationHelper { public: - D3Q27InterpolationHelper(D3Q27InterpolationProcessorPtr iProcessor); - ~D3Q27InterpolationHelper(); + InterpolationHelper(InterpolationProcessorPtr iProcessor); + ~InterpolationHelper(); void interpolate8to1(D3Q27ICell& icellF, LBMReal* icellC, double x1, double x2, double x3, LBMReal omega); void interpolate8to1WithVelocity(D3Q27ICell& icellF, double x1, double x2, double x3, LBMReal omega, LBMReal &vx1, LBMReal &vx2, LBMReal &vx3); void interpolate8to1WithVelocityWithShearStress(D3Q27ICell& icellF, double x1, double x2, double x3, LBMReal omega, @@ -18,7 +18,7 @@ public: LBMReal &tauxx, LBMReal &tauyy, LBMReal &tauzz,LBMReal &tauxy, LBMReal &tauxz, LBMReal &tauyz); protected: private: - D3Q27InterpolationProcessorPtr iProcessor; + InterpolationProcessorPtr iProcessor; }; #endif diff --git a/source/VirtualFluidsCore/LBM/D3Q27InterpolationProcessor.cpp b/source/VirtualFluidsCore/LBM/InterpolationProcessor.cpp similarity index 88% rename from source/VirtualFluidsCore/LBM/D3Q27InterpolationProcessor.cpp rename to source/VirtualFluidsCore/LBM/InterpolationProcessor.cpp index a6f02f49e..23d8861a4 100644 --- a/source/VirtualFluidsCore/LBM/D3Q27InterpolationProcessor.cpp +++ b/source/VirtualFluidsCore/LBM/InterpolationProcessor.cpp @@ -1,19 +1,19 @@ -#include "D3Q27InterpolationProcessor.h" +#include "InterpolationProcessor.h" #include "StringUtil.hpp" ////////////////////////////////////////////////////////////////////////// -D3Q27InterpolationProcessor::D3Q27InterpolationProcessor() +InterpolationProcessor::InterpolationProcessor() { } ////////////////////////////////////////////////////////////////////////// -D3Q27InterpolationProcessor::~D3Q27InterpolationProcessor() +InterpolationProcessor::~InterpolationProcessor() { } ////////////////////////////////////////////////////////////////////////// -void D3Q27InterpolationProcessor::readICell(DistributionArray3DPtr f, D3Q27ICell& icell, int x1, int x2, int x3) +void InterpolationProcessor::readICell(DistributionArray3DPtr f, D3Q27ICell& icell, int x1, int x2, int x3) { f->getDistribution(icell.BSW, x1, x2, x3); f->getDistribution(icell.BSE, x1+1, x2, x3); @@ -25,7 +25,7 @@ void D3Q27InterpolationProcessor::readICell(DistributionArray3DPtr f, D3Q27ICell f->getDistribution(icell.TNE, x1+1, x2+1, x3+1); } ////////////////////////////////////////////////////////////////////////// -void D3Q27InterpolationProcessor::writeICell(DistributionArray3DPtr f, const D3Q27ICell& icell, int x1, int x2, int x3) +void InterpolationProcessor::writeICell(DistributionArray3DPtr f, const D3Q27ICell& icell, int x1, int x2, int x3) { f->setDistributionInv(icell.BSW, x1, x2, x3); f->setDistributionInv(icell.BSE, x1+1, x2, x3); @@ -37,12 +37,12 @@ void D3Q27InterpolationProcessor::writeICell(DistributionArray3DPtr f, const D3Q f->setDistributionInv(icell.TNE, x1+1, x2+1, x3+1); } ////////////////////////////////////////////////////////////////////////// -void D3Q27InterpolationProcessor::writeINode(DistributionArray3DPtr f, const LBMReal* const inode, int x1, int x2, int x3) +void InterpolationProcessor::writeINode(DistributionArray3DPtr f, const LBMReal* const inode, int x1, int x2, int x3) { f->setDistributionInv(inode, x1, x2, x3); } ////////////////////////////////////////////////////////////////////////// -bool D3Q27InterpolationProcessor::iCellHasSolid(const BCArray3D<D3Q27BoundaryCondition>& bcArray, int x1, int x2, int x3) +bool InterpolationProcessor::iCellHasSolid(const BCArray3D& bcArray, int x1, int x2, int x3) { for (int ix3 = x3; ix3 <= x3 + 1; ix3++) for(int ix2 = x2; ix2 <= x2 + 1; ix2++) @@ -54,7 +54,7 @@ bool D3Q27InterpolationProcessor::iCellHasSolid(const BCArray3D<D3Q27BoundaryCon return false; } ////////////////////////////////////////////////////////////////////////// -bool D3Q27InterpolationProcessor::findNeighborICell(const BCArray3D<D3Q27BoundaryCondition>& bcArray, DistributionArray3DPtr f, +bool InterpolationProcessor::findNeighborICell(const BCArray3D& bcArray, DistributionArray3DPtr f, D3Q27ICell& icell, int maxX1, int maxX2, int maxX3, int x1, int x2, int x3, LBMReal& xoff, LBMReal& yoff, LBMReal& zoff) { @@ -283,7 +283,7 @@ bool D3Q27InterpolationProcessor::findNeighborICell(const BCArray3D<D3Q27Boundar return 1; } ////////////////////////////////////////////////////////////////////////// -int D3Q27InterpolationProcessor::iCellHowManySolids( const BCArray3D<D3Q27BoundaryCondition>& bcArray, int x1, int x2, int x3 ) +int InterpolationProcessor::iCellHowManySolids( const BCArray3D& bcArray, int x1, int x2, int x3 ) { int count = 0; for (int ix3 = x3; ix3 <= x3 + 1; ix3++) diff --git a/source/VirtualFluidsCore/LBM/InterpolationProcessor.h b/source/VirtualFluidsCore/LBM/InterpolationProcessor.h index 83d8ffa03..9a9b61bd8 100644 --- a/source/VirtualFluidsCore/LBM/InterpolationProcessor.h +++ b/source/VirtualFluidsCore/LBM/InterpolationProcessor.h @@ -1,19 +1,68 @@ -#ifndef INTERPOLATIONPRZESSOR_H_ -#define INTERPOLATIONPRZESSOR_H_ +#ifndef D3Q27INTRPOLATIOPROCESSOR_H_ +#define D3Q27INTRPOLATIOPROCESSOR_H_ +#include "InterpolationProcessor.h" #include "LBMSystem.h" +#include "DistributionArray3D.h" +#include "BoundaryConditions.h" +#include "BCArray3D.h" +struct D3Q27ICell +{ + LBMReal TSW[27]; + LBMReal TNW[27]; + LBMReal TNE[27]; + LBMReal TSE[27]; + LBMReal BSW[27]; + LBMReal BNW[27]; + LBMReal BNE[27]; + LBMReal BSE[27]; +}; + class InterpolationProcessor; typedef boost::shared_ptr<InterpolationProcessor> InterpolationProcessorPtr; +#include "InterpolationHelper.h" + class InterpolationProcessor { public: - //virtual void interpolate() = 0; + InterpolationProcessor(); + virtual ~InterpolationProcessor(); + virtual InterpolationProcessorPtr clone() = 0; + virtual void setOmegas(LBMReal omegaC, LBMReal omegaF) = 0; + virtual void interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF) = 0; + virtual void interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF, LBMReal xoff, LBMReal yoff, LBMReal zoff) = 0; + virtual void interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC) = 0; + virtual void interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC, LBMReal xoff, LBMReal yoff, LBMReal zoff) = 0; + + static void readICell(DistributionArray3DPtr f, D3Q27ICell& icell, int x1, int x2, int x3); + static void writeICell(DistributionArray3DPtr f, const D3Q27ICell& icell, int x1, int x2, int x3); + static void writeINode(DistributionArray3DPtr f, const LBMReal* const inode, int x1, int x2, int x3); + static bool iCellHasSolid(const BCArray3D& bcArray, int x1, int x2, int x3); + static int iCellHowManySolids(const BCArray3D& bcArray, int x1, int x2, int x3); + + bool findNeighborICell(const BCArray3D& bcArray, DistributionArray3DPtr f, + D3Q27ICell& icell, int maxX1, int maxX2, int maxX3, + int x1, int x2, int x3, LBMReal& xoff, LBMReal& yoff, LBMReal& zoff); + protected: + virtual void calcInterpolatedCoefficiets(const D3Q27ICell& icell, LBMReal omega, LBMReal eps_new){} + virtual void calcInterpolatedNodeFC(LBMReal* f, LBMReal omega){} + virtual void calcInterpolatedVelocity(LBMReal x, LBMReal y, LBMReal z,LBMReal& vx1, LBMReal& vx2, LBMReal& vx3){} + virtual void calcInterpolatedShearStress(LBMReal x, LBMReal y, LBMReal z,LBMReal& tauxx, LBMReal& tauyy, LBMReal& tauzz,LBMReal& tauxy, LBMReal& tauxz, LBMReal& tauyz){} + virtual void setOffsets(LBMReal xoff, LBMReal yoff, LBMReal zoff){} + friend class InterpolationHelper; private: + bool inRange(int x1, int x2, int x3); + int m_maxX1, m_maxX2, m_maxX3; }; +////////////////////////////////////////////////////////////////////////// +inline bool InterpolationProcessor::inRange(int x1, int x2, int x3) +{ + return x1 >= 0 && x1 < m_maxX1 && x2 >= 0 && x2 < m_maxX2 && x3 >= 0 && x3 < m_maxX3; +} #endif diff --git a/source/VirtualFluidsCore/LBM/LBMKernel3D.cpp b/source/VirtualFluidsCore/LBM/LBMKernel.cpp similarity index 70% rename from source/VirtualFluidsCore/LBM/LBMKernel3D.cpp rename to source/VirtualFluidsCore/LBM/LBMKernel.cpp index c503464df..d301691ee 100644 --- a/source/VirtualFluidsCore/LBM/LBMKernel3D.cpp +++ b/source/VirtualFluidsCore/LBM/LBMKernel.cpp @@ -1,7 +1,7 @@ -#include "LBMKernel3D.h" +#include "LBMKernel.h" -LBMKernel3D::LBMKernel3D() : ghostLayerWidth(1), +LBMKernel::LBMKernel() : ghostLayerWidth(1), deltaT(1.0), withForcing(false), withSpongeLayer(false), @@ -13,84 +13,84 @@ LBMKernel3D::LBMKernel3D() : ghostLayerWidth(1), dataSet = DataSet3DPtr(new DataSet3D()); } ////////////////////////////////////////////////////////////////////////// -LBMKernel3D::~LBMKernel3D() +LBMKernel::~LBMKernel() { } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::setBCProcessor(BCProcessorPtr bcp) +void LBMKernel::setBCProcessor(BCProcessorPtr bcp) { bcProcessor = bcp; } ////////////////////////////////////////////////////////////////////////// -BCProcessorPtr LBMKernel3D::getBCProcessor() +BCProcessorPtr LBMKernel::getBCProcessor() { return bcProcessor; } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::setCollisionFactor(double collFactor) +void LBMKernel::setCollisionFactor(double collFactor) { this->collFactor = collFactor; } ////////////////////////////////////////////////////////////////////////// -double LBMKernel3D::getCollisionFactor() const +double LBMKernel::getCollisionFactor() const { return collFactor; } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::setForcingX1(LBMReal forcingX1) +void LBMKernel::setForcingX1(LBMReal forcingX1) { this->muForcingX1.SetExpr( UbSystem::toString(forcingX1,LBMRealLim::digits10) ); this->checkFunction(muForcingX1); } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::setForcingX2(LBMReal forcingX2) +void LBMKernel::setForcingX2(LBMReal forcingX2) { this->muForcingX2.SetExpr( UbSystem::toString(forcingX2,LBMRealLim::digits10) ); this->checkFunction(muForcingX2); } -void LBMKernel3D::setForcingX3(LBMReal forcingX3) +void LBMKernel::setForcingX3(LBMReal forcingX3) { this->muForcingX3.SetExpr( UbSystem::toString(forcingX3,LBMRealLim::digits10) ); this->checkFunction(muForcingX3); } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::setForcingX1( const mu::Parser& parser) +void LBMKernel::setForcingX1( const mu::Parser& parser) { this->checkFunction(parser); this->muForcingX1 = parser; } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::setForcingX2( const mu::Parser& parser) +void LBMKernel::setForcingX2( const mu::Parser& parser) { this->checkFunction(parser); this->muForcingX2 = parser; } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::setForcingX3( const mu::Parser& parser) +void LBMKernel::setForcingX3( const mu::Parser& parser) { this->checkFunction(parser); this->muForcingX3 = parser; } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::setForcingX1( const std::string& muParserString) +void LBMKernel::setForcingX1( const std::string& muParserString) { this->muForcingX1.SetExpr(muParserString); this->checkFunction(muForcingX1); } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::setForcingX2( const std::string& muParserString) +void LBMKernel::setForcingX2( const std::string& muParserString) { this->muForcingX2.SetExpr(muParserString); this->checkFunction(muForcingX2); } -void LBMKernel3D::setForcingX3( const std::string& muParserString) +void LBMKernel::setForcingX3( const std::string& muParserString) { this->muForcingX3.SetExpr(muParserString); this->checkFunction(muForcingX3); } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::checkFunction(mu::Parser fct) +void LBMKernel::checkFunction(mu::Parser fct) { double x1=1.0,x2=1.0,x3=1.0, dt=1.0, nue=1.0; fct.DefineVar("x1",&x1); @@ -111,87 +111,92 @@ void LBMKernel3D::checkFunction(mu::Parser fct) } } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::setGhostLayerWidth(int witdh) +void LBMKernel::setGhostLayerWidth(int witdh) { ghostLayerWidth = witdh; } ////////////////////////////////////////////////////////////////////////// -int LBMKernel3D::getGhostLayerWidth() const +int LBMKernel::getGhostLayerWidth() const { return ghostLayerWidth; } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::setIndex( int x1, int x2, int x3 ) +void LBMKernel::setIndex( int x1, int x2, int x3 ) { this->ix1 = x1; this->ix2 = x2; this->ix3 = x3; } ////////////////////////////////////////////////////////////////////////// -DataSet3DPtr LBMKernel3D::getDataSet() const +DataSet3DPtr LBMKernel::getDataSet() const { return this->dataSet; } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::setDeltaT( LBMReal dt ) +void LBMKernel::setDeltaT( LBMReal dt ) { deltaT = dt; } ////////////////////////////////////////////////////////////////////////// -bool LBMKernel3D::getCompressible() const +bool LBMKernel::getCompressible() const { return compressible; } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::setCompressible(bool val) +void LBMKernel::setCompressible(bool val) { compressible = val; } ////////////////////////////////////////////////////////////////////////// -bool LBMKernel3D::getWithForcing() const +bool LBMKernel::getWithForcing() const { return withForcing; } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::setWithForcing( bool val ) +void LBMKernel::setWithForcing( bool val ) { withForcing = val; } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::setBlock( Block3DPtr block ) +void LBMKernel::setBlock( Block3DPtr block ) { this->block = block; } ////////////////////////////////////////////////////////////////////////// -Block3DPtr LBMKernel3D::getBlock() const +Block3DPtr LBMKernel::getBlock() const { return block.lock(); } ////////////////////////////////////////////////////////////////////////// -bool LBMKernel3D::getWithSpongeLayer() const +bool LBMKernel::getWithSpongeLayer() const { return withSpongeLayer; } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::setWithSpongeLayer( bool val ) +void LBMKernel::setWithSpongeLayer( bool val ) { withSpongeLayer = val; } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::setSpongeLayer( const mu::Parser& parser ) +void LBMKernel::setSpongeLayer( const mu::Parser& parser ) { this->checkFunction(parser); this->muSpongeLayer = parser; } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::setSpongeLayer( const std::string& muParserString ) +void LBMKernel::setSpongeLayer( const std::string& muParserString ) { this->muSpongeLayer.SetExpr(muParserString); this->checkFunction(muSpongeLayer); } ////////////////////////////////////////////////////////////////////////// -void LBMKernel3D::setDataSet(DataSet3DPtr dataSet) +void LBMKernel::setDataSet(DataSet3DPtr dataSet) { this->dataSet = dataSet; } +////////////////////////////////////////////////////////////////////////// +void LBMKernel::swapDistributions() +{ + dataSet->getFdistributions()->swap(); +} diff --git a/source/VirtualFluidsCore/LBM/LBMKernel3D.h b/source/VirtualFluidsCore/LBM/LBMKernel.h similarity index 85% rename from source/VirtualFluidsCore/LBM/LBMKernel3D.h rename to source/VirtualFluidsCore/LBM/LBMKernel.h index e90da3ee6..c36a5229c 100644 --- a/source/VirtualFluidsCore/LBM/LBMKernel3D.h +++ b/source/VirtualFluidsCore/LBM/LBMKernel.h @@ -13,24 +13,23 @@ #include <boost/weak_ptr.hpp> #include <boost/shared_ptr.hpp> -class LBMKernel3D; -typedef boost::shared_ptr<LBMKernel3D> LBMKernel3DPtr; +class LBMKernel; +typedef boost::shared_ptr<LBMKernel> LBMKernelPtr; #include "BCProcessor.h" #include "Block3D.h" -class LBMKernel3D : public boost::enable_shared_from_this<LBMKernel3D> +class LBMKernel : public boost::enable_shared_from_this<LBMKernel> { public: typedef std::numeric_limits<LBMReal> LBMRealLim; public: - LBMKernel3D(); - virtual ~LBMKernel3D(); + LBMKernel(); + virtual ~LBMKernel(); - virtual LBMKernel3DPtr clone() = 0; + virtual LBMKernelPtr clone() = 0; virtual void calculate() = 0; - virtual void swapDistributions() = 0; virtual double getCallculationTime() = 0; void setBCProcessor(BCProcessorPtr bcp); @@ -76,6 +75,8 @@ public: void setBlock(Block3DPtr block); Block3DPtr getBlock() const; + void swapDistributions(); + protected: DataSet3DPtr dataSet; BCProcessorPtr bcProcessor; @@ -97,6 +98,7 @@ protected: boost::weak_ptr<Block3D> block; + int nx1, nx2, nx3; private: friend class boost::serialization::access; @@ -111,9 +113,8 @@ private: ar & deltaT; ar & dataSet; ar & bcProcessor; - ar & ix1; - ar & ix2; - ar & ix3; + ar & ix1 & ix2 & ix3; + ar & nx1 & nx2 & nx3; } void checkFunction(mu::Parser fct); diff --git a/source/VirtualFluidsCore/LBM/LBMKernelETD3Q27.cpp b/source/VirtualFluidsCore/LBM/LBMKernelETD3Q27.cpp deleted file mode 100644 index ebabaea11..000000000 --- a/source/VirtualFluidsCore/LBM/LBMKernelETD3Q27.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "LBMKernelETD3Q27.h" - -//BOOST_CLASS_EXPORT(LBMKernelETD3Q27Cascaded) - -////////////////////////////////////////////////////////////////////////// -LBMKernelETD3Q27::LBMKernelETD3Q27() -{ - -} -////////////////////////////////////////////////////////////////////////// -LBMKernelETD3Q27::LBMKernelETD3Q27(int nx1, int nx2, int nx3) - : LBMKernel3D(), nx1(nx1), nx2(nx2), nx3(nx3) -{ -} -////////////////////////////////////////////////////////////////////////// -LBMKernelETD3Q27::~LBMKernelETD3Q27(void) -{ -} -////////////////////////////////////////////////////////////////////////// -void LBMKernelETD3Q27::swapDistributions() -{ - dataSet->getFdistributions()->swap(); -} - - diff --git a/source/VirtualFluidsCore/LBM/LBMKernelETD3Q27.h b/source/VirtualFluidsCore/LBM/LBMKernelETD3Q27.h deleted file mode 100644 index c3f4da8db..000000000 --- a/source/VirtualFluidsCore/LBM/LBMKernelETD3Q27.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef LBMKERNELETD3Q27_H -#define LBMKERNELETD3Q27_H - -#include "LBMKernel3D.h" -#include "BCProcessor.h" -#include "D3Q27ETBCProcessor.h" -#include "EsoTwist3D.h" - -#include <boost/serialization/base_object.hpp> - -class LBMKernelETD3Q27; -typedef boost::shared_ptr<LBMKernelETD3Q27> LBMKernelETD3Q27Ptr; - -class LBMKernelETD3Q27 : public LBMKernel3D -{ -public: - LBMKernelETD3Q27(); - LBMKernelETD3Q27(int nx1, int nx2, int nx3); - virtual ~LBMKernelETD3Q27(void); - void swapDistributions(); -protected: - friend class boost::serialization::access; - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - ar & boost::serialization::base_object<LBMKernel3D>(*this); - ar & nx1 & nx2 & nx3; - } - int nx1, nx2, nx3; -}; -#endif diff --git a/source/VirtualFluidsCore/LBM/VoidLBMKernel.cpp b/source/VirtualFluidsCore/LBM/VoidLBMKernel.cpp index 35b188a7a..a8e479559 100644 --- a/source/VirtualFluidsCore/LBM/VoidLBMKernel.cpp +++ b/source/VirtualFluidsCore/LBM/VoidLBMKernel.cpp @@ -17,9 +17,9 @@ VoidLBMKernel::~VoidLBMKernel() } -LBMKernel3DPtr VoidLBMKernel::clone() +LBMKernelPtr VoidLBMKernel::clone() { - LBMKernel3DPtr kernel(new VoidLBMKernel(nx1, nx2, nx3)); + LBMKernelPtr kernel(new VoidLBMKernel(nx1, nx2, nx3)); kernel->setCollisionFactor(this->collFactor); kernel->setBCProcessor(bcProcessor->clone(kernel)); kernel->setWithForcing(withForcing); diff --git a/source/VirtualFluidsCore/LBM/VoidLBMKernel.h b/source/VirtualFluidsCore/LBM/VoidLBMKernel.h index 0165e711a..ad5346555 100644 --- a/source/VirtualFluidsCore/LBM/VoidLBMKernel.h +++ b/source/VirtualFluidsCore/LBM/VoidLBMKernel.h @@ -1,15 +1,15 @@ #ifndef VoidLBMKernel_h__ #define VoidLBMKernel_h__ -#include "LBMKernel3D.h" +#include "LBMKernel.h" -class VoidLBMKernel : public LBMKernel3D +class VoidLBMKernel : public LBMKernel { public: VoidLBMKernel(); VoidLBMKernel(int nx1, int nx2, int nx3); ~VoidLBMKernel(); - LBMKernel3DPtr clone(); + LBMKernelPtr clone(); void calculate(); void swapDistributions(); double getCallculationTime(); @@ -20,7 +20,7 @@ private: template<class Archive> void serialize(Archive & ar, const unsigned int version) { - ar & boost::serialization::base_object<LBMKernel3D>(*this); + ar & boost::serialization::base_object<LBMKernel>(*this); ar & nx1 & nx2 & nx3; } diff --git a/source/VirtualFluidsCore/Utilities/ChangeRandomQs.hpp b/source/VirtualFluidsCore/Utilities/ChangeRandomQs.hpp index 9a91f578f..267f7efdf 100644 --- a/source/VirtualFluidsCore/Utilities/ChangeRandomQs.hpp +++ b/source/VirtualFluidsCore/Utilities/ChangeRandomQs.hpp @@ -1,25 +1,25 @@ #ifndef ChangeRandomQs_h__ #define ChangeRandomQs_h__ -#include "LBMKernel3D.h" -#include "D3Q27IntegrateValuesHelper.h" -#include "D3Q27BoundaryCondition.h" +#include "LBMKernel.h" +#include "IntegrateValuesHelper.h" +#include "BoundaryConditions.h" #include "BCArray3D.h" -#include "D3Q27ETBCProcessor.h" +#include "BCProcessor.h" namespace Utilities { - void ChangeRandomQs(D3Q27IntegrateValuesHelperPtr integrateValues) + void ChangeRandomQs(IntegrateValuesHelperPtr integrateValues) { - std::vector<D3Q27IntegrateValuesHelper::CalcNodes> cnodes = integrateValues->getCNodes(); + std::vector<IntegrateValuesHelper::CalcNodes> cnodes = integrateValues->getCNodes(); - BOOST_FOREACH(D3Q27IntegrateValuesHelper::CalcNodes cn, cnodes) + BOOST_FOREACH(IntegrateValuesHelper::CalcNodes cn, cnodes) { - LBMKernel3DPtr kernel = cn.block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = cn.block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); BOOST_FOREACH(UbTupleInt3 node, cn.nodes) { - D3Q27BoundaryConditionPtr bc = bcArray.getBC(val<1>(node), val<2>(node), val<3>(node)); + BoundaryConditionsPtr bc = bcArray.getBC(val<1>(node), val<2>(node), val<3>(node)); if (bc) { for (int fdir=D3Q27System::FSTARTDIR; fdir<=D3Q27System::FENDDIR; fdir++) diff --git a/source/VirtualFluidsCore/Utilities/VoxelMatrixUtil.hpp b/source/VirtualFluidsCore/Utilities/VoxelMatrixUtil.hpp index 216209ef3..2b9c6f964 100644 --- a/source/VirtualFluidsCore/Utilities/VoxelMatrixUtil.hpp +++ b/source/VirtualFluidsCore/Utilities/VoxelMatrixUtil.hpp @@ -2,7 +2,7 @@ #define VoxelMatrixUtil_h__ #include "GbCuboid3D.h" -#include "D3Q27NoSlipBCAdapter.h" +#include "NoSlipBCAdapter.h" #include "D3Q27Interactor.h" #include "SetSolidOrTransBlockVisitor.h" #include "Block3D.h" @@ -13,7 +13,7 @@ namespace Utilities { void voxelMatrixDiscretisation(GbVoxelMatrix3DPtr matrix, std::string& pathname, int myid, int fileCounter, Grid3DPtr grid, int bounceBackOption, bool vmFile) { - D3Q27BoundaryConditionAdapterPtr noSlipPM(new D3Q27NoSlipBCAdapter(bounceBackOption)); + BCAdapterPtr noSlipPM(new NoSlipBCAdapter(bounceBackOption)); D3Q27InteractorPtr vmInt = D3Q27InteractorPtr(new D3Q27Interactor(matrix, grid, noSlipPM, Interactor3D::SOLID)); if (vmFile) diff --git a/source/VirtualFluidsCore/Visitors/BoundaryConditionBlockVisitor.cpp b/source/VirtualFluidsCore/Visitors/BoundaryConditionBlockVisitor.cpp deleted file mode 100644 index 6f07701e2..000000000 --- a/source/VirtualFluidsCore/Visitors/BoundaryConditionBlockVisitor.cpp +++ /dev/null @@ -1,122 +0,0 @@ -#include "BoundaryConditionBlockVisitor.h" -#include "LBMKernelETD3Q27.h" -#include "D3Q27ETBCProcessor.h" -#include "Grid3DSystem.h" - -BoundaryConditionBlockVisitor::BoundaryConditionBlockVisitor() : -Block3DVisitor(0, Grid3DSystem::MAXLEVEL) -{ - -} -////////////////////////////////////////////////////////////////////////// -BoundaryConditionBlockVisitor::~BoundaryConditionBlockVisitor() -{ - -} -////////////////////////////////////////////////////////////////////////// -void BoundaryConditionBlockVisitor::visit(Grid3DPtr grid, Block3DPtr block) -{ - if (block->getRank() == grid->getRank()) - { - LBMKernel3DPtr kernel = block->getKernel(); - D3Q27ETBCProcessorPtr bcProcessor = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor()); - velocity = bcProcessor->getBC(BoundaryCondition::Velocity); - density = bcProcessor->getBC(BoundaryCondition::Density); - noSlip = bcProcessor->getBC(BoundaryCondition::NoSlip); - slip = bcProcessor->getBC(BoundaryCondition::Slip); - BCArray3D<D3Q27BoundaryCondition>& bcArray = bcProcessor->getBCArray(); - bool compressible = kernel->getCompressible(); - double collFactor = kernel->getCollisionFactor(); - int level = block->getLevel(); - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - int maxX1 = (int)bcArray.getNX1(); - int maxX2 = (int)bcArray.getNX2(); - int maxX3 = (int)bcArray.getNX3(); - D3Q27BoundaryConditionPtr bcPtr; - - int vCount = 0; - int dCount = 0; - int nsCount = 0; - int sCount = 0; - - if (velocity) velocity->clearData(); - if (density) density->clearData(); - if (noSlip) noSlip->clearData(); - if (slip) slip->clearData(); - - EsoTwist3DPtr distributions = boost::dynamic_pointer_cast<EsoTwist3D>(kernel->getDataSet()->getFdistributions()); - - 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)) - { - if ((bcPtr = bcArray.getBC(x1, x2, x3)) != NULL) - { - //velocity boundary condition - if (bcPtr->hasVelocityBoundary() && velocity) - { - velocity->addNode(x1, x2, x3); - velocity->addBcPointer(bcPtr); - vCount++; - } - //density boundary condition - else if (bcPtr->hasDensityBoundary() && density) - { - density->addNode(x1, x2, x3); - density->addBcPointer(bcPtr); - dCount++; - } - //no slip boundary condition - else if (bcPtr->hasNoSlipBoundary() && noSlip) - { - noSlip->addNode(x1, x2, x3); - noSlip->addBcPointer(bcPtr); - nsCount++; - } - //slip boundary condition - else if (bcPtr->hasSlipBoundary() && slip) - { - slip->addNode(x1, x2, x3); - slip->addBcPointer(bcPtr); - sCount++; - } - } - } - } - } - } - if (vCount > 0) - { - velocity->addDistributions(distributions); - velocity->setCollFactor(collFactor); - velocity->setCompressible(compressible); - } - if (dCount > 0) - { - density->addDistributions(distributions); - density->setCollFactor(collFactor); - density->setCompressible(compressible); - } - if (nsCount > 0) - { - noSlip->addDistributions(distributions); - noSlip->setCollFactor(collFactor); - noSlip->setCompressible(compressible); - } - if (sCount > 0) - { - slip->addDistributions(distributions); - slip->setCollFactor(collFactor); - slip->setCompressible(compressible); - } - } -} - - diff --git a/source/VirtualFluidsCore/Visitors/BoundaryConditionBlockVisitor.h b/source/VirtualFluidsCore/Visitors/BoundaryConditionBlockVisitor.h deleted file mode 100644 index abb3366fc..000000000 --- a/source/VirtualFluidsCore/Visitors/BoundaryConditionBlockVisitor.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef BoundaryConditionBlockVisitor_h__ -#define BoundaryConditionBlockVisitor_h__ - -#include "Block3DVisitor.h" - -class BoundaryConditionBlockVisitor : public Block3DVisitor -{ -public: - BoundaryConditionBlockVisitor(); - virtual ~BoundaryConditionBlockVisitor(); - void visit(Grid3DPtr grid, Block3DPtr block); -protected: -private: - BoundaryConditionPtr velocity; - BoundaryConditionPtr density; - BoundaryConditionPtr noSlip; - BoundaryConditionPtr slip; -}; -#endif // BoundaryConditionBlockVisitor_h__ diff --git a/source/VirtualFluidsCore/Visitors/BoundaryConditionsBlockVisitor.cpp b/source/VirtualFluidsCore/Visitors/BoundaryConditionsBlockVisitor.cpp new file mode 100644 index 000000000..ffc3b28d8 --- /dev/null +++ b/source/VirtualFluidsCore/Visitors/BoundaryConditionsBlockVisitor.cpp @@ -0,0 +1,85 @@ +#include "BoundaryConditionsBlockVisitor.h" +#include "LBMKernel.h" +#include "BCProcessor.h" +#include "Grid3DSystem.h" +#include "D3Q27EsoTwist3DSplittedVector.h" +#include "ThinWallNoSlipBCAlgorithm.h" + +BoundaryConditionsBlockVisitor::BoundaryConditionsBlockVisitor() : +Block3DVisitor(0, Grid3DSystem::MAXLEVEL) +{ + +} +////////////////////////////////////////////////////////////////////////// +BoundaryConditionsBlockVisitor::~BoundaryConditionsBlockVisitor() +{ + +} +////////////////////////////////////////////////////////////////////////// +void BoundaryConditionsBlockVisitor::visit(Grid3DPtr grid, Block3DPtr block) +{ + if (block->getRank() == grid->getRank()) + { + LBMKernelPtr kernel = block->getKernel(); + BCProcessorPtr bcProcessor = kernel->getBCProcessor(); + + if (!bcProcessor) + { + throw UbException(UB_EXARGS,"Boundary Conditions Processor is not exist!" ); + } + + BCArray3D& bcArray = bcProcessor->getBCArray(); + bool compressible = kernel->getCompressible(); + double collFactor = kernel->getCollisionFactor(); + int level = block->getLevel(); + + int minX1 = 0; + int minX2 = 0; + int minX3 = 0; + int maxX1 = (int)bcArray.getNX1(); + int maxX2 = (int)bcArray.getNX2(); + int maxX3 = (int)bcArray.getNX3(); + BoundaryConditionsPtr bcPtr; + + bcProcessor->clearBC(); + + //DistributionArray3DPtr distributions = boost::dynamic_pointer_cast<EsoTwist3D>(kernel->getDataSet()->getFdistributions()); + DistributionArray3DPtr distributions = kernel->getDataSet()->getFdistributions(); + + 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)) + { + if ((bcPtr = bcArray.getBC(x1, x2, x3)) != NULL) + { + char alg = bcPtr->getBcAlgorithmType(); + BCAlgorithmPtr bca = bcMap[alg]; + if (bca) + { + bca = bca->clone(); + bca->addNode(x1, x2, x3); + bca->addBcPointer(bcPtr); + bca->addDistributions(distributions); + bca->setCollFactor(collFactor); + bca->setCompressible(compressible); + bcProcessor->addBC(bca); + } + } + } + } + } + } + } +} +////////////////////////////////////////////////////////////////////////// +void BoundaryConditionsBlockVisitor::addBC(BCAdapterPtr bc) +{ + bcMap.insert(std::make_pair(bc->getBcAlgorithmType(), bc->getAlgorithm())); +} + + + diff --git a/source/VirtualFluidsCore/Visitors/BoundaryConditionsBlockVisitor.h b/source/VirtualFluidsCore/Visitors/BoundaryConditionsBlockVisitor.h new file mode 100644 index 000000000..160139467 --- /dev/null +++ b/source/VirtualFluidsCore/Visitors/BoundaryConditionsBlockVisitor.h @@ -0,0 +1,19 @@ +#ifndef BoundaryConditionBlockVisitor_h__ +#define BoundaryConditionBlockVisitor_h__ + +#include "Block3DVisitor.h" +#include "BCAdapter.h" + +class BoundaryConditionsBlockVisitor : public Block3DVisitor +{ +public: + BoundaryConditionsBlockVisitor(); + virtual ~BoundaryConditionsBlockVisitor(); + + void visit(Grid3DPtr grid, Block3DPtr block); + void addBC(BCAdapterPtr bc); +protected: +private: + std::map<char, BCAlgorithmPtr> bcMap; +}; +#endif // BoundaryConditionBlockVisitor_h__ diff --git a/source/VirtualFluidsCore/Visitors/ChangeBoundaryDensityBlockVisitor.cpp b/source/VirtualFluidsCore/Visitors/ChangeBoundaryDensityBlockVisitor.cpp index 0908da0a4..f389054fd 100644 --- a/source/VirtualFluidsCore/Visitors/ChangeBoundaryDensityBlockVisitor.cpp +++ b/source/VirtualFluidsCore/Visitors/ChangeBoundaryDensityBlockVisitor.cpp @@ -1,7 +1,8 @@ #include "ChangeBoundaryDensityBlockVisitor.h" -#include "LBMKernelETD3Q27.h" +#include "LBMKernel.h" #include "Grid3DSystem.h" -#include "D3Q27BoundaryCondition.h" +#include "BoundaryConditions.h" +#include "BCProcessor.h" ChangeBoundaryDensityBlockVisitor::ChangeBoundaryDensityBlockVisitor(float oldBoundaryDensity, float newBoundaryDensity) : Block3DVisitor(0, Grid3DSystem::MAXLEVEL), @@ -20,8 +21,8 @@ void ChangeBoundaryDensityBlockVisitor::visit(Grid3DPtr grid, Block3DPtr block) { if (block->getRank() == grid->getRank()) { - LBMKernel3DPtr kernel = block->getKernel(); - BCArray3D<D3Q27BoundaryCondition>& bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + LBMKernelPtr kernel = block->getKernel(); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); int minX1 = 0; int minX2 = 0; diff --git a/source/VirtualFluidsCore/Visitors/ChangeBoundaryDensityBlockVisitor.h b/source/VirtualFluidsCore/Visitors/ChangeBoundaryDensityBlockVisitor.h index 3ec36c3fc..06fff8280 100644 --- a/source/VirtualFluidsCore/Visitors/ChangeBoundaryDensityBlockVisitor.h +++ b/source/VirtualFluidsCore/Visitors/ChangeBoundaryDensityBlockVisitor.h @@ -2,7 +2,7 @@ #define ChangeBoundaryDensityBlockVisitor_h__ #include "Block3DVisitor.h" -#include "D3Q27BoundaryCondition.h" +#include "BoundaryConditions.h" class ChangeBoundaryDensityBlockVisitor : public Block3DVisitor { @@ -14,6 +14,6 @@ protected: private: float oldBoundaryDensity; float newBoundaryDensity; - D3Q27BoundaryConditionPtr bcPtr; + BoundaryConditionsPtr bcPtr; }; #endif // ChangeBoundaryDensityBlockVisitor_h__ diff --git a/source/VirtualFluidsCore/Visitors/CoarsenCrossAndInsideGbObjectBlockVisitor.cpp b/source/VirtualFluidsCore/Visitors/CoarsenCrossAndInsideGbObjectBlockVisitor.cpp new file mode 100644 index 000000000..4806e8dfe --- /dev/null +++ b/source/VirtualFluidsCore/Visitors/CoarsenCrossAndInsideGbObjectBlockVisitor.cpp @@ -0,0 +1,38 @@ +#include "CoarsenCrossAndInsideGbObjectBlockVisitor.h" + +CoarsenCrossAndInsideGbObjectBlockVisitor::CoarsenCrossAndInsideGbObjectBlockVisitor() + : Block3DVisitor(), notActive(true) +{ +} +////////////////////////////////////////////////////////////////////////// +CoarsenCrossAndInsideGbObjectBlockVisitor::CoarsenCrossAndInsideGbObjectBlockVisitor(GbObject3DPtr geoObject, int fineLevel, int coarseLevel) + : Block3DVisitor(fineLevel, fineLevel), geoObject(geoObject), notActive(true), coarseLevel(coarseLevel) +{ + +} +////////////////////////////////////////////////////////////////////////// +CoarsenCrossAndInsideGbObjectBlockVisitor::~CoarsenCrossAndInsideGbObjectBlockVisitor() +{ +} +////////////////////////////////////////////////////////////////////////// +void CoarsenCrossAndInsideGbObjectBlockVisitor::visit(const Grid3DPtr grid, Block3DPtr block) +{ + int fineLevel = block->getLevel(); + if (notActive && block->isNotActive()) return; + if (fineLevel>this->getStopLevel()) return; + + UbTupleDouble3 coords = grid->getBlockWorldCoordinates(block); + UbTupleDouble3 deltas = grid->getBlockLengths(block); + if (geoObject->isCellInsideOrCuttingGbObject3D(val<1>(coords) + , val<2>(coords) + , val<3>(coords) + , val<1>(coords)+val<1>(deltas) + , val<2>(coords)+val<2>(deltas) + , val<3>(coords)+val<3>(deltas))) + { + grid->collapseBlock(block->getX1(), block->getX2(), block->getX3(), fineLevel, coarseLevel); + } + + return; +} +////////////////////////////////////////////////////////////////////////// diff --git a/source/VirtualFluidsCore/Visitors/CoarsenCrossAndInsideGbObjectBlockVisitor.h b/source/VirtualFluidsCore/Visitors/CoarsenCrossAndInsideGbObjectBlockVisitor.h new file mode 100644 index 000000000..90ca0137a --- /dev/null +++ b/source/VirtualFluidsCore/Visitors/CoarsenCrossAndInsideGbObjectBlockVisitor.h @@ -0,0 +1,28 @@ +#ifndef CoarsenCrossAndInsideGbObjectBlockVisitor_H +#define CoarsenCrossAndInsideGbObjectBlockVisitor_H + +#include "Block3DVisitor.h" +#include <numerics/geometry3d/GbObject3D.h> + +//! \brief Refine blocks on base of bounding box which is defined with <i>geoObject</i> +//! \details The class uses a geometry object for define a bounding box. Inside and across this bounding box will be grid on block basis refinement. +//! \author K. Kutscher +class CoarsenCrossAndInsideGbObjectBlockVisitor : public Block3DVisitor +{ +public: + //! A default constructor + CoarsenCrossAndInsideGbObjectBlockVisitor(); + //! A constructor + //! \param geoObject a smart pointer to bounding box + //! \param refineLevel an integer for refine on this level + CoarsenCrossAndInsideGbObjectBlockVisitor(GbObject3DPtr geoObject, int fineLevel, int coarseLevel); + virtual ~CoarsenCrossAndInsideGbObjectBlockVisitor(); + void visit(Grid3DPtr grid, Block3DPtr block); + ////////////////////////////////////////////////////////////////////////// +protected: + GbObject3DPtr geoObject; + bool notActive; + int coarseLevel; +}; + +#endif diff --git a/source/VirtualFluidsCore/Visitors/ConnectorBlockVisitor.cpp b/source/VirtualFluidsCore/Visitors/ConnectorBlockVisitor.cpp index 1960d7076..658a46a52 100644 --- a/source/VirtualFluidsCore/Visitors/ConnectorBlockVisitor.cpp +++ b/source/VirtualFluidsCore/Visitors/ConnectorBlockVisitor.cpp @@ -1,7 +1,7 @@ #include "ConnectorBlockVisitor.h" #include "Grid3DSystem.h" -ConnectorBlockVisitor::ConnectorBlockVisitor(CommunicatorPtr comm, LBMReal nu, D3Q27InterpolationProcessorPtr iProcessor, ConnectorFactoryPtr cFactory) : +ConnectorBlockVisitor::ConnectorBlockVisitor(CommunicatorPtr comm, LBMReal nu, InterpolationProcessorPtr iProcessor, ConnectorFactoryPtr cFactory) : Block3DVisitor(0, Grid3DSystem::MAXLEVEL), comm(comm), nu(nu), @@ -382,11 +382,11 @@ void ConnectorBlockVisitor::setInterpolationConnectors(Block3DPtr fblock00, Bloc LBMReal omegaC = LBMSystem::calcCollisionFactor(nu, cBlock->getLevel()); iProcessor->setOmegas(omegaC, omegaF); - D3Q27InterpolationProcessorPtr cIProcessor(iProcessor->clone()); - D3Q27InterpolationProcessorPtr fIProcessor00(iProcessor->clone()); - D3Q27InterpolationProcessorPtr fIProcessor10(iProcessor->clone()); - D3Q27InterpolationProcessorPtr fIProcessor01(iProcessor->clone()); - D3Q27InterpolationProcessorPtr fIProcessor11(iProcessor->clone()); + InterpolationProcessorPtr cIProcessor(iProcessor->clone()); + InterpolationProcessorPtr fIProcessor00(iProcessor->clone()); + InterpolationProcessorPtr fIProcessor10(iProcessor->clone()); + InterpolationProcessorPtr fIProcessor01(iProcessor->clone()); + InterpolationProcessorPtr fIProcessor11(iProcessor->clone()); CreateTransmittersHelper::TransmitterPtr senderCF00, receiverCF00, senderCF01, receiverCF01, diff --git a/source/VirtualFluidsCore/Visitors/ConnectorBlockVisitor.h b/source/VirtualFluidsCore/Visitors/ConnectorBlockVisitor.h index 10f6a5a04..b49f148cd 100644 --- a/source/VirtualFluidsCore/Visitors/ConnectorBlockVisitor.h +++ b/source/VirtualFluidsCore/Visitors/ConnectorBlockVisitor.h @@ -4,14 +4,14 @@ #include "Block3DVisitor.h" #include "D3Q27System.h" #include "Communicator.h" -#include "D3Q27InterpolationProcessor.h" +#include "InterpolationProcessor.h" #include "CreateTransmittersHelper.h" #include "ConnectorFactory.h" class ConnectorBlockVisitor : public Block3DVisitor { public: - ConnectorBlockVisitor(CommunicatorPtr comm, LBMReal nu, D3Q27InterpolationProcessorPtr iProcessor, ConnectorFactoryPtr cFactory); + ConnectorBlockVisitor(CommunicatorPtr comm, LBMReal nu, InterpolationProcessorPtr iProcessor, ConnectorFactoryPtr cFactory); virtual ~ConnectorBlockVisitor(); void visit(Grid3DPtr grid, Block3DPtr block); ////////////////////////////////////////////////////////////////////////// @@ -29,7 +29,7 @@ protected: CommunicatorPtr comm; int gridRank; LBMReal nu; - D3Q27InterpolationProcessorPtr iProcessor; + InterpolationProcessorPtr iProcessor; ConnectorFactoryPtr cFactory; }; diff --git a/source/VirtualFluidsCore/Visitors/D3Q27SetUndefinedNodesBlockVisitor.h b/source/VirtualFluidsCore/Visitors/D3Q27SetUndefinedNodesBlockVisitor.h deleted file mode 100644 index 5a878454f..000000000 --- a/source/VirtualFluidsCore/Visitors/D3Q27SetUndefinedNodesBlockVisitor.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef D3Q27SetUndefinedNodesBlockVisitor_h -#define D3Q27SetUndefinedNodesBlockVisitor_h - -#include "Block3DVisitor.h" -#include "LBMKernel3D.h" -#include "BCArray3D.h" -#include "D3Q27BoundaryCondition.h" -#include "D3Q27ETBCProcessor.h" - -class D3Q27SetUndefinedNodesBlockVisitor : public Block3DVisitor -{ -public: - D3Q27SetUndefinedNodesBlockVisitor(); - - virtual ~D3Q27SetUndefinedNodesBlockVisitor() {} - - void visit(Grid3DPtr grid, Block3DPtr block); - -private: - void setNodesUndefined( int startix1, int endix1, int startix2, int endix2, int startix3, int endix3, BCArray3D<D3Q27BoundaryCondition>& bcMatix ); -}; -#endif diff --git a/source/VirtualFluidsCore/Visitors/D3Q27ETInitDistributionsBlockVisitor.cpp b/source/VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.cpp similarity index 83% rename from source/VirtualFluidsCore/Visitors/D3Q27ETInitDistributionsBlockVisitor.cpp rename to source/VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.cpp index a4be9cab5..34b8fec59 100644 --- a/source/VirtualFluidsCore/Visitors/D3Q27ETInitDistributionsBlockVisitor.cpp +++ b/source/VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.cpp @@ -1,9 +1,9 @@ -#include "D3Q27ETInitDistributionsBlockVisitor.h" -#include "LBMKernel3D.h" -#include "D3Q27ETBCProcessor.h" +#include "InitDistributionsBlockVisitor.h" +#include "LBMKernel.h" +#include "BCProcessor.h" #include "Grid3DSystem.h" -D3Q27ETInitDistributionsBlockVisitor::D3Q27ETInitDistributionsBlockVisitor() +InitDistributionsBlockVisitor::InitDistributionsBlockVisitor() : Block3DVisitor(0, Grid3DSystem::MAXLEVEL) { this->setVx1(0.0); @@ -21,7 +21,7 @@ D3Q27ETInitDistributionsBlockVisitor::D3Q27ETInitDistributionsBlockVisitor() // this->setRho(rho); //} ////////////////////////////////////////////////////////////////////////// -D3Q27ETInitDistributionsBlockVisitor::D3Q27ETInitDistributionsBlockVisitor( LBMReal nu, LBMReal rho, LBMReal vx1, LBMReal vx2, LBMReal vx3) +InitDistributionsBlockVisitor::InitDistributionsBlockVisitor( LBMReal nu, LBMReal rho, LBMReal vx1, LBMReal vx2, LBMReal vx3) : Block3DVisitor(0, Grid3DSystem::MAXLEVEL) { this->setVx1(vx1); @@ -31,79 +31,79 @@ D3Q27ETInitDistributionsBlockVisitor::D3Q27ETInitDistributionsBlockVisitor( LBMR this->setNu(nu); } ////////////////////////////////////////////////////////////////////////// -void D3Q27ETInitDistributionsBlockVisitor::setVx1( const mu::Parser& parser) +void InitDistributionsBlockVisitor::setVx1( const mu::Parser& parser) { this->checkFunction(parser); this->muVx1 = parser; } ////////////////////////////////////////////////////////////////////////// -void D3Q27ETInitDistributionsBlockVisitor::setVx2( const mu::Parser& parser) +void InitDistributionsBlockVisitor::setVx2( const mu::Parser& parser) { this->checkFunction(parser); this->muVx2 = parser; } ////////////////////////////////////////////////////////////////////////// -void D3Q27ETInitDistributionsBlockVisitor::setVx3( const mu::Parser& parser) +void InitDistributionsBlockVisitor::setVx3( const mu::Parser& parser) { this->checkFunction(parser); this->muVx3 = parser; } ////////////////////////////////////////////////////////////////////////// -void D3Q27ETInitDistributionsBlockVisitor::setRho( const mu::Parser& parser) +void InitDistributionsBlockVisitor::setRho( const mu::Parser& parser) { this->checkFunction(parser); this->muRho = parser; } ////////////////////////////////////////////////////////////////////////// -void D3Q27ETInitDistributionsBlockVisitor::setVx1( const std::string& muParserString) +void InitDistributionsBlockVisitor::setVx1( const std::string& muParserString) { this->muVx1.SetExpr(muParserString); this->checkFunction(muVx1); } ////////////////////////////////////////////////////////////////////////// -void D3Q27ETInitDistributionsBlockVisitor::setVx2( const std::string& muParserString) +void InitDistributionsBlockVisitor::setVx2( const std::string& muParserString) { this->muVx2.SetExpr(muParserString); this->checkFunction(muVx2); } ////////////////////////////////////////////////////////////////////////// -void D3Q27ETInitDistributionsBlockVisitor::setVx3( const std::string& muParserString) +void InitDistributionsBlockVisitor::setVx3( const std::string& muParserString) { this->muVx3.SetExpr(muParserString); this->checkFunction(muVx3); } ////////////////////////////////////////////////////////////////////////// -void D3Q27ETInitDistributionsBlockVisitor::setRho( const std::string& muParserString) +void InitDistributionsBlockVisitor::setRho( const std::string& muParserString) { this->muRho.SetExpr(muParserString); this->checkFunction(muRho); } ////////////////////////////////////////////////////////////////////////// -void D3Q27ETInitDistributionsBlockVisitor::setVx1( LBMReal vx1 ) +void InitDistributionsBlockVisitor::setVx1( LBMReal vx1 ) { this->muVx1.SetExpr( UbSystem::toString(vx1,D3Q27RealLim::digits10) ); this->checkFunction(muVx1); } ////////////////////////////////////////////////////////////////////////// -void D3Q27ETInitDistributionsBlockVisitor::setVx2( LBMReal vx2 ) +void InitDistributionsBlockVisitor::setVx2( LBMReal vx2 ) { this->muVx2.SetExpr( UbSystem::toString(vx2,D3Q27RealLim::digits10) ); this->checkFunction(muVx2); } ////////////////////////////////////////////////////////////////////////// -void D3Q27ETInitDistributionsBlockVisitor::setVx3( LBMReal vx3 ) +void InitDistributionsBlockVisitor::setVx3( LBMReal vx3 ) { this->muVx3.SetExpr( UbSystem::toString(vx3,D3Q27RealLim::digits10) ); this->checkFunction(muVx3); } ////////////////////////////////////////////////////////////////////////// -void D3Q27ETInitDistributionsBlockVisitor::setRho( LBMReal rho ) +void InitDistributionsBlockVisitor::setRho( LBMReal rho ) { this->muRho.SetExpr( UbSystem::toString(rho,D3Q27RealLim::digits10) ); this->checkFunction(muRho); } ////////////////////////////////////////////////////////////////////////// -void D3Q27ETInitDistributionsBlockVisitor::visit(const Grid3DPtr grid, Block3DPtr block) +void InitDistributionsBlockVisitor::visit(const Grid3DPtr grid, Block3DPtr block) { using namespace D3Q27System; @@ -133,7 +133,7 @@ void D3Q27ETInitDistributionsBlockVisitor::visit(const Grid3DPtr grid, Block3DPt if (blockRank == gridRank && block->isActive()) { - LBMKernel3DPtr kernel = block->getKernel(); + LBMKernelPtr kernel = block->getKernel(); if (!kernel) throw UbException(UB_EXARGS, "The LBM kernel isn't exist in block: "+block->toString()); @@ -144,8 +144,8 @@ void D3Q27ETInitDistributionsBlockVisitor::visit(const Grid3DPtr grid, Block3DPt UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); - BCArray3D<D3Q27BoundaryCondition> bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); - EsoTwist3DPtr distributions = boost::dynamic_pointer_cast<EsoTwist3D>(kernel->getDataSet()->getFdistributions()); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); + EsoTwist3DPtr distributions = boost::dynamic_pointer_cast<EsoTwist3D>(kernel->getDataSet()->getFdistributions()); LBMReal f[D3Q27System::ENDF+1]; @@ -279,7 +279,7 @@ void D3Q27ETInitDistributionsBlockVisitor::visit(const Grid3DPtr grid, Block3DPt } ////////////////////////////////////////////////////////////////////////// -void D3Q27ETInitDistributionsBlockVisitor::checkFunction(mu::Parser fct) +void InitDistributionsBlockVisitor::checkFunction(mu::Parser fct) { double x1=1.0,x2=1.0,x3=1.0; fct.DefineVar("x1",&x1); @@ -298,7 +298,7 @@ void D3Q27ETInitDistributionsBlockVisitor::checkFunction(mu::Parser fct) } } ////////////////////////////////////////////////////////////////////////// -void D3Q27ETInitDistributionsBlockVisitor::setNu( LBMReal nu ) +void InitDistributionsBlockVisitor::setNu( LBMReal nu ) { this->nu = nu; } diff --git a/source/VirtualFluidsCore/Visitors/D3Q27ETInitDistributionsBlockVisitor.h b/source/VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.h similarity index 86% rename from source/VirtualFluidsCore/Visitors/D3Q27ETInitDistributionsBlockVisitor.h rename to source/VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.h index 893bab67b..a047cd3d0 100644 --- a/source/VirtualFluidsCore/Visitors/D3Q27ETInitDistributionsBlockVisitor.h +++ b/source/VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.h @@ -1,5 +1,5 @@ -#ifndef D3Q27ETInitDistributionsBlockVisitor_H -#define D3Q27ETInitDistributionsBlockVisitor_H +#ifndef InitDistributionsBlockVisitor_H +#define InitDistributionsBlockVisitor_H #include <boost/foreach.hpp> @@ -34,13 +34,13 @@ if function is invalid an UbException with detailed information is thrown -class D3Q27ETInitDistributionsBlockVisitor : public Block3DVisitor +class InitDistributionsBlockVisitor : public Block3DVisitor { public: typedef std::numeric_limits<LBMReal> D3Q27RealLim; public: - D3Q27ETInitDistributionsBlockVisitor(); + InitDistributionsBlockVisitor(); //D3Q27ETInitDistributionsBlockVisitor(LBMReal rho, LBMReal vx1=0.0, LBMReal vx2=0.0, LBMReal vx3=0.0); //! Constructor //! \param nu - viscosity @@ -48,7 +48,7 @@ public: //! \param vx1 - velocity in x //! \param vx2 - velocity in y //! \param vx3 - velocity in z - D3Q27ETInitDistributionsBlockVisitor( LBMReal nu, LBMReal rho, LBMReal vx1=0.0, LBMReal vx2=0.0, LBMReal vx3=0.0); + InitDistributionsBlockVisitor( LBMReal nu, LBMReal rho, LBMReal vx1=0.0, LBMReal vx2=0.0, LBMReal vx3=0.0); ////////////////////////////////////////////////////////////////////////// //automatic vars are: x1,x2, x3 //ussage example: setVx1("x1*0.01+x2*0.003") diff --git a/source/VirtualFluidsCore/Visitors/InitDistributionsFromFileBlockVisitor.cpp b/source/VirtualFluidsCore/Visitors/InitDistributionsFromFileBlockVisitor.cpp index 9df3d1d37..b1f4e1024 100644 --- a/source/VirtualFluidsCore/Visitors/InitDistributionsFromFileBlockVisitor.cpp +++ b/source/VirtualFluidsCore/Visitors/InitDistributionsFromFileBlockVisitor.cpp @@ -1,7 +1,7 @@ #include "InitDistributionsFromFileBlockVisitor.h" #include <basics/utilities/UbFileInputASCII.h> -#include "LBMKernel3D.h" -#include "D3Q27ETBCProcessor.h" +#include "LBMKernel.h" +#include "BCProcessor.h" #include "Grid3DSystem.h" #include "InitDensityLBMKernel.h" @@ -24,6 +24,10 @@ InitDistributionsFromFileBlockVisitor::InitDistributionsFromFileBlockVisitor(LBM for (int x2 = 0; x2<nodesX2; x2++) for (int x1 = 0; x1<nodesX1; x1++) { + //for (int x1 = 0; x1<nodesX1; x1++) + // for (int x2 = 0; x2<nodesX2; x2++) + // for (int x3 = 0; x3<nodesX3; x3++) + // { matrix(Vx1, x1, x2, x3) = in.readDouble(); matrix(Vx2, x1, x2, x3) = in.readDouble(); matrix(Vx3, x1, x2, x3) = in.readDouble(); @@ -57,7 +61,7 @@ void InitDistributionsFromFileBlockVisitor::visit(const Grid3DPtr grid, Block3DP if (blockRank==gridRank && block->isActive()) { - LBMKernel3DPtr kernel = block->getKernel(); + LBMKernelPtr kernel = block->getKernel(); if (!kernel) throw UbException(UB_EXARGS, "The LBM kernel isn't exist in block: "+block->toString()); @@ -68,8 +72,8 @@ void InitDistributionsFromFileBlockVisitor::visit(const Grid3DPtr grid, Block3DP UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); - BCArray3D<D3Q27BoundaryCondition> bcArray = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); - EsoTwist3DPtr distributions = boost::dynamic_pointer_cast<EsoTwist3D>(kernel->getDataSet()->getFdistributions()); + BCArray3D& bcArray = kernel->getBCProcessor()->getBCArray(); + EsoTwist3DPtr distributions = boost::dynamic_pointer_cast<EsoTwist3D>(kernel->getDataSet()->getFdistributions()); LBMReal f[D3Q27System::ENDF+1]; diff --git a/source/VirtualFluidsCore/Visitors/RenumberBlockVisitor.h b/source/VirtualFluidsCore/Visitors/RenumberBlockVisitor.h index 126a929d0..ecf37dab7 100644 --- a/source/VirtualFluidsCore/Visitors/RenumberBlockVisitor.h +++ b/source/VirtualFluidsCore/Visitors/RenumberBlockVisitor.h @@ -9,7 +9,7 @@ #define RenumberBlockVisitor_h #include "Block3DVisitor.h" -#include "LBMKernel3D.h" +#include "LBMKernel.h" //! \brief Visitor class which renumber blocks. //! \details Visitor class which renumber blocks. diff --git a/source/VirtualFluidsCore/Visitors/D3Q27SetConnectorsBlockVisitor.cpp b/source/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.cpp similarity index 93% rename from source/VirtualFluidsCore/Visitors/D3Q27SetConnectorsBlockVisitor.cpp rename to source/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.cpp index 999c45d55..4b0453a8a 100644 --- a/source/VirtualFluidsCore/Visitors/D3Q27SetConnectorsBlockVisitor.cpp +++ b/source/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.cpp @@ -1,4 +1,4 @@ -#include "D3Q27SetConnectorsBlockVisitor.h" +#include "SetConnectorsBlockVisitor.h" #include "D3Q27ETFullDirectConnector.h" #include "D3Q27ETFullVectorConnector.h" #include "D3Q27ETCFOffVectorConnector.h" @@ -6,8 +6,8 @@ #include "Grid3DSystem.h" #include <basics/transmitter/TbTransmitterLocal.h> -D3Q27SetConnectorsBlockVisitor::D3Q27SetConnectorsBlockVisitor(CommunicatorPtr comm, bool fullConnector, int dirs, - LBMReal nue, D3Q27InterpolationProcessorPtr iProcessor) : +SetConnectorsBlockVisitor::SetConnectorsBlockVisitor(CommunicatorPtr comm, bool fullConnector, int dirs, + LBMReal nue, InterpolationProcessorPtr iProcessor) : Block3DVisitor(0, Grid3DSystem::MAXLEVEL), comm(comm), fullConnector(fullConnector), @@ -17,11 +17,11 @@ Block3DVisitor(0, Grid3DSystem::MAXLEVEL), { } ////////////////////////////////////////////////////////////////////////// -D3Q27SetConnectorsBlockVisitor::~D3Q27SetConnectorsBlockVisitor(void) +SetConnectorsBlockVisitor::~SetConnectorsBlockVisitor(void) { } ////////////////////////////////////////////////////////////////////////// -void D3Q27SetConnectorsBlockVisitor::visit(Grid3DPtr grid, Block3DPtr block) +void SetConnectorsBlockVisitor::visit(Grid3DPtr grid, Block3DPtr block) { if(!block) return; @@ -39,7 +39,7 @@ void D3Q27SetConnectorsBlockVisitor::visit(Grid3DPtr grid, Block3DPtr block) UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::visit() - end"); } ////////////////////////////////////////////////////////////////////////// -void D3Q27SetConnectorsBlockVisitor::setSameLevelConnectors(Grid3DPtr grid, Block3DPtr block) +void SetConnectorsBlockVisitor::setSameLevelConnectors(Grid3DPtr grid, Block3DPtr block) { UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::setSameLevelConnectors() - start"); int blockRank = block->getRank(); @@ -97,7 +97,7 @@ void D3Q27SetConnectorsBlockVisitor::setSameLevelConnectors(Grid3DPtr grid, Bloc UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::setSameLevelConnectors() - end"); } ////////////////////////////////////////////////////////////////////////// -void D3Q27SetConnectorsBlockVisitor::setRemoteConnectors(Block3DPtr sblock, Block3DPtr tblock, int dir, bool fullConnector) +void SetConnectorsBlockVisitor::setRemoteConnectors(Block3DPtr sblock, Block3DPtr tblock, int dir, bool fullConnector) { UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::setRemoteConnectors() - start"); CreateTransmittersHelper helper; @@ -111,7 +111,7 @@ void D3Q27SetConnectorsBlockVisitor::setRemoteConnectors(Block3DPtr sblock, Bloc UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::setRemoteConnectors() - end"); } ////////////////////////////////////////////////////////////////////////// -void D3Q27SetConnectorsBlockVisitor::setInterpolationConnectors(Grid3DPtr grid, Block3DPtr block) +void SetConnectorsBlockVisitor::setInterpolationConnectors(Grid3DPtr grid, Block3DPtr block) { UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::setInterpolationConnectors() - start"); int blockRank = block->getRank(); @@ -379,7 +379,7 @@ void D3Q27SetConnectorsBlockVisitor::setInterpolationConnectors(Grid3DPtr grid, UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::setInterpolationConnectors() - end"); } ////////////////////////////////////////////////////////////////////////// -void D3Q27SetConnectorsBlockVisitor::setInterpolationConnectors(Block3DPtr fBlockSW, Block3DPtr fBlockSE, Block3DPtr fBlockNW, Block3DPtr fBlockNE, Block3DPtr cBlock, int dir) +void SetConnectorsBlockVisitor::setInterpolationConnectors(Block3DPtr fBlockSW, Block3DPtr fBlockSE, Block3DPtr fBlockNW, Block3DPtr fBlockNE, Block3DPtr cBlock, int dir) { UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::setInterpolationConnectors(...) - start"); int fBlockSWRank = -999, fBlockSERank = -999, fBlockNWRank = -999, fBlockNERank = -999; @@ -397,11 +397,11 @@ void D3Q27SetConnectorsBlockVisitor::setInterpolationConnectors(Block3DPtr fBloc LBMReal omegaC = LBMSystem::calcCollisionFactor(nue, cBlock->getLevel()); iProcessor->setOmegas(omegaC, omegaF); - D3Q27InterpolationProcessorPtr cIProcessor(iProcessor->clone()); - D3Q27InterpolationProcessorPtr fIProcessorSW(iProcessor->clone()); - D3Q27InterpolationProcessorPtr fIProcessorSE(iProcessor->clone()); - D3Q27InterpolationProcessorPtr fIProcessorNW(iProcessor->clone()); - D3Q27InterpolationProcessorPtr fIProcessorNE(iProcessor->clone()); + InterpolationProcessorPtr cIProcessor(iProcessor->clone()); + InterpolationProcessorPtr fIProcessorSW(iProcessor->clone()); + InterpolationProcessorPtr fIProcessorSE(iProcessor->clone()); + InterpolationProcessorPtr fIProcessorNW(iProcessor->clone()); + InterpolationProcessorPtr fIProcessorNE(iProcessor->clone()); CreateTransmittersHelper::TransmitterPtr senderCFevenEvenSW, receiverCFevenEvenSW, senderCFevenOddNW, receiverCFevenOddNW, @@ -452,7 +452,7 @@ void D3Q27SetConnectorsBlockVisitor::setInterpolationConnectors(Block3DPtr fBloc UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::setInterpolationConnectors(...) - end"); } ////////////////////////////////////////////////////////////////////////// -void D3Q27SetConnectorsBlockVisitor::createTransmitters(Block3DPtr cBlock, Block3DPtr fBlock, int dir, +void SetConnectorsBlockVisitor::createTransmitters(Block3DPtr cBlock, Block3DPtr fBlock, int dir, CreateTransmittersHelper::IBlock ib, CreateTransmittersHelper::TransmitterPtr& senderCF, CreateTransmittersHelper::TransmitterPtr& receiverCF, diff --git a/source/VirtualFluidsCore/Visitors/D3Q27SetConnectorsBlockVisitor.h b/source/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.h similarity index 70% rename from source/VirtualFluidsCore/Visitors/D3Q27SetConnectorsBlockVisitor.h rename to source/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.h index fa9ccccff..9cf6b700b 100644 --- a/source/VirtualFluidsCore/Visitors/D3Q27SetConnectorsBlockVisitor.h +++ b/source/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.h @@ -1,17 +1,17 @@ -#ifndef D3Q27SETCONNECTORSBLOCKVISITOR_H -#define D3Q27SETCONNECTORSBLOCKVISITOR_H +#ifndef SETCONNECTORSBLOCKVISITOR_H +#define SETCONNECTORSBLOCKVISITOR_H #include "Block3DVisitor.h" #include "D3Q27System.h" #include "Communicator.h" -#include "D3Q27InterpolationProcessor.h" +#include "InterpolationProcessor.h" #include "CreateTransmittersHelper.h" -class D3Q27SetConnectorsBlockVisitor : public Block3DVisitor +class SetConnectorsBlockVisitor : public Block3DVisitor { public: - D3Q27SetConnectorsBlockVisitor(CommunicatorPtr comm, bool fullConnector, int dirs, LBMReal nue, D3Q27InterpolationProcessorPtr iProcessor); - virtual ~D3Q27SetConnectorsBlockVisitor(); + SetConnectorsBlockVisitor(CommunicatorPtr comm, bool fullConnector, int dirs, LBMReal nue, InterpolationProcessorPtr iProcessor); + virtual ~SetConnectorsBlockVisitor(); void visit(Grid3DPtr grid, Block3DPtr block); ////////////////////////////////////////////////////////////////////////// protected: @@ -30,7 +30,7 @@ protected: int dirs; int gridRank; LBMReal nue; - D3Q27InterpolationProcessorPtr iProcessor; + InterpolationProcessorPtr iProcessor; }; #endif //D3Q27SETCONNECTORSVISITOR_H diff --git a/source/VirtualFluidsCore/Visitors/SetForcingBlockVisitor.h b/source/VirtualFluidsCore/Visitors/SetForcingBlockVisitor.h index 46f7f76c2..b269b7aaf 100644 --- a/source/VirtualFluidsCore/Visitors/SetForcingBlockVisitor.h +++ b/source/VirtualFluidsCore/Visitors/SetForcingBlockVisitor.h @@ -2,7 +2,7 @@ #define SetForcingBlockVisitor_h #include "Block3DVisitor.h" -#include "LBMKernel3D.h" +#include "LBMKernel.h" //! \brief Set forcing for all kernels of grid //! \details This visitor is useful if you need to set or reset forcing in kernels (e.g. after restart because forcing is not serializable). diff --git a/source/VirtualFluidsCore/Visitors/SetInterpolationDirsBlockVisitor.h b/source/VirtualFluidsCore/Visitors/SetInterpolationDirsBlockVisitor.h index 84a23dcef..820ce1769 100644 --- a/source/VirtualFluidsCore/Visitors/SetInterpolationDirsBlockVisitor.h +++ b/source/VirtualFluidsCore/Visitors/SetInterpolationDirsBlockVisitor.h @@ -2,7 +2,7 @@ #define SetInterpolationDirsBlockVisitor_h #include "Block3DVisitor.h" -#include "LBMKernel3D.h" +#include "LBMKernel.h" class SetInterpolationDirsBlockVisitor : public Block3DVisitor diff --git a/source/VirtualFluidsCore/Visitors/SetKernelBlockVisitor.cpp b/source/VirtualFluidsCore/Visitors/SetKernelBlockVisitor.cpp index 608b14e36..598ec67e1 100644 --- a/source/VirtualFluidsCore/Visitors/SetKernelBlockVisitor.cpp +++ b/source/VirtualFluidsCore/Visitors/SetKernelBlockVisitor.cpp @@ -17,7 +17,7 @@ // } //} ////////////////////////////////////////////////////////////////////////// -SetKernelBlockVisitor::SetKernelBlockVisitor(LBMKernel3DPtr kernel, LBMReal nue, double availMem, double needMem, SetKernelBlockVisitor::Action action /*= SetKernelBlockVisitor::New*/) : +SetKernelBlockVisitor::SetKernelBlockVisitor(LBMKernelPtr kernel, LBMReal nue, double availMem, double needMem, SetKernelBlockVisitor::Action action /*= SetKernelBlockVisitor::New*/) : Block3DVisitor(0, Grid3DSystem::MAXLEVEL), kernel(kernel), nue(nue), action(action), dataSetFlag(true) { if (needMem > availMem) @@ -35,14 +35,14 @@ void SetKernelBlockVisitor::visit(Grid3DPtr grid, Block3DPtr block) kernel->setIndex(block->getX1(), block->getX2(), block->getX3()); kernel->setDeltaT(LBMSystem::getDeltaT(block->getLevel())); kernel->setBlock(block); - LBMKernel3DPtr newKernel = kernel->clone(); + LBMKernelPtr newKernel = kernel->clone(); switch (action) { - case SetKernelBlockVisitor::New: + case SetKernelBlockVisitor::NewKernel: block->setKernel(newKernel); break; - case SetKernelBlockVisitor::Change: + case SetKernelBlockVisitor::ChangeKernel: { DataSet3DPtr dataSet = block->getKernel()->getDataSet(); if (!dataSet) @@ -62,7 +62,7 @@ void SetKernelBlockVisitor::visit(Grid3DPtr grid, Block3DPtr block) } break; - case SetKernelBlockVisitor::ChangeBC: + case SetKernelBlockVisitor::ChangeKernelWithData: { BCProcessorPtr bcProc = block->getKernel()->getBCProcessor(); if (!bcProc) diff --git a/source/VirtualFluidsCore/Visitors/SetKernelBlockVisitor.h b/source/VirtualFluidsCore/Visitors/SetKernelBlockVisitor.h index d2bdff5fd..cb3921b39 100644 --- a/source/VirtualFluidsCore/Visitors/SetKernelBlockVisitor.h +++ b/source/VirtualFluidsCore/Visitors/SetKernelBlockVisitor.h @@ -2,19 +2,19 @@ #define SetKernelBlockVisitor_h #include "Block3DVisitor.h" -#include "LBMKernel3D.h" +#include "LBMKernel.h" class SetKernelBlockVisitor : public Block3DVisitor { public: - enum Action { New, Change, ChangeBC}; + enum Action { NewKernel, ChangeKernel, ChangeKernelWithData}; public: //SetKernelBlockVisitor(LBMKernel3DPtr kernel, LBMReal nue); //SetKernelBlockVisitor(LBMKernel3DPtr kernel, LBMReal nue, double availMem, double needMem); - SetKernelBlockVisitor(LBMKernel3DPtr kernel, LBMReal nue, double availMem, double needMem, SetKernelBlockVisitor::Action action = SetKernelBlockVisitor::New); + SetKernelBlockVisitor(LBMKernelPtr kernel, LBMReal nue, double availMem, double needMem, SetKernelBlockVisitor::Action action = SetKernelBlockVisitor::NewKernel); virtual ~SetKernelBlockVisitor() {} @@ -23,7 +23,7 @@ public: void setNoDataSetFlag(bool flag); private: - LBMKernel3DPtr kernel; + LBMKernelPtr kernel; LBMReal nue; Action action; bool dataSetFlag; diff --git a/source/VirtualFluidsCore/Visitors/SetSpongeLayerBlockVisitor.h b/source/VirtualFluidsCore/Visitors/SetSpongeLayerBlockVisitor.h index a7f802707..baf3ff782 100644 --- a/source/VirtualFluidsCore/Visitors/SetSpongeLayerBlockVisitor.h +++ b/source/VirtualFluidsCore/Visitors/SetSpongeLayerBlockVisitor.h @@ -2,7 +2,7 @@ #define SetSpongeLayerBlockVisitor_h__ #include "Block3DVisitor.h" -#include "LBMKernel3D.h" +#include "LBMKernel.h" //! \brief Set sponge layer for all kernels of grid //! \details This visitor is useful if you need to set or reset sponge layer in kernels (e.g. after restart because sponge layer is not serializable). diff --git a/source/VirtualFluidsCore/Visitors/D3Q27SetUndefinedNodesBlockVisitor.cpp b/source/VirtualFluidsCore/Visitors/SetUndefinedNodesBlockVisitor.cpp similarity index 94% rename from source/VirtualFluidsCore/Visitors/D3Q27SetUndefinedNodesBlockVisitor.cpp rename to source/VirtualFluidsCore/Visitors/SetUndefinedNodesBlockVisitor.cpp index e2e7039d8..47e8c3a1b 100644 --- a/source/VirtualFluidsCore/Visitors/D3Q27SetUndefinedNodesBlockVisitor.cpp +++ b/source/VirtualFluidsCore/Visitors/SetUndefinedNodesBlockVisitor.cpp @@ -1,23 +1,23 @@ -#include "D3Q27SetUndefinedNodesBlockVisitor.h" +#include "SetUndefinedNodesBlockVisitor.h" #include "BCArray3D.h" -#include "D3Q27BoundaryCondition.h" -#include "D3Q27ETBCProcessor.h" +#include "BoundaryConditions.h" +#include "BCProcessor.h" #include "Grid3DSystem.h" #include "D3Q27System.h" #include <boost/pointer_cast.hpp> -D3Q27SetUndefinedNodesBlockVisitor::D3Q27SetUndefinedNodesBlockVisitor() : +SetUndefinedNodesBlockVisitor::SetUndefinedNodesBlockVisitor() : Block3DVisitor(0, Grid3DSystem::MAXLEVEL) { } ////////////////////////////////////////////////////////////////////////// -void D3Q27SetUndefinedNodesBlockVisitor::visit(Grid3DPtr grid, Block3DPtr block) +void SetUndefinedNodesBlockVisitor::visit(Grid3DPtr grid, Block3DPtr block) { if(!block->hasInterpolationFlag()) return; - LBMKernel3DPtr kernel = block->getKernel(); + LBMKernelPtr kernel = block->getKernel(); if(!kernel && (block->getRank() != grid->getRank())) return; @@ -25,7 +25,7 @@ void D3Q27SetUndefinedNodesBlockVisitor::visit(Grid3DPtr grid, Block3DPtr block) //int gl = kernel->getGhostLayerWidth(); int gl = 0; - BCArray3D<D3Q27BoundaryCondition>& bcMatrix = boost::dynamic_pointer_cast<D3Q27ETBCProcessor>(kernel->getBCProcessor())->getBCArray(); + BCArray3D& bcMatrix = kernel->getBCProcessor()->getBCArray(); int minX1 = gl; int minX2 = gl; @@ -664,7 +664,7 @@ void D3Q27SetUndefinedNodesBlockVisitor::visit(Grid3DPtr grid, Block3DPtr block) } ////////////////////////////////////////////////////////////////////////// -void D3Q27SetUndefinedNodesBlockVisitor::setNodesUndefined( int startix1, int endix1, int startix2, int endix2, int startix3, int endix3, BCArray3D<D3Q27BoundaryCondition>& bcMatrix ) +void SetUndefinedNodesBlockVisitor::setNodesUndefined( int startix1, int endix1, int startix2, int endix2, int startix3, int endix3, BCArray3D& bcMatrix ) { for (int ix3=startix3; ix3<=endix3; ix3++) for (int ix2=startix2; ix2<=endix2; ix2++) diff --git a/source/VirtualFluidsCore/Visitors/SetUndefinedNodesBlockVisitor.h b/source/VirtualFluidsCore/Visitors/SetUndefinedNodesBlockVisitor.h new file mode 100644 index 000000000..c01217a8d --- /dev/null +++ b/source/VirtualFluidsCore/Visitors/SetUndefinedNodesBlockVisitor.h @@ -0,0 +1,22 @@ +#ifndef SetUndefinedNodesBlockVisitor_h +#define SetUndefinedNodesBlockVisitor_h + +#include "Block3DVisitor.h" +#include "LBMKernel.h" +#include "BCArray3D.h" +#include "BoundaryConditions.h" +#include "BCProcessor.h" + +class SetUndefinedNodesBlockVisitor : public Block3DVisitor +{ +public: + SetUndefinedNodesBlockVisitor(); + + virtual ~SetUndefinedNodesBlockVisitor() {} + + void visit(Grid3DPtr grid, Block3DPtr block); + +private: + void setNodesUndefined( int startix1, int endix1, int startix2, int endix2, int startix3, int endix3, BCArray3D& bcMatix ); +}; +#endif diff --git a/source/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.cpp b/source/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.cpp index 060bd6e0a..10170f8cb 100644 --- a/source/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.cpp +++ b/source/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.cpp @@ -42,7 +42,7 @@ void SpongeLayerBlockVisitor::visit( Grid3DPtr grid, Block3DPtr block ) if (boundingBox->isCellInsideGbObject3D(minX1,minX2,minX3,maxX1,maxX2,maxX3)) { - LBMKernel3DPtr kernel = block->getKernel(); + LBMKernelPtr kernel = block->getKernel(); kernel->setCollisionFactor(kernel->getCollisionFactor()*0.5); } } diff --git a/source/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.h b/source/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.h index 29039cb03..fc7c6d328 100644 --- a/source/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.h +++ b/source/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.h @@ -2,7 +2,7 @@ #define SpongeLayerBlockVisitor_h__ #include "Block3DVisitor.h" -#include "LBMKernel3D.h" +#include "LBMKernel.h" #include <numerics/geometry3d/GbCuboid3D.h> //! \brief Set sponge layer for all kernels of grid diff --git a/source/VirtualFluidsCore/Visitors/ViscosityBlockVisitor.h b/source/VirtualFluidsCore/Visitors/ViscosityBlockVisitor.h index ab485c83a..d5e87fe74 100644 --- a/source/VirtualFluidsCore/Visitors/ViscosityBlockVisitor.h +++ b/source/VirtualFluidsCore/Visitors/ViscosityBlockVisitor.h @@ -2,7 +2,7 @@ #define ViscosityBlockVisitor_h #include "Block3DVisitor.h" -#include "LBMKernel3D.h" +#include "LBMKernel.h" class ViscosityBlockVisitor : public Block3DVisitor -- GitLab