From 3c290498a2759ed9c5bec65b6231b5d4776f868b Mon Sep 17 00:00:00 2001 From: Soeren Peters <peters@irmb.tu-bs.de> Date: Wed, 19 Aug 2020 14:29:51 +0200 Subject: [PATCH] Moved VirtualFludis Open Source to the new cmake structure. --- CMakeLists.txt | 4 +- cpu.cmake | 155 +- .../geometry3d/CoordinateTransformation3D.cpp | 54 +- .../geometry3d/CoordinateTransformation3D.h | 143 +- src/basics/geometry3d/GbCuboid3D.cpp | 138 +- src/basics/geometry3d/GbCuboid3D.h | 65 +- src/basics/geometry3d/GbCylinder3D.cpp | 1262 -------- src/basics/geometry3d/GbCylinder3D.h | 153 - src/basics/geometry3d/GbHalfSpace3D.cpp | 99 - src/basics/geometry3d/GbHalfSpace3D.h | 84 - .../geometry3d/GbHalfSpaceKrischan3D.cpp | 267 -- src/basics/geometry3d/GbHalfSpaceKrischan3D.h | 205 -- src/basics/geometry3d/GbLine3D.cpp | 66 +- src/basics/geometry3d/GbLine3D.h | 83 +- src/basics/geometry3d/GbMeshTools3D.h | 402 --- src/basics/geometry3d/GbObject3D.cpp | 41 +- src/basics/geometry3d/GbObject3D.h | 99 +- src/basics/geometry3d/GbObject3DManager.cpp | 285 -- src/basics/geometry3d/GbObject3DManager.h | 119 - src/basics/geometry3d/GbObjectGroup3D.cpp | 146 - src/basics/geometry3d/GbObjectGroup3D.h | 159 - src/basics/geometry3d/GbPoint3D.cpp | 64 +- src/basics/geometry3d/GbPoint3D.h | 77 +- src/basics/geometry3d/GbPolygon3D.cpp | 398 +-- src/basics/geometry3d/GbPolygon3D.h | 326 +- src/basics/geometry3d/GbQuadFaceMesh3D.cpp | 362 --- src/basics/geometry3d/GbQuadFaceMesh3D.h | 123 - src/basics/geometry3d/GbSphere3D.cpp | 922 ------ src/basics/geometry3d/GbSphere3D.h | 164 - src/basics/geometry3d/GbSystem3D.cpp | 45 +- src/basics/geometry3d/GbSystem3D.h | 40 +- src/basics/geometry3d/GbTriFaceMesh3D.cpp | 1257 -------- src/basics/geometry3d/GbTriFaceMesh3D.h | 385 --- src/basics/geometry3d/GbTriangle3D.cpp | 173 +- src/basics/geometry3d/GbTriangle3D.h | 113 +- src/basics/geometry3d/GbTriangularMesh3D.cpp | 1535 ---------- src/basics/geometry3d/GbTriangularMesh3D.h | 179 -- src/basics/geometry3d/GbVector3D.cpp | 38 +- src/basics/geometry3d/GbVector3D.h | 52 +- src/basics/geometry3d/GbVoxelMatrix3D.cpp | 1109 ------- src/basics/geometry3d/GbVoxelMatrix3D.h | 341 --- src/basics/geometry3d/KdTree/KdNode.h | 284 -- src/basics/geometry3d/KdTree/KdRay.h | 69 - .../geometry3d/KdTree/KdSplitCandidate.h | 68 - .../KdTree/KdSplitCandidateManager.h | 75 - src/basics/geometry3d/KdTree/KdTree.h | 100 - src/basics/geometry3d/KdTree/KdUtilities.cpp | 13 - src/basics/geometry3d/KdTree/KdUtilities.h | 164 - .../examples/AdvancedPIOTests/CMakeLists.txt | 39 - .../KdTree/examples/AdvancedPIOTests/main.cpp | 542 ---- .../KdTree/examples/PIOTests/CMakeLists.txt | 36 - .../KdTree/examples/PIOTests/main.cpp | 342 --- .../KdCountLineIntersectionHandler.h | 56 - .../KdCountRayIntersectionHandler.h | 164 - .../KdLineIntersectionHandler.h | 30 - .../KdRayIntersectionHandler.h | 20 - src/basics/geometry3d/KdTree/package.include | 0 .../KdTree/splitalgorithms/KdSAHSplit.cpp | 10 - .../KdTree/splitalgorithms/KdSAHSplit.h | 287 -- .../splitalgorithms/KdSpatiallMedianSplit.h | 90 - .../KdTree/splitalgorithms/KdSplitAlgorithm.h | 26 - .../geometry3d/creator/GbCuboid3DCreator.h | 77 - .../geometry3d/creator/GbCylinder3DCreator.h | 81 - .../geometry3d/creator/GbLine3DCreator.h | 31 - .../geometry3d/creator/GbObject3DCreator.h | 77 - .../geometry3d/creator/GbObject3DFactory.cpp | 97 - .../geometry3d/creator/GbObject3DFactory.h | 43 - .../geometry3d/creator/GbPoint3DCreator.h | 31 - .../geometry3d/creator/GbPolygon3DCreator.h | 32 - .../creator/GbQuadFaceMesh3DCreator.cpp | 66 - .../creator/GbQuadFaceMesh3DCreator.h | 52 - .../geometry3d/creator/GbSphere3DCreator.h | 126 - .../creator/GbTriFaceMesh3DCreator.cpp | 431 --- .../creator/GbTriFaceMesh3DCreator.h | 85 - .../geometry3d/creator/GbTriangle3DCreator.h | 31 - .../creator/GbTriangularMesh3DCreator.cpp | 258 -- .../creator/GbTriangularMesh3DCreator.h | 83 - .../creator/GbVoxelMatrix3DCreator.cpp | 84 - .../creator/GbVoxelMatrix3DCreator.h | 81 - src/basics/geometry3d/creator/package.include | 0 .../insideOutsideTests/CMakeLists.txt | 61 - .../examples/insideOutsideTests/main.cpp | 46 - .../examples/stl2inp/CMakeLists.txt | 140 - .../examples/stl2inp/QDefineUniformMesh.cpp | 17 - .../examples/stl2inp/QDefineUniformMesh.h | 35 - .../examples/stl2inp/QDefineUniformMesh.ui | 258 -- .../geometry3d/examples/stl2inp/main.cpp | 15 - .../geometry3d/examples/stl2inp/stl2inp.cpp | 261 -- .../geometry3d/examples/stl2inp/stl2inp.h | 36 - .../geometry3d/examples/stl2inp/stl2inp.ui | 452 --- .../geometry3d/fem/FeAdhocTriFaceMesh3D.cpp | 124 - .../geometry3d/fem/FeAdhocTriFaceMesh3D.h | 62 - src/basics/geometry3d/fem/FeHalfDisc3D.cpp | 622 ---- src/basics/geometry3d/fem/FeHalfDisc3D.h | 104 - .../fem/FePlateTriangularMesh3D.cpp | 223 -- .../geometry3d/fem/FePlateTriangularMesh3D.h | 50 - src/basics/geometry3d/fem/FePoint3D.h | 148 - src/basics/geometry3d/fem/FeRing3D.cpp | 468 --- src/basics/geometry3d/fem/FeRing3D.h | 107 - src/basics/geometry3d/fem/FeTriFaceMesh3D.cpp | 256 -- src/basics/geometry3d/fem/FeTriFaceMesh3D.h | 204 -- .../fem/creator/FeTriFaceMesh3DCreator.cpp | 417 --- .../fem/creator/FeTriFaceMesh3DCreator.h | 82 - src/basics/geometry3d/package.include | 0 .../presentation/QGbCuboid3DInstrument.cpp | 67 - .../presentation/QGbCuboid3DInstrument.h | 31 - .../presentation/QGbCuboid3DInstrument.ui | 347 --- .../presentation/QGbCylinder3DInstrument.cpp | 102 - .../presentation/QGbCylinder3DInstrument.h | 35 - .../presentation/QGbCylinder3DInstrument.ui | 682 ----- .../presentation/QGbObject3DInstrument.cpp | 66 - .../presentation/QGbObject3DInstrument.h | 30 - .../presentation/QGbObject3DInstrument.ui | 512 ---- .../presentation/QGbSphere3DInstrument.cpp | 60 - .../presentation/QGbSphere3DInstrument.h | 36 - .../presentation/QGbSphere3DInstrument.ui | 303 -- .../presentation/QVTKGbObject3DViewer.cpp | 35 - .../presentation/QVTKGbObject3DViewer.h | 22 - .../geometry3d/presentation/vtkGbCuboid3D.cpp | 144 - .../geometry3d/presentation/vtkGbCuboid3D.h | 29 - .../presentation/vtkGbCylinder3D.cpp | 103 - .../geometry3d/presentation/vtkGbCylinder3D.h | 30 - .../geometry3d/presentation/vtkGbSphere3D.cpp | 112 - .../geometry3d/presentation/vtkGbSphere3D.h | 33 - .../presentation/vtkGbTriangularMesh3D.cpp | 167 - .../presentation/vtkGbTriangularMesh3D.h | 31 - src/cpu/DemCoupling/CMakePackage.txt | 2 - .../CreateDemObjectsCoProcessor.cpp | 119 - .../DemCoupling/CreateDemObjectsCoProcessor.h | 52 - src/cpu/DemCoupling/DemCoProcessor.cpp | 516 ---- src/cpu/DemCoupling/DemCoProcessor.h | 90 - src/cpu/DemCoupling/DemCoupling.cmake | 31 - src/cpu/DemCoupling/IncludsList.cmake | 8 - .../DemCoupling/MovableObjectInteractor.cpp | 260 -- src/cpu/DemCoupling/MovableObjectInteractor.h | 58 - .../DemCoupling/PePartitioningGridVisitor.cpp | 156 - .../DemCoupling/PePartitioningGridVisitor.h | 56 - .../RestartDemObjectsCoProcessor.cpp | 119 - .../RestartDemObjectsCoProcessor.h | 38 - .../WriteDemObjectsCoProcessor.cpp | 74 - .../DemCoupling/WriteDemObjectsCoProcessor.h | 34 - .../DemCoupling/WritePeBlocksCoProcessor.cpp | 88 - .../DemCoupling/WritePeBlocksCoProcessor.h | 43 - src/cpu/DemCoupling/package.include | 1 - .../physicsEngineAdapter/CMakePackage.txt | 2 - .../PhysicsEngineGeometryAdapter.h | 45 - .../PhysicsEngineMaterialAdapter.h | 33 - .../PhysicsEngineSolverAdapter.h | 26 - .../dummy/CMakePackage.txt | 2 - .../DummyPhysicsEngineGeometryAdapter.cpp | 79 - .../dummy/DummyPhysicsEngineGeometryAdapter.h | 45 - .../DummyPhysicsEngineMaterialAdapter.cpp | 1 - .../dummy/DummyPhysicsEngineMaterialAdapter.h | 23 - .../dummy/DummyPhysicsEngineSolverAdapter.cpp | 14 - .../dummy/DummyPhysicsEngineSolverAdapter.h | 28 - .../dummy/package.include | 0 .../physicsEngineAdapter/package.include | 0 .../physicsEngineAdapter/pe/CMakePackage.txt | 2 - .../physicsEngineAdapter/pe/PeAdapter.h | 28 - .../physicsEngineAdapter/pe/PeAdapterTest.cpp | 28 - .../pe/PeLoadBalancerAdapter.cpp | 48 - .../pe/PeLoadBalancerAdapter.h | 25 - .../pe/PePhysicsEngineGeometryAdapter.cpp | 131 - .../pe/PePhysicsEngineGeometryAdapter.h | 75 - .../pe/PePhysicsEngineMaterialAdapter.cpp | 10 - .../pe/PePhysicsEngineMaterialAdapter.h | 26 - .../pe/PePhysicsEngineSolverAdapter.cpp | 225 -- .../pe/PePhysicsEngineSolverAdapter.h | 103 - .../physicsEngineAdapter/pe/package.include | 0 .../reconstructor/CMakePackage.txt | 2 - .../EquilibriumReconstructor.cpp | 56 - .../reconstructor/EquilibriumReconstructor.h | 29 - .../ExtrapolationReconstructor.cpp | 120 - .../ExtrapolationReconstructor.h | 42 - .../reconstructor/LBMReconstructor.cpp | 149 - .../reconstructor/LBMReconstructor.h | 37 - .../DemCoupling/reconstructor/Reconstructor.h | 27 - .../reconstructor/VelocityBcReconstructor.cpp | 102 - .../reconstructor/VelocityBcReconstructor.h | 27 - .../DemCoupling/reconstructor/package.include | 0 .../BoundaryConditions/BCAdapter.h | 177 +- .../BoundaryConditions/BCAlgorithm.cpp | 33 + .../BoundaryConditions/BCAlgorithm.h | 34 + .../BoundaryConditions/BCArray3D.cpp | 436 +-- .../BoundaryConditions/BCArray3D.h | 35 +- .../BoundaryConditions/BCFunction.cpp | 43 +- .../BoundaryConditions/BCFunction.h | 199 +- .../BoundaryConditions/BCProcessor.cpp | 35 +- .../BoundaryConditions/BCProcessor.h | 102 +- .../BoundaryConditions/BoundaryConditions.cpp | 41 +- .../BoundaryConditions/BoundaryConditions.h | 212 +- .../BoundaryConditions/CMakePackage.txt | 2 +- .../BoundaryConditions/DensityBCAdapter.cpp | 157 - .../BoundaryConditions/DensityBCAdapter.h | 75 - .../EqDensityBCAlgorithm.cpp | 60 - .../BoundaryConditions/EqDensityBCAlgorithm.h | 18 - .../HighViscosityNoSlipBCAlgorithm.cpp | 47 - .../HighViscosityNoSlipBCAlgorithm.h | 19 - .../BoundaryConditions/NoSlipBCAdapter.cpp | 34 +- .../BoundaryConditions/NoSlipBCAdapter.h | 115 +- .../BoundaryConditions/NoSlipBCAlgorithm.cpp | 33 + .../BoundaryConditions/NoSlipBCAlgorithm.h | 36 +- .../NonEqDensityBCAlgorithm.cpp | 66 - .../NonEqDensityBCAlgorithm.h | 18 - .../NonReflectingOutflowBCAlgorithm.cpp | 187 -- .../NonReflectingOutflowBCAlgorithm.h | 18 - .../BoundaryConditions/SlipBCAdapter.cpp | 35 - .../BoundaryConditions/SlipBCAdapter.h | 89 - .../BoundaryConditions/SlipBCAlgorithm.cpp | 88 - .../BoundaryConditions/SlipBCAlgorithm.h | 18 - .../ThinWallBCProcessor.cpp | 43 - .../BoundaryConditions/ThinWallBCProcessor.h | 23 - .../ThinWallNoSlipBCAlgorithm.cpp | 66 - .../ThinWallNoSlipBCAlgorithm.h | 25 - .../BoundaryConditions/VelocityBCAdapter.cpp | 645 ++-- .../BoundaryConditions/VelocityBCAdapter.h | 313 +- .../VelocityBCAlgorithm.cpp | 37 +- .../BoundaryConditions/VelocityBCAlgorithm.h | 40 +- .../VelocityWithDensityBCAlgorithm.cpp | 84 - .../VelocityWithDensityBCAlgorithm.h | 24 - src/cpu/VirtualFluidsCore/CMakeLists.txt | 88 +- .../CoProcessors/AdjustForcingCoProcessor.cpp | 172 -- .../CoProcessors/AdjustForcingCoProcessor.h | 58 - .../CoProcessors/AverageValuesCoProcessor.cpp | 573 ---- .../CoProcessors/AverageValuesCoProcessor.h | 74 - .../CoProcessors/CMakePackage.txt | 4 +- .../CalculateForcesCoProcessor.cpp | 243 -- .../CoProcessors/CalculateForcesCoProcessor.h | 58 - .../CoProcessors/CoProcessor.cpp | 33 + .../CoProcessors/CoProcessor.h | 45 + .../DecreaseViscosityCoProcessor.cpp | 83 - .../DecreaseViscosityCoProcessor.h | 48 - .../CoProcessors/EmergencyExitCoProcessor.cpp | 75 - .../CoProcessors/EmergencyExitCoProcessor.h | 43 - .../CoProcessors/ForceCalculator.cpp | 145 - .../CoProcessors/ForceCalculator.h | 43 - .../InSituCatalystCoProcessor.cpp | 349 --- .../CoProcessors/InSituCatalystCoProcessor.h | 54 - .../CoProcessors/InSituVTKCoProcessor.cpp | 304 -- .../CoProcessors/InSituVTKCoProcessor.h | 52 - .../CoProcessors/IntegrateValuesHelper.cpp | 305 -- .../CoProcessors/IntegrateValuesHelper.h | 89 - .../LineTimeSeriesCoProcessor.cpp | 247 -- .../CoProcessors/LineTimeSeriesCoProcessor.h | 58 - .../CoProcessors/MPIIOCoProcessor.cpp | 411 --- .../CoProcessors/MPIIOCoProcessor.h | 38 - .../MPIIOMigrationBECoProcessor.cpp | 2619 ---------------- .../MPIIOMigrationBECoProcessor.h | 84 - .../MPIIOMigrationCoProcessor.cpp | 2168 ------------- .../CoProcessors/MPIIOMigrationCoProcessor.h | 78 - .../CoProcessors/MPIIORestartCoProcessor.cpp | 2720 ----------------- .../CoProcessors/MPIIORestartCoProcessor.h | 80 - .../MicrophoneArrayCoProcessor.cpp | 126 - .../CoProcessors/MicrophoneArrayCoProcessor.h | 57 - .../CoProcessors/NUPSCounterCoProcessor.cpp | 171 +- .../CoProcessors/NUPSCounterCoProcessor.h | 119 +- .../PressureCoefficientCoProcessor.cpp | 223 -- .../PressureCoefficientCoProcessor.h | 55 - .../PressureDifferenceCoProcessor.cpp | 102 - .../PressureDifferenceCoProcessor.h | 44 - .../CoProcessors/QCriterionCoProcessor.cpp | 389 --- .../CoProcessors/QCriterionCoProcessor.h | 66 - .../CoProcessors/ShearStressCoProcessor.cpp | 702 ----- .../CoProcessors/ShearStressCoProcessor.h | 69 - .../TimeAveragedValuesCoProcessor.cpp | 1001 ------ .../TimeAveragedValuesCoProcessor.h | 123 - .../TimeDependentBCCoProcessor.cpp | 34 - .../CoProcessors/TimeDependentBCCoProcessor.h | 31 - .../CoProcessors/TimeseriesCoProcessor.cpp | 87 - .../CoProcessors/TimeseriesCoProcessor.h | 48 - .../TurbulenceIntensityCoProcessor.cpp | 268 -- .../TurbulenceIntensityCoProcessor.h | 43 - .../CoProcessors/WriteBlocksCoProcessor.cpp | 339 +- .../CoProcessors/WriteBlocksCoProcessor.h | 113 +- .../WriteBoundaryConditionsCoProcessor.cpp | 82 +- .../WriteBoundaryConditionsCoProcessor.h | 135 +- .../WriteGbObjectsCoProcessor.cpp | 82 - .../CoProcessors/WriteGbObjectsCoProcessor.h | 38 - .../WriteMQFromSelectionCoProcessor.cpp | 237 -- .../WriteMQFromSelectionCoProcessor.h | 57 - .../WriteMacroscopicQuantitiesCoProcessor.cpp | 101 +- .../WriteMacroscopicQuantitiesCoProcessor.h | 157 +- .../Connectors/Block3DConnector.h | 181 +- .../Connectors/Block3DConnectorFactory.cpp | 50 - .../Connectors/Block3DConnectorFactory.h | 39 - .../Connectors/CMakePackage.txt | 2 +- .../CoarseToFineBlock3DConnector.cpp | 135 - .../Connectors/CoarseToFineBlock3DConnector.h | 105 - .../CoarseToFineNodeSetBlock3DConnector.cpp | 1384 --------- .../CoarseToFineNodeSetBlock3DConnector.h | 103 - .../Connectors/ConnectorFactory.h | 38 - .../D3Q27ETCFOffVectorConnector.cpp | 1 - .../Connectors/D3Q27ETCFOffVectorConnector.h | 1940 ------------ .../D3Q27ETFCOffVectorConnector.cpp | 3 - .../Connectors/D3Q27ETFCOffVectorConnector.h | 1437 --------- .../Connectors/D3Q27ETFullDirectConnector.cpp | 453 +-- .../Connectors/D3Q27ETFullDirectConnector.h | 190 +- .../Connectors/D3Q27ETFullVectorConnector.cpp | 468 --- .../Connectors/D3Q27ETFullVectorConnector.h | 118 - .../Connectors/D3Q27ETOffConnectorFactory.cpp | 38 - .../Connectors/D3Q27ETOffConnectorFactory.h | 34 - .../FineToCoarseBlock3DConnector.cpp | 77 - .../Connectors/FineToCoarseBlock3DConnector.h | 95 - .../FineToCoarseNodeSetBlock3DConnector.cpp | 1235 -------- .../FineToCoarseNodeSetBlock3DConnector.h | 78 - .../Connectors/LocalBlock3DConnector.h | 132 +- .../Connectors/RemoteBlock3DConnector.cpp | 64 - .../Connectors/RemoteBlock3DConnector.h | 72 - .../Connectors/TransmitterType.h | 16 - .../VirtualFluidsCore/Data/CMakePackage.txt | 4 +- .../Data/D3Q27EsoTwist3DSoA.cpp | 594 ---- .../Data/D3Q27EsoTwist3DSoA.h | 91 - .../Data/D3Q27EsoTwist3DSplittedVector.cpp | 1339 ++++---- .../Data/D3Q27EsoTwist3DSplittedVector.h | 41 +- .../Data/D3Q27EsoTwist3DSplittedVectorEx.cpp | 13 - .../Data/D3Q27EsoTwist3DSplittedVectorEx.h | 15 - src/cpu/VirtualFluidsCore/Data/DataSet3D.h | 304 +- .../Data/DistributionArray3D.h | 122 +- src/cpu/VirtualFluidsCore/Data/EsoTwist3D.h | 134 +- .../Data/EsoTwistD3Q27System.cpp | 217 +- .../Data/EsoTwistD3Q27System.h | 250 +- src/cpu/VirtualFluidsCore/Data/VoidData3D.h | 37 - .../Grid/BasicCalculator.cpp | 799 ++--- .../VirtualFluidsCore/Grid/BasicCalculator.h | 36 +- src/cpu/VirtualFluidsCore/Grid/Block3D.cpp | 1038 ++++--- src/cpu/VirtualFluidsCore/Grid/Block3D.h | 36 +- .../VirtualFluidsCore/Grid/CMakePackage.txt | 4 +- src/cpu/VirtualFluidsCore/Grid/Calculator.cpp | 33 + src/cpu/VirtualFluidsCore/Grid/Calculator.h | 36 +- src/cpu/VirtualFluidsCore/Grid/Grid3D.cpp | 766 +++-- src/cpu/VirtualFluidsCore/Grid/Grid3D.h | 38 +- .../VirtualFluidsCore/Grid/Grid3DSystem.cpp | 129 +- src/cpu/VirtualFluidsCore/Grid/Grid3DSystem.h | 344 ++- src/cpu/VirtualFluidsCore/IncludsList.cmake | 17 - .../Interactors/CMakePackage.txt | 4 +- .../Interactors/D3Q27Interactor.cpp | 172 +- .../Interactors/D3Q27Interactor.h | 205 +- .../D3Q27TriFaceMeshInteractor.cpp | 1839 ----------- .../Interactors/D3Q27TriFaceMeshInteractor.h | 106 - .../Interactors/Interactor3D.cpp | 662 ++-- .../Interactors/Interactor3D.h | 263 +- .../Interactors/InteractorsHelper.cpp | 164 +- .../Interactors/InteractorsHelper.h | 104 +- .../Interactors/package.include | 0 .../VirtualFluidsCore/LBM/BGKLBMKernel.cpp | 299 -- src/cpu/VirtualFluidsCore/LBM/BGKLBMKernel.h | 36 - .../VirtualFluidsCore/LBM/CMakePackage.txt | 4 +- ...ibleCumulant4thOrderViscosityLBMKernel.cpp | 1075 ------- ...ssibleCumulant4thOrderViscosityLBMKernel.h | 51 - .../LBM/CompressibleCumulantLBMKernel.cpp | 1049 ------- .../LBM/CompressibleCumulantLBMKernel.h | 53 - ...mpressibleOffsetInterpolationProcessor.cpp | 722 ----- ...CompressibleOffsetInterpolationProcessor.h | 76 - ...bleOffsetMomentsInterpolationProcessor.cpp | 1289 -------- ...sibleOffsetMomentsInterpolationProcessor.h | 82 - ...etSquarePressureInterpolationProcessor.cpp | 1288 -------- ...fsetSquarePressureInterpolationProcessor.h | 81 - .../LBM/CumulantK17LBMKernel.cpp | 648 ++++ .../LBM/CumulantK17LBMKernel.h | 146 + src/cpu/VirtualFluidsCore/LBM/D3Q27System.cpp | 391 +-- src/cpu/VirtualFluidsCore/LBM/D3Q27System.h | 1372 ++++----- src/cpu/VirtualFluidsCore/LBM/ICell.h | 33 - src/cpu/VirtualFluidsCore/LBM/ILBMKernel.h | 36 +- .../LBM/IncompressibleCumulantLBMKernel.cpp | 902 ------ .../LBM/IncompressibleCumulantLBMKernel.h | 49 - ...ssibleCumulantWithSpongeLayerLBMKernel.cpp | 1011 ------ ...ressibleCumulantWithSpongeLayerLBMKernel.h | 42 - ...mpressibleOffsetInterpolationProcessor.cpp | 794 ----- ...compressibleOffsetInterpolationProcessor.h | 77 - .../LBM/InitDensityLBMKernel.cpp | 1071 ------- .../LBM/InitDensityLBMKernel.h | 31 - .../LBM/InterpolationHelper.cpp | 39 - .../LBM/InterpolationHelper.h | 25 - .../LBM/InterpolationProcessor.cpp | 313 -- .../LBM/InterpolationProcessor.h | 70 - src/cpu/VirtualFluidsCore/LBM/LBMKernel.cpp | 33 + src/cpu/VirtualFluidsCore/LBM/LBMKernel.h | 38 +- .../LBM/LBMKernelETD3Q27BGK.cpp | 299 -- .../LBM/LBMKernelETD3Q27BGK.h | 36 - src/cpu/VirtualFluidsCore/LBM/LBMSystem.cpp | 45 +- src/cpu/VirtualFluidsCore/LBM/LBMSystem.h | 189 +- .../VirtualFluidsCore/LBM/LBMUnitConverter.h | 386 ++- .../VirtualFluidsCore/LBM/VoidLBMKernel.cpp | 46 - src/cpu/VirtualFluidsCore/LBM/VoidLBMKernel.h | 18 - .../Parallel/BlocksDistributor.cpp | 7 - .../Parallel/BlocksDistributor.h | 23 - .../Parallel/CMakePackage.txt | 4 +- .../Parallel/Communicator.cpp | 57 +- .../VirtualFluidsCore/Parallel/Communicator.h | 118 +- .../Parallel/MPICommunicator.cpp | 245 -- .../Parallel/MPICommunicator.h | 190 -- .../Parallel/MPIIODataStructures.h | 181 -- .../Parallel/MetisPartitioner.cpp | 81 - .../Parallel/MetisPartitioner.h | 59 - .../Parallel/NullCommunicator.cpp | 149 +- .../Parallel/NullCommunicator.h | 90 +- .../Parallel/PriorityQueueDecompositor.cpp | 2 - .../Parallel/PriorityQueueDecompositor.h | 68 - .../Parallel/SimpleGeometricPartitioner.h | 97 - .../Parallel/ZoltanPartitioner.cpp | 204 -- .../Parallel/ZoltanPartitioner.h | 74 - .../VirtualFluidsCore/PointerDefinitions.h | 78 +- .../Utilities/CMakePackage.txt | 4 +- .../Utilities/ChangeRandomQs.hpp | 51 - .../Utilities/CheckpointConverter.cpp | 595 ---- .../Utilities/CheckpointConverter.h | 40 - .../Utilities/ConfigurationFile.hpp | 243 -- .../VirtualFluidsCore/Utilities/MathUtil.hpp | 97 - .../VirtualFluidsCore/Utilities/MemoryUtil.h | 63 +- .../Utilities/VoxelMatrixUtil.hpp | 59 - .../Visitors/Block3DVisitor.h | 146 +- .../BoundaryConditionsBlockVisitor.cpp | 34 +- .../Visitors/BoundaryConditionsBlockVisitor.h | 88 +- .../Visitors/CMakePackage.txt | 4 +- .../ChangeBoundaryDensityBlockVisitor.cpp | 62 - .../ChangeBoundaryDensityBlockVisitor.h | 24 - .../Visitors/CheckRatioBlockVisitor.cpp | 75 - .../Visitors/CheckRatioBlockVisitor.h | 33 - ...rsenCrossAndInsideGbObjectBlockVisitor.cpp | 41 - ...oarsenCrossAndInsideGbObjectBlockVisitor.h | 33 - .../Visitors/ConnectorBlockVisitor.cpp | 472 --- .../Visitors/ConnectorBlockVisitor.h | 41 - .../Visitors/CreateTransmittersHelper.cpp | 160 - .../Visitors/CreateTransmittersHelper.h | 38 - .../Visitors/GenBlocksGridVisitor.cpp | 35 +- .../Visitors/GenBlocksGridVisitor.h | 34 + .../Visitors/Grid3DVisitor.h | 70 +- .../InitDistributionsBlockVisitor.cpp | 35 +- .../Visitors/InitDistributionsBlockVisitor.h | 177 +- .../InitDistributionsFromFileBlockVisitor.cpp | 258 -- .../InitDistributionsFromFileBlockVisitor.h | 28 - ...tributionsWithInterpolationGridVisitor.cpp | 610 ---- ...istributionsWithInterpolationGridVisitor.h | 34 - .../Visitors/MetisPartitioningGridVisitor.cpp | 322 -- .../Visitors/MetisPartitioningGridVisitor.h | 68 - .../Visitors/OverlapBlockVisitor.cpp | 60 - .../Visitors/OverlapBlockVisitor.h | 31 - .../PQueuePartitioningGridVisitor.cpp | 54 - .../Visitors/PQueuePartitioningGridVisitor.h | 27 - .../Visitors/RatioBlockVisitor.cpp | 129 - .../Visitors/RatioBlockVisitor.h | 49 - .../Visitors/RatioSmoothBlockVisitor.cpp | 145 - .../Visitors/RatioSmoothBlockVisitor.h | 49 - .../Visitors/RefineAroundGbObjectHelper.cpp | 55 - .../Visitors/RefineAroundGbObjectHelper.h | 34 - ...fineCrossAndInsideGbObjectBlockVisitor.cpp | 43 - ...RefineCrossAndInsideGbObjectBlockVisitor.h | 33 - .../RefineCrossAndInsideGbObjectHelper.cpp | 78 - .../RefineCrossAndInsideGbObjectHelper.h | 36 - .../Visitors/RefineInterGbObjectsVisitor.cpp | 68 - .../Visitors/RefineInterGbObjectsVisitor.h | 27 - .../Visitors/RenumberBlockVisitor.cpp | 22 - .../Visitors/RenumberBlockVisitor.h | 32 - .../Visitors/RenumberGridVisitor.cpp | 49 - .../Visitors/RenumberGridVisitor.h | 33 - .../Visitors/SetBcBlocksBlockVisitor.cpp | 33 + .../Visitors/SetBcBlocksBlockVisitor.h | 34 + .../Visitors/SetConnectorsBlockVisitor.cpp | 595 +--- .../Visitors/SetConnectorsBlockVisitor.h | 107 +- .../Visitors/SetForcingBlockVisitor.cpp | 70 - .../Visitors/SetForcingBlockVisitor.h | 39 - .../SetInterpolationDirsBlockVisitor.cpp | 162 - .../SetInterpolationDirsBlockVisitor.h | 27 - .../Visitors/SetKernelBlockVisitor.cpp | 184 +- .../Visitors/SetKernelBlockVisitor.h | 102 +- .../Visitors/SetSolidBlocksBlockVisitor.cpp | 33 + .../Visitors/SetSolidBlocksBlockVisitor.h | 34 + .../Visitors/SetSpongeLayerBlockVisitor.cpp | 31 - .../Visitors/SetSpongeLayerBlockVisitor.h | 28 - .../SetUndefinedNodesBlockVisitor.cpp | 677 ---- .../Visitors/SetUndefinedNodesBlockVisitor.h | 26 - .../Visitors/SpongeLayerBlockVisitor.cpp | 123 - .../Visitors/SpongeLayerBlockVisitor.h | 30 - .../Visitors/ViscosityBlockVisitor.cpp | 22 - .../Visitors/ViscosityBlockVisitor.h | 25 - .../ZoltanPartitioningGridVisitor.cpp | 148 - .../Visitors/ZoltanPartitioningGridVisitor.h | 38 - 477 files changed, 10747 insertions(+), 78080 deletions(-) delete mode 100644 src/basics/geometry3d/GbCylinder3D.cpp delete mode 100644 src/basics/geometry3d/GbCylinder3D.h delete mode 100644 src/basics/geometry3d/GbHalfSpace3D.cpp delete mode 100644 src/basics/geometry3d/GbHalfSpace3D.h delete mode 100644 src/basics/geometry3d/GbHalfSpaceKrischan3D.cpp delete mode 100644 src/basics/geometry3d/GbHalfSpaceKrischan3D.h delete mode 100644 src/basics/geometry3d/GbMeshTools3D.h delete mode 100644 src/basics/geometry3d/GbObject3DManager.cpp delete mode 100644 src/basics/geometry3d/GbObject3DManager.h delete mode 100644 src/basics/geometry3d/GbObjectGroup3D.cpp delete mode 100644 src/basics/geometry3d/GbObjectGroup3D.h delete mode 100644 src/basics/geometry3d/GbQuadFaceMesh3D.cpp delete mode 100644 src/basics/geometry3d/GbQuadFaceMesh3D.h delete mode 100644 src/basics/geometry3d/GbSphere3D.cpp delete mode 100644 src/basics/geometry3d/GbSphere3D.h delete mode 100644 src/basics/geometry3d/GbTriFaceMesh3D.cpp delete mode 100644 src/basics/geometry3d/GbTriFaceMesh3D.h delete mode 100644 src/basics/geometry3d/GbTriangularMesh3D.cpp delete mode 100644 src/basics/geometry3d/GbTriangularMesh3D.h delete mode 100644 src/basics/geometry3d/GbVoxelMatrix3D.cpp delete mode 100644 src/basics/geometry3d/GbVoxelMatrix3D.h delete mode 100644 src/basics/geometry3d/KdTree/KdNode.h delete mode 100644 src/basics/geometry3d/KdTree/KdRay.h delete mode 100644 src/basics/geometry3d/KdTree/KdSplitCandidate.h delete mode 100644 src/basics/geometry3d/KdTree/KdSplitCandidateManager.h delete mode 100644 src/basics/geometry3d/KdTree/KdTree.h delete mode 100644 src/basics/geometry3d/KdTree/KdUtilities.cpp delete mode 100644 src/basics/geometry3d/KdTree/KdUtilities.h delete mode 100644 src/basics/geometry3d/KdTree/examples/AdvancedPIOTests/CMakeLists.txt delete mode 100644 src/basics/geometry3d/KdTree/examples/AdvancedPIOTests/main.cpp delete mode 100644 src/basics/geometry3d/KdTree/examples/PIOTests/CMakeLists.txt delete mode 100644 src/basics/geometry3d/KdTree/examples/PIOTests/main.cpp delete mode 100644 src/basics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h delete mode 100644 src/basics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h delete mode 100644 src/basics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h delete mode 100644 src/basics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h delete mode 100644 src/basics/geometry3d/KdTree/package.include delete mode 100644 src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp delete mode 100644 src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h delete mode 100644 src/basics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h delete mode 100644 src/basics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h delete mode 100644 src/basics/geometry3d/creator/GbCuboid3DCreator.h delete mode 100644 src/basics/geometry3d/creator/GbCylinder3DCreator.h delete mode 100644 src/basics/geometry3d/creator/GbLine3DCreator.h delete mode 100644 src/basics/geometry3d/creator/GbObject3DCreator.h delete mode 100644 src/basics/geometry3d/creator/GbObject3DFactory.cpp delete mode 100644 src/basics/geometry3d/creator/GbObject3DFactory.h delete mode 100644 src/basics/geometry3d/creator/GbPoint3DCreator.h delete mode 100644 src/basics/geometry3d/creator/GbPolygon3DCreator.h delete mode 100644 src/basics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp delete mode 100644 src/basics/geometry3d/creator/GbQuadFaceMesh3DCreator.h delete mode 100644 src/basics/geometry3d/creator/GbSphere3DCreator.h delete mode 100644 src/basics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp delete mode 100644 src/basics/geometry3d/creator/GbTriFaceMesh3DCreator.h delete mode 100644 src/basics/geometry3d/creator/GbTriangle3DCreator.h delete mode 100644 src/basics/geometry3d/creator/GbTriangularMesh3DCreator.cpp delete mode 100644 src/basics/geometry3d/creator/GbTriangularMesh3DCreator.h delete mode 100644 src/basics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp delete mode 100644 src/basics/geometry3d/creator/GbVoxelMatrix3DCreator.h delete mode 100644 src/basics/geometry3d/creator/package.include delete mode 100644 src/basics/geometry3d/examples/insideOutsideTests/CMakeLists.txt delete mode 100644 src/basics/geometry3d/examples/insideOutsideTests/main.cpp delete mode 100644 src/basics/geometry3d/examples/stl2inp/CMakeLists.txt delete mode 100644 src/basics/geometry3d/examples/stl2inp/QDefineUniformMesh.cpp delete mode 100644 src/basics/geometry3d/examples/stl2inp/QDefineUniformMesh.h delete mode 100644 src/basics/geometry3d/examples/stl2inp/QDefineUniformMesh.ui delete mode 100644 src/basics/geometry3d/examples/stl2inp/main.cpp delete mode 100644 src/basics/geometry3d/examples/stl2inp/stl2inp.cpp delete mode 100644 src/basics/geometry3d/examples/stl2inp/stl2inp.h delete mode 100644 src/basics/geometry3d/examples/stl2inp/stl2inp.ui delete mode 100644 src/basics/geometry3d/fem/FeAdhocTriFaceMesh3D.cpp delete mode 100644 src/basics/geometry3d/fem/FeAdhocTriFaceMesh3D.h delete mode 100644 src/basics/geometry3d/fem/FeHalfDisc3D.cpp delete mode 100644 src/basics/geometry3d/fem/FeHalfDisc3D.h delete mode 100644 src/basics/geometry3d/fem/FePlateTriangularMesh3D.cpp delete mode 100644 src/basics/geometry3d/fem/FePlateTriangularMesh3D.h delete mode 100644 src/basics/geometry3d/fem/FePoint3D.h delete mode 100644 src/basics/geometry3d/fem/FeRing3D.cpp delete mode 100644 src/basics/geometry3d/fem/FeRing3D.h delete mode 100644 src/basics/geometry3d/fem/FeTriFaceMesh3D.cpp delete mode 100644 src/basics/geometry3d/fem/FeTriFaceMesh3D.h delete mode 100644 src/basics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.cpp delete mode 100644 src/basics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h delete mode 100644 src/basics/geometry3d/package.include delete mode 100644 src/basics/geometry3d/presentation/QGbCuboid3DInstrument.cpp delete mode 100644 src/basics/geometry3d/presentation/QGbCuboid3DInstrument.h delete mode 100644 src/basics/geometry3d/presentation/QGbCuboid3DInstrument.ui delete mode 100644 src/basics/geometry3d/presentation/QGbCylinder3DInstrument.cpp delete mode 100644 src/basics/geometry3d/presentation/QGbCylinder3DInstrument.h delete mode 100644 src/basics/geometry3d/presentation/QGbCylinder3DInstrument.ui delete mode 100644 src/basics/geometry3d/presentation/QGbObject3DInstrument.cpp delete mode 100644 src/basics/geometry3d/presentation/QGbObject3DInstrument.h delete mode 100644 src/basics/geometry3d/presentation/QGbObject3DInstrument.ui delete mode 100644 src/basics/geometry3d/presentation/QGbSphere3DInstrument.cpp delete mode 100644 src/basics/geometry3d/presentation/QGbSphere3DInstrument.h delete mode 100644 src/basics/geometry3d/presentation/QGbSphere3DInstrument.ui delete mode 100644 src/basics/geometry3d/presentation/QVTKGbObject3DViewer.cpp delete mode 100644 src/basics/geometry3d/presentation/QVTKGbObject3DViewer.h delete mode 100644 src/basics/geometry3d/presentation/vtkGbCuboid3D.cpp delete mode 100644 src/basics/geometry3d/presentation/vtkGbCuboid3D.h delete mode 100644 src/basics/geometry3d/presentation/vtkGbCylinder3D.cpp delete mode 100644 src/basics/geometry3d/presentation/vtkGbCylinder3D.h delete mode 100644 src/basics/geometry3d/presentation/vtkGbSphere3D.cpp delete mode 100644 src/basics/geometry3d/presentation/vtkGbSphere3D.h delete mode 100644 src/basics/geometry3d/presentation/vtkGbTriangularMesh3D.cpp delete mode 100644 src/basics/geometry3d/presentation/vtkGbTriangularMesh3D.h delete mode 100644 src/cpu/DemCoupling/CMakePackage.txt delete mode 100644 src/cpu/DemCoupling/CreateDemObjectsCoProcessor.cpp delete mode 100644 src/cpu/DemCoupling/CreateDemObjectsCoProcessor.h delete mode 100644 src/cpu/DemCoupling/DemCoProcessor.cpp delete mode 100644 src/cpu/DemCoupling/DemCoProcessor.h delete mode 100644 src/cpu/DemCoupling/DemCoupling.cmake delete mode 100644 src/cpu/DemCoupling/IncludsList.cmake delete mode 100644 src/cpu/DemCoupling/MovableObjectInteractor.cpp delete mode 100644 src/cpu/DemCoupling/MovableObjectInteractor.h delete mode 100644 src/cpu/DemCoupling/PePartitioningGridVisitor.cpp delete mode 100644 src/cpu/DemCoupling/PePartitioningGridVisitor.h delete mode 100644 src/cpu/DemCoupling/RestartDemObjectsCoProcessor.cpp delete mode 100644 src/cpu/DemCoupling/RestartDemObjectsCoProcessor.h delete mode 100644 src/cpu/DemCoupling/WriteDemObjectsCoProcessor.cpp delete mode 100644 src/cpu/DemCoupling/WriteDemObjectsCoProcessor.h delete mode 100644 src/cpu/DemCoupling/WritePeBlocksCoProcessor.cpp delete mode 100644 src/cpu/DemCoupling/WritePeBlocksCoProcessor.h delete mode 100644 src/cpu/DemCoupling/package.include delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/CMakePackage.txt delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineGeometryAdapter.h delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineMaterialAdapter.h delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineSolverAdapter.h delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/dummy/CMakePackage.txt delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.cpp delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.h delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.cpp delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.h delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.cpp delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.h delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/dummy/package.include delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/package.include delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/pe/CMakePackage.txt delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/pe/PeAdapter.h delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/pe/PeAdapterTest.cpp delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/pe/PeLoadBalancerAdapter.cpp delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/pe/PeLoadBalancerAdapter.h delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.cpp delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.h delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.cpp delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.h delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.cpp delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.h delete mode 100644 src/cpu/DemCoupling/physicsEngineAdapter/pe/package.include delete mode 100644 src/cpu/DemCoupling/reconstructor/CMakePackage.txt delete mode 100644 src/cpu/DemCoupling/reconstructor/EquilibriumReconstructor.cpp delete mode 100644 src/cpu/DemCoupling/reconstructor/EquilibriumReconstructor.h delete mode 100644 src/cpu/DemCoupling/reconstructor/ExtrapolationReconstructor.cpp delete mode 100644 src/cpu/DemCoupling/reconstructor/ExtrapolationReconstructor.h delete mode 100644 src/cpu/DemCoupling/reconstructor/LBMReconstructor.cpp delete mode 100644 src/cpu/DemCoupling/reconstructor/LBMReconstructor.h delete mode 100644 src/cpu/DemCoupling/reconstructor/Reconstructor.h delete mode 100644 src/cpu/DemCoupling/reconstructor/VelocityBcReconstructor.cpp delete mode 100644 src/cpu/DemCoupling/reconstructor/VelocityBcReconstructor.h delete mode 100644 src/cpu/DemCoupling/reconstructor/package.include delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/DensityBCAdapter.cpp delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/DensityBCAdapter.h delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.cpp delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.h delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.cpp delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.h delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.cpp delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.h delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.cpp delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.h delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCAdapter.cpp delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCAdapter.h delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.cpp delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.h delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/ThinWallBCProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/ThinWallBCProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.cpp delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.h delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityWithDensityBCAlgorithm.cpp delete mode 100644 src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityWithDensityBCAlgorithm.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/EmergencyExitCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/EmergencyExitCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/ForceCalculator.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/ForceCalculator.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/InSituCatalystCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/InSituCatalystCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/InSituVTKCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/InSituVTKCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/MicrophoneArrayCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/MicrophoneArrayCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/TimeDependentBCCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/TimeDependentBCCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/WriteGbObjectsCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/WriteGbObjectsCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/Block3DConnectorFactory.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/Block3DConnectorFactory.h delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.h delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/CoarseToFineNodeSetBlock3DConnector.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/CoarseToFineNodeSetBlock3DConnector.h delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/ConnectorFactory.h delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/D3Q27ETCFOffVectorConnector.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/D3Q27ETCFOffVectorConnector.h delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFCOffVectorConnector.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFCOffVectorConnector.h delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFullVectorConnector.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFullVectorConnector.h delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/D3Q27ETOffConnectorFactory.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/D3Q27ETOffConnectorFactory.h delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.h delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/FineToCoarseNodeSetBlock3DConnector.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/FineToCoarseNodeSetBlock3DConnector.h delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/RemoteBlock3DConnector.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/RemoteBlock3DConnector.h delete mode 100644 src/cpu/VirtualFluidsCore/Connectors/TransmitterType.h delete mode 100644 src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSoA.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSoA.h delete mode 100644 src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSplittedVectorEx.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSplittedVectorEx.h delete mode 100644 src/cpu/VirtualFluidsCore/Data/VoidData3D.h delete mode 100644 src/cpu/VirtualFluidsCore/Interactors/D3Q27TriFaceMeshInteractor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Interactors/D3Q27TriFaceMeshInteractor.h delete mode 100644 src/cpu/VirtualFluidsCore/Interactors/package.include delete mode 100644 src/cpu/VirtualFluidsCore/LBM/BGKLBMKernel.cpp delete mode 100644 src/cpu/VirtualFluidsCore/LBM/BGKLBMKernel.h delete mode 100644 src/cpu/VirtualFluidsCore/LBM/CompressibleCumulant4thOrderViscosityLBMKernel.cpp delete mode 100644 src/cpu/VirtualFluidsCore/LBM/CompressibleCumulant4thOrderViscosityLBMKernel.h delete mode 100644 src/cpu/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp delete mode 100644 src/cpu/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.h delete mode 100644 src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetMomentsInterpolationProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetMomentsInterpolationProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetSquarePressureInterpolationProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetSquarePressureInterpolationProcessor.h create mode 100644 src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.cpp create mode 100644 src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.h delete mode 100644 src/cpu/VirtualFluidsCore/LBM/ICell.h delete mode 100644 src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.cpp delete mode 100644 src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.h delete mode 100644 src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.cpp delete mode 100644 src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.h delete mode 100644 src/cpu/VirtualFluidsCore/LBM/IncompressibleOffsetInterpolationProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/LBM/IncompressibleOffsetInterpolationProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/LBM/InitDensityLBMKernel.cpp delete mode 100644 src/cpu/VirtualFluidsCore/LBM/InitDensityLBMKernel.h delete mode 100644 src/cpu/VirtualFluidsCore/LBM/InterpolationHelper.cpp delete mode 100644 src/cpu/VirtualFluidsCore/LBM/InterpolationHelper.h delete mode 100644 src/cpu/VirtualFluidsCore/LBM/InterpolationProcessor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/LBM/InterpolationProcessor.h delete mode 100644 src/cpu/VirtualFluidsCore/LBM/LBMKernelETD3Q27BGK.cpp delete mode 100644 src/cpu/VirtualFluidsCore/LBM/LBMKernelETD3Q27BGK.h delete mode 100644 src/cpu/VirtualFluidsCore/LBM/VoidLBMKernel.cpp delete mode 100644 src/cpu/VirtualFluidsCore/LBM/VoidLBMKernel.h delete mode 100644 src/cpu/VirtualFluidsCore/Parallel/BlocksDistributor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Parallel/BlocksDistributor.h delete mode 100644 src/cpu/VirtualFluidsCore/Parallel/MPICommunicator.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Parallel/MPICommunicator.h delete mode 100644 src/cpu/VirtualFluidsCore/Parallel/MPIIODataStructures.h delete mode 100644 src/cpu/VirtualFluidsCore/Parallel/MetisPartitioner.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Parallel/MetisPartitioner.h delete mode 100644 src/cpu/VirtualFluidsCore/Parallel/PriorityQueueDecompositor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Parallel/PriorityQueueDecompositor.h delete mode 100644 src/cpu/VirtualFluidsCore/Parallel/SimpleGeometricPartitioner.h delete mode 100644 src/cpu/VirtualFluidsCore/Parallel/ZoltanPartitioner.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Parallel/ZoltanPartitioner.h delete mode 100644 src/cpu/VirtualFluidsCore/Utilities/ChangeRandomQs.hpp delete mode 100644 src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.h delete mode 100644 src/cpu/VirtualFluidsCore/Utilities/ConfigurationFile.hpp delete mode 100644 src/cpu/VirtualFluidsCore/Utilities/MathUtil.hpp delete mode 100644 src/cpu/VirtualFluidsCore/Utilities/VoxelMatrixUtil.hpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/ChangeBoundaryDensityBlockVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/ChangeBoundaryDensityBlockVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/CheckRatioBlockVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/CheckRatioBlockVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/CoarsenCrossAndInsideGbObjectBlockVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/CoarsenCrossAndInsideGbObjectBlockVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/ConnectorBlockVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/ConnectorBlockVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/CreateTransmittersHelper.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/CreateTransmittersHelper.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/InitDistributionsFromFileBlockVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/InitDistributionsFromFileBlockVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/InitDistributionsWithInterpolationGridVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/InitDistributionsWithInterpolationGridVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/MetisPartitioningGridVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/MetisPartitioningGridVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/OverlapBlockVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/OverlapBlockVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/PQueuePartitioningGridVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/PQueuePartitioningGridVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/RatioBlockVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/RatioBlockVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/RatioSmoothBlockVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/RatioSmoothBlockVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/RefineAroundGbObjectHelper.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/RefineAroundGbObjectHelper.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectBlockVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectBlockVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectHelper.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectHelper.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/RefineInterGbObjectsVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/RefineInterGbObjectsVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/RenumberBlockVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/RenumberBlockVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/RenumberGridVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/RenumberGridVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/SetForcingBlockVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/SetForcingBlockVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/SetInterpolationDirsBlockVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/SetInterpolationDirsBlockVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/SetSpongeLayerBlockVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/SetSpongeLayerBlockVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/SetUndefinedNodesBlockVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/SetUndefinedNodesBlockVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/ViscosityBlockVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/ViscosityBlockVisitor.h delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/ZoltanPartitioningGridVisitor.cpp delete mode 100644 src/cpu/VirtualFluidsCore/Visitors/ZoltanPartitioningGridVisitor.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f031956ba..68933a5f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,9 +48,9 @@ add_subdirectory(src/basics) ################################################################################# # VIRTUAL FLUIDS CPU / GPU ################################################################################# -if (BUILD_VF_CPU) +#if (BUILD_VF_CPU) include (cpu.cmake) -endif() +#endif() if(BUILD_VF_GPU) include (gpu.cmake) endif() diff --git a/cpu.cmake b/cpu.cmake index 204c00b71..30b325445 100644 --- a/cpu.cmake +++ b/cpu.cmake @@ -1,169 +1,18 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.10) -#workaround for machine with mpi compiler wrapper -#it most define before project -#MPI -#set(CMAKE_C_COMPILER mpicc) -#set(CMAKE_CXX_COMPILER mpicxx) - -#Intel MPI -#set(CMAKE_C_COMPILER mpiicc) -#set(CMAKE_CXX_COMPILER mpiicpc) - -#Cray -#set(CMAKE_C_COMPILER cc) -#set(CMAKE_CXX_COMPILER CC) +SET(USE_INTEL OFF CACHE BOOL "include Intel compiler support") +SET(USE_GCC OFF CACHE BOOL "include gcc compiler support") -#SuperMUC -#set(CMAKE_C_COMPILER mpicc) -#set(CMAKE_CXX_COMPILER mpiCC) -PROJECT(VirtualFluids) set (SOURCE_DIR ${PROJECT_SOURCE_DIR}) set(SOURCE_ROOT ${CMAKE_SOURCE_DIR}) -#debug build for unix -#IF(UNIX) -#SET(CMAKE_BUILD_TYPE DEBUG) -#ENDIF() - -SET(USE_ZOLTAN OFF CACHE BOOL "include Zoltan library support") -SET(USE_METIS ON CACHE BOOL "include METIS library support") -SET(USE_MPI ON CACHE BOOL "include MPI library support") -SET(USE_VTK OFF CACHE BOOL "include VTK library support") -SET(USE_CATALYST OFF CACHE BOOL "include Paraview Catalyst support") -SET(USE_BOOST OFF CACHE BOOL "include Boost support") -#SET(USE_PYTHON OFF CACHE BOOL "include Python scripting support") -#SET(USE_FETOL OFF CACHE BOOL "include FETOL library support") -SET(USE_INTEL OFF CACHE BOOL "include Intel compiler support") -SET(USE_GCC OFF CACHE BOOL "include gcc compiler support") #TODO: why do we need to set this manually? -SET(USE_HLRN_LUSTRE OFF CACHE BOOL "include HLRN Lustre support") -SET(USE_DEM_COUPLING OFF CACHE BOOL "PE plugin") - - #CAB include("CMake/CMakeCABMacros.cmake") #TODO: Currently we have to include the CABMacros also here, so that the USE_* are defined in the config files for the cpu version -#include("CMake/FileUtilities.cmake") -#include("CMake/VirtualFluidsMacros.cmake") - -#MPI -IF((NOT ${CMAKE_CXX_COMPILER} MATCHES mpicxx) AND (NOT ${CMAKE_CXX_COMPILER} MATCHES mpiicpc))# OR NOT ${CMAKE_CXX_COMPILER} MATCHES cc OR NOT ${CMAKE_CXX_COMPILER} MATCHES mpiCC) - FIND_PACKAGE(MPI REQUIRED) -ENDIF() -#SET(MPI_CXX_LINK_FLAGS -mpe=mpilog) - -#SET(BOOST_USE_MULTITHREAD ON) -#SET(Boost_USE_STATIC_LIBS ON) -#SET(Boost_DEBUG TRUE) - -#SET(bv ${BOOST_VERSION}) #hack for find boost, after next command ${BOOST_VERSION} would be set to 0 -#FIND_PACKAGE(Boost ${bv} COMPONENTS system date_time thread serialization chrono regex) -#FIND_PACKAGE(Boost ${BOOST_VERSION} COMPONENTS system date_time thread serialization chrono regex) -#FIND_PACKAGE(Boost ${bv} COMPONENTS system thread serialization date_time) -#SET(BOOST_VERSION ${bv}) -#IF(${USE_PYTHON}) -# FIND_PACKAGE(Boost ${BOOST_VERSION} COMPONENTS system date_time thread serialization chrono regex python) -#ELSE(${USE_PYTHON}) -# FIND_PACKAGE(Boost ${BOOST_VERSION} COMPONENTS system date_time thread serialization chrono regex) -#ENDIF() - -IF(${USE_BOOST}) - FIND_PACKAGE(Boost ${BOOST_VERSION}) -ENDIF() - -################################################################################## -# Java -############################################################################## -### FindJNI.cmake -# IF(${USE_FETOL}) -# find_package(JNI REQUIRED) -# ENDIF() - -#VTK -IF(${USE_VTK}) - #find_package(VTK 6.1 NO_MODULE) - FIND_PACKAGE(VTK REQUIRED) - INCLUDE_DIRECTORIES(${VTK_INCLUDE_DIRS}) - MESSAGE("VTK_INCLUDE_DIRS = " ${VTK_INCLUDE_DIRS}) -ENDIF() - -IF(${USE_CATALYST}) - find_package(ParaView 4.3 REQUIRED COMPONENTS vtkPVPythonCatalyst) - include("${PARAVIEW_USE_FILE}") -ENDIF() - -#LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DCAB_BOOST) -LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DNOMINMAX) -#LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DBOOST_SIGNALS_NO_DEPRECATION_WARNING) -#LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DCAB_RUBY) -#LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -mpe=mpilog) -#LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -noshlib) -#LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DSINGLEPRECISION) - -IF(${USE_ZOLTAN}) - LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DVF_ZOLTAN) -ENDIF() -IF(${USE_METIS}) - LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DVF_METIS) -ENDIF() -IF(${USE_MPI}) - LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DVF_MPI) -ENDIF() -# IF(${USE_FETOL}) -# LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DVF_FETOL) -# ENDIF() -IF(${USE_VTK}) - LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DVF_VTK) -ENDIF() -IF(${USE_CATALYST}) - LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DVF_CATALYST) -ENDIF() - -IF(${USE_BOOST}) - LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DVF_BOOST) -ENDIF() - -IF(${USE_HLRN_LUSTRE}) - LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DHLRN_LUSTRE) -ENDIF() - -IF(${USE_INTEL}) - SET(CAB_ADDITIONAL_LINK_FLAGS ${CAB_ADDITIONAL_LINK_FLAGS} -parallel) -ENDIF() - -IF(${USE_GCC}) - SET(CAB_ADDITIONAL_LINK_FLAGS ${CAB_ADDITIONAL_LINK_FLAGS} -lgomp) -ENDIF() - - -# IF(${USE_PYTHON}) -# FIND_PACKAGE(PythonLibs) -# INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIR}) -# LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DVF_PYTHON) -# LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DBOOST_PYTHON_STATIC_LIB) -# add_subdirectory(python) -# ENDIF() - -# IF(${USE_INTEL}) -# LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DMPICH_IGNORE_CXX_SEEK) -# LIST(APPEND CAB_ADDTIONAL_COMPILER_FLAGS -DMPICH_SKIP_MPICXX) -# ENDIF() -#message("MPI_CXX_LIBRARY: " ${MPI_CXX_LIBRARY}) -#IF(MPI_CXX_LIBRARY) -#SET(MPI_LIBRARY ${MPI_LIBRARY} ${MPI_CXX_LIBRARY}) -#message("MPI_LIBRARY: " ${MPI_LIBRARY}) -#ENDIF() - - -#IF(${USE_DEM_COUPLING}) -# add_subdirectory(Plugins/dem_coupling) -#ENDIF() add_subdirectory(3rdParty/MuParser) add_subdirectory(src/cpu/VirtualFluidsCore) -#add_subdirectory(VirtualFluidsBasic) set (APPS_ROOT_CPU "${CMAKE_SOURCE_DIR}/apps/cpu/") include(${APPS_ROOT_CPU}/Applications.cmake) \ No newline at end of file diff --git a/src/basics/geometry3d/CoordinateTransformation3D.cpp b/src/basics/geometry3d/CoordinateTransformation3D.cpp index ba219df77..d92075c9e 100644 --- a/src/basics/geometry3d/CoordinateTransformation3D.cpp +++ b/src/basics/geometry3d/CoordinateTransformation3D.cpp @@ -1,4 +1,36 @@ -#include <numerics/geometry3d/CoordinateTransformation3D.h> +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file CoordinateTransformation3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= +#include <geometry3d/CoordinateTransformation3D.h> #include <basics/utilities/UbMath.h> using namespace std; @@ -42,7 +74,9 @@ CoordinateTransformation3D::CoordinateTransformation3D(CoordinateTransformation3 // } /*======================================================*/ -/**==== Set transformation values +/**==== Set transformation values ====**/ +/*! +\brief Set transformation values @param a transformed coordinate system x0 (in global coordinates) @param b transformed coordinate system y0 (in global coordinates) @param c transformed coordinate system z0 (in global coordinates) @@ -52,8 +86,8 @@ CoordinateTransformation3D::CoordinateTransformation3D(CoordinateTransformation3 @param alpha rotation around z angle (positive FROM global TO transformed coordinate system) @param beta rotation around y angle @param gamma rotation around x angle -@exception IllegalArgumentException if one of the scale values is between -1.0E-8 and 1.0E-8 -**/ +@exception IllegalArgumentException if c1 of the scale values is between -1.0E-8 and 1.0E-8 +*/ void CoordinateTransformation3D::setTransformationValues(const double& originX1, const double& originX2, const double& originX3, const double& dx1, const double& dx2, const double& dx3, const double& alpha, const double& beta, const double& gamma) { @@ -124,7 +158,7 @@ void CoordinateTransformation3D::setTransformationValues(const double& originX1, this->transformation = true; } /*======================================================*/ -/** +/*! Set transformation active state (if this IS a transformation) @param active true to be active, false otherwise **/ @@ -134,7 +168,7 @@ void CoordinateTransformation3D::setActive(const bool& active) if(this->transformation) this->active = active; } /*======================================================*/ -/** +/*! Transform FROM global coordinates TO transformed coordinates. @param x1 the global x coordinate @param x2 the global y coordinate @@ -158,7 +192,7 @@ double CoordinateTransformation3D::transformForwardToX3Coordinate(const double& else return x3; } /*======================================================*/ -/** +/*! Transform FROM global coordinates TO transformed coordinates (ignoring rotation). @param x1 the global x coordinate **/ @@ -180,7 +214,7 @@ double CoordinateTransformation3D::transformForwardToX3CoordinateIgnoringRotatio else return x3; } /*======================================================*/ -/** +/*! Transform FROM transformed coordinates TO global coordinates. @param x1 the transformed x coordinate @param x2 the transformed y coordinate @@ -204,7 +238,7 @@ double CoordinateTransformation3D::transformBackwardToX3Coordinate(const double& else return x3; } /*======================================================*/ -/** +/*! Transform FROM transformed coordinates TO global coordinates (ignoring rotation). @param x1 the transformed x coordinate **/ @@ -226,7 +260,7 @@ double CoordinateTransformation3D::transformBackwardToX3CoordinateIgnoringRotati else return x3; } /*======================================================*/ -/** +/*! Returns a string representation of this transformation. @return a string representation of this transformation **/ diff --git a/src/basics/geometry3d/CoordinateTransformation3D.h b/src/basics/geometry3d/CoordinateTransformation3D.h index 3179de328..1f89a5e68 100644 --- a/src/basics/geometry3d/CoordinateTransformation3D.h +++ b/src/basics/geometry3d/CoordinateTransformation3D.h @@ -1,46 +1,68 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file CoordinateTransformation3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef COORDINATETRANSFORMATION3D_H #define COORDINATETRANSFORMATION3D_H -#ifdef RCF_USE_BOOST_SERIALIZATION - #include <boost/archive/text_oarchive.hpp> - #include <boost/archive/text_iarchive.hpp> -#endif //RCF_USE_BOOST_SERIALIZATION - #include <cmath> #include <string> #include <sstream> #include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileInput.h> -#include <basics/utilities/UbFileOutput.h> #include <PointerDefinitions.h> -//description: x1/x2/x3 = alt, x1*/x2*/x3* = neu -// x2 -// ^ x* -// | / -// | 2* -// 4 / -// | / -// 3 1* => neues coordsys ist um originX1=originX2=originX3=2 verschoben -// | / neues dx1=dx2=dx2=2 -> skalierung um 2 in x1-,x2- und x3-richtung -// 2 / ERST verdrehung um alpha um "x1" achse -// | \ DANN verdrehung um beta um "x2" achse -// 1 \ DANN verdrehung um gamma um "x3" achse -// | x1* -// |--1--2--3--4--5------------- > x1 -// -// Bemerkung: kann sein, dass die Verdrehung um x1 und x3 vertauschst sind -// - muss mal einer pr�fen ... - - +/////////////////////////////////////////////////////////////////////////////////////// +//! +//! \brief A class provides 3d coordinate transformation +//! \details +//! description: x1/x2/x3 = old, x1*/x2*/x3* = new +//! x2 +//! ^ x* +//! | / +//! | 2* +//! 4 / +//! | / +//! 3 1* => new coordsys is translated by originX1=originX2=originX3=2 +//! | / new dx1=dx2=dx2=2 -> scaling by 2 in x1-,x2- und x3-direction +//! 2 / FIRST rotation by alpha around "x1" axis +//! | \ THEN rotation by beta around "x2" axis +//! 1 \ THEN rotation by gamma around "x3" axis +//! | x1* +//! |--1--2--3--4--5------------- > x1 +//! +//! Remark: It might be that the rotations around x1 and x3 axis are swapped. +//! +////////////////////////////////////////////////////////////////////////////////////// class CoordinateTransformation3D { @@ -61,7 +83,7 @@ public: double getRotationX2Angle() const { return this->beta; } double getRotationX3Angle() const { return this->gamma; } //Rotation - //Achtung die Winkel passen nicht �berein -siehe setTransformationValues + //Achtung die Winkel passen nicht überein -siehe setTransformationValues void setRotationX1Angle(double alpha) { this->setTransformationValues(this->Tx1, this->Tx2, this->Tx3, this->Sx1, this->Sx2, this->Sx3, alpha, this->beta, this->gamma); } void setRotationX2Angle(double beta ) { this->setTransformationValues(this->Tx1, this->Tx2, this->Tx3, this->Sx1, this->Sx2, this->Sx3, this->alpha, beta, this->gamma); } void setRotationX3Angle(double gamma) { this->setTransformationValues(this->Tx1, this->Tx2, this->Tx3, this->Sx1, this->Sx2, this->Sx3, this->alpha, this->beta, gamma); } @@ -84,58 +106,6 @@ public: double transformBackwardToX3CoordinateIgnoringRotation(const double& x3) const; std::string toString() const; - //------------- implements CAB serialization ----- start - void write(UbFileOutput* out) const - { - out->writeString("Coordtransfomartion3D"); - out->writeDouble(this->Tx1); - out->writeDouble(this->Tx2); - out->writeDouble(this->Tx3); - out->writeDouble(this->Sx1); - out->writeDouble(this->Sx2); - out->writeDouble(this->Sx3); - out->writeDouble(this->alpha); - out->writeDouble(this->beta ); - out->writeDouble(this->gamma); - } - void read(UbFileInput* in) - { - in->readString(); - this->Tx1 = in->readDouble(); - this->Tx2 = in->readDouble(); - this->Tx3 = in->readDouble(); - this->Sx1 = in->readDouble(); - this->Sx2 = in->readDouble(); - this->Sx3 = in->readDouble(); - this->alpha = in->readDouble(); - this->beta = in->readDouble(); - this->gamma = in->readDouble(); - - this->setTransformationValues(Tx1,Tx2,Tx3,Sx1,Sx2,Sx3,alpha,beta,gamma); - } - //------------- implements CAB serialization ----- end - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & Tx1; ar & Tx2; ar & Tx3; - ar & Sx1; ar & Sx2; ar & Sx3; - ar & alpha; ar & beta; ar & gamma; - - ar & toX1factorX1; ar & toX1factorX2; ar & toX1factorX3; ar & toX1delta; - ar & toX2factorX1; ar & toX2factorX2; ar & toX2factorX3; ar & toX2delta; - ar & toX3factorX1; ar & toX3factorX2; ar & toX3factorX3; ar & toX3delta; - - ar & fromX1factorX1; ar & fromX1factorX2; ar & fromX1factorX3; ar & fromX1delta; - ar & fromX2factorX1; ar & fromX2factorX2; ar & fromX2factorX3; ar & fromX2delta; - ar & fromX3factorX1; ar & fromX3factorX2; ar & fromX3factorX3; ar & fromX3delta; - - ar & active; - ar & transformation; - } -#endif //CAB_RCF - private: double Tx1, Tx2, Tx3, Sx1, Sx2, Sx3, alpha, beta, gamma; @@ -150,11 +120,6 @@ private: bool active; bool transformation; - friend class MPIIOCoProcessor; - friend class MPIIORestartCoProcessor; - friend class MPIIOMigrationCoProcessor; - friend class MPIIOMigrationBECoProcessor; - friend class CheckpointConverter; }; #endif //COORDINATETRANSFORMATION3D_H diff --git a/src/basics/geometry3d/GbCuboid3D.cpp b/src/basics/geometry3d/GbCuboid3D.cpp index 2fa48953c..67a7d3d15 100644 --- a/src/basics/geometry3d/GbCuboid3D.cpp +++ b/src/basics/geometry3d/GbCuboid3D.cpp @@ -1,18 +1,43 @@ -#include <numerics/geometry3d/GbCuboid3D.h> -#include <numerics/geometry3d/creator/GbCuboid3DCreator.h> +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbCuboid3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= +#include <GbCuboid3D.h> +#include <GbSystem3D.h> +#include <GbTriangle3D.h> #include <basics/utilities/UbMath.h> -#include <numerics/geometry3d/GbSystem3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> - using namespace std; -/*=======================================================*/ -ObObjectCreator* GbCuboid3D::getCreator() -{ - return GbCuboid3DCreator::getInstance(); -} /*=======================================================*/ // Konstruktor GbCuboid3D::GbCuboid3D() : GbObject3D() @@ -415,23 +440,6 @@ void GbCuboid3D::objectWillBeDeleted(UbObservable* objectForDeletion) //ACHTUNG: eigentlich muessten in allen methoden von GbLine if abfragen fuer NULL pointer hin... toDo } /*=======================================================*/ -void GbCuboid3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - p1->write(out); - p2->write(out); -} -/*=======================================================*/ -void GbCuboid3D::read(UbFileInput* in) -{ - in->readString(); - this->p1 = new GbPoint3D; - p1->read(in); - in->readString(); - this->p2 = new GbPoint3D; - p2->read(in); -} -/*=======================================================*/ void GbCuboid3D::translate(const double& tx1, const double& tx2, const double& tx3) { this->p1->translate(tx1, tx2, tx3); @@ -556,78 +564,4 @@ double GbCuboid3D::getIntersectionRaytraceFactor(const double& x1, const double& return maxT[whichPlane] ; /* ray hits box */ } -/*==========================================================*/ -// double GbCuboid3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) -// { -// double absX,absMaxX,absY,absMaxY,absZ,absMaxZ; -// -// if(rx1<0.0) absX = this->getX1Maximum() - x1; -// else absX = this->getX1Minimum() - x1; -// if(1-(rx1<0.0)) absMaxX = this->getX1Maximum() - x1; -// else absMaxX = this->getX1Minimum() - x1; -// -// if(rx2<0.0) absY = this->getX2Maximum() - x2; -// else absY = this->getX2Minimum() - x2; -// if(1-(rx2<0.0)) absMaxY = this->getX2Maximum() - x2; -// else absMaxY = this->getX2Minimum() - x2; -// -// if(rx3<0.0) absZ = this->getX3Maximum() - x3; -// else absZ = this->getX3Minimum() - x3; -// if(1-(rx3<0.0)) absMaxZ = this->getX3Maximum() - x3; -// else absMaxZ = this->getX3Minimum() - x3; -// -// -// //tmin ist die verschneidung des Gerade (Ray) durch die naehere Gerade (MinX oder MaxX) -// //tmax ist die verschneidung des Gerade (Ray) durch die weiteste Gerade (MinX oder MaxX) -// //analog fuer tymin und tymax -// double tmin, tymin, tzmin, tmax, tymax, tzmax; -// -// if(!UbMath::zero(rx1)) tmin = tmax = 1.0/rx1; -// else if(rx1<0.0) tmin = tmax = -UbMath::getPositiveInfinity<double>(); -// else tmin = tmax = UbMath::getPositiveInfinity<double>(); -// -// if(!UbMath::zero(rx2)) tymin = tymax = 1.0/rx2; -// else if(rx2<0.0) tymin = tymax = -UbMath::getPositiveInfinity<double>(); -// else tymin = tymax = UbMath::getPositiveInfinity<double>(); -// -// if(!UbMath::zero(rx3)) tzmin = tzmax = 1.0/rx3; -// else if(rx1<0.0) tzmin = tzmax = -UbMath::getPositiveInfinity<double>(); -// else tzmin = tzmax = UbMath::getPositiveInfinity<double>(); -// -// //tmin *= absX; -// //tmax *= absMaxX; -// //tymin *= absY; -// //tymax *= absMaxY; -// //tzmin *= absZ; -// //tzmax *= absMaxZ; -// -// //0 * 1/0 vermeiden, da es ein Undefined wert produziert -// if( !UbMath::zero(absX) || !UbMath::zero(rx1) ) tmin *= absX; -// else tmin = tymin; -// -// if( !UbMath::zero(absY) || !UbMath::zero(rx2)) tymin *= absY; -// else tymin = tmin; -// -// if( !UbMath::zero(absZ) || !UbMath::zero(rx3)) tzmin *= absZ; -// else tzmin = tymin; -// -// if( !UbMath::zero(absMaxX) || !UbMath::zero(rx1)) tmax *= absMaxX; -// else tmax = tymax; -// -// if( !UbMath::zero(absMaxY) || !UbMath::zero(rx2)) tymax *= absMaxY; -// else tymax = tmax; -// -// if( !UbMath::zero(absMaxZ) || !UbMath::zero(rx3)) tzmax *= absMaxZ; -// else tzmax = tymax; -// -// //in dieser Fall gibt es keine Verschneidung -// if( (tmin > tymax) || (tymin > tmax) ) return -1; -// -// tmin = UbMath::max(tmin,tymin,tzmin); -// tmax = UbMath::min(tmax,tymax,tzmax); -// -// if( (tmin > tzmax) || (tzmin > tmax) ) return -1; -// if(tmin >= 0.0) return tmin ; -// -// return tmax; -//} + diff --git a/src/basics/geometry3d/GbCuboid3D.h b/src/basics/geometry3d/GbCuboid3D.h index fd4376876..db7e0245d 100644 --- a/src/basics/geometry3d/GbCuboid3D.h +++ b/src/basics/geometry3d/GbCuboid3D.h @@ -1,20 +1,42 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbCuboid3D.h +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef GBCUBOID3D_H #define GBCUBOID3D_H -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - #include <vector> #include <cmath> -#include <numerics/geometry3d/GbPoint3D.h> +#include <GbPoint3D.h> #include <basics/utilities/UbObserver.h> #include <basics/utilities/UbMath.h> @@ -25,7 +47,7 @@ class GbObject3DCreator; class GbCuboid3D; typedef SPtr<GbCuboid3D> GbCuboid3DPtr; - +//! \brief This Class provides basic 3D box objects. class GbCuboid3D : public GbObject3D, public UbObserver { public: @@ -108,10 +130,6 @@ public: std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - //virtuelle Methoden von UbObserver void objectChanged(UbObservable* changedObject); void objectWillBeDeleted(UbObservable* objectForDeletion); @@ -119,26 +137,9 @@ public: using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & p1; - ar & p2; - } -#endif //CAB_RCF - protected: GbPoint3D* p1; GbPoint3D* p2; }; -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - UB_AUTO_RUN_NAMED( SF::registerType<GbCuboid3D>("GbCuboid3D") , SF_GbCuboid3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbCuboid3D >()), SF_GbCuboid3D_BD1 ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbCuboid3D>() ), SF_GbCuboid3D_BD2 ); -#endif //RCF_USE_SF_SERIALIZATION - - #endif diff --git a/src/basics/geometry3d/GbCylinder3D.cpp b/src/basics/geometry3d/GbCylinder3D.cpp deleted file mode 100644 index 1adec348a..000000000 --- a/src/basics/geometry3d/GbCylinder3D.cpp +++ /dev/null @@ -1,1262 +0,0 @@ -#include <numerics/geometry3d/GbCylinder3D.h> -#include <numerics/geometry3d/GbSystem3D.h> -#include <numerics/geometry3d/GbPoint3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> -#include <basics/utilities/UbInfinity.h> - -#include <numerics/geometry3d/creator/GbCylinder3DCreator.h> - -using namespace std; - -/*=======================================================*/ -ObObjectCreator* GbCylinder3D::getCreator() -{ - return GbCylinder3DCreator::getInstance(); -} -// Konstruktor -/*==========================================================*/ -GbCylinder3D::GbCylinder3D() - : minX1(0.0) , minX2(0.0) , minX3(0.0) - , maxX1(0.0) , maxX2(0.0) , maxX3(0.0) - , centerX1(0.0), centerX2(0.0), centerX3(0.0) -{ - this->setName("cylinder"); - GbPoint3D* p1 = new GbPoint3D(); - GbPoint3D* p2 = new GbPoint3D(); - mLine = new GbLine3D(p1,p2); - this->mLine->addObserver(this); - mRad = 0.0; - cylinderType = GbCylinder3D::NOTPARALLELTOAXIS; - this->mLine->addObserver(this); - this->calculateValues(); -} -/*=======================================================*/ -GbCylinder3D::GbCylinder3D(GbCylinder3D* cylinder) - : minX1(0.0) , minX2(0.0) , minX3(0.0) - , maxX1(0.0) , maxX2(0.0) , maxX3(0.0) - , centerX1(0.0), centerX2(0.0), centerX3(0.0) -{ - this->setName("cylinder"); - mRad = cylinder->getRadius(); - cylinderType = cylinder->cylinderType; - mLine = cylinder->getLine()->clone(); - - this->mLine->addObserver(this); - this->calculateValues(); -} -/*==========================================================*/ -GbCylinder3D::GbCylinder3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& rad) - : minX1(0.0) , minX2(0.0) , minX3(0.0) - , maxX1(0.0) , maxX2(0.0) , maxX3(0.0) - , centerX1(0.0), centerX2(0.0), centerX3(0.0) -{ - this->setName("cylinder"); - mLine = new GbLine3D; - //Min/Max, damit gewaehrleistet ist, dass Startpunkt immer der "Achs-Minimale" ist - //Anm.: bin nich tsicher ob weiter unten irgendwelche Algos drauf beruhen... - // geht nat nur solange, zylinder achs-parallel, aber das ist erzeit so!!! - mLine->setPoints( new GbPoint3D(min(x1a,x1b), min(x2a,x2b), min(x3a,x3b)) - ,new GbPoint3D(max(x1a,x1b), max(x2a,x2b), max(x3a,x3b))); - //mLine->setPoints( new GbPoint3D(x1a,x2a,x3a),new GbPoint3D(x1b, x2b ,x3b )); - this->mLine->addObserver(this); - mRad = fabs(rad); - - this->calculateValues(); -} -/*==========================================================*/ -GbCylinder3D::GbCylinder3D(GbPoint3D* p1, GbPoint3D* p2, const double& rad) - : minX1(0.0), minX2(0.0), minX3(0.0) - , maxX1(0.0), maxX2(0.0), maxX3(0.0) - , centerX1(0.0), centerX2(0.0), centerX3(0.0) -{ - this->setName("cylinder"); - mRad = rad; - - mLine = new GbLine3D(p1,p2); - this->mLine->addObserver(this); - this->calculateValues(); -} -/*==========================================================*/ -GbCylinder3D::GbCylinder3D(GbLine3D* line, const double& rad) - : minX1(0.0), minX2(0.0), minX3(0.0) - , maxX1(0.0), maxX2(0.0), maxX3(0.0) - , centerX1(0.0), centerX2(0.0), centerX3(0.0) -{ - this->setName("cylinder"); - mRad = rad; - - this->mLine = line; - this->mLine->addObserver(this); - - this->calculateValues(); -} -/*==========================================================*/ -// Destruktor -GbCylinder3D::~GbCylinder3D() -{ - if(mLine) this->mLine->removeObserver(this); - mLine = NULL; -} -/*=======================================================*/ -void GbCylinder3D::calculateValues() -{ - double x1a = mLine->getPoint1()->x1; double x1b = mLine->getPoint2()->x1; - double x2a = mLine->getPoint1()->x2; double x2b = mLine->getPoint2()->x2; - double x3a = mLine->getPoint1()->x3; double x3b = mLine->getPoint2()->x3; - - if (x1a!=x1b && x2a==x2b && x3a==x3b) this->cylinderType = X1PARALLEL; - else if(x2a!=x2b && x1a==x1b && x3a==x3b) this->cylinderType = X2PARALLEL; - else if(x3a!=x3b && x1a==x1b && x2a==x2b) this->cylinderType = X3PARALLEL; - // nach dem serialisieren ruft er den Standardkonstruktor auf wo alles 0 ist und bricht sonst hier ab - else if(x3a==x3b && x1a==x1b && x2a==x2b) this->cylinderType = X1PARALLEL; - else this->cylinderType = NOTPARALLELTOAXIS; - - if((this->cylinderType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) - throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Zylinder erlaubt... isPointInObject3D funzt sonst ned"); - - if(this->isParallelToX1Axis()) - { - minX1 = mLine->getX1Minimum(); - maxX1 = mLine->getX1Maximum(); - minX2 = mLine->getX2Centroid()-mRad; - maxX2 = mLine->getX2Centroid()+mRad; - minX3 = mLine->getX3Centroid()-mRad; - maxX3 = mLine->getX3Centroid()+mRad; - } - else if(this->isParallelToX2Axis()) - { - minX1 = mLine->getX1Centroid()-mRad; - maxX1 = mLine->getX1Centroid()+mRad; - minX2 = mLine->getX2Minimum(); - maxX2 = mLine->getX2Maximum(); - minX3 = mLine->getX3Centroid()-mRad; - maxX3 = mLine->getX3Centroid()+mRad; - } - else if(this->isParallelToX3Axis()) - { - minX1 = mLine->getX1Centroid()-mRad; - maxX1 = mLine->getX1Centroid()+mRad; - minX2 = mLine->getX2Centroid()-mRad; - maxX2 = mLine->getX2Centroid()+mRad; - minX3 = mLine->getX3Minimum(); - maxX3 = mLine->getX3Maximum(); - } - - centerX1 = mLine->getX1Centroid(); - centerX2 = mLine->getX2Centroid(); - centerX3 = mLine->getX3Centroid(); -} - -/*=======================================================*/ -void GbCylinder3D::finalize() -{ - if(this->mLine) - { - mLine->finalize(); - delete mLine; - mLine=NULL; - } -} -/*=======================================================*/ -double GbCylinder3D::getHeight() -{ - if(mLine) return mLine->getLength(); return 0.0; -} -/*=======================================================*/ -GbPoint3D* GbCylinder3D::getPoint1() -{ - if(this->mLine) return this->mLine->getPoint1(); - return NULL; -} -/*=======================================================*/ -GbPoint3D* GbCylinder3D::getPoint2() -{ - if(this->mLine) return this->mLine->getPoint2(); - return NULL; -} -/*=======================================================*/ -void GbCylinder3D::setRadius(const double& radius) -{ - this->mRad = std::fabs(radius); - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void GbCylinder3D::setLine(GbLine3D* line) -{ - if(this->mLine) this->mLine->removeObserver(this); - this->mLine = line; - this->mLine->addObserver(this); - this->calculateValues(); - - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void GbCylinder3D::setPoint1(const double& x1, const double& x2, const double& x3) -{ - if(!mLine->getPoint1()) throw UbException(UB_EXARGS,"line has no point1"); - mLine->getPoint1()->setCoordinates(x1,x2,x3); - this->calculateValues(); - - //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt... -} -/*=======================================================*/ -void GbCylinder3D::setPoint2(const double& x1, const double& x2, const double& x3) -{ - if(!mLine->getPoint2()) throw UbException(UB_EXARGS,"line has no point2"); - mLine->getPoint2()->setCoordinates(x1,x2,x3); - this->calculateValues(); - - //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt... -} -/*==========================================================*/ -bool GbCylinder3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p) -{ - //true, wenn 'in Object' oder 'auf Boundary'! - if ( this->isParallelToX1Axis() && (UbMath::less(x1p,minX1) || UbMath::greater(x1p,maxX1))) return false; - else if( this->isParallelToX2Axis() && (UbMath::less(x2p,minX2) || UbMath::greater(x2p,maxX2))) return false; - else if( this->isParallelToX3Axis() && (UbMath::less(x3p,minX3) || UbMath::greater(x3p,maxX3))) return false; - else if( this->isNotParallelToAxis() ) throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Zylinder erlaubt... isPointInObject3D funzt sonst ned"); - - return UbMath::lessEqual(fabs(mLine->getDistance(x1p,x2p,x3p)),fabs(mRad)); -} -/*==========================================================*/ -bool GbCylinder3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary) -{ - //funzt derzeit nur bei achsparallelen cylindern - pointIsOnBoundary = false; - - if ( this->isParallelToX1Axis() && (UbMath::less(x1p,minX1) || UbMath::greater(x1p,maxX1))) return false; - else if( this->isParallelToX2Axis() && (UbMath::less(x2p,minX2) || UbMath::greater(x2p,maxX2))) return false; - else if( this->isParallelToX3Axis() && (UbMath::less(x3p,minX3) || UbMath::greater(x3p,maxX3))) return false; - else if( this->isNotParallelToAxis() ) throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Zylinder erlaubt... isPointInObject3D funzt sonst ned"); - - //true, wenn 'in Object' oder 'auf Boundary'! - - double dis = mLine->getDistance(x1p,x2p,x3p); - - if(UbMath::equal(dis,mRad)) pointIsOnBoundary = true; - - if (this->isParallelToX1Axis() && (UbMath::equal(x1p,minX1) || UbMath::equal(x1p,maxX1))) pointIsOnBoundary = true; - else if(this->isParallelToX2Axis() && (UbMath::equal(x2p,minX2) || UbMath::equal(x2p,maxX2))) pointIsOnBoundary = true; - else if(this->isParallelToX3Axis() && (UbMath::equal(x3p,minX3) || UbMath::equal(x3p,maxX3))) pointIsOnBoundary = true; - - return UbMath::lessEqual(dis,mRad); -} -/*==========================================================*/ -string GbCylinder3D::toString() -{ - stringstream ss; - ss<<"GbCylinder3D["; - ss<<"line="<<this->mLine->toString(); - ss<<", r="<<this->mRad; - ss<<"]"; - return(ss.str()); -} -/*=======================================================*/ -bool GbCylinder3D::isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - if( this->isPointInGbObject3D(x1a, x2a, x3a) - && this->isPointInGbObject3D(x1b, x2a, x3a) - && this->isPointInGbObject3D(x1b, x2b, x3a) - && this->isPointInGbObject3D(x1a, x2b, x3a) - && this->isPointInGbObject3D(x1a, x2a, x3b) - && this->isPointInGbObject3D(x1b, x2a, x3b) - && this->isPointInGbObject3D(x1b, x2b, x3b) - && this->isPointInGbObject3D(x1a, x2b, x3b)) - { - return true; - } - return false; -} -/*==========================================================*/ -bool GbCylinder3D::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 cylinder3D -// - cell boxes cylinder3D -//returns false: -// - cell completely inside cylinder3D ( = cylinder3D boxes cell) -// - cell und cylinder3D haben kein gemeinsames Volumen -{ - //erstmal wieder die dumm Loesung - if( this->isCellInsideOrCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) - && !this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) ) - { - return true; - } - - return false; -} -/*==========================================================*/ -bool GbCylinder3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -//returns true: -// - cell completely inside cylinder3D ( = cylinder3D boxes cell) -// - cell cuts cylinder3D -// - cell boxes cylinder3D -//returns false: -// - cell und cylinder3D haben kein gemeinsames Volumen -{ - double dmin = 0.0; - - if(this->isParallelToX1Axis()) - { - //check liegt Cell komplett !x1-ausserhalb"? - if( UbMath::less (x1a,minX1) && UbMath::less (x1b,minX1) ) return false; - if( UbMath::greater(x1a,maxX1) && UbMath::greater(x1b,maxX1) ) return false; - - //mittelpunkt kreis-querschnitt - double& midX2 = mLine->getPoint1()->x2; - double& midX3 = mLine->getPoint1()->x3; - if ( UbMath::less ( midX2, x2a ) ) dmin += std::pow( midX2 - x2a, 2.0 ); - else if( UbMath::greater( midX2, x2b ) ) dmin += std::pow( midX2 - x2b, 2.0 ); - if ( UbMath::less ( midX3, x3a ) ) dmin += std::pow( midX3 - x3a, 2.0 ); - else if( UbMath::greater( midX3, x3b ) ) dmin += std::pow( midX3 - x3b, 2.0 ); - if( UbMath::lessEqual( dmin, mRad*mRad) ) return true; - - return false; - } - else if(this->isParallelToX2Axis()) - { - //check liegt Cell komplett !x2-ausserhalb"? - if( UbMath::less (x2a,minX2) && UbMath::less (x2b,minX2) ) return false; - if( UbMath::greater(x2a,maxX2 ) && UbMath::greater(x2b,maxX2) ) return false; - - //mittelpunkt kreis-querschnitt - double& midX1 = mLine->getPoint1()->x1; - double& midX3 = mLine->getPoint1()->x3; - if ( UbMath::less ( midX1, x1a ) ) dmin += std::pow( midX1 - x1a, 2.0 ); - else if( UbMath::greater( midX1, x1b ) ) dmin += std::pow( midX1 - x1b, 2.0 ); - if ( UbMath::less ( midX3, x3a ) ) dmin += std::pow( midX3 - x3a, 2.0 ); - else if( UbMath::greater( midX3, x3b ) ) dmin += std::pow( midX3 - x3b, 2.0 ); - if( UbMath::lessEqual( dmin, mRad*mRad ) ) return true; - - } - else if(this->isParallelToX3Axis()) - { - //check liegt Cell komplett !x3-ausserhalb"? - if( UbMath::less (x3a,minX3) && UbMath::less (x3b,minX3) ) return false; - if( UbMath::greater(x3a,maxX3) && UbMath::greater(x3b,maxX3) ) return false; - - //mittelpunkt kreis-querschnitt - double& midX1 = mLine->getPoint1()->x1; - double& midX2 = mLine->getPoint1()->x2; - if ( UbMath::less ( midX1, x1a ) ) dmin += std::pow( midX1 - x1a, 2.0 ); - else if( UbMath::greater( midX1, x1b ) ) dmin += std::pow( midX1 - x1b, 2.0 ); - if ( UbMath::less ( midX2, x2a ) ) dmin += std::pow( midX2 - x2a, 2.0 ); - else if( UbMath::greater( midX2, x2b ) ) dmin += std::pow( midX2 - x2b, 2.0 ); - if( UbMath::lessEqual( dmin, mRad*mRad ) ) return true; - } - - return false; -} -/*==========================================================*/ -GbLine3D* GbCylinder3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2) -{ - //liefert immer "innere" linie, also der teil, der vom Zylinder "abgeschnitten" wurde! - //funktioniert derzeit nur mit achsenparallelen Zylindern! - vector<GbPoint3D*> schnittpunkte; - - double xa,ya,za,xb,yb,zb,xm,ym,zStart,zEnd,t1,t2; - - if(this->isParallelToX1Axis()) - { - xa = point1.getX2Coordinate(); - ya = point1.getX3Coordinate(); - za = point1.getX1Coordinate(); - xb = point2.getX2Coordinate(); - yb = point2.getX3Coordinate(); - zb = point2.getX1Coordinate(); - xm = mLine->getPoint1()->getX2Coordinate(); - ym = mLine->getPoint1()->getX3Coordinate(); - zStart = mLine->getPoint1()->getX1Coordinate(); - zEnd = mLine->getPoint2()->getX1Coordinate(); - } - else if(this->isParallelToX2Axis()) - { - xa = point1.getX1Coordinate(); - ya = point1.getX3Coordinate(); - za = point1.getX2Coordinate(); - xb = point2.getX1Coordinate(); - yb = point2.getX3Coordinate(); - zb = point2.getX2Coordinate(); - xm = mLine->getPoint1()->getX1Coordinate(); - ym = mLine->getPoint1()->getX3Coordinate(); - zStart = mLine->getPoint1()->getX2Coordinate(); - zEnd = mLine->getPoint2()->getX2Coordinate(); - } - else if(this->isParallelToX3Axis()) - { - xa = point1.getX1Coordinate(); - ya = point1.getX2Coordinate(); - za = point1.getX3Coordinate(); - xb = point2.getX1Coordinate(); - yb = point2.getX2Coordinate(); - zb = point2.getX3Coordinate(); - xm = mLine->getPoint1()->getX1Coordinate(); - ym = mLine->getPoint1()->getX2Coordinate(); - zStart = mLine->getPoint1()->getX3Coordinate(); - zEnd = mLine->getPoint2()->getX3Coordinate(); - } - else throw UbException(UB_EXARGS,"funktioniert derzeit nur mit achsenparallelen Zylindern"); - - //Bestimmung des Schnittpunktes mit unendlich ausgedehntem Zylinder - double r = mRad; - double r2 = r*r; - double xa2 = xa*xa; - double xb2 = xb*xb; - double ya2 = ya*ya; - double yb2 = yb*yb; - double xm2 = xm*xm; - double ym2 = ym*ym; - - double wurzel = 2.0*xa*xm*yb2+2.0*ya*ym*xb2-2.0*xa*xb*r2+2.0*xa*xb*ym2-2.0*ya*yb*r2+2.0*xa2*yb*ym - +2.0*xa*xm*ya*ym-2.0*xa*xm*yb*ym-2.0*ya*ym*xb*xm+2.0*xb*xm*yb*ym+2.0*ya*yb*xa*xb - -2.0*ya*yb*xa*xm-2.0*ya*yb*xb*xm-2.0*xa*xb*ya*ym-2.0*xa*xb*yb*ym+2.0*xb*xm*ya2 - +2.0*ya*yb*xm2-xa2*yb2-xb2*ya2+xa2*r2-xa2*ym2+xb2*r2-xb2*ym2+ya2*r2-ya2*xm2+yb2*r2-yb2*xm2; - double nenner = -2.0*(ya*yb+xa*xb)+xa2+xb2+ya2+yb2; - double zaehler = 2.0*(-xa*xm+xb*xm-ya*ym+yb*ym)+xa2-xb2+ya2-yb2; - - if(UbMath::greaterEqual(wurzel,0.0) && !UbMath::zero(nenner) )//fabs(nenner)>1.E-13) - { - t1 = (zaehler+2.0*sqrt(wurzel))/nenner; - t2 = (zaehler-2.0*sqrt(wurzel))/nenner; - - if(UbMath::inClosedInterval(t1, -1.0, 1.0)) //Schnittpunkt innerhalb der Strecke - { - double x = xa*(0.5-0.5*t1)+xb*(0.5+0.5*t1); - double y = ya*(0.5-0.5*t1)+yb*(0.5+0.5*t1); - double z = za*(0.5-0.5*t1)+zb*(0.5+0.5*t1); - - if(UbMath::inClosedInterval(z,zStart,zEnd)) //zWert muss sich innerhal der cylinderlaenge befinden - { - if (this->isParallelToX1Axis()) schnittpunkte.push_back(new GbPoint3D(z,x,y)); - else if(this->isParallelToX2Axis()) schnittpunkte.push_back(new GbPoint3D(x,z,y)); - else if(this->isParallelToX3Axis()) schnittpunkte.push_back(new GbPoint3D(x,y,z)); - } - } - if(fabs(t2-t1)>1.E-13 && UbMath::inClosedInterval(t2, -1.0, 1.0)) //Schnittpunkt innerhalb der Strecke - { - double x = xa*(0.5-0.5*t2)+xb*(0.5+0.5*t2); - double y = ya*(0.5-0.5*t2)+yb*(0.5+0.5*t2); - double z = za*(0.5-0.5*t2)+zb*(0.5+0.5*t2); - - if(UbMath::inClosedInterval(z,zStart,zEnd)) //zWert muss sich innerhal der cylinderlaenge befinden - { - if (this->isParallelToX1Axis()) schnittpunkte.push_back(new GbPoint3D(z,x,y)); - else if(this->isParallelToX2Axis()) schnittpunkte.push_back(new GbPoint3D(x,z,y)); - else if(this->isParallelToX3Axis()) schnittpunkte.push_back(new GbPoint3D(x,y,z)); - } - } - } - //wenn nenner==0 -> Strecke parallel zu Zylinder! Es muss noch auf Schnittpunkt mit "Deckeln" geprueft werden - - //Schnittpunkt mit Seitenflaechen bestimmen - //hierzu wird der schnittpunkt der gegebnen strecke mit den seitenflaechenberechnet - //als erstes "schaut man seitlich auf den Zylinder" --> kreisflaechen wird als strecke darsgestellt - //mit diesen "strecken" berechnet man Schnittpunkte. - //anschliessend wird geprueft, ob der berechnete Schnittpunkt ueberhaupt im kreis liegt - //falls ja --> Schnittpunkt vorhanden - - double x1a,y1a,z1a,x1b,y1b,z1b, //uebergebene Strecke - x2a,y2a,x2b,y2b, //erste "Kreisstrecke" - x3a,y3a,x3b,y3b, //zweite "Kreisstrecke" - y2m,z2m,y3m,z3m; - double nenner1ab; - - if(this->isParallelToX1Axis()) - { - x1a=point1.getX1Coordinate(); - y1a=point1.getX2Coordinate(); - z1a=point1.getX3Coordinate(); - x1b=point2.getX1Coordinate(); - y1b=point2.getX2Coordinate(); - z1b=point2.getX3Coordinate(); - - x2a=mLine->getPoint1()->getX1Coordinate(); - y2m=mLine->getPoint1()->getX2Coordinate(); - z2m=mLine->getPoint1()->getX3Coordinate(); - y2a=y2m+mRad; - x2b=mLine->getPoint1()->getX1Coordinate(); - y2b=y2m-mRad; - - x3a=mLine->getPoint2()->getX1Coordinate(); // - y3m=mLine->getPoint2()->getX2Coordinate(); - z3m=mLine->getPoint2()->getX3Coordinate(); - y3a=y3m+mRad; - x3b=mLine->getPoint2()->getX1Coordinate(); - y3b=y3m-mRad; - } - else if(this->isParallelToX2Axis()) - { - x1a=point1.getX2Coordinate(); - y1a=point1.getX3Coordinate(); - z1a=point1.getX1Coordinate(); - x1b=point2.getX2Coordinate(); - y1b=point2.getX3Coordinate(); - z1b=point2.getX1Coordinate(); - - x2a=mLine->getPoint1()->getX2Coordinate(); - y2m=mLine->getPoint1()->getX3Coordinate(); - z2m=mLine->getPoint1()->getX1Coordinate(); - y2a=y2m+mRad; - x2b=mLine->getPoint1()->getX2Coordinate(); - y2b=y2m-mRad; - - x3a=mLine->getPoint2()->getX2Coordinate(); // - y3m=mLine->getPoint2()->getX3Coordinate(); - z3m=mLine->getPoint2()->getX1Coordinate(); - y3a=y3m+mRad; - x3b=mLine->getPoint2()->getX2Coordinate(); - y3b=y3m-mRad; - } - else if(this->isParallelToX3Axis()) - { - x1a=point1.getX3Coordinate(); - y1a=point1.getX2Coordinate(); - z1a=point1.getX1Coordinate(); - x1b=point2.getX3Coordinate(); - y1b=point2.getX2Coordinate(); - z1b=point2.getX1Coordinate(); - - x2a=mLine->getPoint1()->getX3Coordinate(); - y2m=mLine->getPoint1()->getX2Coordinate(); - z2m=mLine->getPoint1()->getX1Coordinate(); - y2a=y2m+mRad; - x2b=mLine->getPoint1()->getX3Coordinate(); - y2b=y2m-mRad; - - x3a=mLine->getPoint2()->getX3Coordinate(); // - y3m=mLine->getPoint2()->getX2Coordinate(); - z3m=mLine->getPoint2()->getX1Coordinate(); - y3a=y3m+mRad; - x3b=mLine->getPoint2()->getX3Coordinate(); - y3b=y3m-mRad; - } - else throw UbException(UB_EXARGS,"funktioniert derzeit nur mit achsenparallelen Zylindern"); - - nenner1ab = -y1a*x2a+y1a*x2b+y1b*x2a-y1b*x2b+x1a*y2a-x1a*y2b-x1b*y2a+x1b*y2b; - //double nenner2 = x1a*y2a-x1a*y2b-x1b*y2a+x1b*y2b-y1a*x2a+y1a*x2b+y1b*x2a-y1b*x2b; - if(fabs(nenner1ab)>1.E-13) //andernfalls sind die beiden Strecken parallel - { - //tStrecke ist fuer gegebene Strecke! - double t1ab = (-y1a*x2a+y1a*x2b-2.0*y2a*x2b+x1a*y2a-x1a*y2b-x1b*y2b+2.0*y2b*x2a+x1b*y2a-y1b*x2a+y1b*x2b)/nenner1ab; - //double tStrecke = -(-x1a*y2a+x1a*y2b+2.0*y2a*x2b+y1a*x2a-2.0*x2a*y2b-y1a*x2b+y1b*x2a-y1b*x2b-x1b*y2a+x1b*y2b)/nenner2; - //wenn -1 <= t2 <= +1 -> SP mit strecke - if(UbMath::inClosedInterval(t1ab, -1.0, 1.0)) //Schnittpunkt innerhalb der Strecke - { - double x,y,z,abstand_ist; - if (this->isParallelToX1Axis()) - { - x = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab); - y = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab); - z = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab); - abstand_ist=sqrt((y3m-y)*(y3m-y)+(z3m-z)*(z3m-z)); - } - else if(this->isParallelToX2Axis()) - { - y = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab); - z = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab); - x = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab); - abstand_ist=sqrt((y3m-z)*(y3m-z)+(z3m-x)*(z3m-x)); - } - else if(this->isParallelToX3Axis()) - { - z = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab); - y = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab); - x = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab); - abstand_ist=sqrt((y3m-y)*(y3m-y)+(z3m-x)*(z3m-x)); - } - else throw UbException(UB_EXARGS,"funktioniert derzeit nur mit achsenparallelen Zylindern"); - - //pruefen, ob Punkt Element von Kreisflaeche - //double abstand_ist=sqrt((y2m-y)*(y2m-y)+(z2m-z)*(z2m-z)); - if(UbMath::lessEqual(abstand_ist,mRad)) //Punkt ist Schnittpunkt - { - bool exists = false; - for(int pos=0;pos<(int)schnittpunkte.size();++pos) - { - if( fabs(schnittpunkte[pos]->getX1Coordinate()-x)<1.E-13 - && fabs(schnittpunkte[pos]->getX2Coordinate()-y)<1.E-13 - && fabs(schnittpunkte[pos]->getX3Coordinate()-z)<1.E-13 ) exists=true; - } - - if(!exists) schnittpunkte.push_back(new GbPoint3D(x,y,z)); - } - } - } - - nenner1ab = -y1a*x3a+y1a*x3b+y1b*x3a-y1b*x3b+x1a*y3a-x1a*y3b-x1b*y3a+x1b*y3b; - - if(fabs(nenner1ab)>1.E-13) //andernfalls sind die beiden Strecken parallel - { - //tStrecke ist fuer gegebene Strecke! - double t1ab = (-y1a*x3a+y1a*x3b-x1b*y3b-2.0*y3a*x3b-x1a*y3b+2.0*y3b*x3a+x1a*y3a+x1b*y3a-y1b*x3a+y1b*x3b)/nenner1ab; - - if(UbMath::inClosedInterval(t1ab, -1.0, 1.0)) //Schnittpunkt innerhalb der Strecke - { - double x,y,z,abstand_ist; - if (this->isParallelToX1Axis()) - { - x = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab); - y = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab); - z = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab); - abstand_ist=sqrt((y3m-y)*(y3m-y)+(z3m-z)*(z3m-z)); - } - else if(this->isParallelToX2Axis()) - { - y = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab); - z = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab); - x = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab); - abstand_ist=sqrt((y3m-z)*(y3m-z)+(z3m-x)*(z3m-x)); - } - else if(this->isParallelToX3Axis()) - { - z = x1a*(0.5-0.5*t1ab)+x1b*(0.5+0.5*t1ab); - y = y1a*(0.5-0.5*t1ab)+y1b*(0.5+0.5*t1ab); - x = z1a*(0.5-0.5*t1ab)+z1b*(0.5+0.5*t1ab); - abstand_ist=sqrt((y3m-y)*(y3m-y)+(z3m-x)*(z3m-x)); - } - else throw UbException(UB_EXARGS,"cylinder must be parallel to one axis"); - - //pruefen, ob Punkt Element von Kreisflaeche - //double abstand_ist=sqrt((y2m-y)*(y2m-y)+(z2m-z)*(z2m-z)); - - if(UbMath::lessEqual(abstand_ist,mRad)) //Punkt ist Schnittpunkt - { - bool exists = false; - for(int pos=0;pos<(int)schnittpunkte.size();++pos) - { - if( fabs(schnittpunkte[pos]->getX1Coordinate()-x)<1.E-13 - && fabs(schnittpunkte[pos]->getX2Coordinate()-y)<1.E-13 - && fabs(schnittpunkte[pos]->getX3Coordinate()-z)<1.E-13 ) exists=true; - } - - if(!exists) schnittpunkte.push_back(new GbPoint3D(x,y,z)); - } - } - } - - int nofSchnittpunkte = (int)schnittpunkte.size(); - if (nofSchnittpunkte==0) return NULL; - else if(nofSchnittpunkte >2) throw UbException(UB_EXARGS,"more than three intersection points - not possible"); - else if(nofSchnittpunkte==2) return new GbLine3D(schnittpunkte[0],schnittpunkte[1]); - else if(nofSchnittpunkte==1) - { - if (this->isPointInGbObject3D(&point1)) return new GbLine3D(schnittpunkte[0],new GbPoint3D(point1)); - else if(this->isPointInGbObject3D(&point2)) return new GbLine3D(schnittpunkte[0],new GbPoint3D(point2)); - else return new GbLine3D(schnittpunkte[0],new GbPoint3D(*(schnittpunkte[0]))); //strecke beruehrt clippedLine reduziert sich auf einen Punkt!!! - } - - return NULL; -} -/*==========================================================*/ -vector<GbTriangle3D*> GbCylinder3D::getSurfaceTriangleSet() -{ - double x1ma,x1mb,x2m,x3m; - if( this->isParallelToX1Axis() ) - { - x1ma = this->getX1Minimum(); - x1mb = this->getX1Maximum(); - x2m = this->getX2Centroid(); - x3m = this->getX3Centroid(); - } - else if( this->isParallelToX2Axis() ) - { - x1ma = this->getX2Minimum(); - x1mb = this->getX2Maximum(); - x2m = this->getX1Centroid(); - x3m = this->getX3Centroid(); - } - else if( this->isParallelToX3Axis() ) - { - x1ma = this->getX3Minimum(); - x1mb = this->getX3Maximum(); - x2m = this->getX2Centroid(); - x3m = this->getX1Centroid(); - } - else throw UbException(UB_EXARGS,"cylinder not axis prallel"); - - vector<GbTriangle3D*> triangles; - - int segmentsCircle = 20; - double deltaPhi = UbMath::PI/(double)segmentsCircle; - - double phiX1a,phiX1b; - double x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d; - - double dXCylinder = fabs((x1mb-x1ma))/(double)segmentsCircle; - int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder); - for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++) - { - x1a = x1d = x1ma+segCyl*dXCylinder; - x1b = x1c = x1a+dXCylinder; - - for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = x2m+mRad*std::sin(phiX1a); - x3a = x3m+mRad*std::cos(phiX1a); - x2b = x2m+mRad*std::sin(phiX1b); - x3b = x3m+mRad*std::cos(phiX1b); - - if( this->isParallelToX1Axis() ) - { - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1b,x2b,x3b),new GbPoint3D(x1b,x2a,x3a),new GbPoint3D(x1a,x2a,x3a))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1a,x2a,x3a),new GbPoint3D(x1a,x2b,x3b),new GbPoint3D(x1b,x2b,x3b))); - } - else if( this->isParallelToX2Axis() ) - { - triangles.push_back(new GbTriangle3D(new GbPoint3D(x2b,x1b,x3b),new GbPoint3D(x2a,x1b,x3a),new GbPoint3D(x2a,x1a,x3a))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x2a,x1a,x3a),new GbPoint3D(x2b,x1a,x3b),new GbPoint3D(x2b,x1b,x3b))); - } - else if( this->isParallelToX3Axis() ) - { - triangles.push_back(new GbTriangle3D(new GbPoint3D(x3b,x2b,x1b),new GbPoint3D(x3a,x2a,x1b),new GbPoint3D(x3a,x2a,x1a))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x3a,x2a,x1a),new GbPoint3D(x3b,x2b,x1a),new GbPoint3D(x3b,x2b,x1b))); - } - - } - } - - int segmentsSide = (int)(mRad/dXCylinder); - double radius0, radius1; - for(int segCyl = 0; segCyl<segmentsSide; segCyl++) - { - radius0 = segCyl*dXCylinder; - radius1 = radius0+dXCylinder; - if(segCyl==segmentsSide-1) radius1=mRad; - - for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = x2m+radius0*std::sin(phiX1a); - x3a = x3m+radius0*std::cos(phiX1a); - x2b = x2m+radius0*std::sin(phiX1b); - x3b = x3m+radius0*std::cos(phiX1b); - x2c = x2m+radius1*std::sin(phiX1b); - x3c = x3m+radius1*std::cos(phiX1b); - x2d = x2m+radius1*std::sin(phiX1a); - x3d = x3m+radius1*std::cos(phiX1a); - - if( this->isParallelToX1Axis() ) - { - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1ma,x2a,x3a),new GbPoint3D(x1ma,x2b,x3b),new GbPoint3D(x1ma,x2c,x3c))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1ma,x2c,x3c),new GbPoint3D(x1ma,x2d,x3d),new GbPoint3D(x1ma,x2a,x3a))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1mb,x2c,x3c),new GbPoint3D(x1mb,x2b,x3b),new GbPoint3D(x1mb,x2a,x3a))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1mb,x2a,x3a),new GbPoint3D(x1mb,x2d,x3d),new GbPoint3D(x1mb,x2c,x3c))); - } - else if( this->isParallelToX2Axis() ) - { - triangles.push_back(new GbTriangle3D(new GbPoint3D(x2a,x1ma,x3a),new GbPoint3D(x2b,x1ma,x3b),new GbPoint3D(x2c,x1ma,x3c))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x2c,x1ma,x3c),new GbPoint3D(x2d,x1ma,x3d),new GbPoint3D(x2a,x1ma,x3a))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x2c,x1mb,x3c),new GbPoint3D(x2b,x1mb,x3b),new GbPoint3D(x2a,x1mb,x3a))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x2a,x1mb,x3a),new GbPoint3D(x2d,x1mb,x3d),new GbPoint3D(x2c,x1mb,x3c))); - } - else if( this->isParallelToX3Axis() ) - { - triangles.push_back(new GbTriangle3D(new GbPoint3D(x3a,x2a,x1ma),new GbPoint3D(x3b,x2b,x1ma),new GbPoint3D(x3c,x2c,x1ma))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x3c,x2c,x1ma),new GbPoint3D(x3d,x2d,x1ma),new GbPoint3D(x3a,x2a,x1ma))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x3c,x2c,x1mb),new GbPoint3D(x3b,x2b,x1mb),new GbPoint3D(x3a,x2a,x1mb))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x3a,x2a,x1mb),new GbPoint3D(x3d,x2d,x1mb),new GbPoint3D(x3c,x2c,x1mb))); - } - } - } - - return triangles; -} -/*==========================================================*/ -void GbCylinder3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles) -{ - float x1ma,x1mb,x2m,x3m; - if( this->isParallelToX1Axis() ) - { - x1ma = (float)this->getX1Minimum(); - x1mb = (float)this->getX1Maximum(); - x2m = (float)this->getX2Centroid(); - x3m = (float)this->getX3Centroid(); - } - else if( this->isParallelToX2Axis() ) - { - x1ma = (float)this->getX2Minimum(); - x1mb = (float)this->getX2Maximum(); - x2m = (float)this->getX1Centroid(); - x3m = (float)this->getX3Centroid(); - } - else if( this->isParallelToX3Axis() ) - { - x1ma = (float)this->getX3Minimum(); - x1mb = (float)this->getX3Maximum(); - x2m = (float)this->getX2Centroid(); - x3m = (float)this->getX1Centroid(); - } - else throw UbException(UB_EXARGS,"cylinder not axis prallel"); - - int segmentsCircle = 20; - double deltaPhi = UbMath::PI/(double)segmentsCircle; - - double phiX1a,phiX1b; - float x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d; - - double dXCylinder = fabs((x1mb-x1ma))/(double)segmentsCircle; - int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder); - int nodenr = 0; - for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++) - { - x1a = x1d = (float)(x1ma+segCyl*dXCylinder); - x1b = x1c = (float)(x1a+dXCylinder); - - for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = (float)(x2m+mRad*std::sin(phiX1a)); - x3a = (float)(x3m+mRad*std::cos(phiX1a)); - x2b = (float)(x2m+mRad*std::sin(phiX1b)); - x3b = (float)(x3m+mRad*std::cos(phiX1b)); - - if( this->isParallelToX1Axis() ) - { - nodes.push_back( makeUbTuple(x1b,x2b,x3b) ); nodes.push_back( makeUbTuple(x1b,x2a,x3a) ); nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); - nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); nodes.push_back( makeUbTuple(x1a,x2b,x3b) ); nodes.push_back( makeUbTuple(x1b,x2b,x3b) ); - } - else if( this->isParallelToX2Axis() ) - { - nodes.push_back( makeUbTuple(x2b,x1b,x3b) ); nodes.push_back( makeUbTuple(x2a,x1b,x3a) ); nodes.push_back( makeUbTuple(x2a,x1a,x3a) ); - nodes.push_back( makeUbTuple(x2a,x1a,x3a) ); nodes.push_back( makeUbTuple(x2b,x1a,x3b) ); nodes.push_back( makeUbTuple(x2b,x1b,x3b) ); - } - else if( this->isParallelToX3Axis() ) - { - nodes.push_back( makeUbTuple(x3b,x2b,x1b) ); nodes.push_back( makeUbTuple(x3a,x2a,x1b) ); nodes.push_back( makeUbTuple(x3a,x2a,x1a) ); - nodes.push_back( makeUbTuple(x3a,x2a,x1a) ); nodes.push_back( makeUbTuple(x3b,x2b,x1a) ); nodes.push_back( makeUbTuple(x3b,x2b,x1b) ); - } - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - } - } - - int segmentsSide = (int)(mRad/dXCylinder); - double radius0, radius1; - for(int segCyl = 0; segCyl<segmentsSide; segCyl++) - { - radius0 = segCyl*dXCylinder; - radius1 = radius0+dXCylinder; - if(segCyl==segmentsSide-1) radius1=mRad; - - for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = x2m+(float)(radius0*std::sin(phiX1a)); - x3a = x3m+(float)(radius0*std::cos(phiX1a)); - x2b = x2m+(float)(radius0*std::sin(phiX1b)); - x3b = x3m+(float)(radius0*std::cos(phiX1b)); - x2c = x2m+(float)(radius1*std::sin(phiX1b)); - x3c = x3m+(float)(radius1*std::cos(phiX1b)); - x2d = x2m+(float)(radius1*std::sin(phiX1a)); - x3d = x3m+(float)(radius1*std::cos(phiX1a)); - - if( this->isParallelToX1Axis() ) - { - nodes.push_back( makeUbTuple(x1ma,x2a,x3a) ); nodes.push_back( makeUbTuple(x1ma,x2b,x3b) ); nodes.push_back( makeUbTuple(x1ma,x2c,x3c) ); - nodes.push_back( makeUbTuple(x1ma,x2c,x3c) ); nodes.push_back( makeUbTuple(x1ma,x2d,x3d) ); nodes.push_back( makeUbTuple(x1ma,x2a,x3a) ); - nodes.push_back( makeUbTuple(x1mb,x2c,x3c) ); nodes.push_back( makeUbTuple(x1mb,x2b,x3b) ); nodes.push_back( makeUbTuple(x1mb,x2a,x3a) ); - nodes.push_back( makeUbTuple(x1mb,x2a,x3a) ); nodes.push_back( makeUbTuple(x1mb,x2d,x3d) ); nodes.push_back( makeUbTuple(x1mb,x2c,x3c) ); - } - else if( this->isParallelToX2Axis() ) - { - nodes.push_back( makeUbTuple(x2a,x1ma,x3a) ); nodes.push_back( makeUbTuple(x2b,x1ma,x3b) ); nodes.push_back( makeUbTuple(x2c,x1ma,x3c) ); - nodes.push_back( makeUbTuple(x2c,x1ma,x3c) ); nodes.push_back( makeUbTuple(x2d,x1ma,x3d) ); nodes.push_back( makeUbTuple(x2a,x1ma,x3a) ); - nodes.push_back( makeUbTuple(x2c,x1mb,x3c) ); nodes.push_back( makeUbTuple(x2b,x1mb,x3b) ); nodes.push_back( makeUbTuple(x2a,x1mb,x3a) ); - nodes.push_back( makeUbTuple(x2a,x1mb,x3a) ); nodes.push_back( makeUbTuple(x2d,x1mb,x3d) ); nodes.push_back( makeUbTuple(x2c,x1mb,x3c) ); - } - else if( this->isParallelToX3Axis() ) - { - nodes.push_back( makeUbTuple(x3a,x2a,x1ma) ); nodes.push_back( makeUbTuple(x3b,x2b,x1ma) ); nodes.push_back( makeUbTuple(x3c,x2c,x1ma) ); - nodes.push_back( makeUbTuple(x3c,x2c,x1ma) ); nodes.push_back( makeUbTuple(x3d,x2d,x1ma) ); nodes.push_back( makeUbTuple(x3a,x2a,x1ma) ); - nodes.push_back( makeUbTuple(x3c,x2c,x1mb) ); nodes.push_back( makeUbTuple(x3b,x2b,x1mb) ); nodes.push_back( makeUbTuple(x3a,x2a,x1mb) ); - nodes.push_back( makeUbTuple(x3a,x2a,x1mb) ); nodes.push_back( makeUbTuple(x3d,x2d,x1mb) ); nodes.push_back( makeUbTuple(x3c,x2c,x1mb) ); - } - - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - } - } -} -/*==========================================================*/ -void GbCylinder3D::addSurfaceTriangleSetSegments(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles, int segmentsRound, int segmentsHeight ) -{ - float x1ma,x1mb,x2m,x3m; - if( this->isParallelToX1Axis() ) - { - x1ma = (float)this->getX1Minimum(); - x1mb = (float)this->getX1Maximum(); - x2m = (float)this->getX2Centroid(); - x3m = (float)this->getX3Centroid(); - } - else if( this->isParallelToX2Axis() ) - { - x1ma = (float)this->getX2Minimum(); - x1mb = (float)this->getX2Maximum(); - x2m = (float)this->getX1Centroid(); - x3m = (float)this->getX3Centroid(); - } - else if( this->isParallelToX3Axis() ) - { - x1ma = (float)this->getX3Minimum(); - x1mb = (float)this->getX3Maximum(); - x2m = (float)this->getX2Centroid(); - x3m = (float)this->getX1Centroid(); - } - else throw UbException(UB_EXARGS,"cylinder not axis prallel"); - - int segmentsCircle = segmentsRound; - double deltaPhi = UbMath::PI/(double)segmentsCircle; - - double phiX1a,phiX1b; - float x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d; - - double dXCylinder = fabs((x1mb-x1ma))/(double)segmentsHeight; //hier evtl. segmentsheight - int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder); - int nodenr = 0; - for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++) - { - x1a = x1d = (float)(x1ma+segCyl*dXCylinder); - x1b = x1c = (float)(x1a+dXCylinder); - - //for(phiX1a=2.0*UbMath::PI; phiX1a>0.0; phiX1a-=deltaPhi) - for(phiX1a=0.0; phiX1a<2.0*UbMath::PI-0.5*deltaPhi; phiX1a+=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = (float)(x2m+mRad*std::sin(phiX1a)); - x3a = (float)(x3m+mRad*std::cos(phiX1a)); - x2b = (float)(x2m+mRad*std::sin(phiX1b)); - x3b = (float)(x3m+mRad*std::cos(phiX1b)); - - if( this->isParallelToX1Axis() ) - { - nodes.push_back( makeUbTuple(x1b,x2b,x3b) ); nodes.push_back( makeUbTuple(x1b,x2a,x3a) ); nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); - nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); nodes.push_back( makeUbTuple(x1a,x2b,x3b) ); nodes.push_back( makeUbTuple(x1b,x2b,x3b) ); - } - else if( this->isParallelToX2Axis() ) - { - nodes.push_back( makeUbTuple(x2b,x1b,x3b) ); nodes.push_back( makeUbTuple(x2a,x1b,x3a) ); nodes.push_back( makeUbTuple(x2a,x1a,x3a) ); - nodes.push_back( makeUbTuple(x2a,x1a,x3a) ); nodes.push_back( makeUbTuple(x2b,x1a,x3b) ); nodes.push_back( makeUbTuple(x2b,x1b,x3b) ); - } - else if( this->isParallelToX3Axis() ) - { - nodes.push_back( makeUbTuple(x3b,x2b,x1b) ); nodes.push_back( makeUbTuple(x3a,x2a,x1b) ); nodes.push_back( makeUbTuple(x3a,x2a,x1a) ); - nodes.push_back( makeUbTuple(x3a,x2a,x1a) ); nodes.push_back( makeUbTuple(x3b,x2b,x1a) ); nodes.push_back( makeUbTuple(x3b,x2b,x1b) ); - } - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - } - } - - int segmentsSide = (int)(mRad/dXCylinder); - double radius0, radius1; - for(int segCyl = 0; segCyl<segmentsSide; segCyl++) - { - radius0 = segCyl*dXCylinder; - radius1 = radius0+dXCylinder; - if(segCyl==segmentsSide-1) radius1=mRad; - - //for(phiX1a=2.0*UbMath::PI; phiX1a>0.0; phiX1a-=deltaPhi) - for(phiX1a=0.0; phiX1a<2.0*UbMath::PI-0.5*deltaPhi; phiX1a+=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = x2m+(float)(radius0*std::sin(phiX1a)); - x3a = x3m+(float)(radius0*std::cos(phiX1a)); - x2b = x2m+(float)(radius0*std::sin(phiX1b)); - x3b = x3m+(float)(radius0*std::cos(phiX1b)); - x2c = x2m+(float)(radius1*std::sin(phiX1b)); - x3c = x3m+(float)(radius1*std::cos(phiX1b)); - x2d = x2m+(float)(radius1*std::sin(phiX1a)); - x3d = x3m+(float)(radius1*std::cos(phiX1a)); - - if( this->isParallelToX1Axis() ) - { - nodes.push_back( makeUbTuple(x1ma,x2a,x3a) ); nodes.push_back( makeUbTuple(x1ma,x2b,x3b) ); nodes.push_back( makeUbTuple(x1ma,x2c,x3c) ); - nodes.push_back( makeUbTuple(x1ma,x2c,x3c) ); nodes.push_back( makeUbTuple(x1ma,x2d,x3d) ); nodes.push_back( makeUbTuple(x1ma,x2a,x3a) ); - nodes.push_back( makeUbTuple(x1mb,x2c,x3c) ); nodes.push_back( makeUbTuple(x1mb,x2b,x3b) ); nodes.push_back( makeUbTuple(x1mb,x2a,x3a) ); - nodes.push_back( makeUbTuple(x1mb,x2a,x3a) ); nodes.push_back( makeUbTuple(x1mb,x2d,x3d) ); nodes.push_back( makeUbTuple(x1mb,x2c,x3c) ); - } - else if( this->isParallelToX2Axis() ) - { - nodes.push_back( makeUbTuple(x2a,x1ma,x3a) ); nodes.push_back( makeUbTuple(x2b,x1ma,x3b) ); nodes.push_back( makeUbTuple(x2c,x1ma,x3c) ); - nodes.push_back( makeUbTuple(x2c,x1ma,x3c) ); nodes.push_back( makeUbTuple(x2d,x1ma,x3d) ); nodes.push_back( makeUbTuple(x2a,x1ma,x3a) ); - nodes.push_back( makeUbTuple(x2c,x1mb,x3c) ); nodes.push_back( makeUbTuple(x2b,x1mb,x3b) ); nodes.push_back( makeUbTuple(x2a,x1mb,x3a) ); - nodes.push_back( makeUbTuple(x2a,x1mb,x3a) ); nodes.push_back( makeUbTuple(x2d,x1mb,x3d) ); nodes.push_back( makeUbTuple(x2c,x1mb,x3c) ); - } - else if( this->isParallelToX3Axis() ) - { - nodes.push_back( makeUbTuple(x3a,x2a,x1ma) ); nodes.push_back( makeUbTuple(x3b,x2b,x1ma) ); nodes.push_back( makeUbTuple(x3c,x2c,x1ma) ); - nodes.push_back( makeUbTuple(x3c,x2c,x1ma) ); nodes.push_back( makeUbTuple(x3d,x2d,x1ma) ); nodes.push_back( makeUbTuple(x3a,x2a,x1ma) ); - nodes.push_back( makeUbTuple(x3c,x2c,x1mb) ); nodes.push_back( makeUbTuple(x3b,x2b,x1mb) ); nodes.push_back( makeUbTuple(x3a,x2a,x1mb) ); - nodes.push_back( makeUbTuple(x3a,x2a,x1mb) ); nodes.push_back( makeUbTuple(x3d,x2d,x1mb) ); nodes.push_back( makeUbTuple(x3c,x2c,x1mb) ); - } - - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - triangles.push_back( makeUbTuple(nodenr , nodenr+1, nodenr+2) ); nodenr+=3; - } - } -} - -/*==========================================================*/ -void GbCylinder3D::objectChanged(UbObservable* changedObject) -{ - GbLine3D* line = dynamic_cast<GbLine3D*>(changedObject); - if(!line || this->mLine!=line) return; - - this->notifyObserversObjectChanged(); -} -/*==========================================================*/ -void GbCylinder3D::objectWillBeDeleted(UbObservable* objectForDeletion) -{ - if(this->mLine) - { - UbObservable* observedObj = dynamic_cast<UbObservable*>(this->mLine); - if(objectForDeletion == observedObj) { this->mLine = NULL; } - } -} -/*=======================================================*/ -void GbCylinder3D::scale(const double& sx1, const double& sx2, const double& sx3) -{ - if( this->isParallelToX1Axis() ) - { - if(!UbMath::equal(sx2,sx3)) throw UbException(UB_EXARGS,"|| to x1 -> different scaling sx2 and sx3 not possible"); - this->mRad*=sx2; - } - else if( this->isParallelToX2Axis() ) - { - if(!UbMath::equal(sx1,sx3)) throw UbException(UB_EXARGS,"|| to x2 -> different scaling sx1 and sx3 not possible"); - this->mRad*=sx1; - } - else if( this->isParallelToX3Axis() ) - { - if(!UbMath::equal(sx1,sx2)) throw UbException(UB_EXARGS,"|| to x3 -> different scaling sx1 and sx2 not possible"); - this->mRad*=sx1; - } - else throw UbException(UB_EXARGS,"unknown direction"); - - this->mLine->scale(sx1,sx2,sx3); - //notify observer wird automatisch aufgerufen -} -/*==========================================================*/ -void GbCylinder3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - mLine->write(out); - out->writeDouble(mRad); - out->writeInteger(cylinderType); -} -/*==========================================================*/ -void GbCylinder3D::read(UbFileInput* in) -{ - in->readString(); - mLine = new GbLine3D; - mLine->read(in); - mRad = in->readDouble(); - cylinderType = in->readInteger(); -} -/*==========================================================*/ -double GbCylinder3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) -{ - /* - Distance D of the intersection between a Ray((ox1,ox2,ox3),(dx1,dx2,dx3)) and a Plane P: ax+by+cz+d=0 - dc = a*dx1 + b*dx2 + c*dx3 - dw = a*ox1 + b*ox2 + c*ox3 + d - D = - dw / dc - */ - double px1, px2, px3; - double d = Ub::inf; // Distance to Min or Max Plane of the Zylinder - // final distance should be less that d - - if( this->isParallelToX1Axis() ) - { - if (UbMath::equal(x1 ,minX1) && UbMath::negative(rx1)) return -1.0; - else if(UbMath::equal(x1 ,maxX1) && UbMath::positive(rx1)) return -1.0; - - //falls die Linie nicht parallel zu den Seitenflaechen ist - if( x1< minX1 || x1 > maxX1 ) //nur fuer punkte links und rechts des cylinders - { - px1 = (x1 < minX1 ? minX1 : maxX1); - //falls die Linie nicht parallel zu den Seitenflaechen ist - if( !UbMath::zero(rx1) ) - { - // Plane a= 0, b= 1, c=0 d= -1*px2 - d = -1.0*(x1 - px1) / rx1; - px2 = x2 + d*rx2; - px3 = x3 + d*rx3; - - if(UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad)) - { - if (x1 < minX1 && rx1>0.0 ) d = Ub::inf; //punkt liegt "links" vom cylinder und strahl hat evtl weiteren SP auf oberflaeche - else if(x1 > maxX1 && rx1<0.0 ) d = Ub::inf; - else return -1.0; - } - else return d; - } - else return -1.0; - } - else - { - //if (UbMath::negative(rx1)) d = -1.0 * (x1 - minX1) / rx1; - //else if(UbMath::positive(rx1)) d = -1.0 * (x1 - maxX1) / rx1; - if (UbMath::negative(rx1)) d = -1.0 * (x1 - maxX1) / rx1; - else if(UbMath::positive(rx1)) d = -1.0 * (x1 - minX1) / rx1; - } - } - else if( this->isParallelToX2Axis() ) - { - if (UbMath::equal(x2 ,minX2) && UbMath::negative(rx2)) return -1; - else if(UbMath::equal(x2 ,maxX2) && UbMath::positive(rx2)) return -1; - - if( minX2 > x2 || x2 > maxX2 ) - { - px2 = (x2 < minX2 ? minX2 : maxX2); - //falls die Linie nicht parallel zu den Seitenflaechen ist - if( !UbMath::zero(rx2) ) - { - // Plane a= 0, b= 1, c=0 d= -1*px2 - d = -1*(x2 - px2) / rx2; - px1 = x1 + d*rx1; - px3 = x3 + d*rx3; - - if (UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad)) - { - if (x2 < minX2 && rx2>0.0 ) d = Ub::inf; //punkt liegt "links oberhalb" vom cylinder und strahl mit pos x1 hat evtl weiteren SP auf oberflaeche - else if(x2 > maxX2 && rx2<0.0 ) d = Ub::inf; - else return -1.0; - } - else return d; - } - else return -1.0; - } - else - { - if (UbMath::negative(rx2)) d = -1.0 * (x2 - minX2) / rx2; - else if(UbMath::positive(rx2)) d = -1.0 * (x2 - maxX2) / rx2; - } - } - else if( this->isParallelToX3Axis() ) - { - if (UbMath::equal(x3, minX3) && UbMath::negative(rx3)) return -1.0; - else if(UbMath::equal(x3, maxX3) && UbMath::positive(rx3)) return -1.0; - - if(minX3 > x3 || x3 > maxX3 ) - { - px3 = (x3 < minX3 ? minX3 : maxX3); - //falls die Linie nicht parallel zu den Seitenflaechen ist - if (!UbMath::zero(rx3)) - { - // Plane a= 0, b= 0, c=1 d= -1*px3 - d = -1.0*(x3 - px3) / rx3; - px2 = x2 + d*rx2; - px1 = x1 + d*rx1; - if( UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad) ) - { - if (x3 < minX3 && rx3>0.0 ) d = Ub::inf; - else if(x3 > maxX3 && rx3<0.0 ) d = Ub::inf; - else return -1.0; - } - else return d; - } - else return -1.0; - } - else - { - if (UbMath::negative(rx3)) d = -1.0 * (x3 - minX3) / rx3; - else if(UbMath::positive(rx3)) d = -1.0 * (x3 - maxX3) / rx3; - } - } - else throw UbException(UB_EXARGS,"funzt nur bei achsen parallelem cylinder"); - ////////////////////////////////////////////////////////////////////////// - //Q berechnen fuer Infinity Zylinder - double axisX1 = mLine->getPoint2()->x1 - mLine->getPoint1()->x1; /* Axis of the cylinder */ - double axisX2 = mLine->getPoint2()->x2 - mLine->getPoint1()->x2; /* mit p1 als base of cylinder */ - double axisX3 = mLine->getPoint2()->x3 - mLine->getPoint1()->x3; - - //double dirlen = mLine->getLength(); - //double abs, t, s; - - double RCx1 = x1 - mLine->getPoint1()->x1; - double RCx2 = x2 - mLine->getPoint1()->x2; - double RCx3 = x3 - mLine->getPoint1()->x3; - - //n = ray x axis - double nx1 = rx2*axisX3 - rx3*axisX2; - double nx2 = rx3*axisX1 - rx1*axisX3; - double nx3 = rx1*axisX2 - rx2*axisX1; - double nLength = nx1*nx1 + nx2*nx2 + nx3*nx3; - - double abs; - if( UbMath::zero( nLength ) ) - { /* ray parallel to cyl */ - //abs = RC dot axis - double tmpabs = RCx1*axisX1 + RCx2*axisX2 + RCx3*axisX3; - double dx1 = RCx1 - tmpabs*axisX1; - double dx2 = RCx2 - tmpabs*axisX2; - double dx3 = RCx3 - tmpabs*axisX3; - if( UbMath::greater( dx1*dx1 + dx2*dx2 + dx3*dx3 , mRad*mRad) ) - return -1.0; - } - - //normalize "n" - nLength = std::sqrt(nLength); - double invnLength = 1.0/nLength; - nx1*=invnLength; - nx2*=invnLength; - nx3*=invnLength; - - //shortest distance = fabs( RC dot n ) - abs = std::fabs( RCx1*nx1 + RCx2*nx2 + RCx3*nx3 ); - - if( UbMath::lessEqual(abs, mRad) ) - { /* if ray hits cylinder */ - //Ox1 = RC x axis - double Ox1 = RCx2*axisX3 - RCx3*axisX2; - double Ox2 = RCx3*axisX1 - RCx1*axisX3; - double Ox3 = RCx1*axisX2 - RCx2*axisX1; - //t = - O dot n / nLength; - double t = - (Ox1*nx1 + Ox2*nx2 + Ox3*nx3) / nLength; - - //O = n x axis; - Ox1 = nx2*axisX3 - nx3*axisX2; - Ox2 = nx3*axisX1 - nx1*axisX3; - Ox3 = nx1*axisX2 - nx2*axisX1; - - //normalize O - invnLength = 1.0/std::sqrt(Ox1*Ox1 + Ox2*Ox2 + Ox3*Ox3); - Ox1*=invnLength; - Ox2*=invnLength; - Ox3*=invnLength; - - double s = std::fabs( sqrt(mRad*mRad - abs*abs) / (rx1*Ox1 + rx2*Ox2 + rx3*Ox3) ); - - //Wert a) t-s: entering distance - // b) t+s: exiting distance - // - // -> we only consider factors in ray-dir -> means positive values! - // (s is always positive) - - if(t>s) - { - return UbMath::min( t-s, d ); - } - else if( (t+s) > 0 ) - { - return UbMath::min( t+s, d ); - } - } - - return -1.0; -} -/*==========================================================*/ diff --git a/src/basics/geometry3d/GbCylinder3D.h b/src/basics/geometry3d/GbCylinder3D.h deleted file mode 100644 index e32d2008f..000000000 --- a/src/basics/geometry3d/GbCylinder3D.h +++ /dev/null @@ -1,153 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBCYLINDER3D_H -#define GBCYLINDER3D_H - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -#include <vector> -#include <cmath> - -#include <numerics/geometry3d/GbObject3D.h> -#include <numerics/geometry3d/GbLine3D.h> -#include <basics/utilities/UbObserver.h> - -class GbPoint3D; -class GbLine3D; -class GbTriangle3D; - -class GbObject3DCreator; - -#include <PointerDefinitions.h> -class GbCylinder3D; -typedef SPtr<GbCylinder3D> GbCylinder3DPtr; - - -class GbCylinder3D : public GbObject3D , public UbObserver -{ -public: - GbCylinder3D(); - GbCylinder3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& radius); - GbCylinder3D(GbPoint3D* p1, GbPoint3D* p2, const double& radius); - GbCylinder3D(GbLine3D* line, const double& rad); - GbCylinder3D(GbCylinder3D* cylinder); - ~GbCylinder3D(); - - GbCylinder3D* clone() { return new GbCylinder3D(this); } - void finalize(); - - double getRadius() { return this->mRad; }; - GbLine3D* getLine() {return mLine;} - GbPoint3D* getPoint1(); - GbPoint3D* getPoint2(); - - void setRadius(const double& radius); - void setLine(GbLine3D* line); - void setPoint1(const double& x1, const double& x2, const double& x3); - void setPoint2(const double& x1, const double& x2, const double& x3); - - bool isParallelToX1Axis() { return((this->cylinderType & X1PARALLEL ) == X1PARALLEL );} - bool isParallelToX2Axis() { return((this->cylinderType & X2PARALLEL ) == X2PARALLEL );} - bool isParallelToX3Axis() { return((this->cylinderType & X3PARALLEL ) == X3PARALLEL );} - bool isNotParallelToAxis(){ return((this->cylinderType & NOTPARALLELTOAXIS ) == NOTPARALLELTOAXIS );} - - double getHeight(); - - void scale(const double& sx1, const double& sx2, const double& sx3); - - void translate(const double& x1, const double& x2, const double& x3) - { - this->mLine->translate( x1, x2, x3 ); - this->calculateValues(); - //this->notifyObserversObjectChanged(); - } - - double getX1Centroid() { return centerX1; } - double getX1Minimum() { return minX1; } - double getX1Maximum() { return maxX1; } - double getX2Centroid() { return centerX2; } - double getX2Minimum() { return minX2; } - double getX2Maximum() { return maxX2; } - double getX3Centroid() { return centerX3; } - double getX3Minimum() { return minX3; } - double getX3Maximum() { return maxX3; } - - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p); - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); - 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); - - GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2); - - //SG ausdokumentieren, da der nur unendlcihe Zylinder macht ... - //bool hasRaytracing() { return true; } - bool hasRaytracing() { return false; } - bool raytracingSupportsPointsInside() { return true; } - - - /*|r| must be 1! einheitsvector!!*/ - double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3); - - std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles); - void addSurfaceTriangleSetSegments(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles, int segmentsRound, int segmentsHeight ); - - std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - - //virtuelle Methoden von UbObserver - void objectChanged(UbObservable* changedObject); - void objectWillBeDeleted(UbObservable* objectForDeletion); - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & mLine; - ar & mRad; - ar & cylinderType; - - if( ArchiveTools::isReading(ar) ) - this->calculateValues(); - } -#endif //CAB_RCF - - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere - - -protected: - void calculateValues(); - - GbLine3D* mLine; - double mRad; - - double minX1, minX2, minX3; - double maxX1, maxX2, maxX3; - double centerX1, centerX2, centerX3; - - int cylinderType; - - //void berechneQuerschnittsWerte(); - static const int NOTPARALLELTOAXIS = (1<<0); //1 - static const int X1PARALLEL = (1<<1); //2 - static const int X2PARALLEL = (1<<2); //4 - static const int X3PARALLEL = (1<<3); //8 -}; - -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - UB_AUTO_RUN_NAMED( SF::registerType<GbCylinder3D >("GbCylinder3D") , SF_GbCylinder3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbCylinder3D >() ), SF_GbCylinder3D_BD1 ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbCylinder3D>() ), SF_GbCylinder3D_BD2 ); -#endif //RCF_USE_SF_SERIALIZATION - -#endif diff --git a/src/basics/geometry3d/GbHalfSpace3D.cpp b/src/basics/geometry3d/GbHalfSpace3D.cpp deleted file mode 100644 index cb4ec6c4e..000000000 --- a/src/basics/geometry3d/GbHalfSpace3D.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include <numerics/geometry3d/GbHalfSpace3D.h> - -using namespace std; - -/*==========================================================*/ -GbHalfSpace3D::GbHalfSpace3D(GbTriangle3D* triangle) -{ - GbPoint3D* PointA = triangle->getPoint1(); - GbPoint3D* PointB = triangle->getPoint2(); - GbPoint3D* PointC = triangle->getPoint3(); - - GbVector3D A(PointA->x1, PointA->x2, PointA->x3 ); - GbVector3D BA(PointB->x1-PointA->x1, PointB->x2-PointA->x2, PointB->x3-PointA->x3 ); - GbVector3D CA(PointC->x1-PointA->x1, PointC->x2-PointA->x2, PointC->x3-PointA->x3 ); - GbVector3D BACA = BA.Cross(CA); - //this->Normal = PointB->subtract(PointA)->cross(PointC->subtract(PointA))->normalize(); - BACA.Normalize(); - //this->Normal = BACA; - normalX = BACA[0]; - normalY = BACA[1]; - normalZ = BACA[2]; - //this->d = this->Normal.Dot(A); - this->d = normalX*A[0] + normalY*A[1] + normalZ*A[2] ; -} -/*==========================================================*/ -GbHalfSpace3D::GbHalfSpace3D(GbPoint3D* PointA, GbPoint3D* PointB, GbPoint3D* PointC) -{ - GbVector3D A(PointA->x1, PointA->x2, PointA->x3 ); - GbVector3D BA(PointB->x1-PointA->x1, PointB->x2-PointA->x2, PointB->x3-PointA->x3 ); - GbVector3D CA(PointC->x1-PointA->x1, PointC->x2-PointA->x2, PointC->x3-PointA->x3 ); - GbVector3D BACA = BA.Cross(CA); - //this->Normal = PointB->subtract(PointA)->cross(PointC->subtract(PointA))->normalize(); - BACA.Normalize(); - //this->Normal = BACA; - normalX = BACA[0]; - normalY = BACA[1]; - normalZ = BACA[2]; - //this->d = this->Normal.Dot(A); - this->d = normalX*A[0] + normalY*A[1] + normalZ*A[2] ; -} -/*==========================================================*/ -GbHalfSpace3D::GbHalfSpace3D(GbPoint3D* PointA, GbPoint3D* PointB) -{ - GbVector3D A(PointA->x1, PointA->x2, PointA->x3 ); - GbVector3D B(PointB->x1, PointB->x2, PointB->x3 ); - GbVector3D K(0.0,0.0,0.99); // the vector from PointA - third point - - GbVector3D PointBA = B-A; - GbVector3D PointBAK = PointBA.Cross(K); - PointBAK.Normalize(); - - //this->Normal = PointBAK; - normalX = PointBAK[0]; - normalY = PointBAK[1]; - normalZ = PointBAK[2]; - - //this->d = this->Normal.Dot(A); - this->d = normalX*PointA->x1 + normalY*PointA->x2 + normalZ*PointA->x3; -} -/*==========================================================*/ -GbHalfSpace3D::GbHalfSpace3D( const double& p1x, const double& p1y, const double& p1z - , const double& p2x, const double& p2y, const double& p2z - , const double& p3x, const double& p3y, const double& p3z ) -{ - double p2minusP1x = p2x-p1x; - double p2minusP1y = p2y-p1y; - double p2minusP1z = p2z-p1z; - - double P3minusP1x = p3x-p1x; - double P3minusP1y = p3y-p1y; - double P3minusP1z = p3z-p1z; - - //normal = BA x CA - normalX = p2minusP1y*P3minusP1z - p2minusP1z*P3minusP1y; - normalY = p2minusP1z*P3minusP1x - p2minusP1x*P3minusP1z; - normalZ = p2minusP1x*P3minusP1y - p2minusP1y*P3minusP1x; - - //normalize BACA - double oneOverNormalLength = 1.0 / ( std::sqrt( normalX*normalX + normalY*normalY + normalZ*normalZ ) ); - normalX *= oneOverNormalLength; - normalY *= oneOverNormalLength; - normalZ *= oneOverNormalLength; - - //d = normal * p1 - this->d = normalX*p1x + normalY*p1y + normalZ*p1z; -} -/*==========================================================*/ -GbHalfSpace3D::GbHalfSpace3D( const double& p1x, const double& p1y, const double& p1z, - const double& nx, const double& ny, const double& nz) -{ - //normal = BA x CA - normalX =nx; - normalY =ny; - normalZ =nz; - - //d = normal * p1 - this->d = nx*p1x + ny*p1y + nz*p1z; -} -/*==========================================================*/ diff --git a/src/basics/geometry3d/GbHalfSpace3D.h b/src/basics/geometry3d/GbHalfSpace3D.h deleted file mode 100644 index 4e4dd86eb..000000000 --- a/src/basics/geometry3d/GbHalfSpace3D.h +++ /dev/null @@ -1,84 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBHALFSPACE3D_H -#define GBHALFSPACE3D_H - -#include <sstream> -#include <iostream> - -#include <basics/utilities/UbMath.h> - -#include <numerics/geometry3d/GbPoint3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> -#include <numerics/geometry3d/GbVector3D.h> - -#include <PointerDefinitions.h> - - -/*=========================================================================*/ -/* GbHalfSpace3D */ -/* */ -/** -* This Class helps in performing some operations on a halfspace defined by 2 or 3 points -*/ - -class GbHalfSpace3D -{ -public: - GbHalfSpace3D(GbTriangle3D* triangle); - - GbHalfSpace3D(GbPoint3D* PointA, GbPoint3D* PointB, GbPoint3D* PointC); - - GbHalfSpace3D(GbPoint3D* PointA, GbPoint3D* PointB); - - GbHalfSpace3D( const double& p1x, const double& p1y, const double& p1z - , const double& p2x, const double& p2y, const double& p2z - , const double& p3x, const double& p3y, const double& p3z ); - GbHalfSpace3D( const double& p1x, const double& p1y, const double& p1z, - const double& nx, const double& ny, const double& nz); - - /*=======================================================*/ - std::string getTypeID() {return "GbHalfSpace3D"; } - /*=============================================*/ - bool ptInside(const double& x, const double& y, const double& z) - { - return UbMath::greaterEqual( normalX*x + normalY*y + normalZ*z, this->d ); - } - /*=============================================*/ - bool ptInside(GbPoint3D* pointX) - { - //GbVector3D X(PointX->x1, PointX->x2, PointX->x3 ); - //return UbMath::greaterEqual(this->Normal.Dot(X), this->d); - return UbMath::greaterEqual( normalX*pointX->x1 + normalY*pointX->x2 + normalZ*pointX->x3, this->d ); - } - /*=============================================*/ - bool ptInside(GbVector3D& x) - { - //return UbMath::greaterEqual(this->Normal.Dot(X), this->d); - return UbMath::greaterEqual( normalX*x[0] + normalY*x[1] + normalZ*x[2], this->d ); - } - /*=============================================*/ - double getDistance(const double& x1p, const double& x2p, const double& x3p) - { - return (normalX*x1p + normalY*x2p + normalZ*x3p) - this->d; - } - - const double& getNormalX() { return this->normalX; } - const double& getNormalY() { return this->normalY; } - const double& getNormalZ() { return this->normalZ; } - const double& getD() { return this->d; } - -private: - //GbVector3D Normal; - double normalX; - double normalY; - double normalZ; - double d; -}; -/*=========================================================================*/ - -#endif //GBHALFSPACE3D_H diff --git a/src/basics/geometry3d/GbHalfSpaceKrischan3D.cpp b/src/basics/geometry3d/GbHalfSpaceKrischan3D.cpp deleted file mode 100644 index 522f52f0a..000000000 --- a/src/basics/geometry3d/GbHalfSpaceKrischan3D.cpp +++ /dev/null @@ -1,267 +0,0 @@ -#include <numerics/geometry3d/GbHalfSpaceKrischan3D.h> - -using namespace std; - -/*==========================================================*/ -GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D(GbTriangle3D* triangle) -{ - GbPoint3D* PointA = triangle->getPoint1(); - GbPoint3D* PointB = triangle->getPoint2(); - GbPoint3D* PointC = triangle->getPoint3(); - - GbVector3D A(PointA->x1, PointA->x2, PointA->x3 ); - GbVector3D BA(PointB->x1-PointA->x1, PointB->x2-PointA->x2, PointB->x3-PointA->x3 ); - GbVector3D CA(PointC->x1-PointA->x1, PointC->x2-PointA->x2, PointC->x3-PointA->x3 ); - GbVector3D BACA = BA.Cross(CA); - //this->Normal = PointB->subtract(PointA)->cross(PointC->subtract(PointA))->normalize(); - BACA.Normalize(); - this->Normal = BACA; - this->d = this->Normal.Dot(A); -} -/*==========================================================*/ -GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D(GbPoint3D* PointA, GbPoint3D* PointB, GbPoint3D* PointC) -{ - GbVector3D A(PointA->x1, PointA->x2, PointA->x3 ); - GbVector3D BA(PointB->x1-PointA->x1, PointB->x2-PointA->x2, PointB->x3-PointA->x3 ); - GbVector3D CA(PointC->x1-PointA->x1, PointC->x2-PointA->x2, PointC->x3-PointA->x3 ); - GbVector3D BACA = BA.Cross(CA); - //this->Normal = PointB->subtract(PointA)->cross(PointC->subtract(PointA))->normalize(); - BACA.Normalize(); - this->Normal = BACA; - this->d = this->Normal.Dot(A); -} -/*==========================================================*/ -GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D(GbPoint3D* PointA, GbPoint3D* PointB) -{ - GbVector3D A(PointA->x1, PointA->x2, PointA->x3 ); - GbVector3D B(PointB->x1, PointB->x2, PointB->x3 ); - GbVector3D K(0.0,0.0,0.99); // the vector from PointA - third point - - GbVector3D PointBA = B-A; - GbVector3D PointBAK = PointBA.Cross(K); - PointBAK.Normalize(); - this->Normal = PointBAK; - this->d = this->Normal.Dot(A); -} -/*==========================================================*/ -GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D( const double& p1x, const double& p1y, const double& p1z - , const double& p2x, const double& p2y, const double& p2z - , const double& p3x, const double& p3y, const double& p3z ) -{ - GbVector3D A( p1x, p1y, p1z ); - GbVector3D BA(p2x-p1x, p2y-p1y, p2z-p1z ); - GbVector3D CA(p3x-p1x, p3y-p1y, p3z-p1z ); - GbVector3D BACA = BA.Cross(CA); - - BACA.Normalize(); - this->Normal = BACA; - this->d = this->Normal.Dot(A); -} -/*==========================================================*/ -GbHalfSpaceKrischan3D::GbHalfSpaceKrischan3D(double nx, double ny, double nz, double dist) -{ - this->Normal = GbVector3D(nx,ny,nz); - this->Normal.Normalize(); - this->d = dist; -} -/*==========================================================*/ -double GbHalfSpaceKrischan3D::getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - - double x1 = x1b-x1a; - double x2 = x2b-x2a; - double x3 = x3b-x3a; - - if( this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) ) return 1.0*x1*x2*x3; - if( !(this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)) ) return 0.0; - - double alpha=0.0; - double internX1,internX2,internX3; - - for(int x1vers=0;x1vers<2;x1vers++){ - for(int x2vers=0;x2vers<2;x2vers++){ - for(int x3vers=0;x3vers<2;x3vers++){ - internX1 = x1a + (x1b-x1a)*x1vers; - internX2 = x2a + (x2b-x2a)*x2vers; - internX3 = x3a + (x3b-x3a)*x3vers; - - // if point is INSIDE the halfspace, distance is smaller than zero - // --> loop determines the minimum alpha...i.e. the alpha with maximum absolute value for all points INSIDE the halfspace - if( UbMath::lessEqual( this->getDistance(internX1,internX2,internX3) , alpha ) ) - alpha = this->getDistance(internX1,internX2,internX3); - //cout<<zelltyp<<" "<<kugel->getDistance(internX1,internX2,internX3)<<" "<<alpha<<endl; - }//end first for - }//end second for - }//end third for - - // PLIC needs alphas > 0.0 - alpha = (-1)*alpha; - - - - double n[3]; - n[0] = this->Normal[0]; - n[1] = this->Normal[1]; - n[2] = this->Normal[2]; - - //cout << "Koordinaten: "<<x1<<" "<<x2<<" "<<x3<<endl; - //cout << "Deltas: "<<deltaX1<<" "<<deltaX2<<" "<<deltaX3<<endl; - //cout << "Halbe Zelle: "<<halfcelldelta<<endl; - - //cout<<"Centroid: "<<kugel->getX1Centroid()<<" "<<kugel->getX2Centroid()<<" "<<kugel->getX3Centroid()<<endl; - - //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl; - - double normLength; - normLength = sqrt(n[0]*n[0] + n[1]*n[1] + n[2]*n[2]); - n[0] /= normLength; - n[1] /= normLength; - n[2] /= normLength; - - if( UbMath::less(n[0],0.0) ) n[0] = -n[0]; - if( UbMath::less(n[1],0.0) ) n[1] = -n[1]; - if( UbMath::less(n[2],0.0) ) n[2] = -n[2]; - - //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl; - - double dummy; - if( UbMath::greater(n[0],n[1])) {dummy=n[1]; n[1]=n[0]; n[0]=dummy;} - if( UbMath::greater(n[1],n[2])) {dummy=n[2]; n[2]=n[1]; n[1]=dummy;} - if( UbMath::greater(n[0],n[1])) {dummy=n[1]; n[1]=n[0]; n[0]=dummy;} - - //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl; - - double n1,n2,n3; - n1=n[0]; - n2=n[1]; - n3=n[2]; - - double preresult=0.0,result=0.0; - - // 1D Check - if ( UbMath::lessEqual(n1,0.00001)&&UbMath::lessEqual(n2,0.00001) ) - { - result = alpha * x1 * x2; - } - // 2D Check - else if ( UbMath::lessEqual(n1,0.00001) ) - { - preresult = (2*n2*n3); - result = (alpha*alpha)/preresult; - - if( UbMath::greater(alpha,n2*x2) ) - { - result += -(alpha-n2*x2)*(alpha-n2*x2)/preresult; - } - if( UbMath::greater(alpha,n3*x3) ) - { - result += -(alpha-n3*x3)*(alpha-n3*x3)/preresult; - } - if( UbMath::greater(alpha,n2*x2+n3*x3) ) - { - result += (alpha-n2*x2-n3*x3)*(alpha-n2*x2-n3*x3)/preresult; - } - - // tiefenrichtung mit einmultiplizieren... - result *= x1; - } - // 3D Check - else - { - preresult =6*n1*n2*n3; - - result = alpha*alpha*alpha/preresult; - - if ( UbMath::greater (alpha,n1*x1)) - { - result+=-((alpha-n1*x1)*(alpha-n1*x1)*(alpha-n1*x1))/preresult; - } - if (UbMath::greater(alpha,n2*x2)) - { - result+=-((alpha-n2*x2)*(alpha-n2*x2)*(alpha-n2*x2))/preresult; - } - if (UbMath::greater(alpha,n3*x3)) - { - result+=-((alpha-n3*x3)*(alpha-n3*x3)*(alpha-n3*x3))/preresult; - } - if (UbMath::greater(alpha,(n1*x1+n2*x2))) - { - result+=((alpha-(n1*x1+n2*x2))*(alpha-(n1*x1+n2*x2))*(alpha-(n1*x1+n2*x2)))/preresult; - } - if (UbMath::greater(alpha,(n1*x1+n3*x3))) - { - result+=((alpha-(n1*x1+n3*x3))*(alpha-(n1*x1+n3*x3))*(alpha-(n1*x1+n3*x3)))/preresult; - } - if (UbMath::greater(alpha,(n2*x2+n3*x3))) - { - result+=((alpha-(n2*x2+n3*x3))*(alpha-(n2*x2+n3*x3))*(alpha-(n2*x2+n3*x3)))/preresult; - } - - //NEW - if (UbMath::greater(alpha,(n1*x1+n2*x2+n3*x3))) - { - result+= -((alpha-(n1*x1+n2*x2+n3*x3))*(alpha-(n1*x1+n2*x2+n3*x3))*(alpha-(n1*x1+n2*x2+n3*x3)))/preresult; - } - - } - - if( !UbMath::inClosedInterval( result/ (x1*x2*x3), -0.01, 1.01) ) - { - stringstream errMsg; - - errMsg << "Danger...Fuellstand "<<result<<" nicht im Interfall [0.0..1.0]" << endl; - errMsg << "NormVec: " << n1 << " " << n2 << " " << n3 << endl; - errMsg << "Cell: " << x1 << " " << x2 << " " << x3 << endl; - errMsg << "Alpha: " << alpha << endl; - - - throw UbException( UB_EXARGS, errMsg.str() ); - } - - return result; - - - //double eps=0.0; - //if( UbMath::equal(n1,0.0) && UbMath::equal(n2,0.0) ) - //{ - // eps = alpha/n3; - //} - //else if( UbMath::equal(n1,0.0) ) - //{ - // double dim1,dim2; - // dim1 = alpha/n2; - // dim2 = alpha/n3; - - // eps = 0.5*dim1*dim2; - // if( UbMath::greater(dim1,1.0) ) eps -= 0.5*(dim1-1.0)*dim2/dim1*(dim1-1.0); - // if( UbMath::greater(dim2,1.0) ) eps -= 0.5*(dim2-1.0)*dim1/dim2*(dim2-1.0); - //} - //else - //{ - // eps = alpha*alpha*alpha; - // if( UbMath::greater(alpha,n1) ) - // eps -= (alpha-n1)*(alpha-n1)*(alpha-n1); - // if( UbMath::greater(alpha,n2) ) - // eps -= (alpha-n2)*(alpha-n2)*(alpha-n2); - // if( UbMath::greater(alpha,n3) ) - // eps -= (alpha-n3)*(alpha-n3)*(alpha-n3); - - // if( UbMath::greater(alpha,n1+n2) ) - // eps += (alpha-n1-n2)*(alpha-n1-n2)*(alpha-n1-n2); - // if( UbMath::greater(alpha,n1+n3) ) - // eps += (alpha-n1-n3)*(alpha-n1-n3)*(alpha-n1-n3); - // if( UbMath::greater(alpha,n2+n3) ) - // eps += (alpha-n2-n3)*(alpha-n2-n3)*(alpha-n2-n3); - - // //attention: use without delta_i - // eps = eps / (6*n[0]*n[1]*n[2]); - - // eps = eps / (deltaX1*deltaX2*deltaX3); - //} - - - //return(eps) ; - //cout << "alpha ist " << alpha << endl; - //cout << "fillLevel ist " << eps << endl; -} -/*==========================================================*/ diff --git a/src/basics/geometry3d/GbHalfSpaceKrischan3D.h b/src/basics/geometry3d/GbHalfSpaceKrischan3D.h deleted file mode 100644 index a9146718b..000000000 --- a/src/basics/geometry3d/GbHalfSpaceKrischan3D.h +++ /dev/null @@ -1,205 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GbHalfSpaceKrischan3D_H -#define GbHalfSpaceKrischan3D_H - -#include <sstream> -#include <iostream> - -#include <basics/utilities/UbMath.h> - -#include <numerics/geometry3d/GbPoint3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> -#include <numerics/geometry3d/GbVector3D.h> -#include <numerics/geometry3d/GbLine3D.h> - -/*=========================================================================*/ -/* GbHalfSpaceKrischan3D */ -/* */ -/** -* This Class helps in performing some operations on a halfspace defined by 2 or 3 points -*/ - -class GbHalfSpaceKrischan3D : public GbObject3D , public UbObserver -{ -public: - GbHalfSpaceKrischan3D(GbTriangle3D* triangle); - - GbHalfSpaceKrischan3D(GbPoint3D* PointA, GbPoint3D* PointB, GbPoint3D* PointC); - - GbHalfSpaceKrischan3D(double nx, double ny, double nz, double dist); - - GbHalfSpaceKrischan3D(GbPoint3D* PointA, GbPoint3D* PointB); - - GbHalfSpaceKrischan3D( const double& p1x, const double& p1y, const double& p1z - , const double& p2x, const double& p2y, const double& p2z - , const double& p3x, const double& p3y, const double& p3z ); - - /*=======================================================*/ - virtual ~GbHalfSpaceKrischan3D() { } - /*=======================================================*/ - std::string getTypeID() {return "GbHalfSpaceKrischan3D"; } - /*=============================================*/ - bool ptInside(const double& x, const double& y, const double& z) - { - return UbMath::lessEqual(Normal[0]*x+Normal[1]*y+Normal[2]*z, this->d); - } - /*=============================================*/ - bool ptInside(GbPoint3D* PointX) - { - GbVector3D X(PointX->x1, PointX->x2, PointX->x3 ); - return UbMath::lessEqual(this->Normal.Dot(X), this->d); - } - /*=============================================*/ - bool ptInside(GbVector3D &X) - { - return UbMath::lessEqual(this->Normal.Dot(X), this->d); - } - - /*=====================================================*/ - //true, wenn 'in Object' oder 'auf Boundary'! - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p) - { - return (ptInside(x1p,x2p,x3p)); - } - /*=====================================================*/ - //true, wenn 'in Object' oder 'auf Boundary'! - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary) - { - return (ptInside(x1p,x2p,x3p)); - } - - void finalize(){} - ObObjectCreator* getCreator(){ return NULL; } - - double getX1Centroid(){ return 0.0; } - double getX1Minimum() { return -99999.0; } - double getX1Maximum() { return 99999.0; } - double getX2Centroid(){ return 0.0; } - double getX2Minimum() { return -99999.0; } - double getX2Maximum() { return 99999.0; } - double getX3Centroid(){ return 0.0; } - double getX3Minimum() { return -99999.0; } - double getX3Maximum() { return 99999.0; } - - void write(UbFileOutput* out){} - void read(UbFileInput* in){} - - GbLine3D* createClippedLine3D (GbPoint3D &point1, GbPoint3D &point2) - { - GbPoint3D *p1 = new GbPoint3D(point1); - GbPoint3D *p2 = new GbPoint3D(point2); - - GbVector3D p1p2( p2->x1-p1->x1, p2->x2-p1->x2, p2->x3-p1->x3); - - double dist1 = getDistance( p1->x1,p1->x2,p1->x3 ); - double dist2 = getDistance( p2->x1,p2->x2,p2->x3 ); - - double totalDist = std::abs(dist1) + std::abs(dist2); - - // Falls erster Punkt nicht drinliegt - if( !ptInside(p1) ) - { - if( !ptInside(p2) ) return NULL; - - // distance ausrechnen (groesser null) - if( UbMath::less( dist1, 0.0 ) ) throw UbException( UB_EXARGS, "Punkt ausserhalb, aber Distanz kleiner null???" ); - - p1->x1 = p1->x1 + dist1/totalDist*p1p2[0]; - p1->x2 = p1->x2 + dist1/totalDist*p1p2[1]; - p1->x3 = p1->x3 + dist1/totalDist*p1p2[2]; - } - // Falls zweiter Punkt nicht drinliegt - if( !ptInside(p2) ) - { - if( !ptInside(p1) ) return NULL; - - // distance ausrechnen (groesser null) - if( UbMath::less( dist2, 0.0 ) ) throw UbException( UB_EXARGS, "Punkt ausserhalb, aber Distanz kleiner null???" ); - - p2->x1 = p2->x1 - dist2/totalDist*p1p2[0]; - p2->x2 = p2->x2 - dist2/totalDist*p1p2[1]; - p2->x3 = p2->x3 - dist2/totalDist*p1p2[2]; - } - - return new GbLine3D(p1,p2); - } - - - double getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - - double getDistance(const double& x1p, const double& x2p, const double& x3p) - { - return (Normal[0]*x1p + Normal[1]*x2p + Normal[2]*x3p) - this->d; - } - - void getNormal( double& n1, double& n2, double& n3 ) - { - n1 = this->Normal[0]; - n2 = this->Normal[1]; - n3 = this->Normal[2]; - } - - void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles) - { - std::cout << " addSurfaceTriangleSet(): TO BE DONE AND CHECKED ... " << std::endl; - } - - std::vector<GbTriangle3D*> getSurfaceTriangleSet() - { - std::vector<GbTriangle3D*> triangles; - GbPoint3D p1( 0.0,0.0,0.0 ); - GbPoint3D p2( 1.0,0.0,0.0 ); - GbPoint3D p3( 0.0,1.0,0.0 ); - - triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p2),new GbPoint3D(p3))); - - return triangles; - } - - void objectChanged(UbObservable* changedObject) - { - return; - - //GbLine3D* line = dynamic_cast<GbLine3D*>(changedObject); - //if(!line || this->mLine!=line) return; - //this->notifyObserversObjectChanged(); - } - /*==========================================================*/ - void objectWillBeDeleted(UbObservable* objectForDeletion) - { - return; - //if(this->mLine) - //{ - // UbObservable* observedObj = dynamic_cast<UbObservable*>(this->mLine); - // if(objectForDeletion == observedObj) { this->mLine = NULL; } - //} - } - - ObObject* clone(){ return NULL; }; - - std::string toString() - { - std::stringstream temp; - - temp << "GbHalfSpaceKrischan3D: "; - temp << " Distance " << this->d; - temp << " Norm vec " << this->Normal[0]; - temp << " " << this->Normal[1]; - temp << " " << this->Normal[2]; - - - return temp.str(); - }; - -private: - GbVector3D Normal; - double d; -}; -/*=========================================================================*/ - -#endif //GbHalfSpaceKrischan3D_H diff --git a/src/basics/geometry3d/GbLine3D.cpp b/src/basics/geometry3d/GbLine3D.cpp index cac15fa05..4626eaccb 100644 --- a/src/basics/geometry3d/GbLine3D.cpp +++ b/src/basics/geometry3d/GbLine3D.cpp @@ -1,16 +1,42 @@ -#include <numerics/geometry3d/GbLine3D.h> -#include <numerics/geometry3d/creator/GbLine3DCreator.h> - -#include <numerics/geometry3d/GbSystem3D.h> -#include <numerics/geometry3d/GbCuboid3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbLine3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= +#include <GbLine3D.h> +#include <GbSystem3D.h> +#include <GbCuboid3D.h> +#include <GbTriangle3D.h> using namespace std; -ObObjectCreator* GbLine3D::getCreator() -{ - return GbLine3DCreator::getInstance(); -} /*=======================================================*/ GbLine3D::GbLine3D() { @@ -183,26 +209,6 @@ void GbLine3D::objectWillBeDeleted(UbObservable* objectForDeletion) //ACHTUNG: eigentlich muessten in allen methoden von GbLine if abfragen fuer NULL pointer hin... toDo } /*==========================================================*/ -void GbLine3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - p1->write(out); - p2->write(out); -} -/*==========================================================*/ -void GbLine3D::read(UbFileInput* in) -{ - p1 = new GbPoint3D; - p2 = new GbPoint3D; - in->readString(); - p1->read(in); - p1->addObserver(this); - in->readString(); - p2->read(in); - p2->addObserver(this); - this->calculateValues(); -} -/*==========================================================*/ void GbLine3D::scale(const double& sx1, const double& sx2, const double& sx3) { double p1X1 = this->p1->getX1Coordinate(); diff --git a/src/basics/geometry3d/GbLine3D.h b/src/basics/geometry3d/GbLine3D.h index d338db3e5..69d6de96d 100644 --- a/src/basics/geometry3d/GbLine3D.h +++ b/src/basics/geometry3d/GbLine3D.h @@ -1,38 +1,58 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbLine3D.h +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef GBLINE3D_H #define GBLINE3D_H -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - #include <sstream> #include <cmath> #include <basics/utilities/UbObserver.h> -#include <numerics/geometry3d/GbObject3D.h> -#include <numerics/geometry3d/GbPoint3D.h> +#include <GbObject3D.h> +#include <GbPoint3D.h> class GbCuboid3D; -class GbObject3DCreator; #include <PointerDefinitions.h> - -/*=========================================================================*/ -/* GbLine3D */ -/* */ -/** - * This Class provides basic 3D line objects. - * The describing points are observed by 3D line objects. - * <BR><BR><HR> -*/ +////////////////////////////////////////////////////////////////////////// +//! +//! \class GbLine3D +//! +//! \brief This Class provides basic 3D line objects. +//! \details The describing points are observed by 3D line objects. +//! +////////////////////////////////////////////////////////////////////////// class GbLine3D : public GbObject3D , public UbObserver { @@ -101,21 +121,6 @@ public: void objectWillBeDeleted(UbObservable* objectForDeletion); std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & p1; - ar & p2; - ar & length; - if( ArchiveTools::isReading(ar) ) this->calculateValues(); - } -#endif //CAB_RCF using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere protected: @@ -127,10 +132,4 @@ private: void calculateValues(); }; -#ifdef RCF_USE_SF_SERIALIZATION - UB_AUTO_RUN_NAMED( SF::registerType<GbLine3D>("GbLine3D"), SF_GbLine3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbLine3D >()), SF_GbLine3D_BD1 ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbLine3D>() ), SF_GbLine3D_BD2 ); -#endif //RCF_USE_SF_SERIALIZATION - #endif diff --git a/src/basics/geometry3d/GbMeshTools3D.h b/src/basics/geometry3d/GbMeshTools3D.h deleted file mode 100644 index 9805e33a6..000000000 --- a/src/basics/geometry3d/GbMeshTools3D.h +++ /dev/null @@ -1,402 +0,0 @@ -#ifndef GBMESHTOOLS3D_H -#define GBMESHTOOLS3D_H - -#include <sstream> -#include <iostream> -#include <vector> - -#include <basics/utilities/UbMath.h> - -namespace GbMeshTools3D -{ - inline int planeBoxOverlap(float normal[3], float vert[3], float maxbox[3]) // -NJMP- - { - int q; - float vmin[3],vmax[3],v; - - for(q=0;q<=2;q++) - { - v=vert[q]; // -NJMP- - if(normal[q]>0.0f) - { - vmin[q]=-maxbox[q] - v; // -NJMP- - vmax[q]= maxbox[q] - v; // -NJMP- - } - else - { - vmin[q]= maxbox[q] - v; // -NJMP- - vmax[q]=-maxbox[q] - v; // -NJMP- - } - } - if(( normal[0]*vmin[0] + normal[1]*vmin[1] + normal[2]*vmin[2] )>0.0f ) return 0; // -NJMP- - if(( normal[0]*vmax[0] + normal[1]*vmax[1] + normal[2]*vmax[2] )>=0.0f) return 1; // -NJMP- - return 0; - } - - //Testet auf schnittpunkt Box <-> Dreieck - //boxcenter = Mittelpunkt der Box - //boxhalfsize = Halbe Laenge/Hoehe/Breite der Box - //triverts = Koordinaten der Deickspunkte - inline int triBoxOverlap(float boxcenter[3],float boxhalfsize[3],float triverts[3][3]) - { - /* use separating axis theorem to test overlap between triangle and box */ - /* need to test for overlap in these directions: */ - /* 1) the {x,y,z}-directions (actually, since we use the AABB of the triangle */ - /* we do not even need to test these) */ - /* 2) normal of the triangle */ - /* 3) crossproduct(edge from tri, {x,y,z}-directin) */ - /* this gives 3x3=9 more tests */ - - float v0[3],v1[3],v2[3]; - - // float axis[3]; - - float min,max,p0,p1,p2,rad,fex,fey,fez; // -NJMP- "d" local variable removed - float normal[3],e0[3],e1[3],e2[3]; - - /* This is the fastest branch on Sun */ - /* move everything so that the boxcenter is in (0,0,0) */ - //SUB(v0,triverts[0],boxcenter); - //#define SUB(dest,v1,v2) - v0[0]=triverts[0][0]-boxcenter[0]; - v0[1]=triverts[0][1]-boxcenter[1]; - v0[2]=triverts[0][2]-boxcenter[2]; - - //SUB(v1,triverts[1],boxcenter); - //#define SUB(dest,v1,v2) - v1[0]=triverts[1][0]-boxcenter[0]; - v1[1]=triverts[1][1]-boxcenter[1]; - v1[2]=triverts[1][2]-boxcenter[2]; - - //SUB(v2,triverts[2],boxcenter); - //#define SUB(dest,v1,v2) - v2[0]=triverts[2][0]-boxcenter[0]; - v2[1]=triverts[2][1]-boxcenter[1]; - v2[2]=triverts[2][2]-boxcenter[2]; - - /* compute triangle edges */ - //SUB(e0,v1,v0); /* tri edge 0 */ - //#define SUB(dest,v1,v2) - e0[0]=v1[0]-v0[0]; - e0[1]=v1[1]-v0[1]; - e0[2]=v1[2]-v0[2]; - - //SUB(e1,v2,v1); /* tri edge 1 */ - //#define SUB(dest,v1,v2) - e1[0]=v2[0]-v1[0]; - e1[1]=v2[1]-v1[1]; - e1[2]=v2[2]-v1[2]; - - //SUB(e2,v0,v2); /* tri edge 2 */ - //#define SUB(dest,v1,v2) - e2[0]=v0[0]-v2[0]; - e2[1]=v0[1]-v2[1]; - e2[2]=v0[2]-v2[2]; - - /* Bullet 3: */ - /* test the 9 tests first (this was faster) */ - fex = fabsf(e0[0]); - fey = fabsf(e0[1]); - fez = fabsf(e0[2]); - - //AXISTEST_X01(e0[2], e0[1], fez, fey); - //#define AXISTEST_X01(a, b, fa, fb) - p0 = e0[2]*v0[1] - e0[1]*v0[2]; - p2 = e0[2]*v2[1] - e0[1]*v2[2]; - if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} - rad = fez * boxhalfsize[1] + fey * boxhalfsize[2]; - if(min>rad || max<-rad) return 0; - - //AXISTEST_Y02(e0[2], e0[0], fez, fex); - //#define AXISTEST_Y02(a, b, fa, fb) - p0 = -e0[2]*v0[0] + e0[0]*v0[2]; - p2 = -e0[2]*v2[0] + e0[0]*v2[2]; - if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} - rad = fez * boxhalfsize[0] + fex * boxhalfsize[2]; - if(min>rad || max<-rad) return 0; - - //AXISTEST_Z12(e0[1], e0[0], fey, fex); - //#define AXISTEST_Z12(a, b, fa, fb) - p1 = e0[1]*v1[0] - e0[0]*v1[1]; - p2 = e0[1]*v2[0] - e0[0]*v2[1]; - if(p2<p1) {min=p2; max=p1;} else {min=p1; max=p2;} - rad = fey * boxhalfsize[0] + fex * boxhalfsize[1]; - if(min>rad || max<-rad) return 0; - - fex = fabsf(e1[0]); - fey = fabsf(e1[1]); - fez = fabsf(e1[2]); - - //AXISTEST_X01(e1[2], e1[1], fez, fey); - //#define AXISTEST_X01(a, b, fa, fb) - p0 = e1[2]*v0[1] - e1[1]*v0[2]; - p2 = e1[2]*v2[1] - e1[1]*v2[2]; - if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} - rad = fez * boxhalfsize[1] + fey * boxhalfsize[2]; - if(min>rad || max<-rad) return 0; - - //AXISTEST_Y02(e1[2], e1[0], fez, fex); - //#define AXISTEST_Y02(a, b, fa, fb) - p0 = -e1[2]*v0[0] + e1[0]*v0[2]; - p2 = -e1[2]*v2[0] + e1[0]*v2[2]; - if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} - rad = fez * boxhalfsize[0] + fex * boxhalfsize[2]; - if(min>rad || max<-rad) return 0; - - //AXISTEST_Z0(e1[1], e1[0], fey, fex); - //#define AXISTEST_Z0(a, b, fa, fb) - p0 = e1[1]*v0[0] - e1[0]*v0[1]; - p1 = e1[1]*v1[0] - e1[0]*v1[1]; - if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} - rad = fey * boxhalfsize[0] + fex * boxhalfsize[2]; - if(min>rad || max<-rad) return 0; - - fex = fabsf(e2[0]); - fey = fabsf(e2[1]); - fez = fabsf(e2[2]); - //AXISTEST_X2(e2[2], e2[1], fez, fey); - //#define AXISTEST_X2(a, b, fa, fb) - p0 = e2[2]*v0[1] - e2[1]*v0[2]; - p1 = e2[2]*v1[1] - e2[1]*v1[2]; - if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} - rad = fez * boxhalfsize[1] + fey * boxhalfsize[2]; - if(min>rad || max<-rad) return 0; - - //AXISTEST_Y1(e2[2], e2[0], fez, fex); - //#define AXISTEST_Y1(a, b, fa, fb) - p0 = -e2[2]*v0[0] + e2[0]*v0[2]; - p1 = -e2[2]*v1[0] + e2[0]*v1[2]; - if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} - rad = fez * boxhalfsize[0] + fex * boxhalfsize[2]; - if(min>rad || max<-rad) return 0; - - //AXISTEST_Z12(e2[1], e2[0], fey, fex); - //#define AXISTEST_Z12(a, b, fa, fb) - p1 = e2[1]*v1[0] - e2[0]*v1[1]; - p2 = e2[1]*v2[0] - e2[0]*v2[1]; - if(p2<p1) {min=p2; max=p1;} else {min=p1; max=p2;} - rad = fey * boxhalfsize[0] + fex * boxhalfsize[1]; - if(min>rad || max<-rad) return 0; - - /* Bullet 1: */ - /* first test overlap in the {x,y,z}-directions */ - /* find min, max of the triangle each direction, and test for overlap in */ - /* that direction -- this is equivalent to testing a minimal AABB around */ - /* the triangle against the AABB */ - /* test in X-direction */ - //FINDMINMAX(v0[0],v1[0],v2[0],min,max); - min = (float)UbMath::min(v0[0],v1[0],v2[0]); - max = (float)UbMath::max(v0[0],v1[0],v2[0]); - if(min>boxhalfsize[0] || max<-boxhalfsize[0]) return 0; - - /* test in Y-direction */ - //FINDMINMAX(v0[1],v1[1],v2[1],min,max); - min = (float)UbMath::min(v0[1],v1[1],v2[1]); - max = (float)UbMath::max(v0[1],v1[1],v2[1]); - if(min>boxhalfsize[1] || max<-boxhalfsize[1]) return 0; - - /* test in Z-direction */ - //FINDMINMAX(v0[2],v1[2],v2[2],min,max); - min = (float)UbMath::min(v0[2],v1[2],v2[2]); - max = (float)UbMath::max(v0[2],v1[2],v2[2]); - - if(min>boxhalfsize[2] || max<-boxhalfsize[2]) return 0; - - /* Bullet 2: */ - /* test if the box intersects the plane of the triangle */ - /* compute plane equation of triangle: normal*x+d=0 */ - //CROSS(normal,e0,e1); - //#define CROSS(dest,v1,v2) - normal[0]=e0[1]*e1[2]-e0[2]*e1[1]; - normal[1]=e0[2]*e1[0]-e0[0]*e1[2]; - normal[2]=e0[0]*e1[1]-e0[1]*e1[0]; - - // -NJMP- (line removed here) - if(!planeBoxOverlap(normal,v0,boxhalfsize)) return 0; // -NJMP- - return 1; /* box and triangle overlaps */ - } - - - -}; - -#endif - -//original - NICHT LOESCHEN - von kroete lynn - -//#define X 0 -//#define Y 1 -//#define Z 2 -// -//#define CROSS(dest,v1,v2) -// dest[0]=v1[1]*v2[2]-v1[2]*v2[1]; -// dest[1]=v1[2]*v2[0]-v1[0]*v2[2]; -// dest[2]=v1[0]*v2[1]-v1[1]*v2[0]; -// -//#define DOT(v1,v2) (v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2]) -// -//#define SUB(dest,v1,v2) -// dest[0]=v1[0]-v2[0]; -// dest[1]=v1[1]-v2[1]; -// dest[2]=v1[2]-v2[2]; -// -//#define FINDMINMAX(x0,x1,x2,min,max) -// min = max = x0; -// if(x1<min) min=x1; -// if(x1>max) max=x1; -// if(x2<min) min=x2; -// if(x2>max) max=x2; -// -//int planeBoxOverlap(float normal[3], float vert[3], float maxbox[3]) // -NJMP- -//{ -// int q; -// float vmin[3],vmax[3],v; -// -// for(q=X;q<=Z;q++) -// { -// v=vert[q]; // -NJMP- -// if(normal[q]>0.0f) -// { -// vmin[q]=-maxbox[q] - v; // -NJMP- -// vmax[q]= maxbox[q] - v; // -NJMP- -// } -// else -// { -// vmin[q]= maxbox[q] - v; // -NJMP- -// vmax[q]=-maxbox[q] - v; // -NJMP- -// } -// } -// if(DOT(normal,vmin)>0.0f) return 0; // -NJMP- -// if(DOT(normal,vmax)>=0.0f) return 1; // -NJMP- -// return 0; -//} -// -///*======================== X-tests ======================== -// -//#define AXISTEST_X01(a, b, fa, fb) -// p0 = a*v0[Y] - b*v0[Z]; -// p2 = a*v2[Y] - b*v2[Z]; -// if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} -// rad = fa * boxhalfsize[Y] + fb * boxhalfsize[Z]; -// if(min>rad || max<-rad) return 0; -// -//#define AXISTEST_X2(a, b, fa, fb) -// p0 = a*v0[Y] - b*v0[Z]; -// p1 = a*v1[Y] - b*v1[Z]; -// if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} -// rad = fa * boxhalfsize[Y] + fb * boxhalfsize[Z]; -// if(min>rad || max<-rad) return 0; -// -// -// -///*======================== Y-tests ======================== -// -//#define AXISTEST_Y02(a, b, fa, fb) -// p0 = -a*v0[X] + b*v0[Z]; -// p2 = -a*v2[X] + b*v2[Z]; -// if(p0<p2) {min=p0; max=p2;} else {min=p2; max=p0;} -// rad = fa * boxhalfsize[X] + fb * boxhalfsize[Z]; -// if(min>rad || max<-rad) return 0; -// -//#define AXISTEST_Y1(a, b, fa, fb) -// p0 = -a*v0[X] + b*v0[Z]; -// p1 = -a*v1[X] + b*v1[Z]; -// if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} -// rad = fa * boxhalfsize[X] + fb * boxhalfsize[Z]; -// if(min>rad || max<-rad) return 0; -// -//======================== Z-tests ======================== -// -//#define AXISTEST_Z12(a, b, fa, fb) -// p1 = a*v1[X] - b*v1[Y]; -// p2 = a*v2[X] - b*v2[Y]; -// if(p2<p1) {min=p2; max=p1;} else {min=p1; max=p2;} -// rad = fa * boxhalfsize[X] + fb * boxhalfsize[Y]; -// if(min>rad || max<-rad) return 0; -// -//#define AXISTEST_Z0(a, b, fa, fb) -// p0 = a*v0[X] - b*v0[Y]; -// p1 = a*v1[X] - b*v1[Y]; -// if(p0<p1) {min=p0; max=p1;} else {min=p1; max=p0;} -// rad = fa * boxhalfsize[X] + fb * boxhalfsize[Y]; -// if(min>rad || max<-rad) return 0; -// -//int triBoxOverlap(float boxcenter[3],float boxhalfsize[3],float triverts[3][3]) -//{ -// //use separating axis theorem to test overlap between triangle and box -// //need to test for overlap in these directions: -// //1) the {x,y,z}-directions (actually, since we use the AABB of the triangle -// // we do not even need to test these) -// //2) normal of the triangle -// //3) crossproduct(edge from tri, {x,y,z}-directin) -// // this gives 3x3=9 more tests -// -// float v0[3],v1[3],v2[3]; -// -// // float axis[3]; -// -// float min,max,p0,p1,p2,rad,fex,fey,fez; // -NJMP- "d" local variable removed -// float normal[3],e0[3],e1[3],e2[3]; -// -// /* This is the fastest branch on Sun */ -// /* move everything so that the boxcenter is in (0,0,0) */ -// SUB(v0,triverts[0],boxcenter); -// SUB(v1,triverts[1],boxcenter); -// SUB(v2,triverts[2],boxcenter); -// -// /* compute triangle edges */ -// SUB(e0,v1,v0); /* tri edge 0 */ -// SUB(e1,v2,v1); /* tri edge 1 */ -// SUB(e2,v0,v2); /* tri edge 2 */ -// -// /* Bullet 3: */ -// /* test the 9 tests first (this was faster) */ -// fex = fabsf(e0[X]); -// fey = fabsf(e0[Y]); -// fez = fabsf(e0[Z]); -// -// AXISTEST_X01(e0[Z], e0[Y], fez, fey); -// AXISTEST_Y02(e0[Z], e0[X], fez, fex); -// AXISTEST_Z12(e0[Y], e0[X], fey, fex); -// fex = fabsf(e1[X]); -// fey = fabsf(e1[Y]); -// fez = fabsf(e1[Z]); -// -// AXISTEST_X01(e1[Z], e1[Y], fez, fey); -// AXISTEST_Y02(e1[Z], e1[X], fez, fex); -// AXISTEST_Z0(e1[Y], e1[X], fey, fex); -// -// fex = fabsf(e2[X]); -// fey = fabsf(e2[Y]); -// fez = fabsf(e2[Z]); -// AXISTEST_X2(e2[Z], e2[Y], fez, fey); -// AXISTEST_Y1(e2[Z], e2[X], fez, fex); -// AXISTEST_Z12(e2[Y], e2[X], fey, fex); -// -// /* Bullet 1: */ -// /* first test overlap in the {x,y,z}-directions */ -// /* find min, max of the triangle each direction, and test for overlap in */ -// /* that direction -- this is equivalent to testing a minimal AABB around */ -// /* the triangle against the AABB */ -// /* test in X-direction */ -// FINDMINMAX(v0[X],v1[X],v2[X],min,max); -// if(min>boxhalfsize[X] || max<-boxhalfsize[X]) return 0; -// -// /* test in Y-direction */ -// FINDMINMAX(v0[Y],v1[Y],v2[Y],min,max); -// if(min>boxhalfsize[Y] || max<-boxhalfsize[Y]) return 0; -// -// /* test in Z-direction */ -// FINDMINMAX(v0[Z],v1[Z],v2[Z],min,max); -// if(min>boxhalfsize[Z] || max<-boxhalfsize[Z]) return 0; -// -// /* Bullet 2: */ -// /* test if the box intersects the plane of the triangle */ -// /* compute plane equation of triangle: normal*x+d=0 */ -// CROSS(normal,e0,e1); -// -// // -NJMP- (line removed here) -// if(!planeBoxOverlap(normal,v0,boxhalfsize)) return 0; // -NJMP- -// return 1; /* box and triangle overlaps */ -//} - diff --git a/src/basics/geometry3d/GbObject3D.cpp b/src/basics/geometry3d/GbObject3D.cpp index b48d256ee..77a17ac15 100644 --- a/src/basics/geometry3d/GbObject3D.cpp +++ b/src/basics/geometry3d/GbObject3D.cpp @@ -1,14 +1,41 @@ -#include <numerics/geometry3d/GbObject3D.h> -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbPoint3D.h> +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbObject3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= +#include <GbObject3D.h> +#include <GbPoint3D.h> #include <basics/utilities/UbMath.h> using namespace std; -string GbObject3D::getTypeID() -{ - return this->getCreator()->getTypeID(); -} /*======================================================================*/ bool GbObject3D::isPointInGbObject3D(GbPoint3D* p) { diff --git a/src/basics/geometry3d/GbObject3D.h b/src/basics/geometry3d/GbObject3D.h index 9536a8253..dcb27c94e 100644 --- a/src/basics/geometry3d/GbObject3D.h +++ b/src/basics/geometry3d/GbObject3D.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbObject3D.h +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef GBOBJECT3D_H #define GBOBJECT3D_H @@ -11,14 +37,8 @@ #include <vector> -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - #include <basics/utilities/UbSystem.h> #include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileInput.h> -#include <basics/utilities/UbFileOutput.h> #include <basics/utilities/UbObservable.h> #include <basics/utilities/UbTuple.h> #include <basics/objects/ObObject.h> @@ -28,47 +48,23 @@ class GbLine3D; class GbTriangle3D; class GbObject3DCreator; -#ifdef CAB_CTL -#include <ctl.h> -#endif - -#include "basics_export.h" #include <PointerDefinitions.h> +////////////////////////////////////////////////////////////////////////// +//! +//! \class GbObject3D +//! +//! \brief This Interface provides basic 3D geometry objects methods. +//! +////////////////////////////////////////////////////////////////////////// -/*=========================================================================*/ -/* GbObject3D */ -/* */ -/** - * This Interface provides basic 3D geometry objects methods. - * <BR><BR><HR> - * @author <A HREF="mailto:geller@cab.bau.tu-bs.de">S. Geller</A> - * @author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> - * @version 1.0 - 02.02.05 -*/ -class BASICS_EXPORT GbObject3D : public ObObject +class GbObject3D : public ObObject { public: -#ifdef CAB_CTL - virtual ctl::oStream &write(ctl::oStream &os) const - { - return os; - } - virtual ctl::iStream &read(ctl::iStream &is) - { - return is; - } -#endif - virtual ~GbObject3D(){} - //ueberschriebene methode von ObObject - virtual std::string getTypeID(); - //abstract Methods virtual void finalize() =0 ; //detroys also all dynamic objects (e.g. GbPoints in GbLine) - virtual ObObjectCreator* getCreator()=0; - /** * Returns the centroid x1 coordinate of this 3D object. * @return the centroid x1 coordinate of this 3D object @@ -129,9 +125,6 @@ public: virtual void translate(const double& x1, const double& x2, const double& x3) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } virtual void scale(const double& sx1, const double& sx2, const double& sx3) { throw UbException(UB_EXARGS,"not implemented for "+(std::string)typeid(*this).name() ); } - virtual void write(UbFileOutput* out)=0; - virtual void read(UbFileInput* in)=0; - virtual bool isPointInGbObject3D(GbPoint3D* p); virtual bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary)=0; virtual bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3)=0; @@ -153,21 +146,7 @@ public: //|r| must be 1! einheitsvector!! //return negativ value oder zero if no intersection virtual double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) { throw UbException("GbObject3D::getIntersectionRaytraceFactor - not implemented"); } -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<ObObject>(ar, *this); - } -#endif //CAB_RCF }; /*=========================================================================*/ -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - SF_NO_CTOR(GbObject3D); - UB_AUTO_RUN_NAMED(SF::registerType<GbObject3D>("GbObject3D") , SF_GbObject3D); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived<ObObject, GbObject3D >() ), SF_GbObject3D_BD1 ); -#endif //RCF_USE_SF_SERIALIZATION - - #endif diff --git a/src/basics/geometry3d/GbObject3DManager.cpp b/src/basics/geometry3d/GbObject3DManager.cpp deleted file mode 100644 index e7ca650de..000000000 --- a/src/basics/geometry3d/GbObject3DManager.cpp +++ /dev/null @@ -1,285 +0,0 @@ -#include <numerics/geometry3d/GbObject3DManager.h> -#include <numerics/geometry3d/GbObject3D.h> -#include <numerics/geometry3d/creator/GbObject3DFactory.h> - -using namespace std; - -GbObject3DEntry::GbObject3DEntry(GbObject3DManager *parent, GbObject3D *geoObject, bool active, string name):ObObjectEntry(parent, geoObject) -{ - //this->parent = parent; - //this->geoObject = geoObject; - this->active = active; - this->name = name; -} - -/*======================================================*/ -/*== nun halt der Manager ====*/ -/*======================================================*/ - -GbObject3DManager::GbObject3DManager(): ObObjectManager() -{ - this->tableModel = new GbObject3DTableModel(this); -} -/*======================================================*/ -GbObject3DManager::~GbObject3DManager() -{ -// this->gbObject3DList.clear(); -} -/*======================================================*/ -ObObjectFactory* GbObject3DManager::getObObjectFactory() -{ - return GbObject3DFactory::getInstance(); -} - -/*======================================================*/ -ObObjectEntry* GbObject3DManager::createNewObObjectEntry(ObObject *obj) -{ - GbObject3D *geoobject = dynamic_cast<GbObject3D*>(obj); - return new GbObject3DEntry(this, geoobject, true, geoobject->getTypeID()); -} - -/*======================================================*/ -//UbTableModel* GbObject3DManager::getTableModel() -//{ -// return this->tablemodel; -//} - -/*======================================================*/ -//bool GbObject3DManager::addGbObject3D(GbObject3D *geoObject) -//{ -// return this->addGbObject3D(geoObject, true, "GeoObject"); -//} -// -///*======================================================*/ -bool GbObject3DManager::addGbObject3D(GbObject3D *geoObject, string name) -{ - GbObject3DEntry *entry = new GbObject3DEntry (this, geoObject, true, name); - return ObObjectManager::addObObjectEntry(entry); -} -//bool GbObject3DManager::addGbObject3D(GbObject3D *geoObject, bool active, string name) -//{ -// GbObject3DEntry *entry = new GbObject3DEntry (this, geoObject, true, name); -// return ObObjectManager::addObObjectEntry(entry); -//} -// -/*======================================================*/ -bool GbObject3DManager::removeGbObject3D(GbObject3D *geoObject) -{ - return ObObjectManager::removeObObject(geoObject); -} -/*======================================================*/ -bool GbObject3DManager::removeGbObject3D(int index) -{ - return ObObjectManager::removeObObject(index); -} -/*======================================================*/ -//void GbObject3DManager::removeAllGbObject3Ds() -//{ -// this->gbObject3DList.clear(); -//} -/*======================================================*/ -int GbObject3DManager::getNumberOfGbObject3Ds() -{ - return GbObject3DManager::getNumberOfObObjects(); -} -/*======================================================*/ -vector<GbObject3D*>* GbObject3DManager::getAllGbObject3Ds() -{ - throw UbException(UB_EXARGS,"not implemented"); - //vector<GbObject3D*> *geoVektor = new vector<GbObject3D*>; - //for(int u=0; u<(int)this->gbObject3DList.size();u++) - //{ - // GbObject3D* geoObject = dynamic_cast<GbObject3D*>((gbObject3DList)[u]->getObject()); - // geoVektor->push_back(geoObject); - //} - //return geoVektor; -} -/*======================================================*/ -GbObject3D* GbObject3DManager::getGbObject3D(int index) -{ - if(index < 0) return NULL; - if(index >= this->getNumberOfObObjects()) return NULL; - - GbObject3D* geoObject = dynamic_cast<GbObject3D*>(this->getObObject(index)); - return(geoObject); -} -/*======================================================*/ -//GbObject3DEntry* GbObject3DManager::getGbObject3DEntry(int index) -//{ -// if(index < 0) return NULL; -// if(index >= (int)this->gbObject3DList.size()) return NULL; -// -// return((this->gbObject3DList)[index]); -//} -/*====================================================*/ -void GbObject3DManager::write(UbFileOutput *out) -{ - int size = this->getNumberOfObObjects(); - out->writeInteger(size); - out->writeString("// #GbObjects"); - - GbObject3D *geoObject; - for(int pos=0; pos<size; pos++) - { - out->writeLine(); - geoObject = dynamic_cast<GbObject3D*>(this->getObObject(pos)); - cout<<pos<<".:"<<geoObject->toString()<<endl; - geoObject->write(out); - } -} -/*======================================================================*/ -void GbObject3DManager::read(UbFileInput *in) -{ - this->removeAllObObjects(); - - int n = in->readInteger(); - - cout<<"GbObject3DManager::read "<<n<<" GbObject3Ds\n"; - GbObject3D *geoObject; - for(int pos=1; pos<=n; pos++) - { - in->readLine(); - cout<<" - GbObject3D "<<pos<<" ..."; - geoObject = GbObject3DFactory::getInstance()->createGbObject3D(in); - - GbObject3DEntry *entry = new GbObject3DEntry(this, geoObject, true, "GeoObject"); - this->addObObjectEntry(entry); - cout<<"done\n"; - } -} -/*======================================================*/ -string GbObject3DManager::toString() -{ - stringstream ss; ss<<endl; - - int size = this->getNumberOfObObjects(); - for(int pos=0; pos<size; pos++) - { - ObObject* geoObject = this->getObObject(pos); - ss<<(pos+1)<<". "<<geoObject->toString()<<endl; - } - string back = ss.str(); - return back; -} - -/*======================================================*/ -/*======================================================*/ -/*======================================================*/ - -GbObject3DTableModel::GbObject3DTableModel(GbObject3DManager* manager) -{ - this->objectManager = manager; -} - -/*======================================================*/ -GbObject3DTableModel::~GbObject3DTableModel(void) -{ -} - -/*======================================================*/ -//Gibt die Anzahl der Spalten zurueck. -int GbObject3DTableModel::getColumnNumber() -{ - return 3; -} - -/*======================================================*/ -std::string GbObject3DTableModel::getColumnLabel(int column) -{ - switch(column) - { - case COL_NAME: return "Name"; - case COL_TYPE: return "Type"; - case COL_ACTIVE: return "Active"; - default: throw UbException(UB_EXARGS,"falscher Spaltenindex"); - } -} - -/*======================================================*/ -int GbObject3DTableModel::getRowNumber() -{ - return this->objectManager->getNumberOfGbObject3Ds(); -} -/*======================================================*/ -int GbObject3DTableModel::getSelectedRowIndex() -{ - return 0; - // return this->objectManager->getSelectedIndex(); -} - -/*======================================================*/ -int GbObject3DTableModel::getColumnType(int column) -{ - switch(column) { - case COL_NAME : - return UbTableModel::COL_TYPE_STRING; - break; - case COL_TYPE : - return UbTableModel::COL_TYPE_STRING; - break; - case COL_ACTIVE : - return UbTableModel::COL_TYPE_BOOL; - break; - } - return -1; -} - -//Gibt den Eintag der Tabelle an der angegebenen Spalten- und -//Zeilenposition in Form eines String Werts zurueck. -std::string GbObject3DTableModel::getStringValue(int row, int col) -{ - GbObject3DEntry* gbObjEntry = dynamic_cast<GbObject3DEntry*>(this->objectManager->getObObjectEntry(row)); - switch(col) { - case COL_NAME: - return gbObjEntry->name; - break; - case COL_TYPE: - return gbObjEntry->getObject()->getTypeID(); - break; - case COL_ACTIVE: - if ( gbObjEntry->active ) return "True"; - return "False"; - break; - } - return "Fehler"; -} - -/*======================================================*/ -//bool GbObject3DManager::selectGbObject3D(int index) -//{ -// cout<<"GbObject3DManager::selectGbObject3D(int index):"<<index<<endl; -// if (index > (int)this->gbObject3DList.size()-1 || index < 0) return false; -// if ( this->selectedObject == this->getGbObject3D(index) ) return true; -// this->selectedObject = this->getGbObject3D(index); -// this->notifyObserversObjectChanged(); -// return true; -//} -///*======================================================*/ -//bool GbObject3DManager::selectGbObject3D(GbObject3D* geoObject) -//{ -// for(int pos=0; pos<(int)this->gbObject3DList.size(); pos++) -// { -// if(this->gbObject3DList[pos]->geoObject==geoObject) -// { -// return this->selectGbObject3D(pos); -// } -// } -// return false; -//} -///*======================================================*/ -//GbObject3D* GbObject3DManager::getSelectedGbObject3D() -//{ -// return this->selectedObject; -//} -///*======================================================*/ -//int GbObject3DManager::getSelectedIndex() -//{ -// for(int pos=0; pos<(int)this->gbObject3DList.size(); pos++) -// { -// if(this->gbObject3DList[pos]->geoObject==this->selectedObject) -// { -// return pos; -// } -// } -// return -1; -//} diff --git a/src/basics/geometry3d/GbObject3DManager.h b/src/basics/geometry3d/GbObject3DManager.h deleted file mode 100644 index 5f698f090..000000000 --- a/src/basics/geometry3d/GbObject3DManager.h +++ /dev/null @@ -1,119 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBOBJECT3DMANAGER_H -#define GBOBJECT3DMANAGER_H - -#include <string> -#include <sstream> -#include <vector> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileInput.h> -#include <basics/utilities/UbFileOutput.h> -#include <basics/utilities/UbTableModel.h> -#include <basics/objects/ObObjectManager.h> - -#include <PointerDefinitions.h> - -class GbObject3D; -class GbObject3DManager; -class GbObject3DTableModel; - -class GbObject3DEntry : public ObObjectEntry -{ - friend class GbObject3DManager; - friend class GbObject3DTableModel; -public: - std::string getName() { return this->name;} -private: - //GbObject3DManager *parent; - //GbObject3D *geoObject; - bool active; - std::string name; - - - GbObject3DEntry(GbObject3DManager* parent, GbObject3D* geoObject, bool active, std::string name); - -}; - - -class GbObject3DManager : public ObObjectManager -{ -public: - GbObject3DManager(); - ~GbObject3DManager(); - - ObObjectEntry* createNewObObjectEntry(ObObject *obj); - ObObjectFactory* getObObjectFactory(); - - - //bool addGbObject3D(GbObject3D *geoObject3D); - bool addGbObject3D(GbObject3D *geoObject3D, std::string name); - //bool addGbObject3D(GbObject3D *geoObject3D, bool active, std::string name); - - bool removeGbObject3D(GbObject3D *geoObject3D); - bool removeGbObject3D(int index); - - int getNumberOfGbObject3Ds(); - std::vector<GbObject3D*>* getAllGbObject3Ds(); - GbObject3D* getGbObject3D(int index); - - //keine Definition dafuer da ... - //void writeValidationAVSFile(string filename); - //void writeSurfaceAVSFile(string filename); - - //public final OctConstructionDescriptor[] getAllActiveConstructions() - //public final OctSpecificConstructionInstrument getSpecificConstructionInstrumentInstance(int index) - //public final boolean isConstructionActive(int index) - //public final boolean isConstructionVisible(int index) - //public final void activateConstruction(int index, boolean active) - //public final void visibleConstruction(int index, boolean visible) - // UbTableModel* getTableModel(); - //void objectChanged(UbObservable* observable); - //void objectWillBeDeleted(UbObservable* observable); - - - void read(UbFileInput *in); - void write(UbFileOutput *out); - - std::string toString(); - -private: - //GbObject3DTableModel* tablemodel; - // GbObject3D* selectedObject; - //vector<GbObject3DEntry*> gbObject3DList; -}; - -class GbObject3DTableModel : public UbTableModel -{ -public: - - static const int COL_NAME = 0; - static const int COL_TYPE = 1; - static const int COL_ACTIVE = 2; - - GbObject3DTableModel(GbObject3DManager* manager); - ~GbObject3DTableModel(void); - - ////////////////////////////////////////////////////////////////////////// - //Geerbt von CabTable - int getColumnNumber(void); - int getRowNumber(); - - std::string getColumnLabel(int column); - - int getColumnType(int); - std::string getStringValue(int row, int col); - int getSelectedRowIndex(); - //bool GetBoolValue(int row, int col); - void setStringValue(int row, int col, std::string str) { throw UbException(UB_EXARGS,"not implemented"); } - -protected: - GbObject3DManager* objectManager; -}; - -#endif diff --git a/src/basics/geometry3d/GbObjectGroup3D.cpp b/src/basics/geometry3d/GbObjectGroup3D.cpp deleted file mode 100644 index 4a6301a4d..000000000 --- a/src/basics/geometry3d/GbObjectGroup3D.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include <numerics/geometry3d/GbObjectGroup3D.h> -#include <numerics/geometry3d/GbSystem3D.h> -#include <numerics/geometry3d/GbPoint3D.h> -#include <numerics/geometry3d/GbLine3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> - -using namespace std; - -/*=====================================================*/ -GbObjectGroup3D::GbObjectGroup3D() -{ - this->setName("ObjectGroup"); -} -/*=====================================================*/ -GbObjectGroup3D::~GbObjectGroup3D() -{ -} -/*=====================================================*/ -void GbObjectGroup3D::finalize() -{ - throw UbException(UB_EXARGS,"not implemented."); -} -/*=======================================================*/ -void GbObjectGroup3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3) -{ - throw UbException(UB_EXARGS,"not implemented."); -} -/*=====================================================*/ -double GbObjectGroup3D::getDistance(GbPoint3D* p) -{ - throw UbException(UB_EXARGS,"not implemented."); -} -/*=====================================================*/ - -void GbObjectGroup3D::setCenterX1Coordinate(const double& value) -{ - throw UbException(UB_EXARGS,"not implemented."); -} -/*=====================================================*/ -void GbObjectGroup3D::setCenterX2Coordinate(const double& value) -{ - throw UbException(UB_EXARGS,"not implemented."); -} -/*=====================================================*/ -void GbObjectGroup3D::setCenterX3Coordinate(const double& value) -{ - throw UbException(UB_EXARGS,"not implemented."); -} -/*=====================================================*/ -void GbObjectGroup3D::setRadius(const double& radius) -{ - throw UbException(UB_EXARGS,"not implemented."); -} -/*=====================================================*/ -double GbObjectGroup3D::getDistance(const double& x1p, const double& x2p, const double& x3p) -{ - throw UbException(UB_EXARGS,"not implemented."); -} -/*=====================================================*/ -//true, wenn 'in Object' oder 'auf Boundary'! -bool GbObjectGroup3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p) -{ - return false; -} -/*=====================================================*/ -//true, wenn 'in Object' oder 'auf Boundary'! -bool GbObjectGroup3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary) -{ - return false; -} -/*=====================================================*/ -string GbObjectGroup3D::toString() -{ - stringstream ss; - ss<< "GbObjectGroup3D["; - ss <<"mid="<<midPoint->toString()<<", r="<<radius<<"]"; - return ss.str(); -} -/*=====================================================*/ -GbLine3D* GbObjectGroup3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2) -{ - return NULL; -} -/*=========================================================================*/ -vector<GbTriangle3D*> GbObjectGroup3D::getSurfaceTriangleSet() -{ - vector<GbTriangle3D*> allTriangles; - - //loop ueber alle objekte in der group - for( std::list< GbObject3D* >::iterator iter = this->geoobjects.begin(); - iter != this->geoobjects.end(); - iter++ ) - { - vector<GbTriangle3D*> triangles; - triangles = (*iter)->getSurfaceTriangleSet(); - - for( size_t i=0;i<triangles.size(); i++ ) - { - //kopieren... - allTriangles.push_back( triangles[i] ); - } - } - return allTriangles; -} -/*=======================================================*/ -void GbObjectGroup3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles) -{ -} -/*=======================================================*/ -void GbObjectGroup3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - midPoint->write(out); - out->writeDouble(radius); - out->writeInteger((int)triangulationMode); -} -/*=======================================================*/ -void GbObjectGroup3D::read(UbFileInput* in) -{ -} -/*=======================================================*/ -bool GbObjectGroup3D::hasIntersectionWithDirectedLine(GbPoint3D origin, GbPoint3D direction) -{ - return false; -} -/*=======================================================*/ -bool GbObjectGroup3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - return false; -} -/*=======================================================*/ -bool GbObjectGroup3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - return false; -} -/*==========================================================*/ -double GbObjectGroup3D::getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - return 0.0; -} -/*==========================================================*/ -double GbObjectGroup3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) -{ - return 0.0; -} -/*=======================================================*/ diff --git a/src/basics/geometry3d/GbObjectGroup3D.h b/src/basics/geometry3d/GbObjectGroup3D.h deleted file mode 100644 index 49c00da70..000000000 --- a/src/basics/geometry3d/GbObjectGroup3D.h +++ /dev/null @@ -1,159 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBOBJECTGROUP3D_H -#define GBOBJECTGROUP3D_H - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF -#ifdef CAB_CTL - #include <ctl.h> -#endif //CAB_CTL - -#include <vector> -#include <cmath> - -#include <numerics/geometry3d/GbObject3D.h> -#include <basics/utilities/UbObserver.h> -#include <numerics/geometry3d/GbPoint3D.h> - -#include <PointerDefinitions.h> - -class GbLine3D; -class GbTriangle3D; -class GbObject3DCreator; - -class GbObjectGroup3D : public GbObject3D, public UbObserver -{ -public: - enum TRIANGULATIONMODE { CUBOIDPROJECTION ,RAYPROJECTION }; - - ////////////////////////////////////////////////////////////////////////// - // Konstruktoren - GbObjectGroup3D(); - GbObjectGroup3D(GbObjectGroup3D *group){}; - ~GbObjectGroup3D(); - - GbObjectGroup3D* clone() {return new GbObjectGroup3D(this);} - void finalize(); - - void addGbObject(GbObject3D* object) - { - this->geoobjects.push_back(object); - } - - double getRadius() const { return this->radius; } - - double getX1Centroid() { return midPoint->getX1Coordinate();} - double getX1Minimum() { return midPoint->getX1Coordinate()-radius;} - double getX1Maximum() { return midPoint->getX1Coordinate()+radius;} - double getX2Centroid() { return midPoint->getX2Coordinate();} - double getX2Minimum() { return midPoint->getX2Coordinate()-radius;} - double getX2Maximum() { return midPoint->getX2Coordinate()+radius;} - double getX3Centroid() { return midPoint->getX3Coordinate();} - double getX3Minimum() { return midPoint->getX3Coordinate()-radius;} - double getX3Maximum() { return midPoint->getX3Coordinate()+radius;} - - void setCenterX1Coordinate(const double& value); - void setCenterX2Coordinate(const double& value); - void setCenterX3Coordinate(const double& value); - void setCenterCoordinates(const double& x1, const double& x2, const double& x3); - void setRadius(const double& radius); - - GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2); - double getDistance(GbPoint3D* p); - double getDistance(const double& x1p, const double& x2p, const double& x3p); - - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3); - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); - - 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); - - std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles); - - bool hasRaytracing() { return true; } - /*|r| must be 1! einheitsvector!!*/ - double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3); - - bool hasIntersectionWithDirectedLine(GbPoint3D origin, GbPoint3D direction); - - std::string toString(); - - ObObjectCreator* getCreator(){ return NULL; }; - void write(UbFileOutput* out); - void read(UbFileInput* in); - - void translate(const double& x1, const double& x2, const double& x3) - { - this->midPoint->translate(x1, x2, x3); - this->notifyObserversObjectChanged(); - } - void rotate(const double& rx1, const double& rx2, const double& rx3) {/* rotation makes no sense*/ } - void scale(const double& sx1, const double& sx2, const double& sx3) { this->radius *= sx1; } - - TRIANGULATIONMODE getTriangulationMode() {return triangulationMode;} - void setTriangulationMode(TRIANGULATIONMODE mode) { this->triangulationMode = mode; } - - //virtuelle Methoden von UbObserver - void objectChanged(UbObservable* changedObject) - { - this->notifyObserversObjectChanged(); - //std::cout<<"GbSphere:objectChanged() - toDo-);"; - } - void objectWillBeDeleted(UbObservable* objectForDeletion) - { - std::cout<<"throw UbException(-GbObjectGroup3D::finalize() - toDo-);"; - } - - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere, weil man eine - - std::list< GbObject3D* > getGbObject3DList() { return this->geoobjects; } - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & midPoint; - ar & radius; - ar & triangulationMode; - ar & geoobjects; - } -#endif //CAB_RCF -#ifdef CAB_CTL - ctl::oStream &write(ctl::oStream &os) const - { - midPoint->write(os); - return os<<radius; - } - ctl::iStream &read(ctl::iStream &is) - { - midPoint->read(is); - return is>>radius; - } -#endif //CAB_CTL - -private: - GbPoint3D* midPoint; - double radius; // Radius des Kreises - TRIANGULATIONMODE triangulationMode; - - std::list< GbObject3D* > geoobjects; -}; - -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - #if defined(RCF_USE_SF_SERIALIZATION) && (CAB_RCF <= 903) - SF_SERIALIZE_ENUM(GbObjectGroup3D::TRIANGULATIONMODE) //bei klassen ausserhalb der klasse;-) - #endif - UB_AUTO_RUN_NAMED( SF::registerType<GbObjectGroup3D>("GbObjectGroup3D") , SF_GbObjectGroup3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbObjectGroup3D >()), SF_GbObjectGroup3D_BD1 ); -#endif //RCF_USE_SF_SERIALIZATION - -#endif //GbObjectGroup3D_H diff --git a/src/basics/geometry3d/GbPoint3D.cpp b/src/basics/geometry3d/GbPoint3D.cpp index e5fec169c..b0a179e69 100644 --- a/src/basics/geometry3d/GbPoint3D.cpp +++ b/src/basics/geometry3d/GbPoint3D.cpp @@ -1,14 +1,38 @@ -#include <numerics/geometry3d/GbPoint3D.h> -//#include <numerics/geometry3d/GbTriangle3D.h> -#include <numerics/geometry3d/creator/GbPoint3DCreator.h> - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbPoint3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= +#include <GbPoint3D.h> using namespace std; -/*=======================================================*/ -ObObjectCreator* GbPoint3D::getCreator() -{ - return GbPoint3DCreator::getInstance(); -} /*=======================================================*/ GbPoint3D::GbPoint3D() { @@ -77,7 +101,7 @@ vector<GbTriangle3D*> GbPoint3D::getSurfaceTriangleSet() //old: //to avoid unnecessary exceptions a point will generate a triangle with - //three point with same coordinates + //c3 point with same coordinates //vector<GbTriangle3D*> triangles; //GbPoint3D p1(getX1Coordinate(),getX2Coordinate(),getX3Coordinate()); //triangles.push_back(new GbTriangle3D(new GbPoint3D(p1),new GbPoint3D(p1),new GbPoint3D(p1))); @@ -95,31 +119,11 @@ string GbPoint3D::toString() return((ss.str()).c_str()); } /*=======================================================*/ -void GbPoint3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - out->writeDouble(x1); - out->writeDouble(x2); - out->writeDouble(x3); -} -/*=======================================================*/ -void GbPoint3D::read(UbFileInput* in) -{ - x1=in->readDouble(); - x2=in->readDouble(); - x3=in->readDouble(); -} -/*=======================================================*/ void GbPoint3D::translate(const double& dx1, const double& dx2, const double& dx3) { this->x1 += dx1; this->x2 += dx2; this->x3 += dx3; - // wenn Notify hier dann nicht im Cuboid oder spher translate ?! - //sollte eigentlich! - //--> hier muss notify aufgerufen werden udn rekuriv dann z.B. Cuboid, etc - - //aber da ist halt einfach daemlich, ich asse es auf gellers way... (erstmal) this->notifyObserversObjectChanged(); } /*=======================================================*/ diff --git a/src/basics/geometry3d/GbPoint3D.h b/src/basics/geometry3d/GbPoint3D.h index 611e1a036..956f10461 100644 --- a/src/basics/geometry3d/GbPoint3D.h +++ b/src/basics/geometry3d/GbPoint3D.h @@ -1,31 +1,49 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbPoint3D.h +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef GBPOINT3D_H #define GBPOINT3D_H -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - #include <string> #include <sstream> #include <cmath> -#include <numerics/geometry3d/GbObject3D.h> +#include <GbObject3D.h> #include <PointerDefinitions.h> class GbTriangle3D; -class GbObject3DCreator; - -#ifdef CAB_CTL - #include <ctl.h> -#endif +//! \brief This Class provides basic 3D point objects. class GbPoint3D : public GbObject3D { public: @@ -77,33 +95,9 @@ public: std::vector<GbTriangle3D*> getSurfaceTriangleSet(); GbLine3D* createClippedLine3D(GbPoint3D &point1, GbPoint3D &point2); virtual std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren //, welche sonst hier "ueberdeckt" waere,da es dieselbe methode mit anderen args gibt! -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & x1; - ar & x2; - ar & x3; - } -#endif //CAB_RCF - -#ifdef CAB_CTL - ctl::oStream &write(ctl::oStream &os) const - { - return os<<x1<<x2<<x3; - } - ctl::iStream &read(ctl::iStream &is) - { - return is>>x1>>x2>>x3; - } -#endif //member double x1; @@ -112,9 +106,4 @@ public: }; -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - UB_AUTO_RUN_NAMED( SF::registerType<GbPoint3D>("GbPoint3D") , SF_GbPoint3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbPoint3D >()), SF_GbPoint3D_BD1 ); -#endif //RCF_USE_SF_SERIALIZATION - #endif diff --git a/src/basics/geometry3d/GbPolygon3D.cpp b/src/basics/geometry3d/GbPolygon3D.cpp index 80f883347..2ba04de82 100644 --- a/src/basics/geometry3d/GbPolygon3D.cpp +++ b/src/basics/geometry3d/GbPolygon3D.cpp @@ -1,13 +1,39 @@ -#include <numerics/geometry3d/GbPolygon3D.h> -#include <numerics/geometry3d/creator/GbPolygon3DCreator.h> +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbPolygon3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= +#include <GbPolygon3D.h> using namespace std; -ObObjectCreator* GbPolygon3D::getCreator() -{ - return GbPolygon3DCreator::getInstance(); -} - int GbPolygon3D::counter = 0; GbPolygon3D::GbPolygon3D() @@ -29,7 +55,7 @@ void GbPolygon3D::init() ps = NULL; } -/** +/*! * Creates an empty 3D polygon with the specified capacity. * @param capacity the initial capacity */ @@ -283,44 +309,6 @@ void GbPolygon3D::addPoints(vector<GbPoint3D>& points) //super.notifyObservers(); } /** -* Inserts a point at the specified position within this polygon. Notifies the observers of this 3D polygon. -* @param point the point -* @param index the index -* @exception ArrayIndexOutOfBoundsException if the specified index is not valid -*/ -//public void insertPoint(GbPoint3D point, int index) throws ArrayIndexOutOfBoundsException -//{ -// if((this instanceof GbPolygon3D) && !(point instanceof GbPoint3D)) throw new IllegalArgumentException("GbPolygon3D.insertPoint(): points of 3D polygons have to be 3D points!"); -// if(index < 0 || index > this.ps.size()) throw new ArrayIndexOutOfBoundsException("GbPolygon3D.insert(): invalid index specified: "+index); - -// this.ps.insert(point, index); -// point.addObserver(this.po); -// this.consistent = false; -// super.notifyObservers(); -//} -/** -* Removes all points from this polygon identical to the specified one. Notifies the observers of this 3D polygon. -* @param point the point -*/ -//public void deletePoint(GbPoint3D point) -//{ -// this.ps.delete(point); -// point.removeObserver(this.po); -// this.consistent = false; -// super.notifyObservers(); -//} -/** -* Removes all points from this polygon equal to the specified one. Notifies the observers of this 3D polygon. -* @param point the point -*/ -//public void deleteEqualPoint(GbPoint3D point) -//{ -// this.ps.deleteEqual(point); -// point.removeObserver(this.po); -// this.consistent = false; -// super.notifyObservers(); -//} -/** * Removes all points from this polygon. Notifies the observers of this 3D polygon. */ void GbPolygon3D::clear() @@ -333,27 +321,6 @@ void GbPolygon3D::clear() this->consistent = false; //super.notifyObservers(); } - -/** -* Returns true if this 3D polygon equals the specified object. -* Two polygon are equal, if their points are equal. -* <BR>Note that the order of points is recognized! -* @return true if this 3D polygon equals the specified object -* @see GbPoint3D#equals(java.lang.Object) -*/ -// bool equals(Object object) -// { -// try -// { -// GbPolygon2D polygon = (GbPolygon3D) object; -//int n = this.size(); - -//if(n != polygon.size()) return(false); -//for(int i=0; i<n; i++) if(!this.getPoint(i).equals(polygon.getPoint(i))) return(false); -//return(true); -// } -// catch(Exception e){ return(false); } -// } /** * Returns a string representation of this 3D polygon. * @return a string representation of this 3D polygon @@ -363,16 +330,6 @@ string GbPolygon3D::toString() stringstream ss; ss<<"GbPolygon3D["; ss<<this->size()<<" points"; - - // ss<<", x1s="<<this->x1s; - // ss<<", x2s="<<this->x2s; - //ss<<", x3s="<<this->x3s; - // ss<<", x1min="<<this->x1min; - // ss<<", x1max="<<this->x1max; - // ss<<", x2min="<<this->x2min; - // ss<<", x2max="<<this->x2max; - //ss<<", x3min="<<this->x3min; - // ss<<", x3max="<<this->x3max; ss<<"]"<<endl; for(int u=0; u<this->size(); u++) ss<<this->ps->getPoint(u)->toString()<<endl; @@ -381,204 +338,6 @@ string GbPolygon3D::toString() } /*======================================================================*/ - -/*======================================================================*/ -/* Calculation */ -/* */ -/* -* Returns the intersection points of this 3D polygon and the specified 3D line. -* @param line the 3D line to intersect -* @return the intersection points of this 3D polygon and the specified 3D line -*/ -// public GbPoint3D[] calculateIntersectionPoints3D(GbLine3D line) -// { -// GbSystem.PointSet pointSet = new GbSystem.PointSet(0); -// GbPoint3D points[] = this.getPoints(); -// GbPoint3D pCrossed = null; -// int n = points.length; -// if(n < 2) return(pointSet.getPoints()); - -// for(int i=1; i<n; i++) -// { -//pCrossed = GbSystem.calculateIntersectionPoint3D(points[i-1], points[i], line.p1, line.p2); -//if(pCrossed != null) pointSet.add(pCrossed); -// } -// pCrossed = GbSystem.calculateIntersectionPoint3D(points[n-1], points[0], line.p1, line.p2); -// if(pCrossed != null) pointSet.add(pCrossed); - -// return(pointSet.getPoints()); -// } - -/* -* Returns true if the specified 3D point lies within (or on the border of) this 3D polygon. -* @param point the 3D point to check -* @return true if the specified 3D point lies within (or on the border of) this 3D polygon -*/ -// public boolean enclosesPoint3D(GbPoint3D point) -// { -// if(GbSystem.less(point.x1, this.x1min)) return(false); -// if(GbSystem.less(point.x2, this.x2min)) return(false); -// if(GbSystem.greater(point.x1, this.x1max)) return(false); -// if(GbSystem.greater(point.x2, this.x2max)) return(false); -// if(this.containsEqual(point) > 0) return(true); - -// QbList ltest = new QbList(GbPoint2D.class, QbList.NOEQUALOBJECTS); -// GbPoint3D points[] = this.getPoints(); -// GbPoint3D ptest; -// int n = points.length; -// if(n < 2) return(false); - -// if(GbSystem.equal(point.x2, this.x2min)) ptest = new GbPoint3D(point.x1, this.x2min-1.0); -// else ptest = new GbPoint3D(point.x1, this.x2max+1.0); - -// for(int i=1; i<n; i++) -// { -//try { ltest.append(GbSystem.calculateIntersectionPoint2D(points[i-1], points[i], point, ptest)); } -//catch(Exception e){} -// } -// try { ltest.append(GbSystem.calculateIntersectionPoint3D(points[n-1], points[0], point, ptest)); } -// catch(Exception e){} -// return((ltest.size()%2)==1); -// } - -/* -* Returns a new 3D polygon clipped by the specified 3D rectangle (result may be null!). -* @param rectangle the 3D rectangle -* @return a new 3D polygon clipped by the specified 3D rectangle -*/ -// GbPolygon3D *createClippedPolygon3D(GbCuboid3D *cube) -// { -//return(GbSystem::clipPolygon3D(this->getPoints(), cube->p1->x1, cube->p1->x2, cube->p1->x3, , cube->p2->x1, cube->p2->x2, cube->p2->x3)); -// } -/* -* Returns a new 3D polygon clipped by the specified 3D rectangle (result may be null!). -* @param p1 the 1st point of the rectangle -* @param p2 the 2nd point of the rectangle -* @return a new 3D polygon clipped by the specified 3D rectangle -*/ -// GbPolygon3D *createClippedPolygon3D(GbPoint3D *p1, GbPoint3D *p2) -// { -//return(GbSystem::clipPolygon3D(this->getPoints(), p1->x1, p1->x2, p1->x3, p2->x1, p2->x2, p2->x3)); -// } -/* -* Returns a new 3D polygon clipped by the specified 3D rectangle (result may be null!). -* @param p1x1 the 1st x1 coordinate of the rectangle -* @param p1x2 the 1st x2 coordinate of the rectangle -* @param p2x1 the 2nd x1 coordinate of the rectangle -* @param p2x2 the 2nd x2 coordinate of the rectangle -* @return a new 3D polygon clipped by the specified 3D rectangle -*/ -// GbPolygon3D *createClippedPolygon3D(double p1x1, double p1x2, double p1x3, double p2x1, double p2x2, double p2x3) -// { -//return(GbSystem::clipPolygon3D(this.getPoints(), p1x1, p1x2, p1x3, p2x1, p2x2. p2x3)); -// } - -/* -* Returns true if the specified 3D rectangle lies completely within this 3D polygon. -* @param rectangle the 3D rectangle to check -* @return true if the specified 3D rectangle lies completely within this 3D polygon -*/ -//public boolean enclosesRectangle3D(GbRectangle3D rectangle) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); -// return(p!=null && GbSystem.equal(Math.abs(p.getArea()), rectangle.getArea())); -//} -/* -* Returns true if the specified 3D rectangle lies completely within this 3D polygon. -* @param p1 the 1st point of the rectangle to check -* @param p2 the 2nd point of the rectangle to check -* @return true if the specified 3D rectangle lies completely within this 3D polygon -*/ -//public boolean enclosesRectangle3D(GbPoint3D p1, GbPoint3D p2) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2); -// return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2)))); -//} -/* -* Returns true if the specified 3D rectangle lies completely within this 3D polygon. -* @param p1x1 the 1st x1 coordinate of the rectangle to check -* @param p1x2 the 1st x2 coordinate of the rectangle to check -* @param p2x1 the 2nd x1 coordinate of the rectangle to check -* @param p2x2 the 2nd x2 coordinate of the rectangle to check -* @return true if the specified 3D rectangle lies completely within this 3D polygon -*/ -//public boolean enclosesRectangle3D(double p1x1, double p1x2, double p2x1, double p2x2) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1x1, p1x2, p2x1, p2x2); -// return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1x1-p2x1)*(p1x2-p2x2)))); -//} - -/* -* Returns true if the specified 3D rectangle is crossed by this 3D polygon. -* @param rectangle the 3D rectangle to check -* @return true if the specified 3D rectangle is crossed by this 3D polygon -*/ -//public boolean crossesRectangle3D(GbRectangle3D rectangle) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); -// return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, rectangle.getArea())); -//} -/* -* Returns true if the specified 3D rectangle is crossed by this 3D polygon. -* @param p1 the 1st point of the rectangle to check -* @param p2 the 2nd point of the rectangle to check -* @return true if the specified 3D rectangle is crossed by this 3D polygon -*/ -//public boolean crossesRectangle3D(GbPoint3D p1, GbPoint3D p2) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2); -// return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2)))); -//} -/* -* Returns true if the specified 3D rectangle is crossed by this 3D polygon. -* @param p1x1 the 1st x1 coordinate of the rectangle to check -* @param p1x2 the 1st x2 coordinate of the rectangle to check -* @param p2x1 the 2nd x1 coordinate of the rectangle to check -* @param p2x2 the 2nd x2 coordinate of the rectangle to check -* @return true if the specified 3D rectangle is crossed by this 3D polygon -*/ -//public boolean crossesRectangle3D(double p1x1, double p1x2, double p2x1, double p2x2) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1x1, p1x2, p2x1, p2x2); -// return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1x1-p2x1)*(p1x2-p2x2)))); -//} - -/* -* Returns true if the specified 3D rectangle lies (at least partly) within this 3D polygon. -* @param rectangle the 3D rectangle to check -* @return true if the specified 3D rectangle lies (at least partly) within this 3D polygon -*/ -//public boolean enclosesOrCrossesRectangle3D(GbRectangle3D rectangle) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); -// return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); -//} -/* -* Returns true if the specified 3D rectangle lies (at least partly) within this 3D polygon. -* @param p1 the 1st point of the rectangle to check -* @param p2 the 2nd point of the rectangle to check -* @return true if the specified 3D rectangle lies (at least partly) within this 3D polygon -*/ -//public boolean enclosesOrCrossesRectangle3D(GbPoint3D p1, GbPoint3D p2) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2); -// return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); -//} -/* -* Returns true if the specified 3D rectangle lies (at least partly) within this 3D polygon. -* @param p1x1 the 1st x1 coordinate of the rectangle to check -* @param p1x2 the 1st x2 coordinate of the rectangle to check -* @param p2x1 the 2nd x1 coordinate of the rectangle to check -* @param p2x2 the 2nd x2 coordinate of the rectangle to check -* @return true if the specified 3D rectangle lies (at least partly) within this 3D polygon -*/ -//public boolean enclosesOrCrossesRectangle3D(double p1x1, double p1x2, double p2x1, double p2x2) -//{ -// GbPolygon3D p = GbSystem.clipPolygon3D(this.getPoints(), p1x1, p1x2, p2x1, p2x2); -// return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); -//} -/*======================================================================*/ - void GbPolygon3D::calculateValues() { this->x1s = 0.0; @@ -591,96 +350,7 @@ void GbPolygon3D::calculateValues() this->x3min = 0.0; this->x3max = 0.0; throw UbException(UB_EXARGS,"should be implemented"); - - //this->consistent = true; - - //this->points = this->ps->getPoints(); - - //int n = (int)this->points.size(); - //if(n < 1) return; - - //GbPoint3D p1 = (this->points)[0]; - //GbPoint3D p2 = NULL; - //double h1 = 0.0; - //double h2 = 0.0; - //double f=0.0; - - //this->x1s = p1.x1; - //this->x1min = p1.x1; - //this->x1max = p1.x1; - //this->x2s = p1.x2; - //this->x2min = p1.x2; - //this->x2max = p1.x2; - //this->x3s = p1.x2; - //this->x3min = p1.x2; - //this->x3max = p1.x2; - - //std::cout<<"Should be implemented "<<endl; - - //for(int i=1; i<n; i++) - //{ - // p2 = (this->points)[i]; - // f = p1.x1*p2.x2 - p1.x2*p2.x1; - // this->area += f; - // h1 += f*(p1.x2 + p2.x2); - // h2 += f*(p1.x1 + p2.x1); - // p1 = p2; - - // if(p1.x1 < this->x1min) this->x1min = p1.x1; - // if(p1.x1 > this->x1max) this->x1max = p1.x1; - // if(p1.x2 < this->x2min) this->x2min = p1.x2; - // if(p1.x2 > this->x2max) this->x2max = p1.x2; - //} - //p2 = (this->points)[0]; - //f = p1.x1*p2.x2 - p1.x2*p2.x1; - //this->area += f; - //h1 += f*(p1.x2 + p2.x2); - //h2 += f*(p1.x1 + p2.x1); - - //this->area *= 0.5; - //h1 /= 6.0; - //h2 /= 6.0; - - //if(n > 2) - //{ - // this->x1s = h2/this->area; - // this->x2s = h1/this->area; - //} - - //if(n < 3 || !GbSystem::inClosedInterval(this->x1s, this->x1min, this->x1max)) this->x1s = 0.5*(this->x1min+this->x1max); - //if(n < 3 || !GbSystem::inClosedInterval(this->x2s, this->x2min, this->x2max)) this->x2s = 0.5*(this->x2min+this->x2max); } /*======================================================================*/ -/*======================================================================*/ -// private class PointObserver implements TiObserver -// { -// GbPolygon3D polygon = null; - -// PointObserver(GbPolygon3D polygon) -// { -//this.polygon = polygon; -// } - -// public void objectChanged(Object object) -// { -//if((object instanceof GbPoint3D) && this.polygon.contains((GbPoint3D)object)>0) -//{ -// this.polygon.consistent = false; -// this.polygon.notifyObservers(); -//} -// } -// } -/*=======================================================*/ -void GbPolygon3D::write(UbFileOutput* out) -{ - throw UbException(UB_EXARGS,"not implemented"); -} -/*=======================================================*/ -void GbPolygon3D::read(UbFileInput* in) -{ - throw UbException(UB_EXARGS,"not implemented"); -} -/*=======================================================*/ - diff --git a/src/basics/geometry3d/GbPolygon3D.h b/src/basics/geometry3d/GbPolygon3D.h index 736913caf..e94f2227d 100644 --- a/src/basics/geometry3d/GbPolygon3D.h +++ b/src/basics/geometry3d/GbPolygon3D.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbPolygon3D.h +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef GBPOLYGON3D_H #define GBPOLYGON3D_H @@ -11,21 +37,19 @@ #include <iostream> -#include <numerics/geometry3d/GbObject3D.h> -#include <numerics/geometry3d/GbLine3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> -#include <numerics/geometry3d/GbSystem3D.h> +#include <GbObject3D.h> +#include <GbLine3D.h> +#include <GbTriangle3D.h> +#include <GbSystem3D.h> #include <PointerDefinitions.h> -class GbObject3DCreator; /*=========================================================================*/ -/* GbPolygon2D */ +//! \class GbPolygon2D /* */ -/* -* This Class provides basic 3D polygon objects. -*/ +//! \brief This Class provides basic 3D polygon objects. + class GbPolygon3D : public GbObject3D { public: @@ -54,7 +78,7 @@ private: /*======================================================================*/ - /* Konstruktoren */ + /* Construcrors */ /* */ /* * Creates an empty 2D polygon. @@ -149,15 +173,6 @@ public: std::vector<GbPoint3D> getPoints(); /* * Returns the points within the specified rectangle. - * @param rectangle the 2D rectangle - * @return the points within the specified rectangle - */ - //public GbPoint2D[] getPoints(GbRectangle2D rectangle) - //{ - // return(this.getPoints(rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2)); - //} - /* - * Returns the points within the specified rectangle. * @param p1 the 1st point of the rectangle * @param p2 the 2nd point of the rectangle * @return the points within the specified rectangle @@ -203,44 +218,6 @@ public: */ void addPoints(std::vector<GbPoint3D>& points); /* - * Inserts a point at the specified position within this polygon. Notifies the observers of this 2D polygon. - * @param point the point - * @param index the index - * @exception ArrayIndexOutOfBoundsException if the specified index is not valid - */ - //public void insertPoint(GbPoint2D point, int index) throws ArrayIndexOutOfBoundsException - //{ - // if((this instanceof GbPolygon3D) && !(point instanceof GbPoint3D)) throw new IllegalArgumentException("GbPolygon2D.insertPoint(): points of 3D polygons have to be 3D points!"); - // if(index < 0 || index > this.ps.size()) throw new ArrayIndexOutOfBoundsException("GbPolygon2D.insert(): invalid index specified: "+index); - - // this.ps.insert(point, index); - // point.addObserver(this.po); - // this.consistent = false; - // super.notifyObservers(); - //} - /* - * Removes all points from this polygon identical to the specified one. Notifies the observers of this 2D polygon. - * @param point the point - */ - //public void deletePoint(GbPoint2D point) - //{ - // this.ps.delete(point); - // point.removeObserver(this.po); - // this.consistent = false; - // super.notifyObservers(); - //} - /* - * Removes all points from this polygon equal to the specified one. Notifies the observers of this 2D polygon. - * @param point the point - */ - //public void deleteEqualPoint(GbPoint2D point) - //{ - // this.ps.deleteEqual(point); - // point.removeObserver(this.po); - // this.consistent = false; - // super.notifyObservers(); - //} - /* * Removes all points from this polygon. Notifies the observers of this 2D polygon. */ void clear(); @@ -291,237 +268,12 @@ public: * @return a string representation of this 2D polygon */ std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - /*======================================================================*/ - - - /*======================================================================*/ - /* Calculation */ - /* */ - /* - * Returns the intersection points of this 2D polygon and the specified 2D line. - * @param line the 2D line to intersect - * @return the intersection points of this 2D polygon and the specified 2D line - */ - // public GbPoint2D[] calculateIntersectionPoints2D(GbLine2D line) - // { - // GbSystem.PointSet pointSet = new GbSystem.PointSet(0); - // GbPoint2D points[] = this.getPoints(); - // GbPoint2D pCrossed = null; - // int n = points.length; - // if(n < 2) return(pointSet.getPoints()); - - // for(int i=1; i<n; i++) - // { - //pCrossed = GbSystem.calculateIntersectionPoint2D(points[i-1], points[i], line.p1, line.p2); - //if(pCrossed != null) pointSet.add(pCrossed); - // } - // pCrossed = GbSystem.calculateIntersectionPoint2D(points[n-1], points[0], line.p1, line.p2); - // if(pCrossed != null) pointSet.add(pCrossed); - - // return(pointSet.getPoints()); - // } - - /* - * Returns true if the specified 2D point lies within (or on the border of) this 2D polygon. - * @param point the 2D point to check - * @return true if the specified 2D point lies within (or on the border of) this 2D polygon - */ - // public boolean enclosesPoint2D(GbPoint2D point) - // { - // if(GbSystem.less(point.x1, this.x1min)) return(false); - // if(GbSystem.less(point.x2, this.x2min)) return(false); - // if(GbSystem.greater(point.x1, this.x1max)) return(false); - // if(GbSystem.greater(point.x2, this.x2max)) return(false); - // if(this.containsEqual(point) > 0) return(true); - - // QbList ltest = new QbList(GbPoint2D.class, QbList.NOEQUALOBJECTS); - // GbPoint2D points[] = this.getPoints(); - // GbPoint2D ptest; - // int n = points.length; - // if(n < 2) return(false); - - // if(GbSystem.equal(point.x2, this.x2min)) ptest = new GbPoint2D(point.x1, this.x2min-1.0); - // else ptest = new GbPoint2D(point.x1, this.x2max+1.0); - - // for(int i=1; i<n; i++) - // { - //try { ltest.append(GbSystem.calculateIntersectionPoint2D(points[i-1], points[i], point, ptest)); } - //catch(Exception e){} - // } - // try { ltest.append(GbSystem.calculateIntersectionPoint2D(points[n-1], points[0], point, ptest)); } - // catch(Exception e){} - // return((ltest.size()%2)==1); - // } - - /* - * Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!). - * @param rectangle the 2D rectangle - * @return a new 2D polygon clipped by the specified 2D rectangle - */ - // GbPolygon3D *createClippedPolygon3D(GbCuboid3D *cube) - // { - //return(GbSystem::clipPolygon3D(this->getPoints(), cube->p1->x1, cube->p1->x2, cube->p1->x3, , cube->p2->x1, cube->p2->x2, cube->p2->x3)); - // }; - /* - * Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!). - * @param p1 the 1st point of the rectangle - * @param p2 the 2nd point of the rectangle - * @return a new 2D polygon clipped by the specified 2D rectangle - */ - // GbPolygon3D *createClippedPolygon2D(GbPoint3D *p1, GbPoint3D *p2) - // { - //return(GbSystem::clipPolygon3D(this->getPoints(), p1->x1, p1->x2, p1->x3, p2->x1, p2->x2, p2->x3)); - // }; - /* - * Returns a new 2D polygon clipped by the specified 2D rectangle (result may be null!). - * @param p1x1 the 1st x1 coordinate of the rectangle - * @param p1x2 the 1st x2 coordinate of the rectangle - * @param p2x1 the 2nd x1 coordinate of the rectangle - * @param p2x2 the 2nd x2 coordinate of the rectangle - * @return a new 2D polygon clipped by the specified 2D rectangle - */ - // GbPolygon3D *createClippedPolygon3D(double p1x1, double p1x2, double p1x3, double p2x1, double p2x2, double p2x3) - // { - //return(GbSystem::clipPolygon3D(this.getPoints(), p1x1, p1x2, p1x3, p2x1, p2x2. p2x3)); - // }; - - /* - * Returns true if the specified 2D rectangle lies completely within this 2D polygon. - * @param rectangle the 2D rectangle to check - * @return true if the specified 2D rectangle lies completely within this 2D polygon - */ - //public boolean enclosesRectangle2D(GbRectangle2D rectangle) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); - // return(p!=null && GbSystem.equal(Math.abs(p.getArea()), rectangle.getArea())); - //} - /* - * Returns true if the specified 2D rectangle lies completely within this 2D polygon. - * @param p1 the 1st point of the rectangle to check - * @param p2 the 2nd point of the rectangle to check - * @return true if the specified 2D rectangle lies completely within this 2D polygon - */ - //public boolean enclosesRectangle2D(GbPoint2D p1, GbPoint2D p2) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2); - // return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2)))); - //} - /* - * Returns true if the specified 2D rectangle lies completely within this 2D polygon. - * @param p1x1 the 1st x1 coordinate of the rectangle to check - * @param p1x2 the 1st x2 coordinate of the rectangle to check - * @param p2x1 the 2nd x1 coordinate of the rectangle to check - * @param p2x2 the 2nd x2 coordinate of the rectangle to check - * @return true if the specified 2D rectangle lies completely within this 2D polygon - */ - //public boolean enclosesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1x1, p1x2, p2x1, p2x2); - // return(p!=null && GbSystem.equal(Math.abs(p.getArea()), Math.abs((p1x1-p2x1)*(p1x2-p2x2)))); - //} - - /* - * Returns true if the specified 2D rectangle is crossed by this 2D polygon. - * @param rectangle the 2D rectangle to check - * @return true if the specified 2D rectangle is crossed by this 2D polygon - */ - //public boolean crossesRectangle2D(GbRectangle2D rectangle) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); - // return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, rectangle.getArea())); - //} - /* - * Returns true if the specified 2D rectangle is crossed by this 2D polygon. - * @param p1 the 1st point of the rectangle to check - * @param p2 the 2nd point of the rectangle to check - * @return true if the specified 2D rectangle is crossed by this 2D polygon - */ - //public boolean crossesRectangle2D(GbPoint2D p1, GbPoint2D p2) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2); - // return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1.x1-p2.x1)*(p1.x2-p2.x2)))); - //} - /* - * Returns true if the specified 2D rectangle is crossed by this 2D polygon. - * @param p1x1 the 1st x1 coordinate of the rectangle to check - * @param p1x2 the 1st x2 coordinate of the rectangle to check - * @param p2x1 the 2nd x1 coordinate of the rectangle to check - * @param p2x2 the 2nd x2 coordinate of the rectangle to check - * @return true if the specified 2D rectangle is crossed by this 2D polygon - */ - //public boolean crossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1x1, p1x2, p2x1, p2x2); - // return(p!=null && GbSystem.inOpenInterval(Math.abs(p.getArea()), 0.0, Math.abs((p1x1-p2x1)*(p1x2-p2x2)))); - //} - - /* - * Returns true if the specified 2D rectangle lies (at least partly) within this 2D polygon. - * @param rectangle the 2D rectangle to check - * @return true if the specified 2D rectangle lies (at least partly) within this 2D polygon - */ - //public boolean enclosesOrCrossesRectangle2D(GbRectangle2D rectangle) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), rectangle.p1.x1, rectangle.p1.x2, rectangle.p2.x1, rectangle.p2.x2); - // return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); - //} - /* - * Returns true if the specified 2D rectangle lies (at least partly) within this 2D polygon. - * @param p1 the 1st point of the rectangle to check - * @param p2 the 2nd point of the rectangle to check - * @return true if the specified 2D rectangle lies (at least partly) within this 2D polygon - */ - //public boolean enclosesOrCrossesRectangle2D(GbPoint2D p1, GbPoint2D p2) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1.x1, p1.x2, p2.x1, p2.x2); - // return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); - //} - /* - * Returns true if the specified 2D rectangle lies (at least partly) within this 2D polygon. - * @param p1x1 the 1st x1 coordinate of the rectangle to check - * @param p1x2 the 1st x2 coordinate of the rectangle to check - * @param p2x1 the 2nd x1 coordinate of the rectangle to check - * @param p2x2 the 2nd x2 coordinate of the rectangle to check - * @return true if the specified 2D rectangle lies (at least partly) within this 2D polygon - */ - //public boolean enclosesOrCrossesRectangle2D(double p1x1, double p1x2, double p2x1, double p2x2) - //{ - // GbPolygon2D p = GbSystem.clipPolygon2D(this.getPoints(), p1x1, p1x2, p2x1, p2x2); - // return(p!=null && GbSystem.greater(Math.abs(p.getArea()), 0.0)); - //} - /*======================================================================*/ - /*======================================================================*/ /* Private Methoden */ /* */ void calculateValues(); /*======================================================================*/ - - - /*======================================================================*/ - // private class PointObserver implements TiObserver - // { - // GbPolygon2D polygon = null; - - // PointObserver(GbPolygon2D polygon) - // { - //this.polygon = polygon; - // } - - // public void objectChanged(Object object) - // { - //if((object instanceof GbPoint2D) && this.polygon.contains((GbPoint2D)object)>0) - //{ - // this.polygon.consistent = false; - // this.polygon.notifyObservers(); - //} - // } - // } - /*======================================================================*/ }; /*=========================================================================*/ #endif diff --git a/src/basics/geometry3d/GbQuadFaceMesh3D.cpp b/src/basics/geometry3d/GbQuadFaceMesh3D.cpp deleted file mode 100644 index 43a72e0c9..000000000 --- a/src/basics/geometry3d/GbQuadFaceMesh3D.cpp +++ /dev/null @@ -1,362 +0,0 @@ -#include <numerics/geometry3d/GbQuadFaceMesh3D.h> -#include <numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h> - -#include <numerics/geometry3d/GbHalfSpace3D.h> -#include <numerics/geometry3d/GbCuboid3D.h> - - -using namespace std; - -GbQuadFaceMesh3D::GbQuadFaceMesh3D() : GbObject3D() -{ - this->name = "new GbMesh"; - this->nodes = new vector<Vertex>; - this->quads = new vector<QuadFace>; - this->consistent = false; -} - -GbQuadFaceMesh3D::GbQuadFaceMesh3D(string name, vector<Vertex> *nodes, vector<QuadFace> *quads) : GbObject3D() -{ - if(name.size()==0 ) throw UbException(UB_EXARGS,"no name specified"); - if(!nodes ) throw UbException(UB_EXARGS,"no nodes specified"); - if(!quads ) throw UbException(UB_EXARGS,"no quads specified"); - - this->name = name; - this->nodes = nodes; - this->quads = quads; - this->consistent = false; -} -/*=============================================================================================*/ - -GbQuadFaceMesh3D::~GbQuadFaceMesh3D() -{ - if(nodes) - { - // for(unsigned u=0; u<nodes->size(); u++) delete (*nodes)[u]; - delete nodes; - } - if(quads) - { - delete quads; - } -} -/*======================================================================*/ -ObObjectCreator* GbQuadFaceMesh3D::getCreator() -{ - return GbQuadFaceMesh3DCreator::getInstance(); -} -/*======================================================================*/ - -void GbQuadFaceMesh3D::init() -{ - nodes = NULL; - quads = NULL; - x1min = 0.0; - x1max = 0.0; - x2min = 0.0; - x2max = 0.0; - x3min = 0.0; - x3max = 0.0; - consistent = false; -} - /** - * Returns a string representation of this triangular mesh. - * @return a string representation of this triangular mesh - */ -string GbQuadFaceMesh3D::toString() -{ - stringstream ss; - ss<<"GbQuadFaceMesh3D["; - ss<<(int)this->quads->size()<<"-Quadangles, "<<(int)this->nodes->size()<<"-Nodes, "<<endl; - //ss<<"\""<<this->name<<", Area=sollt mal berechnet werden ;-)"<<"\""; - //ss<<", x1min="<<this->x1min; - //ss<<", x1max="<<this->x1max; - //ss<<", x2min="<<this->x2min; - //ss<<", x2max="<<this->x2max; - //ss<<", x3min="<<this->x3min; - //ss<<", x3max="<<this->x3max; - ss<<"]"; - return(ss.str()); -} -/** - * Returns the name of this triangular mesh. - * @return the name of this triangular mesh - */ -string GbQuadFaceMesh3D::getName(){ return(this->name); } - -/** - * Returns the nodes of this triangular mesh. - * @return the nodes of this triangular mesh - */ -vector<GbQuadFaceMesh3D::Vertex>* GbQuadFaceMesh3D::getNodes() { return(this->nodes); } -/** - * Returns the quads of this triangular mesh. - * @return the quads of this triangular mesh - */ -vector<GbQuadFaceMesh3D::QuadFace>* GbQuadFaceMesh3D::getQuads() { return(this->quads); } -/** - * Returns the center x1 coordinate of this triangular mesh. - * @return the center x1 coordinate of this triangular mesh - */ -double GbQuadFaceMesh3D::getX1Centroid() -{ - if(!this->consistent) this->calculateValues(); - return(0.5*(this->x1min+this->x1max)); -} -/** - * Returns the center x2 coordinate of this triangular mesh. - * @return the center x2 coordinate of this triangular mesh - */ -double GbQuadFaceMesh3D::getX2Centroid() -{ - if(!this->consistent) this->calculateValues(); - return(0.5*(this->x2min+this->x2max)); -} -/** -* Returns the center x3 coordinate of this triangular mesh. - * @return the center x3 coordinate of this triangular mesh - */ -double GbQuadFaceMesh3D::getX3Centroid() -{ - if(!this->consistent) this->calculateValues(); - return(0.5*(this->x3min+this->x3max)); -} - -/** - * Returns the minimum x1 coordinate of this triangular mesh. - * @return the minimum x1 coordinate of this triangular mesh - */ -double GbQuadFaceMesh3D::getX1Minimum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x1min); -} -/** - * Returns the maximum x1 coordinate of this triangular mesh. - * @return the maximum x1 coordinate of this triangular mesh - */ -double GbQuadFaceMesh3D::getX1Maximum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x1max); -} -/** - * Returns the minimum x2 coordinate of this triangular mesh. - * @return the minimum x2 coordinate of this triangular mesh - */ -double GbQuadFaceMesh3D::getX2Minimum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x2min); -} -/** - * Returns the maximum x2 coordinate of this triangular mesh. - * @return the maximum x2 coordinate of this triangular mesh - */ -double GbQuadFaceMesh3D::getX2Maximum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x2max); -} -/** - * Returns the minimum x3 coordinate of this triangular mesh. - * @return the minimum x3 coordinate of this triangular mesh - */ -double GbQuadFaceMesh3D::getX3Minimum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x3min); -} -/** - * Returns the maximum x3 coordinate of this triangular mesh. - * @return the maximum x3 coordinate of this triangular mesh - */ -double GbQuadFaceMesh3D::getX3Maximum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x3max); -} - -void GbQuadFaceMesh3D::calculateValues() -{ - double x1, x2, x3; - - this->x1min = (*this->nodes)[0].x; - this->x1max = (*this->nodes)[0].x; - this->x2min = (*this->nodes)[0].y; - this->x2max = (*this->nodes)[0].y; - this->x3min = (*this->nodes)[0].z; - this->x3max = (*this->nodes)[0].z; - - for(int i=1; i<(int)this->nodes->size(); i++) - { - x1 = (*this->nodes)[i].x; - x2 = (*this->nodes)[i].y; - x3 = (*this->nodes)[i].z; - if(x1 < this->x1min) this->x1min = x1; - if(x1 > this->x1max) this->x1max = x1; - if(x2 < this->x2min) this->x2min = x2; - if(x2 > this->x2max) this->x2max = x2; - if(x3 < this->x3min) this->x3min = x3; - if(x3 > this->x3max) this->x3max = x3; - } - this->consistent = true; -} - - -/*======================================================================*/ -vector<GbTriangle3D*> GbQuadFaceMesh3D::getSurfaceTriangleSet() -{ - vector<GbTriangle3D*> triangles(0); - return triangles; - //throw UbException(__FILE__, __LINE__, "GbQuadFaceMesh3D::getSurfaceTriangelSet - not implemented"); -} -//vector<GbQuad3D*> GbQuadFaceMesh3D::getSurfaceQuadSet() -//{ -// throw UbException(__FILE__, __LINE__, "GbQuadFaceMesh3D::getSurfaceQuadSet - not implemented"); -// //vector<GbQuadangle3D*> tris; -// //GbQuadangle3D* quad; -// //GbPoint3D* p1; -// //GbPoint3D* p2; -// //GbPoint3D* p3; -// //int size = (int)this->quads->size(); -// //for(int u=0; u<size;u++) -// //{ -// // quad = (*this->quads)[u]; -// // p1 = new GbPoint3D(quad->getPoint1()); -// // p2 = new GbPoint3D(quad->getPoint2()); -// // p3 = new GbPoint3D(quad->getPoint3()); -// // tris.push_back(new GbQuadangle3D(p1, p2, p3)); -// //} -// //return tris; -//} -/*======================================================================*/ -/* -* Function to determine if the point is inside the polyhedron defined as a 3D object -* using the Halfspace algorithm -* @param xp the x-coordinate of the point -* @param yp the y-coordinate of the point -* @param zp the z-coordinate of the point -* @return true if point is inside else return false -*/ -bool GbQuadFaceMesh3D::isPointInObject3DHalfSpace(const double& xp, const double& yp, const double& zp) -{ - throw UbException(UB_EXARGS,"not implemented"); - //vector<GbQuadangle3D*> *Quadangles = this->quads; - //int Quadanglesize = (int)Quadangles->size(); - //GbPoint3D Point(xp,yp,zp); - //for (int i=0; i<Quadanglesize; i++) - //{ - // GbPoint3D* point1 = (*Quadangles)[i]->getPoint1(); - // GbPoint3D* point2 = (*Quadangles)[i]->getPoint2(); - // GbPoint3D* point3 = (*Quadangles)[i]->getPoint3(); - - // GbHalfSpace3D halfspace(point1, point2, point3); - // if (halfspace.ptInside(&Point)) return false; - //} - //return true; -} -/*======================================================================*/ -/*======================================================================*/ -bool GbQuadFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3) -{ - - double xmin=this->getX1Minimum(); double xmax=this->getX1Maximum(); - double ymin=this->getX2Minimum(); double ymax=this->getX2Maximum(); - double zmin=this->getX3Minimum(); double zmax=this->getX3Maximum(); - double dX = (xmax-xmin)/100.; - double dY = (ymax-ymin)/100.; - double dZ = (zmax-zmin)/100.; - GbCuboid3D boundingCube(xmin-dX, ymin-dY, zmin-dZ, xmax+dX, ymax+dY, zmax+dZ); - if(!boundingCube.isPointInGbObject3D(x1, x2, x3)) - { - boundingCube.finalize(); - return false; - } - boundingCube.finalize(); - - // Halfspace algorithm, Area of spherical polygons algorithm or Ray crossing algorithm - GbVector3D bMin(boundingCube.getPoint1()); - GbVector3D bMax(boundingCube.getPoint2()); - bMin = bMax.Subtract(bMin); - //int radius = (int)bMin.Length(); - - //if(((GbQuadFaceMesh3D*)this->geoObject3D)->isPointInObject3DHalfSpace(x1,x2,x3) ) - //if(((GbQuadFaceMesh3D*)this->geoObject3D)->isPointInObject3Darea(x11,x12,x13,numQuadangles)) - //if(this->isPointInObject3DRayCrossing(x1,x2,x3,radius,(int)this->nodes->size(),(int)this->quads->size())) - // return true; - //else - return false; -} -/*======================================================================*/ -bool GbQuadFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary) -{ - throw UbException(UB_EXARGS,"not implemented"); -} -/*======================================================================*/ -GbLine3D* GbQuadFaceMesh3D::createClippedLine3D (GbPoint3D& point1, GbPoint3D& point2) -{ - throw UbException(UB_EXARGS,"not implemented"); -} - -/*======================================================================*/ -void GbQuadFaceMesh3D::writeAVSMesh(UbFileOutput *out, bool normals) -{ - cout<<" - write_ucd ("<<out->getFileName()<<") -> "; - if(!out) - { - cout<<"GbQuadFaceMesh3D::writeAVSMesh() - File konnte nicht geschrieben werden: "<<endl; - return; - } - out->writeLine("# UCD-File created by GbQuadFaceMesh3D"); - - int quadsize = (int)this->quads->size(); - int nodesize = (int)this->nodes->size(); - - out->writeInteger(nodesize); - out->writeInteger(quadsize); - - out->writeInteger(0); - out->writeInteger(0); - out->writeInteger(0); - out->writeLine(); - int nr=1; - Vertex node; - QuadFace face; - for(int i=0;i<nodesize; i++) - { - node = (*nodes)[i]; - out->writeInteger(nr++); - out->writeDouble(node.x); - out->writeDouble(node.y); - out->writeDouble(node.z); - out->writeLine(); - } - - nr=1; - for(int i=0;i<quadsize; i++) - { - face = (*quads)[i]; - out->writeInteger(nr++); - out->writeInteger(2); - out->writeString("quad"); - out->writeInteger(face.vertex1+1); - out->writeInteger(face.vertex2+1); - out->writeInteger(face.vertex3+1); - out->writeInteger(face.vertex4+1); - out->writeLine(); - } - - //out->writeInteger(0); out->writeInteger(1); out->writeLine(); - //out->writeInteger(1); out->writeInteger(1); out->writeLine(); - //out->writeLine("TEST,no_unit"); - //nr=1; - //for(int i=0;i<quadsize; i++) - //{ - // out->writeInteger(nr++); - // out->writeInteger(10); - // out->writeLine(); - //} - cout<<"done\n"; -} - diff --git a/src/basics/geometry3d/GbQuadFaceMesh3D.h b/src/basics/geometry3d/GbQuadFaceMesh3D.h deleted file mode 100644 index 7a993abd7..000000000 --- a/src/basics/geometry3d/GbQuadFaceMesh3D.h +++ /dev/null @@ -1,123 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBQUADFACEMESH3D_H -#define GBQUADFACEMESH3D_H - -#include <sstream> -#include <iostream> - - -#include <numerics/geometry3d/GbObject3D.h> -#include <basics/utilities/UbException.h> - -#include <PointerDefinitions.h> - -class UbFileOutput; -class UbFileInput; -/*=========================================================================*/ -/* GbQuadFaceMesh3D */ -/* */ -/** - * This Class provides the triangular meshes. - * Note, that up to now no methods for checking consistency are included. - * in this context this class describes facettes from an 3D-object !!! -*/ -class GbQuadFaceMesh3D : public GbObject3D -{ -public: - // nested class start - class Vertex - { - public: - Vertex(){} - Vertex(float x, float y, float z) - { - this->x=x; - this->y=y; - this->z=z; - } - float x, y, z; - }; - - class QuadFace - { - public: - QuadFace() {} - QuadFace(int v1, int v2, int v3, int v4) - { - this->vertex1=v1; - this->vertex2=v2; - this->vertex3=v3; - this->vertex4=v4; - } - - int vertex1, vertex2, vertex3, vertex4; - }; - // nested class end - -public: - GbQuadFaceMesh3D(); - GbQuadFaceMesh3D(std::string name, std::vector<Vertex> *nodes, std::vector<QuadFace> *quads); - virtual ~GbQuadFaceMesh3D(); - GbQuadFaceMesh3D* clone() { throw UbException(UB_EXARGS,"clone() - not implemented"); } - void finalize() { throw UbException(UB_EXARGS,"finalize() - not implemented");} - - std::string toString(); - std::string getName(); - std::vector<Vertex>* getNodes(); - std::vector<QuadFace>* getQuads(); - double getX1Centroid(); - double getX2Centroid(); - double getX3Centroid(); - double getX1Minimum(); - double getX1Maximum(); - double getX2Minimum(); - double getX2Maximum(); - double getX3Minimum(); - double getX3Maximum(); - void calculateValues(); - - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3); - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary); - - bool isPointInObject3DHalfSpace(const double& xp, const double& yp, const double& zp); //based on Halfspace algorithm - //bool isPointInObject3DSpherical(const double& xp, const double& yp, const double& zp, int numQuads); //based on Spherical polygon area method - //bool isPointInObject3DRayCrossing(const double& xp, const double& yp, const double& zp, int radius, int numVertices, int numQuads); //based on Ray tracing algorithm - - //char SegPlaneInt(GbQuad3D *quad, GbVector3D &PointQ, GbVector3D &PointR, GbVector3D &Point, int *m); - //char SegQuadCross(GbQuad3D *quad, GbVector3D &PointQ, GbVector3D &PointR); - //till here !!! - - virtual GbLine3D* createClippedLine3D (GbPoint3D &point1,GbPoint3D &point2); - //virtual std::vector<GbQuad3D*> getSurfaceQuadSet(); - virtual std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - virtual ObObjectCreator* getCreator(); - - virtual void write(UbFileOutput* out) { std::cout<<"GbQuadFaceMesh3D::write - sorry not implemented\n"; } - virtual void read(UbFileInput* in) { std::cout<<"GbQuadFaceMesh3D::read - sorry not implemented\n"; } - - void writeAVSMesh(UbFileOutput *out, bool normals=false); - - /*======================================================================*/ - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere -private: - void init(); - /*======================================================================*/ - std::string name; - std::vector<Vertex> *nodes; - std::vector<QuadFace> *quads; - double x1min; - double x1max; - double x2min; - double x2max; - double x3min; - double x3max; - bool consistent; -}; -/*=========================================================================*/ - -#endif diff --git a/src/basics/geometry3d/GbSphere3D.cpp b/src/basics/geometry3d/GbSphere3D.cpp deleted file mode 100644 index 40603c33a..000000000 --- a/src/basics/geometry3d/GbSphere3D.cpp +++ /dev/null @@ -1,922 +0,0 @@ -#include <numerics/geometry3d/GbSphere3D.h> -#include <numerics/geometry3d/GbSystem3D.h> -#include <numerics/geometry3d/GbPoint3D.h> -#include <numerics/geometry3d/GbLine3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> - -#include <numerics/geometry3d/creator/GbSphere3DCreator.h> - -using namespace std; - -ObObjectCreator* GbSphere3D::getCreator() -{ - return GbSphere3DCreator::getInstance(); -} -/*=====================================================*/ -GbSphere3D::GbSphere3D() - : GbObject3D(), UbObserver() -{ - this->setName("sphere"); - radius=0; - midPoint=new GbPoint3D(0,0,0); -} -/*=====================================================*/ -GbSphere3D::GbSphere3D(const double& x1,const double& x2, const double& x3, const double& radius) - : GbObject3D(), UbObserver() -{ - this->setName("sphere"); - midPoint = new GbPoint3D(x1,x2,x3); - midPoint->addObserver(this); - - this->radius = radius; - triangulationMode = RAYPROJECTION; - //triangulationMode = CUBOIDPROJECTION; -} -/*=====================================================*/ -GbSphere3D::GbSphere3D(const GbSphere3D& sphere) - : GbObject3D(), UbObserver() -{ - this->setName("sphere"); - - this->midPoint = sphere.midPoint->clone(); - this->radius = sphere.radius; - triangulationMode = RAYPROJECTION; - - this->midPoint->addObserver(this); -} -/*=====================================================*/ -GbSphere3D::GbSphere3D(GbSphere3D* sphere) - : GbObject3D(), UbObserver() -{ - this->setName(sphere->getName()); - midPoint = sphere->midPoint->clone(); - midPoint->addObserver(this); - - this->radius = sphere->getRadius(); - triangulationMode = RAYPROJECTION; -} -/*=====================================================*/ -GbSphere3D::~GbSphere3D() -{ - if(this->midPoint) this->midPoint->removeObserver(this); -} -/*=====================================================*/ -void GbSphere3D::finalize() -{ - if(this->midPoint) - { - this->midPoint->removeObserver(this); - this->midPoint->finalize(); - delete this->midPoint; - this->midPoint = NULL; - } - - if(this->midPoint) this->midPoint->removeObserver(this); -} -/*=====================================================*/ -bool GbSphere3D::intersects(SPtr<GbSphere3D> sphere) -{ - return this->getDistance(sphere->midPoint) < radius + sphere->radius; -} -/*=======================================================*/ -void GbSphere3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3) -{ - this->translate(x1-getX1Centroid(), x2-getX2Centroid(), x3-getX3Centroid() ); -} - -void GbSphere3D::setCenterCoordinates(const UbTupleDouble3& position) -{ - this->setCenterCoordinates(val<1>(position), val<2>(position), val<3>(position)); -} - -/*=====================================================*/ -double GbSphere3D::getDistance(GbPoint3D* p) -{ - return this->getDistance(p->getX1Centroid(),p->getX2Coordinate(),p->getX3Coordinate()); -} -/*=====================================================*/ -void GbSphere3D::setCenterX1Coordinate(const double& value) -{ - if(this->midPoint) this->midPoint->setX1(value); - else throw UbException(UB_EXARGS,"Sphere has no midPoint"); - //kein notifyObserver(), da der knoten notifyObserver() ausfuehrt und die GbSphere dieses event - //abfaengt und dann selbst notifyObservers ausfuehrt ;-) -} -/*=====================================================*/ -void GbSphere3D::setCenterX2Coordinate(const double& value) -{ - if(this->midPoint) this->midPoint->setX2(value); - else throw UbException(UB_EXARGS,"Sphere has no midPoint"); - //kein notifyObserver(), da der knoten notifyObserver() ausfuehrt und die GbSphere dieses event - //abfaengt und dann selbst notifyObservers ausfuehrt ;-) -} -/*=====================================================*/ -void GbSphere3D::setCenterX3Coordinate(const double& value) -{ - if(this->midPoint) this->midPoint->setX3(value); - else throw UbException(UB_EXARGS,"sphere has no midPoint"); - //kein notifyObserver(), da der knoten notifyObserver() ausfuehrt und die GbSphere dieses event - //abfaengt und dann selbst notifyObservers ausfuehrt ;-) -} -/*=====================================================*/ -void GbSphere3D::setRadius(const double& radius) -{ - if (radius != this->radius) - { - this->radius=radius; - this->notifyObserversObjectChanged(); -} -} -/*=====================================================*/ -double GbSphere3D::getDistance(const double& x1p, const double& x2p, const double& x3p) -{ - double deltaX1 = x1p - midPoint->getX1Coordinate(); - double deltaX2 = x2p - midPoint->getX2Coordinate(); - double deltaX3 = x3p - midPoint->getX3Coordinate(); - return sqrt(deltaX1*deltaX1+deltaX2*deltaX2+deltaX3*deltaX3)-this->radius; -} -/*=====================================================*/ -//true, wenn 'in Object' oder 'auf Boundary'! -bool GbSphere3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p) -{ - double deltaX1 = x1p - midPoint->getX1Coordinate(); - double deltaX2 = x2p - midPoint->getX2Coordinate(); - double deltaX3 = x3p - midPoint->getX3Coordinate(); - - return UbMath::lessEqual(deltaX1*deltaX1+deltaX2*deltaX2+deltaX3*deltaX3, this->radius*this->radius); -} -/*=====================================================*/ -//true, wenn 'in Object' oder 'auf Boundary'! -bool GbSphere3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary) -{ - double deltaX1 = x1p - midPoint->getX1Coordinate(); - double deltaX2 = x2p - midPoint->getX2Coordinate(); - double deltaX3 = x3p - midPoint->getX3Coordinate(); - - double distanceSquare = deltaX1*deltaX1+deltaX2*deltaX2+deltaX3*deltaX3; - double radiusSquare = this->radius*this->radius; - - pointIsOnBoundary = UbMath::equal(distanceSquare,radiusSquare); - - return UbMath::lessEqual(distanceSquare,radiusSquare); -} -/*=====================================================*/ -//bool GbSphere3D::crossCellCrossSection(double x11,double x21,double x12,double x22, double ra) -//{ -// if(this->isPointInCrossection(x11, x12) || this->isPointInCrossection(x21, x22) || this->isPointInCrossection(x11, x22) || this->isPointInCrossection(x21, x12)) -// { -// if(!this->isPointInCrossection(x11, x12) || !this->isPointInCrossection(x21, x22) || !this->isPointInCrossection(x11, x22) || !this->isPointInCrossection(x21, x12)) return true; -// } -// return false; -//} -// -///*=====================================================*/ -//bool GbSphere3D::cellCrossAndInsideCrossSection(double x11,double x21,double x12,double x22, double ra) -//{ -// if(this->isPointInCrossection(x11, x12) || this->isPointInCrossection(x21, x22) || this->isPointInCrossection(x11, x22) || this->isPointInCrossection(x21, x12)) return true; -// return false; -//} -/*=====================================================*/ -string GbSphere3D::toString() -{ - stringstream ss; - ss<< "GbSphere3D["; - ss <<"mid="<<midPoint->toString()<<", r="<<radius<<"]"; - return ss.str(); -} -/*=====================================================*/ -GbLine3D* GbSphere3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2) -{ - double factor = 100.0; //um rundungsfehler beim wurzelterm zu minimieren - double xa = factor*point1.getX1Coordinate(); - double ya = factor*point1.getX2Coordinate(); - double za = factor*point1.getX3Coordinate(); - double xb = factor*point2.getX1Coordinate(); - double yb = factor*point2.getX2Coordinate(); - double zb = factor*point2.getX3Coordinate(); - double xm = factor*this->midPoint->getX1Coordinate(); - double ym = factor*this->midPoint->getX2Coordinate(); - double zm = factor*this->midPoint->getX3Coordinate(); - double r = factor*this->radius; - - double xa2 = xa*xa; - double ya2 = ya*ya; - double za2 = za*za; - double xb2 = xb*xb; - double yb2 = yb*yb; - double zb2 = zb*zb; - double xm2 = xm*xm; - double ym2 = ym*ym; - double zm2 = zm*zm; - double r2 = r*r; - - double wurzel = 2.0*xa*xb*ym2-2.0*ya*yb*r2+2.0*ya*ym*xb2+2.0*yb*ym*za2 - +2.0*ya*ym*zb2+2.0*xb*xm*za2+2.0*za*zb*ym2+2.0*xb*xm*ya2+2.0*xa*xm*yb2 - +2.0*yb*ym*xa2+2.0*zb*zm*ya2+2.0*xa*xm*zb2+2.0*za*zm*xb2+2.0*za*zm*yb2 - +2.0*xa*xb*zm2-2.0*xa*xb*r2-2.0*za*zb*r2+2.0*za*zb*xm2-2.0*ya*yb*xa*xm - +2.0*ya*yb*xa*xb+2.0*zb*zm*xa2-2.0*ya*yb*xb*xm+2.0*ya*yb*xm2-2.0*ya*yb*zb*zm - +2.0*ya*yb*zm2+2.0*zb*zm*yb*ym-2.0*zb*zm*ya*ym+2.0*zb*zm*xb*xm-2.0*xa*xm*yb*ym - +2.0*xa*xm*za*zm+2.0*xa*xm*ya*ym-2.0*yb*ym*za*zm+2.0*yb*ym*xb*xm+2.0*za*zm*ya*ym - -2.0*za*zm*xb*xm-2.0*ya*ym*xb*xm+2.0*za*zb*xa*xb-2.0*za*zb*xa*xm-2.0*za*zb*xb*xm - +2.0*za*zb*ya*yb-2.0*za*zb*ya*ym-2.0*za*zb*yb*ym-2.0*ya*yb*za*zm-xa2*zb2 - -xa2*yb2-zb2*ya2-za2*xb2-za2*yb2-xb2*ya2-2.0*zb*zm*xa*xm - -2.0*xa*xb*za*zm-2.0*xa*xb*zb*zm-2.0*xa*xb*ya*ym-2.0*xa*xb*yb*ym+za2*r2 - -za2*xm2-za2*ym2+zb2*r2-zb2*xm2-zb2*ym2+xa2*r2-xa2*zm2 - -xa2*ym2+xb2*r2-xb2*zm2-xb2*ym2+ya2*r2-ya2*zm2-ya2*xm2 - +yb2*r2-yb2*zm2-yb2*xm2; - double nenner = -2.0*za*zb-2.0*ya*yb-2.0*xa*xb+za2+zb2+xa2+xb2+ya2+yb2; - double zaehler = 2.0*zb*zm-2.0*xa*xm+2.0*yb*ym-2.0*za*zm+xa2-2.0*ya*ym - +2.0*xb*xm-zb2+za2-xb2+ya2-yb2; - - vector<GbPoint3D*> schnittpunkte; - - if(fabs(nenner)>1.E-13 && UbMath::greaterEqual(wurzel,0.0)) - { - double t1 = (zaehler+2.0*sqrt(wurzel))/nenner; - double t2 = (zaehler-2.0*sqrt(wurzel))/nenner; - - if(UbMath::inClosedInterval(t1,-1.0,1.0)) - { - double x = ( xa*(0.5-0.5*t1)+xb*(0.5+0.5*t1) )/factor; - double y = ( ya*(0.5-0.5*t1)+yb*(0.5+0.5*t1) )/factor; - double z = ( za*(0.5-0.5*t1)+zb*(0.5+0.5*t1) )/factor; - - schnittpunkte.push_back(new GbPoint3D(x,y,z)); - } - if(fabs(t2-t1)>1.E-13 && UbMath::inClosedInterval(t2,-1.0,1.0)) - { - double x = ( xa*(0.5-0.5*t2)+xb*(0.5+0.5*t2) )/factor; - double y = ( ya*(0.5-0.5*t2)+yb*(0.5+0.5*t2) )/factor; - double z = ( za*(0.5-0.5*t2)+zb*(0.5+0.5*t2) )/factor; - - schnittpunkte.push_back(new GbPoint3D(x,y,z)); - } - } - - int nofSchnittpunkte = (int)schnittpunkte.size(); - if(nofSchnittpunkte==1) - { - if (this->isPointInGbObject3D(&point1)) return new GbLine3D(schnittpunkte[0],new GbPoint3D(point1)); - else if(this->isPointInGbObject3D(&point2)) return new GbLine3D(schnittpunkte[0],new GbPoint3D(point2)); - else //line beruehrt kugel! -> clippedLine reduziert sich zu einem Punkt! - { - if(std::fabs(this->getDistance(schnittpunkte[0])-this->radius)<1.E-13) - throw UbException(UB_EXARGS,"Beide LinenPunkte ausserhalb des Kreises, der berechnete Punkt ist jedoch KEIN Beruhrungspunkt der Sphere..."); - return new GbLine3D(schnittpunkte[0],new GbPoint3D(*(schnittpunkte[0]))); - } - } - else if(nofSchnittpunkte==2) return new GbLine3D(schnittpunkte[0],schnittpunkte[1]); - - return NULL; -} -/*=========================================================================*/ -vector<GbTriangle3D*> GbSphere3D::getSurfaceTriangleSet() -{ - if(triangulationMode==RAYPROJECTION) - { - double x1m = midPoint->getX1Coordinate(); - double x2m = midPoint->getX2Coordinate(); - double x3m = midPoint->getX3Coordinate(); - - vector<GbTriangle3D*> triangles; - - int segments =30; - double deltaPhi = UbMath::PI/(double)segments; - double phiX1a,phiX1b,phiX3a,phiX3b; - double x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d; - - for(phiX3a=0.5*UbMath::PI; phiX3a>-1.5*UbMath::PI; phiX3a-=deltaPhi) - { - for(phiX1a=0.0; phiX1a<UbMath::PI; phiX1a+=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - phiX3b = phiX3a+deltaPhi; - - x1a = x1m+radius*cos(phiX3a)*std::cos(phiX1a); - x2a = x2m+radius*cos(phiX3a)*std::sin(phiX1a); - x3a = x3m+radius*sin(phiX3a); - x1b = x1m+radius*cos(phiX3a)*std::cos(phiX1b); - x2b = x2m+radius*cos(phiX3a)*std::sin(phiX1b); - x3b = x3m+radius*sin(phiX3a); - x1c = x1m+radius*cos(phiX3b)*std::cos(phiX1b); - x2c = x2m+radius*cos(phiX3b)*std::sin(phiX1b); - x3c = x3m+radius*sin(phiX3b); - x1d = x1m+radius*cos(phiX3b)*std::cos(phiX1a); - x2d = x2m+radius*cos(phiX3b)*std::sin(phiX1a); - x3d = x3m+radius*sin(phiX3b); - - if(UbMath::greater(phiX3b,-0.5*UbMath::PI) && UbMath::less(phiX3a,0.5*UbMath::PI)) - { - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1a,x2a,x3a),new GbPoint3D(x1b,x2b,x3b),new GbPoint3D(x1c,x2c,x3c))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1a,x2a,x3a),new GbPoint3D(x1c,x2c,x3c),new GbPoint3D(x1d,x2d,x3d))); - } - else - { - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1d,x2d,x3d),new GbPoint3D(x1c,x2c,x3c),new GbPoint3D(x1a,x2a,x3a))); - triangles.push_back(new GbTriangle3D(new GbPoint3D(x1c,x2c,x3c),new GbPoint3D(x1b,x2b,x3b),new GbPoint3D(x1a,x2a,x3a))); - } - } - } - return triangles; - } - else if(triangulationMode==CUBOIDPROJECTION) - { - vector<GbTriangle3D*> triangles; - vector<GbPoint3D*> points; - double x1min = this->getX1Minimum(); - double x2min = this->getX2Minimum(); - double x3min = this->getX3Minimum(); - double x1max = this->getX1Maximum(); - double x2max = this->getX2Maximum(); - double x3max = this->getX3Maximum(); - double ax1 = x1min; double bx2 = x2min; double cx1 = x1min; - double ax2 = x2min; double bx3 = x3min; double cx3 = x3min; - - int anzahl = 20; - double dx1 = (x1max-x1min)/(double)(anzahl-1); - double dx2 = (x2max-x2min)/(double)(anzahl-1); - double dx3 = (x3max-x3min)/(double)(anzahl-1); - - for (int u=0; u<anzahl; u++) - { - ax2 = x2min; - bx2 = x2min; - cx3 = x3min; - for (int v=0; v<anzahl; v++) - { - GbPoint3D p1 = GbPoint3D(ax1, ax2, x3max); - GbPoint3D p2 = GbPoint3D(ax1, ax2, x3min); - GbPoint3D p3 = GbPoint3D(cx1, x2min, cx3); - GbPoint3D p4 = GbPoint3D(cx1, x2max, cx3); - GbPoint3D p5 = GbPoint3D(x1min, bx2, bx3); - GbPoint3D p6 = GbPoint3D(x1max, bx2, bx3); - - GbLine3D* clippedline1 = this->createClippedLine3D(*this->midPoint, p1); - GbLine3D* clippedline2 = this->createClippedLine3D(*this->midPoint, p2); - GbLine3D* clippedline3 = this->createClippedLine3D(*this->midPoint, p3); - GbLine3D* clippedline4 = this->createClippedLine3D(*this->midPoint, p4); - GbLine3D* clippedline5 = this->createClippedLine3D(*this->midPoint, p5); - GbLine3D* clippedline6 = this->createClippedLine3D(*this->midPoint, p6); - points.push_back(new GbPoint3D(clippedline1->getPoint1())); - points.push_back(new GbPoint3D(clippedline2->getPoint1())); - points.push_back(new GbPoint3D(clippedline3->getPoint1())); - points.push_back(new GbPoint3D(clippedline4->getPoint1())); - points.push_back(new GbPoint3D(clippedline5->getPoint1())); - points.push_back(new GbPoint3D(clippedline6->getPoint1())); - clippedline1->deletePoints(); delete clippedline1; - clippedline2->deletePoints(); delete clippedline2; - clippedline3->deletePoints(); delete clippedline3; - clippedline4->deletePoints(); delete clippedline4; - clippedline5->deletePoints(); delete clippedline5; - clippedline6->deletePoints(); delete clippedline6; - ax2 +=dx2; - cx3 +=dx3; - bx2 +=dx2; - } - ax1 +=dx1; - cx1 +=dx1; - bx3 +=dx3; - } - - int anz = anzahl*anzahl*6; - GbPoint3D* point1 = NULL; - GbPoint3D* point2 = NULL; - GbPoint3D* point3 = NULL; - int anzahl2 = anzahl*6; - int anzahl3 = anzahl2+6; - for (int u=0; u<anz-anzahl3; u++) - { - point1 = new GbPoint3D(points[u+6]); - point2 = new GbPoint3D(points[u]); - point3 = new GbPoint3D(points[u+anzahl2]); - if(u%2 == 0) triangles.push_back(new GbTriangle3D(point1, point2, point3)); - else triangles.push_back(new GbTriangle3D(point2, point1, point3)); - - point1 = new GbPoint3D(points[u+6]); - point2 = new GbPoint3D(points[u+anzahl2]); - point3 = new GbPoint3D(points[u+anzahl3]); - if(u%2 == 0) triangles.push_back(new GbTriangle3D(point1, point2, point3)); - else triangles.push_back(new GbTriangle3D(point2, point1, point3)); - } - for (int u=0; u<anz; u++) delete points[u]; - - return triangles; - } - else throw UbException(UB_EXARGS,"undefined triangulationmode"); -} -/*=======================================================*/ -void GbSphere3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& nodes, vector<UbTupleInt3>& triangles) -{ - //wenn ich viele Kugeln bei der PE rausschreibe sollten die vektoren nicht geresized werden - //nodes.resize(0); - //triangles.resize(0); - - if(triangulationMode==RAYPROJECTION) - { - float x1m = (float)midPoint->getX1Coordinate(); - float x2m = (float)midPoint->getX2Coordinate(); - float x3m = (float)midPoint->getX3Coordinate(); - - int segments =30; - float deltaPhi = (float)UbMath::PI/(float)segments; - float phiX1a,phiX1b,phiX3a,phiX3b; - float x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d; - int nodeNr = nodes.size(); - for(phiX3a=(float)(0.5*UbMath::PI); phiX3a > (float)(-1.5*UbMath::PI); phiX3a-=deltaPhi) - { - for(phiX1a=0.0; phiX1a<UbMath::PI; phiX1a+=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - phiX3b = phiX3a+deltaPhi; - - x1a = x1m+(float)(radius*cos(phiX3a)*std::cos(phiX1a)); - x2a = x2m+(float)(radius*cos(phiX3a)*std::sin(phiX1a)); - x3a = x3m+(float)(radius*sin(phiX3a)); - x1b = x1m+(float)(radius*cos(phiX3a)*std::cos(phiX1b)); - x2b = x2m+(float)(radius*cos(phiX3a)*std::sin(phiX1b)); - x3b = x3m+(float)(radius*sin(phiX3a)); - x1c = x1m+(float)(radius*cos(phiX3b)*std::cos(phiX1b)); - x2c = x2m+(float)(radius*cos(phiX3b)*std::sin(phiX1b)); - x3c = x3m+(float)(radius*sin(phiX3b)); - x1d = x1m+(float)(radius*cos(phiX3b)*std::cos(phiX1a)); - x2d = x2m+(float)(radius*cos(phiX3b)*std::sin(phiX1a)); - x3d = x3m+(float)(radius*sin(phiX3b)); - - if(UbMath::greater(phiX3b,-0.5*UbMath::PI) && UbMath::less(phiX3a,0.5*UbMath::PI)) - { - nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); - nodes.push_back( makeUbTuple(x1b,x2b,x3b) ); - nodes.push_back( makeUbTuple(x1c,x2c,x3c) ); - - nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); - nodes.push_back( makeUbTuple(x1c,x2c,x3c) ); - nodes.push_back( makeUbTuple(x1d,x2d,x3d) ); - } - else - { - nodes.push_back( makeUbTuple(x1d,x2d,x3d) ); - nodes.push_back( makeUbTuple(x1c,x2c,x3c) ); - nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); - - nodes.push_back( makeUbTuple(x1c,x2c,x3c) ); - nodes.push_back( makeUbTuple(x1b,x2b,x3b) ); - nodes.push_back( makeUbTuple(x1a,x2a,x3a) ); - } - triangles.push_back( makeUbTuple(nodeNr, nodeNr+1, nodeNr+2) ); - triangles.push_back( makeUbTuple(nodeNr+3, nodeNr+4, nodeNr+5) ); - nodeNr+=6; - } - } - } - else if(triangulationMode==CUBOIDPROJECTION) - { - vector<GbPoint3D*> points; - double x1min = this->getX1Minimum(); - double x2min = this->getX2Minimum(); - double x3min = this->getX3Minimum(); - double x1max = this->getX1Maximum(); - double x2max = this->getX2Maximum(); - double x3max = this->getX3Maximum(); - double ax1 = x1min; double bx2 = x2min; double cx1 = x1min; - double ax2 = x2min; double bx3 = x3min; double cx3 = x3min; - - int anzahl = 20; - double dx1 = (x1max-x1min)/(double)(anzahl-1); - double dx2 = (x2max-x2min)/(double)(anzahl-1); - double dx3 = (x3max-x3min)/(double)(anzahl-1); - - for (int u=0; u<anzahl; u++) - { - ax2 = x2min; - bx2 = x2min; - cx3 = x3min; - for (int v=0; v<anzahl; v++) - { - GbPoint3D p1 = GbPoint3D(ax1, ax2, x3max); - GbPoint3D p2 = GbPoint3D(ax1, ax2, x3min); - GbPoint3D p3 = GbPoint3D(cx1, x2min, cx3); - GbPoint3D p4 = GbPoint3D(cx1, x2max, cx3); - GbPoint3D p5 = GbPoint3D(x1min, bx2, bx3); - GbPoint3D p6 = GbPoint3D(x1max, bx2, bx3); - - GbLine3D* clippedline1 = this->createClippedLine3D(*this->midPoint, p1); - GbLine3D* clippedline2 = this->createClippedLine3D(*this->midPoint, p2); - GbLine3D* clippedline3 = this->createClippedLine3D(*this->midPoint, p3); - GbLine3D* clippedline4 = this->createClippedLine3D(*this->midPoint, p4); - GbLine3D* clippedline5 = this->createClippedLine3D(*this->midPoint, p5); - GbLine3D* clippedline6 = this->createClippedLine3D(*this->midPoint, p6); - points.push_back(new GbPoint3D(clippedline1->getPoint1())); - points.push_back(new GbPoint3D(clippedline2->getPoint1())); - points.push_back(new GbPoint3D(clippedline3->getPoint1())); - points.push_back(new GbPoint3D(clippedline4->getPoint1())); - points.push_back(new GbPoint3D(clippedline5->getPoint1())); - points.push_back(new GbPoint3D(clippedline6->getPoint1())); - clippedline1->deletePoints(); delete clippedline1; - clippedline2->deletePoints(); delete clippedline2; - clippedline3->deletePoints(); delete clippedline3; - clippedline4->deletePoints(); delete clippedline4; - clippedline5->deletePoints(); delete clippedline5; - clippedline6->deletePoints(); delete clippedline6; - ax2 +=dx2; - cx3 +=dx3; - bx2 +=dx2; - } - ax1 +=dx1; - cx1 +=dx1; - bx3 +=dx3; - } - - int anz = anzahl*anzahl*6; - int anzahl2 = anzahl*6; - int anzahl3 = anzahl2+6; - int nodeNr = 0; - for (int u=0; u<anz-anzahl3; u++) - { - nodes.push_back( makeUbTuple((float)points[u+6]->x1 , (float)points[u+6]->x2 , (float)points[u+6]->x3) ); - nodes.push_back( makeUbTuple((float)points[u]->x1 , (float)points[u]->x2 , (float)points[u]->x3) ); - nodes.push_back( makeUbTuple((float)points[u+anzahl2]->x1, (float)points[u+anzahl2]->x2, (float)points[u+anzahl2]->x3) ); - - if(u%2 == 0) triangles.push_back( makeUbTuple(nodeNr , nodeNr+1, nodeNr+2) ); - else triangles.push_back( makeUbTuple(nodeNr , nodeNr+1, nodeNr+2) ); - - nodes.push_back( makeUbTuple((float)points[u+6]->x1 , (float)points[u+6]->x2 , (float)points[u+6]->x3) ); - nodes.push_back( makeUbTuple((float)points[u+anzahl2]->x1, (float)points[u+anzahl2]->x2, (float)points[u+anzahl2]->x3) ); - nodes.push_back( makeUbTuple((float)points[u+anzahl3]->x1, (float)points[u+anzahl3]->x2, (float)points[u+anzahl3]->x3) ); - if(u%2 == 0) triangles.push_back( makeUbTuple(nodeNr+3, nodeNr+4, nodeNr+5) ); - else triangles.push_back( makeUbTuple(nodeNr+3, nodeNr+4, nodeNr+5) ); - - nodeNr+=6; - } - for(int u=0; u<anz; u++) delete points[u]; - } - else throw UbException(UB_EXARGS,"undefined triangulationmode"); -} -/*=======================================================*/ -void GbSphere3D::transform(const double matrix[4][4]) -{ - midPoint->transform(matrix); - this->setRadius(this->getRadius()*matrix[0][0]); - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void GbSphere3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - midPoint->write(out); - out->writeDouble(radius); - out->writeInteger((int)triangulationMode); -} -/*=======================================================*/ -void GbSphere3D::read(UbFileInput* in) -{ - if(midPoint) - { - midPoint->removeObserver(this); - midPoint->finalize(); - delete midPoint; - } - midPoint = new GbPoint3D; - in->readString(); - midPoint->read(in); - midPoint->addObserver(this); - radius = in->readDouble(); - triangulationMode = (TRIANGULATIONMODE)in->readInteger(); -} -/*=======================================================*/ -bool GbSphere3D::hasIntersectionWithDirectedLine(GbPoint3D origin, GbPoint3D direction) -{ - GbVector3D vecOrigin(origin.getX1Coordinate(),origin.getX2Coordinate(), origin.getX3Coordinate()) ; - GbVector3D vecDirection(direction.getX1Coordinate(),direction.getX2Coordinate(), direction.getX3Coordinate()); - GbVector3D vecSfereCenter(getX1Centroid(), getX2Centroid(), getX3Centroid()); - GbVector3D diff = vecOrigin - vecSfereCenter; - float a = (float)(vecDirection.Dot(vecDirection)); - float b = (float)(2.0 * vecDirection.Dot(diff)); - float c = (float)(diff.Dot(diff) - this->getRadius()*this->getRadius()); - - // use 'abc'-formula for finding root t_1,2 = (-b +/- sqrt(b^2-4ac))/(2a) - float inRoot = (float)(b*b - 4.0*a*c); - if (inRoot < 0) return false; - float root = sqrt(inRoot); - - float dist = (float)((-b - root)/(2.0*a)); - - double infinity = DBL_MAX; - double eps = 1E-4; - - if (dist > infinity) - return false; - - if (dist < eps) - { - dist = (float)((-b + root)/(2.0*a)); - if (dist < eps || dist > infinity) - return false; - } - return true; -} -/*=======================================================*/ -bool GbSphere3D::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 SphereUmrandung -//returns true: -// - cell cuts sphere3D -// - cell boxes sphere3D -//returns false: -// - cell completely inside sphere3D ( = sphere3D boxes cell) -// - cell und sphere3D haben kein gemeinsames Volumen -{ - double midX[] = { this->getX1Centroid() - , this->getX2Centroid() - , this->getX3Centroid() }; - - double Bmin[] = { UbMath::min(x1a, x1b) - , UbMath::min(x2a, x2b) - , UbMath::min(x3a, x3b) }; - - double Bmax[] = { UbMath::max(x1a, x1b) - , UbMath::max(x2a, x2b) - , UbMath::max(x3a, x3b) }; - - /* Solid Box - Hollow Sphere */ - double dmin = 0.0; - double dmax = 0.0; - double r2 = radius*radius; - - for( int i=0; i<3; i++ ) - { - double a = pow( midX[i] - Bmin[i], 2.0 ); - double b = pow( midX[i] - Bmax[i], 2.0 ); - dmax += UbMath::max( a, b ); - if ( UbMath::less ( midX[i], Bmin[i] ) ) dmin += a; - else if( UbMath::greater( midX[i], Bmax[i] ) ) dmin += b; - } - if( UbMath::lessEqual(dmin, r2 ) - && UbMath::lessEqual(r2 , dmax ) ) - { - return true; - } - return false; -} -/*=======================================================*/ -bool GbSphere3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -//returns true: -// - cell completely inside sphere3D ( = sphere3D boxes cell) -// - cell cuts sphere3D -// - cell boxes sphere3D -//returns false: -// - cell und sphere3D haben kein gemeinsames Volumen -{ - //URL: http://tog.acm.org/GraphicsGems/gems/BoxSphere.c (mode=4, beides solids!!!) - // solid - solid - //this routine tests for intersection between an 3-dimensional - //axis-aligned box and an 3-dimensional sphere. - - //true: - // - wenn Schnitt - // - Cell komplett innerhalb GbSphere3D - // - Cell umhuellt GbSphere3D - - - double midX1 = this->getX1Centroid(); - double midX2 = this->getX2Centroid(); - double midX3 = this->getX3Centroid(); - - double dmin = 0.0; - - if ( UbMath::less ( midX1, x1a ) ) dmin += std::pow( midX1 - x1a, 2.0 ); - else if( UbMath::greater( midX1, x1b ) ) dmin += std::pow( midX1 - x1b, 2.0 ); - - if ( UbMath::less ( midX2, x2a ) ) dmin += std::pow( midX2 - x2a, 2.0 ); - else if( UbMath::greater( midX2, x2b ) ) dmin += std::pow( midX2 - x2b, 2.0 ); - - if ( UbMath::less ( midX3, x3a ) ) dmin += std::pow( midX3 - x3a, 2.0 ); - else if( UbMath::greater( midX3, x3b ) ) dmin += std::pow( midX3 - x3b, 2.0 ); - - if( UbMath::lessEqual( dmin, radius*radius ) ) - { - return true; - } - - return false; -} -/*==========================================================*/ -double GbSphere3D::getCellVolumeInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - double deltaX1 = (x1b-x1a); - double deltaX2 = (x2b-x2a); - double deltaX3 = (x3b-x3a); - - if( this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) ) return 1.0*deltaX1*deltaX2*deltaX3; - if( !(this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)) ) return 0.0; - - double tempResult = 0.0; - - int iMax = 10; - int jMax = 10; - int kMax = 10; - - for( int i=0; i<iMax; i++){ - for( int j=0; j<jMax; j++){ - for( int k=0; k<kMax; k++){ - - tempResult += getCellVolumeInsideGbObject3DHelperFunction( - x1a+((double) i )*deltaX1/((double)iMax), x2a+((double) j )*deltaX2/((double)jMax), x3a+((double) k )*deltaX3/((double)kMax), - x1a+((double)(i+1))*deltaX1/((double)iMax), x2a+((double)(j+1))*deltaX2/((double)jMax), x3a+((double)(k+1))*deltaX3/((double)kMax) ); - } - } - } - - - double resultWithOneCell = getCellVolumeInsideGbObject3DHelperFunction( x1a, x2a, x3a, x1b, x2b, x3b ); - - //cout << tempResult << " vs. " << resultWithOneCell << endl; - - return tempResult; - -} -/*==========================================================*/ -double GbSphere3D::getCellVolumeInsideGbObject3DHelperFunction(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - - double deltaX1 = x1b-x1a; - double deltaX2 = x2b-x2a; - double deltaX3 = x3b-x3a; - - if( this->isCellInsideGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b) ) return 1.0*deltaX1*deltaX2*deltaX3; - if( !(this->isCellCuttingGbObject3D(x1a,x2a,x3a,x1b,x2b,x3b)) ) return 0.0; - - double alpha=0.0; - double internX1,internX2,internX3; - - for(int x1vers=0;x1vers<2;x1vers++){ - for(int x2vers=0;x2vers<2;x2vers++){ - for(int x3vers=0;x3vers<2;x3vers++){ - internX1 = x1a + (x1b-x1a)*x1vers; - internX2 = x2a + (x2b-x2a)*x2vers; - internX3 = x3a + (x3b-x3a)*x3vers; - - if( UbMath::lessEqual(this->getDistance(internX1,internX2,internX3),alpha) ) - alpha = this->getDistance(internX1,internX2,internX3); - //cout<<zelltyp<<" "<<kugel->getDistance(internX1,internX2,internX3)<<" "<<alpha<<endl; - }//end first for - }//end second for - }//end third for - - alpha = (-1)*alpha; - - - - double n[3]; - n[0] = 0.5*(x1b+x1a) - this->getX1Centroid(); - n[1] = 0.5*(x2b+x2a) - this->getX2Centroid(); - n[2] = 0.5*(x3b+x3a) - this->getX3Centroid(); - - //cout << "Koordinaten: "<<x1<<" "<<x2<<" "<<x3<<endl; - //cout << "Deltas: "<<deltaX1<<" "<<deltaX2<<" "<<deltaX3<<endl; - //cout << "Halbe Zelle: "<<halfcelldelta<<endl; - - //cout<<"Centroid: "<<kugel->getX1Centroid()<<" "<<kugel->getX2Centroid()<<" "<<kugel->getX3Centroid()<<endl; - - //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl; - - double normLength; - normLength = sqrt(n[0]*n[0] + n[1]*n[1] + n[2]*n[2]); - n[0] /= normLength; - n[1] /= normLength; - n[2] /= normLength; - - if( UbMath::less(n[0],0.0) ) n[0] = -n[0]; - if( UbMath::less(n[1],0.0) ) n[1] = -n[1]; - if( UbMath::less(n[2],0.0) ) n[2] = -n[2]; - - //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl; - - double dummy; - if( UbMath::greater(n[0],n[1])) {dummy=n[1]; n[1]=n[0]; n[0]=dummy;} - if( UbMath::greater(n[1],n[2])) {dummy=n[2]; n[2]=n[1]; n[1]=dummy;} - if( UbMath::greater(n[0],n[1])) {dummy=n[1]; n[1]=n[0]; n[0]=dummy;} - - //cout<<"Normals: "<<n[0]<<" "<<n[1]<<" "<<n[2]<<endl; - - double n1,n2,n3; - n1=n[0]; - n2=n[1]; - n3=n[2]; - - double maxVol = deltaX1*deltaX2*deltaX3; - - double result = 0.0, preresult = 0.0; - - if( UbMath::lessEqual( maxVol, 0.000001 ) ) - return 0.0; - - // 1D Check - if ( UbMath::lessEqual(n1,0.001)&&UbMath::lessEqual(n2,0.001) ) - { - result = alpha*deltaX1*deltaX2; - } - // 2D Check - else if ( UbMath::lessEqual(n1,0.001) ) - { - preresult = (2*n2*n3); - result = (alpha*alpha)/preresult; - - if( UbMath::greater(alpha,n2*deltaX2) ) - { - result += -(alpha-n2*deltaX2)*(alpha-n2*deltaX2)/preresult; - } - if( UbMath::greater(alpha,n3*deltaX3) ) - { - result += -(alpha-n3*deltaX3)*(alpha-n3*deltaX3)/preresult; - } - if( UbMath::greater(alpha,n2*deltaX2+n3*deltaX3) ) - { - result += (alpha-n2*deltaX2-n3*deltaX3)*(alpha-n2*deltaX2-n3*deltaX3)/preresult; - } - - // tiefenrichtung mit einmultiplizieren... - result *= deltaX1; - } - // 3D Check - else - { - preresult =6*n1*n2*n3; - - result = alpha*alpha*alpha; - - if ( UbMath::greaterEqual(alpha,n1*deltaX1)) - { - result+=-((alpha-n1*deltaX1)*(alpha-n1*deltaX1)*(alpha-n1*deltaX1)); - } - if (UbMath::greaterEqual(alpha,n2*deltaX2)) - { - result+=-((alpha-n2*deltaX2)*(alpha-n2*deltaX2)*(alpha-n2*deltaX2)); - } - if (UbMath::greaterEqual(alpha,n3*deltaX3)) - { - result+=-((alpha-n3*deltaX3)*(alpha-n3*deltaX3)*(alpha-n3*deltaX3)); - } - if (UbMath::greaterEqual(alpha,(n1*deltaX1+n2*deltaX2))) - { - result+=((alpha-(n1*deltaX1+n2*deltaX2))*(alpha-(n1*deltaX1+n2*deltaX2))*(alpha-(n1*deltaX1+n2*deltaX2))); - } - if (UbMath::greaterEqual(alpha,(n1*deltaX1+n3*deltaX3))) - { - result+=((alpha-(n1*deltaX1+n3*deltaX3))*(alpha-(n1*deltaX1+n3*deltaX3))*(alpha-(n1*deltaX1+n3*deltaX3))); - } - if (UbMath::greaterEqual(alpha,(n2*deltaX2+n3*deltaX3))) - { - result+=((alpha-(n2*deltaX2+n3*deltaX3))*(alpha-(n2*deltaX2+n3*deltaX3))*(alpha-(n2*deltaX2+n3*deltaX3))); - } - - //NEW - if (UbMath::greaterEqual(alpha,(n1*deltaX1+n2*deltaX2+n3*deltaX3))) - { - result+= -((alpha-(n1*deltaX1+n2*deltaX2+n3*deltaX3))*(alpha-(n1*deltaX1+n2*deltaX2+n3*deltaX3))*(alpha-(n1*deltaX1+n2*deltaX2+n3*deltaX3))); - } - - result = result / preresult; - - } - return(result) ; - - //cout << "alpha ist " << alpha << endl; - //cout << "fillLevel ist " << eps << endl; -} -/*==========================================================*/ -double GbSphere3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) -{ - double lx1 = midPoint->x1 - x1; - double lx2 = midPoint->x2 - x2; - double lx3 = midPoint->x3 - x3; - double l_sq = lx1*lx1 + lx2*lx2 + lx3*lx3; //l = abstand Punkt(x1,x2,x3)<->kreismittelpunkt - - double s = lx1*rx1 + lx2*rx2 + lx3*rx3; //s= l*ray_dir) - double r_sq = this->radius * this->radius; // r² =r*r - //if (d<0 (fuer die Richtung falls sie gegen das Kreis dann haben wir ein negativer Zahl) - // && l² > r² (point outside )) - //wenn s<0->Punkt liegt rechts vom mittelpunkt, wenn nun punkt ausserhalb des kreises liegt, kann es keinen SP mehr geben - if( s<-1.E-10 && l_sq>r_sq+1.E-10 ) - return -1.0; - //Pythagor on Triangle Rectangle (point, center of the cercle, intersection of the direction on point and m) - // l² = m² + d² - double m_sq = l_sq - s*s; - // if (m² > r² (dann gibt es kein schnittpunt zwischen direction und circle)) - if( m_sq > r_sq+1.E-10 ) return -1.0; - // Pythagoras on Triangle Rectangle in cercle (direction , m, r) - // r² = m² + h² - - //patch: rundungsfehler bei kleinen delta!!! - //-> wenn wurzel minimal null-> - double wurzelTerm = r_sq - m_sq; - if(wurzelTerm<0.0) - { - if(wurzelTerm<-1E-10) return -1.0; //definitiv kein SP - else return s; //im rundungsfehler-bereich. SP liegt dierkt auf sphere umrandung - } - - //if point outside of the circle - if(l_sq>r_sq) return s-sqrt(wurzelTerm); - - return s+sqrt(wurzelTerm); -} -/*=======================================================*/ diff --git a/src/basics/geometry3d/GbSphere3D.h b/src/basics/geometry3d/GbSphere3D.h deleted file mode 100644 index c8e4eee5f..000000000 --- a/src/basics/geometry3d/GbSphere3D.h +++ /dev/null @@ -1,164 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBSPHERE3D_H -#define GBSPHERE3D_H - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF -#ifdef CAB_CTL - #include <ctl.h> -#endif //CAB_CTL - -#include <vector> -#include <cmath> - -#include <basics/utilities/UbObserver.h> - -#include <numerics/geometry3d/GbObject3D.h> -#include <numerics/geometry3d/GbPoint3D.h> - -#include <PointerDefinitions.h> - -class GbLine3D; -class GbTriangle3D; -class GbObject3DCreator; - -class GbSphere3D : public GbObject3D, public UbObserver -{ -public: - enum TRIANGULATIONMODE { CUBOIDPROJECTION ,RAYPROJECTION }; - - ////////////////////////////////////////////////////////////////////////// - // Konstruktoren - GbSphere3D(); - GbSphere3D(const double& x1,const double& x2, const double& x3, const double& radius); - GbSphere3D(const GbSphere3D& sphere); - GbSphere3D(GbSphere3D* sphere); //<-unschoen! - - ~GbSphere3D(); - - GbSphere3D* clone() { return new GbSphere3D(*this);} - void finalize(); - - - bool intersects(SPtr<GbSphere3D> sphere); - - double getRadius() const { return this->radius; } - - double getX1Centroid() { return midPoint->getX1Coordinate();} - double getX1Minimum() { return midPoint->getX1Coordinate()-radius;} - double getX1Maximum() { return midPoint->getX1Coordinate()+radius;} - double getX2Centroid() { return midPoint->getX2Coordinate();} - double getX2Minimum() { return midPoint->getX2Coordinate()-radius;} - double getX2Maximum() { return midPoint->getX2Coordinate()+radius;} - double getX3Centroid() { return midPoint->getX3Coordinate();} - double getX3Minimum() { return midPoint->getX3Coordinate()-radius;} - double getX3Maximum() { return midPoint->getX3Coordinate()+radius;} - - void setCenterX1Coordinate(const double& value); - void setCenterX2Coordinate(const double& value); - void setCenterX3Coordinate(const double& value); - void setCenterCoordinates(const double& x1, const double& x2, const double& x3); - virtual void setCenterCoordinates(const UbTupleDouble3& position); - void setRadius(const double& radius); - - GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2); - double getDistance(GbPoint3D* p); - double getDistance(const double& x1p, const double& x2p, const double& x3p); - - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3); - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); - - 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); - double getCellVolumeInsideGbObject3DHelperFunction(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b); - - std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles); - - bool hasRaytracing() { return true; } - /*|r| must be 1! einheitsvector!!*/ - double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3); - - bool hasIntersectionWithDirectedLine(GbPoint3D origin, GbPoint3D direction); - - std::string toString(); - - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - - void translate(const double& x1, const double& x2, const double& x3) - { - this->midPoint->translate(x1, x2, x3); - this->notifyObserversObjectChanged(); - } - void rotate(const double& rx1, const double& rx2, const double& rx3) {/* rotation makes no sense*/ } - void scale(const double& sx1, const double& sx2, const double& sx3) - { - this->radius *= sx1; - this->notifyObserversObjectChanged(); - } - - void transform(const double matrix[4][4]); - - TRIANGULATIONMODE getTriangulationMode() {return triangulationMode;} - void setTriangulationMode(TRIANGULATIONMODE mode) { this->triangulationMode = mode; } - - //virtuelle Methoden von UbObserver - void objectChanged(UbObservable* changedObject) - { - this->notifyObserversObjectChanged(); - //std::cout<<"GbSphere:objectChanged() - toDo-);"; - } - void objectWillBeDeleted(UbObservable* objectForDeletion) - { - throw UbException(UB_EXARGS,"not implemented"); - } - - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere, weil man eine - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & midPoint; - ar & radius; - ar & triangulationMode; - } -#endif //CAB_RCF -#ifdef CAB_CTL - ctl::oStream &write(ctl::oStream &os) const - { - midPoint->write(os); - return os<<radius; - } - ctl::iStream &read(ctl::iStream &is) - { - midPoint->read(is); - return is>>radius; - } -#endif //CAB_CTL - -private: - GbPoint3D* midPoint; - double radius; // Radius des Kreises - TRIANGULATIONMODE triangulationMode; -}; - -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - #if CAB_RCF <= 903 - SF_SERIALIZE_ENUM(GbSphere3D::TRIANGULATIONMODE) //bei klassen ausserhalb der klasse;-) - #endif - UB_AUTO_RUN_NAMED( SF::registerType<GbSphere3D>("GbSphere3D") , SF_GbSphere3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbSphere3D >()), SF_GbSphere3D_BD1 ); -#endif //RCF_USE_SF_SERIALIZATION - -#endif //GBSPHERE3D_H diff --git a/src/basics/geometry3d/GbSystem3D.cpp b/src/basics/geometry3d/GbSystem3D.cpp index 7a224f8bf..3afca818f 100644 --- a/src/basics/geometry3d/GbSystem3D.cpp +++ b/src/basics/geometry3d/GbSystem3D.cpp @@ -1,7 +1,38 @@ -#include <numerics/geometry3d/GbSystem3D.h> - -#include <numerics/geometry3d/GbPolygon3D.h> -#include <numerics/geometry3d/GbCuboid3D.h> +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbSystem3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= +#include <GbSystem3D.h> +#include <GbPolygon3D.h> +#include <GbCuboid3D.h> using namespace std; @@ -1012,7 +1043,7 @@ void GbSystem3D::PointSet3::insert(const GbPoint3D& point, int index) /*=======================================================*/ void GbSystem3D::PointSet3::clear() { - //clears points (size==0 but capacity is the old one) + //clears points (size==0 but capacity is the old c1) this->points.clear(); this->consistent = false; } @@ -1084,7 +1115,7 @@ int GbSystem3D::PointSet3::containsEqual(const GbPoint3D& point) /*=======================================================*/ bool GbSystem3D::PointSet3::containsLine(GbPoint3D *point1, GbPoint3D *point2) { - //returns true if pointset has two in "this->points"vector neighboured points + //returns true if pointset has c2 in "this->points"vector neighboured points //wich have the same adress as point1 or point2 vector<GbPoint3D>::iterator pos1=this->points.begin(); vector<GbPoint3D>::iterator pos2; @@ -1102,7 +1133,7 @@ bool GbSystem3D::PointSet3::containsLine(GbPoint3D *point1, GbPoint3D *point2) /*=======================================================*/ bool GbSystem3D::PointSet3::containsEqualLine(const GbPoint3D& point1, const GbPoint3D& point2) { - //returns true if pointset has two in "this->points"vector neighboured points + //returns true if pointset has c2 in "this->points"vector neighboured points //wich have the same coordinates as point1 or point2 vector<GbPoint3D>::iterator pos1=this->points.begin(); vector<GbPoint3D>::iterator pos2; diff --git a/src/basics/geometry3d/GbSystem3D.h b/src/basics/geometry3d/GbSystem3D.h index d0e842a52..57955d6b9 100644 --- a/src/basics/geometry3d/GbSystem3D.h +++ b/src/basics/geometry3d/GbSystem3D.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbSystem3D.h +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef GBSYSTEM3D_H #define GBSYSTEM3D_H @@ -11,9 +37,9 @@ #include <cmath> #include <vector> +#include <GbPoint3D.h> +#include <GbObject3D.h> #include <basics/utilities/UbMath.h> -#include <numerics/geometry3d/GbPoint3D.h> -#include <numerics/geometry3d/GbObject3D.h> #include <basics/writer/WbWriter.h> class GbPolygon3D; diff --git a/src/basics/geometry3d/GbTriFaceMesh3D.cpp b/src/basics/geometry3d/GbTriFaceMesh3D.cpp deleted file mode 100644 index 4715c64c8..000000000 --- a/src/basics/geometry3d/GbTriFaceMesh3D.cpp +++ /dev/null @@ -1,1257 +0,0 @@ - -#include <numerics/geometry3d/GbTriFaceMesh3D.h> - -#include <numerics/geometry3d/GbCuboid3D.h> -#include <numerics/geometry3d/GbHalfSpace3D.h> -#include <numerics/geometry3d/CoordinateTransformation3D.h> -#include <numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h> -#include <basics/utilities/UbRandom.h> -#include <basics/utilities/UbTiming.h> -#include <basics/utilities/UbLogger.h> -#include <basics/writer/WbWriter.h> - -#include <numerics/geometry3d/KdTree/KdTree.h> -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h> -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h> - -#define MAX_ITER 10 - -using namespace std; - -GbTriFaceMesh3D::GbTriFaceMesh3D() - : GbObject3D() - , buildVertTriRelationMap(false) - , kdTree(NULL) - , transX1(0.0) - , transX2(0.0) - , transX3(0.0) - , transferViaFilename(false) - -{ - this->setName("CAB_GbTriFaceMesh3D"); - this->nodes = new vector<Vertex>; - this->triangles = new vector<TriFace>; - this->consistent = false; - this->kdtreeSplitAlg = KDTREE_SAHPLIT; -} -/*=======================================================================*/ -GbTriFaceMesh3D::GbTriFaceMesh3D(string name, vector<Vertex>* nodes, vector<TriFace>* triangles, KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) - : GbObject3D() - , nodes(nodes) - , triangles(triangles) - , buildVertTriRelationMap(false) - , consistent(false) - , kdTree(NULL) - , kdtreeSplitAlg(splitAlg) - , transX1(0.0) - , transX2(0.0) - , transX3(0.0) - , transferViaFilename(false) -{ - if( name.empty() ) throw UbException(UB_EXARGS,"no name specified"); - if( !nodes ) throw UbException(UB_EXARGS,"no nodes specified"); - if( !triangles ) throw UbException(UB_EXARGS,"no triangles specified"); - - this->setName(name); - - if(removeRedundantNodes) - { - this->deleteRedundantNodes(); //dort wird autoamtisch calculateValues() aufgerufen - } - else - { - this->calculateValues(); - } -} -/*=======================================================================*/ -GbTriFaceMesh3D::~GbTriFaceMesh3D() -{ - if( nodes ) { delete nodes; nodes = NULL; } - if( triangles ) { delete triangles; triangles = NULL; } - if( kdTree ) { delete kdTree; kdTree = NULL; } -} -/*======================================================================*/ -ObObjectCreator* GbTriFaceMesh3D::getCreator() -{ - return GbTriFaceMesh3DCreator::getInstance(); -} -/*======================================================================*/ -void GbTriFaceMesh3D::init() -{ - nodes = NULL; - triangles = NULL; - x1min = 0.0; - x1max = 0.0; - x1center = 0.0; - x2min = 0.0; - x2max = 0.0; - x2center = 0.0; - x3min = 0.0; - x3max = 0.0; - x3center = 0.0; - consistent = false; -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3D::clone() -{ - vector<GbTriFaceMesh3D::Vertex> *newNodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *newTriangles = new vector<GbTriFaceMesh3D::TriFace>; - - int numberNodes = (int)this->nodes->size(); - - double x,y,z; - for(int u=0;u<numberNodes;u++) - { - x=(*nodes)[u].x; - y=(*nodes)[u].y; - z=(*nodes)[u].z; - newNodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - } - int numberTris = (int)this->triangles->size(); - UBLOG(logDEBUG1,"numberTris:"<<numberTris); - - int id1,id2,id3; - for(int u=0;u<numberTris;u++) - { - id1 = (*this->triangles)[u].v1; - id2 = (*this->triangles)[u].v2; - id3 = (*this->triangles)[u].v3; - newTriangles->push_back(GbTriFaceMesh3D::TriFace(id1,id2,id3)); - //cout<<u<<" - id1,id2,id3:"<<id1<<","<<id2<<","<<id3<<endl; - } - UBLOG(logDEBUG1,"Tris gelesen"); - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D("no name", newNodes, newTriangles); - UBLOG(logDEBUG1,"mesh cloned ..."); - - return mesh; -} - -/*======================================================================*/ -//checks for doppelt nodes und fixed Dreicke die zweimal denselben Knoten haben -void GbTriFaceMesh3D::deleteRedundantNodes() -{ - UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Nodes before deleting redundant: "<<this->nodes->size()); - - map<Vertex,size_t/*new vecIndex*/> vertexMap; - map<Vertex,size_t/*new vecIndex*/>::iterator pos; - map<Vertex,size_t/*new vecIndex*/>::iterator it; - - vector<TriFace>& tris = *this->triangles; - vector<Vertex>& oldNodes = *this->nodes; - vector<Vertex> newNodes; - - for(size_t t=0; t<tris.size(); t++) - { - if(t%100==0) UBLOG(logDEBUG5,"GbTriFaceMesh3D::deleteRedundantNodes - tri: "<<(t)<<" von "<<tris.size()); - TriFace& tri = tris[t]; - //Knoten bereits in neuem node vector? - for(int v=0; v<=2; v++) - { - Vertex& vert = tri.getNode(v,oldNodes); - //pos=vertexMap.find( vert ); - //if( pos==vertexMap.end() ) - { - for(pos=vertexMap.begin();pos!=vertexMap.end();pos++) - { - Vertex rhs = pos->first; - //if(UbMath::inClosedInterval(vert.z,0.01999, 0.02001)) - if ( fabs(vert.x-rhs.x)<1.E-5 && fabs(vert.y-rhs.y)<1.E-5 && fabs(vert.z-rhs.z)<1.E-5 ) - { - break; - } - } - } - if( pos!=vertexMap.end() ) tri.setNode(v, (int)pos->second); - else - { - newNodes.push_back(vert); - int index = (int)newNodes.size()-1; - vertexMap[vert] = index; - tri.setNode(v,index); - } - } - } - - std::swap(*nodes,newNodes); - - UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Nodes after deleting redundant:"<<this->nodes->size()); - // - //Das geht irgendwie nicht ... - // - //UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - checking for double triangles !!!"); - //UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Triangles before deleting redundant: "<<this->triangles->size()); - //vector<TriFace> newSingleTris; - //newSingleTris.reserve( this->triangles->size() ); - //for(size_t t=0; t<tris.size(); t++) - //{ - // Vertex& v1 = tris[t].getNode(0,*nodes); - // Vertex& v2 = tris[t].getNode(1,*nodes); - // Vertex& v3 = tris[t].getNode(2,*nodes); - - // if(UbMath::greater(std::fabs(v1.x), 0.0634) && UbMath::inClosedInterval(v1.z, 0.01999, 0.02001)) - // { - // UBLOG2(logINFO,std::cout, "V1:"<<v1.x<<" "<<v1.y<<" "<<v1.z); - // } - // if(UbMath::greater(std::fabs(v2.x), 0.0634) && UbMath::inClosedInterval(v2.z, 0.01999, 0.02001)) - // { - // UBLOG2(logINFO,std::cout, "V2:"<<v2.x<<" "<<v2.y<<" "<<v2.z); - // } - // if(UbMath::greater(std::fabs(v3.x), 0.0634) && UbMath::inClosedInterval(v3.z, 0.01999, 0.02001)) - // { - // UBLOG2(logINFO,std::cout, "V3:"<<v3.x<<" "<<v3.y<<" "<<v3.z); - // } - - // bool inList = false; - // for(size_t u=0; u<newSingleTris.size(); u++) - // { - // Vertex& vn1 = newSingleTris[t].getNode(0,*nodes); - // Vertex& vn2 = newSingleTris[t].getNode(1,*nodes); - // Vertex& vn3 = newSingleTris[t].getNode(2,*nodes); - - // if(v1==vn1 && v2==vn2 && v3==vn3) inList = true; - // else if(v1==vn1 && v2==vn3 && v3==vn2) inList = true; - // else if(v1==vn2 && v2==vn3 && v3==vn1) inList = true; - // else if(v1==vn2 && v2==vn1 && v3==vn3) inList = true; - // else if(v1==vn3 && v2==vn1 && v3==vn2) inList = true; - // else if(v1==vn3 && v2==vn2 && v3==vn1) inList = true; - // } - // if(!inList) newSingleTris.push_back(tris[t]); - // else - // UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - inList !!!!"); - - //} - //swap(tris,newSingleTris); - - //UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - Triangles after deleting redundant:"<<this->triangles->size()); - UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - checking for triangles that have same node several times or are lines!!!"); - int counter1 = 0; - int counter2 = 0; - vector<TriFace> newTris; - newTris.reserve( this->triangles->size() ); - for(size_t t=0; t<tris.size(); t++) - { - Vertex& v1 = tris[t].getNode(0,*nodes); - Vertex& v2 = tris[t].getNode(1,*nodes); - Vertex& v3 = tris[t].getNode(2,*nodes); - if( v1==v2 || v1==v3 || v2==v3 ) - { - counter1++; - } - else if( tris[t].getArea(*nodes)<1.0E-8 ) - { - counter2++; - } - else newTris.push_back(tris[t]); - } - if(counter1) - { - UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - ### Warning ###: found and removed "<<counter1<<" triangle with double nodes!"); - } - if(counter2) - { - UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - ### Warning ###: found and removed "<<counter2<<" triangle that are lines!") ; - } - if(!counter1 && !counter2) { UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - alles gut... nix doppelt"); } - else swap(tris,newTris); - - UBLOG(logDEBUG1,"GbTriFaceMesh3D::deleteRedundantNodes - done" ); - this->calculateValues(); -} -/*======================================================================*/ -void GbTriFaceMesh3D::setKdTreeSplitAlgorithm(KDTREE_SPLITAGORITHM mode) -{ - if(kdTree && mode != this->kdtreeSplitAlg) { delete kdTree; kdTree = NULL; } - this->kdtreeSplitAlg = mode; -} -/*======================================================================*/ - /** - * Returns a string representation of this triangular mesh. - * @return a string representation of this triangular mesh - */ -string GbTriFaceMesh3D::toString() -{ - stringstream ss; - ss<<"GbTriFaceMesh3D["; - ss<<(int)this->triangles->size()<<"-Triangles, "<<(int)this->nodes->size()<<"-Nodes, "<<endl; - ss<<"]"; - return(ss.str()); -} -/** - * Returns the nodes of this triangular mesh. - * @return the nodes of this triangular mesh - */ -vector<GbTriFaceMesh3D::Vertex>* GbTriFaceMesh3D::getNodes() { return this->nodes; } -/** - * Returns the triangles of this triangular mesh. - * @return the triangles of this triangular mesh - */ -vector<GbTriFaceMesh3D::TriFace>* GbTriFaceMesh3D::getTriangles() { return this->triangles; } -/** - * Returns the center x1 coordinate of this triangular mesh. - * @return the center x1 coordinate of this triangular mesh - */ -double GbTriFaceMesh3D::getVolume() -{ - vector<Vertex>& vertices = *nodes; - vector<TriFace>& tris = *triangles; - - double x1,x2,x3,y1,y2,y3,z1,z2,z3, G3i; - //double rSP1 = 0.0;double rSP2 = 0.0;double rSP3 = 0.0; - double volume = 0.0; - for(size_t t=0; t<tris.size(); t++) - { - TriFace& triangle = tris[t]; - x1 = triangle.getV1x(vertices); y1 = triangle.getV1y(vertices); z1 = triangle.getV1z(vertices); - x2 = triangle.getV2x(vertices); y2 = triangle.getV2y(vertices); z2 = triangle.getV2z(vertices); - x3 = triangle.getV3x(vertices); y3 = triangle.getV3y(vertices); z3 = triangle.getV3z(vertices); - G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3); - volume = volume+G3i/6.0; - } - return volume; -} -/*===============================================*/ -UbTupleDouble3 GbTriFaceMesh3D::calculateCenterOfGravity() -{ - vector<Vertex>& vertices = *nodes; - vector<TriFace>& tris = *triangles; - - double x1,x2,x3,y1,y2,y3,z1,z2,z3; - double G3i; - double rSP1 = 0.0, rSP2 = 0.0, rSP3 = 0.0, volume = 0.0; - - for(size_t t=0; t<tris.size(); t++) - { - TriFace& triangle = tris[t]; - x1 = triangle.getV1x(vertices); y1 = triangle.getV1y(vertices); z1 = triangle.getV1z(vertices); - x2 = triangle.getV2x(vertices); y2 = triangle.getV2y(vertices); z2 = triangle.getV2z(vertices); - x3 = triangle.getV3x(vertices); y3 = triangle.getV3y(vertices); z3 = triangle.getV3z(vertices); - G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3); - volume = volume+G3i/6.0; - rSP1 = rSP1+G3i*(x1+x2+x3); - rSP2 = rSP2+G3i*(y1+y2+y3); - rSP3 = rSP3+G3i*(z1+z2+z3); - } - rSP1 = rSP1/(24.0*volume); - rSP2 = rSP2/(24.0*volume); - rSP3 = rSP3/(24.0*volume); - - return UbTupleDouble3(rSP1, rSP2, rSP3); -} -/*===============================================*/ -UbTupleDouble6 GbTriFaceMesh3D::calculateMomentOfInertia(double rhoP) -{ - vector<Vertex>& vertices = *nodes; - - double x1,x2,x3,y1,y2,y3,z1,z2,z3; - double G3i; - double xx,yy,zz,xy,yz,zx; - double rSP1 = 0.0;double rSP2 = 0.0;double rSP3 = 0.0; - double volume = 0.0; - double top11 = 0.0;double top22 = 0.0;double top33 = 0.0; - double top12 = 0.0;double top23 = 0.0;double top13 = 0.0; - int size = (int)this->triangles->size(); - for(int u=0; u<size;u++) - { - TriFace& triangle = (*this->triangles)[u]; - x1 = triangle.getV1x(vertices); y1 = triangle.getV1y(vertices); z1 = triangle.getV1z(vertices); - x2 = triangle.getV2x(vertices); y2 = triangle.getV2y(vertices); z2 = triangle.getV2z(vertices); - x3 = triangle.getV3x(vertices); y3 = triangle.getV3y(vertices); z3 = triangle.getV3z(vertices); - G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3); - volume = volume+G3i/6.0; - rSP1 = rSP1+G3i*(x1+x2+x3); - rSP2 = rSP2+G3i*(y1+y2+y3); - rSP3 = rSP3+G3i*(z1+z2+z3); - } - rSP1 = rSP1/(24.0*volume); - rSP2 = rSP2/(24.0*volume); - rSP3 = rSP3/(24.0*volume); - - double x1s = 0.0;//rSP1;//0.0;// - double x2s = 0.0;//rSP2;//0.0;// - double x3s = 0.0;//rSP3;//0.0;// - - for(int u=0; u<size;u++) - { - TriFace& triangle = (*this->triangles)[u]; - x1 = triangle.getV1x(vertices)-x1s; - y1 = triangle.getV1y(vertices)-x2s; - z1 = triangle.getV1z(vertices)-x3s; - x2 = triangle.getV2x(vertices)-x1s; - y2 = triangle.getV2y(vertices)-x2s; - z2 = triangle.getV2z(vertices)-x3s; - x3 = triangle.getV3x(vertices)-x1s; - y3 = triangle.getV3y(vertices)-x2s; - z3 = triangle.getV3z(vertices)-x3s; - G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3); - //rSP1 = rSP1+G3i*(x1+x2+x3)/(24.0*volume); - //rSP2 = rSP2+G3i*(y1+y2+y3)/(24.0*volume); - //rSP3 = rSP3+G3i*(z1+z2+z3)/(24.0*volume); - xx = x1*x1+x2*x2+x3*x3+x1*x2+x2*x3+x3*x1; - yy = y1*y1+y2*y2+y3*y3+y1*y2+y2*y3+y3*y1; - zz = z1*z1+z2*z2+z3*z3+z1*z2+z2*z3+z3*z1; - top11 = top11+(yy+zz)*rhoP*G3i/60.; - top22 = top22+(xx+zz)*rhoP*G3i/60.; - top33 = top33+(yy+xx)*rhoP*G3i/60.; - xy = 2.0*(x1*y1+x2*y2+x3*y3)+x2*y3+x3*y1+x1*y2+x3*y2+x1*y3+x2*y1; - yz = 2.0*(y1*z1+y2*z2+y3*z3)+y2*z3+y3*z1+y1*z2+y3*z2+y1*z3+y2*z1; - zx = 2.0*(z1*x1+z2*x2+z3*x3)+z2*x3+z3*x1+z1*x2+z3*x2+z1*x3+z2*x1; - top12 = top12-xy*rhoP*G3i/120.; - top23 = top23-yz*rhoP*G3i/120.; - top13 = top13-zx*rhoP*G3i/120.; - } - //Satz von Steiner ... - top11 = top11-rhoP*volume*(rSP2*rSP2+rSP3+rSP3); - top22 = top22-rhoP*volume*(rSP3*rSP3+rSP1*rSP1); - top33 = top33-rhoP*volume*(rSP1*rSP1+rSP2*rSP2); - top12 = top12+rhoP*volume*rSP1*rSP2; - top23 = top23+rhoP*volume*rSP2*rSP3; - top13 = top13+rhoP*volume*rSP3*rSP1; - - cout<<"Volume:"<<volume<<"\n Traegheitsmomente:\n"; - cout<<" top11:"<<top11<<" top22:"<<top22<<" top33:"<<top33<<endl; - cout<<" top12:"<<top12<<" top23:"<<top23<<" top13:"<<top13<<endl; - - return UbTupleDouble6(top11,top22,top33,top12,top23,top13); -} -/*==============================================================*/ -void GbTriFaceMesh3D::calculateValues() -{ - relationVertTris.clear(); - - if( nodes->empty() ) - { - x1min = x1max = x2min = x2max = x3min = x3max = 0.0; - } - else - { - Vertex& v = (*nodes)[0]; - x1min = x1max = v.x; - x2min = x2max = v.y; - x3min = x3max = v.z; - - for(size_t i=1; i<this->nodes->size(); i++) - { - Vertex& v1 = (*nodes)[i]; - - x1min = UbMath::min<double>(x1min,v1.x); - x2min = UbMath::min<double>(x2min,v1.y); - x3min = UbMath::min<double>(x3min,v1.z); - - x1max = UbMath::max<double>(x1max,v1.x); - x2max = UbMath::max<double>(x2max,v1.y); - x3max = UbMath::max<double>(x3max,v1.z); - } - x1center = 0.5 * (x1min + x1max ); - x2center = 0.5 * (x2min + x2max ); - x3center = 0.5 * (x3min + x3max ); - - vector<TriFace>& tris = *this->triangles; - vector<Vertex>& verts = *this->nodes; - for(size_t i=0; i<this->triangles->size(); i++) - { - tris[i].calculateNormal(verts); - } - //relation Vertex <-> Triangle ermitteln - if(buildVertTriRelationMap) - { - for(size_t t=0; t<tris.size(); t++) - { - TriFace& tri = tris[t]; - relationVertTris.insert( make_pair( &verts[tri.v1], &tri) ); - relationVertTris.insert( make_pair( &verts[tri.v2], &tri) ); - relationVertTris.insert( make_pair( &verts[tri.v3], &tri) ); - } - } - } - if(kdTree) - { - delete kdTree; - kdTree=NULL; - } - - this->consistent = true; -} -/*=========================================================================*/ -std::vector<GbTriFaceMesh3D::TriFace*> GbTriFaceMesh3D::getTrianglesForVertex(Vertex* vertex) -{ - if(!buildVertTriRelationMap) { buildVertTriRelationMap=true; consistent = false;} - if(!consistent) this->calculateValues(); - - typedef std::multimap<Vertex*,TriFace*>::iterator Iterator; - pair<Iterator,Iterator> objRange = relationVertTris.equal_range(vertex); - - std::vector<TriFace*> tmpTris; - for(Iterator pos=objRange.first; pos!=objRange.second; ++pos) - tmpTris.push_back( pos->second ); - - return tmpTris; -} -/*=======================================================*/ -void GbTriFaceMesh3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3) -{ - this->translate(x1-getX1Centroid(), x2-getX2Centroid(), x3-getX3Centroid() ); -} - -/*======================================================================*/ -void GbTriFaceMesh3D::scale(const double& sx1, const double& sx2, const double& sx3) -{ - CoordinateTransformation3D trafoForw(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), 1.0, 1.0, 1.0, 0.0, 0.0, 0.0); - CoordinateTransformation3D trafoBack(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), sx1, sx2, sx3, 0, 0, 0); - - vector<Vertex>& vertices = *nodes; - for(size_t i=0; i<vertices.size(); i++) - { - Vertex& v = vertices[i]; - double p1x1 = trafoForw.transformForwardToX1Coordinate(v.x, v.y, v.z); - double p1x2 = trafoForw.transformForwardToX2Coordinate(v.x, v.y, v.z); - double p1x3 = trafoForw.transformForwardToX3Coordinate(v.x, v.y, v.z); - v.x = (float)trafoBack.transformBackwardToX1Coordinate(p1x1, p1x2, p1x3); - v.y = (float)trafoBack.transformBackwardToX2Coordinate(p1x1, p1x2, p1x3); - v.z = (float)trafoBack.transformBackwardToX3Coordinate(p1x1, p1x2, p1x3); - } - this->calculateValues(); -} -/*======================================================================*/ -void GbTriFaceMesh3D::rotate(const double& alpha, const double& beta, const double& gamma) -{ - CoordinateTransformation3D trafoForw(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), 1.0, 1.0, 1.0, 0.0, 0.0, 0.0); - CoordinateTransformation3D trafoBack(this->getX1Centroid(), this->getX2Centroid(), this->getX3Centroid(), 1.0, 1.0, 1.0, alpha, beta, gamma); - - vector<Vertex>& vertices = *nodes; - for(size_t i=0; i<vertices.size(); i++) - { - Vertex& v = vertices[i]; - double p1x1 = trafoForw.transformForwardToX1Coordinate(v.x, v.y, v.z); - double p1x2 = trafoForw.transformForwardToX2Coordinate(v.x, v.y, v.z); - double p1x3 = trafoForw.transformForwardToX3Coordinate(v.x, v.y, v.z); - v.x = (float)trafoBack.transformBackwardToX1Coordinate(p1x1, p1x2, p1x3); - v.y = (float)trafoBack.transformBackwardToX2Coordinate(p1x1, p1x2, p1x3); - v.z = (float)trafoBack.transformBackwardToX3Coordinate(p1x1, p1x2, p1x3); - } - this->calculateValues(); -} -/*======================================================================*/ -void GbTriFaceMesh3D::rotateAroundPoint(const double& px1, const double& px2, const double& px3, const double& alpha, const double& beta, const double& gamma) -{ - CoordinateTransformation3D trafoForw(px1, px2, px3, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0); - CoordinateTransformation3D trafoBack(px1, px2, px3, 1.0, 1.0, 1.0, alpha, beta, gamma); - - vector<Vertex>& vertices = *nodes; - for(size_t i=0; i<vertices.size(); i++) - { - Vertex& v = vertices[i]; - double p1x1 = trafoForw.transformForwardToX1Coordinate(v.x, v.y, v.z); - double p1x2 = trafoForw.transformForwardToX2Coordinate(v.x, v.y, v.z); - double p1x3 = trafoForw.transformForwardToX3Coordinate(v.x, v.y, v.z); - v.x = (float)trafoBack.transformBackwardToX1Coordinate(p1x1, p1x2, p1x3); - v.y = (float)trafoBack.transformBackwardToX2Coordinate(p1x1, p1x2, p1x3); - v.z = (float)trafoBack.transformBackwardToX3Coordinate(p1x1, p1x2, p1x3); - } - this->calculateValues(); -} - - -/*======================================================================*/ -void GbTriFaceMesh3D::translate(const double& x1, const double& x2, const double& x3) -{ - vector<Vertex>& vertices = *nodes; - for(size_t i=0; i<vertices.size(); i++) - { - Vertex& v = vertices[i]; - v.x += static_cast<float>(x1); - v.y += static_cast<float>(x2); - v.z += static_cast<float>(x3); - } - this->calculateValues(); -} -/*======================================================================*/ -vector<GbTriangle3D*> GbTriFaceMesh3D::getSurfaceTriangleSet() -{ - //SirAnn: eine miese Speicherlochmethode - // hier werden dynmamische Objekte angelegt - // mit sowas rechnet von aussen kein Mensch!!! - vector<GbTriangle3D*> tris( triangles->size() ); - - for(size_t i=0; i<this->triangles->size(); i++) - { - Vertex& v1 = (*nodes)[(*triangles)[i].v1]; - Vertex& v2 = (*nodes)[(*triangles)[i].v2]; - Vertex& v3 = (*nodes)[(*triangles)[i].v3]; - - tris[i] = new GbTriangle3D( new GbPoint3D(v1.x,v1.y,v1.z) - , new GbPoint3D(v2.x,v2.y,v2.z) - , new GbPoint3D(v3.x,v3.y,v3.z) ); - } - return tris; -} -/*=======================================================*/ -void GbTriFaceMesh3D::addSurfaceTriangleSet(vector<UbTupleFloat3>& pts, vector<UbTupleInt3>& tris) -{ - int nodeNr = pts.size(); - for(int i=0; i<(int)this->triangles->size(); i++) - { - Vertex& v1 = (*nodes)[(*triangles)[i].v1]; - Vertex& v2 = (*nodes)[(*triangles)[i].v2]; - Vertex& v3 = (*nodes)[(*triangles)[i].v3]; - pts.push_back( makeUbTuple(v1.x,v1.y,v1.z)); - pts.push_back( makeUbTuple(v2.x,v2.y,v2.z)); - pts.push_back( makeUbTuple(v3.x,v3.y,v3.z)); - - tris.push_back( makeUbTuple( nodeNr, nodeNr+1, nodeNr+2 ) ); - nodeNr+=3; - } -} -/*======================================================================*/ -//bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, int counter) -//{ -// -// -// if( !nodes->empty() ) -// { -// //Baum erstellen, wen noch keiner vorhanden -// if( !kdTree) -// { -// UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start"); -// UbTimer timer; timer.start(); -// if(kdtreeSplitAlg == KDTREE_SAHPLIT ) -// { -// UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit"); -// this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>() ); -// } -// else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT) -// { -// UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit"); -// this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); -// } -// else throw UbException(UB_EXARGS, "unknown kdtree split option)" ); -// UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds"); -// } -// -// //eigentlicher PIO-Test -// //int iSec; -// //for(int i=0; i<100; i++) -// //{ -// // Kd::Ray<double> ray( x1, x2, x3 //, 1, 0 ,0 ); -// // , ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) -// // , ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) -// // , ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ); -// // -// // iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() ); -// // -// // if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen -// // { -// // if(iSec == Kd::Intersection::ON_BOUNDARY ) -// // { -// // return true; -// // } -// // return (iSec&1); //ungerade anzahl an schnitten --> drinnen -// // } -// // UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if - an edge was hit "); -// //} -// //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); -// int iSec1,iSec2; -// -// Kd::Ray<double> ray1( x1, x2, x3, 1.0, 0.0 ,0.0 ); -// iSec1 = kdTree->intersectRay( ray1, Kd::CountRayIntersectionHandler<double>() ); -// Kd::Ray<double> ray2( x1, x2, x3, -1.0, 0.0 ,0.0 ); -// iSec2 = kdTree->intersectRay( ray2, Kd::CountRayIntersectionHandler<double>() ); -// -// if(iSec1 == Kd::Intersection::ON_BOUNDARY || iSec2 == Kd::Intersection::ON_BOUNDARY) -// { -// return true; -// } -// if( iSec1 == Kd::Intersection::INTERSECT_EDGE && iSec2 == Kd::Intersection::INTERSECT_EDGE) -// { -// UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.INTERSECT_EDGE"); -// double eps = UbMath::getEqualityEpsilon<float>()*1000.0; -// if (counter>100) {return(iSec1&1); UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");} -// return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1)); -// } -// else if( iSec1 == Kd::Intersection::INTERSECT_EDGE) -// { -// return (iSec2&1); -// } -// else if( iSec2 == Kd::Intersection::INTERSECT_EDGE) -// { -// return (iSec1&1); -// } -// else -// { -// if((iSec1&1) != (iSec2&1)) -// { -// UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.iSec1&1 != iSec2&1"); -// double eps = UbMath::getEqualityEpsilon<float>()*1000.0; -// if (counter>100) {return(iSec1&1); UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");} -// return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1)); -// } -// return iSec1&1; -// } -// //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); -// -// } -// return false; -//} -bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, int counter) -{ - - if( !nodes->empty() ) - { - //Baum erstellen, wen noch keiner vorhanden - if( !kdTree) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start"); - UbTimer timer; timer.start(); - if(kdtreeSplitAlg == KDTREE_SAHPLIT ) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit"); - this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>() ); - } - else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit"); - this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); - } - else throw UbException(UB_EXARGS, "unknown kdtree split option)" ); - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds"); - } - - //eigentlicher PIO-Test - //int iSec; - //for(int i=0; i<100; i++) - //{ - // Kd::Ray<double> ray( x1, x2, x3 //, 1, 0 ,0 ); - // , ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) - // , ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) - // , ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ); - // - // iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() ); - // - // if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen - // { - // if(iSec == Kd::Intersection::ON_BOUNDARY ) - // { - // return true; - // } - // return (iSec&1); //ungerade anzahl an schnitten --> drinnen - // } - // UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if - an edge was hit "); - //} - //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); - int iSec1,iSec2; - double eps = 0.05; - Kd::Ray<double> ray1( x1, x2, x3, 1.0+eps*((double)counter), eps*((double)counter) ,eps*((double)counter) ); - iSec1 = kdTree->intersectRay( ray1, Kd::CountRayIntersectionHandler<double>() ); - Kd::Ray<double> ray2( x1, x2, x3, -1.0-eps*((double)counter), -eps*((double)counter) ,-eps*((double)counter) ); - - iSec2 = kdTree->intersectRay( ray2, Kd::CountRayIntersectionHandler<double>() ); - - if(iSec1 == Kd::Intersection::ON_BOUNDARY || iSec2 == Kd::Intersection::ON_BOUNDARY) - { - return true; - } - if( iSec1 == Kd::Intersection::INTERSECT_EDGE && iSec2 == Kd::Intersection::INTERSECT_EDGE) - { - //UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.INTERSECT_EDGE"); - - if (counter>20) {return(iSec1&1); UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");} - return this->isPointInGbObject3D(x1, x2, x3,(counter+1)); - } - else if( iSec1 == Kd::Intersection::INTERSECT_EDGE) - { - return (iSec2&1); - } - else if( iSec2 == Kd::Intersection::INTERSECT_EDGE) - { - return (iSec1&1); - } - else - { - if((iSec1&1) != (iSec2&1)) - { - //UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.iSec1&1 != iSec2&1"); - - if (counter>20) {return(iSec1&1); UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");} - return this->isPointInGbObject3D(x1, x2, x3,(counter+1)); - } - return iSec1&1; - } - //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); - - } - return false; -} -/*======================================================================*/ -bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3) -{ - int counter=0; - - if( !nodes->empty() ) - { - //Baum erstellen, wen noch keiner vorhanden - if( !kdTree) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start"); - UbTimer timer; timer.start(); - if(kdtreeSplitAlg == KDTREE_SAHPLIT ) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit"); - cout << "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit" << std::endl; - this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>() ); - } - else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit"); - this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); - } - else throw UbException(UB_EXARGS, "unknown kdtree split option)" ); - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds"); - cout << "GbTriFaceMesh3D::calculateValues - built kdTree in " << timer.stop() << "seconds" << std::endl; - } - - //eigentlicher PIO-Test - int iSec; - for(int i=0; i<MAX_ITER; i++) - { - Kd::Ray<double> ray( x1, x2, x3 //, 1, 0 ,0 ); - , ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) - , ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) - , ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ); - - iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() ); - - if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen - { - if(iSec == Kd::Intersection::ON_BOUNDARY ) - { - return true; - } - return (iSec&1); //ungerade anzahl an schnitten --> drinnen - } - UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if - an edge was hit "); - } - throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); - - // int iSec1,iSec2; - // - // Kd::Ray<double> ray1( x1, x2, x3, 1.0, 0.0 ,0.0 ); - // iSec1 = kdTree->intersectRay( ray1, Kd::CountRayIntersectionHandler<double>() ); - // Kd::Ray<double> ray2( x1, x2, x3, -1.0, 0.0 ,0.0 ); - // iSec2 = kdTree->intersectRay( ray2, Kd::CountRayIntersectionHandler<double>() ); - - // if(iSec1 == Kd::Intersection::ON_BOUNDARY || iSec2 == Kd::Intersection::ON_BOUNDARY) - // { - // return true; - // } - // if( iSec1 == Kd::Intersection::INTERSECT_EDGE && iSec2 == Kd::Intersection::INTERSECT_EDGE) - // { - // //UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.INTERSECT_EDGE"); - // double eps = UbMath::getEqualityEpsilon<double>(); - // if (counter>100) {return(iSec1&1); UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");} - // return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1)); - // } - // else if( iSec1 == Kd::Intersection::INTERSECT_EDGE) - // { - // return (iSec2&1); - // } - // else if( iSec2 == Kd::Intersection::INTERSECT_EDGE) - // { - // return (iSec1&1); - // } - // else - // { - // if((iSec1&1) != (iSec2&1)) - // { - // UBLOG(logINFO, "GbTriFaceMesh3D.isPointInGbObject3D.iSec1&1 != iSec2&1"); - // double eps = UbMath::getEqualityEpsilon<double>(); - // if (counter>100) {return(iSec1&1); UBLOG(logINFO, "NACH 100 Iterationen Eps umsetzen aufgegeben!");} - // return this->isPointInGbObject3D(x1+eps, x2+eps, x3+eps,(counter+1)); - // } - // return iSec1&1; - // } - // //throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); - - } - return false; -} -/*======================================================================*/ -bool GbTriFaceMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary) -{ - if( !nodes->empty() ) - { - //Baum erstellen, wen noch keiner vorhanden - if( !kdTree) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start"); - UbTimer timer; timer.start(); - if(kdtreeSplitAlg == KDTREE_SAHPLIT ) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit"); - this->kdTree = new Kd::Tree<double>( *this, Kd::SAHSplit<double>() ); - } - else if(kdtreeSplitAlg == KDTREE_SPATIALSPLIT) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit"); - this->kdTree = new Kd::Tree<double>( *this, Kd::SpatialMedianSplit<double>() ); - } - else throw UbException(UB_EXARGS, "unknown kdtree split option)" ); - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in "<<timer.stop()<<"seconds"); - } - - //eigentlicher PIO-Test - int iSec; - for(int i=0; i<MAX_ITER; i++) - { - Kd::Ray<double> ray( x1, x2, x3 - , float( ( x1 < x1center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ) - , float( ( x2 < x2center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ) - , float( ( x3 < x3center ? UbRandom::rand(-1.0,-0.001, 10) : UbRandom::rand(0.001, 1.0, 10) ) ) ); - - iSec = kdTree->intersectRay( ray, Kd::CountRayIntersectionHandler<double>() ); - - if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen - { - if(iSec == Kd::Intersection::ON_BOUNDARY ) - { - pointIsOnBoundary = true; - return true; - } - pointIsOnBoundary = false; - return (iSec&1); //ungerade anzahl an schnitten --> drinnen - } - } - - throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); - } - - return false; -} -/*======================================================================*/ -bool GbTriFaceMesh3D::intersectLine(const double& p1_x1, const double& p1_x2, const double& p1_x3, const double& p2_x1, const double& p2_x2, const double& p2_x3) -{ - //Baum erstellen, wen noch keiner vorhanden - if (!kdTree) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree start"); - UbTimer timer; timer.start(); - if (kdtreeSplitAlg == KDTREE_SAHPLIT) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SAHSplit"); - this->kdTree = new Kd::Tree<double>(*this, Kd::SAHSplit<double>()); - } - else if (kdtreeSplitAlg == KDTREE_SPATIALSPLIT) - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - build KdTree with SpatialMedianSplit"); - this->kdTree = new Kd::Tree<double>(*this, Kd::SpatialMedianSplit<double>()); - } - else throw UbException(UB_EXARGS, "unknown kdtree split option)"); - UBLOG(logDEBUG3, "GbTriFaceMesh3D::calculateValues - built kdTree in " << timer.stop() << "seconds"); - } - - int iSec = kdTree->intersectLine(UbTupleDouble3(p1_x1, p1_x2, p1_x3), UbTupleDouble3(p2_x1, p2_x2, p2_x3), Kd::CountLineIntersectionHandler<double>()); - - return (iSec != Kd::Intersection::NO_INTERSECTION); -} -/*======================================================================*/ -GbLine3D* GbTriFaceMesh3D::createClippedLine3D (GbPoint3D& point1, GbPoint3D& point2) -{ - throw UbException(UB_EXARGS,"not implemented"); -} -/*======================================================================*/ -void GbTriFaceMesh3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - out->writeInteger((int)kdtreeSplitAlg); - out->writeBool(transferViaFilename); - - if(!transferViaFilename) - { - //nodes - vector<Vertex>& vertices = *nodes; - out->writeSize_t( nodes->size() ); - out->writeLine(); - for(size_t i=0; i<vertices.size(); i++) - { - Vertex& v = vertices[i]; - out->writeFloat(v.x); - out->writeFloat(v.y); - out->writeFloat(v.z); - out->writeLine(); - } - - //triangles - vector<TriFace>& tris = *triangles; - out->writeSize_t( tris.size() ); - out->writeLine(); - for(size_t i=0; i<tris.size(); i++) - { - TriFace& t = tris[i]; - out->writeInteger(t.v1); - out->writeInteger(t.v2); - out->writeInteger(t.v3); - out->writeLine(); - } - } - else - { - out->writeString(filename); - out->writeLine(); - out->writeDouble(transX1); - out->writeDouble(transX2); - out->writeDouble(transX3); - - } -} -/*======================================================================*/ -void GbTriFaceMesh3D::read(UbFileInput* in) -{ - kdtreeSplitAlg = (KDTREE_SPLITAGORITHM)in->readInteger(); - transferViaFilename = in->readBool(); - - if(!transferViaFilename) - { - if(!nodes) nodes = new vector<Vertex>; - //nodes - vector<Vertex>& vertices = *nodes; - vertices.resize( in->readSize_t( ) ); - in->readLine(); - for(size_t i=0; i<vertices.size(); i++) - { - Vertex& v = vertices[i]; - v.x = in->readFloat(); - v.y = in->readFloat(); - v.z = in->readFloat(); - in->readLine(); - } - - //triangles - if(!triangles) triangles = new vector<TriFace>; - vector<TriFace>& tris = *triangles; - tris.resize( in->readSize_t( ) ); - in->readLine(); - for(size_t i=0; i<tris.size(); i++) - { - TriFace& t = tris[i]; - t.v1 = in->readInteger(); - t.v2 = in->readInteger(); - t.v3 = in->readInteger(); - in->readLine(); - } - - this->calculateValues(); - } - else - { - filename = in->readString(); - in->readLine(); - transX1 = in->readDouble(); - transX2 = in->readDouble(); - transX3 = in->readDouble(); - - this->readMeshFromSTLFile(filename, true); - this->translate(transX1,transX2,transX3); - } -} -/*======================================================================*/ -UbTuple<string, string> GbTriFaceMesh3D::writeMesh(string filename, WbWriter* writer, bool writeNormals, vector< string >* datanames, std::vector< std::vector < double > >* nodedata ) -{ - UBLOG(logINFO, "GbTriFaceMesh3D::writeMesh "); - - vector<UbTupleFloat3 > triNodes(nodes->size()); - vector<UbTupleInt3 > tris(triangles->size()); - - for(size_t i=0; i<nodes->size(); i++) - triNodes[i] = makeUbTuple( (*nodes)[i].x, (*nodes)[i].y, (*nodes)[i].z ); - - for(size_t i=0; i<triangles->size(); i++) - tris[i] = makeUbTuple( (*triangles)[i].v1, (*triangles)[i].v2, (*triangles)[i].v3 ) ; - - UbTuple<string, string> filenames("",""); - - if( !datanames || datanames->empty() || !nodedata ) - { - val<1>(filenames) = writer->writeTriangles(filename,triNodes,tris); - } - else - { - val<1>(filenames) = writer->writeTrianglesWithNodeData(filename,triNodes,tris,*datanames,*nodedata); - } - - if(writeNormals) - { - vector<UbTupleFloat3 > lineNodes(triangles->size()*2); - vector<UbTupleInt2 > lines(triangles->size()); - for(size_t i=0; i<triangles->size(); i++) - { - TriFace& triangle = (*triangles)[i]; - lineNodes[i*2 ] = makeUbTuple( triangle.getX1Centroid(*nodes) - ,triangle.getX2Centroid(*nodes) - ,triangle.getX3Centroid(*nodes)); - - lineNodes[i*2+1] = makeUbTuple( (float)(triangle.getX1Centroid(*nodes)+1.0*triangle.nx) - ,(float)(triangle.getX2Centroid(*nodes)+1.0*triangle.ny) - ,(float)(triangle.getX3Centroid(*nodes)+1.0*triangle.nz)); - - lines[i] = makeUbTuple((int)i*2,(int)i*2+1); - } - val<2>(filenames) = writer->writeLines(filename+"_normals",lineNodes,lines); - } - - return filenames; -} -/*======================================================================*/ -void GbTriFaceMesh3D::writeMeshPly( const std::string& filename) -{ - ofstream out(filename.c_str() ); - if( !out ) - throw UbException(UB_EXARGS, "couldn't open " + filename); - - out << "ply" << endl; - out << "format ascii 1.0" << endl; - out << "element vertex " << (int)nodes->size() << endl; - out << "property float x" << endl; - out << "property float y" << endl; - out << "property float z" << endl; - out << "element face " << (int)triangles->size() << endl; - out << "property list uchar int vertex_indices" << endl; - out << "end_header" << endl; - - for(size_t i=0; i<nodes->size(); i++) - out << (*nodes)[i].x << " " << (*nodes)[i].y << " " << (*nodes)[i].z << endl; - - for(size_t i=0; i<triangles->size(); i++) - out << "3 " << (*triangles)[i].v1 << " " << (*triangles)[i].v2 << " " << (*triangles)[i].v3 << endl; -} -/*======================================================================*/ -void GbTriFaceMesh3D::readMeshFromSTLFile(string filename, bool removeRedundantNodes) -{ - UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ..."); - - UbFileInputASCII in(filename); - //this->nodes = new vector<GbTriFaceMesh3D::Vertex>; - //this->triangles = new vector<GbTriFaceMesh3D::TriFace>; - string dummy; - - double x, y, z; - int nr=0; - - in.readLine(); - while(dummy!="endsolid") - { - in.readLine(); - in.readLine(); - dummy = in.readString(); - if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format"); - x=in.readDouble(); - y=in.readDouble(); - z=in.readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - in.readLine(); - in.readString(); - x=in.readDouble(); - y=in.readDouble(); - z=in.readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - in.readLine(); - in.readString(); - x=in.readDouble(); - y=in.readDouble(); - z=in.readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - triangles->push_back(GbTriFaceMesh3D::TriFace(nr,nr+1,nr+2)); - in.readLine(); - in.readLine(); - in.readLine(); - dummy = in.readString(); - nr+=3; - } - if(removeRedundantNodes) - { - this->deleteRedundantNodes(); //dort wird autoamtisch calculateValues() aufgerufen - } - else - { - this->calculateValues(); - } -} -////////////////////////////////////////////////////////////////////////// -//void GbTriFaceMesh3D::writeMeshToSTLFile(string filename, bool isBinaryFormat) -//{ -// vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; -// vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; -// int nr=0; -// -// if (!isBinaryFormat) { -// ofstream out(filename.c_str()); -// if (!out.good()) -// { -// delete nodes; -// delete triangles; -// UB_THROW(UbException(UB_EXARGS, "Can not open STL file: "+filename)); -// } -// char title[80] = "ASCII"; -// std::string s0, s1; -// float n0, n1, n2, f0, f1, f2, f3, f4, f5, f6, f7, f8; -// out.write(title, 80); -// size_t size = nodes->size(); -// for (size_t i = 0; i < size) -// { -// out << nodes[i++] -// in >> s0; // facet || endsolid -// if (s0=="facet") { -// in >> s1 >> n0 >> n1 >> n2; // normal x y z -// in >> s0 >> s1; // outer loop -// in >> s0 >> f0 >> f1 >> f2; // vertex x y z -// in >> s0 >> f3 >> f4 >> f5; // vertex x y z -// in >> s0 >> f6 >> f7 >> f8; // vertex x y z -// in >> s0; // endloop -// in >> s0; // endfacet -// // Generate a new Triangle without Normal as 3 Vertices -// nodes->push_back(GbTriFaceMesh3D::Vertex(f0, f1, f2)); -// nodes->push_back(GbTriFaceMesh3D::Vertex(f3, f4, f5)); -// nodes->push_back(GbTriFaceMesh3D::Vertex(f6, f7, f8)); -// triangles->push_back(GbTriFaceMesh3D::TriFace(nr, nr+1, nr+2)); -// nr+=3; -// } -// else if (s0=="endsolid") { -// break; -// } -// } -// in.close(); -// } -// else { -// FILE *f = fopen(filename.c_str(), "rb"); -// if (!f) -// { -// delete nodes; -// delete triangles; -// UB_THROW(UbException(UB_EXARGS, "Can not open STL file: "+filename)); -// } -// char title[80]; -// int nFaces; -// fread(title, 80, 1, f); -// fread((void*)&nFaces, 4, 1, f); -// float v[12]; // normal=3, vertices=3*3 = 12 -// unsigned short uint16; -// // Every Face is 50 Bytes: Normal(3*float), Vertices(9*float), 2 Bytes Spacer -// for (size_t i=0; i<nFaces; ++i) { -// for (size_t j=0; j<12; ++j) { -// fread((void*)&v[j], sizeof(float), 1, f); -// } -// fread((void*)&uint16, sizeof(unsigned short), 1, f); // spacer between successive faces -// nodes->push_back(GbTriFaceMesh3D::Vertex(v[3], v[4], v[5])); -// nodes->push_back(GbTriFaceMesh3D::Vertex(v[6], v[7], v[8])); -// nodes->push_back(GbTriFaceMesh3D::Vertex(v[9], v[10], v[11])); -// triangles->push_back(GbTriFaceMesh3D::TriFace(nr, nr+1, nr+2)); -// nr+=3; -// } -// fclose(f); -// } -// -// GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes); -// -// return mesh; -//} -////////////////////////////////////////////////////////////////////////// diff --git a/src/basics/geometry3d/GbTriFaceMesh3D.h b/src/basics/geometry3d/GbTriFaceMesh3D.h deleted file mode 100644 index 85e624aa7..000000000 --- a/src/basics/geometry3d/GbTriFaceMesh3D.h +++ /dev/null @@ -1,385 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBTRIFACEMESH3D_H -#define GBTRIFACEMESH3D_H - -#include <sstream> -#include <iostream> -#include <vector> - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbMath.h> -#include <basics/utilities/Vector3D.h> - -#include <basics/memory/MbSmartPtr.h> - -#include <numerics/geometry3d/GbPoint3D.h> - -#include <PointerDefinitions.h> - -namespace Kd -{ - template< typename T> class Tree; - template< typename T > class SplitAlgorithm; - template< typename T > class RayIntersectionHandler; -} - -class WbWriter; - -/*=========================================================================*/ -/* GbTriFaceMesh3D */ -/* */ -/** - * This Class provides the triangular meshes. - * Note, that up to now no methods for checking consistency are included. - * in this context this class describes facettes from an 3D-object !!! -*/ -class BASICS_EXPORT GbTriFaceMesh3D : public GbObject3D -{ -public: - // nested class start - class Vertex - { - public: - Vertex() : x(0.0), y(0.0), z(0.0) { } - Vertex(const float& x, const float& y, const float& z) : x(x), y(y),z(z) { } - Vertex(Vertex* vert) - { - this->x = vert->x; - this->y = vert->y; - this->z = vert->z; - } - float operator[] (const int&i) const - { - if (i==0) return x; - else if(i==1) return y; - else if(i==2) return z; - - throw UbException(UB_EXARGS,"i not in [0;2]"); - } - float& operator[] (const int& i) - { - if (i==0) return x; - else if(i==1) return y; - else if(i==2) return z; - - throw UbException(UB_EXARGS,"not in [0;2]"); - } - bool operator== (const Vertex& rhs) - { - return ( fabs(x-rhs.x)<1.E-8 && fabs(y-rhs.y)<1.E-8 && fabs(z-rhs.z)<1.E-8 ); - } - friend inline bool operator<(const Vertex & lhsVert,const Vertex & rhsVert) - { - if( lhsVert.x < rhsVert.x ) return true; - if( lhsVert.x > rhsVert.x ) return false; - if( lhsVert.y < rhsVert.y ) return true; - if( lhsVert.y > rhsVert.y ) return false; - if( lhsVert.z < rhsVert.z ) return true; - - return false; - } - friend std::ostream& operator<<( std::ostream& os, const Vertex& node ) - { - return os<<node.x<<","<<node.y<<","<<node.z; - } - Vertex* clone() - { - return(new Vertex(this)); - } - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & x; ar & y; ar & z; - } -#endif //CAB_RCF - - public: - float x, y, z; - }; - ////////////////////////////////////////////////////////////////////////// - class TriFace - { - public: - TriFace() - : v1(-1), v2(-1), v3(-1), nx(0.0), ny(0.0), nz(0.0) - { - - } - TriFace(const int& v1, const int& v2, const int& v3) - : v1(v1), v2(v2), v3(v3), nx(0.0), ny(0.0), nz(0.0) - { - } - - const int& getIndexVertex1() const { return v1; } - const int& getIndexVertex2() const { return v2; } - const int& getIndexVertex3() const { return v3; } - - Vertex& getNode(const int& i, std::vector<Vertex>& nodes) - { - if(i==0) return nodes[v1]; - if(i==1) return nodes[v2]; - if(i==2) return nodes[v3]; - throw UbException(UB_EXARGS,"invalid i - not in range [0;2]"); - } - void setNode(const int& i, const int& index) - { - if (i==0) v1=index; - else if(i==1) v2=index; - else if(i==2) v3=index; - else throw UbException(UB_EXARGS,"invalid i - not in range [0;2]"); - } - - int operator[] (int index) - { - if(index==0) return v1; - if(index==1) return v2; - if(index==2) return v3; - throw UbException(UB_EXARGS,"invalid i - not in range [0;2]"); - } - - float& getV1x(std::vector<Vertex>& nodes) { return nodes[v1].x; } - float& getV1y(std::vector<Vertex>& nodes) { return nodes[v1].y; } - float& getV1z(std::vector<Vertex>& nodes) { return nodes[v1].z; } - - float& getV2x(std::vector<Vertex>& nodes) { return nodes[v2].x; } - float& getV2y(std::vector<Vertex>& nodes) { return nodes[v2].y; } - float& getV2z(std::vector<Vertex>& nodes) { return nodes[v2].z; } - - float& getV3x(std::vector<Vertex>& nodes) { return nodes[v3].x; } - float& getV3y(std::vector<Vertex>& nodes) { return nodes[v3].y; } - float& getV3z(std::vector<Vertex>& nodes) { return nodes[v3].z; } - - float getMinX(std::vector<Vertex>& nodes) { return (float)UbMath::min(nodes[v1].x,nodes[v2].x,nodes[v3].x); } - float getMinY(std::vector<Vertex>& nodes) { return (float)UbMath::min(nodes[v1].y,nodes[v2].y,nodes[v3].y); } - float getMinZ(std::vector<Vertex>& nodes) { return (float)UbMath::min(nodes[v1].z,nodes[v2].z,nodes[v3].z); } - - float getMaxX(std::vector<Vertex>& nodes) { return (float)UbMath::max(nodes[v1].x,nodes[v2].x,nodes[v3].x); } - float getMaxY(std::vector<Vertex>& nodes) { return (float)UbMath::max(nodes[v1].y,nodes[v2].y,nodes[v3].y); } - float getMaxZ(std::vector<Vertex>& nodes) { return (float)UbMath::max(nodes[v1].z,nodes[v2].z,nodes[v3].z); } - - float getX1Centroid(std::vector<Vertex>& nodes) {return (float)UbMath::c1o3 * (getV1x(nodes)+getV2x(nodes)+getV3x(nodes)); } - float getX2Centroid(std::vector<Vertex>& nodes) {return (float)UbMath::c1o3 * (getV1y(nodes)+getV2y(nodes)+getV3y(nodes)); } - float getX3Centroid(std::vector<Vertex>& nodes) {return (float)UbMath::c1o3 * (getV1z(nodes)+getV2z(nodes)+getV3z(nodes)); } - - double calculateDistanceToPoint3D(const double& x1, const double& x2, const double& x3, std::vector<Vertex>& nodes); - - double getArea(std::vector<Vertex>& nodes) - { - //GbVector3D A(nodes[v1].x, nodes[v1].y, nodes[v1].z); - //GbVector3D B(nodes[v2].x, nodes[v2].y, nodes[v2].z); - //GbVector3D C(nodes[v3].x, nodes[v3].y, nodes[v3].z); - //GbVector3D AB = B-A; - //GbVector3D AC = C-A; - //GbVector3D N = AB.Cross(AC); - //return 0.5*N.Length(); - Vector3D A(nodes[v1].x, nodes[v1].y, nodes[v1].z); - Vector3D B(nodes[v2].x, nodes[v2].y, nodes[v2].z); - Vector3D C(nodes[v3].x, nodes[v3].y, nodes[v3].z); - Vector3D AB = B-A; - Vector3D AC = C-A; - Vector3D N = AB.Cross(AC); - return 0.5*N.Length(); - } - void calculateNormal(std::vector<Vertex>& nodes) - { - const float& v1x = nodes[v1].x; const float& v1y = nodes[v1].y; const float& v1z = nodes[v1].z; - const float& v2x = nodes[v2].x; const float& v2y = nodes[v2].y; const float& v2z = nodes[v2].z; - const float& v3x = nodes[v3].x; const float& v3y = nodes[v3].y; const float& v3z = nodes[v3].z; - - nx = ( v3z - v1z) * ( v2y - v1y ) - ( v2z - v1z) * ( v3y - v1y ); - ny = ( v2z - v1z) * ( v3x - v1x ) - ( v2x - v1x) * ( v3z - v1z ); - nz = ( v2x - v1x) * ( v3y - v1y ) - ( v2y - v1y) * ( v3x - v1x ); - - float length = std::sqrt( nx*nx + ny*ny + nz*nz ); - if(length>1.E-10) - { - length = 1.0f/length; - nx *= length; - ny *= length; - nz *= length; - } - else - { - std::cerr<<"GbTriFaceMesh3D::TriFace - calculateNormal: nx=ny=nz=0 -> kann nich sein " - <<"(dreieck hat evtl knoten doppelt oder ist ne Linie)" - <<"->removeRedunantNodes"<<std::endl; - } - } - #ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & v1; ar & v2; ar & v3; - } - #endif //CAB_RCF - - public: - int v1, v2, v3; - float nx, ny, nz; - }; - -public: - enum KDTREE_SPLITAGORITHM { KDTREE_SAHPLIT, KDTREE_SPATIALSPLIT }; - -public: - GbTriFaceMesh3D(); - GbTriFaceMesh3D(std::string name, std::vector<Vertex>* nodes, std::vector<TriFace>* triangles, KDTREE_SPLITAGORITHM splitAlg = KDTREE_SAHPLIT, bool removeRedundantNodes=true); - ~GbTriFaceMesh3D(); - - GbTriFaceMesh3D* clone();// { throw UbException(UB_EXARGS,"not implemented"); } - void finalize() {} - - //void setRegardPointInPolyhedronTest(bool value) { this->regardPiO=value; } - - std::string toString(); - - //std::string getName(); - std::vector<Vertex>* getNodes(); - std::vector<TriFace>* getTriangles(); - - void setTransferViaFilename(bool transferViaFilename, std::string filename, double transX1, double transX2, double transX3) - { - this->filename = filename; - this->transferViaFilename = transferViaFilename; - this->transX1 = transX1; - this->transX2 = transX2; - this->transX3 = transX3; - } - void readMeshFromSTLFile(std::string filename, bool removeRedundantNodes); - - double getX1Minimum() { if(!this->consistent) this->calculateValues(); return this->x1min; } - double getX1Maximum() { if(!this->consistent) this->calculateValues(); return this->x1max; } - double getX1Centroid() { if(!this->consistent) this->calculateValues(); return this->x1center; } - - double getX2Minimum() { if(!this->consistent) this->calculateValues(); return this->x2min; } - double getX2Maximum() { if(!this->consistent) this->calculateValues(); return this->x2max; } - double getX2Centroid() { if(!this->consistent) this->calculateValues(); return this->x2center; } - - double getX3Minimum() { if(!this->consistent) this->calculateValues(); return this->x3min; } - double getX3Centroid() { if(!this->consistent) this->calculateValues(); return this->x3center; } - double getX3Maximum() { if(!this->consistent) this->calculateValues(); return this->x3max; } - - void calculateValues(); - - double getVolume(); - void deleteRedundantNodes(); - - UbTupleDouble6 calculateMomentOfInertia(double rhoP); - UbTupleDouble3 calculateCenterOfGravity(); - - void setCenterCoordinates(const double& x1, const double& x2, const double& x3); - - - void scale(const double& sx1, const double& sx2, const double& sx3); - void rotate(const double& alpha, const double& beta, const double& gamma); - void rotateAroundPoint(const double& px1, const double& px2, const double& px3, const double& alpha, const double& beta, const double& gamma); - void translate(const double& x1, const double& x2, const double& x3); - void reflectAcrossXYLine(const double& alpha); - - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3); - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, int counter); - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary); - - virtual GbLine3D* createClippedLine3D (GbPoint3D &point1,GbPoint3D &point2); - - virtual std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles); - - std::vector<GbTriFaceMesh3D::TriFace*> getTrianglesForVertex(Vertex* vertex); - - void setKdTreeSplitAlgorithm(KDTREE_SPLITAGORITHM mode); - KDTREE_SPLITAGORITHM getKdTreeSplitAlgorithm() { return this->kdtreeSplitAlg; } - Kd::Tree<double>* getKdTree() { return this->kdTree; } - - virtual ObObjectCreator* getCreator(); - - void write(UbFileOutput* out); - void read(UbFileInput* in); - - virtual UbTuple<std::string, std::string> writeMesh(std::string filename, WbWriter* writer, bool writeNormals=false, std::vector< std::string >* datanames=NULL, std::vector< std::vector < double > >* nodedata=NULL ); - void writeMeshPly( const std::string& filename); - - /*======================================================================*/ - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere - - bool intersectLine(const double& p1_x1, const double& p1_x2, const double& p1_x3, const double& p2_x1, const double& p2_x2, const double& p2_x3); - - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & kdtreeSplitAlg; - ar & transferViaFilename; - if(!transferViaFilename) - { - ar & nodes; - ar & triangles; - } - else - { - ar & filename; - ar & transX1; - ar & transX2; - ar & transX3; - if(ArchiveTools::isReading(ar) ) - { - this->readMeshFromSTLFile(filename, true); - this->translate(transX1,transX2,transX3); - } - } - - if(ArchiveTools::isReading(ar)) this->calculateValues(); - } -#endif //CAB_RCF - -protected: - KDTREE_SPLITAGORITHM kdtreeSplitAlg; - void init(); - - std::vector<Vertex>* nodes; - std::vector<TriFace>* triangles; - //for transfer - std::string filename; - bool transferViaFilename; - double transX1; - double transX2; - double transX3; - - double x1min; - double x1max; - double x2min; - double x2max; - double x3min; - double x3max; - double x1center; - double x2center; - double x3center; - - bool consistent; - - bool buildVertTriRelationMap; - std::multimap<Vertex*,TriFace*> relationVertTris; - - Kd::Tree< double >* kdTree; -}; - -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - UB_AUTO_RUN_NAMED( SF::registerType<GbTriFaceMesh3D >("GbTriFaceMesh3D ") , SF_GbTriFaceMesh3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbTriFaceMesh3D >() ), SF_GbTriFaceMesh3D_BD1 ); -#endif //RCF_USE_SF_SERIALIZATION - -#endif //GBTRIFACEMESH3D_H diff --git a/src/basics/geometry3d/GbTriangle3D.cpp b/src/basics/geometry3d/GbTriangle3D.cpp index 0ac50c0f7..b9024aaf4 100644 --- a/src/basics/geometry3d/GbTriangle3D.cpp +++ b/src/basics/geometry3d/GbTriangle3D.cpp @@ -1,29 +1,43 @@ -#include <numerics/geometry3d/GbTriangle3D.h> -#include <numerics/geometry3d/creator/GbTriangle3DCreator.h> +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbTriangle3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= +#include <GbTriangle3D.h> +#include <GbSystem3D.h> +#include <GbLine3D.h> +#include <GbCuboid3D.h> #include <basics/utilities/UbMath.h> -#include <numerics/geometry3d/GbSystem3D.h> -#include <numerics/geometry3d/GbLine3D.h> -#include <numerics/geometry3d/GbCuboid3D.h> -//#include <numerics/geometry3d/GbPolygon3D.h> - -using namespace std; - -ObObjectCreator* GbTriangle3D::getCreator() -{ - return GbTriangle3DCreator::getInstance(); -} - -/*=========================================================================*/ -/* GbTriangle3D */ -/* */ -/* -* This Class provides basic 3D triangle objects. -* The describing points are observed by 2D triangle objects. -* <BR><BR><HR> -* @version 1.0 - 24.01.05 -*/ +using namespace std; GbTriangle3D::GbTriangle3D() { @@ -245,42 +259,6 @@ void GbTriangle3D::setPoint(GbPoint3D* point, int index) this->calculateNormal(); } -/* -* Returns true if this 2D triangle equals the specified object. -* Two triangle are equal, if their points are equal. -* <BR>Note that the order of points is not recognized! -* @return true if this 2D triangle equals the specified object -* @see GbPoint2D#equals(java.lang.Object) -* @see GbPoint3D#equals(java.lang.Object) -*/ -//bool equals(GbObject3D *object) -//{ -// try -// { -// GbTriangle3D *triangle = (GbTriangle3D*) object; - -//if(this.points[0].equals(triangle.points[0])) -//{ -// if(this.points[1].equals(triangle.points[1]) && this.points[2].equals(triangle.points[2])) return(true); -// if(this.points[1].equals(triangle.points[2]) && this.points[2].equals(triangle.points[1])) return(true); -// return(false); -//} -//else if(this.points[0].equals(triangle.points[1])) -//{ -// if(this.points[1].equals(triangle.points[0]) && this.points[2].equals(triangle.points[2])) return(true); -// if(this.points[1].equals(triangle.points[2]) && this.points[2].equals(triangle.points[0])) return(true); -// return(false); -//} -//else if(this.points[0].equals(triangle.points[2])) -//{ -// if(this.points[1].equals(triangle.points[0]) && this.points[2].equals(triangle.points[1])) return(true); -// if(this.points[1].equals(triangle.points[1]) && this.points[2].equals(triangle.points[0])) return(true); -// return(false); -//} -//return(false); -// } -// catch(Exception e){ return(false); } -// } /* * Returns the surface triangle set with new nodes !!! * @returns the surface triangle set with new nodes !!! @@ -366,32 +344,6 @@ double GbTriangle3D::getIntersectionRaytraceFactor(const double& x1, const doubl return f * (e2x1*qx1 + e2x2*qx2 + e2x3*qx3); } -/*======================================================================*/ -/* Calculation */ -/* */ -/* -* Returns the intersection points of this 2D triangle and the specified 2D line. -* @param line the 2D line to intersect -* @return the intersection points of this 2D triangle and the specified 2D line -*/ -/* -vector<GbPoint3D> GbTriangle3D::calculateIntersectionPoints3D(GbLine3D *line) -{ -//throw UbException(UB_EXARGS,"not yet implemented"); - -GbSystem::PointSet3 pointSet(0); -GbPoint3D *pCrossed = NULL; - -pCrossed = GbSystem::calculateIntersectionPoint3D(*this->points[0], *this->points[1], *line->getPoint1(), *line->getPoint2()); -if(pCrossed != NULL) pointSet.addUnequal(pCrossed); -pCrossed = GbSystem::calculateIntersectionPoint3D(*this->points[1], *this->points[2], *line->getPoint1(), *line->getPoint2()); -if(pCrossed != NULL) pointSet.addUnequal(pCrossed); -pCrossed = GbSystem::calculateIntersectionPoint3D(*this->points[2], *this->points[0], *line->getPoint1(), *line->getPoint2()); -if(pCrossed != NULL) pointSet.addUnequal(pCrossed); -//vector<GbPoint3D> points = pointSet->getPoints(); -return(pointSet.getPoints()); -} -*/ /*===========================================================*/ GbLine3D* GbTriangle3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2) @@ -900,31 +852,6 @@ void GbTriangle3D::calculateValues() /*======================================================================*/ -/*======================================================================*/ -//class PointObserver : public UbObserver -//{ -// GbTriangle3D *triangle; - -// PointObserver(GbTriangle3D *triangle) -// { -// this->triangle = triangle; -// } - -//public: -// void objectChanged(GbObject3D *object) -// { -// if(object == this->triangle->points[0] || object == this->triangle->points[1] || object == this->triangle->points[2]) -// { -// this->triangle->consistent = false; -// this->triangle->notifyObservers(); -// } -// } -//}; -//bool GbTriangle3D::isPointOnEdge(GbVector3D& q) -//{ -////cout<<"muss einer machen ...\n"; -// return false; -//} /*======================================================================*/ GbVector3D GbTriangle3D::getNormal() { @@ -946,32 +873,6 @@ void GbTriangle3D::init() points.resize(3,NULL); } /*=======================================================*/ -void GbTriangle3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - if(points[0]) points[0]->write(out); - else {GbPoint3D tmp; tmp.write(out);} - if(points[1]) points[1]->write(out); - else {GbPoint3D tmp; tmp.write(out);} - if(points[2]) points[2]->write(out); - else {GbPoint3D tmp; tmp.write(out);} -} -/*=======================================================*/ -void GbTriangle3D::read(UbFileInput* in) -{ - this->deletePoints(); - points[0] = new GbPoint3D; - points[1] = new GbPoint3D; - points[2] = new GbPoint3D; - in->readString(); - points[0]->read(in); - in->readString(); - points[1]->read(in); - in->readString(); - points[2]->read(in); - consistent = false; -} -/*=======================================================*/ void GbTriangle3D::calculateNormal() { GbPoint3D*& a = points[0]; diff --git a/src/basics/geometry3d/GbTriangle3D.h b/src/basics/geometry3d/GbTriangle3D.h index 276652b40..61a8f5ff5 100644 --- a/src/basics/geometry3d/GbTriangle3D.h +++ b/src/basics/geometry3d/GbTriangle3D.h @@ -1,21 +1,43 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbTriangle3D.h +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef GBTRIANGLE3D_H #define GBTRIANGLE3D_H #include <sstream> -#include <numerics/geometry3d/GbObject3D.h> -#include <numerics/geometry3d/GbVector3D.h> -#include <numerics/geometry3d/GbPoint3D.h> - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF +#include <GbObject3D.h> +#include <GbVector3D.h> +#include <GbPoint3D.h> #include <PointerDefinitions.h> @@ -23,13 +45,14 @@ class GbCuboid3D; class GbPolygon3D; class GbObject3DCreator; -/*=========================================================================*/ -/* GbTriangle3D */ -/* */ -/* -* This Class provides basic 3D triangle objects. -*/ -//class GbLine2D; +////////////////////////////////////////////////////////////////////////// +//! +//! \class GbTriangle3D +//! +//! \brief This Class provides basic 3D triangle objects. +//! \details The describing points are observed by 2D triangle objects. +//! +////////////////////////////////////////////////////////////////////////// class GbTriangle3D : public GbObject3D , public UbObserver { @@ -101,9 +124,6 @@ public: double getDistanceFromPoint(GbVector3D punct); std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); /*======================================================================*/ /* Calculation */ @@ -140,27 +160,6 @@ public: /* */ virtual void calculateValues(); - /*======================================================================*/ - //class PointObserver : public UbObserver - //{ - // GbTriangle3D *triangle; - - // PointObserver(GbTriangle3D *triangle) - // { - // this->triangle = triangle; - // } - - //public: - // void objectChanged(GbObject3D *object) - // { - // if(object == this->triangle->points[0] || object == this->triangle->points[1] || object == this->triangle->points[2]) - // { - // this->triangle->consistent = false; - // this->triangle->notifyObservers(); - // } - // } - //}; - /*======================================================================*/ //virtuelle Methoden von UbObserver //!! quick and dirty von sirann !! @@ -193,28 +192,6 @@ public: } using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & points; - ar & normal; - ar & x1s; - ar & x2s; - ar & x3s; - ar & x1min; - ar & x1max; - ar & x2min; - ar & x2max; - ar & x3min; - ar & x3max; - ar & area; - ar & consistent; - if( ArchiveTools::isReading(ar) ) this->calculateNormal(); - } -#endif //CAB_RCF - protected: bool consistent; double x1s; @@ -236,10 +213,4 @@ private: }; /*=========================================================================*/ -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - UB_AUTO_RUN_NAMED( SF::registerType<GbTriangle3D >("GbTriangle3D ") , SF_GbTriangle3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbTriangle3D >() ), SF_GbTriangle3D_BD1 ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< UbObserver, GbTriangle3D>() ), SF_GbTriangle3D_BD2 ); -#endif //RCF_USE_SF_SERIALIZATION - #endif diff --git a/src/basics/geometry3d/GbTriangularMesh3D.cpp b/src/basics/geometry3d/GbTriangularMesh3D.cpp deleted file mode 100644 index 9006ca690..000000000 --- a/src/basics/geometry3d/GbTriangularMesh3D.cpp +++ /dev/null @@ -1,1535 +0,0 @@ -#include <numerics/geometry3d/GbTriangularMesh3D.h> -#include <numerics/geometry3d/creator/GbTriangularMesh3DCreator.h> - -#include <map> - -#include <basics/utilities/UbMath.h> - -#include <numerics/geometry3d/GbHalfSpace3D.h> -#include <numerics/geometry3d/GbCuboid3D.h> -#include <numerics/geometry3d/CoordinateTransformation3D.h> - -using namespace std; - -GbTriangularMesh3D::GbTriangularMesh3D() : GbObject3D() -{ - this->setName("new GbMesh"); - this->nodes = new vector<GbPoint3D*>; - this->triangles = new vector<GbTriangle3D*>; - this->edges = new vector<GbLine3D*>; - - this->pointinobjecttest = RAYCROSSING; - - this->consistent = false; - x1min = x1max = x2min = x2max = x3min = x3max = 0.0; -} -/*=============================================================================================*/ -GbTriangularMesh3D::GbTriangularMesh3D(string name, vector<GbPoint3D*> *nodes, vector<GbTriangle3D*> *triangles) : GbObject3D() -{ - if(name.size()==0 ) throw UbException(UB_EXARGS,"no name specified"); - if(!nodes ) throw UbException(UB_EXARGS,"no nodes specified"); - if(!triangles ) throw UbException(UB_EXARGS,"no triangles specified"); - - this->setName(name); - this->nodes = nodes; - this->triangles = triangles; - this->edges = new vector<GbLine3D*>; - this->pointinobjecttest = RAYCROSSING; - - this->consistent = false; - x1min = x1max = x2min = x2max = x3min = x3max = 0.0; -} -/*=============================================================================================*/ -GbTriangularMesh3D::GbTriangularMesh3D(string name, vector<GbTriangle3D*> *tris) : GbObject3D() -{ - cout<<"Das Teil erzeugt seinen KnotenVector aus den Dreiecken ...\n Es sollte deleteRedundantNodes() aufgerufen werden \n"; - if(name.size()==0 ) throw UbException(UB_EXARGS,"no name specified"); - if(!tris ) throw UbException(UB_EXARGS,"no triangles specified"); - - vector<GbPoint3D*> *points = new vector<GbPoint3D*>; - this->triangles = new vector<GbTriangle3D*>; - GbPoint3D* p1 = NULL; - GbPoint3D* p2 = NULL; - GbPoint3D* p3 = NULL; - for(int u=0;u<(int)tris->size();u++) - { - if(UbMath::zero((*tris)[u]->getArea())) - { - (*tris)[u]->finalize(); - delete (*tris)[u]; - (*tris)[u] = NULL; - continue; - } - this->triangles->push_back((*tris)[u]); - p1 = (*tris)[u]->getPoint1(); - p2 = (*tris)[u]->getPoint2(); - p3 = (*tris)[u]->getPoint3(); - points->push_back(p1); - points->push_back(p2); - points->push_back(p3); - } - - this->setName(name); - this->nodes = points; - //this->triangles = triangles; - this->edges = new vector<GbLine3D*>; - this->edges->resize(0, NULL); - this->pointinobjecttest = RAYCROSSING; - - this->consistent = false; - x1min = x1max = x2min = x2max = x3min = x3max = 0.0; -} -/*=============================================================================================*/ -GbTriangularMesh3D::GbTriangularMesh3D(string name, vector<GbPoint3D*> *nodes, vector<GbLine3D*> *edges, vector<GbTriangle3D*> *triangles) : GbObject3D() -{ - if(name.size()==0) throw UbException(UB_EXARGS,"no name specified"); - if(!nodes ) throw UbException(UB_EXARGS,"no nodes specified"); - if(!triangles ) throw UbException(UB_EXARGS,"no triangles specified"); - if(!edges ) throw UbException(UB_EXARGS,"no edges specified"); - - this->setName(name); - this->nodes = nodes; - this->edges = edges; - this->triangles = triangles; - this->pointinobjecttest = RAYCROSSING; - - this->consistent = false; - x1min = x1max = x2min = x2max = x3min = x3max = 0.0; -} -/*=============================================================================================*/ -GbTriangularMesh3D::~GbTriangularMesh3D() -{ - if( this->nodes ) - { - for(unsigned u=0; u<nodes->size(); u++) delete (*nodes)[u]; - delete nodes; - } - if(triangles) - { - for(unsigned u=0; u<triangles->size(); u++) delete (*triangles)[u]; - delete triangles; - } -} -/*======================================================================*/ -ObObjectCreator* GbTriangularMesh3D::getCreator() -{ - return GbTriangularMesh3DCreator::getInstance(); -} -/*======================================================================*/ -void GbTriangularMesh3D::deleteRedundantNodes() -{ - std::map<GbPoint3D*,GbTriangle3D*> pointTriMap; - GbPoint3D* p1 = NULL; - GbPoint3D* p2 = NULL; - GbPoint3D* p3 = NULL; - GbTriangle3D* tri = NULL; - - for(int u=0;u<(int)this->triangles->size();u++) - { - tri = (*this->triangles)[u]; - p1 = tri->getPoint1(); - p2 = tri->getPoint2(); - p3 = tri->getPoint3(); - pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p1,tri)); - pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p2,tri)); - pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p3,tri)); - } - - cout<<"Nodes before deleting redundant:"<<this->nodes->size()<<endl; - GbPoint3D* pA = NULL; - GbPoint3D* pB = NULL; - std::map<GbPoint3D*,GbTriangle3D*>::iterator mapIterator; - for(int u=0;u<(int)this->nodes->size();u++) - { - //cout<<u<<" von "<<this->nodes->size()<<endl; - pA = (*this->nodes)[u]; - if(pA==NULL) continue; - for(int w=u+1;w<(int)this->nodes->size();w++) - { - // cout<<w<<" Wvon "<<this->nodes->size()<<endl; - pB = (*this->nodes)[w]; - if(pB==NULL) continue; - if(pA->equals(pB)) - { - //doppelter Knoten ... - mapIterator = pointTriMap.find(pB); - tri = dynamic_cast<GbTriangle3D*>(mapIterator->second); - if(!tri) throw UbException(UB_EXARGS,"triangle not found"); - p1 = tri->getPoint1(); - p2 = tri->getPoint2(); - p3 = tri->getPoint3(); - if(pB==p1) tri->setPoint(pA, 0); - else if(pB==p2) tri->setPoint(pA, 1); - else if(pB==p3) tri->setPoint(pA, 2); - else throw UbException(UB_EXARGS,"node should be there"); - delete pB; - (*this->nodes)[w] = NULL; - } - } - } - vector<GbPoint3D*> *points = new vector<GbPoint3D*>; - for(int u=0;u<(int)this->nodes->size();u++) - { - pA = (*this->nodes)[u]; - if(pA!=NULL) points->push_back(pA); - } - delete this->nodes; - this->nodes = points; - cout<<"Nodes after deleting redundant:"<<this->nodes->size()<<endl; - - -//nochmal kontrolle ... - pointTriMap.clear(); - for(int u=0;u<(int)this->triangles->size();u++) - { - tri = (*this->triangles)[u]; - p1 = tri->getPoint1(); - p2 = tri->getPoint2(); - p3 = tri->getPoint3(); - pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p1,tri)); - pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p2,tri)); - pointTriMap.insert(pair<GbPoint3D*,GbTriangle3D*>(p3,tri)); - } - for(int u=0;u<(int)this->nodes->size();u++) - { - pA = (*this->nodes)[u]; - if(pA==NULL) throw UbException(UB_EXARGS,"sollte kein NULL pointer sein ..."); - mapIterator = pointTriMap.find(pA); - tri = dynamic_cast<GbTriangle3D*>(mapIterator->second); - if(!tri) throw UbException(UB_EXARGS,"triangle not found"); - } -} -/*======================================================================*/ -void GbTriangularMesh3D::translate(const double& x1, const double& x2, const double& x3) -{ - GbPoint3D* pt; - for(int u=0;u<(int)this->nodes->size();u++) - { - pt = (*nodes)[u]; - pt->setX1(pt->getX1Coordinate()+x1); - pt->setX2(pt->getX2Coordinate()+x2); - pt->setX3(pt->getX3Coordinate()+x3); - } - this->consistent = false; -} -/*======================================================================*/ -void GbTriangularMesh3D::rotate(const double& alpha, const double& beta, const double& gamma) -{ - if(!this->consistent) this->calculateValues(); - double a1 = this->getX1Centroid(); - double a2 = this->getX2Centroid(); - double a3 = this->getX3Centroid(); - CoordinateTransformation3D trafoFor(a1, a2, a3, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0); - CoordinateTransformation3D trafoBack(a1, a2, a3, 1.0, 1.0, 1.0, alpha, beta, gamma); - - vector<GbPoint3D*> points; - GbPoint3D* p1 = NULL; - GbPoint3D* p2 = NULL; - GbPoint3D* p3 = NULL; - for(int u=0;u<(int)this->triangles->size();u++) - { - p1 = (*triangles)[u]->getPoint1(); - p2 = (*triangles)[u]->getPoint2(); - p3 = (*triangles)[u]->getPoint3(); - double p1x1 = trafoFor.transformForwardToX1Coordinate(p1->x1, p1->x2, p1->x3); - double p1x2 = trafoFor.transformForwardToX2Coordinate(p1->x1, p1->x2, p1->x3); - double p1x3 = trafoFor.transformForwardToX3Coordinate(p1->x1, p1->x2, p1->x3); - double p2x1 = trafoFor.transformForwardToX1Coordinate(p2->x1, p2->x2, p2->x3); - double p2x2 = trafoFor.transformForwardToX2Coordinate(p2->x1, p2->x2, p2->x3); - double p2x3 = trafoFor.transformForwardToX3Coordinate(p2->x1, p2->x2, p2->x3); - double p3x1 = trafoFor.transformForwardToX1Coordinate(p3->x1, p3->x2, p3->x3); - double p3x2 = trafoFor.transformForwardToX2Coordinate(p3->x1, p3->x2, p3->x3); - double p3x3 = trafoFor.transformForwardToX3Coordinate(p3->x1, p3->x2, p3->x3); - p1->x1 = trafoBack.transformBackwardToX1Coordinate(p1x1, p1x2, p1x3); - p1->x2 = trafoBack.transformBackwardToX2Coordinate(p1x1, p1x2, p1x3); - p1->x3 = trafoBack.transformBackwardToX3Coordinate(p1x1, p1x2, p1x3); - p2->x1 = trafoBack.transformBackwardToX1Coordinate(p2x1, p2x2, p2x3); - p2->x2 = trafoBack.transformBackwardToX2Coordinate(p2x1, p2x2, p2x3); - p2->x3 = trafoBack.transformBackwardToX3Coordinate(p2x1, p2x2, p2x3); - p3->x1 = trafoBack.transformBackwardToX1Coordinate(p3x1, p3x2, p3x3); - p3->x2 = trafoBack.transformBackwardToX2Coordinate(p3x1, p3x2, p3x3); - p3->x3 = trafoBack.transformBackwardToX3Coordinate(p3x1, p3x2, p3x3); - } - this->calculateValues(); -} -/*======================================================================*/ - /** - * Returns a string representation of this triangular mesh. - * @return a string representation of this triangular mesh - */ -string GbTriangularMesh3D::toString() -{ - stringstream ss; - ss<<"GbTriangularMesh3D["; - ss<<(int)this->triangles->size()<<"-Triangles, "<<(int)this->nodes->size()<<"-Nodes, "<<(int)this->edges->size()<<"-Edges"<<endl; - //ss<<"\""<<this->name<<", Area=sollt mal berechnet werden ;-)"<<"\""; - //ss<<", x1min="<<this->x1min; - //ss<<", x1max="<<this->x1max; - //ss<<", x2min="<<this->x2min; - //ss<<", x2max="<<this->x2max; - //ss<<", x3min="<<this->x3min; - //ss<<", x3max="<<this->x3max; - ss<<"]"; - return(ss.str()); -} -/** - * Returns the name of this triangular mesh. - * @return the name of this triangular mesh - */ -//string GbTriangularMesh3D::getName(){ return(this->name); } - -/** - * Returns the nodes of this triangular mesh. - * @return the nodes of this triangular mesh - */ -vector<GbPoint3D*>* GbTriangularMesh3D::getNodes() { return(this->nodes); } -/** - * Returns the triangles of this triangular mesh. - * @return the triangles of this triangular mesh - */ -vector<GbTriangle3D*>* GbTriangularMesh3D::getTriangles() { return(this->triangles); } -/** - * Returns the center x1 coordinate of this triangular mesh. - * @return the center x1 coordinate of this triangular mesh - */ -double GbTriangularMesh3D::getX1Centroid() -{ - if(!this->consistent) this->calculateValues(); - return(0.5*(this->x1min+this->x1max)); -} -/** - * Returns the center x2 coordinate of this triangular mesh. - * @return the center x2 coordinate of this triangular mesh - */ -double GbTriangularMesh3D::getX2Centroid() -{ - if(!this->consistent) this->calculateValues(); - return(0.5*(this->x2min+this->x2max)); -} -/** -* Returns the center x3 coordinate of this triangular mesh. - * @return the center x3 coordinate of this triangular mesh - */ -double GbTriangularMesh3D::getX3Centroid() -{ - if(!this->consistent) this->calculateValues(); - return(0.5*(this->x3min+this->x3max)); -} - -/** - * Returns the minimum x1 coordinate of this triangular mesh. - * @return the minimum x1 coordinate of this triangular mesh - */ -double GbTriangularMesh3D::getX1Minimum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x1min); -} -/** - * Returns the maximum x1 coordinate of this triangular mesh. - * @return the maximum x1 coordinate of this triangular mesh - */ -double GbTriangularMesh3D::getX1Maximum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x1max); -} -/** - * Returns the minimum x2 coordinate of this triangular mesh. - * @return the minimum x2 coordinate of this triangular mesh - */ -double GbTriangularMesh3D::getX2Minimum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x2min); -} -/** - * Returns the maximum x2 coordinate of this triangular mesh. - * @return the maximum x2 coordinate of this triangular mesh - */ -double GbTriangularMesh3D::getX2Maximum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x2max); -} -/** - * Returns the minimum x3 coordinate of this triangular mesh. - * @return the minimum x3 coordinate of this triangular mesh - */ -double GbTriangularMesh3D::getX3Minimum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x3min); -} -/** - * Returns the maximum x3 coordinate of this triangular mesh. - * @return the maximum x3 coordinate of this triangular mesh - */ -double GbTriangularMesh3D::getX3Maximum() -{ - if(!this->consistent) this->calculateValues(); - return(this->x3max); -} - -void GbTriangularMesh3D::calculateValues() -{ - double x1, x2, x3; - - this->x1min = (*this->nodes)[0]->getX1Coordinate(); - this->x1max = (*this->nodes)[0]->getX1Coordinate(); - this->x2min = (*this->nodes)[0]->getX2Coordinate(); - this->x2max = (*this->nodes)[0]->getX2Coordinate(); - this->x3min = (*this->nodes)[0]->getX3Coordinate(); - this->x3max = (*this->nodes)[0]->getX3Coordinate(); - - for(int i=1; i<(int)this->nodes->size(); i++) - { - x1 = (*this->nodes)[i]->getX1Coordinate(); - x2 = (*this->nodes)[i]->getX2Coordinate(); - x3 = (*this->nodes)[i]->getX3Coordinate(); - if(x1 < this->x1min) this->x1min = x1; - if(x1 > this->x1max) this->x1max = x1; - if(x2 < this->x2min) this->x2min = x2; - if(x2 > this->x2max) this->x2max = x2; - if(x3 < this->x3min) this->x3min = x3; - if(x3 > this->x3max) this->x3max = x3; - } - this->consistent = true; -} - -/** - * Returns the total area of this triangular mesh. - * @return the total area of this triangular mesh - */ -double GbTriangularMesh3D::getArea() -{ - double area = 0.0; - for(int i=0; i<(int)this->triangles->size(); i++) area += (*this->triangles)[i]->getArea(); - return(area); -} -/** - * Returns the total volume of this triangular mesh. - * @return the total volume of this triangular mesh - */ -double GbTriangularMesh3D::getVolume() -{ - GbTriangle3D* triangle; - GbPoint3D* p1; - GbPoint3D* p2; - GbPoint3D* p3; - - double x1,x2,x3,y1,y2,y3,z1,z2,z3; - double G3i; - double volume = 0.0; - int size = (int)this->triangles->size(); - for(int u=0; u<size;u++) - { - triangle = (*this->triangles)[u]; - p1 = triangle->getPoint1(); - p2 = triangle->getPoint2(); - p3 = triangle->getPoint3(); - x1 = p1->getX1Coordinate(); y1 = p1->getX2Coordinate(); z1 = p1->getX3Coordinate(); - x2 = p2->getX1Coordinate(); y2 = p2->getX2Coordinate(); z2 = p2->getX3Coordinate(); - x3 = p3->getX1Coordinate(); y3 = p3->getX2Coordinate(); z3 = p3->getX3Coordinate(); - G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3); - volume = volume+G3i/6.0; - } - return volume; -} -/*===============================================*/ -UbTupleDouble3 GbTriangularMesh3D::calculateCenterOfGravity() -{ - GbTriangle3D* triangle; - GbPoint3D* p1; - GbPoint3D* p2; - GbPoint3D* p3; - - double x1,x2,x3,y1,y2,y3,z1,z2,z3; - double G3i; - double rSP1 = 0.0;double rSP2 = 0.0;double rSP3 = 0.0; - double volume = 0.0; - int size = (int)this->triangles->size(); - for(int u=0; u<size;u++) - { - triangle = (*this->triangles)[u]; - p1 = triangle->getPoint1(); - p2 = triangle->getPoint2(); - p3 = triangle->getPoint3(); - x1 = p1->getX1Coordinate(); y1 = p1->getX2Coordinate(); z1 = p1->getX3Coordinate(); - x2 = p2->getX1Coordinate(); y2 = p2->getX2Coordinate(); z2 = p2->getX3Coordinate(); - x3 = p3->getX1Coordinate(); y3 = p3->getX2Coordinate(); z3 = p3->getX3Coordinate(); - G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3); - volume = volume+G3i/6.0; - rSP1 = rSP1+G3i*(x1+x2+x3); - rSP2 = rSP2+G3i*(y1+y2+y3); - rSP3 = rSP3+G3i*(z1+z2+z3); - } - rSP1 = rSP1/(24.0*volume); - rSP2 = rSP2/(24.0*volume); - rSP3 = rSP3/(24.0*volume); - - return UbTupleDouble3(rSP1, rSP2, rSP3); -} -/*===============================================*/ -UbTupleDouble6 GbTriangularMesh3D::calculateMomentOfInertia(double rhoP) -{ - GbTriangle3D* triangle; - GbPoint3D* p1; - GbPoint3D* p2; - GbPoint3D* p3; - - double x1,x2,x3,y1,y2,y3,z1,z2,z3; - double G3i; - double xx,yy,zz,xy,yz,zx; - double rSP1 = 0.0;double rSP2 = 0.0;double rSP3 = 0.0; - double volume = 0.0; - double top11 = 0.0;double top22 = 0.0;double top33 = 0.0; - double top12 = 0.0;double top23 = 0.0;double top13 = 0.0; - int size = (int)this->triangles->size(); - for(int u=0; u<size;u++) - { - triangle = (*this->triangles)[u]; - p1 = triangle->getPoint1(); - p2 = triangle->getPoint2(); - p3 = triangle->getPoint3(); - x1 = p1->getX1Coordinate(); y1 = p1->getX2Coordinate(); z1 = p1->getX3Coordinate(); - x2 = p2->getX1Coordinate(); y2 = p2->getX2Coordinate(); z2 = p2->getX3Coordinate(); - x3 = p3->getX1Coordinate(); y3 = p3->getX2Coordinate(); z3 = p3->getX3Coordinate(); - G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3); - volume = volume+G3i/6.0; - rSP1 = rSP1+G3i*(x1+x2+x3); - rSP2 = rSP2+G3i*(y1+y2+y3); - rSP3 = rSP3+G3i*(z1+z2+z3); - } - rSP1 = rSP1/(24.0*volume); - rSP2 = rSP2/(24.0*volume); - rSP3 = rSP3/(24.0*volume); - - double x1s = 0.0;//rSP1;//0.0;// - double x2s = 0.0;//rSP2;//0.0;// - double x3s = 0.0;//rSP3;//0.0;// - - for(int u=0; u<size;u++) - { - triangle = (*this->triangles)[u]; - p1 = triangle->getPoint1(); - p2 = triangle->getPoint2(); - p3 = triangle->getPoint3(); - x1 = p1->getX1Coordinate()-x1s; - y1 = p1->getX2Coordinate()-x2s; - z1 = p1->getX3Coordinate()-x3s; - x2 = p2->getX1Coordinate()-x1s; - y2 = p2->getX2Coordinate()-x2s; - z2 = p2->getX3Coordinate()-x3s; - x3 = p3->getX1Coordinate()-x1s; - y3 = p3->getX2Coordinate()-x2s; - z3 = p3->getX3Coordinate()-x3s; - G3i = x1*(y2*z3-z2*y3)+y1*(z2*x3-x2*z3)+z1*(x2*y3-y2*x3); - //rSP1 = rSP1+G3i*(x1+x2+x3)/(24.0*volume); - //rSP2 = rSP2+G3i*(y1+y2+y3)/(24.0*volume); - //rSP3 = rSP3+G3i*(z1+z2+z3)/(24.0*volume); - xx = x1*x1+x2*x2+x3*x3+x1*x2+x2*x3+x3*x1; - yy = y1*y1+y2*y2+y3*y3+y1*y2+y2*y3+y3*y1; - zz = z1*z1+z2*z2+z3*z3+z1*z2+z2*z3+z3*z1; - top11 = top11+(yy+zz)*rhoP*G3i/60.; - top22 = top22+(xx+zz)*rhoP*G3i/60.; - top33 = top33+(yy+xx)*rhoP*G3i/60.; - xy = 2.0*(x1*y1+x2*y2+x3*y3)+x2*y3+x3*y1+x1*y2+x3*y2+x1*y3+x2*y1; - yz = 2.0*(y1*z1+y2*z2+y3*z3)+y2*z3+y3*z1+y1*z2+y3*z2+y1*z3+y2*z1; - zx = 2.0*(z1*x1+z2*x2+z3*x3)+z2*x3+z3*x1+z1*x2+z3*x2+z1*x3+z2*x1; - top12 = top12-xy*rhoP*G3i/120.; - top23 = top23-yz*rhoP*G3i/120.; - top13 = top13-zx*rhoP*G3i/120.; - } - //Satz von Steiner ... - top11 = top11-rhoP*volume*(rSP2*rSP2+rSP3+rSP3); - top22 = top22-rhoP*volume*(rSP3*rSP3+rSP1*rSP1); - top33 = top33-rhoP*volume*(rSP1*rSP1+rSP2*rSP2); - top12 = top12+rhoP*volume*rSP1*rSP2; - top23 = top23+rhoP*volume*rSP2*rSP3; - top13 = top13+rhoP*volume*rSP3*rSP1; - - cout<<"Volume:"<<volume<<"\n Traegheitsmomente:\n"; - cout<<" top11:"<<top11<<" top22:"<<top22<<" top33:"<<top33<<endl; - cout<<" top12:"<<top12<<" top23:"<<top23<<" top13:"<<top13<<endl; - - return UbTupleDouble6(top11,top22,top33,top12,top23,top13); -} - - /** - * Returns the volume of this triangular mesh within the specified rectangle. - * @param p1x1 the 1st x1 coordinate of the rectangle - * @param p1x2 the 1st x2 coordinate of the rectangle - * @param p2x1 the 2nd x1 coordinate of the rectangle - * @param p2x2 the 2nd x2 coordinate of the rectangle - * @return the volume of this triangular mesh within the specified rectangle - * @exception NullPointerException if no triangles are found within the specified rectangle - */ -double GbTriangularMesh3D::getVolumeForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) -{ - throw UbException(UB_EXARGS,"not yet implemented"); - // GbPolygon2D polygon; - // double volume = 0.0; - // double area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2)); - // double area2 = 0.0; - // double t1min, t1max, t2min, t2max; - // double x1, x2; - // boolean f = false; - - // for(int i=0; i<this.triangles.length; i++) - // { - // t1min = this.triangles[i].getX1Minimum(); - // t1max = this.triangles[i].getX1Maximum(); - // if(GbSystem.less2(t1min, t1max, p1x1, p2x1)) continue; - // if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue; - - // t2min = this.triangles[i].getX2Minimum(); - // t2max = this.triangles[i].getX2Maximum(); - // if(GbSystem.less2(t2min, t2max, p1x2, p2x2)) continue; - // if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue; - - // if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) && - // GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2)) - // { - // volume += this.triangles[i].getVolume(); - // area2 += this.triangles[i].getArea(); - // f = true; - // } - // else - // { - // polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2); - - // if(polygon != null && polygon.size() > 2) - // { - // try - // { - // x1 = polygon.getX1Centroid(); - // x2 = polygon.getX2Centroid(); - // volume += this.triangles[i].getX3Coordinate(x1, x2) * Math.abs(polygon.getArea()); - // area2 += Math.abs(polygon.getArea()); - // f = true; - // } - // catch(Exception e){} - // } - // } - // if(GbSystem.greaterEqual(area2, area1)) break; - //} - // if(f) return(volume); - // else throw new NullPointerException(); -} - -/** - * Returns the triangles of this triangular mesh located within the specified rectangle (may be an empty array). - * @param p1x1 the 1st x1 coordinate of the rectangle - * @param p1x2 the 1st x2 coordinate of the rectangle - * @param p2x1 the 2nd x1 coordinate of the rectangle - * @param p2x2 the 2nd x2 coordinate of the rectangle - * @return the triangles of this triangular mesh located within the specified rectangle - */ -vector<GbTriangle3D*>* GbTriangularMesh3D::getTrianglesForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) -{ - throw UbException(UB_EXARGS,"not yet implemented"); - // QbList triangleList = new QbList(GbTriangle3D.class); - // GbPolygon2D polygon; - // double t1min, t1max, t2min, t2max; - // double area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2)); - // double area2 = 0.0; - - // for(int i=0; i<this.triangles.length; i++) - // { - // t1min = this.triangles[i].getX1Minimum(); - // t1max = this.triangles[i].getX1Maximum(); - // if(GbSystem.less2(t1min, t1max, p1x1, p2x1)) continue; - // if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue; - - // t2min = this.triangles[i].getX2Minimum(); - // t2max = this.triangles[i].getX2Maximum(); - // if(GbSystem.less2(t2min, t2max, p1x2, p2x2)) continue; - // if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue; - - // if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) && - // GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2)) - // { - // try { triangleList.append(this.triangles[i]); } catch(Exception e){} - // area2 += this.triangles[i].getArea(); - // } - // else - // { - // polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2); - // if(polygon != null && polygon.size() > 2) - // { - // try { triangleList.append(this.triangles[i]); } catch(Exception e){} - // area2 += Math.abs(polygon.getArea()); - // } - // } - // if(GbSystem.greaterEqual(area2, area1)) break; - //} - // return((GbTriangle3D[])triangleList.getObjectArray()); -} -/** - * Returns the nodes of this triangular mesh located within the specified rectangle (may be an empty array). - * @param p1x1 the 1st x1 coordinate of the rectangle - * @param p1x2 the 1st x2 coordinate of the rectangle - * @param p2x1 the 2nd x1 coordinate of the rectangle - * @param p2x2 the 2nd x2 coordinate of the rectangle - * @return the nodes of this triangular mesh located within the specified rectangle - */ -vector<GbPoint3D*>* GbTriangularMesh3D::getNodesForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) -{ - throw UbException(UB_EXARGS,"not implemented"); -// QbList nodeList = new QbList(GbPoint3D.class); - - // for(int i=0; i<this.edges.length; i++) - // { - //if(GbSystem.inClosedInterval(this.nodes[i].getX1Coordinate(), p1x1, p2x1) && GbSystem.inClosedInterval(this.nodes[i].getX2Coordinate(), p1x2, p2x2)) - //{ - // try { nodeList.append(this.nodes[i]); } catch(Exception e){} - //} - // } - // return((GbPoint3D[])nodeList.getObjectArray()); -} - -/** - * Returns the difference of maximum and minimum x3 coordinates - * of this triangular mesh within the specified rectangle. - * @param p1x1 the 1st x1 coordinate of the rectangle - * @param p1x2 the 1st x2 coordinate of the rectangle - * @param p2x1 the 2nd x1 coordinate of the rectangle - * @param p2x2 the 2nd x2 coordinate of the rectangle - * @return the difference of maximum and minimum x3 coordinates of this triangular mesh within the specified rectangle - * @exception NullPointerException if no triangles are found within the specified rectangle - */ -double GbTriangularMesh3D::getX3RangeForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) -{ - throw UbException(UB_EXARGS,"not implemented"); - // GbPolygon3D polygon; - // boolean f = false; - // double x3min = 0.0; - // double x3max = 0.0; - // double t1min, t1max, t2min, t2max; - // double area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2)); - // double area2 = 0.0; - - // for(int i=0; i<this.triangles.length; i++) - // { - // t1min = this.triangles[i].getX1Minimum(); - // t1max = this.triangles[i].getX1Maximum(); - // if(GbSystem.less2(t1min, t1max, p1x1, p2x1)) continue; - // if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue; - - // t2min = this.triangles[i].getX2Minimum(); - // t2max = this.triangles[i].getX2Maximum(); - // if(GbSystem.less2(t2min, t2max, p1x2, p2x2)) continue; - // if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue; - - // if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) && - // GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2)) - // { - // if(f) - // { - // if(this.triangles[i].getX3Minimum() < x3min) x3min = this.triangles[i].getX3Minimum(); - // if(this.triangles[i].getX3Maximum() > x3max) x3max = this.triangles[i].getX3Maximum(); - // } - // else - // { - // x3min = this.triangles[i].getX3Minimum(); - // x3max = this.triangles[i].getX3Maximum(); - // f = true; - // } - // area2 += this.triangles[i].getArea(); - //} - // else - // { - // polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2); - - // if(polygon != null && polygon.size() > 2) - // { - // if(f) - // { - // if(polygon.getX3Minimum() < x3min) x3min = polygon.getX3Minimum(); - // if(polygon.getX3Maximum() > x3max) x3max = polygon.getX3Maximum(); - // } - // else - // { - // x3min = polygon.getX3Minimum(); - // x3max = polygon.getX3Maximum(); - // f = true; - // } - // area2 += Math.abs(polygon.getArea()); - // } - // } - // if(GbSystem.greaterEqual(area2, area1)) break; - // } - // if(f) return(x3max-x3min); - // else throw new NullPointerException(); -} -/** - * Returns the minimum x3 coordinates of this triangular mesh within the specified rectangle. - * @param p1x1 the 1st x1 coordinate of the rectangle - * @param p1x2 the 1st x2 coordinate of the rectangle - * @param p2x1 the 2nd x1 coordinate of the rectangle - * @param p2x2 the 2nd x2 coordinate of the rectangle - * @return the minimum x3 coordinates of this triangular mesh within the specified rectangle - * @exception NullPointerException if no triangles are found within the specified rectangle - */ -double GbTriangularMesh3D::getX3MinimumForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) -{ - throw UbException(UB_EXARGS,"not implemented"); - // GbPolygon3D polygon; - // boolean f = false; - // double x3min = 0.0; - // double t1min, t1max, t2min, t2max; - // double area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2)); - // double area2 = 0.0; - - // for(int i=0; i<this.triangles.length; i++) - // { - //t1min = this.triangles[i].getX1Minimum(); - //t1max = this.triangles[i].getX1Maximum(); - //if(GbSystem.less2(t1min, t1max, p1x1, p2x1)) continue; - //if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue; - - //t2min = this.triangles[i].getX2Minimum(); - //t2max = this.triangles[i].getX2Maximum(); - //if(GbSystem.less2(t2min, t2max, p1x2, p2x2)) continue; - //if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue; - - //if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) && - // GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2)) - //{ - // if(f) - // { - // if(this.triangles[i].getX3Minimum() < x3min) x3min = this.triangles[i].getX3Minimum(); - // } - // else - // { - // x3min = this.triangles[i].getX3Minimum(); - // f = true; - // } - // area2 += this.triangles[i].getArea(); - //} - //else - //{ - // polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2); - - // if(polygon != null && polygon.size() > 2) - // { - // if(f) - // { - // if(polygon.getX3Minimum() < x3min) x3min = polygon.getX3Minimum(); - // } - // else - // { - // x3min = polygon.getX3Minimum(); - // f = true; - // } - // area2 += Math.abs(polygon.getArea()); - // } - //} - //if(GbSystem.greaterEqual(area2, area1)) break; - // } - // if(f) return(x3min); - // else throw new NullPointerException(); -} -/** - * Returns the maximum x3 coordinates of this triangular mesh within the specified rectangle. - * @param p1x1 the 1st x1 coordinate of the rectangle - * @param p1x2 the 1st x2 coordinate of the rectangle - * @param p2x1 the 2nd x1 coordinate of the rectangle - * @param p2x2 the 2nd x2 coordinate of the rectangle - * @return the maximum x3 coordinates of this triangular mesh within the specified rectangle - * @exception NullPointerException if no triangles are found within the specified rectangle - */ -double GbTriangularMesh3D::getX3MaximumForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2) -{ - throw UbException(UB_EXARGS,"not implemented"); - // GbPolygon3D polygon; - // boolean f = false; - // double x3max = 0.0; - // double t1min, t1max, t2min, t2max; - // double area1 = Math.abs((p1x1-p2x1)*(p1x2-p2x2)); - // double area2 = 0.0; - - // for(int i=0; i<this.triangles.length; i++) - // { - //t1min = this.triangles[i].getX1Minimum(); - //t1max = this.triangles[i].getX1Maximum(); - //if(GbSystem.less2(t1min, t1max, p1x1, p2x1)) continue; - //if(GbSystem.greater2(t1min, t1max, p1x1, p2x1)) continue; - - //t2min = this.triangles[i].getX2Minimum(); - //t2max = this.triangles[i].getX2Maximum(); - //if(GbSystem.less2(t2min, t2max, p1x2, p2x2)) continue; - //if(GbSystem.greater2(t2min, t2max, p1x2, p2x2)) continue; - - //if(GbSystem.inOpenInterval(t1min, p1x1, p2x1) && GbSystem.inOpenInterval(t1max, p1x1, p2x1) && - // GbSystem.inOpenInterval(t2min, p1x2, p2x2) && GbSystem.inOpenInterval(t2max, p1x2, p2x2)) - //{ - // if(f) - // { - // if(this.triangles[i].getX3Maximum() < x3max) x3max = this.triangles[i].getX3Maximum(); - // } - // else - // { - // x3max = this.triangles[i].getX3Maximum(); - // f = true; - // } - // area2 += this.triangles[i].getArea(); - //} - //else - //{ - // polygon = this.triangles[i].createClippedPolygon3D(p1x1, p1x2, p2x1, p2x2); - - // if(polygon != null && polygon.size() > 2) - // { - // if(f) - // { - // if(polygon.getX3Maximum() < x3max) x3max = polygon.getX3Maximum(); - // } - // else - // { - // x3max = polygon.getX3Maximum(); - // f = true; - // } - // area2 += Math.abs(polygon.getArea()); - // } - //} - //if(GbSystem.greaterEqual(area2, area1)) break; - // } - // if(f) return(x3max); - // else throw new NullPointerException(); -} -/*======================================================================*/ -vector<GbTriangle3D*> GbTriangularMesh3D::getSurfaceTriangleSet() -{ - vector<GbTriangle3D*> tris; - GbTriangle3D* triangle; - GbPoint3D* p1; - GbPoint3D* p2; - GbPoint3D* p3; - int size = (int)this->triangles->size(); - for(int u=0; u<size;u++) - { - triangle = (*this->triangles)[u]; - p1 = new GbPoint3D(triangle->getPoint1()); - p2 = new GbPoint3D(triangle->getPoint2()); - p3 = new GbPoint3D(triangle->getPoint3()); - tris.push_back(new GbTriangle3D(p1, p2, p3)); - } - return tris; -} -/*======================================================================*/ -/* -* Function to determine if the point is inside the polyhedron defined as a 3D object -* using the Halfspace algorithm -* @param xp the x-coordinate of the point -* @param yp the y-coordinate of the point -* @param zp the z-coordinate of the point -* @return true if point is inside else return false -*/ -bool GbTriangularMesh3D::isPointInObject3DHalfSpace(const double& xp, const double& yp, const double& zp) -{ - vector<GbTriangle3D*> *Triangles = this->triangles; - int Trianglesize = (int)Triangles->size(); - //GbPoint3D Point(xp,yp,zp); - for (int i=0; i<Trianglesize; i++) - { - //GbPoint3D* point1 = (*Triangles)[i]->getPoint1(); - //GbPoint3D* point2 = (*Triangles)[i]->getPoint2(); - //GbPoint3D* point3 = (*Triangles)[i]->getPoint3(); - - //GbHalfSpace3D halfspace(point1, point2, point3); - GbHalfSpace3D halfspace((*Triangles)[i]); - if (halfspace.ptInside(xp,yp,zp)) return false; - } - return true; -} -/*======================================================================*/ -bool GbTriangularMesh3D::isPointInObject3DRayCrossing(const double& xp, const double& yp, const double& zp, int radius, int numVertices, int numTriangles) -{ - GbVector3D point(xp,yp,zp); - - if ( this->InPolyhedron(numTriangles, point, radius) ) return true; - else return false; - -} -/*======================================================================*/ -bool GbTriangularMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3) -{ - double xmin=this->getX1Minimum(); double xmax=this->getX1Maximum(); - double ymin=this->getX2Minimum(); double ymax=this->getX2Maximum(); - double zmin=this->getX3Minimum(); double zmax=this->getX3Maximum(); - double dX = (xmax-xmin)/100.; - double dY = (ymax-ymin)/100.; - double dZ = (zmax-zmin)/100.; - GbCuboid3D boundingCube(xmin-dX, ymin-dY, zmin-dZ, xmax+dX, ymax+dY, zmax+dZ); - if(!boundingCube.isPointInGbObject3D(x1, x2, x3)) { boundingCube.finalize(); return false; } - - // Halfspace algorithm, Area of spherical polygons algorithm or Ray crossing algorithm - GbVector3D bMin(boundingCube.getPoint1()); - GbVector3D bMax(boundingCube.getPoint2()); - - boundingCube.finalize(); - - bMin = bMax.Subtract(bMin); - int radius = (int)(bMin.Length()+1)+1; - - if(this->pointinobjecttest == HALFSPACE) return this->isPointInObject3DHalfSpace(x1,x2,x3); - else if(this->pointinobjecttest == RAYCROSSING) return this->isPointInObject3DRayCrossing(x1,x2,x3,radius,(int)this->nodes->size(),(int)this->triangles->size()); - else throw UbException(UB_EXARGS,"no ptInObjTest"); -} -/*======================================================================*/ -bool GbTriangularMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary) -{ - throw UbException(UB_EXARGS,"not implemented"); -} -/*======================================================================*/ -GbLine3D* GbTriangularMesh3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2) -{ - throw UbException(UB_EXARGS,"not implemented"); -} -/*======================================================================*/ -void GbTriangularMesh3D::writeMesh(string filename, WbWriter* writer, bool writeNormals) -{ - vector<UbTupleFloat3 > nodes(triangles->size()*3); - vector<UbTupleInt3 > tris(triangles->size()); - - for(size_t i=0; i<triangles->size(); i++) - { - GbTriangle3D& tri = *((*triangles)[i]); - GbPoint3D& node1 = *tri.getPoint(0); - GbPoint3D& node2 = *tri.getPoint(1); - GbPoint3D& node3 = *tri.getPoint(2); - - nodes[i*3 ] = makeUbTuple( (float)node1.getX1Coordinate() - ,(float)node1.getX2Coordinate() - ,(float)node1.getX3Coordinate()); - nodes[i*3+1] = makeUbTuple( (float)node2.getX1Coordinate() - ,(float)node2.getX2Coordinate() - ,(float)node2.getX3Coordinate()); - nodes[i*3+2] = makeUbTuple( (float)node3.getX1Coordinate() - ,(float)node3.getX2Coordinate() - ,(float)node3.getX3Coordinate()); - - tris[i] = makeUbTuple((int)i*3,(int)i*3+1,(int)i*3+2); - } - writer->writeTriangles(filename,nodes,tris); - - if(writeNormals) - { - vector<UbTupleFloat3 > lineNodes(triangles->size()*2); - vector<UbTupleInt2 > lines(triangles->size()); - for(size_t i=0; i<triangles->size(); i++) - { - GbVector3D vec = (*triangles)[i]->getNormal(); - lineNodes[i*2 ] = makeUbTuple( (float)(*triangles)[i]->getX1Centroid() - ,(float)(*triangles)[i]->getX2Centroid() - ,(float)(*triangles)[i]->getX3Centroid()); - lineNodes[i*2+1] = makeUbTuple( (float)((*triangles)[i]->getX1Centroid()+vec.X1()) - ,(float)((*triangles)[i]->getX2Centroid()+vec.X2()) - ,(float)((*triangles)[i]->getX3Centroid()+vec.X3())); - - lines[i] = makeUbTuple((int)i*2,(int)i*2+1); - } - writer->writeLines(filename+"_normals",lineNodes,lines); - } -} -/*======================================================================*/ -void GbTriangularMesh3D::writeAVSMesh(UbFileOutput *out, bool normals) -{ - cout<<" - write_ucd ("<<out->getFileName()<<") -> "; - if(!out) - { - cout<<"GbTriangularMesh3D::writeAVSMesh() - File konnte nicht geschrieben werden: "<<endl; - return; - } - out->writeLine("# UCD-File created by GbTriangularMesh3D"); - //vector<GbPoint3D*> *nodes = this->getNodes(); - vector<GbTriangle3D*> *triangles = this->getTriangles(); - //int nodesize = (int)nodes->size(); - int trianglesize = (int)triangles->size(); - int nodesize = trianglesize*3; - if(normals) - { - out->writeInteger(nodesize+trianglesize*2); - out->writeInteger(trianglesize*2); - } - else - { - out->writeInteger(nodesize); - out->writeInteger(trianglesize); - } - out->writeInteger(0); - out->writeInteger(0); - out->writeInteger(0); - out->writeLine(); - int nr=1; - GbPoint3D *node; - for(int i=0;i<trianglesize; i++) - { - node = (*triangles)[i]->getPoint(0); - out->writeInteger(nr++); - out->writeDouble(node->getX1Coordinate()); - out->writeDouble(node->getX2Coordinate()); - out->writeDouble(node->getX3Coordinate()); - out->writeLine(); - node = (GbPoint3D*)(*triangles)[i]->getPoint(1); - out->writeInteger(nr++); - out->writeDouble(node->getX1Coordinate()); - out->writeDouble(node->getX2Coordinate()); - out->writeDouble(node->getX3Coordinate()); - out->writeLine(); - node = (GbPoint3D*)(*triangles)[i]->getPoint(2); - out->writeInteger(nr++); - out->writeDouble(node->getX1Coordinate()); - out->writeDouble(node->getX2Coordinate()); - out->writeDouble(node->getX3Coordinate()); - out->writeLine(); - } - - if(normals) - { - for(int i=0;i<trianglesize; i++) - { - GbVector3D vec = (*triangles)[i]->getNormal(); - out->writeInteger(nr++); - out->writeDouble((*triangles)[i]->getX1Centroid()); - out->writeDouble((*triangles)[i]->getX2Centroid()); - out->writeDouble((*triangles)[i]->getX3Centroid()); - out->writeLine(); - out->writeInteger(nr++); - out->writeDouble((*triangles)[i]->getX1Centroid()+vec.X1()); - out->writeDouble((*triangles)[i]->getX2Centroid()+vec.X2()); - out->writeDouble((*triangles)[i]->getX3Centroid()+vec.X3()); - out->writeLine(); - } - } - nr=1; - int el=1; - for(int i=0;i<trianglesize; i++) - { - nr = 3*el-2; - out->writeInteger(el); - out->writeInteger(2); - out->writeString("tri"); - out->writeInteger(nr); - out->writeInteger(nr+1); - out->writeInteger(nr+2); - out->writeLine(); - el++; - } - if(normals) - { - nr = trianglesize*3+1; - for(int i=trianglesize;i<2*trianglesize; i++) - { - out->writeInteger(el); - out->writeInteger(2); - out->writeString("line"); - out->writeInteger(nr++); - out->writeInteger(nr++); - out->writeLine(); - el++; - } - } - cout<<"done\n"; -} - -/*======================================================================*/ -/* -This function returns a char: -'V': the query point a coincides with a Vertex of polyhedron P. -'E': the query point a is in the relative interior of an Edge of polyhedron P. -'F': the query point a is in the relative interior of a Face of polyhedron P. -'i': the query point a is strictly interior to polyhedron P. -'o': the query point a is strictly exterior to( or outside of) polyhedron P. -*/ -bool GbTriangularMesh3D::InPolyhedron( int F, GbVector3D& q, int radius ) -{ - GbVector3D r; /* Ray endpoint. */ - GbVector3D p; /* Intersection point; not used. */ - int f, k = 0, crossings = 0; - char code = '?'; - - while( k++ < F ) - { - crossings = 0; - - RandomRay( r, radius ); - r = q.Add(r); - // printf("Ray endpoint: (%d,%d,%d)\n", r[0],r[1],r[2] ); - - for ( f = 0; f < F; f++ ) /* Begin check each face */ - { - if( BoxTest( (*this->triangles)[f], q, r ) == false ) code = '0'; // printf("BoxTest = 0!\n"); - else code = SegTriInt( (*this->triangles)[f], q, r, p );// printf( "Face = %d: BoxTest/SegTriInt returns %c\n\n", f, code ); - - /* If ray is degenerate, then goto outer while to generate another. */ - if( code=='p' || code=='v' || code=='e' ) break; //goto LOOP; //printf("Degenerate ray\n"); - /* If ray hits face at interior point, increment crossings. */ - else if ( code=='f' ) crossings++; // printf( "crossings = %d\n", crossings ); - /* If query endpoint q sits on a V/E/F, return that code. */ - else if ( code=='V' || code=='E' || code=='F' ) return true; - /* If ray misses triangle, do nothing. */ - else if ( code=='0' ) { /*nothing to do*/ } - else throw UbException(UB_EXARGS,"Error" ); - } /* End check each face */ - - /* No degeneracies encountered: ray is generic, so finished. */ - if(f>=F) break; - } /* End while loop */ - - // printf( "Crossings = %d\n", crossings ); - /* q strictly interior to polyhedron iff an odd number of crossings. */ - if( (crossings%2) == 1 ) return true; - - return false; -} - -/* Return a random ray endpoint */ -void GbTriangularMesh3D::RandomRay( GbVector3D& ray, int radius ) -{ - double x, y, z, w, t; - - double MAX_INT = 2147483647; - /* Generate a random point on a sphere of radius 1. */ - /* the sphere is sliced at z, and a random point at angle t - generated on the circle of intersection. */ - z = 2.0 * (double) rand() / MAX_INT - 1.0; - t = 2.0 * UbMath::PI * (double) rand() / MAX_INT; - w = sqrt( 1 - z*z ); - x = w * cos( t ); - y = w * sin( t ); - - ray[0] = radius * x; - ray[1] = radius * y; - ray[2] = radius * z; - - /*printf( "RandomRay returns %6d %6d %6d\n", ray[X], ray[Y], ray[Z] );*/ -} - -/*--------------------------------------------------------------------- -'p': The segment lies wholly within the plane. -'q': The q endpoint is on the plane (but not 'p'). -'r': The r endpoint is on the plane (but not 'p'). -'0': The segment lies strictly to one side or the other of the plane. -'1': The segement intersects the plane, and 'p' does not hold. ----------------------------------------------------------------------*/ -char GbTriangularMesh3D::SegPlaneInt( GbTriangle3D* T, GbVector3D& q, GbVector3D& r, GbVector3D& p, int *m) -{ - // cout<<"SegPlaneInt..\n"; - GbVector3D N; double D; - GbVector3D rq; - double num, denom, t; - int i; - - *m = PlaneCoeff( T, N, &D ); - /*printf("m=%d; plane=(%lf,%lf,%lf,%lf)\n", m, N[X],N[Y],N[Z],D);*/ - num = D - q.Dot( N ); - rq = r.Subtract( q ); - denom = rq.Dot( N ); - /*printf("SegPlaneInt: num=%lf, denom=%lf\n", num, denom );*/ - - if ( denom == 0.0 ) { /* Segment is parallel to plane. */ - if ( num == 0.0 ) /* q is on plane. */ - //if (UbMath::zero(denom)) { /* Segment is parallel to plane. */ - // if ( UbMath::zero(num)) /* q is on plane. */ - return 'p'; - else - return '0'; - } - else - t = num / denom; - /*printf("SegPlaneInt: t=%lf \n", t );*/ - - for( i = 0; i < 3; i++ ) - p[i] = q[i] + t * ( r[i] - q[i] ); - - if ( (0.0 < t) && (t < 1.0) ) - return '1'; - else if ( num == 0.0 ) /* t == 0 */ - return 'q'; - else if ( num == denom ) /* t == 1 */ - return 'r'; - else return '0'; - - //if ( (0.0 < t) && (t < 1.0) ) - // return '1'; - //else if ( UbMath::zero(num)) /* t == 0 */ - // return 'q'; - //else if ( UbMath::equal(num , denom) ) /* t == 1 */ - // return 'r'; - //else return '0'; - -} -/*--------------------------------------------------------------------- -Computes N & D and returns index m of largest component. ----------------------------------------------------------------------*/ -int GbTriangularMesh3D::PlaneCoeff( GbTriangle3D* T, GbVector3D& N, double *D ) -{ - int i; - double t; /* Temp storage */ - double biggest = 0.0; /* Largest component of normal vector. */ - int m = 0; /* Index of largest component. */ - - N = T->getNormal(); - /*printf("PlaneCoeff: N=(%lf,%lf,%lf)\n", N[X],N[Y],N[Z]);*/ - GbVector3D a(T->getPoint1()); - - *D = a.Dot( N ); - - /* Find the largest component of N. */ - for ( i = 0; i < 3; i++ ) - { - t = std::fabs( N[i] ); - if ( t > biggest ) - { - biggest = t; - m = i; - } - } - return m; -} - -/* Assumption: p lies in the plane containing T. -Returns a char: -'V': the query point p coincides with a Vertex of triangle T. -'E': the query point p is in the relative interior of an Edge of triangle T. -'F': the query point p is in the relative interior of a Face of triangle T. -'0': the query point p does not intersect (misses) triangle T. -*/ - -char GbTriangularMesh3D::InTri3D( GbTriangle3D* T, int m, GbVector3D& p ) -{ -// int i; /* Index for X,Y,Z */ - int j; /* Index for X,Y */ -// int k; /* Index for triangle vertex */ - GbVector3D pp; /* projected p */ - GbVector3D Tp[3]; /* projected T: three new vertices */ - - /* Project out coordinate m in both p and the triangular face */ - //j = 0; - //for ( i = 0; i < 3; i++ ) { - // if ( i != m ) { /* skip largest coordinate */ - // pp[j] = p[i]; - // //for ( k = 0; k < 3; k++ ) - // std::cout<<"aachtung###############################################"; - // // Tp[k][j] = Vertices[T[k]][i]; - // j++; - // } - //} - j=0; - if(m!=0) - { - Tp[0][j] = T->getPoint1()->getX1Coordinate(); - Tp[1][j] = T->getPoint2()->getX1Coordinate(); - Tp[2][j] = T->getPoint3()->getX1Coordinate(); - j++; - } - if(m!=1) - { - Tp[0][j] = T->getPoint1()->getX2Coordinate(); - Tp[1][j] = T->getPoint2()->getX2Coordinate(); - Tp[2][j] = T->getPoint3()->getX2Coordinate(); - j++; - } - if(m!=2) - { - Tp[0][j] = T->getPoint1()->getX3Coordinate(); - Tp[1][j] = T->getPoint2()->getX3Coordinate(); - Tp[2][j] = T->getPoint3()->getX3Coordinate(); - j++; - } - - return( InTri2D( Tp, pp ) ); -} - -char GbTriangularMesh3D::InTri2D( GbVector3D Tp[3], GbVector3D& pp ) -{ - double area0, area1, area2; - - /* compute three AreaSign() values for pp w.r.t. each edge of the face in 2D */ - area0 = AreaSign( pp, Tp[0], Tp[1] ); - area1 = AreaSign( pp, Tp[1], Tp[2] ); - area2 = AreaSign( pp, Tp[2], Tp[0] ); - // printf("area0=%f area1=%f area2=%f\n",area0,area1,area2); - - if ( ( area0 == 0. ) && ( area1 > 0. ) && ( area2 > 0. ) || - ( area1 == 0. ) && ( area0 > 0. ) && ( area2 > 0. ) || - ( area2 == 0. ) && ( area0 > 0. ) && ( area1 > 0. ) ) - return 'E'; - - if ( ( area0 == 0. ) && ( area1 < 0. ) && ( area2 < 0. ) || - ( area1 == 0. ) && ( area0 < 0. ) && ( area2 < 0. ) || - ( area2 == 0. ) && ( area0 < 0. ) && ( area1 < 0. ) ) - return 'E'; - - if ( ( area0 > 0. ) && ( area1 > 0. ) && ( area2 > 0. ) || - ( area0 < 0. ) && ( area1 < 0. ) && ( area2 < 0. ) ) - return 'F'; - - if ( ( area0 == 0.0 ) && ( area1 == 0.0 ) && ( area2 == 0.0 ) ) - fprintf( stderr, "Error in InTriD\n" ), exit(EXIT_FAILURE); - - if ( ( area0 == 0. ) && ( area1 == 0. ) || - ( area0 == 0. ) && ( area2 == 0. ) || - ( area1 == 0. ) && ( area2 == 0. ) ) - return 'V'; - - else - return '0'; -} - -double GbTriangularMesh3D::AreaSign( GbVector3D& a, GbVector3D& b, GbVector3D& c ) -{ - double area2; - - area2 = ( b[0] - a[0] ) * ( c[1] - a[1] ) - - ( c[0] - a[0] ) * ( b[1] - a[1] ); - - return area2; - /* The area should be an integer. */ - if ( area2 > 0.5 ) return 1; - else if ( area2 < -0.5 ) return -1; - else return 0; -} - -char GbTriangularMesh3D::SegTriInt( GbTriangle3D* T, GbVector3D& q, GbVector3D& r, GbVector3D& p ) -{ - int code = '?'; - int m = -1; - - code = SegPlaneInt( T, q, r, p, &m ); - // printf("SegPlaneInt code=%c, m=%d; p=(%lf,%lf,%lf)\n", code,m,p[0],p[1],p[2]); - - if ( code == '0') return '0'; - else if ( code == 'q') return InTri3D( T, m, q ); - else if ( code == 'r') return InTri3D( T, m, r ); - else if ( code == 'p' ) return InPlane( T, m, q, r, p ); - else if ( code == '1' ) return SegTriCross( T, q, r ); - else /* Error */ return code; -} - -char GbTriangularMesh3D::InPlane( GbTriangle3D* T, int m, GbVector3D& q, GbVector3D& r, GbVector3D& p) -{ - // cout<<"inplane\n"; - /* NOT IMPLEMENTED */ - return 'p'; -} - -/*--------------------------------------------------------------------- -The signed volumes of three tetrahedra are computed, determined -by the segment qr, and each edge of the triangle. -Returns a char: -'v': the open segment includes a vertex of T. -'e': the open segment includes a point in the relative interior of an edge -of T. -'f': the open segment includes a point in the relative interior of a face -of T. -'0': the open segment does not intersect triangle T. ----------------------------------------------------------------------*/ - -char GbTriangularMesh3D::SegTriCross( GbTriangle3D* T, GbVector3D& q, GbVector3D& r ) -{ - // cout<<"SegTriCross\n"; - double vol0, vol1, vol2; - GbVector3D vert0(T->getPoint1()); - GbVector3D vert1(T->getPoint2()); - GbVector3D vert2(T->getPoint3()); - - vol0 = VolumeSign( q, vert0, vert1, r ); - vol1 = VolumeSign( q, vert1, vert2, r ); - vol2 = VolumeSign( q, vert2, vert0, r ); - - // printf( "SegTriCross: vol0 = %d; vol1 = %d; vol2 = %d\n", vol0, vol1, vol2 ); - - /* Same sign: segment intersects interior of triangle. */ - if ( ( ( vol0 > 0. ) && ( vol1 > 0. ) && ( vol2 > 0. ) ) || - ( ( vol0 < 0. ) && ( vol1 < 0. ) && ( vol2 < 0. ) ) ) - //if ( ( UbMath::greater(vol0, 0. ) && UbMath::greater(vol1 , 0. ) && UbMath::greater(vol2 , 0. ) ) || - // ( UbMath::less(vol0, 0. ) && UbMath::less(vol1, 0. ) && UbMath::less(vol2, 0. ) ) ) - { - return 'f'; - } - - /* Opposite sign: no intersection between segment and triangle */ - if ( ( ( vol0 > 0. ) || ( vol1 > 0. ) || ( vol2 > 0. ) ) && - ( ( vol0 < 0. ) || ( vol1 < 0. ) || ( vol2 < 0. ) ) ) - { - return '0'; - } - else if ( ( vol0 == 0.0 ) && ( vol1 == 0.0 ) && ( vol2 == 0.0 ) ) - { - std::cout<<vol0<<" "<<vol1<<" "<<vol2<<std::endl; - fprintf( stderr, "Error 1 in SegTriCross\n" ), exit(EXIT_FAILURE); - } - - /* Two zeros: segment intersects vertex. */ - else if ( ( ( vol0 == 0. ) && ( vol1 == 0. ) ) || - ( ( vol0 == 0. ) && ( vol2 == 0. ) ) || - ( ( vol1 == 0. ) && ( vol2 == 0. ) ) ) - { - return 'v'; - } - - /* One zero: segment intersects edge. */ - else if ( ( vol0 == 0. ) || ( vol1 == 0. ) || ( vol2 == 0. ) ) - { - return 'e'; - } - - throw UbException(UB_EXARGS,"fprintf( stderr, Error 2 in SegTriCross\n ), exit(EXIT_FAILURE);"); -} - - -double GbTriangularMesh3D::VolumeSign( GbVector3D& a, GbVector3D& b, GbVector3D& c, GbVector3D& d ) -{ - double vol; - double ax, ay, az, bx, by, bz, cx, cy, cz, dx, dy, dz; - double bxdx, bydy, bzdz, cxdx, cydy, czdz; - - ax = a[0]; ay = a[1]; az = a[2]; - bx = b[0]; by = b[1]; bz = b[2]; - cx = c[0]; cy = c[1]; cz = c[2]; - dx = d[0]; dy = d[1]; dz = d[2]; - - bxdx=bx-dx; - bydy=by-dy; - bzdz=bz-dz; - cxdx=cx-dx; - cydy=cy-dy; - czdz=cz-dz; - vol = (az-dz) * (bxdx*cydy - bydy*cxdx) - + (ay-dy) * (bzdz*cxdx - bxdx*czdz) - + (ax-dx) * (bydy*czdz - bzdz*cydy); - - //std::cout<< vol<<std::endl; - return vol; - - - /* The volume should be an integer. */ - if ( vol > 0.5 ) return 1; - else if ( vol < -0.5 ) return -1; - else return 0; -} - -bool GbTriangularMesh3D::BoxTest(GbTriangle3D* triangle, GbVector3D& PointQ, GbVector3D& PointR) -{ - double minX1 = triangle->getX1Minimum(); - double minX2 = triangle->getX2Minimum(); - double minX3 = triangle->getX3Minimum(); - - double maxX1 = triangle->getX1Maximum(); - double maxX2 = triangle->getX2Maximum(); - double maxX3 = triangle->getX3Maximum(); - - if((PointQ.X1() < minX1) && (PointR.X1() < minX1)) return false; - if((PointQ.X2() < minX2) && (PointR.X2() < minX2)) return false; - if((PointQ.X3() < minX3) && (PointR.X3() < minX3)) return false; - if((PointQ.X1() > maxX1) && (PointR.X1() > maxX1)) return false; - if((PointQ.X2() > maxX2) && (PointR.X2() > maxX2)) return false; - if((PointQ.X3() > maxX3) && (PointR.X3() > maxX3)) return false; - - return true; -} - diff --git a/src/basics/geometry3d/GbTriangularMesh3D.h b/src/basics/geometry3d/GbTriangularMesh3D.h deleted file mode 100644 index 8f3b6a46e..000000000 --- a/src/basics/geometry3d/GbTriangularMesh3D.h +++ /dev/null @@ -1,179 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBTRIANGULARMESH_H -#define GBTRIANGULARMESH_H - -#include <sstream> -#include <iostream> - - -#include <numerics/geometry3d/GbLine3D.h> -#include <numerics/geometry3d/GbPoint3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> -#include <numerics/geometry3d/GbVector3D.h> - -#include <basics/writer/WbWriter.h> - -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -#include <PointerDefinitions.h> - -/*=========================================================================*/ -/* GbTriangularMesh3D */ -/* */ -/** - * This Class provides the triangular meshes. - * Note, that up to now no methods for checking consistency are included. - * in this context this class describes facettes from an 3D-object !!! -*/ -class GbTriangularMesh3D : public GbObject3D -{ -public: - enum POINTINOBJECTTEST { RAYCROSSING, HALFSPACE}; - - GbTriangularMesh3D(); - GbTriangularMesh3D(std::string name, std::vector<GbPoint3D*> *nodes, std::vector<GbTriangle3D*> *triangles); - GbTriangularMesh3D(std::string name, std::vector<GbTriangle3D*> *triangles); - GbTriangularMesh3D(std::string name, std::vector<GbPoint3D*> *nodes, std::vector<GbLine3D*> *edges, std::vector<GbTriangle3D*> *triangles); - ~GbTriangularMesh3D(); - GbTriangularMesh3D* clone() { throw UbException(UB_EXARGS,"not implemented"); } - void finalize() - { - throw UbException("GbTriangularMesh3D::finalize() - toDo"); - } - void setPointInObjectTest(POINTINOBJECTTEST mode) { this->pointinobjecttest = mode; } - - std::string getClassName() {return "GbTriangularMesh3D"; } - - std::string toString(); - //std::string getName(); - std::vector<GbPoint3D*>* getNodes(); - std::vector<GbTriangle3D*>* getTriangles(); - double getX1Centroid(); - double getX2Centroid(); - double getX3Centroid(); - double getX1Minimum(); - double getX1Maximum(); - double getX2Minimum(); - double getX2Maximum(); - double getX3Minimum(); - double getX3Maximum(); - - void rotate(const double& alpha, const double& beta, const double& gamma); - void translate(const double& x1, const double& x2, const double& x3); - - void calculateValues(); - void deleteRedundantNodes(); - - UbTupleDouble6 calculateMomentOfInertia(double rhoP); - UbTupleDouble3 calculateCenterOfGravity(); - - double getArea(); - double getVolume(); - double getVolumeForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2); - std::vector<GbTriangle3D*>* getTrianglesForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2); - std::vector<GbPoint3D*>* getNodesForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2); - double getX3RangeForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2); - double getX3MinimumForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2); - double getX3MaximumForRectangle(const double& p1x1, const double& p1x2, const double& p2x1, const double& p2x2); - - virtual bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3); - - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3, bool& pointIsOnBoundary); - - bool isPointInObject3DHalfSpace(const double& xp, const double& yp, const double& zp); //based on Halfspace algorithm - bool isPointInObject3DSpherical(const double& xp, const double& yp, const double& zp, int numTriangles); //based on Spherical polygon area method - - //should be checked !!! - bool isPointInObject3DRayCrossing(const double& xp, const double& yp, const double& zp, int radius, int numVertices, int numTriangles); //based on Ray tracing algorithm - - bool InPolyhedron( int F, GbVector3D& q, int radius ); - void RandomRay( GbVector3D& ray, int radius ); - char SegPlaneInt( GbTriangle3D* Tri, GbVector3D& q, GbVector3D& r, GbVector3D& p, int *m); - int PlaneCoeff( GbTriangle3D* Tri, GbVector3D& Normal, double *D ); - char InTri3D( GbTriangle3D* T, int m, GbVector3D& p ); - char InTri2D( GbVector3D Tp[3], GbVector3D& pp ); - double AreaSign( GbVector3D& a, GbVector3D& b, GbVector3D& c ); - char SegTriInt(GbTriangle3D* Tri, GbVector3D& q, GbVector3D& r, GbVector3D& p ); - char InPlane( GbTriangle3D* T, int m, GbVector3D& q, GbVector3D& r, GbVector3D& p); - char SegTriCross( GbTriangle3D* T, GbVector3D& q, GbVector3D& r ); - double VolumeSign( GbVector3D& a, GbVector3D& b, GbVector3D& c, GbVector3D& d ); - bool BoxTest ( GbTriangle3D* triangle, GbVector3D& PointQ, GbVector3D& PointR); - //till here !!! - - - virtual GbLine3D* createClippedLine3D (GbPoint3D &point1,GbPoint3D &point2); - virtual std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - virtual ObObjectCreator* getCreator(); - - virtual void write(UbFileOutput* out) { std::cout<<"GbTriangularMesh3D::write - sorry not implemented\n"; } - virtual void read(UbFileInput* in) { std::cout<<"GbTriangularMesh3D::read - sorry not implemented\n"; } - - void writeMesh(std::string filename, WbWriter* writer, bool writeNormals=false); - void writeAVSMesh(UbFileOutput* out, bool normals=false); - - /*======================================================================*/ - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); - ar & triangles; - if(ArchiveTools::isWriting(ar)) - { - for(std::size_t t=0; t<triangles->size(); t++) - { - nodes->push_back((*triangles)[t]->getPoint(0)); - nodes->push_back((*triangles)[t]->getPoint(1)); - nodes->push_back((*triangles)[t]->getPoint(2)); - } - } - //ar & nodes; //<- problem redundanz - //ar & edges; - ar & pointinobjecttest; - ar & x1min; - ar & x1max; - ar & x2min; - ar & x2max; - ar & x3min; - ar & x3max; - ar & consistent; - } -#endif //CAB_RCF - -protected: - std::vector<GbPoint3D*>* nodes; - std::vector<GbLine3D*>* edges; - std::vector<GbTriangle3D*>* triangles; - -private: - POINTINOBJECTTEST pointinobjecttest; - void init(); - /*======================================================================*/ - double x1min; - double x1max; - double x2min; - double x2max; - double x3min; - double x3max; - bool consistent; -}; -/*=========================================================================*/ - -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - #if CAB_RCF <= 903 - SF_SERIALIZE_ENUM(GbTriangularMesh3D::POINTINOBJECTTEST) //bei klassen ausserhalb der klasse;-) - #endif - UB_AUTO_RUN_NAMED( SF::registerType<GbTriangularMesh3D >("GbTriangularMesh3D ") , SF_GbTriangularMesh3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, GbTriangularMesh3D >() ), SF_GbTriangularMesh3D_BD1 ); -#endif //RCF_USE_SF_SERIALIZATION - -#endif diff --git a/src/basics/geometry3d/GbVector3D.cpp b/src/basics/geometry3d/GbVector3D.cpp index 4283ddfc5..6246a7d15 100644 --- a/src/basics/geometry3d/GbVector3D.cpp +++ b/src/basics/geometry3d/GbVector3D.cpp @@ -1,9 +1,41 @@ -#include <numerics/geometry3d/GbVector3D.h> +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbVector3D.cpp +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= +#include <GbVector3D.h> +#include <GbPoint3D.h> #include <basics/utilities/UbMath.h> #include <basics/utilities/UbInfinity.h> -#include <numerics/geometry3d/GbPoint3D.h> - + using namespace std; diff --git a/src/basics/geometry3d/GbVector3D.h b/src/basics/geometry3d/GbVector3D.h index 538ead812..61184e8e0 100644 --- a/src/basics/geometry3d/GbVector3D.h +++ b/src/basics/geometry3d/GbVector3D.h @@ -1,9 +1,35 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GbVector3D.h +//! \ingroup geometry3d +//! \author Soeren Freudiger, Sebastian Geller +//======================================================================================= #ifndef GBVECTOR3D_H #define GBVECTOR3D_H @@ -11,14 +37,11 @@ #include <cassert> #include <string> -#ifdef CAB_RCF - #include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - #include <PointerDefinitions.h> class GbPoint3D; +//! \brief This Class provides basic 3D vector objects. class GbVector3D { public: @@ -109,13 +132,6 @@ public: static const GbVector3D UNIT_X2; static const GbVector3D UNIT_X3; -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & m_afTuple; - } -#endif //CAB_RCF private: // support for comparisons int CompareArrays (const GbVector3D& rkV) const; @@ -125,8 +141,4 @@ private: GbVector3D operator* (const double& fScalar, const GbVector3D& rkV); -#ifdef RCF_USE_SF_SERIALIZATION - UB_AUTO_RUN_NAMED( SF::registerType<GbVector3D >("GbVector3D "), SF_GbVector3D ); -#endif //RCF_USE_SF_SERIALIZATION - #endif //GBVECTOR3D_H diff --git a/src/basics/geometry3d/GbVoxelMatrix3D.cpp b/src/basics/geometry3d/GbVoxelMatrix3D.cpp deleted file mode 100644 index 5552482bb..000000000 --- a/src/basics/geometry3d/GbVoxelMatrix3D.cpp +++ /dev/null @@ -1,1109 +0,0 @@ -#include <numerics/geometry3d/GbVoxelMatrix3D.h> - -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbFileInputASCII.h> -#include <numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h> -#include <numerics/geometry3d/GbTriangle3D.h> -#include <basics/utilities/UbFileOutputASCII.h> -#include <numerics/geometry3d/CoordinateTransformation3D.h> - -#include <basics/utilities/UbSystem.h> - -#ifdef MC_CUBES -#include <MarchingCubes/MarchingCubes.h> -#endif // MC_CUBES - -using namespace std; - -const float GbVoxelMatrix3D::SOLID = 1.0f; -const float GbVoxelMatrix3D::FLUID = 0.0f; - - -/*=======================================================*/ -ObObjectCreator* GbVoxelMatrix3D::getCreator() -{ - return GbVoxelMatrix3DCreator::getInstance(); -} -/*=======================================================*/ -// Konstruktor -GbVoxelMatrix3D::GbVoxelMatrix3D(int nx1, int nx2, int nx3, float initVal, double lowerThreshold, double upperThreshold) - : GbObject3D() - , minX1(0.0) - , minX2(0.0) - , minX3(0.0) - , lowerThreshold(lowerThreshold) - , upperThreshold(upperThreshold) - , nodesX1(nx1) - , nodesX2(nx2) - , nodesX3(nx3) - , deltaX1(1.0) - , deltaX2(1.0) - , deltaX3(1.0) - , transferViaFilename(false) - , addSurfaceTriangleSetFlag(true) - , voxelMatrix(Matrix3D(nx1, nx2, nx3, initVal)) -{ - 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) -{ - 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) -{ - this->setName("VoxelMatrix3D"); -} -/*=======================================================*/ -GbVoxelMatrix3D* GbVoxelMatrix3D::clone() -{ - GbVoxelMatrix3D* vm = new GbVoxelMatrix3D(this->voxelMatrix, lowerThreshold, upperThreshold); - vm->setVoxelMatrixMininum(minX1, minX2, minX3); - vm->setVoxelMatrixDelta(deltaX1, deltaX2, deltaX3); - return vm; -} -/*=======================================================*/ -void GbVoxelMatrix3D::setCenterCoordinates(const double& x1, const double& x2, const double& x3) -{ - 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; - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void GbVoxelMatrix3D::setClosedVoidSpaceToSolid() -{ - voxelMatrixTemp = Matrix3D(nodesX1, nodesX2, nodesX3, SOLID); - flagMatrix = CbArray3D<char>(nodesX1, nodesX2, nodesX3, 0); - - for (int x3 = 0; x3<nodesX3; x3++) - { - for (int x2 = 0; x2<nodesX2; x2++) - { - for (int x1 = 0; x1<nodesX1; x1++) - { - if (voxelMatrix(x1, x2, x3)==FLUID) - { - UBLOG(logINFO, "setClosedVoidSpaceToSolid:start"); - x1Nbr.push_back(x1); - x2Nbr.push_back(x2); - x3Nbr.push_back(x3); - int size = (int)x1Nbr.size(); - while (size>0) - { - for (int i = 0; i<size; i++) - { - findFluidNeighbor(x1Nbr[i], x2Nbr[i], x3Nbr[i]); - } - - swap(x1Nbr, x1NbrTemp); - swap(x2Nbr, x2NbrTemp); - swap(x3Nbr, x3NbrTemp); - - x1NbrTemp.clear(); - x2NbrTemp.clear(); - x3NbrTemp.clear(); - size = (int)x1Nbr.size(); - } - UBLOG(logINFO, "setClosedVoidSpaceToSolid:end"); - voxelMatrix = voxelMatrixTemp; - return; - } - - } - } - } -} -/*=======================================================*/ -void GbVoxelMatrix3D::findFluidNeighbor(int x1, int x2, int x3) -{ - for (int k3 = -1; k3<=1; k3++) - { - for (int k2 = -1; k2<=1; k2++) - { - for (int k1 = -1; k1<=1; k1++) - { - 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 (voxelMatrix(j1, j2, j3)==FLUID) - { - if (flagMatrix(j1, j2, j3)==0) - { - voxelMatrixTemp(j1, j2, j3) = FLUID; - flagMatrix(j1, j2, j3) = 1; - x1NbrTemp.push_back(j1); - x2NbrTemp.push_back(j2); - x3NbrTemp.push_back(j3); - } - } - } - } - } - } -} -/*=======================================================*/ -void GbVoxelMatrix3D::calculateNumberOfSolidAndFluid() -{ - numberOfSolid = 0; - - for (int x3 = 0; x3<nodesX3; x3++) - for (int x2 = 0; x2<nodesX2; x2++) - for (int x1 = 0; x1<nodesX1; x1++) - { - if (voxelMatrix(x1, x2, x3)==GbVoxelMatrix3D::SOLID) - { - numberOfSolid++; - } - } - - numberOfFluid = (long)nodesX1*(long)nodesX2*(long)nodesX3-numberOfSolid; -} -/*=======================================================*/ -long GbVoxelMatrix3D::getNumberOfSolid() -{ - return numberOfSolid; -} -/*=======================================================*/ -long GbVoxelMatrix3D::getNumberOfFluid() -{ - return numberOfFluid; -} -/*=======================================================*/ -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(fabs(rx1), UbMath::one_over_sqrt3)) - &&(UbMath::equal(rx2, 0.0)||UbMath::equal(fabs(rx2), 1.0)||UbMath::equal(fabs(rx2), UbMath::one_over_sqrt2)||UbMath::equal(fabs(rx2), UbMath::one_over_sqrt3)) - &&(UbMath::equal(rx3, 0.0)||UbMath::equal(fabs(rx3), 1.0)||UbMath::equal(fabs(rx3), UbMath::one_over_sqrt2)||UbMath::equal(fabs(rx3), UbMath::one_over_sqrt3)))) - { - throw UbException(UB_EXARGS, "nur fuer diskrete Boltzmannrichungen implementiert!!!"); - } - - //nachbarindex ermitteln - int ndx1 = 0, ndx2 = 0, ndx3 = 0; - if (UbMath::greater(rx1, 0.0)) ndx1 = 1; - else if (UbMath::less(rx1, 0.0)) ndx1 = -1; - if (UbMath::greater(rx2, 0.0)) ndx2 = 1; - else if (UbMath::less(rx2, 0.0)) ndx2 = -1; - 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; - - //test ob nachbar solid - if (nix1>=0 - &&nix2>=0 - &&nix3>=0 - &&nix1<voxelMatrix.getNX1() - &&nix2<voxelMatrix.getNX2() - &&nix3<voxelMatrix.getNX3()) - { - 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.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()) - { - if (UbMath::equal(voxelMatrix(ix1, ix2, ix3), SOLID)) return true; - } - - return false; -} -/*=======================================================*/ -bool GbVoxelMatrix3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary) -{ - pointIsOnBoundary = false; - - 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) -{ - return false; - //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); - - 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); - - 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)) - 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) -//Merksatz: cell oder deren Volumen schneidet oder beinhaltet komplette oder Teile der CuboidUmrandung -//returns true: -// - cell cuts GbVoxelMatrix3D -// - cell boxes GbVoxelMatrix3D -//returns false: -// - cell completely inside GbVoxelMatrix3D -// - 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)) - { - return true; - } - - return false; -} -/*=======================================================*/ -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 -// - cell boxes cuboid3D -//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! - - 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->getX3Centroid()-0.5*(x3b+x3a) /*Tx3*/) - , 0.5*(this->getLengthX3()+std::fabs(x3b-x3a) /*dx3A+dx3B*/))) - { - return true; - } - - 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); - - mc.init_all(); - mc.run(0.5); - - //const int nofVertices = mc.nverts(); - const int nofTriangles = mc.ntrigs(); - - 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") - - 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") - mc.init_all(); - 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") - 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++) - { - McMatrixWrapper wrapper(matrices[i]); - McMarchingCubesGenerator mc(wrapper); - - mc.init_all(); - mc.run(0.5); - - 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)); - } - } -#else - cerr<<"void GbVoxelMatrix3D.addSurfaceTriangleSet - benoetigt MARCHING_CUBE paket aus 3rdParty"<<endl; -#endif // MC_CUBES - - UBLOG(logINFO, " GbVoxelMatrix3D addSurfaceTriangleSet end") -} -/*=======================================================*/ -string GbVoxelMatrix3D::toString() -{ - return "GbVoxelMatrix3D"; -} -/*=======================================================*/ -void GbVoxelMatrix3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - out->writeDouble(minX1); - out->writeDouble(minX2); - out->writeDouble(minX3); - out->writeDouble(deltaX1); - out->writeDouble(deltaX2); - out->writeDouble(deltaX3); - out->writeInteger(nodesX1); - out->writeInteger(nodesX2); - out->writeInteger(nodesX3); - out->writeDouble(lowerThreshold); - out->writeDouble(upperThreshold); - out->writeBool(addSurfaceTriangleSetFlag); - out->writeBool(transferViaFilename); - if (!transferViaFilename) - { - throw UbException(UB_EXARGS, "void GbVoxelMatrix3D::write(UbFileOutput* out) - geht ned"); - } - else - { - out->writeString(filename); - } - - - //CbUniformMatrix3D<float> voxelMatrix; -} -/*=======================================================*/ -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(); - deltaX1 = in->readDouble(); - deltaX2 = in->readDouble(); - deltaX3 = in->readDouble(); - nodesX1 = in->readInteger(); - nodesX2 = in->readInteger(); - nodesX3 = in->readInteger(); - lowerThreshold = in->readDouble(); - upperThreshold = in->readDouble(); - addSurfaceTriangleSetFlag = in->readBool(); - transferViaFilename = in->readBool(); - if (!transferViaFilename) - { - throw UbException(UB_EXARGS, "void GbVoxelMatrix3D::read(UbFileOutput* out) - geht ned"); - } - else - { - filename = in->readString(); - this->readMatrixFromVtiASCIIFile(filename); - } -#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"); } -#endif -} -/*=======================================================*/ -void GbVoxelMatrix3D::readMatrixFromVtiASCIIFile(std::string filename) - -{ - //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); - in.readLine(); - in.readLine(); - in.readLine(); - in.readLine(); - in.readLine(); - - voxelMatrix = Matrix3D(nodesX1, nodesX2, nodesX3, GbVoxelMatrix3D::FLUID); - - //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++) - { - val = in.readInteger(); - //if( !UbMath::equal(val, 0.0f) ) - //if( UbMath::greater(val, threshold) ) - if ((double)val>=lowerThreshold&&(double)val<=upperThreshold) - { - (voxelMatrix)(x1, x2, x3) = GbVoxelMatrix3D::SOLID; - } - } - //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 tempMinPunktX1tf = tempMinPunktX1; - double tempMinPunktX2tf = -tempMinPunktX3; - double tempMinPunktX3tf = tempMinPunktX2; - - double minX1_temp = tempMinPunktX1tf+cX1; - double minX2_temp = tempMinPunktX2tf+cX2; - double minX3_temp = tempMinPunktX3tf+cX3; - - minX2 = minX2_temp; - minX3 = minX3_temp; - - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); - - int nx1_new = nx1; - int nx2_new = nx3; - int nx3_new = nx2; - - double delta_temp = deltaX2; - deltaX2 = deltaX3; - deltaX3 = delta_temp; - - 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++) - { - voxelMatrix_temp(x1, nx3-x3-1, x2) = this->voxelMatrix(x1, x2, x3); - } - } - } - std::swap(this->voxelMatrix, voxelMatrix_temp); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::rotate90aroundX() -{ - double cX1 = this->getX1Centroid(); - double cX2 = this->getX2Centroid(); - double cX3 = this->getX3Centroid(); - - rotate90aroundX(cX1, cX2, cX3); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::rotate90aroundY(double cX1, double cX2, double 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; - - minX1 = minX1_temp; - minX3 = minX3_temp; - - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); - - int nx1_new = nx3; - int nx2_new = nx2; - int nx3_new = nx1; - - double delta_temp = deltaX1; - deltaX1 = deltaX3; - deltaX3 = delta_temp; - - 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++) - { - voxelMatrix_temp(x3, x2, nx1-x1-1) = this->voxelMatrix(x1, x2, x3); - } - } - } - std::swap(this->voxelMatrix, voxelMatrix_temp); -} -////////////////////////////////////////////////////////////////////////// -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 tempMinPunktX1tf = -tempMinPunktX2; - double tempMinPunktX2tf = tempMinPunktX1; - double tempMinPunktX3tf = tempMinPunktX3; - - double minX1_temp = tempMinPunktX1tf+cX1; - double minX2_temp = tempMinPunktX2tf+cX2; - double minX3_temp = tempMinPunktX3tf+cX3; - - minX1 = minX1_temp; - minX2 = minX2_temp; - - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); - - int nx1_new = nx2; - int nx2_new = nx1; - int nx3_new = nx3; - - double delta_temp = deltaX1; - deltaX1 = deltaX2; - deltaX2 = delta_temp; - - 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++) - { - voxelMatrix_temp(nx2-x2-1, x1, x3) = this->voxelMatrix(x1, x2, x3); - } - } - } - std::swap(this->voxelMatrix, voxelMatrix_temp); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::rotate90aroundZ() -{ - double cX1 = this->getX1Centroid(); - double cX2 = this->getX2Centroid(); - double cX3 = this->getX3Centroid(); - - rotate90aroundZ(cX1, cX2, cX3); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::mirrorX() -{ - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); - - 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++) - { - voxelMatrix_temp(nx1-x1-1, x2, x3) = this->voxelMatrix(x1, x2, x3); - } - } - } - std::swap(this->voxelMatrix, voxelMatrix_temp); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::mirrorY() -{ - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); - - 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++) - { - voxelMatrix_temp(x1, nx2-x2-1, x3) = this->voxelMatrix(x1, x2, x3); - } - } - } - std::swap(this->voxelMatrix, voxelMatrix_temp); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::mirrorZ() -{ - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); - - 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++) - { - voxelMatrix_temp(x1, x2, nx3-x3-1) = this->voxelMatrix(x1, x2, x3); - } - } - } - std::swap(this->voxelMatrix, voxelMatrix_temp); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::rotateAroundY(double theta) -{ - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); - - GbVoxelMatrix3D::Matrix3D voxelMatrix_temp(nx1, nx2, nx3, FLUID); - - double newMinX1 = cos(theta)*minX1+sin(theta)*minX3; - double newMinX3 = -sin(theta)*minX1+cos(theta)*minX3; - - for (int x3 = 0; x3<nx3; x3++) { - for (int x2 = 0; x2<nx2; x2++) { - for (int x1 = 0; x1<nx1; x1++) - { - if (voxelMatrix(x1, x2, x3)==SOLID) - { - double rcX1 = minX1+deltaX1*x1; - double rcX3 = minX3+deltaX3*x3; - - double nrcX1 = cos(theta)*rcX1+sin(theta)*rcX3; - double nrcX3 = -sin(theta)*rcX1+cos(theta)*rcX3; - - int newX1 = UbMath::integerRounding((nrcX1-minX1)/deltaX1); - int newX2 = x2; - int newX3 = UbMath::integerRounding((nrcX3-minX3)/deltaX3); - - if (newX1 < 0) - { - int test=1; - } - - if (newX1>0 && newX3>0 && newX1<nx1 && newX3<nx3) - { - voxelMatrix_temp(newX1, newX2, newX3) = voxelMatrix(x1, x2, x3); - } - - //int ix1, ix2, ix3; - //double ixx1 = (abs(nrcX1-minX1)/deltaX1); - //ix2 = x2; - //double ixx3 = (abs(nrcX3-minX3)/deltaX3); - //if (ixx1-(int)ixx1>.9999999999) ix1 = (int)ixx1+1; else ix1 = (int)ixx1; - ////if (ixx2-(int)ixx2>.9999999999) ix2 = (int)ixx2+1; else ix2 = (int)ixx2; - //if (ixx3-(int)ixx3>.9999999999) ix3 = (int)ixx3+1; else ix3 = (int)ixx3; - - //if (ix1>=0 && ix3>=0 && ix1<nx1 && ix3<nx3) - //{ - // voxelMatrix_temp(ix1, ix2, ix3) = voxelMatrix(x1, x2, x3); - //} - } - - } - } - } - std::swap(voxelMatrix, voxelMatrix_temp); - - for (int x3 = 0; x3<nx3; x3++) - for (int x2 = 0; x2<nx2; x2++) - for (int x1 = 0; x1<nx1; x1++) - { - int count = 0; - for (int k3 = -1; k3<=1; k3++) - for (int k1 = -1; k1<=1; k1++) - { - int j1 = x1+k1; - int j3 = x3+k3; - if (j1>=0 && j3>=0 && j1<nx1 && j3<nx3) - { - if (voxelMatrix(j1, x2, j3)==SOLID) - { - count++; - } - } - - } - if (count == 8) - { - voxelMatrix(x1, x2, x3) = SOLID; - } - } -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::writeToLegacyVTKASCII(const std::string& fileName) -{ - string fn = fileName+".ascii.vtk"; - - 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(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); - - 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, "\n"); - - fclose(file); -} -////////////////////////////////////////////////////////////////////////// -void GbVoxelMatrix3D::writeToLegacyVTKBinary(const std::string& fileName) -{ - string fn = fileName+".binary.vtk"; - - 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); - } - - int nx1 = (int)voxelMatrix.getNX1(); - int nx2 = (int)voxelMatrix.getNX2(); - int nx3 = (int)voxelMatrix.getNX3(); - - int nn = nx1*nx2*nx3; - - 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"); - 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++) - { - float tmp = this->voxelMatrix(x1, x2, x3); - UbSystem::swapByteOrder((unsigned char*)(&(tmp)), sizeof(float)); - 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); - fclose(file); -} -////////////////////////////////////////////////////////////////////////// -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"; - - 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); - } - - 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, "\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); -} -////////////////////////////////////////////////////////////////////////// -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"; - - 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); - } - - 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"); - unsigned long long size = (unsigned long long)voxelMatrix.getDataVector().size()*sizeof(float); - fwrite(&size, sizeof(unsigned long long), 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); -} - - diff --git a/src/basics/geometry3d/GbVoxelMatrix3D.h b/src/basics/geometry3d/GbVoxelMatrix3D.h deleted file mode 100644 index 626803b7e..000000000 --- a/src/basics/geometry3d/GbVoxelMatrix3D.h +++ /dev/null @@ -1,341 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef GBVOXELMATRIX3D_H -#define GBVOXELMATRIX3D_H - -#ifdef CAB_RCF -#include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -#include <vector> -#include <cmath> - -#include <numerics/geometry3d/GbObject3D.h> -#include <basics/utilities/UbObserver.h> -#include <basics/container/CbArray3D.h> - -#include <PointerDefinitions.h> - -class GbLine3D; -class GbTriangle3D; -class GbObject3DCreator; - -class GbVoxelMatrix3D : public GbObject3D, public UbObserver -{ -public: - typedef CbArray3D<float> Matrix3D; - 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() {} - - void finalize() {}; - 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); - } - /*=======================================================================*/ - 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); - } - /*=======================================================================*/ - void setTransferViaFilename(bool transferViaFilename, std::string filename) - { - this->filename = filename; - this->transferViaFilename = transferViaFilename; - } - void setThreshold(double lowerThreshold, double upperThreshold) { this->lowerThreshold = lowerThreshold; this->upperThreshold = upperThreshold; } - void setAddSurfaceTriangleSetFlag(bool flag) { this->addSurfaceTriangleSetFlag = flag; } - - /*=======================================================================*/ - void setVoxelMatrixMininum(double minX1, double minX2, double minX3) { this->minX1 = minX1; this->minX2 = minX2; this->minX3 = minX3; } - 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; } - void setVoxelMatrixDeltaX2(double deltaX2) { this->deltaX2 = deltaX2; } - 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 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 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); - //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"); } - - std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - void addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles); - - bool hasRaytracing() { return true; } - /*|r| must be 1! einheitsvector!!*/ - double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3); - - std::string toString(); - - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - - //virtuelle Methoden von UbObserver - void objectChanged(UbObservable* changedObject) {} - void objectWillBeDeleted(UbObservable* objectForDeletion) {} - - template <class T> - void readMatrixFromRawFile(std::string filename, GbVoxelMatrix3D::Endian endian); - template <class T> - void readBufferedMatrixFromRawFile(std::string filename, GbVoxelMatrix3D::Endian endian); - void readMatrixFromVtiASCIIFile(std::string filename); - - void rotate90aroundX(); - void rotate90aroundY(); - void rotate90aroundZ(); - void rotate90aroundX(double cX1, double cX2, double cX3); - void rotate90aroundY(double cX1, double cX2, double cX3); - void rotate90aroundZ(double cX1, double cX2, double cX3); - void mirrorX(); - void mirrorY(); - void mirrorZ(); - - void rotateAroundY(double theta); - - void writeToLegacyVTKASCII(const std::string& fileName); - void writeToLegacyVTKBinary(const std::string& fileName); - void writeToVTKImageDataASCII(const std::string& fileName); - void writeToVTKImageDataAppended(const std::string& fileName); - - void setClosedVoidSpaceToSolid(); - - void calculateNumberOfSolidAndFluid(); - long getNumberOfSolid(); - long getNumberOfFluid(); - -protected: - void findFluidNeighbor(int cx1, int cx2, int cx3); - Matrix3D voxelMatrixTemp; - CbArray3D<char> flagMatrix; - - std::vector<int> x1Nbr; - std::vector<int> x2Nbr; - std::vector<int> x3Nbr; - - std::vector<int> x1NbrTemp; - std::vector<int> x2NbrTemp; - std::vector<int> x3NbrTemp; - - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere - -//#ifdef CAB_RCF -// template<class Archive> -// void SF_SERIALIZE(Archive & ar) -// { -// SF_SERIALIZE_PARENT<GbObject3D>(ar, *this); -// ar & minX1; -// ar & minX2; -// ar & minX3; -// ar & deltaX1; -// ar & deltaX2; -// ar & deltaX3; -// ar & nodesX1; -// ar & nodesX2; -// ar & nodesX3; -// ar & threshold; -// ar & transferViaFilename; -// ar & addSurfaceTriangleSetFlag; -// if (!transferViaFilename) -// { -// ar & voxelMatrix; -// } -// else -// { -// ar & filename; -// if (ArchiveTools::isReading(ar)) -// { -// this->readMatrixFromVtiASCIIFile(filename); -// } -// } -// -// } -//#endif //CAB_RCF - -protected: - //for transfer - std::string filename; - bool transferViaFilename; - - bool addSurfaceTriangleSetFlag; - - int nodesX1; - int nodesX2; - int nodesX3; - double lowerThreshold, upperThreshold; - - double minX1; - double minX2; - double minX3; - double deltaX1; - double deltaX2; - double deltaX3; - - Matrix3D voxelMatrix; - - long numberOfSolid; - long numberOfFluid; - -}; - -////////////////////////////////////////////////////////////////////////// -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"); - ifstream in(filename.c_str(), ios::binary); - if (!in) throw UbException(UB_EXARGS, "could not open file "+filename); - - in.seekg(0, ios::end); //Ende springen - fstream::off_type length = in.tellg(); //Position abfragen - 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) - { - throw UbException(UB_EXARGS, "number of nodes("+UbSystem::toString(nofn)+") doesn't match file size("+UbSystem::toString((long)length)+")"); - } - - //UBLOG(logINFO," - create GbVoxelMatrix3D"); - //GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID); - voxelMatrix = Matrix3D(nodesX1, nodesX2, nodesX3, GbVoxelMatrix3D::FLUID); - - //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++) - { - //in.read((char*)&val,sizeof(float)); - 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) - { - (voxelMatrix)(x1, x2, x3) = GbVoxelMatrix3D::SOLID; - } - //(voxelMatrix)(x1, x2, x3) = (float)val; - } - - //UBLOG(logINFO,"GbVoxelMatrix3D::readMatrixFromFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end"); -} - -////////////////////////////////////////////////////////////////////////// -template <class T> -void GbVoxelMatrix3D::readBufferedMatrixFromRawFile(std::string filename, GbVoxelMatrix3D::Endian endian) -{ - using namespace std; - UBLOG(logINFO, "GbVoxelMatrix3D::readMatrixFromRawFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start"); - - FILE *file; - file = fopen(filename.c_str(), "rb"); - if (file==NULL) - { - throw UbException(UB_EXARGS, "Could not open file "+filename); - } - - // obtain file size: - fseek(file, 0, SEEK_END); - unsigned long int length = ftell(file); - 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) - { - //throw UbException(UB_EXARGS, "number of nodes("+UbSystem::toString(nofn)+") doesn't match file size("+UbSystem::toString(length)+")"); - } - - UBLOG(logINFO, " - create GbVoxelMatrix3D"); - voxelMatrix = Matrix3D(nodesX1, nodesX2, nodesX3, GbVoxelMatrix3D::FLUID); - - CbArray3D<T> readMatrix(nodesX1, nodesX2, nodesX3); - - UBLOG(logINFO, " - read file to matrix"); - fread(readMatrix.getStartAdressOfSortedArray(0, 0, 0), sizeof(T), readMatrix.getDataVector().size(), file); - fclose(file); - - UBLOG(logINFO, " - init values"); - - numberOfSolid = 0; - T val; - for (int x3 = 0; x3<nodesX3; x3++) - for (int x2 = 0; x2<nodesX2; x2++) - for (int x1 = 0; x1<nodesX1; x1++) - { - val = readMatrix(x1, x2, x3); - - if (endian==BigEndian) - { - UbSystem::swapByteOrder((unsigned char*)(&(val)), sizeof(T)); - } - - if ((double)val>=lowerThreshold&&(double)val<=upperThreshold) - { - voxelMatrix(x1, x2, x3) = GbVoxelMatrix3D::SOLID; - } - } - - UBLOG(logINFO, "GbVoxelMatrix3D::readMatrixFromRawFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end"); -} - - - -//#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); -//#endif //RCF_USE_SF_SERIALIZATION - - -#endif diff --git a/src/basics/geometry3d/KdTree/KdNode.h b/src/basics/geometry3d/KdTree/KdNode.h deleted file mode 100644 index 724ed9e08..000000000 --- a/src/basics/geometry3d/KdTree/KdNode.h +++ /dev/null @@ -1,284 +0,0 @@ -#ifndef KDNODE_H -#define KDNODE_H - -#include <basics/memory/MbSmartPtr.h> - -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbTuple.h> -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbKeys.h> - -#include <numerics/geometry3d/GbTriFaceMesh3D.h> -#include <numerics/geometry3d/KdTree/KdUtilities.h> -#include <numerics/geometry3d/KdTree/KdRay.h> -#include <numerics/geometry3d/KdTree/KdSplitCandidate.h> -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h> - - -#include <vector> -#include <string> - -namespace Kd -{ - template< typename T > - class Node - { - public: - Node( const T& x1, const T& y1, const T& z1 - , const T& x2, const T& y2, const T& z2 - , const MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFaces - , std::vector<GbTriFaceMesh3D::Vertex>* ptrNodes ) - : child1(NULL) - , child2(NULL) - , triFaces(triFaces) - , ptrNodes(ptrNodes) - { - if( x1 < x2 ) { this->x[0] = x1; this->x[1] = x2; } - else { this->x[0] = x2; this->x[1] = x1; } - - if( y1 < y2 ) { this->y[0] = y1; this->y[1] = y2; } - else { this->y[0] = y2; this->y[1] = y1; } - - if( z1 < z2 ) { this->z[0] = z1; this->z[1] = z2; } - else { this->z[0] = z2; this->z[1] = z1; } - } - /* ======================================================================================= */ - ~Node() - { - if(child1) { delete child1; child1 = NULL; } - if(child2) { delete child2; child2 = NULL; } - } - /* ======================================================================================= */ - bool isLeaf() - { - return child1 == NULL && child2 == NULL; - } - /* ======================================================================================= */ - void deleteTriFaces() - { - triFaces = MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> >(); - } - /* ======================================================================================= */ - const MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> >& getTriFaces() - { - return triFaces; - } - /* ======================================================================================= */ - std::vector<GbTriFaceMesh3D::Vertex>& getNodes() - { - if(!ptrNodes) throw UbException(UB_EXARGS,"ups,no nodes"); - return *ptrNodes; - } - - /* ======================================================================================= */ - void buildTree(const int& level, const int& maxLevel, const SplitAlgorithm<T>& splitAlg) - { - SplitCandidate<T> splitCandidate = splitAlg.findBestSplitCandidate(level, maxLevel, *this); - - if( splitCandidate.isValid ) - { - - MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFacesForChild1( new std::vector<GbTriFaceMesh3D::TriFace> ); - MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFacesForChild2( new std::vector<GbTriFaceMesh3D::TriFace> ); - - splitAlg.distributeTriFaces(splitCandidate, *triFacesForChild1, *triFacesForChild2, *this); - - ////////////////////////////////////////////////////////////////////////// - // calculate center points and edges of new child nodes - T x1_l = x[0], y1_l = y[0], z1_l = z[0]; - T x2_l = x[1], y2_l = y[1], z2_l = z[1]; - T x1_r = x[0], y1_r = y[0], z1_r = z[0]; - T x2_r = x[1], y2_r = y[1], z2_r = z[1]; - - if (splitCandidate.axis == Axis::X) - { - x2_l = splitCandidate.position; - x1_r = splitCandidate.position; - } - else if (splitCandidate.axis == Axis::Y) - { - y2_l = splitCandidate.position; - y1_r = splitCandidate.position; - } - else - { - z2_l = splitCandidate.position; - z1_r = splitCandidate.position; - } - // ---------------------------------------------------------------------- - // ---------------------------------------------------------------------- - - if (triFacesForChild1->size() > 0) - { - if( this->child1 ) delete this->child1; - this->child1 = new Node(x1_l, y1_l, z1_l, x2_l, y2_l, z2_l, triFacesForChild1, ptrNodes); - this->child1->buildTree(level + 1, maxLevel, splitAlg); - } - - if (triFacesForChild2->size() > 0) - { - if( this->child2 ) delete this->child2; - this->child2 = new Node(x1_r, y1_r, z1_r, x2_r, y2_r, z2_r, triFacesForChild2, ptrNodes); - this->child2->buildTree(level + 1, maxLevel, splitAlg); - } - } - } - /* ======================================================================================= */ - int intersectLineBoundingBox(const UbTuple<T,T,T>& n1, const UbTuple<T,T,T>& n2) - { - const T& n1X = val<1>(n1); - const T& n1Y = val<2>(n1); - const T& n1Z = val<3>(n1); - - const T& n2X = val<1>(n2); - const T& n2Y = val<2>(n2); - const T& n2Z = val<3>(n2); - - double t_nah = UbMath::max( ( (n1X <= n2X ? x[0] : x[1]) - n1X) / (n2X - n1X) - , ( (n1Y <= n2Y ? y[0] : y[1]) - n1Y) / (n2Y - n1Y) - , ( (n1Z <= n2Z ? z[0] : z[1]) - n1Z) / (n2Z - n1Z) ); - - double t_fern = UbMath::min( ( (n1X > n2X ? x[0] : x[1]) - n1X) / (n2X - n1X) - , ( (n1Y > n2Y ? y[0] : y[1]) - n1Y) / (n2Y - n1Y) - , ( (n1Z > n2Z ? z[0] : z[1]) - n1Z) / (n2Z - n1Z) ); - - if ( UbMath::greater( UbMath::max( ( (n1X <= n2X ? x[0] : x[1]) - n1X) / (n2X - n1X) - , ( (n1Y <= n2Y ? y[0] : y[1]) - n1Y) / (n2Y - n1Y) - , ( (n1Z <= n2Z ? z[0] : z[1]) - n1Z) / (n2Z - n1Z) ) - , UbMath::min( ( (n1X > n2X ? x[0] : x[1]) - n1X) / (n2X - n1X) - , ( (n1Y > n2Y ? y[0] : y[1]) - n1Y) / (n2Y - n1Y) - , ( (n1Z > n2Z ? z[0] : z[1]) - n1Z) / (n2Z - n1Z) ) ) ) - { - return Intersection::NO_INTERSECTION; - } - else - { - return Intersection::INTERSECTION; - } - } - /* ======================================================================================= */ - int intersectRayBoundingBox(const Ray<T>& ray) - { - T tmin = (x[ ray.signX] - ray.originX) * ray.inv_directionX; - T tmax = (x[1-ray.signX] - ray.originX) * ray.inv_directionX; - - T tymin = (y[ ray.signY] - ray.originY) * ray.inv_directionY; - T tymax = (y[1-ray.signY] - ray.originY) * ray.inv_directionY; - - if( (tmin > tymax) || (tymin > tmax) ) - { - return false; - } - if( tymin > tmin ) tmin = tymin; - if( tymax < tmax ) tmax = tymax; - - T tzmin = (z[ ray.signZ] - ray.originZ) * ray.inv_directionZ; - T tzmax = (z[1-ray.signZ] - ray.originZ) * ray.inv_directionZ; - - //if( (UbMath::greater( tmin, tzmax) ) || ( UbMath::greater( tzmin, tmax) ) ) - if( ( tmin > tzmax) || ( tzmin > tmax) ) - { - return false; - } - //if(tzmin > tmin) tmin = tzmin; - if(tzmax < tmax) tmax = tzmax; - - //return ( (tmin =< t1) && (tmax >= t0) ); - if( UbMath::greaterEqual( tmax, T(0.0) ) ) - { - return Intersection::INTERSECTION; - } - else - { - return Intersection::NO_INTERSECTION; - } - } - /* ======================================================================================= */ - bool intersectLine(const UbTuple<T,T,T>& n1, const UbTuple<T,T,T>& n2, const LineIntersectionHandler<T>& iHandler) - { - return iHandler.intersectLine(n1, n2, *this, child1, child2); - } - /* ======================================================================================= */ - int intersectRay(const Ray<T>& ray, const RayIntersectionHandler<T>& iHandler, std::set< UbKeys::Key3<int> >& mailbox) - { - return iHandler.intersectRay(ray, *this, child1, child2, mailbox); - } - /* ======================================================================================= */ - int getNumOfTriFaces() - { - if(!child1 && !child2) - { - if(triFaces) return (int)triFaces->size(); - else return 0; - } - else - { - int sum = 0; - - if(child1) sum += child1->getNumOfTriFaces(); - if(child2) sum += child2->getNumOfTriFaces(); - - return sum; - } - } - /* ======================================================================================= */ - int getNumOfNodes() - { - if( !child1 && !child2) - { - return 1; - } - else - { - int sum = 0; - if(child1) sum += child1->getNumOfNodes(); - if(child2) sum += child2->getNumOfNodes(); - - return 1 + sum; - } - } - /* ======================================================================================= */ - std::string toString() - { - return "";//"[" + x1 + "," + y1 + "," + z1 + "] -" + " [" + x2 + "," + y2 + "," + z2 + "]"; - } - /* ======================================================================================= */ - void addCubeInfo(std::vector< UbTupleFloat3 >& nodes, std::vector< UbTupleInt8 >& cells, std::vector<std::string >& datanames, std::vector<std::vector<double > >& celldata) - { - nodes.push_back( makeUbTuple(float(x[0]), float(y[0]), float(z[0]) ) ); - nodes.push_back( makeUbTuple(float(x[1]), float(y[0]), float(z[0]) ) ); - nodes.push_back( makeUbTuple(float(x[1]), float(y[1]), float(z[0]) ) ); - nodes.push_back( makeUbTuple(float(x[0]), float(y[1]), float(z[0]) ) ); - - nodes.push_back( makeUbTuple(float(x[0]), float(y[0]), float(z[1]) ) ); - nodes.push_back( makeUbTuple(float(x[1]), float(y[0]), float(z[1]) ) ); - nodes.push_back( makeUbTuple(float(x[1]), float(y[1]), float(z[1]) ) ); - nodes.push_back( makeUbTuple(float(x[0]), float(y[1]), float(z[1]) ) ); - - cells.push_back( makeUbTuple( int(nodes.size()-8), int(nodes.size()-7), int(nodes.size()-6), int(nodes.size()-5), - int(nodes.size()-4), int(nodes.size()-3), int(nodes.size()-2), int(nodes.size()-1) ) ); - datanames.resize(1); - datanames[0] = "childs"; - celldata.resize( datanames.size() ); - if ( child1 && child2 ) celldata[0].push_back(2); - else if( child1 || child2 ) celldata[0].push_back(1); - else celldata[0].push_back(0); - - if(child1) child1->addCubeInfo(nodes, cells, datanames, celldata); - if(child2) child2->addCubeInfo(nodes, cells, datanames, celldata); - } - - public: - T x[2], y[2], z[2]; - - private: - Node* child1; - Node* child2; - - MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFaces; - std::vector<GbTriFaceMesh3D::Vertex>* ptrNodes; //lediglich für Zugriff auf die Knoten!!! - }; -} -#endif //KDNODE_H diff --git a/src/basics/geometry3d/KdTree/KdRay.h b/src/basics/geometry3d/KdTree/KdRay.h deleted file mode 100644 index 8465b8308..000000000 --- a/src/basics/geometry3d/KdTree/KdRay.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef KDRAY_H -#define KDRAY_H - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbMath.h> - - -namespace Kd -{ - /* - * Ray class, for use with the optimized ray-box intersection test - * described in: - * - * Amy Williams, Steve Barrus, R. Keith Morley, and Peter Shirley - * "An Efficient and Robust Ray-Box Intersection Algorithm" - * Journal of graphics tools, 10(1):49-54, 2005 - * - */ - template< typename T> - class Ray - { - public: - Ray( const T& originX , const T& originY , const T& originZ - , const T& directionX, const T& directionY, const T& directionZ ) - { - this->originX = originX; - this->originY = originY; - this->originZ = originZ; - - //normierung (fuer ray-triangle-intersection) - T oneOverLength = T(1.0/std::sqrt( directionX*directionX - + directionY*directionY - + directionZ*directionZ ) ); - - this->directionX = directionX*oneOverLength; - this->directionY = directionY*oneOverLength; - this->directionZ = directionZ*oneOverLength; - - this->inv_directionX = T(1.0/this->directionX); //ACHTUNG: BEWUSST KEINE ==0 Abfrage - this->inv_directionY = T(1.0/this->directionY); //Alg verwendet exlitzit INF - this->inv_directionZ = T(1.0/this->directionZ); - - if(this->inv_directionX < 0.0) this->signX = 1; - else this->signX = 0; - if(this->inv_directionY < 0.0) this->signY = 1; - else this->signY = 0; - if(this->inv_directionZ < 0.0) this->signZ = 1; - else this->signZ = 0; - } - - T originX; - T originY; - T originZ; - - T directionX; - T directionY; - T directionZ; - - T inv_directionX; - T inv_directionY; - T inv_directionZ; - - int signX; - int signY; - int signZ; - }; -} //namespace Kd - -#endif //KDRAY_H diff --git a/src/basics/geometry3d/KdTree/KdSplitCandidate.h b/src/basics/geometry3d/KdTree/KdSplitCandidate.h deleted file mode 100644 index 9fe19c065..000000000 --- a/src/basics/geometry3d/KdTree/KdSplitCandidate.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef KDSPLITCANDIDATE_H -#define KDSPLITCANDIDATE_H - -#include <basics/utilities/UbMath.h> - -namespace Kd -{ - template< typename T > - class SplitCandidate - { - public: - SplitCandidate() - : axis(0) - , position(0.0) - , starting(0) - , ending(0) - , np_left(false) - , np_right(false) - , Cn(0.0) - , nr(0) - , nl(0) - , isValid(false) - { - - } - /* ======================================================================================= */ - SplitCandidate(const int& axis, const T& position, const int& starting, const int& ending, const int& insidePlane) - : np_left(false) - , np_right(false) - , axis(axis) - , position(position) - , starting(starting) - , ending(ending) - , np(insidePlane) - , Cn(0.0) - , nr(0) - , nl(0) - , isValid(true) - { - } - /* ======================================================================================= */ - bool operator!() const - { - return isValid; - } - /* ======================================================================================= */ - friend inline bool operator< (const SplitCandidate& lhs, const SplitCandidate& rhs) - { - return lhs.position < rhs.position; - } - /* ======================================================================================= */ - - public: - int axis; - T Cn; - T position; - int nl; - int nr; - int np; - int starting; - int ending; - bool np_left; - bool np_right; - bool isValid; - }; -} - -#endif //KDSPLITCANDIDATE_H diff --git a/src/basics/geometry3d/KdTree/KdSplitCandidateManager.h b/src/basics/geometry3d/KdTree/KdSplitCandidateManager.h deleted file mode 100644 index 2849def3a..000000000 --- a/src/basics/geometry3d/KdTree/KdSplitCandidateManager.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef KDSPLITCANDIDATEMANAGER_H -#define KDSPLITCANDIDATEMANAGER_H - -#include <numerics/geometry3d/KdTree/KdSplitCandidate.h> - -#include <map> -#include <vector> -#include <algorithm> - - -namespace Kd -{ - template< typename T > - class SplitCandidateManager - { - public: - SplitCandidateManager() - : objects_starting_outside_left(0) - , objects_fully_outside_node(0) - { - - } - /* ======================================================================================= */ - SplitCandidate<T>& operator[] (const int& i) - { - #ifdef DEBUG - return splitCandidatesVec.at(i); - #else - return splitCandidatesVec[i]; - #endif - } - /* ======================================================================================= */ - typename std::vector< SplitCandidate< T > >::size_type size() - { - return splitCandidatesVec.size(); - } - /* ======================================================================================= */ - void add(const T& pos, const int& axis, const int& starting, const int& ending, const int& np) - { - typename std::map<T, SplitCandidate<T> >::iterator it = splitCandidates.find(pos); - if ( it != splitCandidates.end() ) //split candidate is already available -> increase parameter (starting, ending and np) - { - SplitCandidate<T>& sc = it->second; - sc.np += np; - sc.starting += starting; - sc.ending += ending; - } - else // split candidate is not available -> add new split candidate - { - this->splitCandidates[pos] = SplitCandidate<T>(axis, pos, starting, ending, np); - } - } - /* ======================================================================================= */ - void createSortedArray() - { - splitCandidatesVec.clear(); - typename std::map<T, SplitCandidate<T> >::iterator it; - for( it=splitCandidates.begin(); it!=splitCandidates.end(); ++it) - splitCandidatesVec.push_back(it->second); - splitCandidates.clear(); - std::sort(splitCandidatesVec.begin(), splitCandidatesVec.end(), std::less< SplitCandidate<T> >() ); - } - /* ======================================================================================= */ - - public: - int objects_starting_outside_left; - int objects_fully_outside_node; - - private: - std::map<T, SplitCandidate<T> > splitCandidates; - std::vector< SplitCandidate<T> > splitCandidatesVec; - }; -} - -#endif //KDSPLITCANDIDATEMANAGER_H diff --git a/src/basics/geometry3d/KdTree/KdTree.h b/src/basics/geometry3d/KdTree/KdTree.h deleted file mode 100644 index 7bf58a315..000000000 --- a/src/basics/geometry3d/KdTree/KdTree.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef KDTREE_H -#define KDTREE_H - -#include <basics/memory/MbSmartPtr.h> -#include <basics/writer/WbWriterVtkXmlBinary.h> -#include <numerics/geometry3d/GbTriFaceMesh3D.h> -#include <basics/utilities/UbKeys.h> - -#include <numerics/geometry3d/KdTree/KdNode.h> -#include <numerics/geometry3d/KdTree/KdRay.h> -#include <numerics/geometry3d/KdTree/KdSplitCandidate.h> -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h> - -#include <string> - -namespace Kd -{ - template< typename T > - class Tree - { - public: - /* ======================================================================================= */ - Tree(GbTriFaceMesh3D& mesh, const SplitAlgorithm<T>& splitAlg) - : rootNode(NULL) - { - this->buildTree(mesh, splitAlg); - } - /* ======================================================================================= */ - ~Tree() - { - if(rootNode) { delete rootNode; rootNode = NULL; } - } - /* ======================================================================================= */ - // the IntersectionHandler specifies how to handle the intersection - bool intersectLine(const UbTuple< T, T, T >& n1, const UbTuple< T, T, T >& n2, const LineIntersectionHandler<T>& iHandler) - { - return rootNode->intersectLine(n1, n2, iHandler); - } - /* ======================================================================================= */ - // the IntersectionHandler specifies how to handle the intersection - int intersectRay(const Ray<T>& ray, const RayIntersectionHandler<T>& iHandler) - { - std::set< UbKeys::Key3<int> > mailbox; - return rootNode->intersectRay(ray, iHandler, mailbox); - } - /* ======================================================================================= */ - int getNumOfNodes() - { - if(rootNode) return rootNode->getNumOfNodes(); - return 0; - } - /* ======================================================================================= */ - int getNumOfTriFaces() - { - if(rootNode) return rootNode->getNumOfTriFaces(); - return 0; - } - /* ======================================================================================= */ - std::string toString() - { - return "";//Tree:: num of nodes: " + rootNode.getNumOfNodes() + ", primitives:" + rootNode.getNumOfPrimitives() + ", root_primitives:" + getNumOfPrimitives() + ", max_level:" + max_level; - } - /* ======================================================================================= */ - void buildTree(GbTriFaceMesh3D& mesh, const SplitAlgorithm<T>& splitAlg ) - { - if(rootNode) delete rootNode; - - // create a copy of triangles - MbSmartPtr< std::vector<GbTriFaceMesh3D::TriFace> > triFaces(new std::vector<GbTriFaceMesh3D::TriFace>(*mesh.getTriangles() ) ); - - int maxLevel = (int)(8.0 + 1.3 * std::log( (double)triFaces->size() ) + 0.5); - - rootNode = new Node<T>( T( mesh.getX1Minimum() ) - , T( mesh.getX2Minimum() ) - , T( mesh.getX3Minimum() ) - , T( mesh.getX1Maximum() ) - , T( mesh.getX2Maximum() ) - , T( mesh.getX3Maximum() ) - , triFaces, mesh.getNodes() ); - - rootNode->buildTree(0, maxLevel, splitAlg); - } - void writeTree(const std::string& filename, WbWriter* writer = WbWriterVtkXmlBinary::getInstance()) - { - if(rootNode) - { - std::vector<UbTupleFloat3 > nodes; - std::vector<UbTupleInt8 > cubes; - std::vector<std::string > datanames; - std::vector<std::vector<double > > cubesdata; - rootNode->addCubeInfo(nodes, cubes, datanames, cubesdata); - writer->writeOctsWithCellData(filename,nodes,cubes,datanames,cubesdata); - } - } - private: - Node<T>* rootNode; - }; -} - -#endif //KDTREE_H diff --git a/src/basics/geometry3d/KdTree/KdUtilities.cpp b/src/basics/geometry3d/KdTree/KdUtilities.cpp deleted file mode 100644 index f0b7115b6..000000000 --- a/src/basics/geometry3d/KdTree/KdUtilities.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include <numerics/geometry3d/KdTree/KdUtilities.h> - -namespace Kd -{ - const int Axis::X = 0; - const int Axis::Y = 1; - const int Axis::Z = 2; - - const int Intersection::ON_BOUNDARY = -2; - const int Intersection::INTERSECT_EDGE = -1; - const int Intersection::INTERSECTION = 1; -const int Intersection::NO_INTERSECTION = 0; -} //namespace Kd diff --git a/src/basics/geometry3d/KdTree/KdUtilities.h b/src/basics/geometry3d/KdTree/KdUtilities.h deleted file mode 100644 index 177893950..000000000 --- a/src/basics/geometry3d/KdTree/KdUtilities.h +++ /dev/null @@ -1,164 +0,0 @@ -#ifndef KDUTILIES_H -#define KDUTILIES_H - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbTuple.h> -#include <basics/utilities/UbMath.h> - -#include <numerics/geometry3d/GbTriFaceMesh3D.h> - -#include <algorithm> -#include <vector> - -namespace Kd -{ - struct Axis - { - static const int X;// = 0; - static const int Y;// = 1; - static const int Z;// = 2; - }; - /* ======================================================================================= */ - struct Intersection - { - static const int ON_BOUNDARY; // = -2; - static const int INTERSECT_EDGE; // = -1; - static const int INTERSECTION; // = 1; - static const int NO_INTERSECTION;// = 0; - }; - /* ======================================================================================= */ - template< typename T> - inline void project2Axis(GbTriFaceMesh3D::TriFace& triFace, std::vector<GbTriFaceMesh3D::Vertex>& nodes, const int& axis, std::vector<T>& projection) - { - projection.resize(3); - - if(axis==Axis::X) - { - projection[0] = triFace.getV1x(nodes); - projection[1] = triFace.getV2x(nodes); - projection[2] = triFace.getV3x(nodes); - } - else if(axis==Axis::Y) - { - projection[0] = triFace.getV1y(nodes); - projection[1] = triFace.getV2y(nodes); - projection[2] = triFace.getV3y(nodes); - } - else if(axis==Axis::Z) - { - projection[0] = triFace.getV1z(nodes); - projection[1] = triFace.getV2z(nodes); - projection[2] = triFace.getV3z(nodes); - } - else throw UbException(UB_EXARGS,"unknown axis"); - - std::sort( projection.begin(), projection.end(), std::less<double>() ); - } - /* ======================================================================================= */ - template< typename T> - inline bool isPointOnPlane(const T& px, const T& py, const T& pz, const T& precision, GbTriFaceMesh3D::Vertex& pointOfTriFace, GbTriFaceMesh3D::TriFace& triFace) - { - return std::fabs( (px - pointOfTriFace.x) * triFace.nx + (py - pointOfTriFace.y) * triFace.ny + (pz - pointOfTriFace.z) * triFace.nz ) < precision; - } - /* ======================================================================================= */ - template< typename T> - inline bool isPointOnTriangle( const T& px, const T& py, const T& pz, const T& precision - , GbTriFaceMesh3D::Vertex& p1, GbTriFaceMesh3D::Vertex& p2, GbTriFaceMesh3D::Vertex& p3 - , GbTriFaceMesh3D::TriFace& triFace ) - { - if( Kd::isPointOnPlane(px, py, pz, precision, p1, triFace) ) - { - T a_x = p1.x - px; - T a_y = p1.y - py; - T a_z = p1.z - pz; - T b_x = p2.x - px; - T b_y = p2.y - py; - T b_z = p2.z - pz; - T c_x = p3.x - px; - T c_y = p3.y - py; - T c_z = p3.z - pz; - - const T factor = 0.5; - T Q1_x = (a_y * b_z - a_z * b_y) * factor; - T Q1_y = (a_z * b_x - a_x * b_z) * factor; - T Q1_z = (a_x * b_y - a_y * b_x) * factor; - - T Q2_x = (b_y * c_z - b_z * c_y) * factor; - T Q2_y = (b_z * c_x - b_x * c_z) * factor; - T Q2_z = (b_x * c_y - b_y * c_x) * factor; - - T Q3_x = (c_y * a_z - c_z * a_y) * factor; - T Q3_y = (c_z * a_x - c_x * a_z) * factor; - T Q3_z = (c_x * a_y - c_y * a_x) * factor; - - T Q_x = Q1_x + Q2_x + Q3_x; - T Q_y = Q1_y + Q2_y + Q3_y; - T Q_z = Q1_z + Q2_z + Q3_z; - - - if ( UbMath::zero(Q_x * Q1_x + Q_y * Q1_y + Q_z * Q1_z ) ) return true; - else if( UbMath::zero(Q_x * Q2_x + Q_y * Q2_y + Q_z * Q2_z ) ) return true; - else if( UbMath::zero(Q_x * Q3_x + Q_y * Q3_y + Q_z * Q3_z ) ) return true; - else if( UbMath::less(Q_x * Q1_x + Q_y * Q1_y + Q_z * Q1_z, T(0.0) ) ) return false; - else if( UbMath::less(Q_x * Q2_x + Q_y * Q2_y + Q_z * Q2_z, T(0.0) ) ) return false; - else if( UbMath::less(Q_x * Q3_x + Q_y * Q3_y + Q_z * Q3_z, T(0.0) ) ) return false; - - return true; - } - - return false; - } - /* ======================================================================================= */ - template< typename T> - inline bool intersectLine(const UbTuple<T,T,T>& n1, const UbTuple<T,T,T>& n2, GbTriFaceMesh3D::TriFace& triFace, std::vector<GbTriFaceMesh3D::Vertex>& nodes) - { - GbTriFaceMesh3D::Vertex& p0=triFace.getNode(0,nodes); - - const T& n1X = val<1>(n1); - const T& n1Y = val<2>(n1); - const T& n1Z = val<3>(n1); - - const T& n2X = val<1>(n2); - const T& n2Y = val<2>(n2); - const T& n2Z = val<3>(n2); - - //if( Kd::isPointOnPlane(n1X, n1Y, n1Z, T(1.0E-6), p0, triFace) - // && Kd::isPointOnPlane(n2X, n2Y, n2Z, T(1.0E-6), p0, triFace)) - //{ - // return true; - //} - - T denom = ( n2X - n1X ) * triFace.nx + ( n2Y - n1Y ) * triFace.ny + ( n2Z - n1Z ) * triFace.nz; - - if( UbMath::zero( denom ) ) //line does not intersect the plane of the triangle ! - { - return false; - } - else - { - T d = - triFace.nx * p0.x - triFace.ny * p0.y - triFace.nz * p0.z; - T mu = T(-1.0 * (d + n1X * triFace.nx + n1Y * triFace.ny + n1Z * triFace.nz ) / denom); - - if( !UbMath::inClosedInterval( mu, T(0.0), T(1.0)) ) // Point of intersection of line and plane does not lie on the triangle - { - return false; - } - else - { - // intersection with plane - - //Test whether Point lies inside the triangle or not - GbTriFaceMesh3D::Vertex& p1=triFace.getNode(1,nodes); - GbTriFaceMesh3D::Vertex& p2=triFace.getNode(2,nodes); - - return Kd::isPointOnTriangle( n1X + ( (n2X - n1X) * mu ) //intersectionPointX - , n1Y + ( (n2Y - n1Y) * mu ) //intersectionPointY - , n1Z + ( (n2Z - n1Z) * mu ) //intersectionPointZ - , T(0.001) - , p0, p1, p2, triFace ); - } - } - } -} //namespace Kd - -#endif //KDUTILIES_H diff --git a/src/basics/geometry3d/KdTree/examples/AdvancedPIOTests/CMakeLists.txt b/src/basics/geometry3d/KdTree/examples/AdvancedPIOTests/CMakeLists.txt deleted file mode 100644 index 77bce4264..000000000 --- a/src/basics/geometry3d/KdTree/examples/AdvancedPIOTests/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -cmake_minimum_required(VERSION 2.6) - -PROJECT(kdtree_pioTest) - -################################################################# -# MACHINE_SPECIFIC CMAKE_CONFIG_FILE -################################################################# -INCLUDE("../../../../../CMake/CMakeCABMacros.txt") - -################################################################# -### PACKAGES ### -################################################################# -INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/3rdParty/dirstream/CMakePackage.txt) - -INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/container/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/memory/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/objects/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/writer/CMakePackage.txt) - -INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/KdTree/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/fem/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/creator/CMakePackage.txt) - -################################################################# -### OWN DEFINES ### -################################################################# -FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h - ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) - -SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES}) -SOURCE_GROUP(z_main FILES ${SPECIFIC_FILES}) - -################################################################# -### PROJECT ERSTELLEN ### -################################################################# -CREATE_CAB_PROJECT(${PROJECT_NAME} BINARY) diff --git a/src/basics/geometry3d/KdTree/examples/AdvancedPIOTests/main.cpp b/src/basics/geometry3d/KdTree/examples/AdvancedPIOTests/main.cpp deleted file mode 100644 index e608f44c4..000000000 --- a/src/basics/geometry3d/KdTree/examples/AdvancedPIOTests/main.cpp +++ /dev/null @@ -1,542 +0,0 @@ -#include <basics/utilities/UbTiming.h> -#include <basics/utilities/UbRandom.h> -#include <basics/utilities/UbTuple.h> - -#include <basics/writer/WbWriterAvsASCII.h> -#include <basics/writer/WbWriterAvsBinary.h> -#include <basics/writer/WbWriterVtkXmlBinary.h> -#include <basics/writer/WbWriterVtkXmlASCII.h> - -#include <basics/container/CbUniformMatrix3D.h> - -#include <numerics/geometry3d/GbTriFaceMesh3D.h> -#include <numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h> -#include <numerics/geometry3d/GbHalfSpace3D.h> - -#include <numerics/geometry3d/KdTree/KdTree.h> -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h> -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h> - -#include <stack> -#include <list> - -using namespace std; - -void createGrid(std::string meshfile, int maxNofPointsPerDir, Kd::SplitAlgorithm<float>& splitAlg, bool writeFiles = true, std::string outpath = "g:/temp"); -void recursiveGridFill(CbUniformMatrix3D<short>& grid, const short& xs, const short& ys, const short& zs, const short& type); -void iterativeGridFill(CbUniformMatrix3D<short>& grid, const short& xs, const short& ys, const short& zs, const short& type); - -#include <3rdParty/dirstream/dirstream.h> -#include <3rdParty/dirstream/filter_utils.h> // enthält die Definiton der bool'schen Ops für Filter - - -using namespace std; - -int main() -{ - try - { -// ////////////////////////////////////////////////////////////////////////// -// //STL File auswaehlen -// ////////////////////////////////////////////////////////////////////////// -// string pathname = "c:/temp"; -// string stlPath = "c:/temp"; -// dirstr::dirstream str(stlPath.c_str(), dirstr::op(dirstr::pattern_f("*.stl")) -// || dirstr::op(dirstr::pattern_f("*.ply")) || dirstr::op(dirstr::pattern_f("*.inp")) -// || dirstr::op(dirstr::pattern_f("*.mesh"))); -// -// // UbLog::setReportingLevel(logDEBUG5); -// UbLog::setReportingLevel(logINFO); -// -// vector<string> filenames; -// for(string entry; str >> entry;) -// { -// GbTriFaceMesh3D* mesh = GbTriFaceMesh3DCreator::getInstance()->readMeshFromFile(entry,"mesh"); -// -// string fn = UbSystem::getFilenameFromString(entry); -// mesh->writeMeshPly(pathname+"/"+fn+".ply"); -// -// delete mesh; -// } -// -// exit(0); - - //createGrid("c:/temp/clumps.stl", 200, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/50spheres.inp", 200, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/Sphere5040.inp", 200, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/cooling_2.inp", 400, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/NDR-Konzertsaal.inp", 100, Kd::SAHSplit<float>() , true, "g:/temp"); - - //createGrid("c:/temp/Campus-Details-W3.inp", 200, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/Boein707.mesh", 100, Kd::SAHSplit<float>() , true, "g:/temp"); - - //createGrid("c:/temp/dolphin.mesh", 400, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/box.ply", 10, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/bodyRight.stl", 200, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/flamingo.mesh", 200, Kd::SAHSplit<float>() , true, "g:/temp"); - - //createGrid("c:/temp/torus.inp", 256, Kd::SAHSplit<float>() , true, "g:/temp"); - createGrid("c:/temp/xzx_dragon.stl", 512, Kd::SAHSplit<float>() , true, "g:/temp"); -// createGrid("c:/temp/bunny_ascii.ply", 256, Kd::SAHSplit<float>() , true, "g:/temp"); -// createGrid("c:/temp/dragon_ascii.ply", 256, Kd::SAHSplit<float>() , true, "g:/temp"); -// createGrid("c:/temp/budda_ascii.ply", 256, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGridWithLines("c:/temp/box.ply", 10, Kd::SAHSplit<float>() , true, "g:/temp"); - -// createGrid("c:/temp/beatle.mesh",200, Kd::SAHSplit<float>(), true, "g:/temp"); -// createGrid("c:/temp/atrium-30000tri.inp",200, Kd::SAHSplit<float>(), true, "g:/temp"); -// createGrid("c:/temp/Buero.inp",200, Kd::SAHSplit<float>(), true, "g:/temp"); -// createGrid("c:/temp/office_space.inp",200, Kd::SAHSplit<float>(), true, "g:/temp"); - - //createGrid("d:/meshes/50spheres.inp",200, Kd::SAHSplit<float>(), true, "d:/temp"); - - //createGrid("c:/temp/torus.inp",200, Kd::SAHSplit<float>(), true, "g:/temp"); - //createGrid("c:/temp/bodyRight.stl", 200, Kd::SAHSplit<float>() , true, "g:/temp"); - - //createGrid("c:/temp/jetta.stl", 200, GbTriFaceMesh3D::KDTREE_SPATIALSPLIT , true, "g:/temp"); - //createGrid("c:/temp/jetta.stl", 200, Kd::SAHSplit<float>(), true, "g:/temp"); - //createGrid("c:/temp/VW_body.ply", 200, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/kugel.stl", 50, Kd::SAHSplit<float>() , true, "g:/temp"); - //createGrid("c:/temp/ship-2.mesh", 100, Kd::SAHSplit<float>() , true, "g:/temp/schiff2"); - } - catch(const std::exception& e) - { - UBLOG2( logERROR, std::cerr, "Caught exception:"); - UBLOG2( logERROR, std::cerr, "Type: " << typeid(e).name() ); - UBLOG2ML(logERROR, std::cerr, "What: " << e.what() ); - } - catch(...) - { - UBLOG2(logERROR, std::cerr, "unknown exception occurs in "<< UB_FUNCTION) - } -} - -namespace Flag -{ - const short UNDEF = 2; - const short SOLID = 1; - const short FLUID = 0; -} - -////////////////////////////////////////////////////////////////////// -void createGrid(std::string meshfile, int maxNofPointsPerDir, Kd::SplitAlgorithm<float>& splitAlg, bool writeFiles, std::string outpath) -{ - UbLog::setReportingLevel(logDEBUG5); - std::string filename = UbSystem::getFilenameFromString(meshfile); - - std::list< UbTuple<string, double> > timerVals; - UbTimer timer; - timer.start(); - GbTriFaceMesh3D* mesh = GbTriFaceMesh3DCreator::getInstance()->readMeshFromFile(meshfile,"mesh",GbTriFaceMesh3D::KDTREE_SAHPLIT); - timerVals.push_back( UbTuple<string, double>("mesh", timer.stop() ) ); - UBLOG( logINFO, "read mesh in "<<val<2>(timerVals.back())<<"s" ); - - timer.start(); - Kd::Tree<float> kdTree( *mesh, splitAlg ); - timerVals.push_back( UbTuple<string, double>("kdTree", timer.stop() ) ); - UBLOG( logINFO, "build tree in "<<val<2>(timerVals.back())<<"s" ); - - UBLOG(logINFO, "############################################################"); - UBLOG(logINFO, "nodes of TriFaceMesh....... "<<mesh->getNodes()->size() ); - UBLOG(logINFO, "triFaces of TriFaceMesh.... "<<mesh->getTriangles()->size() ); - UBLOG(logINFO, "triFace copies in KdTree... "<<kdTree.getNumOfTriFaces() ); - UBLOG(logINFO, "nodes of kdNodes of KdTree. "<<kdTree.getNumOfNodes() ); - UBLOG(logINFO, ""); - - ////////////////////////////////////////////////////////////////////////// - // Ausgangs 3-D_Feld erstellen - ////////////////////////////////////////////////////////////////////////// - const float percentOverLap = 0.05f; //=5% - const float maxLength = (1.0f+percentOverLap)*(float)UbMath::max( mesh->getLengthX1(), mesh->getLengthX2(), mesh->getLengthX3() ); - const float dx1 = maxLength/(maxNofPointsPerDir-1); - const float dx2 = dx1; - const float dx3 = dx1; - - const int nx1 = 1 + int( std::ceil(mesh->getLengthX1()*(1.0f+percentOverLap)/dx1)+0.5 ); - const int nx2 = 1 + int( std::ceil(mesh->getLengthX2()*(1.0f+percentOverLap)/dx2)+0.5 ); - const int nx3 = 1 + int( std::ceil(mesh->getLengthX3()*(1.0f+percentOverLap)/dx3)+0.5 ); - - CbUniformMatrix3D<short> solids(nx1,nx2,nx3,Flag::UNDEF); - - ////////////////////////////////////////////////////////////////////////// - // Knoten typisieren - ////////////////////////////////////////////////////////////////////////// - const float orgx1 = (float)( -0.5*percentOverLap*mesh->getLengthX1()+mesh->getX1Minimum() ); - const float orgx2 = (float)( -0.5*percentOverLap*mesh->getLengthX2()+mesh->getX2Minimum() ); - const float orgx3 = (float)( -0.5*percentOverLap*mesh->getLengthX3()+mesh->getX3Minimum() ); - - std::vector<GbTriFaceMesh3D::TriFace>& triFaces = *mesh->getTriangles(); - std::vector<GbTriFaceMesh3D::Vertex>& vertices = *mesh->getNodes(); - - float x1center = float( mesh->getX1Centroid() ); - float x2center = float( mesh->getX2Centroid() ); - float x3center = float( mesh->getX3Centroid() ); - - UBLOG( logINFO, "performing point-in-object(PIO)-tests"); - long counter1=0, counter2 = 0; - float x1w, x2w, x3w; - int x1Min, x2Min, x3Min, x1Max, x2Max, x3Max; - float einflussBereichKnoten_sq = dx1*dx1+dx2*dx2+dx3*dx3; - - timer.start(); - for(size_t t=0; t<triFaces.size(); t++) - { - GbTriFaceMesh3D::TriFace& triangle = triFaces[t]; - GbTriFaceMesh3D::Vertex& v1 = vertices[triangle.v1]; - GbTriFaceMesh3D::Vertex& v2 = vertices[triangle.v2]; - GbTriFaceMesh3D::Vertex& v3 = vertices[triangle.v3]; - - ////////////////////////////////////////////////////////////////////////// - // AABB riangle - ////////////////////////////////////////////////////////////////////////// - x1Min = /*UbMath::integerRounding*/( std::floor( ( UbMath::min( v1.x, v2.x, v3.x ) - orgx1) / dx1 ) ); - x2Min = /*UbMath::integerRounding*/( std::floor( ( UbMath::min( v1.y, v2.y, v3.y ) - orgx2) / dx2 ) ); - x3Min = /*UbMath::integerRounding*/( std::floor( ( UbMath::min( v1.z, v2.z, v3.z ) - orgx3) / dx3 ) ); - - x1Max = /*UbMath::integerRounding*/( std::ceil( ( UbMath::max( v1.x, v2.x, v3.x ) - orgx1) / dx1 ) ); - x2Max = /*UbMath::integerRounding*/( std::ceil( ( UbMath::max( v1.y, v2.y, v3.y ) - orgx2) / dx2 ) ); - x3Max = /*UbMath::integerRounding*/( std::ceil( ( UbMath::max( v1.z, v2.z, v3.z ) - orgx3) / dx3 ) ); - - GbHalfSpace3D halfSpace( v1.x, v1.y, v1.z, v2.x, v2.y, v2.z, v3.x, v3.y, v3.z ); - - for(int x3=x3Min; x3<=x3Max; x3++) - { - for(int x2=x2Min; x2<=x2Max; x2++) - { - for(int x1=x1Min; x1<=x1Max; x1++) - { - counter1++; - - short& solidVal = solids(x1,x2,x3); - - if( solidVal != Flag::UNDEF ) //doppeltes Testen vermeiden - { - continue; - } - - counter2++; - - //Weltkoords - x1w = orgx1+x1*dx1; - x2w = orgx2+x2*dx2; - x3w = orgx3+x3*dx3; - - float dist = (float)halfSpace.getDistance( x1w, x2w, x3w ); - if( UbMath::greater( dist, 0.0f) ) - { - continue; - } - if( UbMath::greater(dist*dist, einflussBereichKnoten_sq)) - { - continue; - } - - //eigentlicher PIO-Test - bool testFailed = true; - for(int i=0; i<100; i++ ) - { - Kd::Ray<float> ray( x1w, x2w, x3w //, 1, 0 ,0 ); - , ( x1w < x1center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) - , ( x2w < x2center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) - , ( x3w < x3center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) ); - - int iSec = kdTree.intersectRay( ray, Kd::CountRayIntersectionHandler<float>() ); - - if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen - { - if(iSec == Kd::Intersection::ON_BOUNDARY ) - { - solidVal = Flag::SOLID; - } - else - { - solidVal = (iSec&1); //ungerade anzahl an schnitten --> drinnen - } - testFailed = false; - break; - } - else - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if - an edge was hit "); - } - } - if( testFailed ) throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); - } - } - } - } - timerVals.push_back( UbTuple<string, double>("PiO-Test", timer.stop() ) ); - UBLOG( logINFO,counter2 <<" point-in-object(PIO)-tests done in "<<val<2>(timerVals.back())<<"s" ); - UBLOG( logINFO,counter1-counter2 <<" point-in-object(PIO)-tests uebersprungen" ); - - ////////////////////////////////////////////////////////////////////////// - // FLOOD FILL - ////////////////////////////////////////////////////////////////////////// - - if( false) //using just one seed point - { - //FUELL - bool foundSeedPoint = false; - int seedPointSearchCounter = 0; - int seedX1 = Ub::inf; - int seedX2 = Ub::inf; - int seedX3 = Ub::inf; - - timer.start(); - for(size_t t=0; t<triFaces.size(); t++) - { - GbTriFaceMesh3D::TriFace& triangle = triFaces[t]; - - float& nx = triangle.nx; - float& ny = triangle.ny; - float& nz = triangle.nz; - - float cx1 = triangle.getX1Centroid(vertices); - float cx2 = triangle.getX2Centroid(vertices); - float cx3 = triangle.getX3Centroid(vertices); - - for(int k=0; k<5; k++) - { - seedPointSearchCounter++; - - cx1 -= nx * dx1; - cx2 -= ny * dx2; - cx3 -= nz * dx3; - - int ix1 = UbMath::integerRounding( (cx1-orgx1)/dx1 ); - int ix2 = UbMath::integerRounding( (cx2-orgx2)/dx2 ); - int ix3 = UbMath::integerRounding( (cx3-orgx3)/dx3 ); - - if( solids.indicesInRange(ix1,ix2,ix3) - && solids(ix1, ix2, ix3 ) == Flag::UNDEF ) - { - x1w = orgx1+ix1*dx1; - x2w = orgx2+ix2*dx2; - x3w = orgx3+ix3*dx3; - - Kd::Ray<float> ray( x1w, x2w, x3w //, 1, 0 ,0 ); - , ( x1w < x1center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) - , ( x2w < x2center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) - , ( x3w < x3center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) ); - - int iSec = kdTree.intersectRay( ray, Kd::CountRayIntersectionHandler<float>() ); - - if( iSec>0 && (iSec&1) ) - { - seedX1 = ix1; - seedX2 = ix2; - seedX3 = ix3; - foundSeedPoint = true; - break; - } - } - } - if(foundSeedPoint) break; - } - if(!foundSeedPoint) - throw UbException(UB_EXARGS,"fuck no seed point found"); - timerVals.push_back( UbTuple<string, double>("Seed found in", timer.stop() ) ); - UBLOG( logINFO,"found seed Point in "<<val<2>(timerVals.back())<<"s with "<<seedPointSearchCounter << " tested points" ); - - cout<<nx1<<","<<nx2<<","<<nx3<<endl; - bool recursiveFloodFill = ( nx1*nx2*nx3 < 100*100*30 ); - if(recursiveFloodFill) - { - timer.start(); - recursiveGridFill(solids, seedX1, seedX2, seedX3, Flag::SOLID); - timerVals.push_back( UbTuple<string, double>("flood fill (r)", timer.stop() ) ); - UBLOG( logINFO,"recursive flood fill in "<<val<2>(timerVals.back())<<"s with "<<seedPointSearchCounter << " tested points" ); - - CbUniformMatrix3D<short> solidsCpy(solids); - timer.start(); - iterativeGridFill(solidsCpy, seedX1, seedX2, seedX3, Flag::SOLID); - timerVals.push_back( UbTuple<string, double>("flood fill (i)", timer.stop() ) ); - UBLOG( logINFO,"iterative flood fill in "<<val<2>(timerVals.back())<<"s with "<<seedPointSearchCounter << " tested points" ); - } - else - { - timer.start(); - iterativeGridFill(solids, seedX1, seedX2, seedX3, Flag::SOLID); - timerVals.push_back( UbTuple<string, double>("flood fill (r)", timer.stop() ) ); - UBLOG( logINFO,"recursive flood fill in "<<val<2>(timerVals.back())<<"s with "<<seedPointSearchCounter << " tested points" ); - } - - UBLOG(logINFO, "############################################################"); - - } - else //verifying complete arry - { - bool recursiveFloodFill = ( nx1*nx2*nx3 < 100*100*30 ); - int solidCounter = 0; - - timer.start(); - for(int x3=0; x3<solids.getNX3(); x3++) - for(int x2=0; x2<solids.getNX2(); x2++) - for(int x1=0; x1<solids.getNX1(); x1++) - { - if( solids(x1 ,x2 ,x3 ) == Flag::UNDEF ) - { - x1w = orgx1+x1*dx1; - x2w = orgx2+x2*dx2; - x3w = orgx3+x3*dx3; - - int iSec = -1; - do{ - Kd::Ray<float> ray( x1w, x2w, x3w //, 1, 0 ,0 ); - , ( x1w < x1center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) - , ( x2w < x2center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) - , ( x3w < x3center ? (float)UbRandom::rand(-1.0,-0.001, 10) : (float)UbRandom::rand(0.001, 1.0, 10) ) ); - - iSec = kdTree.intersectRay( ray, Kd::CountRayIntersectionHandler<float>() ); - }while(iSec<0); - - if( iSec&1 ) - { - if(recursiveFloodFill) recursiveGridFill(solids,x1,x2,x3,Flag::SOLID); - else iterativeGridFill(solids,x1,x2,x3,Flag::SOLID); - } - else - { - if(recursiveFloodFill) recursiveGridFill(solids,x1,x2,x3,Flag::FLUID); - else iterativeGridFill(solids,x1,x2,x3,Flag::FLUID); - } - } - } - if(recursiveFloodFill) timerVals.push_back( UbTuple<string, double>("flood fill (r)", timer.stop() ) ); - else timerVals.push_back( UbTuple<string, double>("flood fill (i)", timer.stop() ) ); - UBLOG( logINFO,"recursive flood fill in "<<val<2>(timerVals.back())<<"s " ); - } - - list< UbTuple< string, double > >::iterator iter; - for(iter = timerVals.begin(); iter!=timerVals.end(); ++iter) - { - UBLOG( logINFO, setw(16) << val<1>(*iter) << " in " << setw(8) << setprecision(8) << val<2>(*iter) << "s" ); - } - - int solidCounter = 0; - for(int x3=0; x3<solids.getNX3(); x3++) - for(int x2=0; x2<solids.getNX2(); x2++) - for(int x1=0; x1<solids.getNX1(); x1++) - { - if( solids(x1 ,x2 ,x3 ) == Flag::SOLID ) - { - solidCounter++; - } - } - - UBLOG( logINFO, "SOLIDS = " <<solidCounter); - UBLOG( logINFO, "SOLIDS = " <<solidCounter); - UBLOG( logINFO, "SOLIDS = " <<solidCounter); - UBLOG( logINFO, "SOLIDS = " <<solidCounter); - - /* ======================================================================================= */ - if(writeFiles) - { - UBLOG( logINFO, "writeFiles - start"); - string subfiledir = outpath+"/"+filename+"_solid_node_files"; - UbSystem::makeDirectory( subfiledir ); - - std::vector<UbTupleFloat3 > nodes; - std::vector<std::string > datanames(1,"data"); - datanames[0] = "solid"; - - std::vector< std::string > outFilenames; - - std::vector<std::vector<double > > nodedata( datanames.size() ); - - for(int x3=0; x3<solids.getNX3(); x3++) - for(int x2=0; x2<solids.getNX2(); x2++) - for(int x1=0; x1<solids.getNX1(); x1++) - { - if( solids(x1 ,x2 ,x3 ) == Flag::SOLID ) - { - nodes.push_back( makeUbTuple( orgx1+x1*dx1, orgx2+x2*dx2, orgx3+x3*dx3 ) ); - nodedata[0].push_back( solids(x1 ,x2 ,x3 ) ); - } - - if( nodes.size() > 2000000 - || ( x1==(solids.getNX1()-1) && x2==(solids.getNX2()-1) && x3==(solids.getNX3()-1) ) ) - { - outFilenames.push_back( WbWriterVtkXmlBinary::getInstance()->writeNodesWithNodeData(subfiledir+"/"+filename+"_solid_nodes_"+"_part"+UbSystem::toString(outFilenames.size()+1),nodes,datanames,nodedata) ); - nodes.clear(); - nodedata.clear(); - nodedata.resize( datanames.size() ); - } - } - - WbWriterVtkXmlBinary::getInstance()->writeCollection(outpath+"/"+filename+"_solids_nodes",outFilenames,0,false); - - - mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterVtkXmlBinary::getInstance()); - kdTree.writeTree(outpath+"/"+filename+"_kdTree",WbWriterVtkXmlBinary::getInstance()); - - UBLOG( logINFO, "writeFiles - end") - } - - delete mesh; -} - -namespace Dirs -{ - const int X1[] = { 1, -1, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1, 0, 0, 0, 0, 0 }; - const int X2[] = { 0, 0, 1, -1, 0, 0, 1, -1, -1, 1, 0, 0, 0, 0, 1, -1, 1, -1, 0 }; - const int X3[] = { 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 1, -1, -1, 1, 1, -1, -1, 1, 0 }; - - const int START = 0; - const int END6 = 5; - const int END18 = 17; -} -/*==================================================================*/ -bool floodFillCheck(CbUniformMatrix3D<short>& grid, const short& x, const short& y, const short& z) -{ - return grid.indicesInRange( x, y, z ) && grid(x,y,z)==Flag::UNDEF; -} -int g_counter = 0; -void recursiveGridFill(CbUniformMatrix3D<short>& grid, const short& xs, const short& ys, const short& zs, const short& type) -{ - // Algorithmus zum Füllen eines Polyeders, ausgehend vom Saatpunkt xs,ys,zs - - //Saatknoten einfärben - short& val = grid(xs,ys,zs); - if( val==Flag::UNDEF ) - { - val = type; - } - if( floodFillCheck( grid, xs+1, ys , zs ) ) recursiveGridFill( grid, xs+1, ys , zs , type ); - if( floodFillCheck( grid, xs , ys+1, zs ) ) recursiveGridFill( grid, xs , ys+1, zs , type ); - if( floodFillCheck( grid, xs , ys , zs+1 ) ) recursiveGridFill( grid, xs , ys , zs+1, type ); - if( floodFillCheck( grid, xs-1, ys , zs ) ) recursiveGridFill( grid, xs-1, ys , zs , type ); - if( floodFillCheck( grid, xs , ys-1, zs ) ) recursiveGridFill( grid, xs , ys-1, zs , type ); - if( floodFillCheck( grid, xs , ys , zs-1 ) ) recursiveGridFill( grid, xs , ys , zs-1, type ); -} -/*==================================================================*/ -void iterativeGridFill(CbUniformMatrix3D<short>& grid, const short& xs, const short& ys, const short& zs, const short& type) -{ - std::stack< UbTupleInt3 > stck; - stck.push( UbTupleInt3(xs,ys,zs) ); - - int x,y,z; - - while( !stck.empty() ) - { - x = val<1>( stck.top() ); - y = val<2>( stck.top() ); - z = val<3>( stck.top() ); - stck.pop(); - - short& flagType = grid( x, y, z ); - - if( flagType == Flag::UNDEF ) - { - flagType = type; - - if ( grid.indicesInRange( x+1, y , z ) ) stck.push( UbTupleInt3( x+1, y , z ) ); - if ( grid.indicesInRange( x , y+1, z ) ) stck.push( UbTupleInt3( x , y+1, z ) ); - if ( grid.indicesInRange( x , y , z+1 ) ) stck.push( UbTupleInt3( x , y , z+1 ) ); - if ( grid.indicesInRange( x-1, y , z ) ) stck.push( UbTupleInt3( x-1, y , z ) ); - if ( grid.indicesInRange( x , y-1, z ) ) stck.push( UbTupleInt3( x , y-1, z ) ); - if ( grid.indicesInRange( x , y , z-1 ) ) stck.push( UbTupleInt3( x , y , z-1 ) ); - } - } -} diff --git a/src/basics/geometry3d/KdTree/examples/PIOTests/CMakeLists.txt b/src/basics/geometry3d/KdTree/examples/PIOTests/CMakeLists.txt deleted file mode 100644 index c6c94204a..000000000 --- a/src/basics/geometry3d/KdTree/examples/PIOTests/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -cmake_minimum_required(VERSION 2.6) - -PROJECT(kdtree_pioTest) - -################################################################# -# MACHINE_SPECIFIC CMAKE_CONFIG_FILE -################################################################# -INCLUDE("../../../../../CMake/CMakeCABMacros.txt") - -################################################################# -### PACKAGES ### -################################################################# -INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/container/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/memory/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/objects/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/basics/writer/CMakePackage.txt) - -INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/KdTree/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/fem/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/creator/CMakePackage.txt) - -################################################################# -### OWN DEFINES ### -################################################################# -FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h - ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) - -SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES}) -SOURCE_GROUP(z_main FILES ${SPECIFIC_FILES}) - -################################################################# -### PROJECT ERSTELLEN ### -################################################################# -CREATE_CAB_PROJECT(${PROJECT_NAME} BINARY) diff --git a/src/basics/geometry3d/KdTree/examples/PIOTests/main.cpp b/src/basics/geometry3d/KdTree/examples/PIOTests/main.cpp deleted file mode 100644 index f24132c36..000000000 --- a/src/basics/geometry3d/KdTree/examples/PIOTests/main.cpp +++ /dev/null @@ -1,342 +0,0 @@ -#include <basics/utilities/UbTiming.h> -#include <basics/utilities/UbRandom.h> - -#include <basics/writer/WbWriterAvsASCII.h> -#include <basics/writer/WbWriterAvsBinary.h> -#include <basics/writer/WbWriterVtkXmlBinary.h> -#include <basics/writer/WbWriterVtkXmlASCII.h> - -#include <basics/container/CbUniformMatrix4D.h> - -#include <numerics/geometry3d/GbTriFaceMesh3D.h> -#include <numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h> - -#include <numerics/geometry3d/KdTree/KdTree.h> -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h> -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h> - -using namespace std; - -void KdTreeTest (std::string meshfile, int maxNofPointsPerDir, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM pio, bool writeFiles = true, std::string outpath = "g:/temp"); -void KdTreeTestWithLines(std::string meshfile, int maxNofPointsPerDir, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM pio, bool writeFiles = true, std::string outpath = "g:/temp"); - -int main() -{ - try - { - //KdTreeTest("c:/temp/clumps.stl", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/50spheres.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/Sphere5040.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/cooling_2.inp", 400, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/NDR-Konzertsaal.inp", 100, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - - //KdTreeTest("c:/temp/Campus-Details-W3.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/Boein707.mesh", 100, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - - //KdTreeTest("c:/temp/dolphin.mesh", 400, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/box.ply", 10, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/bodyRight.stl", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/flamingo.mesh", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - - //KdTreeTest("c:/temp/torus.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTestWithLines("c:/temp/box.ply", 10, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - - KdTreeTest("c:/temp/doppelwandbox.ply", 100, GbTriFaceMesh3D::KDTREE_SPATIALSPLIT, true, "g:/temp"); - - //KdTreeTestWithLines("c:/temp/torus.inp", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT, true, "g:/temp"); - - //KdTreeTestWithLines("c:/temp/bodyRight.stl", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - - //KdTreeTest("c:/temp/jetta.stl", 200, GbTriFaceMesh3D::KDTREE_SPATIALSPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/jetta.stl", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT, true, "g:/temp"); - //KdTreeTest("c:/temp/VW_body.ply", 200, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/kugel.stl", 50, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp"); - //KdTreeTest("c:/temp/ship-2.mesh", 100, GbTriFaceMesh3D::KDTREE_SAHPLIT , true, "g:/temp/schiff2"); - } - catch(const std::exception& e) - { - UBLOG2( logERROR, std::cerr, "Caught exception:"); - UBLOG2( logERROR, std::cerr, "Type: " << typeid(e).name() ); - UBLOG2ML(logERROR, std::cerr, "What: " << e.what() ); - } - catch(...) - { - UBLOG2(logERROR, std::cerr, "unknown exception occurs in "<< UB_FUNCTION) - } - - - - -} - -////////////////////////////////////////////////////////////////////// -void KdTreeTest(std::string meshfile, int maxNofPointsPerDir, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM pio, bool writeFiles, std::string outpath) -{ - UbLog::setReportingLevel(logDEBUG5); - std::string filename = UbSystem::getFilenameFromString(meshfile); - - GbTriFaceMesh3D* mesh = GbTriFaceMesh3DCreator::getInstance()->readMeshFromFile(meshfile,"mesh",pio); - mesh->scale(10000,10000,10000); - //dummy test, damit der baum erstellt wird - mesh->isPointInGbObject3D(0,0,0); - - UBLOG(logINFO, "############################################################"); - UBLOG(logINFO, "nodes of TriFaceMesh....... "<<mesh->getNodes()->size() ); - UBLOG(logINFO, "triFaces of TriFaceMesh.... "<<mesh->getTriangles()->size() ); - UBLOG(logINFO, "triFace copies in KdTree... "<<mesh->getKdTree()->getNumOfTriFaces() ); - UBLOG(logINFO, "nodes of kdNodes of KdTree. "<<mesh->getKdTree()->getNumOfNodes() ); - UBLOG(logINFO, ""); - - - const float percentOverLap = 0.05f; //=5% - const float maxLength = (1.0f+percentOverLap)*UbMath::max( mesh->getLengthX1(), mesh->getLengthX2(), mesh->getLengthX3() ); - const float dx1 = maxLength/(maxNofPointsPerDir-1); - const float dx2 = dx1; - const float dx3 = dx1; - - const int nx1 = 1 + int( std::ceil(mesh->getLengthX1()*(1.0f+percentOverLap)/dx1)+0.5 ); - const int nx2 = 1 + int( std::ceil(mesh->getLengthX2()*(1.0f+percentOverLap)/dx2)+0.5 ); - const int nx3 = 1 + int( std::ceil(mesh->getLengthX3()*(1.0f+percentOverLap)/dx3)+0.5 ); - - CbUniformMatrix4D<int> solids(nx1,nx2,nx3,1,0); - - const float orgx1 = -0.5*percentOverLap*mesh->getLengthX1()+mesh->getX1Minimum(); - const float orgx2 = -0.5*percentOverLap*mesh->getLengthX2()+mesh->getX2Minimum(); - const float orgx3 = -0.5*percentOverLap*mesh->getLengthX3()+mesh->getX3Minimum(); - - const float outX1 = 2*mesh->getX1Maximum(); - const float outX2 = 0;//2*mesh->getX2Maximum(); - const float outX3 = 0;//2*mesh->getX3Maximum(); - - UBLOG( logINFO, "performing " << nx1*nx2*nx3 <<" point-in-object(PIO)-tests"); - UbTimer ff; - ff.start(); - for(int x3=0; x3<solids.getNX3(); x3++) - for(int x2=0; x2<solids.getNX2(); x2++) - for(int x1=0; x1<solids.getNX1(); x1++) - { - solids(x1,x2,x3,0) = mesh->isPointInGbObject3D(orgx1+x1*dx1, orgx2+x2*dx2, orgx3+x3*dx3); - } - UBLOG( logINFO, nx1*nx2*nx3 <<" point-in-object(PIO)-tests done in "<<ff.stop()<<"s" ); - UBLOG(logINFO, "############################################################"); - - - /* ======================================================================================= */ - if(writeFiles) - { - UBLOG( logINFO, "writeFiles - start"); - string subfiledir = outpath+"/"+filename+"_solid_node_files"; - UbSystem::makeDirectory( subfiledir ); - - std::vector<UbTupleFloat3 > nodes; - std::vector<std::string > datanames(solids.getNX4(),"data"); - datanames[0] = "solid"; - //datanames[1] = "solid"; - - std::vector< std::string > outFilenames; - - std::vector<std::vector<double > > nodedata( datanames.size() ); - for(int x3=0; x3<solids.getNX3(); x3++) - for(int x2=0; x2<solids.getNX2(); x2++) - for(int x1=0; x1<solids.getNX1(); x1++) - { - if( solids(x1 ,x2 ,x3 , 0) ) - { - nodes.push_back( makeUbTuple( orgx1+x1*dx1, orgx2+x2*dx2, orgx3+x3*dx3 ) ); - - for(int i=0; i<solids.getNX4(); i++) - { - nodedata[i].push_back( solids(x1 ,x2 ,x3 ,i) ); - } - } - - if( nodes.size() > 2000000 - || ( x1==(solids.getNX1()-1) && x2==(solids.getNX2()-1) && x3==(solids.getNX3()-1) ) ) - { - outFilenames.push_back( WbWriterVtkXmlBinary::getInstance()->writeNodesWithNodeData(subfiledir+"/"+filename+"_solid_nodes_"+"_part"+UbSystem::toString(outFilenames.size()+1),nodes,datanames,nodedata) ); - nodes.clear(); - nodedata.clear(); - nodedata.resize( datanames.size() ); - } - } - - WbWriterVtkXmlBinary::getInstance()->writeCollection(outpath+"/"+filename+"_solids_nodes",outFilenames,0,false); - - - mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterVtkXmlBinary::getInstance(),true); - mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterAvsASCII::getInstance(),true); - mesh->getKdTree()->writeTree(outpath+"/"+filename+"_kdTree",WbWriterVtkXmlBinary::getInstance()); - - UBLOG( logINFO, "writeFiles - end") - } -} - -////////////////////////////////////////////////////////////////////// -void KdTreeTestWithLines(std::string meshfile, int maxNofPointsPerDir, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM pio, bool writeFiles, std::string outpath) -{ - UbLog::setReportingLevel(logDEBUG5); - std::string filename = UbSystem::getFilenameFromString(meshfile); - - GbTriFaceMesh3D* mesh = GbTriFaceMesh3DCreator::getInstance()->readMeshFromFile(meshfile,"mesh",pio); - - //dummy test, damit der baum erstellt wird - mesh->isPointInGbObject3D(0,0,0); - - UBLOG(logINFO, "############################################################"); - UBLOG(logINFO, "nodes of TriFaceMesh....... "<<mesh->getNodes()->size() ); - UBLOG(logINFO, "triFaces of TriFaceMesh.... "<<mesh->getTriangles()->size() ); - UBLOG(logINFO, "triFace copies in KdTree... "<<mesh->getKdTree()->getNumOfTriFaces() ); - UBLOG(logINFO, "nodes of kdNodes of KdTree. "<<mesh->getKdTree()->getNumOfNodes() ); - UBLOG(logINFO, ""); - - - const float percentOverLap = 0.05f; //=5% - const float maxLength = (1.0f+percentOverLap)*UbMath::max( mesh->getLengthX1(), mesh->getLengthX2(), mesh->getLengthX3() ); - const float dx1 = maxLength/(maxNofPointsPerDir-1); - const float dx2 = dx1; - const float dx3 = dx1; - - const int nx1 = 1 + /*UbMath::integerRounding*/( std::ceil(mesh->getLengthX1()*(1.0f+percentOverLap)/dx1) ); - const int nx2 = 1 + /*UbMath::integerRounding*/( std::ceil(mesh->getLengthX2()*(1.0f+percentOverLap)/dx2) ); - const int nx3 = 1 + /*UbMath::integerRounding*/( std::ceil(mesh->getLengthX3()*(1.0f+percentOverLap)/dx3) ); - - CbUniformMatrix4D<int> solids(nx1,nx2,nx3,2,0); - - const float orgx1 = -0.5*percentOverLap*mesh->getLengthX1()+mesh->getX1Minimum(); - const float orgx2 = -0.5*percentOverLap*mesh->getLengthX2()+mesh->getX2Minimum(); - const float orgx3 = -0.5*percentOverLap*mesh->getLengthX3()+mesh->getX3Minimum(); - -// const float outX1 = 2*mesh->getX1Maximum(); -// const float outX2 = 2*mesh->getX2Maximum(); -// const float outX3 = 2*mesh->getX3Maximum(); - - - Kd::Tree<double>* kdTree = mesh->getKdTree(); - - std::vector<GbTriFaceMesh3D::TriFace>& triFaces = *mesh->getTriangles(); - std::vector<GbTriFaceMesh3D::Vertex>& vertices = *mesh->getNodes(); - - float x1center = float( mesh->getX1Centroid() ); - float x2center = float( mesh->getX2Centroid() ); - float x3center = float( mesh->getX3Centroid() ); - - UBLOG( logINFO, "performing point-in-object(PIO)-tests"); - UbTimer ff; - ff.start(); - long counter1=0, counter2 = 0; - for(size_t t=0; t<triFaces.size(); t++) - { - int x1Min = /*UbMath::integerRounding*/( std::floor( (triFaces[t].getMinX(vertices)-orgx1) / dx1 ) ); - int x2Min = /*UbMath::integerRounding*/( std::floor( (triFaces[t].getMinY(vertices)-orgx2) / dx2 ) ); - int x3Min = /*UbMath::integerRounding*/( std::floor( (triFaces[t].getMinZ(vertices)-orgx3) / dx3 ) ); - - int x1Max = /*UbMath::integerRounding*/( std::ceil( (triFaces[t].getMaxX(vertices)-orgx1) / dx1 ) ); - int x2Max = /*UbMath::integerRounding*/( std::ceil( (triFaces[t].getMaxY(vertices)-orgx2) / dx2 ) ); - int x3Max = /*UbMath::integerRounding*/( std::ceil( (triFaces[t].getMaxZ(vertices)-orgx3) / dx3 ) ); - - for(int x3=x3Min; x3<=x3Max; x3++) - for(int x2=x2Min; x2<=x2Max; x2++) - for(int x1=x1Min; x1<=x1Max; x1++) - { - counter1++; - - if( !solids.indicesInRange(x1,x2,x3,0) - || solids(x1,x2,x3,1) == 1 ) //doppeltes Testeb vermeiden - { - continue; - } - - counter2++; - - double x1w = orgx1+x1*dx1; - double x2w = orgx2+x2*dx2; - double x3w = orgx3+x3*dx3; - - //eigentlicher PIO-Test - bool testFailed = true; - for(int i=0; i<100; i++) - { - UbTupleDouble3 n1(x1w, x2w, x3w); - UbTupleDouble3 n2( double( x1w < x1center ? mesh->getX1Minimum()-UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX1() : mesh->getX1Maximum()+UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX1() ) - , double( x2w < x2center ? mesh->getX2Minimum()-UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX2() : mesh->getX2Maximum()+UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX2() ) - , double( x3w < x3center ? mesh->getX3Minimum()-UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX3() : mesh->getX3Maximum()+UbRandom::rand(0.5, 1.0, 10)*mesh->getLengthX3() ) ); - - int iSec = kdTree->intersectLine( n1, n2, Kd::CountLineIntersectionHandler<double>() ); - - if( iSec != Kd::Intersection::INTERSECT_EDGE ) //KEINE Kante getroffen - { - if(iSec == Kd::Intersection::ON_BOUNDARY ) - { - solids(x1,x2,x3,0) = true; - } - else - { - solids(x1,x2,x3,0) = (iSec&1); //ungerade anzahl an schnitten --> drinnen - } - testFailed = false; - break; - } - else - { - UBLOG(logDEBUG3, "GbTriFaceMesh3D.isPointInGbObject3D.if - an edge was hit "); - } - } - if( testFailed ) throw UbException(UB_EXARGS, "ups, nach 100 Strahlen immer noch kein Ergebnis"); - solids(x1,x2,x3,1) = 1; - } - } - UBLOG( logINFO,counter2 <<" point-in-object(PIO)-tests done in "<<ff.stop()<<"s" ); - UBLOG( logINFO,counter1-counter2 <<" point-in-object(PIO)-tests uebersprungen" ); - UBLOG(logINFO, "############################################################"); - - /* ======================================================================================= */ - if(writeFiles) - { - UBLOG( logINFO, "writeFiles - start"); - string subfiledir = outpath+"/"+filename+"_solid_node_files"; - UbSystem::makeDirectory( subfiledir ); - - std::vector<UbTupleFloat3 > nodes; - std::vector<std::string > datanames(solids.getNX4(),"data"); - datanames[0] = "solid"; - //datanames[1] = "solid"; - - std::vector< std::string > outFilenames; - - std::vector<std::vector<double > > nodedata( datanames.size() ); - for(int x3=0; x3<solids.getNX3(); x3++) - for(int x2=0; x2<solids.getNX2(); x2++) - for(int x1=0; x1<solids.getNX1(); x1++) - { - if( solids(x1 ,x2 ,x3 , 0) ) - { - nodes.push_back( makeUbTuple( orgx1+x1*dx1, orgx2+x2*dx2, orgx3+x3*dx3 ) ); - - for(int i=0; i<solids.getNX4(); i++) - { - nodedata[i].push_back( solids(x1 ,x2 ,x3 ,i) ); - } - } - - if( nodes.size() > 2000000 - || ( x1==(solids.getNX1()-1) && x2==(solids.getNX2()-1) && x3==(solids.getNX3()-1) ) ) - { - outFilenames.push_back( WbWriterVtkXmlBinary::getInstance()->writeNodesWithNodeData(subfiledir+"/"+filename+"_solid_nodes_"+"_part"+UbSystem::toString(outFilenames.size()+1),nodes,datanames,nodedata) ); - nodes.clear(); - nodedata.clear(); - nodedata.resize( datanames.size() ); - } - } - - WbWriterVtkXmlBinary::getInstance()->writeCollection(outpath+"/"+filename+"_solids_nodes",outFilenames,0,false); - - - mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterVtkXmlBinary::getInstance()); - mesh->writeMesh(outpath+"/"+filename+"_mesh",WbWriterAvsASCII::getInstance()); - mesh->getKdTree()->writeTree(outpath+"/"+filename+"_kdTree",WbWriterVtkXmlBinary::getInstance()); - - UBLOG( logINFO, "writeFiles - end") - } -} diff --git a/src/basics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h b/src/basics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h deleted file mode 100644 index 025a913cf..000000000 --- a/src/basics/geometry3d/KdTree/intersectionhandler/KdCountLineIntersectionHandler.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef KDCOUNTLINEINTERSECTIONHANDLER_H -#define KDCOUNTLINEINTERSECTIONHANDLER_H - -#include <basics/utilities/UbTuple.h> -#include <basics/utilities/UbKeys.h> - -#include <numerics/geometry3d/GbTriFaceMesh3D.h> - -#include <numerics/geometry3d/KdTree/KdNode.h> -#include <numerics/geometry3d/KdTree/KdUtilities.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h> - -#include <set> - -namespace Kd -{ - template< typename T > - class CountLineIntersectionHandler : public LineIntersectionHandler<T> - { - public: - bool intersectLine(const UbTuple<T,T,T>& n1, const UbTuple<T,T,T>& n2, Node<T>& parent, Node<T>*& child1, Node<T>*& child2) const - { - if( parent.intersectLineBoundingBox(n1, n2) == Intersection::INTERSECTION) - { - if( parent.isLeaf() ) - { - std::vector<GbTriFaceMesh3D::TriFace>& triFaces = *parent.getTriFaces(); - std::vector<GbTriFaceMesh3D::Vertex>& nodes = parent.getNodes(); - - for( std::size_t i=0; i<triFaces.size(); i++ ) - { - GbTriFaceMesh3D::TriFace& triFace = triFaces[i]; - - if( Kd::intersectLine(n1, n2, triFace, nodes) ) return true; - } - return false; - } - else - { - if( child1 ) - { - if (child1->intersectLine(n1, n2, *this)) return true; - } - if( child2 ) - { - if (child2->intersectLine(n1, n2, *this)) return true; - } - } - } - return false; - } - /* ======================================================================================= */ - }; -} - -#endif //KDCOUNTLINEINTERSECTIONHANDLER_H diff --git a/src/basics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h b/src/basics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h deleted file mode 100644 index e426723c1..000000000 --- a/src/basics/geometry3d/KdTree/intersectionhandler/KdCountRayIntersectionHandler.h +++ /dev/null @@ -1,164 +0,0 @@ -#ifndef KDCOUNTRAYINTERSECTIONHANDLER_H -#define KDCOUNTRAYINTERSECTIONHANDLER_H - -#include <basics/utilities/UbTuple.h> -#include <basics/utilities/UbKeys.h> - -#include <numerics/geometry3d/GbTriFaceMesh3D.h> - -#include <numerics/geometry3d/KdTree/KdNode.h> -//#include <numerics/geometry3d/KdTree/KdUtilities.h> -#include <numerics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h> - -#include <set> - -namespace Kd -{ - template< typename T > - class CountRayIntersectionHandler : public RayIntersectionHandler<T> - { - public: - int intersectRay(const Ray<T>& ray, Node<T>& parent, Node<T>*& child1, Node<T>*& child2, std::set< UbKeys::Key3<int> >& mailbox) const - { - if( parent.intersectRayBoundingBox(ray) == Intersection::INTERSECTION) - { - if( parent.isLeaf() ) - { - return this->checkIntersectionWithTriFaces(ray, *parent.getTriFaces(), parent.getNodes(), mailbox); - } - else - { - int sum = 0; - if( child1 ) - { - int erg = child1->intersectRay(ray, *this, mailbox); - if(erg < 0) - { - return erg; - } - sum += erg; - } - if( child2 ) - { - int erg = child2->intersectRay(ray, *this, mailbox); - if(erg < 0) - { - return erg; - } - sum += erg; - } - return sum; - } - } - else - { - return 0; - } - } - /* ======================================================================================= */ - - private: - int checkIntersectionWithTriFaces(const Ray<T>& ray, std::vector<GbTriFaceMesh3D::TriFace>& triFaces, std::vector<GbTriFaceMesh3D::Vertex>& nodes, std::set< UbKeys::Key3<int> >& mailbox) const - { - T e1x,e1y,e1z,e2x,e2y,e2z,px,py,pz,a,f,sx,sy,sz,u,qx,qy,qz,v,factor; - - int counter = 0, iSec = 0; - - for( std::size_t i=0; i<triFaces.size(); i++ ) - { - GbTriFaceMesh3D::TriFace& triFace = triFaces[i]; - - if( mailbox.find( UbKeys::Key3<int>(triFace.getIndexVertex1(), triFace.getIndexVertex2(), triFace.getIndexVertex3() ) )==mailbox.end() ) - { - mailbox.insert( UbKeys::Key3<int>(triFace.getIndexVertex1(), triFace.getIndexVertex2(), triFace.getIndexVertex3() ) ); //schon hier rein, ansonsten muss man es unten bei JEDEm continue und am ende des ifs machen - - GbTriFaceMesh3D::Vertex& v1 = triFace.getNode(0, nodes); - GbTriFaceMesh3D::Vertex& v2 = triFace.getNode(1, nodes); - GbTriFaceMesh3D::Vertex& v3 = triFace.getNode(2, nodes); - - ////////////////////////////////////////////////////////////////////////// - //Raytracing - start( Anm.: prüft NUR in Strahlrichtung - // Grundidee: Schnittpunkt in Baryzentrischen Koordinaten besimmten - // t(u,v,w) = w*v0 + u*v1 + v*v2 - // mit w = 1.0-u-v, da fuer alle Punkte (u,v,w) im Dreick gilt u+v+w = 1 - // wenn u, v oder w == 0 -> Punkt liegt auf Kante - // wenn u, v oder w == 1 -> Punkt liegt auf Eckpunkt (-> die anderen Werte muessen 0 ) - - //e1 = v1 - v0 - e1x = v2.x-v1.x; - e1y = v2.y-v1.y; - e1z = v2.z-v1.z; - - //e2 = v2 - v0 - e2x = v3.x-v1.x; - e2y = v3.y-v1.y; - e2z = v3.z-v1.z; - - //p = d x e2 - px = ray.directionY*e2z - ray.directionZ*e2y; - py = ray.directionZ*e2x - ray.directionX*e2z; - pz = ray.directionX*e2y - ray.directionY*e2x; - - //a = e1 dot p - a = e1x*px + e1y*py + e1z*pz; - //if( fabs(a)<1.E-10 ) continue; - if( fabs(a) < UbMath::Epsilon<T>::val() ) continue; - f = T(1.0/a); - - //s = o - v0 - sx = ray.originX - v1.x; - sy = ray.originY - v1.y; - sz = ray.originZ - v1.z; - - //u = f * ( s dot p) - u = f * ( sx*px + sy*py + sz*pz ); - - //u ist nur gueltig in [0;1] - if( ( UbMath::less( u, T(0.0) ) ) || ( UbMath::greater(u, T(1.0) ) ) ) - { - continue; - } - - //q = s x e1 - qx = sy*e1z - sz*e1y; - qy = sz*e1x - sx*e1z; - qz = sx*e1y - sy*e1x; - - //v = f*(e2 dot q) - v = f * (ray.directionX*qx + ray.directionY*qy + ray.directionZ*qz); - - //v ist nur gueltig in [0;1] da aber v bereits gueltig ist -> u+v darf nicht > 1.0 sein ;-) - if( ( UbMath::less(v, T(0.0) ) ) || ( UbMath::greater(u+v, T(1.0) ) ) ) - { - continue; - } - - //t = f * (e2 dot q) - factor = f * (e2x*qx + e2y*qy + e2z*qz); - //Raytracing - end - ////////////////////////////////////////////////////////////////////////// - - if( UbMath::zero( factor ) ) - { - return Intersection::ON_BOUNDARY; //ray.Org liegt direkt auf einem dreieck --> boundary - } - if( factor < 0.0 ) - { - continue; //Schnittpunkt liegt in entgegengesetzter Strahlrichtung - } - - //edge tests - //wenn u, v oder w ==0 -> Punkt liegt auf Kante bzw. Eckpunkt - if( UbMath::zero(u) ) return Intersection::INTERSECT_EDGE; - if( UbMath::zero(v) ) return Intersection::INTERSECT_EDGE; - if( UbMath::zero(T(1.0)-u-v) ) return Intersection::INTERSECT_EDGE; - - counter++; - } - } - return counter; - } - }; -} - -#endif //KDCOUNTRAYLINEINTERSECTIONHANDLER_H diff --git a/src/basics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h b/src/basics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h deleted file mode 100644 index 65f94876a..000000000 --- a/src/basics/geometry3d/KdTree/intersectionhandler/KdLineIntersectionHandler.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef KDLINEINTERSECTIONHANDLER_H -#define KDLINEINTERSECTIONHANDLER_H - -#include <basics/utilities/UbTuple.h> -//#include <numerics/geometry3d/GbTriFaceMesh3D.h> - -#include <set> - -// #ifdef CAB_RCF -// # include <3rdParty/rcf/RcfSerializationIncludes.h> -// #end -namespace Kd -{ - template< typename T> - class Node; - - template< typename T> - class LineIntersectionHandler - { - public: - virtual bool intersectLine(const UbTuple<T,T,T>& n1, const UbTuple<T,T,T>& n2, Node<T>& parent, Node<T>*& child1, Node<T>*& child2) const = 0; - virtual ~LineIntersectionHandler() {} - }; -} - -// #if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) -// SF_NO_CTOR(Kd::LineIntersectionHandler<float>); -// SF_NO_CTOR(Kd::LineIntersectionHandler<double>); -// #endif //RCF_USE_SF_SERIALIZATI -#endif //KDLINEINTERSECTIONHANDLER_H diff --git a/src/basics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h b/src/basics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h deleted file mode 100644 index 7578d9046..000000000 --- a/src/basics/geometry3d/KdTree/intersectionhandler/KdRayIntersectionHandler.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef KDRAYINTERSECTIONHANDLER_H -#define KDRAYINTERSECTIONHANDLER_H - -#include <basics/utilities/UbTuple.h> -#include <numerics/geometry3d/KdTree/KdRay.h> - -#include <set> - -namespace Kd -{ - template< typename T> - class RayIntersectionHandler - { - public: - virtual int intersectRay(const Ray<T>& ray, Node<T>& parent, Node<T>*& child1, Node<T>*& child2, std::set< UbKeys::Key3<int> >& mailbox) const = 0; - virtual ~RayIntersectionHandler() {} - }; -} - -#endif //KDRAYINTERSECTIONHANDLER_H diff --git a/src/basics/geometry3d/KdTree/package.include b/src/basics/geometry3d/KdTree/package.include deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp b/src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp deleted file mode 100644 index da4ff2746..000000000 --- a/src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.cpp +++ /dev/null @@ -1,10 +0,0 @@ -//#include <numerics/geometry3d/KdTree/SAHSplit.h> - - -// namespace Kd -// { -// const double SAHSplit::Ct = 3.0; //traversal cost -// const double SAHSplit::Ci = 4.0; //ray-patch-intersection-cost -// } - - diff --git a/src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h b/src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h deleted file mode 100644 index aa2a739a3..000000000 --- a/src/basics/geometry3d/KdTree/splitalgorithms/KdSAHSplit.h +++ /dev/null @@ -1,287 +0,0 @@ -#ifndef KDSAHSPLIT_H -#define KDSAHSPLIT_H - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbInfinity.h> -#include <numerics/geometry3d/GbTriFaceMesh3D.h> - -#include <numerics/geometry3d/KdTree/KdNode.h> -#include <numerics/geometry3d/KdTree/KdUtilities.h> -#include <numerics/geometry3d/KdTree/KdSplitCandidateManager.h> -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h> - -#include <vector> -#include <cmath> - -namespace Kd -{ - template< typename T > - class SAHSplit : public SplitAlgorithm<T> - { - public: - /* ======================================================================================= */ - SplitCandidate<T> findBestSplitCandidate(const int& level, const int& maxLevel, Node<T>& node ) const - { - if( !node.getTriFaces() ) throw UbException(UB_EXARGS, "triFace NULL pointer"); - - if( node.getTriFaces()->size() <= 1 //max triangles in node - || level >= maxLevel ) - { - return SplitCandidate<T>(); - } - - SplitCandidate<T> bestSplitCandidate; - T minCN = Ub::inf; - - for(int splitAxis = 0; splitAxis < 3; splitAxis++) - { - SplitCandidateManager<T> sc; - findPossibleSplitCandidates(splitAxis, node, sc); - - // incremental sweep to find best split position - for( std::size_t i = 0; i < sc.size(); i++) - { - if (i == 0) - { - sc[i].nl = sc.objects_starting_outside_left + sc.objects_fully_outside_node; - sc[i].nr = node.getTriFaces()->size() - sc[0].np - sc[0].ending; - } - else - { - sc[i].nl = sc[i - 1].nl + sc[i - 1].starting + sc[i - 1].np; - sc[i].nr = sc[i - 1].nr - sc[i ].ending - sc[i ].np; - } - - this->calcSAH(sc[i], node); - - if (sc[i].Cn < minCN) - { - minCN = sc[i].Cn; - bestSplitCandidate = sc[i]; - } - } - } - - // automatic termination criterion (SAH) - if ( bestSplitCandidate.isValid && bestSplitCandidate.Cn >= node.getTriFaces()->size() * Ci) - { - return SplitCandidate<T>(); - } - - return bestSplitCandidate; - } - /* ======================================================================================= */ - void distributeTriFaces(const SplitCandidate<T>& candidate, std::vector<GbTriFaceMesh3D::TriFace>& triFacesForChild1, std::vector<GbTriFaceMesh3D::TriFace>& triFacesForChild2, Node<T>& node) const - { - if( !node.getTriFaces() ) throw UbException(UB_EXARGS, "null pointer at triface list"); - - std::vector<GbTriFaceMesh3D::TriFace>& srcTriFaces = *node.getTriFaces(); - std::vector<GbTriFaceMesh3D::Vertex>& srcNodes = node.getNodes(); - std::vector<T> projection; - - for(std::size_t i=0; i<srcTriFaces.size(); i++) - { - GbTriFaceMesh3D::TriFace& triFace = srcTriFaces[i]; - Kd::project2Axis(triFace, srcNodes, candidate.axis, projection); - - T& min = projection[0]; - T& max = projection[2]; - // --------------------------------------------------- // - // case 1 : object inside plane - if( UbMath::equal(min, max) ) - { - if( UbMath::equal(min, candidate.position) ) - { - if(candidate.np_left) - { - triFacesForChild1.push_back(triFace); - } - else if(candidate.np_right) - { - triFacesForChild2.push_back(triFace); - } - } - else if( UbMath::less(min, candidate.position) ) - { - triFacesForChild1.push_back(triFace); - } - else //if( UbMath::greater(min, candidate.position) - { - triFacesForChild2.push_back(triFace); - } - } // - // --------------------------------------------------- // - // case 2 : object on left side of plane - else if( UbMath::lessEqual(max,candidate.position) ) - { - triFacesForChild1.push_back(triFace); - } // --------------------------------------------------- // - // case 3 : object on right side of plane - else if ( UbMath::greaterEqual( min, candidate.position) ) - { - triFacesForChild2.push_back(triFace); - }// - // --------------------------------------------------- // - // case 4 : object in both nodes - else - { - triFacesForChild1.push_back(triFace); - triFacesForChild2.push_back(triFace); - }// - // --------------------------------------------------- // - } - - node.deleteTriFaces(); - } - - - private: - /* ======================================================================================= */ - // cost function - inline T calcCosts(const int& nl, const int& nr, const T& SA_VL, const T& SA_VR, const T& SA_V) const - { - return Ct + Ci * (nl * SA_VL / SA_V + nr * SA_VR / SA_V); - } - /* ======================================================================================= */ - void findPossibleSplitCandidates(const int& splitAxis, Node<T>& node, SplitCandidateManager<T>& splitCandidateManager) const - { - T p1_node = (splitAxis == Axis::X ? node.x[0] : splitAxis == Axis::Y ? node.y[0] : node.z[0]); - T p2_node = (splitAxis == Axis::X ? node.x[1] : splitAxis == Axis::Y ? node.y[1] : node.z[1]); - - if( !node.getTriFaces() ) throw UbException(UB_EXARGS, "null pointer"); - - std::vector<GbTriFaceMesh3D::TriFace>& srcTriFaces = *node.getTriFaces(); - std::vector<GbTriFaceMesh3D::Vertex >& srcNodes = node.getNodes(); - std::vector<T> projection; - - for(std::size_t i=0; i<srcTriFaces.size(); i++) - { - GbTriFaceMesh3D::TriFace& triFace = srcTriFaces[i]; - - // project object to axis - Kd::project2Axis(triFace,srcNodes,splitAxis, projection); - // left point - T& p1 = projection[0]; - // right point - T& p2 = projection[2]; - - // --------------------------------------------------- // - // --------------------------------------------------- // - // case 1 : object is fully inside the current node - if( UbMath::greaterEqual(p1, p1_node) - && UbMath::lessEqual(p2, p2_node) ) - { - if( UbMath::equal(p1, p2) ) - { - // object is inside the plane - splitCandidateManager.add(p1, splitAxis, 0, 0, 1); - } - else - { - splitCandidateManager.add(p1, splitAxis, 1, 0, 0); - splitCandidateManager.add(p2, splitAxis, 0, 1, 0); - } - } // - // --------------------------------------------------- // - // --------------------------------------------------- // - // case 2 : just the right point (p2) is inside the current node - else if( UbMath::less(p1, p1_node) - && UbMath::lessEqual(p2,p2_node) - && UbMath::greaterEqual(p2, p1_node) ) - { - splitCandidateManager.add(p2, splitAxis, 0, 1, 0); - splitCandidateManager.objects_starting_outside_left++; - } // - // --------------------------------------------------- // - // --------------------------------------------------- // - // case 3 : just the left point (p1) is inside the current node - else if( UbMath::greaterEqual(p1, p1_node) - && UbMath::greater(p2, p2_node) - && UbMath::lessEqual(p1, p2_node) ) - { - splitCandidateManager.add(p1, splitAxis, 1, 0, 0); - } // - // --------------------------------------------------- // - // --------------------------------------------------- // - // case 4 : left and right point are outside the current node - else if( UbMath::less(p1, p1_node) - && UbMath::greater(p2, p2_node) ) - { - splitCandidateManager.objects_fully_outside_node++; - } // - // --------------------------------------------------- // - // --------------------------------------------------- // - } - - splitCandidateManager.createSortedArray(); - } - - - /* ======================================================================================= */ - // calculates the costs for a given splitCandidate based on the Surface Area Heuristic (SAH) - void calcSAH(SplitCandidate<T>& candidate, Node<T>& node) const - { - T p1_node = (candidate.axis == Axis::X ? node.x[0] : candidate.axis == Axis::Y ? node.y[0] : node.z[0]); - - // edges of (root) voxel - T dx = std::fabs(node.x[1] - node.x[0]); - T dy = std::fabs(node.y[1] - node.y[0]); - T dz = std::fabs(node.z[1] - node.z[0]); - - // surface area (root) voxel - T SA_V = T((2.0 * dx * dy) + (2.0 * dx * dz) + (2.0 * dy * dz)); - - T delta = (candidate.axis == Axis::X ? dx : candidate.axis == Axis::Y ? dy : dz); - T deltaL = std::fabs(candidate.position - p1_node); - T deltaR = std::fabs(delta - deltaL); - - // edges of sub voxel left - T dx_l = (candidate.axis == Axis::X ? deltaL : dx), dy_l = (candidate.axis == Axis::Y ? deltaL : dy), dz_l = (candidate.axis == Axis::Z ? deltaL : dz); - - // surface area sub voxel left - T SA_VL = T( (2.0 * dx_l * dy_l) + (2.0 * dx_l * dz_l) + (2.0 * dy_l * dz_l) ); - - // edges of sub voxel right - T dx_r = (candidate.axis == Axis::X ? deltaR : dx), dy_r = (candidate.axis == Axis::Y ? deltaR : dy), dz_r = (candidate.axis == Axis::Z ? deltaR : dz); - - // surface area sub voxel right - T SA_VR = T( (2.0 * dx_r * dy_r) + (2.0 * dx_r * dz_r) + (2.0 * dy_r * dz_r) ); - - if (candidate.np == 0) - { - candidate.Cn = calcCosts(candidate.nl, candidate.nr, SA_VL, SA_VR, SA_V); - return; - } - - // once putting np with nl, and once with nr - and select the one with lowest cost - // see: Wald, Havran: "On building fast kd-Trees for Ray Tracing, and doing that in O(N log N)", 2006 - T CP_L = calcCosts(candidate.nl + candidate.np, candidate.nr , SA_VL, SA_VR, SA_V); - T CP_R = calcCosts(candidate.nl , candidate.nr + candidate.np, SA_VL, SA_VR, SA_V); - - if(CP_L < CP_R) - { - candidate.Cn = CP_L; - candidate.np_right = true; - } - else - { - candidate.Cn = CP_R; - candidate.np_left = true; - } - } - /* ======================================================================================= */ - - protected: - static const T Ct;// = 3.0; traversal cost - static const T Ci;// = 4.0; ray-patch-intersection-cost - }; - - - template< typename T> - const T SAHSplit<T>::Ct = 3.0; //traversal cost - template< typename T> - const T SAHSplit<T>::Ci = 4.0; //ray-patch-intersection-cost -} - -#endif //KDSAHSPLIT_H diff --git a/src/basics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h b/src/basics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h deleted file mode 100644 index b87c18b48..000000000 --- a/src/basics/geometry3d/KdTree/splitalgorithms/KdSpatiallMedianSplit.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef SPATIALLMEDIANSPLIT_H -#define SPATIALLMEDIANSPLIT_H - -#include <basics/utilities/UbMath.h> -#include <numerics/geometry3d/GbTriFaceMesh3D.h> - -#include <numerics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h> - -namespace Kd -{ - template< typename T > - class SpatialMedianSplit : public SplitAlgorithm<T> - { - /* ======================================================================================= */ - SplitCandidate<T> findBestSplitCandidate(const int& level, const int& maxLevel, Node<T>& node ) const - { - if( node.getTriFaces()->size() <= 24 //max triangles in node - || level >= maxLevel ) - { - return SplitCandidate<T>(); - } - - T dx = std::fabs(node.x[1] - node.x[0]); - T dy = std::fabs(node.y[1] - node.y[0]); - T dz = std::fabs(node.z[1] - node.z[0]); - - if ( UbMath::equal(dx, UbMath::max(dx, dy, dz) ) ) return SplitCandidate<T>(Axis::X, node.x[0] + 0.5 * dx, 0, 0, 0); - else if( UbMath::equal(dy, UbMath::max(dy, dz ) ) ) return SplitCandidate<T>(Axis::Y, node.y[0] + 0.5 * dy, 0, 0, 0); - - return SplitCandidate<T>(Axis::Z, node.z[0] + 0.5 * dz, 0, 0, 0); - - } - /* ======================================================================================= */ - void distributeTriFaces(const SplitCandidate<T>& candidate, std::vector<GbTriFaceMesh3D::TriFace>& primitives_child1, std::vector<GbTriFaceMesh3D::TriFace>& primitives_child2, Node<T>& node) const - { - if( !node.getTriFaces() ) throw UbException(UB_EXARGS, "null pointer"); - - std::vector<GbTriFaceMesh3D::TriFace>& srcTriFaces = *node.getTriFaces(); - std::vector<GbTriFaceMesh3D::Vertex>& srcNodes = node.getNodes(); - std::vector<T> projection; - - for(std::size_t i=0; i<srcTriFaces.size(); i++) - { - GbTriFaceMesh3D::TriFace& triFace = srcTriFaces[i]; - Kd::project2Axis(triFace, srcNodes, candidate.axis, projection); - - T& min = projection[0]; - T& max = projection[2]; - - // case 1 : object inside plane - if( UbMath::equal(min,max) ) - { - if( UbMath::equal(min,candidate.position) ) - { - primitives_child1.push_back(triFace); - primitives_child2.push_back(triFace); - } - else if( UbMath::less(min, candidate.position) ) - { - primitives_child1.push_back(triFace); - } - else if( UbMath::greater(min, candidate.position) ) - { - primitives_child2.push_back(triFace); - } - } - // case 2 : object on left side of plane - else if( UbMath::lessEqual(max, candidate.position) ) - { - primitives_child1.push_back(triFace); - } - // case 3 : object on right side of plane - else if( UbMath::greaterEqual(min, candidate.position) ) - { - primitives_child2.push_back(triFace); - } - // case 4 : object in both nodes - else - { - primitives_child1.push_back(triFace); - primitives_child2.push_back(triFace); - } - } - - node.deleteTriFaces(); - } - }; -} - -#endif //SPATIALLMEDIANSPLIT_H diff --git a/src/basics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h b/src/basics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h deleted file mode 100644 index 162443005..000000000 --- a/src/basics/geometry3d/KdTree/splitalgorithms/KdSplitAlgorithm.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef KDSPLITALGORITHM_H -#define KDSPLITALGORITHM_H - -#include <numerics/geometry3d/GbTriFaceMesh3D.h> -//#include <numerics/geometry3d/KdTree/Node.h> -#include <numerics/geometry3d/KdTree/KdSplitCandidate.h> - -#include <vector> - -namespace Kd -{ - template< typename T > - class Node; - - template< typename T > - class SplitAlgorithm - { - public: - virtual SplitCandidate<T> findBestSplitCandidate(const int& level, const int& maxLevel, Node<T>& node ) const = 0; - virtual void distributeTriFaces(const SplitCandidate<T>& candidate, std::vector<GbTriFaceMesh3D::TriFace>& triFacesForChild1, std::vector<GbTriFaceMesh3D::TriFace>& triFacesForChild2, Node<T>& node) const=0; - virtual ~SplitAlgorithm() {} - }; -} - - -#endif //KDSPLITALGORITHM_H diff --git a/src/basics/geometry3d/creator/GbCuboid3DCreator.h b/src/basics/geometry3d/creator/GbCuboid3DCreator.h deleted file mode 100644 index 4f1414b7d..000000000 --- a/src/basics/geometry3d/creator/GbCuboid3DCreator.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef GBCUBOID3DCREATOR_H -#define GBCUBOID3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbCuboid3D.h> - -#ifdef CAB_QT -#include <numerics/geometry3d/presentation/QGbCuboid3DInstrument.h> -#include <QtGui/QWidget> -#include <QtGui/QDialog> -#endif - -#ifdef CAB_VTK -#include <numerics/geometry3d/presentation/vtkGbCuboid3D.h> -#endif - -class GbCuboid3DCreator : public GbObject3DCreator -{ -public: - static GbCuboid3DCreator* getInstance() - { - static GbCuboid3DCreator instance; - return &instance; - } - - GbCuboid3D* createGbObject3D() { return new GbCuboid3D(); } - - std::string getGbObject3DTypeID() { return "GbCuboid3D"; }; - std::string toString() { return "GbCuboid3DCreator"; } - -private: - GbCuboid3DCreator() : GbObject3DCreator() {} - - GbCuboid3DCreator( const GbCuboid3DCreator& ); //no copy allowed - const GbCuboid3DCreator& operator=( const GbCuboid3DCreator& ); //no copy allowed - -#ifdef CAB_QT -public: - GbCuboid3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0) - { - GbCuboid3D* cuboid = this->createGbObject3D(); - cuboid->getPoint2()->setX1(2.0); - cuboid->getPoint2()->setX2(2.0); - cuboid->getPoint2()->setX3(2.0); - - QGbCuboid3DInstrument instrument(parent, flags); - instrument.setGbCuboid3D(cuboid); - if (instrument.exec()) { return cuboid; } - delete cuboid; - - return NULL; - } - - QDialog* getSpecificInstrument(QWidget* parent=0, Qt::WFlags flags=0) { return new QGbCuboid3DInstrument(parent, flags); } - - void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0) - { - GbCuboid3D* cuboid = dynamic_cast<GbCuboid3D*>(gbObj); - if(!cuboid) throw UbException(UB_EXARGS,"selected object to edit is no GbCuboid3D!"); - - QGbCuboid3DInstrument instrument(parent, flags); - instrument.setGbCuboid3D(cuboid); - instrument.exec(); - } -#endif -#ifdef CAB_VTK -public: - Presentator* createObjectPresentator(ObObject *object) { return new vtkGbCuboid3D(dynamic_cast<GbCuboid3D*>(object)); } -#endif - -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbCuboid3DCreator::getInstance()), CAB_GbCuboid3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbCylinder3DCreator.h b/src/basics/geometry3d/creator/GbCylinder3DCreator.h deleted file mode 100644 index 7769985da..000000000 --- a/src/basics/geometry3d/creator/GbCylinder3DCreator.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef GBCYLINDER3DCREATOR_H -#define GBCYLINDER3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbCylinder3D.h> - -#ifdef CAB_QT -#include <numerics/geometry3d/presentation/QGbCylinder3DInstrument.h> -#include <QtGui/QWidget> -#include <QtGui/QDialog> -#endif - -#ifdef CAB_VTK -#include <numerics/geometry3d/presentation/vtkGbCylinder3D.h> -#endif - - -class GbCylinder3DCreator : public GbObject3DCreator -{ -public: - static GbCylinder3DCreator* getInstance() - { - static GbCylinder3DCreator instance; - return &instance; - } - - GbCylinder3D* createGbObject3D() { return new GbCylinder3D(); } - - std::string getGbObject3DTypeID(){ return "GbCylinder3D"; } - std::string toString() { return "GbCylinder3DCreator"; } - -private: - GbCylinder3DCreator( const GbCylinder3DCreator& ); //no copy allowed - const GbCylinder3DCreator& operator=( const GbCylinder3DCreator& ); //no copy allowed -GbCylinder3DCreator() : GbObject3DCreator() {} - -#ifdef CAB_QT -public: - - GbCylinder3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0) - { - GbCylinder3D* cylinder = this->createGbObject3D(); - cylinder->setRadius(2.0); - cylinder->setPoint1(0.0, 0.0, 0.0); - cylinder->setPoint2(0.0, 5.0, 0.0); - - QGbCylinder3DInstrument instrument(parent, flags); - instrument.setGbCylinder3D(cylinder); - if (instrument.exec()){ return cylinder; } - delete cylinder; - - return NULL; - } - - QDialog* getSpecificInstrument(QWidget* parent=0, Qt::WFlags flags=0) - { - return new QGbCylinder3DInstrument(parent, flags); - } - - void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0) - { - GbCylinder3D* cylinder = dynamic_cast<GbCylinder3D*>(gbObj); - if(!cylinder) throw UbException(UB_EXARGS,"selected object to edit is no GbCylinder3D!"); - - QGbCylinder3DInstrument instrument(parent, flags); - instrument.setGbCylinder3D(cylinder); - instrument.exec(); - } -#endif -#ifdef CAB_VTK -public: - Presentator* createObjectPresentator(ObObject *object) { return new vtkGbCylinder3D(dynamic_cast<GbCylinder3D*>(object)); } -#endif - -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbCylinder3DCreator::getInstance()), CAB_GbCylinder3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbLine3DCreator.h b/src/basics/geometry3d/creator/GbLine3DCreator.h deleted file mode 100644 index cb5bdb991..000000000 --- a/src/basics/geometry3d/creator/GbLine3DCreator.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef GBLINE3DCREATOR_H -#define GBLINE3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbLine3D.h> - -class GbLine3DCreator : public GbObject3DCreator -{ -public: - static GbLine3DCreator* getInstance() - { - static GbLine3DCreator instance; - return &instance; - } - - GbLine3D* createGbObject3D() { return new GbLine3D(); } - - std::string getGbObject3DTypeID(){ return "GbLine3D"; } - std::string toString() { return "GbLine3DCreator"; } - -private: - GbLine3DCreator( const GbLine3DCreator& ); //no copy allowed - const GbLine3DCreator& operator=( const GbLine3DCreator& ); //no copy allowed - GbLine3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbLine3DCreator::getInstance()), CAB_GbLine3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbObject3DCreator.h b/src/basics/geometry3d/creator/GbObject3DCreator.h deleted file mode 100644 index e2cc7b638..000000000 --- a/src/basics/geometry3d/creator/GbObject3DCreator.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef GBOBJECT3DCREATOR_H -#define GBOBJECT3DCREATOR_H - -#include <string> - -#include <basics/objects/ObObjectCreator.h> -#include <basics/utilities/UbAutoRun.hpp> - -#include <numerics/geometry3d/GbObject3D.h> - -#ifdef CAB_QT -#include <qdialog.h> -#endif - -#ifdef CAB_VTK -#include <userinterface/presentation/vtkPoElement3D.h> -#endif - -#ifdef CAB_PARAVIEW -#include "vtkPVSource.h" -#endif - -class GbObject3DCreator : public ObObjectCreator -{ -protected: - GbObject3DCreator() {} -private: - GbObject3DCreator( const GbObject3DCreator& ); //no copy allowed !!! - const GbObject3DCreator& operator=( const GbObject3DCreator& ); //no copy allowed -public: - virtual ~GbObject3DCreator(){} - - virtual std::string getTypeID() { return getGbObject3DTypeID();} - virtual ObObject* createObObject() - { - return this->createGbObject3D(); - } - - - virtual GbObject3D* createGbObject3D()=0; - virtual std::string getGbObject3DTypeID()=0; - virtual std::string toString() { return "GbObject3DCreator"; } - -#ifdef CAB_QT - virtual GbObject3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0) { throw UbException(UB_EXARGS,"Not implemented..."); } - virtual void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0) { throw UbException(UB_EXARGS,"Not implemented..."); } -#endif - //die Teile von ObObjectCreator ... -#ifdef CAB_QT - void showSpecificInstrument(ObObject* object,QWidget* parent=0) - { - GbObject3D* geoObj = dynamic_cast<GbObject3D*>(object); - this->editGbObject3DwithQt(geoObj, parent); - } - virtual ObObject* createObObjectWithQt() { return this->createGbObject3DwithQt();} - virtual QObObjectSpecificInstrument* getSpecificInstrument() { throw UbException(UB_EXARGS,"not implemented"); } - -#endif -#ifdef CAB_VTK - virtual Presentator* createObjectPresentator(ObObject *object) { return NULL; } -#endif - - -#ifdef CAB_PARAVIEW - virtual vtkPVSource* createPVSource(vtkPVWindow *Window) { throw UbException(UB_EXARGS,"vtkPVSource* createPVSource"); } -#endif - - -}; - -#include <numerics/geometry3d/creator/GbObject3DFactory.h> - -/*=========================================================================*/ -#endif - - - diff --git a/src/basics/geometry3d/creator/GbObject3DFactory.cpp b/src/basics/geometry3d/creator/GbObject3DFactory.cpp deleted file mode 100644 index 2b1f2412e..000000000 --- a/src/basics/geometry3d/creator/GbObject3DFactory.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include <numerics/geometry3d/creator/GbObject3DFactory.h> -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -//#include <numerics/geometry3d/creator/GbPoint3DCreator.h> -// #include <numerics/geometry3d/creator/GbCuboid3DCreator.h> -// #include <numerics/geometry3d/creator/GbSphere3DCreator.h> -// #include <numerics/geometry3d/creator/GbCylinder3DCreator.h> -// #include <numerics/geometry3d/creator/GbLine3DCreator.h> -// #include <numerics/geometry3d/creator/GbPolygon3DCreator.h> -// #include <numerics/geometry3d/creator/GbTriangle3DCreator.h> -// #include <numerics/geometry3d/creator/GbTriangularMesh3DCreator.h> - -using namespace std; - -//GbObject3DFactory* GbObject3DFactory::instance = NULL; - -/*======================================================================*/ -GbObject3DFactory::GbObject3DFactory() - : ObObjectFactory() -{ -} -/*======================================================================*/ -GbObject3DFactory* GbObject3DFactory::getInstance() -{ - static GbObject3DFactory instance; - return &instance; -} - -///*======================================================================*/ -//void GbObject3DFactory::addGbObject3DCreator(GbObject3DCreator* creator) -//{ -// //cout<<"Meth:"<<creator->toString()<<" Meth-ID:"<<creator->getGbObject3DTypeID()<<endl; -// creatorSet.insert(pair<string, GbObject3DCreator*>(creator->getGbObject3DTypeID(), creator)); -//} -// -//void GbObject3DFactory::deleteGbObject3DCreator(GbObject3DCreator* creator) -//{ -// throw UbException(UB_EXARGS,"GbObject3DFactory::deleteGbObject3DCreator not yet implemented"); -// // this.creatorSet.delete(creator); -//} - -/*======================================================================*/ -GbObject3D* GbObject3DFactory::createGbObject3D(UbFileInput *in) -{ - string str = in->readString(); - //cout<<"GbObject3DFactory::createGbObject3D:"<<str<<endl; - - GbObject3D *gbObject3D = createEmptyGbObject3D(str); - - if(!gbObject3D) - throw UbException(UB_EXARGS,"creator for type available"); - - gbObject3D->read(in); - - return gbObject3D; -} -/*======================================================================*/ -GbObject3D* GbObject3DFactory::createEmptyGbObject3D(string objectType) -{ - typedef std::map<string, ObObjectCreator*>::iterator CreatorIterator; - std::map<string, ObObjectCreator*>* creatorSet = this->getCreatorSet(); - CreatorIterator creatorIterator = creatorSet->find(objectType); - - if(creatorIterator == creatorSet->end()) - throw UbException(UB_EXARGS,"factory has no creator for "+objectType); - - GbObject3DCreator *creator = dynamic_cast<GbObject3DCreator*>(creatorIterator->second); - - if(!creator) - throw UbException(UB_EXARGS,"factory has no creator for "+objectType); - - return creator->createGbObject3D(); -} -/*======================================================================*/ -//GbObject3DCreator* GbObject3DFactory::getCreator(string objectType) -//{ -// CreatorIterator creatorIterator = creatorSet.find(objectType); -// if(creatorIterator == creatorSet.end()) throw UbException(UB_EXARGS,"factory has no creator for "+objectType); -// GbObject3DCreator *creator = creatorIterator->second; -// if(!creator) throw UbException(UB_EXARGS,"factory has no creator for "+objectType); -// return(creator); -//} -/*======================================================================*/ -string GbObject3DFactory::toString() -{ - stringstream ss; - ss<<"GbObject2DFactory"; - int a=1; - std::map<std::string, ObObjectCreator*>::iterator creatorIterator; - std::map<std::string, ObObjectCreator*>* tmp = this->getCreatorSet(); - for(creatorIterator=tmp->begin(); creatorIterator!=tmp->end(); creatorIterator++) - { - ss<<(a++)<<". "; - ss<<creatorIterator->second->getTypeID(); - ss<<endl; - } - return(ss.str()); -} diff --git a/src/basics/geometry3d/creator/GbObject3DFactory.h b/src/basics/geometry3d/creator/GbObject3DFactory.h deleted file mode 100644 index 0231e34ad..000000000 --- a/src/basics/geometry3d/creator/GbObject3DFactory.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef GBOBJECT3DFACTORY_H -#define GBOBJECT3DFACTORY_H - -#include <string> -#include <sstream> -#include <map> - -#include <basics/objects/ObObjectFactory.h> - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileInput.h> - -class GbObject3D; -class GbObject3DCreator; - -class GbObject3DFactory : public ObObjectFactory -{ -private: - GbObject3DFactory(); - GbObject3DFactory( const GbObject3DFactory& ); //no copy allowed - const GbObject3DFactory& operator=( const GbObject3DFactory& ); //no copy allowed -public: - static GbObject3DFactory* getInstance(); - - GbObject3D* createGbObject3D(UbFileInput* in); - - //void addGbObject3DCreator(GbObject3DCreator* creator); - //void deleteGbObject3DCreator(GbObject3DCreator* creator); - //std::map<std::string, GbObject3DCreator*>* getCreatorSet() { return &creatorSet; } - - std::string toString(); - GbObject3D* createEmptyGbObject3D(std::string objectType); - //GbObject3DCreator* getCreator(std::string objectTypeID); - -private: - - - //std::map<std::string, GbObject3DCreator*> creatorSet; - //typedef std::map<std::string, GbObject3DCreator*>::iterator CreatorIterator; -}; -/*=========================================================================*/ -#endif - diff --git a/src/basics/geometry3d/creator/GbPoint3DCreator.h b/src/basics/geometry3d/creator/GbPoint3DCreator.h deleted file mode 100644 index e861fe2cb..000000000 --- a/src/basics/geometry3d/creator/GbPoint3DCreator.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef GBPOINT3DCREATOR_H -#define GBPOINT3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbPoint3D.h> - -class GbPoint3DCreator : public GbObject3DCreator -{ -public: - static GbPoint3DCreator* getInstance() - { - static GbPoint3DCreator instance; - return &instance; - } - - GbPoint3D* createGbObject3D() { return new GbPoint3D(); } - - std::string getGbObject3DTypeID() { return "GbPoint3D"; } - std::string toString() { return "GbPoint3DCreator"; } - -private: - GbPoint3DCreator( const GbPoint3DCreator& ); //no copy allowed - const GbPoint3DCreator& operator=( const GbPoint3DCreator& ); //no copy allowed - GbPoint3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbPoint3DCreator::getInstance()), CAB_GbPoint3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbPolygon3DCreator.h b/src/basics/geometry3d/creator/GbPolygon3DCreator.h deleted file mode 100644 index 72435ff0a..000000000 --- a/src/basics/geometry3d/creator/GbPolygon3DCreator.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef GBPOLYGON3DCREATOR_H -#define GBPOLYGON3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbPoint3D.h> - -class GbPolygon3DCreator : public GbObject3DCreator -{ -public: - static GbPolygon3DCreator* getInstance() - { - static GbPolygon3DCreator instance; - return &instance; - } - - GbPolygon3D* createGbObject3D() { return new GbPolygon3D(); } - - std::string getGbObject3DTypeID() { return "GbPolygon3D"; } - std::string toString() { return "GbPolygon3DCreator"; } - -private: - GbPolygon3DCreator( const GbPolygon3DCreator& ); //no copy allowed - const GbPolygon3DCreator& operator=( const GbPolygon3DCreator& ); //no copy allowed - - GbPolygon3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbPolygon3DCreator::getInstance()), CAB_GbPolygon3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp b/src/basics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp deleted file mode 100644 index d5cc520a3..000000000 --- a/src/basics/geometry3d/creator/GbQuadFaceMesh3DCreator.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include <numerics/geometry3d/creator/GbQuadFaceMesh3DCreator.h> -#include <numerics/geometry3d/GbQuadFaceMesh3D.h> -#include <basics/utilities/UbFileInputASCII.h> - -using namespace std; - -/***************************************************************************/ -GbObject3D* GbQuadFaceMesh3DCreator::createGbObject3D() -{ - return new GbQuadFaceMesh3D(); -} -/***************************************************************************/ -GbQuadFaceMesh3D* GbQuadFaceMesh3DCreator::createQuadMesh3D(int nodesX1, int nodesX2, float startX1, float startX2, double knotenabstandX1, double knotenabstandX2, float nullNiveau, string name) -{ - vector<GbQuadFaceMesh3D::Vertex> *vertices = new vector<GbQuadFaceMesh3D::Vertex>; - vector<GbQuadFaceMesh3D::QuadFace> *quads = new vector<GbQuadFaceMesh3D::QuadFace>; - for(int x1=0;x1<nodesX1;x1++) - { - for(int x2=0;x2<nodesX2;x2++) - { - vertices->push_back(GbQuadFaceMesh3D::Vertex((float)(x1*knotenabstandX1+startX1), (float)(x2*knotenabstandX2+startX2), nullNiveau)); - } - } - for(int x1=0;x1<nodesX1-1;x1++) - { - for(int x2=0;x2<nodesX2-1;x2++) - { - int index = x1*nodesX2+x2; - quads->push_back(GbQuadFaceMesh3D::QuadFace(index, index+nodesX2, index+nodesX2+1, index+1)); - } - } - - return (new GbQuadFaceMesh3D(name, vertices, quads)); -} - -/*============================================================*/ - -#ifdef CAB_QT - -GbQuadFaceMesh3D* GbQuadFaceMesh3DCreator::createGbObject3DwithQt() -{ - //QString s = QFileDialog::getOpenFileName(NULL,NULL,NULL,"open file dialog","Choose a STL file" ); - //QString s = QFileDialog::getOpenFileName(NULL, "Choose a STL file", "/home", "*.stl"); - //QFileDialog* fd = new QFileDialog( NULL ); - //fd->setIconText(QString("Hallo")); - //fd->show(); - //TODO: Open File Dialog einbauen. - //UbFileInputASCII in( s.toAscii().data() ); - //stringstream stream; - //stream <<"TriangularMesh3D ";//<<_objCount++; - //GbQuadFaceMesh3D *mesh = NULL;//GbQuadFaceMesh3DCreator::readMeshFromSTLFile(&in, stream.str() ); - //return mesh; - return NULL; -} -//QDialog* getSpecificInstrument() { return 0;} -void GbQuadFaceMesh3DCreator::editGbObject3DwithQt(GbObject3D* gbObj) -{ - -} -#endif -#ifdef CAB_VTK -Presentator* GbQuadFaceMesh3DCreator::createObjectPresentator(ObObject *object) -{ - return NULL; -} -#endif diff --git a/src/basics/geometry3d/creator/GbQuadFaceMesh3DCreator.h b/src/basics/geometry3d/creator/GbQuadFaceMesh3DCreator.h deleted file mode 100644 index c2d779c63..000000000 --- a/src/basics/geometry3d/creator/GbQuadFaceMesh3DCreator.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef GBQUADFACEMESH3DCREATOR_H -#define GBQUADFACEMESH3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> - -class GbQuadFaceMesh3D; - -#ifdef CAB_QT - -#endif - -#ifdef CAB_VTK -//#include <numerics/geometry3d/presentation/vtkGbQuadangularMesh3D.h> -#endif - -class GbQuadFaceMesh3DCreator : public GbObject3DCreator -{ -public: - static GbQuadFaceMesh3DCreator* getInstance() - { - static GbQuadFaceMesh3DCreator instance; - return &instance; - } - static GbQuadFaceMesh3D *createQuadMesh3D(int nodesX1, int nodesX2, float startX1, float startX2, double knotenabstandX1, double knotenabstandX2, float nullNiveau, std::string name); - - GbObject3D* createGbObject3D(); - - std::string getGbObject3DTypeID() { return "GbQuadFaceMesh3D"; } - std::string toString() { return "GbQuadFaceMesh3DCreator"; } - -#ifdef CAB_QT - - GbQuadFaceMesh3D* createGbObject3DwithQt(); - //QDialog* getSpecificInstrument() { return 0;} - void editGbObject3DwithQt(GbObject3D* gbObj); -#endif -#ifdef CAB_VTK - Presentator* createObjectPresentator(ObObject *object); -#endif - - -private: - GbQuadFaceMesh3DCreator( const GbQuadFaceMesh3DCreator& ); //no copy allowed - const GbQuadFaceMesh3DCreator& operator=( const GbQuadFaceMesh3DCreator& ); //no copy allowed - GbQuadFaceMesh3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbQuadFaceMesh3DCreator::getInstance()), CAB_GbQuadFaceMesh3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbSphere3DCreator.h b/src/basics/geometry3d/creator/GbSphere3DCreator.h deleted file mode 100644 index 30a9bfd81..000000000 --- a/src/basics/geometry3d/creator/GbSphere3DCreator.h +++ /dev/null @@ -1,126 +0,0 @@ -#ifndef GBSPHERE3DCREATOR_H -#define GBSPHERE3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbSphere3D.h> - -#ifdef CAB_QT -#include <numerics/geometry3d/presentation/QGbSphere3DInstrument.h> -#include <QtGui/QWidget> -#include <QtGui/QDialog> -#endif - -#ifdef CAB_VTK -#include <numerics/geometry3d/presentation/vtkGbSphere3D.h> -#endif - -#ifdef CAB_PARAVIEW -#include "vtkSMSourceProxy.h" -#include "vtkSMProperty.h" -#include "vtkSMDoubleVectorProperty.h" -#endif - -class GbSphere3DCreator : public GbObject3DCreator -{ -public: - static GbSphere3DCreator* getInstance() - { - static GbSphere3DCreator instance; - return &instance; - } - - GbSphere3D* createGbObject3D() { return new GbSphere3D(); } - - std::string getGbObject3DTypeID() { return "GbSphere3D"; }; - std::string toString() { return "GbSphere3DCreator"; } - -private: - GbSphere3DCreator( const GbSphere3DCreator& ); //no copy allowed - const GbSphere3DCreator& operator=( const GbSphere3DCreator& ); //no copy allowed - GbSphere3DCreator() : GbObject3DCreator() {} - -#ifdef CAB_QT -public: - - GbSphere3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0) - { - GbSphere3D* sphere = this->createGbObject3D(); - sphere->setRadius(3.0); - sphere->setCenterX1Coordinate(6.0); - - QGbSphere3DInstrument instrument(parent, flags); - instrument.setGbSphere3D(sphere); - if (instrument.exec()) { return sphere; } - delete sphere; - return NULL; - } - QDialog* getSpecificInstrument(QWidget* parent=0, Qt::WFlags flags=0) { return new QGbSphere3DInstrument(parent, flags); } - - void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0) - { - GbSphere3D* sphere = dynamic_cast<GbSphere3D*>(gbObj); - if(!sphere) throw UbException(UB_EXARGS,"selected object to edit is no GbSphere3D"); - - QGbSphere3DInstrument instrument(parent, flags); - instrument.setGbSphere3D(sphere); - instrument.exec(); - } -#endif -#ifdef CAB_VTK -public: - Presentator* createObjectPresentator(ObObject *object) { return new vtkGbSphere3D(dynamic_cast<GbSphere3D*>(object)); } -#endif - - -#ifdef CAB_PARAVIEW - vtkPVSource* createPVSource(vtkPVWindow *Window); -#endif -}; - -#ifdef CAB_PARAVIEW -vtkPVSource* GbSphere3DCreator::createPVSource(vtkPVWindow *Window) -{ - GbSphere3D *mysphere = this->createGbObject3D(); - mysphere->setCenterX1Coordinate(2.0); - mysphere->setCenterX2Coordinate(1.0); - mysphere->setCenterX3Coordinate(3.0); - mysphere->setRadius(0.3); - - vtkPVSource* pvs = Window->CreatePVSource("SphereSource"); - pvs->CreateProperties(); - if (pvs) - { - pvs->IsPermanentOn(); - pvs->Accept(1, 1); - //pvs->SetTraceReferenceObject(this->GetWindow()); - pvs->SetTraceReferenceObject(Window); - } - //vtkPVDisplayGUI *settingsGUI= pvs->GetPVOutput(); - - vtkSMSourceProxy* proxy = pvs->GetProxy(); - vtkSMProperty *prop = proxy->GetProperty("Center"); - - vtkSMDoubleVectorProperty *doubleprop = vtkSMDoubleVectorProperty::SafeDownCast(proxy->GetProperty("Center")); - doubleprop->SetElement(0, mysphere->getX1Centroid()); - doubleprop->SetElement(1, mysphere->getX2Centroid()); - doubleprop->SetElement(2, mysphere->getX3Centroid()); - pvs->SetLabel("Kugel"); - - doubleprop = vtkSMDoubleVectorProperty::SafeDownCast(proxy->GetProperty("Radius")); - doubleprop->SetElement(0, mysphere->getRadius()); - - pvs->GetPVWidget("Center")->ResetInternal(); - pvs->GetPVWidget("Radius")->ResetInternal(); - - pvs->SetVisibility(TRUE); - pvs->AcceptCallback(); - pvs->Update(); - return pvs; -} -#endif - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbSphere3DCreator::getInstance()), CAB_GbSphere3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp b/src/basics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp deleted file mode 100644 index a39bf633a..000000000 --- a/src/basics/geometry3d/creator/GbTriFaceMesh3DCreator.cpp +++ /dev/null @@ -1,431 +0,0 @@ -#include <numerics/geometry3d/creator/GbTriFaceMesh3DCreator.h> -#include <basics/utilities/UbLogger.h> -#include <basics/utilities/UbTiming.h> - -using namespace std; - -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - if(meshName.empty()) - { - size_t pos=filename.rfind("/"); - if(pos!=string::npos) meshName = filename.substr(pos+1); - else meshName = filename; - } - - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - string ext=stlfile.getFileExtension(); - - //in "kleinbuchstaben" umwandeln - transform(ext.begin(), ext.end(), ext.begin(), (int(*)(int))tolower); //(int(*)(int)) ist irgendso ein fieser cast, weil tolower ne alte c-methode ist - - //UBLOG(logINFO, "GbTriFaceMesh3DCreator::readMeshFromFile - read " <<filename ); - - if ( !ext.compare("ply" ) ) return GbTriFaceMesh3DCreator::readMeshFromPLYFile(filename, meshName,splitAlg , removeRedundantNodes); - else if( !ext.compare("stl" ) ) return GbTriFaceMesh3DCreator::readMeshFromSTLFile(filename, meshName,splitAlg , removeRedundantNodes); - else if( !ext.compare("inp" ) ) return GbTriFaceMesh3DCreator::readMeshFromAVSFile(filename, meshName,splitAlg , removeRedundantNodes); - else if( !ext.compare("mesh") ) return GbTriFaceMesh3DCreator::readMeshFromMeshFile(filename, meshName,splitAlg , removeRedundantNodes); - //else if( !ext.compare("raw") ) return GbTriFaceMesh3DCreator::readMeshFromRAWFile(filename,splitAlg , meshName); - else throw UbException(UB_EXARGS,"fileformat "+ext); - - return NULL; -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromMeshFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UbFileInputASCII meshfile(filename); - if(!meshfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return GbTriFaceMesh3DCreator::readMeshFromMeshFile(&meshfile,meshName,splitAlg,removeRedundantNodes); -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromMeshFile(UbFileInput* in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - - while( !in->eof() ) - { - std::string line = in->readStringLine(); - if( line.find("Vertices") !=std::string::npos ) - break; - } - int numVertices = in->readInteger(); - - UBLOG(logDEBUG1,"Number of vertices "<<numVertices); - - nodes->resize(numVertices); - - float x, y, z; - for (int i=0; i<numVertices; i++) - { - x = in->readFloat(); - y = in->readFloat(); - z = in->readFloat(); - in->readLine(); - (*nodes)[i] = GbTriFaceMesh3D::Vertex(x,y,z); - } - UBLOG(logDEBUG1," - read vertices (#"<<numVertices<<") done"); - - while( !in->eof() ) - { - std::string line = in->readStringLine(); - if( line.find("Triangles") !=std::string::npos ) - break; - } - int numFaces = in->readInteger(); - triangles->reserve(numFaces); - UBLOG(logDEBUG1,"Number of faces "<<numFaces); - - int j,k,l; - for(int i=0; i<numFaces; i++) - { - j = in->readInteger()-1; - k = in->readInteger()-1; - l = in->readInteger()-1; - in->readLine(); - - (*triangles).push_back(GbTriFaceMesh3D::TriFace(j,k,l)); - } - UBLOG(logDEBUG1," - read faces (#"<<(int)triangles->size()<<", #nonTriangles="<<(int)triangles->size()-numFaces<<") done"); - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes ); - - return mesh; -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromPLYFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UbFileInputASCII plyfile(filename); - if(!plyfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return GbTriFaceMesh3DCreator::readMeshFromPLYFile(&plyfile,meshName,splitAlg,removeRedundantNodes); -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromPLYFile(UbFileInput* in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - //cout<<"GbTriangularMesh3DFile.readMeshFromPLYFile !!! Dieses Format hat leider redundante Knoten ..."<<endl; - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - - float x, y, z; - string dummy; - - int numVertices = in->readIntegerAfterString("element vertex"); - int numFaces = in->readIntegerAfterString("element face"); - in->setPosAfterLineWithString("end_header"); - - UBLOG(logDEBUG1,"Number of vertices "<<numVertices); - UBLOG(logDEBUG1,"Number of faces "<<numFaces); - - nodes->resize(numVertices); - triangles->reserve(numFaces); - - int onePercent = (int)UbMath::max(1,UbMath::integerRounding(numVertices*0.01)); - for (int i=0; i<numVertices; i++) - { - if( i%onePercent==0 ) - cout<<" - read vertices (#"<<numVertices<<") "<<UbMath::integerRounding(i/(double)numVertices*100.0)<<"% "<<"\r"<<flush; - x = in->readFloat(); - y = in->readFloat(); - z = in->readFloat(); - in->readLine(); - (*nodes)[i] = GbTriFaceMesh3D::Vertex(x,y,z); - } - UBLOG(logDEBUG1," - read vertices (#"<<numVertices<<") done"); - - int p,j,k,l,n; - onePercent = (int)UbMath::max(1,UbMath::integerRounding(numFaces*0.01)); - for(int i=0; i<numFaces; i++) - { - if( i%onePercent==0 ) cout<<" - read faces (#"<<numFaces<<") "<<UbMath::integerRounding(i/(double)numFaces*100.0)<<"% "<<"\r"<<flush; - - p = in->readInteger(); - if(p==3) //Dreieck, alles andere wird stumpf ingnoriert - { - j = in->readInteger(); - k = in->readInteger(); - l = in->readInteger(); - - if( !UbMath::inClosedInterval(j,0,numVertices-1) - || !UbMath::inClosedInterval(k,0,numVertices-1) - || !UbMath::inClosedInterval(l,0,numVertices-1) ) - { - throw UbException(UB_EXARGS,"dreiecksindex ist groesser als max Knotenindex oder kleiner 0"); - } - triangles->push_back(GbTriFaceMesh3D::TriFace(j,k,l)); - } - else if(p==4) //Viereck --> wird zu zwei Dreiecken! - { - j = in->readInteger(); - k = in->readInteger(); - l = in->readInteger(); - n = in->readInteger(); - numFaces++; - i++; - - if( !UbMath::inClosedInterval(j,0,numVertices-1) - || !UbMath::inClosedInterval(k,0,numVertices-1) - || !UbMath::inClosedInterval(l,0,numVertices-1) - || !UbMath::inClosedInterval(n,0,numVertices-1) - ) - { - throw UbException(UB_EXARGS,"vierecksindex ist groesser als max Knotenindex oder kleiner 0"); - } - triangles->push_back(GbTriFaceMesh3D::TriFace(j,k,l)); - triangles->push_back(GbTriFaceMesh3D::TriFace(l,n,j)); - } - - in->readLine(); - - } - UBLOG(logDEBUG1," - read faces (#"<<(int)triangles->size()<<", #nonTriangles="<<(int)triangles->size()-numFaces<<") done"); - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes); - - return mesh; -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromSTLFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return GbTriFaceMesh3DCreator::readMeshFromSTLFile(&stlfile,meshName,splitAlg,removeRedundantNodes); -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromSTLFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ..."); - - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - string dummy; - - double x, y, z; - int nr=0; - - in->readLine(); - while(dummy!="endsolid") - { - in->readLine(); - in->readLine(); - dummy = in->readString(); - if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format"); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - in->readLine(); - in->readString(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - in->readLine(); - in->readString(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - triangles->push_back(GbTriFaceMesh3D::TriFace(nr,nr+1,nr+2)); - in->readLine(); - in->readLine(); - in->readLine(); - dummy = in->readString(); - nr+=3; - //std::cout<<"read mesh "<< nr <<" \n"; - } - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes); - - return mesh; -} -////////////////////////////////////////////////////////////////////////// -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromSTLFile2(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes, bool isBinaryFormat) -{ - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - int nr=0; - - if (!isBinaryFormat) { - ifstream in(filename.c_str()); - if (!in.good()) - { - delete nodes; - delete triangles; - UB_THROW(UbException(UB_EXARGS, "Can not open STL file: "+filename)); - } - char title[80]; - std::string s0, s1; - float n0, n1, n2, f0, f1, f2, f3, f4, f5, f6, f7, f8; - in.read(title, 80); - while (!in.eof()) { - in >> s0; // facet || endsolid - if (s0=="facet") { - in >> s1 >> n0 >> n1 >> n2; // normal x y z - in >> s0 >> s1; // outer loop - in >> s0 >> f0 >> f1 >> f2; // vertex x y z - in >> s0 >> f3 >> f4 >> f5; // vertex x y z - in >> s0 >> f6 >> f7 >> f8; // vertex x y z - in >> s0; // endloop - in >> s0; // endfacet - // Generate a new Triangle without Normal as 3 Vertices - nodes->push_back(GbTriFaceMesh3D::Vertex(f0, f1, f2)); - nodes->push_back(GbTriFaceMesh3D::Vertex(f3, f4, f5)); - nodes->push_back(GbTriFaceMesh3D::Vertex(f6, f7, f8)); - triangles->push_back(GbTriFaceMesh3D::TriFace(nr,nr+1,nr+2)); - nr+=3; - } - else if (s0=="endsolid") { - break; - } - } - in.close(); - } - else { - FILE *f = fopen(filename.c_str(), "rb"); - if (!f) - { - delete nodes; - delete triangles; - UB_THROW(UbException(UB_EXARGS, "Can not open STL file: "+filename)); - } - char title[80]; - int nFaces; - fread(title, 80, 1, f); - fread((void*)&nFaces, 4, 1, f); - float v[12]; // normal=3, vertices=3*3 = 12 - unsigned short uint16; - // Every Face is 50 Bytes: Normal(3*float), Vertices(9*float), 2 Bytes Spacer - for (size_t i=0; i<nFaces; ++i) { - for (size_t j=0; j<12; ++j) { - fread((void*)&v[j], sizeof(float), 1, f); - } - fread((void*)&uint16, sizeof(unsigned short), 1, f); // spacer between successive faces - nodes->push_back(GbTriFaceMesh3D::Vertex(v[3], v[4], v[5])); - nodes->push_back(GbTriFaceMesh3D::Vertex(v[6], v[7], v[8])); - nodes->push_back(GbTriFaceMesh3D::Vertex(v[9], v[10], v[11])); - triangles->push_back(GbTriFaceMesh3D::TriFace(nr, nr+1, nr+2)); - nr+=3; - } - fclose(f); - } - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes); - - return mesh; -} - -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromAVSFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return GbTriFaceMesh3DCreator::readMeshFromAVSFile(&stlfile,meshName,splitAlg,removeRedundantNodes); -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromAVSFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg , bool removeRedundantNodes) -{ - UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator.readMeshFromAVSFile !!! Dieses Format hat leider redundante Knoten ..."); - - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - string dummy; - - in->readLine(); - int numberNodes = in->readInteger(); - int numberTris = in->readInteger(); - in->readLine(); - - double x,y,z; - for(int u=0;u<numberNodes;u++) - { - in->readInteger(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - in->readLine(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - } - int id1,id2,id3; - for(int u=0;u<numberTris;u++) - { - in->readInteger(); - in->readInteger(); - in->readString(); - id1 = in->readInteger(); - id2 = in->readInteger(); - id3 = in->readInteger(); - triangles->push_back(GbTriFaceMesh3D::TriFace(id1-1,id2-1,id3-1)); - } - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes); - - return mesh; -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return GbTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(&stlfile,meshName,splitAlg,removeRedundantNodes); -} -/*======================================================================*/ -GbTriFaceMesh3D* GbTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator.readMeshFromVTKASCIIFile !!! Dieses Format hat leider redundante Knoten ..."); - - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - string dummy; - - in->readLine(); - in->readLine(); - in->readLine(); - in->readLine(); - - in->readString(); - int numberNodes = in->readInteger(); - in->readLine(); - - double x,y,z; - for(int u=0;u<numberNodes;u++) - { - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - //cout<<u<<" - x,y,z:"<<x<<","<<y<<","<<z<<endl; - //x=in->readDouble(); - //y=in->readDouble(); - //z=in->readDouble(); - //nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - //x=in->readDouble(); - //y=in->readDouble(); - //z=in->readDouble(); - //nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - //in->readLine(); - } - in->readLine(); - in->readString(); - int numberTris = in->readInteger(); - in->readLine(); - UBLOG(logDEBUG1,"numberTris:"<<numberTris); - - int id1,id2,id3; - for(int u=0;u<numberTris;u++) - { - in->readInteger(); - id1 = in->readInteger(); - id2 = in->readInteger(); - id3 = in->readInteger(); - triangles->push_back(GbTriFaceMesh3D::TriFace(id1,id2,id3)); - //cout<<u<<" - id1,id2,id3:"<<id1<<","<<id2<<","<<id3<<endl; - } - UBLOG(logDEBUG1,"Tris gelesen"); - - GbTriFaceMesh3D* mesh = new GbTriFaceMesh3D(meshName, nodes, triangles, splitAlg, removeRedundantNodes); - UBLOG(logDEBUG1,"mesh erzeugt (with remove redundant nodes = "<< boolalpha <<removeRedundantNodes<<")"); - - - return mesh; -} diff --git a/src/basics/geometry3d/creator/GbTriFaceMesh3DCreator.h b/src/basics/geometry3d/creator/GbTriFaceMesh3DCreator.h deleted file mode 100644 index 38247cdbe..000000000 --- a/src/basics/geometry3d/creator/GbTriFaceMesh3DCreator.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef GBTRIFACEMESH3DCREATOR_H -#define GBTRIFACEMESH3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbTriFaceMesh3D.h> -#include <basics/utilities/UbFileInputASCII.h> - -#ifdef CAB_QT -#include <qfiledialog.h> -#endif - -#ifdef CAB_VTK -#include <numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h> -#endif - -class GbTriFaceMesh3DCreator : public GbObject3DCreator -{ -public: - static GbTriFaceMesh3DCreator* getInstance() - { - static GbTriFaceMesh3DCreator instance; - return &instance; - } - static GbTriFaceMesh3D* readMeshFromFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - - static GbTriFaceMesh3D* readMeshFromMeshFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - static GbTriFaceMesh3D* readMeshFromMeshFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - - static GbTriFaceMesh3D* readMeshFromPLYFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - static GbTriFaceMesh3D* readMeshFromPLYFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - - static GbTriFaceMesh3D* readMeshFromSTLFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - static GbTriFaceMesh3D* readMeshFromSTLFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - static GbTriFaceMesh3D* readMeshFromSTLFile2(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true, bool isBinaryFormat=true); - - static GbTriFaceMesh3D* readMeshFromAVSFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - static GbTriFaceMesh3D* readMeshFromAVSFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - - static GbTriFaceMesh3D* readMeshFromVTKASCIIFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - static GbTriFaceMesh3D* readMeshFromVTKASCIIFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - - GbTriFaceMesh3D* createGbObject3D() { return new GbTriFaceMesh3D(); } - - std::string getGbObject3DTypeID(){ return "GbTriFaceMesh3D"; }; - std::string toString() { return "GbTriFaceMesh3DCreator"; } - -#ifdef CAB_QT - - - GbTriFaceMesh3D* createGbObject3DwithQt() - { - //QString s = QFileDialog::getOpenFileName(NULL,NULL,NULL,"open file dialog","Choose a STL file" ); - QString s = QFileDialog::getOpenFileName(NULL, "Choose a STL file", "/home", "*.stl"); - //QFileDialog* fd = new QFileDialog( NULL ); - //fd->setIconText(QString("Hallo")); - //fd->show(); - //TODO: Open File Dialog einbauen. - UbFileInputASCII in( s.toAscii().data() ); - stringstream stream; - stream <<"TriangularMesh3D ";//<<_objCount++; - GbTriFaceMesh3D *mesh = NULL;//GbTriFaceMesh3DCreator::readMeshFromSTLFile(&in, stream.str() ); - return mesh; - } - //QDialog* getSpecificInstrument() { return 0;} - void editGbObject3DwithQt(GbObject3D* gbObj) - { - } -#endif -#ifdef CAB_VTK -public: - Presentator* createObjectPresentator(ObObject *object) { return new vtkGbTriangularMesh3D((GbTriangularMesh3D*)object); } -#endif - - -private: - GbTriFaceMesh3DCreator( const GbTriFaceMesh3DCreator& ); //no copy allowed - const GbTriFaceMesh3DCreator& operator=( const GbTriFaceMesh3DCreator& ); //no copy allowed - GbTriFaceMesh3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbTriFaceMesh3DCreator::getInstance()), CAB_GbTriFaceMesh3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbTriangle3DCreator.h b/src/basics/geometry3d/creator/GbTriangle3DCreator.h deleted file mode 100644 index 54c1fd9a4..000000000 --- a/src/basics/geometry3d/creator/GbTriangle3DCreator.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef GBTRIANGLE3DCREATOR_H -#define GBTRIANGLE3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbTriangle3D.h> - -class GbTriangle3DCreator : public GbObject3DCreator -{ -public: - static GbTriangle3DCreator* getInstance() - { - static GbTriangle3DCreator instance; - return &instance; - } - - GbTriangle3D* createGbObject3D() { return new GbTriangle3D(); } - - std::string getGbObject3DTypeID(){ return "GbTriangle3D"; } - std::string toString() { return "GbTriangle3DCreator"; } - -private: - GbTriangle3DCreator( const GbTriangle3DCreator& ); //no copy allowed - const GbTriangle3DCreator& operator=( const GbTriangle3DCreator& ); //no copy allowed - GbTriangle3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbTriangle3DCreator::getInstance()), CAB_GbTriangle3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbTriangularMesh3DCreator.cpp b/src/basics/geometry3d/creator/GbTriangularMesh3DCreator.cpp deleted file mode 100644 index 0b3f297cd..000000000 --- a/src/basics/geometry3d/creator/GbTriangularMesh3DCreator.cpp +++ /dev/null @@ -1,258 +0,0 @@ -#include <numerics/geometry3d/creator/GbTriangularMesh3DCreator.h> -#include <algorithm> -#include <basics/utilities/UbLogger.h> - -using namespace std; - -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromFile(string filename, string meshName) -{ - if(meshName.empty()) - { - size_t pos=filename.rfind("/"); - if(pos!=string::npos) meshName = filename.substr(pos+1); - else meshName = filename; - } - - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - string ext=stlfile.getFileExtension(); - - //in "kleinbuchstaben" umwandeln - transform(ext.begin(), ext.end(), ext.begin(), (int(*)(int))tolower); - - if ( !ext.compare("ply") ) return GbTriangularMesh3DCreator::readMeshFromPLYFile(filename, meshName); - else if( !ext.compare("stl") ) return GbTriangularMesh3DCreator::readMeshFromSTLFile(filename, meshName); - else if( !ext.compare("gts") ) return GbTriangularMesh3DCreator::readMeshFromGTSFile(filename, meshName); - else if( !ext.compare("raw") ) return GbTriangularMesh3DCreator::readMeshFromRAWFile(filename, meshName); - else throw UbException(UB_EXARGS,"unrecognized fileformat "+ext); - - return NULL; -} -/*======================================================================*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromSTLFile(string filename, string meshName) -{ - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return GbTriangularMesh3DCreator::readMeshFromSTLFile(&stlfile,meshName); -} -/*======================================================================*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromSTLFile(UbFileInput* in, string meshName) -{ - UBLOG(logINFO,"GbTriangularMesh3DFile.readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ..."); - vector<GbPoint3D*> *nodes = new vector<GbPoint3D*>; - vector<GbTriangle3D*> *triangles = new vector<GbTriangle3D*>; - nodes->resize(0, NULL); - triangles->resize(0, NULL); - double x, y, z; - //int nr=0; - string dummy; - GbPoint3D *node1 = NULL; - GbPoint3D *node2 = NULL; - GbPoint3D *node3 = NULL; - GbTriangle3D *triangle = NULL; - in->readLine(); - while(dummy!="endsolid") - { - in->readLine(); - in->readLine(); - dummy = in->readString(); if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format"); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - node1 = new GbPoint3D(x,y,z); nodes->push_back(node1); - in->readLine(); - in->readString(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - node2 = new GbPoint3D(x,y,z); nodes->push_back(node2); - in->readLine(); - in->readString(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - node3 = new GbPoint3D(x,y,z); nodes->push_back(node3); - triangle = new GbTriangle3D(node1, node2, node3); triangles->push_back(triangle); - in->readLine(); - in->readLine(); - in->readLine(); - dummy = in->readString(); - } - return new GbTriangularMesh3D(meshName, nodes, triangles); -} -/*======================================================================*/ -/** -* Returns a triangular mesh created from the specified TICAD source ASCII stream (system.dat format). -* @param in the input stream -* @param meshName the name of the created mesh -* @return a triangular mesh created from the specified TICAD source ASCII stream -* @exception IOException if any error occurs in creating the triangular mesh -*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromGTSFile(string inputfile, string meshName) -{ - UbFileInputASCII gtlfile(inputfile); - if(!gtlfile) throw UbException(UB_EXARGS,"cannot open file "+inputfile); - return GbTriangularMesh3DCreator::readMeshFromGTSFile(>lfile,meshName); -} -/*======================================================================*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromGTSFile(UbFileInput *in, string meshName) -{ - UBLOG(logINFO,"GbTriangularMesh3DFile.readMeshFromGTSFile !!! "); - vector<GbPoint3D*> *nodes = new vector<GbPoint3D*>; - vector<GbLine3D*> *edges = new vector<GbLine3D*>; - vector<GbTriangle3D*> *triangles = new vector<GbTriangle3D*>; - nodes->resize(0, NULL); - edges->resize(0, NULL); - triangles->resize(0, NULL); - double x, y, z; - int point1, point2, point3; - //int nr = 0; - //in->readLine(); - int nodesize = in->readInteger(); - int edgesize = in->readInteger(); - int trianglesize = in->readInteger(); - UBLOG(logINFO,"node-/edge-/trianglesize: "<<nodesize<<" / "<<edgesize<<" / "<<trianglesize); - - for(int i=0; i<nodesize;i++) - { - in->readLine(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(new GbPoint3D(x,y,z)); - } - for(int i=0; i<edgesize;i++) - { - in->readLine(); - point1=in->readInteger()-1; - point2=in->readInteger()-1; - edges->push_back(new GbLine3D((*nodes)[point1],(*nodes)[point2])); - } - for(int i=0; i<trianglesize;i++) - { - in->readLine(); - point1=in->readInteger(); - point2=in->readInteger(); - point3=in->readInteger(); - //triangles->push_back(new GbTriangle3D((*nodes)[point1-1],(*nodes)[point2-1],(*nodes)[point3-1])); - triangles->push_back(new GbTriangle3D((GbPoint3D*)(*edges)[point1-1]->getPoint1(),(GbPoint3D*)(*edges)[point2-1]->getPoint1(),(GbPoint3D*)(*edges)[point3-1]->getPoint1())); - } - return(new GbTriangularMesh3D(meshName, nodes, edges, triangles)); -} -/*======================================================================*/ -/** -* Returns a triangular mesh created from the specified TICAD source ASCII stream (system.dat format). -* @param in the input stream -* @param meshName the name of the created mesh -* @return a triangular mesh created from the specified TICAD source ASCII stream -* @exception IOException if any error occurs in creating the triangular mesh -*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromPLYFile(string inputfile, string meshName) -{ - UbFileInputASCII plyfile(inputfile); - if(!plyfile) throw UbException(UB_EXARGS,"cannot open file "+inputfile); - return GbTriangularMesh3DCreator::readMeshFromPLYFile(&plyfile,meshName); -} -/*======================================================================*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromPLYFile(UbFileInput *in, string meshName) -{ - //cout<<"GbTriangularMesh3DFile.readMeshFromPLYFile !!! Dieses Format hat leider redundante Knoten ..."<<endl; - vector<GbPoint3D*> *nodes = new vector<GbPoint3D*>; - vector<GbTriangle3D*> *triangles = new vector<GbTriangle3D*>; - nodes->resize(0, NULL); - triangles->resize(0, NULL); - double x, y, z; - int nr=0; - string dummy; - int numVertices, numFaces; - GbPoint3D *node = NULL; - GbPoint3D *node1 = NULL; - GbPoint3D *node2 = NULL; - GbPoint3D *node3 = NULL; - GbTriangle3D *triangle = NULL; - in->readLine(); - in->readLine(); - in->readString(); in->readString(); numVertices = in->readInteger(); - in->readLine(); - in->readLine(); - in->readLine(); - in->readLine(); - in->readLine(); - in->readLine(); - in->readLine(); - in->readString(); in->readString(); numFaces = in->readInteger(); in->readLine(); - in->readLine(); - in->readLine(); - UBLOG(logINFO,"Number of vertices "<<numVertices); - UBLOG(logINFO,"Number of faces "<<numFaces); - for (int i=0; i<numVertices; i++) - { - x = in->readDouble(); - y = in->readDouble(); - z = in->readDouble(); - // cout<<x<<y<<z; - // in->readString(); in->readString(); in->readString(); - in->readLine(); - node = new GbPoint3D(x,y,z); nodes->push_back(node); - } - nr=0; - - for (int i=0; i<numFaces; i++) - { - in->readString(); - int j,k,l; - j = in->readInteger(); k = in->readInteger(); l = in->readInteger(); - node1 = (*nodes)[j]; - node2 = (*nodes)[k]; - node3 = (*nodes)[l]; - in->readLine(); - nr++; - triangle = new GbTriangle3D(node1, node2, node3); triangles->push_back(triangle); - } - - return(new GbTriangularMesh3D(meshName, nodes, triangles)); -} -/*======================================================================*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromRAWFile(string inputfile, string meshName) -{ - UbFileInputASCII stlfile(inputfile); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+inputfile); - return GbTriangularMesh3DCreator::readMeshFromRAWFile(&stlfile,meshName); -} -/*======================================================================*/ -GbTriangularMesh3D* GbTriangularMesh3DCreator::readMeshFromRAWFile(UbFileInput *in, string meshName) -{ - UBLOG(logINFO,"GbTriangularMesh3DFile.readMeshFromGTSFile !!! "); - vector<GbPoint3D*> *nodes = new vector<GbPoint3D*>; - vector<GbLine3D*> *edges = new vector<GbLine3D*>; - vector<GbTriangle3D*> *triangles = new vector<GbTriangle3D*>; - nodes->resize(0, NULL); - edges->resize(0, NULL); - triangles->resize(0, NULL); - double x, y, z; - int point1, point2, point3; - //int nr = 0; - //in->readLine(); - int nodesize = in->readInteger(); - int trianglesize = in->readInteger(); - int edgesize = 0; - UBLOG(logINFO,"node-/edge-/trianglesize "<<nodesize<<" / "<<edgesize<<" / "<<trianglesize); - - for(int i=0; i<nodesize;i++) - { - in->readLine(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(new GbPoint3D(x,y,z)); - } - for(int i=0; i<trianglesize;i++) - { - in->readLine(); - point1=in->readInteger(); - point2=in->readInteger(); - point3=in->readInteger(); - triangles->push_back(new GbTriangle3D((*nodes)[point1],(*nodes)[point2],(*nodes)[point3])); - } - return(new GbTriangularMesh3D(meshName, nodes, edges, triangles)); -} diff --git a/src/basics/geometry3d/creator/GbTriangularMesh3DCreator.h b/src/basics/geometry3d/creator/GbTriangularMesh3DCreator.h deleted file mode 100644 index d449f0849..000000000 --- a/src/basics/geometry3d/creator/GbTriangularMesh3DCreator.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef GBTRIANGULARMESH3DCREATOR_H -#define GBTRIANGULARMESH3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbTriangularMesh3D.h> -#include <basics/utilities/UbFileInputASCII.h> - -#ifdef CAB_QT -#include <qfiledialog.h> -#endif - -#ifdef CAB_VTK -#include <numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h> -#endif - -class GbTriangularMesh3DCreator : public GbObject3DCreator -{ -public: - static GbTriangularMesh3DCreator* getInstance() - { - static GbTriangularMesh3DCreator instance; - return &instance; - } - - static GbTriangularMesh3D* readMeshFromFile(std::string filename, std::string meshName=""); - - static GbTriangularMesh3D* readMeshFromSTLFile(std::string filename, std::string meshName); - static GbTriangularMesh3D* readMeshFromGTSFile(std::string filename, std::string meshName); - static GbTriangularMesh3D* readMeshFromPLYFile(std::string filename, std::string meshName); - //static GbTriangularMesh3D* readMeshFromAVSFile(std::string filename, std::string meshName); - static GbTriangularMesh3D* readMeshFromRAWFile(std::string inputFile, std::string meshName); - - static GbTriangularMesh3D* readMeshFromSTLFile(UbFileInput* infile, std::string meshName); - static GbTriangularMesh3D* readMeshFromGTSFile(UbFileInput* infile, std::string meshName); - static GbTriangularMesh3D* readMeshFromPLYFile(UbFileInput* infile, std::string meshName); - //static GbTriangularMesh3D* readMeshFromAVSFile(UbFileInput* infile, std::string meshName); - static GbTriangularMesh3D* readMeshFromRAWFile(UbFileInput* infile, std::string meshName); - - - GbTriangularMesh3D* createGbObject3D() { return new GbTriangularMesh3D(); } - - std::string getGbObject3DTypeID(){ return "GbTriangularMesh3D"; }; - std::string toString() { return "GbTriangularMesh3DCreator"; } - -#ifdef CAB_QT - - GbTriangularMesh3D* createGbObject3DwithQt(QWidget* parent=0, Qt::WFlags flags=0) - { - //QString s = QFileDialog::getOpenFileName(NULL,NULL,NULL,"open file dialog","Choose a STL file" ); - QString s = QFileDialog::getOpenFileName(NULL, "Choose a STL file", "/home", "*.stl"); - //QFileDialog* fd = new QFileDialog( NULL ); - //fd->setIconText(QString("Hallo")); - //fd->show(); - //TODO: Open File Dialog einbauen. - UbFileInputASCII in( s.toAscii().data() ); - stringstream stream; - stream <<"TriangularMesh3D ";//<<_objCount++; - GbTriangularMesh3D *mesh = GbTriangularMesh3DCreator::readMeshFromSTLFile(&in, stream.str() ); - mesh->deleteRedundantNodes(); - return mesh; - } - //QDialog* getSpecificInstrument() { return 0;} - void editGbObject3DwithQt(GbObject3D* gbObj, QWidget* parent=0, Qt::WFlags flags=0) - { - } -#endif -#ifdef CAB_VTK -public: - Presentator* createObjectPresentator(ObObject *object) { return new vtkGbTriangularMesh3D((GbTriangularMesh3D*)object); } -#endif - - -private: - GbTriangularMesh3DCreator( const GbTriangularMesh3DCreator& ); //no copy allowed - const GbTriangularMesh3DCreator& operator=( const GbTriangularMesh3DCreator& ); //no copy allowed - GbTriangularMesh3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbTriangularMesh3DCreator::getInstance()), CAB_GbTriangularMesh3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp b/src/basics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp deleted file mode 100644 index 182d8b30a..000000000 --- a/src/basics/geometry3d/creator/GbVoxelMatrix3DCreator.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include <numerics/geometry3d/creator/GbVoxelMatrix3DCreator.h> -#include <numerics/geometry3d/GbVoxelMatrix3D.h> -#include <basics/utilities/UbFileInputASCII.h> -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbLogger.h> - -using namespace std; - -/***************************************************************************/ -GbVoxelMatrix3D* GbVoxelMatrix3DCreator::createFromRawFloatFile( string filename, int nodesX1, int nodesX2, int nodesX3, float threshold) -{ - UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start"); - ifstream in(filename.c_str(), ios::binary); - if(!in) throw UbException(UB_EXARGS,"could not open file "+filename); - - in.seekg( 0, ios::end ); //Ende springen - fstream::off_type length = in.tellg(); //Position abfragen - in.seekg( 0, ios::beg ); //An den Anfang springen - if( (nodesX1*nodesX2*nodesX3)*sizeof(float) != (long)length ) - { - throw UbException(UB_EXARGS,"number of nodes doesn't match filesize"); - } - - UBLOG(logINFO," - create GbVoxelMatrix3D"); - GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID, threshold); - - UBLOG(logINFO," - init values"); - float val; - 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)); - //if( !UbMath::equal(val, 0.0f) ) - if( UbMath::greater(val, threshold) ) - { - (*voxelGeo)(x1,x2,x3) = GbVoxelMatrix3D::SOLID; - } - } - - UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end"); - - return voxelGeo; -} -/***************************************************************************/ -GbVoxelMatrix3D* GbVoxelMatrix3DCreator::createFromVtiASCIIFloatFile( string filename, int nodesX1, int nodesX2, int nodesX3, float threshold) -{ - UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromVtiASCIIFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start"); - UbFileInputASCII in(filename); - //ifstream in(filename.c_str(), ios::binary); - if(!in) throw UbException(UB_EXARGS,"could not open file "+filename); - in.readLine(); - in.readLine(); - in.readLine(); - in.readLine(); - in.readLine(); - //in.readLine(); !!!manchmal hat das vti file noch die xml version dabei ... - - UBLOG(logINFO," - create GbVoxelMatrix3D"); - GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID, threshold); - - 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++) - { - val = in.readInteger(); - - //u++; if(u>125000) UBLOG(logINFO,"val:"<<u<<" "<<val); - - //if( !UbMath::equal(val, 0.0f) ) - if( UbMath::greater(val, threshold) ) - { - (*voxelGeo)(x1,x2,x3) = GbVoxelMatrix3D::SOLID; - } - } - - UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromVtiASCIIFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end"); - - return voxelGeo; -} - diff --git a/src/basics/geometry3d/creator/GbVoxelMatrix3DCreator.h b/src/basics/geometry3d/creator/GbVoxelMatrix3DCreator.h deleted file mode 100644 index fd2cc0482..000000000 --- a/src/basics/geometry3d/creator/GbVoxelMatrix3DCreator.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef GBVOXELMATRIX3DCREATOR_H -#define GBVOXELMATRIX3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/GbVoxelMatrix3D.h> -#include <iostream> -#include <fstream> - -class GbVoxelMatrix3DCreator : public GbObject3DCreator -{ -public: - enum DataType {t8bit, t16bit}; -public: - static GbVoxelMatrix3DCreator* getInstance() - { - static GbVoxelMatrix3DCreator instance; - return &instance; - } - - GbVoxelMatrix3D* createGbObject3D() { return new GbVoxelMatrix3D(); } - GbVoxelMatrix3D* createFromRawFloatFile( std::string filename, int nodesX1, int nodesX2, int nodesX3, float threshold=0.0); - GbVoxelMatrix3D* createFromVtiASCIIFloatFile( std::string filename, int nodesX1, int nodesX2, int nodesX3, float threshold=0.0); - - std::string getGbObject3DTypeID() { return "GbVoxelMatrix3D"; }; - std::string toString() { return "GbVoxelMatrix3DCreator"; } - -private: - GbVoxelMatrix3DCreator() : GbObject3DCreator() {} - - GbVoxelMatrix3DCreator( const GbVoxelMatrix3DCreator& ); //no copy allowed - const GbVoxelMatrix3DCreator& operator=( const GbVoxelMatrix3DCreator& ); //no copy allowed - -public: - template< typename T > - GbVoxelMatrix3D* createFromRawFile(std::string filename, int nodesX1, int nodesX2, int nodesX3, float threshold) - { - UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - start"); - - std::ifstream in(filename.c_str(), std::ios::binary); - if(!in) throw UbException(UB_EXARGS,"could not open file "+filename); - - in.seekg( 0, std::ios::end ); //Ende springen - std::fstream::off_type length = in.tellg(); //Position abfragen - in.seekg( 0, std::ios::beg ); //An den Anfang springen - long m_size = (nodesX1*nodesX2*nodesX3)*sizeof(T); - if( m_size != (long)length ) - { - throw UbException(UB_EXARGS,"number of nodes doesn't match filesize: " + UbSystem::toString(length)); - } - - UBLOG(logINFO," - create GbVoxelMatrix3D"); - GbVoxelMatrix3D* voxelGeo = new GbVoxelMatrix3D(nodesX1,nodesX2,nodesX3,GbVoxelMatrix3D::FLUID, threshold); - - UBLOG(logINFO," - init values"); - T val; - 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(T)); - //if( !UbMath::equal(val, 0.0f) ) - //if( UbMath::greater(val, (T)threshold) ) - if(val > (T)threshold) - { - (*voxelGeo)(x1,x2,x3) = GbVoxelMatrix3D::SOLID; - } - } - - UBLOG(logINFO,"GbVoxelMatrix3DCreator::createFromRawFloatFile \""<<filename<<"\" nodes("<<nodesX1<<"/"<<nodesX2<<"/"<<nodesX3<<") - end"); - - return voxelGeo; - } -}; - - - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(GbVoxelMatrix3DCreator::getInstance()), CAB_GbVoxelMatrix3DCreator); -#endif - -#endif //GBVOXELMATRIX3DCREATOR_H diff --git a/src/basics/geometry3d/creator/package.include b/src/basics/geometry3d/creator/package.include deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/basics/geometry3d/examples/insideOutsideTests/CMakeLists.txt b/src/basics/geometry3d/examples/insideOutsideTests/CMakeLists.txt deleted file mode 100644 index f4da98789..000000000 --- a/src/basics/geometry3d/examples/insideOutsideTests/CMakeLists.txt +++ /dev/null @@ -1,61 +0,0 @@ -cmake_minimum_required(VERSION 2.4) - -INCLUDE("../../../../CMakeCABMacros.txt") -INCLUDE("../../../../CMakeSetCompilerFlags.txt") - -CHECK_FOR_VARIABLE(CAB_MACHINE "machine name, e.g. ALTIX, ARWEN") -SET(CMAKE_CONFIG_FILE "${SOURCE_ROOT}/cmake_config_files/${CAB_MACHINE}.config.cmake") - -IF(CAB_MACHINE AND EXISTS ${CMAKE_CONFIG_FILE} ) - - PROJECT(geo3dCellCutTests) - - SET(EXECUTABLE_NAME geo3dCellCutTests) - - #erst hier das config file einfügen, ansonsten werden manche settings durch (Project) überschrieben) - INCLUDE(${CMAKE_CONFIG_FILE}) - - ################################################################# - ### PACKAGES ### - ################################################################# - INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakePackage.txt) - INCLUDE(${SOURCE_ROOT}/basics/objects/CMakePackage.txt) - INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/CMakePackage.txt) - INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/creator/CMakePackage.txt) - INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/fem/CMakePackage.txt) - - ################################################################# - ### OWN DEFINES ### - ################################################################# - FILE(GLOB SPECIFIC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h - ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) - - - SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES}) - SOURCE_GROUP(example FILES ${SPECIFIC_FILES}) - - SET_COMPILER_SPECIFIC_FLAGS(${CAB_COMPILER} BINARY) - - ################################################################# - ### ADDITIONAL_MAKE_CLEAN_FILES ### - ################################################################# - SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${GENERATED_FILES}") - - ################################################################# - ### EXCECUTABLE ### - ################################################################# - ADD_EXECUTABLE(${EXECUTABLE_NAME} ${ALL_SOURCES} ) - - ################################################################# - ### ADDITIONAL LINK PROPERTIES ### - ################################################################# - IF(CAB_ADDITIONAL_LINK_FLAGS) - SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS ${CAB_ADDITIONAL_LINK_FLAGS}) - ENDIF(CAB_ADDITIONAL_LINK_FLAGS) -ELSE() - IF(CAB_MACHINE) - MESSAGE("CAB_MACHINE error - following file is missing: \n ${CMAKE_CONFIG_FILE}") - ELSE() - MESSAGE("check CAB_MACHINE!!!") - ENDIF() -ENDIF() \ No newline at end of file diff --git a/src/basics/geometry3d/examples/insideOutsideTests/main.cpp b/src/basics/geometry3d/examples/insideOutsideTests/main.cpp deleted file mode 100644 index f420be84a..000000000 --- a/src/basics/geometry3d/examples/insideOutsideTests/main.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include <numerics/geometry3d/GbCuboid3D.h> -#include <numerics/geometry3d/GbSphere3D.h> -#include <numerics/geometry3d/GbCylinder3D.h> - -int main(int argc, char** argv) -{ - GbSphere3D test(10,10,10,8); - - bool cutSp1 /*false*/= test.isCellCuttingGbObject3D(9,9,9,11,11,11); //cell komplett IN sphere - bool cutSp2 /*true */= test.isCellCuttingGbObject3D(0,0,0,20,20,20); //cell umhuellt sphere - bool cutSp3 /*true */= test.isCellCuttingGbObject3D(0,0,0,10,10,10); //cell cutted sphere - bool cutSp4 /*false*/= test.isCellCuttingGbObject3D(100,100,100,101,101,101); //cell nix sphere - - - bool cutInsSp1 /*true */= test.isCellInsideOrCuttingGbObject3D(9,9,9,11,11,11); //cell komplett IN sphere - bool cutInsSp2 /*true */= test.isCellInsideOrCuttingGbObject3D(0,0,0,20,20,20); //cell umhuellt sphere - bool cutInsSp3 /*true */= test.isCellInsideOrCuttingGbObject3D(0,0,0,10,10,10); //cell cutted sphere - bool cutInsSp4 /*false*/= test.isCellInsideOrCuttingGbObject3D(100,100,100,101,101,101); //cell nix sphere - - GbCuboid3D test1(0,0,0,10,10,10); - - bool cutCu1 /*false*/= test1.isCellCuttingGbObject3D(4,4,4,6,6,6); //cell komplett IN cube - bool cutCu2 /*true */= test1.isCellCuttingGbObject3D(-1,-1,-1,11,11,11); //cell umhuellt cube - bool cutCu3 /*true */= test1.isCellCuttingGbObject3D(5,5,5,15,15,15); //cell cutted cube - bool cutCu4 /*false*/= test1.isCellCuttingGbObject3D(12,12,12,15,15,15); //cell nix cube - - bool cutInsCu1 /*true */= test1.isCellInsideOrCuttingGbObject3D(4,4,4,6,6,6); //cell komplett IN cube - bool cutInsCu2 /*true */= test1.isCellInsideOrCuttingGbObject3D(-1,-1,-1,11,11,11); //cell umhuellt cube - bool cutInsCu3 /*true */= test1.isCellInsideOrCuttingGbObject3D(5,5,5,15,15,15); //cell cutted cube - bool cutInsCu4 /*false*/= test1.isCellInsideOrCuttingGbObject3D(12,12,12,15,15,15); //cell nix cube - - GbCylinder3D test2( 0,0,0, 20, 0, 0, 10); - - bool cutCy1 /*false*/ = test2.isCellCuttingGbObject3D(1,-1,-1,4,1,1); //cell komplett IN cyl - bool cutCy2 /*true */ = test2.isCellCuttingGbObject3D(10,0,0,15,12,11); //cell umhuellt cyl - bool cutCy3a /*true */ = test2.isCellCuttingGbObject3D(5,5,5,15,15,15); //cell cutted cyl im kreisbreich - bool cutCy3b /*true */ = test2.isCellCuttingGbObject3D(-5,-1,-1,5,1,1); //cell cutted cyl am stirn - bool cutCy4 /*false*/= test2.isCellCuttingGbObject3D(-10,-10,-10,-5,-5,-5); //cell nix cyl - - - bool cutInsCy1 /*true */= test2.isCellInsideOrCuttingGbObject3D(4,4,4,6,6,6); //cell komplett IN cube - bool cutInsCy2 /*true */= test2.isCellInsideOrCuttingGbObject3D(10,0,0,15,12,11); //cell umhuellt cyl - bool cutInsCy3a /*true */= test2.isCellInsideOrCuttingGbObject3D(5,5,5,15,15,15); //cell cutted cyl im kreisbreich - bool cutInsCy3b /*true */= test2.isCellInsideOrCuttingGbObject3D(-5,-1,-1,5,1,1); //cell cutted cube - bool cutInsCy4 /*false*/= test2.isCellInsideOrCuttingGbObject3D(-10,-10,-10,-5,-5,-5); //cell nix cube -} \ No newline at end of file diff --git a/src/basics/geometry3d/examples/stl2inp/CMakeLists.txt b/src/basics/geometry3d/examples/stl2inp/CMakeLists.txt deleted file mode 100644 index 8046a72e2..000000000 --- a/src/basics/geometry3d/examples/stl2inp/CMakeLists.txt +++ /dev/null @@ -1,140 +0,0 @@ -SET(SOURCE_ROOT $ENV{CAB_DIR} CACHE PATH "(e.g. d:/temp/source)" ) -STRING(REGEX REPLACE "\\\\" "/" SOURCE_ROOT ${SOURCE_ROOT}) # "\" --> "/" - -IF(EXISTS ${SOURCE_ROOT}) - IF(EXISTS ${SOURCE_ROOT}/basics) - - INCLUDE(${SOURCE_ROOT}/CMakeCABMacros.txt) - - PROJECT (STL2INP) - SET(EXECUTABLE_NAME stl2inp) - - ################################################################# - ### PACKAGES ### - ################################################################# - - INCLUDE(${SOURCE_ROOT}/basics/objects/CMakeLists.txt) - INCLUDE(${SOURCE_ROOT}/basics/utilities/CMakeLists.txt) - INCLUDE(${SOURCE_ROOT}/basics/relation/CMakeLists.txt) - - - INCLUDE(${SOURCE_ROOT}/numerics/geometry2d/CMakeLists.txt) - INCLUDE(${SOURCE_ROOT}/numerics/geometry2d/creator/CMakeLists.txt) - - INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/CMakeLists.txt) - INCLUDE(${SOURCE_ROOT}/numerics/geometry3d/creator/CMakeLists.txt) - - INCLUDE(${SOURCE_ROOT}/octree/CMakeLists.txt) - INCLUDE(${SOURCE_ROOT}/octree/facette/CMakeLists.txt) - - INCLUDE(${SOURCE_ROOT}/quadtree/CMakeLists.txt) - INCLUDE(${SOURCE_ROOT}/quadtree/nodeadaptation/CMakeLists.txt) - - - ################################################################# - ### OWN DEFINES ### - ################################################################# - # ADD_DEFINITIONS( -DCAB_QT ) - # ADD_DEFINITIONS( -DCAB_QTONLY ) - ADD_DEFINITIONS( -DMEMPOOL_A2PIIOCTNODEVD) - SET(SPECIFIC_FILES main.cpp stl2inp.h stl2inp.cpp QDefineUniformMesh.h QDefineUniformMesh.cpp) - SET(ALL_SOURCES ${ALL_SOURCES} ${SPECIFIC_FILES}) - SOURCE_GROUP(z_specific FILES ${SPECIFIC_FILES}) - - IF(WIN32) - ADD_CXX_FLAGS("/wd4996") - ELSE(WIN32) - ADD_CXX_FLAGS("-O3 -mcpu=athlon-4 -fomit-frame-pointer -finline-functions -funroll-all-loops") - ENDIF(WIN32) - - - - ################################################################# - ### QT SPECIFIC (only has effects if a QT source is included) ### - ################################################################# - #QT specific - SET(NEED_QT "YES") - INCLUDE(${SOURCE_ROOT}/CMakeQtMacros.txt) - - IF(QT_FOUND) - INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} - ${QT_INCLUDE_PATH} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ) - LINK_LIBRARIES ( ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ) - ADD_DEFINITIONS( ${QT_DEFINITIONS}) - ELSE(QT_FOUND) - IF(${NEED_QT} MATCHES "YES") - MESSAGE("Ups\nAt least one package needs Qt!\nPlease check Qt settings\n(e.g. librarys within Advanced Values)") - ENDIF(${NEED_QT} MATCHES "YES") - - - ENDIF(QT_FOUND) - - IF(QT_FOUND) - SET(SUBDIRPATH numerics/geometry3d/examples/stl2inp) - SET(CURRENT_DIR ${SOURCE_ROOT}/${SUBDIRPATH}) - - ################################################################ - ### Qt4 UI FILES ### - ################################################################ - FILE(GLOB UI_FILES ${CURRENT_DIR}/*.ui) #collect ui files - QT4_WRAP_UI(${CURRENT_DIR} OUTFILES ${UI_FILES}) #wrap ui files - REMOVE(TEMP_FILES ${OUTFILES} ) - SET(TEMP_FILES ${TEMP_FILES} ${OUTFILES} ) - - #make subfolders for VS with new files - SOURCE_GROUP(${SUBDIRPATH} FILES ${OUTFILES}) - - IF(WIN32) - SET(ALL_SOURCES ${ALL_SOURCES} ${UI_FILES}) - SOURCE_GROUP(${SUBDIRPATH} FILES ${UI_FILES}) - ENDIF(WIN32) - - ################################################################ - ### Qt4 HEADERS TO BE MOCED ### - ################################################################ - MAKE_DIRECTORY(${CURRENT_DIR}${QTGEN_MOC}) - SET(MOC_FILES ) #empty MOC_FILES - #SET(MOC_CLASSES ${CURRENT_DIR}/stl2inp.h QDefineUniformMesh.ui ) - - QT4_WRAP_CPP(${CURRENT_DIR}${QTGEN_MOC} MOC_FILES ${MOC_CLASSES}) - REMOVE(TEMP_FILES ${MOC_FILES}) - SET(TEMP_FILES ${TEMP_FILES} ${MOC_FILES}) - SOURCE_GROUP(${SUBDIRPATH}${QTGEN_MOC} FILES ${MOC_FILES}) - - SET(ALL_SOURCES ${ALL_SOURCES} ${TEMP_FILES}) - - ENDIF(QT_FOUND) - - - ################################################################# - ### ADDITIONAL_MAKE_CLEAN_FILES ### - ################################################################# - SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${GENERATED_FILES}") - - ################################################################# - ### EXCECUTABLE ### - ################################################################# - ADD_EXECUTABLE( ${EXECUTABLE_NAME} - ${ALL_SOURCES} - ) - - - ################################################################# - ### ADDITIONAL LINK PROPERTIES ### - ################################################################# - IF(CAB_ADDITIONAL_LINK_FLAGS) - SET_TARGET_PROPERTIES(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS ${CAB_ADDITIONAL_LINK_FLAGS}) - ENDIF(CAB_ADDITIONAL_LINK_FLAGS) - - ELSE(EXISTS ${SOURCE_ROOT}/basics) - MESSAGE("Set Path to \"source\" directory at\nSOURCE_ROOT\nis not correct") - ENDIF(EXISTS ${SOURCE_ROOT}/basics) -ELSE(EXISTS ${SOURCE_ROOT}) - SET(SOURCE_ROOT "CAB_DIR NOT FOUND" CACHE PATH "(e.g. d:/temp/source)" FORCE) - MESSAGE("Please Set Path to \"source\" directory at\nSOURCE_ROOT\n(e.g. D:/temp/source)") -ENDIF(EXISTS ${SOURCE_ROOT}) diff --git a/src/basics/geometry3d/examples/stl2inp/QDefineUniformMesh.cpp b/src/basics/geometry3d/examples/stl2inp/QDefineUniformMesh.cpp deleted file mode 100644 index 0676719cd..000000000 --- a/src/basics/geometry3d/examples/stl2inp/QDefineUniformMesh.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "./QDefineUniformMesh.h" -#include <QtGui/QFileDialog> -#include <QString> -#include <QFile> -#include <QMessageBox> -#include <cstdio> - - -QDefineUniformMesh::QDefineUniformMesh(QWidget *parent, Qt::WFlags flags) -{ - ui.setupUi(this); -} - -QDefineUniformMesh::~QDefineUniformMesh() -{ - -} diff --git a/src/basics/geometry3d/examples/stl2inp/QDefineUniformMesh.h b/src/basics/geometry3d/examples/stl2inp/QDefineUniformMesh.h deleted file mode 100644 index 0648b9ae2..000000000 --- a/src/basics/geometry3d/examples/stl2inp/QDefineUniformMesh.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef QDEFINEUNIFORMMESH_H -#define QDEFINEUNIFORMMESH_H - -#include <QtGui/QDialog> -#include "./QDefineUniformMeshUI.h" - -class QDefineUniformMesh : public QDialog -{ - Q_OBJECT - -public: - QDefineUniformMesh(QWidget *parent = 0, Qt::WFlags flags = 0); - ~QDefineUniformMesh(); - - void setStartLevel(int startLevel) { ui.spinBox_startLevel->setValue(startLevel); } - void setStopLevel(int stopLevel) { ui.spinBox_stopLevel->setValue(stopLevel); } - void setDelta(double delta) { ui.doubleSpinBox_delta->setValue(delta); } - void setNX1(int nx1) { ui.spinBox_nx1->setValue(nx1); } - void setNX2(int nx2) { ui.spinBox_nx2->setValue(nx2); } - void setNX3(int nx3) { ui.spinBox_nx3->setValue(nx3); } - - int getStartLevel() { return ui.spinBox_startLevel->value(); } - int getStopLevel() { return ui.spinBox_stopLevel->value(); } - double getDelta() { return ui.doubleSpinBox_delta->value(); } - int getNX1() { return ui.spinBox_nx1->value(); } - int getNX2() { return ui.spinBox_nx2->value(); } - int getNX3() { return ui.spinBox_nx3->value(); } - -private: - Ui::QDefineUniformMesh ui; - -//private slots: -}; - -#endif // QDEFINEUNIFORMMESH_H diff --git a/src/basics/geometry3d/examples/stl2inp/QDefineUniformMesh.ui b/src/basics/geometry3d/examples/stl2inp/QDefineUniformMesh.ui deleted file mode 100644 index c03b2513f..000000000 --- a/src/basics/geometry3d/examples/stl2inp/QDefineUniformMesh.ui +++ /dev/null @@ -1,258 +0,0 @@ -<ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> - <class>QDefineUniformMesh</class> - <widget class="QDialog" name="QDefineUniformMesh" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>180</width> - <height>220</height> - </rect> - </property> - <property name="windowTitle" > - <string>Define Mesh Parameters</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="0" > - <layout class="QGridLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="1" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="label" > - <property name="toolTip" > - <string>Stop-Level der Verfeinerung</string> - </property> - <property name="text" > - <string>Stop-Level</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spinBox_stopLevel" /> - </item> - </layout> - </item> - <item row="0" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="label_6" > - <property name="toolTip" > - <string>Start-Level der Verfeinerung</string> - </property> - <property name="text" > - <string>Start-Level</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spinBox_startLevel" /> - </item> - </layout> - </item> - </layout> - </item> - <item row="1" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="label_2" > - <property name="toolTip" > - <string>Größe der Zellen</string> - </property> - <property name="text" > - <string>Delta</string> - </property> - </widget> - </item> - <item> - <widget class="QDoubleSpinBox" name="doubleSpinBox_delta" /> - </item> - </layout> - </item> - <item row="3" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>131</width> - <height>31</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="okButton" > - <property name="text" > - <string>OK</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="cancelButton" > - <property name="text" > - <string>Cancel</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="2" column="0" > - <layout class="QVBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="label_3" > - <property name="toolTip" > - <string>Anzahl Zellen in X-Richtung</string> - </property> - <property name="text" > - <string>nx1</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spinBox_nx1" /> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="label_4" > - <property name="toolTip" > - <string>Anzahl Zellen in Y-Richtung</string> - </property> - <property name="text" > - <string>nx2</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spinBox_nx2" /> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="label_5" > - <property name="toolTip" > - <string>Anzahl Zellen in Z-Richtung</string> - </property> - <property name="text" > - <string>nx3</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spinBox_nx3" /> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - <pixmapfunction></pixmapfunction> - <resources/> - <connections> - <connection> - <sender>okButton</sender> - <signal>clicked()</signal> - <receiver>QDefineUniformMesh</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel" > - <x>286</x> - <y>257</y> - </hint> - <hint type="destinationlabel" > - <x>96</x> - <y>254</y> - </hint> - </hints> - </connection> - <connection> - <sender>cancelButton</sender> - <signal>clicked()</signal> - <receiver>QDefineUniformMesh</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel" > - <x>369</x> - <y>257</y> - </hint> - <hint type="destinationlabel" > - <x>179</x> - <y>282</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/src/basics/geometry3d/examples/stl2inp/main.cpp b/src/basics/geometry3d/examples/stl2inp/main.cpp deleted file mode 100644 index 70f49c728..000000000 --- a/src/basics/geometry3d/examples/stl2inp/main.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include <iostream> -#include <cstdlib> - -#include <QtGui/QApplication> -#include "./stl2inp.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - STL2INP w; - - w.show(); - a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); - return a.exec(); -} diff --git a/src/basics/geometry3d/examples/stl2inp/stl2inp.cpp b/src/basics/geometry3d/examples/stl2inp/stl2inp.cpp deleted file mode 100644 index a476b0ced..000000000 --- a/src/basics/geometry3d/examples/stl2inp/stl2inp.cpp +++ /dev/null @@ -1,261 +0,0 @@ -#include "stl2inp.h" -#include <QtGui/QFileDialog> -#include <QString> -#include <QFile> -#include <QMessageBox> -#include <cstdio> - -#include "./QDefineUniformMesh.h" - -#include "./../../../../../source/basics/utilities/UbFileInputASCII.h" -#include "./../../../../../source/basics/utilities/UbFileOutputASCII.h" -#include "./../../../../../source/basics/utilities/UbFileOutputBinary.h" -#include "./../../../../../source/numerics/geometry3d/GbTriangularMesh3D.h" -#include "./../../../../../source/numerics/geometry3d/creator/GbTriangularMesh3DCreator.h" -#include "./../../../../../source/numerics/geometry3D/CoordinateTransformation3D.h" -#include "./../../../../../source/basics/utilities/UbTiming.h" -#include "./../../../../../source/octree/facette/OctFacettenGrid2.h" - -STL2INP::STL2INP(QWidget *parent, Qt::WFlags flags) -: QMainWindow(parent, flags) -{ - ui.setupUi(this); - startLevel = 0; - stopLevel = 3; - delta = 10.00; - nx1 = 30; - nx2 = 15; - nx3 = 5; - -} - -STL2INP::~STL2INP() -{ - -} - -void STL2INP::on_pBtn_Input_pressed() -{ - QString s = QFileDialog::getOpenFileName( - this, - "Choose a file", - "E:/", - "STL-Files (*.stl)"); - if(s != ""){ - ui.lineEdit_In->setText(s); - ui.statusBar->showMessage("Input-File: Filename defined", 3000); - } - else - ui.statusBar->showMessage("Input-File: No file found", 3000); - -} - -void STL2INP::on_lineEdit_In_returnPressed(){ - QString s = ui.lineEdit_In->text(); - if(s != ""){ - if(!s.endsWith(".stl",Qt::CaseSensitivity(false))) - { - s.append(".stl"); - ui.lineEdit_In->setText(s); - } - if(QFile::exists(s)) - ui.statusBar->showMessage("Inputput-File: File found", 3000); - else - ui.statusBar->showMessage("Input-File: File does not exist", 3000); - } - else - ui.statusBar->showMessage("Input-File: no Filename", 3000); -} - -void STL2INP::on_pBtn_Output_pressed(){ - QString s = QFileDialog::getSaveFileName( - this, - "Choose a filename to save under", - "E:/", - "AVS-File (*.inp)"); - if(s != ""){ - ui.lineEdit_Out->setText(s); - ui.statusBar->showMessage("Output-File: Filename defined", 3000); - } - else - ui.statusBar->showMessage("Output-File: No file defined", 3000); -} - -void STL2INP::on_lineEdit_Out_returnPressed(){ - QString s = ui.lineEdit_Out->text(); - if(s != ""){ - if(!s.endsWith(".inp",Qt::CaseSensitivity(false))) - { - s.append(".inp"); - ui.lineEdit_Out->setText(s); - } - if (QFile::exists(s)) - if(QMessageBox::question(this, - tr("Overwrite File? -- Application Name"), - tr("A file called %1 already exists." - "Do you want to overwrite it?") - .arg(s), - tr("&Yes"), tr("&No"), - QString(), 0, 1)) - ui.lineEdit_Out->setText(""); - else - ui.statusBar->showMessage("Output-File: overwrite existing File", 3000); - else - ui.statusBar->showMessage("Output-File: Filename defined", 3000); - } - else - ui.statusBar->showMessage("Output-File: No file defined", 3000); -} - -void STL2INP::on_pBtn_Output_2_pressed(){ - QString s = QFileDialog::getSaveFileName( - this, - "Choose a filename to save under", - "E:/", - "Data-File (*.dat)"); - if(s != ""){ - ui.pBtn_EditMesh->setEnabled(true); - ui.lineEdit_Out_2->setText(s); - ui.statusBar->showMessage("Output-File: Filename defined", 3000); - on_pBtn_EditMesh_pressed(); - } - else - ui.statusBar->showMessage("Output-File: No file defined", 3000); -} - -void STL2INP::on_lineEdit_Out_2_returnPressed(){ - QString s = ui.lineEdit_Out_2->text(); - if(s != ""){ - ui.pBtn_EditMesh->setEnabled(true); - if(!s.endsWith(".dat",Qt::CaseSensitivity(false))) - { - s.append(".dat"); - ui.lineEdit_Out_2->setText(s); - } - if (QFile::exists(s)) - if(QMessageBox::question(this, - tr("Overwrite File? -- Application Name"), - tr("A file called %1 already exists." - "Do you want to overwrite it?") - .arg(s), - tr("&Yes"), tr("&No"), - QString(), 0, 1)){ - ui.lineEdit_Out_2->setText(""); - ui.pBtn_EditMesh->setEnabled(false); - } - else{ - ui.statusBar->showMessage("Output-File: overwrite existing File", 3000); - ui.pBtn_EditMesh->setEnabled(true); - } - else{ - ui.statusBar->showMessage("Output-File: Filename defined", 3000); - on_pBtn_EditMesh_pressed(); - } - } - else - ui.statusBar->showMessage("Output-File: No file defined", 3000); -} - -void STL2INP::on_pBtn_Convert_pressed(){ - if(ui.lineEdit_In->text() == "") - QMessageBox::warning(this,"ERROR", "No Input-File defined!", - QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); - else if(ui.lineEdit_Out->text() == "" && ui.lineEdit_Out_2->text() == "") - QMessageBox::warning(this,"ERROR", "No Output-File defined!", - QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); - else - { - UbFileInputASCII *fileInput = new UbFileInputASCII(std::string(ui.lineEdit_In->text().toAscii())); - GbTriangularMesh3D *mesh = GbTriangularMesh3DCreator::readMeshFromSTLFile(fileInput, "Cube"); - ui.statusBar->showMessage("Input-File was read", 3000); - delete fileInput; - cout<<mesh->toString()<<endl; - if(ui.checkBox_writeAVS->isChecked()){ - if(ui.checkBox_Binary->isChecked()){ - UbFileOutputBinary *fileOutput_AVS = new UbFileOutputBinary(std::string(ui.lineEdit_Out->text().toAscii())); - mesh->writeAVSMesh(fileOutput_AVS); - delete fileOutput_AVS; - } - else{ - UbFileOutputASCII *fileOutput_AVS = new UbFileOutputASCII(std::string(ui.lineEdit_Out->text().toAscii())); - mesh->writeAVSMesh(fileOutput_AVS); - delete fileOutput_AVS; - } - ui.statusBar->showMessage("wrote AVS-Output-File"); - } - if(ui.checkBox_writeUM->isChecked()){ - cout<<"MinX:"<<mesh->getX1Minimum()<<endl; - cout<<"MaxX:"<<mesh->getX1Maximum()<<endl; - cout<<"MinY:"<<mesh->getX2Minimum()<<endl; - cout<<"MaxY:"<<mesh->getX2Maximum()<<endl; - cout<<"MinZ:"<<mesh->getX3Minimum()<<endl; - cout<<"MaxZ:"<<mesh->getX3Maximum()<<endl; - ui.statusBar->showMessage("start Writing Uniform-Mesh-File"); - double minX = 0.0; - double minY = 0.0; - double minZ = 0.0; - - CoordinateTransformation3D *trafo = new CoordinateTransformation3D(minX, minY, minZ, delta, delta, delta); - - UbTiming time; - time.initTiming(); - time.startTiming(); - - ui.statusBar->showMessage("start Building FacetteGrid", 3000); - OctFacettenGrid2 *facettegrid = new OctFacettenGrid2("FacettenGrid", nx1, nx2, nx3, startLevel, stopLevel, mesh, trafo); - ui.statusBar->showMessage("end Building FacetteGrid", 3000); - - UbFileOutputASCII out("E:/DATA/test.inp"); - facettegrid->writeCellsToAVS(&out); - - time.endTiming(); - cout<<"Dauer:"<<time.getDuration()<<endl; - cout<<"Number of cells:"<<facettegrid->getNumberOfCells()<<endl; - cout<<"after generation ..."<<endl<<endl; - double mydouble=0.0; - - time.initTiming(); - time.startTiming(); - ui.statusBar->showMessage("start writing", 3000); - UbFileOutputASCII *fileOutput_UM = new UbFileOutputASCII(std::string(ui.lineEdit_Out_2->text().toAscii())); - facettegrid->writeToUniformGridFile2(fileOutput_UM); - delete fileOutput_UM; - time.endTiming(); - cout<<"Dauer:"<<time.getDuration()<<endl; - int number = (int)facettegrid->getCells()->size(); - delete trafo; - delete mesh; - delete facettegrid; - cout<<"Ready!!!"<<endl; - ui.statusBar->showMessage("wrote Unstructured-Mesh Output-File", 3000); - } - } -} - -void STL2INP::on_checkBox_stateChanged(int) -{ - -} - -void STL2INP::on_pBtn_EditMesh_pressed() -{ - QDefineUniformMesh *meshdef = new QDefineUniformMesh(this); - meshdef->setStartLevel(startLevel); - meshdef->setStopLevel(stopLevel); - meshdef->setDelta(delta); - meshdef->setNX1(nx1); - meshdef->setNX2(nx2); - meshdef->setNX3(nx3); - meshdef->exec(); - - startLevel = meshdef->getStartLevel(); - stopLevel = meshdef->getStopLevel(); - //cout<<"Start-Level: "<<startLevel<<" Stop-Level: "<<stopLevel<<endl; - delta = meshdef->getDelta(); - //cout<<"Delta: "<<delta<<endl; - nx1 = meshdef->getNX1(); - nx2 = meshdef->getNX2(); - nx3 = meshdef->getNX3(); - //cout<<"nx1: "<<nx1<<" nx2: "<<nx2<<" nx3: "<<nx3<<endl; - delete meshdef; -} \ No newline at end of file diff --git a/src/basics/geometry3d/examples/stl2inp/stl2inp.h b/src/basics/geometry3d/examples/stl2inp/stl2inp.h deleted file mode 100644 index 353f2a2a7..000000000 --- a/src/basics/geometry3d/examples/stl2inp/stl2inp.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef STL2INP_H -#define STL2INP_H - -#include <QtGui/QMainWindow> -#include <QtGui/QProgressBar> -#include <QTimer> -#include "stl2inpUI.h" - -class STL2INP : public QMainWindow -{ - Q_OBJECT - -public: - STL2INP(QWidget *parent = 0, Qt::WFlags flags = 0); - ~STL2INP(); - - int startLevel, stopLevel; - double delta; - int nx1, nx2, nx3; - -private: - Ui::STL2INPClass ui; - - private slots: - void on_checkBox_stateChanged(int); - void on_pBtn_Input_pressed(); - void on_pBtn_Output_pressed(); - void on_pBtn_Output_2_pressed(); - void on_pBtn_Convert_pressed(); - void on_lineEdit_In_returnPressed(); - void on_lineEdit_Out_returnPressed(); - void on_lineEdit_Out_2_returnPressed(); - void on_pBtn_EditMesh_pressed(); -}; - -#endif // STL2INP_H diff --git a/src/basics/geometry3d/examples/stl2inp/stl2inp.ui b/src/basics/geometry3d/examples/stl2inp/stl2inp.ui deleted file mode 100644 index 28d3ab49c..000000000 --- a/src/basics/geometry3d/examples/stl2inp/stl2inp.ui +++ /dev/null @@ -1,452 +0,0 @@ -<ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> - <class>STL2INPClass</class> - <widget class="QMainWindow" name="STL2INPClass" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>350</height> - </rect> - </property> - <property name="windowTitle" > - <string>STL2INP</string> - </property> - <property name="statusTip" > - <string>...</string> - </property> - <widget class="QWidget" name="centralWidget" > - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="4" column="0" colspan="2" > - <widget class="QGroupBox" name="groupBox_2" > - <property name="title" > - <string>Output-Files</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="0" > - <widget class="QCheckBox" name="checkBox_writeAVS" > - <property name="text" > - <string>write AVS-File</string> - </property> - </widget> - </item> - <item row="0" column="1" colspan="3" > - <widget class="QCheckBox" name="checkBox_Binary" > - <property name="text" > - <string>write *.inp to Binary</string> - </property> - </widget> - </item> - <item row="4" column="0" > - <widget class="QCheckBox" name="checkBox_writeUM" > - <property name="text" > - <string>write Uniform-Mesh-File</string> - </property> - </widget> - </item> - <item row="1" column="0" colspan="3" > - <widget class="QLineEdit" name="lineEdit_Out" > - <property name="enabled" > - <bool>false</bool> - </property> - <property name="minimumSize" > - <size> - <width>300</width> - <height>17</height> - </size> - </property> - </widget> - </item> - <item row="5" column="3" > - <widget class="QPushButton" name="pBtn_Output_2" > - <property name="enabled" > - <bool>false</bool> - </property> - <property name="maximumSize" > - <size> - <width>25</width> - <height>23</height> - </size> - </property> - <property name="text" > - <string>...</string> - </property> - </widget> - </item> - <item row="5" column="0" colspan="3" > - <widget class="QLineEdit" name="lineEdit_Out_2" > - <property name="enabled" > - <bool>false</bool> - </property> - <property name="minimumSize" > - <size> - <width>300</width> - <height>17</height> - </size> - </property> - </widget> - </item> - <item row="1" column="3" > - <widget class="QPushButton" name="pBtn_Output" > - <property name="enabled" > - <bool>false</bool> - </property> - <property name="maximumSize" > - <size> - <width>25</width> - <height>23</height> - </size> - </property> - <property name="text" > - <string>...</string> - </property> - </widget> - </item> - <item rowspan="2" row="2" column="0" colspan="4" > - <widget class="Line" name="line" > - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item rowspan="2" row="3" column="2" colspan="2" > - <widget class="QPushButton" name="pBtn_EditMesh" > - <property name="enabled" > - <bool>false</bool> - </property> - <property name="minimumSize" > - <size> - <width>51</width> - <height>20</height> - </size> - </property> - <property name="maximumSize" > - <size> - <width>51</width> - <height>20</height> - </size> - </property> - <property name="text" > - <string>Edit Mesh</string> - </property> - </widget> - </item> - <item row="4" column="1" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item row="0" column="0" > - <widget class="QLabel" name="label_3" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>14</pointsize> - <weight>75</weight> - <italic>false</italic> - <bold>true</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>STL2INP</string> - </property> - </widget> - </item> - <item row="1" column="0" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="6" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QPushButton" name="pushButton_4" > - <property name="text" > - <string>EXIT</string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="pBtn_Convert" > - <property name="text" > - <string>Convert</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="5" column="0" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>21</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="0" > - <widget class="QGroupBox" name="groupBox" > - <property name="title" > - <string>Input-File</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="1" > - <widget class="QPushButton" name="pBtn_Input" > - <property name="maximumSize" > - <size> - <width>25</width> - <height>23</height> - </size> - </property> - <property name="text" > - <string>...</string> - </property> - </widget> - </item> - <item row="0" column="0" > - <widget class="QLineEdit" name="lineEdit_In" > - <property name="minimumSize" > - <size> - <width>300</width> - <height>17</height> - </size> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="3" column="0" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QStatusBar" name="statusBar" > - <property name="geometry" > - <rect> - <x>0</x> - <y>331</y> - <width>400</width> - <height>19</height> - </rect> - </property> - </widget> - </widget> - <layoutdefault spacing="6" margin="11" /> - <pixmapfunction></pixmapfunction> - <tabstops> - <tabstop>lineEdit_In</tabstop> - <tabstop>pBtn_Input</tabstop> - <tabstop>lineEdit_Out</tabstop> - <tabstop>pBtn_Output</tabstop> - <tabstop>checkBox_Binary</tabstop> - <tabstop>pBtn_Convert</tabstop> - <tabstop>pushButton_4</tabstop> - </tabstops> - <resources/> - <connections> - <connection> - <sender>pushButton_4</sender> - <signal>clicked()</signal> - <receiver>STL2INPClass</receiver> - <slot>close()</slot> - <hints> - <hint type="sourcelabel" > - <x>82</x> - <y>320</y> - </hint> - <hint type="destinationlabel" > - <x>222</x> - <y>349</y> - </hint> - </hints> - </connection> - <connection> - <sender>checkBox_writeAVS</sender> - <signal>clicked(bool)</signal> - <receiver>lineEdit_Out</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel" > - <x>43</x> - <y>189</y> - </hint> - <hint type="destinationlabel" > - <x>99</x> - <y>210</y> - </hint> - </hints> - </connection> - <connection> - <sender>checkBox_writeAVS</sender> - <signal>clicked(bool)</signal> - <receiver>pBtn_Output</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel" > - <x>130</x> - <y>189</y> - </hint> - <hint type="destinationlabel" > - <x>380</x> - <y>209</y> - </hint> - </hints> - </connection> - <connection> - <sender>checkBox_writeUM</sender> - <signal>clicked(bool)</signal> - <receiver>lineEdit_Out_2</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel" > - <x>74</x> - <y>237</y> - </hint> - <hint type="destinationlabel" > - <x>88</x> - <y>258</y> - </hint> - </hints> - </connection> - <connection> - <sender>checkBox_writeUM</sender> - <signal>clicked(bool)</signal> - <receiver>pBtn_Output_2</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel" > - <x>152</x> - <y>237</y> - </hint> - <hint type="destinationlabel" > - <x>380</x> - <y>257</y> - </hint> - </hints> - </connection> - <connection> - <sender>lineEdit_In</sender> - <signal>selectionChanged()</signal> - <receiver>pBtn_Input</receiver> - <slot>animateClick()</slot> - <hints> - <hint type="sourcelabel" > - <x>236</x> - <y>105</y> - </hint> - <hint type="destinationlabel" > - <x>345</x> - <y>98</y> - </hint> - </hints> - </connection> - <connection> - <sender>lineEdit_Out</sender> - <signal>selectionChanged()</signal> - <receiver>pBtn_Output</receiver> - <slot>animateClick()</slot> - <hints> - <hint type="sourcelabel" > - <x>302</x> - <y>203</y> - </hint> - <hint type="destinationlabel" > - <x>362</x> - <y>202</y> - </hint> - </hints> - </connection> - <connection> - <sender>lineEdit_Out_2</sender> - <signal>selectionChanged()</signal> - <receiver>pBtn_Output_2</receiver> - <slot>animateClick()</slot> - <hints> - <hint type="sourcelabel" > - <x>256</x> - <y>249</y> - </hint> - <hint type="destinationlabel" > - <x>365</x> - <y>253</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/src/basics/geometry3d/fem/FeAdhocTriFaceMesh3D.cpp b/src/basics/geometry3d/fem/FeAdhocTriFaceMesh3D.cpp deleted file mode 100644 index 86b7cc239..000000000 --- a/src/basics/geometry3d/fem/FeAdhocTriFaceMesh3D.cpp +++ /dev/null @@ -1,124 +0,0 @@ -#include "./FeAdhocTriFaceMesh3D.h" - -#include "./../GbPoint3D.h" -#include "./../GbTriangle3D.h" -#include "./../GbTriangularMesh3D.h" - -#include "./../../../basics/utilities/UbFileOutputASCII.h" -#include "./../../../basics/utilities/UbLogger.h" - -/*====================================================*/ -FeAdhocTriFaceMesh3D::FeAdhocTriFaceMesh3D():FeTriFaceMesh3D() -{ -} -/*====================================================*/ -FeAdhocTriFaceMesh3D::FeAdhocTriFaceMesh3D(std::string name, Mesh* mesh):FeTriFaceMesh3D() -{ - this->mesh = mesh; - this->setName(name); - - std::cout << "FeAdhocTriFaceMesh3D:Konstruktor !!!"<<std::endl; - std::cout << "num vertices: " << mesh->VL->nitem << ", num triangles: " << mesh->TL->nitem - << ", num quads: " << mesh->QL->nitem << std::endl; - - // this->writeAdhoCMeshForStefan("/scratch/geller/StudienMitAdhoC3D/mesh.inp"); - this->adhocVertices = new vector< ::Vertex*>; - - List *vertexlist = mesh->VL; - List *elementlist = mesh->TL; - - ListItem* LI; - ListItem* LI2; - Tri* triangle; - // double z1, z2, z3; - int id1, id2, id3; - ::Vertex *v1, *v2, *v3; - - //if (mesh->VL->status==open) close_Vertex_List(mesh->VL); - - FOR_ALL(vertexlist->first, LI, 0) - { - ::Vertex* V = get_Vertex(LI); - this->nodes->push_back(GbTriFaceMesh3D::Vertex((float)V->x, (float)V->y, (float)V->z)); - this->adhocVertices->push_back(V); - } - int countTris=0; - int fred=0; - FOR_ALL(elementlist->first, LI, 0) - { - triangle = get_Tri(LI); - if(triangle==NULL) UBLOG(logINFO, "hugo - dreieck ist NULL"); - v1 = triangle->V[0]; - v2 = triangle->V[1]; - v3 = triangle->V[2]; - int count=0; - id1=-1; id2=-1; id3=-1; - FOR_ALL(vertexlist->first, LI2, 0) - { - ::Vertex* V = get_Vertex(LI2); - if(v1==V) id1=count; - if(v2==V) id2=count; - if(v3==V) id3=count; - if((id1!=-1) && (id2!=-1) && (id3!=-1)) - { - break; - } - count++; - } - // this->triangles->push_back(GbTriFaceMesh3D::TriFace(v1->id, v2->id, v3->id)); - // das geht bei Winkelplatte und Bathe - this->triangles->push_back(GbTriFaceMesh3D::TriFace(id2, id1, id3)); - // this->triangles->push_back(GbTriFaceMesh3D::TriFace(id1, id2, id3)); - countTris++; - } - - std::cout<<"#################################"<<std::endl; - std::cout<<"countTris:"<<countTris<<std::endl; - std::cout<<"vecSize:"<<this->triangles->size()<<std::endl; - this->attributes->resize(nodes->size()); - - countTris=0; - for(int u=0;u<(int)this->triangles->size(); u++) - { - double area = (*this->triangles)[u].getArea(*this->nodes); - if(UbMath::zero(area)) countTris++; - } - std::cout<<"#################################"<<std::endl; - std::cout<<"Area 0 für:"<<countTris<<" Dreiecke"<<std::endl; - - this->calculateValues(); - - this->createVertexTriFaceMap(); -} -/*===============================================================================*/ -void FeAdhocTriFaceMesh3D::writeAdhoCMeshForStefan(string filename) -{ - std::cout << "FeAdhocTriFaceMesh3D::writeAdhoCMeshForStefan ...\n"; - List *elementlist = mesh->TL; - - ListItem* LI; - Tri* triangle; - - vector<GbPoint3D*>* tmnodes = new vector<GbPoint3D*>; - vector<GbTriangle3D*>* tmtriangles = new vector<GbTriangle3D*>; - - FOR_ALL(elementlist->first, LI, 0) - { - triangle = get_Tri(LI); - - GbPoint3D *node1 = new GbPoint3D(triangle->V[0]->x, triangle->V[0]->y, triangle->V[0]->z); - GbPoint3D *node2 = new GbPoint3D(triangle->V[1]->x, triangle->V[1]->y, triangle->V[1]->z); - GbPoint3D *node3 = new GbPoint3D(triangle->V[2]->x, triangle->V[2]->y, triangle->V[2]->z); - - tmnodes->push_back(node1); - tmnodes->push_back(node2); - tmnodes->push_back(node3); - tmtriangles->push_back(new GbTriangle3D(node1, node2, node3)); - - } - - GbTriangularMesh3D tmmesh("Name", tmnodes, tmtriangles); - UbFileOutputASCII out(filename); - tmmesh.writeAVSMesh(&out); -} - diff --git a/src/basics/geometry3d/fem/FeAdhocTriFaceMesh3D.h b/src/basics/geometry3d/fem/FeAdhocTriFaceMesh3D.h deleted file mode 100644 index 99a0a983f..000000000 --- a/src/basics/geometry3d/fem/FeAdhocTriFaceMesh3D.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef FEADHOCTRIFACEMESH3D_H -#define FEADHOCTRIFACEMESH3D_H - -#include <sstream> -#include <iostream> -#include <vector> -using namespace std; - -//extern "C" -//{ - //#include "mshpi.h" - #include "fsi_interface.h" - #include "fsi_user_interface.h" -//} - -#include "./FeTriFaceMesh3D.h" - -#ifdef CAB_RCF -#include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - - -/*=========================================================================*/ -/* FeAdhocTriFaceMesh3D */ -/* */ -/** - * This Class provides the triangular meshes. - * Note, that up to now no methods for checking consistency are included. - * in this context this class describes facettes from an 3D-object !!! -*/ -class FeAdhocTriFaceMesh3D : public FeTriFaceMesh3D -{ -public: - FeAdhocTriFaceMesh3D(); - FeAdhocTriFaceMesh3D(std::string name, Mesh *mesh); - - Mesh* getMesh() { return mesh; } - - void writeAdhoCMeshForStefan(string filename); - std::vector< ::Vertex*>* getAdhocVertices() { return this->adhocVertices; } - -#ifdef CAB_RCF - template<class Archive> - void serialize(Archive & ar, const unsigned int version) - { - serializeParent<FeTriFaceMesh3D>(ar, *this); - } -#endif //CAB_RCF - -private: - Mesh* mesh; - std::vector< ::Vertex*>* adhocVertices; -}; - -#ifdef RCF_USE_SF_SERIALIZATION -UB_AUTO_RUN_NAMED( SF::registerType<FeAdhocTriFaceMesh3D >("FeAdhocTriFaceMesh3D ") , SF_FeAdhocTriFaceMesh3D ); -UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< FeTriFaceMesh3D, FeAdhocTriFaceMesh3D>() ), SF_FeAdhocTriFaceMesh3D_BD1 ); -UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbTriFaceMesh3D, FeAdhocTriFaceMesh3D>() ), SF_FeAdhocTriFaceMesh3D_BD2 ); -UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, FeAdhocTriFaceMesh3D>() ), SF_FeAdhocTriFaceMesh3D_BD3 ); -#endif //RCF_USE_SF_SERIALIZATION - -#endif //FEADHOCTRIFACEMESH3D_H diff --git a/src/basics/geometry3d/fem/FeHalfDisc3D.cpp b/src/basics/geometry3d/fem/FeHalfDisc3D.cpp deleted file mode 100644 index b3751d20d..000000000 --- a/src/basics/geometry3d/fem/FeHalfDisc3D.cpp +++ /dev/null @@ -1,622 +0,0 @@ -#include <numerics/geometry3d/fem/FeHalfDisc3D.h> -#include <numerics/geometry3d/GbSystem3D.h> -#include <numerics/geometry3d/GbLine3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> -#include <numerics/geometry3d/fem/FePoint3D.h> -#include <basics/utilities/UbInfinity.h> - -using namespace std; - -/*=======================================================*/ -ObObjectCreator* FeHalfDisc3D::getCreator() -{ - return NULL;//FeHalfDisc3DCreator::getInstance(); -} -// Konstruktor -/*==========================================================*/ -FeHalfDisc3D::FeHalfDisc3D() -{ - GbPoint3D* p1 = new GbPoint3D(); - GbPoint3D* p2 = new GbPoint3D(); - mLine = new GbLine3D(p1,p2); - this->mLine->addObserver(this); - mRad = 0.0; - cylinderType = FeHalfDisc3D::NOTPARALLELTOAXIS; -} -/*=======================================================*/ -FeHalfDisc3D::FeHalfDisc3D(FeHalfDisc3D* cylinder) -{ - mRad = cylinder->getRadius(); - cylinderType = cylinder->cylinderType; - mLine = cylinder->getLine()->clone(); - - this->mLine->addObserver(this); -} -/*==========================================================*/ -FeHalfDisc3D::FeHalfDisc3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& rad) -{ - mLine = new GbLine3D; - mLine->setPoints( new GbPoint3D(min(x1a,x1b), min(x2a,x2b), min(x3a,x3b)) - ,new GbPoint3D(max(x1a,x1b), max(x2a,x2b), max(x3a,x3b))); - this->mLine->addObserver(this); - mRad = fabs(rad); - - this->initCylinderType(); - if((this->cylinderType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) - throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -FeHalfDisc3D::FeHalfDisc3D(GbPoint3D* p1, GbPoint3D* p2, const double& rad) -{ - mRad = rad; - - mLine = new GbLine3D(p1,p2); - this->mLine->addObserver(this); - this->initCylinderType(); - if((this->cylinderType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) - throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -FeHalfDisc3D::FeHalfDisc3D(GbLine3D* line, const double& rad) -{ - mRad = rad; - - this->mLine = line; - this->mLine->addObserver(this); - this->initCylinderType(); - if((this->cylinderType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) - throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -// Destruktor -FeHalfDisc3D::~FeHalfDisc3D() -{ - if(mLine) this->mLine->removeObserver(this); - mLine = NULL; -} -/*=======================================================*/ -void FeHalfDisc3D::initCylinderType() -{ - double x1a = mLine->getPoint1()->x1; double x1b = mLine->getPoint2()->x1; - double x2a = mLine->getPoint1()->x2; double x2b = mLine->getPoint2()->x2; - double x3a = mLine->getPoint1()->x3; double x3b = mLine->getPoint2()->x3; - - if (x1a!=x1b && x2a==x2b && x3a==x3b) this->cylinderType = X1PARALLEL; - else if(x2a!=x2b && x1a==x1b && x3a==x3b) this->cylinderType = X2PARALLEL; - else if(x3a!=x3b && x1a==x1b && x2a==x2b) this->cylinderType = X3PARALLEL; - else this->cylinderType = NOTPARALLELTOAXIS; -} -/*=======================================================*/ -void FeHalfDisc3D::finalize() -{ - if(this->mLine) - { - mLine->finalize(); - delete mLine; - mLine=NULL; - } -} -/*=======================================================*/ -double FeHalfDisc3D::getHeight() -{ - if(mLine) return mLine->getLength(); return 0.0; -} -/*=======================================================*/ -GbPoint3D* FeHalfDisc3D::getPoint1() -{ - if(this->mLine) return this->mLine->getPoint1(); - return NULL; -} -/*=======================================================*/ -GbPoint3D* FeHalfDisc3D::getPoint2() -{ - if(this->mLine) return this->mLine->getPoint2(); - return NULL; -} -/*=======================================================*/ -void FeHalfDisc3D::setRadius(const double& radius) -{ - this->mRad = std::fabs(radius); - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void FeHalfDisc3D::setLine(GbLine3D* line) -{ - if(this->mLine) this->mLine->removeObserver(this); - this->mLine = line; - this->mLine->addObserver(this); - this->initCylinderType(); - - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void FeHalfDisc3D::setPoint1(const double& x1, const double& x2, const double& x3) -{ - if(!mLine->getPoint1()) throw UbException(UB_EXARGS,"line has no point1"); - mLine->getPoint1()->setCoordinates(x1,x2,x3); - this->initCylinderType(); - - //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt... -} -/*=======================================================*/ -void FeHalfDisc3D::setPoint2(const double& x1, const double& x2, const double& x3) -{ - if(!mLine->getPoint2()) throw UbException(UB_EXARGS,"line has no point2"); - mLine->getPoint2()->setCoordinates(x1,x2,x3); - this->initCylinderType(); - - //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt... -} -/*==========================================================*/ -double FeHalfDisc3D::getX1Centroid() -{ - return mLine->getX1Centroid(); -} -/*==========================================================*/ -double FeHalfDisc3D::getX1Minimum() -{ - if (this->isParallelToX1Axis()) return mLine->getX1Minimum(); - else if(this->isParallelToX2Axis()) return mLine->getX1Centroid()-mRad; - else if(this->isParallelToX3Axis()) return mLine->getX1Centroid()-mRad; - else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeHalfDisc3D::getX1Maximum() -{ - if (this->isParallelToX1Axis()) return mLine->getX1Maximum(); - else if(this->isParallelToX2Axis()) return mLine->getX1Centroid()+mRad; - else if(this->isParallelToX3Axis()) return mLine->getX1Centroid()+mRad; - else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeHalfDisc3D::getX2Centroid() -{ - return mLine->getX2Centroid(); -} -/*==========================================================*/ -double FeHalfDisc3D::getX2Minimum() -{ - if (this->isParallelToX1Axis()) return mLine->getX2Centroid()-mRad; - else if(this->isParallelToX2Axis()) return mLine->getX2Minimum(); - else if(this->isParallelToX3Axis()) return mLine->getX2Centroid()-mRad; - else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeHalfDisc3D::getX2Maximum() -{ - if (this->isParallelToX1Axis()) return mLine->getX2Centroid()+mRad; - else if(this->isParallelToX2Axis()) return mLine->getX2Maximum(); - else if(this->isParallelToX3Axis()) return mLine->getX2Centroid()+mRad; - else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeHalfDisc3D::getX3Centroid() -{ - return mLine->getX3Centroid(); -} -/*==========================================================*/ -double FeHalfDisc3D::getX3Minimum() -{ - if (this->isParallelToX1Axis()) return mLine->getX3Centroid()-mRad; - else if(this->isParallelToX2Axis()) return mLine->getX3Centroid()-mRad; - else if(this->isParallelToX3Axis()) return mLine->getX3Minimum(); - else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeHalfDisc3D::getX3Maximum() -{ - if (this->isParallelToX1Axis()) return mLine->getX3Centroid()+mRad; - else if(this->isParallelToX2Axis()) return mLine->getX3Centroid()+mRad; - else if(this->isParallelToX3Axis()) return mLine->getX3Maximum(); - else throw UbException(UB_EXARGS,"derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -bool FeHalfDisc3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p) -{ - throw UbException(UB_EXARGS,"sollte mal einer machen ... "); -} -/*==========================================================*/ -bool FeHalfDisc3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary) -{ - throw UbException(UB_EXARGS,"sollte mal einer machen ... "); -} -/*=======================================================*/ -bool FeHalfDisc3D::isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - throw UbException(UB_EXARGS,"sollte mal einer machen ... "); -} - -/*==========================================================*/ -string FeHalfDisc3D::toString() -{ - stringstream ss; - ss<<"FeHalfDisc3D["; - ss<<"line="<<this->mLine->toString(); - ss<<", r="<<this->mRad; - ss<<"]"; - return(ss.str()); -} -/*==========================================================*/ -bool FeHalfDisc3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - throw UbException(UB_EXARGS,"sollte mal einer machen ... "); -} -/*==========================================================*/ -bool FeHalfDisc3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - throw UbException(UB_EXARGS,"sollte mal einer machen ... "); -} -/*==========================================================*/ -GbLine3D* FeHalfDisc3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2) -{ - throw UbException(UB_EXARGS,"sollte mal einer machen ... "); -} -/*==========================================================*/ -vector<GbTriangle3D*> FeHalfDisc3D::getSurfaceTriangleSet() -{ - double x1ma,x1mb,x2m,x3m; - if( this->isParallelToX1Axis() ) - { - x1ma = this->getX1Minimum(); - x1mb = this->getX1Maximum(); - x2m = this->getX2Centroid(); - x3m = this->getX3Centroid(); - } - else if( this->isParallelToX2Axis() ) - { - x1ma = this->getX2Minimum(); - x1mb = this->getX2Maximum(); - x2m = this->getX1Centroid(); - x3m = this->getX3Centroid(); - } - else if( this->isParallelToX3Axis() ) - { - x1ma = this->getX3Minimum(); - x1mb = this->getX3Maximum(); - x2m = this->getX2Centroid(); - x3m = this->getX1Centroid(); - } - else throw UbException(UB_EXARGS,"cylinder is not axis prallel"); - - vector<GbTriangle3D*> triangles; - - int segmentsCircle = 14; - double deltaPhi = UbMath::PI/(double)segmentsCircle; - - double phiX1a,phiX1b; - double x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d; - - double dXCylinder = fabs((x1mb-x1ma)); ///(double)0.5; - int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder); - for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++) - { - x1a = x1d = x1ma+segCyl*dXCylinder; - x1b = x1c = x1a+dXCylinder; - - for(phiX1a=UbMath::PI-deltaPhi; phiX1a>-deltaPhi; phiX1a-=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = x2m+mRad*std::sin(phiX1a); - x3a = x3m+mRad*std::cos(phiX1a); - x2b = x2m+mRad*std::sin(phiX1b); - x3b = x3m+mRad*std::cos(phiX1b); - - if( this->isParallelToX1Axis() ) - { - triangles.push_back(new GbTriangle3D(new FePoint3D(x1b,x2a,x3a),new FePoint3D(x1b,x2b,x3b),new FePoint3D(x1a,x2a,x3a))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1a,x2b,x3b),new FePoint3D(x1a,x2a,x3a),new FePoint3D(x1b,x2b,x3b))); - } - else if( this->isParallelToX2Axis() ) - { - triangles.push_back(new GbTriangle3D(new FePoint3D(x2b,x1b,x3b),new FePoint3D(x2a,x1b,x3a),new FePoint3D(x2a,x1a,x3a))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1a,x3a),new FePoint3D(x2b,x1a,x3b),new FePoint3D(x2b,x1b,x3b))); - } - else if( this->isParallelToX3Axis() ) - { - triangles.push_back(new GbTriangle3D(new FePoint3D(x3b,x2b,x1b),new FePoint3D(x3a,x2a,x1b),new FePoint3D(x3a,x2a,x1a))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1a),new FePoint3D(x3b,x2b,x1a),new FePoint3D(x3b,x2b,x1b))); - } - - } - } - - x2a = x2m; - x3a = x3m; - x2d = x2m; - x3d = x3m+mRad; - x3b = x3m; - x3c = x3m-mRad; - - triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2a,x3a),new FePoint3D(x1mb,x2a,x3a),new FePoint3D(x1ma,x2a,x3d))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2a,x3d),new FePoint3D(x1mb,x2a,x3a),new FePoint3D(x1mb,x2a,x3d))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2a,x3b),new FePoint3D(x1ma,x2a,x3b),new FePoint3D(x1ma,x2a,x3c))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2a,x3b),new FePoint3D(x1ma,x2a,x3c),new FePoint3D(x1mb,x2a,x3c))); - - for(phiX1a=UbMath::PI-deltaPhi; phiX1a>-deltaPhi; phiX1a-=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = x2m; - x3a = x3m; - x2b = x2m; - x3b = x3m; - x2c = x2m+mRad*std::sin(phiX1b); - x3c = x3m+mRad*std::cos(phiX1b); - x2d = x2m+mRad*std::sin(phiX1a); - x3d = x3m+mRad*std::cos(phiX1a); - - if( this->isParallelToX1Axis() ) - { - triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2d,x3d),new FePoint3D(x1ma,x2c,x3c),new FePoint3D(x1ma,x2a,x3a))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2d,x3d),new FePoint3D(x1mb,x2a,x3a),new FePoint3D(x1mb,x2c,x3c))); - } - else if( this->isParallelToX2Axis() ) - { - triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1ma,x3a),new FePoint3D(x2b,x1ma,x3b),new FePoint3D(x2c,x1ma,x3c))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x2c,x1ma,x3c),new FePoint3D(x2d,x1ma,x3d),new FePoint3D(x2a,x1ma,x3a))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x2c,x1mb,x3c),new FePoint3D(x2b,x1mb,x3b),new FePoint3D(x2a,x1mb,x3a))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1mb,x3a),new FePoint3D(x2d,x1mb,x3d),new FePoint3D(x2c,x1mb,x3c))); - } - else if( this->isParallelToX3Axis() ) - { - triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1ma),new FePoint3D(x3b,x2b,x1ma),new FePoint3D(x3c,x2c,x1ma))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x3c,x2c,x1ma),new FePoint3D(x3d,x2d,x1ma),new FePoint3D(x3a,x2a,x1ma))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x3c,x2c,x1mb),new FePoint3D(x3b,x2b,x1mb),new FePoint3D(x3a,x2a,x1mb))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1mb),new FePoint3D(x3d,x2d,x1mb),new FePoint3D(x3c,x2c,x1mb))); - } - } - - return triangles; -} -/*==========================================================*/ -void FeHalfDisc3D::objectChanged(UbObservable* changedObject) -{ - GbLine3D* line = dynamic_cast<GbLine3D*>(changedObject); - if(!line || this->mLine!=line) return; - - this->notifyObserversObjectChanged(); -} -/*==========================================================*/ -void FeHalfDisc3D::objectWillBeDeleted(UbObservable* objectForDeletion) -{ - if(this->mLine) - { - UbObservable* observedObj = dynamic_cast<UbObservable*>(this->mLine); - if(objectForDeletion == observedObj) { this->mLine = NULL; } - } -} -/*=======================================================*/ -void FeHalfDisc3D::scale(const double& sx1, const double& sx2, const double& sx3) -{ - if( this->isParallelToX1Axis() ) - { - if(!UbMath::equal(sx2,sx3)) throw UbException(UB_EXARGS,"|| to x1 -> different scaling sx2 and sx3 not possible"); - this->mRad*=sx2; - } - else if( this->isParallelToX2Axis() ) - { - if(!UbMath::equal(sx1,sx3)) throw UbException(UB_EXARGS,"|| to x2 -> different scaling sx1 and sx3 not possible"); - this->mRad*=sx1; - } - else if( this->isParallelToX3Axis() ) - { - if(!UbMath::equal(sx1,sx2)) throw UbException(UB_EXARGS,"|| to x3 -> different scaling sx1 and sx2 not possible"); - this->mRad*=sx1; - } - else throw UbException(UB_EXARGS,"unknown direction"); - - this->mLine->scale(sx1,sx2,sx3); - //notify observer wird automatisch aufgerufen -} -/*==========================================================*/ -void FeHalfDisc3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - mLine->write(out); - out->writeDouble(mRad); - out->writeInteger(cylinderType); -} -/*==========================================================*/ -void FeHalfDisc3D::read(UbFileInput* in) -{ - in->readString(); - mLine = new GbLine3D; - mLine->read(in); - mRad = in->readDouble(); - cylinderType = in->readInteger(); -} -/*==========================================================*/ -double FeHalfDisc3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) -{ - /* - Distance D of the intersection between a Ray((ox1,ox2,ox3),(dx1,dx2,dx3)) and a Plane P: ax+by+cz+d=0 - dc = a*dx1 + b*dx2 + c*dx3 - dw = a*ox1 + b*ox2 + c*ox3 + d - D = - dw / dc - */ - double px1, px2, px3; - double d = Ub::inf; // Distance to Min or Max Plane of the Cylinder - // final distance should be less that d - - if( this->isParallelToX1Axis() ) - { - double minX1 = this->getX1Minimum(); - double maxX1 = this->getX1Maximum(); - - if (UbMath::equal(x1 ,minX1) && UbMath::negative(rx1)) return -1.0; - else if(UbMath::equal(x1 ,maxX1) && UbMath::positive(rx1)) return -1.0; - - //falls die Linie nicht parallel zu den Seitenflächen ist - if( x1< minX1 || x1 > maxX1 ) //nur für punkte links und rechts des cylinders - { - px1 = (x1 < minX1 ? minX1 : maxX1); - //falls die Linie nicht parallel zu den Seitenflächen ist - if( !UbMath::zero(rx1) ) - { - // Plane a= 0, b= 1, c=0 d= -1*px2 - d = -1.0*(x1 - px1) / rx1; - px2 = x2 + d*rx2; - px3 = x3 + d*rx3; - - if(UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad)) - { - if (x1 < minX1 && rx1>0.0 ) d = Ub::inf; //punkt liegt "links" vom cylinder und strahl hat evtl weiteren SP auf oberfläche - else if(x1 > maxX1 && rx1<0.0 ) d = Ub::inf; - else return -1.0; - } - else return d; - } - else return -1.0; - } - else - { - if (UbMath::negative(rx1)) d = -1.0 * (x1 - minX1) / rx1; - else if(UbMath::positive(rx1)) d = -1.0 * (x1 - maxX1) / rx1; - } - } - else if( this->isParallelToX2Axis() ) - { - double minX2 = this->getX2Minimum(); - double maxX2 = this->getX2Maximum(); - - if (UbMath::equal(x2 ,minX2) && UbMath::negative(rx2)) return -1; - else if(UbMath::equal(x2 ,maxX2) && UbMath::positive(rx2)) return -1; - - if( minX2 > x2 || x2 > maxX2 ) - { - px2 = (x2 < minX2 ? minX2 : maxX2); - //falls die Linie nicht parallel zu den Seitenflächen ist - if( !UbMath::zero(rx2) ) - { - // Plane a= 0, b= 1, c=0 d= -1*px2 - d = -1*(x2 - px2) / rx2; - px1 = x1 + d*rx1; - px3 = x3 + d*rx3; - - if (UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad)) - { - if (x2 < minX2 && rx2>0.0 ) d = Ub::inf; //punkt liegt "links oberhalb" vom cylinder und strahl mit pos x1 hat evtl weiteren SP auf oberfläche - else if(x2 > maxX2 && rx2<0.0 ) d = Ub::inf; - else return -1.0; - } - else return d; - } - else return -1.0; - } - else - { - if (UbMath::negative(rx2)) d = -1.0 * (x2 - minX2) / rx2; - else if(UbMath::positive(rx2)) d = -1.0 * (x2 - maxX2) / rx2; - } - } - else if( this->isParallelToX3Axis() ) - { - double minX3 = this->getX3Minimum(); - double maxX3 = this->getX3Maximum(); - - if (UbMath::equal(x3, minX3) && UbMath::negative(rx3)) return -1.0; - else if(UbMath::equal(x3, maxX3) && UbMath::positive(rx3)) return -1.0; - - if(minX3 > x3 || x3 > maxX3 ) - { - px3 = (x3 < minX3 ? minX3 : maxX3); - //falls die Linie nicht parallel zu den Seitenflächen ist - if (!UbMath::zero(rx3)) - { - // Plane a= 0, b= 0, c=1 d= -1*px3 - d = -1.0*(x3 - px3) / rx3; - px2 = x2 + d*rx2; - px1 = x1 + d*rx1; - if( UbMath::greater(mLine->getDistance(px1,px2,px3) , mRad) ) - { - if (x3 < minX3 && rx3>0.0 ) d = Ub::inf; - else if(x3 > maxX3 && rx3<0.0 ) d = Ub::inf; - else return -1.0; - } - else return d; - } - else return -1.0; - } - else - { - if (UbMath::negative(rx3)) d = -1.0 * (x3 - minX3) / rx3; - else if(UbMath::positive(rx3)) d = -1.0 * (x3 - maxX3) / rx3; - } - } - else throw UbException(UB_EXARGS,"funzt nur bei achsen parallelem cylinder"); - ////////////////////////////////////////////////////////////////////////// - //Q berechnen für Infinity Cylinder - GbPoint3D* p1 = mLine->getPoint1(); - GbPoint3D* p2 = mLine->getPoint2(); - - double axisX1 = p2->x1 - p1->x1; /* Axis of the cylinder */ - double axisX2 = p2->x2 - p1->x2; /* mit p1 als base of cylinder */ - double axisX3 = p2->x3 - p1->x3; - - //double dirlen = mLine->getLength(); - //double abs, t, s; - - double RCx1 = x1 - p1->x1; - double RCx2 = x2 - p1->x2; - double RCx3 = x3 - p1->x3; - - //n = ray x axis - double nx1 = rx2*axisX3 - rx3*axisX2; - double nx2 = rx3*axisX1 - rx1*axisX3; - double nx3 = rx1*axisX2 - rx2*axisX1; - double nLength = nx1*nx1 + nx2*nx2 + nx3*nx3; - - double abs; - if( UbMath::zero( nLength ) ) - { /* ray parallel to cyl */ - //abs = RC dot axis - double abs = RCx1*axisX1 + RCx2*axisX2 + RCx3*axisX3; - double dx1 = RCx1 - abs*axisX1; - double dx2 = RCx2 - abs*axisX2; - double dx3 = RCx3 - abs*axisX3; - //abs = sqrt(dx1*dx1 + dx2*dx2 + dx3*dx3); - if( UbMath::greater( dx1*dx1 + dx2*dx2 + dx3*dx3 , mRad*mRad) ) - return -1.0; - } - - //normalize "n" - nLength = std::sqrt(nLength); - double invnLength = 1.0/nLength; - nx1*=invnLength; - nx2*=invnLength; - nx3*=invnLength; - - //shortest distance = fabs( RC dot n ) - abs = fabs( RCx1*nx1 + RCx2*nx2 + RCx3*nx3 ); - - if( UbMath::lessEqual(abs, mRad) ) - { /* if ray hits cylinder */ - //Ox1 = RC x axis - double Ox1 = RCx2*axisX3 - RCx3*axisX2; - double Ox2 = RCx3*axisX1 - RCx1*axisX3; - double Ox3 = RCx1*axisX2 - RCx2*axisX1; - //t = - O dot n / nLength; - double t = - (Ox1*nx1 + Ox2*nx2 + Ox3*nx3) / nLength; - - //O = n x axis; - Ox1 = nx2*axisX3 - nx3*axisX2; - Ox2 = nx3*axisX1 - nx1*axisX3; - Ox3 = nx1*axisX2 - nx2*axisX1; - - //normalize O - invnLength = 1.0/sqrt(Ox1*Ox1 + Ox2*Ox2 + Ox3*Ox3); - Ox1*=invnLength; - Ox2*=invnLength; - Ox3*=invnLength; - - double s = fabs( sqrt(mRad*mRad - abs*abs) / (rx1*Ox1 + rx2*Ox2 + rx3*Ox3) ); - - if( UbMath::greater(t-s,d) ) return -1.0; - - return t - s; - } - - return -1.0; -} -/*==========================================================*/ diff --git a/src/basics/geometry3d/fem/FeHalfDisc3D.h b/src/basics/geometry3d/fem/FeHalfDisc3D.h deleted file mode 100644 index 4855dac3f..000000000 --- a/src/basics/geometry3d/fem/FeHalfDisc3D.h +++ /dev/null @@ -1,104 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef FEHALFDISC3D_H -#define FEHALFDISC3D_H - -#include <vector> -#include <cmath> - -#include <numerics/geometry3d/GbObject3D.h> -#include <basics/utilities/UbObserver.h> - -class GbPoint3D; -class GbLine3D; -class GbTriangle3D; - -class GbObject3DCreator; - -class FeHalfDisc3D : public GbObject3D , public UbObserver -{ -public: - FeHalfDisc3D(); - FeHalfDisc3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& radius); - FeHalfDisc3D(GbPoint3D* p1, GbPoint3D* p2, const double& radius); - FeHalfDisc3D(GbLine3D* line, const double& rad); - FeHalfDisc3D(FeHalfDisc3D* cylinder); - ~FeHalfDisc3D(); - - FeHalfDisc3D* clone() { return new FeHalfDisc3D(this); } - void finalize(); - - double getRadius() { return this->mRad; }; - GbLine3D* getLine() {return mLine;} - GbPoint3D* getPoint1(); - GbPoint3D* getPoint2(); - - void setRadius(const double& radius); - void setLine(GbLine3D* line); - void setPoint1(const double& x1, const double& x2, const double& x3); - void setPoint2(const double& x1, const double& x2, const double& x3); - - bool isParallelToX1Axis() { return((this->cylinderType & X1PARALLEL ) == X1PARALLEL );} - bool isParallelToX2Axis() { return((this->cylinderType & X2PARALLEL ) == X2PARALLEL );} - bool isParallelToX3Axis() { return((this->cylinderType & X3PARALLEL ) == X3PARALLEL );} - bool isNotParallelToAxis(){ return((this->cylinderType & NOTPARALLELTOAXIS ) == NOTPARALLELTOAXIS );} - - double getHeight(); - - void scale(const double& sx1, const double& sx2, const double& sx3); - - double getX1Centroid(); - double getX1Minimum() ; - double getX1Maximum() ; - double getX2Centroid(); - double getX2Minimum() ; - double getX2Maximum() ; - double getX3Centroid(); - double getX3Minimum() ; - double getX3Maximum() ; - - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p); - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); - 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); - - GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2); - - bool hasRaytracing() { return true; } - /*|r| must be 1! einheitsvector!!*/ - double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3); - - std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - - std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - - //virtuelle Methoden von UbObserver - void objectChanged(UbObservable* changedObject); - void objectWillBeDeleted(UbObservable* objectForDeletion); - - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere - -protected: - void initCylinderType(); - - GbLine3D* mLine; - double mRad; - - int cylinderType; - - //void berechneQuerschnittsWerte(); - static const int NOTPARALLELTOAXIS = (1<<0); //1 - static const int X1PARALLEL = (1<<1); //2 - static const int X2PARALLEL = (1<<2); //4 - static const int X3PARALLEL = (1<<3); //8 -}; - -#endif diff --git a/src/basics/geometry3d/fem/FePlateTriangularMesh3D.cpp b/src/basics/geometry3d/fem/FePlateTriangularMesh3D.cpp deleted file mode 100644 index 8654792cb..000000000 --- a/src/basics/geometry3d/fem/FePlateTriangularMesh3D.cpp +++ /dev/null @@ -1,223 +0,0 @@ -#include <numerics/geometry3d/fem/FePlateTriangularMesh3D.h> - -using namespace std; - -FePlateTriangularMesh3D::FePlateTriangularMesh3D() : GbTriangularMesh3D() -{ -} - -FePlateTriangularMesh3D::FePlateTriangularMesh3D(string name, vector<GbPoint3D*> *nodes, vector<GbTriangle3D*> *triangles) : GbTriangularMesh3D(name, nodes, triangles) -{ -} - -/*=============================================================================================*/ - -FePlateTriangularMesh3D::FePlateTriangularMesh3D(string name, vector<GbTriangle3D*> *triangles) : GbTriangularMesh3D(name, triangles) -{ -} - -/*=============================================================================================*/ -FePlateTriangularMesh3D::FePlateTriangularMesh3D(string name, vector<GbPoint3D*> *nodes, vector<GbLine3D*> *edges, vector<GbTriangle3D*> *triangles) : GbTriangularMesh3D(name, nodes, edges, triangles) -{ -} -/*=============================================================================================*/ -FePlateTriangularMesh3D::~FePlateTriangularMesh3D() -{ - -} -/*======================================================================*/ - -/*======================================================================*/ -bool FePlateTriangularMesh3D::isPointInGbObject3D(const double& x1, const double& x2, const double& x3) -{ - //cout<<"GbTriangularMesh3D::isPointInGbObject3D"<<endl; - //Sebastian - //double xmin=this->getX1Minimum(); double xmax=this->getX1Maximum(); - // double ymin=this->getX2Minimum(); double ymax=this->getX2Maximum(); - // double zmin=this->getX3Minimum(); double zmax=this->getX3Maximum(); - // double dX = (xmax-xmin)/100.; - // double dY = (ymax-ymin)/100.; - // double dZ = (zmax-zmin)/100.; - // GbCuboid3D boundingCube(xmin-dX, ymin-dY, zmin-dZ, xmax+dX, ymax+dY, zmax+dZ); - // - //if(this->isPointInObject3DHalfSpace(x1,x2,x3)) - //{ - // return true; - //} - //if(!boundingCube.isPointInGbObject3D(x1, x2, x3)) - //{ - // return false; - //} - - //return false; - //Marco - int inside = 0; - int nx1 = this->getNodesX1Dir()-1; - int nx2 = this->getNodesX2Dir()-1; - int maxTriangels = 2*nx1*nx2; - - //Überprüft, ob der Punkt innerhalb des Netzes liegt - double xmin=this->getX1Minimum(); double xmax=this->getX1Maximum(); - double ymin=this->getX2Minimum(); double ymax=this->getX2Maximum(); - double zmin=this->getX3Minimum(); double zmax=this->getX3Maximum(); - if( x1<=xmax && x1>=xmin - && x2<=ymax && x2>=ymin - && x3<=zmax && x3>=zmin) - { - //Achtung Sonderfall - //Es wird nur gegen die obere Lage Dreiecke getestet, da die untere Lage um den Abstand 'height' verschoben ist! - //Die Seiten müssen somit auch nicht berücksichtigt werden - for(int i=0; i<int(maxTriangels);i++) - { - if( (triangles->at(i))->enclosesPoint2D(x1, x2) - && x3<triangles->at(i)->getX3Centroid() - && x3>triangles->at(i)->getX3Centroid() - this->height ) - { - inside++; - } - } - } - - if(inside!=0) - { - return true; - } - else return false; -} -/*======================================================================*/ -FePlateTriangularMesh3D* FePlateTriangularMesh3D::createMeshByElements(int ElementsX1, int ElementsX2, double nulllevel, double deltaX1, double deltaX2, double height) -{ - FePlateTriangularMesh3D* triMesh = FePlateTriangularMesh3D::createMeshByNodes(ElementsX1+1, ElementsX2+1, nulllevel, deltaX1, deltaX2, height); - return triMesh; -} -/*======================================================================*/ -FePlateTriangularMesh3D* FePlateTriangularMesh3D::createMeshByNodes(int nodesX1, int nodesX2, double nulllevel, double deltaX1, double deltaX2, double height) -{ - cout<<"erstelle GbTriangularMesh3D -> "; - vector<GbTriangle3D*> *triangles = new vector<GbTriangle3D*>; - vector<GbPoint3D*> *points = new vector<GbPoint3D*>; - double h1=nulllevel+0.5*height; - double h2=nulllevel-0.5*height; - GbPoint3D* point1; - GbPoint3D* point2; - GbPoint3D* point3; - GbPoint3D* point4; - //Erstelle Knoten - //oben - for(int i=0; i<nodesX1; i++) - { - for(int j=0; j<nodesX2; j++) - { - GbPoint3D* point = new GbPoint3D(i*deltaX1,j*deltaX2,h1); - points->push_back(point); - } - } - //unten - for(int i=0; i<nodesX1; i++) - { - for(int j=0; j<nodesX2; j++) - { - GbPoint3D* point = new GbPoint3D(i*deltaX1,j*deltaX2,h2); - points->push_back(point); - } - } - int size=int(points->size()); - //Erstelle Dreiecke - //oben - for(int i=0; i<(size/2)-nodesX2; i+=nodesX2) - { - for(int j=0; j<nodesX2-1; j++) - { - point1 = points->at(i+j); - point2 = points->at(i+j+1); - point3 = points->at(i+j+nodesX2); - point4 = points->at(i+j+nodesX2+1); - GbTriangle3D* tri1 = new GbTriangle3D(point1,point3,point4); - GbTriangle3D* tri2 = new GbTriangle3D(point1,point4,point2); - triangles->push_back(tri1); - triangles->push_back(tri2); - } - } - //unten - for(int i=(size/2); i<size-nodesX2; i+=nodesX2) - { - for(int j=0; j<nodesX2-1; j++) - { - point1 = points->at(i+j); - point2 = points->at(i+j+1); - point3 = points->at(i+j+nodesX2); - point4 = points->at(i+j+nodesX2+1); - GbTriangle3D* tri1 = new GbTriangle3D(point4,point3,point1); - GbTriangle3D* tri2 = new GbTriangle3D(point2,point4,point1); - triangles->push_back(tri1); - triangles->push_back(tri2); - } - } - //Rand - //Nord - for(int i=0;i<nodesX1-1;i++) - { - int a = i*nodesX2+nodesX2-1; - int b = (i+1)*nodesX2+nodesX2-1; - point1 = points->at(a); - point2 = points->at(b); - point3 = points->at(a+size/2); - point4 = points->at(b+size/2); - GbTriangle3D* tri1 = new GbTriangle3D(point1,point2,point3); - GbTriangle3D* tri2 = new GbTriangle3D(point2,point4,point3); - triangles->push_back(tri1); - triangles->push_back(tri2); - } - //Süd - for(int i=0;i<nodesX1-1;i++) - { - int a = i*nodesX2; - int b = (i+1)*nodesX2; - point1 = points->at(a); - point2 = points->at(b); - point3 = points->at(a+size/2); - point4 = points->at(b+size/2); - GbTriangle3D* tri1 = new GbTriangle3D(point3,point2,point1); - GbTriangle3D* tri2 = new GbTriangle3D(point3,point4,point2); - triangles->push_back(tri1); - triangles->push_back(tri2); - } - //Ost - for(int j=0;j<nodesX2-1;j++) - { - int a = j; - int b = j+1; - point1 = points->at(a); - point2 = points->at(b); - point3 = points->at(a+size/2); - point4 = points->at(b+size/2); - GbTriangle3D* tri1 = new GbTriangle3D(point1,point2,point3); - GbTriangle3D* tri2 = new GbTriangle3D(point4,point3,point2); - triangles->push_back(tri1); - triangles->push_back(tri2); - } - //West - for(int j=0;j<nodesX2-1;j++) - { - int a = j+(nodesX1-1)*nodesX2; - int b = j+(nodesX1-1)*nodesX2+1; - point1 = points->at(a); - point2 = points->at(b); - point3 = points->at(a+size/2); - point4 = points->at(b+size/2); - GbTriangle3D* tri1 = new GbTriangle3D(point3,point2,point1); - GbTriangle3D* tri2 = new GbTriangle3D(point2,point3,point4); - triangles->push_back(tri1); - triangles->push_back(tri2); - } - string name = "TriMesh"; - FePlateTriangularMesh3D* triMesh = new FePlateTriangularMesh3D(name,points,triangles); - triMesh->setNullLevel((float)nulllevel); - triMesh->setHeight(height); - triMesh->setNodesX1Dir(nodesX1); - triMesh->setNodesX2Dir(nodesX2); - cout<<"done"<<endl; - return triMesh; -} - - diff --git a/src/basics/geometry3d/fem/FePlateTriangularMesh3D.h b/src/basics/geometry3d/fem/FePlateTriangularMesh3D.h deleted file mode 100644 index 19fc2a07c..000000000 --- a/src/basics/geometry3d/fem/FePlateTriangularMesh3D.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef FEPLATETRIANGULARMESH_H -#define FEPLATETRIANGULARMESH_H - -#include <sstream> -#include <iostream> - -#include <numerics/geometry3d/GbTriangularMesh3D.h> - - -/*=========================================================================*/ -/* GbTriangularMesh3D */ -/* */ -/** - * This Class provides the triangular meshes. - * Note, that up to now no methods for checking consistency are included. - * in this context this class describes facettes from an 3D-object !!! -*/ -class FePlateTriangularMesh3D : public GbTriangularMesh3D -{ -public: - FePlateTriangularMesh3D(); - FePlateTriangularMesh3D(std::string name, std::vector<GbPoint3D*> *nodes, std::vector<GbTriangle3D*> *triangles); - FePlateTriangularMesh3D(std::string name, std::vector<GbTriangle3D*> *triangles); - FePlateTriangularMesh3D(std::string name, std::vector<GbPoint3D*> *nodes, std::vector<GbLine3D*> *edges, std::vector<GbTriangle3D*> *triangles); - virtual ~FePlateTriangularMesh3D(); - - static FePlateTriangularMesh3D* createMeshByNodes(int nodesX1, int nodesX2, double nulllevel, double deltaX1, double deltaX2, double height); - static FePlateTriangularMesh3D* createMeshByElements(int ElementsX1, int ElementsX2, double nulllevel, double deltaX1, double deltaX2, double height); - - - float getNullLevel() { return this->nulllevel; } - void setNullLevel(float nulllevel) { this->nulllevel = nulllevel; } - double getHeight() { return this->height; } - void setHeight(double height) { this->height = height; } - int getNodesX1Dir() { return this->nodesX1Dir; } - void setNodesX1Dir(int nodesX1Dir) { this->nodesX1Dir = nodesX1Dir; } - int getNodesX2Dir() { return this->nodesX2Dir; } - void setNodesX2Dir(int nodesX2Dir) { this->nodesX2Dir = nodesX2Dir; } - - bool isPointInGbObject3D(const double& x1, const double& x2, const double& x3); - - /*======================================================================*/ -private: - float nulllevel; - double height; - int nodesX1Dir; - int nodesX2Dir; -}; -/*=========================================================================*/ -#endif diff --git a/src/basics/geometry3d/fem/FePoint3D.h b/src/basics/geometry3d/fem/FePoint3D.h deleted file mode 100644 index 8e0eb8a7a..000000000 --- a/src/basics/geometry3d/fem/FePoint3D.h +++ /dev/null @@ -1,148 +0,0 @@ -#ifndef FEPOINT3D_H -#define FEPOINT3D_H - -#include <sstream> -#include <numerics/geometry3d/GbPoint3D.h> - - -/*=========================================================================*/ -/* GbPoint3D */ -/* */ -/** - * This Class provides basic 3D point objects. - * <BR><BR><HR> - * @author <A HREF="mailto:geller@bauinf.tu-cottbus.de">S. Geller</A> - * @version 1.0 - 10.02.07 - * - */ -class FePoint3D : public GbPoint3D -{ -private: - - double Fx; - double Fy; - double Fz; - //double oldFx; - //double oldFy; - double sumFx; - double sumFy; - double sumFz; - double velocityX; - double velocityY; - double velocityZ; - //double accelerationX; - //double accelerationY; - UbTupleDouble6 stresses; - - double area; -public: - FePoint3D():GbPoint3D() - { - this->init(); - } - FePoint3D(double x, double y, double z):GbPoint3D(x,y,z) - { - this->init(); - } - FePoint3D(GbPoint3D *point):GbPoint3D(point) - { - this->init(); - } - - FePoint3D(FePoint3D *point):GbPoint3D(point) - { - this->Fx = point->Fx; - this->Fy = point->Fy; - this->Fz = point->Fz; - throw UbException(__FILE__,__LINE__,"spaeter fertig machen..."); - } - - virtual ~FePoint3D() - { - } - - void init() - { - this->Fx = 0.0; - this->Fy = 0.0; - this->Fz = 0.0; - //this->oldFx = 0.0; - //this->oldFy = 0.0; - this->sumFx = 0.0; - this->sumFy = 0.0; - this->sumFz = 0.0; - val<1>(stresses) = 0.0; - val<2>(stresses) = 0.0; - val<3>(stresses) = 0.0; - val<4>(stresses) = 0.0; - val<5>(stresses) = 0.0; - val<6>(stresses) = 0.0; - this->area = 0.0; - this->velocityX = 0.0; - this->velocityY = 0.0; - this->velocityZ = 0.0; - } - /*======================================================================*/ - FePoint3D* clone() - { - return(new FePoint3D(this)); - } - - double getVelocityX() { return(this->velocityX); } - double getVelocityY() { return(this->velocityY); } - double getVelocityZ() { return(this->velocityZ); } - void setVelocityX(double x) { this->velocityX = x; } - void setVelocityY(double y) { this->velocityY = y; } - void setVelocityZ(double z) { this->velocityZ = z; } - - double getFX() { return(this->Fx); } - double getFY() { return(this->Fy); } - double getFZ() { return(this->Fz); } - void setFX(double FX) { this->Fx = FX; } - void setFY(double FY) { this->Fy = FY; } - void setFZ(double FZ) { this->Fz = FZ; } - void addFX(double FX) { this->Fx += FX; } - void addFY(double FY) { this->Fy += FY; } - void addFZ(double FZ) { this->Fz += FZ; } - - double getSumFX() { return(this->sumFx); } - double getSumFY() { return(this->sumFy); } - double getSumFZ() { return(this->sumFz); } - void setSumFX(double FX) { this->sumFx = FX; } - void setSumFY(double FY) { this->sumFy = FY; } - void setSumFZ(double FZ) { this->sumFz = FZ; } - void addSumFX(double FX) { this->sumFx += FX; } - void addSumFY(double FY) { this->sumFy += FY; } - void addSumFZ(double FZ) { this->sumFz += FZ; } - - UbTupleDouble6& getStresses() { return this->stresses; } -// void setS11(double S11) { this->S11 = S11; } -// void setS12(double S12) { this->S12 = S12; } -// void setS22(double S22) { this->S22 = S22; } - double getArea() { return this->area; } - void setArea(double area) { this->area = area; } - void addArea(double area) { this->area += area; } - - /** - * Returns a string representation of this 3D fe-point. - * @return a string representation of this 3D fe-point - */ - std::string toString() - { - std::stringstream ss; - ss<<"FePoint3D["; - ss<<"x1="<<this->x1; - ss<<", x2="<<this->x2; - ss<<", x3="<<this->x3; - ss<<", Fx="<<this->Fx; - ss<<", Fy="<<this->Fy; - ss<<", Fz="<<this->Fz<<"]"; - return((ss.str()).c_str()); - } - /*======================================================================*/ -}; -/*=========================================================================*/ -#endif - - - diff --git a/src/basics/geometry3d/fem/FeRing3D.cpp b/src/basics/geometry3d/fem/FeRing3D.cpp deleted file mode 100644 index 320e4d2b1..000000000 --- a/src/basics/geometry3d/fem/FeRing3D.cpp +++ /dev/null @@ -1,468 +0,0 @@ -#include <numerics/geometry3d/fem/FeRing3D.h> -#include <numerics/geometry3d/GbSystem3D.h> -#include <numerics/geometry3d/fem/FePoint3D.h> -#include <numerics/geometry3d/GbLine3D.h> -#include <numerics/geometry3d/GbTriangle3D.h> - -using namespace std; - -/*=======================================================*/ -ObObjectCreator* FeRing3D::getCreator() -{ - return NULL; //FeRing3DCreator::getInstance(); -} -// Konstruktor -/*==========================================================*/ -FeRing3D::FeRing3D() -{ - GbPoint3D* p1 = new GbPoint3D(); - GbPoint3D* p2 = new GbPoint3D(); - mLine = new GbLine3D(p1,p2); - this->mLine->addObserver(this); - inRadius = 0.0; - outRadius = 0.0; - ringType = FeRing3D::NOTPARALLELTOAXIS; -} -/*=======================================================*/ -FeRing3D::FeRing3D(FeRing3D* ring) -{ - inRadius = ring->getInRadius(); - outRadius = ring->getOutRadius(); - ringType = ring->ringType; - mLine = ring->getLine()->clone(); - - this->mLine->addObserver(this); -} -/*==========================================================*/ -FeRing3D::FeRing3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& inradius, const double& outradius) -{ - mLine = new GbLine3D; - mLine->setPoints( new GbPoint3D(min(x1a,x1b), min(x2a,x2b), min(x3a,x3b)) - ,new GbPoint3D(max(x1a,x1b), max(x2a,x2b), max(x3a,x3b))); - this->mLine->addObserver(this); - this->inRadius = inradius; - this->outRadius = outradius; - - this->initRingType(); - if((this->ringType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) - throw UbException("FeRing3D::FeRing3D - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -FeRing3D::FeRing3D(GbPoint3D* p1, GbPoint3D* p2, const double& inradius, const double& outradius) -{ - this->inRadius = inradius; - this->outRadius = outradius; - - mLine = new GbLine3D(p1,p2); - this->mLine->addObserver(this); - this->initRingType(); - if((this->ringType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) - throw UbException("FeRing3D::FeRing3D - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -FeRing3D::FeRing3D(GbLine3D* line, const double& inradius, const double& outradius) -{ - this->inRadius = inradius; - this->outRadius = outradius; - - this->mLine = line; - this->mLine->addObserver(this); - this->initRingType(); - if((this->ringType & NOTPARALLELTOAXIS)==NOTPARALLELTOAXIS) - throw UbException("FeRing3D::FeRing3D - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -// Destruktor -FeRing3D::~FeRing3D() -{ - if(mLine) this->mLine->removeObserver(this); - mLine = NULL; -} -/*=======================================================*/ -void FeRing3D::initRingType() -{ - double x1a = mLine->getPoint1()->x1; double x1b = mLine->getPoint2()->x1; - double x2a = mLine->getPoint1()->x2; double x2b = mLine->getPoint2()->x2; - double x3a = mLine->getPoint1()->x3; double x3b = mLine->getPoint2()->x3; - - if (x1a!=x1b && x2a==x2b && x3a==x3b) this->ringType = X1PARALLEL; - else if(x2a!=x2b && x1a==x1b && x3a==x3b) this->ringType = X2PARALLEL; - else if(x3a!=x3b && x1a==x1b && x2a==x2b) this->ringType = X3PARALLEL; - else this->ringType = NOTPARALLELTOAXIS; -} -/*=======================================================*/ -void FeRing3D::finalize() -{ - if(this->mLine) - { - mLine->finalize(); - delete mLine; - mLine=NULL; - } -} -/*=======================================================*/ -double FeRing3D::getHeight() -{ - if(mLine) return mLine->getLength(); return 0.0; -} -/*=======================================================*/ -GbPoint3D* FeRing3D::getPoint1() -{ - if(this->mLine) return this->mLine->getPoint1(); - return NULL; -} -/*=======================================================*/ -GbPoint3D* FeRing3D::getPoint2() -{ - if(this->mLine) return this->mLine->getPoint2(); - return NULL; -} -/*=======================================================*/ -void FeRing3D::setInRadius(const double& radius) -{ - this->inRadius = std::fabs(radius); - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void FeRing3D::setOutRadius(const double& radius) -{ - this->outRadius = std::fabs(radius); - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void FeRing3D::setLine(GbLine3D* line) -{ - if(this->mLine) this->mLine->removeObserver(this); - this->mLine = line; - this->mLine->addObserver(this); - this->initRingType(); - - this->notifyObserversObjectChanged(); -} -/*=======================================================*/ -void FeRing3D::setPoint1(const double& x1, const double& x2, const double& x3) -{ - if(!mLine->getPoint1()) throw UbException("FeRing3D::setPoint1() - line has no point1"); - mLine->getPoint1()->setCoordinates(x1,x2,x3); - this->initRingType(); - - //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt... -} -/*=======================================================*/ -void FeRing3D::setPoint2(const double& x1, const double& x2, const double& x3) -{ - if(!mLine->getPoint2()) throw UbException("FeRing3D::setPoint1() - line has no point2"); - mLine->getPoint2()->setCoordinates(x1,x2,x3); - this->initRingType(); - - //this->notifyObserversObjectChanged(); //wird automatisch aufgerufen, da der point (this) benachrichtigt... -} -/*==========================================================*/ -double FeRing3D::getX1Centroid() -{ - return mLine->getX1Centroid(); -} -/*==========================================================*/ -double FeRing3D::getX1Minimum() -{ - if (this->isParallelToX1Axis()) return mLine->getX1Minimum(); - else if(this->isParallelToX2Axis()) return mLine->getX1Centroid()-outRadius; - else if(this->isParallelToX3Axis()) return mLine->getX1Centroid()-outRadius; - else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Minimum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeRing3D::getX1Maximum() -{ - if (this->isParallelToX1Axis()) return mLine->getX1Maximum(); - else if(this->isParallelToX2Axis()) return mLine->getX1Centroid()+outRadius; - else if(this->isParallelToX3Axis()) return mLine->getX1Centroid()+outRadius; - else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Maximum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeRing3D::getX2Centroid() -{ - return mLine->getX2Centroid(); -} -/*==========================================================*/ -double FeRing3D::getX2Minimum() -{ - if (this->isParallelToX1Axis()) return mLine->getX2Centroid()-outRadius; - else if(this->isParallelToX2Axis()) return mLine->getX2Minimum(); - else if(this->isParallelToX3Axis()) return mLine->getX2Centroid()-outRadius; - else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Minimum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeRing3D::getX2Maximum() -{ - if (this->isParallelToX1Axis()) return mLine->getX2Centroid()+outRadius; - else if(this->isParallelToX2Axis()) return mLine->getX2Maximum(); - else if(this->isParallelToX3Axis()) return mLine->getX2Centroid()+outRadius; - else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Maximum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeRing3D::getX3Centroid() -{ - return mLine->getX3Centroid(); -} -/*==========================================================*/ -double FeRing3D::getX3Minimum() -{ - if (this->isParallelToX1Axis()) return mLine->getX3Centroid()-outRadius; - else if(this->isParallelToX2Axis()) return mLine->getX3Centroid()-outRadius; - else if(this->isParallelToX3Axis()) return mLine->getX3Minimum(); - else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Minimum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -double FeRing3D::getX3Maximum() -{ - if (this->isParallelToX1Axis()) return mLine->getX3Centroid()+outRadius; - else if(this->isParallelToX2Axis()) return mLine->getX3Centroid()+outRadius; - else if(this->isParallelToX3Axis()) return mLine->getX3Maximum(); - else throw UbException(__FILE__, __LINE__, "FeRing3D::getX3Maximum - derzeit nur zu Achsen orthogonale Cylinder erlaubt... isPointInObject3D funzt sonst ned"); -} -/*==========================================================*/ -bool FeRing3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p) -{ - throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented"); - -} -/*==========================================================*/ -bool FeRing3D::isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary) -{ - throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented"); -} -/*=======================================================*/ -bool FeRing3D::isCellInsideGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented"); -} - -/*==========================================================*/ -string FeRing3D::toString() -{ - stringstream ss; - ss<<"FeRing3D["; - ss<<"line="<<this->mLine->toString(); - ss<<", inRadius="<<this->inRadius; - ss<<", outRadius="<<this->outRadius; - ss<<"]"; - return(ss.str()); -} -/*==========================================================*/ -bool FeRing3D::isCellInsideOrCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented"); -} -/*==========================================================*/ -bool FeRing3D::isCellCuttingGbObject3D(const double& x1a,const double& x2a,const double& x3a,const double& x1b,const double& x2b,const double& x3b) -{ - throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented"); -} -/*==========================================================*/ -GbLine3D* FeRing3D::createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2) -{ - throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented"); -} -/*==========================================================*/ -vector<GbTriangle3D*> FeRing3D::getSurfaceTriangleSet() -{ - double x1ma,x1mb,x2m,x3m; - if( this->isParallelToX1Axis() ) - { - x1ma = this->getX1Minimum(); - x1mb = this->getX1Maximum(); - x2m = this->getX2Centroid(); - x3m = this->getX3Centroid(); - } - else if( this->isParallelToX2Axis() ) - { - x1ma = this->getX2Minimum(); - x1mb = this->getX2Maximum(); - x2m = this->getX1Centroid(); - x3m = this->getX3Centroid(); - } - else if( this->isParallelToX3Axis() ) - { - x1ma = this->getX3Minimum(); - x1mb = this->getX3Maximum(); - x2m = this->getX2Centroid(); - x3m = this->getX1Centroid(); - } - else throw UbException(__FILE__, __LINE__, "FeRing3D::getSurfaceTriangleSet() - ring not axis prallel"); - - vector<GbTriangle3D*> triangles; - - int segmentsCircle = 14; - double deltaPhi = UbMath::PI/(double)segmentsCircle; - - double phiX1a,phiX1b; - double x1a,x2a,x3a,x1b,x2b,x3b,x1c,x2c,x3c,x1d,x2d,x3d; - double x2aa,x3aa,x2bb,x3bb; - - double dXCylinder = fabs((x1mb-x1ma)); // /(double)segmentsCircle; - int segmentsCylinder = (int)(fabs(x1mb-x1ma)/dXCylinder); - for(int segCyl = 0; segCyl<segmentsCylinder; segCyl++) - { - x1a = x1d = x1ma+segCyl*dXCylinder; - x1b = x1c = x1a+dXCylinder; - - for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = x2m+this->outRadius*std::sin(phiX1a); - x3a = x3m+this->outRadius*std::cos(phiX1a); - x2b = x2m+this->outRadius*std::sin(phiX1b); - x3b = x3m+this->outRadius*std::cos(phiX1b); - - x2aa = x2m+this->inRadius*std::sin(phiX1a); - x3aa = x3m+this->inRadius*std::cos(phiX1a); - x2bb = x2m+this->inRadius*std::sin(phiX1b); - x3bb = x3m+this->inRadius*std::cos(phiX1b); - - if( this->isParallelToX1Axis() ) - { - triangles.push_back(new GbTriangle3D(new FePoint3D(x1b,x2a,x3a),new FePoint3D(x1b,x2b,x3b),new FePoint3D(x1a,x2a,x3a))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1a,x2b,x3b),new FePoint3D(x1a,x2a,x3a),new FePoint3D(x1b,x2b,x3b))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1b,x2bb,x3bb),new FePoint3D(x1b,x2aa,x3aa),new FePoint3D(x1a,x2aa,x3aa))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1a,x2aa,x3aa),new FePoint3D(x1a,x2bb,x3bb),new FePoint3D(x1b,x2bb,x3bb))); - } - else if( this->isParallelToX2Axis() ) - { - throw UbException(__FILE__,__LINE__," sollte man mal machen"); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x2b,x1b,x3b),new FePoint3D(x2a,x1b,x3a),new FePoint3D(x2a,x1a,x3a))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1a,x3a),new FePoint3D(x2b,x1a,x3b),new FePoint3D(x2b,x1b,x3b))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x2bb,x1b,x3bb),new FePoint3D(x2aa,x1b,x3aa),new FePoint3D(x2aa,x1a,x3aa))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x2aa,x1a,x3aa),new FePoint3D(x2bb,x1a,x3bb),new FePoint3D(x2bb,x1b,x3bb))); - } - else if( this->isParallelToX3Axis() ) - { - throw UbException(__FILE__,__LINE__," sollte man mal machen"); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x3b,x2b,x1b),new FePoint3D(x3a,x2a,x1b),new FePoint3D(x3a,x2a,x1a))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1a),new FePoint3D(x3b,x2b,x1a),new FePoint3D(x3b,x2b,x1b))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x3bb,x2bb,x1b),new FePoint3D(x3aa,x2aa,x1b),new FePoint3D(x3aa,x2aa,x1a))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x3aa,x2aa,x1a),new FePoint3D(x3bb,x2bb,x1a),new FePoint3D(x3bb,x2bb,x1b))); - } - - } - } - - //int segmentsSide = (int)(this->outRadius/dXCylinder); - - double radius0, radius1; - //for(int segCyl = 10; segCyl<segmentsSide; segCyl++) - //{ - radius0 = inRadius;//segCyl*dXCylinder; - radius1 = outRadius;//radius0+dXCylinder; - //if(segCyl==segmentsSide-1) radius1=outRadius; - - for(phiX1a=2.0*UbMath::PI; phiX1a>0; phiX1a-=deltaPhi) - { - phiX1b = phiX1a+deltaPhi; - - x2a = x2m+radius0*std::sin(phiX1a); - x3a = x3m+radius0*std::cos(phiX1a); - x2b = x2m+radius0*std::sin(phiX1b); - x3b = x3m+radius0*std::cos(phiX1b); - x2c = x2m+radius1*std::sin(phiX1b); - x3c = x3m+radius1*std::cos(phiX1b); - x2d = x2m+radius1*std::sin(phiX1a); - x3d = x3m+radius1*std::cos(phiX1a); - - if( this->isParallelToX1Axis() ) - { - triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2b,x3b),new FePoint3D(x1ma,x2a,x3a),new FePoint3D(x1ma,x2c,x3c))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1ma,x2d,x3d),new FePoint3D(x1ma,x2c,x3c),new FePoint3D(x1ma,x2a,x3a))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2b,x3b),new FePoint3D(x1mb,x2c,x3c),new FePoint3D(x1mb,x2a,x3a))); - triangles.push_back(new GbTriangle3D(new FePoint3D(x1mb,x2d,x3d),new FePoint3D(x1mb,x2a,x3a),new FePoint3D(x1mb,x2c,x3c))); - } - else if( this->isParallelToX2Axis() ) - { - throw UbException(__FILE__,__LINE__," sollte man mal machen"); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1ma,x3a),new FePoint3D(x2b,x1ma,x3b),new FePoint3D(x2c,x1ma,x3c))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x2c,x1ma,x3c),new FePoint3D(x2d,x1ma,x3d),new FePoint3D(x2a,x1ma,x3a))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x2c,x1mb,x3c),new FePoint3D(x2b,x1mb,x3b),new FePoint3D(x2a,x1mb,x3a))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x2a,x1mb,x3a),new FePoint3D(x2d,x1mb,x3d),new FePoint3D(x2c,x1mb,x3c))); - } - else if( this->isParallelToX3Axis() ) - { - throw UbException(__FILE__,__LINE__," sollte man mal machen"); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1ma),new FePoint3D(x3b,x2b,x1ma),new FePoint3D(x3c,x2c,x1ma))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x3c,x2c,x1ma),new FePoint3D(x3d,x2d,x1ma),new FePoint3D(x3a,x2a,x1ma))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x3c,x2c,x1mb),new FePoint3D(x3b,x2b,x1mb),new FePoint3D(x3a,x2a,x1mb))); - //triangles.push_back(new GbTriangle3D(new FePoint3D(x3a,x2a,x1mb),new FePoint3D(x3d,x2d,x1mb),new FePoint3D(x3c,x2c,x1mb))); - } - } - // } - - return triangles; -} -/*==========================================================*/ -void FeRing3D::objectChanged(UbObservable* changedObject) -{ - GbLine3D* line = dynamic_cast<GbLine3D*>(changedObject); - if(!line || this->mLine!=line) return; - - this->notifyObserversObjectChanged(); -} -/*==========================================================*/ -void FeRing3D::objectWillBeDeleted(UbObservable* objectForDeletion) -{ - if(this->mLine) - { - UbObservable* observedObj = dynamic_cast<UbObservable*>(this->mLine); - if(objectForDeletion == observedObj) { this->mLine = NULL; } - } -} -/*=======================================================*/ -void FeRing3D::scale(const double& sx1, const double& sx2, const double& sx3) -{ - if( this->isParallelToX1Axis() ) - { - if(!UbMath::equal(sx2,sx3)) throw UbException("FeRing3D::scale - || to x1 -> different scaling sx2 and sx3 not possible"); - this->inRadius*=sx2; - this->outRadius*=sx2; - } - else if( this->isParallelToX2Axis() ) - { - if(!UbMath::equal(sx1,sx3)) throw UbException("FeRing3D::scale - || to x2 -> different scaling sx1 and sx3 not possible"); - this->inRadius*=sx1; - this->outRadius*=sx1; - } - else if( this->isParallelToX3Axis() ) - { - if(!UbMath::equal(sx1,sx2)) throw UbException("FeRing3D::scale - || to x3 -> different scaling sx1 and sx2 not possible"); - this->inRadius*=sx1; - this->outRadius*=sx1; - } - else throw UbException("FeRing3D::scale - unknown direction"); - - this->mLine->scale(sx1,sx2,sx3); - //notify observer wird automatisch aufgerufen -} -/*==========================================================*/ -void FeRing3D::write(UbFileOutput* out) -{ - out->writeString(this->getCreator()->getTypeID()); - mLine->write(out); - out->writeDouble(inRadius); - out->writeDouble(outRadius); - out->writeInteger(ringType); -} -/*==========================================================*/ -void FeRing3D::read(UbFileInput* in) -{ - in->readString(); - mLine = new GbLine3D; - mLine->read(in); - inRadius = in->readDouble(); - outRadius = in->readDouble(); - ringType = in->readInteger(); -} -/*==========================================================*/ -double FeRing3D::getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3) -{ - throw UbException(__FILE__,__LINE__,"FeRing3D function not implemented"); -} -/*==========================================================*/ - diff --git a/src/basics/geometry3d/fem/FeRing3D.h b/src/basics/geometry3d/fem/FeRing3D.h deleted file mode 100644 index 65e9a7ba4..000000000 --- a/src/basics/geometry3d/fem/FeRing3D.h +++ /dev/null @@ -1,107 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef FERING3D_H -#define FERING3D_H - -#include <vector> -#include <cmath> - -#include <numerics/geometry3d/GbObject3D.h> -#include <basics/utilities/UbObserver.h> - -class GbPoint3D; -class GbLine3D; -class GbTriangle3D; - -class GbObject3DCreator; - -class FeRing3D : public GbObject3D , public UbObserver -{ -public: - FeRing3D(); - FeRing3D(const double& x1a,const double& x2a, const double& x3a, const double& x1b,const double& x2b, const double& x3b, const double& inradius, const double& outradius); - FeRing3D(GbPoint3D* p1, GbPoint3D* p2, const double& inradius, const double& outradius); - FeRing3D(GbLine3D* line, const double& inradius, const double& outradius); - FeRing3D(FeRing3D* ring); - ~FeRing3D(); - - FeRing3D* clone() { return new FeRing3D(this); } - void finalize(); - - double getInRadius() { return this->inRadius; }; - double getOutRadius() { return this->outRadius; }; - GbLine3D* getLine() {return mLine;} - GbPoint3D* getPoint1(); - GbPoint3D* getPoint2(); - - void setInRadius(const double& radius); - void setOutRadius(const double& radius); - void setLine(GbLine3D* line); - void setPoint1(const double& x1, const double& x2, const double& x3); - void setPoint2(const double& x1, const double& x2, const double& x3); - - bool isParallelToX1Axis() { return((this->ringType & X1PARALLEL ) == X1PARALLEL );} - bool isParallelToX2Axis() { return((this->ringType & X2PARALLEL ) == X2PARALLEL );} - bool isParallelToX3Axis() { return((this->ringType & X3PARALLEL ) == X3PARALLEL );} - bool isNotParallelToAxis(){ return((this->ringType & NOTPARALLELTOAXIS ) == NOTPARALLELTOAXIS );} - - double getHeight(); - - void scale(const double& sx1, const double& sx2, const double& sx3); - - double getX1Centroid(); - double getX1Minimum() ; - double getX1Maximum() ; - double getX2Centroid(); - double getX2Minimum() ; - double getX2Maximum() ; - double getX3Centroid(); - double getX3Minimum() ; - double getX3Maximum() ; - - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p); - bool isPointInGbObject3D(const double& x1p, const double& x2p, const double& x3p, bool& pointIsOnBoundary); - 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); - - GbLine3D* createClippedLine3D(GbPoint3D& point1, GbPoint3D& point2); - - bool hasRaytracing() { return true; } - /*|r| must be 1! einheitsvector!!*/ - double getIntersectionRaytraceFactor(const double& x1, const double& x2, const double& x3, const double& rx1, const double& rx2, const double& rx3); - - std::vector<GbTriangle3D*> getSurfaceTriangleSet(); - - std::string toString(); - ObObjectCreator* getCreator(); - void write(UbFileOutput* out); - void read(UbFileInput* in); - - //virtuelle Methoden von UbObserver - void objectChanged(UbObservable* changedObject); - void objectWillBeDeleted(UbObservable* objectForDeletion); - - using GbObject3D::isPointInGbObject3D; //Grund: dadurch muss man hier isPointInGbObject3D(GbPoint3D*) nicht ausprogrammieren, welche sonst hier "ueberdeckt" waere - -protected: - void initRingType(); - - GbLine3D* mLine; - double inRadius; - double outRadius; - - int ringType; - - //void berechneQuerschnittsWerte(); - static const int NOTPARALLELTOAXIS = (1<<0); //1 - static const int X1PARALLEL = (1<<1); //2 - static const int X2PARALLEL = (1<<2); //4 - static const int X3PARALLEL = (1<<3); //8 -}; - -#endif diff --git a/src/basics/geometry3d/fem/FeTriFaceMesh3D.cpp b/src/basics/geometry3d/fem/FeTriFaceMesh3D.cpp deleted file mode 100644 index 68838ccea..000000000 --- a/src/basics/geometry3d/fem/FeTriFaceMesh3D.cpp +++ /dev/null @@ -1,256 +0,0 @@ -#include <numerics/geometry3d/fem/FeTriFaceMesh3D.h> - -#include <numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h> -#include <numerics/geometry3d/GbTriangle3D.h> - -#include <basics/writer/WbWriterVtkXmlBinary.h> -#include <basics/writer/WbWriterVtkXmlASCII.h> - -using namespace std; - -FeTriFaceMesh3D::FeTriFaceMesh3D():GbTriFaceMesh3D() -{ - this->attributes = new vector<VertexAttributes>; -// this->createVertexTriFaceMap(); -} -/*====================================================*/ -FeTriFaceMesh3D::FeTriFaceMesh3D(std::string name, std::vector<Vertex>* nodes, std::vector<TriFace>* triangles):GbTriFaceMesh3D(name,nodes,triangles) -{ - this->attributes = new vector<VertexAttributes>; - this->attributes->resize(nodes->size()); -// this->createVertexTriFaceMap(); -} -/*======================================================================*/ -ObObjectCreator* FeTriFaceMesh3D::getCreator() -{ - return FeTriFaceMesh3DCreator::getInstance(); -} -/*====================================================*/ -void FeTriFaceMesh3D::resizeAttributes() -{ - this->attributes->resize(nodes->size()); -} -/*====================================================*/ -//void FeTriFaceMesh3D::createVertexTriFaceMap() -//{ -// vertexTriFaceMap.clear(); -// vector<TriFace>& tris = *this->triangles; -// vector<Vertex>& pts = *this->nodes; -// -// for(size_t t=0; t<tris.size(); t++) -// { -// TriFace& tri = tris[t]; -// Vertex& vert1 = pts[tri.v1]; -// Vertex& vert2 = pts[tri.v2]; -// Vertex& vert3 = pts[tri.v3]; -// vertexTriFaceMap.setVertexTriFaceRelation(&vert1,&tri); -// vertexTriFaceMap.setVertexTriFaceRelation(&vert2,&tri); -// vertexTriFaceMap.setVertexTriFaceRelation(&vert3,&tri); -// } -//} -/*====================================================*/ -FeTriFaceMesh3D* FeTriFaceMesh3D::createMeshByTriangles(std::string name, std::vector<GbTriangle3D*> *triangles) -{ - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *tris = new vector<GbTriFaceMesh3D::TriFace>; - int nr=0; - for(int u=0;u<(int)triangles->size();u++) - { - if(UbMath::zero((*triangles)[u]->getArea())) continue; - - GbPoint3D* p1 = (*triangles)[u]->getPoint1(); - GbPoint3D* p2 = (*triangles)[u]->getPoint2(); - GbPoint3D* p3 = (*triangles)[u]->getPoint3(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)p1->getX1Coordinate(),(float)p1->getX2Coordinate(),(float)p1->getX3Coordinate())); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)p2->getX1Coordinate(),(float)p2->getX2Coordinate(),(float)p2->getX3Coordinate())); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)p3->getX1Coordinate(),(float)p3->getX2Coordinate(),(float)p3->getX3Coordinate())); - tris->push_back(GbTriFaceMesh3D::TriFace(nr,nr+1,nr+2)); - nr+=3; - } - FeTriFaceMesh3D* triMesh = new FeTriFaceMesh3D(name, nodes, tris); - triMesh->deleteRedundantNodes(); - triMesh->resizeAttributes(); - return triMesh; -} - -/*======================================================================*/ -UbTuple<string,string> FeTriFaceMesh3D::writeMesh(string filename, WbWriter* writer, bool writeNormals, std::vector< std::string >* datanames, std::vector< std::vector < double > >* nodedata) -{ - if(datanames || nodedata) - { - UBLOG(logWARNING,"FeTriFaceMesh3D::writeMesh - no support for extra datanames || nodedata"); - } - - UBLOG2(logDEBUG1,std::cout,"FeTriFaceMesh3D::writeMesh - start"); - - UbTuple<string,string> filenames; - - if( dynamic_cast<WbWriterVtkXmlBinary*>(writer) || dynamic_cast<WbWriterVtkXmlASCII*>(writer)) - { - vector< UbTupleFloat3 > triNodes( nodes->size() ); - vector< UbTupleInt3 > tris( triangles->size() ); - - for(size_t i=0; i<nodes->size(); i++) - triNodes[i] = makeUbTuple( (*nodes)[i].x, (*nodes)[i].y, (*nodes)[i].z ); - - for(size_t i=0; i<triangles->size(); i++) - tris[i] = makeUbTuple( (*triangles)[i].v1, (*triangles)[i].v2, (*triangles)[i].v3 ) ; - - vector<string> localDataNames; - localDataNames.push_back("Fx" ); - localDataNames.push_back("Fy" ); - localDataNames.push_back("Fz" ); - localDataNames.push_back("sumFx" ); - localDataNames.push_back("sumFy" ); - localDataNames.push_back("sumFz" ); - localDataNames.push_back("vx" ); - localDataNames.push_back("vy" ); - localDataNames.push_back("vz" ); - localDataNames.push_back("S1" ); - localDataNames.push_back("S2" ); - localDataNames.push_back("S3" ); - localDataNames.push_back("S4" ); - localDataNames.push_back("S5" ); - localDataNames.push_back("S6" ); - localDataNames.push_back("Pressure"); - - std::vector< std::vector < double > > localNodedata( localDataNames.size(), std::vector<double>( nodes->size() ) ); - for(size_t n=0; n<nodes->size(); n++) - { - FeTriFaceMesh3D::VertexAttributes& attribut = (*this->attributes)[n]; - - localNodedata[ 0][n] = attribut.getFX(); - localNodedata[ 1][n] = attribut.getFY(); - localNodedata[ 2][n] = attribut.getFZ(); - localNodedata[ 3][n] = attribut.getSumFX(); - localNodedata[ 4][n] = attribut.getSumFY(); - localNodedata[ 5][n] = attribut.getSumFZ(); - localNodedata[ 6][n] = attribut.getVelocityX(); - localNodedata[ 7][n] = attribut.getVelocityY(); - localNodedata[ 8][n] = attribut.getVelocityZ(); - localNodedata[ 9][n] = val<1>(attribut.getStresses()); - localNodedata[10][n] = val<2>(attribut.getStresses()); - localNodedata[11][n] = val<3>(attribut.getStresses()); - localNodedata[12][n] = val<4>(attribut.getStresses()); - localNodedata[13][n] = val<5>(attribut.getStresses()); - localNodedata[14][n] = val<6>(attribut.getStresses()); - localNodedata[15][n] = attribut.getPressure(); - } - val<1>(filenames) = writer->writeTrianglesWithNodeData(filename,triNodes,tris,localDataNames,localNodedata); - } - else - { - string avsfilename = filename+writer->getFileExtension(); - val<1>(filenames)=avsfilename; - - ofstream out(avsfilename.c_str(),ios::out); - if(!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!outfile) weiterhin true!!! - string path = UbSystem::getPathFromString(filename); - if(path.size()>0){UbSystem::makeDirectory(path);out.open(filename.c_str(),ios::out);} - if(!out) throw UbException(UB_EXARGS,"file konnte nicht geschrieben werden"); - } - - //cout<<"AvsASCII - writeLines to "<<avsfilename<<" ..."; - - int nofNodes = (int)nodes->size(); - int nofTrian = (int)triangles->size(); - int dataSize = 16; - - out<<"# UCD-File created by WbWriterAvsASCII\n"; - out<<nofNodes<<" "<<nofTrian<<" "<<dataSize<<" 0 0 "<<endl; - - for(int i=0; i<nofNodes; i++) - out<<i+1<<" "<< (*nodes)[i].x<<" "<< (*nodes)[i].y<<" "<< (*nodes)[i].z<<" \n"; - - for(int i=0; i<nofTrian; i++) - out<<i+1<<" 2 tri "<<(*triangles)[i].v1+1<<" "<<(*triangles)[i].v2+1<<" "<<(*triangles)[i].v3+1<<" "<<endl; - - out<<dataSize; - for(int i=0;i<dataSize;i++) out<<" "<<1; - out<<endl; - - out<<"Fx, no_unit"<<endl; - out<<"Fy, no_unit"<<endl; - out<<"Fz, no_unit"<<endl; - out<<"sumFx, no_unit"<<endl; - out<<"sumFy, no_unit"<<endl; - out<<"sumFz, no_unit"<<endl; - out<<"vx, no_unit"<<endl; - out<<"vy, no_unit"<<endl; - out<<"vz, no_unit"<<endl; - out<<"S1, no_unit"<<endl; - out<<"S2, no_unit"<<endl; - out<<"S3, no_unit"<<endl; - out<<"S4, no_unit"<<endl; - out<<"S5, no_unit"<<endl; - out<<"S6, no_unit"<<endl; - out<<"Pressure, no_unit"<<endl; - - for(int n=0; n<nofNodes; n++) - { - FeTriFaceMesh3D::VertexAttributes& attribut = (*this->attributes)[n]; - - double Fx = attribut.getFX(); - double Fy = attribut.getFY(); - double Fz = attribut.getFZ(); - double sumFx = attribut.getSumFX(); - double sumFy = attribut.getSumFY(); - double sumFz = attribut.getSumFZ(); - double vx = attribut.getVelocityX(); - double vy = attribut.getVelocityY(); - double vz = attribut.getVelocityZ(); - double p = attribut.getPressure(); - UbTupleDouble6& stresses = attribut.getStresses(); - out<<n+1<<" "<<Fx<<" "<<Fy<<" "<<Fz; - out<<" "<<sumFx<<" "<<sumFy<<" "<<sumFz; - out<<" "<<vx<<" "<<vy<<" "<<vz; - out<<" "<<val<1>(stresses)<<" "<<val<2>(stresses)<<" "<<val<3>(stresses); - out<<" "<<val<4>(stresses)<<" "<<val<5>(stresses)<<" "<<val<6>(stresses); - out<<" "<<p<<endl; - } - out.close(); - } - - if(writeNormals) - { - vector<UbTupleFloat3 > lineNodes(triangles->size()*2); - vector<UbTupleInt2 > lines(triangles->size()); - for(size_t i=0; i<triangles->size(); i++) - { - TriFace& triangle = (*triangles)[i]; - lineNodes[i*2 ] = makeUbTuple( triangle.getX1Centroid(*nodes) - ,triangle.getX2Centroid(*nodes) - ,triangle.getX3Centroid(*nodes)); - lineNodes[i*2+1] = makeUbTuple( (float)(triangle.getX1Centroid(*nodes)+triangle.nx) - ,(float)(triangle.getX2Centroid(*nodes)+triangle.ny) - ,(float)(triangle.getX3Centroid(*nodes)+triangle.nz)); - - lines[i] = makeUbTuple((int)i*2,(int)i*2+1); - } - val<2>(filenames) = writer->writeLines(filename+"_normals",lineNodes,lines); - } - - - if(writeNormals) - { - vector<UbTupleFloat3 > lineNodes(nodes->size()*2); - vector<UbTupleInt2 > lines(nodes->size()); - for(size_t i=0; i<nodes->size(); i++) - { - FeTriFaceMesh3D::VertexAttributes& attribut = (*this->attributes)[i]; - lineNodes[i*2 ] = makeUbTuple((*nodes)[i].x, (*nodes)[i].y, (*nodes)[i].z ); - lineNodes[i*2+1] = makeUbTuple((*nodes)[i].x+(float)attribut.getNormalX() - ,(*nodes)[i].y+(float)attribut.getNormalY() - ,(*nodes)[i].z+(float)attribut.getNormalZ()); - - lines[i] = makeUbTuple((int)i*2,(int)i*2+1); - } - writer->writeLines(filename+"_PointNormals",lineNodes,lines); - } - - UBLOG2(logDEBUG1,std::cout,"FeTriFaceMesh3D::writeMesh - end"); - - return filenames; -} diff --git a/src/basics/geometry3d/fem/FeTriFaceMesh3D.h b/src/basics/geometry3d/fem/FeTriFaceMesh3D.h deleted file mode 100644 index 924941867..000000000 --- a/src/basics/geometry3d/fem/FeTriFaceMesh3D.h +++ /dev/null @@ -1,204 +0,0 @@ -#ifndef FETRIFACEMESH3D_H -#define FETRIFACEMESH3D_H - -#include <sstream> -#include <iostream> -#include <vector> -#include <map> - -#include "./../GbTriFaceMesh3D.h" - -#ifdef CAB_RCF -#include <3rdParty/rcf/RcfSerializationIncludes.h> -#endif //CAB_RCF - -/*=========================================================================*/ -/* FeTriFaceMesh3D */ -/* */ -/** - * This Class provides the triangular meshes. - * Note, that up to now no methods for checking consistency are included. - * in this context this class describes facettes from an 3D-object !!! -*/ -class FeTriFaceMesh3D : public GbTriFaceMesh3D -{ -public: - class VertexAttributes - { - private: - double Fx; - double Fy; - double Fz; - double sumFx; - double sumFy; - double sumFz; - double velocityX; - double velocityY; - double velocityZ; - double normalX; - double normalY; - double normalZ; - UbTupleDouble6 stresses; - double area; - double p; //pressure - public: - VertexAttributes() - { - this->init(); - } - ~VertexAttributes() {} - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - ar & Fx; ar & Fy; ar & Fz; - ar & velocityX; ar & velocityY; ar & velocityZ; - } -#endif //CAB_RCF - - void init() - { - this->Fx = 0.0; - this->Fy = 0.0; - this->Fz = 0.0; - this->sumFx = 0.0; - this->sumFy = 0.0; - this->sumFz = 0.0; - val<1>(stresses) = 0.0; - val<2>(stresses) = 0.0; - val<3>(stresses) = 0.0; - val<4>(stresses) = 0.0; - val<5>(stresses) = 0.0; - val<6>(stresses) = 0.0; - this->area = 0.0; - this->p = 0.0; - this->velocityX = 0.0; - this->velocityY = 0.0; - this->velocityZ = 0.0; - this->normalX = 0.0; - this->normalY = 0.0; - this->normalZ = 0.0; - } - double getVelocityX() { return this->velocityX; } - double getVelocityY() { return this->velocityY; } - double getVelocityZ() { return this->velocityZ; } - void setVelocityX(double x) { this->velocityX = x; } - void setVelocityY(double y) { this->velocityY = y; } - void setVelocityZ(double z) { this->velocityZ = z; } - - double getNormalX() { return this->normalX; } - double getNormalY() { return this->normalY; } - double getNormalZ() { return this->normalZ; } - void setNormalX(double x) { this->normalX = x; } - void setNormalY(double y) { this->normalY = y; } - void setNormalZ(double z) { this->normalZ = z; } - - double getFX() { return this->Fx; } - double getFY() { return this->Fy; } - double getFZ() { return this->Fz; } - void setFX(double FX) { this->Fx = FX; } - void setFY(double FY) { this->Fy = FY; } - void setFZ(double FZ) { this->Fz = FZ; } - void addFX(double FX) { this->Fx += FX; } - void addFY(double FY) { this->Fy += FY; } - void addFZ(double FZ) { this->Fz += FZ; } - - double getSumFX() { return this->sumFx; } - double getSumFY() { return this->sumFy; } - double getSumFZ() { return this->sumFz; } - void setSumFX(double FX) { this->sumFx = FX; } - void setSumFY(double FY) { this->sumFy = FY; } - void setSumFZ(double FZ) { this->sumFz = FZ; } - void addSumFX(double FX) { this->sumFx += FX; } - void addSumFY(double FY) { this->sumFy += FY; } - void addSumFZ(double FZ) { this->sumFz += FZ; } - - UbTupleDouble6& getStresses() { return this->stresses; } - - double getArea() { return this->area; } - void setArea(double area) { this->area = area; } - void addArea(double area) { this->area += area; } - - double getPressure() { return this->p; } - void setPressure(double p) { this->p = p; } - - }; -/*=========================================================================*/ -/*=========================================================================*/ -/*=========================================================================*/ - //class VertexTriFaceMap : public std::multimap<Vertex*, TriFace*> - //{ - //public: - // VertexTriFaceMap() {} - // /*=========================================================================*/ - // void setVertexTriFaceRelation(Vertex* v, TriFace* tri) - // { - // this->insert(std::pair<Vertex*,TriFace*>(v,tri)); - // } - // /*=========================================================================*/ - // int getNumberOfTriFaces(Vertex* v) - // { - // return((int)this->count(v)); - // } - // /*=========================================================================*/ - // std::vector<TriFace*> getTriFacesForVertex(Vertex* v) - // { - // std::vector<TriFace*> trivector; - // unsigned number = (unsigned)this->count(v); - // std::multimap<Vertex*,TriFace*>::iterator mapIterator = this->find(v); - // for(unsigned u =0; u<number; u++) - // { - // trivector.push_back(mapIterator->second); - // mapIterator ++; - // } - // return trivector; - // } - // //void deleteNeighbors(QtInteractor* interactor); - // ///*=========================================================================*/ - //}; -/*=========================================================================*/ -/*=========================================================================*/ -/*=========================================================================*/ -public: - //#ifndef SWIG - //VertexTriFaceMap vertexTriFaceMap; - //#endif - - FeTriFaceMesh3D(); - FeTriFaceMesh3D(std::string name, std::vector<Vertex>* nodes, std::vector<TriFace>* triangles); - - std::vector<VertexAttributes>* getAttributes() { return this->attributes; } - void resizeAttributes(); - //void createVertexTriFaceMap(); - - UbTuple<std::string,std::string> writeMesh(std::string filename, WbWriter* writer, bool writeNormals=false, std::vector< std::string >* datanames=NULL, std::vector< std::vector < double > >* nodedata=NULL); - - static FeTriFaceMesh3D* createMeshByTriangles(std::string name, std::vector<GbTriangle3D*>* triangles); - - virtual ObObjectCreator* getCreator(); - -#ifdef CAB_RCF - template<class Archive> - void SF_SERIALIZE(Archive & ar) - { - SF_SERIALIZE_PARENT<GbTriFaceMesh3D>(ar, *this); - ar & attributes; - //if( ArchiveTools::isReading(ar) ) this->createVertexTriFaceMap(); - } -#endif //CAB_RCF - - -protected: - std::vector<VertexAttributes>* attributes; - -}; - -#if defined(RCF_USE_SF_SERIALIZATION) && !defined(SWIG) - UB_AUTO_RUN_NAMED( SF::registerType<FeTriFaceMesh3D >("FeTriFaceMesh3D ") , SF_FeTriFaceMesh3D ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbTriFaceMesh3D, FeTriFaceMesh3D >() ), SF_FeTriFaceMesh3D_BD1 ); - UB_AUTO_RUN_NAMED( ( SF::registerBaseAndDerived< GbObject3D, FeTriFaceMesh3D >() ), SF_FeTriFaceMesh3D_BD2 ); -#endif //RCF_USE_SF_SERIALIZATION - - -#endif //FETRIFACEMESH3D_H diff --git a/src/basics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.cpp b/src/basics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.cpp deleted file mode 100644 index 58a6171c1..000000000 --- a/src/basics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.cpp +++ /dev/null @@ -1,417 +0,0 @@ -#include <numerics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h> -#include <basics/utilities/UbLogger.h> -#include <basics/utilities/UbTiming.h> - -using namespace std; - -FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromFile(string filename, string meshName, bool removeRedundantNodes) -{ - if(meshName.empty()) - { - size_t pos=filename.rfind("/"); - if(pos!=string::npos) meshName = filename.substr(pos+1); - else meshName = filename; - } - - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - string ext=stlfile.getFileExtension(); - - //in "kleinbuchstaben" umwandeln - transform(ext.begin(), ext.end(), ext.begin(), (int(*)(int))tolower); //(int(*)(int)) ist irgendso ein fieser cast, weil tolower ne alte c-methode ist - - if ( !ext.compare("ply") ) return FeTriFaceMesh3DCreator::readMeshFromPLYFile(filename, meshName, removeRedundantNodes); - else if( !ext.compare("stl") ) return FeTriFaceMesh3DCreator::readMeshFromSTLFile(filename, meshName, removeRedundantNodes); - else if( !ext.compare("inp") ) return FeTriFaceMesh3DCreator::readMeshFromAVSFile(filename, meshName, removeRedundantNodes); - //else if( !ext.compare("gts") ) return FeTriFaceMesh3DCreator::readMeshFromGTSFile(filename, meshName); - //else if( !ext.compare("raw") ) return FeTriFaceMesh3DCreator::readMeshFromRAWFile(filename, meshName); - else throw UbException(UB_EXARGS,"fileformat "+ext); - - return NULL; -} -/*======================================================================*/ -FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromPLYFile(string filename, string meshName, bool removeRedundantNodes) -{ - UbFileInputASCII plyfile(filename); - if(!plyfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return FeTriFaceMesh3DCreator::readMeshFromPLYFile(&plyfile,meshName); -} -/*======================================================================*/ -FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromPLYFile(UbFileInput* in, string meshName, bool removeRedundantNodes) -{ - //cout<<"GbTriangularMesh3DFile.readMeshFromPLYFile !!! Dieses Format hat leider redundante Knoten ..."<<endl; - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - - float x, y, z; - string dummy; - - int numVertices = in->readIntegerAfterString("element vertex"); - int numFaces = in->readIntegerAfterString("element face"); - in->setPosAfterLineWithString("end_header"); - - UBLOG(logDEBUG1,"Number of vertices "<<numVertices); - UBLOG(logDEBUG1,"Number of faces "<<numFaces); - - nodes->resize(numVertices); - triangles->reserve(numFaces); - - int onePercent = (int)UbMath::max(1,UbMath::integerRounding(numVertices*0.01)); - for (int i=0; i<numVertices; i++) - { - if( i%onePercent==0 ) - cout<<" - read vertices (#"<<numVertices<<") "<<UbMath::integerRounding(i/(double)numVertices*100.0)<<"% "<<"\r"<<flush; - x = in->readFloat(); - y = in->readFloat(); - z = in->readFloat(); - in->readLine(); - (*nodes)[i] = GbTriFaceMesh3D::Vertex(x,y,z); - } - UBLOG(logDEBUG1," - read vertices (#"<<numVertices<<") done"); - - int p,j,k,l,n; - onePercent = (int)UbMath::max(1,UbMath::integerRounding(numFaces*0.01)); - for(int i=0; i<numFaces; i++) - { - if( i%onePercent==0 ) cout<<" - read faces (#"<<numFaces<<") "<<UbMath::integerRounding(i/(double)numFaces*100.0)<<"% "<<"\r"<<flush; - - p = in->readInteger(); - if(p==3) //Dreieck, alles andere wird stumpf ingnoriert - { - j = in->readInteger(); - k = in->readInteger(); - l = in->readInteger(); - - if( !UbMath::inClosedInterval(j,0,numVertices-1) - || !UbMath::inClosedInterval(k,0,numVertices-1) - || !UbMath::inClosedInterval(l,0,numVertices-1) ) - { - throw UbException(UB_EXARGS,"dreiecksindex ist groesser als max Knotenindex oder kleiner 0"); - } - triangles->push_back(GbTriFaceMesh3D::TriFace(j,k,l)); - } - else if(p==4) //Viereck --> wird zu zwei Dreiecken! - { - j = in->readInteger(); - k = in->readInteger(); - l = in->readInteger(); - n = in->readInteger(); - numFaces++; - i++; - - if( !UbMath::inClosedInterval(j,0,numVertices-1) - || !UbMath::inClosedInterval(k,0,numVertices-1) - || !UbMath::inClosedInterval(l,0,numVertices-1) - || !UbMath::inClosedInterval(n,0,numVertices-1) - ) - { - throw UbException(UB_EXARGS,"vierecksindex ist groesser als max Knotenindex oder kleiner 0"); - } - triangles->push_back(GbTriFaceMesh3D::TriFace(j,k,l)); - triangles->push_back(GbTriFaceMesh3D::TriFace(l,n,j)); - } - - in->readLine(); - - } - UBLOG(logDEBUG1," - read faces (#"<<(int)triangles->size()<<", #nonTriangles="<<(int)triangles->size()-numFaces<<") done"); - - FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles); - - if(removeRedundantNodes) mesh->deleteRedundantNodes(); - - mesh->resizeAttributes(); - //mesh->createVertexTriFaceMap(); - mesh->calculateValues(); - - - return mesh; -} -/*======================================================================*/ -FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromSTLFile(string filename, string meshName, bool removeRedundantNodes) -{ - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return FeTriFaceMesh3DCreator::readMeshFromSTLFile(&stlfile,meshName,removeRedundantNodes); -} -/*======================================================================*/ -FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromSTLFile(UbFileInput *in, string meshName, bool removeRedundantNodes) -{ - UBLOG(logINFO,"FeTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ..."); - - vector<FeTriFaceMesh3D::Vertex> *nodes = new vector<FeTriFaceMesh3D::Vertex>; - vector<FeTriFaceMesh3D::TriFace> *triangles = new vector<FeTriFaceMesh3D::TriFace>; - string dummy; - - double x, y, z; - int nr=0; - - in->readLine(); - while(dummy!="endsolid") - { - in->readLine(); - in->readLine(); - dummy = in->readString(); - if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format"); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - in->readLine(); - in->readString(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - in->readLine(); - in->readString(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - triangles->push_back(FeTriFaceMesh3D::TriFace(nr,nr+1,nr+2)); - in->readLine(); - in->readLine(); - in->readLine(); - dummy = in->readString(); - nr+=3; - } - - - FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles); - - if(removeRedundantNodes) mesh->deleteRedundantNodes(); - - mesh->resizeAttributes(); -// mesh->createVertexTriFaceMap(); - mesh->calculateValues(); - - - return mesh; -} -// /*======================================================================*/ -// FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromMeshFile(string filename, string meshName, bool removeRedundantNodes) -// { -// public static void read(String file, ArrayList<Node3d> nodeList, ArrayList<TrianglePatch> patches) throws FileReaderException { -// -// UBLOG(logINFO,"FeTriFaceMesh3DCreator::readMeshFromSTLFile !!! Dieses Format hat leider redundante Knoten ..."); -// -// vector<FeTriFaceMesh3D::Vertex> *nodes = new vector<FeTriFaceMesh3D::Vertex>; -// vector<FeTriFaceMesh3D::TriFace> *triangles = new vector<FeTriFaceMesh3D::TriFace>; -// string dummy; -// -// double x, y, z; -// int nr=0; -// -// in->readLine(); -// while(dummy!="endsolid") -// { -// in->readLine(); -// in->readLine(); -// dummy = in->readString(); -// if(dummy!="vertex") throw UbException(UB_EXARGS,"no vertex format"); -// x=in->readDouble(); -// y=in->readDouble(); -// z=in->readDouble(); -// nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); -// in->readLine(); -// in->readString(); -// x=in->readDouble(); -// y=in->readDouble(); -// z=in->readDouble(); -// nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); -// in->readLine(); -// in->readString(); -// x=in->readDouble(); -// y=in->readDouble(); -// z=in->readDouble(); -// nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); -// triangles->push_back(FeTriFaceMesh3D::TriFace(nr,nr+1,nr+2)); -// in->readLine(); -// in->readLine(); -// in->readLine(); -// dummy = in->readString(); -// nr+=3; -// } -// -// -// FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles); -// -// if(removeRedundantNodes) mesh->deleteRedundantNodes(); -// -// return mesh; -// -// -// try { -// -// FileInput input = new FileInput(file); -// -// int line = 0; -// while(true) -// { -// if(line>1000) break; -// if(input.readLine().contains("Vertices")) -// break; -// line++; -// } -// -// int num_of_points = input.readInt(); -// -// for (int i = 0; i < num_of_points; i++) { -// float x = (float) input.readDouble(); -// float y = (float) input.readDouble(); -// float z = (float) input.readDouble(); -// int nr = input.readInt(); -// nodeList.add(new Node3d(x, y, z)); -// } -// -// input.skipLine(); -// input.skipLine(); -// int num_of_triangles = input.readInt(); -// -// for (int i = 0; i < num_of_triangles; i++) { -// -// int a = input.readInt(); -// int b = input.readInt(); -// int c = input.readInt(); -// int nr = input.readInt(); -// -// Node3d P1 = nodeList.get(a - 1); -// Node3d P2 = nodeList.get(b - 1); -// Node3d P3 = nodeList.get(c - 1); -// -// patches.add(new TrianglePatch(P1, P2, P3)); -// } -// -// // END reading mesh file -// } -// -// -- -// -// Dipl.-Ing. Sebastian Bindick -// -// Institute for Computational Modeling in Civil Engineering (iRMB) Technische Universität Braunschweig Pockelsstr. 3 (9th Floor) D-38106, Braunschweig, Germany -// -// phone +49 531/391-7598 -// fax +49 531/391-7599 -// email bindick@irmb.tu-bs.de -// web www.irmb.tu-bs.de -// -// -/*======================================================================*/ -FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromAVSFile(string filename, string meshName, bool removeRedundantNodes) -{ - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return FeTriFaceMesh3DCreator::readMeshFromAVSFile(&stlfile,meshName,removeRedundantNodes); -} -/*======================================================================*/ -FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromAVSFile(UbFileInput *in, string meshName, bool removeRedundantNodes) -{ - UBLOG(logINFO,"FeTriFaceMesh3DCreator.readMeshFromAVSFile !!! Dieses Format hat leider redundante Knoten ..."); - - vector<FeTriFaceMesh3D::Vertex> *nodes = new vector<FeTriFaceMesh3D::Vertex>; - vector<FeTriFaceMesh3D::TriFace> *triangles = new vector<FeTriFaceMesh3D::TriFace>; - string dummy; - - in->readLine(); - int numberNodes = in->readInteger(); - int numberTris = in->readInteger(); - in->readLine(); - - double x,y,z; - for(int u=0;u<numberNodes;u++) - { - in->readInteger(); - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - in->readLine(); - nodes->push_back(FeTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - } - int id1,id2,id3; - for(int u=0;u<numberTris;u++) - { - in->readInteger(); - in->readInteger(); - in->readString(); - id1 = in->readInteger(); - id2 = in->readInteger(); - id3 = in->readInteger(); - triangles->push_back(FeTriFaceMesh3D::TriFace(id1-1,id2-1,id3-1)); - } - - FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles); - - if(removeRedundantNodes) mesh->deleteRedundantNodes(); - - mesh->resizeAttributes(); -// mesh->createVertexTriFaceMap(); - mesh->calculateValues(); - - - return mesh; -} -/*======================================================================*/ -FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(string filename, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UbFileInputASCII stlfile(filename); - if(!stlfile) throw UbException(UB_EXARGS,"cannot open file "+filename); - return FeTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(&stlfile,meshName,splitAlg,removeRedundantNodes); -} -/*======================================================================*/ -FeTriFaceMesh3D* FeTriFaceMesh3DCreator::readMeshFromVTKASCIIFile(UbFileInput *in, string meshName, GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg, bool removeRedundantNodes) -{ - UBLOG(logDEBUG1,"GbTriFaceMesh3DCreator.readMeshFromVTKASCIIFile !!! Dieses Format hat leider redundante Knoten ..."); - - vector<GbTriFaceMesh3D::Vertex> *nodes = new vector<GbTriFaceMesh3D::Vertex>; - vector<GbTriFaceMesh3D::TriFace> *triangles = new vector<GbTriFaceMesh3D::TriFace>; - string dummy; - - in->readLine(); - in->readLine(); - in->readLine(); - in->readLine(); - - in->readString(); - int numberNodes = in->readInteger(); - in->readLine(); - - double x,y,z; - for(int u=0;u<numberNodes;u++) - { - x=in->readDouble(); - y=in->readDouble(); - z=in->readDouble(); - nodes->push_back(GbTriFaceMesh3D::Vertex((float)x,(float)y,(float)z)); - } - in->readLine(); - in->readString(); - int numberTris = in->readInteger(); - in->readLine(); - UBLOG(logDEBUG1,"numberTris:"<<numberTris); - - int id1,id2,id3; - for(int u=0;u<numberTris;u++) - { - in->readInteger(); - id1 = in->readInteger(); - id2 = in->readInteger(); - id3 = in->readInteger(); - triangles->push_back(GbTriFaceMesh3D::TriFace(id1,id2,id3)); - //cout<<u<<" - id1,id2,id3:"<<id1<<","<<id2<<","<<id3<<endl; - } - UBLOG(logDEBUG1,"Tris gelesen"); - - FeTriFaceMesh3D* mesh = new FeTriFaceMesh3D(meshName, nodes, triangles); - - if(removeRedundantNodes) mesh->deleteRedundantNodes(); - - mesh->resizeAttributes(); -// mesh->createVertexTriFaceMap(); - mesh->calculateValues(); - - UBLOG(logDEBUG1,"mesh erzeugt (with remove redundant nodes = "<< boolalpha <<removeRedundantNodes<<")"); - - return mesh; -} diff --git a/src/basics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h b/src/basics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h deleted file mode 100644 index a7e25ea19..000000000 --- a/src/basics/geometry3d/fem/creator/FeTriFaceMesh3DCreator.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef FETRIFACEMESH3DCREATOR_H -#define FETRIFACEMESH3DCREATOR_H - -#include <numerics/geometry3d/creator/GbObject3DCreator.h> -#include <numerics/geometry3d/fem/FeTriFaceMesh3D.h> -#include <basics/utilities/UbFileInputASCII.h> - -#ifdef CAB_QT -#include <qfiledialog.h> -#endif - -#ifdef CAB_VTK -//#include <numerics/geometry3d/presentation/vtkGbTriangularMesh3D.h> -#endif - -class FeTriFaceMesh3DCreator : public GbObject3DCreator -{ -public: - static FeTriFaceMesh3DCreator* getInstance() - { - static FeTriFaceMesh3DCreator instance; - return &instance; - } - static FeTriFaceMesh3D* readMeshFromFile(std::string filename, std::string meshName, bool removeRedundantNodes=true); - - static FeTriFaceMesh3D* readMeshFromPLYFile(std::string filename, std::string meshName, bool removeRedundantNodes=true); - static FeTriFaceMesh3D* readMeshFromPLYFile(UbFileInput* in, std::string meshName, bool removeRedundantNodes=true); - - static FeTriFaceMesh3D* readMeshFromSTLFile(std::string filename, std::string meshName, bool removeRedundantNodes=true); - static FeTriFaceMesh3D* readMeshFromSTLFile(UbFileInput* in, std::string meshName, bool removeRedundantNodes=true); - - static FeTriFaceMesh3D* readMeshFromAVSFile(std::string filename, std::string meshName, bool removeRedundantNodes=true); - static FeTriFaceMesh3D* readMeshFromAVSFile(UbFileInput* in, std::string meshName, bool removeRedundantNodes=true); - - static FeTriFaceMesh3D* readMeshFromVTKASCIIFile(std::string filename, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - static FeTriFaceMesh3D* readMeshFromVTKASCIIFile(UbFileInput* in, std::string meshName="", GbTriFaceMesh3D::KDTREE_SPLITAGORITHM splitAlg = GbTriFaceMesh3D::KDTREE_SAHPLIT, bool removeRedundantNodes=true); - - - FeTriFaceMesh3D* createGbObject3D() { return new FeTriFaceMesh3D(); } - - std::string getGbObject3DTypeID(){ return "FeTriFaceMesh3D"; }; - std::string toString() { return "FeTriFaceMesh3DCreator"; } - -#ifdef CAB_QT - - - FeTriFaceMesh3D* createGbObject3DwithQt() - { - //QString s = QFileDialog::getOpenFileName(NULL,NULL,NULL,"open file dialog","Choose a STL file" ); - QString s = QFileDialog::getOpenFileName(NULL, "Choose a STL file", "/home", "*.stl"); - //QFileDialog* fd = new QFileDialog( NULL ); - //fd->setIconText(QString("Hallo")); - //fd->show(); - //TODO: Open File Dialog einbauen. - UbFileInputASCII in( s.toAscii().data() ); - stringstream stream; - stream <<"TriangularMesh3D ";//<<_objCount++; - FeTriFaceMesh3D *mesh = NULL;//FeTriFaceMesh3DCreator::readMeshFromSTLFile(&in, stream.str() ); - return mesh; - } - //QDialog* getSpecificInstrument() { return 0;} - void editGbObject3DwithQt(GbObject3D* gbObj) - { - } -#endif -#ifdef CAB_VTK -public: - Presentator* createObjectPresentator(ObObject *object) { return new vtkGbTriangularMesh3D((GbTriangularMesh3D*)object); } -#endif - - -private: - FeTriFaceMesh3DCreator( const FeTriFaceMesh3DCreator& ); //no copy allowed - const FeTriFaceMesh3DCreator& operator=( const FeTriFaceMesh3DCreator& ); //no copy allowed - FeTriFaceMesh3DCreator() : GbObject3DCreator() {} -}; - -#ifndef SWIG -UB_AUTO_RUN_NAMED( GbObject3DFactory::getInstance()->addObObjectCreator(FeTriFaceMesh3DCreator::getInstance()), CAB_FeTriFaceMesh3DCreator); -#endif - -#endif diff --git a/src/basics/geometry3d/package.include b/src/basics/geometry3d/package.include deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/basics/geometry3d/presentation/QGbCuboid3DInstrument.cpp b/src/basics/geometry3d/presentation/QGbCuboid3DInstrument.cpp deleted file mode 100644 index 0e444b4b7..000000000 --- a/src/basics/geometry3d/presentation/QGbCuboid3DInstrument.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "./QGbCuboid3DInstrument.h" - -/**** Qt ****/ -#include <qlineedit.h> -#include <qstring.h> -#include <qcheckbox.h> - -/**** CAB ****/ -#include "./../GbCuboid3D.h" -#include "./../GbPoint3D.h" - - -QGbCuboid3DInstrument::QGbCuboid3DInstrument( QWidget* parent, Qt::WFlags flags ):QDialog(parent, flags) -{ - ui.setupUi(this); - - this->gbCuboid = NULL; - -} - -QGbCuboid3DInstrument::~QGbCuboid3DInstrument() -{ -} - -void QGbCuboid3DInstrument::setGbCuboid3D(GbCuboid3D* cuboid) -{ - this->gbCuboid = cuboid; - ui.lineEditPoint1X->setText( QString("%1").arg(gbCuboid->getPoint1()->getX1Coordinate() ) ); - ui.lineEditPoint1Y->setText( QString("%1").arg(gbCuboid->getPoint1()->getX2Coordinate() ) ); - ui.lineEditPoint1Z->setText( QString("%1").arg(gbCuboid->getPoint1()->getX3Coordinate() ) ); - ui.lineEditPoint2X->setText( QString("%1").arg(gbCuboid->getPoint2()->getX1Coordinate() ) ); - ui.lineEditPoint2Y->setText( QString("%1").arg(gbCuboid->getPoint2()->getX2Coordinate() ) ); - ui.lineEditPoint2Z->setText( QString("%1").arg(gbCuboid->getPoint2()->getX3Coordinate() ) ); - //this->checkBoxActive->setChecked( cuboid->isActive() ); - ui.checkBoxActive->setChecked( true ); -} - -GbCuboid3D* QGbCuboid3DInstrument::getGbCuboid3D() -{ - return this->gbCuboid; -} - -//void QGbCuboid3DInstrument::SetGbObject3D(GbObject3D* gbObj) -//{ -// this->SetGbSphere(dynamic_cast<GbSphere3D*>(gbObj)); -//} - -void QGbCuboid3DInstrument::on_pBtnOK_clicked() -{ - this->gbCuboid->getPoint1()->setX1(ui.lineEditPoint1X->text().toDouble() ); - this->gbCuboid->getPoint1()->setX2(ui.lineEditPoint1Y->text().toDouble() ); - this->gbCuboid->getPoint1()->setX3(ui.lineEditPoint1Z->text().toDouble() ); - this->gbCuboid->getPoint2()->setX1(ui.lineEditPoint2X->text().toDouble() ); - this->gbCuboid->getPoint2()->setX2(ui.lineEditPoint2Y->text().toDouble() ); - this->gbCuboid->getPoint2()->setX3(ui.lineEditPoint2Z->text().toDouble() ); - //this->gbCuboid->setActive( this->checkBoxActive->isChecked() ); - - this->gbCuboid->notifyObserversObjectChanged(); - this->accept(); -} - - -void QGbCuboid3DInstrument::on_pBtnCancel_clicked() -{ - this->reject(); -} - diff --git a/src/basics/geometry3d/presentation/QGbCuboid3DInstrument.h b/src/basics/geometry3d/presentation/QGbCuboid3DInstrument.h deleted file mode 100644 index 312fb0efa..000000000 --- a/src/basics/geometry3d/presentation/QGbCuboid3DInstrument.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef QGBCUBOID3DINSTRUMENT_H -#define QGBCUBOID3DINSTRUMENT_H - - -#include "./QGbCuboid3DInstrumentUI.h" - -class GbCuboid3D; -class GbObject3D; - -class QGbCuboid3DInstrument : public QDialog -{ - Q_OBJECT - -public: - QGbCuboid3DInstrument( QWidget* parent = 0, Qt::WFlags fl = 0 ); - ~QGbCuboid3DInstrument(); - void setGbCuboid3D(GbCuboid3D* cuboid); - GbCuboid3D* getGbCuboid3D(); - -protected: - GbCuboid3D* gbCuboid; - -private: - Ui::QGbCuboid3DInstrument ui; - -private slots: - void on_pBtnOK_clicked(); - void on_pBtnCancel_clicked(); -}; - -#endif diff --git a/src/basics/geometry3d/presentation/QGbCuboid3DInstrument.ui b/src/basics/geometry3d/presentation/QGbCuboid3DInstrument.ui deleted file mode 100644 index e584634af..000000000 --- a/src/basics/geometry3d/presentation/QGbCuboid3DInstrument.ui +++ /dev/null @@ -1,347 +0,0 @@ -<ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> - <class>QGbCuboid3DInstrument</class> - <widget class="QDialog" name="QGbCuboid3DInstrument" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>252</width> - <height>239</height> - </rect> - </property> - <property name="windowTitle" > - <string>GbCuboid3DInstrument</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>10</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="0" > - <widget class="QLabel" name="textLabel2" > - <property name="font" > - <font> - <family>Arial</family> - <pointsize>20</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Cuboid</string> - </property> - </widget> - </item> - <item row="1" column="0" colspan="4" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QVBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabelPoint1" > - <property name="font" > - <font> - <family>Arial</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Point 1:</string> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1" > - <property name="text" > - <string>X:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditPoint1X" > - <property name="text" > - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_2" > - <property name="text" > - <string>Y:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditPoint1Y" > - <property name="text" > - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_3" > - <property name="text" > - <string>Z:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditPoint1Z" > - <property name="text" > - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - <item> - <layout class="QVBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabelPoint2" > - <property name="font" > - <font> - <family>Arial</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Point 2:</string> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_4" > - <property name="text" > - <string>X:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditPoint2X" > - <property name="text" > - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_2_2" > - <property name="text" > - <string>Y:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditPoint2Y" > - <property name="text" > - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_3_2" > - <property name="text" > - <string>Z:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditPoint2Z" > - <property name="text" > - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </item> - <item row="0" column="2" colspan="2" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>90</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="4" column="0" > - <widget class="QPushButton" name="pBtnOK" > - <property name="text" > - <string>OK</string> - </property> - </widget> - </item> - <item row="4" column="3" > - <widget class="QPushButton" name="pBtnCancel" > - <property name="text" > - <string>Cancel</string> - </property> - </widget> - </item> - <item row="3" column="0" colspan="2" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>13</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="3" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="0" colspan="3" > - <widget class="QCheckBox" name="checkBoxActive" > - <property name="text" > - <string>Active</string> - </property> - <property name="checked" > - <bool>true</bool> - </property> - </widget> - </item> - <item row="4" column="1" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <layoutdefault spacing="6" margin="11" /> - <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> - <resources/> - <connections/> -</ui> diff --git a/src/basics/geometry3d/presentation/QGbCylinder3DInstrument.cpp b/src/basics/geometry3d/presentation/QGbCylinder3DInstrument.cpp deleted file mode 100644 index 34ff20fe1..000000000 --- a/src/basics/geometry3d/presentation/QGbCylinder3DInstrument.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include "./QGbCylinder3DInstrument.h" - -/**** Qt ****/ -#include <QtCore/QString> -#include <QtGui/QLineEdit> -#include <QtGui/QCheckBox> -#include <QtGui/QTabWidget> - -/**** CAB ****/ -#include "./../GbCylinder3D.h" -#include "./../GbPoint3D.h" - -QGbCylinder3DInstrument::QGbCylinder3DInstrument( QWidget* parent, Qt::WFlags flags ) -{ - ui.setupUi(this); - - /*JZ TODO daher Buttons noch ausgeschaltet (29.11.05)*/ - ui.rBtnXAxis->setEnabled(false); - ui.rBtnYAxis->setEnabled(false); - ui.rBtnZAxis->setEnabled(false); - - this->gbCylinder = NULL; -} - -QGbCylinder3DInstrument::~QGbCylinder3DInstrument(void) -{ -} - -void QGbCylinder3DInstrument::setGbCylinder3D(GbCylinder3D* cylinder) -{ - this->gbCylinder = cylinder; - ui.lineEdit1_X_1->setText( QString("%1").arg(gbCylinder->getPoint1()->x1 ) ); - ui.lineEdit1_Y_1->setText( QString("%1").arg(gbCylinder->getPoint1()->x2 ) ); - ui.lineEdit1_Z_1->setText( QString("%1").arg(gbCylinder->getPoint1()->x3 ) ); - ui.lineEdit1_X_2->setText( QString("%1").arg(gbCylinder->getPoint2()->x1 ) ); - ui.lineEdit1_Y_2->setText( QString("%1").arg(gbCylinder->getPoint2()->x2 ) ); - ui.lineEdit1_Z_2->setText( QString("%1").arg(gbCylinder->getPoint2()->x3 ) ); - ui.dSpBoxRadius1->setValue(gbCylinder->getRadius()); - ui.checkBoxActive1->setChecked( true ); - ui.lineEdit2_X->setText( QString("%1").arg(gbCylinder->getPoint1()->x1 ) ); - ui.lineEdit2_Y->setText( QString("%1").arg(gbCylinder->getPoint1()->x2 ) ); - ui.lineEdit2_Z->setText( QString("%1").arg(gbCylinder->getPoint1()->x3 ) ); - ui.dSpBoxRadius2->setValue(gbCylinder->getRadius()); - ui.checkBoxActive2->setChecked( true ); - ui.lineEditLength->setText( QString("%1").arg(gbCylinder->getHeight()) ); - //if (!this->gbCylinder->isParallelToX1Axis()) - //{ - // if (!this->gbCylinder->isParallelToX2Axis()) - // { - // ui.rBtnZAxis->setChecked(true); - // } - // else ui.rBtnYAxis->setChecked(true); - //} - //else ui.rBtnXAxis->setChecked(true); -} - -GbCylinder3D* QGbCylinder3DInstrument::getGbCylinder3D(void) -{ - return this->gbCylinder; -} - -//void QGbSphere3DInstrument::SetGbObject3D(GbObject3D* gbObj) -//{ -// this->SetGbSphere(dynamic_cast<GbSphere3D*>(gbObj)); -//} - -void QGbCylinder3DInstrument::on_pBtnOK_clicked() -{ - if(ui.tabWidget->currentIndex()==0) - { - this->gbCylinder->setPoint1( ui.lineEdit1_X_1->text().toDouble(), - ui.lineEdit1_Y_1->text().toDouble(), - ui.lineEdit1_Z_1->text().toDouble()); - - this->gbCylinder->setPoint2( ui.lineEdit1_X_2->text().toDouble(), - ui.lineEdit1_Y_2->text().toDouble(), - ui.lineEdit1_Z_2->text().toDouble()); - this->gbCylinder->setRadius(ui.dSpBoxRadius1->value()); - - this->gbCylinder->notifyObserversObjectChanged(); - } - if(ui.tabWidget->currentIndex()==1) - { - this->gbCylinder->setPoint1( ui.lineEdit2_X->text().toDouble(), - ui.lineEdit2_Y->text().toDouble(), - ui.lineEdit2_Z->text().toDouble()); - this->gbCylinder->setPoint2( ui.lineEdit2_X->text().toDouble(), - ui.lineEdit2_Y->text().toDouble()+ui.lineEditLength->text().toDouble(), - ui.lineEdit2_Z->text().toDouble()); - this->gbCylinder->setRadius(ui.dSpBoxRadius2->value()); - - this->gbCylinder->notifyObserversObjectChanged(); - } - - this->accept(); -} - - -void QGbCylinder3DInstrument::on_pBtnCancel_clicked() -{ - this->reject(); -} diff --git a/src/basics/geometry3d/presentation/QGbCylinder3DInstrument.h b/src/basics/geometry3d/presentation/QGbCylinder3DInstrument.h deleted file mode 100644 index 3ab65d380..000000000 --- a/src/basics/geometry3d/presentation/QGbCylinder3DInstrument.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef QGBCYLINDER3DINSTRUMENT_H -#define QGBCYLINDER3DINSTRUMENT_H - -#include <QtGui/QDialog> -#include <QtGui/QWidget> - -#include "./QGbCylinder3DInstrumentUI.h" -#include "./QGbObject3DInstrument.h" - -class GbCylinder3D; -class GbObject3D; - -class QGbCylinder3DInstrument : public QDialog -{ - - Q_OBJECT - -public: - QGbCylinder3DInstrument( QWidget* parent = 0, Qt::WFlags flags = 0 ); - ~QGbCylinder3DInstrument(); - void setGbCylinder3D(GbCylinder3D* cylinder); - GbCylinder3D* getGbCylinder3D(); - -protected: - GbCylinder3D* gbCylinder; - -private: - Ui::QGbCylinder3DInstrument ui; - -private slots: - void on_pBtnOK_clicked(); - void on_pBtnCancel_clicked(); -}; - -#endif \ No newline at end of file diff --git a/src/basics/geometry3d/presentation/QGbCylinder3DInstrument.ui b/src/basics/geometry3d/presentation/QGbCylinder3DInstrument.ui deleted file mode 100644 index 18f74c576..000000000 --- a/src/basics/geometry3d/presentation/QGbCylinder3DInstrument.ui +++ /dev/null @@ -1,682 +0,0 @@ -<ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> - <class>QGbCylinder3DInstrument</class> - <widget class="QDialog" name="QGbCylinder3DInstrument" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>457</width> - <height>347</height> - </rect> - </property> - <property name="windowTitle" > - <string>GbCylinder3DInstrument</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="1" column="0" > - <widget class="QTabWidget" name="tabWidget" > - <widget class="QWidget" name="tabPoints" > - <attribute name="title" > - <string>Define by Points</string> - </attribute> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="0" > - <widget class="QGroupBox" name="groupBox" > - <property name="title" > - <string>Base Centerpoint</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="2" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_3_2" > - <property name="text" > - <string>Z:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit1_Z_1" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_2_3" > - <property name="text" > - <string>Y:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit1_Y_1" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="0" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_5" > - <property name="text" > - <string>X:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit1_X_1" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item row="0" column="1" > - <widget class="QGroupBox" name="groupBox_2" > - <property name="title" > - <string>Top Centerpoint</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="2" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_3_3_2_2" > - <property name="text" > - <string>Z:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit1_Z_2" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_2_2_2_2" > - <property name="text" > - <string>Y:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit1_Y_2" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="0" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_4_2_2" > - <property name="text" > - <string>X:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit1_X_2" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item row="1" column="0" colspan="2" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QCheckBox" name="checkBoxActive1" > - <property name="text" > - <string>Active</string> - </property> - <property name="checked" > - <bool>true</bool> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>51</width> - <height>60</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QGroupBox" name="groupBox_3_2" > - <property name="minimumSize" > - <size> - <width>16</width> - <height>60</height> - </size> - </property> - <property name="title" > - <string>Radius</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="1" > - <widget class="QDoubleSpinBox" name="dSpBoxRadius1" > - <property name="decimals" > - <number>1</number> - </property> - <property name="maximum" > - <double>100</double> - </property> - <property name="value" > - <double>3</double> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <widget class="QWidget" name="tabLength" > - <attribute name="title" > - <string>Define by Length</string> - </attribute> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="1" > - <widget class="QGroupBox" name="groupBox_5" > - <property name="title" > - <string>Parameters</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="2" column="0" colspan="2" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QRadioButton" name="rBtnXAxis" > - <property name="text" > - <string>X - Axis</string> - </property> - </widget> - </item> - <item> - <widget class="QRadioButton" name="rBtnYAxis" > - <property name="text" > - <string>Y - Axis</string> - </property> - </widget> - </item> - <item> - <widget class="QRadioButton" name="rBtnZAxis" > - <property name="text" > - <string>Z - Axis</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="0" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_5_2_2" > - <property name="text" > - <string>Length:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditLength" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0" > - <widget class="QLabel" name="label" > - <property name="text" > - <string>Parallel to</string> - </property> - </widget> - </item> - <item row="0" column="1" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - <widget class="QWidget" name="widget_2" > - <property name="geometry" > - <rect> - <x>11</x> - <y>71</y> - <width>194</width> - <height>18</height> - </rect> - </property> - </widget> - </widget> - </item> - <item row="0" column="0" > - <widget class="QGroupBox" name="groupBox_4" > - <property name="title" > - <string>Base Centerpoint</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="2" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_3_2_2" > - <property name="text" > - <string>Z:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit2_Z" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_2_3_2" > - <property name="text" > - <string>Y:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit2_Y" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="0" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_5_2" > - <property name="text" > - <string>X:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEdit2_X" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item row="1" column="0" colspan="2" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QCheckBox" name="checkBoxActive2" > - <property name="text" > - <string>Active</string> - </property> - <property name="checked" > - <bool>true</bool> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>51</width> - <height>60</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QGroupBox" name="groupBox_3_2_2" > - <property name="minimumSize" > - <size> - <width>16</width> - <height>60</height> - </size> - </property> - <property name="title" > - <string>Radius</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>8</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="1" > - <widget class="QDoubleSpinBox" name="dSpBoxRadius2" > - <property name="decimals" > - <number>1</number> - </property> - <property name="maximum" > - <double>100</double> - </property> - <property name="value" > - <double>3</double> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - </layout> - <widget class="QWidget" name="widget" > - <property name="geometry" > - <rect> - <x>9</x> - <y>9</y> - <width>415</width> - <height>101</height> - </rect> - </property> - </widget> - </widget> - </widget> - </item> - <item row="0" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2" > - <property name="font" > - <font> - <family>Arial</family> - <pointsize>20</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Cylinder</string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="3" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QPushButton" name="pBtnOK" > - <property name="text" > - <string>OK</string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="pBtnCancel" > - <property name="text" > - <string>Cancel</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="2" column="0" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <layoutdefault spacing="6" margin="11" /> - <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> - <tabstops> - <tabstop>tabWidget</tabstop> - <tabstop>lineEdit1_X_1</tabstop> - <tabstop>lineEdit1_X_2</tabstop> - <tabstop>lineEdit1_Y_1</tabstop> - <tabstop>lineEdit1_Y_2</tabstop> - <tabstop>lineEdit1_Z_1</tabstop> - <tabstop>lineEdit1_Z_2</tabstop> - <tabstop>checkBoxActive1</tabstop> - <tabstop>dSpBoxRadius1</tabstop> - <tabstop>lineEdit2_X</tabstop> - <tabstop>lineEdit2_Y</tabstop> - <tabstop>lineEdit2_Z</tabstop> - <tabstop>lineEditLength</tabstop> - <tabstop>rBtnXAxis</tabstop> - <tabstop>rBtnYAxis</tabstop> - <tabstop>rBtnZAxis</tabstop> - <tabstop>checkBoxActive2</tabstop> - <tabstop>dSpBoxRadius2</tabstop> - <tabstop>pBtnOK</tabstop> - <tabstop>pBtnCancel</tabstop> - </tabstops> - <resources/> - <connections/> -</ui> diff --git a/src/basics/geometry3d/presentation/QGbObject3DInstrument.cpp b/src/basics/geometry3d/presentation/QGbObject3DInstrument.cpp deleted file mode 100644 index 62c4b2bf4..000000000 --- a/src/basics/geometry3d/presentation/QGbObject3DInstrument.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "./QGbObject3DInstrument.h" - -/**** Qt ****/ -#include <qlineedit.h> - -/**** vtk ****/ -#include "./../GbObject3D.h" -#include "./../../../basics/utilities/UbMath.h" - -//#define PI 3.14159265358979323846 - -QGbObject3DInstrument::QGbObject3DInstrument( QWidget* parent, Qt::WFlags flags ) -{ - ui.setupUi(this); - - this->gbObject3D = NULL; -} - -QGbObject3DInstrument::~QGbObject3DInstrument() -{ -} - -void QGbObject3DInstrument::setGbObject3D(GbObject3D* obj) -{ - this->gbObject3D = obj; -} - -GbObject3D* QGbObject3DInstrument::getGbObject3D() -{ - return this->gbObject3D; -} - -void QGbObject3DInstrument::on_pBtnOK_clicked() -{ - double rx = ui.lineEditRotationX->text().toDouble(); - double ry = ui.lineEditRotationY->text().toDouble(); - double rz = ui.lineEditRotationZ->text().toDouble(); - - rx *= UbMath::PI /180; - ry *= UbMath::PI /180; - rz *= UbMath::PI /180; - - if ( rx != 0.0 || ry != 0.0 || rz != 0.0 ) this->gbObject3D->rotate(rx, ry, rz); - - double sx = ui.lineEditScalingX->text().toDouble(); - double sy = ui.lineEditScalingY->text().toDouble(); - double sz = ui.lineEditScalingZ->text().toDouble(); - - if ( sx != 0.0 || sy != 0.0 || sz != 0.0 ) this->gbObject3D->scale(sx, sy, sz); - - double x = ui.lineEditTranlationX->text().toDouble(); - double y = ui.lineEditTranlationY->text().toDouble(); - double z = ui.lineEditTranlationZ->text().toDouble(); - - if ( x != 0.0 || y != 0.0 || z != 0.0 ) this->gbObject3D->translate(x, y, z); - - this->gbObject3D->notifyObserversObjectChanged(); - - this->accept(); -} - - -void QGbObject3DInstrument::on_pBtnCancel_clicked() -{ - this->reject(); -} diff --git a/src/basics/geometry3d/presentation/QGbObject3DInstrument.h b/src/basics/geometry3d/presentation/QGbObject3DInstrument.h deleted file mode 100644 index 5c3e556b5..000000000 --- a/src/basics/geometry3d/presentation/QGbObject3DInstrument.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef QGBOBJECT3DINSTRUMENT_H -#define QGBOBJECT3DINSTRUMENT_H - -#include <QDialog> -#include "./QGbObject3DInstrumentUI.h" - - -class GbObject3D; - -class QGbObject3DInstrument : public QDialog -{ - Q_OBJECT - -public: - QGbObject3DInstrument( QWidget* parent = 0, Qt::WFlags flags = 0 ); - ~QGbObject3DInstrument(); - void setGbObject3D(GbObject3D* gbObject); - GbObject3D* getGbObject3D(); - -protected: - GbObject3D *gbObject3D; - -private: - Ui::QGbObject3DInstrument ui; - -private slots: - void on_pBtnOK_clicked(); - void on_pBtnCancel_clicked(); -}; -#endif diff --git a/src/basics/geometry3d/presentation/QGbObject3DInstrument.ui b/src/basics/geometry3d/presentation/QGbObject3DInstrument.ui deleted file mode 100644 index 2fb6f96a9..000000000 --- a/src/basics/geometry3d/presentation/QGbObject3DInstrument.ui +++ /dev/null @@ -1,512 +0,0 @@ -<ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> - <class>QGbObject3DInstrument</class> - <widget class="QDialog" name="QGbObject3DInstrument" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>391</width> - <height>167</height> - </rect> - </property> - <property name="windowTitle" > - <string>GeneralModifyInstrument</string> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>10</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="2" column="1" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QPushButton" name="pBtnOK" > - <property name="text" > - <string>OK</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="pBtnCancel" > - <property name="text" > - <string>Cancel</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="2" column="2" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="0" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="1" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>16</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="0" colspan="3" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QGridLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="0" > - <widget class="QLabel" name="textLabel1" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Translation:</string> - </property> - </widget> - </item> - <item row="3" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2_2_2" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Z:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditTranlationZ" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>X:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditTranlationX" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="2" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2_2" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Y:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditTranlationY" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - <item> - <layout class="QGridLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="0" > - <widget class="QLabel" name="textLabel1_2" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Rotation:</string> - </property> - </widget> - </item> - <item row="3" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2_2_2_2" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Z:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditRotationZ" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2_3" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>X:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditRotationX" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="2" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2_2_3" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Y:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditRotationY" > - <property name="text" > - <string>0.0</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - <item> - <layout class="QGridLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="0" > - <widget class="QLabel" name="textLabel1_2_2" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Scaling:</string> - </property> - </widget> - </item> - <item row="3" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2_2_2_2_2" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Z:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditScalingZ" > - <property name="text" > - <string>1.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2_3_2" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>X:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditScalingX" > - <property name="text" > - <string>1.0</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="2" column="0" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2_2_3_2" > - <property name="font" > - <font> - <family>Tahoma</family> - <pointsize>10</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Y:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditScalingY" > - <property name="text" > - <string>1.0</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - <layoutdefault spacing="6" margin="11" /> - <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> - <resources/> - <connections/> -</ui> diff --git a/src/basics/geometry3d/presentation/QGbSphere3DInstrument.cpp b/src/basics/geometry3d/presentation/QGbSphere3DInstrument.cpp deleted file mode 100644 index bb397eda5..000000000 --- a/src/basics/geometry3d/presentation/QGbSphere3DInstrument.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "./QGbSphere3DInstrument.h" - -/**** Qt ****/ -#include <qlineedit.h> -#include <qstring.h> -#include <qcheckbox.h> - -/**** CAB ****/ -#include "./../GbSphere3D.h" - -QGbSphere3DInstrument::QGbSphere3DInstrument( QWidget* parent, Qt::WFlags flags ):QDialog(parent,flags) -{ - - ui.setupUi(this); - - this->gbSphere = NULL; -} - -QGbSphere3DInstrument::~QGbSphere3DInstrument(void) -{ -} - -void QGbSphere3DInstrument::setGbSphere3D(GbSphere3D* sphere) -{ - this->gbSphere = sphere; - ui.lineEditX->setText( QString("%1").arg(gbSphere->getX1Centroid() ) ); - ui.lineEditY->setText( QString("%1").arg(gbSphere->getX2Centroid() ) ); - ui.lineEditZ->setText( QString("%1").arg(gbSphere->getX3Centroid() ) ); - ui.lineEditName->setText( QString(gbSphere->getName().c_str()) ); - ui.lineEditRadius->setText( QString("%1").arg(gbSphere->getRadius() ) ); - ui.checkBoxActive->setChecked( true ); -} - -GbSphere3D* QGbSphere3DInstrument::getGbSphere3D(void) -{ - return this->gbSphere; -} - -//void QGbSphere3DInstrument::SetGbObject3D(GbObject3D* gbObj) -//{ -// this->SetGbSphere(dynamic_cast<GbSphere3D*>(gbObj)); -//} - -void QGbSphere3DInstrument::on_pBtnOK_clicked() -{ - this->gbSphere->setCenterX1Coordinate(ui.lineEditX->text().toDouble()); - this->gbSphere->setCenterX2Coordinate(ui.lineEditY->text().toDouble()); - this->gbSphere->setCenterX3Coordinate(ui.lineEditZ->text().toDouble()); - this->gbSphere->setRadius(ui.lineEditRadius->text().toDouble()); - this->gbSphere->setName(ui.lineEditName->text().toStdString()); - //this->gbSphere->setActive( this->checkBoxActive->isChecked() ); - this->gbSphere->notifyObserversObjectChanged(); - this->accept(); -} - - -void QGbSphere3DInstrument::on_pBtnCancel_clicked() -{ - this->reject(); -} diff --git a/src/basics/geometry3d/presentation/QGbSphere3DInstrument.h b/src/basics/geometry3d/presentation/QGbSphere3DInstrument.h deleted file mode 100644 index afe97b1ef..000000000 --- a/src/basics/geometry3d/presentation/QGbSphere3DInstrument.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef QGBSPHERE3DINSTRUMENT_H -#define QGBSPHERE3DINSTRUMENT_H - -#include <QtGui/QDialog> -#include <QtGui/QWidget> - -#include "./QGbSphere3DInstrumentUI.h" -#include "./QGbObject3DInstrument.h" - -class GbSphere3D; -class GbObject3D; - - -class QGbSphere3DInstrument : public QDialog -{ - Q_OBJECT - -public: - QGbSphere3DInstrument( QWidget* parent = 0, Qt::WFlags flags = 0 ); - ~QGbSphere3DInstrument(); - void setGbSphere3D(GbSphere3D* sphere); - GbSphere3D* getGbSphere3D(); - //void SetGbObject3D(GbObject3D*); - -protected: - GbSphere3D* gbSphere; - -private: - Ui::QGbSphere3DInstrument ui; - -private slots: - void on_pBtnOK_clicked(); - void on_pBtnCancel_clicked(); -}; - -#endif diff --git a/src/basics/geometry3d/presentation/QGbSphere3DInstrument.ui b/src/basics/geometry3d/presentation/QGbSphere3DInstrument.ui deleted file mode 100644 index dced5d31c..000000000 --- a/src/basics/geometry3d/presentation/QGbSphere3DInstrument.ui +++ /dev/null @@ -1,303 +0,0 @@ -<ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> - <class>QGbSphere3DInstrument</class> - <widget class="QDialog" name="QGbSphere3DInstrument" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>426</width> - <height>180</height> - </rect> - </property> - <property name="windowTitle" > - <string>GbSphere3DInstrument</string> - </property> - <widget class="QWidget" name="layoutWidget" > - <property name="geometry" > - <rect> - <x>10</x> - <y>50</y> - <width>406</width> - <height>82</height> - </rect> - </property> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QVBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1" > - <property name="text" > - <string>X:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditX" > - <property name="text" > - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_2" > - <property name="text" > - <string>Y:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditY" > - <property name="text" > - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_3" > - <property name="text" > - <string>Z:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditZ" > - <property name="text" > - <string>0</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - <item> - <layout class="QVBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QVBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel1_3_2" > - <property name="text" > - <string>Radius:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditRadius" > - <property name="text" > - <string>5</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - <item> - <widget class="QCheckBox" name="checkBoxActive" > - <property name="text" > - <string>Active</string> - </property> - <property name="checked" > - <bool>true</bool> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>16</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </widget> - <widget class="QWidget" name="layoutWidget" > - <property name="geometry" > - <rect> - <x>10</x> - <y>144</y> - <width>401</width> - <height>28</height> - </rect> - </property> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QPushButton" name="pBtnOK" > - <property name="text" > - <string>OK</string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>132</width> - <height>16</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="pBtnCancel" > - <property name="text" > - <string>Cancel</string> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="" > - <property name="geometry" > - <rect> - <x>12</x> - <y>12</y> - <width>401</width> - <height>35</height> - </rect> - </property> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="textLabel2" > - <property name="font" > - <font> - <family>Arial</family> - <pointsize>20</pointsize> - <weight>50</weight> - <italic>false</italic> - <bold>false</bold> - <underline>false</underline> - <strikeout>false</strikeout> - </font> - </property> - <property name="text" > - <string>Sphere</string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Expanding</enum> - </property> - <property name="sizeHint" > - <size> - <width>101</width> - <height>33</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QLabel" name="textLabel1_3_3" > - <property name="text" > - <string>Name:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="lineEditName" /> - </item> - </layout> - </widget> - </widget> - <layoutdefault spacing="6" margin="11" /> - <pixmapfunction>qPixmapFromMimeSource</pixmapfunction> - <resources/> - <connections/> -</ui> diff --git a/src/basics/geometry3d/presentation/QVTKGbObject3DViewer.cpp b/src/basics/geometry3d/presentation/QVTKGbObject3DViewer.cpp deleted file mode 100644 index 46f97bf4a..000000000 --- a/src/basics/geometry3d/presentation/QVTKGbObject3DViewer.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "./QVTKGbObject3DViewer.h" - -/**** Qt ****/ -#include <qtabwidget.h> -#include <qlabel.h> -/**** vtk ****/ - -#include <QVTKWidget.h> -//#include "QvtkWindow.h" - -/**** CAB ****/ -#include "./../../../basics/utilities/UbMath.h" -#include "./../GbObject3DManager.h" - - -#include "./../../../userinterface/instrument/QManagerPresentatorInstrument.h" -//#include "./QGbObject3DManagerInstrument.h" - - - -QVTKGbObject3DViewer::QVTKGbObject3DViewer():QVTKViewer3DApplication() -{ - //GbObjectManagerInstrument - this->gbObject3DManager = new GbObject3DManager(); - QManagerPresentatorInstrument* gbObjManInst = new QManagerPresentatorInstrument(gbObject3DManager); - //gbObjManInst->setQViewer(this->getViewer()); - - //Instrumente hinzufügen - this->addInstrument(gbObjManInst, "Geometries"); -} - -QVTKGbObject3DViewer::~QVTKGbObject3DViewer() -{ -} - diff --git a/src/basics/geometry3d/presentation/QVTKGbObject3DViewer.h b/src/basics/geometry3d/presentation/QVTKGbObject3DViewer.h deleted file mode 100644 index 86b4cb831..000000000 --- a/src/basics/geometry3d/presentation/QVTKGbObject3DViewer.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef QVTKGBOBJECT3DVIEWER_H -#define QVTGBOBJECT3DKVIEWER_H - -#include "./../../../userinterface/viewer3d/QVTKViewer3DApplication.h" - -class QVTKWindow; -class QVTKViewer3D; -class GbObject3DManager; -class OctNodeGridManager; - -class QVTKGbObject3DViewer : public QVTKViewer3DApplication -{ -public: - QVTKGbObject3DViewer(); - ~QVTKGbObject3DViewer(); - -protected: - - GbObject3DManager* gbObject3DManager; - -}; -#endif diff --git a/src/basics/geometry3d/presentation/vtkGbCuboid3D.cpp b/src/basics/geometry3d/presentation/vtkGbCuboid3D.cpp deleted file mode 100644 index bfd53a09c..000000000 --- a/src/basics/geometry3d/presentation/vtkGbCuboid3D.cpp +++ /dev/null @@ -1,144 +0,0 @@ -#include "./vtkGbCuboid3D.h" - -#include "./../GbCuboid3D.h" -#include "./../../../userinterface/presentation/vtkEventCallbacks.h" - -#include "vtkCubeSource.h" -#include "vtkPolyDataMapper.h" -//#include "math.h" - -vtkGbCuboid3D::vtkGbCuboid3D(GbCuboid3D* gbObject) -{ - this->gbCuboid = gbObject; - this->gbCuboid->addObserver(this); - - this->setName("vtkGbCuboid3D"); - - this->source = vtkCubeSource::New(); - this->mapper = vtkPolyDataMapper::New(); - - this->setValues(); - - this->mapper->SetInput( this->source->GetOutput() ); - this->actor->SetMapper( this->mapper ); -} - -vtkGbCuboid3D::~vtkGbCuboid3D(void) -{ - this->gbCuboid->removeObserver(this); - if (this->source) this->source->Delete(); -} - -//void vtkGbCuboid3D::ModifiedEventFired() -//{ -// //double a_orien[3]; -// double a_pos[3]; -// this->actor->GetPosition(a_pos); -// //this->actor->GetOrientation(a_orien); -// this->actor->SetPosition(0.0,0.0,0.0); -// this->actor->SetOrientation(0.0,0.0,0.0); -// this->actor->SetScale(1.0,1.0,1.0); -// -// //cout<<"Orien:"<<a_orien[0]<<","<<a_orien[1]<<","<<a_orien[3]<<endl; -// //cout<<"Position:"<<a_pos[0]<<","<<a_pos[1]<<","<<a_pos[3]<<endl; -// -// this->gbCuboid->translate(a_pos[0], a_pos[1], a_pos[2]); -// this->gbCuboid->notifyObserversObjectChanged(); -//} - -void vtkGbCuboid3D::applyActorModifications() -{ - if (isModified) - { - double pos[3]; - double scale[3]; - //double orien[3]; - this->actor->GetPosition(pos); - this->actor->GetScale(scale); - //this->actor->GetOrientation(orien); - - this->actor->SetPosition(0.0,0.0,0.0); - this->actor->SetOrientation(0.0,0.0,0.0); - this->actor->SetScale(1.0,1.0,1.0); - - //cout<<"Orien:"<<a_orien[0]<<","<<a_orien[1]<<","<<a_orien[3]<<endl; - //cout<<"Position:"<<a_pos[0]<<","<<a_pos[1]<<","<<a_pos[3]<<endl; - - - //////////////////////////////////////////////////////////////////////////// - ////Rotieren - ////[Cy x1 + Sy x3, x2, -Sy x1 + Cy x3, 1] - //double center[3]; - //center[0] = this->gbCuboid->getX1Centroid(); - //center[1] = this->gbCuboid->getX2Centroid(); - //center[2] = this->gbCuboid->getX3Centroid(); - - ////Punkt1 - //double p1x = this->gbCuboid->getPoint1()->getX1Coordinate(); - //double p1y = this->gbCuboid->getPoint1()->getX2Coordinate(); - //double p1z = this->gbCuboid->getPoint1()->getX3Coordinate(); - - //p1x = cos(orien[1]) * p1x + sin(orien[1]) * p1z; - ////p1y = p1y; - //p1z = -sin(orien[1]) * p1x + cos(orien[1]) * p1z; - - //this->gbCuboid->getPoint1()->setX1(p1x); - //this->gbCuboid->getPoint1()->setX2(p1y); - //this->gbCuboid->getPoint1()->setX3(p1z); - - // - ////Punkt2 - //double p2x = this->gbCuboid->getPoint2()->getX1Coordinate(); - //double p2y = this->gbCuboid->getPoint2()->getX2Coordinate(); - //double p2z = this->gbCuboid->getPoint2()->getX3Coordinate(); - - //p2x = cos(orien[1]) * p2x + sin(orien[1]) * p2z; - ////p1y = p1y; - //p2z = -sin(orien[1]) * p2x + cos(orien[1]) * p2z; - - //this->gbCuboid->getPoint2()->setX1(p2x); - //this->gbCuboid->getPoint2()->setX2(p2y); - //this->gbCuboid->getPoint2()->setX3(p2z); - // - //////////////////////////////////////////////////////////////////////////// - - if (scale[0] != 1.0) this->gbCuboid->scale(scale[0], scale[1], scale[2]); - else this->gbCuboid->translate(pos[0], pos[1], pos[2]); - this->gbCuboid->notifyObserversObjectChanged(); - - //Methode der Basisklasse aufrufen. - vtkPoElement3D::applyActorModifications(); - } -} - -void vtkGbCuboid3D::setValues(void) -{ - double bounds[6]; - bounds[0] = this->gbCuboid->getX1Minimum(); - bounds[1] = this->gbCuboid->getX1Maximum(); - bounds[2] = this->gbCuboid->getX2Minimum(); - bounds[3] = this->gbCuboid->getX2Maximum(); - bounds[4] = this->gbCuboid->getX3Minimum(); - bounds[5] = this->gbCuboid->getX3Maximum(); - this->source->SetBounds(bounds); - -// this->actor->SetVisibility( this->gbCuboid->isActive() ); -} - -bool vtkGbCuboid3D::isPointInObject(double const point[3]) -{ - return this->gbCuboid->isPointInGbObject3D(point[0], point[1], point[2]); -} - -void vtkGbCuboid3D::objectChanged(UbObservable*) -{ - this->setValues(); - this->source->Update(); -} - -void vtkGbCuboid3D::objectWillBeDeleted(UbObservable*) -{ - //TODO: Hier muss auf jeden Fall noch was geschehen.... - this->gbCuboid->removeObserver(this); - delete this; -} diff --git a/src/basics/geometry3d/presentation/vtkGbCuboid3D.h b/src/basics/geometry3d/presentation/vtkGbCuboid3D.h deleted file mode 100644 index 4163d4467..000000000 --- a/src/basics/geometry3d/presentation/vtkGbCuboid3D.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef VTKGBCUBOID3D_H -#define VTKGBCUBOID3D_H - -#include "./../../../userinterface/presentation/vtkPoElement3D.h" - -/**** vtk ****/ -class vtkCubeSource; -class vtkPolyDataMapper; - -class GbCuboid3D; - -class vtkGbCuboid3D : public vtkPoElement3D -{ -public: - vtkGbCuboid3D(GbCuboid3D*); - ~vtkGbCuboid3D(void); - void objectChanged(UbObservable*); - void objectWillBeDeleted(UbObservable*); - //void ModifiedEventFired(void); - void applyActorModifications(); - bool isPointInObject(double const point[3]); -protected: - void setValues(); - - GbCuboid3D* gbCuboid; - vtkCubeSource* source; - vtkPolyDataMapper* mapper; -}; -#endif diff --git a/src/basics/geometry3d/presentation/vtkGbCylinder3D.cpp b/src/basics/geometry3d/presentation/vtkGbCylinder3D.cpp deleted file mode 100644 index 77390a146..000000000 --- a/src/basics/geometry3d/presentation/vtkGbCylinder3D.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include "./vtkGbCylinder3D.h" - -#include "./../GbCylinder3D.h" -#include "./../GbPoint3D.h" -#include "./../../../userinterface/presentation/vtkEventCallbacks.h" - -#include "vtkCylinderSource.h" -#include "vtkPolyDataMapper.h" - - -vtkGbCylinder3D::vtkGbCylinder3D(GbCylinder3D* gbObject) -{ - this->gbCylinder = gbObject; - this->gbCylinder->addObserver(this); - - this->setName("vtkGbCylinder3D"); - - this->source = vtkCylinderSource::New(); - this->mapper = vtkPolyDataMapper::New(); - - this->setValues(); - - this->mapper->SetInput( this->source->GetOutput() ); - this->actor->SetMapper( this->mapper ); - - //this->applyActorModifications(); -} - -vtkGbCylinder3D::~vtkGbCylinder3D(void) -{ - this->gbCylinder->removeObserver(this); - if (this->source) this->source->Delete(); -} - - -void vtkGbCylinder3D::setValues(void) -{ - //this->source->SetCenter( this->gbCylinder->getX1Centroid(), - // this->gbCylinder->getX2Centroid(), - // this->gbCylinder->getX3Centroid()); - //this->source->SetHeight(this->gbCylinder->getLength()); - //this->source->SetRadius( this->gbCylinder->getRadius()); - - /* JZ Attention not ready still some work TODO*/ - this->source->SetHeight(this->gbCylinder->getHeight()); - this->source->SetCenter(this->gbCylinder->getX1Centroid(), - this->gbCylinder->getX2Centroid(), - this->gbCylinder->getX3Centroid()); - this->source->SetRadius( this->gbCylinder->getRadius() ); - this->source->SetResolution(10); -} - -void vtkGbCylinder3D::applyActorModifications() -{ - //this->actor->SetScale(1.0, this->gbCylinder->getLength(), 1.0); - this->source->SetHeight(this->gbCylinder->getHeight()); - this->actor->SetPosition( this->gbCylinder->getPoint1()->x1, - this->gbCylinder->getPoint1()->x2, - this->gbCylinder->getPoint1()->x3); - this->source->SetRadius( this->gbCylinder->getRadius() ); - - - - //if (this->isModified) - //{ - // double pos[3]; - // double scale[3]; - // this->actor->GetPosition(pos); - // this->actor->GetScale(scale); - - // this->actor->SetPosition(0.0,0.0,0.0); - // this->actor->SetOrientation(0.0,0.0,0.0); - // this->actor->SetScale(1.0,1.0,1.0); - - - // if (scale[0] != 1.0) this->gbCylinder->scale(scale[0], scale[1], scale[2]); - // else this->gbCylinder->translate(pos[0], pos[1], pos[2]); - // this->gbCylinder->notifyObserversObjectChanged(); - - // vtkPoElement3D::applyActorModifications(); - //} -} - -bool vtkGbCylinder3D::isPointInObject(double const point[3]) -{ - return this->gbCylinder->isPointInGbObject3D(point[0], point[1], point[2]); -} - -//Wird aufgerufen, wenn sich das zugehörige GBObject3D ändert. -void vtkGbCylinder3D::objectChanged(UbObservable*) -{ - this->setValues(); -// this->applyActorModifications(); - this->source->Modified(); -} - -void vtkGbCylinder3D::objectWillBeDeleted(UbObservable*) -{ - //TODO: Hier muss auf jeden Fall noch was geschehen.... - this->gbCylinder->removeObserver(this); - delete this; -} - diff --git a/src/basics/geometry3d/presentation/vtkGbCylinder3D.h b/src/basics/geometry3d/presentation/vtkGbCylinder3D.h deleted file mode 100644 index 19da3417b..000000000 --- a/src/basics/geometry3d/presentation/vtkGbCylinder3D.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef VTKGBCYLINDER3D_H -#define VTKGBCYLINDER3D_H - -#include "./../../../userinterface/presentation/vtkPoElement3D.h" - -class GbCylinder3D; - -class vtkCylinderSource; -class vtkPolyDataMapper; - - -class vtkGbCylinder3D : public vtkPoElement3D -{ -public: - vtkGbCylinder3D(GbCylinder3D* cylinder); - ~vtkGbCylinder3D(); - void objectChanged(UbObservable*); - void objectWillBeDeleted(UbObservable*); - //void ModifiedEventFired(void); - void applyActorModifications(); - bool isPointInObject(double const point[3]); -protected: - void setValues(); - - GbCylinder3D* gbCylinder; - vtkCylinderSource* source; - vtkPolyDataMapper* mapper; -}; -#endif - diff --git a/src/basics/geometry3d/presentation/vtkGbSphere3D.cpp b/src/basics/geometry3d/presentation/vtkGbSphere3D.cpp deleted file mode 100644 index bac51ecc1..000000000 --- a/src/basics/geometry3d/presentation/vtkGbSphere3D.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include "./vtkGbSphere3D.h" - -#include "./../GbSphere3D.h" -#include "./../../../userinterface/presentation/vtkEventCallbacks.h" - -#include "vtkSphereSource.h" -#include "vtkPolyDataMapper.h" - - -vtkGbSphere3D::vtkGbSphere3D(GbSphere3D* gbObject):vtkPoElement3D() -{ - this->gbSphere = gbObject; - this->gbSphere->addObserver(this); - - this->setName("vtkGbSphere3D"); - - - this->source = vtkSphereSource::New(); - this->mapper = vtkPolyDataMapper::New(); - - this->setValues(); - - this->mapper->SetInput( this->source->GetOutput() ); - this->actor->SetMapper( this->mapper ); -// this->actor->GetProperty()->SetRepresentationToWireframe(); -} - -vtkGbSphere3D::~vtkGbSphere3D(void) -{ - this->gbSphere->removeObserver(this); - if (this->source) this->source->Delete(); -} - -//void vtkGbSphere3D::ModifiedEventFired() -//{ -// ////double a_orien[3]; -// //double a_pos[3]; -// ////double a_scale[3]; -// //this->actor->GetPosition(a_pos); -// ////this->actor->GetOrientation(a_orien); -// ////this->actor->GetScale(a_scale); -// -// //this->actor->SetPosition(0.0,0.0,0.0); -// //this->actor->SetOrientation(0.0,0.0,0.0); -// //this->actor->SetScale(1.0,1.0,1.0); -// // -// ////cout<<"Orien:"<<a_orien[0]<<","<<a_orien[1]<<","<<a_orien[3]<<endl; -// ////cout<<"Position:"<<a_pos[0]<<","<<a_pos[1]<<","<<a_pos[3]<<endl; -// ////cout<<"Scale:"<<a_scale[0]<<","<<a_scale[1]<<","<<a_scale[3]<<endl; -// -// //this->gbSphere->translate(a_pos[0], a_pos[1], a_pos[2]); -// //this->gbSphere->notifyObserversObjectChanged(); -// PoElement3D::ModifiedEventFired(); -//} - -void vtkGbSphere3D::setValues(void) -{ - this->source->SetCenter( this->gbSphere->getX1Centroid(), - this->gbSphere->getX2Centroid(), - this->gbSphere->getX3Centroid() ); - - this->source->SetRadius( this->gbSphere->getRadius() ); -// this->actor->SetVisibility( this->gbSphere->isActive() ); -} - -void vtkGbSphere3D::applyActorModifications() -{ - if (this->isModified) - { - //double a_orien[3]; - double pos[3]; - double scale[3]; - this->actor->GetPosition(pos); - //this->actor->GetOrientation(a_orien); - this->actor->GetScale(scale); - - this->actor->SetPosition(0.0,0.0,0.0); - this->actor->SetOrientation(0.0,0.0,0.0); - this->actor->SetScale(1.0,1.0,1.0); - - //cout<<"Orien:"<<a_orien[0]<<","<<a_orien[1]<<","<<a_orien[3]<<endl; - //cout<<"Position:"<<a_pos[0]<<","<<a_pos[1]<<","<<a_pos[3]<<endl; - //cout<<"Scale:"<<a_scale[0]<<","<<a_scale[1]<<","<<a_scale[3]<<endl; - - if (scale[0] != 1.0) this->gbSphere->scale(scale[0], scale[1], scale[2]); - else this->gbSphere->translate(pos[0], pos[1], pos[2]); - this->gbSphere->notifyObserversObjectChanged(); - - vtkPoElement3D::applyActorModifications(); - } -} - -bool vtkGbSphere3D::isPointInObject(double const point[3]) -{ - return this->gbSphere->isPointInGbObject3D(point[0], point[1], point[2]); -} - -//Wird aufgerufen, wenn sich das zugehörige GBObject3D ändert. -void vtkGbSphere3D::objectChanged(UbObservable*) -{ - this->setValues(); - this->source->Modified(); - this->actor->Modified(); -} - -void vtkGbSphere3D::objectWillBeDeleted(UbObservable*) -{ - //TODO: Hier muss auf jeden Fall noch was geschehen.... - this->gbSphere->removeObserver(this); - delete this; -} - diff --git a/src/basics/geometry3d/presentation/vtkGbSphere3D.h b/src/basics/geometry3d/presentation/vtkGbSphere3D.h deleted file mode 100644 index dd6c1f696..000000000 --- a/src/basics/geometry3d/presentation/vtkGbSphere3D.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef VTKGBSPHERE3D_H -#define VTKGBSPHERE3D_H - -#include "./../../../userinterface/presentation/vtkPoElement3D.h" -//#include "./../../../../vtkEventListeners.h" - -class GbSphere3D; - -class vtkSphereSource; -class vtkPolyDataMapper; - -class vtkGbSphere3D : public vtkPoElement3D -{ -public: - vtkGbSphere3D(GbSphere3D*); - ~vtkGbSphere3D(void); - void objectChanged(UbObservable*); - void objectWillBeDeleted(UbObservable*); - //void ModifiedEventFired(void); - void applyActorModifications(); - bool isPointInObject(double const point[3]); - - virtual string toString() { return "vtkGbSphere3D"; } - -protected: - void setValues(); - - GbSphere3D* gbSphere; - vtkPolyDataMapper* mapper; - vtkSphereSource* source; -}; -#endif - diff --git a/src/basics/geometry3d/presentation/vtkGbTriangularMesh3D.cpp b/src/basics/geometry3d/presentation/vtkGbTriangularMesh3D.cpp deleted file mode 100644 index f772e7c97..000000000 --- a/src/basics/geometry3d/presentation/vtkGbTriangularMesh3D.cpp +++ /dev/null @@ -1,167 +0,0 @@ -#include "./vtkGbTriangularMesh3D.h" - -/**** CAB ****/ -#include "./../GbTriangularMesh3D.h" -#include "./../GbTriangle3D.h" -#include "./../../../basics/utilities/UbMath.h" - -/**** vtk ****/ -#include "vtkUnstructuredGrid.h" -#include "vtkDataSetMapper.h" -#include "vtkPoints.h" -#include "vtkTriangle.h" -#include "vtkIdList.h" - -/*** temp ****/ -#include "./../GbPoint3D.h" -#include "vtkMatrix4x4.h" - -//#define PI 3.14159265358979323846 - -vtkGbTriangularMesh3D::vtkGbTriangularMesh3D(GbTriangularMesh3D* mesh) -{ - this->gbTriangularMesh = mesh; - this->gbTriangularMesh->addObserver(this); - - this->setName("vtkGbTriangularMesh3D"); - - this->unstGrid = vtkUnstructuredGrid::New(); - this->buildGrid(); - - - this->dataSetMapper = vtkDataSetMapper::New(); - this->dataSetMapper->SetInput(unstGrid); - - this->actor->SetMapper( this->dataSetMapper ); -} - -vtkGbTriangularMesh3D::~vtkGbTriangularMesh3D(void) -{ - this->gbTriangularMesh->removeObserver(this); - this->unstGrid->Delete(); - this->dataSetMapper->Delete(); -} - -//void vtkGbTriangularMesh3D::ModifiedEventFired() -//{ -// double pos[3]; -// this->actor->GetPosition(pos); -// -// this->actor->SetPosition(0.0,0.0,0.0); -// this->actor->SetOrientation(0.0,0.0,0.0); -// this->actor->SetScale(1.0,1.0,1.0); -// -// double x1 = pos[0]; -// double x2 = pos[1]; -// double x3 = pos[3]; -// -// vector<GbPoint3D*>* pointList = this->gbTriangularMesh->getNodes(); -// for (int pos=0; pos<pointList->size(); pos++) -// { -// (*pointList)[pos]->translate(x1,x2,x3); -// //((*pointList)[pos])->translate(pos[0], pos[1], pos[3]); -// } -// this->gbTriangularMesh->notifyObserversObjectChanged(); -//} - -void vtkGbTriangularMesh3D::applyActorModifications() -{ - if (isModified) - { - double pos[3]; - double orien[3]; - double scale[3]; - this->actor->GetPosition(pos); - this->actor->GetOrientation(orien); - this->actor->GetScale(scale); - - orien[0] = orien[0] / 180 * UbMath::PI; - orien[1] = orien[1] / 180 * UbMath::PI; - orien[2] = orien[2] / 180 * UbMath::PI; - - //cout<<"Orien:"<<orien[0]<<","<<orien[1]<<","<<orien[3]<<endl; - //cout<<"Position:"<<pos[0]<<","<<pos[1]<<","<<pos[3]<<endl; - //cout<<"Scale:"<<scale[0]<<","<<scale[1]<<","<<scale[3]<<endl; - - this->actor->SetPosition(0.0,0.0,0.0); - this->actor->SetOrientation(0.0,0.0,0.0); - this->actor->SetScale(1.0,1.0,1.0); - - vector<GbPoint3D*>* pointList = this->gbTriangularMesh->getNodes(); - for (int index=0; index<(int)pointList->size(); index++) - { - (*pointList)[index]->rotate(orien[0], orien[1], orien[2]); - (*pointList)[index]->scale(scale[0], scale[1], scale[2]); - (*pointList)[index]->translate(pos[0], pos[1], pos[2]); - } - this->gbTriangularMesh->notifyObserversObjectChanged(); - //Methode der Basisklasse aufrufen. - vtkPoElement3D::applyActorModifications(); - } -} - -void vtkGbTriangularMesh3D::buildGrid(void) -{ - this->unstGrid->Reset(); - - vector<GbTriangle3D*>* triangles = this->gbTriangularMesh->getTriangles(); - double xyz[3]; - //this.setContext(new PoContext3D()); - - vtkPoints* points = vtkPoints::New(); - vtkTriangle* triangle = vtkTriangle::New(); - for(int u=0; u<(int)triangles->size(); u++) - { - xyz[0] = (*triangles)[u]->getPoint(0)->getX1Coordinate(); - xyz[1] = (*triangles)[u]->getPoint(0)->getX2Coordinate(); - xyz[2] = (*triangles)[u]->getPoint(0)->getX3Coordinate(); - triangle->GetPointIds()->InsertId(0, points->InsertNextPoint(xyz)); - //points.InsertPoint(u, xyz); // 3D geometry - - xyz[0] = (*triangles)[u]->getPoint(1)->getX1Coordinate(); - xyz[1] = (*triangles)[u]->getPoint(1)->getX2Coordinate(); - xyz[2] = (*triangles)[u]->getPoint(1)->getX3Coordinate(); - triangle->GetPointIds()->InsertId(1, points->InsertNextPoint(xyz)); - //points.InsertPoint(u, xyz); // 3D geometry - - xyz[0] = (*triangles)[u]->getPoint(2)->getX1Coordinate(); - xyz[1] = (*triangles)[u]->getPoint(2)->getX2Coordinate(); - xyz[2] = (*triangles)[u]->getPoint(2)->getX3Coordinate(); - triangle->GetPointIds()->InsertId(2, points->InsertNextPoint(xyz)); - //points.InsertPoint(u, xyz); // 3D geometry - - this->insertNextCell( triangle->GetCellType(), triangle->GetPointIds() ); // grid topology - - } - this->setPoints(points); - //this->source->SetCenter( this->gbSphere->getX1Centroid(), - // this->gbSphere->getX2Centroid(), - // this->gbSphere->getX3Centroid() ); - - //this->source->SetRadius( this->gbSphere->getRadius() ); - //this->actor->SetVisibility( this->gbSphere->isActive() ); - //this->unstGrid->Modified(); -} - -int vtkGbTriangularMesh3D::insertNextCell(int type, vtkIdList* idList) -{ - return this->unstGrid->InsertNextCell(type, idList); -} - -void vtkGbTriangularMesh3D::setPoints(vtkPoints* points) -{ - this->unstGrid->SetPoints(points); -} - -void vtkGbTriangularMesh3D::objectChanged(UbObservable*) -{ - this->buildGrid(); - this->unstGrid->Update(); -} - -void vtkGbTriangularMesh3D::objectWillBeDeleted(UbObservable*) -{ - //TODO: Hier muss auf jeden Fall noch was geschehen.... - this->gbTriangularMesh->removeObserver(this); - delete this; -} diff --git a/src/basics/geometry3d/presentation/vtkGbTriangularMesh3D.h b/src/basics/geometry3d/presentation/vtkGbTriangularMesh3D.h deleted file mode 100644 index 968f98846..000000000 --- a/src/basics/geometry3d/presentation/vtkGbTriangularMesh3D.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef VTKGBTRIANGULARMESH3D_H -#define VTKGBTRIANGULARMESH3D_H - -#include "./../../../userinterface/presentation/vtkPoElement3D.h" - -class GbTriangularMesh3D; -class vtkUnstructuredGrid; -class vtkDataSetMapper; -class vtkIdList; -class vtkPoints; - -class vtkGbTriangularMesh3D : public vtkPoElement3D -{ -public: - vtkGbTriangularMesh3D(GbTriangularMesh3D* mesh); - ~vtkGbTriangularMesh3D(); - void objectChanged(UbObservable* ); - void objectWillBeDeleted(UbObservable* ); - int insertNextCell(int, vtkIdList*); - void setPoints(vtkPoints*); - //void ModifiedEventFired(void); - void applyActorModifications(); -protected: - void buildGrid(); - - GbTriangularMesh3D* gbTriangularMesh; - vtkUnstructuredGrid* unstGrid; - vtkDataSetMapper* dataSetMapper; -}; -#endif - diff --git a/src/cpu/DemCoupling/CMakePackage.txt b/src/cpu/DemCoupling/CMakePackage.txt deleted file mode 100644 index 1b8416f01..000000000 --- a/src/cpu/DemCoupling/CMakePackage.txt +++ /dev/null @@ -1,2 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) diff --git a/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.cpp b/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.cpp deleted file mode 100644 index 6e99b35f5..000000000 --- a/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.cpp +++ /dev/null @@ -1,119 +0,0 @@ -#include "CreateDemObjectsCoProcessor.h" -#include "UbScheduler.h" -#include "DemCoProcessor.h" -#include "GbSphere3D.h" -#include "NoSlipBCAlgorithm.h" -#include "VelocityBCAdapter.h" -#include "VelocityWithDensityBCAlgorithm.h" -#include "VelocityBCAlgorithm.h" -#include "MovableObjectInteractor.h" -#include "LBMReconstructor.h" -#include "EquilibriumReconstructor.h" -#include "VelocityBcReconstructor.h" -#include "ExtrapolationReconstructor.h" -#include "PePhysicsEngineMaterialAdapter.h" -#include "muParser.h" -#include "PhysicsEngineMaterialAdapter.h" -#include "SetBcBlocksBlockVisitor.h" -#include "Grid3D.h" -#include "Communicator.h" - - - -CreateDemObjectsCoProcessor::CreateDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, std::shared_ptr<Communicator> comm, SPtr<DemCoProcessor> demCoProcessor, SPtr<PhysicsEngineMaterialAdapter> demObjectMaterial, double tolerance) : - CoProcessor(grid, s), - comm(comm), - demCoProcessor(demCoProcessor), - demObjectMaterial(demObjectMaterial), - tolerance(tolerance) -{ - mu::Parser fct; - fct.SetExpr("U"); - fct.DefineConst("U", 0.0); - velocityBcParticleAdapter = SPtr<BCAdapter>(new VelocityBCAdapter(true, false, false, fct, 0, BCFunction::INFCONST)); - velocityBcParticleAdapter->setBcAlgorithm(SPtr<BCAlgorithm>(new VelocityWithDensityBCAlgorithm())); - - //const std::shared_ptr<Reconstructor> velocityReconstructor(new VelocityBcReconstructor()); - std::shared_ptr<Reconstructor> equilibriumReconstructor(new EquilibriumReconstructor()); - //const std::shared_ptr<Reconstructor> lbmReconstructor(new LBMReconstructor(false)); - extrapolationReconstructor = SPtr<Reconstructor>(new ExtrapolationReconstructor(equilibriumReconstructor)); - demCounter = 0; -} -////////////////////////////////////////////////////////////////////////// -void CreateDemObjectsCoProcessor::process(double step) -{ - if (scheduler->isDue(step)) - { - int istep = static_cast<int>(step); - - -#ifdef TIMING - if (comm->isRoot()) UBLOG(logINFO, "CreateDemObjectsCoProcessor::process start step: " << istep); - timer.resetAndStart(); -#endif - - createGeoObjects(); - -#ifdef TIMING -// if (comm->isRoot()) UBLOG(logINFO, "createGeoObjects() time = "<<timer.stop()<<" s"); -// if (comm->isRoot()) UBLOG(logINFO, "number of objects = "<<(int)(geoObjectPrototypeVector.size())); -// if (comm->isRoot()) UBLOG(logINFO, "total number of objects = "<<demCounter); - if (comm->isRoot()) UBLOG(logINFO, "CreateDemObjectsCoProcessor::process stop step: " << istep); -#endif - - //demCoProcessor->distributeIDs(); - -//#ifdef TIMING -// if (comm->isRoot()) UBLOG(logINFO, "demCoProcessor->distributeIDs() time = "<<timer.stop()<<" s"); -//#endif - - - } -} -////////////////////////////////////////////////////////////////////////// -void CreateDemObjectsCoProcessor::addGeoObject(SPtr<GbObject3D> geoObjectPrototype, Vector3D initalVelocity) -{ - geoObjectPrototypeVector.push_back(geoObjectPrototype); - this->initalVelocity.push_back(initalVelocity); -} - -void CreateDemObjectsCoProcessor::clearGeoObjects() -{ - geoObjectPrototypeVector.clear(); - initalVelocity.clear(); -} - -void CreateDemObjectsCoProcessor::createGeoObjects() -{ - int size = (int)(geoObjectPrototypeVector.size()); - - std::vector< std::shared_ptr<Block3D> > blockVector; - - for (int i = 0; i < size; i++) - { - SPtr<GbSphere3D> sphere = std::dynamic_pointer_cast<GbSphere3D>(geoObjectPrototypeVector[i]); - if (demCoProcessor->isSpheresIntersection(sphere->getX1Centroid(), sphere->getX2Centroid(), sphere->getX3Centroid(), sphere->getRadius()*2.0*(1.0-tolerance))) - { - continue; - } - - SPtr<GbObject3D> geoObject((GbObject3D*)(geoObjectPrototypeVector[i]->clone())); - SPtr<MovableObjectInteractor> geoObjectInt = SPtr<MovableObjectInteractor>(new MovableObjectInteractor(geoObject, grid, velocityBcParticleAdapter, Interactor3D::SOLID, extrapolationReconstructor, State::UNPIN)); - demCoProcessor->addInteractor(geoObjectInt, demObjectMaterial, initalVelocity[i]); - demCounter++; - } - -#ifdef TIMING - if (comm->isRoot()) UBLOG(logINFO, "createGeoObjects() time = "<<timer.stop()<<" s"); - if (comm->isRoot()) UBLOG(logINFO, "number of objects = "<<(int)(geoObjectPrototypeVector.size())); - if (comm->isRoot()) UBLOG(logINFO, "total number of objects = "<<demCounter); - //if (comm->isRoot()) UBLOG(logINFO, "CreateDemObjectsCoProcessor::process stop step: " << istep); -#endif - - demCoProcessor->distributeIDs(); - -#ifdef TIMING - if (comm->isRoot()) UBLOG(logINFO, "demCoProcessor->distributeIDs() time = "<<timer.stop()<<" s"); -#endif -} - diff --git a/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.h b/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.h deleted file mode 100644 index 38ce7c2f5..000000000 --- a/src/cpu/DemCoupling/CreateDemObjectsCoProcessor.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef CreateSphereCoProcessor_h__ -#define CreateSphereCoProcessor_h__ - -#include "CoProcessor.h" -#include "Vector3D.h" -#include <vector> -#include <array> - - -//#define TIMING - -#ifdef TIMING -#include "UbTiming.h" -#endif - - -class Grid3D; -class UbScheduler; -class Communicator; -class DemCoProcessor; -class GbObject3D; -class BCAdapter; -class Reconstructor; -class PhysicsEngineMaterialAdapter; - - -class CreateDemObjectsCoProcessor : public CoProcessor -{ -public: - CreateDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, std::shared_ptr<Communicator> comm, SPtr<DemCoProcessor> demCoProcessor, SPtr<PhysicsEngineMaterialAdapter> geoObjectMaterial, double tolerance = 0); - void process(double step) override; - void addGeoObject(SPtr<GbObject3D> geoObjectPrototype, Vector3D initalVelocity); - void clearGeoObjects(); - void createGeoObjects(); - double getToleranz() const { return tolerance; } - void setToleranz(double val) { tolerance = val; } -protected: -private: - SPtr<Communicator> comm; - SPtr<DemCoProcessor> demCoProcessor; - std::vector< SPtr<GbObject3D> > geoObjectPrototypeVector; - SPtr<PhysicsEngineMaterialAdapter> demObjectMaterial; - std::vector<Vector3D> initalVelocity; - SPtr<BCAdapter> velocityBcParticleAdapter; - SPtr<Reconstructor> extrapolationReconstructor; - int demCounter; - double tolerance; -#ifdef TIMING - UbTimer timer; -#endif -}; -#endif // CreateSphereCoProcessor_h__ diff --git a/src/cpu/DemCoupling/DemCoProcessor.cpp b/src/cpu/DemCoupling/DemCoProcessor.cpp deleted file mode 100644 index 09deb9165..000000000 --- a/src/cpu/DemCoupling/DemCoProcessor.cpp +++ /dev/null @@ -1,516 +0,0 @@ -#include "DemCoProcessor.h" - -#include "GbSphere3D.h" -#include "MovableObjectInteractor.h" -#include "Communicator.h" -#include "ForceCalculator.h" -#include "Grid3D.h" -#include "UbScheduler.h" -#include "ILBMKernel.h" -#include "DistributionArray3D.h" -#include "BCProcessor.h" -#include "DataSet3D.h" -#include "SetBcBlocksBlockVisitor.h" - -#include "PhysicsEngineMaterialAdapter.h" -#include "PhysicsEngineGeometryAdapter.h" -#include "PhysicsEngineSolverAdapter.h" -#include "PePhysicsEngineSolverAdapter.h" -#include "PePhysicsEngineGeometryAdapter.h" - -#include "BoundaryConditions.h" -#include "Block3D.h" -#include "BCArray3D.h" -#include "MPICommunicator.h" -#include "BoundaryConditionsBlockVisitor.h" - -#include "UbLogger.h" - - -#include <array> -#include <functional> - -DemCoProcessor::DemCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<Communicator> comm, std::shared_ptr<ForceCalculator> forceCalculator, std::shared_ptr<PhysicsEngineSolverAdapter> physicsEngineSolver, double intermediatePeSteps) : - CoProcessor(grid, s), comm(comm), forceCalculator(forceCalculator), physicsEngineSolver(std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(physicsEngineSolver)), intermediateDemSteps(intermediatePeSteps) -{ -#ifdef TIMING - timer.resetAndStart(); -#endif - - std::shared_ptr<walberla::blockforest::BlockForest> forest = std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(physicsEngineSolver)->getBlockForest(); - std::shared_ptr<walberla::domain_decomposition::BlockDataID> storageId = std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(physicsEngineSolver)->getStorageId(); - - - for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt) - { - walberla::pe::Storage* storage = blockIt->getData< walberla::pe::Storage >(*storageId.get()); - walberla::pe::BodyStorage* bodyStorage = &(*storage)[0]; - walberla::pe::BodyStorage* bodyStorageShadowCopies = &(*storage)[1]; - - bodyStorage->registerAddCallback("DemCoProcessor", std::bind1st(std::mem_fun(&DemCoProcessor::addPeGeo), this)); - bodyStorage->registerRemoveCallback("DemCoProcessor", std::bind1st(std::mem_fun(&DemCoProcessor::removePeGeo), this)); - - bodyStorageShadowCopies->registerAddCallback("DemCoProcessor", std::bind1st(std::mem_fun(&DemCoProcessor::addPeShadowGeo), this)); - bodyStorageShadowCopies->registerRemoveCallback("DemCoProcessor", std::bind1st(std::mem_fun(&DemCoProcessor::removePeShadowGeo), this)); - } -} - -DemCoProcessor::~DemCoProcessor() -{ - std::shared_ptr<walberla::blockforest::BlockForest> forest = std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(physicsEngineSolver)->getBlockForest(); - std::shared_ptr<walberla::domain_decomposition::BlockDataID> storageId = std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(physicsEngineSolver)->getStorageId(); - - for (auto& currentBlock : *forest) - { - walberla::pe::Storage * storage = currentBlock.getData< walberla::pe::Storage >(*storageId.get()); - walberla::pe::BodyStorage& localStorage = (*storage)[0]; - walberla::pe::BodyStorage& shadowStorage = (*storage)[1]; - - localStorage.clearAddCallbacks(); - localStorage.clearRemoveCallbacks(); - - shadowStorage.clearAddCallbacks(); - shadowStorage.clearRemoveCallbacks(); - } -} - -void DemCoProcessor::addInteractor(std::shared_ptr<MovableObjectInteractor> interactor, std::shared_ptr<PhysicsEngineMaterialAdapter> physicsEngineMaterial, Vector3D initalVelocity) -{ - interactors.push_back(interactor); - const int id = static_cast<int>(interactors.size()-1); - interactor->setID(id); - const auto peGeometryAdapter = this->createPhysicsEngineGeometryAdapter(interactor, physicsEngineMaterial); - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(peGeometryAdapter)->isActive()) - { - peGeometryAdapter->setLinearVelolocity(initalVelocity); - geoIdMap.insert(std::make_pair(std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(peGeometryAdapter)->getSystemID(), std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(peGeometryAdapter))); - } - SetBcBlocksBlockVisitor setBcVisitor(interactor); - grid->accept(setBcVisitor); - - //std::vector< std::shared_ptr<Block3D> > blockVector; - //UbTupleInt3 blockNX=grid->getBlockNX(); - //SPtr<GbObject3D> geoObject(interactor->getGbObject3D()); - //double ext = 0.0; - //std::array<double, 6> AABB ={ geoObject->getX1Minimum(),geoObject->getX2Minimum(),geoObject->getX3Minimum(),geoObject->getX1Maximum(),geoObject->getX2Maximum(),geoObject->getX3Maximum() }; - //grid->getBlocksByCuboid(AABB[0]-(double)val<1>(blockNX)*ext, AABB[1]-(double)val<2>(blockNX)*ext, AABB[2]-(double)val<3>(blockNX)*ext, AABB[3]+(double)val<1>(blockNX)*ext, AABB[4]+(double)val<2>(blockNX)*ext, AABB[5]+(double)val<3>(blockNX)*ext, blockVector); - //for (std::shared_ptr<Block3D> block : blockVector) - //{ - // if (block->getKernel()) - // { - // interactor->setBCBlock(block); - // //UBLOG(logINFO, "DemCoProcessor::addInteractor() rank = "<<comm->getProcessID()); - // } - //} - - interactor->initInteractor(); - - physicsEngineGeometrieAdapters.push_back(peGeometryAdapter); -} - - -std::shared_ptr<PhysicsEngineGeometryAdapter> DemCoProcessor::createPhysicsEngineGeometryAdapter(std::shared_ptr<MovableObjectInteractor> interactor, std::shared_ptr<PhysicsEngineMaterialAdapter> physicsEngineMaterial) const -{ - const int id = static_cast<int>(interactors.size()-1); - SPtr<GbSphere3D> vfSphere = std::static_pointer_cast<GbSphere3D>(interactor->getGbObject3D()); - const Vector3D position(vfSphere->getX1Centroid(), vfSphere->getX2Centroid(), vfSphere->getX3Centroid()); - auto peGeometryAdapter = this->physicsEngineSolver->createPhysicsEngineGeometryAdapter(id, position, vfSphere->getRadius(), physicsEngineMaterial); - interactor->setPhysicsEngineGeometry(peGeometryAdapter); - return peGeometryAdapter; -} - -void DemCoProcessor::process(double actualTimeStep) -{ -#ifdef TIMING - timer.resetAndStart(); -#endif - - this->applyForcesOnGeometries(); - -#ifdef TIMING - if (comm->isRoot()) UBLOG(logINFO, "DemCoProcessor::process start step: " << actualTimeStep); - if (comm->isRoot()) UBLOG(logINFO, "DemCoProcessor::applyForcesOnGeometries() time = "<<timer.stop()<<" s"); -#endif - - if (scheduler->isDue(actualTimeStep)) - { - //UBLOG(logINFO, "DemCoProcessor::update - START - timestep = " << actualTimeStep); - const double demTimeStepsPerIteration = scheduler->getMinStep(); - - if (demTimeStepsPerIteration != 1) - this->scaleForcesAndTorques(1.0 / demTimeStepsPerIteration); - -#ifdef TIMING - if (comm->isRoot()) UBLOG(logINFO, "DemCoProcessor::scaleForcesAndTorques() time = "<<timer.stop()<<" s"); - if (comm->isRoot()) UBLOG(logINFO, "DemCoProcessor::calculateDemTimeStep():"); -#endif - - if (this->intermediateDemSteps == 1) - this->calculateDemTimeStep(demTimeStepsPerIteration); - - //#ifdef TIMING - // if (comm->isRoot()) UBLOG(logINFO, "DemCoProcessor::calculateDemTimeStep() time = "<<timer.stop()<<" s"); - //#endif - //if ((int)actualTimeStep % 100 == 0) - //{ - // if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometries[0])->isActive()) - // { - // //UBLOG(logINFO, "v: (x,y,z) " << physicsEngineGeometries[0]->getLinearVelocity() << " actualTimeStep = " << UbSystem::toString(actualTimeStep)); - // } - //} - - // during the intermediate time steps of the collision response, the currently acting forces - // (interaction forces, gravitational force, ...) have to remain constant. - // Since they are reset after the call to collision response, they have to be stored explicitly before. - // Then they are set again after each intermediate step. - - this->moveVfGeoObjects(); - -#ifdef TIMING - if (comm->isRoot()) UBLOG(logINFO, "DemCoProcessor::moveVfGeoObject() time = "<<timer.stop()<<" s"); -#endif - - grid->accept(*boundaryConditionsBlockVisitor.get()); - -#ifdef TIMING - if (comm->isRoot()) UBLOG(logINFO, "grid->accept(*boundaryConditionsBlockVisitor.get()) time = "<<timer.stop()<<" s"); -#endif - - //UBLOG(logINFO, "DemCoProcessor::update - END - timestep = " << actualTimeStep); - } - -#ifdef TIMING - if (comm->isRoot()) UBLOG(logINFO, "DemCoProcessor::process stop step: " << actualTimeStep); -#endif -} -////////////////////////////////////////////////////////////////////////// -std::shared_ptr<PhysicsEngineSolverAdapter> DemCoProcessor::getPhysicsEngineSolver() -{ - return physicsEngineSolver; -} - -void DemCoProcessor::applyForcesOnGeometries() -{ - for (int i = 0; i < physicsEngineGeometrieAdapters.size(); i++) - { - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive()) - { - this->setForcesToObject(grid, interactors[i], physicsEngineGeometrieAdapters[i]); - - //physicsEngineGeometries[i]->setLinearVelolocity(Vector3D(-0.001, 0.0, 0.0)); - //physicsEngineGeometries[i]->setAngularVelocity(Vector3D(0.01, 0.01, 0.01)); - //UBLOG(logINFO, "v: (x,y,z) " << physicsEngineGeometries[i]->getLinearVelocity()); - } - } -} - -void DemCoProcessor::setForcesToObject(SPtr<Grid3D> grid, SPtr<MovableObjectInteractor> interactor, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry) -{ - for (BcNodeIndicesMap::value_type t : interactor->getBcNodeIndicesMap()) - { - SPtr<Block3D> block = t.first; - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - distributions->swap(); - - std::set< std::vector<int> >& transNodeIndicesSet = t.second; - for (std::vector<int> node : transNodeIndicesSet) - { - int x1 = node[0]; - int x2 = node[1]; - int x3 = node[2]; - - if (kernel->isInsideOfDomain(x1, x2, x3) && bcArray->isFluid(x1, x2, x3)) - { - //TODO: calculate assumed boundary position - - const Vector3D worldCoordinates = grid->getNodeCoordinates(block, x1, x2, x3); - const auto boundaryVelocity = physicsEngineGeometry->getVelocityAtPosition(worldCoordinates); - - SPtr<BoundaryConditions> bc = bcArray->getBC(x1, x2, x3); - const Vector3D force = forceCalculator->getForces(x1, x2, x3, distributions, bc, boundaryVelocity); - physicsEngineGeometry->addForceAtPosition(force, worldCoordinates); - } - } - distributions->swap(); - } -} - - -void DemCoProcessor::scaleForcesAndTorques(double scalingFactor) -{ - for (int i = 0; i < physicsEngineGeometrieAdapters.size(); i++) - { - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive()) - { - const Vector3D force = physicsEngineGeometrieAdapters[i]->getForce() * scalingFactor; - const Vector3D torque = physicsEngineGeometrieAdapters[i]->getTorque() * scalingFactor; - - physicsEngineGeometrieAdapters[i]->resetForceAndTorque(); - - physicsEngineGeometrieAdapters[i]->setForce(force); - physicsEngineGeometrieAdapters[i]->setTorque(torque); - - //UBLOG(logINFO, "F: (x,y,z) " << force); - //UBLOG(logINFO, "T: (x,y,z) " << torque); - } - } -} - - -void DemCoProcessor::calculateDemTimeStep(double step) -{ - physicsEngineSolver->runTimestep(step); - -#ifdef TIMING - if (comm->isRoot()) UBLOG(logINFO, " physicsEngineSolver->runTimestep() time = "<< timer.stop() <<" s"); -#endif -} - -void DemCoProcessor::moveVfGeoObjects() -{ - for (int i = 0; i < interactors.size(); i++) - { - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive()) - { - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->getSemiactive()) - { - walberla::pe::RigidBody* peGeoObject = getPeGeoObject(std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->getSystemID()); - if (peGeoObject != nullptr) - { - std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->setGeometry(peGeoObject); - interactors[i]->moveGbObjectTo(physicsEngineGeometrieAdapters[i]->getPosition()); - std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->setSemiactive(false); - } - else - { - std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->setInactive(); - } - } - else - { - interactors[i]->moveGbObjectTo(physicsEngineGeometrieAdapters[i]->getPosition()); - } - } - } -} - -bool DemCoProcessor::isDemObjectInAABB(std::array<double, 6> AABB) -{ - bool result = false; - for (int i = 0; i < interactors.size(); i++) - { - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive()) - { - SPtr<GbObject3D> geoObject = interactors[i]->getGbObject3D(); - std::array <double, 2> minMax1; - std::array <double, 2> minMax2; - std::array <double, 2> minMax3; - minMax1[0] = geoObject->getX1Minimum(); - minMax2[0] = geoObject->getX2Minimum(); - minMax3[0] = geoObject->getX3Minimum(); - minMax1[1] = geoObject->getX1Maximum(); - minMax2[1] = geoObject->getX2Maximum(); - minMax3[1] = geoObject->getX3Maximum(); - - for (int x3 = 0; x3 < 2; x3++) - for (int x2 = 0; x2 < 2; x2++) - for (int x1 = 0; x1 < 2; x1++) - { - result = result || (minMax1[x1] >= AABB[0] && minMax2[x2] >= AABB[1] && minMax3[x3] >= AABB[2] && minMax1[x1] <= AABB[3] && minMax2[x2] <= AABB[4] && minMax3[x3] <= AABB[5]); - } - } - } - - std::vector<int> values; - values.push_back((int)result); - std::vector<int> rvalues = comm->gather(values); - - if (comm->isRoot()) - { - for (int i = 0; i < (int)rvalues.size(); i++) - { - result = result || (bool)rvalues[i]; - } - } - int iresult = (int)result; - comm->broadcast(iresult); - result = (bool)iresult; - - return result; -} - -int DemCoProcessor::addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles) -{ - for (int i = 0; i < interactors.size(); i++) - { - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive()) - { - interactors[i]->getGbObject3D()->addSurfaceTriangleSet(nodes, triangles); - } - } - return (int)interactors.size(); -} - -void DemCoProcessor::getObjectsPropertiesVector(std::vector<double>& p) -{ - for (int i = 0; i < interactors.size(); i++) - { - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive()) - { - p.push_back(i); - p.push_back(interactors[i]->getGbObject3D()->getX1Centroid()); - p.push_back(interactors[i]->getGbObject3D()->getX2Centroid()); - p.push_back(interactors[i]->getGbObject3D()->getX3Centroid()); - Vector3D v = physicsEngineGeometrieAdapters[i]->getLinearVelocity(); - p.push_back(v[0]); - p.push_back(v[1]); - p.push_back(v[2]); - } - } -} - -void DemCoProcessor::addPeGeo(walberla::pe::RigidBody * peGeo) -{ - auto geometry = getPeGeoAdapter(peGeo->getSystemID()); - if (geometry != nullptr) - { - geometry->setActive(); - geometry->setGeometry(peGeo); - return; - } - else - return; -} - -void DemCoProcessor::removePeGeo(walberla::pe::RigidBody * peGeo) -{ - auto geometry = getPeGeoAdapter(peGeo->getSystemID()); - if (geometry != nullptr) - { - geometry->setSemiactive(true); - } - else - throw UbException(UB_EXARGS, "PeGeo SystemId="+UbSystem::toString(peGeo->getSystemID())+" is not matching geometry ID"); -} - -void DemCoProcessor::addPeShadowGeo(walberla::pe::RigidBody * peGeo) -{ - auto geometry = getPeGeoAdapter(peGeo->getSystemID()); - if (geometry != nullptr) - { - geometry->setActive(); - geometry->setGeometry(peGeo); - return; - } - else - throw UbException(UB_EXARGS, "PeGeo ID="+UbSystem::toString(peGeo->getSystemID())+" is not matching geometry ID"); -} - -void DemCoProcessor::removePeShadowGeo(walberla::pe::RigidBody * peGeo) -{ - auto geometry = getPeGeoAdapter(peGeo->getSystemID()); - - if (geometry != nullptr) - { - geometry->setSemiactive(true); - } - else - throw UbException(UB_EXARGS, "PeGeo ID="+UbSystem::toString(peGeo->getSystemID())+" is not matching geometry ID"); -} - -bool DemCoProcessor::isSpheresIntersection(double centerX1, double centerX2, double centerX3, double d) -{ - bool result = false; - for (int i = 0; i < interactors.size(); i++) - { - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive()) - { - SPtr<GbObject3D> sphere = interactors[i]->getGbObject3D(); - result = result || (sqrt(pow(sphere->getX1Centroid()-centerX1, 2.0)+pow(sphere->getX2Centroid()-centerX2, 2.0)+pow(sphere->getX3Centroid()-centerX3, 2.0)) <= d); - } - } - std::vector<int> values; - values.push_back((int)result); - std::vector<int> rvalues = comm->gather(values); - - if (comm->isRoot()) - { - for (int i = 0; i < (int)rvalues.size(); i++) - { - result = result || (bool)rvalues[i]; - } - } - int iresult = (int)result; - comm->broadcast(iresult); - result = (bool)iresult; - - return result; -} - -void DemCoProcessor::distributeIDs() -{ - std::vector<unsigned long long> peIDsSend; - std::vector<int> vfIDsSend; - - for (int i = 0; i < interactors.size(); i++) - { - if (std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->isActive()) - { - peIDsSend.push_back(std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->getSystemID()); - vfIDsSend.push_back(interactors[i]->getID()); - } - } - - std::vector<unsigned long long> peIDsRecv; - std::vector<int> vfIDsRecv; - - comm->allGather(peIDsSend, peIDsRecv); - comm->allGather(vfIDsSend, vfIDsRecv); - - std::map<int, unsigned long long> idMap; - - for (int i = 0; i < peIDsRecv.size(); i++) - { - idMap.insert(std::make_pair(vfIDsRecv[i], peIDsRecv[i])); - } - - for (int i = 0; i < interactors.size(); i++) - { - std::map<int, unsigned long long>::const_iterator it; - if ((it=idMap.find(interactors[i]->getID())) == idMap.end()) - { - throw UbException(UB_EXARGS, "Interactor ID = "+UbSystem::toString(interactors[i]->getID())+" is invalid! The DEM object may be not in PE domain!"); - } - - std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i])->setSystemID(it->second); - - geoIdMap.insert(std::make_pair(it->second, std::dynamic_pointer_cast<PePhysicsEngineGeometryAdapter>(physicsEngineGeometrieAdapters[i]))); - } -} -////////////////////////////////////////////////////////////////////////// -void DemCoProcessor::setBlockVisitor(std::shared_ptr<BoundaryConditionsBlockVisitor> boundaryConditionsBlockVisitor) -{ - this->boundaryConditionsBlockVisitor = boundaryConditionsBlockVisitor; -} -////////////////////////////////////////////////////////////////////////// -walberla::pe::RigidBody* DemCoProcessor::getPeGeoObject(walberla::id_t id) -{ - std::shared_ptr<walberla::blockforest::BlockForest> forest = std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(physicsEngineSolver)->getBlockForest(); - std::shared_ptr<walberla::domain_decomposition::BlockDataID> storageId = std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(physicsEngineSolver)->getStorageId(); - std::shared_ptr<walberla::pe::BodyStorage> globalBodyStorage = std::dynamic_pointer_cast<PePhysicsEngineSolverAdapter>(physicsEngineSolver)->getGlobalBodyStorage(); - - return walberla::pe::getBody(*globalBodyStorage, *forest, *storageId, id, walberla::pe::StorageSelect::LOCAL | walberla::pe::StorageSelect::SHADOW); -} -//////////////////////////////////////////////////////////////////////////// -std::shared_ptr<PePhysicsEngineGeometryAdapter> DemCoProcessor::getPeGeoAdapter(unsigned long long systemId) -{ - std::map< unsigned long long, std::shared_ptr<PePhysicsEngineGeometryAdapter> >::const_iterator it; - if ((it=geoIdMap.find(systemId)) == geoIdMap.end()) - { - return nullptr; - } - else - return it->second; -} diff --git a/src/cpu/DemCoupling/DemCoProcessor.h b/src/cpu/DemCoupling/DemCoProcessor.h deleted file mode 100644 index 74718a911..000000000 --- a/src/cpu/DemCoupling/DemCoProcessor.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Author: S. Peters - * mail: peters@irmb.tu-bs.de - */ -#ifndef DEM_CO_PROCESSOR_H -#define DEM_CO_PROCESSOR_H - -#include <memory> -#include <vector> -#include <map> - -#include "Vector3D.h" - -#include "CoProcessor.h" -#include "UbTuple.h" - -#include <pe/basic.h> - -//#define TIMING - -#ifdef TIMING - #include "UbTiming.h" -#endif - - -class PhysicsEngineGeometryAdapter; -class PhysicsEngineSolverAdapter; -class PePhysicsEngineSolverAdapter; -class PhysicsEngineMaterialAdapter; -class PePhysicsEngineGeometryAdapter; - -class UbScheduler; -class Grid3D; -class ForceCalculator; -class Communicator; -class MovableObjectInteractor; -class Communicator; -class BoundaryConditionsBlockVisitor; - - -class DemCoProcessor : public CoProcessor -{ -public: - DemCoProcessor(std::shared_ptr<Grid3D> grid, std::shared_ptr<UbScheduler> s, std::shared_ptr<Communicator> comm, std::shared_ptr<ForceCalculator> forceCalculator, std::shared_ptr<PhysicsEngineSolverAdapter> physicsEngineSolver, double intermediatePeSteps = 1.0); - virtual ~DemCoProcessor(); - - void addInteractor(std::shared_ptr<MovableObjectInteractor> interactor, std::shared_ptr<PhysicsEngineMaterialAdapter> physicsEngineMaterial, Vector3D initalVelocity = Vector3D(0.0, 0.0, 0.0)); - void process(double step) override; - std::shared_ptr<PhysicsEngineSolverAdapter> getPhysicsEngineSolver(); - void distributeIDs(); - void setBlockVisitor(std::shared_ptr<BoundaryConditionsBlockVisitor> blockVisitor); - bool isDemObjectInAABB(std::array<double,6> AABB); - int addSurfaceTriangleSet(std::vector<UbTupleFloat3>& nodes, std::vector<UbTupleInt3>& triangles); - void getObjectsPropertiesVector(std::vector<double>& p); - void addPeGeo(walberla::pe::RigidBody* peGeo); - void removePeGeo(walberla::pe::RigidBody* peGeo); - void addPeShadowGeo(walberla::pe::RigidBody* peGeo); - void removePeShadowGeo(walberla::pe::RigidBody* peGeo); - bool isSpheresIntersection(double centerX1, double centerX2, double centerX3, double d); - -private: - std::shared_ptr<PhysicsEngineGeometryAdapter> createPhysicsEngineGeometryAdapter(std::shared_ptr<MovableObjectInteractor> interactor, std::shared_ptr<PhysicsEngineMaterialAdapter> physicsEngineMaterial) const; - void applyForcesOnGeometries(); - void setForcesToObject(SPtr<Grid3D> grid, std::shared_ptr<MovableObjectInteractor> interactor, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry); - void scaleForcesAndTorques(double scalingFactor); - void calculateDemTimeStep(double step); - void moveVfGeoObjects(); - walberla::pe::RigidBody* getPeGeoObject(walberla::id_t id); - std::shared_ptr<PePhysicsEngineGeometryAdapter> getPeGeoAdapter(unsigned long long systemId); -private: - std::shared_ptr<Communicator> comm; - std::vector<std::shared_ptr<MovableObjectInteractor> > interactors; - std::shared_ptr<ForceCalculator> forceCalculator; - std::shared_ptr<PePhysicsEngineSolverAdapter> physicsEngineSolver; - std::vector<std::shared_ptr<PhysicsEngineGeometryAdapter> > physicsEngineGeometrieAdapters; - double intermediateDemSteps; - SPtr<BoundaryConditionsBlockVisitor> boundaryConditionsBlockVisitor; - //walberla::pe::BodyStorage* bodyStorage; //!< Reference to the central body storage. - //walberla::pe::BodyStorage* bodyStorageShadowCopies; //!< Reference to the body storage containing body shadow copies. - - std::map< unsigned long long, std::shared_ptr<PePhysicsEngineGeometryAdapter> > geoIdMap; - -#ifdef TIMING - UbTimer timer; -#endif -}; - - -#endif - diff --git a/src/cpu/DemCoupling/DemCoupling.cmake b/src/cpu/DemCoupling/DemCoupling.cmake deleted file mode 100644 index beff09755..000000000 --- a/src/cpu/DemCoupling/DemCoupling.cmake +++ /dev/null @@ -1,31 +0,0 @@ -INCLUDE(${SOURCE_ROOT}/DemCoupling/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/DemCoupling/physicsEngineAdapter/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/DemCoupling/physicsEngineAdapter/dummy/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/DemCoupling/physicsEngineAdapter/pe/CMakePackage.txt) -INCLUDE(${SOURCE_ROOT}/DemCoupling/reconstructor/CMakePackage.txt) - -INCLUDE(${SOURCE_ROOT}/DemCoupling/IncludsList.cmake) - -SET(LINK_LIBRARY optimized ${PE_RELEASE_LIBRARY} debug ${PE_DEBUG_LIBRARY}) -SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) - -SET(LINK_LIBRARY optimized ${BLOCKFOREST_RELEASE_LIBRARY} debug ${BLOCKFOREST_DEBUG_LIBRARY}) -SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) - -SET(LINK_LIBRARY optimized ${DOMAIN_DECOMPOSITION_RELEASE_LIBRARY} debug ${DOMAIN_DECOMPOSITION_DEBUG_LIBRARY}) -SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) - -SET(LINK_LIBRARY optimized ${GEOMETRY_RELEASE_LIBRARY} debug ${GEOMETRY_DEBUG_LIBRARY}) -SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) - -SET(LINK_LIBRARY optimized ${CORE_RELEASE_LIBRARY} debug ${CORE_DEBUG_LIBRARY}) -SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) - -IF(${USE_GCC}) - SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} "stdc++fs") -ENDIF() - -IF(${USE_METIS}) - SET(LINK_LIBRARY optimized ${METIS_RELEASE_LIBRARY} debug ${METIS_DEBUG_LIBRARY}) - SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) -ENDIF() \ No newline at end of file diff --git a/src/cpu/DemCoupling/IncludsList.cmake b/src/cpu/DemCoupling/IncludsList.cmake deleted file mode 100644 index 7ebf198e6..000000000 --- a/src/cpu/DemCoupling/IncludsList.cmake +++ /dev/null @@ -1,8 +0,0 @@ -INCLUDE_DIRECTORIES(${SOURCE_ROOT}/DemCoupling) -INCLUDE_DIRECTORIES(${SOURCE_ROOT}/DemCoupling/physicsEngineAdapter) -INCLUDE_DIRECTORIES(${SOURCE_ROOT}/DemCoupling/physicsEngineAdapter/dummy) -INCLUDE_DIRECTORIES(${SOURCE_ROOT}/DemCoupling/physicsEngineAdapter/pe) -INCLUDE_DIRECTORIES(${SOURCE_ROOT}/DemCoupling/reconstructor) - -INCLUDE_DIRECTORIES(${PE_ROOT}/src) -INCLUDE_DIRECTORIES(${PE_BINARY_DIR}/src) \ No newline at end of file diff --git a/src/cpu/DemCoupling/MovableObjectInteractor.cpp b/src/cpu/DemCoupling/MovableObjectInteractor.cpp deleted file mode 100644 index 49a9ece51..000000000 --- a/src/cpu/DemCoupling/MovableObjectInteractor.cpp +++ /dev/null @@ -1,260 +0,0 @@ -#include "MovableObjectInteractor.h" - -#include "UbLogger.h" -#include "GbObject3D.h" -#include "Vector3D.h" - -#include "Block3D.h" -#include "Grid3D.h" -#include "BCArray3D.h" -#include "BCAdapter.h" -#include "BCProcessor.h" -#include "ILBMKernel.h" -#include "CoordinateTransformation3D.h" - -#include "SetBcBlocksBlockVisitor.h" -#include "BoundaryConditionsBlockVisitor.h" - -#include "PhysicsEngineGeometryAdapter.h" -#include "Reconstructor.h" - -#include <array> - -//#define TIMING - -#ifdef TIMING - #include "UbTiming.h" -#endif - - -MovableObjectInteractor::MovableObjectInteractor(std::shared_ptr<GbObject3D> geoObject3D, std::shared_ptr<Grid3D> grid, std::shared_ptr<BCAdapter> bcAdapter, int type, std::shared_ptr<Reconstructor> reconstructor, State state) - : D3Q27Interactor(geoObject3D, grid, bcAdapter, type), reconstructor(reconstructor), state(state) -{ - //grid->getBlocks(0, grid->getRank(), true, blockVector); -} - -MovableObjectInteractor::~MovableObjectInteractor() -{ - -} - -void MovableObjectInteractor::setPhysicsEngineGeometry(std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry) -{ - this->physicsEngineGeometry = physicsEngineGeometry; - physicsEngineGeometry->changeState(this->state); -} - -void MovableObjectInteractor::moveGbObjectTo(const Vector3D& position) -{ - //UBLOG(logINFO, "new position: (x,y,z) " << val<1>(position) << ", " << val<2>(position) << ", " << val<3>(position)); - - this->getGbObject3D()->setCenterCoordinates(UbTupleDouble3(position[0], position[1], position[2])); - this->rearrangeGrid(); -} - -void MovableObjectInteractor::rearrangeGrid() -{ -#ifdef TIMING - UbTimer timer; - timer.resetAndStart(); -#endif - -#ifdef TIMING - UBLOG(logINFO, "MovableObjectInteractor::rearrangeGrid():start"); -#endif - - this->reconstructDistributionOnSolidNodes(); - -#ifdef TIMING - UBLOG(logINFO, "reconstructDistributionOnSolidNodes() time = "<<timer.stop()<<" s"); -#endif - - this->setSolidNodesToFluid(); - -#ifdef TIMING - UBLOG(logINFO, "setSolidNodesToFluid() time = "<<timer.stop()<<" s"); -#endif - - this->setBcNodesToFluid(); - -#ifdef TIMING - UBLOG(logINFO, "setBcNodesToFluid() time = "<<timer.stop()<<" s"); -#endif - - this->removeSolidBlocks(); - -#ifdef TIMING - UBLOG(logINFO, "removeSolidBlocks() time = "<<timer.stop()<<" s"); -#endif - - this->removeBcBlocks(); - -#ifdef TIMING - UBLOG(logINFO, "removeBcBlocks() time = "<<timer.stop()<<" s"); -#endif - - this->setBcBlocks(); - -#ifdef TIMING - UBLOG(logINFO, "setBcBlocks() time = "<<timer.stop()<<" s"); -#endif - - this->initInteractor(); - -#ifdef TIMING - UBLOG(logINFO, "initInteractor() time = "<<timer.stop()<<" s"); -#endif - - this->updateVelocityBc(); - -#ifdef TIMING - UBLOG(logINFO, "updateVelocityBc() time = "<<timer.stop()<<" s"); -#endif -} - -void MovableObjectInteractor::updateNodeLists() -{ - //for (BcNodeIndicesMap::value_type t : bcNodeIndicesMap) - //{ - // SPtr<Block3D> block = t.first; - // std::set< UbTupleInt3 >& bcNodeIndices = t.second; - - - // SPtr<ILBMKernel> kernel = block->getKernel(); - - // for (UbTupleInt3 node : bcNodeIndices) - // { - - // } - //} -} - -void MovableObjectInteractor::reconstructDistributionOnSolidNodes() -{ - for(SolidNodeIndicesMap::value_type t : solidNodeIndicesMap) - { - SPtr<Block3D> block = t.first; - std::set< UbTupleInt3 >& solidNodeIndices = t.second; - - - SPtr<ILBMKernel> kernel = block->getKernel(); - - for (UbTupleInt3 node : solidNodeIndices) - { - const int x1 = val<1>(node); - const int x2 = val<2>(node); - const int x3 = val<3>(node); - - const Vector3D worldCoordinates = this->grid.lock()->getNodeCoordinates(block, x1, x2, x3); - - if (kernel->isInsideOfDomain(x1, x2, x3)) - reconstructor->reconstructNode(x1, x2, x3, worldCoordinates, physicsEngineGeometry, kernel); - } - } -} - -void MovableObjectInteractor::setSolidNodesToFluid() -{ - for (SolidNodeIndicesMap::value_type t : solidNodeIndicesMap) - { - SPtr<Block3D> block = t.first; - std::set< UbTupleInt3 >& solidNodeIndices = t.second; - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - - for (UbTupleInt3 node : solidNodeIndices) - bcArray->setFluid(val<1>(node), val<2>(node), val<3>(node)); - } -} - -void MovableObjectInteractor::setBcNodesToFluid() -{ - for (BcNodeIndicesMap::value_type t : bcNodeIndicesMap) - { - SPtr<Block3D> block = t.first; - std::set< std::vector<int> >& bcNodeIndices = t.second; - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - - for (std::vector<int> node : bcNodeIndices) - bcArray->setFluid(node[0], node[1], node[2]); - } -} - -void MovableObjectInteractor::setBcBlocks() -{ - SetBcBlocksBlockVisitor v(shared_from_this()); - this->grid.lock()->accept(v); - - ////////////////////////////////////////////////////////////////////////// - //SPtr<GbObject3D> geoObject = this->getGbObject3D(); - //std::array<double, 6> AABB ={ geoObject->getX1Minimum(),geoObject->getX2Minimum(),geoObject->getX3Minimum(),geoObject->getX1Maximum(),geoObject->getX2Maximum(),geoObject->getX3Maximum() }; - //blockVector.clear(); - //UbTupleInt3 blockNX=grid.lock()->getBlockNX(); - //double ext = 0.0; - //grid.lock()->getBlocksByCuboid(AABB[0]-(double)val<1>(blockNX)*ext, AABB[1]-(double)val<2>(blockNX)*ext, AABB[2]-(double)val<3>(blockNX)*ext, AABB[3]+(double)val<1>(blockNX)*ext, AABB[4]+(double)val<2>(blockNX)*ext, AABB[5]+(double)val<3>(blockNX)*ext, blockVector); - - //for(std::shared_ptr<Block3D> block : this->blockVector) - //{ - // if (block->getKernel()) - // { - // setBCBlock(block); - // } - //} - ////////////////////////////////////////////////////////////////////////// - //SPtr<GbObject3D> geoObject = this->getGbObject3D(); - //std::array <double, 2> minMax1; - //std::array <double, 2> minMax2; - //std::array <double, 2> minMax3; - //minMax1[0] = geoObject->getX1Minimum(); - //minMax2[0] = geoObject->getX2Minimum(); - //minMax3[0] = geoObject->getX3Minimum(); - //minMax1[1] = geoObject->getX1Maximum(); - //minMax2[1] = geoObject->getX2Maximum(); - //minMax3[1] = geoObject->getX3Maximum(); - - //SPtr<CoordinateTransformation3D> trafo = grid.lock()->getCoordinateTransformator(); - - //for (int x3 = 0; x3 < 2; x3++) - // for (int x2 = 0; x2 < 2; x2++) - // for (int x1 = 0; x1 < 2; x1++) - // { - // int ix1 = (int)trafo->transformForwardToX1Coordinate(minMax1[x1], minMax2[x2], minMax3[x3]); - // int ix2 = (int)trafo->transformForwardToX2Coordinate(minMax1[x1], minMax2[x2], minMax3[x3]); - // int ix3 = (int)trafo->transformForwardToX3Coordinate(minMax1[x1], minMax2[x2], minMax3[x3]); - // blockVector.push_back(grid.lock()->getBlock(ix1, ix2, ix3, 0)); - // } - //for(std::shared_ptr<Block3D> block : this->blockVector) - //{ - // if (block->getKernel()) - // { - // setBCBlock(block); - // } - //} -} - -void MovableObjectInteractor::updateVelocityBc() -{ - for(BcNodeIndicesMap::value_type t : this->getBcNodeIndicesMap()) - { - SPtr<Block3D> block = t.first; - std::set< std::vector<int> >& bcNodeIndices = t.second; - - SPtr<BCArray3D> bcArray = block->getKernel()->getBCProcessor()->getBCArray(); - - for(std::vector<int> node : bcNodeIndices) - setGeometryVelocityToBoundaryCondition(node, block, bcArray); - } -} - - -void MovableObjectInteractor::setGeometryVelocityToBoundaryCondition(std::vector<int> node, SPtr<Block3D> block, SPtr<BCArray3D> bcArray) const -{ - const SPtr<BoundaryConditions> bc = bcArray->getBC(node[0], node[1], node[2]); - const Vector3D worldCoordinates = this->grid.lock()->getNodeCoordinates(block, node[0], node[1], node[2]); - const Vector3D velocity = this->physicsEngineGeometry->getVelocityAtPosition(worldCoordinates); - - bc->setBoundaryVelocity(velocity); -} diff --git a/src/cpu/DemCoupling/MovableObjectInteractor.h b/src/cpu/DemCoupling/MovableObjectInteractor.h deleted file mode 100644 index 0aeb22bbd..000000000 --- a/src/cpu/DemCoupling/MovableObjectInteractor.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -* Author: S. Peters -* mail: peters@irmb.tu-bs.de -*/ -#ifndef D3Q27_MOVABLE_OBJECT_INTERACTOR_H -#define D3Q27_MOVABLE_OBJECT_INTERACTOR_H - -#include <memory> -#include <vector> - -#include "D3Q27Interactor.h" - -#include "Vector3D.h" -#include "PhysicsEngineGeometryAdapter.h" - - -class Grid3D; -class Block3D; -class BCArray3D; -class BCAdapter; -class GbObject3D; - -class PhysicsEngineGeometryAdapter; -class Reconstructor; - -class MovableObjectInteractor : public D3Q27Interactor -{ -public: - typedef std::map<SPtr<Block3D>, std::set< std::array<int,3> > > InBcNodeIndicesMap; - typedef std::map<SPtr<Block3D>, std::set< std::array<int,3> > > OutBcNodeIndicesMap; -public: - MovableObjectInteractor(std::shared_ptr<GbObject3D> geoObject3D, std::shared_ptr<Grid3D> grid, std::shared_ptr<BCAdapter> bcAdapter, int type, std::shared_ptr<Reconstructor> reconstructor, State isPinned); - virtual ~MovableObjectInteractor(); - - void setPhysicsEngineGeometry(std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry); - - void moveGbObjectTo(const Vector3D& position); - -private: - void rearrangeGrid(); - void updateNodeLists(); - void setSolidNodesToFluid(); - void setBcNodesToFluid(); - void reconstructDistributionOnSolidNodes(); - void setBcBlocks(); - - void updateVelocityBc(); - void setGeometryVelocityToBoundaryCondition(std::vector<int> node, std::shared_ptr<Block3D> block, std::shared_ptr<BCArray3D> bcArray) const; - - std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry; - - std::shared_ptr<Reconstructor> reconstructor; - State state; - std::vector< std::shared_ptr<Block3D> > blockVector; -}; - - -#endif diff --git a/src/cpu/DemCoupling/PePartitioningGridVisitor.cpp b/src/cpu/DemCoupling/PePartitioningGridVisitor.cpp deleted file mode 100644 index b52d3ba57..000000000 --- a/src/cpu/DemCoupling/PePartitioningGridVisitor.cpp +++ /dev/null @@ -1,156 +0,0 @@ -#if defined VF_METIS && defined VF_MPI - -#include <shared_mutex> -#include "PePartitioningGridVisitor.h" -#include <math.h> -#include "Block3D.h" -#include "Grid3D.h" -#include "Communicator.h" -#include "UbLogger.h" -#include "CoordinateTransformation3D.h" - -#include "DemCoProcessor.h" - -using namespace std; - -PePartitioningGridVisitor::PePartitioningGridVisitor(SPtr<Communicator> comm, std::shared_ptr<DemCoProcessor> dem) - : Grid3DVisitor(), - comm(comm), - dem(dem) -{ - forest = dynamicPointerCast<PePhysicsEngineSolverAdapter>(dem->getPhysicsEngineSolver())->getForest(); -} -////////////////////////////////////////////////////////////////////////// -PePartitioningGridVisitor::~PePartitioningGridVisitor() -{ - -} -////////////////////////////////////////////////////////////////////////// -void PePartitioningGridVisitor::visit(SPtr<Grid3D> grid) -{ - UBLOG(logDEBUG1, "PePartitioningGridVisitor::visit() - start"); - - collectData(grid); - distributePartitionData(grid); - - UBLOG(logDEBUG1, "PePartitioningGridVisitor::visit() - end"); -} -////////////////////////////////////////////////////////////////////////// -void PePartitioningGridVisitor::collectData(SPtr<Grid3D> grid) -{ - //int minInitLevel = grid->getCoarsestInitializedLevel(); - //int maxInitLevel = grid->getFinestInitializedLevel(); - - walberla::uint_t peRank; - - for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt) - { - forest->getProcessRank(peRank, blockIt->getId()); - vector<SPtr<Block3D>> blocks; - walberla::AABB aabb = blockIt->getAABB(); - - //getBlocksByCuboid((double)aabb.xMin(), (double)aabb.yMin(), (double)aabb.zMin(), (double)aabb.xMax(), (double)aabb.yMax(), (double)aabb.zMax(), blocks, grid); - //for (SPtr<Block3D> block : blocks) - //{ - // ids.push_back(block->getGlobalID()); - // ranks.push_back((int)peRank); - //} - SPtr<Block3D> block = getBlockByMinUniform((double)aabb.xMin(), (double)aabb.yMin(), (double)aabb.zMin(), grid); - if (block) - { - ids.push_back(block->getGlobalID()); - ranks.push_back((int)peRank); - } - } -} -////////////////////////////////////////////////////////////////////////// -//void PePartitioningGridVisitor::getBlocksByCuboid(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, std::vector<SPtr<Block3D>>& blocks, SPtr<Grid3D> grid) -//{ -// int coarsestLevel = grid->getCoarsestInitializedLevel(); -// int finestLevel = grid->getFinestInitializedLevel(); -// -// SPtr<CoordinateTransformation3D> trafo = grid->getCoordinateTransformator(); -// -// ////////////////////////////////////////////////////////////////////////// -// //MINIMALE BLOCK-INDIZES BESTIMMEN -// // -// //min: -// double dMinX1 = trafo->transformForwardToX1Coordinate(minX1, minX2, minX3)*(1<<finestLevel); -// double dMinX2 = trafo->transformForwardToX2Coordinate(minX1, minX2, minX3)*(1<<finestLevel); -// double dMinX3 = trafo->transformForwardToX3Coordinate(minX1, minX2, minX3)*(1<<finestLevel); -// -// //Achtung, wenn minX1 genau auf grenze zwischen zwei bloecken -> der "kleinere" muss genommen werden, -// //da beim Transformieren der "groessere" Index rauskommt -// int iMinX1 = (int)dMinX1; //if (UbMath::zero(dMinX1-iMinX1)) iMinX1-=1; -// int iMinX2 = (int)dMinX2; //if (UbMath::zero(dMinX2-iMinX2)) iMinX2-=1; -// int iMinX3 = (int)dMinX3; //if (UbMath::zero(dMinX3-iMinX3)) iMinX3-=1; -// -// //max (hier kann die Zusatzabfrage vernachlaessigt werden): -// int iMaxX1 = (int)(trafo->transformForwardToX1Coordinate(maxX1, maxX2, maxX3)*(1<<finestLevel)); -// int iMaxX2 = (int)(trafo->transformForwardToX2Coordinate(maxX1, maxX2, maxX3)*(1<<finestLevel)); -// int iMaxX3 = (int)(trafo->transformForwardToX3Coordinate(maxX1, maxX2, maxX3)*(1<<finestLevel)); -// -// SPtr<Block3D> block; -// -// //set, um doppelte bloecke zu vermeiden, die u.U. bei periodic auftreten koennen -// std::set<SPtr<Block3D>> blockset; -// for (int level=coarsestLevel; level<=finestLevel; level++) -// { -// //damit bei negativen werten auch der "kleinere" genommen wird -> floor! -// int minx1 = (int)std::floor((double)iMinX1/(1<<(finestLevel-level))); -// int minx2 = (int)std::floor((double)iMinX2/(1<<(finestLevel-level))); -// int minx3 = (int)std::floor((double)iMinX3/(1<<(finestLevel-level))); -// -// int maxx1 = iMaxX1/(1<<(finestLevel-level)); -// int maxx2 = iMaxX2/(1<<(finestLevel-level)); -// int maxx3 = iMaxX3/(1<<(finestLevel-level)); -// -// for (int ix1=minx1; ix1<maxx1; ix1++) -// for (int ix2=minx2; ix2<maxx2; ix2++) -// for (int ix3=minx3; ix3<maxx3; ix3++) -// if ((block=grid->getBlock(ix1, ix2, ix3, level))) -// { -// blockset.insert(block); -// } -// } -// -// blocks.resize(blockset.size()); -// std::copy(blockset.begin(), blockset.end(), blocks.begin()); -//} - -SPtr<Block3D> PePartitioningGridVisitor::getBlockByMinUniform(double minX1, double minX2, double minX3, SPtr<Grid3D> grid) -{ - SPtr<CoordinateTransformation3D> trafo = grid->getCoordinateTransformator(); - - int ix1 = (int)trafo->transformForwardToX1Coordinate(minX1, minX2, minX3); - int ix2 = (int)trafo->transformForwardToX2Coordinate(minX1, minX2, minX3); - int ix3 = (int)trafo->transformForwardToX3Coordinate(minX1, minX2, minX3); - - return grid->getBlock(ix1, ix2, ix3, 0); -} - -////////////////////////////////////////////////////////////////////////// -void PePartitioningGridVisitor::distributePartitionData(SPtr<Grid3D> grid) -{ - std::vector<int> totalIDs; - std::vector<int> totalRanks; - - assert(ids.size() != 0); - assert(ranks.size() != 0); - - comm->allGather(ids, totalIDs); - comm->allGather(ranks, totalRanks); - - - assert(totalIDs.size() == totalRanks.size()); - for (int i = 0; i < totalIDs.size(); i++) - { - SPtr<Block3D> block = grid->getBlock(totalIDs[i]); - if (block) block->setRank(totalRanks[i]); - } -} -////////////////////////////////////////////////////////////////////////// - - - -#endif //VF_METIS diff --git a/src/cpu/DemCoupling/PePartitioningGridVisitor.h b/src/cpu/DemCoupling/PePartitioningGridVisitor.h deleted file mode 100644 index bce2ca0d2..000000000 --- a/src/cpu/DemCoupling/PePartitioningGridVisitor.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef PePartitioningGridVisitor_h -#define PePartitioningGridVisitor_h - -#if defined VF_MPI - -#include <vector> -#include <PointerDefinitions.h> - -#include "Grid3DVisitor.h" - -#include "PePhysicsEngineSolverAdapter.h" - -#include <array> - -//////////////////////////////////////////////////////////////////////// -//! \brief The class implements domain decomposition with PE library -//! \author Konstantin Kutscher -////////////////////////////////////////////////////////////////////////// -class Communicator; -class Grid3D; -class Block3D; -class DemCoProcessor; -//class walberla::blockforest::BlockForest; - -class PePartitioningGridVisitor : public Grid3DVisitor -{ -public: - //! This describe different types of decomposition - enum GraphType{LevelIntersected, LevelBased}; - -public: - //! Constructor - //! \param comm - communicator - - PePartitioningGridVisitor(SPtr<Communicator> comm, std::shared_ptr<DemCoProcessor> dem); - virtual ~PePartitioningGridVisitor(); - void visit(SPtr<Grid3D> grid) override; - -protected: - void collectData(SPtr<Grid3D> grid); - void distributePartitionData(SPtr<Grid3D> grid); - //void getBlocksByCuboid(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, std::vector<SPtr<Block3D>>& blocks, SPtr<Grid3D> grid); - SPtr<Block3D> getBlockByMinUniform(double minX1, double minX2, double minX3, SPtr<Grid3D> grid); - -private: - SPtr<Communicator> comm; - std::shared_ptr<DemCoProcessor> dem; - - std::vector<int> ids; - std::vector<int> ranks; - - std::shared_ptr< walberla::blockforest::BlockForest > forest; -}; - -#endif //VF_MPI -#endif diff --git a/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.cpp b/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.cpp deleted file mode 100644 index 1cc39ad6e..000000000 --- a/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.cpp +++ /dev/null @@ -1,119 +0,0 @@ -#include "RestartDemObjectsCoProcessor.h" - -#include "Vector3D.h" -#include "Communicator.h" -#include "UbScheduler.h" -#include "Grid3D.h" -#include "UbSystem.h" -#include "GbSphere3D.h" -#include "DemCoProcessor.h" -#include "UbFileInputBinary.h" -#include "UbFileOutputBinary.h" -#include "CreateDemObjectsCoProcessor.h" - -RestartDemObjectsCoProcessor::RestartDemObjectsCoProcessor() -{ -} - -RestartDemObjectsCoProcessor::RestartDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string & path, SPtr<DemCoProcessor> demCoProcessor, SPtr<CreateDemObjectsCoProcessor> createDemObjectsCoProcessor, double radius, SPtr<Communicator> comm) : CoProcessor(grid, s), path(path), demCoProcessor(demCoProcessor), createDemObjectsCoProcessor(createDemObjectsCoProcessor), radius(radius), comm(comm) -{ -} - -void RestartDemObjectsCoProcessor::process(double step) -{ - if (scheduler->isDue(step)) - { - int istep = static_cast<int>(step); - - if (comm->isRoot()) - UBLOG(logINFO, "RestartDemObjectsCoProcessor::write step: " << istep); - - write(istep); - } -} - -void RestartDemObjectsCoProcessor::restart(double step) -{ - if (comm->isRoot()) - UBLOG(logINFO, "RestartDemObjectsCoProcessor::read step: " << (int)step); - - read((int)step); -} - -void RestartDemObjectsCoProcessor::write(int step) -{ - if (comm->isRoot()) UBLOG(logINFO, "RestartDemObjectsCoProcessor::write start "); - std::vector<double> p; - - demCoProcessor->getObjectsPropertiesVector(p); - - //TODO implement getherv - std::vector<double> rvalues; - comm->allGather(p, rvalues); - - if (comm->isRoot()) - { - std::map< int, std::vector< double> > infMap; - int size = (int)rvalues.size(); - for (int i = 0; i < size; i += 7) - { - std::vector< double> infVector(6); - for (int j = 0; j < 6; j ++) - { - infVector[j] = rvalues[i+1+j]; - } - infMap.insert(std::make_pair((int)rvalues[i], infVector)); - } - std::vector< double> wvalues; - typedef std::map< int, std::vector< double> >::iterator it_type; - for (it_type iterator = infMap.begin(); iterator != infMap.end(); iterator++) - { - // iterator->first = key - // iterator->second = value - std::vector<double>::iterator it = wvalues.end(); - it = wvalues.insert(it, iterator->second.begin(), iterator->second.end()); - } - std::string subfolder = "dem_cp_"+UbSystem::toString(step); - std::string filePath = path+"/dem_cp/"+subfolder+"/dem_cp.bin"; - UbFileOutputBinary fo(filePath); - fo.writeInteger((int)wvalues.size()); - fo.writeVector<double>(wvalues); - UBLOG(logINFO, "RestartDemObjectsCoProcessor::write number of objects = " << wvalues.size()/6); - } - if (comm->isRoot()) UBLOG(logINFO, "RestartDemObjectsCoProcessor::write stop "); -} - -void RestartDemObjectsCoProcessor::read(int step) -{ - if (comm->isRoot()) UBLOG(logINFO, "RestartDemObjectsCoProcessor::read start "); - std::vector<double> p; - - if (comm->isRoot()) - { - std::string subfolder = "dem_cp_"+UbSystem::toString(step); - std::string filePath = path+"/dem_cp/"+subfolder+"/dem_cp.bin"; - UbFileInputBinary fi(filePath); - int size = fi.readInteger(); - p.resize(size); - fi.readVector<double>(p); - } - comm->broadcast(p); - - if (comm->isRoot()) UBLOG(logINFO, "RestartDemObjectsCoProcessor::read number of objects = " << p.size()/6); - - createDemObjectsCoProcessor->clearGeoObjects(); - - int size = (int)p.size(); - - for (int i = 0; i < size; i += 6) - { - SPtr<GbObject3D> sphere(new GbSphere3D(p[i], p[i+1], p[i+2], radius)); - createDemObjectsCoProcessor->addGeoObject(sphere, Vector3D(p[i+3], p[i+4], p[i+5])); - } - - createDemObjectsCoProcessor->createGeoObjects(); - - createDemObjectsCoProcessor->clearGeoObjects(); - - if (comm->isRoot()) UBLOG(logINFO, "RestartDemObjectsCoProcessor::read stop "); -} diff --git a/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.h b/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.h deleted file mode 100644 index 8a1fdb721..000000000 --- a/src/cpu/DemCoupling/RestartDemObjectsCoProcessor.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -* Author: K. Kutscher -* mail: kutscher@irmb.tu-bs.de -*/ -#ifndef RestartDemObjectsCoProcessor_H -#define RestartDemObjectsCoProcessor_H - -#include <PointerDefinitions.h> -#include <string> -#include <vector> - -#include "CoProcessor.h" - -class Communicator; -class Grid3D; -class UbScheduler; -class DemCoProcessor; -class CreateDemObjectsCoProcessor; - -class RestartDemObjectsCoProcessor : public CoProcessor -{ -public: - RestartDemObjectsCoProcessor(); - RestartDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, SPtr<DemCoProcessor> demCoProcessor, SPtr<CreateDemObjectsCoProcessor> createDemObjectsCoProcessor, double radius, SPtr<Communicator> comm); - ~RestartDemObjectsCoProcessor() {} - void process(double step) override; - void restart(double step); - void write(int step); - void read(int step); - -private: - std::string path; - double radius; - SPtr<Communicator> comm; - SPtr<DemCoProcessor> demCoProcessor; - SPtr<CreateDemObjectsCoProcessor> createDemObjectsCoProcessor; -}; -#endif diff --git a/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.cpp b/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.cpp deleted file mode 100644 index 30b25c0de..000000000 --- a/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "WriteDemObjectsCoProcessor.h" - -#include "basics/writer/WbWriterVtkXmlBinary.h" -#include "basics/writer/WbWriterVtkXmlASCII.h" - -#include "Communicator.h" -#include "UbScheduler.h" -#include "Grid3D.h" -#include "UbSystem.h" -#include "DemCoProcessor.h" - -WriteDemObjectsCoProcessor::WriteDemObjectsCoProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -WriteDemObjectsCoProcessor::WriteDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, WbWriter* const writer, SPtr<DemCoProcessor> demCoProcessor, SPtr<Communicator> comm) - : CoProcessor(grid, s), - path(path), - writer(writer), - demCoProcessor(demCoProcessor), - comm(comm) -{ - -} -////////////////////////////////////////////////////////////////////////// -void WriteDemObjectsCoProcessor::process(double step) -{ - if (scheduler->isDue(step)) - { - std::vector<UbTupleFloat3> nodes; - std::vector<UbTupleInt3> triangles; - - int numObjcts = demCoProcessor->addSurfaceTriangleSet(nodes, triangles); - - int istep = static_cast<int>(step); - - std::string pfilePath, partPath, subfolder, cfilePath; - - subfolder = "dem"+UbSystem::toString(istep); - pfilePath = path+"/dem/"+subfolder; - cfilePath = path+"/dem/dem_collection"; - partPath = pfilePath+"/dem"+UbSystem::toString(comm->getProcessID())+ "_" + UbSystem::toString(istep); - - - std::string partName = writer->writeTriangles(partPath, nodes, triangles); - size_t found=partName.find_last_of("/"); - std::string piece = partName.substr(found+1); - piece = subfolder + "/" + piece; - - std::vector<std::string> datanames; - std::vector<std::string> cellDataNames; - std::vector<std::string> pieces = comm->gather(piece); - if (comm->isRoot()) - { - std::string pname = WbWriterVtkXmlASCII::getInstance()->writeParallelFile(pfilePath, pieces, datanames, cellDataNames); - found=pname.find_last_of("/"); - piece = pname.substr(found+1); - - std::vector<std::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, "WriteDemObjectsCoProcessor number of objects: " << numObjcts); - UBLOG(logINFO, "WriteDemObjectsCoProcessor step: " << istep); - } - } -} diff --git a/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.h b/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.h deleted file mode 100644 index 93d87bcf8..000000000 --- a/src/cpu/DemCoupling/WriteDemObjectsCoProcessor.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -* Author: K. Kutscher -* mail: kutscher@irmb.tu-bs.de -*/ -#ifndef WriteDemObjectsCoProcessor_H -#define WriteDemObjectsCoProcessor_H - -#include <PointerDefinitions.h> -#include <string> -#include <vector> - -#include "CoProcessor.h" - -class Communicator; -class Grid3D; -class UbScheduler; -class DemCoProcessor; -class WbWriter; - -class WriteDemObjectsCoProcessor : public CoProcessor -{ -public: - WriteDemObjectsCoProcessor(); - WriteDemObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, WbWriter* const writer, SPtr<DemCoProcessor> demCoProcessor, SPtr<Communicator> comm); - ~WriteDemObjectsCoProcessor() {} - void process(double step) override; - -private: - std::string path; - WbWriter* writer; - SPtr<Communicator> comm; - SPtr<DemCoProcessor> demCoProcessor; -}; -#endif diff --git a/src/cpu/DemCoupling/WritePeBlocksCoProcessor.cpp b/src/cpu/DemCoupling/WritePeBlocksCoProcessor.cpp deleted file mode 100644 index f46208ac9..000000000 --- a/src/cpu/DemCoupling/WritePeBlocksCoProcessor.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "WritePeBlocksCoProcessor.h" - -#include "basics/writer/WbWriterVtkXmlASCII.h" - -#include "D3Q27System.h" -#include "Block3D.h" -#include "UbScheduler.h" -#include "Communicator.h" -#include "Grid3D.h" - -WritePeBlocksCoProcessor::WritePeBlocksCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, WbWriter* const writer, SPtr<Communicator> comm, SPtr<walberla::blockforest::BlockForest> forest) : - CoProcessor(grid, s), - path(path), - writer(writer), - comm(comm), - forest(forest) -{ - -} - -WritePeBlocksCoProcessor::~WritePeBlocksCoProcessor() -{ - -} - -void WritePeBlocksCoProcessor::process(double step) -{ - if (scheduler->isDue(step)) - collectData(step); -} - -void WritePeBlocksCoProcessor::collectData(double step) -{ - if (comm->getProcessID() == comm->getRoot()) - { - int istep = int(step); - std::vector<std::string> filenames; - std::vector< UbTupleFloat3 > nodes; - std::vector< UbTupleInt8 > cells; - std::vector<std::string> celldatanames; - - celldatanames.push_back("ID"); - celldatanames.push_back("rank"); - - walberla::uint_t rank = 0; - - - std::vector< std::vector< double > > celldata(celldatanames.size()); - - int nr=0; - - for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt) - { - walberla::AABB aabb = blockIt->getAABB(); - - nodes.push_back(makeUbTuple((float)aabb.xMin(), (float)aabb.yMin(), (float)aabb.zMin())); - nodes.push_back(makeUbTuple((float)aabb.xMax(), (float)aabb.yMin(), (float)aabb.zMin())); - nodes.push_back(makeUbTuple((float)aabb.xMax(), (float)aabb.yMax(), (float)aabb.zMin())); - nodes.push_back(makeUbTuple((float)aabb.xMin(), (float)aabb.yMax(), (float)aabb.zMin())); - nodes.push_back(makeUbTuple((float)aabb.xMin(), (float)aabb.yMin(), (float)aabb.zMax())); - nodes.push_back(makeUbTuple((float)aabb.xMax(), (float)aabb.yMin(), (float)aabb.zMax())); - nodes.push_back(makeUbTuple((float)aabb.xMax(), (float)aabb.yMax(), (float)aabb.zMax())); - nodes.push_back(makeUbTuple((float)aabb.xMin(), (float)aabb.yMax(), (float)aabb.zMax())); - cells.push_back(makeUbTuple(nr, nr+1, nr+2, nr+3, nr+4, nr+5, nr+6, nr+7)); - nr += 8; - - //data - celldata[0].push_back((double)blockIt->getId().getID()); - forest->getProcessRank(rank,blockIt->getId()); - celldata[1].push_back((double)rank); - } - - filenames.push_back(writer->writeOctsWithCellData(path+"/peBlocks/peBlocks_" + UbSystem::toString(grid->getRank()) + "_" + UbSystem::toString(istep), nodes, cells, celldatanames, celldata)); - - if (istep == CoProcessor::scheduler->getMinBegin()) - { - WbWriterVtkXmlASCII::getInstance()->writeCollection(path+"/peBlocks/peBlocks_collection", filenames, istep, false); - } - else - { - WbWriterVtkXmlASCII::getInstance()->addFilesToCollection(path + "/peBlocks/peBlocks_collection", filenames, istep, false); - } - - UBLOG(logINFO, "WritePeBlocksCoProcessor step: " << istep); - - } - -} \ No newline at end of file diff --git a/src/cpu/DemCoupling/WritePeBlocksCoProcessor.h b/src/cpu/DemCoupling/WritePeBlocksCoProcessor.h deleted file mode 100644 index 6d1022566..000000000 --- a/src/cpu/DemCoupling/WritePeBlocksCoProcessor.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -* WritePeBlocksCoProcessor.h -* -* Created on: 07.09.2018 -* Author: K. Kutscher -*/ - -#ifndef WritePeBlocksCoProcessor_H_ -#define WritePeBlocksCoProcessor_H_ - -#include <PointerDefinitions.h> -#include <string> - -#include "CoProcessor.h" - -#include <pe/basic.h> - -class Communicator; -class Grid3D; -class UbScheduler; -class WbWriter; - -class WritePeBlocksCoProcessor : public CoProcessor -{ -public: - WritePeBlocksCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, WbWriter* const writer, SPtr<Communicator> comm, SPtr<walberla::blockforest::BlockForest> forest); - virtual ~WritePeBlocksCoProcessor(); - - void process(double step) override; - -protected: - void collectData(double step); - - std::string path; - WbWriter* writer; - SPtr<Communicator> comm; - SPtr<walberla::blockforest::BlockForest> forest; -}; - - - -#endif - diff --git a/src/cpu/DemCoupling/package.include b/src/cpu/DemCoupling/package.include deleted file mode 100644 index 8b1378917..000000000 --- a/src/cpu/DemCoupling/package.include +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/CMakePackage.txt b/src/cpu/DemCoupling/physicsEngineAdapter/CMakePackage.txt deleted file mode 100644 index 1b8416f01..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/CMakePackage.txt +++ /dev/null @@ -1,2 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineGeometryAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineGeometryAdapter.h deleted file mode 100644 index a7eb5c6bc..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineGeometryAdapter.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -* Author: S. Peters -* mail: peters@irmb.tu-bs.de -*/ -#ifndef PHYSICS_ENGINE_GEOMETRY_ADAPTER_H -#define PHYSICS_ENGINE_GEOMETRY_ADAPTER_H - -#include "Vector3D.h" - -enum class State -{ - PIN, UNPIN -}; - -class PhysicsEngineGeometryAdapter -{ -public: - virtual ~PhysicsEngineGeometryAdapter() {} - - virtual void addForce(const Vector3D& force) = 0; - virtual void addTorque(const Vector3D& torque) = 0; - - virtual void setForce(const Vector3D& force) = 0; - virtual void setTorque(const Vector3D& torque) = 0; - - virtual void addForceAtPosition(const Vector3D& force, const Vector3D& position) = 0; - virtual void setLinearVelolocity(const Vector3D& velocity) = 0; - virtual void setAngularVelocity(const Vector3D& velocity) = 0; - - virtual void resetForceAndTorque() = 0; - - virtual Vector3D getPosition() const = 0; - virtual Vector3D getVelocityAtPosition(const Vector3D& position) const = 0; - virtual Vector3D getLinearVelocity() const = 0; - virtual Vector3D getAngularVelocity() const = 0; - - virtual Vector3D getForce() const = 0; - virtual Vector3D getTorque() const = 0; - - virtual void changeState(State state) = 0; -}; - - -#endif - diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineMaterialAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineMaterialAdapter.h deleted file mode 100644 index 1b887cda1..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineMaterialAdapter.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -* Author: S. Peters -* mail: peters@irmb.tu-bs.de -*/ -#ifndef PHYSICS_ENGINE_MATERIAL_ADAPTER_H -#define PHYSICS_ENGINE_MATERIAL_ADAPTER_H - -#include <string> - -class PhysicsEngineMaterialAdapter -{ -public: - PhysicsEngineMaterialAdapter(std::string name, double density, double restitution, double staticFriction, double dynamicFriction, double poissonRatio, double youngModul, double stiffnessInNormalDirection, double dampingoefficientNormalDirection, double dampingTangentialDirection) - : name(name), density(density), restitution(restitution), staticFriction(staticFriction), dynamicFriction(dynamicFriction), poissonRatio(poissonRatio), youngModul(youngModul), stiffnessInNormalDirection(stiffnessInNormalDirection), dampingoefficientNormalDirection(dampingoefficientNormalDirection), dampingTangentialDirection(dampingTangentialDirection) - {} - virtual ~PhysicsEngineMaterialAdapter() {} - -protected: - std::string name; - double density; - double restitution; - double staticFriction; // Note: pe doubles the input coefficient of friction for material-material contacts. - double dynamicFriction; // Similar to static friction for low speed friction. - double poissonRatio; - double youngModul; - double stiffnessInNormalDirection; - double dampingoefficientNormalDirection; - double dampingTangentialDirection; -}; - - -#endif - diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineSolverAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineSolverAdapter.h deleted file mode 100644 index bb035ab31..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/PhysicsEngineSolverAdapter.h +++ /dev/null @@ -1,26 +0,0 @@ -/* -* Author: S. Peters -* mail: peters@irmb.tu-bs.de -*/ -#ifndef PHYSICS_ENGINE_SOLVER_ADAPTER_H -#define PHYSICS_ENGINE_SOLVER_ADAPTER_H - -#include "Vector3D.h" - - -class PhysicsEngineGeometryAdapter; -class PhysicsEngineMaterialAdapter; - -class PhysicsEngineSolverAdapter -{ -public: - virtual ~PhysicsEngineSolverAdapter() {} - - virtual std::shared_ptr<PhysicsEngineGeometryAdapter> createPhysicsEngineGeometryAdapter(int id, const Vector3D& position, double radius, std::shared_ptr<PhysicsEngineMaterialAdapter> material) const = 0; - virtual void runTimestep(double step) = 0; -}; - - - -#endif - diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/CMakePackage.txt b/src/cpu/DemCoupling/physicsEngineAdapter/dummy/CMakePackage.txt deleted file mode 100644 index 1b8416f01..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/CMakePackage.txt +++ /dev/null @@ -1,2 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.cpp b/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.cpp deleted file mode 100644 index ababa676a..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "DummyPhysicsEngineGeometryAdapter.h" - - - -void DummyPhysicsEngineGeometryAdapter::addForce(const Vector3D& force) -{ - -} - -void DummyPhysicsEngineGeometryAdapter::addTorque(const Vector3D& torque) -{ - -} - -void DummyPhysicsEngineGeometryAdapter::setForce(const Vector3D& force) -{ - -} - -void DummyPhysicsEngineGeometryAdapter::setTorque(const Vector3D& torque) -{ - -} - -void DummyPhysicsEngineGeometryAdapter::addForceAtPosition(const Vector3D& force, const Vector3D& position) -{ - -} - -void DummyPhysicsEngineGeometryAdapter::setLinearVelolocity(const Vector3D& velocity) -{ - this->velocity = velocity; -} - -void DummyPhysicsEngineGeometryAdapter::setAngularVelocity(const Vector3D& velocity) -{ - -} - -void DummyPhysicsEngineGeometryAdapter::resetForceAndTorque() -{ - -} - -Vector3D DummyPhysicsEngineGeometryAdapter::getVelocityAtPosition(const Vector3D& position) const -{ - return velocity; -} - -Vector3D DummyPhysicsEngineGeometryAdapter::getLinearVelocity() const -{ - return Vector3D(); -} - -Vector3D DummyPhysicsEngineGeometryAdapter::getAngularVelocity() const -{ - return Vector3D(); -} - -Vector3D DummyPhysicsEngineGeometryAdapter::getPosition() const -{ - return Vector3D(); -} - -Vector3D DummyPhysicsEngineGeometryAdapter::getForce() const -{ - return Vector3D(); -} - -Vector3D DummyPhysicsEngineGeometryAdapter::getTorque() const -{ - return Vector3D(); -} - -void DummyPhysicsEngineGeometryAdapter::changeState(State state) -{ - -} - diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.h deleted file mode 100644 index 2f37f466b..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineGeometryAdapter.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -* Author: S. Peters -* mail: peters@irmb.tu-bs.de -*/ -#ifndef DUMMY_PHYSICS_ENGINE_GEOMETRY_ADAPTER_H -#define DUMMY_PHYSICS_ENGINE_GEOMETRY_ADAPTER_H - -#include "UbTuple.h" - -#include "PhysicsEngineGeometryAdapter.h" - - - -class DummyPhysicsEngineGeometryAdapter : public PhysicsEngineGeometryAdapter -{ -public: - DummyPhysicsEngineGeometryAdapter() {} - virtual ~DummyPhysicsEngineGeometryAdapter() {} - - void addForce(const Vector3D& force) override; - void addTorque(const Vector3D& torque) override; - - void setForce(const Vector3D& force) override; - void setTorque(const Vector3D& torque) override; - - void addForceAtPosition(const Vector3D& force, const Vector3D& position) override; - void setLinearVelolocity(const Vector3D& velocity) override; - void setAngularVelocity(const Vector3D& velocity) override; - - void resetForceAndTorque() override; - - Vector3D getVelocityAtPosition(const Vector3D& position) const override; - Vector3D getLinearVelocity() const override; - Vector3D getAngularVelocity() const override; - Vector3D getPosition() const override; - Vector3D getForce() const override; - Vector3D getTorque() const override; - - void changeState(State state) override; -private: - Vector3D velocity; -}; - -#endif - diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.cpp b/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.cpp deleted file mode 100644 index 7890f9668..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "DummyPhysicsEngineMaterialAdapter.h" diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.h deleted file mode 100644 index c9b8a44a1..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineMaterialAdapter.h +++ /dev/null @@ -1,23 +0,0 @@ -/* -* Author: S. Peters -* mail: peters@irmb.tu-bs.de -*/ -#ifndef DUMMY_PHYSICS_ENGINE_MATERIAL_ADAPTER -#define DUMMY_PHYSICS_ENGINE_MATERIAL_ADAPTER - -#include "PhysicsEngineMaterialAdapter.h" - - -class DummyPhysicsEngineMaterialAdapter : public PhysicsEngineMaterialAdapter -{ -public: - DummyPhysicsEngineMaterialAdapter(std::string name, double density, double restitution, double staticFriction, double dynamicFriction, double poissonRatio, double youngModul, double stiffnessInNormalDirection, double dampingoefficientNormalDirection, double dampingTangentialDirection) - : PhysicsEngineMaterialAdapter(name, density, restitution, staticFriction, dynamicFriction, poissonRatio, youngModul, stiffnessInNormalDirection, dampingoefficientNormalDirection, dampingTangentialDirection) - { - } - virtual ~DummyPhysicsEngineMaterialAdapter() {} - -}; - -#endif - diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.cpp b/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.cpp deleted file mode 100644 index 8053942b9..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "DummyPhysicsEngineSolverAdapter.h" - -#include "DummyPhysicsEngineGeometryAdapter.h" - - -std::shared_ptr<PhysicsEngineGeometryAdapter> DummyPhysicsEngineSolverAdapter::createPhysicsEngineGeometryAdapter(int id, const Vector3D& position, double radius, std::shared_ptr<PhysicsEngineMaterialAdapter> material) const -{ - return std::static_pointer_cast<PhysicsEngineGeometryAdapter>(std::make_shared<DummyPhysicsEngineGeometryAdapter>()); -} - -void DummyPhysicsEngineSolverAdapter::runTimestep(double step) -{ - -} diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.h deleted file mode 100644 index 38975727e..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/DummyPhysicsEngineSolverAdapter.h +++ /dev/null @@ -1,28 +0,0 @@ -/* -* Author: S. Peters -* mail: peters@irmb.tu-bs.de -*/ -#ifndef DUMMY_PHYSICS_ENGINE_SOLVER_ADAPTER_H -#define DUMMY_PHYSICS_ENGINE_SOLVER_ADAPTER_H - -#include <memory> - -#include "UbTuple.h" - -#include "PhysicsEngineSolverAdapter.h" - - - -class DummyPhysicsEngineSolverAdapter : public PhysicsEngineSolverAdapter -{ -public: - DummyPhysicsEngineSolverAdapter() {}; - virtual ~DummyPhysicsEngineSolverAdapter() {} - - std::shared_ptr<PhysicsEngineGeometryAdapter> createPhysicsEngineGeometryAdapter(int id, const Vector3D& position, double radius, std::shared_ptr<PhysicsEngineMaterialAdapter> material) const override; - void runTimestep(double step) override; - -}; - -#endif - diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/dummy/package.include b/src/cpu/DemCoupling/physicsEngineAdapter/dummy/package.include deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/package.include b/src/cpu/DemCoupling/physicsEngineAdapter/package.include deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/CMakePackage.txt b/src/cpu/DemCoupling/physicsEngineAdapter/pe/CMakePackage.txt deleted file mode 100644 index 1b8416f01..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/CMakePackage.txt +++ /dev/null @@ -1,2 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeAdapter.h deleted file mode 100644 index 6f0416685..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeAdapter.h +++ /dev/null @@ -1,28 +0,0 @@ -/* -* Author: S. Peters -* mail: peters@irmb.tu-bs.de -*/ -#ifndef PE_ADAPTER_H -#define PE_ADAPTER_H - -#include <pe/basic.h> -#include "Vector3D.h" - - -class PeConverter -{ -public: - static Vector3D convert(walberla::pe::Vec3 vec3) - { - return Vector3D(vec3[0], vec3[1], vec3[2]); - } - - static walberla::pe::Vec3 convert(const Vector3D& vec3) - { - return walberla::pe::Vec3(vec3[0], vec3[1], vec3[2]); - } -}; - - -#endif - diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeAdapterTest.cpp b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeAdapterTest.cpp deleted file mode 100644 index 1deffe629..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeAdapterTest.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//#include "gmock/gmock.h" -// -//#include "PeAdapter.h" -//#include <pe/basic.h> -// -//#include "UbTuple.h" -// -// -//TEST(PeAdapterTest, convert_WalberlaVec3_to_Vector3D) -//{ -// walberla::pe::Vec3 walberlaVec(1.0, -2.0, 3.4); -// Vector3D ubTuple = PeConverter::convert(walberlaVec); -// -// EXPECT_THAT(ubTuple[0], testing::DoubleEq(walberlaVec[0])); -// EXPECT_THAT(ubTuple[1], testing::DoubleEq(walberlaVec[1])); -// EXPECT_THAT(ubTuple[2], testing::DoubleEq(walberlaVec[2])); -//} -// -//TEST(PeAdapterTest, convert_Vector3D_to_WalberlaVec3) -//{ -// Vector3D ubTuple(1.0, -2.0, 3.4); -// walberla::pe::Vec3 walberlaVec = PeConverter::convert(ubTuple); -// -// EXPECT_THAT(ubTuple[0], testing::DoubleEq(walberlaVec[0])); -// EXPECT_THAT(ubTuple[1], testing::DoubleEq(walberlaVec[1])); -// EXPECT_THAT(ubTuple[2], testing::DoubleEq(walberlaVec[2])); -//} - diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeLoadBalancerAdapter.cpp b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeLoadBalancerAdapter.cpp deleted file mode 100644 index 75d2c2850..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeLoadBalancerAdapter.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "PeLoadBalancerAdapter.h" -#include "Grid3D.h" -#include "Block3D.h" -#include "CoordinateTransformation3D.h" -#include "UbLogger.h" - -#include "core/debug/CheckFunctions.h" - - -PeLoadBalancerAdapter::PeLoadBalancerAdapter(SPtr<Grid3D> grid, unsigned numberOfProcesses, int rank) : grid(grid), numberOfProcesses(numberOfProcesses), rank(rank) -{ - -} - -walberla::uint_t PeLoadBalancerAdapter::operator()(walberla::SetupBlockForest & forest, const walberla::uint_t numberOfProcesses, const walberla::memory_t perProcessMemoryLimit) -{ - std::vector< walberla::SetupBlock * > peBlocks; - forest.getBlocks(peBlocks); - - for (auto peBlock = peBlocks.begin(); peBlock != peBlocks.end(); ++peBlock) - { - walberla::AABB aabb = (*peBlock)->getAABB(); - SPtr<Block3D> block = getBlockByMinUniform(aabb.xMin()+0.5*(aabb.xMax()-aabb.xMin()), aabb.yMin()+0.5*(aabb.yMax()-aabb.yMin()), aabb.zMin()+0.5*(aabb.zMax()-aabb.zMin()), grid); - if (block) - { - (*peBlock)->assignTargetProcess((walberla::uint_t)block->getRank()); - } - else - { - //TODO: the rank of pe blocks is not consistent with VF blocks - (*peBlock)->assignTargetProcess(0); - //UBLOG(logINFO, "PeLoadBalancerAdapter::operator() peBlockId="<<(*peBlock)->getId()); - } - } - - return numberOfProcesses; -} - -SPtr<Block3D> PeLoadBalancerAdapter::getBlockByMinUniform(double minX1, double minX2, double minX3, SPtr<Grid3D> grid) -{ - SPtr<CoordinateTransformation3D> trafo = grid->getCoordinateTransformator(); - - int ix1 = (int)trafo->transformForwardToX1Coordinate(minX1, minX2, minX3); - int ix2 = (int)trafo->transformForwardToX2Coordinate(minX1, minX2, minX3); - int ix3 = (int)trafo->transformForwardToX3Coordinate(minX1, minX2, minX3); - - return grid->getBlock(ix1, ix2, ix3, 0); -} diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeLoadBalancerAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeLoadBalancerAdapter.h deleted file mode 100644 index 6b904d994..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PeLoadBalancerAdapter.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef PeLoadBalancerAdapter_h__ -#define PeLoadBalancerAdapter_h__ - -#include "blockforest/SetupBlockForest.h" -#include "PointerDefinitions.h" - -class Grid3D; -class Block3D; - -class PeLoadBalancerAdapter -{ -public: - PeLoadBalancerAdapter(SPtr<Grid3D> grid, unsigned numberOfProcesses, int rank); - walberla::uint_t operator()( walberla::SetupBlockForest & forest, const walberla::uint_t numberOfProcesses, const walberla::memory_t perProcessMemoryLimit ); - unsigned getNumberOfProcesses() const { return numberOfProcesses; } - int getRank() const { return rank; } -protected: - SPtr<Block3D> getBlockByMinUniform(double minX1, double minX2, double minX3, SPtr<Grid3D> grid); -private: - SPtr<Grid3D> grid; - unsigned numberOfProcesses; - int rank; -}; - -#endif // PeLoadBalancerAdapter_h__ \ No newline at end of file diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.cpp b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.cpp deleted file mode 100644 index a044a6ea2..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.cpp +++ /dev/null @@ -1,131 +0,0 @@ -#include "PePhysicsEngineGeometryAdapter.h" - -#include <pe/basic.h> - -#include "PeAdapter.h" - - -//PePhysicsEngineGeometryAdapter::PePhysicsEngineGeometryAdapter(walberla::pe::RigidBody* peGeoObject) : peGeoObject(peGeoObject) -//{ -// this->id = peGeoObject->getID(); -// this->active = true; -//} - -PePhysicsEngineGeometryAdapter::PePhysicsEngineGeometryAdapter() -{ - this->id = -999; - this->systemID = -999; - this->active = false; - this->semiactive = false; - shadowCounter = 0; - counter = 0; -} - -void PePhysicsEngineGeometryAdapter::addForce(const Vector3D& force) -{ - peGeoObject->addForce(PeConverter::convert(force)); -} - -void PePhysicsEngineGeometryAdapter::addTorque(const Vector3D& torque) -{ - peGeoObject->addTorque(PeConverter::convert(torque)); -} - -void PePhysicsEngineGeometryAdapter::setForce(const Vector3D& force) -{ - peGeoObject->setForce(PeConverter::convert(force)); -} - -void PePhysicsEngineGeometryAdapter::setTorque(const Vector3D& torque) -{ - peGeoObject->setTorque(PeConverter::convert(torque)); -} - -void PePhysicsEngineGeometryAdapter::addForceAtPosition(const Vector3D& force, const Vector3D& position) -{ - peGeoObject->addForceAtPos(PeConverter::convert(force), PeConverter::convert(position)); -} - -void PePhysicsEngineGeometryAdapter::setLinearVelolocity(const Vector3D& velocity) -{ - peGeoObject->setLinearVel(PeConverter::convert(velocity)); -} - -void PePhysicsEngineGeometryAdapter::setAngularVelocity(const Vector3D& velocity) -{ - peGeoObject->setAngularVel(PeConverter::convert(velocity)); -} - -void PePhysicsEngineGeometryAdapter::resetForceAndTorque() -{ - peGeoObject->resetForceAndTorque(); -} - -Vector3D PePhysicsEngineGeometryAdapter::getVelocityAtPosition(const Vector3D& position) const -{ - return PeConverter::convert(peGeoObject->velFromWF(PeConverter::convert(position))); -} - -Vector3D PePhysicsEngineGeometryAdapter::getLinearVelocity() const -{ - return PeConverter::convert(peGeoObject->getLinearVel()); -} - -Vector3D PePhysicsEngineGeometryAdapter::getAngularVelocity() const -{ - return PeConverter::convert(peGeoObject->getAngularVel()); -} - -Vector3D PePhysicsEngineGeometryAdapter::getPosition() const -{ - return PeConverter::convert(peGeoObject->getPosition()); -} - -Vector3D PePhysicsEngineGeometryAdapter::getForce() const -{ - return PeConverter::convert(peGeoObject->getForce()); -} - -Vector3D PePhysicsEngineGeometryAdapter::getTorque() const -{ - return PeConverter::convert(peGeoObject->getTorque()); -} - -void PePhysicsEngineGeometryAdapter::changeState(State state) -{ - if (state == State::PIN) - peGeoObject->setMassAndInertiaToInfinity(); -} - -int PePhysicsEngineGeometryAdapter::getId() const -{ - return id; -} - -void PePhysicsEngineGeometryAdapter::setId(int id) -{ - this->id = id; -} - -void PePhysicsEngineGeometryAdapter::setGeometry(walberla::pe::RigidBody* peGeoObject) -{ - this->peGeoObject = peGeoObject; -} - -////////////////////////////////////////////////////////////////////////// -void PePhysicsEngineGeometryAdapter::setActive() -{ - active = true; -} -////////////////////////////////////////////////////////////////////////// -void PePhysicsEngineGeometryAdapter::setInactive() -{ - active = false; -} -////////////////////////////////////////////////////////////////////////// -bool PePhysicsEngineGeometryAdapter::isActive() -{ - - - return active; -} diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.h deleted file mode 100644 index 13c830a41..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineGeometryAdapter.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -* Author: S. Peters -* mail: peters@irmb.tu-bs.de -*/ -#ifndef PE_PHYSICS_ENGINE_GEOMETRY_ADAPTER_H -#define PE_PHYSICS_ENGINE_GEOMETRY_ADAPTER_H - - -#include "PhysicsEngineGeometryAdapter.h" -#include <core/DataTypes.h> - -namespace walberla -{ - namespace pe - { - class RigidBody; - } -} - -class PePhysicsEngineGeometryAdapter : public PhysicsEngineGeometryAdapter -{ -public: - PePhysicsEngineGeometryAdapter(); - //PePhysicsEngineGeometryAdapter(walberla::pe::RigidBody* peGeoObject); - virtual ~PePhysicsEngineGeometryAdapter() {} - - void addForce(const Vector3D& force) override; - void addTorque(const Vector3D& torque) override; - - void setForce(const Vector3D& force) override; - void setTorque(const Vector3D& torque) override; - - void addForceAtPosition(const Vector3D& force, const Vector3D& position) override; - void setLinearVelolocity(const Vector3D& velocity) override; - void setAngularVelocity(const Vector3D& velocity) override; - - void resetForceAndTorque() override; - - Vector3D getVelocityAtPosition(const Vector3D& position) const override; - Vector3D getLinearVelocity() const override; - Vector3D getAngularVelocity() const override; - Vector3D getPosition() const override; - Vector3D getForce() const override; - Vector3D getTorque() const override; - - void changeState(State state) override; - - int getId() const; - void setId(int id); - void setGeometry(walberla::pe::RigidBody* peGeoObject); - - void setActive(); - void setInactive(); - bool isActive(); - //void increaseShadowCounter(); - //void decreaseShad - int shadowCounter; - int counter; - - unsigned long long getSystemID() const { return systemID; } - void setSystemID(unsigned long long val) { systemID = val; } - bool getSemiactive() const { return semiactive; } - void setSemiactive(bool val) { semiactive = val; } -private: - walberla::pe::RigidBody* peGeoObject; - //unsigned long long id; - int id; - //walberla::id_t systemId; - unsigned long long systemID; - bool active; - bool semiactive; -}; - -#endif - diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.cpp b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.cpp deleted file mode 100644 index fcd4e6eee..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "PePhysicsEngineMaterialAdapter.h" - - -walberla::pe::MaterialID PePhysicsEngineMaterialAdapter::getPeMaterial() const -{ - if (walberla::pe::Material::find(name) != -1) - return walberla::pe::Material::find(name); - - return walberla::pe::createMaterial(name, density, restitution, staticFriction, dynamicFriction, poissonRatio, youngModul, stiffnessInNormalDirection, dampingoefficientNormalDirection, dampingTangentialDirection); -} diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.h deleted file mode 100644 index b99afaa38..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineMaterialAdapter.h +++ /dev/null @@ -1,26 +0,0 @@ -/* -* Author: S. Peters -* mail: peters@irmb.tu-bs.de -*/ -#ifndef PE_PHYSICS_ENGINE_MATERIAL_ADAPTER -#define PE_PHYSICS_ENGINE_MATERIAL_ADAPTER - -#include "../PhysicsEngineMaterialAdapter.h" -#include <pe/basic.h> - - -class PePhysicsEngineMaterialAdapter : public PhysicsEngineMaterialAdapter -{ -public: - PePhysicsEngineMaterialAdapter(std::string name, double density, double restitution, double staticFriction, double dynamicFriction, double poissonRatio, double youngModul, double stiffnessInNormalDirection, double dampingoefficientNormalDirection, double dampingTangentialDirection) - : PhysicsEngineMaterialAdapter(name, density, restitution, staticFriction, dynamicFriction, poissonRatio, youngModul, stiffnessInNormalDirection, dampingoefficientNormalDirection, dampingTangentialDirection) - { - } - virtual ~PePhysicsEngineMaterialAdapter() {} - - virtual walberla::pe::MaterialID getPeMaterial() const; - -}; - -#endif - diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.cpp b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.cpp deleted file mode 100644 index 9aa16a081..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.cpp +++ /dev/null @@ -1,225 +0,0 @@ -#include "PePhysicsEngineSolverAdapter.h" - -#include <exception> - -#include <pe/basic.h> -#include <pe/rigidbody/UnionFactory.h> -#include "pe/rigidbody/BoxFactory.h" -#include "pe/rigidbody/SphereFactory.h" -#include "pe/rigidbody/PlaneFactory.h" -//#include "geometry/GeometricalFunctions.h" -#include "PeAdapter.h" -#include "PePhysicsEngineGeometryAdapter.h" -#include "PePhysicsEngineMaterialAdapter.h" -#include "PeLoadBalancerAdapter.h" -#include "Communicator.h" -#include "UbLogger.h" -#include <boost/tuple/tuple.hpp> -#include "UbException.h" -#include "UbSystem.h" -#include <memory> - -using namespace walberla; -using namespace walberla::pe; - -typedef boost::tuple<walberla::pe::Box, walberla::pe::Sphere, walberla::pe::Plane> BodyTypeTuple; - -PePhysicsEngineSolverAdapter::PePhysicsEngineSolverAdapter(std::shared_ptr<PeParameter> peParameter, std::shared_ptr<PeLoadBalancerAdapter> loadBalancer) : peParameter(peParameter), loadBalancer(loadBalancer) -{ - this->initalizePeEnvironment(); -} - -void PePhysicsEngineSolverAdapter::initalizePeEnvironment() -{ - this->initialPeBodyStorage(); - this->initialPeBlockForest(); - this->initalBlockData(); - this->initalPeIntegrator(); - this->executePeBodyTypeTuple(); - this->initialPeChannel(); -} - - -std::shared_ptr<PhysicsEngineGeometryAdapter> PePhysicsEngineSolverAdapter::createPhysicsEngineGeometryAdapter(int id, const Vector3D& position, double radius, std::shared_ptr<PhysicsEngineMaterialAdapter> material) const -{ - const std::shared_ptr<PePhysicsEngineMaterialAdapter> peMaterial = std::dynamic_pointer_cast<PePhysicsEngineMaterialAdapter>(material); - std::shared_ptr<PePhysicsEngineGeometryAdapter> peGeometryAdapter(new PePhysicsEngineGeometryAdapter()); - - //UBLOG(logINFO, "PePhysicsEngineSolverAdapter::createSphere():start"); - walberla::pe::GeomID peGeometry = createSphere(*globalBodyStorage, *forest, *storageId, id, PeConverter::convert(position), radius, peMaterial->getPeMaterial()); - //UBLOG(logINFO, "PePhysicsEngineSolverAdapter::createSphere():end"); - - if (peGeometry) - { - peGeometryAdapter->setId(id); - peGeometryAdapter->setSystemID(peGeometry->getSystemID()); - peGeometryAdapter->setActive(); - peGeometryAdapter->setGeometry(peGeometry); - return peGeometryAdapter; - } - else - { - peGeometryAdapter->setId(id); - peGeometryAdapter->setInactive(); - return peGeometryAdapter; - } - - walberla::pe::syncNextNeighbors<BodyTypeTuple>(*forest, *storageId); -} - -void PePhysicsEngineSolverAdapter::runTimestep(double step) -{ - cr->timestep(walberla::real_c(step)); - walberla::pe::syncNextNeighbors<BodyTypeTuple>(*forest, *storageId); -} - - - -void PePhysicsEngineSolverAdapter::initialPeBodyStorage() -{ - globalBodyStorage = std::make_shared<walberla::pe::BodyStorage>(); -} - -void PePhysicsEngineSolverAdapter::initialPeBlockForest() -{ - - //walberla::SetupBlockForest sforest = walberla::blockforest::createUniformBlockGrid(walberla::AABB(peParameter->simulationDomain[0], peParameter->simulationDomain[1], peParameter->simulationDomain[2], - // peParameter->simulationDomain[3], peParameter->simulationDomain[4], peParameter->simulationDomain[5]), // simulationDomain - // walberla::uint_t(val<1>(peParameter->numberOfBlocks)), walberla::uint_t(val<2>(peParameter->numberOfBlocks)), walberla::uint_t(val<3>(peParameter->numberOfBlocks)),walberla::uint_t(10),walberla::uint_t(10),walberla::uint_t(10), 5.0,false); - walberla::SetupBlockForest sforest; - //sforest.addWorkloadMemorySUIDAssignmentFunction( uniformWorkloadAndMemoryAssignment ); - sforest.init(walberla::AABB(peParameter->simulationDomain[0], peParameter->simulationDomain[1], peParameter->simulationDomain[2], - peParameter->simulationDomain[3], peParameter->simulationDomain[4], peParameter->simulationDomain[5]), // simulationDomain - walberla::uint_t(val<1>(peParameter->numberOfBlocks)), walberla::uint_t(val<2>(peParameter->numberOfBlocks)), walberla::uint_t(val<3>(peParameter->numberOfBlocks)), // blocks in each direction - val<1>(peParameter->isPeriodic), val<2>(peParameter->isPeriodic), val<3>(peParameter->isPeriodic)); - sforest.balanceLoad(*loadBalancer.get(), loadBalancer->getNumberOfProcesses()); - forest = std::shared_ptr< walberla::blockforest::BlockForest >( new walberla::blockforest::BlockForest( walberla::uint_c( loadBalancer->getRank() ), sforest) ); - - auto mpiManager = walberla::MPIManager::instance(); - mpiManager->useWorldComm(); - if (!forest) - throw std::runtime_error("No PE BlockForest created ... "); -} - -void PePhysicsEngineSolverAdapter::initalBlockData() -{ - storageId = std::make_shared<walberla::domain_decomposition::BlockDataID> - ( - forest->addBlockData(walberla::pe::createStorageDataHandling<BodyTypeTuple>(), "Storage") - ); -} - -void PePhysicsEngineSolverAdapter::initalPeIntegrator() -{ - auto ccdID = forest->addBlockData(walberla::pe::ccd::createHashGridsDataHandling(globalBodyStorage, *storageId), "CCD"); - auto fcdID = forest->addBlockData(walberla::pe::fcd::createGenericFCDDataHandling<BodyTypeTuple, walberla::pe::fcd::AnalyticCollideFunctor>(), "FCD"); - - cr = std::make_shared<walberla::pe::cr::HardContactSemiImplicitTimesteppingSolvers>(globalBodyStorage, forest, *storageId, ccdID, fcdID); - cr->setMaxIterations(peParameter->maxPeIterations); - cr->setRelaxationModel(walberla::pe::cr::HardContactSemiImplicitTimesteppingSolvers::ApproximateInelasticCoulombContactByDecoupling); - cr->setRelaxationParameter(walberla::real_t(peParameter->relaxationParameter)); - cr->setGlobalLinearAcceleration(PeConverter::convert(peParameter->globalLinearAcceleration)); -} - -void PePhysicsEngineSolverAdapter::executePeBodyTypeTuple() -{ - walberla::pe::SetBodyTypeIDs<BodyTypeTuple>::execute(); -} - -void PePhysicsEngineSolverAdapter::initialPeChannel() const -{ - const walberla::pe::MaterialID material = peParameter->planes->getPeMaterial(); - - auto simulationDomain = forest->getDomain(); - - //createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(1, 0, 0), simulationDomain.minCorner(), material); - //createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(-1, 0, 0), simulationDomain.maxCorner(), material); - //createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(0, 1, 0), simulationDomain.minCorner(), material); - //createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(0, -1, 0), simulationDomain.maxCorner(), material); - //createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(0, 0, 1), simulationDomain.minCorner(), material); - //createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(0, 0, -1), simulationDomain.maxCorner(), material); - - Vector3D minOffset = peParameter->minOffset; - Vector3D maxOffset = peParameter->maxOffset; - - walberla::pe::Vec3 minX1_Offset( minOffset.X1(), 0, 0); - walberla::pe::Vec3 maxX1_Offset( maxOffset.X1(), 0, 0); - walberla::pe::Vec3 minX2_Offset( 0, minOffset.X2(), 0); - walberla::pe::Vec3 maxX2_Offset( 0, maxOffset.X2(), 0); - walberla::pe::Vec3 minX3_Offset( 0, 0, minOffset.X3()); - walberla::pe::Vec3 maxX3_Offset( 0, 0, maxOffset.X3()); - - walberla::pe::Vec3 minCorner = simulationDomain.minCorner(); - walberla::pe::Vec3 maxCorner = simulationDomain.maxCorner(); - - createPlane(*globalBodyStorage, 0, walberla::pe::Vec3( 1, 0, 0), minCorner + minX1_Offset, material); - createPlane(*globalBodyStorage, 0, walberla::pe::Vec3(-1, 0, 0), maxCorner + maxX1_Offset, material); - createPlane(*globalBodyStorage, 0, walberla::pe::Vec3( 0, 1, 0), minCorner + minX2_Offset, material); - createPlane(*globalBodyStorage, 0, walberla::pe::Vec3( 0,-1, 0), maxCorner + maxX2_Offset, material); - createPlane(*globalBodyStorage, 0, walberla::pe::Vec3( 0, 0, 1), minCorner + minX3_Offset, material); - createPlane(*globalBodyStorage, 0, walberla::pe::Vec3( 0, 0,-1), maxCorner + maxX3_Offset, material); -} - -std::shared_ptr< walberla::blockforest::BlockForest > PePhysicsEngineSolverAdapter::getForest() -{ - return forest; -} - -void PePhysicsEngineSolverAdapter::saveToFile(const std::string & path) -{ - forest->saveToFile(path+"SerializeDeserialize.sbf"); - forest->saveBlockData("SerializeDeserialize.dump", *storageId.get()); -} - -void PePhysicsEngineSolverAdapter::loadFromFile(const std::string & path) -{ - //forest = std::make_shared< walberla::blockforest::BlockForest >( walberla::uint_c( walberla::MPIManager::instance()->rank() ), path+"SerializeDeserialize.sbf", true, false ); - std::string file = path+"SerializeDeserialize.sbf"; - forest = std::shared_ptr < walberla::blockforest::BlockForest > (new walberla::blockforest::BlockForest( walberla::uint_c( walberla::MPIManager::instance()->rank() ), file.c_str(), true, false )); - storageId = std::make_shared< walberla::domain_decomposition::BlockDataID >(forest->loadBlockData(path+"SerializeDeserialize.dump", walberla::pe::createStorageDataHandling<BodyTypeTuple>(), "Storage")); - - this->initalPeIntegrator(); - - auto ccdID = forest->addBlockData(walberla::pe::ccd::createHashGridsDataHandling(globalBodyStorage, *storageId), "CCD"); - auto fcdID = forest->addBlockData(walberla::pe::fcd::createGenericFCDDataHandling<BodyTypeTuple, walberla::pe::fcd::AnalyticCollideFunctor>(), "FCD"); - - cr = std::make_shared<walberla::pe::cr::HardContactSemiImplicitTimesteppingSolvers>(globalBodyStorage, forest, *storageId, ccdID, fcdID); - cr->setMaxIterations(peParameter->maxPeIterations); - cr->setRelaxationModel(walberla::pe::cr::HardContactSemiImplicitTimesteppingSolvers::ApproximateInelasticCoulombContactByDecoupling); - cr->setRelaxationParameter(walberla::real_t(peParameter->relaxationParameter)); - cr->setGlobalLinearAcceleration(PeConverter::convert(peParameter->globalLinearAcceleration)); - - this->executePeBodyTypeTuple(); - this->initialPeChannel(); - - for (auto blockIt = forest->begin(); blockIt != forest->end(); ++blockIt) - { - walberla::pe::ccd::ICCD* ccd = blockIt->getData< walberla::pe::ccd::ICCD >(ccdID); - ccd->reloadBodies(); - } -} - -std::shared_ptr<walberla::blockforest::BlockForest> PePhysicsEngineSolverAdapter::getBlockForest() -{ - return forest; -} - -std::shared_ptr<walberla::domain_decomposition::BlockDataID> PePhysicsEngineSolverAdapter::getStorageId() -{ - return storageId; -} - -std::shared_ptr<walberla::pe::BodyStorage> PePhysicsEngineSolverAdapter::getGlobalBodyStorage() -{ - return globalBodyStorage; -} - -void PePhysicsEngineSolverAdapter::createObstacle(const Vector3D & center, const Vector3D & lengths) -{ - const walberla::pe::MaterialID material = peParameter->planes->getPeMaterial(); - bool global = true; - bool communicating = false; - bool infiniteMass = true; - - walberla::pe::createBox(*globalBodyStorage, *forest, *storageId, 0, PeConverter::convert(center), PeConverter::convert(lengths), material, global, communicating, infiniteMass); -} diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.h b/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.h deleted file mode 100644 index b1274ce3a..000000000 --- a/src/cpu/DemCoupling/physicsEngineAdapter/pe/PePhysicsEngineSolverAdapter.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -* Author: S. Peters -* mail: peters@irmb.tu-bs.de -*/ -#ifndef PE_PHYSICS_ENGINE_SOLVER_ADAPTER_H -#define PE_PHYSICS_ENGINE_SOLVER_ADAPTER_H - -#include <memory> -#include <shared_mutex> - -#include <pe/basic.h> -#include "UbTuple.h" - -#include "PhysicsEngineSolverAdapter.h" -#include "PePhysicsEngineSolverAdapter.h" - - -class PePhysicsEngineMaterialAdapter; -class PhysicsEngineGeometryAdapter; -class PePhysicsEngineGeometryAdapter; -class PeLoadBalancerAdapter; - -namespace walberla -{ - namespace domain_decomposition - { - class BlockDataID; - } - namespace blockforest - { - class BlockForest; - } - namespace pe - { - class BodyStorage; - class RigidBody; - namespace cr - { - class HardContactSemiImplicitTimesteppingSolvers; - } - } -} - -struct PeParameter -{ - PeParameter(double relaxationParameter, int maxPeIterations, Vector3D globalLinearAcceleration, std::shared_ptr<PePhysicsEngineMaterialAdapter> planes, std::array<double, 6> simulationDomain, UbTupleInt3 numberOfBlocks, UbTupleBool3 isPeriodic, Vector3D minOffset, Vector3D maxOffset) - : relaxationParameter(relaxationParameter), maxPeIterations(maxPeIterations), globalLinearAcceleration(globalLinearAcceleration), simulationDomain(simulationDomain), numberOfBlocks(numberOfBlocks), isPeriodic(isPeriodic), planes(planes), minOffset(minOffset), maxOffset(maxOffset) - { - } - - double relaxationParameter; - int maxPeIterations; - Vector3D globalLinearAcceleration; - - std::array<double, 6> simulationDomain; - UbTupleInt3 numberOfBlocks; - UbTupleBool3 isPeriodic; - - std::shared_ptr<PePhysicsEngineMaterialAdapter> planes; - - Vector3D minOffset; - Vector3D maxOffset; - -}; - -class PePhysicsEngineSolverAdapter : public PhysicsEngineSolverAdapter -{ -public: - PePhysicsEngineSolverAdapter(std::shared_ptr<PeParameter> peParameter, std::shared_ptr<PeLoadBalancerAdapter> loadBalancer); - virtual ~PePhysicsEngineSolverAdapter() {} - - std::shared_ptr<PhysicsEngineGeometryAdapter> createPhysicsEngineGeometryAdapter(int id, const Vector3D& position, double radius, std::shared_ptr<PhysicsEngineMaterialAdapter> material) const override; - void runTimestep(double step) override; - std::shared_ptr< walberla::blockforest::BlockForest > getForest(); - void saveToFile(const std::string& path); - void loadFromFile(const std::string& path); - std::shared_ptr<walberla::blockforest::BlockForest> getBlockForest(); - std::shared_ptr<walberla::domain_decomposition::BlockDataID> getStorageId(); - std::shared_ptr<walberla::pe::BodyStorage> getGlobalBodyStorage(); - void createObstacle(const Vector3D& center, const Vector3D& lengths); - -private: - void initalizePeEnvironment(); - void initialPeBodyStorage(); - void initialPeBlockForest(); - void initalBlockData(); - - void initalPeIntegrator(); - static void executePeBodyTypeTuple(); - void initialPeChannel() const; - -private: - std::shared_ptr<PeParameter> peParameter; - std::shared_ptr<PeLoadBalancerAdapter> loadBalancer; - - std::shared_ptr<walberla::pe::BodyStorage> globalBodyStorage; - std::shared_ptr< walberla::blockforest::BlockForest > forest; - std::shared_ptr<walberla::domain_decomposition::BlockDataID> storageId; - std::shared_ptr<walberla::pe::cr::HardContactSemiImplicitTimesteppingSolvers> cr; -}; - -#endif - diff --git a/src/cpu/DemCoupling/physicsEngineAdapter/pe/package.include b/src/cpu/DemCoupling/physicsEngineAdapter/pe/package.include deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/cpu/DemCoupling/reconstructor/CMakePackage.txt b/src/cpu/DemCoupling/reconstructor/CMakePackage.txt deleted file mode 100644 index 1b8416f01..000000000 --- a/src/cpu/DemCoupling/reconstructor/CMakePackage.txt +++ /dev/null @@ -1,2 +0,0 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) diff --git a/src/cpu/DemCoupling/reconstructor/EquilibriumReconstructor.cpp b/src/cpu/DemCoupling/reconstructor/EquilibriumReconstructor.cpp deleted file mode 100644 index ad4db58f1..000000000 --- a/src/cpu/DemCoupling/reconstructor/EquilibriumReconstructor.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "EquilibriumReconstructor.h" - -#include "ILBMKernel.h" -#include "D3Q27System.h" -#include "DataSet3D.h" -#include "BCProcessor.h" -#include "BCArray3D.h" - -#include "PhysicsEngineGeometryAdapter.h" - -void EquilibriumReconstructor::reconstructNode(const int& x1, const int& x2, const int& x3, - const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, std::shared_ptr<ILBMKernel> kernel) const -{ - const double averageDensity = this->getLocalAverageDensity(x1, x2, x3, kernel); - LBMReal feq[27]; - const Vector3D boundaryVelocity = physicsEngineGeometry->getVelocityAtPosition(worldCoordinates); - - if (kernel->getCompressible()) - D3Q27System::calcCompFeq(feq, averageDensity, boundaryVelocity[0], boundaryVelocity[1], boundaryVelocity[2]); - else - D3Q27System::calcIncompFeq(feq, averageDensity, boundaryVelocity[0], boundaryVelocity[1], boundaryVelocity[2]); - - - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - //distributions->setDistribution(feq, x1, x2, x3); - distributions->setDistributionInv(feq, x1, x2, x3); -} - - -double EquilibriumReconstructor::getLocalAverageDensity(const int &x1, const int &x2, const int &x3, std::shared_ptr<ILBMKernel> kernel) const -{ - int nAverage = 0; - double averageDensity = 0.0; - - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - - LBMReal f[D3Q27System::ENDF + 1]; - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - - int neighborX1, neighborX2, neighborX3; - for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++) - { - neighborX1 = x1 + D3Q27System::DX1[fDir]; - neighborX2 = x2 + D3Q27System::DX2[fDir]; - neighborX3 = x3 + D3Q27System::DX3[fDir]; - - if (bcArray->isFluid(neighborX1, neighborX2, neighborX3)) - { - distributions->getDistribution(f, neighborX1, neighborX2, neighborX3); - averageDensity += D3Q27System::getDensity(f); - ++nAverage; - } - } - return (nAverage > 0) ? averageDensity / nAverage : 0.0; -} - diff --git a/src/cpu/DemCoupling/reconstructor/EquilibriumReconstructor.h b/src/cpu/DemCoupling/reconstructor/EquilibriumReconstructor.h deleted file mode 100644 index e75297ddb..000000000 --- a/src/cpu/DemCoupling/reconstructor/EquilibriumReconstructor.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -* Author: S. Peters -* mail: peters@irmb.tu-bs.de -*/ -#ifndef EQUILIBRIUM_RECONSTRUCTOR_H -#define EQUILIBRIUM_RECONSTRUCTOR_H - -#include "UbTuple.h" - -#include "Reconstructor.h" - -class ILBMKernel; -class PhysicsEngineGeometryAdapter; - -class EquilibriumReconstructor : public Reconstructor -{ -public: - virtual ~EquilibriumReconstructor() {} - - void reconstructNode(const int &x1, const int &x2, const int &x3, const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, std::shared_ptr<ILBMKernel> kernel) const override; - -private: - double getLocalAverageDensity(const int &x1, const int &x2, const int &x3, std::shared_ptr<ILBMKernel> kernel) const; -}; - - - -#endif - diff --git a/src/cpu/DemCoupling/reconstructor/ExtrapolationReconstructor.cpp b/src/cpu/DemCoupling/reconstructor/ExtrapolationReconstructor.cpp deleted file mode 100644 index 72cc555a6..000000000 --- a/src/cpu/DemCoupling/reconstructor/ExtrapolationReconstructor.cpp +++ /dev/null @@ -1,120 +0,0 @@ -#include "ExtrapolationReconstructor.h" - -#include "ILBMKernel.h" -#include "D3Q27System.h" -#include "DataSet3D.h" -#include "BCProcessor.h" -#include "BCArray3D.h" - -#include "PhysicsEngineGeometryAdapter.h" -#include "DistributionArray3D.h" - -void ExtrapolationReconstructor::setAlternativeReconstructor(std::shared_ptr<Reconstructor> alternativeReconstructor) -{ - this->alternativeReconstructor = alternativeReconstructor; -} - - -ExtrapolationReconstructor::ExtrapolationReconstructor(std::shared_ptr<Reconstructor> alternativeReconstructor) : alternativeReconstructor(alternativeReconstructor) -{ -} - -void ExtrapolationReconstructor::reconstructNode(const int& x1, const int& x2, const int& x3, - const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, std::shared_ptr<ILBMKernel> kernel) const -{ - const UbTupleInt3 extrapolationDirection = getSphereDirection(worldCoordinates, physicsEngineGeometry); - const int numberOfCellsForExtrapolation = getNumberOfExtrapolationCells(x1, x2, x3, extrapolationDirection, kernel); - - //if (numberOfCellsForExtrapolation < 2) - alternativeReconstructor->reconstructNode(x1, x2, x3, worldCoordinates, physicsEngineGeometry, kernel); - //else - //{ - // //UBLOG(logINFO, "point (x,y,z) " << val<1>(worldCoordinates) << ", " << val<2>(worldCoordinates) << ", " << val<3>(worldCoordinates)); - // //UBLOG(logINFO, "extradir (x,y,z) " << val<1>(extrapolationDirection) << ", " << val<2>(extrapolationDirection) << ", " << val<3>(extrapolationDirection)); - // //UBLOG(logINFO, "numberOfCellsForExtrapolation: " << numberOfCellsForExtrapolation ); - - // this->extrapolatePdFs(x1, x2, x3, extrapolationDirection, numberOfCellsForExtrapolation, kernel); - //} - -} - -UbTupleInt3 ExtrapolationReconstructor::getSphereDirection(const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry) const -{ - const Vector3D spherePosition = physicsEngineGeometry->getPosition(); - const Vector3D bodyNormal = worldCoordinates - spherePosition; - return this->getCorrespondingLatticeDirection(bodyNormal); -} - -UbTupleInt3 ExtrapolationReconstructor::getCorrespondingLatticeDirection(const Vector3D& direction) const -{ - int correspondingDirection = 0; - double innerProduct = 0.0; - for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++) - { - // compute inner product <dir,c_i> - const double temporaryInnerProduct = direction[0] * D3Q27System::cNorm[0][fDir] + direction[1] * D3Q27System::cNorm[1][fDir] + direction[2] * D3Q27System::cNorm[2][fDir]; - if (temporaryInnerProduct > innerProduct) - { - innerProduct = temporaryInnerProduct; - correspondingDirection = fDir; - } - } - - return UbTupleInt3(D3Q27System::DX1[correspondingDirection], D3Q27System::DX2[correspondingDirection], D3Q27System::DX3[correspondingDirection]); -} - -int ExtrapolationReconstructor::getNumberOfExtrapolationCells(const int x1, const int x2, const int x3, const UbTupleInt3& extrapolationDirection, std::shared_ptr<ILBMKernel> kernel) const -{ - if (extrapolationDirection == UbTupleInt3(0, 0, 0)) - return 0; - - const int desiredCellsInExtrapolationDirection = 3; - - for (int numCells = 1; numCells <= desiredCellsInExtrapolationDirection; ++numCells) - { - UbTupleInt3 neighbor(x1 + numCells * val<1>(extrapolationDirection), x2 + numCells * val<2>(extrapolationDirection), x3 + numCells * val<3>(extrapolationDirection)); - - if(!kernel->isInsideOfDomain(val<1>(neighbor), val<2>(neighbor), val<3>(neighbor))) - return numCells - 1; - - - if (!kernel->getBCProcessor()->getBCArray()->isFluid(val<1>(neighbor), val<2>(neighbor), val<3>(neighbor))) - return numCells - 1; - } - return desiredCellsInExtrapolationDirection; -} - - -void ExtrapolationReconstructor::extrapolatePdFs(const int x1, const int x2, const int x3, - const UbTupleInt3& extrapolationDirection, int numberOfCellsForExtrapolation, std::shared_ptr<ILBMKernel> kernel) const -{ - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - - const int nx1 = val<1>(extrapolationDirection); - const int nx2 = val<2>(extrapolationDirection); - const int nx3 = val<3>(extrapolationDirection); - - LBMReal pdf[D3Q27System::ENDF + 1]; - LBMReal pdfNeighbor1[D3Q27System::ENDF + 1]; - LBMReal pdfNeighbor2[D3Q27System::ENDF + 1]; - - distributions->getDistribution(pdf, x1, x2, x3); - distributions->getDistribution(pdfNeighbor1, x1 + nx1, x2 + nx2, x3 + nx3); - distributions->getDistribution(pdfNeighbor2, x1 + 2 * nx1, x2 + 2 * nx2, x3 + 2 * nx3); - - if (numberOfCellsForExtrapolation == 3) // quadratic normal extrapolation - { - LBMReal pdfNeighbor3[D3Q27System::ENDF + 1]; - distributions->getDistribution(pdfNeighbor3, x1 + 3 * nx1, x2 + 3 * nx2, x3 + 3 * nx3); - - for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++) - pdf[fDir] = 3 * pdfNeighbor1[fDir] - 3 * pdfNeighbor2[fDir] + pdfNeighbor3[fDir]; - } - else // numberOfCellsForExtrapolation == 2 // linear normal extrapolation - { - for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++) - pdf[fDir] = 2 * pdfNeighbor1[fDir] - pdfNeighbor2[fDir]; - } - - distributions->setDistribution(pdf, x1, x2, x3); -} diff --git a/src/cpu/DemCoupling/reconstructor/ExtrapolationReconstructor.h b/src/cpu/DemCoupling/reconstructor/ExtrapolationReconstructor.h deleted file mode 100644 index ec60da39e..000000000 --- a/src/cpu/DemCoupling/reconstructor/ExtrapolationReconstructor.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -* Author: S. Peters -* mail: peters@irmb.tu-bs.de -*/ -#ifndef EXTRAPOLATION_RECONSTRUCTOR_H -#define EXTRAPOLATION_RECONSTRUCTOR_H - -#include <memory> - -#include "UbTuple.h" - -#include "Reconstructor.h" - -class ILBMKernel; -class PhysicsEngineGeometryAdapter; - -class ExtrapolationReconstructor : public Reconstructor -{ -public: - ExtrapolationReconstructor(std::shared_ptr<Reconstructor> alternativeReconstructor); - virtual ~ExtrapolationReconstructor() {} - - - void reconstructNode(const int &x1, const int &x2, const int &x3, const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, std::shared_ptr<ILBMKernel> kernel) const override; - - void setAlternativeReconstructor(std::shared_ptr<Reconstructor> alternativeReconstructor); - -private: - int getNumberOfExtrapolationCells(const int x1, const int x2, const int x3, const UbTupleInt3& ubTuple, std::shared_ptr<ILBMKernel> kernel) const; - UbTupleInt3 getSphereDirection(const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry) const; - UbTupleInt3 getCorrespondingLatticeDirection(const Vector3D& direction) const; - void extrapolatePdFs(const int x1, const int x2, const int x3, const UbTupleInt3& ubTuple, int numberOfCellsForExtrapolation, std::shared_ptr<ILBMKernel> kernel) const; - - - std::shared_ptr<Reconstructor> alternativeReconstructor; - -}; - - - -#endif - diff --git a/src/cpu/DemCoupling/reconstructor/LBMReconstructor.cpp b/src/cpu/DemCoupling/reconstructor/LBMReconstructor.cpp deleted file mode 100644 index 1cef0c2f0..000000000 --- a/src/cpu/DemCoupling/reconstructor/LBMReconstructor.cpp +++ /dev/null @@ -1,149 +0,0 @@ -#include "LBMReconstructor.h" - -#include "ILBMKernel.h" -#include "D3Q27System.h" -#include "DataSet3D.h" -#include "BCProcessor.h" -#include "BCArray3D.h" - -#include "PhysicsEngineGeometryAdapter.h" - -using namespace D3Q27System; - -LBMReconstructor::LBMReconstructor(bool compressible) -{ - if (compressible) - { - calcMacrosFct = &D3Q27System::calcCompMacroscopicValues; - } - else - { - calcMacrosFct = &D3Q27System::calcIncompMacroscopicValues; - } -} - -void LBMReconstructor::reconstructNode(const int& x1, const int& x2, const int& x3, - const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, std::shared_ptr<ILBMKernel> kernel) const -{ - LBMReal pdf[D3Q27System::ENDF + 1]; - - LBMReal rho, vx1, vx2, vx3; - calcMacrosFct(pdf, rho, vx1, vx2, vx3); - - LBMReal rho_dif = 1; - - while (rho_dif > 1e-5) - { - for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++) - { - - UbTupleInt3 neighbor(x1 + D3Q27System::DX1[fDir], x2 + D3Q27System::DX2[fDir], x3 + D3Q27System::DX3[fDir]); - - if (!kernel->getBCProcessor()->getBCArray()->isFluid(val<1>(neighbor), val<2>(neighbor), val<3>(neighbor))) - { - LBMReal pdfNeighbor[D3Q27System::ENDF + 1]; - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - const int invDir = D3Q27System::INVDIR[fDir]; - distributions->getDistributionForDirection(pdfNeighbor[invDir], val<1>(neighbor), val<2>(neighbor), val<3>(neighbor)); - distributions->setDistributionInvForDirection(pdf[invDir], x1, x2, x3, invDir); - } - - - } - } - - - - LBMReal collFactor = kernel->getCollisionFactor(); - collide(pdf, collFactor); - - - - -} - - -void LBMReconstructor::collide(LBMReal* f, LBMReal collFactor) -{ - - LBMReal drho, vx1, vx2, vx3; - LBMReal feq[D3Q27System::ENDF+1]; - - - drho = ((f[TNE]+f[BSW])+(f[TSE]+f[BNW]))+((f[BSE]+f[TNW])+(f[TSW]+f[BNE])) - +(((f[NE]+f[SW])+(f[SE]+f[NW]))+((f[TE]+f[BW])+(f[BE]+f[TW])) - +((f[BN]+f[TS])+(f[TN]+f[BS])))+((f[E]+f[W])+(f[N]+f[S]) - +(f[T]+f[B]))+f[ZERO]; - - vx1 = ((((f[TNE]-f[BSW])+(f[TSE]-f[BNW]))+((f[BSE]-f[TNW])+(f[BNE]-f[TSW])))+ - (((f[BE]-f[TW])+(f[TE]-f[BW]))+((f[SE]-f[NW])+(f[NE]-f[SW])))+ - (f[E]-f[W])); - - vx2 = ((((f[TNE]-f[BSW])+(f[BNW]-f[TSE]))+((f[TNW]-f[BSE])+(f[BNE]-f[TSW])))+ - (((f[BN]-f[TS])+(f[TN]-f[BS]))+((f[NW]-f[SE])+(f[NE]-f[SW])))+ - (f[N]-f[S])); - - vx3 = ((((f[TNE]-f[BSW])+(f[TSE]-f[BNW]))+((f[TNW]-f[BSE])+(f[TSW]-f[BNE])))+ - (((f[TS]-f[BN])+(f[TN]-f[BS]))+((f[TW]-f[BE])+(f[TE]-f[BW])))+ - (f[T]-f[B])); - - LBMReal cu_sq = 1.5*(vx1*vx1+vx2*vx2+vx3*vx3); - - feq[ZERO] = c8o27*(drho-cu_sq); - feq[E] = c2o27*(drho+3.0*(vx1)+c9o2*(vx1)*(vx1)-cu_sq); - feq[W] = c2o27*(drho+3.0*(-vx1)+c9o2*(-vx1)*(-vx1)-cu_sq); - feq[N] = c2o27*(drho+3.0*(vx2)+c9o2*(vx2)*(vx2)-cu_sq); - feq[S] = c2o27*(drho+3.0*(-vx2)+c9o2*(-vx2)*(-vx2)-cu_sq); - feq[T] = c2o27*(drho+3.0*(vx3)+c9o2*(vx3)*(vx3)-cu_sq); - feq[B] = c2o27*(drho+3.0*(-vx3)+c9o2*(-vx3)*(-vx3)-cu_sq); - feq[NE] = c1o54*(drho+3.0*(vx1+vx2)+c9o2*(vx1+vx2)*(vx1+vx2)-cu_sq); - feq[SW] = c1o54*(drho+3.0*(-vx1-vx2)+c9o2*(-vx1-vx2)*(-vx1-vx2)-cu_sq); - feq[SE] = c1o54*(drho+3.0*(vx1-vx2)+c9o2*(vx1-vx2)*(vx1-vx2)-cu_sq); - feq[NW] = c1o54*(drho+3.0*(-vx1+vx2)+c9o2*(-vx1+vx2)*(-vx1+vx2)-cu_sq); - feq[TE] = c1o54*(drho+3.0*(vx1+vx3)+c9o2*(vx1+vx3)*(vx1+vx3)-cu_sq); - feq[BW] = c1o54*(drho+3.0*(-vx1-vx3)+c9o2*(-vx1-vx3)*(-vx1-vx3)-cu_sq); - feq[BE] = c1o54*(drho+3.0*(vx1-vx3)+c9o2*(vx1-vx3)*(vx1-vx3)-cu_sq); - feq[TW] = c1o54*(drho+3.0*(-vx1+vx3)+c9o2*(-vx1+vx3)*(-vx1+vx3)-cu_sq); - feq[TN] = c1o54*(drho+3.0*(vx2+vx3)+c9o2*(vx2+vx3)*(vx2+vx3)-cu_sq); - feq[BS] = c1o54*(drho+3.0*(-vx2-vx3)+c9o2*(-vx2-vx3)*(-vx2-vx3)-cu_sq); - feq[BN] = c1o54*(drho+3.0*(vx2-vx3)+c9o2*(vx2-vx3)*(vx2-vx3)-cu_sq); - feq[TS] = c1o54*(drho+3.0*(-vx2+vx3)+c9o2*(-vx2+vx3)*(-vx2+vx3)-cu_sq); - feq[TNE] = c1o216*(drho+3.0*(vx1+vx2+vx3)+c9o2*(vx1+vx2+vx3)*(vx1+vx2+vx3)-cu_sq); - feq[BSW] = c1o216*(drho+3.0*(-vx1-vx2-vx3)+c9o2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3)-cu_sq); - feq[BNE] = c1o216*(drho+3.0*(vx1+vx2-vx3)+c9o2*(vx1+vx2-vx3)*(vx1+vx2-vx3)-cu_sq); - feq[TSW] = c1o216*(drho+3.0*(-vx1-vx2+vx3)+c9o2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3)-cu_sq); - feq[TSE] = c1o216*(drho+3.0*(vx1-vx2+vx3)+c9o2*(vx1-vx2+vx3)*(vx1-vx2+vx3)-cu_sq); - feq[BNW] = c1o216*(drho+3.0*(-vx1+vx2-vx3)+c9o2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3)-cu_sq); - feq[BSE] = c1o216*(drho+3.0*(vx1-vx2-vx3)+c9o2*(vx1-vx2-vx3)*(vx1-vx2-vx3)-cu_sq); - feq[TNW] = c1o216*(drho+3.0*(-vx1+vx2+vx3)+c9o2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3)-cu_sq); - - //Relaxation - f[ZERO] += (feq[ZERO]-f[ZERO])*collFactor; - f[E] += (feq[E]-f[E])*collFactor; - f[W] += (feq[W]-f[W])*collFactor; - f[N] += (feq[N]-f[N])*collFactor; - f[S] += (feq[S]-f[S])*collFactor; - f[T] += (feq[T]-f[T])*collFactor; - f[B] += (feq[B]-f[B])*collFactor; - f[NE] += (feq[NE]-f[NE])*collFactor; - f[SW] += (feq[SW]-f[SW])*collFactor; - f[SE] += (feq[SE]-f[SE])*collFactor; - f[NW] += (feq[NW]-f[NW])*collFactor; - f[TE] += (feq[TE]-f[TE])*collFactor; - f[BW] += (feq[BW]-f[BW])*collFactor; - f[BE] += (feq[BE]-f[BE])*collFactor; - f[TW] += (feq[TW]-f[TW])*collFactor; - f[TN] += (feq[TN]-f[TN])*collFactor; - f[BS] += (feq[BS]-f[BS])*collFactor; - f[BN] += (feq[BN]-f[BN])*collFactor; - f[TS] += (feq[TS]-f[TS])*collFactor; - - f[TNE] += (feq[TNE]-f[TNE])*collFactor; - f[BSW] += (feq[BSW]-f[BSW])*collFactor; - f[BNE] += (feq[BNE]-f[BNE])*collFactor; - f[TSW] += (feq[TSW]-f[TSW])*collFactor; - f[TSE] += (feq[TSE]-f[TSE])*collFactor; - f[BNW] += (feq[BNW]-f[BNW])*collFactor; - f[BSE] += (feq[BSE]-f[BSE])*collFactor; - f[TNW] += (feq[TNW]-f[TNW])*collFactor; -} \ No newline at end of file diff --git a/src/cpu/DemCoupling/reconstructor/LBMReconstructor.h b/src/cpu/DemCoupling/reconstructor/LBMReconstructor.h deleted file mode 100644 index 0ba24f898..000000000 --- a/src/cpu/DemCoupling/reconstructor/LBMReconstructor.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -* Author: S. Peters -* mail: peters@irmb.tu-bs.de -*/ -#ifndef LBM_RECONSTRUCTOR_H -#define LBM_RECONSTRUCTOR_H - -#include "UbTuple.h" - -#include "Reconstructor.h" - -#include "LBMSystem.h" - -class ILBMKernel; -class PhysicsEngineGeometryAdapter; - - -class LBMReconstructor : public Reconstructor -{ -public: - LBMReconstructor(bool compressible); - virtual ~LBMReconstructor() {} - - void reconstructNode(const int &x1, const int &x2, const int &x3, const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, std::shared_ptr<ILBMKernel> kernel) const override; - -private: - static void collide(LBMReal* f, LBMReal collFactor); - - typedef void(*CalcMacrosFct)(const LBMReal* const& /*f[27]*/, LBMReal& /*rho*/, LBMReal& /*vx1*/, LBMReal& /*vx2*/, LBMReal& /*vx3*/); - CalcMacrosFct calcMacrosFct; - -}; - - - -#endif - diff --git a/src/cpu/DemCoupling/reconstructor/Reconstructor.h b/src/cpu/DemCoupling/reconstructor/Reconstructor.h deleted file mode 100644 index cbcb49ba2..000000000 --- a/src/cpu/DemCoupling/reconstructor/Reconstructor.h +++ /dev/null @@ -1,27 +0,0 @@ -/* -* Author: S. Peters -* mail: peters@irmb.tu-bs.de -*/ -#ifndef RECONSTRCUTOR_H -#define RECONSTRCUTOR_H - -#include <PointerDefinitions.h> - -#include "Vector3D.h" - -class ILBMKernel; -class PhysicsEngineGeometryAdapter; - -class Reconstructor -{ -public: - virtual ~Reconstructor() {} - - virtual void reconstructNode(const int &x1, const int &x2, const int &x3, const Vector3D& worldCoordinates, SPtr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, std::shared_ptr<ILBMKernel> kernel) const = 0; - -}; - - - -#endif - diff --git a/src/cpu/DemCoupling/reconstructor/VelocityBcReconstructor.cpp b/src/cpu/DemCoupling/reconstructor/VelocityBcReconstructor.cpp deleted file mode 100644 index 1b9282730..000000000 --- a/src/cpu/DemCoupling/reconstructor/VelocityBcReconstructor.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include "VelocityBcReconstructor.h" - -#include <exception> - -#include "ILBMKernel.h" -#include "D3Q27System.h" -#include "BCArray3D.h" -#include "EsoTwist3D.h" -#include "BCProcessor.h" -#include "DataSet3D.h" - -#include "PhysicsEngineGeometryAdapter.h" - -void VelocityBcReconstructor::reconstructNode(const int& x1, const int& x2, const int& x3, - const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, std::shared_ptr<ILBMKernel> kernel) const -{ - if (kernel->getCompressible()) - throw std::runtime_error("not implemented yet!"); - - const Vector3D boundaryVelocity = physicsEngineGeometry->getVelocityAtPosition(worldCoordinates); - //TODO: move to D3Q27 system - LBMReal wijk[D3Q27System::ENDF + 1]; - D3Q27System::calcIncompFeq(wijk, 1, 0, 0, 0); - - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - - SPtr<BoundaryConditions> bc = SPtr<BoundaryConditions>(new BoundaryConditions()); - bc->setBoundaryVelocityX1((float)boundaryVelocity[0]); - bc->setBoundaryVelocityX2((float)boundaryVelocity[1]); - bc->setBoundaryVelocityX3((float)boundaryVelocity[2]); - - LBMReal feqNullRho[D3Q27System::ENDF + 1]; - D3Q27System::calcIncompFeq(feqNullRho, 0, boundaryVelocity[0], boundaryVelocity[1], boundaryVelocity[2]); - - LBMReal fpre[D3Q27System::ENDF + 1]; - LBMReal fpost[D3Q27System::ENDF + 1]; - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - - distributions->swap(); - distributions->getDistributionInv(fpost, x1, x2, x3); - distributions->swap(); - distributions->getDistribution(fpre, x1, x2, x3); - - int neighborX1, neighborX2, neighborX3; - int neighborX1Inv, neighborX2Inv, neighborX3Inv; - - double sumRho = 0, sumWijk = 0; - double collFactor = kernel->getCollisionFactor(); - - for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++) - { - neighborX1 = x1 + D3Q27System::DX1[fDir]; - neighborX2 = x2 + D3Q27System::DX2[fDir]; - neighborX3 = x3 + D3Q27System::DX3[fDir]; - - if (bcArray->isFluid(neighborX1, neighborX2, neighborX3)) - { - int invDir = D3Q27System::INVDIR[fDir]; - - neighborX1Inv = x1 + D3Q27System::DX1[invDir]; - neighborX2Inv = x2 + D3Q27System::DX2[invDir]; - neighborX3Inv = x3 + D3Q27System::DX3[invDir]; - if (!bcArray->isFluid(neighborX1Inv, neighborX2Inv, neighborX3Inv)) - { - - double velocity = bc->getBoundaryVelocity(invDir); - - fpre[fDir] = fpre[invDir] - velocity; - double Omega = fpost[fDir] - fpre[fDir]; - - sumRho += Omega / collFactor + fpre[fDir] - feqNullRho[fDir]; - sumWijk += wijk[fDir]; - } - - } - } - - double rho = 0.0; - if (sumWijk > 0.0) - rho = sumRho / sumWijk; - - for (int fDir = D3Q27System::FSTARTDIR; fDir <= D3Q27System::FENDDIR; fDir++) - { - neighborX1 = x1 + D3Q27System::DX1[fDir]; - neighborX2 = x2 + D3Q27System::DX2[fDir]; - neighborX3 = x3 + D3Q27System::DX3[fDir]; - - if (!bcArray->isFluid(neighborX1, neighborX2, neighborX3)) - { - int invDir = D3Q27System::INVDIR[fDir]; - neighborX1Inv = x1 + D3Q27System::DX1[invDir]; - neighborX2Inv = x2 + D3Q27System::DX2[invDir]; - neighborX3Inv = x3 + D3Q27System::DX3[invDir]; - if (!bcArray->isFluid(neighborX1Inv, neighborX2Inv, neighborX3Inv)) - { - fpre[fDir] = D3Q27System::getIncompFeqForDirection(fDir, rho, bc->getBoundaryVelocityX1(), bc->getBoundaryVelocityX2(), bc->getBoundaryVelocityX3()); - } - - } - } - -} diff --git a/src/cpu/DemCoupling/reconstructor/VelocityBcReconstructor.h b/src/cpu/DemCoupling/reconstructor/VelocityBcReconstructor.h deleted file mode 100644 index 8be5bcb65..000000000 --- a/src/cpu/DemCoupling/reconstructor/VelocityBcReconstructor.h +++ /dev/null @@ -1,27 +0,0 @@ -/* -* Author: S. Peters -* mail: peters@irmb.tu-bs.de -*/ -#ifndef VELOCITY_BC_RECONSTRUCTOR_H -#define VELOCITY_BC_RECONSTRUCTOR_H - -#include "UbTuple.h" - -#include "Reconstructor.h" - -class ILBMKernel; -class PhysicsEngineGeometryAdapter; - -class VelocityBcReconstructor : public Reconstructor -{ -public: - virtual ~VelocityBcReconstructor() {} - - void reconstructNode(const int &x1, const int &x2, const int &x3, const Vector3D& worldCoordinates, std::shared_ptr<PhysicsEngineGeometryAdapter> physicsEngineGeometry, std::shared_ptr<ILBMKernel> kernel) const override; - -}; - - - -#endif - diff --git a/src/cpu/DemCoupling/reconstructor/package.include b/src/cpu/DemCoupling/reconstructor/package.include deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/BCAdapter.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/BCAdapter.h index f91e6ad48..26437dafc 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/BCAdapter.h +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/BCAdapter.h @@ -1,85 +1,92 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef BCAdapter_H -#define BCAdapter_H - -#include <PointerDefinitions.h> - -#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, SPtr<BoundaryConditions> bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& time=0 ) = 0; - virtual void adaptBCForDirection( const D3Q27Interactor& interactor, SPtr<BoundaryConditions> bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& q, const int& fdirection, const double& time=0 ) = 0; - - void setBcAlgorithm(SPtr<BCAlgorithm> alg) {algorithmType = alg->getType(); algorithm = alg;} - SPtr<BCAlgorithm> getAlgorithm() {return algorithm;} - char getBcAlgorithmType() {return algorithmType;} - -protected: - short secondaryBcOption; - - char type; - - SPtr<BCAlgorithm> algorithm; - char algorithmType; - - static const char TIMEDEPENDENT = 1<<0;//'1'; - static const char TIMEPERIODIC = 1<<1;//'2'; - -private: - -}; - - -#endif //D3Q27BOUNDARYCONDITIONADAPTER_H +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file BCAdapter.h +//! \ingroup BoundarConditions +//! \author Sören Freudiger +//======================================================================================= +#ifndef BCAdapter_H +#define BCAdapter_H + +#include <PointerDefinitions.h> + +#include "BoundaryConditions.h" +#include "BCAlgorithm.h" + +class D3Q27Interactor; + +//! \brief Abstract class of baundary conditions adapter +//! \details BCAdapter supports the definition of boundary conditions in grid generation +class BCAdapter +{ +public: + BCAdapter() + : secondaryBcOption(0) + , type(0) + , algorithmType(-1) + { + } + //! \param secondaryBcOption additional option of boundary conditions + 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, SPtr<BoundaryConditions> bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& time=0 ) = 0; + virtual void adaptBCForDirection( const D3Q27Interactor& interactor, SPtr<BoundaryConditions> bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& q, const int& fdirection, const double& time=0 ) = 0; + + void setBcAlgorithm(SPtr<BCAlgorithm> alg) {algorithmType = alg->getType(); algorithm = alg;} + SPtr<BCAlgorithm> getAlgorithm() {return algorithm;} + char getBcAlgorithmType() {return algorithmType;} + +protected: + short secondaryBcOption; + + char type; + + SPtr<BCAlgorithm> algorithm; + char algorithmType; + + static const char TIMEDEPENDENT = 1<<0;//'1'; + static const char TIMEPERIODIC = 1<<1;//'2'; +}; + + +#endif diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/BCAlgorithm.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/BCAlgorithm.cpp index dbdfb9ed1..630b3ec7e 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/BCAlgorithm.cpp +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/BCAlgorithm.cpp @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file BCAlgorithm.cpp +//! \ingroup BoundarConditions +//! \author Konstantin Kutscher +//======================================================================================= + #include "BCAlgorithm.h" #include "BoundaryConditions.h" diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/BCAlgorithm.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/BCAlgorithm.h index ab9484fbd..5a3944c7e 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/BCAlgorithm.h +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/BCAlgorithm.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file BCAlgorithm.h +//! \ingroup BoundarConditions +//! \author Konstantin Kutscher +//======================================================================================= #ifndef BOUNDARYCONDITIONS_H #define BOUNDARYCONDITIONS_H @@ -10,6 +42,8 @@ class DistributionArray3D; class BCArray3D; class BoundaryConditions; +//! \brief Abstract class of baundary conditions algorithm +//! \details BCAlgorithm provides interface for implementation of diferent boundary conditions class BCAlgorithm { public: diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/BCArray3D.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/BCArray3D.cpp index 87df6d4bd..10fe50523 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/BCArray3D.cpp +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/BCArray3D.cpp @@ -1,203 +1,235 @@ -#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, SPtr<BoundaryConditions> 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(SPtr<BoundaryConditions>).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(); -} -////////////////////////////////////////////////////////////////////////// -std::vector< int >& BCArray3D::getBcindexmatrixDataVector() -{ - return bcindexmatrix.getDataVector(); -} - - -////////////////////////////////////////////////////////////////////////// -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] = SPtr<BoundaryConditions>(); +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file BCArray3D.cpp +//! \ingroup BoundarConditions +//! \author Sören Freudiger +//======================================================================================= + +#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, SPtr<BoundaryConditions> const& bc) +{ + if (this->hasBC(x1, x2, x3)) + { + if (this->getBC(x1, x2, x3) == bc) return; + else this->deleteBC(x1, x2, x3); + } + + //if no vacant BCs available + 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(SPtr<BoundaryConditions>).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(); +} +////////////////////////////////////////////////////////////////////////// +std::vector< int >& BCArray3D::getBcindexmatrixDataVector() +{ + return bcindexmatrix.getDataVector(); +} + + +////////////////////////////////////////////////////////////////////////// +void BCArray3D::deleteBCAndSetType(std::size_t x1, std::size_t x2, std::size_t x3, int type) + { + this->deleteBC(x1, x2, x3); + + //Assign matrix to new type + bcindexmatrix(x1, x2, x3) = type; + } +////////////////////////////////////////////////////////////////////////// +void BCArray3D::deleteBC(std::size_t x1, std::size_t x2, std::size_t x3) + { + //check if BC exists at all + int index = bcindexmatrix(x1, x2, x3); + if (index < 0) return; + + //slide the released index into the index container + indexContainer.push_back(index); + + //"delete" element + bcvector[index] = SPtr<BoundaryConditions>(); } \ No newline at end of file diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/BCArray3D.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/BCArray3D.h index b8e9b711d..b87b03ed3 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/BCArray3D.h +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/BCArray3D.h @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file BCArray3D.h +//! \ingroup BoundarConditions +//! \author Sören Freudiger +//======================================================================================= + #ifndef BCArray_H #define BCArray_H @@ -8,7 +41,7 @@ #include <PointerDefinitions.h> - +//! A class implements array to store boundary conditions flags class BCArray3D { public: diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/BCFunction.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/BCFunction.cpp index d2ca1b159..2f661804b 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/BCFunction.cpp +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/BCFunction.cpp @@ -1,5 +1,38 @@ -#include "BCFunction.h" - -const double BCFunction::INFTIMEDEPENDENT = -1.0; -const double BCFunction::INFCONST = -10.0; - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file BCFunction.cpp +//! \ingroup BoundarConditions +//! \author Sören Freudiger +//======================================================================================= + +#include "BCFunction.h" + +const double BCFunction::INFTIMEDEPENDENT = -1.0; +const double BCFunction::INFCONST = -10.0; + diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/BCFunction.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/BCFunction.h index 40d47b1b2..0f9ad2f34 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/BCFunction.h +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/BCFunction.h @@ -1,86 +1,113 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef D3Q27BCFUNCTION_H -#define D3Q27BCFUNCTION_H - -#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& endtime) {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: - -}; - -#endif //D3Q27BCFUNCTION_H +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file BCFunction.h +//! \ingroup BoundarConditions +//! \author Sören Freudiger +//======================================================================================= + +#ifndef D3Q27BCFUNCTION_H +#define D3Q27BCFUNCTION_H + +#include <basics/utilities/UbInfinity.h> + +#include <MuParser/include/muParser.h> + +//! A class implements function parcer for boundary conditions +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: + +}; + +#endif //D3Q27BCFUNCTION_H diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/BCProcessor.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/BCProcessor.cpp index 452af7bc4..5eabfe8ee 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/BCProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/BCProcessor.cpp @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file BCProcessor.h +//! \ingroup BoundarConditions +//! \author Konstantin Kutscher +//======================================================================================= + #include "BCProcessor.h" #include "D3Q27EsoTwist3DSplittedVector.h" #include "DataSet3D.h" @@ -12,7 +45,7 @@ BCProcessor::BCProcessor() ////////////////////////////////////////////////////////////////////////// BCProcessor::BCProcessor(SPtr<ILBMKernel> kernel) { - SPtr<DistributionArray3D> distributions = dynamicPointerCast<EsoTwist3D>(kernel->getDataSet()->getFdistributions()); + SPtr<DistributionArray3D> distributions = std::dynamic_pointer_cast<EsoTwist3D>(kernel->getDataSet()->getFdistributions()); bcArray = SPtr<BCArray3D>(new BCArray3D( distributions->getNX1(), distributions->getNX2(), distributions->getNX3(), BCArray3D::FLUID)); } ////////////////////////////////////////////////////////////////////////// diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/BCProcessor.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/BCProcessor.h index 88bb72a76..9dc572b0d 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/BCProcessor.h +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/BCProcessor.h @@ -1,34 +1,68 @@ -#ifndef BC_PROCESSSOR_H -#define BC_PROCESSSOR_H - -#include <PointerDefinitions.h> -#include <vector> - -class BCArray3D; -class BCAlgorithm; -class ILBMKernel; - -class BCProcessor -{ -public: - BCProcessor(); - BCProcessor(SPtr<ILBMKernel> kernel); - virtual ~BCProcessor(); - virtual SPtr<BCArray3D> getBCArray(); - virtual void setBCArray(SPtr<BCArray3D> bcarray); - virtual SPtr<BCProcessor> clone(SPtr<ILBMKernel> kernel); - - void addBC(SPtr<BCAlgorithm> bc); - void applyPreCollisionBC(); - void applyPostCollisionBC(); - void clearBC(); -protected: - std::vector<SPtr<BCAlgorithm> > preBC; - std::vector<SPtr<BCAlgorithm> > postBC; - SPtr<BCArray3D> bcArray; - -private: - -}; - -#endif +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file BCProcessor.h +//! \ingroup BoundarConditions +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef BC_PROCESSSOR_H +#define BC_PROCESSSOR_H + +#include <PointerDefinitions.h> +#include <vector> + +class BCArray3D; +class BCAlgorithm; +class ILBMKernel; + +//! A class provides an interface for boundary conditions in the calculation loop. +class BCProcessor +{ +public: + BCProcessor(); + BCProcessor(SPtr<ILBMKernel> kernel); + virtual ~BCProcessor(); + virtual SPtr<BCArray3D> getBCArray(); + virtual void setBCArray(SPtr<BCArray3D> bcarray); + virtual SPtr<BCProcessor> clone(SPtr<ILBMKernel> kernel); + + void addBC(SPtr<BCAlgorithm> bc); + void applyPreCollisionBC(); + void applyPostCollisionBC(); + void clearBC(); +protected: + std::vector<SPtr<BCAlgorithm> > preBC; + std::vector<SPtr<BCAlgorithm> > postBC; + SPtr<BCArray3D> bcArray; + +private: + +}; + +#endif diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.cpp index 4a384f865..7dadd850f 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.cpp +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.cpp @@ -1,4 +1,37 @@ -#include "BoundaryConditions.h" - -const long long BoundaryConditions::maxOptionVal = ( 1<<optionDigits ) - 1; //2^3-1 -> 7 - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file BoundaryConditions.h +//! \ingroup BoundarConditions +//! \author Sören Freudiger +//======================================================================================= + +#include "BoundaryConditions.h" + +const long long BoundaryConditions::maxOptionVal = ( 1<<optionDigits ) - 1; //2^3-1 -> 7 + diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.h index 0c91558b4..e9131f4f1 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.h +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/BoundaryConditions.h @@ -1,27 +1,51 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ // +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file BoundaryConditions.h +//! \ingroup BoundarConditions +//! \author Sören Freudiger +//======================================================================================= #ifndef BoundaryConditions_H #define BoundaryConditions_H #include <vector> #include <string> -#include "basics/utilities/Vector3D.h" - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbSystem.h> -#include <basics/utilities/UbTuple.h> +#include "Vector3D.h" +#include "UbException.h" +#include "UbSystem.h" +#include "UbTuple.h" #include "D3Q27System.h" #include <PointerDefinitions.h> +//! Difenition of baundary conditions in grid generation class BoundaryConditions { -//public: -// enum BcAlgorithm{VelocityBC, SlipBC, NoSlipBC, ThinWallNoSlipBC, HighViscosityNoSlipBC, EqDensityBC, NonEqDensityBC, NonReflectingVelocityBC, NonReflectingDensityBC}; public: BoundaryConditions() : noslipBoundaryFlags(0) @@ -43,10 +67,7 @@ public: , 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++) @@ -74,9 +95,9 @@ protected: if( (secOpt+1)>maxOptionVal ) throw UbException(UB_EXARGS,"error: option > "+UbSystem::toString(maxOptionVal-1)); - //alle digits an den betreffenden postionen auf "0" + //all digits at the respective positions to "0" flag &= ~( maxOptionVal<<(direction*optionDigits) ); - //alle digitsan den betreffenden postionen entsprechend der marke setzen + //set all digits according to the flag at the respective positions flag |= ((long long)(secOpt+1)<<(direction*optionDigits)); } public: @@ -104,8 +125,8 @@ public: 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); } + void setNormalVector(const LBMReal& nx1,const LBMReal& nx2,const LBMReal& nx3) { this->nx1 = nx1; this->nx2 = nx2; this->nx3 = nx3;} + UbTupleDouble3 getNormalVector() { return makeUbTuple(nx1,nx2,nx3); } /*============== Velocity Boundary ========================*/ void setVelocityBoundaryFlag(const int& direction, const short& secOpt=0) { this->setFlagBits(velocityBoundaryFlags,direction,secOpt); } @@ -118,46 +139,46 @@ public: void setBoundaryVelocity(const Vector3D& vx) { - setBoundaryVelocityX1((float)vx[0]); - setBoundaryVelocityX2((float)vx[1]); - setBoundaryVelocityX3((float)vx[2]); + setBoundaryVelocityX1((LBMReal)vx[0]); + setBoundaryVelocityX2((LBMReal)vx[1]); + setBoundaryVelocityX3((LBMReal)vx[2]); } - 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) + void setBoundaryVelocityX1(const LBMReal& vx1) { this->bcVelocityX1 = vx1; } + void setBoundaryVelocityX2(const LBMReal& vx2) { this->bcVelocityX2 = vx2; } + void setBoundaryVelocityX3(const LBMReal& vx3) { this->bcVelocityX3 = vx3; } + LBMReal getBoundaryVelocityX1() { return this->bcVelocityX1; } + LBMReal getBoundaryVelocityX2() { return this->bcVelocityX2; } + LBMReal getBoundaryVelocityX3() { return this->bcVelocityX3; } + LBMReal 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) ); + case D3Q27System::E : return (LBMReal)( UbMath::c4o9*(+bcVelocityX1) ); //(2/cs^2)(=6)*rho_0(=1 for incompressible)*wi*u*ei with cs=1/sqrt(3) + case D3Q27System::W : return (LBMReal)( UbMath::c4o9*(-bcVelocityX1) ); + case D3Q27System::N : return (LBMReal)( UbMath::c4o9*(+bcVelocityX2) ); + case D3Q27System::S : return (LBMReal)( UbMath::c4o9*(-bcVelocityX2) ); + case D3Q27System::T : return (LBMReal)( UbMath::c4o9*(+bcVelocityX3) ); + case D3Q27System::B : return (LBMReal)( UbMath::c4o9*(-bcVelocityX3) ); + case D3Q27System::NE: return (LBMReal)( UbMath::c1o9*(+bcVelocityX1+bcVelocityX2 ) ); + case D3Q27System::SW: return (LBMReal)( UbMath::c1o9*(-bcVelocityX1-bcVelocityX2 ) ); + case D3Q27System::SE: return (LBMReal)( UbMath::c1o9*(+bcVelocityX1-bcVelocityX2 ) ); + case D3Q27System::NW: return (LBMReal)( UbMath::c1o9*(-bcVelocityX1+bcVelocityX2 ) ); + case D3Q27System::TE: return (LBMReal)( UbMath::c1o9*(+bcVelocityX1 +bcVelocityX3) ); + case D3Q27System::BW: return (LBMReal)( UbMath::c1o9*(-bcVelocityX1 -bcVelocityX3) ); + case D3Q27System::BE: return (LBMReal)( UbMath::c1o9*(+bcVelocityX1 -bcVelocityX3) ); + case D3Q27System::TW: return (LBMReal)( UbMath::c1o9*(-bcVelocityX1 +bcVelocityX3) ); + case D3Q27System::TN: return (LBMReal)( UbMath::c1o9*( +bcVelocityX2+bcVelocityX3) ); + case D3Q27System::BS: return (LBMReal)( UbMath::c1o9*( -bcVelocityX2-bcVelocityX3) ); + case D3Q27System::BN: return (LBMReal)( UbMath::c1o9*( +bcVelocityX2-bcVelocityX3) ); + case D3Q27System::TS: return (LBMReal)( UbMath::c1o9*( -bcVelocityX2+bcVelocityX3) ); + case D3Q27System::TNE: return (LBMReal)( UbMath::c1o36*(+bcVelocityX1+bcVelocityX2+bcVelocityX3) ); + case D3Q27System::BSW: return (LBMReal)( UbMath::c1o36*(-bcVelocityX1-bcVelocityX2-bcVelocityX3) ); + case D3Q27System::BNE: return (LBMReal)( UbMath::c1o36*(+bcVelocityX1+bcVelocityX2-bcVelocityX3) ); + case D3Q27System::TSW: return (LBMReal)( UbMath::c1o36*(-bcVelocityX1-bcVelocityX2+bcVelocityX3) ); + case D3Q27System::TSE: return (LBMReal)( UbMath::c1o36*(+bcVelocityX1-bcVelocityX2+bcVelocityX3) ); + case D3Q27System::BNW: return (LBMReal)( UbMath::c1o36*(-bcVelocityX1+bcVelocityX2-bcVelocityX3) ); + case D3Q27System::BSE: return (LBMReal)( UbMath::c1o36*(+bcVelocityX1-bcVelocityX2-bcVelocityX3) ); + case D3Q27System::TNW: return (LBMReal)( UbMath::c1o36*(-bcVelocityX1+bcVelocityX2+bcVelocityX3) ); default: throw UbException(UB_EXARGS,"unknown error"); } } @@ -171,37 +192,37 @@ public: 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; } + void setBoundaryDensity(LBMReal density) { this->bcDensity = density; } + LBMReal 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; } + void setDensityLodiDensity(const LBMReal& bcLodiDensity) { this->bcLodiDensity = bcLodiDensity; } + void setDensityLodiVelocityX1(const LBMReal& bcLodiVelocityX1) { this->bcLodiVelocityX1 = bcLodiVelocityX1; } + void setDensityLodiVelocityX2(const LBMReal& bcLodiVelocityX2) { this->bcLodiVelocityX2 = bcLodiVelocityX2; } + void setDensityLodiVelocityX3(const LBMReal& bcLodiVelocityX3) { this->bcLodiVelocityX3 = bcLodiVelocityX3; } + void setDensityLodiLength(const LBMReal& bcLodiLentgh) { this->bcLodiLentgh = bcLodiLentgh; } + LBMReal getDensityLodiDensity() const { return this->bcLodiDensity; } + LBMReal getDensityLodiVelocityX1() const { return this->bcLodiVelocityX1; } + LBMReal getDensityLodiVelocityX2() const { return this->bcLodiVelocityX2; } + LBMReal getDensityLodiVelocityX3() const { return this->bcLodiVelocityX3; } + LBMReal 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; } + LBMReal& densityLodiDensity() { return this->bcLodiDensity; } + LBMReal& densityLodiVelocityX1() { return this->bcLodiVelocityX1; } + LBMReal& densityLodiVelocityX2() { return this->bcLodiVelocityX2; } + LBMReal& densityLodiVelocityX3() { return this->bcLodiVelocityX3; } + LBMReal& 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; } + const LBMReal& densityLodiDensity() const { return this->bcLodiDensity; } + const LBMReal& densityLodiVelocityX1() const { return this->bcLodiVelocityX1; } + const LBMReal& densityLodiVelocityX2() const { return this->bcLodiVelocityX2; } + const LBMReal& densityLodiVelocityX3() const { return this->bcLodiVelocityX3; } + const LBMReal& 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]; } + void setQ(const LBMReal& val, const int& direction) { q[direction] = val; } + LBMReal getQ(const int& direction) { return q[direction]; } virtual std::vector< std::string > getBCNames() { @@ -231,12 +252,11 @@ public: 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 int optionDigits = 2; //--> 2 bits for secondary Option --> maxOptionVal = 7 static const long long maxOptionVal;// = ( 1<<optionDigits ) - 1; //2^3-1 -> 7 protected: - float q[D3Q27System::FENDDIR+1]; - //float q[D3Q27System::STARTF+1]; + LBMReal q[D3Q27System::FENDDIR+1]; long long noslipBoundaryFlags; long long slipBoundaryFlags; @@ -244,26 +264,20 @@ protected: long long densityBoundaryFlags; long long wallModelBoundaryFlags; - float bcVelocityX1; - float bcVelocityX2; - float bcVelocityX3; - float bcDensity; + LBMReal bcVelocityX1; + LBMReal bcVelocityX2; + LBMReal bcVelocityX3; + LBMReal bcDensity; - float bcLodiDensity; - float bcLodiVelocityX1; - float bcLodiVelocityX2; - float bcLodiVelocityX3; - float bcLodiLentgh; + LBMReal bcLodiDensity; + LBMReal bcLodiVelocityX1; + LBMReal bcLodiVelocityX2; + LBMReal bcLodiVelocityX3; + LBMReal bcLodiLentgh; - float nx1,nx2,nx3; + LBMReal nx1,nx2,nx3; char algorithmType; - -private: - friend class MPIIORestartCoProcessor; - friend class MPIIOMigrationCoProcessor; - friend class MPIIOMigrationBECoProcessor; - }; -#endif //D3Q27BOUNDARYCONDITION_H +#endif diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/CMakePackage.txt b/src/cpu/VirtualFluidsCore/BoundaryConditions/CMakePackage.txt index de1dc5a88..e3e3f9a38 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/CMakePackage.txt +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/CMakePackage.txt @@ -1,2 +1,2 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +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/src/cpu/VirtualFluidsCore/BoundaryConditions/DensityBCAdapter.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/DensityBCAdapter.cpp deleted file mode 100644 index 24adb6cba..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/DensityBCAdapter.cpp +++ /dev/null @@ -1,157 +0,0 @@ -#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, SPtr<BoundaryConditions> 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, SPtr<BoundaryConditions> 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, SPtr<BoundaryConditions> 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/src/cpu/VirtualFluidsCore/BoundaryConditions/DensityBCAdapter.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/DensityBCAdapter.h deleted file mode 100644 index 9da55f374..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/DensityBCAdapter.h +++ /dev/null @@ -1,75 +0,0 @@ -#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, SPtr<BoundaryConditions> 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, SPtr<BoundaryConditions> 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, SPtr<BoundaryConditions> 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: - -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.cpp deleted file mode 100644 index 852ac405b..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "EqDensityBCAlgorithm.h" -#include "DistributionArray3D.h" -#include "BoundaryConditions.h" - - -EqDensityBCAlgorithm::EqDensityBCAlgorithm() -{ - BCAlgorithm::type = BCAlgorithm::EqDensityBCAlgorithm; - BCAlgorithm::preCollision = false; -} -////////////////////////////////////////////////////////////////////////// -EqDensityBCAlgorithm::~EqDensityBCAlgorithm() -{ -} -////////////////////////////////////////////////////////////////////////// -SPtr<BCAlgorithm> EqDensityBCAlgorithm::clone() -{ - SPtr<BCAlgorithm> bc(new EqDensityBCAlgorithm()); - return bc; -} -////////////////////////////////////////////////////////////////////////// -void EqDensityBCAlgorithm::addDistributions(SPtr<DistributionArray3D> 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/src/cpu/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.h deleted file mode 100644 index 8c4f472bf..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/EqDensityBCAlgorithm.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef EqDensityBCAlgorithm_h__ -#define EqDensityBCAlgorithm_h__ - -#include "BCAlgorithm.h" -#include <PointerDefinitions.h> - -class DistributionArray3D; - -class EqDensityBCAlgorithm : public BCAlgorithm -{ -public: - EqDensityBCAlgorithm(); - ~EqDensityBCAlgorithm(); - SPtr<BCAlgorithm> clone(); - void addDistributions(SPtr<DistributionArray3D> distributions); - void applyBC() override; -}; -#endif // EqDensityBCAlgorithm_h__ diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.cpp deleted file mode 100644 index 5dcd1b727..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "HighViscosityNoSlipBCAlgorithm.h" -#include "DistributionArray3D.h" -#include "BoundaryConditions.h" - -HighViscosityNoSlipBCAlgorithm::HighViscosityNoSlipBCAlgorithm() -{ - BCAlgorithm::type = BCAlgorithm::HighViscosityNoSlipBCAlgorithm; - BCAlgorithm::preCollision = true; -} -////////////////////////////////////////////////////////////////////////// -HighViscosityNoSlipBCAlgorithm::~HighViscosityNoSlipBCAlgorithm() -{ -} -////////////////////////////////////////////////////////////////////////// -SPtr<BCAlgorithm> HighViscosityNoSlipBCAlgorithm::clone() -{ - SPtr<BCAlgorithm> bc(new HighViscosityNoSlipBCAlgorithm()); - return bc; -} -////////////////////////////////////////////////////////////////////////// -void HighViscosityNoSlipBCAlgorithm::addDistributions(SPtr<DistributionArray3D> 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/src/cpu/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.h deleted file mode 100644 index aacc41a5a..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/HighViscosityNoSlipBCAlgorithm.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef HighViscosityNoSlipBCAlgorithm_h__ -#define HighViscosityNoSlipBCAlgorithm_h__ - -#include "BCAlgorithm.h" -#include <PointerDefinitions.h> - -class DistributionArray3D; - -class HighViscosityNoSlipBCAlgorithm : public BCAlgorithm -{ -public: - HighViscosityNoSlipBCAlgorithm(); - ~HighViscosityNoSlipBCAlgorithm(); - SPtr<BCAlgorithm> clone(); - void addDistributions(SPtr<DistributionArray3D> distributions); - void applyBC() override; -}; -#endif // HighViscosityNoSlipBCAlgorithm_h__ - diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/NoSlipBCAdapter.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/NoSlipBCAdapter.cpp index 24bc5794c..58e479e39 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/NoSlipBCAdapter.cpp +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/NoSlipBCAdapter.cpp @@ -1 +1,33 @@ -#include "NoSlipBCAdapter.h" +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file NoSlipBCAdapter.cpp +//! \ingroup BoundarConditions +//! \author Sören Freudiger +//======================================================================================= +#include "NoSlipBCAdapter.h" diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/NoSlipBCAdapter.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/NoSlipBCAdapter.h index 6354e4d6b..5a09aefb4 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/NoSlipBCAdapter.h +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/NoSlipBCAdapter.h @@ -1,47 +1,68 @@ -#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, SPtr<BoundaryConditions> 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, SPtr<BoundaryConditions> bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& time=0 ) - { - bc->setBcAlgorithmType(algorithmType); - } - -private: - -}; -#endif //NoSlipBCAdapter_H +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file NoSlipBCAdapter.cpp +//! \ingroup BoundarConditions +//! \author Sören Freudiger +//======================================================================================= + +#ifndef NoSlipBCAdapter_H +#define NoSlipBCAdapter_H + +#include "BCAdapter.h" + +//! A class provides an interface for no-slip boundary condition in grid generator +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, SPtr<BoundaryConditions> 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, SPtr<BoundaryConditions> bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& time=0 ) + { + bc->setBcAlgorithmType(algorithmType); + } + +private: + +}; +#endif //NoSlipBCAdapter_H diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.cpp index 412c1d104..5b68bf910 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.cpp +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.cpp @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file NoSlipBCAlgorithm.cpp +//! \ingroup BoundarConditions +//! \author Konstantin Kutscher +//======================================================================================= + #include "NoSlipBCAlgorithm.h" #include "DistributionArray3D.h" #include "BoundaryConditions.h" diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.h index 402e2e2bb..1cf6d6420 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.h +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/NoSlipBCAlgorithm.h @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file NoSlipBCAlgorithm.h +//! \ingroup BoundarConditions +//! \author Konstantin Kutscher +//======================================================================================= + #ifndef NoSlipBCAlgorithm_h__ #define NoSlipBCAlgorithm_h__ @@ -6,6 +39,7 @@ class DistributionArray3D; +//! A class implements no-slip boundary condition class NoSlipBCAlgorithm : public BCAlgorithm { public: @@ -16,4 +50,4 @@ public: void applyBC() override; private: }; -#endif // NoSlipBCAlgorithm_h__ +#endif diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.cpp deleted file mode 100644 index 865e2f1cf..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "NonEqDensityBCAlgorithm.h" - -#include "DistributionArray3D.h" -#include "BoundaryConditions.h" - -NonEqDensityBCAlgorithm::NonEqDensityBCAlgorithm() -{ - BCAlgorithm::type = BCAlgorithm::NonEqDensityBCAlgorithm; - BCAlgorithm::preCollision = false; -} -////////////////////////////////////////////////////////////////////////// -NonEqDensityBCAlgorithm::~NonEqDensityBCAlgorithm() -{ -} -////////////////////////////////////////////////////////////////////////// -SPtr<BCAlgorithm> NonEqDensityBCAlgorithm::clone() -{ - SPtr<BCAlgorithm> bc(new NonEqDensityBCAlgorithm()); - return bc; -} -////////////////////////////////////////////////////////////////////////// -void NonEqDensityBCAlgorithm::addDistributions(SPtr<DistributionArray3D> 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 return; //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 vlimit=0.01; - //vx1=(fabs(vx1)>vlimit) ? vx1/fabs(vx1)*vlimit : vx1; - //vx2=(fabs(vx2)>vlimit) ? vx2/fabs(vx2)*vlimit : vx2; - //vx3=(fabs(vx3)>vlimit) ? vx3/fabs(vx3)*vlimit : 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); - //rhoBC=(rho>rhoBC)? rhoBC : rho; //Limiter 08.08.2018 - ftemp = calcFeqsForDirFct(fdir, rhoBC, vx1, vx2, vx3)+f[fdir]-ftemp; - distributions->setDistributionForDirection(ftemp, nx1, nx2, nx3, fdir); - } - } - -} - diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.h deleted file mode 100644 index 8cec91d6e..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/NonEqDensityBCAlgorithm.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef NonEqDensityBCAlgorithm_h__ -#define NonEqDensityBCAlgorithm_h__ - -#include "BCAlgorithm.h" -#include <PointerDefinitions.h> - -class DistributionArray3D; - -class NonEqDensityBCAlgorithm : public BCAlgorithm -{ -public: - NonEqDensityBCAlgorithm(); - ~NonEqDensityBCAlgorithm(); - SPtr<BCAlgorithm> clone(); - void addDistributions(SPtr<DistributionArray3D> distributions); - void applyBC() override; -}; -#endif // NonEqDensityBCAlgorithm_h__ diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.cpp deleted file mode 100644 index 149824f17..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.cpp +++ /dev/null @@ -1,187 +0,0 @@ -#include "NonReflectingOutflowBCAlgorithm.h" - -#include "D3Q27System.h" -#include "DistributionArray3D.h" -#include "BoundaryConditions.h" - - -NonReflectingOutflowBCAlgorithm::NonReflectingOutflowBCAlgorithm() -{ - BCAlgorithm::type = BCAlgorithm::NonReflectingOutflowBCAlgorithm; - BCAlgorithm::preCollision = true; -} -////////////////////////////////////////////////////////////////////////// -NonReflectingOutflowBCAlgorithm::~NonReflectingOutflowBCAlgorithm() -{ -} -////////////////////////////////////////////////////////////////////////// -SPtr<BCAlgorithm> NonReflectingOutflowBCAlgorithm::clone() -{ - SPtr<BCAlgorithm> bc(new NonReflectingOutflowBCAlgorithm()); - return bc; -} -////////////////////////////////////////////////////////////////////////// -void NonReflectingOutflowBCAlgorithm::addDistributions(SPtr<DistributionArray3D> distributions) -{ - this->distributions = distributions; -} -////////////////////////////////////////////////////////////////////////// -void NonReflectingOutflowBCAlgorithm::applyBC() -{ - using namespace D3Q27System; - LBMReal f[ENDF+1]; - LBMReal ftemp[ENDF+1]; - - int nx1 = x1; - int nx2 = x2; - int nx3 = x3; - int direction = -1; - - //flag points in direction of fluid - if (bcPtr->hasDensityBoundaryFlag(E)) { nx1 += 1; direction = E; } - else if (bcPtr->hasDensityBoundaryFlag(W)) { nx1 -= 1; direction = W; } - else if (bcPtr->hasDensityBoundaryFlag(N)) { nx2 += 1; direction = N; } - else if (bcPtr->hasDensityBoundaryFlag(S)) { nx2 -= 1; direction = S; } - else if (bcPtr->hasDensityBoundaryFlag(T)) { nx3 += 1; direction = T; } - else if (bcPtr->hasDensityBoundaryFlag(B)) { nx3 -= 1; direction = B; } - else UB_THROW(UbException(UB_EXARGS, "Danger...no orthogonal BC-Flag on density boundary...")); - - distributions->getDistribution(f, x1, x2, x3); - distributions->getDistribution(ftemp, nx1, nx2, nx3); - - LBMReal rho, vx1, vx2, vx3; - calcMacrosFct(f, rho, vx1, vx2, vx3); - - switch (direction) - { - case E: - f[E] = ftemp[E] * (one_over_sqrt3 + vx1) + (1.0 - one_over_sqrt3 - vx1)*f[E] ; - f[NE] = ftemp[NE] * (one_over_sqrt3 + vx1) + (1.0 - one_over_sqrt3 - vx1)*f[NE] ; - f[SE] = ftemp[SE] * (one_over_sqrt3 + vx1) + (1.0 - one_over_sqrt3 - vx1)*f[SE] ; - f[TE] = ftemp[TE] * (one_over_sqrt3 + vx1) + (1.0 - one_over_sqrt3 - vx1)*f[TE] ; - f[BE] = ftemp[BE] * (one_over_sqrt3 + vx1) + (1.0 - one_over_sqrt3 - vx1)*f[BE] ; - f[TNE] = ftemp[TNE] * (one_over_sqrt3 + vx1) + (1.0 - one_over_sqrt3 - vx1)*f[TNE] ; - f[TSE] = ftemp[TSE] * (one_over_sqrt3 + vx1) + (1.0 - one_over_sqrt3 - vx1)*f[TSE] ; - f[BNE] = ftemp[BNE] * (one_over_sqrt3 + vx1) + (1.0 - one_over_sqrt3 - vx1)*f[BNE] ; - f[BSE] = ftemp[BSE] * (one_over_sqrt3 + vx1) + (1.0 - one_over_sqrt3 - vx1)*f[BSE] ; - - distributions->setDistributionInvForDirection(f[E], x1+DX1[W], x2+DX2[W], x3+DX3[W], W); - distributions->setDistributionInvForDirection(f[NE], x1+DX1[SW], x2+DX2[SW], x3+DX3[SW], SW); - distributions->setDistributionInvForDirection(f[SE], x1+DX1[NW], x2+DX2[NW], x3+DX3[NW], NW); - distributions->setDistributionInvForDirection(f[TE], x1+DX1[BW], x2+DX2[BW], x3+DX3[BW], BW); - distributions->setDistributionInvForDirection(f[BE], x1+DX1[TW], x2+DX2[TW], x3+DX3[TW], TW); - distributions->setDistributionInvForDirection(f[TNE], x1+DX1[BSW], x2+DX2[BSW], x3+DX3[BSW], BSW); - distributions->setDistributionInvForDirection(f[TSE], x1+DX1[BNW], x2+DX2[BNW], x3+DX3[BNW], BNW); - distributions->setDistributionInvForDirection(f[BNE], x1+DX1[TSW], x2+DX2[TSW], x3+DX3[TSW], TSW); - distributions->setDistributionInvForDirection(f[BSE], x1+DX1[TNW], x2+DX2[TNW], x3+DX3[TNW], TNW); - break; - case W: - f[W] = ftemp[W] * (one_over_sqrt3 - vx1) + (1.0 - one_over_sqrt3 + vx1)*f[W] ; - f[NW] = ftemp[NW] * (one_over_sqrt3 - vx1) + (1.0 - one_over_sqrt3 + vx1)*f[NW] ; - f[SW] = ftemp[SW] * (one_over_sqrt3 - vx1) + (1.0 - one_over_sqrt3 + vx1)*f[SW] ; - f[TW] = ftemp[TW] * (one_over_sqrt3 - vx1) + (1.0 - one_over_sqrt3 + vx1)*f[TW] ; - f[BW] = ftemp[BW] * (one_over_sqrt3 - vx1) + (1.0 - one_over_sqrt3 + vx1)*f[BW] ; - f[TNW] = ftemp[TNW] * (one_over_sqrt3 - vx1) + (1.0 - one_over_sqrt3 + vx1)*f[TNW]; - f[TSW] = ftemp[TSW] * (one_over_sqrt3 - vx1) + (1.0 - one_over_sqrt3 + vx1)*f[TSW]; - f[BNW] = ftemp[BNW] * (one_over_sqrt3 - vx1) + (1.0 - one_over_sqrt3 + vx1)*f[BNW]; - f[BSW] = ftemp[BSW] * (one_over_sqrt3 - vx1) + (1.0 - one_over_sqrt3 + vx1)*f[BSW]; - - distributions->setDistributionInvForDirection(f[W], x1+DX1[E], x2+DX2[E], x3+DX3[E], E); - distributions->setDistributionInvForDirection(f[NW], x1+DX1[SE], x2+DX2[SE], x3+DX3[SE], SE); - distributions->setDistributionInvForDirection(f[SW], x1+DX1[NE], x2+DX2[NE], x3+DX3[NE], NE); - distributions->setDistributionInvForDirection(f[TW], x1+DX1[BE], x2+DX2[BE], x3+DX3[BE], BE); - distributions->setDistributionInvForDirection(f[BW], x1+DX1[TE], x2+DX2[TE], x3+DX3[TE], TE); - distributions->setDistributionInvForDirection(f[TNW], x1+DX1[BSE], x2+DX2[BSE], x3+DX3[BSE], BSE); - distributions->setDistributionInvForDirection(f[TSW], x1+DX1[BNE], x2+DX2[BNE], x3+DX3[BNE], BNE); - distributions->setDistributionInvForDirection(f[BNW], x1+DX1[TSE], x2+DX2[TSE], x3+DX3[TSE], TSE); - distributions->setDistributionInvForDirection(f[BSW], x1+DX1[TNE], x2+DX2[TNE], x3+DX3[TNE], TNE); - break; - case N: - f[N] = ftemp[N] * (one_over_sqrt3 + vx2) + (1.0 - one_over_sqrt3 - vx2)*f[N] ; - f[NE] = ftemp[NE] * (one_over_sqrt3 + vx2) + (1.0 - one_over_sqrt3 - vx2)*f[NE] ; - f[NW] = ftemp[NW] * (one_over_sqrt3 + vx2) + (1.0 - one_over_sqrt3 - vx2)*f[NW] ; - f[TN] = ftemp[TN] * (one_over_sqrt3 + vx2) + (1.0 - one_over_sqrt3 - vx2)*f[TN] ; - f[BN] = ftemp[BN] * (one_over_sqrt3 + vx2) + (1.0 - one_over_sqrt3 - vx2)*f[BN] ; - f[TNE] = ftemp[TNE] * (one_over_sqrt3 + vx2) + (1.0 - one_over_sqrt3 - vx2)*f[TNE] ; - f[TNW] = ftemp[TNW] * (one_over_sqrt3 + vx2) + (1.0 - one_over_sqrt3 - vx2)*f[TNW] ; - f[BNE] = ftemp[BNE] * (one_over_sqrt3 + vx2) + (1.0 - one_over_sqrt3 - vx2)*f[BNE] ; - f[BNW] = ftemp[BNW] * (one_over_sqrt3 + vx2) + (1.0 - one_over_sqrt3 - vx2)*f[BNW] ; - - distributions->setDistributionInvForDirection(f[N], x1+DX1[S], x2+DX2[S], x3+DX3[S], S); - distributions->setDistributionInvForDirection(f[NE], x1+DX1[SW], x2+DX2[SW], x3+DX3[SW], SW); - distributions->setDistributionInvForDirection(f[NW], x1+DX1[SE], x2+DX2[SE], x3+DX3[SE], SE); - distributions->setDistributionInvForDirection(f[TN], x1+DX1[BS], x2+DX2[BS], x3+DX3[BS], BS); - distributions->setDistributionInvForDirection(f[BN], x1+DX1[TS], x2+DX2[TS], x3+DX3[TS], TS); - distributions->setDistributionInvForDirection(f[TNE], x1+DX1[BSW], x2+DX2[BSW], x3+DX3[BSW], BSW); - distributions->setDistributionInvForDirection(f[TNW], x1+DX1[BSE], x2+DX2[BSE], x3+DX3[BSE], BSE); - distributions->setDistributionInvForDirection(f[BNE], x1+DX1[TSW], x2+DX2[TSW], x3+DX3[TSW], TSW); - distributions->setDistributionInvForDirection(f[BNW], x1+DX1[TSE], x2+DX2[TSE], x3+DX3[TSE], TSE); - break; - case S: - f[S] = ftemp[S] * (one_over_sqrt3 - vx2) + (1.0 - one_over_sqrt3 + vx2)*f[S] ; - f[SE] = ftemp[SE] * (one_over_sqrt3 - vx2) + (1.0 - one_over_sqrt3 + vx2)*f[SE] ; - f[SW] = ftemp[SW] * (one_over_sqrt3 - vx2) + (1.0 - one_over_sqrt3 + vx2)*f[SW] ; - f[TS] = ftemp[TS] * (one_over_sqrt3 - vx2) + (1.0 - one_over_sqrt3 + vx2)*f[TS] ; - f[BS] = ftemp[BS] * (one_over_sqrt3 - vx2) + (1.0 - one_over_sqrt3 + vx2)*f[BS] ; - f[TSE] = ftemp[TSE] * (one_over_sqrt3 - vx2) + (1.0 - one_over_sqrt3 + vx2)*f[TSE] ; - f[TSW] = ftemp[TSW] * (one_over_sqrt3 - vx2) + (1.0 - one_over_sqrt3 + vx2)*f[TSW] ; - f[BSE] = ftemp[BSE] * (one_over_sqrt3 - vx2) + (1.0 - one_over_sqrt3 + vx2)*f[BSE] ; - f[BSW] = ftemp[BSW] * (one_over_sqrt3 - vx2) + (1.0 - one_over_sqrt3 + vx2)*f[BSW] ; - - distributions->setDistributionInvForDirection(f[S], x1+DX1[N], x2+DX2[N], x3+DX3[N], N); - distributions->setDistributionInvForDirection(f[SE], x1+DX1[NW], x2+DX2[NW], x3+DX3[NW], NW); - distributions->setDistributionInvForDirection(f[SW], x1+DX1[NE], x2+DX2[NE], x3+DX3[NE], NE); - distributions->setDistributionInvForDirection(f[TS], x1+DX1[BN], x2+DX2[BN], x3+DX3[BN], BN); - distributions->setDistributionInvForDirection(f[BS], x1+DX1[TN], x2+DX2[TN], x3+DX3[TN], TN); - distributions->setDistributionInvForDirection(f[TSE], x1+DX1[BNW], x2+DX2[BNW], x3+DX3[BNW], BNW); - distributions->setDistributionInvForDirection(f[TSW], x1+DX1[BNE], x2+DX2[BNE], x3+DX3[BNE], BNE); - distributions->setDistributionInvForDirection(f[BSE], x1+DX1[TNW], x2+DX2[TNW], x3+DX3[TNW], TNW); - distributions->setDistributionInvForDirection(f[BSW], x1+DX1[TNE], x2+DX2[TNE], x3+DX3[TNE], TNE); - break; - case T: - f[T] = ftemp[T] * (one_over_sqrt3 + vx3) + (1.0 - one_over_sqrt3 - vx3)*f[T] ; - f[TE] = ftemp[TE] * (one_over_sqrt3 + vx3) + (1.0 - one_over_sqrt3 - vx3)*f[TE] ; - f[TW] = ftemp[TW] * (one_over_sqrt3 + vx3) + (1.0 - one_over_sqrt3 - vx3)*f[TW] ; - f[TN] = ftemp[TN] * (one_over_sqrt3 + vx3) + (1.0 - one_over_sqrt3 - vx3)*f[TN] ; - f[TS] = ftemp[TS] * (one_over_sqrt3 + vx3) + (1.0 - one_over_sqrt3 - vx3)*f[TS] ; - f[TNE] = ftemp[TNE] * (one_over_sqrt3 + vx3) + (1.0 - one_over_sqrt3 - vx3)*f[TNE] ; - f[TNW] = ftemp[TNW] * (one_over_sqrt3 + vx3) + (1.0 - one_over_sqrt3 - vx3)*f[TNW] ; - f[TSE] = ftemp[TSE] * (one_over_sqrt3 + vx3) + (1.0 - one_over_sqrt3 - vx3)*f[TSE] ; - f[TSW] = ftemp[TSW] * (one_over_sqrt3 + vx3) + (1.0 - one_over_sqrt3 - vx3)*f[TSW] ; - - distributions->setDistributionInvForDirection(f[T], x1+DX1[B], x2+DX2[B], x3+DX3[B], B); - distributions->setDistributionInvForDirection(f[TE], x1+DX1[BW], x2+DX2[BW], x3+DX3[BW], BW); - distributions->setDistributionInvForDirection(f[TW], x1+DX1[BE], x2+DX2[BE], x3+DX3[BE], BE); - distributions->setDistributionInvForDirection(f[TN], x1+DX1[BS], x2+DX2[BS], x3+DX3[BS], BS); - distributions->setDistributionInvForDirection(f[TS], x1+DX1[BN], x2+DX2[BN], x3+DX3[BN], BN); - distributions->setDistributionInvForDirection(f[TNE], x1+DX1[BSW], x2+DX2[BSW], x3+DX3[BSW], BSW); - distributions->setDistributionInvForDirection(f[TNW], x1+DX1[BSE], x2+DX2[BSE], x3+DX3[BSE], BSE); - distributions->setDistributionInvForDirection(f[TSE], x1+DX1[BNW], x2+DX2[BNW], x3+DX3[BNW], BNW); - distributions->setDistributionInvForDirection(f[TSW], x1+DX1[BNE], x2+DX2[BNE], x3+DX3[BNE], BNE); - break; - case B: - f[B] = ftemp[B] * (one_over_sqrt3 - vx3) + (1.0 - one_over_sqrt3 + vx3)*f[B] ; - f[BE] = ftemp[BE] * (one_over_sqrt3 - vx3) + (1.0 - one_over_sqrt3 + vx3)*f[BE] ; - f[BW] = ftemp[BW] * (one_over_sqrt3 - vx3) + (1.0 - one_over_sqrt3 + vx3)*f[BW] ; - f[BN] = ftemp[BN] * (one_over_sqrt3 - vx3) + (1.0 - one_over_sqrt3 + vx3)*f[BN] ; - f[BS] = ftemp[BS] * (one_over_sqrt3 - vx3) + (1.0 - one_over_sqrt3 + vx3)*f[BS] ; - f[BNE] = ftemp[BNE] * (one_over_sqrt3 - vx3) + (1.0 - one_over_sqrt3 + vx3)*f[BNE] ; - f[BNW] = ftemp[BNW] * (one_over_sqrt3 - vx3) + (1.0 - one_over_sqrt3 + vx3)*f[BNW] ; - f[BSE] = ftemp[BSE] * (one_over_sqrt3 - vx3) + (1.0 - one_over_sqrt3 + vx3)*f[BSE] ; - f[BSW] = ftemp[BSW] * (one_over_sqrt3 - vx3) + (1.0 - one_over_sqrt3 + vx3)*f[BSW] ; - - distributions->setDistributionInvForDirection(f[B], x1+DX1[T], x2+DX2[T], x3+DX3[T], T); - distributions->setDistributionInvForDirection(f[BE], x1+DX1[TW], x2+DX2[TW], x3+DX3[TW], TW); - distributions->setDistributionInvForDirection(f[BW], x1+DX1[TE], x2+DX2[TE], x3+DX3[TE], TE); - distributions->setDistributionInvForDirection(f[BN], x1+DX1[TS], x2+DX2[TS], x3+DX3[TS], TS); - distributions->setDistributionInvForDirection(f[BS], x1+DX1[TN], x2+DX2[TN], x3+DX3[TN], TN); - distributions->setDistributionInvForDirection(f[BNE], x1+DX1[TSW], x2+DX2[TSW], x3+DX3[TSW], TSW); - distributions->setDistributionInvForDirection(f[BNW], x1+DX1[TSE], x2+DX2[TSE], x3+DX3[TSE], TSE); - distributions->setDistributionInvForDirection(f[BSE], x1+DX1[TNW], x2+DX2[TNW], x3+DX3[TNW], TNW); - distributions->setDistributionInvForDirection(f[BSW], x1+DX1[TNE], x2+DX2[TNE], x3+DX3[TNE], TNE); - break; - default: - UB_THROW(UbException(UB_EXARGS, "It isn't implemented non reflecting density boundary for this direction!")); - } -} - diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.h deleted file mode 100644 index 4effed280..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef NonReflectingOutflowBCAlgorithm_h__ -#define NonReflectingOutflowBCAlgorithm_h__ - -#include "BCAlgorithm.h" -#include <PointerDefinitions.h> - -class DistributionArray3D; - -class NonReflectingOutflowBCAlgorithm : public BCAlgorithm -{ -public: - NonReflectingOutflowBCAlgorithm(); - ~NonReflectingOutflowBCAlgorithm(); - SPtr<BCAlgorithm> clone(); - void addDistributions(SPtr<DistributionArray3D> distributions); - void applyBC() override; -}; -#endif // NonReflectingDensityBCAlgorithm_h__ diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCAdapter.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCAdapter.cpp deleted file mode 100644 index 9e367fa99..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCAdapter.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "SlipBCAdapter.h" -#include "D3Q27System.h" -#include "D3Q27Interactor.h" -#include "numerics/geometry3d/GbCuboid3D.h" - - -//*==========================================================*/ -//ObObject* D3Q27SlipBCAdapterCreator::createObObject() -//{ -// return new D3Q27SlipBCAdapter; -//} -//*==========================================================*/ -//ObObjectCreator* D3Q27SlipBCAdapter::getCreator() -//{ -// return D3Q27SlipBCAdapterCreator::getInstance(); -//} -//*==========================================================*/ -void SlipBCAdapter::adaptBC(const D3Q27Interactor& interactor, SPtr<BoundaryConditions> bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& time) -{ - ////////////////////////////////////////////////////////////////////////// - //>>> nur workaround! -> Hendrick nach normalen berechnung aus qs fragen - - GbCuboid3DPtr geo = dynamicPointerCast<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/src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCAdapter.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCAdapter.h deleted file mode 100644 index f846d405f..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCAdapter.h +++ /dev/null @@ -1,89 +0,0 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#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, SPtr<BoundaryConditions> 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, SPtr<BoundaryConditions> bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& time=0); - - //------------- implements D3Q27BoundaryConditionAdapter ----- end - -private: - - -}; - -#endif - diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.cpp deleted file mode 100644 index 508fcbae3..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "SlipBCAlgorithm.h" -#include "DistributionArray3D.h" -#include "BoundaryConditions.h" - -SlipBCAlgorithm::SlipBCAlgorithm() -{ - BCAlgorithm::type = BCAlgorithm::SlipBCAlgorithm; - BCAlgorithm::preCollision = false; -} -////////////////////////////////////////////////////////////////////////// -SlipBCAlgorithm::~SlipBCAlgorithm() -{ - -} -////////////////////////////////////////////////////////////////////////// -SPtr<BCAlgorithm> SlipBCAlgorithm::clone() -{ - SPtr<BCAlgorithm> bc(new SlipBCAlgorithm()); - return bc; -} -////////////////////////////////////////////////////////////////////////// -void SlipBCAlgorithm::addDistributions(SPtr<DistributionArray3D> 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, drho; - calcMacrosFct(f, drho, vx1, vx2, vx3); - calcFeqFct(feq, drho, 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! - - rho = 1.0+drho*compressibleFactor; - - for (int fdir = D3Q27System::FSTARTDIR; fdir<=D3Q27System::FENDDIR; fdir++) - { - if (bcPtr->hasSlipBoundaryFlag(fdir)) - { - //quadratic bounce back - const int invDir = D3Q27System::INVDIR[fdir]; - LBMReal q = 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*rho)/(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/src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.h deleted file mode 100644 index 423cde915..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/SlipBCAlgorithm.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef SlipBCAlgorithm_h__ -#define SlipBCAlgorithm_h__ - -#include "BCAlgorithm.h" -#include <PointerDefinitions.h> - -class DistributionArray3D; - -class SlipBCAlgorithm : public BCAlgorithm -{ -public: - SlipBCAlgorithm(); - virtual ~SlipBCAlgorithm(); - SPtr<BCAlgorithm> clone(); - void addDistributions(SPtr<DistributionArray3D> distributions); - void applyBC() override; -}; -#endif // SlipBCAlgorithm_h__ diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/ThinWallBCProcessor.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/ThinWallBCProcessor.cpp deleted file mode 100644 index 89627e235..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/ThinWallBCProcessor.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "ThinWallBCProcessor.h" - -#include "ThinWallNoSlipBCAlgorithm.h" - -#include "LBMKernel.h" - -ThinWallBCProcessor::ThinWallBCProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -ThinWallBCProcessor::ThinWallBCProcessor(SPtr<LBMKernel> kernel) : BCProcessor(kernel) -{ - -} -////////////////////////////////////////////////////////////////////////// -ThinWallBCProcessor::~ThinWallBCProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -SPtr<BCProcessor> ThinWallBCProcessor::clone(SPtr<LBMKernel> kernel) -{ - SPtr<BCProcessor> bcProcessor(new ThinWallBCProcessor(kernel)); - return bcProcessor; -} -////////////////////////////////////////////////////////////////////////// -void ThinWallBCProcessor::applyPostCollisionBC() -{ - BCProcessor::applyPostCollisionBC(); - - for(SPtr<BCAlgorithm> bc : postBC) - { - if (bc->getType() == BCAlgorithm::ThinWallNoSlipBCAlgorithm) - { - dynamicPointerCast<ThinWallNoSlipBCAlgorithm>(bc)->setPass(2); - bc->applyBC(); - dynamicPointerCast<ThinWallNoSlipBCAlgorithm>(bc)->setPass(1); - } - } -} - - diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/ThinWallBCProcessor.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/ThinWallBCProcessor.h deleted file mode 100644 index 63ff19dee..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/ThinWallBCProcessor.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef ThinWallBCProcessor_H -#define ThinWallBCProcessor_H - -#include <PointerDefinitions.h> - -#include "BCProcessor.h" - -class LBMKernel; - -class ThinWallBCProcessor : public BCProcessor -{ -public: - ThinWallBCProcessor(); - ThinWallBCProcessor(SPtr<LBMKernel> kernel); - ~ThinWallBCProcessor(); - SPtr<BCProcessor> clone(SPtr<LBMKernel> kernel); - void applyPostCollisionBC(); -protected: -private: - -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.cpp deleted file mode 100644 index 9143af429..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "ThinWallNoSlipBCAlgorithm.h" - -#include "D3Q27EsoTwist3DSplittedVector.h" -#include "BoundaryConditions.h" - -ThinWallNoSlipBCAlgorithm::ThinWallNoSlipBCAlgorithm() -{ - BCAlgorithm::type = BCAlgorithm::ThinWallNoSlipBCAlgorithm; - BCAlgorithm::preCollision = false; - pass = 1; -} -////////////////////////////////////////////////////////////////////////// -ThinWallNoSlipBCAlgorithm::~ThinWallNoSlipBCAlgorithm() -{ - -} -////////////////////////////////////////////////////////////////////////// -SPtr<BCAlgorithm> ThinWallNoSlipBCAlgorithm::clone() -{ - SPtr<BCAlgorithm> 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(SPtr<DistributionArray3D> distributions) -{ - this->distributions = distributions; -} -////////////////////////////////////////////////////////////////////////// -void ThinWallNoSlipBCAlgorithm::setPass(int pass) -{ - this->pass = pass; -} diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.h deleted file mode 100644 index 6f54bc766..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/ThinWallNoSlipBCAlgorithm.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef ThinWallNoSlipBCAlgorithm_h__ -#define ThinWallNoSlipBCAlgorithm_h__ - -#include "BCAlgorithm.h" -#include <PointerDefinitions.h> - -class DistributionArray3D; - -class ThinWallNoSlipBCAlgorithm : public BCAlgorithm -{ -public: - ThinWallNoSlipBCAlgorithm(); - virtual ~ThinWallNoSlipBCAlgorithm(); - SPtr<BCAlgorithm> clone(); - void addDistributions(SPtr<DistributionArray3D> distributions); - void setPass(int pass); - void applyBC() override; - -protected: - SPtr<DistributionArray3D> distributionsTemp; -private: - int pass; - LBMReal fTemp[D3Q27System::ENDF + 1]; -}; -#endif // ThinWallNoSlipBCAlgorithm_h__ diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityBCAdapter.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityBCAdapter.cpp index 2d7d4857b..7089da4e4 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityBCAdapter.cpp +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityBCAdapter.cpp @@ -1,306 +1,339 @@ -#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, SPtr<BoundaryConditions> 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, SPtr<BoundaryConditions> 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, SPtr<BoundaryConditions> 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(); -} - - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file VelocityBCAdapter.cpp +//! \ingroup BoundarConditions +//! \author Sören Freudiger +//======================================================================================= + +#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, SPtr<BoundaryConditions> 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, SPtr<BoundaryConditions> 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, SPtr<BoundaryConditions> 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((LBMReal)tmpVx1Function->Eval()); + if(tmpVx2Function) bc->setBoundaryVelocityX2((LBMReal)tmpVx2Function->Eval()); + if(tmpVx3Function) bc->setBoundaryVelocityX3((LBMReal)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/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityBCAdapter.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityBCAdapter.h index e17bce373..1ed2bdde1 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityBCAdapter.h +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityBCAdapter.h @@ -1,151 +1,162 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#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, SPtr<BoundaryConditions> 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, SPtr<BoundaryConditions> 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, SPtr<BoundaryConditions> 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: - -}; - -#endif +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file VelocityBCAdapter.h +//! \ingroup BoundarConditions +//! \author Sören Freudiger +//======================================================================================= +#ifndef VelocityBCAdapter_H +#define VelocityBCAdapter_H + +#include <iostream> +#include <string> +#include <sstream> +#include <vector> + +#include <basics/utilities/UbInfinity.h> + +#include <BCAdapter.h> +#include <BCFunction.h> + +//! \brief A class provides an interface for velocity boundary condition in grid generator. + +//! \details +//! Example: +//! \code{.cpp} vector<BCFunction> vx1BCs,vx2BCs,vx3BCs; +//! vx1BCs.push_back(BCFunction(0.01 , 0 , 100) ); //t=[0 ..100[ -> vx1 = 0.01 +//! vx1BCs.push_back(BCFunction(0.004, 100, 200) ); //t=[100..200[ -> vx1 = 0.004 +//! vx1BCs.push_back(BCFunction(0.03 , 200, 400) ); //t=[200..400] -> vx1 = 0.03 +//! +//! vx2BCs.push_back(BCFunction(0.02 , 0 , 200) ); //t=[0 ..200[ -> vx2 = 0.02 +//! vx2BCs.push_back(BCFunction(0.002, 200, 300) ); //t=[200..300[ -> vx2 = 0.002 +//! vx2BCs.push_back(BCFunction(0.043, 300, 600) ); //t=[300..600] -> vx2 = 0.043 +//! +//! VelocityBCAdapter 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 ... +//! \endcode +//! Example of parabolic inflow: +//! \code{.cpp} +//! mu::Parser fct; +//! fct.SetExpr("max(vmax*(1.0-4.0*((x2-x2_vmax)^2+(x3-x3_vmax)^2)/H^2),0.0)"); //paraboloid (with vmax for (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" , diameterOfPipe); +//! fct.DefineConst("vmax" , vmax ); +//! VelocityBCAdapter velBC(true, false ,false ,fct, 0, BCFunction::INFCONST); +//! \endcode + +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); } + + //The following is meant for moving objects... + 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 BCAdapter ----- 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, SPtr<BoundaryConditions> 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, SPtr<BoundaryConditions> bc, const double& worldX1, const double& worldX2, const double& worldX3, const double& time=0 ); + + //------------- implements BCAdapter ----- 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 is determined automatically via BCFunction intervals! + 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, SPtr<BoundaryConditions> 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; + +}; + +#endif diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.cpp index ece5e7edc..d61840a7e 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.cpp +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.cpp @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file VelocityBCAlgorithm.cpp +//! \ingroup BoundarConditions +//! \author Konstantin Kutscher +//======================================================================================= + #include "VelocityBCAlgorithm.h" #include "DistributionArray3D.h" #include "BoundaryConditions.h" @@ -39,9 +72,9 @@ void VelocityBCAlgorithm::applyBC() if (bcPtr->hasVelocityBoundaryFlag(fdir)) { const int invDir = D3Q27System::INVDIR[fdir]; - LBMReal q = bcPtr->getQ(invDir);// m+m q=0 stabiler + LBMReal q = bcPtr->getQ(invDir); 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)); + LBMReal fReturn = f[invDir] - velocity; distributions->setDistributionForDirection(fReturn, x1+D3Q27System::DX1[invDir], x2+D3Q27System::DX2[invDir], x3+D3Q27System::DX3[invDir], fdir); } } diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.h index c33ae6816..03b33779e 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.h +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityBCAlgorithm.h @@ -1,11 +1,45 @@ -#ifndef VelocityBoundaryCondition_h__ -#define VelocityBoundaryCondition_h__ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file VelocityBCAlgorithm.h +//! \ingroup BoundarConditions +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef VelocityBCAlgorithm_H +#define VelocityBCAlgorithm_H #include "BCAlgorithm.h" #include <PointerDefinitions.h> class DistributionArray3D; +//! \brief A class implements velocyty boundary condition class VelocityBCAlgorithm : public BCAlgorithm { public: @@ -16,5 +50,5 @@ public: void applyBC() override; }; -#endif // VelocityBoundaryCondition_h__ +#endif diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityWithDensityBCAlgorithm.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityWithDensityBCAlgorithm.cpp deleted file mode 100644 index 5a1f95caf..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityWithDensityBCAlgorithm.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "VelocityWithDensityBCAlgorithm.h" -#include "DistributionArray3D.h" -#include "BCArray3D.h" - -VelocityWithDensityBCAlgorithm::VelocityWithDensityBCAlgorithm() -{ - BCAlgorithm::type = BCAlgorithm::VelocityWithDensityBCAlgorithm; - BCAlgorithm::preCollision = false; -} -////////////////////////////////////////////////////////////////////////// -VelocityWithDensityBCAlgorithm::~VelocityWithDensityBCAlgorithm() -{ - -} -////////////////////////////////////////////////////////////////////////// -SPtr<BCAlgorithm> VelocityWithDensityBCAlgorithm::clone() -{ - SPtr<BCAlgorithm> bc(new VelocityWithDensityBCAlgorithm()); - return bc; -} -////////////////////////////////////////////////////////////////////////// -void VelocityWithDensityBCAlgorithm::addDistributions(SPtr<DistributionArray3D> distributions) -{ - this->distributions = distributions; -} -////////////////////////////////////////////////////////////////////////// -void VelocityWithDensityBCAlgorithm::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); - - 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); - // //normal velocity bc: 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)); - // //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]; - // LBMReal fReturn = ((1.0 - q) / (1.0 + q))*((f[invDir] - feq[invDir]*collFactor) / (1.0 - collFactor)) + ((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); - //} - - int nX1 = x1 + D3Q27System::DX1[fdir]; - int nX2 = x2 + D3Q27System::DX2[fdir]; - int nX3 = x3 + D3Q27System::DX3[fdir]; - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int maxX1 = (int)bcArray->getNX1(); - int maxX2 = (int)bcArray->getNX2(); - int maxX3 = (int)bcArray->getNX3(); - - if (minX1 <= nX1 && maxX1 > nX1 && minX2 <= nX2 && maxX2 > nX2 && minX3 <= nX3 && maxX3 > nX3) - { - if (bcArray->isSolid(nX1,nX2,nX3)) - { - const int invDir = D3Q27System::INVDIR[fdir]; - LBMReal q =1.0;// bcPtr->getQ(invDir);// m+m q=0 stabiler - LBMReal velocity = bcPtr->getBoundaryVelocity(fdir); - //LBMReal fReturn = ((1.0 - q) / (1.0 + q))*((f[fdir] - feq[fdir]*collFactor) / (1.0 - collFactor)) + ((q*(f[fdir] + f[invDir]) - velocity*rho) / (1.0 + q))-drho*D3Q27System::WEIGTH[invDir]; - - //if q=1 - //LBMReal fReturn = ((q*(f[fdir] + f[invDir]) - velocity*rho) / (1.0 + q))-drho*D3Q27System::WEIGTH[invDir]; - LBMReal fReturn = (f[fdir] + f[invDir] - velocity*rho) / 2.0 - drho*D3Q27System::WEIGTH[invDir]; - - distributions->setDistributionForDirection(fReturn, nX1, nX2, nX3, invDir); - } - } - - } -} diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityWithDensityBCAlgorithm.h b/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityWithDensityBCAlgorithm.h deleted file mode 100644 index 25ec70608..000000000 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/VelocityWithDensityBCAlgorithm.h +++ /dev/null @@ -1,24 +0,0 @@ -//! \file NonReflectingVelocityBCAlgorithm.h -//! \brief Class implements velocity bc for non reflecting pressure bc. -//! \author Konstantin Kutscher - -#ifndef VelocityWithDensityBCAlgorithm_h__ -#define VelocityWithDensityBCAlgorithm_h__ - -#include "BCAlgorithm.h" -#include <PointerDefinitions.h> - -class DistributionArray3D; - -//! \brief Class implements Dirichlet boundary condition for velocity. Set density in system. It is used together with non reflecting outflow. - -class VelocityWithDensityBCAlgorithm : public BCAlgorithm -{ -public: - VelocityWithDensityBCAlgorithm(); - ~VelocityWithDensityBCAlgorithm(); - SPtr<BCAlgorithm> clone(); - void addDistributions(SPtr<DistributionArray3D> distributions); - void applyBC(); -}; -#endif // NonReflectingVelocityBCAlgorithm_h__ diff --git a/src/cpu/VirtualFluidsCore/CMakeLists.txt b/src/cpu/VirtualFluidsCore/CMakeLists.txt index 48e357c49..d8bf322de 100644 --- a/src/cpu/VirtualFluidsCore/CMakeLists.txt +++ b/src/cpu/VirtualFluidsCore/CMakeLists.txt @@ -1,36 +1,6 @@ -################################################################# -### PACKAGES ### -################################################################# -#SET(WITH_SUBFOLDERS_FOR_SG TRUE) - -#INCLUDE(${SOURCE_ROOT}/ThirdParty/MuParser/CMakePackage.txt) - -#new VirtualFluids -#sINCLUDE(${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) -#INCLUDE(${SOURCE_ROOT}/VirtualFluidsCore/LBM/CMakePackage.txt) -#INCLUDE(${SOURCE_ROOT}/VirtualFluidsCore/Parallel/CMakePackage.txt) -#INCLUDE(${SOURCE_ROOT}/VirtualFluidsCore/Grid/CMakePackage.txt) -#INCLUDE(${SOURCE_ROOT}/VirtualFluidsCore/Visitors/CMakePackage.txt) -#INCLUDE(${SOURCE_ROOT}/VirtualFluidsCore/CoProcessors/CMakePackage.txt) -#INCLUDE(${SOURCE_ROOT}/VirtualFluidsCore/Utilities/CMakePackage.txt) - -#old VirtualFluids -#INCLUDE(${SOURCE_ROOT}/VirtualFluidsBasic/VirtualFluidsBasic.cmake) - -#FETOL -IF(${USE_FETOL}) -INCLUDE(${SOURCE_DIR}/VirtualFluidsCore/FETOL/CMakePackage.txt) -ENDIF() - INCLUDE(${CMAKE_CURRENT_LIST_DIR}/IncludsList.cmake) -#SET(CAB_ADDITIONAL_LINK_LIBRARIES muParserLib ${Boost_LIBRARIES} ${MPI_LIBRARY}) -SET(CAB_ADDITIONAL_LINK_LIBRARIES ${MPI_LIBRARY}) - IF(${USE_GCC}) SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} rt) SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} gomp) @@ -41,70 +11,16 @@ IF(${USE_INTEL}) SET(CAB_ADDITIONAL_LINK_FLAGS ${CAB_ADDITIONAL_LINK_FLAGS} parallel) ENDIF() -IF(${USE_ZOLTAN}) - INCLUDE_DIRECTORIES(${ZOLTAN_INCLUDEDIR}) - SET(LINK_LIBRARY optimized ${ZOLTAN_RELEASE_LIBRARY} debug ${ZOLTAN_DEBUG_LIBRARY}) - SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) -ENDIF() - -IF(${USE_METIS}) - SET(LINK_LIBRARY optimized ${METIS_RELEASE_LIBRARY} debug ${METIS_DEBUG_LIBRARY}) - SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) -ENDIF() - -IF(${USE_VTK}) - SET(LINK_LIBRARY optimized ${VTK_LIBRARIES} debug ${VTK_LIBRARIES}) - SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) -ENDIF() - -IF(${USE_CATALYST}) - SET(LINK_LIBRARY optimized vtkPVPythonCatalyst debug vtkPVPythonCatalyst ) - SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) - SET(LINK_LIBRARY optimized vtkParallelMPI debug vtkParallelMPI ) - SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) -ENDIF() - - -IF(${USE_PYTHON}) - SET(LINK_LIBRARY optimized ${PYTHON_LIBRARY} debug ${PYTHON_LIBRARY}) - SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) -ENDIF() - -IF(${USE_FETOL}) - SET(LINK_LIBRARY optimized ${BOND_RELEASE_LIBRARY} debug ${BOND_DEBUG_LIBRARY}) - SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) - - SET(LINK_LIBRARY optimized ${JAVA_JVM_LIBRARY} debug ${JAVA_JVM_LIBRARY}) - SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) - - SET(LINK_LIBRARY optimized ${YAML_RELEASE_LIBRARY} debug ${YAML_DEBUG_LIBRARY}) - SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) - - SET(LINK_LIBRARY optimized ${FETOL_RELEASE_LIBRARY} debug ${FETOL_DEBUG_LIBRARY}) - SET(CAB_ADDITIONAL_LINK_LIBRARIES ${CAB_ADDITIONAL_LINK_LIBRARIES} ${LINK_LIBRARY}) -ENDIF() - -IF(${USE_DEM_COUPLING}) - INCLUDE(${SOURCE_ROOT}/DemCoupling/DemCoupling.cmake) -ENDIF() - -#message("CAB_ADDITIONAL_LINK_LIBRARIES: " ${CAB_ADDITIONAL_LINK_LIBRARIES}) -################################################################# -### CREATE PROJECT ### -################################################################# -#CREATE_CAB_PROJECT(VirtualFluids STATIC) -#include (${CMAKE_SOURCE_DIR}/CMake/VirtualFluidsMacros.cmake) vf_add_library(BUILDTYPE static DEPENDS basics MuParser ${CAB_ADDITIONAL_LINK_LIBRARIES}) vf_get_library_name(library_name) target_include_directories(${library_name} PRIVATE ${CMAKE_SOURCE_DIR}/src/basics) -target_include_directories(${library_name} PRIVATE ${CMAKE_SOURCE_DIR}/src/basics/numerics/geometry3d) -target_include_directories(${library_name} PRIVATE ${CMAKE_SOURCE_DIR}/src/basics/numerics/geometry3d/Creator) -target_include_directories(${library_name} PRIVATE ${CMAKE_SOURCE_DIR}/src/basics/numerics/geometry3d/KdTree) +target_include_directories(${library_name} PRIVATE ${CMAKE_SOURCE_DIR}/src/basics/geometry3d) target_include_directories(${library_name} PRIVATE ${CMAKE_SOURCE_DIR}/src/basics/basics/container) target_include_directories(${library_name} PRIVATE ${CMAKE_SOURCE_DIR}/src/basics/basics/memory) target_include_directories(${library_name} PRIVATE ${CMAKE_SOURCE_DIR}/src/basics/basics/objects) target_include_directories(${library_name} PRIVATE ${CMAKE_SOURCE_DIR}/src/basics/basics/transmitter) target_include_directories(${library_name} PRIVATE ${CMAKE_SOURCE_DIR}/src/basics/basics/utilities) target_include_directories(${library_name} PRIVATE ${CMAKE_SOURCE_DIR}/src/basics/basics/writer) + diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.cpp deleted file mode 100644 index acf38b3fb..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* -* D3Q27AdjustForcingCoProcessor.cpp -* Author: Konstantin Kutscher -*/ -#include "AdjustForcingCoProcessor.h" - -#include <fstream> - -#include <SetForcingBlockVisitor.h> -#include "IntegrateValuesHelper.h" -#include "Communicator.h" -#include "UbScheduler.h" -#include "Grid3D.h" - -AdjustForcingCoProcessor::AdjustForcingCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, - const std::string& path, - SPtr<IntegrateValuesHelper> integrateValues, - double vTarged, - SPtr<Communicator> comm) - - : CoProcessor(grid, s), - path(path), - integrateValues(integrateValues), - comm(comm), - vx1Targed(vTarged), - forcing(forcing) -{ - //cnodes = integrateValues->getCNodes(); - root = comm->isRoot(); - - Ta = scheduler->getMaxStep(); - - Kpcrit = 3.0 / Ta;// 0.3; - Tcrit = 3.0 * Ta; // 30.0; - Tn = 0.5 * Tcrit; - Tv = 0.12 * Tcrit; - - Kp = 0.6 * Kpcrit; - Ki = Kp / Tn; - Kd = Kp * Tv; - - y = 0; - e = 0; - esum = 0; - eold = 0; - forcing = 0; - - if (root) - { - std::string fname = path + "/forcing/forcing.csv"; - std::ofstream ostr; - ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app); - if (!ostr) - { - ostr.clear(); - std::string path = UbSystem::getPathFromString(fname); - if (path.size() > 0) { UbSystem::makeDirectory(path); ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app); } - if (!ostr) throw UbException(UB_EXARGS, "couldn't open file " + fname); - } - ostr << "step;volume;vx1average;forcing\n"; - ostr.close(); - - ////////////////////////////////////////////////////////////////////////////////////////////////// - //temporary solution - std::string fNameCfg = path + "/forcing/forcing.cfg"; - std::ifstream istr2; - istr2.open(fNameCfg.c_str(), std::ios_base::in); - if (istr2) - { - istr2 >> forcing; - //istr2 >> esum; - //istr2 >> eold; - } - istr2.close(); - } - //////////////////////////////////////////////////////////////////////////////////////////////////////// -} -////////////////////////////////////////////////////////////////////////// -AdjustForcingCoProcessor::~AdjustForcingCoProcessor() -{ -} -////////////////////////////////////////////////////////////////////////// -void AdjustForcingCoProcessor::process(double step) -{ - if (scheduler->isDue(step)) - collectData(step); -} -////////////////////////////////////////////////////////////////////////// -void AdjustForcingCoProcessor::collectData(double step) -{ - ////////////////////////////////////////////////////////////////////////////////////////////////// - //temporary solution - if (root) - { - std::string fNameCfg = path + "/forcing/forcing.cfg"; - std::ofstream ostr2; - ostr2.open(fNameCfg.c_str(), std::ios_base::out); - if (!ostr2) - { - ostr2.clear(); - std::string path = UbSystem::getPathFromString(fNameCfg); - if (path.size() > 0) { UbSystem::makeDirectory(path); ostr2.open(fNameCfg.c_str(), std::ios_base::out); } - if (!ostr2) throw UbException(UB_EXARGS, "couldn't open file " + fNameCfg); - } - ostr2 << forcing << " " << esum << " " << eold; - ostr2.close(); - } - //////////////////////////////////////////////////////////////////////////////////////////////////////// - - integrateValues->calculateMQ(); - - if (root) - { - cellsVolume = integrateValues->getCellsVolume(); - double vx1 = integrateValues->getVx1(); - vx1Average = (vx1 / cellsVolume); - - ////////////////////////////////////////////////////////////////////////// - //PID-Controller (PID-Regler) - e = vx1Targed - vx1Average; - esum = esum + e; - y = Kp * e + Ki * Ta * esum + Kd * (e - eold) / Ta; - eold = e; - - forcing = forcing + y; - ////////////////////////////////////////////////////////////////////////// - } - ////////////////////////////////////////////////////////////////////////// - comm->broadcast(forcing); - - mu::Parser fctForcingX1, fctForcingX2, fctForcingX3; - fctForcingX1.SetExpr("Fx1"); - fctForcingX1.DefineConst("Fx1", forcing); - fctForcingX2.SetExpr("0.0"); - fctForcingX3.SetExpr("0.0"); - SetForcingBlockVisitor forcingVisitor(fctForcingX1, fctForcingX2, fctForcingX3); - grid->accept(forcingVisitor); - - //for(CalcNodes cn : cnodes) - //{ - // LBMKernel3DPtr kernel = cn.block->getKernel(); - // if (kernel) - // { - // kernel->setForcingX1(fctForcingX1); - // kernel->setWithForcing(true); - // } - // - //} - - if (root) - { - //UBLOG(logINFO, "D3Q27AdjustForcingCoProcessor step: " << static_cast<int>(step)); - //UBLOG(logINFO, "new forcing is: " << forcing); - std::string fname = path + "/forcing/forcing.csv"; - //std::string fname = path + "/forcing/forcing_"+UbSystem::toString(comm->getProcessID())+".csv"; - std::ofstream ostr; - ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app); - if (!ostr) - { - ostr.clear(); - std::string path = UbSystem::getPathFromString(fname); - if (path.size() > 0) { UbSystem::makeDirectory(path); ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app); } - if (!ostr) throw UbException(UB_EXARGS, "couldn't open file " + fname); - } - int istep = static_cast<int>(step); - - //ostr << istep << ";" << cellsVolume << ";" << vx1Average << "; " << forcing << "\n"; - ostr << istep << ";" << cellsVolume << ";" << vx1Average << "; " << forcing << "; " << e << "; " << esum << "; " << y <<"\n"; - ostr.close(); - - } -} diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.h deleted file mode 100644 index aa625291a..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/AdjustForcingCoProcessor.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef D3Q27ADJUSTFORCINGCoProcessor_H -#define D3Q27ADJUSTFORCINGCoProcessor_H - -#include <PointerDefinitions.h> -#include <string> - -#include "CoProcessor.h" - - -class Communicator; -class UbScheduler; -class Grid3D; -class IntegrateValuesHelper; - -//! \brief Computes forcing such that a given velocity (vx1Targed) is reached inside an averaging domain (h1). -//! \details Algorithm based on PID controller (proportional–integral–derivative controller). The parameters of PID controller estimation based on Ziegler–Nichols method. -//! Integrate values helper, scheduler must be set in test case. -//! \author: Konstantin Kutscher - -class AdjustForcingCoProcessor: public CoProcessor { -public: - AdjustForcingCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, - const std::string& path, - SPtr<IntegrateValuesHelper> integrateValues, - double vTarged, SPtr<Communicator> comm); - virtual ~AdjustForcingCoProcessor(); - //!< calls collect PostprocessData - void process(double step) override; -protected: - //!< object that can compute spacial average values in 3D-subdomain. - SPtr<IntegrateValuesHelper> integrateValues; - //!< compares velocity in integrateValues with target velocity and adjusts forcing accordingly. - void collectData(double step); - SPtr<Communicator> comm; -private: - double vx1Targed; //!< target velocity. - double forcing; //!< forcing at previous update step. - double cellsVolume; - double vx1Average; - bool root; - double Kpcrit; //Kp critical - double Tcrit; //the oscillation period - double Tn; - double Tv; - double e; - double Ta; - double Kp; - double Ki; - double Kd; - double y; - double esum; - double eold; - //std::vector<CalcNodes> cnodes; - std::string path; -}; - - -#endif /* D3Q27RHODIFFERENCECoProcessor_H_ */ diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.cpp deleted file mode 100644 index 474703728..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.cpp +++ /dev/null @@ -1,573 +0,0 @@ -#include "AverageValuesCoProcessor.h" - -#include "LBMKernel.h" -#include "BCProcessor.h" - -#include "basics/writer/WbWriterVtkXmlASCII.h" - -#include "DataSet3D.h" -#include "WbWriter.h" -#include "Grid3D.h" -#include "Block3D.h" -#include "UbScheduler.h" -#include "Communicator.h" -#include "BCArray3D.h" - -using namespace std; - -AverageValuesCoProcessor::AverageValuesCoProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -AverageValuesCoProcessor::AverageValuesCoProcessor(SPtr<Grid3D> grid, const std::string& path, WbWriter* const writer, - SPtr<UbScheduler> s, SPtr<UbScheduler> Avs, SPtr<UbScheduler> rsMeans, SPtr<UbScheduler> rsRMS, bool restart) - : CoProcessor(grid, s), - averageScheduler(Avs), - resetSchedulerMeans(rsMeans), - resetSchedulerRMS(rsRMS), - path(path), - writer(writer) -{ - resetStepMeans = (int)rsMeans->getMinBegin(); - resetStepRMS = (int)rsRMS->getMinBegin(); - averageInterval = (double)Avs->getMinStep(); - - gridRank = grid->getRank(); - 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]); - - if (blockVector[level].size() > 0) - compressible = blockVector[level][0]->getKernel()->getCompressible(); - - if (!restart) - { - for(SPtr<Block3D> block : blockVector[level]) - { - UbTupleInt3 nx = grid->getBlockNX(); - SPtr<AverageValuesArray3D> averageValues = SPtr<AverageValuesArray3D>(new AverageValuesArray3D(11, val<1>(nx)+1, val<2>(nx)+1, val<3>(nx)+1, 0.0)); - block->getKernel()->getDataSet()->setAverageValues(averageValues); - } - } - } - - // for musis special use - //initPlotDataZ(0.0); - //restartStep = 0.0; -} -////////////////////////////////////////////////////////////////////////// -void AverageValuesCoProcessor::process(double step) -{ - //resetRMS(step); - if(resetSchedulerRMS->isDue(step) ) - resetDataRMS(step); - - //reset(step); - if(resetSchedulerMeans->isDue(step) ) - resetDataMeans(step); - - if(averageScheduler->isDue(step) ){ - calculateAverageValues(step); - // for musis special use - //collectPlotDataZ(step); - } - if(scheduler->isDue(step) ){ - collectData(step); - - } - - UBLOG(logDEBUG3, "AverageValuesCoProcessor::update:" << step); -} - -void AverageValuesCoProcessor::resetDataRMS(double step) -{ - resetStepRMS=(int)step; - - for(int level = minInitLevel; level<=maxInitLevel;level++) - { - for(SPtr<Block3D> block : blockVector[level]) - { - if (block) - { - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - SPtr<AverageValuesArray3D> av = kernel->getDataSet()->getAverageValues(); - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int maxX1 = int(distributions->getNX1()); - int maxX2 = int(distributions->getNX2()); - int maxX3 = int(distributions->getNX3()); - - for(int ix3=minX3; ix3<maxX3-1; ix3++) - { - for(int ix2=minX2; ix2<maxX2-1; ix2++) - { - for(int ix1=minX1; ix1<maxX1-1; ix1++) - { - if(!bcArray->isUndefined(ix1,ix2,ix3) && !bcArray->isSolid(ix1,ix2,ix3)) - { - ////////////////////////////////////////////////////////////////////////// - //compute average values - ////////////////////////////////////////////////////////////////////////// - (*av)(AvVxx,ix1,ix2,ix3) = 0.0; - (*av)(AvVyy,ix1,ix2,ix3) = 0.0; - (*av)(AvVzz,ix1,ix2,ix3) = 0.0; - (*av)(AvVxy,ix1,ix2,ix3) = 0.0; - (*av)(AvVxz,ix1,ix2,ix3) = 0.0; - (*av)(AvVyz,ix1,ix2,ix3) = 0.0; - (*av)(AvPrms,ix1,ix2,ix3) = 0.0; - ////////////////////////////////////////////////////////////////////////// - } - } - } - } - } - } - } -} -////////////////////////////////////////////////////////////////////////// -void AverageValuesCoProcessor::resetDataMeans(double step) -{ - resetStepMeans=(int)step; - - for(int level = minInitLevel; level<=maxInitLevel;level++) - { - for(SPtr<Block3D> block : blockVector[level]) - { - if (block) - { - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - SPtr<AverageValuesArray3D> av = kernel->getDataSet()->getAverageValues(); - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int maxX1 = int(distributions->getNX1()); - int maxX2 = int(distributions->getNX2()); - int maxX3 = int(distributions->getNX3()); - - for(int ix3=minX3; ix3<maxX3-1; ix3++) - { - for(int ix2=minX2; ix2<maxX2-1; ix2++) - { - for(int ix1=minX1; ix1<maxX1-1; ix1++) - { - if(!bcArray->isUndefined(ix1,ix2,ix3) && !bcArray->isSolid(ix1,ix2,ix3)) - { - ////////////////////////////////////////////////////////////////////////// - //compute average values - ////////////////////////////////////////////////////////////////////////// - (*av)(AvVx,ix1,ix2,ix3) = 0.0; - (*av)(AvVy,ix1,ix2,ix3) = 0.0; - (*av)(AvVz,ix1,ix2,ix3) = 0.0; - (*av)(AvP,ix1,ix2,ix3) = 0.0; - ////////////////////////////////////////////////////////////////////////// - } - } - } - } - } - } - } -} -////////////////////////////////////////////////////////////////////////// -void AverageValuesCoProcessor::collectData(double step) -{ - int istep = int(step); - - for(int level = minInitLevel; level<=maxInitLevel;level++) - { - for(SPtr<Block3D> block : blockVector[level]) - { - if (block) - { - addData(block); - } - } - } - - string pfilePath, partPath, subfolder, cfilePath; - subfolder = "av"+UbSystem::toString(istep); - pfilePath = path+"/av/"+subfolder; - cfilePath = path+"/av/av_collection"; - partPath = pfilePath+"/av"+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; - SPtr<Communicator> comm = Communicator::getInstance(); - 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,"AverageValuesCoProcessor step: " << istep); - } - - clearData(); -} -////////////////////////////////////////////////////////////////////////// -void AverageValuesCoProcessor::clearData() -{ - nodes.clear(); - cells.clear(); - datanames.clear(); - data.clear(); -} -////////////////////////////////////////////////////////////////////////// -void AverageValuesCoProcessor::addData(const SPtr<Block3D> block) -{ - UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); - UbTupleDouble3 blockLengths = grid->getBlockLengths(block); - UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); - double dx = grid->getDeltaX(block); - - //Diese Daten werden geschrieben: - datanames.resize(0); - datanames.push_back("AvVx"); - datanames.push_back("AvVy"); - datanames.push_back("AvVz"); - datanames.push_back("AvVxx"); - datanames.push_back("AvVyy"); - datanames.push_back("AvVzz"); - datanames.push_back("AvVxy"); - datanames.push_back("AvVxz"); - datanames.push_back("AvVyz"); - datanames.push_back("AvP"); - datanames.push_back("AvPrms"); - - - data.resize(datanames.size()); - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - SPtr<AverageValuesArray3D> av = kernel->getDataSet()->getAverageValues(); - //int ghostLayerWidth = kernel->getGhostLayerWidth(); - - //knotennummerierung faengt immer bei 0 an! - unsigned int SWB,SEB,NEB,NWB,SWT,SET,NET,NWT; - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int maxX1 = int(distributions->getNX1()); - int maxX2 = int(distributions->getNX2()); - int maxX3 = int(distributions->getNX3()); - - //nummern vergeben und node vector erstellen + daten sammeln - CbArray3D<int> nodeNumbers((int)maxX1, (int)maxX2, (int)maxX3,-1); - - maxX1 -= 2; - maxX2 -= 2; - maxX3 -= 2; - - //D3Q27BoundaryConditionPtr bcPtr; - - int nr = (int)nodes.size(); - - for(int ix3=minX3; ix3<=maxX3; ix3++) - { - for(int ix2=minX2; ix2<=maxX2; ix2++) - { - for(int ix1=minX1; ix1<=maxX1; ix1++) - { - if(!bcArray->isUndefined(ix1,ix2,ix3) && !bcArray->isSolid(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)) ); - - LBMReal vx=(*av)(AvVx,ix1,ix2,ix3); - LBMReal vy=(*av)(AvVy,ix1,ix2,ix3); - LBMReal vz=(*av)(AvVz,ix1,ix2,ix3); - - LBMReal vxx=(*av)(AvVxx,ix1,ix2,ix3); - LBMReal vyy=(*av)(AvVyy,ix1,ix2,ix3); - LBMReal vzz=(*av)(AvVzz,ix1,ix2,ix3); - - LBMReal vxy=(*av)(AvVxy,ix1,ix2,ix3); - LBMReal vxz=(*av)(AvVxz,ix1,ix2,ix3); - LBMReal vyz=(*av)(AvVyz,ix1,ix2,ix3); - - LBMReal vp=(*av)(AvP,ix1,ix2,ix3); - LBMReal vprms=(*av)(AvPrms,ix1,ix2,ix3); - - - data[index++].push_back(vx); - data[index++].push_back(vy); - data[index++].push_back(vz); - - data[index++].push_back(vxx); - data[index++].push_back(vyy); - data[index++].push_back(vzz); - - data[index++].push_back(vxy); - data[index++].push_back(vxz); - data[index++].push_back(vyz); - - data[index++].push_back(vp); - data[index++].push_back(vprms); - } - } - } - } - - 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) ); - } - } - } - } -} -////////////////////////////////////////////////////////////////////////// -void AverageValuesCoProcessor::calculateAverageValues(double timeStep) -{ - using namespace D3Q27System; - - //Funktionszeiger - calcMacros = NULL; - if (compressible) - { - calcMacros = &calcCompMacroscopicValues; - } - else - { - calcMacros = &calcIncompMacroscopicValues; - } - - LBMReal f[27]; - - for(int level = minInitLevel; level<=maxInitLevel;level++) - { - for(SPtr<Block3D> block : blockVector[level]) - { - if (block) - { - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - SPtr<AverageValuesArray3D> av = kernel->getDataSet()->getAverageValues(); - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int maxX1 = int(distributions->getNX1()); - int maxX2 = int(distributions->getNX2()); - int maxX3 = int(distributions->getNX3()); - - maxX1 -= 2; - maxX2 -= 2; - maxX3 -= 2; - - for(int ix3=minX3; ix3<=maxX3; ix3++) - { - for(int ix2=minX2; ix2<=maxX2; ix2++) - { - for(int ix1=minX1; ix1<=maxX1; ix1++) - { - if(!bcArray->isUndefined(ix1,ix2,ix3) && !bcArray->isSolid(ix1,ix2,ix3)) - { - ////////////////////////////////////////////////////////////////////////// - //read distribution - //////////////////////////////////////////////////////////////////////////// - distributions->getDistribution(f, ix1, ix2, ix3); - ////////////////////////////////////////////////////////////////////////// - //compute velocity - ////////////////////////////////////////////////////////////////////////// - LBMReal vx,vy,vz,rho; - calcMacros(f,rho,vx,vy,vz); - double press = D3Q27System::calcPress(f,rho,vx,vy,vz); - - ////////////////////////////////////////////////////////////////////////// - //compute average values - ////////////////////////////////////////////////////////////////////////// - - LBMReal timeStepAfterResetRMS=(double)(timeStep-resetStepRMS)/((double)averageInterval); - LBMReal timeStepAfterResetMeans=(double)(timeStep-resetStepMeans)/((double)averageInterval); - - //mean velocity - (*av)(AvVx,ix1,ix2,ix3) = ((*av)(AvVx,ix1,ix2,ix3)*timeStepAfterResetMeans + vx)/(timeStepAfterResetMeans+1.0); - (*av)(AvVy,ix1,ix2,ix3) = ((*av)(AvVy,ix1,ix2,ix3)*timeStepAfterResetMeans + vy)/(timeStepAfterResetMeans+1.0); - (*av)(AvVz,ix1,ix2,ix3) = ((*av)(AvVz,ix1,ix2,ix3)*timeStepAfterResetMeans + vz)/(timeStepAfterResetMeans+1.0); - - //rms - (*av)(AvVxx,ix1,ix2,ix3) = ((vx-(*av)(AvVx,ix1,ix2,ix3))*(vx-(*av)(AvVx,ix1,ix2,ix3)) + - (*av)(AvVxx,ix1,ix2,ix3)*timeStepAfterResetRMS)/(timeStepAfterResetRMS+1.0); - (*av)(AvVyy,ix1,ix2,ix3) = ((vy-(*av)(AvVy,ix1,ix2,ix3))*(vy-(*av)(AvVy,ix1,ix2,ix3)) + - (*av)(AvVyy,ix1,ix2,ix3)*timeStepAfterResetRMS)/(timeStepAfterResetRMS+1.0); - (*av)(AvVzz,ix1,ix2,ix3) = ((vz-(*av)(AvVz,ix1,ix2,ix3))*(vz-(*av)(AvVz,ix1,ix2,ix3)) + - (*av)(AvVzz,ix1,ix2,ix3)*timeStepAfterResetRMS)/(timeStepAfterResetRMS+1.0); - - //cross-correlations - (*av)(AvVxy,ix1,ix2,ix3) = ((vx-(*av)(AvVx,ix1,ix2,ix3))*(vy-(*av)(AvVy,ix1,ix2,ix3)) + - (*av)(AvVxy,ix1,ix2,ix3)*timeStepAfterResetRMS)/(timeStepAfterResetRMS+1.0); - (*av)(AvVxz,ix1,ix2,ix3) = ((vx-(*av)(AvVx,ix1,ix2,ix3))*(vz-(*av)(AvVz,ix1,ix2,ix3)) + - (*av)(AvVxz,ix1,ix2,ix3)*timeStepAfterResetRMS)/(timeStepAfterResetRMS+1.0); - (*av)(AvVyz,ix1,ix2,ix3) = ((vy-(*av)(AvVy,ix1,ix2,ix3))*(vz-(*av)(AvVz,ix1,ix2,ix3)) + - (*av)(AvVyz,ix1,ix2,ix3)*timeStepAfterResetRMS)/(timeStepAfterResetRMS+1.0); - - //mean and rms press - (*av)(AvP,ix1,ix2,ix3) = ((*av)(AvP,ix1,ix2,ix3)*timeStepAfterResetMeans + press)/(timeStepAfterResetMeans+1.0); - (*av)(AvPrms,ix1,ix2,ix3) = ((press-(*av)(AvP,ix1,ix2,ix3))*(press-(*av)(AvP,ix1,ix2,ix3)) + - (*av)(AvPrms,ix1,ix2,ix3)*timeStepAfterResetRMS)/(timeStepAfterResetRMS+1.0); - - ////////////////////////////////////////////////////////////////////////// - } - } - } - } - } - } - } -} -//////////////////////////////////////////////////////////////////////////// -//void AverageValuesCoProcessor::initPlotData(double step) -//{ -// SPtr<Communicator> comm = Communicator::getInstance(); -// if (comm->getProcessID() == comm->getRoot()) -// { -// std::ofstream ostr; -// string fname = path + "_PlotData_" + UbSystem::toString(step) + ".txt"; -// ostr.open(fname.c_str(), std::ios_base::out); -// if(!ostr) -// { -// ostr.clear(); -// string path = UbSystem::getPathFromString(fname); -// if(path.size()>0){ UbSystem::makeDirectory(path); ostr.open(fname.c_str(), std::ios_base::out);} -// if(!ostr) throw UbException(UB_EXARGS,"couldn't open file "+fname); -// } -// ostr << "Time"<< "\t" <<"Ref.Time"<<"\t"<< "Z_Coor"<< "\t" << "Pore fraction" << "\t"; -// ostr << "Vx" << "\t" << "Vy" << "\t" << "Vz" << "\t"; -// ostr << "TSx" << "\t" << "TSy"<< "\t" << "TSz"<< "TSxz"; -// ostr << endl; -// ostr.close(); -// } -//} -////////////////////////////////////////////////////////////////////////////// -//void AverageValuesCoProcessor::collectPlotData(double step) -//{ -// -// double hminX1 = 0.9; -// double hminX2 = 0.0; -// double hmaxX1 = 0.95; -// double hmaxX2 = 0.01; //systemabmessungen world units -// -// // 3 level platte standard: -// double hX3_level[] = {0.305, 0.309,0.3365,0.35}; -// //0.004, 0,0365,0.045 -// //musis: 3 level refinement -// //double hX3_level[] = {0.42, 0.28, 0.105, 0.0}; //refinement coords -// //bsislevel von 0.42-0.28,... (level 0 bis 2 , 3 insgesamt) -// //musis: 4 level refinement -// //double hX3_level[] = {0.42, 0.3, 0.195, 0.078, 0.0}; -// //musis: 5 level refinement -// //double hX3_level[] = {0.396, 0.28, 0.18, 0.08, 0.006, 0.0}; -// -// ostringstream Str; -// Str << step; -// string step2string(Str.str()); -// string fname = path + "_PlotZ_" + step2string + ".txt"; -// -// -// for(int level = minInitLevel; level<=maxInitLevel;level++) -// { -// double dx = grid->getDeltaX(level); -// -// for (double hi =hX3_level[level]; hi >= hX3_level[level+1]; hi=hi-dx ){ -// D3Q27IntegrateValuesHelper h1(grid, comm, -// hminX1, hminX2, hi, -// hmaxX1, hmaxX2, hi-dx); -// -// h1.calculateAV(); -// double nn1 = h1.getNumberOfNodes(); -// double ns1 = h1.getNumberOfSolids(); -// if (nn1 > 0.0){ -// // get data and write into txt files -// if (comm->getProcessID() == comm->getRoot()) -// { -// int istep = static_cast<int>(step); -// std::ofstream ostr; -// -// double AvVx1 = h1.getAvVx1()/nn1; -// double AvVx2 = h1.getAvVx2()/nn1; -// double AvVx3 = h1.getAvVx3()/nn1; -// -// double AvTSx1 = h1.getTSx1()/nn1; -// double AvTSx2 = h1.getTSx2()/nn1; -// double AvTSx3 = h1.getTSx3()/nn1; -// -// double AvTSx1x3 = h1.getTSx1x3()/nn1; -// -// ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app); -// if(!ostr) -// { -// ostr.clear(); -// string path = UbSystem::getPathFromString(fname); -// if(path.size()>0){ UbSystem::makeDirectory(path); ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app);} -// if(!ostr) throw UbException(UB_EXARGS,"couldn't open file "+fname); -// } -// ostr << istep << "\t" << resetStep << "\t" << hi+0.5*dx << "\t" << nn1/(nn1+ns1)*100.0 << "%\t"; -// ostr << AvVx1 << "\t" << AvVx2 << "\t" << AvVx3 << "\t"; -// ostr << AvTSx1<< "\t" << AvTSx2<< "\t" << AvTSx3<< "\t" << AvTSx1x3; -// ostr << endl; -// ostr.close(); -// -// } -// } -// } -// -// } -//} - diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.h deleted file mode 100644 index f3931c4be..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/AverageValuesCoProcessor.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef AverageValuesCoProcessor_H -#define AverageValuesCoProcessor_H - -#include <PointerDefinitions.h> -#include <vector> -#include <string> - -#include "CoProcessor.h" -#include "LBMSystem.h" -#include "UbTuple.h" - -class UbScheduler; -class WbWriter; -class Grid3D; -class Block3D; - -//! \brief Computes the time averaged mean velocity and RMS values and writes to parallel .vtk -//! \details writes at given time intervals specified in scheduler (s), does averaging according to scheduler (Avs) and resets according to scheduler (rs). <br> -//! Computes the time averaged mean velocity \f$ u_{mean}=\frac{1}{N}\sum\limits_{i=1}^n u_{i} \f$ and RMS of fluctuations. You need to calculate a square root before plotting RMS. <br> -// -//! \author Sonja Uphoff, Kostyantyn Kucher -// \f$ u_{mean}=\frac{1}{N}\sum\limits_{i=1}^n u_{i} \f$ -class AverageValuesCoProcessor : public CoProcessor -{ -public: - AverageValuesCoProcessor(); - AverageValuesCoProcessor(SPtr<Grid3D> grid, const std::string& path, WbWriter* const writer, - SPtr<UbScheduler> s, SPtr<UbScheduler> Avs, SPtr<UbScheduler> rsMeans, SPtr<UbScheduler> rsRMS, bool restart); - //! Make update - void process(double step); - //! Resets averaged velocity and RMS-values according to ResetSceduler - void reset(double step); -protected: - //! Prepare data and write in .vtk file - void collectData(double step); - //! Reset data - void resetDataRMS(double step); - void resetDataMeans(double step); - //! prepare data - void addData(const SPtr<Block3D> block); - void clearData(); - //! Computes average and RMS values of macroscopic quantities - void calculateAverageValues(double timeStep); - ////! write .txt file spatial intergrated averaged value, fluctuation, porous features - //void collectPlotDataZ(double step); - ////! create txt file and write head line - //void initPlotDataZ(double step); - -private: - std::vector<UbTupleFloat3> nodes; - std::vector<UbTupleUInt8> cells; - std::vector<std::string> datanames; - std::vector<std::vector<double> > data; - std::vector<std::vector<SPtr<Block3D>> > blockVector; - int minInitLevel; //min init level - int maxInitLevel; - int gridRank; - int resetStepRMS; - int resetStepMeans; - double averageInterval; - std::string path; - WbWriter* writer; - bool restart, compressible; - SPtr<UbScheduler> averageScheduler; //additional scheduler to averaging after a given interval - SPtr<UbScheduler> resetSchedulerRMS; //additional scheduler to restart averaging after a given interval - SPtr<UbScheduler> resetSchedulerMeans; //additional scheduler to restart averaging after a given interval - //labels for the different components, e.g. AvVxx for time averaged RMS: 1/n SUM((U-Umean)^2) - //you need to calculate a square root before plotting RMS - enum Values{AvVx = 0, AvVy = 1, AvVz = 2, AvVxx = 3, AvVyy = 4, AvVzz = 5, AvVxy = 6, AvVxz = 7, AvVyz = 8, AvP = 9, AvPrms = 10}; - - typedef void (*CalcMacrosFct)(const LBMReal* const& /*feq[27]*/,LBMReal& /*(d)rho*/, LBMReal& /*vx1*/, LBMReal& /*vx2*/, LBMReal& /*vx3*/); - CalcMacrosFct calcMacros; -}; -#endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/CMakePackage.txt b/src/cpu/VirtualFluidsCore/CoProcessors/CMakePackage.txt index 9354d3d00..1b8416f01 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/CMakePackage.txt +++ b/src/cpu/VirtualFluidsCore/CoProcessors/CMakePackage.txt @@ -1,2 +1,2 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) +GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.cpp deleted file mode 100644 index 23cb672be..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.cpp +++ /dev/null @@ -1,243 +0,0 @@ -#include "CalculateForcesCoProcessor.h" -#include "BCProcessor.h" - -#include "Communicator.h" -#include "D3Q27Interactor.h" -#include "UbScheduler.h" -#include "Grid3D.h" -#include "BoundaryConditions.h" -#include "DataSet3D.h" -#include "Block3D.h" -#include "LBMKernel.h" -#include "BCArray3D.h" -#include "EsoTwist3D.h" -#include "DistributionArray3D.h" - -CalculateForcesCoProcessor::CalculateForcesCoProcessor( SPtr<Grid3D> grid, SPtr<UbScheduler> s, - const std::string &path, - SPtr<Communicator> comm , - double v, double a) : - CoProcessor(grid, s), - path(path), comm(comm), - v(v), a(a), - forceX1global(0), forceX2global(0), forceX3global(0) -{ - if (comm->getProcessID() == comm->getRoot()) - { - std::ofstream ostr; - std::string fname = path; - ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app); - if(!ostr) - { - ostr.clear(); - std::string path = UbSystem::getPathFromString(fname); - if(path.size()>0){ UbSystem::makeDirectory(path); ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app);} - if(!ostr) throw UbException(UB_EXARGS,"couldn't open file "+fname); - } - ostr.width(12); - ostr << "step" << "\t"; - ostr.width(12); - ostr << "Cx" << "\t"; - ostr.width(12); - ostr << "Cy" << "\t"; - ostr.width(12); - ostr << "Cz" << "\t"; - ostr.width(12); - ostr << "Fx" << "\t"; - ostr.width(12); - ostr << "Fy" << "\t"; - ostr.width(12); - ostr << "Fz" << std::endl; - ostr.close(); - } -} -////////////////////////////////////////////////////////////////////////// -CalculateForcesCoProcessor::~CalculateForcesCoProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -void CalculateForcesCoProcessor::process( double step ) -{ - if(scheduler->isDue(step) ) - collectData(step); - - UBLOG(logDEBUG3, "D3Q27ForcesCoProcessor::update:" << step); -} -////////////////////////////////////////////////////////////////////////// -void CalculateForcesCoProcessor::collectData( double step ) -{ - calculateForces(); - - if (comm->getProcessID() == comm->getRoot()) - { - int istep = static_cast<int>(step); - std::ofstream ostr; - std::string fname = path; - ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app); - if(!ostr) - { - ostr.clear(); - std::string path = UbSystem::getPathFromString(fname); - if(path.size()>0){ UbSystem::makeDirectory(path); ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app);} - if(!ostr) throw UbException(UB_EXARGS,"couldn't open file "+fname); - } - - calculateCoefficients(); - - ostr.width(12); - ostr.setf(std::ios::fixed); - ostr << istep << "\t"; - write(&ostr, C1, (char*)"\t"); - write(&ostr, C2, (char*)"\t"); - write(&ostr, C3, (char*)"\t"); - write(&ostr, forceX1global, (char*)"\t"); - write(&ostr, forceX2global, (char*)"\t"); - write(&ostr, forceX3global, (char*)"\t"); - ostr << std::endl; - ostr.close(); - } -} -////////////////////////////////////////////////////////////////////////// -void CalculateForcesCoProcessor::calculateForces() -{ - forceX1global = 0.0; - forceX2global = 0.0; - forceX3global = 0.0; - - for(SPtr<D3Q27Interactor> interactor : interactors) - { - for(BcNodeIndicesMap::value_type t : interactor->getBcNodeIndicesMap()) - { - double forceX1 = 0.0; - double forceX2 = 0.0; - double forceX3 = 0.0; - - SPtr<Block3D> block = t.first; - std::set< std::vector<int> >& transNodeIndicesSet = t.second; - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - distributions->swap(); - - int ghostLayerWidth = kernel->getGhostLayerWidth(); - int minX1 = ghostLayerWidth; - int maxX1 = (int)bcArray->getNX1() - 1 - ghostLayerWidth; - int minX2 = ghostLayerWidth; - int maxX2 = (int)bcArray->getNX2() - 1 - ghostLayerWidth; - int minX3 = ghostLayerWidth; - int maxX3 = (int)bcArray->getNX3() - 1 - ghostLayerWidth; - - for(std::vector<int> node : transNodeIndicesSet) - { - int x1 = node[0]; - int x2 = node[1]; - int x3 = node[2]; - - //without ghost nodes - if (x1 < minX1 || x1 > maxX1 || x2 < minX2 || x2 > maxX2 ||x3 < minX3 || x3 > maxX3 ) continue; - - if(bcArray->isFluid(x1,x2,x3)) //es kann sein, dass der node von einem anderen interactor z.B. als solid gemarkt wurde!!! - { - SPtr<BoundaryConditions> bc = bcArray->getBC(x1,x2,x3); - UbTupleDouble3 forceVec = getForces(x1,x2,x3,distributions,bc); - forceX1 += val<1>(forceVec); - forceX2 += val<2>(forceVec); - forceX3 += val<3>(forceVec); - } - } - //if we have got discretization with more level - // deltaX is LBM deltaX and equal LBM deltaT - double deltaX = LBMSystem::getDeltaT(block->getLevel()); //grid->getDeltaT(block); - double deltaXquadrat = deltaX*deltaX; - forceX1 *= deltaXquadrat; - forceX2 *= deltaXquadrat; - forceX3 *= deltaXquadrat; - - distributions->swap(); - - forceX1global += forceX1; - forceX2global += forceX2; - forceX3global += forceX3; - } - } - std::vector<double> values; - std::vector<double> rvalues; - values.push_back(forceX1global); - values.push_back(forceX2global); - values.push_back(forceX3global); - - rvalues = comm->gather(values); - if (comm->getProcessID() == comm->getRoot()) - { - forceX1global = 0.0; - forceX2global = 0.0; - forceX3global = 0.0; - - for (int i = 0; i < (int)rvalues.size(); i+=3) - { - forceX1global += rvalues[i]; - forceX2global += rvalues[i+1]; - forceX3global += rvalues[i+2]; - } - } -} -////////////////////////////////////////////////////////////////////////// -UbTupleDouble3 CalculateForcesCoProcessor::getForces(int x1, int x2, int x3, SPtr<DistributionArray3D> distributions, SPtr<BoundaryConditions> bc) -{ - UbTupleDouble3 force(0.0,0.0,0.0); - - if(bc) - { - //references to tuple "force" - double& forceX1 = val<1>(force); - double& forceX2 = val<2>(force); - double& forceX3 = val<3>(force); - double f, fnbr; - - for(int fdir=D3Q27System::FSTARTDIR; fdir<=D3Q27System::FENDDIR; fdir++) - { - if(bc->hasNoSlipBoundaryFlag(fdir)) - { - const int invDir = D3Q27System::INVDIR[fdir]; - f = dynamicPointerCast<EsoTwist3D>(distributions)->getDistributionInvForDirection(x1, x2, x3, invDir); - fnbr = dynamicPointerCast<EsoTwist3D>(distributions)->getDistributionInvForDirection(x1+D3Q27System::DX1[invDir], x2+D3Q27System::DX2[invDir], x3+D3Q27System::DX3[invDir], fdir); - - forceX1 += (f + fnbr)*D3Q27System::DX1[invDir]; - forceX2 += (f + fnbr)*D3Q27System::DX2[invDir]; - forceX3 += (f + fnbr)*D3Q27System::DX3[invDir]; - } - } - } - - return force; -} -////////////////////////////////////////////////////////////////////////// -void CalculateForcesCoProcessor::calculateCoefficients() -{ - double F1 = forceX1global; - double F2 = forceX2global; - double F3 = forceX3global; - - //return 2*F/(rho*v*v*a); - C1 = 2.0*F1/(v*v*a); - C2 = 2.0*F2/(v*v*a); - C3 = 2.0*F3/(v*v*a); -} -////////////////////////////////////////////////////////////////////////// -void CalculateForcesCoProcessor::addInteractor( SPtr<D3Q27Interactor> interactor ) -{ - interactors.push_back(interactor); -} -////////////////////////////////////////////////////////////////////////// -void CalculateForcesCoProcessor::write(std::ofstream *fileObject, double value, char *separator) -{ - (*fileObject).width(12); - //(*fileObject).precision(2); - (*fileObject).setf(std::ios::fixed); - (*fileObject) << value; - (*fileObject) << separator; -} - - diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.h deleted file mode 100644 index 47727f932..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/CalculateForcesCoProcessor.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * D3Q27ForcesCoProcessor.h - * - * Created on: 29.09.2012 - * Author: K. Kucher - */ - -#ifndef D3Q27ForcesCoProcessor_H -#define D3Q27ForcesCoProcessor_H - -#include <PointerDefinitions.h> -#include <string> -#include <vector> - -#include "CoProcessor.h" -#include "UbTuple.h" - -class ForceCalculator; -class Communicator; -class Grid3D; -class UbScheduler; -class D3Q27Interactor; -class DistributionArray3D; -class BoundaryConditions; - -class CalculateForcesCoProcessor: public CoProcessor -{ -public: - //! Constructor - //! \param v - velocity of fluid in LB units - //! \param a - area of object in LB units - CalculateForcesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string &path, - SPtr<Communicator> comm, double v, double a); - virtual ~CalculateForcesCoProcessor(); - void process(double step); - void addInteractor(SPtr<D3Q27Interactor> interactor); -protected: - void collectData(double step); - void calculateForces(); - UbTupleDouble3 getForces(int x1, int x2, int x3, SPtr<DistributionArray3D> distributions, SPtr<BoundaryConditions> bc); - void calculateCoefficients(); - void write(std::ofstream *fileObject, double value, char *separator); -private: - std::string path; - SPtr<Communicator> comm; - std::vector<SPtr<D3Q27Interactor> > interactors; - double forceX1global; - double forceX2global; - double forceX3global; - double v; //!< is the speed of the object relative to the fluid - double a; //!< is the reference area - double C1; - double C2; - double C3; -}; - - -#endif /* D3Q27ForcesCoProcessor_H */ diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/CoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/CoProcessor.cpp index e03555d59..c7ea98194 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/CoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/CoProcessor.cpp @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file CoProcessor.cpp +//! \ingroup CoProcessors +//! \author Konstantin Kutscher +//======================================================================================= + #include "CoProcessor.h" #include "Grid3D.h" diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/CoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/CoProcessor.h index 69fc1e33b..31779a0f6 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/CoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/CoProcessor.h @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file CoProcessor.h +//! \ingroup CoProcessors +//! \author Konstantin Kutscher +//======================================================================================= + #ifndef CoProcessor_H #define CoProcessor_H @@ -6,12 +39,24 @@ class Grid3D; class UbScheduler; +//! \class CoProcessor +//! \brief An abstract class implements observer design pettern class CoProcessor { public: + //! Class default constructor CoProcessor(); + //! \brief Construct CoProcessor object for grid object and scheduler object. + //! \pre The Grid3D and UbScheduler objects must exist. + //! \param grid is observable Grid3D object + //! \param s is UbScheduler object for scheduling of observer + //! \details + //! Class CoProcessor implements the observer design pettern. CoProcessor object is observer. Grid3D object is observable. CoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s); + //! Class destructor virtual ~CoProcessor(); + //! \brief Updates observer + //! \param step is the actual time step virtual void process(double step) = 0; protected: SPtr<Grid3D> grid; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.cpp deleted file mode 100644 index 754c756df..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* -* DecreaseViscosityCoProcessor -* -* Created on: 10.05.2013 -* Author: uphoff -*/ - -#include "DecreaseViscosityCoProcessor.h" - -#include <vector> - -#include "LBMKernel.h" -#include "Communicator.h" -#include "UbScheduler.h" -#include "Grid3D.h" -#include "Block3D.h" - -DecreaseViscosityCoProcessor::DecreaseViscosityCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, - mu::Parser* nueFunc, SPtr<Communicator> comm) - - : CoProcessor(grid, s) - ,nueFunc(nueFunc) - ,comm(comm) -{ - if (comm->getProcessID() == comm->getRoot()) - { - - } -} -////////////////////////////////////////////////////////////////////////// -DecreaseViscosityCoProcessor::~DecreaseViscosityCoProcessor() -{ -} -////////////////////////////////////////////////////////////////////////// -void DecreaseViscosityCoProcessor::process(double step) -{ - if(scheduler->isDue(step) ) - setViscosity(step); -} -////////////////////////////////////////////////////////////////////////// -void DecreaseViscosityCoProcessor::setViscosity(double step) -{ - - UBLOG(logDEBUG3, "DecreaseViscosityCoProcessor::update:" << step); - int gridRank = grid->getRank(); - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - - if (comm->getProcessID() == comm->getRoot()) - { - - for(int level = minInitLevel; level<=maxInitLevel;level++) - { - std::vector<SPtr<Block3D>> blockVector; - grid->getBlocks(level, gridRank, blockVector); - for(SPtr<Block3D> block : blockVector) - { - SPtr<ILBMKernel> kernel = block->getKernel(); - } - } - - int istep = static_cast<int>(step); - this->timeStep = istep; - nueFunc->DefineVar("t" , &this->timeStep); - double nue=nueFunc->Eval(); - - for(int level = minInitLevel; level<=maxInitLevel;level++) - { - std::vector<SPtr<Block3D>> blockVector; - grid->getBlocks(level, gridRank, blockVector); - for(SPtr<Block3D> block : blockVector) - { - SPtr<ILBMKernel> kernel =block->getKernel(); - if(kernel) - { - LBMReal collFactor = LBMSystem::calcCollisionFactor(nue, block->getLevel()); - kernel->setCollisionFactor(collFactor); - } - } - } - - } -} diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.h deleted file mode 100644 index c389f262b..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/DecreaseViscosityCoProcessor.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef DecreaseViscosityCoProcessor_H -#define DecreaseViscosityCoProcessor_H - -#include <PointerDefinitions.h> - -#include "CoProcessor.h" -#include "IntegrateValuesHelper.h" -#include "LBMUnitConverter.h" - -#include "MuParser/include/muParser.h" - - -class UbScheduler; -class Grid3D; -class Communicator; - -//! \brief The class sets viscosity/collision factor according to a previously defined function in time. -//! \details initialization in test case (example): -//! \code{.cpp} -//! mu::Parser decrViscFunc; //define a mu-parser function -//! decrViscFunc.SetExpr("nue0+c0/(t+1)/(t+1)"); //this function is time-dependent, the viscosity decreases a 1/t^2 -//! decrViscFunc.DefineConst("nue0", nueLB); -//! decrViscFunc.DefineConst("c0", 0.1); //constants such as c0 controll how fast the viscosity decreasis -//! SPtr<UbScheduler> DecrViscSch(new UbScheduler()); //the CoProcessor is called according to a Scheduler -//! DecrViscSch->addSchedule(10,10,1000); //in this case the viscosity is reset every 10 timesteps for the first 1000 timesteps -//! DecreaseViscosityCoProcessor decrViscPPPtr(grid, DecrViscSch,&decrViscFunc, comm); -//! \endcode -//! \author Sonja Uphoff - -class DecreaseViscosityCoProcessor: public CoProcessor -{ -public: - DecreaseViscosityCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, - mu::Parser* nueFunc, SPtr<Communicator> comm); - virtual ~DecreaseViscosityCoProcessor(); - //! calls collect PostprocessData. - void process(double step); -protected: - //! resets the collision factor depending on the current timestep. - void setViscosity(double step); - SPtr<Communicator> comm; -private: - mutable mu::value_type timeStep; - mu::Parser* nueFunc; -}; - - -#endif /* DecreaseViscosityCoProcessor_H_ */ diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/EmergencyExitCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/EmergencyExitCoProcessor.cpp deleted file mode 100644 index 990285d99..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/EmergencyExitCoProcessor.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "EmergencyExitCoProcessor.h" -#include <basics/utilities/UbFileOutputASCII.h> -#include <basics/utilities/UbFileInputASCII.h> -#include "UbLogger.h" -#include "UbScheduler.h" -#include "Communicator.h" -#include "MPIIORestartCoProcessor.h" -#include "Grid3D.h" - -EmergencyExitCoProcessor::EmergencyExitCoProcessor( SPtr<Grid3D> grid, SPtr<UbScheduler> s, - const std::string& path, - SPtr<MPIIORestartCoProcessor> rp, SPtr<Communicator> comm) : - CoProcessor(grid, s), - path(path), - rp(rp), - comm(comm) -{ - this->path = path + "/exit"; - metafile = this->path + "/stop.txt"; - if (comm->getProcessID() == comm->getRoot()) - { - //checkMetafile(); - writeMetafile(false); - } - comm->barrier(); -} -////////////////////////////////////////////////////////////////////////// -EmergencyExitCoProcessor::~EmergencyExitCoProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -void EmergencyExitCoProcessor::process( double step ) -{ - if(scheduler->isDue(step) ) - collectData(step); - - UBLOG(logDEBUG3, "EmergencyExitCoProcessor::update:" << step); -} - -void EmergencyExitCoProcessor::collectData( double step ) -{ - if(readMetafile()) - { - rp->process((int)step); - if(comm->getProcessID() == comm->getRoot()) UBLOG(logINFO,"EmergencyExitCoProcessor save step: " << step); - comm->barrier(); - exit(EXIT_SUCCESS); - } -} -////////////////////////////////////////////////////////////////////////// -void EmergencyExitCoProcessor::writeMetafile(int status ) -{ - UbFileOutputASCII out(metafile); - out.writeBool(false); -} -////////////////////////////////////////////////////////////////////////// -bool EmergencyExitCoProcessor::readMetafile() -{ - UbFileInputASCII in(metafile); - return in.readBool(); -} -////////////////////////////////////////////////////////////////////////// -void EmergencyExitCoProcessor::checkMetafile() -{ - std::ifstream file(metafile.c_str()); - if (!file.is_open()) - { - writeMetafile(false); - return; - } - file.close(); -} - - diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/EmergencyExitCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/EmergencyExitCoProcessor.h deleted file mode 100644 index ff1cee853..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/EmergencyExitCoProcessor.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * EmergencyExitCoProcessor.h - * - * Created on: 05.10.2012 - * Author: K. Kucher - */ - -#ifndef EmergencyExitCoProcessor_H -#define EmergencyExitCoProcessor_H - -#include <PointerDefinitions.h> -#include <string> - -#include "CoProcessor.h" - -class MPIIORestartCoProcessor; -class Communicator; -class Grid3D; -class UbScheduler; - -class EmergencyExitCoProcessor : public CoProcessor -{ -public: - EmergencyExitCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, SPtr<MPIIORestartCoProcessor> rp, SPtr<Communicator> comm); - virtual ~EmergencyExitCoProcessor(); - - void process(double step) override; - -protected: - void collectData(double step); - void writeMetafile(int status); - bool readMetafile(); - void checkMetafile(); - -private: - std::string path; - SPtr<Communicator> comm; - SPtr<MPIIORestartCoProcessor> rp; - std::string metafile; -}; - - -#endif /* EmergencyExitCoProcessor_H */ diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/ForceCalculator.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/ForceCalculator.cpp deleted file mode 100644 index 0df2af78f..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/ForceCalculator.cpp +++ /dev/null @@ -1,145 +0,0 @@ -#include "ForceCalculator.h" -#include "BCProcessor.h" - -#include "Communicator.h" -#include "D3Q27Interactor.h" -#include "DataSet3D.h" -#include "LBMKernel.h" -#include "Block3D.h" -#include "BoundaryConditions.h" -#include "BCArray3D.h" -#include "Communicator.h" -#include "DistributionArray3D.h" -#include "BoundaryConditions.h" -#include "D3Q27Interactor.h" - -ForceCalculator::ForceCalculator(SPtr<Communicator> comm) : comm(comm), forceX1global(0), forceX2global(0), forceX3global(0) -{ - -} - -ForceCalculator::~ForceCalculator() -{ - -} - - - - -Vector3D ForceCalculator::getForces(int x1, int x2, int x3, SPtr<DistributionArray3D> distributions, SPtr<BoundaryConditions> bc, const Vector3D& boundaryVelocity) const -{ - double forceX1 = 0; - double forceX2 = 0; - double forceX3 = 0; - if (bc) - { - for (int fdir = D3Q27System::FSTARTDIR; fdir <= D3Q27System::FENDDIR; fdir++) - { - if (bc->hasNoSlipBoundaryFlag(fdir) || bc->hasVelocityBoundaryFlag(fdir)) - { - const int invDir = D3Q27System::INVDIR[fdir]; - const double f = distributions->getDistributionInvForDirection(x1, x2, x3, invDir); - const double fnbr = distributions->getDistributionInvForDirection(x1 + D3Q27System::DX1[invDir], x2 + D3Q27System::DX2[invDir], x3 + D3Q27System::DX3[invDir], fdir); - - double correction[3] = { 0.0, 0.0, 0.0 }; - if(bc->hasVelocityBoundaryFlag(fdir)) - { - const double forceTerm = f - fnbr; - correction[0] = forceTerm * boundaryVelocity[0]; - correction[1] = forceTerm * boundaryVelocity[1]; - correction[2] = forceTerm * boundaryVelocity[2]; - } - - //UBLOG(logINFO, "c, c * bv(x,y,z): " << correction << ", " << correction * val<1>(boundaryVelocity) << ", " << correction * val<2>(boundaryVelocity) << ", " << correction * val<3>(boundaryVelocity)); - - // force consists of the MEM part and the galilean invariance correction including the boundary velocity - forceX1 += (f + fnbr) * D3Q27System::DX1[invDir] - correction[0]; - forceX2 += (f + fnbr) * D3Q27System::DX2[invDir] - correction[1]; - forceX3 += (f + fnbr) * D3Q27System::DX3[invDir] - correction[2]; - } - } - } - return Vector3D(forceX1, forceX2, forceX3); -} - -void ForceCalculator::calculateForces(std::vector<SPtr<D3Q27Interactor> > interactors) -{ - forceX1global = 0.0; - forceX2global = 0.0; - forceX3global = 0.0; - - for (const SPtr<D3Q27Interactor> interactor : interactors) - { - for (BcNodeIndicesMap::value_type t : interactor->getBcNodeIndicesMap()) - { - double forceX1 = 0.0; - double forceX2 = 0.0; - double forceX3 = 0.0; - - SPtr<Block3D>block = t.first; - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - distributions->swap(); - - std::set< std::vector<int> >& transNodeIndices = t.second; - for (std::vector<int> node : transNodeIndices) - { - int x1 = node[0]; - int x2 = node[1]; - int x3 = node[2]; - - if (kernel->isInsideOfDomain(x1, x2, x3) && bcArray->isFluid(x1, x2, x3)) - { - SPtr<BoundaryConditions> bc = bcArray->getBC(x1, x2, x3); - Vector3D forceVec = getForces(x1, x2, x3, distributions, bc); - forceX1 += forceVec[0]; - forceX2 += forceVec[1]; - forceX3 += forceVec[2]; - } - } - //if we have got discretization with more level - // deltaX is LBM deltaX and equal LBM deltaT - double deltaX = LBMSystem::getDeltaT(block->getLevel()); //grid->getDeltaT(block); - double deltaXquadrat = deltaX*deltaX; - forceX1 *= deltaXquadrat; - forceX2 *= deltaXquadrat; - forceX3 *= deltaXquadrat; - - distributions->swap(); - - forceX1global += forceX1; - forceX2global += forceX2; - forceX3global += forceX3; - } - } - gatherGlobalForces(); -} - -void ForceCalculator::gatherGlobalForces() -{ - std::vector<double> values;// intel compiler 17 dasn't support this { forceX1global , forceX2global, forceX3global }; - values.push_back(forceX1global); - values.push_back(forceX2global); - values.push_back(forceX3global); - std::vector<double> rvalues = comm->gather(values); - - if (comm->isRoot()) - { - forceX1global = 0.0; - forceX2global = 0.0; - forceX3global = 0.0; - - for (int i = 0; i < (int)rvalues.size(); i += 3) - { - forceX1global += rvalues[i]; - forceX2global += rvalues[i + 1]; - forceX3global += rvalues[i + 2]; - } - } -} - -Vector3D ForceCalculator::getGlobalForces() const -{ - return Vector3D(forceX1global, forceX2global, forceX3global); -} diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/ForceCalculator.h b/src/cpu/VirtualFluidsCore/CoProcessors/ForceCalculator.h deleted file mode 100644 index 8d90d09d8..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/ForceCalculator.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * ForceCalculator.h - * - * Created on: 25.10.2017 - * Author: S. Peters - */ - -#ifndef ForceCalculator_H -#define ForceCalculator_H - -#include <vector> -#include <memory> - -#include "Vector3D.h" - -class D3Q27Interactor; -class Communicator; -class DistributionArray3D; -class BoundaryConditions; - -class ForceCalculator -{ -public: - ForceCalculator(std::shared_ptr<Communicator> comm); - virtual ~ForceCalculator(); - - void calculateForces(std::vector<std::shared_ptr<D3Q27Interactor> > interactors); - Vector3D getForces(int x1, int x2, int x3, std::shared_ptr<DistributionArray3D> distributions, std::shared_ptr<BoundaryConditions> bc, const Vector3D& boundaryVelocity = Vector3D(0.0, 0.0, 0.0)) const; - - Vector3D getGlobalForces() const; - -private: - void gatherGlobalForces(); - - std::shared_ptr<Communicator> comm; - - double forceX1global; - double forceX2global; - double forceX3global; -}; - - -#endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/InSituCatalystCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/InSituCatalystCoProcessor.cpp deleted file mode 100644 index 7e7ec271a..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/InSituCatalystCoProcessor.cpp +++ /dev/null @@ -1,349 +0,0 @@ -#ifdef VF_CATALYST - -#include "InSituCatalystCoProcessor.h" -#include <LBMKernel.h> -#include <D3Q27ETBCProcessor.h> -#include <vector> -#include <string> - -#include <vtkCellType.h> -#include <vtkPointData.h> -#include <vtkXMLUnstructuredGridWriter.h> - -#include <iostream> -#include <fstream> - -using namespace std; - -InSituCatalystCoProcessor::InSituCatalystCoProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -InSituCatalystCoProcessor::InSituCatalystCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, std::string script) : CoProcessor(grid, s) -{ - gridRank = Communicator::getInstance()->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]); - } - - Processor = vtkSmartPointer<vtkCPProcessor>::New(); - Processor->Initialize(); - - vtkNew<vtkCPPythonScriptPipeline> pipeline; - pipeline->Initialize(script.c_str()); - Processor->AddPipeline(pipeline.GetPointer()); - - buildVTKGrid(); -} -////////////////////////////////////////////////////////////////////////// -InSituCatalystCoProcessor::~InSituCatalystCoProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -void InSituCatalystCoProcessor::process(double step) -{ - if (scheduler->isDue(step)) - collectData(step); - - UBLOG(logDEBUG3, "InSituCatalystCoProcessor::update:" << step); -} -////////////////////////////////////////////////////////////////////////// -void InSituCatalystCoProcessor::collectData(double step) -{ - unsigned int istep = static_cast<int>(step); - - vtkNew<vtkCPDataDescription> dataDescription; - dataDescription->AddInput("input"); - dataDescription->SetTimeData(step, istep); - - if (Processor->RequestDataDescription(dataDescription.GetPointer()) != 0) - { - - index = 0; - - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for(SPtr<Block3D> block : blockVector[level]) - { - if (block) - { - addData(block); - } - } - } - - vtkDoubleArray* rho = vtkDoubleArray::SafeDownCast(unstructuredGrid->GetPointData()->GetArray("Rho")); - rho->SetArray(&rhoArray[0], static_cast<vtkIdType>(rhoArray.size()), 1); - - vtkDoubleArray* vx1 = vtkDoubleArray::SafeDownCast(unstructuredGrid->GetPointData()->GetArray("Vx")); - vx1->SetArray(&vx1Array[0], static_cast<vtkIdType>(vx1Array.size()), 1); - - vtkDoubleArray* vx2 = vtkDoubleArray::SafeDownCast(unstructuredGrid->GetPointData()->GetArray("Vy")); - vx2->SetArray(&vx2Array[0], static_cast<vtkIdType>(vx2Array.size()), 1); - - vtkDoubleArray* vx3 = vtkDoubleArray::SafeDownCast(unstructuredGrid->GetPointData()->GetArray("Vz")); - vx3->SetArray(&vx3Array[0], static_cast<vtkIdType>(vx3Array.size()), 1); - - dataDescription->GetInputDescriptionByName("input")->SetGrid(unstructuredGrid); - Processor->CoProcess(dataDescription.GetPointer()); - } - - UBLOG(logINFO, "InSituCatalystCoProcessor step: " << istep); -} -////////////////////////////////////////////////////////////////////////// -void InSituCatalystCoProcessor::addData(SPtr<Block3D> block) -{ - UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); - UbTupleDouble3 blockLengths = grid->getBlockLengths(block); - UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); - double dx = grid->getDeltaX(block); - - SPtr<LBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - LBMReal f[D3Q27System::ENDF + 1]; - LBMReal vx1, vx2, vx3, rho; - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int maxX1 = (int)(distributions->getNX1()); - int maxX2 = (int)(distributions->getNX2()); - int maxX3 = (int)(distributions->getNX3()); - - //nummern vergeben und node vector erstellen + daten sammeln - CbArray3D<int> nodeNumbers((int)maxX1, (int)maxX2, (int)maxX3, -1); - maxX1 -= 2; - maxX2 -= 2; - maxX3 -= 2; - - - - 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) && !bcArray->isSolid(ix1, ix2, ix3)) - { - distributions->getDistribution(f, ix1, ix2, ix3); - calcMacros(f, rho, vx1, vx2, vx3); - double press = D3Q27System::calcPress(f, rho, vx1, vx2, vx3); - - if (UbMath::isNaN(rho) || UbMath::isInfinity(rho)) - UB_THROW(UbException(UB_EXARGS, "rho is not a number (nan or -1.#IND) or infinity number -1.#INF in block=" + block->toString() + - ", node=" + UbSystem::toString(ix1) + "," + UbSystem::toString(ix2) + "," + UbSystem::toString(ix3))); - //rho=999.0; - if (UbMath::isNaN(press) || UbMath::isInfinity(press)) - UB_THROW(UbException(UB_EXARGS, "press is not a number (nan or -1.#IND) or infinity number -1.#INF in block=" + block->toString() + - ", node=" + UbSystem::toString(ix1) + "," + UbSystem::toString(ix2) + "," + UbSystem::toString(ix3))); - //press=999.0; - if (UbMath::isNaN(vx1) || UbMath::isInfinity(vx1)) - UB_THROW(UbException(UB_EXARGS, "vx1 is not a number (nan or -1.#IND) or infinity number -1.#INF in block=" + block->toString() + - ", node=" + UbSystem::toString(ix1) + "," + UbSystem::toString(ix2) + "," + UbSystem::toString(ix3))); - //vx1=999.0; - if (UbMath::isNaN(vx2) || UbMath::isInfinity(vx2)) - UB_THROW(UbException(UB_EXARGS, "vx2 is not a number (nan or -1.#IND) or infinity number -1.#INF in block=" + block->toString() + - ", node=" + UbSystem::toString(ix1) + "," + UbSystem::toString(ix2) + "," + UbSystem::toString(ix3))); - //vx2=999.0; - if (UbMath::isNaN(vx3) || UbMath::isInfinity(vx3)) - UB_THROW(UbException(UB_EXARGS, "vx3 is not a number (nan or -1.#IND) or infinity number -1.#INF in block=" + block->toString() + - ", node=" + UbSystem::toString(ix1) + "," + UbSystem::toString(ix2) + "," + UbSystem::toString(ix3))); - //vx3=999.0; - - rhoArray[index] = rho; - vx1Array[index] = vx1; - vx2Array[index] = vx2; - vx3Array[index] = vx3; - index++; - } - } - } - } -} -////////////////////////////////////////////////////////////////////////// -void InSituCatalystCoProcessor::buildVTKGrid() -{ - unstructuredGrid = vtkSmartPointer<vtkUnstructuredGrid>::New(); - points = vtkPoints::New(); - unstructuredGrid->SetPoints(points); - arrays[0] = vtkSmartPointer<vtkDoubleArray>::New(); - arrays[0]->SetNumberOfComponents(1); - arrays[0]->SetName("Rho"); - arrays[1] = vtkSmartPointer<vtkDoubleArray>::New(); - arrays[1]->SetNumberOfComponents(1); - arrays[1]->SetName("Vx"); - arrays[2] = vtkSmartPointer<vtkDoubleArray>::New(); - arrays[2]->SetNumberOfComponents(1); - arrays[2]->SetName("Vy"); - arrays[3] = vtkSmartPointer<vtkDoubleArray>::New(); - arrays[3]->SetNumberOfComponents(1); - arrays[3]->SetName("Vz"); - - numOfPoints = 0; - - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for(SPtr<Block3D> block : blockVector[level]) - { - if (block) - { - addVTKGridData(block); - } - } - } - - unstructuredGrid->GetPointData()->AddArray(arrays[0]); - unstructuredGrid->GetPointData()->AddArray(arrays[1]); - unstructuredGrid->GetPointData()->AddArray(arrays[2]); - unstructuredGrid->GetPointData()->AddArray(arrays[3]); - unstructuredGrid->GetPointData()->SetScalars(arrays[1]); - - rhoArray.resize(numOfPoints); - vx1Array.resize(numOfPoints); - vx2Array.resize(numOfPoints); - vx3Array.resize(numOfPoints); -} -////////////////////////////////////////////////////////////////////////// -void InSituCatalystCoProcessor::addVTKGridData(SPtr<Block3D> block) -{ - UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); - UbTupleDouble3 blockLengths = grid->getBlockLengths(block); - UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); - double dx = grid->getDeltaX(block); - - SPtr<LBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - LBMReal f[D3Q27System::ENDF + 1]; - LBMReal vx1, vx2, vx3, rho; - - //knotennummerierung faengt immer bei 0 an! - int SWB, SEB, NEB, NWB, SWT, SET, NET, NWT; - - //Funktionszeiger - //typedef void(*CalcMacrosFct)(const LBMReal* const& /*feq[27]*/, LBMReal& /*(d)rho*/, LBMReal& /*vx1*/, LBMReal& /*vx2*/, LBMReal& /*vx3*/); - - //CalcMacrosFct calcMacros = NULL; - - if (block->getKernel()->getCompressible()) - { - calcMacros = &D3Q27System::calcCompMacroscopicValues; - } - else - { - calcMacros = &D3Q27System::calcIncompMacroscopicValues; - } - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int maxX1 = (int)(distributions->getNX1()); - int maxX2 = (int)(distributions->getNX2()); - int maxX3 = (int)(distributions->getNX3()); - - //nummern vergeben und node vector erstellen + daten sammeln - CbArray3D<int> nodeNumbers((int)maxX1, (int)maxX2, (int)maxX3, -1); - maxX1 -= 2; - maxX2 -= 2; - maxX3 -= 2; - - SPtr<BoundaryConditions> bcPtr; - int nr = points->GetNumberOfPoints(); - - double x[3]; - - 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) && !bcArray->isSolid(ix1, ix2, ix3)) - { - x[0] = double(val<1>(org) -val<1>(nodeOffset) +ix1*dx); - x[1] = double(val<2>(org) -val<2>(nodeOffset) +ix2*dx); - x[2] = double(val<3>(org) -val<3>(nodeOffset) +ix3*dx); - - points->InsertPoint((vtkIdType)nr, x); - - nodeNumbers(ix1, ix2, ix3) = nr++; - - distributions->getDistribution(f, ix1, ix2, ix3); - calcMacros(f, rho, vx1, vx2, vx3); - double press = D3Q27System::calcPress(f, rho, vx1, vx2, vx3); - - if (UbMath::isNaN(rho) || UbMath::isInfinity(rho)) - UB_THROW(UbException(UB_EXARGS, "rho is not a number (nan or -1.#IND) or infinity number -1.#INF in block=" + block->toString() + - ", node=" + UbSystem::toString(ix1) + "," + UbSystem::toString(ix2) + "," + UbSystem::toString(ix3))); - //rho=999.0; - if (UbMath::isNaN(press) || UbMath::isInfinity(press)) - UB_THROW(UbException(UB_EXARGS, "press is not a number (nan or -1.#IND) or infinity number -1.#INF in block=" + block->toString() + - ", node=" + UbSystem::toString(ix1) + "," + UbSystem::toString(ix2) + "," + UbSystem::toString(ix3))); - //press=999.0; - if (UbMath::isNaN(vx1) || UbMath::isInfinity(vx1)) - UB_THROW(UbException(UB_EXARGS, "vx1 is not a number (nan or -1.#IND) or infinity number -1.#INF in block=" + block->toString() + - ", node=" + UbSystem::toString(ix1) + "," + UbSystem::toString(ix2) + "," + UbSystem::toString(ix3))); - //vx1=999.0; - if (UbMath::isNaN(vx2) || UbMath::isInfinity(vx2)) - UB_THROW(UbException(UB_EXARGS, "vx2 is not a number (nan or -1.#IND) or infinity number -1.#INF in block=" + block->toString() + - ", node=" + UbSystem::toString(ix1) + "," + UbSystem::toString(ix2) + "," + UbSystem::toString(ix3))); - //vx2=999.0; - if (UbMath::isNaN(vx3) || UbMath::isInfinity(vx3)) - UB_THROW(UbException(UB_EXARGS, "vx3 is not a number (nan or -1.#IND) or infinity number -1.#INF in block=" + block->toString() + - ", node=" + UbSystem::toString(ix1) + "," + UbSystem::toString(ix2) + "," + UbSystem::toString(ix3))); - //vx3=999.0; - - arrays[0]->InsertNextValue(rho); - arrays[1]->InsertNextValue(vx1); - arrays[2]->InsertNextValue(vx2); - arrays[3]->InsertNextValue(vx3); - numOfPoints++; - } - } - } - } - maxX1 -= 1; - maxX2 -= 1; - maxX3 -= 1; - - vtkIdType ptIds[8]; - //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 ((ptIds[0] = SWB = nodeNumbers(ix1, ix2, ix3)) >= 0 - && (ptIds[1] = SEB = nodeNumbers(ix1 + 1, ix2, ix3)) >= 0 - && (ptIds[2] = NWB = nodeNumbers(ix1, ix2 + 1, ix3)) >= 0 - && (ptIds[3] = NEB = nodeNumbers(ix1 + 1, ix2 + 1, ix3)) >= 0 - && (ptIds[4] = SWT = nodeNumbers(ix1, ix2, ix3 + 1)) >= 0 - && (ptIds[5] = SET = nodeNumbers(ix1 + 1, ix2, ix3 + 1)) >= 0 - && (ptIds[6] = NWT = nodeNumbers(ix1, ix2 + 1, ix3 + 1)) >= 0 - && (ptIds[7] = NET = nodeNumbers(ix1 + 1, ix2 + 1, ix3 + 1)) >= 0 - ) - { - unstructuredGrid->InsertNextCell((int)VTK_VOXEL, (vtkIdType)8, ptIds); - } - } - } - } -} -////////////////////////////////////////////////////////////////////////// - - -#endif - diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/InSituCatalystCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/InSituCatalystCoProcessor.h deleted file mode 100644 index b8e89c462..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/InSituCatalystCoProcessor.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifdef VF_CATALYST - -#ifndef InSituCatalystCoProcessor_h__ -#define InSituCatalystCoProcessor_h__ - - -#include <CoProcessor.h> -#include <Grid3D.h> -#include <LBMUnitConverter.h> - -#include <string> - -#include <vtkSmartPointer.h> -#include <vtkUnstructuredGrid.h> -#include <vtkDoubleArray.h> -#include <vtkCPDataDescription.h> -#include <vtkCPInputDataDescription.h> -#include <vtkCPProcessor.h> -#include <vtkCPPythonScriptPipeline.h> -#include <vtkNew.h> - -class InSituCatalystCoProcessor : public CoProcessor -{ -public: - InSituCatalystCoProcessor(); - InSituCatalystCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, std::string script); - virtual ~InSituCatalystCoProcessor(); - void process(double step); -protected: - void collectData(double step); - void addData(SPtr<Block3D> block); - void buildVTKGrid(); - void addVTKGridData(SPtr<Block3D> block); -private: - std::vector<std::vector<SPtr<Block3D>> > blockVector; - int minInitLevel; - int maxInitLevel; - int gridRank; - vtkSmartPointer<vtkCPProcessor> Processor; - vtkSmartPointer<vtkUnstructuredGrid> unstructuredGrid; - vtkSmartPointer<vtkPoints> points; - vtkSmartPointer<vtkDoubleArray> arrays[4]; - std::vector<double> vx1Array; - std::vector<double> vx2Array; - std::vector<double> vx3Array; - std::vector<double> rhoArray; - int index; - int numOfPoints; - typedef void(*CalcMacrosFct)(const LBMReal* const& /*feq[27]*/, LBMReal& /*(d)rho*/, LBMReal& /*vx1*/, LBMReal& /*vx2*/, LBMReal& /*vx3*/); - CalcMacrosFct calcMacros; -}; -#endif // InSituCatalystCoProcessor_h__ - -#endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/InSituVTKCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/InSituVTKCoProcessor.cpp deleted file mode 100644 index f413955ef..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/InSituVTKCoProcessor.cpp +++ /dev/null @@ -1,304 +0,0 @@ -#ifdef VF_VTK - -#include "InSituVTKCoProcessor.h" -#include <LBMKernel.h> -#include <BCProcessor.h> -#include <Communicator.h> -#include <UbScheduler.h> -#include <DistributionArray3D.h> -#include <D3Q27System.h> -#include <BoundaryConditions.h> -#include <Block3D.h> -#include <LBMKernel.h> -#include <DataSet3D.h> -#include <BCArray3D.h> - -#include <vector> -#include <string> - -#include <vtkCellType.h> -#include <vtkPointData.h> -#include <vtkXMLUnstructuredGridWriter.h> - -#include <iostream> -#include <fstream> - -using namespace std; - -InSituVTKCoProcessor::InSituVTKCoProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -InSituVTKCoProcessor::InSituVTKCoProcessor( SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& configFile, SPtr<LBMUnitConverter> conv ) : CoProcessor(grid, s), conv(conv) -{ - gridRank = Communicator::getInstance()->getProcessID(); - minInitLevel = this->grid->getCoarsestInitializedLevel(); - maxInitLevel = this->grid->getFinestInitializedLevel(); - - readConfigFile(configFile); - - blockVector.resize(maxInitLevel+1); - - for(int level = minInitLevel; level<=maxInitLevel;level++) - { - grid->getBlocks(level, gridRank, true, blockVector[level]); - } - - //initialization of communicator - contr = vtkSmartPointer<vtkSocketController>::New(); - contr->Initialize(); - - comm = vtkSmartPointer<vtkSocketCommunicator>::New(); - - // Establish connection - if (!comm->ConnectTo(wHostname.c_str(), wPort)) - { - cerr << "Client error: Could not connect to the server."<< endl; - return; - } - -} -////////////////////////////////////////////////////////////////////////// -InSituVTKCoProcessor::~InSituVTKCoProcessor() -{ - comm->CloseConnection(); -} -////////////////////////////////////////////////////////////////////////// -void InSituVTKCoProcessor::process( double step ) -{ - if(scheduler->isDue(step) ) - collectData(step); - - UBLOG(logDEBUG3, "InSituVTKCoProcessor::update:" << step); -} -////////////////////////////////////////////////////////////////////////// -void InSituVTKCoProcessor::collectData( double step ) -{ - int istep = static_cast<int>(step); - - unstructuredGrid = vtkSmartPointer<vtkUnstructuredGrid>::New(); - points = vtkPoints::New(); - unstructuredGrid->SetPoints(points); - arrays[0] = vtkSmartPointer<vtkDoubleArray>::New(); - arrays[0]->SetNumberOfComponents(1); - arrays[0]->SetName( "Rho" ); - arrays[1] = vtkSmartPointer<vtkDoubleArray>::New(); - arrays[1]->SetNumberOfComponents(1); - arrays[1]->SetName( "Vx" ); - arrays[2] = vtkSmartPointer<vtkDoubleArray>::New(); - arrays[2]->SetNumberOfComponents(1); - arrays[2]->SetName( "Vy" ); - arrays[3] = vtkSmartPointer<vtkDoubleArray>::New(); - arrays[3]->SetNumberOfComponents(1); - arrays[3]->SetName( "Vz" ); - arrays[4] = vtkSmartPointer<vtkDoubleArray>::New(); - arrays[4]->SetNumberOfComponents(1); - arrays[4]->SetName( "Press" ); - - for(int level = minInitLevel; level<=maxInitLevel;level++) - { - for(SPtr<Block3D> block : blockVector[level]) - { - if (block) - { - addData(block); - } - } - } - - unstructuredGrid->GetPointData()->AddArray(arrays[0]); - unstructuredGrid->GetPointData()->AddArray(arrays[1]); - unstructuredGrid->GetPointData()->AddArray(arrays[2]); - unstructuredGrid->GetPointData()->AddArray(arrays[3]); - unstructuredGrid->GetPointData()->AddArray(arrays[4]); - unstructuredGrid->GetPointData()->SetScalars(arrays[1]); - - if (!comm->Send(&istep, 1, 1, 11)) - { - cerr << "Client error: Error sending data." << endl; - return; - } - - if (!comm->Send(unstructuredGrid, 1, 9)) - { - cerr << "Server error: Error sending data." << endl; - return; - } - - //vtkSmartPointer<vtkXMLUnstructuredGridWriter> writer = vtkSmartPointer<vtkXMLUnstructuredGridWriter>::New(); - //writer->SetInput(unstructuredGrid); - //writer->SetFileName("test.vtu"); - //writer->SetDataModeToAscii(); - //writer->Update(); - - UBLOG(logINFO,"InSituVTKCoProcessor step: " << istep); -} -////////////////////////////////////////////////////////////////////////// -void InSituVTKCoProcessor::addData( SPtr<Block3D> block ) -{ - UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); - UbTupleDouble3 blockLengths = grid->getBlockLengths(block); - UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); - double dx = grid->getDeltaX(block); - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - LBMReal f[D3Q27System::ENDF+1]; - LBMReal vx1,vx2,vx3,rho; - - //knotennummerierung faengt immer bei 0 an! - int SWB,SEB,NEB,NWB,SWT,SET,NET,NWT; - - //Funktionszeiger - typedef void (*CalcMacrosFct)(const LBMReal* const& /*feq[27]*/,LBMReal& /*(d)rho*/, LBMReal& /*vx1*/, LBMReal& /*vx2*/, LBMReal& /*vx3*/); - - CalcMacrosFct calcMacros = NULL; - - if(block->getKernel()->getCompressible()) - { - calcMacros = &D3Q27System::calcCompMacroscopicValues; - } - else - { - calcMacros = &D3Q27System::calcIncompMacroscopicValues; - } - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int maxX1 = (int)(distributions->getNX1()); - int maxX2 = (int)(distributions->getNX2()); - int maxX3 = (int)(distributions->getNX3()); - - //int minX1 = 1; - //int minX2 = 1; - //int minX3 = 1; - - //int maxX1 = (int)(distributions->getNX1()); - //int maxX2 = (int)(distributions->getNX2()); - //int maxX3 = (int)(distributions->getNX3()); - - //nummern vergeben und node vector erstellen + daten sammeln - CbArray3D<int> nodeNumbers((int)maxX1, (int)maxX2, (int)maxX3,-1); - maxX1 -= 2; - maxX2 -= 2; - maxX3 -= 2; - - SPtr<BoundaryConditions> bcPtr; - int nr = points->GetNumberOfPoints(); - - double x[3]; - - 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) && !bcArray->isSolid(ix1,ix2,ix3)) - { - int index = 0; - - x[0] = double(val<1>(org) - val<1>(nodeOffset) + ix1*dx); - x[1] = double(val<2>(org) - val<2>(nodeOffset) + ix2*dx); - x[2] = double(val<3>(org) - val<3>(nodeOffset) + ix3*dx); - - points->InsertPoint((vtkIdType)nr, x); - - nodeNumbers(ix1,ix2,ix3) = nr++; - - distributions->getDistribution(f, ix1, ix2, ix3); - calcMacros(f,rho,vx1,vx2,vx3); - double press = D3Q27System::calcPress(f,rho,vx1,vx2,vx3); - - if (UbMath::isNaN(rho) || UbMath::isInfinity(rho)) - UB_THROW( UbException(UB_EXARGS,"rho is not a number (nan or -1.#IND) or infinity number -1.#INF in block="+block->toString()+ - ", node="+UbSystem::toString(ix1)+","+UbSystem::toString(ix2)+","+UbSystem::toString(ix3))); - //rho=999.0; - if (UbMath::isNaN(press) || UbMath::isInfinity(press)) - UB_THROW( UbException(UB_EXARGS,"press is not a number (nan or -1.#IND) or infinity number -1.#INF in block="+block->toString()+ - ", node="+UbSystem::toString(ix1)+","+UbSystem::toString(ix2)+","+UbSystem::toString(ix3))); - //press=999.0; - if (UbMath::isNaN(vx1) || UbMath::isInfinity(vx1)) - UB_THROW( UbException(UB_EXARGS,"vx1 is not a number (nan or -1.#IND) or infinity number -1.#INF in block="+block->toString()+ - ", node="+UbSystem::toString(ix1)+","+UbSystem::toString(ix2)+","+UbSystem::toString(ix3))); - //vx1=999.0; - if (UbMath::isNaN(vx2) || UbMath::isInfinity(vx2)) - UB_THROW( UbException(UB_EXARGS,"vx2 is not a number (nan or -1.#IND) or infinity number -1.#INF in block="+block->toString()+ - ", node="+UbSystem::toString(ix1)+","+UbSystem::toString(ix2)+","+UbSystem::toString(ix3))); - //vx2=999.0; - if (UbMath::isNaN(vx3) || UbMath::isInfinity(vx3)) - UB_THROW( UbException(UB_EXARGS,"vx3 is not a number (nan or -1.#IND) or infinity number -1.#INF in block="+block->toString()+ - ", node="+UbSystem::toString(ix1)+","+UbSystem::toString(ix2)+","+UbSystem::toString(ix3))); - //vx3=999.0; - - arrays[0]->InsertNextValue(rho * conv->getFactorDensityLbToW2()); - arrays[1]->InsertNextValue(vx1 * conv->getFactorVelocityLbToW2()); - arrays[2]->InsertNextValue(vx2 * conv->getFactorVelocityLbToW2()); - arrays[3]->InsertNextValue(vx3 * conv->getFactorVelocityLbToW2()); - arrays[4]->InsertNextValue(press * conv->getFactorPressureLbToW2()); - } - } - } - } - maxX1 -= 1; - maxX2 -= 1; - maxX3 -= 1; - - vtkIdType ptIds[8]; - //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( (ptIds[0]=SWB=nodeNumbers( ix1 , ix2, ix3 )) >= 0 - && (ptIds[1]=SEB=nodeNumbers( ix1+1, ix2, ix3 )) >= 0 - && (ptIds[2]=NWB=nodeNumbers( ix1 , ix2+1, ix3 )) >= 0 - && (ptIds[3]=NEB=nodeNumbers( ix1+1, ix2+1, ix3 )) >= 0 - && (ptIds[4]=SWT=nodeNumbers( ix1 , ix2, ix3+1 )) >= 0 - && (ptIds[5]=SET=nodeNumbers( ix1+1, ix2, ix3+1 )) >= 0 - && (ptIds[6]=NWT=nodeNumbers( ix1 , ix2+1, ix3+1 )) >= 0 - && (ptIds[7]=NET=nodeNumbers( ix1+1, ix2+1, ix3+1 )) >= 0 - ) - { - unstructuredGrid->InsertNextCell((int)VTK_VOXEL, (vtkIdType)8, ptIds); - } - } - } - } -} -////////////////////////////////////////////////////////////////////////// -void InSituVTKCoProcessor::readConfigFile( const std::string& configFile ) -{ - ifstream ifs; - ifs.open (configFile, ifstream::in); - if(!ifs) throw UbException(UB_EXARGS,"can not open "+configFile); - - string dummy; - int wRank = 0; - getline(ifs, dummy); - int np = Communicator::getInstance()->getNumberOfProcesses(); - - while (ifs.good()) - { - getline(ifs, dummy, ';'); - getline(ifs, wIP, ';'); - getline(ifs, wHostname, ';'); - getline(ifs, dummy); - wPort = stoi(dummy); - if(wRank == gridRank) break; - wRank++; - } - ifs.close(); -} - -////////////////////////////////////////////////////////////////////////// - -#endif - - diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/InSituVTKCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/InSituVTKCoProcessor.h deleted file mode 100644 index 12959df68..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/InSituVTKCoProcessor.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifdef VF_VTK - -#ifndef InSituVTKCoProcessor_h__ -#define InSituVTKCoProcessor_h__ - -#include <CoProcessor.h> -#include <Grid3D.h> -#include <LBMUnitConverter.h> - -#include <string> - -//VTK headers -#include <vtkSocketCommunicator.h> -#include <vtkSocketController.h> -#include <vtkSmartPointer.h> -#include <vtkUnstructuredGrid.h> -#include <vtkDoubleArray.h> - -class InSituVTKCoProcessor : public CoProcessor -{ -public: - InSituVTKCoProcessor(); - InSituVTKCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& configFile, SPtr<LBMUnitConverter> conv); - virtual ~InSituVTKCoProcessor(); - void process(double step); -protected: - void collectData(double step); - void addData(SPtr<Block3D> block); - void readConfigFile(const std::string& configFile); - - //void clearData(); -private: - std::string path; - SPtr<LBMUnitConverter> conv; - std::vector<std::vector<SPtr<Block3D>> > blockVector; - int minInitLevel; - int maxInitLevel; - int gridRank; - vtkSmartPointer<vtkSocketCommunicator> comm; - vtkSmartPointer<vtkSocketController> contr; - vtkSmartPointer<vtkUnstructuredGrid> unstructuredGrid; - vtkSmartPointer<vtkPoints> points; - vtkSmartPointer<vtkDoubleArray> arrays[5]; - int wPort; - std::string wHostname; - std::string wIP; -}; - -#endif // InSituVTKCoProcessor_h__ - -#endif - diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.cpp deleted file mode 100644 index ac67dea0d..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.cpp +++ /dev/null @@ -1,305 +0,0 @@ -#include "IntegrateValuesHelper.h" - - -#include <numerics/geometry3d/GbCuboid3D.h> -#include <numerics/geometry3d/CoordinateTransformation3D.h> -#include <vector> - -#include "LBMKernel.h" -#include "BCProcessor.h" -#include "DataSet3D.h" -#include "BCArray3D.h" - -////////////////////////////////////////////////////////////////////////// -IntegrateValuesHelper::IntegrateValuesHelper(SPtr<Grid3D> grid, SPtr<Communicator> comm, - double minX1, double minX2, - double minX3, double maxX1, - double maxX2, double maxX3) : - - grid(grid), - comm(comm), - sVx1(0.0), sVx2(0.0), sVx3(0.0), sRho(0.0), sCellVolume(0.0), - numberOfFluidsNodes(0), - numberOfSolidNodes(0) -{ - boundingBox = GbCuboid3DPtr(new GbCuboid3D(minX1, minX2, minX3, maxX1, maxX2, maxX3)); - init(-1); -} -////////////////////////////////////////////////////////////////////////// -IntegrateValuesHelper::IntegrateValuesHelper(SPtr<Grid3D> grid, SPtr<Communicator> comm, - double minX1, double minX2, - double minX3, double maxX1, - double maxX2, double maxX3, - int level) : - - grid(grid), - comm(comm), - sVx1(0.0), sVx2(0.0), sVx3(0.0), sRho(0.0), sCellVolume(0.0), - numberOfFluidsNodes(0), - numberOfSolidNodes(0) -{ - boundingBox = GbCuboid3DPtr(new GbCuboid3D(minX1, minX2, minX3, maxX1, maxX2, maxX3)); - init(level); -} -////////////////////////////////////////////////////////////////////////// -IntegrateValuesHelper::~IntegrateValuesHelper() -{ -} -////////////////////////////////////////////////////////////////////////// -void IntegrateValuesHelper::init(int level) -{ - root = comm->isRoot(); - - double orgX1, orgX2, orgX3; - int gridRank = grid->getRank(); - int minInitLevel, maxInitLevel; - if (level < 0) - { - minInitLevel = this->grid->getCoarsestInitializedLevel(); - maxInitLevel = this->grid->getFinestInitializedLevel(); - } - else - { - minInitLevel = level; - maxInitLevel = level; - } - - double numSolids = 0.0; - double numFluids = 0.0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - std::vector<SPtr<Block3D>> blockVector; - grid->getBlocks(level, gridRank, blockVector); - for(SPtr<Block3D> block : blockVector) - { - CalcNodes cn; - cn.block = block; - //Koords bestimmen - UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); - - orgX1 = val<1>(org); - orgX2 = val<2>(org); - orgX3 = val<3>(org); - - SPtr<LBMKernel> kernel = dynamicPointerCast<LBMKernel>(block->getKernel()); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - int ghostLayerWitdh = kernel->getGhostLayerWidth(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - double internX1, internX2, internX3; - - double dx = grid->getDeltaX(block); - UbTupleDouble3 orgDelta = grid->getNodeOffset(block); - - for (int ix3 = ghostLayerWitdh; ix3 < (int)distributions->getNX3() - ghostLayerWitdh; ix3++) - { - for (int ix2 = ghostLayerWitdh; ix2 < (int)distributions->getNX2() - ghostLayerWitdh; ix2++) - { - for (int ix1 = ghostLayerWitdh; ix1 < (int)distributions->getNX1() - ghostLayerWitdh; ix1++) - { - internX1 = orgX1 - val<1>(orgDelta) + ix1 * dx; - internX2 = orgX2 - val<2>(orgDelta) + ix2 * dx; - internX3 = orgX3 - val<3>(orgDelta) + ix3 * dx; - if (boundingBox->isPointInGbObject3D(internX1, internX2, internX3)) - { - if (!bcArray->isSolid(ix1, ix2, ix3) && !bcArray->isUndefined(ix1, ix2, ix3)) - { - cn.nodes.push_back(UbTupleInt3(ix1, ix2, ix3)); - numFluids++; - } - else if (bcArray->isSolid(ix1, ix2, ix3)) - { - numSolids++; - } - } - } - } - } - if (cn.nodes.size() > 0) - cnodes.push_back(cn); - } - } - std::vector<double> rvalues; - std::vector<double> values; - values.push_back(numSolids); - values.push_back(numFluids); - rvalues = comm->gather(values); - - if (root) - { - numberOfSolidNodes = 0.0; - numberOfFluidsNodes = 0.0; - int rsize = (int)rvalues.size(); - int vsize = (int)values.size(); - for (int i = 0; i < rsize; i += vsize) - { - numberOfSolidNodes += rvalues[i]; - numberOfFluidsNodes += rvalues[i + 1]; - } - } - -} -////////////////////////////////////////////////////////////////////////// -// calculation conventional rho, velocity and averaged data -void IntegrateValuesHelper::calculateAV() -{ - clearData(); - - for(CalcNodes cn : cnodes) - { - SPtr<ILBMKernel> kernel = cn.block->getKernel(); - SPtr<AverageValuesArray3D> averagedValues = kernel->getDataSet()->getAverageValues(); - - for(UbTupleInt3 node : cn.nodes) - { - double Avx = (*averagedValues)(val<1>(node), val<2>(node), val<3>(node), AvVx); - double Avy = (*averagedValues)(val<1>(node), val<2>(node), val<3>(node), AvVy); - double Avz = (*averagedValues)(val<1>(node), val<2>(node), val<3>(node), AvVz); - - double Avxx = (*averagedValues)(val<1>(node), val<2>(node), val<3>(node), AvVxx); - double Avyy = (*averagedValues)(val<1>(node), val<2>(node), val<3>(node), AvVyy); - double Avzz = (*averagedValues)(val<1>(node), val<2>(node), val<3>(node), AvVzz); - - double Avxz = (*averagedValues)(val<1>(node), val<2>(node), val<3>(node), AvVxz); - sAvVx1 += abs(Avx); - sAvVx2 += abs(Avy); - sAvVx3 += abs(Avz); - - sTSx1 += sqrt(Avxx); - sTSx2 += sqrt(Avyy); - sTSx3 += sqrt(Avzz); - - sTSx1x3 += Avxz; - numberOfFluidsNodes++; - } - } - std::vector<double> values; - std::vector<double> rvalues; - values.push_back(sAvVx1); - values.push_back(sAvVx2); - values.push_back(sAvVx3); - values.push_back(sTSx1); - values.push_back(sTSx2); - values.push_back(sTSx3); - values.push_back(sTSx1x3); - values.push_back(numberOfFluidsNodes); - - rvalues = comm->gather(values); - if (root) - { - clearData(); - for (int i = 0; i < (int)rvalues.size(); i += 8) - { - sAvVx1 += rvalues[i]; - sAvVx2 += rvalues[i + 1]; - sAvVx3 += rvalues[i + 2]; - sTSx1 += rvalues[i + 3]; - sTSx2 += rvalues[i + 4]; - sTSx3 += rvalues[i + 5]; - sTSx1x3 += rvalues[i + 6]; - numberOfFluidsNodes += rvalues[i + 7]; - } - } -} -////////////////////////////////////////////////////////////////////////// -void IntegrateValuesHelper::calculateMQ() -{ - LBMReal f[D3Q27System::ENDF + 1]; - LBMReal vx1, vx2, vx3, rho; - clearData(); - - //Funktionszeiger - typedef void(*CalcMacrosFct)(const LBMReal* const& /*feq[27]*/, LBMReal& /*(d)rho*/, LBMReal& /*vx1*/, LBMReal& /*vx2*/, LBMReal& /*vx3*/); - - CalcMacrosFct calcMacros = NULL; - - for(CalcNodes cn : cnodes) - { - SPtr<ILBMKernel> kernel = cn.block->getKernel(); - LBMReal dx = 1.0 / (LBMReal)(1 << cn.block->getLevel()); - LBMReal cellVolume = dx*dx*dx; - - if (kernel->getCompressible()) - { - calcMacros = &D3Q27System::calcCompMacroscopicValues; - } - else - { - calcMacros = &D3Q27System::calcIncompMacroscopicValues; - } - - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - for(UbTupleInt3 node : cn.nodes) - { - distributions->getDistribution(f, val<1>(node), val<2>(node), val<3>(node)); - calcMacros(f, rho, vx1, vx2, vx3); - sRho += rho*cellVolume; - sVx1 += vx1*cellVolume; - sVx2 += vx2*cellVolume; - sVx3 += vx3*cellVolume; - sCellVolume += cellVolume; - } - } - std::vector<double> values(5); - std::vector<double> rvalues; - values[0] = sRho; - values[1] = sVx1; - values[2] = sVx2; - values[3] = sVx3; - values[4] = sCellVolume; - - rvalues = comm->gather(values); - if (root) - { - clearData(); - int rsize = (int)rvalues.size(); - int vsize = (int)values.size(); - for (int i = 0; i < rsize; i += vsize) - { - sRho += rvalues[i]; - sVx1 += rvalues[i + 1]; - sVx2 += rvalues[i + 2]; - sVx3 += rvalues[i + 3]; - sCellVolume += rvalues[i + 4]; - } - } -} -////////////////////////////////////////////////////////////////////////// -void IntegrateValuesHelper::clearData() -{ - sRho = 0.0; - sVx1 = 0.0; - sVx2 = 0.0; - sVx3 = 0.0; - sCellVolume = 0.0; - //sVm = 0.0; - //sPress = 0.0; - //numberOfFluidsNodes = 0.0; - sAvVx1 = 0.0; - sAvVx2 = 0.0; - sAvVx3 = 0.0; - sTSx1 = 0.0; - sTSx2 = 0.0; - sTSx3 = 0.0; - sTSx1x3 = 0.0; -} -////////////////////////////////////////////////////////////////////////// -LBMReal IntegrateValuesHelper::getNumberOfFluidsNodes() -{ - return this->numberOfFluidsNodes; -} -////////////////////////////////////////////////////////////////////////// -LBMReal IntegrateValuesHelper::getNumberOfSolidNodes() -{ - return this->numberOfSolidNodes; -} -////////////////////////////////////////////////////////////////////////// -GbCuboid3DPtr IntegrateValuesHelper::getBoundingBox() -{ - return this->boundingBox; -} -////////////////////////////////////////////////////////////////////////// -std::vector<IntegrateValuesHelper::CalcNodes> IntegrateValuesHelper::getCNodes() -{ - return cnodes; -} diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.h b/src/cpu/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.h deleted file mode 100644 index 49ec3b156..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/IntegrateValuesHelper.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef INTEGRATEVALUESHELPER_H -#define INTEGRATEVALUESHELPER_H - -#include <PointerDefinitions.h> - -#include "Grid3D.h" -#include "D3Q27System.h" -#include "Communicator.h" -#include "GbCuboid3D.h" -#include "CbArray2D.h" -#include "Block3D.h" - -//struct CalcNodes -//{ -// SPtr<Block3D> block; -// std::vector<UbTupleInt3> nodes; -//}; -// -//struct Nodes -//{ -// SPtr<Block3D> block; -// UbTupleInt3 nodes; -//}; - - -class IntegrateValuesHelper -{ -public: - struct CalcNodes - { - SPtr<Block3D> block; - std::vector<UbTupleInt3> nodes; - }; - - struct Node - { - SPtr<Block3D> block; - UbTupleInt3 node; - }; -public: - IntegrateValuesHelper(SPtr<Grid3D> grid, SPtr<Communicator> comm, - double minX1, double minX2, double minX3, - double maxX1, double maxX2, double maxX3); - IntegrateValuesHelper(SPtr<Grid3D> grid, SPtr<Communicator> comm, - double minX1, double minX2, double minX3, - double maxX1, double maxX2, double maxX3, int level); - virtual ~IntegrateValuesHelper(); - - void calculateMQ(); - void calculateAV(); - void clearData(); - - double getRho() {return sRho;} - double getVx1() {return sVx1;} - double getVx2() {return sVx2;} - double getVx3() {return sVx3;} - double getCellsVolume() { return sCellVolume; } - // LBMReal getVm() { return sVm; } - //LBMReal getPress() {return sPress;} - double getAvVx1(){return sAvVx1;} - double getAvVx2(){return sAvVx2;} - double getAvVx3(){return sAvVx3;} - double getTSx1(){return sTSx1;} - double getTSx2(){return sTSx2;} - double getTSx3(){return sTSx3;} - double getTSx1x3(){return sTSx1x3;} - - LBMReal getNumberOfFluidsNodes(); - LBMReal getNumberOfSolidNodes(); - GbCuboid3DPtr getBoundingBox(); - std::vector<CalcNodes> getCNodes(); - -protected: -private: - void init(int level); - - bool root; - SPtr<Grid3D> grid; - double sVx1, sVx2, sVx3, sRho, sCellVolume;// sPress, sVm; - double numberOfFluidsNodes, numberOfSolidNodes; - double sAvVx1, sAvVx2, sAvVx3, sTSx1, sTSx2, sTSx3, sTSx1x3; - std::vector<CalcNodes> cnodes; - GbCuboid3DPtr boundingBox; - SPtr<Communicator> comm; - CbArray2D<Node> cnodes2DMatrix; - enum Values{AvVx = 0, AvVy = 1, AvVz = 2, AvVxx = 3, AvVyy = 4, AvVzz = 5, AvVxy = 6, AvVyz = 7, AvVxz = 8}; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.cpp deleted file mode 100644 index 559303616..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.cpp +++ /dev/null @@ -1,247 +0,0 @@ -#include "LineTimeSeriesCoProcessor.h" -#include "BCProcessor.h" -#include "WbWriterVtkXmlASCII.h" - -#include "DataSet3D.h" -#include "LBMKernel.h" -#include "CoordinateTransformation3D.h" -#include "Block3D.h" -#include "GbLine3D.h" -#include "UbScheduler.h" -#include "Grid3D.h" -#include "Communicator.h" -#include "CompressibleCumulantLBMKernel.h" - -LineTimeSeriesCoProcessor::LineTimeSeriesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, SPtr<GbLine3D> line, int level, SPtr<Communicator> comm) : - CoProcessor(grid, s), - path(path), - length(0), - ix1(0), - ix2(0), - ix3(0), - level(level), - line(line) -{ - root = comm->isRoot(); - fname = path; - - mpi_comm = *((MPI_Comm*)comm->getNativeCommunicator()); - numOfProc = comm->getNumberOfProcesses(); - gridRank = comm->getProcessID(); - - double dx = CoProcessor::grid->getDeltaX(level); - - SPtr<CoordinateTransformation3D> trafo = grid->getCoordinateTransformator(); - double orgX1 = trafo->getX1CoordinateOffset(); - double orgX2 = trafo->getX2CoordinateOffset(); - 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); - - UbTupleInt3 blockNx = grid->getBlockNX(); - - if (x1min!=x1max) - { - dir = X1; - blocknx = val<1>(blockNx); - length = x1max; - } - else if (x2min!=x2max) - { - dir = X2; - blocknx = val<2>(blockNx); - length = x2max; - } - else if (x3min!=x3max) - { - dir = X3; - blocknx = val<3>(blockNx); - length = x3max; - } - blockix1 = x1min/val<1>(blockNx); - blockix2 = x2min/val<2>(blockNx); - blockix3 = x3min/val<3>(blockNx); - - ix1 = x1min%val<1>(blockNx)+1; - ix2 = x2min%val<2>(blockNx)+1; - ix3 = x3min%val<3>(blockNx)+1; -} -////////////////////////////////////////////////////////////////////////// -void LineTimeSeriesCoProcessor::process(double step) -{ - if (scheduler->isDue(step)) - { - collectData(); - } - - UBLOG(logDEBUG3, "MacroscopicQuantitiesCoProcessor::update:"<<step); -} -////////////////////////////////////////////////////////////////////////// -void LineTimeSeriesCoProcessor::writeLine(const std::string& path) -{ - std::vector<UbTupleFloat3 > nodes(2); - std::vector<UbTupleInt2 > lines(1); - val<1>(nodes[0]) = (float)line->getX1Minimum(); - val<2>(nodes[0]) = (float)line->getX2Minimum(); - val<3>(nodes[0]) = (float)line->getX3Minimum(); - val<1>(nodes[1]) = (float)line->getX1Maximum(); - val<2>(nodes[1]) = (float)line->getX2Maximum(); - val<3>(nodes[1]) = (float)line->getX3Maximum(); - val<1>(lines[0]) = 0; - val<1>(lines[0]) = 1; - WbWriterVtkXmlASCII *writer = WbWriterVtkXmlASCII::getInstance(); - writer->writeLines(path, nodes, lines); -} -////////////////////////////////////////////////////////////////////////// -void LineTimeSeriesCoProcessor::collectData() -{ - LBMReal f[27]; - LBMReal vx1, vx2, vx3, rho; - MPI_Status status; - std::vector<double> v1(length, 0); - std::vector<double> v2(length, 0); - std::vector<double> v3(length, 0); - std::vector<double> p(length, 0); - for (int x = 0; x<length; x += blocknx) - { - if (dir == X1) - { - blockix1 = x/blocknx; - } - else if (dir == X2) - { - blockix2 = x/blocknx; - } - else if (dir == X3) - { - blockix3 = x/blocknx; - } - - SPtr<Block3D> block = CoProcessor::grid->getBlock(blockix1, blockix2, blockix3, level); - if (block) - { - if (block->getRank()==gridRank) - { - SPtr<ILBMKernel> kernel = block->getKernel(); - calcMacros = NULL; - if (kernel->getCompressible()) - { - calcMacros = &D3Q27System::calcCompMacroscopicValues; - } - else - { - calcMacros = &D3Q27System::calcIncompMacroscopicValues; - } - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - - for (int ix = 1; ix<=blocknx; ix++) - { - if (dir==X1) - { - ix1 = ix; - } - else if (dir==X2) - { - ix2 = ix; - } - else if (dir==X3) - { - ix3 = ix; - } - distributions->getDistribution(f, ix1, ix2, ix3); - calcMacros(f, rho, vx1, vx2, vx3); - v1[x+(ix-1)] = vx1; - v2[x+(ix-1)] = vx2; - v3[x+(ix-1)] = vx3; - p[x+(ix-1)] = rho; - } - } - } - - } - - if (root) - { - for (int i = 1; i<numOfProc; i++) - { - std::vector<double> v1temp(length, 0); - std::vector<double> v2temp(length, 0); - std::vector<double> v3temp(length, 0); - std::vector<double> ptemp(length, 0); - MPI_Recv(&v1temp[0], length, MPI_DOUBLE, i, 1, mpi_comm, &status); - MPI_Recv(&v2temp[0], length, MPI_DOUBLE, i, 2, mpi_comm, &status); - MPI_Recv(&v3temp[0], length, MPI_DOUBLE, i, 3, mpi_comm, &status); - MPI_Recv( &ptemp[0], length, MPI_DOUBLE, i, 4, mpi_comm, &status); - for (int j = 0; j<length; j++) - { - v1[j] += v1temp[j]; - v2[j] += v2temp[j]; - v3[j] += v3temp[j]; - p[j] += ptemp[j]; - } - } - - std::ofstream ostr; - ostr.open(fname.c_str(), std::ios_base::out|std::ios_base::app); - if (!ostr) - { - ostr.clear(); - std::string path = UbSystem::getPathFromString(fname); - if (path.size()>0) { UbSystem::makeDirectory(path); ostr.open(fname.c_str(), std::ios_base::out|std::ios_base::app); } - if (!ostr) throw UbException(UB_EXARGS, "couldn't open file "+fname); - } - - for (int x = 0; x<length; x++) - { - ostr<<v1[x]; - if (x<length-1) - { - ostr<<";"; - } - } - ostr<<"\n"; - for (int x = 0; x<length; x++) - { - ostr<<v2[x]; - if (x<length-1) - { - ostr<<";"; - } - } - ostr<<"\n"; - for (int x = 0; x<length; x++) - { - ostr<<v3[x]; - if (x<length-1) - { - ostr<<";"; - } - } - ostr<<"\n"; - for (int x = 0; x<length; x++) - { - ostr<<p[x]; - if (x<length-1) - { - ostr<<";"; - } - } - ostr<<"\n"; - ostr.close(); - } - else - { - MPI_Send(&v1[0], length, MPI_DOUBLE, 0, 1, mpi_comm); - MPI_Send(&v2[0], length, MPI_DOUBLE, 0, 2, mpi_comm); - MPI_Send(&v3[0], length, MPI_DOUBLE, 0, 3, mpi_comm); - MPI_Send( &p[0], length, MPI_DOUBLE, 0, 4, mpi_comm); - } -} - - diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.h deleted file mode 100644 index b3d821110..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/LineTimeSeriesCoProcessor.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef LineTimeSeriesCoProcessor_h__ -#define LineTimeSeriesCoProcessor_h__ - -#include <PointerDefinitions.h> -#include <string> - -#include <mpi.h> - -#include "CoProcessor.h" -#include "LBMSystem.h" - -class Communicator; -class Grid3D; -class UbScheduler; -class GbLine3D; - -//! \brief Writes to .csv file time series for a line in x1 direction. -//! \details It can be used to compute for given time range the time averaged two-point correlations for a line. <br> -//! \f$ R_{ij}(x_{a},x{b},t) = <u_{i}(x_{a},t)u_{j}(x_{a}+r,t)> \f$ <br> -// -//! \author Konstantin Kutscher - -class LineTimeSeriesCoProcessor : public CoProcessor -{ -public: -enum Direction {X1, X2, X3}; -public: - LineTimeSeriesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, SPtr<GbLine3D> line, int level,SPtr<Communicator> comm); - ~LineTimeSeriesCoProcessor(){} - - void process(double step) override; - void writeLine(const std::string& path); - -protected: - void collectData(); -private: - std::string path; - std::string fname; - bool root; - SPtr<GbLine3D> line; - //function pointer - typedef void(*CalcMacrosFct)(const LBMReal* const& /*feq[27]*/, LBMReal& /*(d)rho*/, LBMReal& /*vx1*/, LBMReal& /*vx2*/, LBMReal& /*vx3*/); - CalcMacrosFct calcMacros; - int blocknx; - int blockix1; - int blockix2; - int blockix3; - int level; - int ix1; - int ix2; - int ix3; - int length; - MPI_Comm mpi_comm; - int numOfProc; - int gridRank; - Direction dir; -}; -#endif // LineTimeSeriesCoProcessor_h__ diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.cpp deleted file mode 100644 index d5a7b0265..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.cpp +++ /dev/null @@ -1,411 +0,0 @@ -#include "MPIIOCoProcessor.h" -#include "Block3D.h" -#include "CoordinateTransformation3D.h" -#include "Grid3D.h" -#include "Communicator.h" -#include "UbScheduler.h" -#include "MPIIODataStructures.h" -#include "UbLogger.h" -#include "MemoryUtil.h" - -using namespace MPIIODataStructures; - -MPIIOCoProcessor::MPIIOCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, SPtr<Communicator> comm) : - CoProcessor(grid, s), - path(path), - comm(comm) -{ - UbSystem::makeDirectory(path + "/mpi_io_cp"); - - //------------------------- define MPI types --------------------------------- - - MPI_Datatype typesGP[3] = { MPI_DOUBLE, MPI_INT, MPI_CHAR }; - int blocksGP[3] = { 34, 6, 5 }; - MPI_Aint offsetsGP[3], lbGP, extentGP; - - offsetsGP[0] = 0; - MPI_Type_get_extent(MPI_DOUBLE, &lbGP, &extentGP); - offsetsGP[1] = blocksGP[0] * extentGP; - - MPI_Type_get_extent(MPI_INT, &lbGP, &extentGP); - offsetsGP[2] = offsetsGP[1] + blocksGP[1] * extentGP; - - MPI_Type_create_struct(3, blocksGP, offsetsGP, typesGP, &gridParamType); - MPI_Type_commit(&gridParamType); - - //----------------------------------------------------------------------- - - MPI_Datatype typesBlock[2] = { MPI_INT, MPI_CHAR }; - int blocksBlock[2] = { 13, 1 }; - MPI_Aint offsetsBlock[2], lbBlock, extentBlock; - - offsetsBlock[0] = 0; - MPI_Type_get_extent(MPI_INT, &lbBlock, &extentBlock); - offsetsBlock[1] = blocksBlock[0] * extentBlock; - - MPI_Type_create_struct(2, blocksBlock, offsetsBlock, typesBlock, &block3dType); - MPI_Type_commit(&block3dType); -} - -MPIIOCoProcessor::~MPIIOCoProcessor() -{ - MPI_Type_free(&gridParamType); - MPI_Type_free(&block3dType); -} - -void MPIIOCoProcessor::writeBlocks(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - //MPI_Comm_size(MPI_COMM_WORLD, &size); - size = 1; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOCoProcessor::writeBlocks start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - int blocksCount = 0; // quantity of all the blocks in the grid, max 2147483648 blocks! - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - - std::vector<SPtr<Block3D>> blocksVector[25]; // max 25 levels - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - //grid->getBlocks(level, rank, blockVector[level]); - grid->getBlocks(level, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - GridParam* gridParameters = new GridParam; - gridParameters->trafoParams[0] = grid->getCoordinateTransformator()->Tx1; - gridParameters->trafoParams[1] = grid->getCoordinateTransformator()->Tx2; - gridParameters->trafoParams[2] = grid->getCoordinateTransformator()->Tx3; - gridParameters->trafoParams[3] = grid->getCoordinateTransformator()->Sx1; - gridParameters->trafoParams[4] = grid->getCoordinateTransformator()->Sx2; - gridParameters->trafoParams[5] = grid->getCoordinateTransformator()->Sx3; - gridParameters->trafoParams[6] = grid->getCoordinateTransformator()->alpha; - gridParameters->trafoParams[7] = grid->getCoordinateTransformator()->beta; - gridParameters->trafoParams[8] = grid->getCoordinateTransformator()->gamma; - - gridParameters->trafoParams[9] = grid->getCoordinateTransformator()->toX1factorX1; - gridParameters->trafoParams[10] = grid->getCoordinateTransformator()->toX1factorX2; - gridParameters->trafoParams[11] = grid->getCoordinateTransformator()->toX1factorX3; - gridParameters->trafoParams[12] = grid->getCoordinateTransformator()->toX1delta; - gridParameters->trafoParams[13] = grid->getCoordinateTransformator()->toX2factorX1; - gridParameters->trafoParams[14] = grid->getCoordinateTransformator()->toX2factorX2; - gridParameters->trafoParams[15] = grid->getCoordinateTransformator()->toX2factorX3; - gridParameters->trafoParams[16] = grid->getCoordinateTransformator()->toX2delta; - gridParameters->trafoParams[17] = grid->getCoordinateTransformator()->toX3factorX1; - gridParameters->trafoParams[18] = grid->getCoordinateTransformator()->toX3factorX2; - gridParameters->trafoParams[19] = grid->getCoordinateTransformator()->toX3factorX3; - gridParameters->trafoParams[20] = grid->getCoordinateTransformator()->toX3delta; - - gridParameters->trafoParams[21] = grid->getCoordinateTransformator()->fromX1factorX1; - gridParameters->trafoParams[22] = grid->getCoordinateTransformator()->fromX1factorX2; - gridParameters->trafoParams[23] = grid->getCoordinateTransformator()->fromX1factorX3; - gridParameters->trafoParams[24] = grid->getCoordinateTransformator()->fromX1delta; - gridParameters->trafoParams[25] = grid->getCoordinateTransformator()->fromX2factorX1; - gridParameters->trafoParams[26] = grid->getCoordinateTransformator()->fromX2factorX2; - gridParameters->trafoParams[27] = grid->getCoordinateTransformator()->fromX2factorX3; - gridParameters->trafoParams[28] = grid->getCoordinateTransformator()->fromX2delta; - gridParameters->trafoParams[29] = grid->getCoordinateTransformator()->fromX3factorX1; - gridParameters->trafoParams[30] = grid->getCoordinateTransformator()->fromX3factorX2; - gridParameters->trafoParams[31] = grid->getCoordinateTransformator()->fromX3factorX3; - gridParameters->trafoParams[32] = grid->getCoordinateTransformator()->fromX3delta; - - gridParameters->active = grid->getCoordinateTransformator()->active; - gridParameters->transformation = grid->getCoordinateTransformator()->transformation; - - gridParameters->deltaX = grid->getDeltaX(minInitLevel); - UbTupleInt3 blocknx = grid->getBlockNX(); - gridParameters->blockNx1 = val<1>(blocknx); - gridParameters->blockNx2 = val<2>(blocknx); - gridParameters->blockNx3 = val<3>(blocknx); - gridParameters->nx1 = grid->getNX1(); - gridParameters->nx2 = grid->getNX2(); - gridParameters->nx3 = grid->getNX3(); - gridParameters->periodicX1 = grid->isPeriodicX1(); - gridParameters->periodicX2 = grid->isPeriodicX2(); - gridParameters->periodicX3 = grid->isPeriodicX3(); - - //---------------------------------------------------------------------- - - Block3d* block3dArray = new Block3d[blocksCount]; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // all the blocks of the current level - { - // save data describing the block - block3dArray[ic].x1 = block->getX1(); - block3dArray[ic].x2 = block->getX2(); - block3dArray[ic].x3 = block->getX3(); - block3dArray[ic].bundle = block->getBundle(); - block3dArray[ic].rank = block->getRank(); - block3dArray[ic].lrank = block->getLocalRank(); - block3dArray[ic].part = block->getPart(); - block3dArray[ic].globalID = block->getGlobalID(); - block3dArray[ic].localID = block->getLocalID(); - block3dArray[ic].level = block->getLevel(); - block3dArray[ic].interpolationFlagCF = block->getCollectionOfInterpolationFlagCF(); - block3dArray[ic].interpolationFlagFC = block->getCollectionOfInterpolationFlagFC(); - block3dArray[ic].counter = block->getMaxGlobalID(); - block3dArray[ic].active = block->isActive(); - - ic++; - } - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOCoProcessor::writeBlocks start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - // write to the file - MPI_File file_handler; - MPI_Info info = MPI_INFO_NULL; - - UbSystem::makeDirectory(path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step)); - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBlocks.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - double start, finish; - MPI_Offset write_offset = (MPI_Offset)(size * sizeof(int)); - - if (comm->isRoot()) - { - start = MPI_Wtime(); - - // each process writes the quantity of it's blocks - MPI_File_write_at(file_handler, 0/*rank*sizeof(int)*/, &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - // each process writes parameters of the grid - MPI_File_write_at(file_handler, write_offset, gridParameters, 1, gridParamType, MPI_STATUS_IGNORE); - // each process writes it's blocks - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(GridParam)), &block3dArray[0], blocksCount, block3dType, MPI_STATUS_IGNORE); - //MPI_File_sync(file_handler); - } - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOCoProcessor::writeBlocks time: " << finish - start << " s"); - } - - delete[] block3dArray; - delete gridParameters; -} - -void MPIIOCoProcessor::readBlocks(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - size = 1; - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOCoProcessor::readBlocks start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBlocks.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - int blocksCount = 0; - MPI_File_read_at(file_handler, 0, &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - Block3d* block3dArray = new Block3d[blocksCount]; - - GridParam* gridParameters = new GridParam; - - // calculate the read offset - MPI_Offset read_offset = (MPI_Offset)(sizeof(int)); - - // read parameters of the grid - MPI_File_read_at(file_handler, read_offset, gridParameters, 1, gridParamType, MPI_STATUS_IGNORE); - // read all the blocks - if (comm->isRoot()) - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(GridParam)), &block3dArray[0], blocksCount, block3dType, MPI_STATUS_IGNORE); - - MPI_Bcast(block3dArray, blocksCount, block3dType, comm->getRoot(), MPI_COMM_WORLD); - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOCoProcessor::readBlocks time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOCoProcessor::readBlocks start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - // clear the grid - grid->deleteBlocks(); - - // restore the grid - SPtr<CoordinateTransformation3D> trafo(new CoordinateTransformation3D()); - trafo->Tx1 = gridParameters->trafoParams[0]; - trafo->Tx2 = gridParameters->trafoParams[1]; - trafo->Tx3 = gridParameters->trafoParams[2]; - trafo->Sx1 = gridParameters->trafoParams[3]; - trafo->Sx2 = gridParameters->trafoParams[4]; - trafo->Sx3 = gridParameters->trafoParams[5]; - trafo->alpha = gridParameters->trafoParams[6]; - trafo->beta = gridParameters->trafoParams[7]; - trafo->gamma = gridParameters->trafoParams[8]; - - trafo->toX1factorX1 = gridParameters->trafoParams[9]; - trafo->toX1factorX2 = gridParameters->trafoParams[10]; - trafo->toX1factorX3 = gridParameters->trafoParams[11]; - trafo->toX1delta = gridParameters->trafoParams[12]; - trafo->toX2factorX1 = gridParameters->trafoParams[13]; - trafo->toX2factorX2 = gridParameters->trafoParams[14]; - trafo->toX2factorX3 = gridParameters->trafoParams[15]; - trafo->toX2delta = gridParameters->trafoParams[16]; - trafo->toX3factorX1 = gridParameters->trafoParams[17]; - trafo->toX3factorX2 = gridParameters->trafoParams[18]; - trafo->toX3factorX3 = gridParameters->trafoParams[19]; - trafo->toX3delta = gridParameters->trafoParams[20]; - - trafo->fromX1factorX1 = gridParameters->trafoParams[21]; - trafo->fromX1factorX2 = gridParameters->trafoParams[22]; - trafo->fromX1factorX3 = gridParameters->trafoParams[23]; - trafo->fromX1delta = gridParameters->trafoParams[24]; - trafo->fromX2factorX1 = gridParameters->trafoParams[25]; - trafo->fromX2factorX2 = gridParameters->trafoParams[26]; - trafo->fromX2factorX3 = gridParameters->trafoParams[27]; - trafo->fromX2delta = gridParameters->trafoParams[28]; - trafo->fromX3factorX1 = gridParameters->trafoParams[29]; - trafo->fromX3factorX2 = gridParameters->trafoParams[30]; - trafo->fromX3factorX3 = gridParameters->trafoParams[31]; - trafo->fromX3delta = gridParameters->trafoParams[32]; - - trafo->active = gridParameters->active; - trafo->transformation = gridParameters->transformation; - - grid->setCoordinateTransformator(trafo); - - grid->setDeltaX(gridParameters->deltaX); - grid->setBlockNX(gridParameters->blockNx1, gridParameters->blockNx2, gridParameters->blockNx3); - grid->setNX1(gridParameters->nx1); - grid->setNX2(gridParameters->nx2); - grid->setNX3(gridParameters->nx3); - grid->setPeriodicX1(gridParameters->periodicX1); - grid->setPeriodicX2(gridParameters->periodicX2); - grid->setPeriodicX3(gridParameters->periodicX3); - - // regenerate blocks - for (int n = 0; n < blocksCount; n++) - { - SPtr<Block3D> block(new Block3D(block3dArray[n].x1, block3dArray[n].x2, block3dArray[n].x3, block3dArray[n].level)); - block->setActive(block3dArray[n].active); - block->setBundle(block3dArray[n].bundle); - block->setRank(block3dArray[n].rank); - block->setLocalRank(block3dArray[n].lrank); - block->setGlobalID(block3dArray[n].globalID); - block->setLocalID(block3dArray[n].localID); - block->setPart(block3dArray[n].part); - block->setLevel(block3dArray[n].level); - block->setCollectionOfInterpolationFlagCF(block3dArray[n].interpolationFlagCF); - block->setCollectionOfInterpolationFlagFC(block3dArray[n].interpolationFlagFC); - - grid->addBlock(block); - } - - delete gridParameters; - delete[] block3dArray; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOCoProcessor::readBlocks end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } -} - -void MPIIOCoProcessor::clearAllFiles(int step) -{ - MPI_File file_handler; - MPI_Info info = MPI_INFO_NULL; - MPI_Offset new_size = 0; - - UbSystem::makeDirectory(path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step)); - - std::string filename1 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBlocks.bin"; - int rc1 = MPI_File_open(MPI_COMM_WORLD, filename1.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handler); - if (rc1 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename1); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename2 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSet.bin"; - int rc2 = MPI_File_open(MPI_COMM_WORLD, filename2.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc2 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename2); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename3 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpArrays.bin"; - int rc3 = MPI_File_open(MPI_COMM_WORLD, filename3.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc3 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename3); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename4 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageDensityArray.bin"; - //MPI_File_delete(filename4.c_str(), info); - int rc4 = MPI_File_open(MPI_COMM_WORLD, filename4.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc4 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename4); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename5 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageVelocityArray.bin"; - //MPI_File_delete(filename5.c_str(), info); - int rc5 = MPI_File_open(MPI_COMM_WORLD, filename5.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc5 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename5); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename6 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageFluktuationsArray.bin"; - //MPI_File_delete(filename6.c_str(), info); - int rc6 = MPI_File_open(MPI_COMM_WORLD, filename6.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc6 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename6); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename7 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageTripleArray.bin"; - //MPI_File_delete(filename7.c_str(), info); - int rc7 = MPI_File_open(MPI_COMM_WORLD, filename7.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc7 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename7); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename8 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpShearStressValArray.bin"; - //MPI_File_delete(filename8.c_str(), info); - int rc8 = MPI_File_open(MPI_COMM_WORLD, filename8.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc8 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename8); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename9 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpRelaxationFactor.bin"; - //MPI_File_delete(filename9.c_str(), info); - int rc9 = MPI_File_open(MPI_COMM_WORLD, filename9.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc9 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename9); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename10 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBC1.bin"; - int rc10 = MPI_File_open(MPI_COMM_WORLD, filename10.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc10 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename10); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename11 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBC2.bin"; - int rc11 = MPI_File_open(MPI_COMM_WORLD, filename11.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc11 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename11); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); -} diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.h deleted file mode 100644 index 93de60bff..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOCoProcessor.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _MPIIOCoProcessor_H_ -#define _MPIIOCoProcessor_H_ - -#include "CoProcessor.h" -#include <PointerDefinitions.h> -#include <string> -#include <mpi.h> - -class Grid3D; -class UbScheduler; -class Communicator; - -//! \class MPIWriteBlocksBECoProcessor -//! \brief Writes the grid each timestep into the files and reads the grip from the files before regenerating -class MPIIOCoProcessor : public CoProcessor -{ -public: - MPIIOCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, SPtr<Communicator> comm); - virtual ~MPIIOCoProcessor(); - - //! Each timestep writes the grid into the files - virtual void process(double step) = 0; - - //! Writes the blocks of the grid into the file cpBlocks.bin - void writeBlocks(int step); - - //! Reads the blocks of the grid from the file cpBlocks.bin - void readBlocks(int step); - - //!The function truncates the data files - void clearAllFiles(int step); -protected: - std::string path; - SPtr<Communicator> comm; - MPI_Datatype gridParamType, block3dType; -}; -#endif // ! _MPIIOCoProcessor_H_ -#define _MPIIOCoProcessor_H_ diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.cpp deleted file mode 100644 index 3c49bd45b..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.cpp +++ /dev/null @@ -1,2619 +0,0 @@ -#include "MPIIOMigrationBECoProcessor.h" -#include "D3Q27System.h" -#include "LBMKernel.h" -#include "D3Q27EsoTwist3DSplittedVector.h" -#include <UbSystem.h> -#include <MemoryUtil.h> -#include "BoundaryConditions.h" -#include "Block3D.h" -#include "CoordinateTransformation3D.h" -#include "DataSet3D.h" -#include "Grid3D.h" -#include "BCArray3D.h" -#include "Communicator.h" -#include "WbWriter.h" -#include "UbScheduler.h" -#include "LBMKernel.h" -#include "BCProcessor.h" -#include "MetisPartitioningGridVisitor.h" -#include "PointerDefinitions.h" -#include "RenumberGridVisitor.h" -#include "UbFileOutputASCII.h" -#include "UbFileInputASCII.h" - -using namespace MPIIODataStructures; - -#define MESSAGE_TAG 80 -#define SEND_BLOCK_SIZE 100000 - -MPIIOMigrationBECoProcessor::MPIIOMigrationBECoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, - const std::string& path, - SPtr<Communicator> comm) : - CoProcessor(grid, s), - path(path), - comm(comm), - nue(-999.999) -{ - UbSystem::makeDirectory(path + "/mpi_io_cp"); - - memset(&boundCondParamStr, 0, sizeof(boundCondParamStr)); - - //------------------------- define MPI types --------------------------------- - - MPI_Datatype typesGP[3] = { MPI_DOUBLE, MPI_INT, MPI_CHAR }; - int blocksGP[3] = { 34, 6, 5 }; - MPI_Aint offsetsGP[3], lbGP, extentGP; - - offsetsGP[0] = 0; - MPI_Type_get_extent(MPI_DOUBLE, &lbGP, &extentGP); - offsetsGP[1] = blocksGP[0] * extentGP; - - MPI_Type_get_extent(MPI_INT, &lbGP, &extentGP); - offsetsGP[2] = offsetsGP[1] + blocksGP[1] * extentGP; - - MPI_Type_create_struct(3, blocksGP, offsetsGP, typesGP, &gridParamType); - MPI_Type_commit(&gridParamType); - - //----------------------------------------------------------------------- - - MPI_Datatype typesBlock[2] = { MPI_INT, MPI_CHAR }; - int blocksBlock[2] = { 13, 1 }; - MPI_Aint offsetsBlock[2], lbBlock, extentBlock; - - offsetsBlock[0] = 0; - MPI_Type_get_extent(MPI_INT, &lbBlock, &extentBlock); - offsetsBlock[1] = blocksBlock[0] * extentBlock; - - MPI_Type_create_struct(2, blocksBlock, offsetsBlock, typesBlock, &block3dType); - MPI_Type_commit(&block3dType); - - //----------------------------------------------------------------------- - - MPI_Datatype typesBC[3] = { MPI_LONG_LONG_INT, MPI_FLOAT, MPI_CHAR }; - int blocksBC[3] = { 5, 38, 1 }; - MPI_Aint offsetsBC[3], lbBC, extentBC; - - offsetsBC[0] = 0; - MPI_Type_get_extent(MPI_LONG_LONG_INT, &lbBC, &extentBC); - offsetsBC[1] = blocksBC[0] * extentBC; - - MPI_Type_get_extent(MPI_FLOAT, &lbBC, &extentBC); - offsetsBC[2] = offsetsBC[1] + blocksBC[1] * extentBC; - - MPI_Type_create_struct(3, blocksBC, offsetsBC, typesBC, &boundCondType); - MPI_Type_commit(&boundCondType); - - //----------------------------------------------------------------------- - - MPI_Type_contiguous(7, MPI_INT, &dataSetParamType); - MPI_Type_commit(&dataSetParamType); - - //--------------------------------------- - - MPI_Type_contiguous(6, MPI_CHAR, &arrayPresenceType); - MPI_Type_commit(&arrayPresenceType); - - //----------------------------------------------------------------------- - - MPI_Type_contiguous(SEND_BLOCK_SIZE, MPI_DOUBLE, &sendBlockDoubleType); - MPI_Type_commit(&sendBlockDoubleType); - - MPI_Type_contiguous(SEND_BLOCK_SIZE, MPI_INT, &sendBlockIntType); - MPI_Type_commit(&sendBlockIntType); - -} - -////////////////////////////////////////////////////////////////////////// -MPIIOMigrationBECoProcessor::~MPIIOMigrationBECoProcessor() -{ - MPI_Type_free(&gridParamType); - MPI_Type_free(&block3dType); - MPI_Type_free(&boundCondType); - MPI_Type_free(&dataSetParamType); - MPI_Type_free(&sendBlockDoubleType); - MPI_Type_free(&sendBlockIntType); - MPI_Type_free(&arrayPresenceType); -} - -void MPIIOMigrationBECoProcessor::process(double step) -{ - if (scheduler->isDue(step)) - { - if (comm->isRoot()) UBLOG(logINFO, "MPIIOMigrationBECoProcessor save step: " << step); - if (comm->isRoot()) UBLOG(logINFO, "Save check point - start"); - clearAllFiles((int)step); - - writeBlocks((int)step); - writeDataSet((int)step); - writeBoundaryConds((int)step); - - writeCpTimeStep((int)step); - - if (comm->isRoot()) UBLOG(logINFO, "Save check point - end"); - } -} - -void MPIIOMigrationBECoProcessor::clearAllFiles(int step) -{ - MPI_File file_handler; - MPI_Info info = MPI_INFO_NULL; - MPI_Offset new_size = 0; - - UbSystem::makeDirectory(path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step)); - - std::string filename1 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBlocks.bin"; - int rc1 = MPI_File_open(MPI_COMM_WORLD, filename1.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handler); - if (rc1 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename1); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename2 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSet.bin"; - int rc2 = MPI_File_open(MPI_COMM_WORLD, filename2.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc2 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename2); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename3 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpArrays.bin"; - int rc3 = MPI_File_open(MPI_COMM_WORLD, filename3.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc3 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename3); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename4 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageDensityArray.bin"; - //MPI_File_delete(filename4.c_str(), info); - int rc4 = MPI_File_open(MPI_COMM_WORLD, filename4.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc4 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename4); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename5 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageVelocityArray.bin"; - //MPI_File_delete(filename5.c_str(), info); - int rc5 = MPI_File_open(MPI_COMM_WORLD, filename5.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc5 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename5); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename6 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageFluktuationsArray.bin"; - //MPI_File_delete(filename6.c_str(), info); - int rc6 = MPI_File_open(MPI_COMM_WORLD, filename6.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc6 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename6); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename7 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageTripleArray.bin"; - //MPI_File_delete(filename7.c_str(), info); - int rc7 = MPI_File_open(MPI_COMM_WORLD, filename7.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc7 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename7); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename8 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpShearStressValArray.bin"; - //MPI_File_delete(filename8.c_str(), info); - int rc8 = MPI_File_open(MPI_COMM_WORLD, filename8.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc8 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename8); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename9 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpRelaxationFactor.bin"; - //MPI_File_delete(filename9.c_str(), info); - int rc9 = MPI_File_open(MPI_COMM_WORLD, filename9.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc9 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename9); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename10 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBC1.bin"; - int rc10 = MPI_File_open(MPI_COMM_WORLD, filename10.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc10 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename10); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename11 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBC2.bin"; - int rc11 = MPI_File_open(MPI_COMM_WORLD, filename11.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc11 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename11); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); -} - -void MPIIOMigrationBECoProcessor::writeCpTimeStep(int step) -{ - if (comm->isRoot()) - { - UbFileOutputASCII f(path + "/mpi_io_cp/cp.txt"); - f.writeInteger(step); - } -} -////////////////////////////////////////////////////////////////////////// -int MPIIOMigrationBECoProcessor::readCpTimeStep() -{ - UbFileInputASCII f(path + "/mpi_io_cp/cp.txt"); - int step = f.readInteger(); - return step; -} - -void MPIIOMigrationBECoProcessor::writeBlocks(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - //MPI_Comm_size(MPI_COMM_WORLD, &size); - size = 1; - - grid->deleteBlockIDs(); - RenumberGridVisitor renumber(comm); - grid->accept(renumber); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeBlocks start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - int blocksCount = 0; // quantity of all the blocks in the grid, max 2147483648 blocks! - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - - std::vector<SPtr<Block3D>> blocksVector[25]; // max 25 levels - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - GridParam* gridParameters = new GridParam; - gridParameters->trafoParams[0] = grid->getCoordinateTransformator()->Tx1; - gridParameters->trafoParams[1] = grid->getCoordinateTransformator()->Tx2; - gridParameters->trafoParams[2] = grid->getCoordinateTransformator()->Tx3; - gridParameters->trafoParams[3] = grid->getCoordinateTransformator()->Sx1; - gridParameters->trafoParams[4] = grid->getCoordinateTransformator()->Sx2; - gridParameters->trafoParams[5] = grid->getCoordinateTransformator()->Sx3; - gridParameters->trafoParams[6] = grid->getCoordinateTransformator()->alpha; - gridParameters->trafoParams[7] = grid->getCoordinateTransformator()->beta; - gridParameters->trafoParams[8] = grid->getCoordinateTransformator()->gamma; - - gridParameters->trafoParams[9] = grid->getCoordinateTransformator()->toX1factorX1; - gridParameters->trafoParams[10] = grid->getCoordinateTransformator()->toX1factorX2; - gridParameters->trafoParams[11] = grid->getCoordinateTransformator()->toX1factorX3; - gridParameters->trafoParams[12] = grid->getCoordinateTransformator()->toX1delta; - gridParameters->trafoParams[13] = grid->getCoordinateTransformator()->toX2factorX1; - gridParameters->trafoParams[14] = grid->getCoordinateTransformator()->toX2factorX2; - gridParameters->trafoParams[15] = grid->getCoordinateTransformator()->toX2factorX3; - gridParameters->trafoParams[16] = grid->getCoordinateTransformator()->toX2delta; - gridParameters->trafoParams[17] = grid->getCoordinateTransformator()->toX3factorX1; - gridParameters->trafoParams[18] = grid->getCoordinateTransformator()->toX3factorX2; - gridParameters->trafoParams[19] = grid->getCoordinateTransformator()->toX3factorX3; - gridParameters->trafoParams[20] = grid->getCoordinateTransformator()->toX3delta; - - gridParameters->trafoParams[21] = grid->getCoordinateTransformator()->fromX1factorX1; - gridParameters->trafoParams[22] = grid->getCoordinateTransformator()->fromX1factorX2; - gridParameters->trafoParams[23] = grid->getCoordinateTransformator()->fromX1factorX3; - gridParameters->trafoParams[24] = grid->getCoordinateTransformator()->fromX1delta; - gridParameters->trafoParams[25] = grid->getCoordinateTransformator()->fromX2factorX1; - gridParameters->trafoParams[26] = grid->getCoordinateTransformator()->fromX2factorX2; - gridParameters->trafoParams[27] = grid->getCoordinateTransformator()->fromX2factorX3; - gridParameters->trafoParams[28] = grid->getCoordinateTransformator()->fromX2delta; - gridParameters->trafoParams[29] = grid->getCoordinateTransformator()->fromX3factorX1; - gridParameters->trafoParams[30] = grid->getCoordinateTransformator()->fromX3factorX2; - gridParameters->trafoParams[31] = grid->getCoordinateTransformator()->fromX3factorX3; - gridParameters->trafoParams[32] = grid->getCoordinateTransformator()->fromX3delta; - - gridParameters->active = grid->getCoordinateTransformator()->active; - gridParameters->transformation = grid->getCoordinateTransformator()->transformation; - - gridParameters->deltaX = grid->getDeltaX(minInitLevel); - UbTupleInt3 blocknx = grid->getBlockNX(); - gridParameters->blockNx1 = val<1>(blocknx); - gridParameters->blockNx2 = val<2>(blocknx); - gridParameters->blockNx3 = val<3>(blocknx); - gridParameters->nx1 = grid->getNX1(); - gridParameters->nx2 = grid->getNX2(); - gridParameters->nx3 = grid->getNX3(); - gridParameters->periodicX1 = grid->isPeriodicX1(); - gridParameters->periodicX2 = grid->isPeriodicX2(); - gridParameters->periodicX3 = grid->isPeriodicX3(); - - //---------------------------------------------------------------------- - - Block3d* block3dArray = new Block3d[blocksCount]; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // all the blocks of the current level - { - // save data describing the block - block3dArray[ic].x1 = block->getX1(); - block3dArray[ic].x2 = block->getX2(); - block3dArray[ic].x3 = block->getX3(); - block3dArray[ic].bundle = block->getBundle(); - block3dArray[ic].rank = block->getRank(); - block3dArray[ic].lrank = block->getLocalRank(); - block3dArray[ic].part = block->getPart(); - block3dArray[ic].globalID = block->getGlobalID(); - block3dArray[ic].localID = block->getLocalID(); - block3dArray[ic].level = block->getLevel(); - block3dArray[ic].interpolationFlagCF = block->getCollectionOfInterpolationFlagCF(); - block3dArray[ic].interpolationFlagFC = block->getCollectionOfInterpolationFlagFC(); - block3dArray[ic].counter = block->getMaxGlobalID(); - block3dArray[ic].active = block->isActive(); - - ic++; - } - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeBlocks start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - // write to the file - MPI_File file_handler; - MPI_Info info = MPI_INFO_NULL; - //MPI_Info_create (&info); - //MPI_Info_set(info,"romio_cb_write","enable"); - //MPI_Info_set(i nfo,"cb_buffer_size","4194304"); - //MPI_Info_set(info,"striping_unit","4194304"); - - // if (comm->isRoot()) - // { - UbSystem::makeDirectory(path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step)); - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBlocks.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - // } - - double start, finish; - //MPI_Offset write_offset = (MPI_Offset)(size * sizeof(int)); - MPI_Offset write_offset = (MPI_Offset)(sizeof(int)); - - if (comm->isRoot()) - { - start = MPI_Wtime(); - - // each process writes the quantity of it's blocks - MPI_File_write_at(file_handler, 0, &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - // each process writes parameters of the grid - MPI_File_write_at(file_handler, write_offset, gridParameters, 1, gridParamType, MPI_STATUS_IGNORE); - // each process writes it's blocks - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(GridParam)), &block3dArray[0], blocksCount, block3dType, MPI_STATUS_IGNORE); - //MPI_File_sync(file_handler); - } - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeBlocks time: " << finish - start << " s"); - } - - delete[] block3dArray; - delete gridParameters; -} - -void MPIIOMigrationBECoProcessor::writeDataSet(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - std::cout << "size = "<<size<<std::endl; - - int blocksCount = 0; // quantity of blocks, that belong to this process - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - dataSetParam dataSetParamStr1, dataSetParamStr2, dataSetParamStr3; - int firstGlobalID; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeDataSet start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - DSArraysPresence arrPresence; - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - SPtr< D3Q27EsoTwist3DSplittedVector > D3Q27EsoTwist3DSplittedVectorPtr = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(block->getKernel()->getDataSet()->getFdistributions()); - CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributions = D3Q27EsoTwist3DSplittedVectorPtr->getLocalDistributions(); - CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions = D3Q27EsoTwist3DSplittedVectorPtr->getNonLocalDistributions(); - CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributions = D3Q27EsoTwist3DSplittedVectorPtr->getZeroDistributions(); - - if (firstBlock)// && block->getKernel()) // when first (any) valid block... - { - firstGlobalID = block->getGlobalID(); // id of the block needed to find it while regenerating the grid - - if (localDistributions) - { - dataSetParamStr1.nx[0] = static_cast<int>(localDistributions->getNX1()); - dataSetParamStr1.nx[1] = static_cast<int>(localDistributions->getNX2()); - dataSetParamStr1.nx[2] = static_cast<int>(localDistributions->getNX3()); - dataSetParamStr1.nx[3] = static_cast<int>(localDistributions->getNX4()); - } - - if (nonLocalDistributions) - { - dataSetParamStr2.nx[0] = static_cast<int>(nonLocalDistributions->getNX1()); - dataSetParamStr2.nx[1] = static_cast<int>(nonLocalDistributions->getNX2()); - dataSetParamStr2.nx[2] = static_cast<int>(nonLocalDistributions->getNX3()); - dataSetParamStr2.nx[3] = static_cast<int>(nonLocalDistributions->getNX4()); - } - if (zeroDistributions) - { - dataSetParamStr3.nx[0] = static_cast<int>(zeroDistributions->getNX1()); - dataSetParamStr3.nx[1] = static_cast<int>(zeroDistributions->getNX2()); - dataSetParamStr3.nx[2] = static_cast<int>(zeroDistributions->getNX3()); - dataSetParamStr3.nx[3] = 1; - } - - // ... than save some parameters that are equal in all blocks - dataSetParamStr1.nx1 = dataSetParamStr2.nx1 = dataSetParamStr3.nx1 = static_cast<int>(block->getKernel()->getDataSet()->getFdistributions()->getNX1()); - dataSetParamStr1.nx2 = dataSetParamStr2.nx2 = dataSetParamStr3.nx2 = static_cast<int>(block->getKernel()->getDataSet()->getFdistributions()->getNX2()); - dataSetParamStr1.nx3 = dataSetParamStr2.nx3 = dataSetParamStr3.nx3 = static_cast<int>(block->getKernel()->getDataSet()->getFdistributions()->getNX3()); - - doubleCountInBlock = dataSetParamStr1.nx[0] * dataSetParamStr1.nx[1] * dataSetParamStr1.nx[2] * dataSetParamStr1.nx[3] + - dataSetParamStr2.nx[0] * dataSetParamStr2.nx[1] * dataSetParamStr2.nx[2] * dataSetParamStr2.nx[3] + - dataSetParamStr3.nx[0] * dataSetParamStr3.nx[1] * dataSetParamStr3.nx[2] * dataSetParamStr3.nx[3]; - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > averageDensityArray = block->getKernel()->getDataSet()->getAverageDensity(); - if (averageDensityArray) - arrPresence.isAverageDensityArrayPresent = true; - else - arrPresence.isAverageDensityArrayPresent = false; - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageVelocityArray3DPtr = block->getKernel()->getDataSet()->getAverageVelocity(); - if (AverageVelocityArray3DPtr) - arrPresence.isAverageVelocityArrayPresent = true; - else - arrPresence.isAverageVelocityArrayPresent = false; - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageFluctArray3DPtr = block->getKernel()->getDataSet()->getAverageFluctuations(); - if (AverageFluctArray3DPtr) - arrPresence.isAverageFluktuationsArrayPresent = true; - else - arrPresence.isAverageFluktuationsArrayPresent = false; - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageTripleArray3DPtr = block->getKernel()->getDataSet()->getAverageTriplecorrelations(); - if (AverageTripleArray3DPtr) - arrPresence.isAverageTripleArrayPresent = true; - else - arrPresence.isAverageTripleArrayPresent = false; - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > ShearStressValArray3DPtr = block->getKernel()->getDataSet()->getShearStressValues(); - if (ShearStressValArray3DPtr) - arrPresence.isShearStressValArrayPresent = true; - else - arrPresence.isShearStressValArrayPresent = false; - - SPtr< CbArray3D<LBMReal, IndexerX3X2X1> > relaxationFactor3DPtr = block->getKernel()->getDataSet()->getRelaxationFactor(); - if (relaxationFactor3DPtr) - arrPresence.isRelaxationFactorPresent = true; - else - arrPresence.isRelaxationFactorPresent = false; - - firstBlock = false; - } - - if (localDistributions && (dataSetParamStr1.nx[0]>0) && (dataSetParamStr1.nx[1]>0) && (dataSetParamStr1.nx[2]>0) && (dataSetParamStr1.nx[3]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), localDistributions->getDataVector().begin(), localDistributions->getDataVector().end()); - if (nonLocalDistributions && (dataSetParamStr2.nx[0]>0) && (dataSetParamStr2.nx[1]>0) && (dataSetParamStr2.nx[2]>0) && (dataSetParamStr2.nx[3]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), nonLocalDistributions->getDataVector().begin(), nonLocalDistributions->getDataVector().end()); - if (zeroDistributions && (dataSetParamStr3.nx[0]>0) && (dataSetParamStr3.nx[1]>0) && (dataSetParamStr3.nx[2]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), zeroDistributions->getDataVector().begin(), zeroDistributions->getDataVector().end()); - - ic++; - } - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeDataSet start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - -#ifdef HLRN_LUSTRE - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - // write to the file - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSet.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_Offset write_offset = (MPI_Offset)(3 * sizeof(dataSetParam)) + (MPI_Offset)(firstGlobalID) * (MPI_Offset)(doubleCountInBlock) * (MPI_Offset)(sizeof(double)); - - MPI_File_write_at(file_handler, (MPI_Offset)0, &dataSetParamStr1, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, (MPI_Offset)(sizeof(dataSetParam)), &dataSetParamStr2, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, (MPI_Offset)(2 * sizeof(dataSetParam)), &dataSetParamStr3, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, write_offset, &doubleValuesArray[0], blocksCount * doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeDataSet time: " << finish - start << " s"); - } - - MPI_File file_handler1; - std::string filename1 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpArrays.bin"; - rc = MPI_File_open(MPI_COMM_WORLD, filename1.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler1); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename1); - MPI_File_write_at(file_handler1, (MPI_Offset)0, &arrPresence, 1, arrayPresenceType, MPI_STATUS_IGNORE); - MPI_File_sync(file_handler1); - MPI_File_close(&file_handler1); - - if (arrPresence.isAverageDensityArrayPresent) - writeAverageDensityArray(step); - - if (arrPresence.isAverageVelocityArrayPresent) - writeAverageVelocityArray(step); - - if (arrPresence.isAverageFluktuationsArrayPresent) - writeAverageFluktuationsArray(step); - - if (arrPresence.isAverageTripleArrayPresent) - writeAverageTripleArray(step); - - if (arrPresence.isShearStressValArrayPresent) - writeShearStressValArray(step); - - if (arrPresence.isRelaxationFactorPresent) - writeRelaxationFactor(step); - -} - -void MPIIOMigrationBECoProcessor::writeAverageDensityArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - int firstGlobalID; - std::vector<double> doubleValuesArray; // double-values of the AverageDensityArray in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeAverageDensityArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > averageDensityArray = block->getKernel()->getDataSet()->getAverageDensity(); - - if (firstBlock) // when first (any) valid block... - { - firstGlobalID = block->getGlobalID(); - - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(averageDensityArray->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(averageDensityArray->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(averageDensityArray->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(averageDensityArray->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - - firstBlock = false; - } - - if ((dataSetParamStr.nx[0] > 0) && (dataSetParamStr.nx[1] > 0) && (dataSetParamStr.nx[2] > 0) && (dataSetParamStr.nx[3] > 0)) - doubleValuesArray.insert(doubleValuesArray.end(), averageDensityArray->getDataVector().begin(), averageDensityArray->getDataVector().end()); - - ic++; - } - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeAverageDensityArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageDensityArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_Offset write_offset = (MPI_Offset)(sizeof(dataSetParam)) + (MPI_Offset)(firstGlobalID) * (MPI_Offset)(doubleCountInBlock) * (MPI_Offset)(sizeof(double)); - - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, write_offset, &doubleValuesArray[0], blocksCount * doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeAverageDensityArray time: " << finish - start << " s"); - } -} - -void MPIIOMigrationBECoProcessor::writeAverageVelocityArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - int firstGlobalID; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeAverageVelocityArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageVelocityArray3DPtr = block->getKernel()->getDataSet()->getAverageVelocity(); - - if (firstBlock) // when first (any) valid block... - { - firstGlobalID = block->getGlobalID(); - - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(AverageVelocityArray3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(AverageVelocityArray3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(AverageVelocityArray3DPtr->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(AverageVelocityArray3DPtr->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - - firstBlock = false; - } - - if ((dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && (dataSetParamStr.nx[2]>0) && (dataSetParamStr.nx[3]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), AverageVelocityArray3DPtr->getDataVector().begin(), AverageVelocityArray3DPtr->getDataVector().end()); - - ic++; - } - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeAverageVelocityArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageVelocityArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_Offset write_offset = (MPI_Offset)(sizeof(dataSetParam)) + (MPI_Offset)(firstGlobalID) * (MPI_Offset)(doubleCountInBlock) * (MPI_Offset)(sizeof(double)); - - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, write_offset, &doubleValuesArray[0], blocksCount * doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeAverageVelocityArray time: " << finish - start << " s"); - } -} - -void MPIIOMigrationBECoProcessor::writeAverageFluktuationsArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - int firstGlobalID; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeAverageFluktuationsArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageFluctArray3DPtr = block->getKernel()->getDataSet()->getAverageFluctuations(); - - if (firstBlock) // when first (any) valid block... - { - firstGlobalID = block->getGlobalID(); - - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(AverageFluctArray3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(AverageFluctArray3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(AverageFluctArray3DPtr->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(AverageFluctArray3DPtr->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - - firstBlock = false; - } - - if ((dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && (dataSetParamStr.nx[2]>0) && (dataSetParamStr.nx[3]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), AverageFluctArray3DPtr->getDataVector().begin(), AverageFluctArray3DPtr->getDataVector().end()); - - ic++; - } - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeAverageFluktuationsArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageFluktuationsArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_Offset write_offset = (MPI_Offset)(sizeof(dataSetParam)) + (MPI_Offset)(firstGlobalID) * (MPI_Offset)(doubleCountInBlock) * (MPI_Offset)(sizeof(double)); - - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, write_offset, &doubleValuesArray[0], blocksCount * doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeAverageFluktuationsArray time: " << finish - start << " s"); - } -} - -void MPIIOMigrationBECoProcessor::writeAverageTripleArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - int firstGlobalID; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageTripleArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageTripleArray3DPtr = block->getKernel()->getDataSet()->getAverageTriplecorrelations(); - - if (firstBlock) // when first (any) valid block... - { - firstGlobalID = block->getGlobalID(); - - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(AverageTripleArray3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(AverageTripleArray3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(AverageTripleArray3DPtr->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(AverageTripleArray3DPtr->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - - firstBlock = false; - } - - if ((dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && (dataSetParamStr.nx[2]>0) && (dataSetParamStr.nx[3]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), AverageTripleArray3DPtr->getDataVector().begin(), AverageTripleArray3DPtr->getDataVector().end()); - - ic++; - } - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeAverageTripleArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - -#ifdef HLRN - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageTripleArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_Offset write_offset = (MPI_Offset)(sizeof(dataSetParam)) + (MPI_Offset)(firstGlobalID) * (MPI_Offset)(doubleCountInBlock) * (MPI_Offset)(sizeof(double)); - - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, write_offset, &doubleValuesArray[0], blocksCount * doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeAverageTripleArray time: " << finish - start << " s"); - } -} - -void MPIIOMigrationBECoProcessor::writeShearStressValArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - int firstGlobalID; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeShearStressValArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > ShearStressValArray3DPtr = block->getKernel()->getDataSet()->getShearStressValues(); - - if (firstBlock) // when first (any) valid block... - { - firstGlobalID = block->getGlobalID(); - - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(ShearStressValArray3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(ShearStressValArray3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(ShearStressValArray3DPtr->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(ShearStressValArray3DPtr->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - - firstBlock = false; - } - - if ((dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && (dataSetParamStr.nx[2]>0) && (dataSetParamStr.nx[3]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), ShearStressValArray3DPtr->getDataVector().begin(), ShearStressValArray3DPtr->getDataVector().end()); - - ic++; - } - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeShearStressValArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - -#ifdef HLRN - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpShearStressValArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_Offset write_offset = (MPI_Offset)(sizeof(dataSetParam)) + (MPI_Offset)(firstGlobalID) * (MPI_Offset)(doubleCountInBlock) * (MPI_Offset)(sizeof(double)); - - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, write_offset, &doubleValuesArray[0], blocksCount * doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeShearStressValArray time: " << finish - start << " s"); - } -} - -void MPIIOMigrationBECoProcessor::writeRelaxationFactor(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - int firstGlobalID; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeRelaxationFactor start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - SPtr< CbArray3D<LBMReal, IndexerX3X2X1> > relaxationFactor3DPtr = block->getKernel()->getDataSet()->getRelaxationFactor(); - - if (firstBlock) // when first (any) valid block... - { - firstGlobalID = block->getGlobalID(); - - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(relaxationFactor3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(relaxationFactor3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(relaxationFactor3DPtr->getNX3()); - dataSetParamStr.nx[3] = 1; - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - - firstBlock = false; - } - - if ((dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && (dataSetParamStr.nx[2]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), relaxationFactor3DPtr->getDataVector().begin(), relaxationFactor3DPtr->getDataVector().end()); - - ic++; - } - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeRelaxationFactor start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - -#ifdef HLRN - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpRelaxationFactor.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_Offset write_offset = (MPI_Offset)(sizeof(dataSetParam)) + (MPI_Offset)(firstGlobalID) * (MPI_Offset)(doubleCountInBlock) * (MPI_Offset)(sizeof(double)); - - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, write_offset, &doubleValuesArray[0], blocksCount * doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeRelaxationFactor time: " << finish - start << " s"); - } -} - -//--------------------------------------------------------------------------------- - -void MPIIOMigrationBECoProcessor::writeBoundaryConds(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeBoundaryConds start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - int blocksCount = 0; // quantity of blocks, that belong to this process - size_t allBytesCount = 0; // quantity of bytes, that one process writes to the file - size_t count_boundCond = 0; // how many BoundaryConditions in all blocks - int count_indexContainer = 0; // how many indexContainer-values in all blocks - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - BCAddMigration* bcAddArray = new BCAddMigration[blocksCount]; - size_t* bytesCount = new size_t[blocksCount]; // quantity of bytes, that each block writes to the file - std::vector<BoundaryCondition>* bcVector = new std::vector<BoundaryCondition>[blocksCount]; - std::vector<int>* indexContainerVector = new std::vector<int>[blocksCount]; - std::vector<int> bcindexmatrixVector; - - bool bcindexmatrixCountNotInit = true; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // all the blocks of the current level - { - SPtr<BCArray3D> bcArr = block->getKernel()->getBCProcessor()->getBCArray(); - - bcAddArray[ic].globalID = block->getGlobalID(); // id of the block needed to find it while regenerating the grid - bcAddArray[ic].boundCond_count = 0; // how many BoundaryConditions in this block - bcAddArray[ic].indexContainer_count = 0; // how many indexContainer-values in this block - bytesCount[ic] = sizeof(BCAddMigration); - bcVector[ic].resize(0); - indexContainerVector[ic].resize(0); - - for (int bc = 0; bc<bcArr->getBCVectorSize(); bc++) - { - BoundaryCondition* bouCond = new BoundaryCondition(); - if (bcArr->bcvector[bc] == NULL) - memset(bouCond, 0, sizeof(BoundaryCondition)); - else - { - bouCond->noslipBoundaryFlags = bcArr->bcvector[bc]->getNoSlipBoundary(); - bouCond->slipBoundaryFlags = bcArr->bcvector[bc]->getSlipBoundary(); - bouCond->velocityBoundaryFlags = bcArr->bcvector[bc]->getVelocityBoundary(); - bouCond->densityBoundaryFlags = bcArr->bcvector[bc]->getDensityBoundary(); - bouCond->wallModelBoundaryFlags = bcArr->bcvector[bc]->getWallModelBoundary(); - bouCond->bcVelocityX1 = bcArr->bcvector[bc]->getBoundaryVelocityX1(); - bouCond->bcVelocityX2 = bcArr->bcvector[bc]->getBoundaryVelocityX2(); - bouCond->bcVelocityX3 = bcArr->bcvector[bc]->getBoundaryVelocityX3(); - bouCond->bcDensity = bcArr->bcvector[bc]->getBoundaryDensity(); - bouCond->bcLodiDensity = bcArr->bcvector[bc]->getDensityLodiDensity(); - bouCond->bcLodiVelocityX1 = bcArr->bcvector[bc]->getDensityLodiVelocityX1(); - bouCond->bcLodiVelocityX2 = bcArr->bcvector[bc]->getDensityLodiVelocityX2(); - bouCond->bcLodiVelocityX3 = bcArr->bcvector[bc]->getDensityLodiVelocityX3(); - bouCond->bcLodiLentgh = bcArr->bcvector[bc]->getDensityLodiLength(); - bouCond->nx1 = bcArr->bcvector[bc]->nx1; - bouCond->nx2 = bcArr->bcvector[bc]->nx2; - bouCond->nx3 = bcArr->bcvector[bc]->nx3; - for (int iq = 0; iq<26; iq++) - bouCond->q[iq] = bcArr->bcvector[bc]->getQ(iq); - bouCond->algorithmType = bcArr->bcvector[bc]->getBcAlgorithmType(); - } - - bcVector[ic].push_back(*bouCond); - bcAddArray[ic].boundCond_count++; - count_boundCond++; - bytesCount[ic] += sizeof(BoundaryCondition); - } - - if (bcindexmatrixCountNotInit) - { - boundCondParamStr.nx1 = static_cast<int>(bcArr->bcindexmatrix.getNX1()); - boundCondParamStr.nx2 = static_cast<int>(bcArr->bcindexmatrix.getNX2()); - boundCondParamStr.nx3 = static_cast<int>(bcArr->bcindexmatrix.getNX3()); - boundCondParamStr.bcindexmatrixCount = static_cast<int>(bcArr->bcindexmatrix.getDataVector().size()); - bcindexmatrixCountNotInit = false; - } - - bcindexmatrixVector.insert(bcindexmatrixVector.end(), bcArr->bcindexmatrix.getDataVector().begin(), bcArr->bcindexmatrix.getDataVector().end()); - - indexContainerVector[ic].insert(indexContainerVector[ic].begin(), bcArr->indexContainer.begin(), bcArr->indexContainer.end()); - bcAddArray[ic].indexContainer_count = static_cast<int>(bcArr->indexContainer.size()); - count_indexContainer += bcAddArray[ic].indexContainer_count; - bytesCount[ic] += bcAddArray[ic].indexContainer_count * sizeof(int); - - allBytesCount += bytesCount[ic]; - - ic++; - } - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeBoundaryConds start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - //MPI_Info_create (&info); - //MPI_Info_set(info,"romio_cb_write","enable"); - //MPI_Info_set(info,"cb_buffer_size","4194304"); - //MPI_Info_set(info,"striping_unit","4194304"); - -//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBC1.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_Offset write_offset = (MPI_Offset)(sizeof(int)) + (MPI_Offset)(bcAddArray[0].globalID) * (MPI_Offset)(boundCondParamStr.bcindexmatrixCount) * (MPI_Offset)(sizeof(int)); - - MPI_File_write_at(file_handler, 0, &boundCondParamStr.bcindexmatrixCount, 1, MPI_INT, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, write_offset, &bcindexmatrixVector[0], blocksCount * boundCondParamStr.bcindexmatrixCount, MPI_INT, MPI_STATUS_IGNORE); - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - -//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBC2.bin"; - rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_File_write_at(file_handler, 0, &boundCondParamStr, 4, MPI_INT, MPI_STATUS_IGNORE); - - write_offset = (MPI_Offset)(sizeof(boundCondParam)) + (MPI_Offset)(grid->getNumberOfBlocks()) * (MPI_Offset)(sizeof(size_t)); - size_t next_file_offset = 0; - if (size > 1) - { - if (rank == 0) - { - next_file_offset = write_offset + allBytesCount; - MPI_Send(&next_file_offset, 1, MPI_LONG_LONG_INT, 1, 5, MPI_COMM_WORLD); - } - else - { - MPI_Recv(&write_offset, 1, MPI_LONG_LONG_INT, rank - 1, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - next_file_offset = write_offset + allBytesCount; - if (rank < size - 1) - MPI_Send(&next_file_offset, 1, MPI_LONG_LONG_INT, rank + 1, 5, MPI_COMM_WORLD); - } - } - - MPI_Offset write_offsetIndex; - - for (int nb = 0; nb < blocksCount; nb++) - { - write_offsetIndex = (MPI_Offset)(sizeof(boundCondParam)) + (MPI_Offset)(bcAddArray[nb].globalID) * (MPI_Offset)(sizeof(size_t)); - MPI_File_write_at(file_handler, write_offsetIndex, &write_offset, 1, MPI_LONG_LONG_INT, MPI_STATUS_IGNORE); - - MPI_File_write_at(file_handler, write_offset, &bcAddArray[nb], 3, MPI_INT, MPI_STATUS_IGNORE); - if (bcVector[nb].size() > 0) - MPI_File_write_at(file_handler, write_offset + (MPI_Offset)(sizeof(BCAddMigration)), &bcVector[nb][0], bcAddArray[nb].boundCond_count, boundCondType, MPI_STATUS_IGNORE); - - if (indexContainerVector[nb].size() > 0) - MPI_File_write_at(file_handler, write_offset + (MPI_Offset)(sizeof(BCAddMigration)) + (MPI_Offset)(bcAddArray[nb].boundCond_count) * (MPI_Offset)(sizeof(BoundaryCondition)), - &indexContainerVector[nb][0], bcAddArray[nb].indexContainer_count, MPI_INT, MPI_STATUS_IGNORE); - - write_offset += bytesCount[nb]; - } - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::writeBoundaryConds time: " << finish - start << " s"); - } - - delete[] bcAddArray; - delete[] bytesCount; - delete[] bcVector; - delete[] indexContainerVector; -} - -//------------------------------------------- READ ----------------------------------------------- -void MPIIOMigrationBECoProcessor::restart(int step) -{ - if (comm->isRoot()) UBLOG(logINFO, "MPIIOMigrationBECoProcessor restart step: " << step); - if (comm->isRoot()) UBLOG(logINFO, "Load check point - start"); - - readBlocks(step); - SPtr<Grid3DVisitor> newMetisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::KWAY)); - grid->accept(newMetisVisitor); - - readDataSet(step); - readBoundaryConds(step); - - grid->setTimeStep(step); - if (comm->isRoot()) UBLOG(logINFO, "Load check point - end"); -} - -void MPIIOMigrationBECoProcessor::readBlocks(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - //MPI_Comm_size(MPI_COMM_WORLD, &size); - size = 1; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readBlocks start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBlocks.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - int blocksCount = 0; - MPI_File_read_at(file_handler, 0, &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - Block3d* block3dArray = new Block3d[blocksCount]; - - GridParam* gridParameters = new GridParam; - - // calculate the read offset - //MPI_Offset read_offset = (MPI_Offset)(size * sizeof(int)); - MPI_Offset read_offset = (MPI_Offset)(sizeof(int)); - - // read parameters of the grid - MPI_File_read_at(file_handler, read_offset, gridParameters, 1, gridParamType, MPI_STATUS_IGNORE); - // read all the blocks - if (comm->isRoot()) - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(GridParam)), &block3dArray[0], blocksCount, block3dType, MPI_STATUS_IGNORE); - - MPI_Bcast(block3dArray, blocksCount, block3dType, comm->getRoot(), MPI_COMM_WORLD); - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readBlocks time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readBlocks start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - // clear the grid - grid->deleteBlocks(); - - // restore the grid - SPtr<CoordinateTransformation3D> trafo(new CoordinateTransformation3D()); - trafo->Tx1 = gridParameters->trafoParams[0]; - trafo->Tx2 = gridParameters->trafoParams[1]; - trafo->Tx3 = gridParameters->trafoParams[2]; - trafo->Sx1 = gridParameters->trafoParams[3]; - trafo->Sx2 = gridParameters->trafoParams[4]; - trafo->Sx3 = gridParameters->trafoParams[5]; - trafo->alpha = gridParameters->trafoParams[6]; - trafo->beta = gridParameters->trafoParams[7]; - trafo->gamma = gridParameters->trafoParams[8]; - - trafo->toX1factorX1 = gridParameters->trafoParams[9]; - trafo->toX1factorX2 = gridParameters->trafoParams[10]; - trafo->toX1factorX3 = gridParameters->trafoParams[11]; - trafo->toX1delta = gridParameters->trafoParams[12]; - trafo->toX2factorX1 = gridParameters->trafoParams[13]; - trafo->toX2factorX2 = gridParameters->trafoParams[14]; - trafo->toX2factorX3 = gridParameters->trafoParams[15]; - trafo->toX2delta = gridParameters->trafoParams[16]; - trafo->toX3factorX1 = gridParameters->trafoParams[17]; - trafo->toX3factorX2 = gridParameters->trafoParams[18]; - trafo->toX3factorX3 = gridParameters->trafoParams[19]; - trafo->toX3delta = gridParameters->trafoParams[20]; - - trafo->fromX1factorX1 = gridParameters->trafoParams[21]; - trafo->fromX1factorX2 = gridParameters->trafoParams[22]; - trafo->fromX1factorX3 = gridParameters->trafoParams[23]; - trafo->fromX1delta = gridParameters->trafoParams[24]; - trafo->fromX2factorX1 = gridParameters->trafoParams[25]; - trafo->fromX2factorX2 = gridParameters->trafoParams[26]; - trafo->fromX2factorX3 = gridParameters->trafoParams[27]; - trafo->fromX2delta = gridParameters->trafoParams[28]; - trafo->fromX3factorX1 = gridParameters->trafoParams[29]; - trafo->fromX3factorX2 = gridParameters->trafoParams[30]; - trafo->fromX3factorX3 = gridParameters->trafoParams[31]; - trafo->fromX3delta = gridParameters->trafoParams[32]; - - trafo->active = gridParameters->active; - trafo->transformation = gridParameters->transformation; - - grid->setCoordinateTransformator(trafo); - - grid->setDeltaX(gridParameters->deltaX); - grid->setBlockNX(gridParameters->blockNx1, gridParameters->blockNx2, gridParameters->blockNx3); - grid->setNX1(gridParameters->nx1); - grid->setNX2(gridParameters->nx2); - grid->setNX3(gridParameters->nx3); - grid->setPeriodicX1(gridParameters->periodicX1); - grid->setPeriodicX2(gridParameters->periodicX2); - grid->setPeriodicX3(gridParameters->periodicX3); - - // regenerate blocks - for (int n = 0; n<blocksCount; n++) - { - SPtr<Block3D> block(new Block3D(block3dArray[n].x1, block3dArray[n].x2, block3dArray[n].x3, block3dArray[n].level)); - block->setActive(block3dArray[n].active); - block->setBundle(block3dArray[n].bundle); - block->setRank(block3dArray[n].rank); - block->setLocalRank(block3dArray[n].lrank); - block->setGlobalID(block3dArray[n].globalID); - block->setLocalID(block3dArray[n].localID); - block->setPart(block3dArray[n].part); - block->setLevel(block3dArray[n].level); - block->setCollectionOfInterpolationFlagCF(block3dArray[n].interpolationFlagCF); - block->setCollectionOfInterpolationFlagFC(block3dArray[n].interpolationFlagFC); - - grid->addBlock(block); - } - - delete gridParameters; - delete[] block3dArray; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readBlocks end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } -} - -void MPIIOMigrationBECoProcessor::blocksExchange(int tagN, int ind1, int ind2, int doubleCountInBlock, std::vector<double>& pV, std::vector<double>* rawDataReceive) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int indexB = ind1; - int indexE = ind2; - int myBlocksCount = indexE - indexB; - - std::vector<double>* rawDataSend = new std::vector<double>[size]; - for (int r = 0; r < size; r++) - { - rawDataSend[r].resize(0); - rawDataSend[r].push_back(0); - } - - SPtr<Block3D> tempBlock; - int tempRank; - for (int ind = indexB - indexB; ind < indexE - indexB; ind++) - { - tempBlock = grid->getBlock(indexB + ind); - if(!tempBlock) throw UbException(UB_EXARGS,"MPIIOMigrationBECoProcessor::blocksExchange -- null block pointer!!!" ); - - tempRank = tempBlock->getRank(); - - if (tempRank == rank) // no need to send data, the process already has it - { - rawDataReceive[tempRank][0]++; - rawDataReceive[tempRank].push_back(double(indexB + ind)); - rawDataReceive[tempRank].insert(rawDataReceive[tempRank].end(), pV.begin() + ind * doubleCountInBlock, - pV.begin() + ind * doubleCountInBlock + doubleCountInBlock); - } - else // we must send data to other processes - { - rawDataSend[tempRank][0]++; - rawDataSend[tempRank].push_back(double(indexB + ind)); - rawDataSend[tempRank].insert(rawDataSend[tempRank].end(), pV.begin() + ind * doubleCountInBlock, - pV.begin() + ind * doubleCountInBlock + doubleCountInBlock); - } - } - - MPI_Request* requests = new MPI_Request[size * 2]; // send + receive - int requestCount = 0; - MPI_Status status; - int quant; - int doubleBlockCount; - int rds; - - for (int r = 0; r < size; r++) - { - if (r != rank) - { - rds = rawDataSend[r].size(); - doubleBlockCount = (int)(rds / SEND_BLOCK_SIZE); - if (doubleBlockCount * SEND_BLOCK_SIZE < rds) - doubleBlockCount += 1; - - for (int i = rds; i < doubleBlockCount * SEND_BLOCK_SIZE; i++) - rawDataSend[r].push_back(0); - - MPI_Isend(&rawDataSend[r][0], doubleBlockCount, sendBlockDoubleType, r, tagN, MPI_COMM_WORLD, &requests[requestCount]); - requestCount++; - } - } - - for (int r = 0; r < size; r++) - { - if (r != rank) - { - MPI_Probe(r, tagN, MPI_COMM_WORLD, &status); - MPI_Get_count(&status, sendBlockDoubleType, &quant); - rawDataReceive[r].resize(quant * SEND_BLOCK_SIZE); - MPI_Irecv(&rawDataReceive[r][0], quant, sendBlockDoubleType, r, tagN, MPI_COMM_WORLD, &requests[requestCount]); - requestCount++; - } - } - - MPI_Waitall(requestCount, &requests[0], MPI_STATUSES_IGNORE); -} - -void MPIIOMigrationBECoProcessor::readDataSet(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (!lbmKernel) - UB_THROW(UbException(UB_EXARGS, "lbmKernel does not exist!")); - if (!bcProcessor) - UB_THROW(UbException(UB_EXARGS, "bcProcessor does not exist!")); - if (nue == -999.999) - UB_THROW(UbException(UB_EXARGS, "nue is not initialised!")); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readDataSet start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - if (comm->isRoot()) - std::cout << "size = "<<size<<std::endl; - - dataSetParam dataSetParamStr1, dataSetParamStr2, dataSetParamStr3; - - int blocksCountAll = grid->getNumberOfBlocks(); // quantity of all blocks in the grid - int blocksPerProcess = blocksCountAll / size; // how many blocks has each process - - int myBlocksCount; - if (rank < (size - 1)) - myBlocksCount = blocksPerProcess; - else - myBlocksCount = blocksPerProcess + (blocksCountAll - blocksPerProcess * size); - - int indexB = rank * blocksPerProcess; // the first "my" block - int indexE = indexB + myBlocksCount; // the latest "my" block - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSet.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr1, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(sizeof(dataSetParam)), &dataSetParamStr2, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(2 * sizeof(dataSetParam)), &dataSetParamStr3, 1, dataSetParamType, MPI_STATUS_IGNORE); - - int doubleCountInBlock = dataSetParamStr1.nx[0] * dataSetParamStr1.nx[1] * dataSetParamStr1.nx[2] * dataSetParamStr1.nx[3] + - dataSetParamStr2.nx[0] * dataSetParamStr2.nx[1] * dataSetParamStr2.nx[2] * dataSetParamStr2.nx[3] + - dataSetParamStr3.nx[0] * dataSetParamStr3.nx[1] * dataSetParamStr3.nx[2] * dataSetParamStr3.nx[3]; - std::vector<double> doubleValuesArray(myBlocksCount * doubleCountInBlock); // double-values in all blocks - - MPI_Offset read_offset = (MPI_Offset)(3 * sizeof(dataSetParam)) + (MPI_Offset)(indexB * doubleCountInBlock * sizeof(double)); - MPI_File_read_at(file_handler, read_offset, &doubleValuesArray[0], myBlocksCount * doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readDataSet time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readDataSet start of exchange of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - std::vector<double>* rawDataReceive = new std::vector<double>[size]; - for (int r = 0; r < size; r++) - { - rawDataReceive[r].resize(0); - rawDataReceive[r].push_back(0); - } - - blocksExchange(MESSAGE_TAG, indexB, indexE, doubleCountInBlock, doubleValuesArray, rawDataReceive); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readDataSet end of exchange of data, rank = " << rank); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readDataSet time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readDataSet start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - //-------------------------------------- restore blocks --------------------------------- - int blockID; - std::vector<double> vectorsOfValues1, vectorsOfValues2, vectorsOfValues3; - - size_t vectorSize1 = dataSetParamStr1.nx[0] * dataSetParamStr1.nx[1] * dataSetParamStr1.nx[2] * dataSetParamStr1.nx[3]; - size_t vectorSize2 = dataSetParamStr2.nx[0] * dataSetParamStr2.nx[1] * dataSetParamStr2.nx[2] * dataSetParamStr2.nx[3]; - size_t vectorSize3 = dataSetParamStr3.nx[0] * dataSetParamStr3.nx[1] * dataSetParamStr3.nx[2] * dataSetParamStr3.nx[3]; - - size_t index; - for (int r = 0; r < size; r++) - { - index = 1; - for (int ii = 0; ii < rawDataReceive[r][0]; ii++) - { - blockID = (int)(rawDataReceive[r][index]); - index += 1; - - vectorsOfValues1.assign(rawDataReceive[r].data() + index, rawDataReceive[r].data() + index + vectorSize1); - index += vectorSize1; - - vectorsOfValues2.assign(rawDataReceive[r].data() + index, rawDataReceive[r].data() + index + vectorSize2); - index += vectorSize2; - - vectorsOfValues3.assign(rawDataReceive[r].data() + index, rawDataReceive[r].data() + index + vectorSize3); - index += vectorSize3; - - SPtr<DistributionArray3D> mFdistributions(new D3Q27EsoTwist3DSplittedVector()); - - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues1, dataSetParamStr1.nx[0], dataSetParamStr1.nx[1], dataSetParamStr1.nx[2], dataSetParamStr1.nx[3]))); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setNonLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues2, dataSetParamStr2.nx[0], dataSetParamStr2.nx[1], dataSetParamStr2.nx[2], dataSetParamStr2.nx[3]))); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setZeroDistributions(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>(vectorsOfValues3, dataSetParamStr3.nx[0], dataSetParamStr3.nx[1], dataSetParamStr3.nx[2]))); - - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setNX1(dataSetParamStr1.nx1); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setNX2(dataSetParamStr1.nx2); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setNX3(dataSetParamStr1.nx3); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(blockID); - this->lbmKernel->setBlock(block); - SPtr<LBMKernel> kernel = this->lbmKernel->clone(); - LBMReal collFactor = LBMSystem::calcCollisionFactor(this->nue, block->getLevel()); - kernel->setCollisionFactor(collFactor); - kernel->setIndex(block->getX1(), block->getX2(), block->getX3()); - kernel->setDeltaT(LBMSystem::getDeltaT(block->getLevel())); - SPtr<DataSet3D> dataSetPtr = SPtr<DataSet3D>(new DataSet3D()); - dataSetPtr->setFdistributions(mFdistributions); - kernel->setDataSet(dataSetPtr); - block->setKernel(kernel); - } - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readDataSet end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - //------------------------------------------------------------- - - DSArraysPresence arrPresence; - MPI_File file_handler1; - std::string filename1 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpArrays.bin"; - rc = MPI_File_open(MPI_COMM_WORLD, filename1.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler1); - if (rc != MPI_SUCCESS) return;// throw UbException(UB_EXARGS, "couldn't open file " + filename1); - - MPI_File_read_at(file_handler1, (MPI_Offset)0, &arrPresence, 1, arrayPresenceType, MPI_STATUS_IGNORE); - MPI_File_close(&file_handler1); - - if (arrPresence.isAverageDensityArrayPresent) - readAverageDensityArray(step); - - if (arrPresence.isAverageVelocityArrayPresent) - readAverageVelocityArray(step); - - if (arrPresence.isAverageFluktuationsArrayPresent) - readAverageFluktuationsArray(step); - - if (arrPresence.isAverageTripleArrayPresent) - readAverageTripleArray(step); - - if (arrPresence.isShearStressValArrayPresent) - readShearStressValArray(step); - - if (arrPresence.isRelaxationFactorPresent) - readRelaxationFactor(step); - -} - -void MPIIOMigrationBECoProcessor::readAverageDensityArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageDensityArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - - int blocksCountAll = grid->getNumberOfBlocks(); // quantity of all blocks in the grid - int blocksPerProcess = blocksCountAll / size; // how many blocks has each process - - int myBlocksCount; - if (rank < (size - 1)) - myBlocksCount = blocksPerProcess; - else - myBlocksCount = blocksPerProcess + (blocksCountAll - blocksPerProcess * size); - - int indexB = rank * blocksPerProcess; // the first "my" block - int indexE = indexB + myBlocksCount; // the latest "my" block - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageDensityArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - int doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> doubleValuesArray(myBlocksCount * doubleCountInBlock); // double-values in all blocks - - MPI_Offset read_offset = (MPI_Offset)(sizeof(dataSetParam)) + (MPI_Offset)(indexB) * (MPI_Offset)(doubleCountInBlock) * (MPI_Offset)(sizeof(double)); - MPI_File_read_at(file_handler, read_offset, &doubleValuesArray[0], myBlocksCount * doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageDensityArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageDensityArray start of exchange of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - std::vector<double>* rawDataReceive = new std::vector<double>[size]; - for (int r = 0; r < size; r++) - { - rawDataReceive[r].resize(0); - rawDataReceive[r].push_back(0); - } - - blocksExchange(MESSAGE_TAG + 1, indexB, indexE, doubleCountInBlock, doubleValuesArray, rawDataReceive); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageDensityArray end of exchange of data, rank = " << rank); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageDensityArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageDensityArray start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - //----------------------------- restore data --------------------------------- - int blockID; - std::vector<double> vectorsOfValues; - size_t index; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - - for (int r = 0; r < size; r++) - { - index = 1; - for(int ii = 0; ii < rawDataReceive[r][0]; ii++) - { - blockID = (int)(rawDataReceive[r][index]); - index += 1; - - vectorsOfValues.assign(rawDataReceive[r].data() + index, rawDataReceive[r].data() + index + nextVectorSize); - index += nextVectorSize; - - // fill mAverageDensity arrays - SPtr<AverageValuesArray3D> mAverageDensity; - mAverageDensity = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], dataSetParamStr.nx[3])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(blockID); - block->getKernel()->getDataSet()->setAverageDensity(mAverageDensity); - } - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageDensityArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } -} - -void MPIIOMigrationBECoProcessor::readAverageVelocityArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageVelocityArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - - int blocksCountAll = grid->getNumberOfBlocks(); // quantity of all blocks in the grid - int blocksPerProcess = blocksCountAll / size; // how many blocks has each process - - int myBlocksCount; - if (rank < (size - 1)) - myBlocksCount = blocksPerProcess; - else - myBlocksCount = blocksPerProcess + (blocksCountAll - blocksPerProcess * size); - - int indexB = rank * blocksPerProcess; // the first "my" block - int indexE = indexB + myBlocksCount; // the latest "my" block - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageVelocityArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - int doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> doubleValuesArray(myBlocksCount * doubleCountInBlock); // double-values in all blocks - - MPI_Offset read_offset = (MPI_Offset)(sizeof(dataSetParam)) + (MPI_Offset)(indexB) * (MPI_Offset)(doubleCountInBlock) * (MPI_Offset)(sizeof(double)); - MPI_File_read_at(file_handler, read_offset, &doubleValuesArray[0], myBlocksCount * doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageVelocityArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageVelocityArray start of exchange of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - std::vector<double>* rawDataReceive = new std::vector<double>[size]; - for (int r = 0; r < size; r++) - { - rawDataReceive[r].resize(0); - rawDataReceive[r].push_back(0); - } - - blocksExchange(MESSAGE_TAG + 2, indexB, indexE, doubleCountInBlock, doubleValuesArray, rawDataReceive); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageVelocityArray end of exchange of data, rank = " << rank); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageVelocityArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageVelocityArray start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - int blockID; - std::vector<double> vectorsOfValues; - - size_t index; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - - for (int r = 0; r < size; r++) - { - index = 1; - for(int ii = 0; ii < rawDataReceive[r][0]; ii++) - { - blockID = (int)(rawDataReceive[r][index]); - index += 1; - - vectorsOfValues.assign(rawDataReceive[r].data() + index, rawDataReceive[r].data() + index + nextVectorSize); - index += nextVectorSize; - - // fill mAverageVelocity array - SPtr<AverageValuesArray3D> mAverageVelocity; - mAverageVelocity = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], dataSetParamStr.nx[3])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(blockID); - block->getKernel()->getDataSet()->setAverageVelocity(mAverageVelocity); - } - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageVelocityArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } -} - -void MPIIOMigrationBECoProcessor::readAverageFluktuationsArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageFluktuationsArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - - int blocksCountAll = grid->getNumberOfBlocks(); // quantity of all blocks in the grid - int blocksPerProcess = blocksCountAll / size; // how many blocks has each process - - int myBlocksCount; - if (rank < (size - 1)) - myBlocksCount = blocksPerProcess; - else - myBlocksCount = blocksPerProcess + (blocksCountAll - blocksPerProcess * size); - - int indexB = rank * blocksPerProcess; // the first "my" block - int indexE = indexB + myBlocksCount; // the latest "my" block - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageFluktuationsArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - int doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> doubleValuesArray(myBlocksCount * doubleCountInBlock); // double-values in all blocks - - MPI_Offset read_offset = (MPI_Offset)(sizeof(dataSetParam)) + (MPI_Offset)(indexB) * (MPI_Offset)(doubleCountInBlock) * (MPI_Offset)(sizeof(double)); - MPI_File_read_at(file_handler, read_offset, &doubleValuesArray[0], myBlocksCount * doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageFluktuationsArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageFluktuationsArray start of exchange of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - std::vector<double>* rawDataReceive = new std::vector<double>[size]; - for (int r = 0; r < size; r++) - { - rawDataReceive[r].resize(0); - rawDataReceive[r].push_back(0); - } - - blocksExchange(MESSAGE_TAG + 3, indexB, indexE, doubleCountInBlock, doubleValuesArray, rawDataReceive); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageFluktuationsArray end of exchange of data, rank = " << rank); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageFluktuationsArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageFluktuationsArray start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - int blockID; - std::vector<double> vectorsOfValues; - - size_t index; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - - for (int r = 0; r < size; r++) - { - index = 1; - for(int ii = 0; ii < rawDataReceive[r][0]; ii++) - { - blockID = (int)(rawDataReceive[r][index]); - index += 1; - - vectorsOfValues.assign(rawDataReceive[r].data() + index, rawDataReceive[r].data() + index + nextVectorSize); - index += nextVectorSize; - - // fill AverageFluktuations array - SPtr<AverageValuesArray3D> mAverageFluktuations; - mAverageFluktuations = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], dataSetParamStr.nx[3])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(blockID); - block->getKernel()->getDataSet()->setAverageFluctuations(mAverageFluktuations); - } - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageFluktuationsArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } -} - -void MPIIOMigrationBECoProcessor::readAverageTripleArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageTripleArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - - int myBlocksCount; - int blocksCountAll = grid->getNumberOfBlocks(); // quantity of all blocks in the grid - int blocksPerProcess = blocksCountAll / size; // how many blocks has each process - - if (rank < (size - 1)) - myBlocksCount = blocksPerProcess; - else - myBlocksCount = blocksPerProcess + (blocksCountAll - blocksPerProcess * size); - - int indexB = rank * blocksPerProcess; // the first "my" block - int indexE = indexB + myBlocksCount; // the latest "my" block - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageTripleArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - int doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> doubleValuesArray(myBlocksCount * doubleCountInBlock); // double-values in all blocks - - MPI_Offset read_offset = (MPI_Offset)(sizeof(dataSetParam)) + (MPI_Offset)(indexB) * (MPI_Offset)(doubleCountInBlock) * (MPI_Offset)(sizeof(double)); - MPI_File_read_at(file_handler, read_offset, &doubleValuesArray[0], myBlocksCount * doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageTripleArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageTripleArray start of exchange of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - std::vector<double>* rawDataReceive = new std::vector<double>[size]; - for (int r = 0; r < size; r++) - { - rawDataReceive[r].resize(0); - rawDataReceive[r].push_back(0); - } - - blocksExchange(MESSAGE_TAG + 4, indexB, indexE, doubleCountInBlock, doubleValuesArray, rawDataReceive); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageTripleArray end of exchange of data, rank = " << rank); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageTripleArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageTripleArray start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - int blockID; - std::vector<double> vectorsOfValues; - - size_t index; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - - for (int r = 0; r < size; r++) - { - index = 1; - for(int ii = 0; ii < rawDataReceive[r][0]; ii++) - { - blockID = (int)(rawDataReceive[r][index]); - index += 1; - - vectorsOfValues.assign(rawDataReceive[r].data() + index, rawDataReceive[r].data() + index + nextVectorSize); - index += nextVectorSize; - - // fill AverageTriplecorrelations array - SPtr<AverageValuesArray3D> mAverageTriplecorrelations; - mAverageTriplecorrelations = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], dataSetParamStr.nx[3])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(blockID); - block->getKernel()->getDataSet()->setAverageTriplecorrelations(mAverageTriplecorrelations); - } - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readAverageTripleArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } -} - -void MPIIOMigrationBECoProcessor::readShearStressValArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readShearStressValArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - - int blocksCountAll = grid->getNumberOfBlocks(); // quantity of all blocks in the grid - int blocksPerProcess = blocksCountAll / size; // how many blocks has each process - - int myBlocksCount; - if (rank < (size - 1)) - myBlocksCount = blocksPerProcess; - else - myBlocksCount = blocksPerProcess + (blocksCountAll - blocksPerProcess * size); - - int indexB = rank * blocksPerProcess; // the first "my" block - int indexE = indexB + myBlocksCount; // the latest "my" block - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpShearStressValArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - int doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> doubleValuesArray(myBlocksCount * doubleCountInBlock); // double-values in all blocks - - MPI_Offset read_offset = (MPI_Offset)(sizeof(dataSetParam)) + (MPI_Offset)(indexB) * (MPI_Offset)(doubleCountInBlock) * (MPI_Offset)(sizeof(double)); - MPI_File_read_at(file_handler, read_offset, &doubleValuesArray[0], myBlocksCount * doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readShearStressValArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readShearStressValArray start of exchange of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - std::vector<double>* rawDataReceive = new std::vector<double>[size]; - for (int r = 0; r < size; r++) - { - rawDataReceive[r].resize(0); - rawDataReceive[r].push_back(0); - } - - blocksExchange(MESSAGE_TAG + 5, indexB, indexE, doubleCountInBlock, doubleValuesArray, rawDataReceive); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readShearStressValArray end of exchange of data, rank = " << rank); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readShearStressValArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readShearStressValArray start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - int blockID; - std::vector<double> vectorsOfValues; - - size_t index; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - - for (int r = 0; r < size; r++) - { - index = 1; - for(int ii = 0; ii < rawDataReceive[r][0]; ii++) - { - blockID = (int)(rawDataReceive[r][index]); - index += 1; - - vectorsOfValues.assign(rawDataReceive[r].data() + index, rawDataReceive[r].data() + index + nextVectorSize); - index += nextVectorSize; - - // fill ShearStressValuesArray array - SPtr<ShearStressValuesArray3D> mShearStressValues; - mShearStressValues = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], dataSetParamStr.nx[3])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(blockID); - block->getKernel()->getDataSet()->setShearStressValues(mShearStressValues); - } - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readShearStressValArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } -} - -void MPIIOMigrationBECoProcessor::readRelaxationFactor(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readRelaxationFactor start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - - int blocksCountAll = grid->getNumberOfBlocks(); // quantity of all blocks in the grid - int blocksPerProcess = blocksCountAll / size; // how many blocks has each process - - int myBlocksCount; - if (rank < (size - 1)) - myBlocksCount = blocksPerProcess; - else - myBlocksCount = blocksPerProcess + (blocksCountAll - blocksPerProcess * size); - - int indexB = rank * blocksPerProcess; // the first "my" block - int indexE = indexB + myBlocksCount; // the latest "my" block - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpRelaxationFactor.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - int doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> doubleValuesArray(myBlocksCount * doubleCountInBlock); // double-values in all blocks - - MPI_Offset read_offset = (MPI_Offset)(sizeof(dataSetParam)) + (MPI_Offset)(indexB) * (MPI_Offset)(doubleCountInBlock) * (MPI_Offset)(sizeof(double)); - MPI_File_read_at(file_handler, read_offset, &doubleValuesArray[0], myBlocksCount * doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readRelaxationFactor time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readRelaxationFactor start of exchange of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - std::vector<double>* rawDataReceive = new std::vector<double>[size]; - for (int r = 0; r < size; r++) - { - rawDataReceive[r].resize(0); - rawDataReceive[r].push_back(0); - } - - blocksExchange(MESSAGE_TAG + 6, indexB, indexE, doubleCountInBlock, doubleValuesArray, rawDataReceive); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readRelaxationFactor end of exchange of data, rank = " << rank); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readRelaxationFactor time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readRelaxationFactor start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - int blockID; - std::vector<double> vectorsOfValues; - - size_t index; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - - for (int r = 0; r < size; r++) - { - index = 1; - for(int ii = 0; ii < rawDataReceive[r][0]; ii++) - { - blockID = (int)(rawDataReceive[r][index]); - index += 1; - - vectorsOfValues.assign(rawDataReceive[r].data() + index, rawDataReceive[r].data() + index + nextVectorSize); - index += nextVectorSize; - - // fill RelaxationFactor array - SPtr<RelaxationFactorArray3D> mRelaxationFactor; - mRelaxationFactor = CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(blockID); - block->getKernel()->getDataSet()->setRelaxationFactor(mRelaxationFactor); - } - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readRelaxationFactor end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } -} - -void MPIIOMigrationBECoProcessor::readBoundaryConds(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readBoundaryConds start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - int blocksCountAll = grid->getNumberOfBlocks(); // quantity of all blocks in the grid - int myBlocksCount; - int blocksPerProcess = blocksCountAll / size; // how many blocks has each process - - if (rank < (size - 1)) - myBlocksCount = blocksPerProcess; - else - myBlocksCount = blocksPerProcess + (blocksCountAll - blocksPerProcess * size); - - int indexB = rank * blocksPerProcess; // the first "my" block - int indexE = indexB + myBlocksCount; // the latest "my" block - - std::vector<int> bcindexmatrixVAll; - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBC1.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - int sizeOfBIM; - MPI_File_read_at(file_handler, (MPI_Offset)0, &sizeOfBIM, 1, MPI_INT, MPI_STATUS_IGNORE); - bcindexmatrixVAll.resize(myBlocksCount * sizeOfBIM); - - MPI_Offset read_offset = (MPI_Offset)(sizeof(int)) + (MPI_Offset)(indexB) * (MPI_Offset)(sizeOfBIM) * (MPI_Offset)(sizeof(int)); - MPI_File_read_at(file_handler, read_offset, &bcindexmatrixVAll[0], myBlocksCount * sizeOfBIM, MPI_INT, MPI_STATUS_IGNORE); - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readBoundaryConds time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readBoundaryConds start of exchange of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - std::vector<int>* rawDataReceive = new std::vector<int>[size]; - std::vector<int>* rawDataSend = new std::vector<int>[size]; - for (int r = 0; r < size; r++) - { - rawDataReceive[r].resize(0); - rawDataSend[r].resize(0); - rawDataReceive[r].push_back(0); - rawDataSend[r].push_back(0); - } - - SPtr<Block3D> tempBlock; - int tempRank; - for (int ind = indexB - indexB; ind < indexE - indexB; ind++) - { - tempBlock = grid->getBlock(indexB + ind); - tempRank = tempBlock->getRank(); - - if (tempRank == rank) // no need to send data, the process already has it - { - rawDataReceive[tempRank][0]++; - rawDataReceive[tempRank].push_back(indexB + ind); - rawDataReceive[tempRank].insert(rawDataReceive[tempRank].end(), bcindexmatrixVAll.begin() + ind * sizeOfBIM, - bcindexmatrixVAll.begin() + ind * sizeOfBIM + sizeOfBIM); - } - else // we must send data to other processes - { - rawDataSend[tempRank][0]++; - rawDataSend[tempRank].push_back(indexB + ind); - rawDataSend[tempRank].insert(rawDataSend[tempRank].end(), bcindexmatrixVAll.begin() + ind * sizeOfBIM, - bcindexmatrixVAll.begin() + ind * sizeOfBIM + sizeOfBIM); - } - } - - MPI_Request* requests = new MPI_Request[size * 2]; // send + receive - int requestCount = 0; - MPI_Status status; - int quant; - int intBlockCount; - int rds; - - for (int r = 0; r < size; r++) - { - if (r != rank) - { - rds = rawDataSend[r].size(); - intBlockCount = (int)(rds / SEND_BLOCK_SIZE); - if (intBlockCount * SEND_BLOCK_SIZE < rds) - intBlockCount += 1; - - for (int i = rds; i < intBlockCount * SEND_BLOCK_SIZE; i++) - rawDataSend[r].push_back(0); - - MPI_Isend(&rawDataSend[r][0], intBlockCount, sendBlockIntType, r, MESSAGE_TAG + 7, MPI_COMM_WORLD, &requests[requestCount]); - //MPI_Isend(&rawDataSend[r][0], rawDataSend[r].size(), MPI_INT, r, MESSAGE_TAG + 7, MPI_COMM_WORLD, &requests[requestCount]); - requestCount++; - } - } - - for (int r = 0; r < size; r++) - { - if (r != rank) - { - MPI_Probe(r, MESSAGE_TAG + 7, MPI_COMM_WORLD, &status); - MPI_Get_count(&status, sendBlockIntType, &quant); - rawDataReceive[r].resize(quant * SEND_BLOCK_SIZE); - MPI_Irecv(&rawDataReceive[r][0], quant, sendBlockIntType, r, MESSAGE_TAG + 7, MPI_COMM_WORLD, &requests[requestCount]); - requestCount++; - } - } - - MPI_Waitall(requestCount, &requests[0], MPI_STATUSES_IGNORE); - -//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readBoundaryConds end of exchange of data, rank = " << rank); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readBoundaryConds time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readBoundaryConds start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBC2.bin"; - rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_File_read_at(file_handler, (MPI_Offset)0, &boundCondParamStr, 4, MPI_INT, MPI_STATUS_IGNORE); - - int blockID; - size_t index; - MPI_Offset read_offset1, read_offset2; - - BCAddMigration bcAddArray; - BoundaryCondition* nullBouCond = new BoundaryCondition(); - memset(nullBouCond, 0, sizeof(BoundaryCondition)); - BoundaryCondition* bcArray; - std::vector<SPtr<BoundaryConditions>> bcVector; - std::vector<int> indexContainerV; - std::vector<int> bcindexmatrixV; - - for (int r = 0; r < size; r++) - { - index = 1; - - for (int ii = 0; ii < rawDataReceive[r][0]; ii++) - { - blockID = (int)(rawDataReceive[r][index]); - index += 1; - - bcindexmatrixV.assign(rawDataReceive[r].data() + index, rawDataReceive[r].data() + index + sizeOfBIM); - index += sizeOfBIM; - - read_offset1 = (MPI_Offset)(sizeof(boundCondParam)) + (MPI_Offset)(blockID) * (MPI_Offset)(sizeof(size_t)); - - MPI_File_read_at(file_handler, read_offset1, &read_offset2, 1, MPI_LONG_LONG_INT, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, read_offset2, &bcAddArray, 3, MPI_INT, MPI_STATUS_IGNORE); - - bcArray = new BoundaryCondition[bcAddArray.boundCond_count]; - indexContainerV.resize(bcAddArray.indexContainer_count); - - if (bcAddArray.boundCond_count > 0) - MPI_File_read_at(file_handler, read_offset2 + (MPI_Offset)(sizeof(BCAddMigration)), &bcArray[0], bcAddArray.boundCond_count, boundCondType, MPI_STATUS_IGNORE); - - if (bcAddArray.indexContainer_count > 0) - MPI_File_read_at(file_handler, read_offset2 + (MPI_Offset)(sizeof(BCAddMigration)) + (MPI_Offset)(bcAddArray.boundCond_count) * (MPI_Offset)(sizeof(BoundaryCondition)), - &indexContainerV[0], bcAddArray.indexContainer_count, MPI_INT, MPI_STATUS_IGNORE); - - bcVector.resize(0); - - for (size_t ibc = 0; ibc<bcAddArray.boundCond_count; ibc++) - { - SPtr<BoundaryConditions> bc; - if (memcmp(&bcArray[ibc], nullBouCond, sizeof(BoundaryCondition)) == 0) - bc = SPtr<BoundaryConditions>(); - else - { - bc = SPtr<BoundaryConditions>(new BoundaryConditions); - bc->noslipBoundaryFlags = bcArray[ibc].noslipBoundaryFlags; - bc->slipBoundaryFlags = bcArray[ibc].slipBoundaryFlags; - bc->densityBoundaryFlags = bcArray[ibc].densityBoundaryFlags; - bc->velocityBoundaryFlags = bcArray[ibc].velocityBoundaryFlags; - bc->wallModelBoundaryFlags = bcArray[ibc].wallModelBoundaryFlags; - bc->bcVelocityX1 = bcArray[ibc].bcVelocityX1; - bc->bcVelocityX2 = bcArray[ibc].bcVelocityX2; - bc->bcVelocityX3 = bcArray[ibc].bcVelocityX3; - bc->bcDensity = bcArray[ibc].bcDensity; - bc->bcLodiDensity = bcArray[ibc].bcLodiDensity; - bc->bcLodiVelocityX1 = bcArray[ibc].bcLodiVelocityX1; - bc->bcLodiVelocityX2 = bcArray[ibc].bcLodiVelocityX2; - bc->bcLodiVelocityX3 = bcArray[ibc].bcLodiVelocityX3; - bc->bcLodiLentgh = bcArray[ibc].bcLodiLentgh; - - bc->nx1 = bcArray[ibc].nx1; - bc->nx2 = bcArray[ibc].nx2; - bc->nx3 = bcArray[ibc].nx3; - for (int iq = 0; iq<26; iq++) - bc->setQ(bcArray[ibc].q[iq], iq); - bc->setBcAlgorithmType(bcArray[ibc].algorithmType); - } - - bcVector.push_back(bc); - } - - CbArray3D<int, IndexerX3X2X1> bcim(bcindexmatrixV, boundCondParamStr.nx1, boundCondParamStr.nx2, boundCondParamStr.nx3); - SPtr<Block3D> block1 = grid->getBlock(blockID); - - SPtr<BCProcessor> bcProc = bcProcessor->clone(block1->getKernel()); - SPtr<BCArray3D> bcArr(new BCArray3D()); - bcArr->bcindexmatrix = bcim; - bcArr->bcvector = bcVector; - bcArr->indexContainer = indexContainerV; - bcProc->setBCArray(bcArr); - - block1->getKernel()->setBCProcessor(bcProc); - } - } - -//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MPI_File_close(&file_handler); - - delete nullBouCond; - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readBoundaryConds end of restore of data, rank = " << rank); - UBLOG(logINFO, "MPIIOMigrationBECoProcessor::readBoundaryConds time: " << finish - start << " s"); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } -} - -////////////////////////////////////////////////////////////////////////// -void MPIIOMigrationBECoProcessor::setLBMKernel(SPtr<LBMKernel> kernel) -{ - this->lbmKernel = kernel; -} -////////////////////////////////////////////////////////////////////////// -void MPIIOMigrationBECoProcessor::setBCProcessor(SPtr<BCProcessor> bcProcessor) -{ - this->bcProcessor = bcProcessor; -} -////////////////////////////////////////////////////////////////////////// -void MPIIOMigrationBECoProcessor::setNu(double nu) -{ - this->nue = nu; -} - diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.h deleted file mode 100644 index 30d5b4b37..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationBECoProcessor.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef _MPIIOMigrationBECoProcessor_H_ -#define _MPIIOMigrationBECoProcessor_H_ - -#include <mpi.h> -#include <string> -#include <vector> - -#include "CoProcessor.h" -#include "MPIIODataStructures.h" - -class Grid3D; -class UbScheduler; -class Communicator; -class BCProcessor; -class LBMKernel; - -//! \class MPIWriteBlocksBECoProcessor -//! \brief Writes the grid each timestep into the files and reads the grip from the files before regenerating -class MPIIOMigrationBECoProcessor : public CoProcessor -{ -public: - MPIIOMigrationBECoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, SPtr<Communicator> comm); - virtual ~MPIIOMigrationBECoProcessor(); - //! Each timestep writes the grid into the files - void process(double step); - //! Reads the grid from the files before grid reconstruction - void restart(int step); - //! Writes the blocks of the grid into the file cpBlocks.bin - void writeBlocks(int step); - //! Writes the datasets of the blocks into the file cpDataSet.bin - void writeDataSet(int step); - void writeAverageDensityArray(int step); - void writeAverageVelocityArray(int step); - void writeAverageFluktuationsArray(int step); - void writeAverageTripleArray(int step); - void writeShearStressValArray(int step); - void writeRelaxationFactor(int step); - //! Writes the boundary conditions of the blocks into the file cpBC.bin - void writeBoundaryConds(int step); - - //! Reads the blocks of the grid from the file cpBlocks.bin - void readBlocks(int step); - //! Reads the datasets of the blocks from the file cpDataSet.bin - void readDataSet(int step); - void readAverageDensityArray(int step); - void readAverageVelocityArray(int step); - void readAverageFluktuationsArray(int step); - void readAverageTripleArray(int step); - void readShearStressValArray(int step); - void readRelaxationFactor(int step); - //! Reads the boundary conditions of the blocks from the file cpBC.bin - void readBoundaryConds(int step); - //! The function sets LBMKernel - void setLBMKernel(SPtr<LBMKernel> kernel); - //!The function sets BCProcessor - void setBCProcessor(SPtr<BCProcessor> bcProcessor); - //!The function truncates the data files - void clearAllFiles(int step); - void setNu(double nu); - //!The function write a time step of last check point - void writeCpTimeStep(int step); - //!The function read a time step of last check point - int readCpTimeStep(); - - void blocksExchange(int tagN, int ind1, int ind2, int doubleCountInBlock, std::vector<double>& pV, std::vector<double>* rawDataReceive); - -protected: - std::string path; - SPtr<Communicator> comm; - -private: - MPI_Datatype gridParamType, block3dType, arrayPresenceType; - MPI_Datatype dataSetParamType, dataSetType, dataSetSmallType, dataSetDoubleType; - MPI_Datatype boundCondParamType, boundCondType, boundCondTypeAdd, bcindexmatrixType; - MPI_Datatype sendBlockDoubleType, sendBlockIntType; - - MPIIODataStructures::boundCondParam boundCondParamStr; - SPtr<LBMKernel> lbmKernel; - SPtr<BCProcessor> bcProcessor; - double nue; - -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp deleted file mode 100644 index 9e7684cb5..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.cpp +++ /dev/null @@ -1,2168 +0,0 @@ -#include "MPIIOMigrationCoProcessor.h" -#include "D3Q27System.h" -#include "LBMKernel.h" -#include "D3Q27EsoTwist3DSplittedVector.h" -#include <UbSystem.h> -#include <MemoryUtil.h> -#include "BoundaryConditions.h" -#include "Block3D.h" -#include "CoordinateTransformation3D.h" -#include "DataSet3D.h" -#include "Grid3D.h" -#include "Grid3DSystem.h" -#include "BCArray3D.h" -#include "Communicator.h" -#include "WbWriter.h" -#include "UbScheduler.h" -#include "LBMKernel.h" -#include "BCProcessor.h" -#include "RenumberBlockVisitor.h" -#include "MetisPartitioningGridVisitor.h" -#include "PointerDefinitions.h" -#include "UbFileOutputASCII.h" -#include "UbFileInputASCII.h" - -using namespace MPIIODataStructures; - -MPIIOMigrationCoProcessor::MPIIOMigrationCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, SPtr<Communicator> comm) : MPIIOCoProcessor(grid, s, path, comm) -{ - memset(&boundCondParamStr, 0, sizeof(boundCondParamStr)); - - //------------------------- define MPI types --------------------------------- - - MPI_Type_contiguous(7, MPI_INT, &dataSetParamType); - MPI_Type_commit(&dataSetParamType); - - //----------------------------------------------------------------------- - - MPI_Datatype typesDataSet[3] = { MPI_DOUBLE, MPI_INT, MPI_CHAR }; - int blocksDataSet[3] = { 2, 2, 2 }; - MPI_Aint offsetsDatatSet[3], lbDataSet, extentDataSet; - - offsetsDatatSet[0] = 0; - MPI_Type_get_extent(MPI_DOUBLE, &lbDataSet, &extentDataSet); - offsetsDatatSet[1] = blocksDataSet[0] * extentDataSet; - - MPI_Type_get_extent(MPI_INT, &lbDataSet, &extentDataSet); - offsetsDatatSet[2] = offsetsDatatSet[1] + blocksDataSet[1] * extentDataSet; - - MPI_Type_create_struct(3, blocksDataSet, offsetsDatatSet, typesDataSet, &dataSetType); - MPI_Type_commit(&dataSetType); - - //----------------------------------------------------------------------- - - MPI_Type_contiguous(1, MPI_INT, &dataSetSmallType); - MPI_Type_commit(&dataSetSmallType); - - //----------------------------------------------------------------------- - - MPI_Type_contiguous(4, MPI_INT, &boundCondParamType); - MPI_Type_commit(&boundCondParamType); - - //----------------------------------------------------------------------- - - MPI_Datatype typesBC[3] = { MPI_LONG_LONG_INT, MPI_FLOAT, MPI_CHAR }; - int blocksBC[3] = { 5, 38, 1 }; - MPI_Aint offsetsBC[3], lbBC, extentBC; - - offsetsBC[0] = 0; - MPI_Type_get_extent(MPI_LONG_LONG_INT, &lbBC, &extentBC); - offsetsBC[1] = blocksBC[0] * extentBC; - - MPI_Type_get_extent(MPI_FLOAT, &lbBC, &extentBC); - offsetsBC[2] = offsetsBC[1] + blocksBC[1] * extentBC; - - MPI_Type_create_struct(3, blocksBC, offsetsBC, typesBC, &boundCondType); - MPI_Type_commit(&boundCondType); - - //--------------------------------------- - - MPI_Type_contiguous(3, MPI_INT, &boundCondTypeAdd); - MPI_Type_commit(&boundCondTypeAdd); - //--------------------------------------- - - MPI_Type_contiguous(6, MPI_CHAR, &arrayPresenceType); - MPI_Type_commit(&arrayPresenceType); - -} -////////////////////////////////////////////////////////////////////////// -MPIIOMigrationCoProcessor::~MPIIOMigrationCoProcessor() -{ - MPI_Type_free(&dataSetParamType); - MPI_Type_free(&dataSetType); - MPI_Type_free(&dataSetSmallType); - MPI_Type_free(&boundCondParamType); - MPI_Type_free(&boundCondType); - MPI_Type_free(&boundCondTypeAdd); - MPI_Type_free(&arrayPresenceType); -} - -////////////////////////////////////////////////////////////////////////// -void MPIIOMigrationCoProcessor::process(double step) -{ - if (scheduler->isDue(step)) - { - if (comm->isRoot()) UBLOG(logINFO, "MPIIOMigrationCoProcessor save step: " << step); - if (comm->isRoot()) UBLOG(logINFO, "Save check point - start"); - /*if (comm->isRoot())*/ clearAllFiles((int)step); - - writeBlocks((int)step); - writeDataSet((int)step); - writeBoundaryConds((int)step); - - writeCpTimeStep(step); - - if (comm->isRoot()) UBLOG(logINFO, "Save check point - end"); - } -} -////////////////////////////////////////////////////////////////////////// -void MPIIOMigrationCoProcessor::writeCpTimeStep(int step) -{ - if (comm->isRoot()) - { - UbFileOutputASCII f(path + "/mpi_io_cp/cp.txt"); - f.writeInteger(step); - } -} -////////////////////////////////////////////////////////////////////////// -int MPIIOMigrationCoProcessor::readCpTimeStep() -{ - UbFileInputASCII f(path + "/mpi_io_cp/cp.txt"); - int step = f.readInteger(); - return step; -} -////////////////////////////////////////////////////////////////////////// -void MPIIOMigrationCoProcessor::writeBlocks(int step) -{ - grid->renumberBlockIDs(); - MPIIOCoProcessor::writeBlocks(step); -} - -void MPIIOMigrationCoProcessor::writeDataSet(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks, that belong to this process - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - dataSetParam dataSetParamStr1, dataSetParamStr2, dataSetParamStr3; - DataSetMigration* dataSetArray = new DataSetMigration[blocksCount]; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeDataSet start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - DSArraysPresence arrPresence; - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetArray[ic].globalID = block->getGlobalID(); // id of the block needed to find it while regenerating the grid - dataSetArray[ic].ghostLayerWidth = block->getKernel()->getGhostLayerWidth(); - dataSetArray[ic].collFactor = block->getKernel()->getCollisionFactor(); - dataSetArray[ic].deltaT = block->getKernel()->getDeltaT(); - dataSetArray[ic].compressible = block->getKernel()->getCompressible(); - dataSetArray[ic].withForcing = block->getKernel()->getWithForcing(); - - SPtr< D3Q27EsoTwist3DSplittedVector > D3Q27EsoTwist3DSplittedVectorPtr = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(block->getKernel()->getDataSet()->getFdistributions()); - CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributions = D3Q27EsoTwist3DSplittedVectorPtr->getLocalDistributions(); - CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions = D3Q27EsoTwist3DSplittedVectorPtr->getNonLocalDistributions(); - CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributions = D3Q27EsoTwist3DSplittedVectorPtr->getZeroDistributions(); - - if (firstBlock)// && block->getKernel()) // when first (any) valid block... - { - if (localDistributions) - { - dataSetParamStr1.nx[0] = static_cast<int>(localDistributions->getNX1()); - dataSetParamStr1.nx[1] = static_cast<int>(localDistributions->getNX2()); - dataSetParamStr1.nx[2] = static_cast<int>(localDistributions->getNX3()); - dataSetParamStr1.nx[3] = static_cast<int>(localDistributions->getNX4()); - } - - if (nonLocalDistributions) - { - dataSetParamStr2.nx[0] = static_cast<int>(nonLocalDistributions->getNX1()); - dataSetParamStr2.nx[1] = static_cast<int>(nonLocalDistributions->getNX2()); - dataSetParamStr2.nx[2] = static_cast<int>(nonLocalDistributions->getNX3()); - dataSetParamStr2.nx[3] = static_cast<int>(nonLocalDistributions->getNX4()); - } - if (zeroDistributions) - { - dataSetParamStr3.nx[0] = static_cast<int>(zeroDistributions->getNX1()); - dataSetParamStr3.nx[1] = static_cast<int>(zeroDistributions->getNX2()); - dataSetParamStr3.nx[2] = static_cast<int>(zeroDistributions->getNX3()); - dataSetParamStr3.nx[3] = 1; - } - - // ... than save some parameters that are equal in all blocks - dataSetParamStr1.nx1 = dataSetParamStr2.nx1 = dataSetParamStr3.nx1 = static_cast<int>(block->getKernel()->getDataSet()->getFdistributions()->getNX1()); - dataSetParamStr1.nx2 = dataSetParamStr2.nx2 = dataSetParamStr3.nx2 = static_cast<int>(block->getKernel()->getDataSet()->getFdistributions()->getNX2()); - dataSetParamStr1.nx3 = dataSetParamStr2.nx3 = dataSetParamStr3.nx3 = static_cast<int>(block->getKernel()->getDataSet()->getFdistributions()->getNX3()); - - doubleCountInBlock = dataSetParamStr1.nx[0] * dataSetParamStr1.nx[1] * dataSetParamStr1.nx[2] * dataSetParamStr1.nx[3] + - dataSetParamStr2.nx[0] * dataSetParamStr2.nx[1] * dataSetParamStr2.nx[2] * dataSetParamStr2.nx[3] + - dataSetParamStr3.nx[0] * dataSetParamStr3.nx[1] * dataSetParamStr3.nx[2] * dataSetParamStr3.nx[3]; - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > averageDensityArray = block->getKernel()->getDataSet()->getAverageDensity(); - if (averageDensityArray) - arrPresence.isAverageDensityArrayPresent = true; - else - arrPresence.isAverageDensityArrayPresent = false; - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageVelocityArray3DPtr = block->getKernel()->getDataSet()->getAverageVelocity(); - if (AverageVelocityArray3DPtr) - arrPresence.isAverageVelocityArrayPresent = true; - else - arrPresence.isAverageVelocityArrayPresent = false; - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageFluctArray3DPtr = block->getKernel()->getDataSet()->getAverageFluctuations(); - if (AverageFluctArray3DPtr) - arrPresence.isAverageFluktuationsArrayPresent = true; - else - arrPresence.isAverageFluktuationsArrayPresent = false; - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageTripleArray3DPtr = block->getKernel()->getDataSet()->getAverageTriplecorrelations(); - if (AverageTripleArray3DPtr) - arrPresence.isAverageTripleArrayPresent = true; - else - arrPresence.isAverageTripleArrayPresent = false; - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > ShearStressValArray3DPtr = block->getKernel()->getDataSet()->getShearStressValues(); - if (ShearStressValArray3DPtr) - arrPresence.isShearStressValArrayPresent = true; - else - arrPresence.isShearStressValArrayPresent = false; - - SPtr< CbArray3D<LBMReal, IndexerX3X2X1> > relaxationFactor3DPtr = block->getKernel()->getDataSet()->getRelaxationFactor(); - if (relaxationFactor3DPtr) - arrPresence.isRelaxationFactorPresent = true; - else - arrPresence.isRelaxationFactorPresent = false; - - firstBlock = false; - } - - if (localDistributions && (dataSetParamStr1.nx[0]>0) && (dataSetParamStr1.nx[1]>0) && (dataSetParamStr1.nx[2]>0) && (dataSetParamStr1.nx[3]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), localDistributions->getDataVector().begin(), localDistributions->getDataVector().end()); - if (nonLocalDistributions && (dataSetParamStr2.nx[0]>0) && (dataSetParamStr2.nx[1]>0) && (dataSetParamStr2.nx[2]>0) && (dataSetParamStr2.nx[3]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), nonLocalDistributions->getDataVector().begin(), nonLocalDistributions->getDataVector().end()); - if (zeroDistributions && (dataSetParamStr3.nx[0]>0) && (dataSetParamStr3.nx[1]>0) && (dataSetParamStr3.nx[2]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), zeroDistributions->getDataVector().begin(), zeroDistributions->getDataVector().end()); - - ic++; - } - } - - // register new MPI-type depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeDataSet start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; -#ifdef HLRN_LUSTRE - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - // write to the file - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSet.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_File_write_at(file_handler, (MPI_Offset)0, &dataSetParamStr1, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, (MPI_Offset)(sizeof(dataSetParam)), &dataSetParamStr2, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, (MPI_Offset)(2 * sizeof(dataSetParam)), &dataSetParamStr3, 1, dataSetParamType, MPI_STATUS_IGNORE); - - MPI_Offset write_offset; - size_t sizeofOneDataSet = sizeof(DataSetMigration) + doubleCountInBlock * sizeof(double); - - for (int nb = 0; nb < blocksCount; nb++) - { - write_offset = (MPI_Offset)(3 * sizeof(dataSetParam) + dataSetArray[nb].globalID * sizeofOneDataSet); - MPI_File_write_at(file_handler, write_offset, &dataSetArray[nb], 1, dataSetType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(DataSetMigration)), &doubleValuesArray[nb * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - } - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeDataSet time: " << finish - start << " s"); - } - - delete[] dataSetArray; - - MPI_File file_handler1; - std::string filename1 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpArrays.bin"; - rc = MPI_File_open(MPI_COMM_WORLD, filename1.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler1); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename1); - MPI_File_write_at(file_handler1, (MPI_Offset)0, &arrPresence, 1, arrayPresenceType, MPI_STATUS_IGNORE); - MPI_File_sync(file_handler1); - MPI_File_close(&file_handler1); - - if (arrPresence.isAverageDensityArrayPresent) - writeAverageDensityArray(step); - - if (arrPresence.isAverageVelocityArrayPresent) - writeAverageVelocityArray(step); - - if (arrPresence.isAverageFluktuationsArrayPresent) - writeAverageFluktuationsArray(step); - - if (arrPresence.isAverageTripleArrayPresent) - writeAverageTripleArray(step); - - if (arrPresence.isShearStressValArrayPresent) - writeShearStressValArray(step); - - if (arrPresence.isRelaxationFactorPresent) - writeRelaxationFactor(step); - -} - -void MPIIOMigrationCoProcessor::writeAverageDensityArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - std::vector<double> doubleValuesArray; // double-values of the AverageDensityArray in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageDensityArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetSmallArray[ic].globalID = block->getGlobalID(); // id of the block needed to find it while regenerating the grid - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > averageDensityArray = block->getKernel()->getDataSet()->getAverageDensity(); - - if (firstBlock) // when first (any) valid block... - { - //if (averageDensityArray) - //{ - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(averageDensityArray->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(averageDensityArray->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(averageDensityArray->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(averageDensityArray->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - //} - //else - // break; - - firstBlock = false; - } - - if (averageDensityArray && (dataSetParamStr.nx[0] > 0) && (dataSetParamStr.nx[1] > 0) && (dataSetParamStr.nx[2] > 0) && (dataSetParamStr.nx[3] > 0)) - doubleValuesArray.insert(doubleValuesArray.end(), averageDensityArray->getDataVector().begin(), averageDensityArray->getDataVector().end()); - - ic++; - } - } - - // register new MPI-types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageDensityArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageDensityArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - MPI_Offset write_offset; - size_t sizeofOneDataSet = sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double); - - for (int nb = 0; nb < blocksCount; nb++) - { - write_offset = (MPI_Offset)(sizeof(dataSetParam) + dataSetSmallArray[nb].globalID * sizeofOneDataSet); - MPI_File_write_at(file_handler, write_offset, &dataSetSmallArray[nb], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[nb * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - } - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageDensityArray time: " << finish - start << " s"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::writeAverageVelocityArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageVelocityArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetSmallArray[ic].globalID = block->getGlobalID(); // id of the block needed to find it while regenerating the grid - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageVelocityArray3DPtr = block->getKernel()->getDataSet()->getAverageVelocity(); - - if (firstBlock) // when first (any) valid block... - { - //if (AverageVelocityArray3DPtr) - //{ - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(AverageVelocityArray3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(AverageVelocityArray3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(AverageVelocityArray3DPtr->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(AverageVelocityArray3DPtr->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - //} - //else - // break; - - firstBlock = false; - } - - if (AverageVelocityArray3DPtr && (dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && (dataSetParamStr.nx[2]>0) && (dataSetParamStr.nx[3]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), AverageVelocityArray3DPtr->getDataVector().begin(), AverageVelocityArray3DPtr->getDataVector().end()); - - ic++; - } - } - - // register new MPI-types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageVelocityArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageVelocityArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - MPI_Offset write_offset; - size_t sizeofOneDataSet = sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double); - - for (int nb = 0; nb < blocksCount; nb++) - { - write_offset = (MPI_Offset)(sizeof(dataSetParam) + dataSetSmallArray[nb].globalID * sizeofOneDataSet); - MPI_File_write_at(file_handler, write_offset, &dataSetSmallArray[nb], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[nb * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - } - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageVelocityArray time: " << finish - start << " s"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::writeAverageFluktuationsArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageFluktuationsArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetSmallArray[ic].globalID = block->getGlobalID(); // id of the block needed to find it while regenerating the grid - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageFluctArray3DPtr = block->getKernel()->getDataSet()->getAverageFluctuations(); - - if (firstBlock) // when first (any) valid block... - { - //if (AverageFluctArray3DPtr) - //{ - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(AverageFluctArray3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(AverageFluctArray3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(AverageFluctArray3DPtr->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(AverageFluctArray3DPtr->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - //} - //else - // break; - - firstBlock = false; - } - - if (AverageFluctArray3DPtr && (dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && (dataSetParamStr.nx[2]>0) && (dataSetParamStr.nx[3]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), AverageFluctArray3DPtr->getDataVector().begin(), AverageFluctArray3DPtr->getDataVector().end()); - - ic++; - } - } - - // register new MPI-types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageFluktuationsArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; -#ifdef HLRN_LUSTRE - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageFluktuationsArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - MPI_Offset write_offset; - size_t sizeofOneDataSet = sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double); - - for (int nb = 0; nb < blocksCount; nb++) - { - write_offset = (MPI_Offset)(sizeof(dataSetParam) + dataSetSmallArray[nb].globalID * sizeofOneDataSet); - MPI_File_write_at(file_handler, write_offset, &dataSetSmallArray[nb], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[nb * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - } - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageFluktuationsArray time: " << finish - start << " s"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::writeAverageTripleArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageTripleArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetSmallArray[ic].globalID = block->getGlobalID(); // id of the block needed to find it while regenerating the grid - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageTripleArray3DPtr = block->getKernel()->getDataSet()->getAverageTriplecorrelations(); - - if (firstBlock) // when first (any) valid block... - { - //if (AverageTripleArray3DPtr) - //{ - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(AverageTripleArray3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(AverageTripleArray3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(AverageTripleArray3DPtr->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(AverageTripleArray3DPtr->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - //} - //else - // break; - - firstBlock = false; - } - - if (AverageTripleArray3DPtr && (dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && (dataSetParamStr.nx[2]>0) && (dataSetParamStr.nx[3]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), AverageTripleArray3DPtr->getDataVector().begin(), AverageTripleArray3DPtr->getDataVector().end()); - - ic++; - } - } - - // register new MPI-types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageTripleArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - -#ifdef HLRN_LUSTRE - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageTripleArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - MPI_Offset write_offset; - size_t sizeofOneDataSet = sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double); - - for (int nb = 0; nb < blocksCount; nb++) - { - write_offset = (MPI_Offset)(sizeof(dataSetParam) + dataSetSmallArray[nb].globalID * sizeofOneDataSet); - MPI_File_write_at(file_handler, write_offset, &dataSetSmallArray[nb], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[nb * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - } - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeAverageTripleArray time: " << finish - start << " s"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::writeShearStressValArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeShearStressValArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetSmallArray[ic].globalID = block->getGlobalID(); // id of the block needed to find it while regenerating the grid - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > ShearStressValArray3DPtr = block->getKernel()->getDataSet()->getShearStressValues(); - - if (firstBlock) // when first (any) valid block... - { - //if (ShearStressValArray3DPtr) - //{ - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(ShearStressValArray3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(ShearStressValArray3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(ShearStressValArray3DPtr->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(ShearStressValArray3DPtr->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - //} - //else - // break; - - firstBlock = false; - } - - if (ShearStressValArray3DPtr && (dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && (dataSetParamStr.nx[2]>0) && (dataSetParamStr.nx[3]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), ShearStressValArray3DPtr->getDataVector().begin(), ShearStressValArray3DPtr->getDataVector().end()); - - ic++; - } - } - - // register new MPI-types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeShearStressValArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - -#ifdef HLRN_LUSTRE - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpShearStressValArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - MPI_Offset write_offset; - size_t sizeofOneDataSet = sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double); - - for (int nb = 0; nb < blocksCount; nb++) - { - write_offset = (MPI_Offset)(sizeof(dataSetParam) + dataSetSmallArray[nb].globalID * sizeofOneDataSet); - MPI_File_write_at(file_handler, write_offset, &dataSetSmallArray[nb], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[nb * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - } - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeShearStressValArray time: " << finish - start << " s"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::writeRelaxationFactor(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeRelaxationFactor start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetSmallArray[ic].globalID = block->getGlobalID(); // id of the block needed to find it while regenerating the grid - - SPtr< CbArray3D<LBMReal, IndexerX3X2X1> > relaxationFactor3DPtr = block->getKernel()->getDataSet()->getRelaxationFactor(); - - if (firstBlock) // when first (any) valid block... - { - //if (relaxationFactor3DPtr) - //{ - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(relaxationFactor3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(relaxationFactor3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(relaxationFactor3DPtr->getNX3()); - dataSetParamStr.nx[3] = 1; - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - //} - //else - // break; - - firstBlock = false; - } - - if (relaxationFactor3DPtr && (dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && (dataSetParamStr.nx[2]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), relaxationFactor3DPtr->getDataVector().begin(), relaxationFactor3DPtr->getDataVector().end()); - - ic++; - } - } - - // register new MPI-types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeRelaxationFactor start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - -#ifdef HLRN_LUSTRE - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpRelaxationFactor.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - MPI_Offset write_offset; - size_t sizeofOneDataSet = sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double); - - for (int nb = 0; nb < blocksCount; nb++) - { - write_offset = (MPI_Offset)(sizeof(dataSetParam) + dataSetSmallArray[nb].globalID * sizeofOneDataSet); - MPI_File_write_at(file_handler, write_offset, &dataSetSmallArray[nb], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[nb * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - } - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeRelaxationFactor time: " << finish - start << " s"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::writeBoundaryConds(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeBoundaryConds start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - int blocksCount = 0; // quantity of blocks, that belong to this process - size_t allBytesCount = 0; // quantity of bytes, that one process writes to the file - size_t count_boundCond = 0; // how many BoundaryConditions in all blocks - int count_indexContainer = 0; // how many indexContainer-values in all blocks - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - BCAddMigration* bcAddArray = new BCAddMigration[blocksCount]; - size_t* bytesCount = new size_t[blocksCount]; // quantity of bytes, that each block writes to the file - std::vector<BoundaryCondition>* bcVector = new std::vector<BoundaryCondition>[blocksCount]; - std::vector<int>* bcindexmatrixVector = new std::vector<int>[blocksCount]; - std::vector<int>* indexContainerVector = new std::vector<int>[blocksCount]; - - bool bcindexmatrixCountNotInit = true; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // all the blocks of the current level - { - SPtr<BCArray3D> bcArr = block->getKernel()->getBCProcessor()->getBCArray(); - - bcAddArray[ic].globalID = block->getGlobalID(); // id of the block needed to find it while regenerating the grid - bcAddArray[ic].boundCond_count = 0; // how many BoundaryConditions in this block - bcAddArray[ic].indexContainer_count = 0; // how many indexContainer-values in this block - bytesCount[ic] = sizeof(BCAddMigration); - bcVector[ic].resize(0); - bcindexmatrixVector[ic].resize(0); - indexContainerVector[ic].resize(0); - - for (int bc = 0; bc<bcArr->getBCVectorSize(); bc++) - { - BoundaryCondition* bouCond = new BoundaryCondition(); - if (bcArr->bcvector[bc] == NULL) - { - memset(bouCond, 0, sizeof(BoundaryCondition)); - } - else - { - bouCond->noslipBoundaryFlags = bcArr->bcvector[bc]->getNoSlipBoundary(); - bouCond->slipBoundaryFlags = bcArr->bcvector[bc]->getSlipBoundary(); - bouCond->velocityBoundaryFlags = bcArr->bcvector[bc]->getVelocityBoundary(); - bouCond->densityBoundaryFlags = bcArr->bcvector[bc]->getDensityBoundary(); - bouCond->wallModelBoundaryFlags = bcArr->bcvector[bc]->getWallModelBoundary(); - bouCond->bcVelocityX1 = bcArr->bcvector[bc]->getBoundaryVelocityX1(); - bouCond->bcVelocityX2 = bcArr->bcvector[bc]->getBoundaryVelocityX2(); - bouCond->bcVelocityX3 = bcArr->bcvector[bc]->getBoundaryVelocityX3(); - bouCond->bcDensity = bcArr->bcvector[bc]->getBoundaryDensity(); - bouCond->bcLodiDensity = bcArr->bcvector[bc]->getDensityLodiDensity(); - bouCond->bcLodiVelocityX1 = bcArr->bcvector[bc]->getDensityLodiVelocityX1(); - bouCond->bcLodiVelocityX2 = bcArr->bcvector[bc]->getDensityLodiVelocityX2(); - bouCond->bcLodiVelocityX3 = bcArr->bcvector[bc]->getDensityLodiVelocityX3(); - bouCond->bcLodiLentgh = bcArr->bcvector[bc]->getDensityLodiLength(); - bouCond->nx1 = bcArr->bcvector[bc]->nx1; - bouCond->nx2 = bcArr->bcvector[bc]->nx2; - bouCond->nx3 = bcArr->bcvector[bc]->nx3; - for (int iq = 0; iq<26; iq++) - bouCond->q[iq] = bcArr->bcvector[bc]->getQ(iq); - bouCond->algorithmType = bcArr->bcvector[bc]->getBcAlgorithmType(); - } - - bcVector[ic].push_back(*bouCond); - bcAddArray[ic].boundCond_count++; - count_boundCond++; - bytesCount[ic] += sizeof(BoundaryCondition); - } - - if (bcindexmatrixCountNotInit) - { - boundCondParamStr.nx1 = static_cast<int>(bcArr->bcindexmatrix.getNX1()); - boundCondParamStr.nx2 = static_cast<int>(bcArr->bcindexmatrix.getNX2()); - boundCondParamStr.nx3 = static_cast<int>(bcArr->bcindexmatrix.getNX3()); - boundCondParamStr.bcindexmatrixCount = static_cast<int>(bcArr->bcindexmatrix.getDataVector().size()); - bcindexmatrixCountNotInit = false; - } - bcindexmatrixVector[ic].insert(bcindexmatrixVector[ic].begin(), bcArr->bcindexmatrix.getDataVector().begin(), bcArr->bcindexmatrix.getDataVector().end()); - bytesCount[ic] += boundCondParamStr.bcindexmatrixCount * sizeof(int); - - indexContainerVector[ic].insert(indexContainerVector[ic].begin(), bcArr->indexContainer.begin(), bcArr->indexContainer.end()); - bcAddArray[ic].indexContainer_count = static_cast<int>(bcArr->indexContainer.size()); - count_indexContainer += bcAddArray[ic].indexContainer_count; - bytesCount[ic] += bcAddArray[ic].indexContainer_count * sizeof(int); - - allBytesCount += bytesCount[ic]; - - ic++; - } - } - - MPI_Type_contiguous(boundCondParamStr.bcindexmatrixCount, MPI_INT, &bcindexmatrixType); - MPI_Type_commit(&bcindexmatrixType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeBoundaryConds start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - //MPI_Info_create (&info); - //MPI_Info_set(info,"romio_cb_write","enable"); - //MPI_Info_set(info,"cb_buffer_size","4194304"); - //MPI_Info_set(info,"striping_unit","4194304"); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBC.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_Offset write_offset = (MPI_Offset)(sizeof(boundCondParam) + grid->getNumberOfBlocks() * sizeof(size_t)); - size_t next_file_offset = 0; - if (size > 1) - { - if (rank == 0) - { - next_file_offset = write_offset + allBytesCount; - MPI_Send(&next_file_offset, 1, MPI_LONG_LONG_INT, 1, 5, MPI_COMM_WORLD); - } - else - { - MPI_Recv(&write_offset, 1, MPI_LONG_LONG_INT, rank - 1, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - next_file_offset = write_offset + allBytesCount; - if (rank < size - 1) - MPI_Send(&next_file_offset, 1, MPI_LONG_LONG_INT, rank + 1, 5, MPI_COMM_WORLD); - } - } - - MPI_File_write_at(file_handler, 0, &boundCondParamStr, 1, boundCondParamType, MPI_STATUS_IGNORE); - - MPI_Offset write_offsetIndex; - - for (int nb = 0; nb < blocksCount; nb++) - { - write_offsetIndex = (MPI_Offset)(sizeof(boundCondParam) + bcAddArray[nb].globalID * sizeof(size_t)); - MPI_File_write_at(file_handler, write_offsetIndex, &write_offset, 1, MPI_LONG_LONG_INT, MPI_STATUS_IGNORE); - - MPI_File_write_at(file_handler, write_offset, &bcAddArray[nb], 1, boundCondTypeAdd, MPI_STATUS_IGNORE); - if (bcVector[nb].size() > 0) - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(BCAddMigration)), &bcVector[nb][0], bcAddArray[nb].boundCond_count, boundCondType, MPI_STATUS_IGNORE); - - if (bcindexmatrixVector[nb].size() > 0) - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(BCAddMigration) + bcAddArray[nb].boundCond_count * sizeof(BoundaryCondition)), - &bcindexmatrixVector[nb][0], 1, bcindexmatrixType, MPI_STATUS_IGNORE); - - if (indexContainerVector[nb].size() > 0) - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(BCAddMigration) + bcAddArray[nb].boundCond_count * sizeof(BoundaryCondition) + boundCondParamStr.bcindexmatrixCount * sizeof(int)), - &indexContainerVector[nb][0], bcAddArray[nb].indexContainer_count, MPI_INT, MPI_STATUS_IGNORE); - - write_offset += bytesCount[nb]; - } - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - MPI_Type_free(&bcindexmatrixType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::writeBoundaryConds time: " << finish - start << " s"); - } - - delete[] bcAddArray; - delete[] bytesCount; - delete[] bcVector; - delete[] bcindexmatrixVector; - delete[] indexContainerVector; -} - -//------------------------------------------- READ ----------------------------------------------- -void MPIIOMigrationCoProcessor::restart(int step) -{ - if (comm->isRoot()) UBLOG(logINFO, "MPIIOMigrationCoProcessor restart step: " << step); - if (comm->isRoot()) UBLOG(logINFO, "Load check point - start"); - - readBlocks(step); - - SPtr<Grid3DVisitor> metisVisitor(new MetisPartitioningGridVisitor(comm, MetisPartitioningGridVisitor::LevelBased, D3Q27System::BSW, MetisPartitioner::KWAY)); - grid->accept(metisVisitor); - - readDataSet(step); - readBoundaryConds(step); - - grid->setTimeStep(step); - - if (comm->isRoot()) UBLOG(logINFO, "Load check point - end"); - //this->reconnect(grid); -} - -void MPIIOMigrationCoProcessor::readBlocks(int step) -{ - MPIIOCoProcessor::readBlocks(step); -} - -void MPIIOMigrationCoProcessor::readDataSet(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readDataSet start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - int blocksCount = 0; // quantity of the blocks, that belong to this process - dataSetParam dataSetParamStr1, dataSetParamStr2, dataSetParamStr3; - - // read from the grid the blocks, that belong to this process - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - DataSetMigration* dataSetArray = new DataSetMigration[blocksCount]; - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSet.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr1, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(sizeof(dataSetParam)), &dataSetParamStr2, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(2 * sizeof(dataSetParam)), &dataSetParamStr3, 1, dataSetParamType, MPI_STATUS_IGNORE); - - double doubleCountInBlock = dataSetParamStr1.nx[0] * dataSetParamStr1.nx[1] * dataSetParamStr1.nx[2] * dataSetParamStr1.nx[3] + - dataSetParamStr2.nx[0] * dataSetParamStr2.nx[1] * dataSetParamStr2.nx[2] * dataSetParamStr2.nx[3] + - dataSetParamStr3.nx[0] * dataSetParamStr3.nx[1] * dataSetParamStr3.nx[2] * dataSetParamStr3.nx[3]; - std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - int ic = 0; - MPI_Offset read_offset; - size_t sizeofOneDataSet = size_t(sizeof(DataSetMigration) + doubleCountInBlock * sizeof(double)); - - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - read_offset = (MPI_Offset)(3 * sizeof(dataSetParam) + block->getGlobalID() * sizeofOneDataSet); - MPI_File_read_at(file_handler, read_offset, &dataSetArray[ic], 1, dataSetType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(DataSetMigration)), &doubleValuesArray[ic * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - ic++; - } - } - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readDataSet time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readDataSet start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - size_t index = 0, vectorSize = 0; - std::vector<double> vectorsOfValues1, vectorsOfValues2, vectorsOfValues3; - - for (int n = 0; n < blocksCount; n++) - { - vectorSize = dataSetParamStr1.nx[0] * dataSetParamStr1.nx[1] * dataSetParamStr1.nx[2] * dataSetParamStr1.nx[3]; - vectorsOfValues1.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + vectorSize); - index += vectorSize; - - vectorSize = dataSetParamStr2.nx[0] * dataSetParamStr2.nx[1] * dataSetParamStr2.nx[2] * dataSetParamStr2.nx[3]; - vectorsOfValues2.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + vectorSize); - index += vectorSize; - - vectorSize = dataSetParamStr3.nx[0] * dataSetParamStr3.nx[1] * dataSetParamStr3.nx[2] * dataSetParamStr3.nx[3]; - vectorsOfValues3.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + vectorSize); - index += vectorSize; - - SPtr<DistributionArray3D> mFdistributions(new D3Q27EsoTwist3DSplittedVector()); - - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues1, dataSetParamStr1.nx[0], dataSetParamStr1.nx[1], dataSetParamStr1.nx[2], dataSetParamStr1.nx[3]))); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setNonLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues2, dataSetParamStr2.nx[0], dataSetParamStr2.nx[1], dataSetParamStr2.nx[2], dataSetParamStr2.nx[3]))); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setZeroDistributions(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>(vectorsOfValues3, dataSetParamStr3.nx[0], dataSetParamStr3.nx[1], dataSetParamStr3.nx[2]))); - - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setNX1(dataSetParamStr1.nx1); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setNX2(dataSetParamStr1.nx2); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setNX3(dataSetParamStr1.nx3); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetArray[n].globalID); - //std::cout << "rank="<<rank<<", dataSetArray[n].globalID=" << dataSetArray[n].globalID << std::endl; - - this->lbmKernel->setBlock(block); - SPtr<LBMKernel> kernel = this->lbmKernel->clone(); - kernel->setGhostLayerWidth(dataSetArray[n].ghostLayerWidth); - kernel->setCollisionFactor(dataSetArray[n].collFactor); - kernel->setDeltaT(dataSetArray[n].deltaT); - kernel->setCompressible(dataSetArray[n].compressible); - kernel->setWithForcing(dataSetArray[n].withForcing); - SPtr<DataSet3D> dataSetPtr = SPtr<DataSet3D>(new DataSet3D()); - dataSetPtr->setFdistributions(mFdistributions); - kernel->setDataSet(dataSetPtr); - block->setKernel(kernel); - } - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readDataSet end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - delete[] dataSetArray; - - //------------------------------------------------------------- - - DSArraysPresence arrPresence; - MPI_File file_handler1; - std::string filename1 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpArrays.bin"; - rc = MPI_File_open(MPI_COMM_WORLD, filename1.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler1); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename1); - MPI_File_read_at(file_handler1, (MPI_Offset)0, &arrPresence, 1, arrayPresenceType, MPI_STATUS_IGNORE); - MPI_File_close(&file_handler1); - - if (arrPresence.isAverageDensityArrayPresent) - readAverageDensityArray(step); - - if (arrPresence.isAverageVelocityArrayPresent) - readAverageVelocityArray(step); - - if (arrPresence.isAverageFluktuationsArrayPresent) - readAverageFluktuationsArray(step); - - if (arrPresence.isAverageTripleArrayPresent) - readAverageTripleArray(step); - - if (arrPresence.isShearStressValArrayPresent) - readShearStressValArray(step); - - if (arrPresence.isRelaxationFactorPresent) - readRelaxationFactor(step); - -} - -void MPIIOMigrationCoProcessor::readAverageDensityArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageDensityArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageDensityArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - int blocksCount = 0; - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - - // read from the grid the blocks, that belong to this process - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - int doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - int ic = 0; - MPI_Offset read_offset; - size_t sizeofOneDataSet = size_t(sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double)); - - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - read_offset = (MPI_Offset)(sizeof(dataSetParam) + block->getGlobalID() * sizeofOneDataSet); - MPI_File_read_at(file_handler, read_offset, &dataSetSmallArray[ic], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[ic * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - ic++; - } - } - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageDensityArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageDensityArray start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - size_t index = 0; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> vectorsOfValues; - for (int n = 0; n < blocksCount; n++) - { - vectorsOfValues.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + nextVectorSize); - index += nextVectorSize; - - // fill mAverageDensity arrays - SPtr<AverageValuesArray3D> mAverageDensity; - //if ((dataSetParamStr.nx[0]==0)&&(dataSetParamStr.nx[1]==0)&&(dataSetParamStr.nx[2]==0)&&(dataSetParamStr.nx[3]==0)) - // mAverageDensity = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(); - //else - mAverageDensity = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], dataSetParamStr.nx[3])); - - //std::cout << "rank=" << rank << ", dataSetArray[n].globalID=" << dataSetSmallArray[n].globalID << std::endl; - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetSmallArray[n].globalID); - block->getKernel()->getDataSet()->setAverageDensity(mAverageDensity); - } - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageDensityArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::readAverageVelocityArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageVelocityArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageVelocityArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - int blocksCount = 0; - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - - // read from the grid the blocks, that belong to this process - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - int doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - int ic = 0; - MPI_Offset read_offset; - size_t sizeofOneDataSet = size_t(sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double)); - - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - read_offset = (MPI_Offset)(sizeof(dataSetParam) + block->getGlobalID() * sizeofOneDataSet); - MPI_File_read_at(file_handler, read_offset, &dataSetSmallArray[ic], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[ic * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - ic++; - } - } - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageVelocityArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageVelocityArray start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - size_t index = 0; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> vectorsOfValues; - for (int n = 0; n < blocksCount; n++) - { - vectorsOfValues.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + nextVectorSize); - index += nextVectorSize; - - // fill mAverageVelocity array - SPtr<AverageValuesArray3D> mAverageVelocity; - //if ((dataSetParamStr.nx[0] == 0) && (dataSetParamStr.nx[1] == 0) && (dataSetParamStr.nx[2] == 0) && (dataSetParamStr.nx[3] == 0)) - // mAverageVelocity = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(); - //else - mAverageVelocity = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], dataSetParamStr.nx[3])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetSmallArray[n].globalID); - block->getKernel()->getDataSet()->setAverageVelocity(mAverageVelocity); - } - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageVelocityArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::readAverageFluktuationsArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageFluktuationsArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageFluktuationsArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - int blocksCount = 0; - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - - // read from the grid the blocks, that belong to this process - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - int doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - int ic = 0; - MPI_Offset read_offset; - size_t sizeofOneDataSet = size_t(sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double)); - - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - read_offset = (MPI_Offset)(sizeof(dataSetParam) + block->getGlobalID() * sizeofOneDataSet); - MPI_File_read_at(file_handler, read_offset, &dataSetSmallArray[ic], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[ic * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - ic++; - } - } - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageFluktuationsArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageFluktuationsArray start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - size_t index = 0; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> vectorsOfValues; - for (int n = 0; n < blocksCount; n++) - { - vectorsOfValues.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + nextVectorSize); - index += nextVectorSize; - - // fill AverageFluktuations array - SPtr<AverageValuesArray3D> mAverageFluktuations; - //if ((dataSetParamStr.nx[0] == 0) && (dataSetParamStr.nx[1] == 0) && (dataSetParamStr.nx[2] == 0) && (dataSetParamStr.nx[3] == 0)) - // mAverageFluktuations = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(); - //else - mAverageFluktuations = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], dataSetParamStr.nx[3])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetSmallArray[n].globalID); - block->getKernel()->getDataSet()->setAverageFluctuations(mAverageFluktuations); - } - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageFluktuationsArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::readAverageTripleArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageTripleArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageTripleArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - int blocksCount = 0; - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - - // read from the grid the blocks, that belong to this process - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - int doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - int ic = 0; - MPI_Offset read_offset; - size_t sizeofOneDataSet = size_t(sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double)); - - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - read_offset = (MPI_Offset)(sizeof(dataSetParam) + block->getGlobalID() * sizeofOneDataSet); - MPI_File_read_at(file_handler, read_offset, &dataSetSmallArray[ic], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[ic * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - ic++; - } - } - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageTripleArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageTripleArray start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - size_t index = 0; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> vectorsOfValues; - for (int n = 0; n < blocksCount; n++) - { - vectorsOfValues.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + nextVectorSize); - index += nextVectorSize; - - // fill AverageTriplecorrelations array - SPtr<AverageValuesArray3D> mAverageTriplecorrelations; - //if ((dataSetParamStr.nx[0] == 0) && (dataSetParamStr.nx[1] == 0) && (dataSetParamStr.nx[2] == 0) && (dataSetParamStr.nx[3] == 0)) - // mAverageTriplecorrelations = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(); - //else - mAverageTriplecorrelations = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], dataSetParamStr.nx[3])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetSmallArray[n].globalID); - block->getKernel()->getDataSet()->setAverageTriplecorrelations(mAverageTriplecorrelations); - } - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readAverageTripleArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::readShearStressValArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readShearStressValArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpShearStressValArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - int blocksCount = 0; - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - - // read from the grid the blocks, that belong to this process - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - int doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - int ic = 0; - MPI_Offset read_offset; - size_t sizeofOneDataSet = size_t(sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double)); - - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - read_offset = (MPI_Offset)(sizeof(dataSetParam) + block->getGlobalID() * sizeofOneDataSet); - MPI_File_read_at(file_handler, read_offset, &dataSetSmallArray[ic], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[ic * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - ic++; - } - } - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readShearStressValArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readShearStressValArray start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - size_t index = 0; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> vectorsOfValues; - for (int n = 0; n < blocksCount; n++) - { - vectorsOfValues.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + nextVectorSize); - index += nextVectorSize; - - // fill ShearStressValuesArray array - SPtr<ShearStressValuesArray3D> mShearStressValues; - //if ((dataSetParamStr.nx[0] == 0) && (dataSetParamStr.nx[1] == 0) && (dataSetParamStr.nx[2] == 0) && (dataSetParamStr.nx[3] == 0)) - // mShearStressValues = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(); - //else - mShearStressValues = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], dataSetParamStr.nx[3])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetSmallArray[n].globalID); - block->getKernel()->getDataSet()->setShearStressValues(mShearStressValues); - } - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readShearStressValArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::readRelaxationFactor(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readRelaxationFactor start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpRelaxationFactor.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - int blocksCount = 0; - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - - // read from the grid the blocks, that belong to this process - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - MPI_File_read_at(file_handler, (MPI_Offset)0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - DataSetSmallMigration* dataSetSmallArray = new DataSetSmallMigration[blocksCount]; - int doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - int ic = 0; - MPI_Offset read_offset; - size_t sizeofOneDataSet = size_t(sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double)); - - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - read_offset = (MPI_Offset)(sizeof(dataSetParam) + block->getGlobalID() * sizeofOneDataSet); - MPI_File_read_at(file_handler, read_offset, &dataSetSmallArray[ic], 1, dataSetSmallType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(DataSetSmallMigration)), &doubleValuesArray[ic * doubleCountInBlock], 1, dataSetDoubleType, MPI_STATUS_IGNORE); - ic++; - } - } - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readRelaxationFactor time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readRelaxationFactor start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - size_t index = 0; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> vectorsOfValues; - for (int n = 0; n < blocksCount; n++) - { - vectorsOfValues.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + nextVectorSize); - index += nextVectorSize; - - // fill RelaxationFactor array - SPtr<RelaxationFactorArray3D> mRelaxationFactor; - //if ((dataSetParamStr.nx[0] == 0) && (dataSetParamStr.nx[1] == 0) && (dataSetParamStr.nx[2] == 0)) - // mRelaxationFactor = CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(); - //else - mRelaxationFactor = CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetSmallArray[n].globalID); - block->getKernel()->getDataSet()->setRelaxationFactor(mRelaxationFactor); - } - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readRelaxationFactor end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - delete[] dataSetSmallArray; -} - -void MPIIOMigrationCoProcessor::readBoundaryConds(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readBoundaryConds start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBC.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - int blocksCount = 0; // quantity of the blocks, that belong to this process - - // read from the grid the blocks, that belong to this process - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - BCAddMigration* bcAddArray = new BCAddMigration[blocksCount]; - BoundaryCondition* nullBouCond = new BoundaryCondition(); - memset(nullBouCond, 0, sizeof(BoundaryCondition)); - BoundaryCondition* bcArray; - int* intArray1; - int* intArray2; - std::vector<SPtr<BoundaryConditions>> bcVector; - std::vector<int> bcindexmatrixV; - std::vector<int> indexContainerV; - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readBoundaryConds time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readBoundaryConds start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - MPI_File_read_at(file_handler, (MPI_Offset)0, &boundCondParamStr, 1, boundCondParamType, MPI_STATUS_IGNORE); - MPI_Type_contiguous(boundCondParamStr.bcindexmatrixCount, MPI_INT, &bcindexmatrixType); - MPI_Type_commit(&bcindexmatrixType); - - int ic = 0; - MPI_Offset read_offset1, read_offset2; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - read_offset1 = (MPI_Offset)(sizeof(boundCondParam) + block->getGlobalID() * sizeof(size_t)); - - MPI_File_read_at(file_handler, read_offset1, &read_offset2, 1, MPI_LONG_LONG_INT, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, read_offset2, &bcAddArray[ic], 1, boundCondTypeAdd, MPI_STATUS_IGNORE); - - bcArray = new BoundaryCondition[bcAddArray[ic].boundCond_count]; - intArray1 = new int[boundCondParamStr.bcindexmatrixCount]; - intArray2 = new int[bcAddArray[ic].indexContainer_count]; - - if (bcAddArray[ic].boundCond_count > 0) - { - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset2 + sizeof(BCAddMigration)), &bcArray[0], bcAddArray[ic].boundCond_count, boundCondType, MPI_STATUS_IGNORE); - } - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset2 + sizeof(BCAddMigration) + bcAddArray[ic].boundCond_count * sizeof(BoundaryCondition)), - &intArray1[0], 1, bcindexmatrixType, MPI_STATUS_IGNORE); - if (bcAddArray[ic].indexContainer_count > 0) - { - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset2 + sizeof(BCAddMigration) + bcAddArray[ic].boundCond_count * sizeof(BoundaryCondition) + boundCondParamStr.bcindexmatrixCount * sizeof(int)), - &intArray2[0], bcAddArray[ic].indexContainer_count, MPI_INT, MPI_STATUS_IGNORE); - } - - bcindexmatrixV.resize(0); - indexContainerV.resize(0); - bcVector.resize(0); - - for (size_t ibc = 0; ibc<bcAddArray[ic].boundCond_count; ibc++) - { - SPtr<BoundaryConditions> bc; - if (memcmp(&bcArray[ibc], nullBouCond, sizeof(BoundaryCondition)) == 0) - bc = SPtr<BoundaryConditions>(); - else - { - bc = SPtr<BoundaryConditions>(new BoundaryConditions); - bc->noslipBoundaryFlags = bcArray[ibc].noslipBoundaryFlags; - bc->slipBoundaryFlags = bcArray[ibc].slipBoundaryFlags; - bc->densityBoundaryFlags = bcArray[ibc].densityBoundaryFlags; - bc->velocityBoundaryFlags = bcArray[ibc].velocityBoundaryFlags; - bc->wallModelBoundaryFlags = bcArray[ibc].wallModelBoundaryFlags; - bc->bcVelocityX1 = bcArray[ibc].bcVelocityX1; - bc->bcVelocityX2 = bcArray[ibc].bcVelocityX2; - bc->bcVelocityX3 = bcArray[ibc].bcVelocityX3; - bc->bcDensity = bcArray[ibc].bcDensity; - bc->bcLodiDensity = bcArray[ibc].bcLodiDensity; - bc->bcLodiVelocityX1 = bcArray[ibc].bcLodiVelocityX1; - bc->bcLodiVelocityX2 = bcArray[ibc].bcLodiVelocityX2; - bc->bcLodiVelocityX3 = bcArray[ibc].bcLodiVelocityX3; - bc->bcLodiLentgh = bcArray[ibc].bcLodiLentgh; - - bc->nx1 = bcArray[ibc].nx1; - bc->nx2 = bcArray[ibc].nx2; - bc->nx3 = bcArray[ibc].nx3; - for (int iq = 0; iq<26; iq++) - bc->setQ(bcArray[ibc].q[iq], iq); - bc->setBcAlgorithmType(bcArray[ibc].algorithmType); - } - - bcVector.push_back(bc); - } - - for (int b1 = 0; b1 < boundCondParamStr.bcindexmatrixCount; b1++) - bcindexmatrixV.push_back(intArray1[b1]); - - for (int b2 = 0; b2 < bcAddArray[ic].indexContainer_count; b2++) - indexContainerV.push_back(intArray2[b2]); - - CbArray3D<int, IndexerX3X2X1> bcim(bcindexmatrixV, boundCondParamStr.nx1, boundCondParamStr.nx2, boundCondParamStr.nx3); - SPtr<Block3D> block1 = grid->getBlock(bcAddArray[ic].globalID); - - SPtr<BCProcessor> bcProc = bcProcessor->clone(block1->getKernel()); - SPtr<BCArray3D> bcArr(new BCArray3D()); - bcArr->bcindexmatrix = bcim; - bcArr->bcvector = bcVector; - bcArr->indexContainer = indexContainerV; - bcProc->setBCArray(bcArr); - - block1->getKernel()->setBCProcessor(bcProc); - - delete bcArray; - delete intArray1; - - ic++; - } - } - MPI_File_close(&file_handler); - - MPI_Type_free(&bcindexmatrixType); - - delete nullBouCond; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIOMigrationCoProcessor::readBoundaryConds end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } -} - -////////////////////////////////////////////////////////////////////////// -void MPIIOMigrationCoProcessor::setLBMKernel(SPtr<LBMKernel> kernel) -{ - this->lbmKernel = kernel; -} -////////////////////////////////////////////////////////////////////////// -void MPIIOMigrationCoProcessor::setBCProcessor(SPtr<BCProcessor> bcProcessor) -{ - this->bcProcessor = bcProcessor; -} - diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.h deleted file mode 100644 index 8644e37ef..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIOMigrationCoProcessor.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef _MPIIOMigrationCoProcessor_H_ -#define _MPIIOMigrationCoProcessor_H_ - -#include <mpi.h> -#include <string> - -#include "MPIIODataStructures.h" -#include "MPIIOCoProcessor.h" - -class Grid3D; -class UbScheduler; -class Communicator; -class BCProcessor; -class LBMKernel; - - -//! \class MPIIOMigrationCoProcessor -//! \brief Writes the grid each timestep into the files and reads the grip from the files before regenerating -class MPIIOMigrationCoProcessor : public MPIIOCoProcessor -{ -public: - MPIIOMigrationCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, SPtr<Communicator> comm); - virtual ~MPIIOMigrationCoProcessor(); - //! Each timestep writes the grid into the files - void process(double step); - //! Reads the grid from the files before grid reconstruction - void restart(int step); - //! Writes the blocks of the grid into the file cpBlocks.bin - void writeBlocks(int step); - //! Writes the datasets of the blocks into the file cpDataSet.bin - void writeDataSet(int step); - void writeAverageDensityArray(int step); - void writeAverageVelocityArray(int step); - void writeAverageFluktuationsArray(int step); - void writeAverageTripleArray(int step); - void writeShearStressValArray(int step); - void writeRelaxationFactor(int step); - //! Writes the boundary conditions of the blocks into the file cpBC.bin - void writeBoundaryConds(int step); - - //! Reads the blocks of the grid from the file cpBlocks.bin - void readBlocks(int step); - //! Reads the datasets of the blocks from the file cpDataSet.bin - void readDataSet(int step); - void readAverageDensityArray(int step); - void readAverageVelocityArray(int step); - void readAverageFluktuationsArray(int step); - void readAverageTripleArray(int step); - void readShearStressValArray(int step); - void readRelaxationFactor(int step); - //! Reads the boundary conditions of the blocks from the file cpBC.bin - void readBoundaryConds(int step); - //! The function sets LBMKernel - void setLBMKernel(SPtr<LBMKernel> kernel); - //!The function sets BCProcessor - void setBCProcessor(SPtr<BCProcessor> bcProcessor); - //!The function write a time step of last check point - void writeCpTimeStep(int step); - //!The function read a time step of last check point - int readCpTimeStep(); - -protected: - //std::string path; - //SPtr<Communicator> comm; - -private: - //MPI_Datatype gridParamType, block3dType, - MPI_Datatype arrayPresenceType; - MPI_Datatype dataSetParamType, dataSetType, dataSetSmallType, dataSetDoubleType; - MPI_Datatype boundCondParamType, boundCondType, boundCondTypeAdd, bcindexmatrixType; - - MPIIODataStructures::boundCondParam boundCondParamStr; - SPtr<LBMKernel> lbmKernel; - SPtr<BCProcessor> bcProcessor; - //double nue; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.cpp deleted file mode 100644 index e7fc67de6..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.cpp +++ /dev/null @@ -1,2720 +0,0 @@ -#include "MPIIORestartCoProcessor.h" -#include "D3Q27System.h" -#include "LBMKernel.h" -#include "D3Q27EsoTwist3DSplittedVector.h" -#include <UbSystem.h> -#include <MemoryUtil.h> -#include "BoundaryConditions.h" -#include "Block3D.h" -#include "CoordinateTransformation3D.h" -#include "DataSet3D.h" -#include "Grid3D.h" -#include "BCArray3D.h" -#include "Communicator.h" -#include "WbWriter.h" -#include "UbScheduler.h" -#include "LBMKernel.h" -#include "BCProcessor.h" -#include "UbFileOutputASCII.h" -#include "UbFileInputASCII.h" - -//! BLOCK_SIZE defines the quantity of the BoundaryCondition-structures written as one block to the file -//! To avoid overflow in the parameter \a count of the function MPI_File_write_at -//! structures BoundaryCondition are being written in blocks containing each of them BLOCK_SIZE structures -#define BLOCK_SIZE 1024 - -using namespace MPIIODataStructures; - -MPIIORestartCoProcessor::MPIIORestartCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, - const std::string& path, - SPtr<Communicator> comm) : - CoProcessor(grid, s), - path(path), - comm(comm) -{ - UbSystem::makeDirectory(path + "/mpi_io_cp"); - - memset(&boundCondParamStr, 0, sizeof(boundCondParamStr)); - - //------------------------- define MPI types --------------------------------- - - MPI_Datatype typesGP[3] = { MPI_DOUBLE, MPI_INT, MPI_CHAR }; - int blocksGP[3] = { 34, 6, 5 }; - MPI_Aint offsetsGP[3], lbGP, extentGP; - - offsetsGP[0] = 0; - MPI_Type_get_extent(MPI_DOUBLE, &lbGP, &extentGP); - offsetsGP[1] = blocksGP[0] * extentGP; - - MPI_Type_get_extent(MPI_INT, &lbGP, &extentGP); - offsetsGP[2] = offsetsGP[1] + blocksGP[1] * extentGP; - - MPI_Type_create_struct(3, blocksGP, offsetsGP, typesGP, &gridParamType); - MPI_Type_commit(&gridParamType); - - //----------------------------------------------------------------------- - - MPI_Datatype typesBlock[2] = { MPI_INT, MPI_CHAR }; - int blocksBlock[2] = { 13, 1 }; - MPI_Aint offsetsBlock[2], lbBlock, extentBlock; - - offsetsBlock[0] = 0; - MPI_Type_get_extent(MPI_INT, &lbBlock, &extentBlock); - offsetsBlock[1] = blocksBlock[0] * extentBlock; - - MPI_Type_create_struct(2, blocksBlock, offsetsBlock, typesBlock, &block3dType); - MPI_Type_commit(&block3dType); - - //----------------------------------------------------------------------- - - MPI_Type_contiguous(7, MPI_INT, &dataSetParamType); - MPI_Type_commit(&dataSetParamType); - - //----------------------------------------------------------------------- - - MPI_Datatype typesDataSet[3] = { MPI_DOUBLE, MPI_INT, MPI_CHAR }; - int blocksDataSet[3] = { 2, 5, 2 }; - MPI_Aint offsetsDatatSet[3], lbDataSet, extentDataSet; - - offsetsDatatSet[0] = 0; - MPI_Type_get_extent(MPI_DOUBLE, &lbDataSet, &extentDataSet); - offsetsDatatSet[1] = blocksDataSet[0] * extentDataSet; - - MPI_Type_get_extent(MPI_INT, &lbDataSet, &extentDataSet); - offsetsDatatSet[2] = offsetsDatatSet[1] + blocksDataSet[1] * extentDataSet; - - MPI_Type_create_struct(3, blocksDataSet, offsetsDatatSet, typesDataSet, &dataSetType); - MPI_Type_commit(&dataSetType); - - //----------------------------------------------------------------------- - - MPI_Type_contiguous(4, MPI_INT, &dataSetSmallType); - MPI_Type_commit(&dataSetSmallType); - - //----------------------------------------------------------------------- - - MPI_Type_contiguous(4, MPI_INT, &boundCondParamType); - MPI_Type_commit(&boundCondParamType); - - //----------------------------------------------------------------------- - - MPI_Datatype typesBC[3] = { MPI_LONG_LONG_INT, MPI_FLOAT, MPI_CHAR }; - int blocksBC[3] = { 5, 38, 1 }; - MPI_Aint offsetsBC[3], lbBC, extentBC; - - offsetsBC[0] = 0; - MPI_Type_get_extent(MPI_LONG_LONG_INT, &lbBC, &extentBC); - offsetsBC[1] = blocksBC[0] * extentBC; - - MPI_Type_get_extent(MPI_FLOAT, &lbBC, &extentBC); - offsetsBC[2] = offsetsBC[1] + blocksBC[1] * extentBC; - - MPI_Type_create_struct(3, blocksBC, offsetsBC, typesBC, &boundCondType); - MPI_Type_commit(&boundCondType); - - //--------------------------------------- - - MPI_Type_contiguous(BLOCK_SIZE, boundCondType, &boundCondType1000); - MPI_Type_commit(&boundCondType1000); - - //--------------------------------------- - - MPI_Type_contiguous(6, MPI_INT, &boundCondTypeAdd); - MPI_Type_commit(&boundCondTypeAdd); - - //--------------------------------------- - - MPI_Type_contiguous(6, MPI_CHAR, &arrayPresenceType); - MPI_Type_commit(&arrayPresenceType); - -} -////////////////////////////////////////////////////////////////////////// -MPIIORestartCoProcessor::~MPIIORestartCoProcessor() -{ - MPI_Type_free(&gridParamType); - MPI_Type_free(&block3dType); - MPI_Type_free(&dataSetParamType); - MPI_Type_free(&dataSetType); - MPI_Type_free(&dataSetSmallType); - MPI_Type_free(&boundCondParamType); - MPI_Type_free(&boundCondType); - MPI_Type_free(&boundCondType1000); - MPI_Type_free(&boundCondTypeAdd); - MPI_Type_free(&arrayPresenceType); -} - -////////////////////////////////////////////////////////////////////////// -void MPIIORestartCoProcessor::process(double step) -{ - if (scheduler->isDue(step)) - { - if (comm->isRoot()) UBLOG(logINFO, "MPIIORestartCoProcessor save step: " << step); - if (comm->isRoot()) UBLOG(logINFO, "Save check point - start"); - /*if (comm->isRoot())*/ clearAllFiles((int)step); - - writeBlocks((int)step); - writeDataSet((int)step); - writeBoundaryConds((int)step); - - writeCpTimeStep((int)step); - - if (comm->isRoot()) UBLOG(logINFO, "Save check point - end"); - } -} -////////////////////////////////////////////////////////////////////////// -void MPIIORestartCoProcessor::clearAllFiles(int step) -{ - MPI_File file_handler; - MPI_Info info = MPI_INFO_NULL; - MPI_Offset new_size = 0; - - UbSystem::makeDirectory(path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step)); - - std::string filename1 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBlocks.bin"; - int rc1 = MPI_File_open(MPI_COMM_WORLD, filename1.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handler); - if (rc1 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename1); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename2 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSet.bin"; - int rc2 = MPI_File_open(MPI_COMM_WORLD, filename2.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc2 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename2); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename3 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpArrays.bin"; - int rc3 = MPI_File_open(MPI_COMM_WORLD, filename3.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc3 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename3); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); - - std::string filename4 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageDensityArray.bin"; - MPI_File_delete(filename4.c_str(), info); - //int rc4 = MPI_File_open(MPI_COMM_WORLD, filename4.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - //if (rc4 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename4); - //MPI_File_set_size(file_handler, new_size); - //MPI_File_close(&file_handler); - - std::string filename5 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageVelocityArray.bin"; - MPI_File_delete(filename5.c_str(), info); - //int rc5 = MPI_File_open(MPI_COMM_WORLD, filename5.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - //if (rc5 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename5); - //MPI_File_set_size(file_handler, new_size); - //MPI_File_close(&file_handler); - - std::string filename6 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageFluktuationsArray.bin"; - MPI_File_delete(filename6.c_str(), info); - //int rc6 = MPI_File_open(MPI_COMM_WORLD, filename6.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - //if (rc6 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename6); - //MPI_File_set_size(file_handler, new_size); - //MPI_File_close(&file_handler); - - std::string filename7 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageTripleArray.bin"; - MPI_File_delete(filename7.c_str(), info); - //int rc7 = MPI_File_open(MPI_COMM_WORLD, filename7.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - //if (rc7 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename7); - //MPI_File_set_size(file_handler, new_size); - //MPI_File_close(&file_handler); - - std::string filename8 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpShearStressValArray.bin"; - MPI_File_delete(filename8.c_str(), info); - //int rc8 = MPI_File_open(MPI_COMM_WORLD, filename8.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - //if (rc8 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename8); - //MPI_File_set_size(file_handler, new_size); - //MPI_File_close(&file_handler); - - std::string filename9 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpRelaxationFactor.bin"; - MPI_File_delete(filename9.c_str(), info); - //int rc9 = MPI_File_open(MPI_COMM_WORLD, filename9.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - //if (rc9 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename9); - //MPI_File_set_size(file_handler, new_size); - //MPI_File_close(&file_handler); - - std::string filename10 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBC.bin"; - int rc10 = MPI_File_open(MPI_COMM_WORLD, filename10.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc10 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename10); - MPI_File_set_size(file_handler, new_size); - MPI_File_close(&file_handler); -} -////////////////////////////////////////////////////////////////////////// -void MPIIORestartCoProcessor::writeCpTimeStep(int step) -{ - if (comm->isRoot()) - { - UbFileOutputASCII f(path + "/mpi_io_cp/cp.txt"); - f.writeInteger(step); - } -} -////////////////////////////////////////////////////////////////////////// -int MPIIORestartCoProcessor::readCpTimeStep() -{ - UbFileInputASCII f(path + "/mpi_io_cp/cp.txt"); - int step = f.readInteger(); - return step; -} -////////////////////////////////////////////////////////////////////////// -void MPIIORestartCoProcessor::writeBlocks(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - //MPI_Comm_size(MPI_COMM_WORLD, &size); - size = 1; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::writeBlocks start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - - std::vector<SPtr<Block3D>> blocksVector[25]; // max 25 levels - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - //grid->getBlocks(level, rank, blockVector[level]); - grid->getBlocks(level, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - GridParam* gridParameters = new GridParam; - gridParameters->trafoParams[0] = grid->getCoordinateTransformator()->Tx1; - gridParameters->trafoParams[1] = grid->getCoordinateTransformator()->Tx2; - gridParameters->trafoParams[2] = grid->getCoordinateTransformator()->Tx3; - gridParameters->trafoParams[3] = grid->getCoordinateTransformator()->Sx1; - gridParameters->trafoParams[4] = grid->getCoordinateTransformator()->Sx2; - gridParameters->trafoParams[5] = grid->getCoordinateTransformator()->Sx3; - gridParameters->trafoParams[6] = grid->getCoordinateTransformator()->alpha; - gridParameters->trafoParams[7] = grid->getCoordinateTransformator()->beta; - gridParameters->trafoParams[8] = grid->getCoordinateTransformator()->gamma; - - gridParameters->trafoParams[9] = grid->getCoordinateTransformator()->toX1factorX1; - gridParameters->trafoParams[10] = grid->getCoordinateTransformator()->toX1factorX2; - gridParameters->trafoParams[11] = grid->getCoordinateTransformator()->toX1factorX3; - gridParameters->trafoParams[12] = grid->getCoordinateTransformator()->toX1delta; - gridParameters->trafoParams[13] = grid->getCoordinateTransformator()->toX2factorX1; - gridParameters->trafoParams[14] = grid->getCoordinateTransformator()->toX2factorX2; - gridParameters->trafoParams[15] = grid->getCoordinateTransformator()->toX2factorX3; - gridParameters->trafoParams[16] = grid->getCoordinateTransformator()->toX2delta; - gridParameters->trafoParams[17] = grid->getCoordinateTransformator()->toX3factorX1; - gridParameters->trafoParams[18] = grid->getCoordinateTransformator()->toX3factorX2; - gridParameters->trafoParams[19] = grid->getCoordinateTransformator()->toX3factorX3; - gridParameters->trafoParams[20] = grid->getCoordinateTransformator()->toX3delta; - - gridParameters->trafoParams[21] = grid->getCoordinateTransformator()->fromX1factorX1; - gridParameters->trafoParams[22] = grid->getCoordinateTransformator()->fromX1factorX2; - gridParameters->trafoParams[23] = grid->getCoordinateTransformator()->fromX1factorX3; - gridParameters->trafoParams[24] = grid->getCoordinateTransformator()->fromX1delta; - gridParameters->trafoParams[25] = grid->getCoordinateTransformator()->fromX2factorX1; - gridParameters->trafoParams[26] = grid->getCoordinateTransformator()->fromX2factorX2; - gridParameters->trafoParams[27] = grid->getCoordinateTransformator()->fromX2factorX3; - gridParameters->trafoParams[28] = grid->getCoordinateTransformator()->fromX2delta; - gridParameters->trafoParams[29] = grid->getCoordinateTransformator()->fromX3factorX1; - gridParameters->trafoParams[30] = grid->getCoordinateTransformator()->fromX3factorX2; - gridParameters->trafoParams[31] = grid->getCoordinateTransformator()->fromX3factorX3; - gridParameters->trafoParams[32] = grid->getCoordinateTransformator()->fromX3delta; - - gridParameters->active = grid->getCoordinateTransformator()->active; - gridParameters->transformation = grid->getCoordinateTransformator()->transformation; - - gridParameters->deltaX = grid->getDeltaX(minInitLevel); - UbTupleInt3 blocknx = grid->getBlockNX(); - gridParameters->blockNx1 = val<1>(blocknx); - gridParameters->blockNx2 = val<2>(blocknx); - gridParameters->blockNx3 = val<3>(blocknx); - gridParameters->nx1 = grid->getNX1(); - gridParameters->nx2 = grid->getNX2(); - gridParameters->nx3 = grid->getNX3(); - gridParameters->periodicX1 = grid->isPeriodicX1(); - gridParameters->periodicX2 = grid->isPeriodicX2(); - gridParameters->periodicX3 = grid->isPeriodicX3(); - - //---------------------------------------------------------------------- - - Block3d* block3dArray = new Block3d[blocksCount]; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // all the blocks of the current level - { - // save data describing the block - block3dArray[ic].x1 = block->getX1(); - block3dArray[ic].x2 = block->getX2(); - block3dArray[ic].x3 = block->getX3(); - block3dArray[ic].bundle = block->getBundle(); - block3dArray[ic].rank = block->getRank(); - block3dArray[ic].lrank = block->getLocalRank(); - block3dArray[ic].part = block->getPart(); - block3dArray[ic].globalID = block->getGlobalID(); - block3dArray[ic].localID = block->getLocalID(); - block3dArray[ic].level = block->getLevel(); - block3dArray[ic].interpolationFlagCF = block->getCollectionOfInterpolationFlagCF(); - block3dArray[ic].interpolationFlagFC = block->getCollectionOfInterpolationFlagFC(); - block3dArray[ic].counter = block->getMaxGlobalID(); - block3dArray[ic].active = block->isActive(); - - ic++; - } - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::writeBlocks start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - MPI_File file_handler; - MPI_Info info = MPI_INFO_NULL; - //MPI_Info_create (&info); - //MPI_Info_set(info,"romio_cb_write","enable"); - //MPI_Info_set(info,"cb_buffer_size","4194304"); - //MPI_Info_set(info,"striping_unit","4194304"); - - // if (comm->isRoot()) - // { - UbSystem::makeDirectory(path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step)); - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBlocks.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - // } - - double start, finish; - MPI_Offset write_offset = (MPI_Offset)(size * sizeof(int)); - - if (comm->isRoot()) - { - start = MPI_Wtime(); - - // each process writes the quantity of it's blocks - MPI_File_write_at(file_handler, (MPI_Offset)(rank * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - // each process writes parameters of the grid - MPI_File_write_at(file_handler, write_offset, gridParameters, 1, gridParamType, MPI_STATUS_IGNORE); - // each process writes it's blocks - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(GridParam)), &block3dArray[0], blocksCount, block3dType, MPI_STATUS_IGNORE); - } - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIORestartCoProcessor::writeBlocks time: " << finish - start << " s"); - } - - delete[] block3dArray; - delete gridParameters; -} - -void MPIIORestartCoProcessor::writeDataSet(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - dataSetParam dataSetParamStr1, dataSetParamStr2, dataSetParamStr3; - DataSetRestart* dataSetArray = new DataSetRestart[blocksCount]; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::writeDataSet start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - DSArraysPresence arrPresence; - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetArray[ic].x1 = block->getX1(); // coordinates of the block needed to find it while regenerating the grid - dataSetArray[ic].x2 = block->getX2(); - dataSetArray[ic].x3 = block->getX3(); - dataSetArray[ic].level = block->getLevel(); - dataSetArray[ic].ghostLayerWidth = block->getKernel()->getGhostLayerWidth(); - dataSetArray[ic].collFactor = block->getKernel()->getCollisionFactor(); - dataSetArray[ic].deltaT = block->getKernel()->getDeltaT(); - dataSetArray[ic].compressible = block->getKernel()->getCompressible(); - dataSetArray[ic].withForcing = block->getKernel()->getWithForcing(); - - SPtr< D3Q27EsoTwist3DSplittedVector > D3Q27EsoTwist3DSplittedVectorPtr = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(block->getKernel()->getDataSet()->getFdistributions()); - CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributions = D3Q27EsoTwist3DSplittedVectorPtr->getLocalDistributions(); - CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions = D3Q27EsoTwist3DSplittedVectorPtr->getNonLocalDistributions(); - CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributions = D3Q27EsoTwist3DSplittedVectorPtr->getZeroDistributions(); - - if (firstBlock) // when first (any) valid block... - { - if (localDistributions) - { - dataSetParamStr1.nx[0] = static_cast<int>(localDistributions->getNX1()); - dataSetParamStr1.nx[1] = static_cast<int>(localDistributions->getNX2()); - dataSetParamStr1.nx[2] = static_cast<int>(localDistributions->getNX3()); - dataSetParamStr1.nx[3] = static_cast<int>(localDistributions->getNX4()); - } - if (nonLocalDistributions) - { - dataSetParamStr2.nx[0] = static_cast<int>(nonLocalDistributions->getNX1()); - dataSetParamStr2.nx[1] = static_cast<int>(nonLocalDistributions->getNX2()); - dataSetParamStr2.nx[2] = static_cast<int>(nonLocalDistributions->getNX3()); - dataSetParamStr2.nx[3] = static_cast<int>(nonLocalDistributions->getNX4()); - } - if (zeroDistributions) - { - dataSetParamStr3.nx[0] = static_cast<int>(zeroDistributions->getNX1()); - dataSetParamStr3.nx[1] = static_cast<int>(zeroDistributions->getNX2()); - dataSetParamStr3.nx[2] = static_cast<int>(zeroDistributions->getNX3()); - dataSetParamStr3.nx[3] = 1; - } - - // ... than save some parameters that are equal in all dataSets - dataSetParamStr1.nx1 = dataSetParamStr2.nx1 = dataSetParamStr3.nx1 = static_cast<int>(block->getKernel()->getDataSet()->getFdistributions()->getNX1()); - dataSetParamStr1.nx2 = dataSetParamStr2.nx2 = dataSetParamStr3.nx2 = static_cast<int>(block->getKernel()->getDataSet()->getFdistributions()->getNX2()); - dataSetParamStr1.nx3 = dataSetParamStr2.nx3 = dataSetParamStr3.nx3 = static_cast<int>(block->getKernel()->getDataSet()->getFdistributions()->getNX3()); - - doubleCountInBlock = dataSetParamStr1.nx[0] * dataSetParamStr1.nx[1] * dataSetParamStr1.nx[2] * dataSetParamStr1.nx[3] + - dataSetParamStr2.nx[0] * dataSetParamStr2.nx[1] * dataSetParamStr2.nx[2] * dataSetParamStr2.nx[3] + - dataSetParamStr3.nx[0] * dataSetParamStr3.nx[1] * dataSetParamStr3.nx[2] * dataSetParamStr3.nx[3]; - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > averageDensityArray = block->getKernel()->getDataSet()->getAverageDensity(); - if (averageDensityArray) - arrPresence.isAverageDensityArrayPresent = true; - else - arrPresence.isAverageDensityArrayPresent = false; - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageVelocityArray3DPtr = block->getKernel()->getDataSet()->getAverageVelocity(); - if (AverageVelocityArray3DPtr) - arrPresence.isAverageVelocityArrayPresent = true; - else - arrPresence.isAverageVelocityArrayPresent = false; - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageFluctArray3DPtr = block->getKernel()->getDataSet()->getAverageFluctuations(); - if (AverageFluctArray3DPtr) - arrPresence.isAverageFluktuationsArrayPresent = true; - else - arrPresence.isAverageFluktuationsArrayPresent = false; - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageTripleArray3DPtr = block->getKernel()->getDataSet()->getAverageTriplecorrelations(); - if (AverageTripleArray3DPtr) - arrPresence.isAverageTripleArrayPresent = true; - else - arrPresence.isAverageTripleArrayPresent = false; - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > ShearStressValArray3DPtr = block->getKernel()->getDataSet()->getShearStressValues(); - if (ShearStressValArray3DPtr) - arrPresence.isShearStressValArrayPresent = true; - else - arrPresence.isShearStressValArrayPresent = false; - - SPtr< CbArray3D<LBMReal, IndexerX3X2X1> > relaxationFactor3DPtr = block->getKernel()->getDataSet()->getRelaxationFactor(); - if (relaxationFactor3DPtr) - arrPresence.isRelaxationFactorPresent = true; - else - arrPresence.isRelaxationFactorPresent = false; - - firstBlock = false; - } - - if (localDistributions && (dataSetParamStr1.nx[0]>0) && (dataSetParamStr1.nx[1]>0) && (dataSetParamStr1.nx[2]>0) && (dataSetParamStr1.nx[3]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), localDistributions->getDataVector().begin(), localDistributions->getDataVector().end()); - if (nonLocalDistributions && (dataSetParamStr2.nx[0]>0) && (dataSetParamStr2.nx[1]>0) && (dataSetParamStr2.nx[2]>0) && (dataSetParamStr2.nx[3]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), nonLocalDistributions->getDataVector().begin(), nonLocalDistributions->getDataVector().end()); - if (zeroDistributions && (dataSetParamStr3.nx[0]>0) && (dataSetParamStr3.nx[1]>0) && (dataSetParamStr3.nx[2]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), zeroDistributions->getDataVector().begin(), zeroDistributions->getDataVector().end()); - - ic++; - } - } - - // register new MPI-types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::writeDataSet start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - // write to the file - // all processes calculate their offsets (quantity of bytes that the process is going to write) - // and notify the next process (with the rank = rank + 1) - MPI_Offset write_offset = (MPI_Offset)(size * sizeof(int)); - size_t next_write_offset = 0; - - if (size>1) - { - if (rank == 0) - { - next_write_offset = write_offset + 3 * sizeof(dataSetParam) + blocksCount * (sizeof(DataSetRestart) + doubleCountInBlock * sizeof(double)); - MPI_Send(&next_write_offset, 1, MPI_LONG_LONG_INT, 1, 5, MPI_COMM_WORLD); - } - else - { - MPI_Recv(&write_offset, 1, MPI_LONG_LONG_INT, rank - 1, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - next_write_offset = write_offset + 3 * sizeof(dataSetParam) + blocksCount * (sizeof(DataSetRestart) + doubleCountInBlock * sizeof(double)); - if (rank<size - 1) - MPI_Send(&next_write_offset, 1, MPI_LONG_LONG_INT, rank + 1, 5, MPI_COMM_WORLD); - } - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - -#ifdef HLRN_LUSTRE - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSet.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // each process writes the quantity of it's blocks - MPI_File_write_at(file_handler, (MPI_Offset)(rank * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, write_offset, &dataSetParamStr1, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(dataSetParam)), &dataSetParamStr2, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + 2 * sizeof(dataSetParam)), &dataSetParamStr3, 1, dataSetParamType, MPI_STATUS_IGNORE); - // each process writes data identifying blocks - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + 3 * sizeof(dataSetParam)), dataSetArray, blocksCount, dataSetType, MPI_STATUS_IGNORE); - // each process writes the dataSet arrays - if (doubleValuesArray.size() > 0) - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + 3 * sizeof(dataSetParam) + blocksCount * sizeof(DataSetRestart)), &doubleValuesArray[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - MPI_Type_free(&dataSetDoubleType); - - delete[] dataSetArray; - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIORestartCoProcessor::writeDataSet time: " << finish - start << " s"); - } - - MPI_File file_handler1; - std::string filename1 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpArrays.bin"; - rc = MPI_File_open(MPI_COMM_WORLD, filename1.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler1); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename1); - MPI_File_write_at(file_handler1, (MPI_Offset)0, &arrPresence, 1, arrayPresenceType, MPI_STATUS_IGNORE); - MPI_File_sync(file_handler1); - MPI_File_close(&file_handler1); - - if (arrPresence.isAverageDensityArrayPresent) - writeAverageDensityArray(step); - - if (arrPresence.isAverageVelocityArrayPresent) - writeAverageVelocityArray(step); - - if (arrPresence.isAverageFluktuationsArrayPresent) - writeAverageFluktuationsArray(step); - - if (arrPresence.isAverageTripleArrayPresent) - writeAverageTripleArray(step); - - if (arrPresence.isShearStressValArrayPresent) - writeShearStressValArray(step); - - if (arrPresence.isRelaxationFactorPresent) - writeRelaxationFactor(step); - -} - -void MPIIORestartCoProcessor::writeAverageDensityArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - DataSetSmallRestart* dataSetSmallArray = new DataSetSmallRestart[blocksCount]; - std::vector<double> doubleValuesArray; // double-values of the AverageDensityArray in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::writeAverageDensityArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetSmallArray[ic].x1 = block->getX1(); // coordinates of the block needed to find it while regenerating the grid - dataSetSmallArray[ic].x2 = block->getX2(); - dataSetSmallArray[ic].x3 = block->getX3(); - dataSetSmallArray[ic].level = block->getLevel(); - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > averageDensityArray = block->getKernel()->getDataSet()->getAverageDensity(); - - if (firstBlock) // when first (any) valid block... - { - //if (averageDensityArray) - //{ - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(averageDensityArray->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(averageDensityArray->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(averageDensityArray->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(averageDensityArray->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - //} - //else - // break; - - firstBlock = false; - } - - if (averageDensityArray && (dataSetParamStr.nx[0] > 0) && (dataSetParamStr.nx[1] > 0) && (dataSetParamStr.nx[2] > 0) && (dataSetParamStr.nx[3] > 0)) - doubleValuesArray.insert(doubleValuesArray.end(), averageDensityArray->getDataVector().begin(), averageDensityArray->getDataVector().end()); - - ic++; - } - } - - // register new MPI-types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::writeAverageDensityArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - // write to the file - // all processes calculate their offsets (quantity of bytes that the process is going to write) - // and notify the next process (with the rank = rank + 1) - MPI_Offset write_offset = (MPI_Offset)(size * sizeof(int)); - size_t next_write_offset = 0; - - if (size > 1) - { - if (rank == 0) - { - next_write_offset = write_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - MPI_Send(&next_write_offset, 1, MPI_LONG_LONG_INT, 1, 5, MPI_COMM_WORLD); - } - else - { - MPI_Recv(&write_offset, 1, MPI_LONG_LONG_INT, rank - 1, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - next_write_offset = write_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - if (rank<size - 1) - MPI_Send(&next_write_offset, 1, MPI_LONG_LONG_INT, rank + 1, 5, MPI_COMM_WORLD); - } - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - -#ifdef HLRN_LUSTRE - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageDensityArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // each process writes the quantity of it's blocks - MPI_File_write_at(file_handler, (MPI_Offset)(rank * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, write_offset, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - // each process writes data identifying blocks - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(dataSetParam)), dataSetSmallArray, blocksCount, dataSetSmallType, MPI_STATUS_IGNORE); - // each process writes the dataSet arrays - if (doubleValuesArray.size() > 0) - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(dataSetParam) + blocksCount * sizeof(DataSetSmallRestart)), &doubleValuesArray[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIORestartCoProcessor::writeAverageDensityArray time: " << finish - start << " s"); - } - - delete[] dataSetSmallArray; -} - -void MPIIORestartCoProcessor::writeAverageVelocityArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - DataSetSmallRestart* dataSetSmallArray = new DataSetSmallRestart[blocksCount]; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::writeAverageVelocityArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetSmallArray[ic].x1 = block->getX1(); // coordinates of the block needed to find it while regenerating the grid - dataSetSmallArray[ic].x2 = block->getX2(); - dataSetSmallArray[ic].x3 = block->getX3(); - dataSetSmallArray[ic].level = block->getLevel(); - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageVelocityArray3DPtr = block->getKernel()->getDataSet()->getAverageVelocity(); - - if (firstBlock) // when first (any) valid block... - { - //if (AverageVelocityArray3DPtr) - //{ - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(AverageVelocityArray3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(AverageVelocityArray3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(AverageVelocityArray3DPtr->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(AverageVelocityArray3DPtr->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - //} - //else - // break; - - firstBlock = false; - } - - if (AverageVelocityArray3DPtr && (dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && (dataSetParamStr.nx[2]>0) && (dataSetParamStr.nx[3]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), AverageVelocityArray3DPtr->getDataVector().begin(), AverageVelocityArray3DPtr->getDataVector().end()); - - ic++; - } - } - - // register new MPI-types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::writeAverageVelocityArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - // write to the file - // all processes calculate their offsets (quantity of bytes that the process is going to write) - // and notify the next process (with the rank = rank + 1) - MPI_Offset write_offset = (MPI_Offset)(size * sizeof(int)); - size_t next_write_offset = 0; - - if (size > 1) - { - if (rank == 0) - { - next_write_offset = write_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - MPI_Send(&next_write_offset, 1, MPI_LONG_LONG_INT, 1, 5, MPI_COMM_WORLD); - } - else - { - MPI_Recv(&write_offset, 1, MPI_LONG_LONG_INT, rank - 1, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - next_write_offset = write_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - if (rank<size - 1) - MPI_Send(&next_write_offset, 1, MPI_LONG_LONG_INT, rank + 1, 5, MPI_COMM_WORLD); - } - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - -#ifdef HLRN_LUSTRE - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageVelocityArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // each process writes the quantity of it's blocks - MPI_File_write_at(file_handler, (MPI_Offset)(rank * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, write_offset, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - // each process writes data identifying blocks - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(dataSetParam)), dataSetSmallArray, blocksCount, dataSetSmallType, MPI_STATUS_IGNORE); - // each process writes the dataSet arrays - if (doubleValuesArray.size() > 0) - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(dataSetParam) + blocksCount * sizeof(DataSetSmallRestart)), &doubleValuesArray[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIORestartCoProcessor::writeAverageVelocityArray time: " << finish - start << " s"); - } - - delete[] dataSetSmallArray; -} - -void MPIIORestartCoProcessor::writeAverageFluktuationsArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - DataSetSmallRestart* dataSetSmallArray = new DataSetSmallRestart[blocksCount]; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::writeAverageFluktuationsArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetSmallArray[ic].x1 = block->getX1(); // coordinates of the block needed to find it while regenerating the grid - dataSetSmallArray[ic].x2 = block->getX2(); - dataSetSmallArray[ic].x3 = block->getX3(); - dataSetSmallArray[ic].level = block->getLevel(); - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageFluctArray3DPtr = block->getKernel()->getDataSet()->getAverageFluctuations(); - - if (firstBlock) // when first (any) valid block... - { - //if (AverageFluctArray3DPtr) - //{ - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(AverageFluctArray3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(AverageFluctArray3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(AverageFluctArray3DPtr->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(AverageFluctArray3DPtr->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - //} - //else - // break; - - firstBlock = false; - } - - if (AverageFluctArray3DPtr && (dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && (dataSetParamStr.nx[2]>0) && (dataSetParamStr.nx[3]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), AverageFluctArray3DPtr->getDataVector().begin(), AverageFluctArray3DPtr->getDataVector().end()); - - ic++; - } - } - - // register new MPI-types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::writeAverageFluktuationsArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - // write to the file - // all processes calculate their offsets (quantity of bytes that the process is going to write) - // and notify the next process (with the rank = rank + 1) - MPI_Offset write_offset = (MPI_Offset)(size * sizeof(int)); - size_t next_write_offset = 0; - - if (size > 1) - { - if (rank == 0) - { - next_write_offset = write_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - MPI_Send(&next_write_offset, 1, MPI_LONG_LONG_INT, 1, 5, MPI_COMM_WORLD); - } - else - { - MPI_Recv(&write_offset, 1, MPI_LONG_LONG_INT, rank - 1, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - next_write_offset = write_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - if (rank<size - 1) - MPI_Send(&next_write_offset, 1, MPI_LONG_LONG_INT, rank + 1, 5, MPI_COMM_WORLD); - } - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - -#ifdef HLRN_LUSTRE - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageFluktuationsArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // each process writes the quantity of it's blocks - MPI_File_write_at(file_handler, (MPI_Offset)(rank * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, write_offset, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - // each process writes data identifying blocks - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(dataSetParam)), dataSetSmallArray, blocksCount, dataSetSmallType, MPI_STATUS_IGNORE); - // each process writes the dataSet arrays - if (doubleValuesArray.size() > 0) - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(dataSetParam) + blocksCount * sizeof(DataSetSmallRestart)), &doubleValuesArray[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIORestartCoProcessor::writeAverageFluktuationsArray time: " << finish - start << " s"); - } - - delete[] dataSetSmallArray; -} - -void MPIIORestartCoProcessor::writeAverageTripleArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - DataSetSmallRestart* dataSetSmallArray = new DataSetSmallRestart[blocksCount]; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::writeAverageTripleArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetSmallArray[ic].x1 = block->getX1(); // coordinates of the block needed to find it while regenerating the grid - dataSetSmallArray[ic].x2 = block->getX2(); - dataSetSmallArray[ic].x3 = block->getX3(); - dataSetSmallArray[ic].level = block->getLevel(); - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > AverageTripleArray3DPtr = block->getKernel()->getDataSet()->getAverageTriplecorrelations(); - - if (firstBlock) // when first (any) valid block... - { - //if (AverageTripleArray3DPtr) - //{ - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(AverageTripleArray3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(AverageTripleArray3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(AverageTripleArray3DPtr->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(AverageTripleArray3DPtr->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - //} - //else - // break; - - firstBlock = false; - } - - if (AverageTripleArray3DPtr && (dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && (dataSetParamStr.nx[2]>0) && (dataSetParamStr.nx[3]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), AverageTripleArray3DPtr->getDataVector().begin(), AverageTripleArray3DPtr->getDataVector().end()); - - ic++; - } - } - - // register new MPI-types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::writeAverageTripleArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - // write to the file - // all processes calculate their offsets (quantity of bytes that the process is going to write) - // and notify the next process (with the rank = rank + 1) - MPI_Offset write_offset = (MPI_Offset)(size * sizeof(int)); - size_t next_write_offset = 0; - - if (size > 1) - { - if (rank == 0) - { - next_write_offset = write_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - MPI_Send(&next_write_offset, 1, MPI_LONG_LONG_INT, 1, 5, MPI_COMM_WORLD); - } - else - { - MPI_Recv(&write_offset, 1, MPI_LONG_LONG_INT, rank - 1, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - next_write_offset = write_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - if (rank<size - 1) - MPI_Send(&next_write_offset, 1, MPI_LONG_LONG_INT, rank + 1, 5, MPI_COMM_WORLD); - } - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - -#ifdef HLRN_LUSTRE - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageTripleArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // each process writes the quantity of it's blocks - MPI_File_write_at(file_handler, (MPI_Offset)(rank * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, write_offset, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - // each process writes data identifying blocks - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(dataSetParam)), dataSetSmallArray, blocksCount, dataSetSmallType, MPI_STATUS_IGNORE); - // each process writes the dataSet arrays - if (doubleValuesArray.size() > 0) - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(dataSetParam) + blocksCount * sizeof(DataSetSmallRestart)), &doubleValuesArray[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIORestartCoProcessor::writeAverageTripleArray time: " << finish - start << " s"); - } - - delete[] dataSetSmallArray; -} - -void MPIIORestartCoProcessor::writeShearStressValArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - DataSetSmallRestart* dataSetSmallArray = new DataSetSmallRestart[blocksCount]; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::writeShearStressValArray start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetSmallArray[ic].x1 = block->getX1(); // coordinates of the block needed to find it while regenerating the grid - dataSetSmallArray[ic].x2 = block->getX2(); - dataSetSmallArray[ic].x3 = block->getX3(); - dataSetSmallArray[ic].level = block->getLevel(); - - SPtr< CbArray4D<LBMReal, IndexerX4X3X2X1> > ShearStressValArray3DPtr = block->getKernel()->getDataSet()->getShearStressValues(); - - if (firstBlock) // when first (any) valid block... - { - //if (ShearStressValArray3DPtr) - //{ - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(ShearStressValArray3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(ShearStressValArray3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(ShearStressValArray3DPtr->getNX3()); - dataSetParamStr.nx[3] = static_cast<int>(ShearStressValArray3DPtr->getNX4()); - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - //} - //else - // break; - - firstBlock = false; - } - - if (ShearStressValArray3DPtr && (dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && (dataSetParamStr.nx[2]>0) && (dataSetParamStr.nx[3]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), ShearStressValArray3DPtr->getDataVector().begin(), ShearStressValArray3DPtr->getDataVector().end()); - - ic++; - } - } - - // register new MPI-types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::writeShearStressValArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - // write to the file - // all processes calculate their offsets (quantity of bytes that the process is going to write) - // and notify the next process (with the rank = rank + 1) - MPI_Offset write_offset = (MPI_Offset)(size * sizeof(int)); - size_t next_write_offset = 0; - - if (size > 1) - { - if (rank == 0) - { - next_write_offset = write_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - MPI_Send(&next_write_offset, 1, MPI_LONG_LONG_INT, 1, 5, MPI_COMM_WORLD); - } - else - { - MPI_Recv(&write_offset, 1, MPI_LONG_LONG_INT, rank - 1, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - next_write_offset = write_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - if (rank<size - 1) - MPI_Send(&next_write_offset, 1, MPI_LONG_LONG_INT, rank + 1, 5, MPI_COMM_WORLD); - } - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - -#ifdef HLRN_LUSTRE - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpShearStressValArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // each process writes the quantity of it's blocks - MPI_File_write_at(file_handler, (MPI_Offset)(rank * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, write_offset, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - // each process writes data identifying blocks - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(dataSetParam)), dataSetSmallArray, blocksCount, dataSetSmallType, MPI_STATUS_IGNORE); - // each process writes the dataSet arrays - if (doubleValuesArray.size() > 0) - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(dataSetParam) + blocksCount * sizeof(DataSetSmallRestart)), &doubleValuesArray[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIORestartCoProcessor::writeShearStressValArray time: " << finish - start << " s"); - } - - delete[] dataSetSmallArray; -} - -void MPIIORestartCoProcessor::writeRelaxationFactor(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - DataSetSmallRestart* dataSetSmallArray = new DataSetSmallRestart[blocksCount]; - std::vector<double> doubleValuesArray; // double-values (arrays of f's) in all blocks - dataSetParam dataSetParamStr; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::writeRelaxationFactor start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - bool firstBlock = true; - int doubleCountInBlock = 0; - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - { - dataSetSmallArray[ic].x1 = block->getX1(); // coordinates of the block needed to find it while regenerating the grid - dataSetSmallArray[ic].x2 = block->getX2(); - dataSetSmallArray[ic].x3 = block->getX3(); - dataSetSmallArray[ic].level = block->getLevel(); - - SPtr< CbArray3D<LBMReal, IndexerX3X2X1> > RelaxationFactor3DPtr = block->getKernel()->getDataSet()->getRelaxationFactor(); - - if (firstBlock) // when first (any) valid block... - { - //if (relaxationFactor3DPtr) - //{ - dataSetParamStr.nx1 = dataSetParamStr.nx2 = dataSetParamStr.nx3 = 0; - dataSetParamStr.nx[0] = static_cast<int>(RelaxationFactor3DPtr->getNX1()); - dataSetParamStr.nx[1] = static_cast<int>(RelaxationFactor3DPtr->getNX2()); - dataSetParamStr.nx[2] = static_cast<int>(RelaxationFactor3DPtr->getNX3()); - dataSetParamStr.nx[3] = 1; - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - //} - //else - // break; - - firstBlock = false; - } - - if (RelaxationFactor3DPtr && (dataSetParamStr.nx[0]>0) && (dataSetParamStr.nx[1]>0) && (dataSetParamStr.nx[2]>0)) - doubleValuesArray.insert(doubleValuesArray.end(), RelaxationFactor3DPtr->getDataVector().begin(), RelaxationFactor3DPtr->getDataVector().end()); - - ic++; - } - } - - // register new MPI-types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::writeRelaxationFactor start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - // write to the file - // all processes calculate their offsets (quantity of bytes that the process is going to write) - // and notify the next process (with the rank = rank + 1) - MPI_Offset write_offset = (MPI_Offset)(size * sizeof(int)); - size_t next_write_offset = 0; - - if (size > 1) - { - if (rank == 0) - { - next_write_offset = write_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - MPI_Send(&next_write_offset, 1, MPI_LONG_LONG_INT, 1, 5, MPI_COMM_WORLD); - } - else - { - MPI_Recv(&write_offset, 1, MPI_LONG_LONG_INT, rank - 1, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - next_write_offset = write_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - if (rank<size - 1) - MPI_Send(&next_write_offset, 1, MPI_LONG_LONG_INT, rank + 1, 5, MPI_COMM_WORLD); - } - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - -#ifdef HLRN_LUSTRE - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpRelaxationFactor.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // each process writes the quantity of it's blocks - MPI_File_write_at(file_handler, (MPI_Offset)(rank * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - // each process writes common parameters of a dataSet - MPI_File_write_at(file_handler, write_offset, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - // each process writes data identifying blocks - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(dataSetParam)), dataSetSmallArray, blocksCount, dataSetSmallType, MPI_STATUS_IGNORE); - // each process writes the dataSet arrays - if (doubleValuesArray.size() > 0) - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + sizeof(dataSetParam) + blocksCount * sizeof(DataSetSmallRestart)), &doubleValuesArray[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIORestartCoProcessor::writeRelaxationFactor time: " << finish - start << " s"); - } - - delete[] dataSetSmallArray; -} - -void MPIIORestartCoProcessor::writeBoundaryConds(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::writeBoundaryConds start collect data rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - int blocksCount = 0; // quantity of blocks in the grid, max 2147483648 blocks! - size_t count_boundCond = 0; // how many BoundaryConditions in all blocks - int count_indexContainer = 0; // how many indexContainer-values in all blocks - size_t byteCount = 0; // how many bytes writes this process in the file - - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, rank, blocksVector[level]); - blocksCount += static_cast<int>(blocksVector[level].size()); - } - - BCAddRestart* bcAddArray = new BCAddRestart[blocksCount]; - std::vector<BoundaryCondition> bcVector; - std::vector<int> bcindexmatrixV; - std::vector<int> indexContainerV; - bool bcindexmatrixCountNotInit = true; - - int ic = 0; - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blocksVector[level]) // all the blocks of the current level - { - SPtr<BCArray3D> bcArr = block->getKernel()->getBCProcessor()->getBCArray(); - - bcAddArray[ic].x1 = block->getX1(); // coordinates of the block needed to find it while regenerating the grid - bcAddArray[ic].x2 = block->getX2(); - bcAddArray[ic].x3 = block->getX3(); - bcAddArray[ic].level = block->getLevel(); - bcAddArray[ic].boundCond_count = 0; // how many BoundaryConditions in this block - bcAddArray[ic].indexContainer_count = 0; // how many indexContainer-values in this block - - for (int bc = 0; bc<bcArr->getBCVectorSize(); bc++) - { - BoundaryCondition* bouCond = new BoundaryCondition(); - if (bcArr->bcvector[bc] == NULL) - { - memset(bouCond, 0, sizeof(BoundaryCondition)); - } - else - { - bouCond->noslipBoundaryFlags = bcArr->bcvector[bc]->getNoSlipBoundary(); - bouCond->slipBoundaryFlags = bcArr->bcvector[bc]->getSlipBoundary(); - bouCond->velocityBoundaryFlags = bcArr->bcvector[bc]->getVelocityBoundary(); - bouCond->densityBoundaryFlags = bcArr->bcvector[bc]->getDensityBoundary(); - bouCond->wallModelBoundaryFlags = bcArr->bcvector[bc]->getWallModelBoundary(); - bouCond->bcVelocityX1 = bcArr->bcvector[bc]->getBoundaryVelocityX1(); - bouCond->bcVelocityX2 = bcArr->bcvector[bc]->getBoundaryVelocityX2(); - bouCond->bcVelocityX3 = bcArr->bcvector[bc]->getBoundaryVelocityX3(); - bouCond->bcDensity = bcArr->bcvector[bc]->getBoundaryDensity(); - bouCond->bcLodiDensity = bcArr->bcvector[bc]->getDensityLodiDensity(); - bouCond->bcLodiVelocityX1 = bcArr->bcvector[bc]->getDensityLodiVelocityX1(); - bouCond->bcLodiVelocityX2 = bcArr->bcvector[bc]->getDensityLodiVelocityX2(); - bouCond->bcLodiVelocityX3 = bcArr->bcvector[bc]->getDensityLodiVelocityX3(); - bouCond->bcLodiLentgh = bcArr->bcvector[bc]->getDensityLodiLength(); - bouCond->nx1 = bcArr->bcvector[bc]->nx1; - bouCond->nx2 = bcArr->bcvector[bc]->nx2; - bouCond->nx3 = bcArr->bcvector[bc]->nx3; - for (int iq = 0; iq<26; iq++) - bouCond->q[iq] = bcArr->bcvector[bc]->getQ(iq); - bouCond->algorithmType = bcArr->bcvector[bc]->getBcAlgorithmType(); - } - - bcVector.push_back(*bouCond); - bcAddArray[ic].boundCond_count++; - count_boundCond++; - } - - // the quantity of elements in the bcindexmatrix array (CbArray3D<int, IndexerX3X2X1>) in bcArray(BCArray3D) is always equal, - // this will be the size of the "write-read-block" in MPI_write_.../MPI_read-functions when writing/reading BoundConds - if (bcindexmatrixCountNotInit) - { - boundCondParamStr.nx1 = static_cast<int>(bcArr->bcindexmatrix.getNX1()); - boundCondParamStr.nx2 = static_cast<int>(bcArr->bcindexmatrix.getNX2()); - boundCondParamStr.nx3 = static_cast<int>(bcArr->bcindexmatrix.getNX3()); - boundCondParamStr.bcindexmatrixCount = static_cast<int>(bcArr->bcindexmatrix.getDataVector().size()); - bcindexmatrixCountNotInit = false; - } - bcindexmatrixV.insert(bcindexmatrixV.end(), bcArr->bcindexmatrix.getDataVector().begin(), bcArr->bcindexmatrix.getDataVector().end()); - - indexContainerV.insert(indexContainerV.end(), bcArr->indexContainer.begin(), bcArr->indexContainer.end()); - bcAddArray[ic].indexContainer_count = static_cast<int>(bcArr->indexContainer.size()); - count_indexContainer += bcAddArray[ic].indexContainer_count; - - ic++; - } - } - - - MPI_Type_contiguous(boundCondParamStr.bcindexmatrixCount, MPI_INT, &bcindexmatrixType); - MPI_Type_commit(&bcindexmatrixType); - - //how many "big blocks" of BLOCK_SIZE size can by formed - int bcBlockCount = (int)(count_boundCond / BLOCK_SIZE); - if (bcBlockCount * BLOCK_SIZE<count_boundCond) - bcBlockCount += 1; - for (int i = (int)count_boundCond; i<bcBlockCount * BLOCK_SIZE; i++) - { - BoundaryCondition* bouCond = new BoundaryCondition(); - memset(bouCond, 0, sizeof(BoundaryCondition)); - bcVector.push_back(*bouCond); - } - - byteCount = bcBlockCount * BLOCK_SIZE * sizeof(BoundaryCondition) + blocksCount * sizeof(BCAddRestart) + sizeof(int) * (blocksCount * boundCondParamStr.bcindexmatrixCount + count_indexContainer); - - // write to the file - // all processes calculate their offsets (quantity of bytes that the process is going to write) - // and notify the next process (with the rank = rank + 1) - MPI_Offset write_offset = (MPI_Offset)(size * (3 * sizeof(int) + sizeof(boundCondParam))); - size_t next_write_offset = 0; - - if (size>1) - { - if (rank == 0) - { - next_write_offset = write_offset + byteCount; - MPI_Send(&next_write_offset, 1, MPI_LONG_LONG_INT, 1, 5, MPI_COMM_WORLD); - } - else - { - MPI_Recv(&write_offset, 1, MPI_LONG_LONG_INT, rank - 1, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - next_write_offset = write_offset + byteCount; - if (rank<size - 1) - MPI_Send(&next_write_offset, 1, MPI_LONG_LONG_INT, rank + 1, 5, MPI_COMM_WORLD); - } - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::writeBoundaryConds start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_Info info = MPI_INFO_NULL; - -#ifdef HLRN_LUSTRE - MPI_Info_create(&info); - MPI_Info_set(info, "striping_factor", "40"); - MPI_Info_set(info, "striping_unit", "4M"); -#endif - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBC.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - MPI_Offset write_offset1 = (MPI_Offset)(rank * (3 * sizeof(int) + sizeof(boundCondParam))); - - // each process writes the quantity of it's blocks - MPI_File_write_at(file_handler, write_offset1, &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - // each process writes the quantity of "big blocks" of BLOCK_SIZE of boundary conditions - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset1 + sizeof(int)), &bcBlockCount, 1, MPI_INT, MPI_STATUS_IGNORE); - // each process writes the quantity of indexContainer elements in all blocks - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset1 + 2 * sizeof(int)), &count_indexContainer, 1, MPI_INT, MPI_STATUS_IGNORE); - // each process writes the quantity of bcindexmatrix elements in every block - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset1 + 3 * sizeof(int)), &boundCondParamStr, 1, boundCondParamType, MPI_STATUS_IGNORE); - - // each process writes data identifying the blocks - MPI_File_write_at(file_handler, write_offset, bcAddArray, blocksCount, boundCondTypeAdd, MPI_STATUS_IGNORE); - // each process writes boundary conditions - if (bcVector.size()>0) - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + blocksCount * sizeof(BCAddRestart)), &bcVector[0], bcBlockCount, boundCondType1000, MPI_STATUS_IGNORE); - // each process writes bcindexmatrix values - if (bcindexmatrixV.size()>0) - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + blocksCount * sizeof(BCAddRestart) + bcBlockCount*BLOCK_SIZE * sizeof(BoundaryCondition)), &bcindexmatrixV[0], blocksCount, bcindexmatrixType, MPI_STATUS_IGNORE); - // each process writes indexContainer values - if (indexContainerV.size()>0) - MPI_File_write_at(file_handler, (MPI_Offset)(write_offset + blocksCount * sizeof(BCAddRestart) + bcBlockCount*BLOCK_SIZE * sizeof(BoundaryCondition) + blocksCount*boundCondParamStr.bcindexmatrixCount * sizeof(int)), &indexContainerV[0], count_indexContainer, MPI_INT, MPI_STATUS_IGNORE); - - MPI_File_sync(file_handler); - MPI_File_close(&file_handler); - - MPI_Type_free(&bcindexmatrixType); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIORestartCoProcessor::writeBoundaryConds time: " << finish - start << " s"); - } - - delete[] bcAddArray; -} - -//------------------------------------------- READ ----------------------------------------------- -void MPIIORestartCoProcessor::restart(int step) -{ - if (comm->isRoot()) UBLOG(logINFO, "MPIIORestartCoProcessor restart step: " << step); - if (comm->isRoot()) UBLOG(logINFO, "Load check point - start"); - - readBlocks(step); - readDataSet(step); - readBoundaryConds(step); - - grid->setTimeStep(step); - - if (comm->isRoot()) UBLOG(logINFO, "Load check point - end"); -} - -void MPIIORestartCoProcessor::readBlocks(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - //MPI_Comm_size(MPI_COMM_WORLD, &size); - size = 1; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::readBlocks start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBlocks.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - int blocksCount = 0; - //MPI_File_read_at(file_handler, rank*sizeof(int), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, 0, &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - Block3d* block3dArray = new Block3d[blocksCount]; - - // calculate the read offset - MPI_Offset read_offset = (MPI_Offset)(size * sizeof(int)); - - GridParam* gridParameters = new GridParam; - - // read parameters of the grid - MPI_File_read_at(file_handler, read_offset, gridParameters, 1, gridParamType, MPI_STATUS_IGNORE); - // read all the blocks - if (comm->isRoot()) - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(GridParam)), &block3dArray[0], blocksCount, block3dType, MPI_STATUS_IGNORE); - - MPI_Bcast(block3dArray, blocksCount, block3dType, comm->getRoot(), MPI_COMM_WORLD); - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIORestartCoProcessor::readBlocks time: " << finish - start << " s"); - } - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::readBlocks start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - // clear the grid - grid->deleteBlocks(); - - // restore the grid - SPtr<CoordinateTransformation3D> trafo(new CoordinateTransformation3D()); - trafo->Tx1 = gridParameters->trafoParams[0]; - trafo->Tx2 = gridParameters->trafoParams[1]; - trafo->Tx3 = gridParameters->trafoParams[2]; - trafo->Sx1 = gridParameters->trafoParams[3]; - trafo->Sx2 = gridParameters->trafoParams[4]; - trafo->Sx3 = gridParameters->trafoParams[5]; - trafo->alpha = gridParameters->trafoParams[6]; - trafo->beta = gridParameters->trafoParams[7]; - trafo->gamma = gridParameters->trafoParams[8]; - - trafo->toX1factorX1 = gridParameters->trafoParams[9]; - trafo->toX1factorX2 = gridParameters->trafoParams[10]; - trafo->toX1factorX3 = gridParameters->trafoParams[11]; - trafo->toX1delta = gridParameters->trafoParams[12]; - trafo->toX2factorX1 = gridParameters->trafoParams[13]; - trafo->toX2factorX2 = gridParameters->trafoParams[14]; - trafo->toX2factorX3 = gridParameters->trafoParams[15]; - trafo->toX2delta = gridParameters->trafoParams[16]; - trafo->toX3factorX1 = gridParameters->trafoParams[17]; - trafo->toX3factorX2 = gridParameters->trafoParams[18]; - trafo->toX3factorX3 = gridParameters->trafoParams[19]; - trafo->toX3delta = gridParameters->trafoParams[20]; - - trafo->fromX1factorX1 = gridParameters->trafoParams[21]; - trafo->fromX1factorX2 = gridParameters->trafoParams[22]; - trafo->fromX1factorX3 = gridParameters->trafoParams[23]; - trafo->fromX1delta = gridParameters->trafoParams[24]; - trafo->fromX2factorX1 = gridParameters->trafoParams[25]; - trafo->fromX2factorX2 = gridParameters->trafoParams[26]; - trafo->fromX2factorX3 = gridParameters->trafoParams[27]; - trafo->fromX2delta = gridParameters->trafoParams[28]; - trafo->fromX3factorX1 = gridParameters->trafoParams[29]; - trafo->fromX3factorX2 = gridParameters->trafoParams[30]; - trafo->fromX3factorX3 = gridParameters->trafoParams[31]; - trafo->fromX3delta = gridParameters->trafoParams[32]; - trafo->active = gridParameters->active; - trafo->transformation = gridParameters->transformation; - - grid->setCoordinateTransformator(trafo); - - grid->setDeltaX(gridParameters->deltaX); - grid->setBlockNX(gridParameters->blockNx1, gridParameters->blockNx2, gridParameters->blockNx3); - grid->setNX1(gridParameters->nx1); - grid->setNX2(gridParameters->nx2); - grid->setNX3(gridParameters->nx3); - grid->setPeriodicX1(gridParameters->periodicX1); - grid->setPeriodicX2(gridParameters->periodicX2); - grid->setPeriodicX3(gridParameters->periodicX3); - - // regenerate blocks - for (int n = 0; n<blocksCount; n++) - { - SPtr<Block3D> block(new Block3D(block3dArray[n].x1, block3dArray[n].x2, block3dArray[n].x3, block3dArray[n].level)); - block->setActive(block3dArray[n].active); - block->setBundle(block3dArray[n].bundle); - block->setRank(block3dArray[n].rank); - block->setLocalRank(block3dArray[n].lrank); - block->setGlobalID(block3dArray[n].globalID); - block->setLocalID(block3dArray[n].localID); - block->setPart(block3dArray[n].part); - block->setLevel(block3dArray[n].level); - block->setCollectionOfInterpolationFlagCF(block3dArray[n].interpolationFlagCF); - block->setCollectionOfInterpolationFlagFC(block3dArray[n].interpolationFlagFC); - - grid->addBlock(block); - } - - delete gridParameters; - delete[] block3dArray; - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::readBlocks end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } -} - -void MPIIORestartCoProcessor::readDataSet(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::readDataSet start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSet.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // calculate the read offset - MPI_Offset read_offset = (MPI_Offset)(size * sizeof(int)); - size_t next_read_offset = 0; - - // read count of blocks - int blocksCount = 0; - dataSetParam dataSetParamStr1, dataSetParamStr2, dataSetParamStr3; - - MPI_File_read_at(file_handler, (MPI_Offset)(rank * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, read_offset, &dataSetParamStr1, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(dataSetParam)), &dataSetParamStr2, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + 2 * sizeof(dataSetParam)), &dataSetParamStr3, 1, dataSetParamType, MPI_STATUS_IGNORE); - - DataSetRestart* dataSetArray = new DataSetRestart[blocksCount]; - double doubleCountInBlock = dataSetParamStr1.nx[0] * dataSetParamStr1.nx[1] * dataSetParamStr1.nx[2] * dataSetParamStr1.nx[3] + - dataSetParamStr2.nx[0] * dataSetParamStr2.nx[1] * dataSetParamStr2.nx[2] * dataSetParamStr2.nx[3] + - dataSetParamStr3.nx[0] * dataSetParamStr3.nx[1] * dataSetParamStr3.nx[2] * dataSetParamStr3.nx[3]; - std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - if (size > 1) - { - if (rank == 0) - { - next_read_offset = read_offset + 3 * sizeof(dataSetParam) + blocksCount * (sizeof(DataSetRestart) + doubleCountInBlock * sizeof(double)); - MPI_Send(&next_read_offset, 1, MPI_LONG_LONG_INT, 1, 5, MPI_COMM_WORLD); - } - else - { - MPI_Recv(&read_offset, 1, MPI_LONG_LONG_INT, rank - 1, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - next_read_offset = read_offset + 3 * sizeof(dataSetParam) + blocksCount * (sizeof(DataSetRestart) + doubleCountInBlock * sizeof(double)); - if (rank < size - 1) - MPI_Send(&next_read_offset, 1, MPI_LONG_LONG_INT, rank + 1, 5, MPI_COMM_WORLD); - } - } - - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + 3 * sizeof(dataSetParam)), dataSetArray, blocksCount, dataSetType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + 3 * sizeof(dataSetParam) + blocksCount * sizeof(DataSetRestart)), &doubleValuesArray[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIORestartCoProcessor::readDataSet time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIORestartCoProcessor::readDataSet start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - size_t index = 0, vectorSize = 0; - std::vector<double> vectorsOfValues1, vectorsOfValues2, vectorsOfValues3; - - for (int n = 0; n < blocksCount; n++) - { - vectorSize = dataSetParamStr1.nx[0] * dataSetParamStr1.nx[1] * dataSetParamStr1.nx[2] * dataSetParamStr1.nx[3]; - vectorsOfValues1.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + vectorSize); - index += vectorSize; - - vectorSize = dataSetParamStr2.nx[0] * dataSetParamStr2.nx[1] * dataSetParamStr2.nx[2] * dataSetParamStr2.nx[3]; - vectorsOfValues2.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + vectorSize); - index += vectorSize; - - vectorSize = dataSetParamStr3.nx[0] * dataSetParamStr3.nx[1] * dataSetParamStr3.nx[2] * dataSetParamStr3.nx[3]; - vectorsOfValues3.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + vectorSize); - index += vectorSize; - - SPtr<DistributionArray3D> mFdistributions(new D3Q27EsoTwist3DSplittedVector()); - - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues1, dataSetParamStr1.nx[0], dataSetParamStr1.nx[1], dataSetParamStr1.nx[2], dataSetParamStr1.nx[3]))); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setNonLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues2, dataSetParamStr2.nx[0], dataSetParamStr2.nx[1], dataSetParamStr2.nx[2], dataSetParamStr2.nx[3]))); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setZeroDistributions(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>(vectorsOfValues3, dataSetParamStr3.nx[0], dataSetParamStr3.nx[1], dataSetParamStr3.nx[2]))); - - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setNX1(dataSetParamStr1.nx1); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setNX2(dataSetParamStr1.nx2); - dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(mFdistributions)->setNX3(dataSetParamStr1.nx3); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetArray[n].x1, dataSetArray[n].x2, dataSetArray[n].x3, dataSetArray[n].level); - this->lbmKernel->setBlock(block); - SPtr<LBMKernel> kernel = this->lbmKernel->clone(); - kernel->setGhostLayerWidth(dataSetArray[n].ghostLayerWidth); - kernel->setCollisionFactor(dataSetArray[n].collFactor); - kernel->setDeltaT(dataSetArray[n].deltaT); - kernel->setCompressible(dataSetArray[n].compressible); - kernel->setWithForcing(dataSetArray[n].withForcing); - SPtr<DataSet3D> dataSetPtr = SPtr<DataSet3D>(new DataSet3D()); - dataSetPtr->setFdistributions(mFdistributions); - kernel->setDataSet(dataSetPtr); - block->setKernel(kernel); - } - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::readDataSet end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - delete[] dataSetArray; - - //------------------------------------------------------------- - - DSArraysPresence arrPresence; - MPI_File file_handler1; - std::string filename1 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpArrays.bin"; - rc = MPI_File_open(MPI_COMM_WORLD, filename1.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler1); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename1); - MPI_File_read_at(file_handler1, (MPI_Offset)0, &arrPresence, 1, arrayPresenceType, MPI_STATUS_IGNORE); - MPI_File_close(&file_handler1); - - if (arrPresence.isAverageDensityArrayPresent) - readAverageDensityArray(step); - - if (arrPresence.isAverageVelocityArrayPresent) - readAverageVelocityArray(step); - - if (arrPresence.isAverageFluktuationsArrayPresent) - readAverageFluktuationsArray(step); - - if (arrPresence.isAverageTripleArrayPresent) - readAverageTripleArray(step); - - if (arrPresence.isShearStressValArrayPresent) - readShearStressValArray(step); - - if (arrPresence.isRelaxationFactorPresent) - readRelaxationFactor(step); - -} - -void MPIIORestartCoProcessor::readAverageDensityArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageDensityArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageDensityArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - int blocksCount = 0; - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - - MPI_File_read_at(file_handler, (MPI_Offset)(rank * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(size * sizeof(int)), &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - DataSetSmallRestart* dataSetSmallArray = new DataSetSmallRestart[blocksCount]; - int doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - // calculate the read offset - MPI_Offset read_offset = (MPI_Offset)(size * sizeof(int)); - size_t next_read_offset = 0; - - if (size > 1) - { - if (rank == 0) - { - next_read_offset = read_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - MPI_Send(&next_read_offset, 1, MPI_LONG_LONG_INT, 1, 5, MPI_COMM_WORLD); - } - else - { - MPI_Recv(&read_offset, 1, MPI_LONG_LONG_INT, rank - 1, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - next_read_offset = read_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - if (rank < size - 1) - MPI_Send(&next_read_offset, 1, MPI_LONG_LONG_INT, rank + 1, 5, MPI_COMM_WORLD); - } - } - - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(dataSetParam)), dataSetSmallArray, blocksCount, dataSetSmallType, MPI_STATUS_IGNORE); - if (doubleCountInBlock > 0) - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(dataSetParam) + blocksCount * sizeof(DataSetSmallRestart)), &doubleValuesArray[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageDensityArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageDensityArray start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - size_t index = 0; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> vectorsOfValues; - for (int n = 0; n < blocksCount; n++) - { - vectorsOfValues.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + nextVectorSize); - index += nextVectorSize; - - // fill mAverageDensity arrays - SPtr<AverageValuesArray3D> mAverageDensity; - //if ((dataSetParamStr.nx[0]==0)&&(dataSetParamStr.nx[1]==0)&&(dataSetParamStr.nx[2]==0)&&(dataSetParamStr.nx[3]==0)) - // mAverageDensity = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(); - //else - mAverageDensity = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], dataSetParamStr.nx[3])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetSmallArray[n].x1, dataSetSmallArray[n].x2, dataSetSmallArray[n].x3, dataSetSmallArray[n].level); - block->getKernel()->getDataSet()->setAverageDensity(mAverageDensity); - } - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageDensityArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - delete[] dataSetSmallArray; -} - -void MPIIORestartCoProcessor::readAverageVelocityArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageVelocityArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageVelocityArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - int blocksCount = 0; - dataSetParam dataSetParamStr; - MPI_File_read_at(file_handler, (MPI_Offset)(rank * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(size * sizeof(int)), &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - DataSetSmallRestart* dataSetSmallArray = new DataSetSmallRestart[blocksCount]; - int doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - // calculate the read offset - MPI_Offset read_offset = (MPI_Offset)(size * sizeof(int)); - size_t next_read_offset = 0; - - if (size > 1) - { - if (rank == 0) - { - next_read_offset = read_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - MPI_Send(&next_read_offset, 1, MPI_LONG_LONG_INT, 1, 5, MPI_COMM_WORLD); - } - else - { - MPI_Recv(&read_offset, 1, MPI_LONG_LONG_INT, rank - 1, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - next_read_offset = read_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - if (rank < size - 1) - MPI_Send(&next_read_offset, 1, MPI_LONG_LONG_INT, rank + 1, 5, MPI_COMM_WORLD); - } - } - - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(dataSetParam)), dataSetSmallArray, blocksCount, dataSetSmallType, MPI_STATUS_IGNORE); - if (doubleCountInBlock > 0) - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(dataSetParam) + blocksCount * sizeof(DataSetSmallRestart)), &doubleValuesArray[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageVelocityArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageVelocityArray start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - size_t index = 0; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> vectorsOfValues; - for (int n = 0; n < blocksCount; n++) - { - vectorsOfValues.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + nextVectorSize); - index += nextVectorSize; - - // fill mAverageVelocity array - SPtr<AverageValuesArray3D> mAverageVelocity; - //if ((dataSetParamStr.nx[0] == 0) && (dataSetParamStr.nx[1] == 0) && (dataSetParamStr.nx[2] == 0) && (dataSetParamStr.nx[3] == 0)) - // mAverageVelocity = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(); - //else - mAverageVelocity = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], dataSetParamStr.nx[3])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetSmallArray[n].x1, dataSetSmallArray[n].x2, dataSetSmallArray[n].x3, dataSetSmallArray[n].level); - block->getKernel()->getDataSet()->setAverageVelocity(mAverageVelocity); - } - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageVelocityArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - delete[] dataSetSmallArray; -} - -void MPIIORestartCoProcessor::readAverageFluktuationsArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageFluktuationsArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageFluktuationsArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - int blocksCount = 0; - dataSetParam dataSetParamStr; - MPI_File_read_at(file_handler, (MPI_Offset)(rank * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(size * sizeof(int)), &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - DataSetSmallRestart* dataSetSmallArray = new DataSetSmallRestart[blocksCount]; - int doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - // calculate the read offset - MPI_Offset read_offset = (MPI_Offset)(size * sizeof(int)); - size_t next_read_offset = 0; - - if (size > 1) - { - if (rank == 0) - { - next_read_offset = read_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - MPI_Send(&next_read_offset, 1, MPI_LONG_LONG_INT, 1, 5, MPI_COMM_WORLD); - } - else - { - MPI_Recv(&read_offset, 1, MPI_LONG_LONG_INT, rank - 1, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - next_read_offset = read_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - if (rank < size - 1) - MPI_Send(&next_read_offset, 1, MPI_LONG_LONG_INT, rank + 1, 5, MPI_COMM_WORLD); - } - } - - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(dataSetParam)), dataSetSmallArray, blocksCount, dataSetSmallType, MPI_STATUS_IGNORE); - if (doubleCountInBlock > 0) - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(dataSetParam) + blocksCount * sizeof(DataSetSmallRestart)), &doubleValuesArray[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageFluktuationsArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageFluktuationsArray start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - size_t index = 0; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> vectorsOfValues; - for (int n = 0; n < blocksCount; n++) - { - vectorsOfValues.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + nextVectorSize); - index += nextVectorSize; - - // fill AverageFluktuations array - SPtr<AverageValuesArray3D> mAverageFluktuations; - //if ((dataSetParamStr.nx[0] == 0) && (dataSetParamStr.nx[1] == 0) && (dataSetParamStr.nx[2] == 0) && (dataSetParamStr.nx[3] == 0)) - // mAverageFluktuations = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(); - //else - mAverageFluktuations = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], dataSetParamStr.nx[3])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetSmallArray[n].x1, dataSetSmallArray[n].x2, dataSetSmallArray[n].x3, dataSetSmallArray[n].level); - block->getKernel()->getDataSet()->setAverageFluctuations(mAverageFluktuations); - } - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageFluktuationsArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - delete[] dataSetSmallArray; -} - -void MPIIORestartCoProcessor::readAverageTripleArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageTripleArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpAverageTripleArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - int blocksCount = 0; - dataSetParam dataSetParamStr; - MPI_File_read_at(file_handler, (MPI_Offset)(rank * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(size * sizeof(int)), &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - DataSetSmallRestart* dataSetSmallArray = new DataSetSmallRestart[blocksCount]; - int doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - // calculate the read offset - MPI_Offset read_offset = (MPI_Offset)(size * sizeof(int)); - size_t next_read_offset = 0; - - if (size > 1) - { - if (rank == 0) - { - next_read_offset = read_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - MPI_Send(&next_read_offset, 1, MPI_LONG_LONG_INT, 1, 5, MPI_COMM_WORLD); - } - else - { - MPI_Recv(&read_offset, 1, MPI_LONG_LONG_INT, rank - 1, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - next_read_offset = read_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - if (rank < size - 1) - MPI_Send(&next_read_offset, 1, MPI_LONG_LONG_INT, rank + 1, 5, MPI_COMM_WORLD); - } - } - - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(dataSetParam)), dataSetSmallArray, blocksCount, dataSetSmallType, MPI_STATUS_IGNORE); - if (doubleCountInBlock > 0) - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(dataSetParam) + blocksCount * sizeof(DataSetSmallRestart)), &doubleValuesArray[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageTripleArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageTripleArray start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - size_t index = 0; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> vectorsOfValues; - for (int n = 0; n < blocksCount; n++) - { - vectorsOfValues.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + nextVectorSize); - index += nextVectorSize; - - // fill AverageTriplecorrelations array - SPtr<AverageValuesArray3D> mAverageTriplecorrelations; - //if ((dataSetParamStr.nx[0] == 0) && (dataSetParamStr.nx[1] == 0) && (dataSetParamStr.nx[2] == 0) && (dataSetParamStr.nx[3] == 0)) - // mAverageTriplecorrelations = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(); - //else - mAverageTriplecorrelations = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], dataSetParamStr.nx[3])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetSmallArray[n].x1, dataSetSmallArray[n].x2, dataSetSmallArray[n].x3, dataSetSmallArray[n].level); - block->getKernel()->getDataSet()->setAverageTriplecorrelations(mAverageTriplecorrelations); - } - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::readAverageTripleArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - delete[] dataSetSmallArray; -} - -void MPIIORestartCoProcessor::readShearStressValArray(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::readShearStressValArray start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpShearStressValArray.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - int blocksCount = 0; - dataSetParam dataSetParamStr; - MPI_File_read_at(file_handler, (MPI_Offset)(rank * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(size * sizeof(int)), &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - DataSetSmallRestart* dataSetSmallArray = new DataSetSmallRestart[blocksCount]; - int doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - // calculate the read offset - MPI_Offset read_offset = (MPI_Offset)(size * sizeof(int)); - size_t next_read_offset = 0; - - if (size > 1) - { - if (rank == 0) - { - next_read_offset = read_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - MPI_Send(&next_read_offset, 1, MPI_LONG_LONG_INT, 1, 5, MPI_COMM_WORLD); - } - else - { - MPI_Recv(&read_offset, 1, MPI_LONG_LONG_INT, rank - 1, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - next_read_offset = read_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - if (rank < size - 1) - MPI_Send(&next_read_offset, 1, MPI_LONG_LONG_INT, rank + 1, 5, MPI_COMM_WORLD); - } - } - - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(dataSetParam)), dataSetSmallArray, blocksCount, dataSetSmallType, MPI_STATUS_IGNORE); - if (doubleCountInBlock > 0) - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(dataSetParam) + blocksCount * sizeof(DataSetSmallRestart)), &doubleValuesArray[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIORestartCoProcessor::readShearStressValArray time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIORestartCoProcessor::readShearStressValArray start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - size_t index = 0; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> vectorsOfValues; - for (int n = 0; n < blocksCount; n++) - { - vectorsOfValues.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + nextVectorSize); - index += nextVectorSize; - - // fill ShearStressValuesArray array - SPtr<ShearStressValuesArray3D> mShearStressValues; - //if ((dataSetParamStr.nx[0] == 0) && (dataSetParamStr.nx[1] == 0) && (dataSetParamStr.nx[2] == 0) && (dataSetParamStr.nx[3] == 0)) - // mShearStressValues = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(); - //else - mShearStressValues = CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal, IndexerX4X3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2], dataSetParamStr.nx[3])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetSmallArray[n].x1, dataSetSmallArray[n].x2, dataSetSmallArray[n].x3, dataSetSmallArray[n].level); - block->getKernel()->getDataSet()->setShearStressValues(mShearStressValues); - } - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::readShearStressValArray end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - delete[] dataSetSmallArray; -} - -void MPIIORestartCoProcessor::readRelaxationFactor(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::readRelaxationFactor start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpRelaxationFactor.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - // read count of blocks - int blocksCount = 0; - dataSetParam dataSetParamStr; - MPI_File_read_at(file_handler, (MPI_Offset)(rank * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(size * sizeof(int)), &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - DataSetSmallRestart* dataSetSmallArray = new DataSetSmallRestart[blocksCount]; - int doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> doubleValuesArray(blocksCount * doubleCountInBlock); // double-values in all blocks - - // define MPI_types depending on the block-specific information - MPI_Type_contiguous(doubleCountInBlock, MPI_DOUBLE, &dataSetDoubleType); - MPI_Type_commit(&dataSetDoubleType); - - // calculate the read offset - MPI_Offset read_offset = (MPI_Offset)(size * sizeof(int)); - size_t next_read_offset = 0; - - if (size > 1) - { - if (rank == 0) - { - next_read_offset = read_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - MPI_Send(&next_read_offset, 1, MPI_LONG_LONG_INT, 1, 5, MPI_COMM_WORLD); - } - else - { - MPI_Recv(&read_offset, 1, MPI_LONG_LONG_INT, rank - 1, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - next_read_offset = read_offset + sizeof(dataSetParam) + blocksCount*(sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - if (rank < size - 1) - MPI_Send(&next_read_offset, 1, MPI_LONG_LONG_INT, rank + 1, 5, MPI_COMM_WORLD); - } - } - - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(dataSetParam)), dataSetSmallArray, blocksCount, dataSetSmallType, MPI_STATUS_IGNORE); - if (doubleCountInBlock > 0) - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + sizeof(dataSetParam) + blocksCount * sizeof(DataSetSmallRestart)), &doubleValuesArray[0], blocksCount, dataSetDoubleType, MPI_STATUS_IGNORE); - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIORestartCoProcessor::readRelaxationFactor time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIORestartCoProcessor::readRelaxationFactor start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - size_t index = 0; - size_t nextVectorSize = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - std::vector<double> vectorsOfValues; - for (int n = 0; n < blocksCount; n++) - { - vectorsOfValues.assign(doubleValuesArray.data() + index, doubleValuesArray.data() + index + nextVectorSize); - index += nextVectorSize; - - // fill RelaxationFactor array - SPtr<RelaxationFactorArray3D> mRelaxationFactor; - //if ((dataSetParamStr.nx[0] == 0) && (dataSetParamStr.nx[1] == 0) && (dataSetParamStr.nx[2] == 0)) - // mRelaxationFactor = CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(); - //else - mRelaxationFactor = CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>(vectorsOfValues, dataSetParamStr.nx[0], dataSetParamStr.nx[1], dataSetParamStr.nx[2])); - - // find the nesessary block and fill it - SPtr<Block3D> block = grid->getBlock(dataSetSmallArray[n].x1, dataSetSmallArray[n].x2, dataSetSmallArray[n].x3, dataSetSmallArray[n].level); - block->getKernel()->getDataSet()->setRelaxationFactor(mRelaxationFactor); - } - - MPI_Type_free(&dataSetDoubleType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::readRelaxationFactor end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - delete[] dataSetSmallArray; -} - -void MPIIORestartCoProcessor::readBoundaryConds(int step) -{ - int rank, size; - MPI_Comm_rank(MPI_COMM_WORLD, &rank); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::readBoundaryConds start MPI IO rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handler; - std::string filename = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBC.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename); - - int blocksCount = 0; - int dataCount1000 = 0; - int dataCount2 = 0; - MPI_Offset read_offset1 = (MPI_Offset)(rank * (3 * sizeof(int) + sizeof(boundCondParam))); - - // read count of blocks - MPI_File_read_at(file_handler, read_offset1, &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - // read count of big BoundaryCondition blocks - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset1 + sizeof(int)), &dataCount1000, 1, MPI_INT, MPI_STATUS_IGNORE); - // read count of indexContainer values in all blocks - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset1 + 2 * sizeof(int)), &dataCount2, 1, MPI_INT, MPI_STATUS_IGNORE); - // read count of bcindexmatrix values in every block - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset1 + 3 * sizeof(int)), &boundCondParamStr, 1, boundCondParamType, MPI_STATUS_IGNORE); - - MPI_Type_contiguous(boundCondParamStr.bcindexmatrixCount, MPI_INT, &bcindexmatrixType); - MPI_Type_commit(&bcindexmatrixType); - - size_t dataCount = dataCount1000 * BLOCK_SIZE; - BCAddRestart* bcAddArray = new BCAddRestart[blocksCount]; - BoundaryCondition* bcArray = new BoundaryCondition[dataCount]; - BoundaryCondition* nullBouCond = new BoundaryCondition(); - memset(nullBouCond, 0, sizeof(BoundaryCondition)); - int* intArray1 = new int[blocksCount * boundCondParamStr.bcindexmatrixCount]; - int* intArray2 = new int[dataCount2]; - - MPI_Offset read_offset = (MPI_Offset)(size * (3 * sizeof(int) + sizeof(boundCondParam))); - size_t next_read_offset = 0; - - if (size>1) - { - if (rank == 0) - { - next_read_offset = read_offset + blocksCount * sizeof(BCAddRestart) + dataCount * sizeof(BoundaryCondition) + (blocksCount * boundCondParamStr.bcindexmatrixCount + dataCount2) * sizeof(int); - MPI_Send(&next_read_offset, 1, MPI_LONG_LONG_INT, 1, 5, MPI_COMM_WORLD); - } - else - { - MPI_Recv(&read_offset, 1, MPI_LONG_LONG_INT, rank - 1, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - next_read_offset = read_offset + blocksCount * sizeof(BCAddRestart) + dataCount * sizeof(BoundaryCondition) + (blocksCount * boundCondParamStr.bcindexmatrixCount + dataCount2) * sizeof(int); - if (rank<size - 1) - MPI_Send(&next_read_offset, 1, MPI_LONG_LONG_INT, rank + 1, 5, MPI_COMM_WORLD); - } - } - - MPI_File_read_at(file_handler, read_offset, bcAddArray, blocksCount, boundCondTypeAdd, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + blocksCount * sizeof(BCAddRestart)), &bcArray[0], dataCount1000, boundCondType1000, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + blocksCount * sizeof(BCAddRestart) + dataCount * sizeof(BoundaryCondition)), &intArray1[0], blocksCount, bcindexmatrixType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handler, (MPI_Offset)(read_offset + blocksCount * sizeof(BCAddRestart) + dataCount * sizeof(BoundaryCondition) + blocksCount * boundCondParamStr.bcindexmatrixCount * sizeof(int)), &intArray2[0], dataCount2, MPI_INT, MPI_STATUS_IGNORE); - - MPI_File_close(&file_handler); - - if (comm->isRoot()) - { - finish = MPI_Wtime(); - UBLOG(logINFO, "MPIIORestartCoProcessor::readBoundaryConds time: " << finish - start << " s"); - UBLOG(logINFO, "MPIIORestartCoProcessor::readBoundaryConds start of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } - - int index = 0, index1 = 0, index2 = 0; - std::vector<SPtr<BoundaryConditions>> bcVector; - std::vector<int> bcindexmatrixV; - std::vector<int> indexContainerV; - - for (size_t n = 0; n<blocksCount; n++) - { - bcVector.resize(0); - bcindexmatrixV.resize(0); - indexContainerV.resize(0); - - for (size_t ibc = 0; ibc<bcAddArray[n].boundCond_count; ibc++) - { - SPtr<BoundaryConditions> bc; - if (memcmp(&bcArray[index], nullBouCond, sizeof(BoundaryCondition)) == 0) - bc = SPtr<BoundaryConditions>(); - else - { - bc = SPtr<BoundaryConditions>(new BoundaryConditions); - bc->noslipBoundaryFlags = bcArray[index].noslipBoundaryFlags; - bc->slipBoundaryFlags = bcArray[index].slipBoundaryFlags; - bc->densityBoundaryFlags = bcArray[index].densityBoundaryFlags; - bc->velocityBoundaryFlags = bcArray[index].velocityBoundaryFlags; - bc->wallModelBoundaryFlags = bcArray[index].wallModelBoundaryFlags; - bc->bcVelocityX1 = bcArray[index].bcVelocityX1; - bc->bcVelocityX2 = bcArray[index].bcVelocityX2; - bc->bcVelocityX3 = bcArray[index].bcVelocityX3; - bc->bcDensity = bcArray[index].bcDensity; - bc->bcLodiDensity = bcArray[index].bcLodiDensity; - bc->bcLodiVelocityX1 = bcArray[index].bcLodiVelocityX1; - bc->bcLodiVelocityX2 = bcArray[index].bcLodiVelocityX2; - bc->bcLodiVelocityX3 = bcArray[index].bcLodiVelocityX3; - bc->bcLodiLentgh = bcArray[index].bcLodiLentgh; - - bc->nx1 = bcArray[index].nx1; - bc->nx2 = bcArray[index].nx2; - bc->nx3 = bcArray[index].nx3; - for (int iq = 0; iq<26; iq++) - bc->setQ(bcArray[index].q[iq], iq); - bc->setBcAlgorithmType(bcArray[index].algorithmType); - } - - bcVector.push_back(bc); - index++; - } - - for (int b1 = 0; b1 < boundCondParamStr.bcindexmatrixCount; b1++) - bcindexmatrixV.push_back(intArray1[index1++]); - - for (int b2 = 0; b2 < bcAddArray[n].indexContainer_count; b2++) - indexContainerV.push_back(intArray2[index2++]); - - CbArray3D<int, IndexerX3X2X1> bcim(bcindexmatrixV, boundCondParamStr.nx1, boundCondParamStr.nx2, boundCondParamStr.nx3); - - SPtr<Block3D> block = grid->getBlock(bcAddArray[n].x1, bcAddArray[n].x2, bcAddArray[n].x3, bcAddArray[n].level); - SPtr<BCProcessor> bcProc = bcProcessor->clone(block->getKernel()); - SPtr<BCArray3D> bcArr(new BCArray3D()); - bcArr->bcindexmatrix = bcim; - bcArr->bcvector = bcVector; - bcArr->indexContainer = indexContainerV; - bcProc->setBCArray(bcArr); - - block->getKernel()->setBCProcessor(bcProc); - } - - delete nullBouCond; - delete[] bcArray; - delete[] bcAddArray; - delete[] intArray1; - delete[] intArray2; - - MPI_Type_free(&bcindexmatrixType); - - if (comm->isRoot()) - { - UBLOG(logINFO, "MPIIORestartCoProcessor::readBoundaryConds end of restore of data, rank = " << rank); - UBLOG(logINFO, "Physical Memory currently used by current process: " << Utilities::getPhysMemUsedByMe() / 1073741824.0 << " GB"); - } -} -////////////////////////////////////////////////////////////////////////// -void MPIIORestartCoProcessor::setLBMKernel(SPtr<LBMKernel> kernel) -{ - this->lbmKernel = kernel; -} -////////////////////////////////////////////////////////////////////////// -void MPIIORestartCoProcessor::setBCProcessor(SPtr<BCProcessor> bcProcessor) -{ - this->bcProcessor = bcProcessor; -} - diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.h deleted file mode 100644 index 79c77481f..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MPIIORestartCoProcessor.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef _MPIIORestartCoProcessor_H_ -#define _MPIIORestartCoProcessor_H_ - -#include <mpi.h> -#include <PointerDefinitions.h> -#include <string> - -#include "CoProcessor.h" -#include "MPIIODataStructures.h" - -class Grid3D; -class UbScheduler; -class Communicator; -class BCProcessor; -class LBMKernel; - - - -//! \class MPIWriteBlocksCoProcessor -//! \brief Writes the grid each timestep into the files and reads the grip from the files before regenerating -class MPIIORestartCoProcessor : public CoProcessor -{ -public: - MPIIORestartCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, SPtr<Communicator> comm); - virtual ~MPIIORestartCoProcessor(); - //! Each timestep writes the grid into the files - void process(double step); - //! Reads the grid from the files before grid reconstruction - void restart(int step); - //! Writes the blocks of the grid into the file cpBlocks.bin - void writeBlocks(int step); - //! Writes the datasets of the blocks into the file cpDataSet.bin - void writeDataSet(int step); - void writeAverageDensityArray(int step); - void writeAverageVelocityArray(int step); - void writeAverageFluktuationsArray(int step); - void writeAverageTripleArray(int step); - void writeShearStressValArray(int step); - void writeRelaxationFactor(int step); - //! Writes the boundary conditions of the blocks into the file cpBC.bin - void writeBoundaryConds(int step); - - //! Reads the blocks of the grid from the file cpBlocks.bin - void readBlocks(int step); - //! Reads the datasets of the blocks from the file cpDataSet.bin - void readDataSet(int step); - void readAverageDensityArray(int step); - void readAverageVelocityArray(int step); - void readAverageFluktuationsArray(int step); - void readAverageTripleArray(int step); - void readShearStressValArray(int step); - void readRelaxationFactor(int step); - //! Reads the boundary conditions of the blocks from the file cpBC.bin - void readBoundaryConds(int step); - //! The function sets LBMKernel - void setLBMKernel(SPtr<LBMKernel> kernel); - //!The function sets BCProcessor - void setBCProcessor(SPtr<BCProcessor> bcProcessor); - //!The function truncates the data files - void clearAllFiles(int step); - //!The function write a time step of last check point - void writeCpTimeStep(int step); - //!The function read a time step of last check point - int readCpTimeStep(); - -protected: - std::string path; - SPtr<Communicator> comm; - -private: - MPI_Datatype gridParamType, block3dType, arrayPresenceType; - MPI_Datatype dataSetParamType, dataSetType, dataSetSmallType, dataSetDoubleType; - MPI_Datatype boundCondParamType, boundCondType, boundCondType1000, boundCondTypeAdd, bcindexmatrixType; - - MPIIODataStructures::boundCondParam boundCondParamStr; - SPtr<LBMKernel> lbmKernel; - SPtr<BCProcessor> bcProcessor; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MicrophoneArrayCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/MicrophoneArrayCoProcessor.cpp deleted file mode 100644 index 8fb0f6eeb..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MicrophoneArrayCoProcessor.cpp +++ /dev/null @@ -1,126 +0,0 @@ -#include "MicrophoneArrayCoProcessor.h" -#include "Vector3D.h" -#include "Grid3D.h" -#include "ILBMKernel.h" -#include "Communicator.h" -#include "Block3D.h" -#include "DistributionArray3D.h" -#include "DataSet3D.h" -#include "D3Q27System.h" -#include "UbScheduler.h" -#include "BCProcessor.h" -#include "BCArray3D.h" -#include <sstream> - -MicrophoneArrayCoProcessor::MicrophoneArrayCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string & path, SPtr<Communicator> comm) : CoProcessor(grid, s), path(path), comm(comm) -{ - count = 0; - micID = 0; -} - -MicrophoneArrayCoProcessor::~MicrophoneArrayCoProcessor() -{ -} - -void MicrophoneArrayCoProcessor::process(double step) -{ - if (microphones.size() > 0) - { - collectData(step); - - if (scheduler->isDue(step)) - writeFile(step); - } - - UBLOG(logDEBUG3, "MicrophoneArrayCoProcessor::process:" << step); -} - -bool MicrophoneArrayCoProcessor::addMicrophone(Vector3D coords) -{ - micID++; - UbTupleInt3 blockIndexes = grid->getBlockIndexes(coords[0], coords[1], coords[2]); - - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - - for (int level = minInitLevel; level<=maxInitLevel; level++) - { - UbTupleInt3 blockIndexes = grid->getBlockIndexes(coords[0], coords[1], coords[2], level); - SPtr<Block3D> block = grid->getBlock(val<1>(blockIndexes), val<2>(blockIndexes), val<3>(blockIndexes), level); - if (block) - { - SPtr<ILBMKernel> kernel = block->getKernel(); - if (kernel) - { - SPtr<BCArray3D> bcarray = kernel->getBCProcessor()->getBCArray(); - UbTupleInt3 nodes = grid->getNodeIndexes(block, coords[0], coords[1], coords[2]); - if (!bcarray->isUndefined(val<1>(nodes), val<2>(nodes), val<3>(nodes))) - { - - if (kernel->getCompressible()) - { - calcMacros = &D3Q27System::calcCompMacroscopicValues; - } - else - { - calcMacros = &D3Q27System::calcIncompMacroscopicValues; - } - SPtr<Mic> mic(new Mic); - mic->id = micID; - mic->distridution = kernel->getDataSet()->getFdistributions(); - mic->nodeIndexes = grid->getNodeIndexes(block, coords[0], coords[1], coords[2]); - microphones.push_back(mic); - - strVector.push_back(SPtr<std::stringstream>(new std::stringstream)); - - std::string fname = path+"/mic/mic_"+UbSystem::toString(micID)+".csv"; - std::ofstream ostr; - ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app); - if (!ostr) - { - ostr.clear(); - std::string path = UbSystem::getPathFromString(fname); - if (path.size()>0) { UbSystem::makeDirectory(path); ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app); } - if (!ostr) throw UbException(UB_EXARGS, "couldn't open file "+fname); - } - ostr << "#microphone position: " << coords[0] << "; " << coords[1] << "; " << coords[2] << "; " << "\n"; - ostr.close(); - return true; - } - } - } - } - return false; -} - -void MicrophoneArrayCoProcessor::collectData(double step) -{ - for (int i = 0; i < microphones.size(); i++ ) - { - LBMReal f[D3Q27System::ENDF+1]; - microphones[i]->distridution->getDistribution(f, val<1>(microphones[i]->nodeIndexes), val<2>(microphones[i]->nodeIndexes), val<3>(microphones[i]->nodeIndexes)); - LBMReal vx1, vx2, vx3, rho; - calcMacros(f, rho, vx1, vx2, vx3); - *strVector[i] << step << ';' << rho << '\n'; - } -} - -void MicrophoneArrayCoProcessor::writeFile(double step) -{ - for (int i = 0; i < microphones.size(); i++) - { - std::string fname = path+"/mic/mic_"+UbSystem::toString(microphones[i]->id)+".csv"; - std::ofstream ostr; - ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app); - if (!ostr) - { - ostr.clear(); - std::string path = UbSystem::getPathFromString(fname); - if (path.size()>0) { UbSystem::makeDirectory(path); ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app); } - if (!ostr) throw UbException(UB_EXARGS, "couldn't open file "+fname); - } - ostr << strVector[i]->str(); - ostr.close(); - strVector[i] = SPtr<std::stringstream>(new std::stringstream); - } -} \ No newline at end of file diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/MicrophoneArrayCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/MicrophoneArrayCoProcessor.h deleted file mode 100644 index b3f5edbc8..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/MicrophoneArrayCoProcessor.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef MicrophoneArrayCoProcessor_h__ -#define MicrophoneArrayCoProcessor_h__ - -#include "CoProcessor.h" -#include <string> -#include <vector> -#include <array> -#include "UbTuple.h" -#include "LBMSystem.h" - -class Communicator; -class Grid3D; -class UbScheduler; -class Vector3D; -class DistributionArray3D; - -//! \brief Class implements microphone array. -//! \details It samples pressure (LBM rho value) and stores to .csv file. -//! \author Konstantin Kutscher -//! \date February 2019 - -class MicrophoneArrayCoProcessor : public CoProcessor -{ -public: - MicrophoneArrayCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, SPtr<Communicator> comm); - virtual ~MicrophoneArrayCoProcessor(); - - //! calls collectData. - void process(double step) override; - - //! add microphone - bool addMicrophone(Vector3D coords); -protected: - void collectData(double step); - void writeFile(double step); -private: - std::string path; - SPtr<Communicator> comm; - - struct Mic - { - unsigned int id; - SPtr<DistributionArray3D> distridution; - UbTupleInt3 nodeIndexes; - }; - std::vector< SPtr<Mic> > microphones; - - std::vector< SPtr<std::stringstream> > strVector; - - int count; - int micID; - - typedef void(*CalcMacrosFct)(const LBMReal* const& /*feq[27]*/, LBMReal& /*(d)rho*/, LBMReal& /*vx1*/, LBMReal& /*vx2*/, LBMReal& /*vx3*/); - CalcMacrosFct calcMacros; -}; - -#endif // MicrophoneArrayCoProcessor_h__ diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/NUPSCounterCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/NUPSCounterCoProcessor.cpp index a42e2aa37..38b11dd01 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/NUPSCounterCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/NUPSCounterCoProcessor.cpp @@ -1,77 +1,94 @@ -#include "NUPSCounterCoProcessor.h" - -#include "Communicator.h" -#include "UbScheduler.h" -#include "Grid3D.h" - -NUPSCounterCoProcessor::NUPSCounterCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, int numOfThreads, SPtr<Communicator> comm) - : CoProcessor(grid, s), - numOfThreads(numOfThreads), - comm(comm), - nup(0), - nup_t(0), - nupsStep(0.0) -{ - if (comm->getProcessID() == comm->getRoot()) - { - timer.resetAndStart(); - - double nop = comm->getNumberOfProcesses(); - int minInitLevel = grid->getCoarsestInitializedLevel(); - int maxInitLevel = grid->getFinestInitializedLevel(); - int gl = 2; - UbTupleInt3 blocknx = grid->getBlockNX(); - //double nod = (val<1>(blocknx)+gl) * (val<2>(blocknx)+gl) * (val<3>(blocknx)+gl); - double nod = (double)(val<1>(blocknx)) * (double)(val<2>(blocknx)) * (double)(val<3>(blocknx)); - nup = 0; - - for(int level = minInitLevel; level<=maxInitLevel; level++) - { - int nob = grid->getNumberOfBlocks(level); - nup_t += (double)(1<<level) * nob * nod; - } - nup = nup_t / nop; - } -} -////////////////////////////////////////////////////////////////////////// -NUPSCounterCoProcessor::~NUPSCounterCoProcessor() -{ -} -////////////////////////////////////////////////////////////////////////// -void NUPSCounterCoProcessor::process(double step) -{ - if(scheduler->isDue(step) ) - collectData(step); -} -////////////////////////////////////////////////////////////////////////// -void NUPSCounterCoProcessor::collectData(double step) -{ - if (comm->getProcessID() == comm->getRoot()) - { - double time = timer.stop(); - //double time = timer.elapsed(); - //std::ofstream ostr; - //std::string fname = path; - //ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app); - //if(!ostr) - //{ - // ostr.clear(); - // std::string path = UbSystem::getPathFromString(fname); - // if(path.size()>0){ UbSystem::makeDirectory(path); ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app);} - // if(!ostr) throw UbException(UB_EXARGS,"couldn't open file "+fname); - //} - double nups_t = nup_t*(step-nupsStep)/time; - double nups = nup*(step-nupsStep)/time;//timer.getTotalTime(); - double tnups = nups/(double)numOfThreads; - //ostr << nups << std::endl; - //ostr.close(); - UBLOG(logINFO, "Calculation step = "<<step); - UBLOG(logINFO, "Total performance = "<<nups_t<<" NUPS"); - UBLOG(logINFO, "Performance per process = "<<nups<<" NUPS"); - UBLOG(logINFO, "Performance per thread = "<<tnups<<" NUPS"); - UBLOG(logINFO, "Time for " << step-nupsStep <<" steps = "<< time <<" s"); - //timer.restart(); - nupsStep = step; - timer.resetAndStart(); - } -} +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file NUPSCounterCoProcessor.cpp +//! \ingroup CoProcessors +//! \author Konstantin Kutscher +//======================================================================================= + +#include "NUPSCounterCoProcessor.h" + +#include "Communicator.h" +#include "UbScheduler.h" +#include "Grid3D.h" + +NUPSCounterCoProcessor::NUPSCounterCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, int numOfThreads, SPtr<Communicator> comm) + : CoProcessor(grid, s), + numOfThreads(numOfThreads), + comm(comm), + nup(0), + nup_t(0), + nupsStep(0.0) +{ + if (comm->getProcessID() == comm->getRoot()) + { + timer.resetAndStart(); + + double nop = comm->getNumberOfProcesses(); + int minInitLevel = grid->getCoarsestInitializedLevel(); + int maxInitLevel = grid->getFinestInitializedLevel(); + UbTupleInt3 blocknx = grid->getBlockNX(); + double nod = (double)(val<1>(blocknx)) * (double)(val<2>(blocknx)) * (double)(val<3>(blocknx)); + nup = 0; + + for(int level = minInitLevel; level<=maxInitLevel; level++) + { + int nob = grid->getNumberOfBlocks(level); + nup_t += (double)(1<<level) * nob * nod; + } + nup = nup_t / nop; + } +} +////////////////////////////////////////////////////////////////////////// +NUPSCounterCoProcessor::~NUPSCounterCoProcessor() +{ +} +////////////////////////////////////////////////////////////////////////// +void NUPSCounterCoProcessor::process(double step) +{ + if(scheduler->isDue(step) ) + collectData(step); +} +////////////////////////////////////////////////////////////////////////// +void NUPSCounterCoProcessor::collectData(double step) +{ + if (comm->getProcessID() == comm->getRoot()) + { + double time = timer.stop(); + double nups_t = nup_t*(step-nupsStep)/time; + double nups = nup*(step-nupsStep)/time; + double tnups = nups/(double)numOfThreads; + UBLOG(logINFO, "Calculation step = "<<step); + UBLOG(logINFO, "Total performance = "<<nups_t<<" NUPS"); + UBLOG(logINFO, "Performance per process = "<<nups<<" NUPS"); + UBLOG(logINFO, "Performance per thread = "<<tnups<<" NUPS"); + UBLOG(logINFO, "Time for " << step-nupsStep <<" steps = "<< time <<" s"); + nupsStep = step; + timer.resetAndStart(); + } +} diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/NUPSCounterCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/NUPSCounterCoProcessor.h index dd101a6ee..a398f10e9 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/NUPSCounterCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/NUPSCounterCoProcessor.h @@ -1,42 +1,77 @@ -/* -* NUPSCounterCoProcessor.h -* -* Created on: 03.05.2011 -* Author: K. Kucher -*/ - -#ifndef NUPSCOUNTERCoProcessor_H_ -#define NUPSCOUNTERCoProcessor_H_ - -#include <PointerDefinitions.h> - -#include "CoProcessor.h" -#include "basics/utilities/UbTiming.h" - -class Communicator; -class Grid3D; -class UbScheduler; - -class NUPSCounterCoProcessor: public CoProcessor -{ -public: - NUPSCounterCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, int numOfThreads, SPtr<Communicator> comm); - virtual ~NUPSCounterCoProcessor(); - - void process(double step)override; - -protected: - void collectData(double step); - UbTimer timer; - //boost::timer timer; - int numOfThreads; - double numberOfNodes; - double numberOfBlocks; - double nup; - double nup_t; - double nupsStep; - SPtr<Communicator> comm; -}; - - -#endif +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file NUPSCounterCoProcessor.h +//! \ingroup CoProcessors +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef NUPSCOUNTERCoProcessor_H_ +#define NUPSCOUNTERCoProcessor_H_ + +#include <PointerDefinitions.h> + +#include "CoProcessor.h" +#include "basics/utilities/UbTiming.h" + +class Communicator; +class Grid3D; +class UbScheduler; + +//! \class NUPSCounterCoProcessor +//! \brief A class calculates Nodal Updates Per Second (NUPS) +class NUPSCounterCoProcessor: public CoProcessor +{ +public: + //! \brief Construct NUPSCounterCoProcessor object for grid object and scheduler object. + //! \pre The Grid3D and UbScheduler objects must exist. + //! \param grid is observable Grid3D object + //! \param s is UbScheduler object for scheduling of observer + //! \param numOfThreads is number of threads + //! \param comm is Communicator object + NUPSCounterCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, int numOfThreads, SPtr<Communicator> comm); + virtual ~NUPSCounterCoProcessor(); + + void process(double step)override; + +protected: + //! Collect data for calculation of NUPS + //! \param step is a time step + void collectData(double step); + UbTimer timer; + int numOfThreads; + double numberOfNodes; + double numberOfBlocks; + double nup; + double nup_t; + double nupsStep; + SPtr<Communicator> comm; +}; + + +#endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.cpp deleted file mode 100644 index ddcfa6b67..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.cpp +++ /dev/null @@ -1,223 +0,0 @@ -#include "PressureCoefficientCoProcessor.h" -#include <WbWriterVtkXmlASCII.h> - -#include "LBMKernel.h" -#include "BCProcessor.h" -#include "DataSet3D.h" -#include "Block3D.h" -#include "UbScheduler.h" -#include "Grid3D.h" -#include "Communicator.h" -#include "GbCuboid3D.h" -#include "D3Q27Interactor.h" -#include "BCArray3D.h" - -PressureCoefficientCoProcessor::PressureCoefficientCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, - GbCuboid3DPtr plane, - const std::string& path, SPtr<Communicator> comm) - : CoProcessor(grid, s), - plane(plane), - path(path), - comm(comm) -{ - maxStep = scheduler->getMaxEnd(); - numberOfSteps = int(maxStep - scheduler->getMinBegin()); -} -////////////////////////////////////////////////////////////////////////// -PressureCoefficientCoProcessor::~PressureCoefficientCoProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -void PressureCoefficientCoProcessor::process(double step) -{ - if (scheduler->isDue(step)) - collectData(step); - - UBLOG(logDEBUG3, "D3Q27ForcesCoProcessor::update:" << step); -} -////////////////////////////////////////////////////////////////////////// -void PressureCoefficientCoProcessor::collectData(double step) -{ - calculateRho(); - - if (step == maxStep) - { - writeValues((int)step); - } -} -////////////////////////////////////////////////////////////////////////// -void PressureCoefficientCoProcessor::calculateRho() -{ - double f[D3Q27System::ENDF+1]; - double vx1, vx2, vx3, rho; - std::vector<double> values; - std::vector<double> rvalues; - - for(SPtr<D3Q27Interactor> interactor : interactors) - { - typedef std::map<SPtr<Block3D>, std::set< std::vector<int> > > TransNodeIndicesMap; - for(TransNodeIndicesMap::value_type t : interactor->getBcNodeIndicesMap()) - { - SPtr<Block3D> block = t.first; - std::set< std::vector<int> >& bcNodeIndicesSet = t.second; - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - - UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); - UbTupleDouble3 blockLengths = grid->getBlockLengths(block); - UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); - double dx = grid->getDeltaX(block); - - if (kernel->getCompressible()) - { - calcMacros = &D3Q27System::calcCompMacroscopicValues; - } - else - { - calcMacros = &D3Q27System::calcIncompMacroscopicValues; - } - - int ghostLayerWidth = kernel->getGhostLayerWidth(); - int minX1 = ghostLayerWidth; - int maxX1 = (int)bcArray->getNX1() - 1 - ghostLayerWidth; - int minX2 = ghostLayerWidth; - int maxX2 = (int)bcArray->getNX2() - 1 - ghostLayerWidth; - int minX3 = ghostLayerWidth; - int maxX3 = (int)bcArray->getNX3() - 1 - ghostLayerWidth; - - for(std::vector<int> node : bcNodeIndicesSet) - { - int x1 = node[0]; - int x2 = node[1]; - int x3 = node[2]; - - //without ghost nodes - if (x1 < minX1 || x1 > maxX1 || x2 < minX2 || x2 > maxX2 ||x3 < minX3 || x3 > maxX3) continue; - - if (bcArray->isFluid(x1, x2, x3)) //es kann sein, dass der node von einem anderen interactor z.B. als solid gemarkt wurde!!! - { - double cx1 = val<1>(org) - val<1>(nodeOffset) + x1*dx; - double cx2 = val<2>(org) - val<2>(nodeOffset) + x2*dx; - double cx3 = val<3>(org) - val<3>(nodeOffset) + x3*dx; - if (plane->isPointInGbObject3D(cx1, cx2, cx3)) - { - distributions->getDistribution(f, x1, x2, x3); - calcMacros(f, rho, vx1, vx2, vx3); - values.push_back(cx1); - values.push_back(cx2); - values.push_back(cx3); - values.push_back(rho); - } - } - } - - } - } - - comm->allGather(values, rvalues); - if (comm->getProcessID() == comm->getRoot()) - { - if (outValues.size() == 0) - { - outValues.resize(rvalues.size()); - } - int size = (int)rvalues.size(); - for (int i = 0; i < size; i+=4) - { - outValues[i] = rvalues[i]; - outValues[i+1] = rvalues[i+1]; - outValues[i+2] = rvalues[i+2]; - outValues[i+3] += rvalues[i+3]; - } - } - -} -////////////////////////////////////////////////////////////////////////// -void PressureCoefficientCoProcessor::writeValues(int step) -{ - if (comm->getProcessID() == comm->getRoot()) - { - datanames.resize(0); - datanames.push_back("rho"); - data.resize(datanames.size()); - - std::ofstream ostr; - std::string fname = path+UbSystem::toString(step)+".csv"; - ostr.open(fname.c_str(), std::ios_base::out); - if (!ostr) - { - ostr.clear(); - std::string path = UbSystem::getPathFromString(fname); - if (path.size()>0) { UbSystem::makeDirectory(path); ostr.open(fname.c_str(), std::ios_base::out); } - if (!ostr) throw UbException(UB_EXARGS, "couldn't open file "+fname); - } - - ostr << "x1;x2;x3;rho\n"; - - int size = (int)outValues.size(); - for (int i = 0; i < size; i+=4) - { - ostr << outValues[i] << ";" << outValues[i+1] <<";" << outValues[i+2] << ";" << outValues[i+3]/numberOfSteps << std::endl; - - int index = 0; - nodes.push_back(makeUbTuple(float(outValues[i]), - float(outValues[i+1]), - float(outValues[i+2]))); - - data[index++].push_back(outValues[i+3]/numberOfSteps); - } - - ostr.close(); - - WbWriterVtkXmlASCII::getInstance()->writeNodesWithNodeData(path+UbSystem::toString(step), nodes, datanames, data); - - fname = path+UbSystem::toString(step)+".bin"; - std::ofstream out(fname.c_str(), std::ios::out | std::ios::binary); - if (!out) - { - out.clear(); //flags ruecksetzen (ansonsten liefert utern if(!out) weiterhin true!!! - std::string path = UbSystem::getPathFromString(fname); - if (path.size()>0) { UbSystem::makeDirectory(path); out.open(fname.c_str(), std::ios::out | std::ios::binary); } - if (!out) throw UbException(UB_EXARGS, "couldn't open file "+fname); - } - - out.write((char*)&outValues[0], outValues.size()*sizeof(double)); - - out.close(); - - UBLOG(logINFO, "PressureCoefficientCoProcessor::writeValues() step: " << (int)step); - } -} -void PressureCoefficientCoProcessor::readValues(int step) -{ - if (comm->isRoot()) - { - std::string fname = path+UbSystem::toString(step)+".bin"; - std::ifstream in(fname.c_str(), std::ios::in | std::ios::binary); - if (!in) - { - throw UbException(UB_EXARGS, "couldn't open file "+fname); - } - - // get length of file: - in.seekg(0, in.end); - int length = (int)in.tellg(); - in.seekg(0, in.beg); - - outValues.resize(length/sizeof(double)); - - in.read((char*)&outValues[0], length); - - in.close(); - - UBLOG(logINFO, "PressureCoefficientCoProcessor::readValues() step: " << (int)step); - } -} -////////////////////////////////////////////////////////////////////////// -void PressureCoefficientCoProcessor::addInteractor(SPtr<D3Q27Interactor> interactor) -{ - interactors.push_back(interactor); -} diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.h deleted file mode 100644 index 5738ec642..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef PressureCoefficientCoProcessor_h__ -#define PressureCoefficientCoProcessor_h__ - -#include <PointerDefinitions.h> -#include <string> -#include <vector> - -#include "CoProcessor.h" -#include "LBMSystem.h" - - -class GbCuboid3D; -class D3Q27Interactor; -class Communicator; -class Grid3D; -class UbScheduler; - -class PressureCoefficientCoProcessor: public CoProcessor -{ -public: - PressureCoefficientCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, - SPtr<GbCuboid3D> plane, const std::string& path, SPtr<Communicator> comm); - ~PressureCoefficientCoProcessor(); - - void process(double step) override; - - void addInteractor(SPtr<D3Q27Interactor> interactor); - void readValues(int step); - -protected: - void collectData(double step); - void calculateRho(); - void writeValues(int step); - -private: - SPtr<GbCuboid3D> plane; - std::string path; - SPtr<Communicator> comm; - std::vector<SPtr<D3Q27Interactor> > interactors; - int numberOfSteps; - double maxStep; - - std::vector<UbTupleFloat3> nodes; - std::vector<std::string> datanames; - std::vector<std::vector<double> > data; - - std::vector<double> outValues; - - typedef void(*CalcMacrosFct)(const LBMReal* const& /*feq[27]*/, LBMReal& /*(d)rho*/, LBMReal& /*vx1*/, LBMReal& /*vx2*/, LBMReal& /*vx3*/); - CalcMacrosFct calcMacros; -}; - -#endif // PressureDistributionCoProcessor_h__ - - diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.cpp deleted file mode 100644 index 65aa52869..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * D3Q27RhoCoProcessor.cpp - * - * Created on: 28.12.2010 - * Author: kucher - */ - -#include "PressureDifferenceCoProcessor.h" - -#include <fstream> - -#include "IntegrateValuesHelper.h" -#include "LBMUnitConverter.h" -#include "Communicator.h" -#include "UbScheduler.h" -#include "Grid3D.h" - - -PressureDifferenceCoProcessor::PressureDifferenceCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, - SPtr<IntegrateValuesHelper> h1, SPtr<IntegrateValuesHelper> h2, - LBMReal rhoReal, LBMReal uReal, LBMReal uLB, - SPtr<Communicator> comm) - - : CoProcessor(grid, s) - , path(path) - , h1(h1) - , h2(h2) - ,comm(comm) -{ - if (comm->getProcessID() == comm->getRoot()) - { - std::ofstream ostr; - std::string fname = path; - ostr.open(fname.c_str(), std::ios_base::out); - if(!ostr) - { - ostr.clear(); - std::string path = UbSystem::getPathFromString(fname); - if(path.size()>0){ UbSystem::makeDirectory(path); ostr.open(fname.c_str(), std::ios_base::out);} - if(!ostr) throw UbException(UB_EXARGS,"couldn't open file "+fname); - } - ostr << "step" << "\t" << "nodes1" << "\t" << "nodes2" << "\t"; - ostr << "sRho1" << "\t" << "p1_1" << "\t" << "sRho2" << "\t" << "p1_2" << "\t" << "deltaP1"<< "\t"; - ostr << "sPress1" << "\t" << "p2_1" << "\t" << "sPress2" << "\t" << "p2_2" << "\t" << "deltaP2"; - ostr << std::endl; - ostr.close(); - - factor1 = (1.0/3.0)*rhoReal*(uReal/uLB)*(uReal/uLB); - factor2 = rhoReal*(uReal/uLB)*(uReal/uLB); - } -} -////////////////////////////////////////////////////////////////////////// -PressureDifferenceCoProcessor::~PressureDifferenceCoProcessor() -{ -} -////////////////////////////////////////////////////////////////////////// -void PressureDifferenceCoProcessor::process(double step) -{ - if(scheduler->isDue(step) ) - collectData(step); -} -////////////////////////////////////////////////////////////////////////// -void PressureDifferenceCoProcessor::collectData(double step) -{ - h1->calculateMQ(); - h2->calculateMQ(); - - if (comm->getProcessID() == comm->getRoot()) - { - int istep = static_cast<int>(step); - std::ofstream ostr; - double nn1 = h1->getNumberOfFluidsNodes(); - double nn2 = h2->getNumberOfFluidsNodes(); - double rho1 = h1->getRho(); - double rho2 = h2->getRho(); - double p1_1 = (rho1/nn1) * factor1; - double p1_2 = (rho2/nn2) * factor1; - double dp1 = p1_1 - p1_2; - - //double press1 = h1->getPress(); - //double press2 = h2->getPress(); - //double p2_1 = (press1/nn1) * factor2; - //double p2_2 = (press2/nn2) * factor2; - //double dp2 = p2_1 - p2_2; - - std::string fname = path; - ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app); - if(!ostr) - { - ostr.clear(); - std::string path = UbSystem::getPathFromString(fname); - if(path.size()>0){ UbSystem::makeDirectory(path); ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app);} - if(!ostr) throw UbException(UB_EXARGS,"couldn't open file "+fname); - } - - ostr << istep << "\t" << nn1 << "\t" << nn2 << "\t"; - ostr << rho1 << "\t" << p1_1 << "\t" << rho2 << "\t" << p1_2 << "\t" << dp1 << "\t"; - //ostr << press1 << "\t" << p2_1 << "\t" << press2 << "\t" << p2_2 << "\t" << dp2; - ostr << std::endl; - ostr.close(); - } -} diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.h deleted file mode 100644 index e844be41b..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/PressureDifferenceCoProcessor.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * D3Q27PressureDifferenceCoProcessor.h - * - * Created on: 28.12.2010 - * Author: kucher - */ - -#ifndef D3Q27PRESSUREDIFFERENCECoProcessor_H -#define D3Q27PRESSUREDIFFERENCECoProcessor_H - -#include <PointerDefinitions.h> -#include <string> - -#include "CoProcessor.h" -#include "LBMSystem.h" - -class Communicator; -class Grid3D; -class UbScheduler; -class LBMUnitConverter; -class IntegrateValuesHelper; - -class PressureDifferenceCoProcessor: public CoProcessor { -public: - PressureDifferenceCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, - SPtr<IntegrateValuesHelper> h1, SPtr<IntegrateValuesHelper> h2, - LBMReal rhoReal, LBMReal uReal, LBMReal uLB, - /*const SPtr<LBMUnitConverter> conv,*/ SPtr<Communicator> comm); - virtual ~PressureDifferenceCoProcessor(); - - void process(double step) override; - -protected: - SPtr<IntegrateValuesHelper> h1, h2; - std::string path; - SPtr<LBMUnitConverter> conv; - void collectData(double step); - SPtr<Communicator> comm; - LBMReal factor1; //= (1/3)*rhoReal*(uReal/uLB)^2 for calculation pReal = rhoLB * (1/3)*rhoReal*(uReal/uLB)^2, rhoReal and uReal in SI - LBMReal factor2; //= rhoReal*(uReal/uLB)^2 for calculation pReal = press * rhoReal*(uReal/uLB)^2, rhoReal and uReal in SI -}; - - -#endif /* D3Q27RHODIFFERENCECoProcessor_H_ */ diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.cpp deleted file mode 100644 index 6378c3b7e..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.cpp +++ /dev/null @@ -1,389 +0,0 @@ -#include "QCriterionCoProcessor.h" -#include "LBMKernel.h" -#include "BCProcessor.h" -#include "basics/writer/WbWriterVtkXmlASCII.h" -#include "DataSet3D.h" -#include "Grid3D.h" -#include "Block3D.h" - -#include "Communicator.h" -#include "UbScheduler.h" -#include "BCArray3D.h" - - -QCriterionCoProcessor::QCriterionCoProcessor(SPtr<Grid3D> grid, const std::string& path, - WbWriter* const writer, - SPtr<UbScheduler> s, SPtr<Communicator> comm) - : CoProcessor(grid, s), - path(path), - comm(comm), - writer(writer) -{ - init(); -} -////////////////////////////////////////////////////////////////////////// -void QCriterionCoProcessor::init() -{ - 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]); //grid: private variable in CoProcessor. Initialized by filling with blocks - } -} -////////////////////////////////////////////////////////////////////////// -void QCriterionCoProcessor::process(double step) -{ - if(scheduler->isDue(step) ) - collectData(step); - - UBLOG(logDEBUG3, "QCriterionCoProcessor::update:" << step); -} -////////////////////////////////////////////////////////////////////////// -void QCriterionCoProcessor::collectData(double step) -{ - int istep = static_cast<int>(step); - - for(int level = minInitLevel; level<=maxInitLevel;level++) - { - for(SPtr<Block3D> block : blockVector[level]) - { - if (block) - { - addData(block); - - } - } - } - - std::string partName = writer->writeOctsWithNodeData(path+ UbSystem::toString(gridRank)+ "_" + UbSystem::toString(istep),nodes,cells,datanames,data); - size_t found=partName.find_last_of("//"); - std::string piece = partName.substr(found+1); - - std::vector<std::string> cellDataNames; - - //distributed writing as in MacroscopicValuesCoProcessor.cpp - std::vector<std::string> pieces = comm->gather(piece); //comm: MPI-Wrapper - if (comm->getProcessID() == comm->getRoot()) - { - std::string pname = WbWriterVtkXmlASCII::getInstance()->writeParallelFile(path+"_"+UbSystem::toString(istep),pieces,datanames,cellDataNames); - - std::vector<std::string> filenames; - filenames.push_back(pname); - if (step == CoProcessor::scheduler->getMinBegin()) //first time in timeseries - { - WbWriterVtkXmlASCII::getInstance()->writeCollection(path+"_collection",filenames,istep,false); - } - else - { - WbWriterVtkXmlASCII::getInstance()->addFilesToCollection(path+"_collection",filenames,istep,false); - } - UBLOG(logINFO,"QCriterionCoProcessor step: " << istep); - } - - clearData(); - - -} -////////////////////////////////////////////////////////////////////////// -void QCriterionCoProcessor::clearData() -{ - nodes.clear(); - cells.clear(); - datanames.clear(); - data.clear(); -} -////////////////////////////////////////////////////////////////////////// -void QCriterionCoProcessor::addData(const SPtr<Block3D> block) -{ - UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); - UbTupleDouble3 blockLengths = grid->getBlockLengths(block); - UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); - double dx = grid->getDeltaX(block); - - //Diese Daten werden geschrieben: - datanames.resize(0); - datanames.push_back("q"); - datanames.push_back("scaleFactor"); - data.resize(datanames.size()); - - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - - unsigned int SWB,SEB,NEB,NWB,SWT,SET,NET,NWT; - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int maxX1 = (int)(distributions->getNX1()); - int maxX2 = (int)(distributions->getNX2()); - int maxX3 = (int)(distributions->getNX3()); - - int currentLevel = block->getLevel(); - //nummern vergeben und node std::vector erstellen + daten sammeln - CbArray3D<int> nodeNumbers((int)maxX1, (int)maxX2, (int)maxX3,-1); - maxX1 -= 2; //-2 wegen ghost layer: - maxX2 -= 2; //0-maxXi-1 ist arraygroesse. - maxX3 -= 2; //ueberlapp 1 in +,- Richtung. zum schreiben werden statt feldern von 1 bis (max-2) felder von 0 bis max-3 verwendet! - - - int nr = (int)nodes.size(); - - for(int ix3=minX3; ix3<=maxX3; ix3++) - { - for(int ix2=minX2; ix2<=maxX2; ix2++) - { - for(int ix1=minX1; ix1<=maxX1; ix1++) - { - if(!bcArray->isUndefined(ix1,ix2,ix3) && !bcArray->isSolid(ix1,ix2,ix3)) - { - //nodeNumbers-vektor wird mit koordinaten befuellt - 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)) ); - - ///////////////////////////// - // Geschwindigkeitsvektoren - LBMReal vE[3]; - LBMReal vW[3]; - LBMReal vN[3]; - LBMReal vS[3]; - LBMReal vT[3]; - LBMReal vB[3]; - //hole geschwindigkeiten an nachbarknoten - getNeighborVelocities(1,0,0, ix1, ix2, ix3, block, vE, vW); - getNeighborVelocities(0,1,0, ix1, ix2, ix3, block, vN, vS); - getNeighborVelocities(0,0,1, ix1, ix2, ix3, block, vT, vB); - ////////////////////////////////// - //derivatives - LBMReal duxdy=(vN[xdir]-vS[xdir])*0.5; - LBMReal duydx=(vE[ydir]-vW[ydir])*0.5; - LBMReal duxdz=(vT[xdir]-vB[xdir])*0.5; - LBMReal duzdx=(vE[zdir]-vW[zdir])*0.5; - LBMReal duydz=(vT[ydir]-vB[ydir])*0.5; - LBMReal duzdy=(vN[zdir]-vS[zdir])*0.5; - - LBMReal duxdx=(vE[xdir]-vW[xdir])*0.5; - LBMReal duydy=(vN[ydir]-vS[ydir])*0.5; - LBMReal duzdz=(vT[zdir]-vB[zdir])*0.5; - - LBMReal scaleFactor=(double)(1<<(currentLevel-minInitLevel));//pow(2.0,(double)(currentLevel-minInitLevel));//finer grid -> current level higher. coarsest grid: currentLevel=minInitLevel=0 - // Q=-0.5*(S_ij S_ij - Omega_ij Omega_ij) => regions where vorticity is larger than strain rate - LBMReal q=-(duxdy*duydx+duxdz*duzdx+duydz*duzdy+duxdx*duxdx+duydy*duydy+duzdz*duzdz)*scaleFactor; - - data[index++].push_back( q ); - data[index++].push_back( scaleFactor ); - - } - } - } - } - 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 ) - { - // for valid points: neighbors are added to cells-vector - cells.push_back( makeUbTuple(SWB,SEB,NEB,NWB,SWT,SET,NET,NWT) ); - } - } - } - } - -} -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void QCriterionCoProcessor::getNeighborVelocities(int offx, int offy, int offz, int ix1, int ix2, int ix3, const SPtr<Block3D> block, LBMReal* vE, LBMReal* vW) -{ - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - - bool compressible = block->getKernel()->getCompressible(); - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int maxX1 = (int)(distributions->getNX1()); - int maxX2 = (int)(distributions->getNX2()); - int maxX3 = (int)(distributions->getNX3()); - if (maxX1<3) throw UbException(UB_EXARGS,"QCriterionCoProcessor: NX1 too small for FD stencils!"); - maxX1 -= 2; - maxX2 -= 2; - maxX3 -= 2; - bool checkInterpolation=true; - bool neighNodeIsBC=false; - SPtr<BoundaryConditions> bcPtr; - - int rankSelf= block->getRank(); - if (!(offx+offy+offz)==1) throw UbException(UB_EXARGS,"getNeighborVelocities called for diagonal directions!"); - //////get neighbor nodes, if existent - if ((ix1==0 && offx==1) || (ix2==0 && offy==1) || (ix3==0 && offz==1)) - { - int RankNeighborW; - Vector3D orgNodeRW = grid->getNodeCoordinates(block, ix1, ix2, ix3); - double xp000= orgNodeRW[0]; - double yp000= orgNodeRW[1]; - double zp000= orgNodeRW[2]; - - int currentLevel = block->getLevel(); - UbTupleInt3 blockIndexes = grid->getBlockIndexes(xp000,yp000, zp000,currentLevel); - SPtr<Block3D> blockNeighW; - - if ((val<1>(blockIndexes)!=0 && offx==1) || (val<2>(blockIndexes)!=0 && offy==1) || (val<3>(blockIndexes)!=0 && offz==1)) - { - - blockNeighW = grid->getBlock(val<1>(blockIndexes)-offx, val<2>(blockIndexes)-offy, val<3>(blockIndexes)-offz, currentLevel); - - } - else if (offx==1 && grid->isPeriodicX1()) - { - blockNeighW = grid->getBlock((grid->getNX1()-1), val<2>(blockIndexes), val<3>(blockIndexes), currentLevel); - } - else if (offy==1 && grid->isPeriodicX1()) - { - blockNeighW = grid->getBlock(val<1>(blockIndexes),(grid->getNX2()-1), val<3>(blockIndexes), currentLevel); - } - else if (offz==1 && grid->isPeriodicX1()) - { - blockNeighW = grid->getBlock( val<1>(blockIndexes), val<2>(blockIndexes),(grid->getNX3()-1), currentLevel); - } - else neighNodeIsBC; - - if(blockNeighW && blockNeighW->isActive()) - { - RankNeighborW= blockNeighW->getRank(); - } - else - { - - blockNeighW = block; - RankNeighborW= blockNeighW->getRank(); - checkInterpolation=false; - } - if (RankNeighborW!=rankSelf) - { - - blockNeighW = block; - RankNeighborW= blockNeighW->getRank(); - checkInterpolation=false; - } - - /////////////////////////////////////// - ////compute distribution at neighboring nodes from neighboring blocks - - if (checkInterpolation==false || neighNodeIsBC) - { - SPtr<ILBMKernel> kernelW = blockNeighW->getKernel(); - SPtr<BCArray3D> bcArrayW = kernelW->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributionsW = kernelW->getDataSet()->getFdistributions(); - LBMReal fW2[27]; - LBMReal fW[27]; - LBMReal f0[27]; - LBMReal fE[27]; - LBMReal v0[3]; - LBMReal vW2[3]; - //distributionsW->getDistribution(fW2, std::max(ix1+2*offx,1), std::max(ix2+2*offy,1), std::max(ix3+2*offz,1)); - //distributionsW->getDistribution(fW, std::max(ix1+offx,1), std::max(ix2+offy,1), std::max(ix3+offz,1)); - //distributionsW->getDistribution(f0, std::max(ix1 ,1), std::max(ix2 ,1), std::max(ix3 ,1)); - //distributions->getDistribution(fE, std::max(ix1+offx ,1), std::max(ix2+offy ,1), std::max(ix3+offz ,1)); //E:= plus 1 - distributionsW->getDistribution(fW2, std::max(ix1+2*offx,0), std::max(ix2+2*offy,0), std::max(ix3+2*offz,0)); - distributionsW->getDistribution(fW, std::max(ix1+offx,0), std::max(ix2+offy,0), std::max(ix3+offz,0)); - distributionsW->getDistribution(f0, std::max(ix1 ,0), std::max(ix2 ,0), std::max(ix3 ,0)); - distributions->getDistribution(fE, std::max(ix1+offx ,0), std::max(ix2+offy ,0), std::max(ix3+offz ,0)); //E:= plus 1 - - computeVelocity(fE,vE,compressible); - computeVelocity(fW,vW,compressible); - computeVelocity(fW2,vW2,compressible); - computeVelocity(f0,v0,compressible); - //second order non-symetric interpolation - vW[0]=v0[0]*1.5-vW[0]+0.5*vW2[0]; - vW[1]=v0[1]*1.5-vW[1]+0.5*vW2[1]; - vW[2]=v0[2]*1.5-vW[2]+0.5*vW2[2]; - //throw UbException(UB_EXARGS,"Parallel or Non-Uniform Simulation -- not yet implemented"); - } - else - { - SPtr<ILBMKernel> kernelW = blockNeighW->getKernel(); - SPtr<BCArray3D> bcArrayW = kernelW->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributionsW = kernelW->getDataSet()->getFdistributions(); - LBMReal fW[27]; - - if (offx==1) - { - distributionsW->getDistribution(fW, (distributions->getNX1())-1, ix2, ix3); //moved one block backward, now get last entry - } - else if (offy==1) - { - distributionsW->getDistribution(fW, ix1,(distributions->getNX2())-1, ix3); - - } - else if (offz==1) - { - distributionsW->getDistribution(fW, ix1,ix2,distributions->getNX3()-1); - } - computeVelocity(fW,vW,compressible); - } - - - } - else - { - //data available in current block: - LBMReal fW[27]; - distributions->getDistribution(fW, ix1-offx, ix2-offy, ix3-offz); - computeVelocity(fW,vW,compressible); - - } - if (checkInterpolation==true) - { - //in plus-direction data is available in current block because of ghost layers - LBMReal fE[27]; - distributions->getDistribution(fE, ix1+offx, ix2+offy, ix3+offz); //E:= plus 1 - computeVelocity(fE,vE,compressible); - } -} -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void QCriterionCoProcessor::computeVelocity(LBMReal* f, LBMReal* v, bool compressible) -{ - ////////////////////////////////////////////////////////////////////////// - //compute x,y,z-velocity components from distribution - ////////////////////////////////////////////////////////////////////////// - if (compressible) - { - v[xdir] = D3Q27System::getCompVelocityX1(f); - v[ydir] = D3Q27System::getCompVelocityX2(f); - v[zdir] = D3Q27System::getCompVelocityX3(f); - } - else - { - v[xdir] = D3Q27System::getIncompVelocityX1(f); - v[ydir] = D3Q27System::getIncompVelocityX2(f); - v[zdir] = D3Q27System::getIncompVelocityX3(f); - } -} diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.h deleted file mode 100644 index 1a1f53d9a..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.h +++ /dev/null @@ -1,66 +0,0 @@ -//! \file QCriterionCoProcessor.h -//! \brief Created on: 25.08.2013 -//! \author: Sonja Uphoff - - -#ifndef QCriterionCoProcessor_H -#define QCriterionCoProcessor_H - -#include <PointerDefinitions.h> -#include <string> -#include <vector> - -#include "CoProcessor.h" -#include "LBMSystem.h" - -class Communicator; -class Grid3D; -class UbScheduler; -class WbWriter; -class Block3D; - -//! \brief Computes the value Q with which vortices can be visualized as isocontours to Q=0, writes to .vtk, For uniform, serial setups only! -//! \details writes at given time intervals specified in scheduler (s) -//! Processing: paraview, take isolines of entry for Q-criterion vortex detection -//! Q-Criterion: Visualize Vorteces as regions where Vorticity is larger than strain rate (Hunt, 1988) -//! \author Sonja Uphoff - -class QCriterionCoProcessor : public CoProcessor -{ -public: - QCriterionCoProcessor(SPtr<Grid3D> grid, const std::string& path, WbWriter* const writer, - SPtr<UbScheduler> s, SPtr<Communicator> comm); - //! Make update if timestep is write-timestep specified in SPtr<UbScheduler> s - void process(double step) override; - -protected: - //! Prepare data and write in .vtk file - void collectData(double step); - //! Q is computed for all points in a block. Data for writing is added to data and cell vectors. - void addData(const SPtr<Block3D> block); - //! After writing to .vtk-file, all vectors are reset - void clearData(); - //! Computes macroscopic velocities - void computeVelocity(LBMReal* f, LBMReal* v, bool compressible); - //! Computes average and RMS values of macroscopic quantities - void getNeighborVelocities(int offx, int offy, int offz, int ix1, int ix2, int ix3,const SPtr<Block3D> block, LBMReal* vE,LBMReal* vW); - -private: - void init(); - std::vector<UbTupleFloat3> nodes; - std::vector<UbTupleUInt8> cells; - std::vector<std::string> datanames; //only one entry for QKrit-CoProcessor: Q - std::vector<std::vector<double> > data; - std::vector<std::vector<SPtr<Block3D> > > blockVector; - int minInitLevel; //go through all levels for block vector of current process from minInitLevel to maxInitLevel - int maxInitLevel; - int gridRank; //comm-Rank des aktuellen prozesses - std::string path; - WbWriter* writer; - SPtr<Communicator> comm; - enum Values{xdir = 0, ydir = 1, zdir = 2}; //labels for the different components -}; - -#endif - - diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.cpp deleted file mode 100644 index 0e5309f7d..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.cpp +++ /dev/null @@ -1,702 +0,0 @@ -#include "ShearStressCoProcessor.h" -#include "BCProcessor.h" -#include "WbWriterVtkXmlASCII.h" - -#include "Block3D.h" -#include "DataSet3D.h" -#include "LBMKernel.h" -#include "Communicator.h" -#include "D3Q27Interactor.h" -#include "UbScheduler.h" -#include "BCArray3D.h" -#include "InterpolationProcessor.h" -#include "Grid3D.h" - -ShearStressCoProcessor::ShearStressCoProcessor(SPtr<Grid3D> grid, const std::string& path, - WbWriter* const writer, - SPtr<UbScheduler> s,SPtr<UbScheduler> rs) - : CoProcessor(grid, s), - Resetscheduler(rs), - path(path), - writer(writer) -{ - SPtr<Communicator> comm = Communicator::getInstance(); - normals.push_back(0); - normals.push_back(0); - normals.push_back(1); - gridRank = grid->getRank(); - 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]); - for(SPtr<Block3D> block : blockVector[level]) - { - UbTupleInt3 nx = grid->getBlockNX(); - SPtr<ShearStressValuesArray3D> shearStressValues = SPtr<ShearStressValuesArray3D>(new ShearStressValuesArray3D(14, val<1>(nx)+1, val<2>(nx)+1, val<3>(nx)+1, 0.0)); - block->getKernel()->getDataSet()->setShearStressValues(shearStressValues); - } - } -} -////////////////////////////////////////////////////////////////////////// -ShearStressCoProcessor::~ShearStressCoProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -void ShearStressCoProcessor::process( double step ) -{ - if (step==0) - { - initDistance(); - } - calculateShearStress(step); - if(scheduler->isDue(step) ) - collectData(step); - UBLOG(logDEBUG3, "D3Q27ShearStressCoProcessor::update:" << step); -} -////////////////////////////////////////////////////////////////////////// -void ShearStressCoProcessor::collectData(double step) -{ - using namespace std; - - int istep = int(step); - addData(); - - //string partName = writer->writeNodesWithNodeData(path+ UbSystem::toString(gridRank)+ "_" + UbSystem::toString(istep),nodes,datanames,data); - //size_t found=partName.find_last_of("//"); - //string piece = partName.substr(found+1); - - //vector<string> cellDataNames; - - //SPtr<Communicator> comm = Communicator::getInstance(); - //vector<string> pieces = comm->gatherStrings(piece); - //if (comm->getProcessID() == comm->getRoot()) - //{ - // string pname = WbWriterVtkXmlASCII::getInstance()->writeParallelFile(path+"_"+UbSystem::toString(istep),pieces,datanames,cellDataNames); - - // vector<string> filenames; - // filenames.push_back(pname); - // if (step == CoProcessor::scheduler->getMinBegin()) - // { - // WbWriterVtkXmlASCII::getInstance()->writeCollection(path+"__Shear_collection",filenames,istep,false); - // } - // else - // { - // WbWriterVtkXmlASCII::getInstance()->addFilesToCollection(path+"__Shear_collection",filenames,istep,false); - // } - // UBLOG(logINFO,"D3Q27ShearStressCoProcessor step: " << istep); - //} - - string pfilePath, partPath, subfolder, cfilePath; - subfolder = "shs"+UbSystem::toString(istep); - pfilePath = path+"/shs/"+subfolder; - cfilePath = path+"/shs/shs_collection"; - partPath = pfilePath+"/shs"+UbSystem::toString(gridRank)+ "_" + UbSystem::toString(istep); - - string partName = writer->writeNodesWithNodeData(partPath,nodes,datanames,data); - size_t found=partName.find_last_of("/"); - string piece = partName.substr(found+1); - piece = subfolder + "/" + piece; - - vector<string> cellDataNames; - SPtr<Communicator> comm = Communicator::getInstance(); - 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,"D3Q27ShearStressCoProcessor step: " << istep); - } - - clearData(); -} -////////////////////////////////////////////////////////////////////////// -void ShearStressCoProcessor::clearData() -{ - nodes.clear(); - datanames.clear(); - data.clear(); -} -////////////////////////////////////////////////////////////////////////// -void ShearStressCoProcessor::calculateShearStress(double timeStep) -{ - using namespace D3Q27System; - - LBMReal f[27]; - LBMReal vx, vy, vz, sxx, syy, szz, sxy, syz, sxz; - - for(SPtr<D3Q27Interactor> interactor : interactors) - { - typedef std::map<SPtr<Block3D>, std::set< std::vector<int> > > TransNodeIndicesMap; - for(TransNodeIndicesMap::value_type t : interactor->getBcNodeIndicesMap()) - { - SPtr<Block3D> block = t.first; - std::set< std::vector<int> >& transNodeIndicesSet = t.second; - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - SPtr<ShearStressValuesArray3D> ssv = kernel->getDataSet()->getShearStressValues(); - - int ghostLayer = kernel->getGhostLayerWidth(); - LBMReal collFactor = kernel->getCollisionFactor(); - - int minX1 = ghostLayer; - int maxX1 = (int)bcArray->getNX1() - 1 - ghostLayer; - int minX2 = ghostLayer; - int maxX2 = (int)bcArray->getNX2() - 1 - ghostLayer; - int minX3 = ghostLayer; - int maxX3 = (int)bcArray->getNX3() - 1 - ghostLayer; - - for(std::vector<int> node : transNodeIndicesSet) - { - int ix1 = node[0]; - int ix2 = node[1]; - int ix3 = node[2]; - - //without ghost nodes - if (ix1 < minX1 || ix1 > maxX1 || ix2 < minX2 || ix2 > maxX2 ||ix3 < minX3 || ix3 > maxX3 ) continue; - - if(bcArray->isFluid(ix1,ix2,ix3)) - { - double q=(*ssv)(normalq,ix1,ix2,ix3) ; - double numPoint=(*ssv)(numberOfPoint,ix1,ix2,ix3) ; - if (q==0||numPoint!=3)continue; - // if (q==0)continue; - ////////////////////////////////////////////////////////////////////////// - //read distribution - //////////////////////////////////////////////////////////////////////////// - distributions->getDistribution(f, ix1, ix2, ix3); - ////////////////////////////////////////////////////////////////////////// - //compute velocity - ////////////////////////////////////////////////////////////////////////// - vx = ((((f[TNE]-f[BSW]) + (f[TSE]-f[BNW])) + ((f[BSE]-f[TNW]) + (f[BNE]-f[TSW]))) + - (((f[BE]-f[TW]) + (f[TE]-f[BW])) + ((f[SE]-f[NW]) + (f[NE]-f[SW]))) + - (f[E]-f[W])); - - vy = ((((f[TNE]-f[BSW]) + (f[BNW]-f[TSE])) + ((f[TNW]-f[BSE]) + (f[BNE]-f[TSW]))) + - (((f[BN]-f[TS]) + (f[TN]-f[BS])) + ((f[NW]-f[SE]) + (f[NE]-f[SW]))) + - (f[N]-f[S])); - - vz = ((((f[TNE]-f[BSW]) + (f[TSE]-f[BNW])) + ((f[TNW]-f[BSE]) + (f[TSW]-f[BNE]))) + - (((f[TS]-f[BN]) + (f[TN]-f[BS])) + ((f[TW]-f[BE]) + (f[TE]-f[BW]))) + - (f[T]-f[B])); - - - sxy = 3.0 * collFactor/(collFactor - 1.0)* ( ((f[TNE] + f[BSW])-(f[TSE]+f[BNW]))+(-(f[BSE]+f[TNW])+ (f[TSW]+f[BNE])) - +(((f[NE] + f[SW]) - (f[SE] + f[NW]))) -vx*vy); - - sxz = 3.0 * collFactor/(collFactor-1.0)*(((f[TNE] + f[BSW])+(f[TSE]+f[BNW]))+(-(f[BSE]+f[TNW])- (f[TSW]+f[BNE])) - +((f[TE] + f[BW])-(f[BE]+ f[TW])) -vx*vz); - - syz = 3.0 * collFactor/(collFactor-1.0)*(((f[TNE] + f[BSW])-(f[TSE]+f[BNW]))+((f[BSE]+f[TNW])- (f[TSW]+f[BNE])) - +(-(f[BN] + f[TS]) + (f[TN] + f[BS])) -vy*vz); - - LBMReal dxxMyy =3.0/2.0 * collFactor/(collFactor-1.0)* (((f[TE] + f[BW])+(f[BE]+ f[TW])) - -((f[BN] + f[TS]) + (f[TN] + f[BS]))+((f[E] + f[W])-(f[N] + f[S]))-vx*vx+vy*vy); - - LBMReal dxxMzz =3.0/2.0 * collFactor/(collFactor-1.0)*((((f[NE] + f[SW]) + (f[SE] + f[NW])) - -((f[BN] + f[TS]) + (f[TN] + f[BS])))+((f[E] + f[W])-(f[T] + f[B])) -vx*vx +vz*vz); - - // LBMReal dyyMzz =3.0/2.0 *collFactor/(collFactor-1.0)*((((f[NE] + f[SW]) + (f[SE] + f[NW]))-((f[TE] + f[BW])+(f[BE]+ f[TW]))) - // +((f[N] + f[S])-(f[T] + f[B])) -vy*vy +vz*vz); - - sxx=(dxxMyy+dxxMzz)/3.0; // weil dxxPyyPzz=0 - - syy=(dxxMzz-2*dxxMyy)/3.0; - - szz=(dxxMyy-2*dxxMzz)/3.0; - - ////////////////////////////////////////////////////////////////////////// - //compute average values - ////////////////////////////////////////////////////////////////////////// - (*ssv)(AvVx,ix1,ix2,ix3) = ((*ssv)(AvVx,ix1,ix2,ix3)*timeStep + vx)/(timeStep+1.0); - (*ssv)(AvVy,ix1,ix2,ix3) = ((*ssv)(AvVy,ix1,ix2,ix3)*timeStep + vy)/(timeStep+1.0); - (*ssv)(AvVz,ix1,ix2,ix3) = ((*ssv)(AvVz,ix1,ix2,ix3)*timeStep + vz)/(timeStep+1.0); - - (*ssv)(AvSxx,ix1,ix2,ix3) = ((*ssv)(AvSxx,ix1,ix2,ix3)*timeStep + sxx)/(timeStep+1.0); - (*ssv)(AvSyy,ix1,ix2,ix3) = ((*ssv)(AvSyy,ix1,ix2,ix3)*timeStep + syy)/(timeStep+1.0); - (*ssv)(AvSzz,ix1,ix2,ix3) = ((*ssv)(AvSzz,ix1,ix2,ix3)*timeStep + szz)/(timeStep+1.0); - (*ssv)(AvSxy,ix1,ix2,ix3) = ((*ssv)(AvSxy,ix1,ix2,ix3)*timeStep + sxy)/(timeStep+1.0); - (*ssv)(AvSyz,ix1,ix2,ix3) = ((*ssv)(AvSyz,ix1,ix2,ix3)*timeStep + syz)/(timeStep+1.0); - (*ssv)(AvSxz,ix1,ix2,ix3) = ((*ssv)(AvSxz,ix1,ix2,ix3)*timeStep + sxz)/(timeStep+1.0); - } - } - - } - } -} -////////////////////////////////////////////////////////////////////////// -void ShearStressCoProcessor::addData() -{ - //Diese Daten werden geschrieben: - datanames.resize(0); - datanames.push_back("y^plus"); - datanames.push_back("u_tau"); - //datanames.push_back("yPlusFD"); - - data.resize(datanames.size()); - - for(SPtr<D3Q27Interactor> interactor : interactors) - { - typedef std::map<SPtr<Block3D>, std::set< std::vector<int> > > TransNodeIndicesMap; - for(TransNodeIndicesMap::value_type t : interactor->getBcNodeIndicesMap()) - { - SPtr<Block3D> block = t.first; - std::set< std::vector<int> >& transNodeIndicesSet = t.second; - - UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); - UbTupleDouble3 blockLengths = grid->getBlockLengths(block); - UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); - double dx = grid->getDeltaX(block); - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - SPtr<ShearStressValuesArray3D> ssv = kernel->getDataSet()->getShearStressValues(); - - int ghostLayer = kernel->getGhostLayerWidth(); - LBMReal collFactor = kernel->getCollisionFactor(); - - int minX1 = ghostLayer; - int maxX1 = (int)bcArray->getNX1() - 1 - ghostLayer; - int minX2 = ghostLayer; - int maxX2 = (int)bcArray->getNX2() - 1 - ghostLayer; - int minX3 = ghostLayer; - int maxX3 = (int)bcArray->getNX3() - 1 - ghostLayer; - - int level=block->getLevel(); - if(level==1) - { - int le=0; - } - for(std::vector<int> node : transNodeIndicesSet) - { - int ix1 = node[0]; - int ix2 = node[1]; - int ix3 = node[2]; - - //without ghost nodes - if (ix1 < minX1 || ix1 > maxX1 || ix2 < minX2 || ix2 > maxX2 ||ix3 < minX3 || ix3 > maxX3 ) continue; - - if(bcArray->isFluid(ix1,ix2,ix3)) - { - double q=(*ssv)(normalq,ix1,ix2,ix3) ; - double numPoint=(*ssv)(numberOfPoint,ix1,ix2,ix3) ; - if (q==0||numPoint!=3)continue; - // if (q==0)continue; - - int index = 0; - 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)) ); - - //////get normal and distance////// - double A,B,C; - A= (*ssv)(normalX1,ix1,ix2,ix3) ; - B= (*ssv)(normalX2,ix1,ix2,ix3) ; - C= (*ssv)(normalX3,ix1,ix2,ix3) ; - - /////////// - //compute y plus - //double vtxSonja, vtySonja, vtzSonja; //tangent velocity - // double temp = (*av)(ix1,ix2,ix3,AvVx)*A+(*av)(ix1,ix2,ix3,AvVy)*B+(*av)(ix1,ix2,ix3,AvVz)*C; - // vtxSonja = (*av)(ix1,ix2,ix3,AvVx)-normals[0]*temp; - // vtySonja = (*av)(ix1,ix2,ix3,AvVy)-normals[1]*temp; - // vtzSonja = (*av)(ix1,ix2,ix3,AvVz)-normals[2]*temp; - - double vtx= (B*B*(*ssv)(AvVx,ix1,ix2,ix3) + C*C*(*ssv)(AvVx,ix1,ix2,ix3) - A*B*(*ssv)(AvVy,ix1,ix2,ix3) - A*C*(*ssv)(AvVy,ix1,ix2,ix3))/(A*A+B*B+C*C); - double vty=(-(A*B*(*ssv)(AvVx,ix1,ix2,ix3)) + A*A*(*ssv)(AvVy,ix1,ix2,ix3) + C*C*(*ssv)(AvVy,ix1,ix2,ix3) - B*C*(*ssv)(AvVz,ix1,ix2,ix3))/(A*A+B*B+C*C); - double vtz=(-(A*C*(*ssv)(AvVx,ix1,ix2,ix3)) - B*C*(*ssv)(AvVy,ix1,ix2,ix3) + A*A*(*ssv)(AvVz,ix1,ix2,ix3) + B*B*(*ssv)(AvVz,ix1,ix2,ix3))/(A*A+B*B+C*C); - - double normVt = sqrt(vtx*vtx+vty*vty+vtz*vtz)+1e-100; - double nvtx = vtx / normVt; - double nvty = vty / normVt; - double nvtz = vtz / normVt; - - double sx=0.5*((*ssv)(AvSxx,ix1,ix2,ix3)*nvtx+(*ssv)(AvSxy,ix1,ix2,ix3)*nvty+(*ssv)(AvSxz,ix1,ix2,ix3)*nvtz); - double sy=0.5*((*ssv)(AvSxy,ix1,ix2,ix3)*nvtx+(*ssv)(AvSyy,ix1,ix2,ix3)*nvty+(*ssv)(AvSyz,ix1,ix2,ix3)*nvtz); - double sz=0.5*((*ssv)(AvSxz,ix1,ix2,ix3)*nvtx+(*ssv)(AvSyz,ix1,ix2,ix3)*nvty+(*ssv)(AvSzz,ix1,ix2,ix3)*nvtz); - double sabs=sqrt(sx*sx+sy*sy+sz*sz); - - double viscosity = (1.0/3.0)*(1.0/collFactor-0.5); - double rho = 1.0; - double utau=sqrt(viscosity/rho*sabs); - - // double q=(*av)(ix1,ix2,ix3,normalq) ; - double yPlus = (utau*q)/viscosity; - - data[index++].push_back(yPlus); - data[index++].push_back(utau); - } - } - } - } - -} -////////////////////////////////////////////////////////////////////////// -void ShearStressCoProcessor::reset(double step) -{ - if(Resetscheduler->isDue(step) ) - resetData(step); - - UBLOG(logDEBUG3, "resetCoProcessor::update:" << step); -} -////////////////////////////////////////////////////////////////////////// -void ShearStressCoProcessor::resetData(double step) -{ - for(int level = minInitLevel; level<=maxInitLevel;level++) - { - for(SPtr<Block3D> block : blockVector[level]) - { - if (block) - { - UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); - UbTupleDouble3 blockLengths = grid->getBlockLengths(block); - UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); - double dx = grid->getDeltaX(block); - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - SPtr<ShearStressValuesArray3D> ssv = kernel->getDataSet()->getShearStressValues(); - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int maxX1 = int(distributions->getNX1()); - int maxX2 = int(distributions->getNX2()); - int maxX3 = int(distributions->getNX3()); - - for(int ix3=minX3; ix3<maxX3-1; ix3++) - { - for(int ix2=minX2; ix2<maxX2-1; ix2++) - { - for(int ix1=minX1; ix1<maxX1-1; ix1++) - { - if(!bcArray->isUndefined(ix1,ix2,ix3) && !bcArray->isSolid(ix1,ix2,ix3)) - { - ////////////////////////////////////////////////////////////////////////// - //compute average values - ////////////////////////////////////////////////////////////////////////// - (*ssv)(AvVx,ix1,ix2,ix3) = 0.0; - (*ssv)(AvVy,ix1,ix2,ix3) = 0.0; - (*ssv)(AvVz,ix1,ix2,ix3) = 0.0; - - (*ssv)(AvSxx,ix1,ix2,ix3) = 0.0; - (*ssv)(AvSyy,ix1,ix2,ix3) = 0.0; - (*ssv)(AvSzz,ix1,ix2,ix3) = 0.0; - (*ssv)(AvSxy,ix1,ix2,ix3) = 0.0; - (*ssv)(AvSyz,ix1,ix2,ix3) = 0.0; - (*ssv)(AvSxz,ix1,ix2,ix3) = 0.0; - ////////////////////////////////////////////////////////////////////////// - } - } - } - } - } - } - } -} -////////////////////////////////////////////////////////////////////////// -void ShearStressCoProcessor::addInteractor( SPtr<D3Q27Interactor> interactor ) -{ - interactors.push_back(interactor); -} -////////////////////////////////////////////////////////////////////////// -void ShearStressCoProcessor::findPlane(int ix1,int ix2,int ix3,SPtr<Grid3D> grid,SPtr<Block3D> block,double &A,double &B,double &C,double &D,double &ii) -{ - 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; - SPtr<BoundaryConditions> bcPtr; - double dx = grid->getDeltaX(block); - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - bcPtr=bcArray->getBC(ix1,ix2,ix3); - int x,y,z; - - - 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) - +"T="+UbSystem::toString(bcPtr->getQ(D3Q27System::T))+"B="+UbSystem::toString(bcPtr->getQ(D3Q27System::B)) - +"E="+UbSystem::toString(bcPtr->getQ(D3Q27System::E))+"W="+UbSystem::toString(bcPtr->getQ(D3Q27System::W))+"N="+UbSystem::toString(bcPtr->getQ(D3Q27System::N)) - +"S="+UbSystem::toString(bcPtr->getQ(D3Q27System::S))+"NE="+UbSystem::toString(bcPtr->getQ(D3Q27System::NE))+"SW="+UbSystem::toString(bcPtr->getQ(D3Q27System::SW)) - +"SE="+UbSystem::toString(bcPtr->getQ(D3Q27System::SE))+"NW="+UbSystem::toString(bcPtr->getQ(D3Q27System::NW)) - +"TE="+ - UbSystem::toString(bcPtr->getQ(D3Q27System::TE))+"BW="+UbSystem::toString(bcPtr->getQ(D3Q27System::BW))+"BE="+UbSystem::toString(bcPtr->getQ(D3Q27System::BE))+"TW="+ - UbSystem::toString(bcPtr->getQ(D3Q27System::TW))+"TN="+UbSystem::toString(bcPtr->getQ(D3Q27System::TN))+"BS="+UbSystem::toString(bcPtr->getQ(D3Q27System::BS))+"BN="+ - UbSystem::toString(bcPtr->getQ(D3Q27System::BN))+"TS="+UbSystem::toString(bcPtr->getQ(D3Q27System::TS))+"TNE="+UbSystem::toString(bcPtr->getQ(D3Q27System::TNE))+"TNW="+ - UbSystem::toString(bcPtr->getQ(D3Q27System::TNW))+"TSE="+UbSystem::toString(bcPtr->getQ(D3Q27System::TSE))+"TSW="+UbSystem::toString(bcPtr->getQ(D3Q27System::TSW))+"BNE="+ - UbSystem::toString(bcPtr->getQ(D3Q27System::BNE))+"BNW="+UbSystem::toString(bcPtr->getQ(D3Q27System::BNW))+"BSE="+UbSystem::toString(bcPtr->getQ(D3Q27System::BSE))+"BSW="+UbSystem::toString(bcPtr->getQ(D3Q27System::BSW)*dx) - ) ) ;}} - - - if(InterpolationProcessor::iCellHasSolid(bcArray, x, y, z)) - { - for(int i = x; i <= x + 1; i++){ - for(int j = y; j <= y + 1; j++){ - for (int k = z; k <= z + 1; k++) - { - Vector3D pointplane1 = grid->getNodeCoordinates(block, i, j, k); - - double iph=pointplane1[0]; - double jph=pointplane1[1]; - double kph=pointplane1[2]; - - if(!bcArray->isSolid(i, j, k)) - { - SPtr<BoundaryConditions> bcPtrIn=bcArray->getBC(i,j,k); - if(bcPtrIn) - { - for(int fdir=D3Q27System::FSTARTDIR; fdir<=D3Q27System::FENDDIR; fdir++) - { - if( ii<=2) - { - LBMReal q = bcPtrIn->getQ(fdir); - if (q!=999.00000) - { - if ( fdir==D3Q27System::E ) - { - //if(!bcArray->isSolid(i, j, k))continue; - if (i+q<=x+1) - { - if (ii==0) { x1plane=iph+q*dx; y1plane=jph; z1plane=kph; ii++; } - else if (ii==1) { x2plane=iph+q*dx; y2plane=jph; z2plane=kph; if (x1plane!=x2plane||y1plane!=y2plane||z1plane!=z2plane) ii++; } - else if(ii==2) { x3plane=iph+q*dx; y3plane=jph; z3plane=kph; if ((x3plane!=x1plane||y3plane!=y1plane||z3plane!=z1plane)&&(x2plane!=x3plane||y2plane!=y3plane||z2plane!=z3plane)) ii++;} - } - } - if ( fdir==D3Q27System::W ) - { - //if(!bcArray->isSolid(i, j, k))continue; - if (i-q>=x) - { - if (ii==0) { x1plane=iph-q*dx; y1plane=jph; z1plane=kph; ii++; } - else if (ii==1) { x2plane=iph-q*dx; y2plane=jph; z2plane=kph; if (x1plane!=x2plane||y1plane!=y2plane||z1plane!=z2plane) ii++; } - else if(ii==2) { x3plane=iph-q*dx; y3plane=jph; z3plane=kph; if ((x3plane!=x1plane||y3plane!=y1plane||z3plane!=z1plane)&&(x2plane!=x3plane||y2plane!=y3plane||z2plane!=z3plane)) ii++;} - } - } - if ( fdir==D3Q27System::N ) - { - //if(!bcArray->isSolid(i, j, k))continue; - if(j+q<=y+1) - { - if (ii==0) { x1plane=iph; y1plane=jph+q*dx; z1plane=kph; ii++; } - else if (ii==1) { x2plane=iph; y2plane=jph+q*dx; z2plane=kph; if (x1plane!=x2plane||y1plane!=y2plane||z1plane!=z2plane) ii++; } - else if (ii==2) { x3plane=iph; y3plane=jph+q*dx; z3plane=kph; if ((x3plane!=x1plane||y3plane!=y1plane||z3plane!=z1plane)&&(x2plane!=x3plane||y2plane!=y3plane||z2plane!=z3plane)) ii++;} - } - } - if ( fdir==D3Q27System::S ) - { - //if(!bcArray->isSolid(i, j, k))continue; - if (j-q>=y) - { - if (ii==0) { x1plane=iph; y1plane=jph-q*dx; z1plane=kph; ii++; } - else if (ii==1) { x2plane=iph; y2plane=jph-q*dx; z2plane=kph; if (x1plane!=x2plane||y1plane!=y2plane||z1plane!=z2plane) ii++; } - else if (ii==2) { x3plane=iph; y3plane=jph-q*dx; z3plane=kph; if ((x3plane!=x1plane||y3plane!=y1plane||z3plane!=z1plane)&&(x2plane!=x3plane||y2plane!=y3plane||z2plane!=z3plane)) ii++;} - } - } - - if ( fdir==D3Q27System::T ) - { - //if(!bcArray->isSolid(i, j, k))continue; - if(k+q<=z+1) - { - if (ii==0) { x1plane=iph; y1plane=jph; z1plane=kph+q*dx; ii++; } - else if (ii==1) { x2plane=iph; y2plane=jph; z2plane=kph+q*dx; if (x1plane!=x2plane||y1plane!=y2plane||z1plane!=z2plane) ii++; } - else if (ii==2) { x3plane=iph; y3plane=jph; z3plane=kph+q*dx; if ((x3plane!=x1plane||y3plane!=y1plane||z3plane!=z1plane)&&(x2plane!=x3plane||y2plane!=y3plane||z2plane!=z3plane)) ii++;} - } - } - if ( fdir==D3Q27System::B ) - { - //if(!bcArray->isSolid(i, j, k))continue; - if (k-q>=z) - { - if (ii==0) { x1plane=iph; y1plane=jph; z1plane=kph-q*dx; ii++; } - else if (ii==1) { x2plane=iph; y2plane=jph; z2plane=kph-q*dx; if (x1plane!=x2plane||y1plane!=y2plane||z1plane!=z2plane) ii++; } - else if (ii==2) { x3plane=iph; y3plane=jph; z3plane=kph-q*dx; if ((x3plane!=x1plane||y3plane!=y1plane||z3plane!=z1plane)&&(x2plane!=x3plane||y2plane!=y3plane||z2plane!=z3plane)) ii++;} - } - } - - } - } - } - } - } - } - } - } - - A = y1plane* (z2plane - z3plane) + y2plane*(z3plane - z1plane) + y3plane* (z1plane - z2plane); - B = z1plane* (x2plane - x3plane) + z2plane*(x3plane - x1plane) + z3plane* (x1plane - x2plane) ; - C = x1plane* (y2plane - y3plane) + x2plane*(y3plane - y1plane) + x3plane* (y1plane - y2plane) ; - D =-( x1plane*(y2plane*z3plane - y3plane*z2plane)+x2plane*(y3plane*z1plane - y1plane*z3plane) + x3plane* (y1plane* z2plane - y2plane* z1plane)); - } - if(ii!=3){ - - {{UB_THROW( UbException(UB_EXARGS,"ii is="+UbSystem::toString(ii)+" ix1="+UbSystem::toString(ix1)+" ix2="+UbSystem::toString(ix2)+" ix3="+UbSystem::toString(ix3)+" Block3D::GlobalID="+UbSystem::toString(block->getGlobalID())+" dx="+UbSystem::toString(dx) - +" T="+UbSystem::toString(bcPtr->getQ(D3Q27System::T))+" B="+UbSystem::toString(bcPtr->getQ(D3Q27System::B)) - +" E="+UbSystem::toString(bcPtr->getQ(D3Q27System::E))+" W="+UbSystem::toString(bcPtr->getQ(D3Q27System::W))+" N="+UbSystem::toString(bcPtr->getQ(D3Q27System::N)) - +" S="+UbSystem::toString(bcPtr->getQ(D3Q27System::S))+" NE="+UbSystem::toString(bcPtr->getQ(D3Q27System::NE))+" SW="+UbSystem::toString(bcPtr->getQ(D3Q27System::SW)) - +" SE="+UbSystem::toString(bcPtr->getQ(D3Q27System::SE))+" NW="+UbSystem::toString(bcPtr->getQ(D3Q27System::NW)) - +" TE="+ - UbSystem::toString(bcPtr->getQ(D3Q27System::TE))+" BW="+UbSystem::toString(bcPtr->getQ(D3Q27System::BW))+" BE="+UbSystem::toString(bcPtr->getQ(D3Q27System::BE))+" TW="+ - UbSystem::toString(bcPtr->getQ(D3Q27System::TW))+" TN="+UbSystem::toString(bcPtr->getQ(D3Q27System::TN))+" BS="+UbSystem::toString(bcPtr->getQ(D3Q27System::BS))+" BN="+ - UbSystem::toString(bcPtr->getQ(D3Q27System::BN))+" TS="+UbSystem::toString(bcPtr->getQ(D3Q27System::TS))+" TNE="+UbSystem::toString(bcPtr->getQ(D3Q27System::TNE))+" TNW="+ - UbSystem::toString(bcPtr->getQ(D3Q27System::TNW))+" TSE="+UbSystem::toString(bcPtr->getQ(D3Q27System::TSE))+" TSW="+UbSystem::toString(bcPtr->getQ(D3Q27System::TSW))+" BNE="+ - UbSystem::toString(bcPtr->getQ(D3Q27System::BNE))+" BNW="+UbSystem::toString(bcPtr->getQ(D3Q27System::BNW))+" BSE="+UbSystem::toString(bcPtr->getQ(D3Q27System::BSE))+" BSW="+UbSystem::toString(bcPtr->getQ(D3Q27System::BSW)) - ) ) ;}} - - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////// -bool ShearStressCoProcessor::checkUndefindedNodes( SPtr<BCArray3D> bcArray,int ix1,int ix2,int ix3) -{ - for(int i = ix1; i <= ix1 + 1; i++){ - for(int j = ix2; j <= ix2 + 1; j++){ - for (int k = ix3; k <= ix3 + 1; k++) - { - if(bcArray->isUndefined(i, j, k)) return true; - } - } - } - return false; -} -////////////////////////////////////////////////////////////////////////////////////// -void ShearStressCoProcessor::initDistance() -{ - for(SPtr<D3Q27Interactor> interactor : interactors) - { - typedef std::map<SPtr<Block3D>, std::set< std::vector<int> > > TransNodeIndicesMap; - for (TransNodeIndicesMap::value_type t : interactor->getBcNodeIndicesMap()) - { - SPtr<Block3D> block = t.first; - std::set< std::vector<int> >& transNodeIndicesSet = t.second; - - UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); - UbTupleDouble3 blockLengths = grid->getBlockLengths(block); - UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); - double dx = grid->getDeltaX(block); - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - SPtr<ShearStressValuesArray3D> ssv = kernel->getDataSet()->getShearStressValues(); - - int ghostLayer = kernel->getGhostLayerWidth(); - LBMReal collFactor = kernel->getCollisionFactor(); - - int minX1 = ghostLayer; - int maxX1 = (int)bcArray->getNX1() - 1 - ghostLayer; - int minX2 = ghostLayer; - int maxX2 = (int)bcArray->getNX2() - 1 - ghostLayer; - int minX3 = ghostLayer; - int maxX3 = (int)bcArray->getNX3() - 1 - ghostLayer; - - for(std::vector<int> node : transNodeIndicesSet) - { - int ix1 = node[0]; - int ix2 = node[1]; - int ix3 = node[2]; - - //without ghost nodes - if (ix1 < minX1 || ix1 > maxX1 || ix2 < minX2 || ix2 > maxX2 ||ix3 < minX3 || ix3 > maxX3 ) continue; - - if(bcArray->isFluid(ix1,ix2,ix3) ) - { - SPtr<BoundaryConditions> bc = bcArray->getBC(ix1,ix2,ix3); - if((bc->hasDensityBoundary()||bc->hasVelocityBoundary()))continue; - int numberOfCorner=0; - - if(bc->getQ(D3Q27System::T) !=999.000){ numberOfCorner++;} - if(bc->getQ(D3Q27System::B) !=999.000){ numberOfCorner++;} - if(bc->getQ(D3Q27System::E) !=999.000){ numberOfCorner++;} - if(bc->getQ(D3Q27System::W) !=999.000){ numberOfCorner++;} - if(bc->getQ(D3Q27System::N) !=999.000){ numberOfCorner++;} - if(bc->getQ(D3Q27System::S) !=999.000){ numberOfCorner++;} - // if(bc->hasVelocityBoundary()||bc->hasDensityBoundary())continue; - if(numberOfCorner>1)continue; - if(checkUndefindedNodes( bcArray, ix1,ix2,ix3))continue; - - - //////get normal and distance////// - double A,B,C,D,ii=0.0; - findPlane(ix1,ix2,ix3,grid,block,A,B,C,D,ii); - Vector3D pointplane1 = grid->getNodeCoordinates(block, ix1,ix2,ix3); - double ix1ph= pointplane1[0]; - double ix2ph= pointplane1[1]; - double ix3ph= pointplane1[2]; - double normalDis; - if(ii!=3) - { - UB_THROW( UbException(UB_EXARGS,"not enough points to create plane"+UbSystem::toString(ii))); - } - else - { - double s = A*ix1ph + B*ix2ph + C*ix3ph + D;//The sign of s = Ax + By + Cz + D determines which side the point (x,y,z) lies with respect to the plane. If s > 0 then the point lies on the same side as the normal (A,B,C). If s < 0 then it lies on the opposite side, if s = 0 then the point (x,y,z) lies on the plane. - if (s>0){s=1;} else if (s<0){s=-1;}else {s=0;} - - normalDis=((A*ix1ph + B*ix2ph + C*ix3ph + D)/sqrt(A*A+B*B+C*C));///distance point to plane xp-Xw=distance - normalDis*=s; - - (*ssv)(normalX1,ix1,ix2,ix3) = A; - (*ssv)(normalX2,ix1,ix2,ix3) = B; - (*ssv)(normalX3,ix1,ix2,ix3) = C; - (*ssv)(normalq,ix1,ix2,ix3) = normalDis; - (*ssv)(numberOfPoint,ix1,ix2,ix3) = ii; - - } - } - } - } - } -} diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.h deleted file mode 100644 index 3ab85f3ae..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/ShearStressCoProcessor.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef D3Q27ShearStressCoProcessor_H -#define D3Q27ShearStressCoProcessor_H - -#include <PointerDefinitions.h> -#include <vector> -#include <string> - -#include <basics/utilities/UbTuple.h> - -#include "CoProcessor.h" - -class Block3D; -class Grid3D; -class UbScheduler; -class D3Q27Interactor; -class BCArray3D; -class WbWriter; - -//! \brief Computes the shear stress and y plus values and writes to parallel .vtk -//! \details writes at given time intervals specified in scheduler (s) and resets according to scheduler (rs). -//! Take root to obtain during post processing (paraview). -//! \author K. Kucher, S. Uphoff, M. Geier, E. Goraki Fard - -class ShearStressCoProcessor: public CoProcessor -{ -public: - //! Default constructor - ShearStressCoProcessor(){} - //! Constructor - ShearStressCoProcessor(SPtr<Grid3D> grid, const std::string& path, WbWriter* const writer, - SPtr<UbScheduler> s, SPtr<UbScheduler> rs); - virtual ~ShearStressCoProcessor(); - - void process(double step) override; - - void addInteractor(SPtr<D3Q27Interactor> interactor); -protected: - //! Computes average and shear stress values of macroscopic quantities - void calculateShearStress(double timeStep); - //! Prepare data and write in .vtk file - void collectData(double step); - //! Reset data - void resetData(double step); - //! prepare data - void addData(); - void clearData(); - void reset(double step); - void findPlane(int ix1,int ix2,int ix3, SPtr<Grid3D> grid, SPtr<Block3D> block,double &A,double &B,double &C,double &D,double &ii); - bool checkUndefindedNodes(SPtr<BCArray3D> bcArray,int ix1,int ix2,int ix3); - void initDistance(); - -private: - std::vector<UbTupleFloat3> nodes; - std::vector<std::string> datanames; - std::vector<std::vector<double> > data; - std::string path; - std::vector<SPtr<D3Q27Interactor> > interactors; - std::vector<double> normals; - int gridRank; - WbWriter* writer; - SPtr<UbScheduler> Resetscheduler; //additional scheduler to restart averaging after a given interval - int minInitLevel; //min init level - int maxInitLevel; - std::vector<std::vector<SPtr<Block3D> > > blockVector; - enum Values{AvVx = 0, AvVy = 1, AvVz = 2, AvSxx = 3, AvSyy = 4, AvSzz = 5, AvSxy = 6, AvSyz = 7, AvSxz = 8, normalX1 = 9, normalX2 = 10, normalX3 = 11, normalq = 12,numberOfPoint=13}; -}; - - -#endif /* D3Q27ShearStressCoProcessor_H */ diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp deleted file mode 100644 index 79dafae06..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.cpp +++ /dev/null @@ -1,1001 +0,0 @@ -#include "TimeAveragedValuesCoProcessor.h" - - -#include "LBMKernel.h" -#include "BCProcessor.h" - -#include "basics/writer/WbWriterVtkXmlASCII.h" -#include "DataSet3D.h" -#include "Grid3D.h" -#include "Block3D.h" -#include "Communicator.h" -#include "UbScheduler.h" - -#include "BCArray3D.h" - - -TimeAveragedValuesCoProcessor::TimeAveragedValuesCoProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -TimeAveragedValuesCoProcessor::TimeAveragedValuesCoProcessor(SPtr<Grid3D> grid, const std::string& path, WbWriter* const writer, - SPtr<UbScheduler> s, SPtr<Communicator> comm, int options) - : CoProcessor(grid, s), - path(path), - writer(writer), - comm(comm), - options(options) -{ - init(); - planarAveraging = false; - timeAveraging = true; -} -////////////////////////////////////////////////////////////////////////// -TimeAveragedValuesCoProcessor::TimeAveragedValuesCoProcessor(SPtr<Grid3D> grid, const std::string& path, WbWriter* const writer, - SPtr<UbScheduler> s, SPtr<Communicator> comm, int options, - std::vector<int> levels, std::vector<double>& levelCoords, std::vector<double>& bounds, bool timeAveraging) - : CoProcessor(grid, s), - path(path), - writer(writer), - comm(comm), - options(options), - levels(levels), - levelCoords(levelCoords), - bounds(bounds), - timeAveraging(timeAveraging) -{ - init(); - planarAveraging = true; -} -////////////////////////////////////////////////////////////////////////// -void TimeAveragedValuesCoProcessor::init() -{ - root = comm->isRoot(); - gridRank = grid->getRank(); - minInitLevel = this->grid->getCoarsestInitializedLevel(); - maxInitLevel = this->grid->getFinestInitializedLevel(); - - withGhostLayer = false; - iMinC = 1; - - minStep = scheduler->getMinBegin(); - maxStep = scheduler->getMaxEnd(); - numberOfSteps = (maxStep - minStep); - - //function pointer - using namespace D3Q27System; - calcMacros = NULL; - if (compressible) - { - calcMacros = &calcCompMacroscopicValues; - } - else - { - calcMacros = &calcIncompMacroscopicValues; - } - - double begin = scheduler->getMinBegin(); - double gridTimeStep = grid->getTimeStep(); - - if (gridTimeStep == begin || gridTimeStep == 0) - { - initData(); - } - else - { - blockVector.clear(); - blockVector.resize(maxInitLevel + 1); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, gridRank, true, blockVector[level]); - if (blockVector[level].size() > 0) compressible = blockVector[level][0]->getKernel()->getCompressible(); - } - } -} -////////////////////////////////////////////////////////////////////////// -void TimeAveragedValuesCoProcessor::initData() -{ - blockVector.clear(); - blockVector.resize(maxInitLevel + 1); - - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, gridRank, true, blockVector[level]); - - if (blockVector[level].size() > 0) - compressible = blockVector[level][0]->getKernel()->getCompressible(); - - for (SPtr<Block3D> block : blockVector[level]) - { - UbTupleInt3 nx = grid->getBlockNX(); - - if ((options&Density) == Density) - { - SPtr<AverageValuesArray3D> ar = SPtr<AverageValuesArray3D>(new AverageValuesArray3D(2, val<1>(nx) + 1, val<2>(nx) + 1, val<3>(nx) + 1, 0.0)); - block->getKernel()->getDataSet()->setAverageDensity(ar); - } - - if ((options&Velocity) == Velocity) - { - SPtr<AverageValuesArray3D> av = SPtr<AverageValuesArray3D>(new AverageValuesArray3D(3, val<1>(nx) + 1, val<2>(nx) + 1, val<3>(nx) + 1, 0.0)); - block->getKernel()->getDataSet()->setAverageVelocity(av); - } - - if ((options&Fluctuations) == Fluctuations) - { - SPtr<AverageValuesArray3D> af = SPtr<AverageValuesArray3D>(new AverageValuesArray3D(6, val<1>(nx) + 1, val<2>(nx) + 1, val<3>(nx) + 1, 0.0)); - block->getKernel()->getDataSet()->setAverageFluctuations(af); - } - - if ((options&Triplecorrelations) == Triplecorrelations) - { - SPtr<AverageValuesArray3D> at = SPtr<AverageValuesArray3D>(new AverageValuesArray3D(10, val<1>(nx) + 1, val<2>(nx) + 1, val<3>(nx) + 1, 0.0)); - block->getKernel()->getDataSet()->setAverageTriplecorrelations(at); - } - } - } -} -////////////////////////////////////////////////////////////////////////// -void TimeAveragedValuesCoProcessor::process(double step) -{ - if (step == minStep) - { - initData(); - numberOfSteps = (maxStep - minStep)+1; - //DEBUG///////////////////// - //UBLOG(logINFO, "process::step = " << step << ", minStep = " << minStep << ", maxStep = " << maxStep << ", numberOfSteps = " << numberOfSteps << " init()"); - //////////////////////////// - } - calculateSubtotal(step); - - if (step == maxStep) - { - //DEBUG///////////////////// - //UBLOG(logINFO, "process::step = " << step << ", minStep = " << minStep << ", maxStep = " << maxStep << ", numberOfSteps = " << numberOfSteps); - //////////////////////////// - - //calculateAverageValues((double)numberOfFineSteps); - calculateAverageValues(numberOfSteps); - - if (timeAveraging) - { - collectData(step); - } - - if (planarAveraging) - { - planarAverage(step); - } - } - - UBLOG(logDEBUG3, "AverageValuesCoProcessor::update:" << step); -} -////////////////////////////////////////////////////////////////////////// -void TimeAveragedValuesCoProcessor::collectData(double step) -{ - int istep = int(step); - - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blockVector[level]) - { - if (block) - { - addData(block); - } - } - } - - std::string pfilePath, partPath, subfolder, cfilePath; - subfolder = "tav" + UbSystem::toString(istep); - pfilePath = path + "/tav/" + subfolder; - partPath = pfilePath + "/tav" + UbSystem::toString(gridRank) + "_" + UbSystem::toString(istep); - - std::string partName = writer->writeOctsWithNodeData(partPath, nodes, cells, datanames, data); - size_t found = partName.find_last_of("/"); - std::string piece = partName.substr(found + 1); - piece = subfolder + "/" + piece; - - std::vector<std::string> cellDataNames; - std::vector<std::string> pieces = comm->gather(piece); - if (root) - { - std::string pname = WbWriterVtkXmlASCII::getInstance()->writeParallelFile(pfilePath, pieces, datanames, cellDataNames); - UBLOG(logINFO, "TimeAveragedValuesCoProcessor::collectData() step: " << istep); - } - - clearData(); -} -////////////////////////////////////////////////////////////////////////// -void TimeAveragedValuesCoProcessor::clearData() -{ - nodes.clear(); - cells.clear(); - datanames.clear(); - data.clear(); -} -////////////////////////////////////////////////////////////////////////// -void TimeAveragedValuesCoProcessor::addData(const SPtr<Block3D> block) -{ - UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); - UbTupleDouble3 blockLengths = grid->getBlockLengths(block); - UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); - double dx = grid->getDeltaX(block); - int level = block->getLevel(); - - //Diese Daten werden geschrieben: - datanames.resize(0); - - datanames.push_back("level"); - datanames.push_back("Rho"); - - if ((options&Density) == Density) - { - datanames.push_back("taRho"); - datanames.push_back("taRhoF"); - } - - if ((options&Velocity) == Velocity) - { - datanames.push_back("taVx"); - datanames.push_back("taVy"); - datanames.push_back("taVz"); - } - - if ((options&Fluctuations) == Fluctuations) - { - datanames.push_back("taVxx"); - datanames.push_back("taVyy"); - datanames.push_back("taVzz"); - datanames.push_back("taVxy"); - datanames.push_back("taVxz"); - datanames.push_back("taVyz"); - datanames.push_back("taVyz"); - } - - if ((options&Triplecorrelations) == Triplecorrelations) - { - datanames.push_back("taVxxx"); - datanames.push_back("taVxxy"); - datanames.push_back("taVxxz"); - datanames.push_back("taVyyy"); - datanames.push_back("taVyyx"); - datanames.push_back("taVyyz"); - datanames.push_back("taVzzz"); - datanames.push_back("taVzzx"); - datanames.push_back("taVzzy"); - datanames.push_back("taVxyz"); - } - - - //datanames.push_back("AvP"); - //datanames.push_back("AvPrms"); - - - data.resize(datanames.size()); - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - SPtr<AverageValuesArray3D> ar = kernel->getDataSet()->getAverageDensity(); - SPtr<AverageValuesArray3D> av = kernel->getDataSet()->getAverageVelocity(); - SPtr<AverageValuesArray3D> af = kernel->getDataSet()->getAverageFluctuations(); - SPtr<AverageValuesArray3D> at = kernel->getDataSet()->getAverageTriplecorrelations(); - //int ghostLayerWidth = kernel->getGhostLayerWidth(); - - //knotennummerierung faengt immer bei 0 an! - unsigned int SWB, SEB, NEB, NWB, SWT, SET, NET, NWT; - - int minX1 = iMinC; - int minX2 = iMinC; - int minX3 = iMinC; - - int maxX1 = int(distributions->getNX1()); - int maxX2 = int(distributions->getNX2()); - int maxX3 = int(distributions->getNX3()); - - //nummern vergeben und node vector erstellen + daten sammeln - CbArray3D<int> nodeNumbers((int)maxX1, (int)maxX2, (int)maxX3, -1); - - maxX1 -= 2; - maxX2 -= 2; - maxX3 -= 2; - - LBMReal f[D3Q27System::ENDF + 1]; - LBMReal vx1, vx2, vx3, rho; - - //D3Q27BoundaryConditionPtr bcPtr; - - int nr = (int)nodes.size(); - - for (int ix3 = minX3; ix3 <= maxX3; ix3++) - { - for (int ix2 = minX2; ix2 <= maxX2; ix2++) - { - for (int ix1 = minX1; ix1 <= maxX1; ix1++) - { - if (!bcArray->isUndefined(ix1, ix2, ix3) && !bcArray->isSolid(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))); - - data[index++].push_back(level); - - distributions->getDistribution(f, ix1, ix2, ix3); - calcMacros(f, rho, vx1, vx2, vx3); - - data[index++].push_back(rho); - - - - if ((options&Density) == Density) - { - data[index++].push_back((*ar)(Rho, ix1, ix2, ix3)); - data[index++].push_back((*ar)(RhoF, ix1, ix2, ix3)); - } - - if ((options&Velocity) == Velocity) - { - data[index++].push_back((*av)(Vx, ix1, ix2, ix3)); - data[index++].push_back((*av)(Vy, ix1, ix2, ix3)); - data[index++].push_back((*av)(Vz, ix1, ix2, ix3)); - } - - if ((options&Fluctuations) == Fluctuations) - { - data[index++].push_back((*af)(Vxx, ix1, ix2, ix3)); - data[index++].push_back((*af)(Vyy, ix1, ix2, ix3)); - data[index++].push_back((*af)(Vzz, ix1, ix2, ix3)); - data[index++].push_back((*af)(Vxy, ix1, ix2, ix3)); - data[index++].push_back((*af)(Vxz, ix1, ix2, ix3)); - data[index++].push_back((*af)(Vyz, ix1, ix2, ix3)); - } - - if ((options&Triplecorrelations) == Triplecorrelations) - { - data[index++].push_back((*at)(Vxxx, ix1, ix2, ix3)); - data[index++].push_back((*at)(Vxxy, ix1, ix2, ix3)); - data[index++].push_back((*at)(Vxxz, ix1, ix2, ix3)); - data[index++].push_back((*at)(Vyyy, ix1, ix2, ix3)); - data[index++].push_back((*at)(Vyyx, ix1, ix2, ix3)); - data[index++].push_back((*at)(Vyyz, ix1, ix2, ix3)); - data[index++].push_back((*at)(Vzzz, ix1, ix2, ix3)); - data[index++].push_back((*at)(Vzzx, ix1, ix2, ix3)); - data[index++].push_back((*at)(Vzzy, ix1, ix2, ix3)); - data[index++].push_back((*at)(Vxyz, ix1, ix2, ix3)); - } - } - } - } - } - - 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)); - } - } - } - } -} -////////////////////////////////////////////////////////////////////////// -void TimeAveragedValuesCoProcessor::calculateAverageValues(double timeSteps) -{ - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - int i; - //#ifdef _OPENMP - // #pragma omp parallel for - //#endif - //for(SPtr<Block3D> block : blockVector[level]) - for (i = 0; i < blockVector[level].size(); i++) - { - SPtr<Block3D> block = blockVector[level][i]; - if (block) - { - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - SPtr<AverageValuesArray3D> ar = kernel->getDataSet()->getAverageDensity(); - SPtr<AverageValuesArray3D> av = kernel->getDataSet()->getAverageVelocity(); - SPtr<AverageValuesArray3D> af = kernel->getDataSet()->getAverageFluctuations(); - SPtr<AverageValuesArray3D> at = kernel->getDataSet()->getAverageTriplecorrelations(); - - int minX1 = iMinC; - int minX2 = iMinC; - int minX3 = iMinC; - - int maxX1 = int(distributions->getNX1()); - int maxX2 = int(distributions->getNX2()); - int maxX3 = int(distributions->getNX3()); - - maxX1 -= 2; - maxX2 -= 2; - maxX3 -= 2; - - LBMReal rho, ux, uy, uz, uxx, uzz, uyy, uxy, uxz, uyz, rhof; - - for (int ix3 = minX3; ix3 <= maxX3; ix3++) - { - for (int ix2 = minX2; ix2 <= maxX2; ix2++) - { - for (int ix1 = minX1; ix1 <= maxX1; ix1++) - { - if (!bcArray->isUndefined(ix1, ix2, ix3) && !bcArray->isSolid(ix1, ix2, ix3)) - { - ////////////////////////////////////////////////////////////////////////// - //compute average values - ////////////////////////////////////////////////////////////////////////// - - //mean density - if ((options&Density) == Density) - { - rho = (*ar)(Rho, ix1, ix2, ix3) / timeSteps; - rhof = (*ar)(RhoF, ix1, ix2, ix3) / timeSteps; - (*ar)(Rho, ix1, ix2, ix3) = rho; - (*ar)(RhoF, ix1, ix2, ix3) = rhof - rho*rho; - } - - //mean velocity - if ((options&Velocity) == Velocity) - { - ux = (*av)(Vx, ix1, ix2, ix3) / timeSteps; - uy = (*av)(Vy, ix1, ix2, ix3) / timeSteps; - uz = (*av)(Vz, ix1, ix2, ix3) / timeSteps; - - (*av)(Vx, ix1, ix2, ix3) = ux; - (*av)(Vy, ix1, ix2, ix3) = uy; - (*av)(Vz, ix1, ix2, ix3) = uz; - } - - //fluctuations - if ((options&Fluctuations) == Fluctuations) - { - uxx = (*af)(Vxx, ix1, ix2, ix3) / timeSteps; - uyy = (*af)(Vyy, ix1, ix2, ix3) / timeSteps; - uzz = (*af)(Vzz, ix1, ix2, ix3) / timeSteps; - uxy = (*af)(Vxy, ix1, ix2, ix3) / timeSteps; - uxz = (*af)(Vxz, ix1, ix2, ix3) / timeSteps; - uyz = (*af)(Vyz, ix1, ix2, ix3) / timeSteps; - - (*af)(Vxx, ix1, ix2, ix3) = uxx - ux*ux; - (*af)(Vyy, ix1, ix2, ix3) = uyy - uy*uy; - (*af)(Vzz, ix1, ix2, ix3) = uzz - uz*uz; - (*af)(Vxy, ix1, ix2, ix3) = uxy - ux*uy; - (*af)(Vxz, ix1, ix2, ix3) = uxz - ux*uz; - (*af)(Vyz, ix1, ix2, ix3) = uyz - uy*uz; - } - - if ((options&Triplecorrelations) == Triplecorrelations) - { - //triple-correlations - (*at)(Vxxx, ix1, ix2, ix3) = (*at)(Vxxx, ix1, ix2, ix3) / timeSteps - 3.0 * uxx*ux + 2.0 * ux*ux*ux; - (*at)(Vxxy, ix1, ix2, ix3) = (*at)(Vxxy, ix1, ix2, ix3) / timeSteps - 2.0 * uxy*ux - uxx*uy + 2.0 * ux*ux*uy; - (*at)(Vxxz, ix1, ix2, ix3) = (*at)(Vxxz, ix1, ix2, ix3) / timeSteps - 2.0 * uxz*ux - uxx*uz + 2.0 * ux*ux*uz; - (*at)(Vyyy, ix1, ix2, ix3) = (*at)(Vyyy, ix1, ix2, ix3) / timeSteps - 3.0 * uyy*uy + 2.0 * uy*uy*uy; - (*at)(Vyyx, ix1, ix2, ix3) = (*at)(Vyyx, ix1, ix2, ix3) / timeSteps - 2.0 * uxy*uy - uyy*ux + 2.0 * uy*uy*ux; - (*at)(Vyyz, ix1, ix2, ix3) = (*at)(Vyyz, ix1, ix2, ix3) / timeSteps - 2.0 * uyz*uy - uyy*uz + 2.0 * uy*uy*uz; - (*at)(Vzzz, ix1, ix2, ix3) = (*at)(Vzzz, ix1, ix2, ix3) / timeSteps - 3.0 * uzz*uz + 2.0 * uz*uz*uz; - (*at)(Vzzx, ix1, ix2, ix3) = (*at)(Vzzx, ix1, ix2, ix3) / timeSteps - 2.0 * uxz*uz - uzz*ux + 2.0 * uz*uz*ux; - (*at)(Vzzy, ix1, ix2, ix3) = (*at)(Vzzy, ix1, ix2, ix3) / timeSteps - 2.0 * uyz*uz - uzz*uy + 2.0 * uz*uz*uy; - (*at)(Vxyz, ix1, ix2, ix3) = (*at)(Vxyz, ix1, ix2, ix3) / timeSteps - uxy*uz - uxz*uy - uyz*ux + 2.0 * ux*uy*uz; - } - ////////////////////////////////////////////////////////////////////////// - } - } - } - } - } - } - } -} -////////////////////////////////////////////////////////////////////////// -void TimeAveragedValuesCoProcessor::calculateSubtotal(double step) -{ - if (scheduler->isDue(step)) - { - - //DEBUG///////////////////// - //UBLOG(logINFO, "calculateSubtotal::step = " << step); - //////////////////////////// - LBMReal f[27]; - - -//#ifdef _OPENMP -//#pragma omp parallel private (f) -//#endif - { - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - int i; -//#ifdef _OPENMP -//#pragma omp for schedule(dynamic) -//#endif - //for(SPtr<Block3D> block : blockVector[level]) - for (i = 0; i < blockVector[level].size(); i++) - { - SPtr<Block3D> block = blockVector[level][i]; - if (block) - { - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - SPtr<AverageValuesArray3D> ar = kernel->getDataSet()->getAverageDensity(); - SPtr<AverageValuesArray3D> av = kernel->getDataSet()->getAverageVelocity(); - SPtr<AverageValuesArray3D> af = kernel->getDataSet()->getAverageFluctuations(); - SPtr<AverageValuesArray3D> at = kernel->getDataSet()->getAverageTriplecorrelations(); - - int minX1 = iMinC; - int minX2 = iMinC; - int minX3 = iMinC; - - int maxX1 = int(distributions->getNX1()); - int maxX2 = int(distributions->getNX2()); - int maxX3 = int(distributions->getNX3()); - - maxX1 -= 2; - maxX2 -= 2; - maxX3 -= 2; - - for (int ix3 = minX3; ix3 <= maxX3; ix3++) - { - for (int ix2 = minX2; ix2 <= maxX2; ix2++) - { - for (int ix1 = minX1; ix1 <= maxX1; ix1++) - { - if (!bcArray->isUndefined(ix1, ix2, ix3) && !bcArray->isSolid(ix1, ix2, ix3)) - { - ////////////////////////////////////////////////////////////////////////// - //read distribution - //////////////////////////////////////////////////////////////////////////// - - distributions->getDistribution(f, ix1, ix2, ix3); - ////////////////////////////////////////////////////////////////////////// - //compute velocity - ////////////////////////////////////////////////////////////////////////// - LBMReal vx, vy, vz, rho; - calcMacros(f, rho, vx, vy, vz); - //double press = D3Q27System::calcPress(f, rho, vx, vy, vz); - - ////////////////////////////////////////////////////////////////////////// - //compute subtotals - ////////////////////////////////////////////////////////////////////////// - - //mean density - if ((options&Density) == Density) - { - (*ar)(0, ix1, ix2, ix3) = (*ar)(Rho, ix1, ix2, ix3) + rho; - (*ar)(RhoF, ix1, ix2, ix3) = (*ar)(RhoF, ix1, ix2, ix3) + rho*rho; - } - - //mean velocity - if ((options&Velocity) == Velocity) - { - (*av)(Vx, ix1, ix2, ix3) = (*av)(Vx, ix1, ix2, ix3) + vx; - (*av)(Vy, ix1, ix2, ix3) = (*av)(Vy, ix1, ix2, ix3) + vy; - (*av)(Vz, ix1, ix2, ix3) = (*av)(Vz, ix1, ix2, ix3) + vz; - } - - //fluctuations - if ((options&Fluctuations) == Fluctuations) - { - (*af)(Vxx, ix1, ix2, ix3) = (*af)(Vxx, ix1, ix2, ix3) + vx*vx; - (*af)(Vyy, ix1, ix2, ix3) = (*af)(Vyy, ix1, ix2, ix3) + vy*vy; - (*af)(Vzz, ix1, ix2, ix3) = (*af)(Vzz, ix1, ix2, ix3) + vz*vz; - (*af)(Vxy, ix1, ix2, ix3) = (*af)(Vxy, ix1, ix2, ix3) + vx*vy; - (*af)(Vxz, ix1, ix2, ix3) = (*af)(Vxz, ix1, ix2, ix3) + vx*vz; - (*af)(Vyz, ix1, ix2, ix3) = (*af)(Vyz, ix1, ix2, ix3) + vy*vz; - } - - //triple-correlations - if ((options&Triplecorrelations) == Triplecorrelations) - { - (*at)(Vxxx, ix1, ix2, ix3) = (*at)(Vxxx, ix1, ix2, ix3) + vx*vx*vx; - (*at)(Vxxy, ix1, ix2, ix3) = (*at)(Vxxy, ix1, ix2, ix3) + vx*vx*vy; - (*at)(Vxxz, ix1, ix2, ix3) = (*at)(Vxxz, ix1, ix2, ix3) + vx*vx*vz; - (*at)(Vyyy, ix1, ix2, ix3) = (*at)(Vyyy, ix1, ix2, ix3) + vy*vy*vy; - (*at)(Vyyx, ix1, ix2, ix3) = (*at)(Vyyx, ix1, ix2, ix3) + vy*vy*vx; - (*at)(Vyyz, ix1, ix2, ix3) = (*at)(Vyyz, ix1, ix2, ix3) + vy*vy*vz; - (*at)(Vzzz, ix1, ix2, ix3) = (*at)(Vzzz, ix1, ix2, ix3) + vz*vz*vz; - (*at)(Vzzx, ix1, ix2, ix3) = (*at)(Vzzx, ix1, ix2, ix3) + vz*vz*vx; - (*at)(Vzzy, ix1, ix2, ix3) = (*at)(Vzzy, ix1, ix2, ix3) + vz*vz*vy; - (*at)(Vxyz, ix1, ix2, ix3) = (*at)(Vxyz, ix1, ix2, ix3) + vx*vy*vz; - } - ////////////////////////////////////////////////////////////////////////// - } - } - } - } - } - } - } - } - } -} -////////////////////////////////////////////////////////////////////////// -void TimeAveragedValuesCoProcessor::planarAverage(double step) -{ - std::ofstream ostr; - - if (root) - { - int istep = int(step); - std::string fname = path + "/tav/" + "tav" + UbSystem::toString(istep) + ".csv"; - - - ostr.open(fname.c_str(), std::ios_base::out); - if (!ostr) - { - ostr.clear(); - std::string path = UbSystem::getPathFromString(fname); - if (path.size() > 0) { UbSystem::makeDirectory(path); ostr.open(fname.c_str(), std::ios_base::out); } - if (!ostr) throw UbException(UB_EXARGS, "couldn't open file " + fname); - } - - ostr << "z"; - - if ((options&Density) == Density) - { - ostr << ";Rho;RhoF"; - } - //mean velocity - if ((options&Velocity) == Velocity) - { - ostr << ";Vx;Vy;Vz"; - } - //fluctuations - if ((options&Fluctuations) == Fluctuations) - { - ostr << ";Vxx;Vyy;Vzz;Vxy;Vxz;Vyz"; - } - //triple-correlations - if ((options&Triplecorrelations) == Triplecorrelations) - { - ostr << ";Vxxx;Vxxy;Vxxz;Vyyy;Vyyx;Vyyz;Vzzz;Vzzx;Vzzy;Vxyz"; - } - ostr << "\n"; - } - - int size = (int)levels.size(); - int sizeOfLevelCoords = (int)levelCoords.size(); - - if (2 * size != sizeOfLevelCoords) - { - UB_THROW(UbException(UB_EXARGS, "Number of levels coordinates don't match number of levels!")); - } - - int k = 0; - - for (int i = 0; i < size; i++) - { - int level = levels[i]; - double dx = grid->getDeltaX(level); - double start = levelCoords[k]; - double stop = levelCoords[k + 1]; - - for (double j = start; j <stop; j += dx) - { - IntegrateValuesHelper intValHelp(grid, comm, - bounds[0], bounds[1], j, - bounds[3], bounds[4], j + dx, level); - - std::vector<IntegrateValuesHelper::CalcNodes> cnodes = intValHelp.getCNodes(); - //if (cnodes.size() == 0) - //{ - // continue; - //} - calculateAverageValuesForPlane(cnodes); - - if (root) - { - double numberOfFluidsNodes = intValHelp.getNumberOfFluidsNodes(); - if (numberOfFluidsNodes > 0) - { - ostr << j + 0.5*dx << std::setprecision(15); - - //mean density - if ((options&Density) == Density) - { - double rho = saRho / numberOfFluidsNodes; - double rhoF = saRhoF / numberOfFluidsNodes; - ostr << ";" << rho << ";" << rhoF; - } - - //mean velocity - if ((options&Velocity) == Velocity) - { - double Vx = saVx / numberOfFluidsNodes; - double Vy = saVy / numberOfFluidsNodes; - double Vz = saVz / numberOfFluidsNodes; - ostr << ";" << Vx << ";" << Vy << ";" << Vz; - } - //fluctuations - if ((options&Fluctuations) == Fluctuations) - { - double Vxx = saVxx / numberOfFluidsNodes; - double Vyy = saVyy / numberOfFluidsNodes; - double Vzz = saVzz / numberOfFluidsNodes; - double Vxy = saVxy / numberOfFluidsNodes; - double Vxz = saVxz / numberOfFluidsNodes; - double Vyz = saVyz / numberOfFluidsNodes; - ostr << ";" << Vxx << ";" << Vyy << ";" << Vzz << ";" << Vxy << ";" << Vxz << ";" << Vyz; - } - //triple-correlations - if ((options&Triplecorrelations) == Triplecorrelations) - { - double Vxxx = saVxxx / numberOfFluidsNodes; - double Vxxy = saVxxy / numberOfFluidsNodes; - double Vxxz = saVxxz / numberOfFluidsNodes; - double Vyyy = saVyyy / numberOfFluidsNodes; - double Vyyx = saVyyx / numberOfFluidsNodes; - double Vyyz = saVyyz / numberOfFluidsNodes; - double Vzzz = saVzzz / numberOfFluidsNodes; - double Vzzx = saVzzx / numberOfFluidsNodes; - double Vzzy = saVzzy / numberOfFluidsNodes; - double Vxyz = saVxyz / numberOfFluidsNodes; - ostr << ";" << Vxxx << ";" << Vxxy << ";" << Vxxz << ";" << Vyyy << ";" << Vyyx << ";" << Vyyz << ";" << Vzzz << ";" << Vzzx << ";" << Vzzy << ";" << Vxyz; - } - ostr << "\n"; - } - } - } - k += 2; - } - - if (root) - { - ostr.close(); - UBLOG(logINFO, "TimeAveragedValuesCoProcessor::planarAverage() step: " << (int)step); - } -} -////////////////////////////////////////////////////////////////////////// -void TimeAveragedValuesCoProcessor::reset() -{ - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - for (SPtr<Block3D> block : blockVector[level]) - { - if (block) - { - SPtr<AverageValuesArray3D> arho = block->getKernel()->getDataSet()->getAverageDensity(); - if (arho) - { - arho->reset(0.0); - } - - SPtr<AverageValuesArray3D> avel = block->getKernel()->getDataSet()->getAverageVelocity(); - if (avel) - { - avel->reset(0.0); - } - - SPtr<AverageValuesArray3D> afl = block->getKernel()->getDataSet()->getAverageFluctuations(); - if (afl) - { - afl->reset(0.0); - } - - SPtr<AverageValuesArray3D> atrp = block->getKernel()->getDataSet()->getAverageTriplecorrelations(); - if (atrp) - { - atrp->reset(0.0); - } - } - } - } -} -////////////////////////////////////////////////////////////////////////// -void TimeAveragedValuesCoProcessor::setWithGhostLayer(bool val) -{ - withGhostLayer = val; - - if (withGhostLayer) - { - iMinC = 0; - } - else - { - iMinC = 1; - } -} -////////////////////////////////////////////////////////////////////////// -bool TimeAveragedValuesCoProcessor::getWithGhostLayer() -{ - return withGhostLayer; -} -////////////////////////////////////////////////////////////////////////// -void TimeAveragedValuesCoProcessor::calculateAverageValuesForPlane(std::vector<IntegrateValuesHelper::CalcNodes>& cnodes) -{ - saVx = 0; - saVy = 0; - saVz = 0; - - saVxx = 0; - saVyy = 0; - saVzz = 0; - saVxy = 0; - saVxz = 0; - saVyz = 0; - - saVxxx = 0; - saVxxy = 0; - saVxxz = 0; - saVyyy = 0; - saVyyx = 0; - saVyyz = 0; - saVzzz = 0; - saVzzx = 0; - saVzzy = 0; - saVxyz = 0; - - saRho = 0; - saRhoF = 0; - - double lsaVx = 0; - double lsaVy = 0; - double lsaVz = 0; - - double lsaVxx = 0; - double lsaVyy = 0; - double lsaVzz = 0; - double lsaVxy = 0; - double lsaVxz = 0; - double lsaVyz = 0; - - double lsaVxxx = 0; - double lsaVxxy = 0; - double lsaVxxz = 0; - double lsaVyyy = 0; - double lsaVyyx = 0; - double lsaVyyz = 0; - double lsaVzzz = 0; - double lsaVzzx = 0; - double lsaVzzy = 0; - double lsaVxyz = 0; - - double lsaRho = 0; - double lsaRhoF = 0; - - for (IntegrateValuesHelper::CalcNodes cn : cnodes) - { - SPtr<ILBMKernel> kernel = cn.block->getKernel(); - SPtr<AverageValuesArray3D> averagedDensity = kernel->getDataSet()->getAverageDensity(); - SPtr<AverageValuesArray3D> averagedVelocity = kernel->getDataSet()->getAverageVelocity(); - SPtr<AverageValuesArray3D> averagedFluctuations = kernel->getDataSet()->getAverageFluctuations(); - SPtr<AverageValuesArray3D> averagedTriplecorrelations = kernel->getDataSet()->getAverageTriplecorrelations(); - - for (UbTupleInt3 node : cn.nodes) - { - double aRho = (*averagedDensity)(Rho, val<1>(node), val<2>(node), val<3>(node)); - double aRhoF = (*averagedDensity)(RhoF, val<1>(node), val<2>(node), val<3>(node)); - - double aVx = (*averagedVelocity)(Vx, val<1>(node), val<2>(node), val<3>(node)); - double aVy = (*averagedVelocity)(Vy, val<1>(node), val<2>(node), val<3>(node)); - double aVz = (*averagedVelocity)(Vz, val<1>(node), val<2>(node), val<3>(node)); - - double aVxx = (*averagedFluctuations)(Vxx, val<1>(node), val<2>(node), val<3>(node)); - double aVyy = (*averagedFluctuations)(Vyy, val<1>(node), val<2>(node), val<3>(node)); - double aVzz = (*averagedFluctuations)(Vzz, val<1>(node), val<2>(node), val<3>(node)); - double aVxy = (*averagedFluctuations)(Vxy, val<1>(node), val<2>(node), val<3>(node)); - double aVxz = (*averagedFluctuations)(Vxz, val<1>(node), val<2>(node), val<3>(node)); - double aVyz = (*averagedFluctuations)(Vyz, val<1>(node), val<2>(node), val<3>(node)); - - - double aVxxx = (*averagedTriplecorrelations)(Vxxx, val<1>(node), val<2>(node), val<3>(node)); - double aVxxy = (*averagedTriplecorrelations)(Vxxy, val<1>(node), val<2>(node), val<3>(node)); - double aVxxz = (*averagedTriplecorrelations)(Vxxz, val<1>(node), val<2>(node), val<3>(node)); - double aVyyy = (*averagedTriplecorrelations)(Vyyy, val<1>(node), val<2>(node), val<3>(node)); - double aVyyx = (*averagedTriplecorrelations)(Vyyx, val<1>(node), val<2>(node), val<3>(node)); - double aVyyz = (*averagedTriplecorrelations)(Vyyz, val<1>(node), val<2>(node), val<3>(node)); - double aVzzz = (*averagedTriplecorrelations)(Vzzz, val<1>(node), val<2>(node), val<3>(node)); - double aVzzx = (*averagedTriplecorrelations)(Vzzx, val<1>(node), val<2>(node), val<3>(node)); - double aVzzy = (*averagedTriplecorrelations)(Vzzy, val<1>(node), val<2>(node), val<3>(node)); - double aVxyz = (*averagedTriplecorrelations)(Vxyz, val<1>(node), val<2>(node), val<3>(node)); - - lsaRho += aRho; - lsaRhoF += aRhoF; - - lsaVx += aVx; - lsaVy += aVy; - lsaVz += aVz; - - lsaVxx += aVxx; - lsaVyy += aVyy; - lsaVzz += aVzz; - lsaVxy += aVxy; - lsaVxz += aVxz; - lsaVyz += aVyz; - - lsaVxxx += aVxxx; - lsaVxxy += aVxxy; - lsaVxxz += aVxxz; - lsaVyyy += aVyyy; - lsaVyyx += aVyyx; - lsaVyyz += aVyyz; - lsaVzzz += aVzzz; - lsaVzzx += aVzzx; - lsaVzzy += aVzzy; - lsaVxyz += aVxyz; - } - } - std::vector<double> values; - std::vector<double> rvalues; - - values.push_back(lsaRho); - values.push_back(lsaRhoF); - - values.push_back(lsaVx); - values.push_back(lsaVy); - values.push_back(lsaVz); - - values.push_back(lsaVxx); - values.push_back(lsaVyy); - values.push_back(lsaVzz); - values.push_back(lsaVxy); - values.push_back(lsaVxz); - values.push_back(lsaVyz); - - values.push_back(lsaVxxx); - values.push_back(lsaVxxy); - values.push_back(lsaVxxz); - values.push_back(lsaVyyy); - values.push_back(lsaVyyx); - values.push_back(lsaVyyz); - values.push_back(lsaVzzz); - values.push_back(lsaVzzx); - values.push_back(lsaVzzy); - values.push_back(lsaVxyz); - - rvalues = comm->gather(values); - if (root) - { - for (int i = 0; i < (int)rvalues.size(); i += 21) - { - saRho += rvalues[i]; - saRhoF += rvalues[i + 1]; - - saVx += rvalues[i + 2]; - saVy += rvalues[i + 3]; - saVz += rvalues[i + 4]; - - saVxx += rvalues[i + 5]; - saVyy += rvalues[i + 6]; - saVzz += rvalues[i + 7]; - saVxy += rvalues[i + 8]; - saVxz += rvalues[i + 9]; - saVyz += rvalues[i + 10]; - - saVxxx += rvalues[i + 11]; - saVxxy += rvalues[i + 12]; - saVxxz += rvalues[i + 13]; - saVyyy += rvalues[i + 14]; - saVyyx += rvalues[i + 15]; - saVyyz += rvalues[i + 16]; - saVzzz += rvalues[i + 17]; - saVzzx += rvalues[i + 18]; - saVzzy += rvalues[i + 19]; - saVxyz += rvalues[i + 20]; - } - } -} diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.h deleted file mode 100644 index 9a9df0f80..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/TimeAveragedValuesCoProcessor.h +++ /dev/null @@ -1,123 +0,0 @@ -#ifndef TimeAveragedValuesCoProcessor_H -#define TimeAveragedValuesCoProcessor_H - -#include <PointerDefinitions.h> -#include <string> -#include <vector> - -#include "CoProcessor.h" -#include "LBMSystem.h" -#include "IntegrateValuesHelper.h" - -class Communicator; -class Grid3D; -class UbScheduler; -class WbWriter; -class Block3D; - -//! \brief Computes the time averaged mean velocity and RMS values and writes to parallel .vtk -//! \details writes at given time intervals specified in scheduler (s), does averaging according to scheduler (Avs) and resets according to scheduler (rs). <br> -//! Computes the time averaged mean velocity \f$ u_{mean}=\frac{1}{N}\sum\limits_{i=1}^n u_{i} \f$ and RMS of fluctuations. You need to calculate a square root before plotting RMS. <br> -// -//! \author Konstantin Kutscher -// \f$ u_{mean}=\frac{1}{N}\sum\limits_{i=1}^n u_{i} \f$ - - -class TimeAveragedValuesCoProcessor : public CoProcessor -{ -public: - enum Options - { - Density = 1, - Velocity = 2, - Fluctuations = 4, - Triplecorrelations = 8, - - //Velocity = 1, - //Fluctuations = 2, - //Triplecorrelations = 4, - }; -public: - TimeAveragedValuesCoProcessor(); - TimeAveragedValuesCoProcessor(SPtr<Grid3D> grid, const std::string& path, WbWriter* const writer, - SPtr<UbScheduler> s, SPtr<Communicator> comm, int options); - TimeAveragedValuesCoProcessor(SPtr<Grid3D> grid, const std::string& path, WbWriter* const writer, - SPtr<UbScheduler> s, SPtr<Communicator> comm, int options, std::vector<int> levels, std::vector<double>& levelCoords, std::vector<double>& bounds, bool timeAveraging = true); - //! Make update - void process(double step); - //! Computes subtotal of velocity , fluctuations and triple correlations - void calculateSubtotal(double step); - void addLevelCoordinate(double c); - void reset(); - void setWithGhostLayer(bool val); - bool getWithGhostLayer(); - -protected: - //! Prepare data and write in .vtk file - void collectData(double step); - //! prepare data - void addData(const SPtr<Block3D> block); - void clearData(); - //! Computes average values of velocity , fluctuations and triple correlations - void calculateAverageValues(double timeStep); - - void init(); - void initData(); - void planarAverage(double step); - void calculateAverageValuesForPlane(std::vector<IntegrateValuesHelper::CalcNodes>& cnodes); - -private: - SPtr<Communicator> comm; - std::vector<UbTupleFloat3> nodes; - std::vector<UbTupleUInt8> cells; - std::vector<std::string> datanames; - std::vector<std::vector<double> > data; - std::vector<std::vector<SPtr<Block3D> > > blockVector; - bool root; - int minInitLevel; //min init level - int maxInitLevel; - int gridRank; - int resetStepRMS; - int resetStepMeans; - double averageInterval; - std::string path; - WbWriter* writer; - bool restart, compressible; - SPtr<UbScheduler> averageScheduler; //additional scheduler to averaging after a given interval - SPtr<UbScheduler> resetSchedulerRMS; //additional scheduler to restart averaging after a given interval - SPtr<UbScheduler> resetSchedulerMeans; //additional scheduler to restart averaging after a given interval - //labels for the different components, e.g. AvVxx for time averaged RMS: 1/n SUM((U-Umean)^2) - //you need to calculate a square root before plotting RMS - enum Density { Rho, RhoF }; - enum Velocity { Vx, Vy, Vz }; - enum Fluctuations { Vxx, Vyy, Vzz, Vxy, Vxz, Vyz }; - enum Triplecorrelations { Vxxx, Vxxy, Vxxz, Vyyy, Vyyx, Vyyz, Vzzz, Vzzx, Vzzy, Vxyz }; - - double saRho, saRhoF; - double saVx, saVy, saVz; - double saVxx, saVyy, saVzz, saVxy, saVxz, saVyz; - double saVxxx, saVxxy, saVxxz, saVyyy, saVyyx, saVyyz, saVzzz, saVzzx, saVzzy, saVxyz; - - int options; - double numberOfSteps; - double minStep; - double maxStep; - - int iMinX1, iMinX2, iMinX3; - //int iMaxX1, iMaxX2, iMaxX3; - int iMinC; - int iMaxC; - - typedef void(*CalcMacrosFct)(const LBMReal* const& /*feq[27]*/, LBMReal& /*(d)rho*/, LBMReal& /*vx1*/, LBMReal& /*vx2*/, LBMReal& /*vx3*/); - CalcMacrosFct calcMacros; - - bool planarAveraging; - bool timeAveraging; - std::vector<double> levelCoords; - std::vector<int> levels; - std::vector<double> bounds; - - bool withGhostLayer; - -}; -#endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/TimeDependentBCCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/TimeDependentBCCoProcessor.cpp deleted file mode 100644 index 9e97fee38..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/TimeDependentBCCoProcessor.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "TimeDependentBCCoProcessor.h" - -#include "Interactor3D.h" -#include "UbScheduler.h" -#include "Grid3D.h" - -TimeDependentBCCoProcessor::TimeDependentBCCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s) : CoProcessor(grid, s) -{ - -} -////////////////////////////////////////////////////////////////////////// -TimeDependentBCCoProcessor::~TimeDependentBCCoProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -void TimeDependentBCCoProcessor::process(double step) -{ - if(scheduler->isDue(step) ) - { - for (SPtr<Interactor3D> inter : interactors) - inter->updateInteractor(step); - UBLOG(logDEBUG3, "TimeDependentBCCoProcessor::update:" << step); - } -} -////////////////////////////////////////////////////////////////////////// -void TimeDependentBCCoProcessor::addInteractor( SPtr<Interactor3D> interactor ) -{ - interactors.push_back(interactor); -} - -////////////////////////////////////////////////////////////////////////// - - diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/TimeDependentBCCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/TimeDependentBCCoProcessor.h deleted file mode 100644 index 3e3795d6a..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/TimeDependentBCCoProcessor.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef TimeDependentBCCoProcessor_H -#define TimeDependentBCCoProcessor_H - -#include <vector> -#include <PointerDefinitions.h> - -#include "CoProcessor.h" - -class Interactor3D; -class Grid3D; - -//! \brief The class update interactors depend of time step. -//! \details TimeDependentBCCoProcessor update every time step information in BCAdapters throw Interactors -//! \author Sonja Uphoff, Kostyantyn Kucher -class TimeDependentBCCoProcessor : public CoProcessor -{ -public: - TimeDependentBCCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s); - virtual ~TimeDependentBCCoProcessor(); - - void process(double step) override; - - //! add interactors to CoProcessor - void addInteractor(SPtr<Interactor3D> interactor); - -private: - std::vector<SPtr<Interactor3D> > interactors; -}; - - -#endif /* TimeDependentBCCoProcessor_H */ diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.cpp deleted file mode 100644 index e0a1ab6a1..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* -* TimeseriesWriterCoProcessor.h -* -* Created on: 08.05.2013 -* Author: uphoff -*/ - -#include "TimeseriesCoProcessor.h" - -#include <fstream> - -#include "IntegrateValuesHelper.h" -#include "LBMUnitConverter.h" -#include "Communicator.h" -#include "UbScheduler.h" -#include "Grid3D.h" - - -TimeseriesCoProcessor::TimeseriesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, - SPtr<IntegrateValuesHelper> h1, - const std::string& path, SPtr<Communicator> comm) - : CoProcessor(grid, s), - h1(h1), - path(path), - comm(comm) -{ - if (comm->getProcessID() == comm->getRoot()) - { - std::ofstream ostr; - //fname = path+"/timeseries/timeseries"+UbSystem::toString(grid->getTimeStep())+".csv"; - fname = path+".csv"; - UBLOG(logINFO, "TimeseriesWriterCoProcessor::fname:" << fname); - ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app); - if(!ostr) - { - ostr.clear(); - std::string path = UbSystem::getPathFromString(fname); - if (path.size()>0) { UbSystem::makeDirectory(path); ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app); } - if(!ostr) throw UbException(UB_EXARGS,"couldn't open file "+fname); - } - ostr << "step;rho;vx;vy;vz;volume\n"; - ostr.close(); - UBLOG(logINFO, "TimeseriesWriterCoProcessor::Constructor:end"); - } -} -////////////////////////////////////////////////////////////////////////// -TimeseriesCoProcessor::~TimeseriesCoProcessor() -{ -} -////////////////////////////////////////////////////////////////////////// -void TimeseriesCoProcessor::process(double step) -{ - if(scheduler->isDue(step) ) - collectData(step); -} -////////////////////////////////////////////////////////////////////////// -void TimeseriesCoProcessor::collectData(double step) -{ - h1->calculateMQ(); - - UBLOG(logDEBUG3, "TimeseriesWriterCoProcessor::update:" << step); - - if (comm->getProcessID() == comm->getRoot()) - { - int istep = static_cast<int>(step); - std::ofstream ostr; - double cellsVolume = h1->getCellsVolume(); - - double rho=(h1->getRho())/cellsVolume; - double vx= (h1->getVx1())/cellsVolume; - double vy= (h1->getVx2())/cellsVolume; - double vz= (h1->getVx3())/cellsVolume; - double volume = cellsVolume; - - ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app); - if(!ostr) - { - ostr.clear(); - std::string path = UbSystem::getPathFromString(fname); - if(path.size()>0){ UbSystem::makeDirectory(path); ostr.open(fname.c_str(), std::ios_base::out | std::ios_base::app);} - if(!ostr) throw UbException(UB_EXARGS,"couldn't open file "+fname); - } - - ostr << istep << ";" << rho <<";" << vx << ";" << vy << ";" << vz << ";" << volume << "\n"; - ostr.close(); - } -} diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.h deleted file mode 100644 index f455065cb..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/TimeseriesCoProcessor.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * TimeseriesCoProcessor.h - * - * Created on: 08.05.2013 - * Author: uphoff - */ - -#ifndef TimeseriesCoProcessor_H -#define TimeseriesCoProcessor_H - -#include <PointerDefinitions.h> -#include <string> - -#include "CoProcessor.h" - -class Communicator; -class Grid3D; -class UbScheduler; -class IntegrateValuesHelper; - -//! \brief Writes timeseries of density and velocity to a file. -//! \details Uses Integrate values helper, scheduler must be set in testcase. -//! \author Sonja Uphoff -//! \date May 2013 - -class TimeseriesCoProcessor : public CoProcessor -{ -public: - TimeseriesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, SPtr<IntegrateValuesHelper> h1, const std::string& path, SPtr<Communicator> comm); - virtual ~TimeseriesCoProcessor(); - - //! calls collectData. - void process(double step) override; - -protected: - void collectData(double step); - - //! object that can compute spacial average values in 3D-subdomain. - SPtr<IntegrateValuesHelper> h1; - SPtr<Communicator> comm; - -private: - std::string path; //! output filename, e.g. pathname + "/steps/timeseries" - std::string fname; -}; - - -#endif /* TimeseriesCoProcessor_H */ diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.cpp deleted file mode 100644 index e3a4f4ee9..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.cpp +++ /dev/null @@ -1,268 +0,0 @@ -#include "TurbulenceIntensityCoProcessor.h" - -#include "LBMKernel.h" -#include "BCProcessor.h" -#include "basics/writer/WbWriterVtkXmlASCII.h" -#include "basics/utilities/UbMath.h" -#include "DataSet3D.h" -#include "Grid3D.h" -#include "Block3D.h" -#include "LBMUnitConverter.h" -#include "Communicator.h" -#include "UbScheduler.h" -#include "BCArray3D.h" - -TurbulenceIntensityCoProcessor::TurbulenceIntensityCoProcessor(SPtr<Grid3D> grid, const std::string& path, - WbWriter* const writer, - SPtr<UbScheduler> s, SPtr<Communicator> comm) - : CoProcessor(grid, s), - path(path), - comm(comm), - writer(writer) -{ - init(); -} -////////////////////////////////////////////////////////////////////////// -void TurbulenceIntensityCoProcessor::init() -{ - gridRank = grid->getRank(); - 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]); - - for(SPtr<Block3D> block : blockVector[level]) - { - UbTupleInt3 nx = grid->getBlockNX(); - SPtr<AverageValuesArray3D> averageValues = SPtr<AverageValuesArray3D>(new AverageValuesArray3D(val<1>(nx)+1, val<2>(nx)+1, val<3>(nx)+1, 4, 0.0)); - block->getKernel()->getDataSet()->setAverageValues(averageValues); - } - } -} -////////////////////////////////////////////////////////////////////////// -void TurbulenceIntensityCoProcessor::process(double step) -{ - calculateAverageValues(int(step)); - - if(scheduler->isDue(step) ) - collectData(step); - - UBLOG(logDEBUG3, "TurbulenceIntensityCoProcessor::update:" << step); -} -////////////////////////////////////////////////////////////////////////// -void TurbulenceIntensityCoProcessor::collectData(double step) -{ - int istep = int(step); - - for(int level = minInitLevel; level<=maxInitLevel;level++) - { - for(SPtr<Block3D> block : blockVector[level]) - { - if (block) - { - addData(block); - } - } - } - - std::string partName = writer->writeOctsWithNodeData(path+ UbSystem::toString(gridRank)+ "_" + UbSystem::toString(istep),nodes,cells,datanames,data); - size_t found=partName.find_last_of("//"); - std::string piece = partName.substr(found+1); - - std::vector<std::string> cellDataNames; - - std::vector<std::string> pieces = comm->gather(piece); - if (comm->getProcessID() == comm->getRoot()) - { - std::string pname = WbWriterVtkXmlASCII::getInstance()->writeParallelFile(path+"_"+UbSystem::toString(istep),pieces,datanames,cellDataNames); - - std::vector<std::string> filenames; - filenames.push_back(pname); - if (step == CoProcessor::scheduler->getMinBegin()) - { - WbWriterVtkXmlASCII::getInstance()->writeCollection(path+"_collection",filenames,istep,false); - } - else - { - WbWriterVtkXmlASCII::getInstance()->addFilesToCollection(path+"_collection",filenames,istep,false); - } - UBLOG(logINFO,"TurbulenceIntensityCoProcessor step: " << istep); - } - - clearData(); -} -////////////////////////////////////////////////////////////////////////// -void TurbulenceIntensityCoProcessor::clearData() -{ - nodes.clear(); - cells.clear(); - datanames.clear(); - data.clear(); -} -////////////////////////////////////////////////////////////////////////// -void TurbulenceIntensityCoProcessor::addData(const SPtr<Block3D> block) -{ - UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); - UbTupleDouble3 blockLengths = grid->getBlockLengths(block); - UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); - double dx = grid->getDeltaX(block); - - //Diese Daten werden geschrieben: - datanames.resize(0); - datanames.push_back("TI"); - - data.resize(datanames.size()); - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - SPtr<AverageValuesArray3D> av = kernel->getDataSet()->getAverageValues(); - //int ghostLayerWidth = kernel->getGhostLayerWidth(); - - //knotennummerierung faengt immer bei 0 an! - unsigned int SWB,SEB,NEB,NWB,SWT,SET,NET,NWT; - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int maxX1 = int(distributions->getNX1()); - int maxX2 = int(distributions->getNX2()); - int maxX3 = int(distributions->getNX3()); - - //nummern vergeben und node std::vector erstellen + daten sammeln - CbArray3D<int> nodeNumbers((int)maxX1, (int)maxX2, (int)maxX3,-1); - //D3Q27BoundaryConditionPtr bcPtr; - int nr = (int)nodes.size(); - - for(int ix3=minX3; ix3<maxX3-1; ix3++) - { - for(int ix2=minX2; ix2<maxX2-1; ix2++) - { - for(int ix1=minX1; ix1<maxX1-1; ix1++) - { - if(!bcArray->isUndefined(ix1,ix2,ix3) && !bcArray->isSolid(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)) ); - - //compute turbulence intensity - double temp = (*av)(ix1,ix2,ix3,AvVxxyyzz)/ - ((*av)(ix1,ix2,ix3,AvVx)*(*av)(ix1,ix2,ix3,AvVx)+ - (*av)(ix1,ix2,ix3,AvVy)*(*av)(ix1,ix2,ix3,AvVy)+ - (*av)(ix1,ix2,ix3,AvVz)*(*av)(ix1,ix2,ix3,AvVz)); - - LBMReal ti = sqrt(temp); - - if (UbMath::isNaN(ti)) UB_THROW( UbException(UB_EXARGS,"TI is not a number (nan or -1.#IND), sqrt(temp), where temp = "+UbSystem::toString(temp)+", AvVx = "+UbSystem::toString((*av)(ix1,ix2,ix3,AvVx))+" AvVy = "+UbSystem::toString((*av)(ix1,ix2,ix3,AvVy))+" AvVz = "+UbSystem::toString((*av)(ix1,ix2,ix3,AvVz)))); - - data[index++].push_back(ti); - } - } - } - } - //cell std::vector erstellen - for(int ix3=minX3; ix3<maxX3-1; ix3++) - { - for(int ix2=minX2; ix2<maxX2-1; ix2++) - { - for(int ix1=minX1; ix1<maxX1-1; 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) ); - } - } - } - } -} -////////////////////////////////////////////////////////////////////////// -void TurbulenceIntensityCoProcessor::calculateAverageValues(double timeStep) -{ - using namespace D3Q27System; - - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - LBMReal f[27]; - LBMReal vx, vy, vz; - - for(int level = minInitLevel; level<=maxInitLevel;level++) - { - for(SPtr<Block3D> block : blockVector[level]) - { - if (block) - { - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - SPtr<AverageValuesArray3D> av = kernel->getDataSet()->getAverageValues(); - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int maxX1 = int(distributions->getNX1()); - int maxX2 = int(distributions->getNX2()); - int maxX3 = int(distributions->getNX3()); - - for(int ix3=minX3; ix3<maxX3-1; ix3++) - { - for(int ix2=minX2; ix2<maxX2-1; ix2++) - { - for(int ix1=minX1; ix1<maxX1-1; ix1++) - { - if(!bcArray->isUndefined(ix1,ix2,ix3) && !bcArray->isSolid(ix1,ix2,ix3)) - { - ////////////////////////////////////////////////////////////////////////// - //read distribution - //////////////////////////////////////////////////////////////////////////// - distributions->getDistribution(f, ix1, ix2, ix3); - ////////////////////////////////////////////////////////////////////////// - //compute velocity - ////////////////////////////////////////////////////////////////////////// - vx = f[E] - f[W] + f[NE] - f[SW] + f[SE] - f[NW] + f[TE] - f[BW] - + f[BE] - f[TW] + f[TNE] - f[TSW] + f[TSE] - f[TNW] + f[BNE] - f[BSW] - + f[BSE] - f[BNW]; - - vy = f[N] - f[S] + f[NE] - f[SW] - f[SE] + f[NW] + f[TN] - f[BS] + f[BN] - - f[TS] + f[TNE] - f[TSW] - f[TSE] + f[TNW] + f[BNE] - f[BSW] - f[BSE] - + f[BNW]; - - vz = f[T] - f[B] + f[TE] - f[BW] - f[BE] + f[TW] + f[TN] - f[BS] - f[BN] - + f[TS] + f[TNE] + f[TSW] + f[TSE] + f[TNW] - f[BNE] - f[BSW] - f[BSE] - - f[BNW]; - ////////////////////////////////////////////////////////////////////////// - //compute average values - ////////////////////////////////////////////////////////////////////////// - (*av)(ix1,ix2,ix3,AvVx) = ((*av)(ix1,ix2,ix3,AvVx)*timeStep + vx)/(timeStep+1.0); - (*av)(ix1,ix2,ix3,AvVy) = ((*av)(ix1,ix2,ix3,AvVy)*timeStep + vy)/(timeStep+1.0); - (*av)(ix1,ix2,ix3,AvVz) = ((*av)(ix1,ix2,ix3,AvVz)*timeStep + vz)/(timeStep+1.0); - - (*av)(ix1,ix2,ix3,AvVxxyyzz) = ((vx-(*av)(ix1,ix2,ix3,AvVx))*(vx-(*av)(ix1,ix2,ix3,AvVx)) + - (vy-(*av)(ix1,ix2,ix3,AvVy))*(vy-(*av)(ix1,ix2,ix3,AvVy)) + - (vz-(*av)(ix1,ix2,ix3,AvVz))*(vz-(*av)(ix1,ix2,ix3,AvVz)) + - (*av)(ix1,ix2,ix3,AvVxxyyzz)*timeStep)/(timeStep+1.0); - ////////////////////////////////////////////////////////////////////////// - } - } - } - } - } - } - } -} - diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.h deleted file mode 100644 index 2fd39b030..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/TurbulenceIntensityCoProcessor.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef TurbulenceIntensityCoProcessor_H -#define TurbulenceIntensityCoProcessor_H - -#include <PointerDefinitions.h> -#include <string> -#include <vector> - -#include "CoProcessor.h" -#include "UbTuple.h" - -class Communicator; -class Grid3D; -class UbScheduler; -class WbWriter; -class Block3D; - -class TurbulenceIntensityCoProcessor : public CoProcessor -{ -public: - TurbulenceIntensityCoProcessor(SPtr<Grid3D> grid, const std::string& path, WbWriter* const writer, - SPtr<UbScheduler> s, SPtr<Communicator> comm); - void process(double step); -protected: - void collectData(double step); - void addData(const SPtr<Block3D> block); - void clearData(); - void calculateAverageValues(double timeStep); -private: - void init(); - std::vector<UbTupleFloat3> nodes; - std::vector<UbTupleUInt8> cells; - std::vector<std::string> datanames; - std::vector<std::vector<double> > data; - std::vector<std::vector<SPtr<Block3D> > > blockVector; - int minInitLevel; - int maxInitLevel; - int gridRank; - std::string path; - WbWriter* writer; - SPtr<Communicator> comm; - enum Values{AvVx = 0, AvVy = 1, AvVz = 2, AvVxxyyzz = 3}; -}; -#endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteBlocksCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/WriteBlocksCoProcessor.cpp index f27d2d59f..8256d2fea 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteBlocksCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteBlocksCoProcessor.cpp @@ -1,153 +1,186 @@ -#include "WriteBlocksCoProcessor.h" -#include "basics/writer/WbWriterVtkXmlASCII.h" - -#include "D3Q27System.h" -#include "Block3D.h" -#include "UbScheduler.h" -#include "Communicator.h" -#include "Grid3D.h" - -WriteBlocksCoProcessor::WriteBlocksCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, - const std::string& path, WbWriter* const writer, - SPtr<Communicator> comm) : - CoProcessor(grid, s), - path(path), - writer(writer), - comm(comm) -{ - -} -////////////////////////////////////////////////////////////////////////// -WriteBlocksCoProcessor::~WriteBlocksCoProcessor() -{ -} -////////////////////////////////////////////////////////////////////////// -void WriteBlocksCoProcessor::process(double step) -{ - if(scheduler->isDue(step) ) - collectData(step); -} -////////////////////////////////////////////////////////////////////////// -void WriteBlocksCoProcessor::collectData(double step) -{ - if (comm->getProcessID() == comm->getRoot()) - { - int istep = int(step); - std::vector<std::string> filenames; - std::vector< UbTupleFloat3 > nodes; - std::vector< UbTupleInt8 > cells; - std::vector<std::string> celldatanames; - - celldatanames.push_back("isActive"); - celldatanames.push_back("rank"); - celldatanames.push_back("interface"); - celldatanames.push_back("ID"); - celldatanames.push_back("part"); - celldatanames.push_back("level"); - //celldatanames.push_back("connectorCF"); - //celldatanames.push_back("connectorFC"); -#if defined VF_FETOL - celldatanames.push_back("bundle"); -#endif - - std::vector< std::vector< double > > celldata(celldatanames.size()); - - int nr=0; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - int maxInitLevel = this->grid->getFinestInitializedLevel(); - - for(int level = minInitLevel; level<=maxInitLevel;level++) - { - std::vector<SPtr<Block3D>> blockVector; - grid->getBlocks(level, blockVector); - for(SPtr<Block3D> block : blockVector) - { - UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); - UbTupleDouble3 blockLength = grid->getBlockLengths(block); - - nodes.push_back(makeUbTuple((float)(val<1>(org)), (float)(val<2>(org)), (float)(val<3>(org)))); - nodes.push_back(makeUbTuple((float)(val<1>(org)+val<1>(blockLength)), (float)(val<2>(org)), (float)(val<3>(org)))); - nodes.push_back(makeUbTuple((float)(val<1>(org)+val<1>(blockLength)), (float)(val<2>(org)+val<2>(blockLength)), (float)(val<3>(org)))); - nodes.push_back(makeUbTuple((float)(val<1>(org)), (float)(val<2>(org)+val<2>(blockLength)), (float)(val<3>(org)))); - nodes.push_back(makeUbTuple((float)(val<1>(org)), (float)(val<2>(org)), (float)(val<3>(org)+val<3>(blockLength)))); - nodes.push_back(makeUbTuple((float)(val<1>(org)+val<1>(blockLength)), (float)(val<2>(org)), (float)(val<3>(org)+val<3>(blockLength)))); - nodes.push_back(makeUbTuple((float)(val<1>(org)+val<1>(blockLength)), (float)(val<2>(org)+val<2>(blockLength)), (float)(val<3>(org)+val<3>(blockLength)))); - nodes.push_back(makeUbTuple((float)(val<1>(org)), (float)(val<2>(org)+val<2>(blockLength)), (float)(val<3>(org)+val<3>(blockLength)))); - cells.push_back(makeUbTuple(nr, nr+1, nr+2, nr+3, nr+4, nr+5, nr+6, nr+7)); - nr += 8; - - //data - celldata[0].push_back((double)block->isActive()); - celldata[1].push_back((double)block->getRank()); - celldata[2].push_back((double)block->hasInterpolationFlag()); - celldata[3].push_back((double)block->getGlobalID()); - celldata[4].push_back((double)block->getPart()); - celldata[5].push_back((double)block->getLevel()); - - //bool flag = false; - //std::vector<SPtr<Block3DConnector>> connectors; - - //block->pushBackLocalInterpolationConnectorsCF(connectors); - //for (std::size_t i = 0; i<connectors.size(); i++) - // if (connectors[i]) - // { - // if (connectors[i]->getSendDir() == D3Q27System::BS) - // { - - // flag = true; - // } - // } - - //if (flag) - //{ - // celldata[6].push_back(1); - // UBLOG(logINFO, "CF: "+block->toString()); - //} - //else - //{ - // celldata[6].push_back(0); - //} - - //flag = false; - //connectors.resize(0); - //block->pushBackLocalInterpolationConnectorsFC(connectors); - //for (std::size_t i = 0; i<connectors.size(); i++) - // if (connectors[i]) - // { - // if (connectors[i]->getSendDir() == D3Q27System::BS) - // { - - // flag = true; - // } - // } - - //if (flag) - //{ - // celldata[7].push_back(1); - // UBLOG(logINFO, "FC: "+block->toString()); - //} - //else - //{ - // celldata[7].push_back(0); - //} - -#ifdef VF_FETOL - celldata[6].push_back( (double)block->getBundle()); -#endif - } - } - - filenames.push_back(writer->writeOctsWithCellData(path+"/blocks/blocks_" + UbSystem::toString(grid->getRank()) + "_" + UbSystem::toString(istep),nodes,cells,celldatanames,celldata)); - - if (istep == CoProcessor::scheduler->getMinBegin()) - { - WbWriterVtkXmlASCII::getInstance()->writeCollection(path+"/blocks/blocks_collection",filenames,istep,false); - } - else - { - WbWriterVtkXmlASCII::getInstance()->addFilesToCollection(path + "/blocks/blocks_collection", filenames, istep, false); - } - - UBLOG(logINFO,"WriteBlocksCoProcessor step: " << istep); - } -} +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WriteBlocksCoProcessor.cpp +//! \ingroup CoProcessors +//! \author Konstantin Kutscher +//======================================================================================= + +#include "WriteBlocksCoProcessor.h" +#include "basics/writer/WbWriterVtkXmlASCII.h" + +#include "D3Q27System.h" +#include "Block3D.h" +#include "UbScheduler.h" +#include "Communicator.h" +#include "Grid3D.h" + +WriteBlocksCoProcessor::WriteBlocksCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, + const std::string& path, WbWriter* const writer, + SPtr<Communicator> comm) : + CoProcessor(grid, s), + path(path), + writer(writer), + comm(comm) +{ + +} +////////////////////////////////////////////////////////////////////////// +WriteBlocksCoProcessor::~WriteBlocksCoProcessor() +{ +} +////////////////////////////////////////////////////////////////////////// +void WriteBlocksCoProcessor::process(double step) +{ + if(scheduler->isDue(step) ) + collectData(step); +} +////////////////////////////////////////////////////////////////////////// +void WriteBlocksCoProcessor::collectData(double step) +{ + if (comm->getProcessID() == comm->getRoot()) + { + int istep = int(step); + std::vector<std::string> filenames; + std::vector< UbTupleFloat3 > nodes; + std::vector< UbTupleInt8 > cells; + std::vector<std::string> celldatanames; + + celldatanames.push_back("isActive"); + celldatanames.push_back("rank"); + celldatanames.push_back("interface"); + celldatanames.push_back("ID"); + celldatanames.push_back("part"); + celldatanames.push_back("level"); + //celldatanames.push_back("connectorCF"); + //celldatanames.push_back("connectorFC"); +#if defined VF_FETOL + celldatanames.push_back("bundle"); +#endif + + std::vector< std::vector< double > > celldata(celldatanames.size()); + + int nr=0; + int minInitLevel = this->grid->getCoarsestInitializedLevel(); + int maxInitLevel = this->grid->getFinestInitializedLevel(); + + for(int level = minInitLevel; level<=maxInitLevel;level++) + { + std::vector<SPtr<Block3D>> blockVector; + grid->getBlocks(level, blockVector); + for(SPtr<Block3D> block : blockVector) + { + UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); + UbTupleDouble3 blockLength = grid->getBlockLengths(block); + + nodes.push_back(makeUbTuple((float)(val<1>(org)), (float)(val<2>(org)), (float)(val<3>(org)))); + nodes.push_back(makeUbTuple((float)(val<1>(org)+val<1>(blockLength)), (float)(val<2>(org)), (float)(val<3>(org)))); + nodes.push_back(makeUbTuple((float)(val<1>(org)+val<1>(blockLength)), (float)(val<2>(org)+val<2>(blockLength)), (float)(val<3>(org)))); + nodes.push_back(makeUbTuple((float)(val<1>(org)), (float)(val<2>(org)+val<2>(blockLength)), (float)(val<3>(org)))); + nodes.push_back(makeUbTuple((float)(val<1>(org)), (float)(val<2>(org)), (float)(val<3>(org)+val<3>(blockLength)))); + nodes.push_back(makeUbTuple((float)(val<1>(org)+val<1>(blockLength)), (float)(val<2>(org)), (float)(val<3>(org)+val<3>(blockLength)))); + nodes.push_back(makeUbTuple((float)(val<1>(org)+val<1>(blockLength)), (float)(val<2>(org)+val<2>(blockLength)), (float)(val<3>(org)+val<3>(blockLength)))); + nodes.push_back(makeUbTuple((float)(val<1>(org)), (float)(val<2>(org)+val<2>(blockLength)), (float)(val<3>(org)+val<3>(blockLength)))); + cells.push_back(makeUbTuple(nr, nr+1, nr+2, nr+3, nr+4, nr+5, nr+6, nr+7)); + nr += 8; + + //data + celldata[0].push_back((double)block->isActive()); + celldata[1].push_back((double)block->getRank()); + celldata[2].push_back((double)block->hasInterpolationFlag()); + celldata[3].push_back((double)block->getGlobalID()); + celldata[4].push_back((double)block->getPart()); + celldata[5].push_back((double)block->getLevel()); + + //bool flag = false; + //std::vector<SPtr<Block3DConnector>> connectors; + + //block->pushBackLocalInterpolationConnectorsCF(connectors); + //for (std::size_t i = 0; i<connectors.size(); i++) + // if (connectors[i]) + // { + // if (connectors[i]->getSendDir() == D3Q27System::BS) + // { + + // flag = true; + // } + // } + + //if (flag) + //{ + // celldata[6].push_back(1); + // UBLOG(logINFO, "CF: "+block->toString()); + //} + //else + //{ + // celldata[6].push_back(0); + //} + + //flag = false; + //connectors.resize(0); + //block->pushBackLocalInterpolationConnectorsFC(connectors); + //for (std::size_t i = 0; i<connectors.size(); i++) + // if (connectors[i]) + // { + // if (connectors[i]->getSendDir() == D3Q27System::BS) + // { + + // flag = true; + // } + // } + + //if (flag) + //{ + // celldata[7].push_back(1); + // UBLOG(logINFO, "FC: "+block->toString()); + //} + //else + //{ + // celldata[7].push_back(0); + //} + +#ifdef VF_FETOL + celldata[6].push_back( (double)block->getBundle()); +#endif + } + } + + filenames.push_back(writer->writeOctsWithCellData(path+"/blocks/blocks_" + UbSystem::toString(grid->getRank()) + "_" + UbSystem::toString(istep),nodes,cells,celldatanames,celldata)); + + if (istep == CoProcessor::scheduler->getMinBegin()) + { + WbWriterVtkXmlASCII::getInstance()->writeCollection(path+"/blocks/blocks_collection",filenames,istep,false); + } + else + { + WbWriterVtkXmlASCII::getInstance()->addFilesToCollection(path + "/blocks/blocks_collection", filenames, istep, false); + } + + UBLOG(logINFO,"WriteBlocksCoProcessor step: " << istep); + } +} diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteBlocksCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/WriteBlocksCoProcessor.h index 041d29586..d797dbccc 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteBlocksCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteBlocksCoProcessor.h @@ -1,38 +1,75 @@ -/* -* WriteBlocksCoProcessor.h -* -* Created on: 24.09.2012 -* Author: K. Kucher -*/ - -#ifndef WriteBlocksCoProcessor_H_ -#define WriteBlocksCoProcessor_H_ - -#include <PointerDefinitions.h> -#include <string> - -#include "CoProcessor.h" - -class Communicator; -class Grid3D; -class UbScheduler; -class WbWriter; - -class WriteBlocksCoProcessor: public CoProcessor -{ -public: - WriteBlocksCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, WbWriter* const writer, SPtr<Communicator> comm); - virtual ~WriteBlocksCoProcessor(); - - void process(double step) override; - -protected: - void collectData(double step); - - std::string path; - WbWriter* writer; - SPtr<Communicator> comm; -}; - - -#endif +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WriteBlocksCoProcessor.h +//! \ingroup CoProcessors +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef WriteBlocksCoProcessor_H_ +#define WriteBlocksCoProcessor_H_ + +#include <PointerDefinitions.h> +#include <string> + +#include "CoProcessor.h" + +class Communicator; +class Grid3D; +class UbScheduler; +class WbWriter; + +//! \class WriteBlocksCoProcessor +//! \brief A class writes a block grid to a VTK-file +class WriteBlocksCoProcessor: public CoProcessor +{ +public: + //! \brief Construct WriteBlocksCoProcessor object. + //! \pre The Grid3D and UbScheduler objects must exist. + //! \param grid is observable Grid3D object + //! \param s is UbScheduler object for scheduling of observer + //! \param path is path of folder for output + //! \param writer is WbWriter object + //! \param comm is Communicator object + WriteBlocksCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, WbWriter* const writer, SPtr<Communicator> comm); + virtual ~WriteBlocksCoProcessor(); + + void process(double step) override; + +protected: + //! Collect data for VTK-file + //! \param step is a time step + void collectData(double step); + + std::string path; + WbWriter* writer; + SPtr<Communicator> comm; +}; + + +#endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.cpp index d74e1edf3..fc6601c73 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.cpp @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WriteBoundaryConditionsCoProcessor.cpp +//! \ingroup CoProcessors +//! \author Konstantin Kutscher +//======================================================================================= + #include "WriteBoundaryConditionsCoProcessor.h" #include "LBMKernel.h" #include "BCProcessor.h" @@ -77,7 +110,8 @@ void WriteBoundaryConditionsCoProcessor::collectData(double step) piece = subfolder+"/"+piece; vector<string> cellDataNames; - vector<string> pieces = comm->gather(piece); + vector<std::string> pieces; + pieces.push_back(piece); if (comm->getProcessID()==comm->getRoot()) { string pname = WbWriterVtkXmlASCII::getInstance()->writeParallelFile(pfilePath, pieces, datanames, cellDataNames); @@ -122,7 +156,9 @@ void WriteBoundaryConditionsCoProcessor::addDataGeo(SPtr<Block3D> block) datanames.push_back("Boundary Conditions"); datanames.push_back("Geometry"); datanames.push_back("Level"); + datanames.push_back("Algorithm"); //datanames.push_back("Interface CF"); + datanames.push_back("qs"); data.resize(datanames.size()); @@ -130,7 +166,7 @@ void WriteBoundaryConditionsCoProcessor::addDataGeo(SPtr<Block3D> block) SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); //knotennummerierung faengt immer bei 0 an! - unsigned int SWB, SEB, NEB, NWB, SWT, SET, NET, NWT; + int SWB, SEB, NEB, NWB, SWT, SET, NET, NWT; int minX1 = 0; int minX2 = 0; @@ -161,7 +197,7 @@ void WriteBoundaryConditionsCoProcessor::addDataGeo(SPtr<Block3D> block) { if (!bcArray->isUndefined(ix1, ix2, ix3)) { - //int index = 0; + 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), @@ -171,31 +207,36 @@ void WriteBoundaryConditionsCoProcessor::addDataGeo(SPtr<Block3D> block) if (!bcArray->hasBC(ix1, ix2, ix3)) { - data[0].push_back(0.0); + data[index++].push_back(0.0); } else if (bcArray->getBC(ix1, ix2, ix3)->hasNoSlipBoundary()) - data[0].push_back(1.0); + data[index++].push_back(1.0); else if (bcArray->getBC(ix1, ix2, ix3)->hasVelocityBoundary()) - data[0].push_back(2.0); + data[index++].push_back(2.0); else if (bcArray->getBC(ix1, ix2, ix3)->hasDensityBoundary()) - data[0].push_back(3.0); + data[index++].push_back(3.0); else if (bcArray->getBC(ix1, ix2, ix3)->hasSlipBoundary()) - data[0].push_back(4.0); + data[index++].push_back(4.0); //else // data[0].push_back(5.0); if (bcArray->isSolid(ix1, ix2, ix3)) { - data[1].push_back(1.0); + data[index++].push_back(1.0); } else { - data[1].push_back(0.0); + data[index++].push_back(0.0); } - data[2].push_back(level); + data[index++].push_back(level); + + if (bcArray->hasBC(ix1, ix2, ix3)) + data[index++].push_back(bcArray->getBC(ix1, ix2, ix3)->getBcAlgorithmType()); + else + data[index++].push_back(-1.0); //if (bcArray->isInterfaceCF(ix1, ix2, ix3)) //{ @@ -206,6 +247,25 @@ void WriteBoundaryConditionsCoProcessor::addDataGeo(SPtr<Block3D> block) // data[3].push_back(0.0); //} + if (bcArray->hasBC(ix1, ix2, ix3)) + { + unsigned int a = 1; + unsigned int b = 0; + for (int fdir = D3Q27System::FSTARTDIR; fdir <= D3Q27System::FENDDIR; fdir++) + { + if (bcArray->getBC(ix1, ix2, ix3)->hasVelocityBoundaryFlag(fdir)) + { + a = a << 1; + if (bcArray->getBC(ix1, ix2, ix3)->hasVelocityBoundaryFlag(fdir)) + { + b = b | a; + } + } + } + data[index++].push_back(b); + } + else + data[index++].push_back(-1.0); } } } diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.h index 407d56b3e..2c2a2f612 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteBoundaryConditionsCoProcessor.h @@ -1,46 +1,89 @@ -#ifndef WriteBoundaryConditionsCoProcessor_H -#define WriteBoundaryConditionsCoProcessor_H - -#include <PointerDefinitions.h> -#include <string> -#include <vector> - -#include "CoProcessor.h" -#include "UbTuple.h" - -class Communicator; -class Grid3D; -class UbScheduler; -class WbWriter; -class Block3D; -class LBMUnitConverter; - -class WriteBoundaryConditionsCoProcessor : public CoProcessor -{ -public: - WriteBoundaryConditionsCoProcessor(); - WriteBoundaryConditionsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, WbWriter* const writer, SPtr<Communicator> comm); - ~WriteBoundaryConditionsCoProcessor() {} - - void process(double step) override; - -protected: - void collectData(double step); - void addDataGeo(SPtr<Block3D> block); - void clearData(); - -private: - std::vector<UbTupleFloat3> nodes; - std::vector<UbTupleUInt8> cells; - std::vector<std::string> datanames; - std::vector<std::vector<double> > data; - std::string path; - WbWriter* writer; - bool bcInformation; - std::vector<std::vector<SPtr<Block3D> > > blockVector; - int minInitLevel; - int maxInitLevel; - int gridRank; - SPtr<Communicator> comm; -}; -#endif +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WriteBoundaryConditionsCoProcessor.h +//! \ingroup CoProcessors +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef WriteBoundaryConditionsCoProcessor_H +#define WriteBoundaryConditionsCoProcessor_H + +#include <PointerDefinitions.h> +#include <string> +#include <vector> + +#include "CoProcessor.h" +#include "UbTuple.h" + +class Communicator; +class Grid3D; +class UbScheduler; +class WbWriter; +class Block3D; +class LBMUnitConverter; + +//! \brief A class writes boundary conditions information to a VTK-file +class WriteBoundaryConditionsCoProcessor : public CoProcessor +{ +public: + WriteBoundaryConditionsCoProcessor(); + //! \brief Construct WriteBoundaryConditionsCoProcessor object + //! \pre The Grid3D and UbScheduler objects must exist + //! \param grid is observable Grid3D object + //! \param s is UbScheduler object for scheduling of observer + //! \param path is path of folder for output + //! \param writer is WbWriter object + //! \param comm is Communicator object + WriteBoundaryConditionsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, WbWriter* const writer, SPtr<Communicator> comm); + ~WriteBoundaryConditionsCoProcessor() {} + + void process(double step) override; + +protected: + //! Collect data for VTK-file + //! \param step is a time step + void collectData(double step); + void addDataGeo(SPtr<Block3D> 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; + bool bcInformation; + std::vector<std::vector<SPtr<Block3D> > > blockVector; + int minInitLevel; + int maxInitLevel; + int gridRank; + SPtr<Communicator> comm; +}; +#endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteGbObjectsCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/WriteGbObjectsCoProcessor.cpp deleted file mode 100644 index 66f01407e..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteGbObjectsCoProcessor.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "WriteGbObjectsCoProcessor.h" -#include "UbScheduler.h" -#include "WbWriterVtkXmlBinary.h" -#include "WbWriterVtkXmlASCII.h" -#include "Communicator.h" -#include "GbObject3D.h" -#include <vector> - -WriteGbObjectsCoProcessor::WriteGbObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, WbWriter* const writer, SPtr<Communicator> comm) : CoProcessor(grid, s), path(path), writer(writer), comm(comm) -{ -} -////////////////////////////////////////////////////////////////////////// -WriteGbObjectsCoProcessor::~WriteGbObjectsCoProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -void WriteGbObjectsCoProcessor::process(double step) -{ - if (scheduler->isDue(step)) - collectData(step); -} -////////////////////////////////////////////////////////////////////////// -void WriteGbObjectsCoProcessor::addGbObject(SPtr<GbObject3D> object) -{ - objects.push_back(object); -} -////////////////////////////////////////////////////////////////////////// -void WriteGbObjectsCoProcessor::collectData(double step) -{ - std::vector<UbTupleFloat3> nodes; - std::vector<UbTupleInt3> triangles; - - int numObjcts = 0; - - for (SPtr<GbObject3D>object : objects) - { - object->addSurfaceTriangleSet(nodes, triangles); - numObjcts++; - } - - int istep = static_cast<int>(step); - - std::string pfilePath, partPath, subfolder, cfilePath; - - subfolder = "gob"+UbSystem::toString(istep); - pfilePath = path+"/gob/"+subfolder; - cfilePath = path+"/gob/gob_collection"; - partPath = pfilePath+"/gob"+UbSystem::toString(comm->getProcessID())+ "_" + UbSystem::toString(istep); - - - std::string partName = writer->writeTriangles(partPath, nodes, triangles); - - size_t found=partName.find_last_of("/"); - std::string piece = partName.substr(found+1); - piece = subfolder + "/" + piece; - - std::vector<std::string> datanames; - std::vector<std::string> cellDataNames; - //std::vector<std::string> pieces = comm->gather(piece); - std::vector<std::string> pieces; - pieces.push_back(piece); - if (comm->isRoot()) - { - std::string pname = WbWriterVtkXmlASCII::getInstance()->writeParallelFile(pfilePath, pieces, datanames, cellDataNames); - found=pname.find_last_of("/"); - piece = pname.substr(found+1); - - std::vector<std::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, "WriteGbObjectsCoProcessor number of objects: " << numObjcts); - UBLOG(logINFO, "WriteGbObjectsCoProcessor step: " << istep); - } -} diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteGbObjectsCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/WriteGbObjectsCoProcessor.h deleted file mode 100644 index a6639a6e9..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteGbObjectsCoProcessor.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef WriteGbObjectsCoProcessor_h__ -#define WriteGbObjectsCoProcessor_h__ - -#include "CoProcessor.h" -#include "UbTuple.h" - -#include <vector> - -class GbObject3D; -class Communicator; -class Grid3D; -class UbScheduler; -class WbWriter; - -//! \brief Writes geometry objects as VTK unstructured grid. -//! \details Writes geometry objects as VTK unstructured grid. Use addGbObject() for add a GbObjects. -//! \author Konstantin Kutscher -//! \date December 2018 - -class WriteGbObjectsCoProcessor :public CoProcessor -{ -public: - WriteGbObjectsCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, const std::string& path, WbWriter* const writer, SPtr<Communicator> comm); - virtual ~WriteGbObjectsCoProcessor(); - //! calls collectData. - void process(double step) override; - //! adds geometry object - void addGbObject(SPtr<GbObject3D> object); -protected: - void collectData(double step); -private: - std::vector< SPtr<GbObject3D> > objects; - std::string path; - WbWriter* writer; - SPtr<Communicator> comm; -}; - -#endif // WriteGbObjectsCoProcessor_h__ \ No newline at end of file diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.cpp deleted file mode 100644 index a27392981..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.cpp +++ /dev/null @@ -1,237 +0,0 @@ -#include "WriteMQFromSelectionCoProcessor.h" -#include "LBMKernel.h" -#include "BCProcessor.h" -#include <vector> -#include <string> - -#include "basics/writer/WbWriterVtkXmlASCII.h" -#include "DataSet3D.h" -#include "UbScheduler.h" -#include "Grid3D.h" -#include "Communicator.h" -#include "LBMUnitConverter.h" -#include "Block3D.h" -#include "BCArray3D.h" -#include "GbObject3D.h" - -WriteMQFromSelectionCoProcessor::WriteMQFromSelectionCoProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -WriteMQFromSelectionCoProcessor::WriteMQFromSelectionCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, - SPtr<GbObject3D> gbObject, - const std::string& path, WbWriter* const writer, - SPtr<LBMUnitConverter> conv, - SPtr<Communicator> comm) - : CoProcessor(grid, s), - gbObject(gbObject), - 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 WriteMQFromSelectionCoProcessor::init() -{ - -} -////////////////////////////////////////////////////////////////////////// -void WriteMQFromSelectionCoProcessor::process(double step) -{ - if(scheduler->isDue(step) ) - collectData(step); - - UBLOG(logDEBUG3, "WriteMQFromSelectionCoProcessor::update:" << step); -} -////////////////////////////////////////////////////////////////////////// -void WriteMQFromSelectionCoProcessor::collectData(double step) -{ - int istep = static_cast<int>(step); - - for(int level = minInitLevel; level<=maxInitLevel;level++) - { - for(SPtr<Block3D> block : blockVector[level]) - { - if (block) - { - UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); - UbTupleDouble3 blockLengths = grid->getBlockLengths(block); - - double minX1 = val<1>(org); - double minX2 = val<2>(org); - double minX3 = val<3>(org); - double maxX1 = val<1>(org)+val<1>(blockLengths); - double maxX2 = val<2>(org)+val<2>(blockLengths); - double maxX3 = val<3>(org)+val<3>(blockLengths); - - if (gbObject->isCellInsideOrCuttingGbObject3D(minX1, minX2, minX3, maxX1, maxX2, maxX3)) - { - addDataMQ(block); - } - } - } - } - - std::string pfilePath, partPath, subfolder, cfilePath; - - subfolder = "mqSelect"+UbSystem::toString(istep); - pfilePath = path+"/mqSelect/"+subfolder; - cfilePath = path+"/mqSelect/mq_collection"; - partPath = pfilePath+"/mqSelect"+UbSystem::toString(gridRank)+ "_" + UbSystem::toString(istep); - - - std::string partName = writer->writeNodesWithNodeData(partPath,nodes,datanames,data); - size_t found=partName.find_last_of("/"); - std::string piece = partName.substr(found+1); - piece = subfolder + "/" + piece; - - std::vector<std::string> cellDataNames; - SPtr<Communicator> comm = Communicator::getInstance(); - std::vector<std::string> pieces = comm->gather(piece); - if (comm->getProcessID() == comm->getRoot()) - { - std::string pname = WbWriterVtkXmlASCII::getInstance()->writeParallelFile(pfilePath,pieces,datanames,cellDataNames); - found=pname.find_last_of("/"); - piece = pname.substr(found+1); - - std::vector<std::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,"WriteMQFromSelectionCoProcessor step: " << istep); - } - - clearData(); -} -////////////////////////////////////////////////////////////////////////// -void WriteMQFromSelectionCoProcessor::clearData() -{ - nodes.clear(); - datanames.clear(); - data.clear(); -} -////////////////////////////////////////////////////////////////////////// -void WriteMQFromSelectionCoProcessor::addDataMQ(SPtr<Block3D> block) -{ - double level = (double)block->getLevel(); - double blockID = (double)block->getGlobalID(); - - //Diese Daten werden geschrieben: - datanames.resize(0); - datanames.push_back("Rho"); - datanames.push_back("Vx"); - datanames.push_back("Vy"); - datanames.push_back("Vz"); - //datanames.push_back("Press"); - datanames.push_back("Level"); - //datanames.push_back("BlockID"); - - - - data.resize(datanames.size()); - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); - LBMReal f[D3Q27System::ENDF+1]; - LBMReal vx1,vx2,vx3,rho; - - if(block->getKernel()->getCompressible()) - { - calcMacros = &D3Q27System::calcCompMacroscopicValues; - } - else - { - calcMacros = &D3Q27System::calcIncompMacroscopicValues; - } - - int minX1 = 1; - int minX2 = 1; - int minX3 = 1; - - int maxX1 = (int)(distributions->getNX1()); - int maxX2 = (int)(distributions->getNX2()); - int maxX3 = (int)(distributions->getNX3()); - - //int minX1 = 1; - //int minX2 = 1; - //int minX3 = 1; - - //int maxX1 = (int)(distributions->getNX1()); - //int maxX2 = (int)(distributions->getNX2()); - //int maxX3 = (int)(distributions->getNX3()); - - //nummern vergeben und node vector erstellen + daten sammeln - CbArray3D<int> nodeNumbers((int)maxX1, (int)maxX2, (int)maxX3,-1); - maxX1 -= 2; - maxX2 -= 2; - maxX3 -= 2; - - //D3Q27BoundaryConditionPtr bcPtr; - int nr = (int)nodes.size(); - - for(int ix3=minX3; ix3<=maxX3; ix3++) - { - for(int ix2=minX2; ix2<=maxX2; ix2++) - { - for(int ix1=minX1; ix1<=maxX1; ix1++) - { - if(!bcArray->isUndefined(ix1,ix2,ix3) && !bcArray->isSolid(ix1,ix2,ix3)) - { - Vector3D worldCoordinates = grid->getNodeCoordinates(block, ix1, ix2, ix3); - if (gbObject->isPointInGbObject3D(worldCoordinates[0], worldCoordinates[1], worldCoordinates[2])) - { - int index = 0; - nodeNumbers(ix1, ix2, ix3) = nr++; - - nodes.push_back(UbTupleFloat3(float(worldCoordinates[0]), - float(worldCoordinates[1]), - float(worldCoordinates[2]))); - - distributions->getDistribution(f, ix1, ix2, ix3); - calcMacros(f, rho, vx1, vx2, vx3); - - if (UbMath::isNaN(rho) || UbMath::isInfinity(rho)) - UB_THROW(UbException(UB_EXARGS, "rho is not a number (nan or -1.#IND) or infinity number -1.#INF in block="+block->toString()+ - ", node="+UbSystem::toString(ix1)+","+UbSystem::toString(ix2)+","+UbSystem::toString(ix3))); - if (UbMath::isNaN(vx1) || UbMath::isInfinity(vx1)) - UB_THROW(UbException(UB_EXARGS, "vx1 is not a number (nan or -1.#IND) or infinity number -1.#INF in block="+block->toString()+ - ", node="+UbSystem::toString(ix1)+","+UbSystem::toString(ix2)+","+UbSystem::toString(ix3))); - //vx1=999.0; - if (UbMath::isNaN(vx2) || UbMath::isInfinity(vx2)) - UB_THROW(UbException(UB_EXARGS, "vx2 is not a number (nan or -1.#IND) or infinity number -1.#INF in block="+block->toString()+ - ", node="+UbSystem::toString(ix1)+","+UbSystem::toString(ix2)+","+UbSystem::toString(ix3))); - //vx2=999.0; - if (UbMath::isNaN(vx3) || UbMath::isInfinity(vx3)) - UB_THROW(UbException(UB_EXARGS, "vx3 is not a number (nan or -1.#IND) or infinity number -1.#INF in block="+block->toString()+ - ", node="+UbSystem::toString(ix1)+","+UbSystem::toString(ix2)+","+UbSystem::toString(ix3))); - - data[index++].push_back(rho); - data[index++].push_back(vx1); - data[index++].push_back(vx2); - data[index++].push_back(vx3); - data[index++].push_back(level); - } - } - } - } - } -} diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.h deleted file mode 100644 index 886fed0f8..000000000 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef WriteMQFromSelectionCoProcessor_H -#define WriteMQFromSelectionCoProcessor_H - -#include <PointerDefinitions.h> -#include <string> -#include <vector> - -#include "CoProcessor.h" - -#include "LBMSystem.h" - -class Communicator; -class Grid3D; -class UbScheduler; -class LBMUnitConverter; -class WbWriter; -class Block3D; -class GbObject3D; - -class WriteMQFromSelectionCoProcessor : public CoProcessor -{ -public: - WriteMQFromSelectionCoProcessor(); - WriteMQFromSelectionCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, - SPtr<GbObject3D> gbObject, - const std::string& path, WbWriter* const writer, - SPtr<LBMUnitConverter> conv, SPtr<Communicator> comm); - ~WriteMQFromSelectionCoProcessor(){} - - void process(double step) override; - -protected: - void collectData(double step); - void addDataMQ(SPtr<Block3D> block); - void clearData(); - -private: - void init(); - std::vector<UbTupleFloat3> nodes; - std::vector<std::string> datanames; - std::vector<std::vector<double> > data; - std::string path; - WbWriter* writer; - SPtr<LBMUnitConverter> conv; - bool bcInformation; - std::vector<std::vector<SPtr<Block3D> > > blockVector; - int minInitLevel; - int maxInitLevel; - int gridRank; - SPtr<Communicator> comm; - SPtr<GbObject3D> gbObject; - - typedef void(*CalcMacrosFct)(const LBMReal* const& /*feq[27]*/, LBMReal& /*(d)rho*/, LBMReal& /*vx1*/, LBMReal& /*vx2*/, LBMReal& /*vx3*/); - CalcMacrosFct calcMacros; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.cpp b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.cpp index 25ce8cd39..e7a378885 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.cpp @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WriteMacroscopicQuantitiesCoProcessor.cpp +//! \ingroup CoProcessors +//! \author Konstantin Kutscher +//======================================================================================= + #include "WriteMacroscopicQuantitiesCoProcessor.h" #include "LBMKernel.h" #include "BCProcessor.h" @@ -82,7 +115,8 @@ void WriteMacroscopicQuantitiesCoProcessor::collectData(double step) piece = subfolder + "/" + piece; std::vector<std::string> cellDataNames; - std::vector<std::string> pieces = comm->gather(piece); + std::vector<std::string> pieces; + pieces.push_back(piece); if (comm->getProcessID() == comm->getRoot()) { std::string pname = WbWriterVtkXmlASCII::getInstance()->writeParallelFile(pfilePath,pieces,datanames,cellDataNames); @@ -115,31 +149,26 @@ void WriteMacroscopicQuantitiesCoProcessor::clearData() ////////////////////////////////////////////////////////////////////////// void WriteMacroscopicQuantitiesCoProcessor::addDataMQ(SPtr<Block3D> block) { - double level = (double)block->getLevel(); double blockID = (double)block->getGlobalID(); - //Diese Daten werden geschrieben: + //This data is written: datanames.resize(0); - datanames.push_back("Rho"); + datanames.push_back("DRho"); + datanames.push_back("Press"); datanames.push_back("Vx"); datanames.push_back("Vy"); datanames.push_back("Vz"); - //datanames.push_back("Press"); - datanames.push_back("Level"); - //datanames.push_back("BlockID"); - - - + data.resize(datanames.size()); SPtr<ILBMKernel> kernel = block->getKernel(); SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); SPtr<DistributionArray3D> distributions = kernel->getDataSet()->getFdistributions(); LBMReal f[D3Q27System::ENDF+1]; - LBMReal vx1,vx2,vx3,rho; + LBMReal vx1,vx2,vx3,drho,press; - //knotennummerierung faengt immer bei 0 an! - unsigned int SWB,SEB,NEB,NWB,SWT,SET,NET,NWT; + //node numbering always starts at 0! + int SWB,SEB,NEB,NWB,SWT,SET,NET,NWT; if(block->getKernel()->getCompressible()) { @@ -158,21 +187,12 @@ void WriteMacroscopicQuantitiesCoProcessor::addDataMQ(SPtr<Block3D> block) int maxX2 = (int)(distributions->getNX2()); int maxX3 = (int)(distributions->getNX3()); - //int minX1 = 1; - //int minX2 = 1; - //int minX3 = 1; - - //int maxX1 = (int)(distributions->getNX1()); - //int maxX2 = (int)(distributions->getNX2()); - //int maxX3 = (int)(distributions->getNX3()); - - //nummern vergeben und node vector erstellen + daten sammeln + //assign numbers and create node vector + collect data CbArray3D<int> nodeNumbers((int)maxX1, (int)maxX2, (int)maxX3,-1); maxX1 -= 2; maxX2 -= 2; maxX3 -= 2; - //D3Q27BoundaryConditionPtr bcPtr; int nr = (int)nodes.size(); for(int ix3=minX3; ix3<=maxX3; ix3++) @@ -191,41 +211,30 @@ void WriteMacroscopicQuantitiesCoProcessor::addDataMQ(SPtr<Block3D> block) float(worldCoordinates[2]) )); distributions->getDistribution(f, ix1, ix2, ix3); - calcMacros(f,rho,vx1,vx2,vx3); - //double press = D3Q27System::calcPress(f,rho,vx1,vx2,vx3); + calcMacros(f,drho,vx1,vx2,vx3); + press = D3Q27System::calcPress(f,drho,vx1,vx2,vx3); - if (UbMath::isNaN(rho) || UbMath::isInfinity(rho)) - UB_THROW( UbException(UB_EXARGS,"rho is not a number (nan or -1.#IND) or infinity number -1.#INF in block="+block->toString()+ + if (UbMath::isNaN(drho) || UbMath::isInfinity(drho)) + UB_THROW( UbException(UB_EXARGS,"drho is not a number (nan or -1.#IND) or infinity number -1.#INF in block="+block->toString()+ + ", node="+UbSystem::toString(ix1)+","+UbSystem::toString(ix2)+","+UbSystem::toString(ix3))); + if (UbMath::isNaN(press) || UbMath::isInfinity(press)) + UB_THROW( UbException(UB_EXARGS,"press is not a number (nan or -1.#IND) or infinity number -1.#INF in block="+block->toString()+ ", node="+UbSystem::toString(ix1)+","+UbSystem::toString(ix2)+","+UbSystem::toString(ix3))); - //rho=999.0; - //if (UbMath::isNaN(press) || UbMath::isInfinity(press)) - // UB_THROW( UbException(UB_EXARGS,"press is not a number (nan or -1.#IND) or infinity number -1.#INF in block="+block->toString()+ - // ", node="+UbSystem::toString(ix1)+","+UbSystem::toString(ix2)+","+UbSystem::toString(ix3))); - //press=999.0; if (UbMath::isNaN(vx1) || UbMath::isInfinity(vx1)) UB_THROW( UbException(UB_EXARGS,"vx1 is not a number (nan or -1.#IND) or infinity number -1.#INF in block="+block->toString()+ ", node="+UbSystem::toString(ix1)+","+UbSystem::toString(ix2)+","+UbSystem::toString(ix3))); - //vx1=999.0; if (UbMath::isNaN(vx2) || UbMath::isInfinity(vx2)) UB_THROW( UbException(UB_EXARGS,"vx2 is not a number (nan or -1.#IND) or infinity number -1.#INF in block="+block->toString()+ ", node="+UbSystem::toString(ix1)+","+UbSystem::toString(ix2)+","+UbSystem::toString(ix3))); - //vx2=999.0; if (UbMath::isNaN(vx3) || UbMath::isInfinity(vx3)) UB_THROW( UbException(UB_EXARGS,"vx3 is not a number (nan or -1.#IND) or infinity number -1.#INF in block="+block->toString()+ ", node="+UbSystem::toString(ix1)+","+UbSystem::toString(ix2)+","+UbSystem::toString(ix3))); - - data[index++].push_back(rho); - data[index++].push_back(vx1); - data[index++].push_back(vx2); - data[index++].push_back(vx3); - //data[index++].push_back(rho * conv->getFactorDensityLbToW2() ); - //data[index++].push_back(vx1 * conv->getFactorVelocityLbToW2()); - //data[index++].push_back(vx2 * conv->getFactorVelocityLbToW2()); - //data[index++].push_back(vx3 * conv->getFactorVelocityLbToW2()); - //data[index++].push_back(press * conv->getFactorPressureLbToW2()); - data[index++].push_back(level); - //data[index++].push_back(blockID); + data[index++].push_back(drho * conv->getFactorDensityLbToW()); + data[index++].push_back(press * conv->getFactorPressureLbToW()); + data[index++].push_back(vx1 * conv->getFactorVelocityLbToW()); + data[index++].push_back(vx2 * conv->getFactorVelocityLbToW()); + data[index++].push_back(vx3 * conv->getFactorVelocityLbToW()); } } } diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.h index e112fc10a..76ecc9437 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMacroscopicQuantitiesCoProcessor.h @@ -1,55 +1,102 @@ -#ifndef WriteMacroscopicQuantitiesCoProcessor_H -#define WriteMacroscopicQuantitiesCoProcessor_H - -#include <PointerDefinitions.h> -#include <string> -#include <vector> - -#include "CoProcessor.h" - -#include "LBMSystem.h" - -class Communicator; -class Grid3D; -class UbScheduler; -class LBMUnitConverter; -class WbWriter; -class Block3D; - -class WriteMacroscopicQuantitiesCoProcessor : public CoProcessor -{ -public: - WriteMacroscopicQuantitiesCoProcessor(); - WriteMacroscopicQuantitiesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, - const std::string& path, WbWriter* const writer, - SPtr<LBMUnitConverter> conv, SPtr<Communicator> comm); - ~WriteMacroscopicQuantitiesCoProcessor(){} - - void process(double step) override; - -protected: - void collectData(double step); - void addDataMQ(SPtr<Block3D> block); - void clearData(); - -private: - void init(); - std::vector<UbTupleFloat3> nodes; - std::vector<UbTupleUInt8> cells; - std::vector<std::string> datanames; - std::vector<std::vector<double> > data; - std::string path; - WbWriter* writer; - SPtr<LBMUnitConverter> conv; - bool bcInformation; - std::vector<std::vector<SPtr<Block3D> > > blockVector; - int minInitLevel; - int maxInitLevel; - int gridRank; - SPtr<Communicator> comm; - - typedef void(*CalcMacrosFct)(const LBMReal* const& /*feq[27]*/, LBMReal& /*(d)rho*/, LBMReal& /*vx1*/, LBMReal& /*vx2*/, LBMReal& /*vx3*/); - CalcMacrosFct calcMacros; -}; - -#endif +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file WriteMacroscopicQuantitiesCoProcessor.h +//! \ingroup CoProcessors +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef WriteMacroscopicQuantitiesCoProcessor_H +#define WriteMacroscopicQuantitiesCoProcessor_H + +#include <PointerDefinitions.h> +#include <string> +#include <vector> + +#include "CoProcessor.h" +#include "UbTuple.h" +#include "LBMSystem.h" + +class Communicator; +class Grid3D; +class UbScheduler; +class LBMUnitConverter; +class WbWriter; +class Block3D; + + +//! \brief A class writes macroscopic quantities information to a VTK-file +class WriteMacroscopicQuantitiesCoProcessor : public CoProcessor +{ +public: + WriteMacroscopicQuantitiesCoProcessor(); + //! \brief Construct WriteMacroscopicQuantitiesCoProcessor object + //! \pre The Grid3D and UbScheduler objects must exist + //! \param grid is observable Grid3D object + //! \param s is UbScheduler object for scheduling of observer + //! \param path is path of folder for output + //! \param writer is WbWriter object + //! \param conv is LBMUnitConverter object + //! \param comm is Communicator object + WriteMacroscopicQuantitiesCoProcessor(SPtr<Grid3D> grid, SPtr<UbScheduler> s, + const std::string& path, WbWriter* const writer, + SPtr<LBMUnitConverter> conv, SPtr<Communicator> comm); + ~WriteMacroscopicQuantitiesCoProcessor(){} + + void process(double step) override; + +protected: + //! Collect data for VTK-file + //! \param step is a time step + void collectData(double step); + //! Collect data for VTK-file + //! \param block is a time step + void addDataMQ(SPtr<Block3D> block); + void clearData(); + +private: + void init(); + std::vector<UbTupleFloat3> nodes; + std::vector<UbTupleInt8> cells; + std::vector<std::string> datanames; + std::vector<std::vector<double> > data; + std::string path; + WbWriter* writer; + SPtr<LBMUnitConverter> conv; + bool bcInformation; + std::vector<std::vector<SPtr<Block3D> > > blockVector; + int minInitLevel; + int maxInitLevel; + int gridRank; + SPtr<Communicator> comm; + + typedef void(*CalcMacrosFct)(const LBMReal* const& /*feq[27]*/, LBMReal& /*(d)rho*/, LBMReal& /*vx1*/, LBMReal& /*vx2*/, LBMReal& /*vx3*/); + CalcMacrosFct calcMacros; +}; + +#endif diff --git a/src/cpu/VirtualFluidsCore/Connectors/Block3DConnector.h b/src/cpu/VirtualFluidsCore/Connectors/Block3DConnector.h index da0013de0..2cf3cee91 100644 --- a/src/cpu/VirtualFluidsCore/Connectors/Block3DConnector.h +++ b/src/cpu/VirtualFluidsCore/Connectors/Block3DConnector.h @@ -1,99 +1,82 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef BLOCK2DCONNECTOR_H -#define BLOCK2DCONNECTOR_H - -#include <vector> -#include <string> - -#include <basics/utilities/UbTuple.h> - -#include <PointerDefinitions.h> - - -class Block3DConnector -{ - //FETOL -#ifdef VF_FETOL -public: - enum TransmitterType{NONE=0, MPI=1, BOND=2}; -#endif -public: - Block3DConnector() - : sendDir(-1) -#ifdef VF_FETOL - , ttype(NONE) -#endif - {} - - Block3DConnector(const int& sendDir) - : sendDir(sendDir) -#ifdef VF_FETOL - , ttype(NONE) -#endif - {} - - virtual ~Block3DConnector() {} - - virtual void init()=0; - - //for synchronize the send- and receive-bufferlength - virtual void sendTransmitterDataSize()=0; - virtual void receiveTransmitterDataSize()=0; - - //send operations (should be called in given order!!!) - virtual void prepareForSend()=0; - virtual void fillSendVectors()=0; - virtual void sendVectors()=0; - - //receive operations (should be called in given order!!!) - virtual void prepareForReceive()=0; - virtual void receiveVectors()=0; - virtual void distributeReceiveVectors()=0; - - //info section - virtual bool isLocalConnector() = 0; - virtual bool isRemoteConnector() = 0; - virtual bool isInterpolationConnectorCF() = 0; - virtual bool isInterpolationConnectorFC() = 0; - - //grid refinement - virtual int getSendDir() const { return sendDir; } - - //virtual double getSendRecieveTime() = 0; - - virtual void prepareForSendX1() = 0; - virtual void prepareForSendX2() = 0; - virtual void prepareForSendX3() = 0; - - virtual void sendVectorsX1() = 0; - virtual void sendVectorsX2() = 0; - virtual void sendVectorsX3() = 0; - - virtual void prepareForReceiveX1() = 0; - virtual void prepareForReceiveX2() = 0; - virtual void prepareForReceiveX3() = 0; - - virtual void receiveVectorsX1() = 0; - virtual void receiveVectorsX2() = 0; - virtual void receiveVectorsX3() = 0; - - //FETOL -#ifdef VF_FETOL - void setTransmitterType(TransmitterType ttype) { this->ttype=ttype;} - TransmitterType getTransmitterType() {return ttype;} -#endif - -protected: - int sendDir; - //FETOL -#ifdef VF_FETOL - TransmitterType ttype; -#endif -}; - -#endif //BLOCK2DCONNECTOR_H +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Block3DConnector.h +//! \ingroup Connectors +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef BLOCK2DCONNECTOR_H +#define BLOCK2DCONNECTOR_H + +#include <vector> +#include <string> + +#include <basics/utilities/UbTuple.h> + +#include <PointerDefinitions.h> + +//! \brief Abstract class of connectors +//! \details Connector send and receive full distributions between two blocks in shared memory. +class Block3DConnector +{ +public: + Block3DConnector() : sendDir(-1) {} + Block3DConnector(const int& sendDir) : sendDir(sendDir) {} + virtual ~Block3DConnector() {} + //!Iniitializes connector + virtual void init()=0; + //!Synchronizes the send-buffer length + virtual void sendTransmitterDataSize()=0; + //!Synchronizes the receive-buffer length + virtual void receiveTransmitterDataSize()=0; + + //Send (should be called in given order!!!) + virtual void prepareForSend()=0; + virtual void fillSendVectors()=0; + virtual void sendVectors()=0; + + //Receive (should be called in given order!!!) + virtual void prepareForReceive()=0; + virtual void receiveVectors()=0; + virtual void distributeReceiveVectors()=0; + + //info section + virtual bool isLocalConnector() = 0; + virtual bool isRemoteConnector() = 0; + virtual bool isInterpolationConnectorCF() = 0; + virtual bool isInterpolationConnectorFC() = 0; + + //grid refinement + virtual int getSendDir() const { return sendDir; } + +protected: + int sendDir; +}; + +#endif //BLOCK3DCONNECTOR_H diff --git a/src/cpu/VirtualFluidsCore/Connectors/Block3DConnectorFactory.cpp b/src/cpu/VirtualFluidsCore/Connectors/Block3DConnectorFactory.cpp deleted file mode 100644 index 37ac83514..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/Block3DConnectorFactory.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "Block3DConnectorFactory.h" -#include "D3Q27ETFullDirectConnector.h" -#include "D3Q27ETFullVectorConnector.h" -#include "CoarseToFineNodeSetBlock3DConnector.h" -#include "FineToCoarseNodeSetBlock3DConnector.h" - -Block3DConnectorFactory::Block3DConnectorFactory() -{ -} -////////////////////////////////////////////////////////////////////////// -Block3DConnectorFactory::~Block3DConnectorFactory() -{ -} -////////////////////////////////////////////////////////////////////////// -SPtr<Block3DConnector> Block3DConnectorFactory::createSameLevelDirectConnector(SPtr<Block3D> from, SPtr<Block3D> to, int sendDir) -{ - return SPtr<Block3DConnector>(new D3Q27ETFullDirectConnector(from, to, sendDir)); -} -////////////////////////////////////////////////////////////////////////// -SPtr<Block3DConnector> Block3DConnectorFactory::createSameLevelVectorConnector(SPtr<Block3D> block, - VectorTransmitterPtr sender, - VectorTransmitterPtr receiver, - int sendDir) -{ - return SPtr<Block3DConnector>(new D3Q27ETFullVectorConnector(block, sender, receiver, sendDir)); -} -////////////////////////////////////////////////////////////////////////// -SPtr<Block3DConnector> Block3DConnectorFactory::createCoarseToFineConnector(SPtr<Block3D> block, - VectorTransmitterPtr sender00, VectorTransmitterPtr receiver00, - VectorTransmitterPtr sender01, VectorTransmitterPtr receiver01, - VectorTransmitterPtr sender10, VectorTransmitterPtr receiver10, - VectorTransmitterPtr sender11, VectorTransmitterPtr receiver11, - int sendDir, InterpolationProcessorPtr iprocessor) -{ - return SPtr<Block3DConnector> (new CoarseToFineNodeSetBlock3DConnector(block, - sender00, receiver00, sender01, receiver01, - sender10, receiver10, sender11, receiver11, - sendDir, iprocessor)); -} -////////////////////////////////////////////////////////////////////////// -SPtr<Block3DConnector> Block3DConnectorFactory::createFineToCoarseConnector(SPtr<Block3D> block, - VectorTransmitterPtr sender, - VectorTransmitterPtr receiver, - int sendDir, - InterpolationProcessorPtr iprocessor, - FineToCoarseBlock3DConnector::CFconnectorType connType) -{ - return SPtr<Block3DConnector>(new FineToCoarseNodeSetBlock3DConnector(block, - sender, receiver, sendDir, iprocessor, connType)); -} diff --git a/src/cpu/VirtualFluidsCore/Connectors/Block3DConnectorFactory.h b/src/cpu/VirtualFluidsCore/Connectors/Block3DConnectorFactory.h deleted file mode 100644 index b90f9775f..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/Block3DConnectorFactory.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef Block3DConnectorFactory_h__ -#define Block3DConnectorFactory_h__ - -#include "ConnectorFactory.h" - -#include <PointerDefinitions.h> - -class Block3DConnectorFactory : public ConnectorFactory -{ -public: - Block3DConnectorFactory(); - virtual ~Block3DConnectorFactory(); - - virtual SPtr<Block3DConnector> createSameLevelDirectConnector(SPtr<Block3D> from, SPtr<Block3D> to, int sendDir); - - virtual SPtr<Block3DConnector> createSameLevelVectorConnector(SPtr<Block3D> block, - VectorTransmitterPtr sender, - VectorTransmitterPtr receiver, - int sendDir); - - virtual SPtr<Block3DConnector> createCoarseToFineConnector(SPtr<Block3D> block, - VectorTransmitterPtr sender00, VectorTransmitterPtr receiver00, - VectorTransmitterPtr sender01, VectorTransmitterPtr receiver01, - VectorTransmitterPtr sender10, VectorTransmitterPtr receiver10, - VectorTransmitterPtr sender11, VectorTransmitterPtr receiver11, - int sendDir, InterpolationProcessorPtr iprocessor); - - virtual SPtr<Block3DConnector> createFineToCoarseConnector(SPtr<Block3D> block, - VectorTransmitterPtr sender, - VectorTransmitterPtr receiver, - int sendDir, - InterpolationProcessorPtr iprocessor, - FineToCoarseBlock3DConnector::CFconnectorType connType); - -private: - -}; -#endif // Block3DConnectorFactory_h__ - diff --git a/src/cpu/VirtualFluidsCore/Connectors/CMakePackage.txt b/src/cpu/VirtualFluidsCore/Connectors/CMakePackage.txt index de1dc5a88..e3e3f9a38 100644 --- a/src/cpu/VirtualFluidsCore/Connectors/CMakePackage.txt +++ b/src/cpu/VirtualFluidsCore/Connectors/CMakePackage.txt @@ -1,2 +1,2 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +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/src/cpu/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.cpp b/src/cpu/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.cpp deleted file mode 100644 index c33623d7e..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.cpp +++ /dev/null @@ -1,135 +0,0 @@ -#include "CoarseToFineBlock3DConnector.h" - - - -//////////////////////////////////////////////////////////////////////////// - -CoarseToFineBlock3DConnector::CoarseToFineBlock3DConnector(SPtr<Block3D> block, - VectorTransmitterPtr sender00, VectorTransmitterPtr receiver00, - VectorTransmitterPtr sender01, VectorTransmitterPtr receiver01, - VectorTransmitterPtr sender10, VectorTransmitterPtr receiver10, - VectorTransmitterPtr sender11, VectorTransmitterPtr receiver11, - int sendDir, InterpolationProcessorPtr iprocessor) : Block3DConnector(sendDir) - , block(block) - , sender00(sender00) - , sender01(sender01) - , sender10(sender10) - , sender11(sender11) - , receiver00(receiver00) - , receiver01(receiver01) - , receiver10(receiver10) - , receiver11(receiver11) - , iprocessor(iprocessor) -{ - if (!(sendDir==D3Q27System::E || sendDir==D3Q27System::W || sendDir==D3Q27System::N || sendDir==D3Q27System::S || sendDir==D3Q27System::T || sendDir==D3Q27System::B - || sendDir==D3Q27System::NE || sendDir==D3Q27System::SW || sendDir==D3Q27System::SE || sendDir==D3Q27System::NW - || sendDir==D3Q27System::TE || sendDir==D3Q27System::BW || sendDir==D3Q27System::BE || sendDir==D3Q27System::TW - || sendDir==D3Q27System::TN || sendDir==D3Q27System::BS || sendDir==D3Q27System::BN || sendDir==D3Q27System::TS - || sendDir==D3Q27System::TNE || sendDir==D3Q27System::TNW || sendDir==D3Q27System::TSE || sendDir==D3Q27System::TSW - || sendDir==D3Q27System::BNE || sendDir==D3Q27System::BNW || sendDir==D3Q27System::BSE || sendDir==D3Q27System::BSW - )) - { - throw UbException(UB_EXARGS, "invalid constructor for this direction"); - } -} -////////////////////////////////////////////////////////////////////////// - -bool CoarseToFineBlock3DConnector::isLocalConnector() -{ - return !this->isRemoteConnector(); -} -////////////////////////////////////////////////////////////////////////// - -bool CoarseToFineBlock3DConnector::isRemoteConnector() -{ - return ((sender11 && sender11->isRemoteTransmitter()) || (receiver11 && receiver11->isRemoteTransmitter()) - || (sender00 && sender00->isRemoteTransmitter()) || (receiver00 && receiver00->isRemoteTransmitter()) - || (sender01 && sender01->isRemoteTransmitter()) || (receiver01 && receiver01->isRemoteTransmitter()) - || (sender10 && sender10->isRemoteTransmitter()) || (receiver10 && receiver10->isRemoteTransmitter())); -} -////////////////////////////////////////////////////////////////////////// - -void CoarseToFineBlock3DConnector::sendTransmitterDataSize() -{ - if (sender00) - { - UBLOG(logDEBUG5, "CoarseToFineBlock3DConnector<VectorTransmitter>::sendTransmitterDataSize()-sender00 "<<block.lock()->toString()<<" sendDir="<<sendDir); - sender00->sendDataSize(); - } - if (sender01) - { - UBLOG(logDEBUG5, "CoarseToFineBlock3DConnector<VectorTransmitter>::sendTransmitterDataSize()-sender01 "<<block.lock()->toString()<<"sendDir="<<sendDir); - sender01->sendDataSize(); - } - if (sender10) - { - UBLOG(logDEBUG5, "CoarseToFineBlock3DConnector<VectorTransmitter>::sendTransmitterDataSize()-sender10 "<<block.lock()->toString()+"sendDir="<<sendDir); - sender10->sendDataSize(); - } - if (sender11) - { - UBLOG(logDEBUG5, "CoarseToFineBlock3DConnector<VectorTransmitter>::sendTransmitterDataSize()-sender11 "<<block.lock()->toString()<<"sendDir="<<sendDir); - sender11->sendDataSize(); - } -} -////////////////////////////////////////////////////////////////////////// - -void CoarseToFineBlock3DConnector::receiveTransmitterDataSize() -{ - if (receiver00) - { - UBLOG(logDEBUG5, "CoarseToFineBlock3DConnector<VectorTransmitter>::receiveTransmitterDataSize()-receiver00 "<<block.lock()->toString()<<"sendDir="<<sendDir); - receiver00->receiveDataSize(); - } - if (receiver01) - { - UBLOG(logDEBUG5, "CoarseToFineBlock3DConnector<VectorTransmitter>::receiveTransmitterDataSize()-receiver01 "<<block.lock()->toString()<<"sendDir="<<sendDir); - receiver01->receiveDataSize(); - } - if (receiver10) - { - UBLOG(logDEBUG5, "CoarseToFineBlock3DConnector<VectorTransmitter>::receiveTransmitterDataSize()-receiver10 "<<block.lock()->toString()<<"sendDir="<<sendDir); - receiver10->receiveDataSize(); - } - if (receiver11) - { - UBLOG(logDEBUG5, "CoarseToFineBlock3DConnector<VectorTransmitter>::receiveTransmitterDataSize()-receiver11 "<<block.lock()->toString()<<"sendDir="<<sendDir); - receiver11->receiveDataSize(); - } -} -////////////////////////////////////////////////////////////////////////// - -void CoarseToFineBlock3DConnector::prepareForSend() -{ - if (sender00) sender00->prepareForSend(); - if (sender01) sender01->prepareForSend(); - if (sender10) sender10->prepareForSend(); - if (sender11) sender11->prepareForSend(); -} -////////////////////////////////////////////////////////////////////////// - -void CoarseToFineBlock3DConnector::sendVectors() -{ - if (sender00) sender00->sendData(); - if (sender01) sender01->sendData(); - if (sender10) sender10->sendData(); - if (sender11) sender11->sendData(); -} -////////////////////////////////////////////////////////////////////////// - -void CoarseToFineBlock3DConnector::prepareForReceive() -{ - if (receiver00) receiver00->prepareForReceive(); - if (receiver01) receiver01->prepareForReceive(); - if (receiver10) receiver10->prepareForReceive(); - if (receiver11) receiver11->prepareForReceive(); -} -////////////////////////////////////////////////////////////////////////// - -void CoarseToFineBlock3DConnector::receiveVectors() -{ - if (receiver00) receiver00->receiveData(); - if (receiver01) receiver01->receiveData(); - if (receiver10) receiver10->receiveData(); - if (receiver11) receiver11->receiveData(); -} diff --git a/src/cpu/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.h b/src/cpu/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.h deleted file mode 100644 index dcca43230..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/CoarseToFineBlock3DConnector.h +++ /dev/null @@ -1,105 +0,0 @@ -//! \file CoarseToFineBlock3DConnector.h -//! \brief Base class for connectors that interpolates and sends data from coarse level to fine. -//! \author Konstantin Kutscher -//! \date 18.05.2015 - -#ifndef CoarseToFineBlock3DConnector_H -#define CoarseToFineBlock3DConnector_H - -#include "TransmitterType.h" -#include "Block3DConnector.h" -#include "D3Q27System.h" -#include "Block3D.h" -#include "InterpolationProcessor.h" -#include <PointerDefinitions.h> - - -class Block3D; - -//! \class CoarseToFineBlock3DConnector -//! \brief Base class for connectors that interpolates and sends data from coarse level to fine. -//! \details The data is copied in a vector (this is located in the transmitter). -//! The vector is transmitted via transmitter. -//! The transmitter can be a local, MPI, RCG, CTL or whatever -//! which a transmitter that is derived from transmitter base class. -//! -//! four fine blocks inside a coarse block: -//! -//! | | | -//! |:--:|:---| -//! | 01 | 11 | -//! | 00 | 10 | -//! -//! send direction: -//! -//! |E<->W | N<->S | T<->B | -//! |--------|---------|--------| -//! | x3 | x3 | x2 | -//! | ^ | ^ | ^ | -//! | +->x2 | +->x1 | +->x1| - - -class CoarseToFineBlock3DConnector : public Block3DConnector -{ -public: - CoarseToFineBlock3DConnector(SPtr<Block3D> block, - VectorTransmitterPtr sender00, VectorTransmitterPtr receiver00, - VectorTransmitterPtr sender01, VectorTransmitterPtr receiver01, - VectorTransmitterPtr sender10, VectorTransmitterPtr receiver10, - VectorTransmitterPtr sender11, VectorTransmitterPtr receiver11, - int sendDir, InterpolationProcessorPtr iprocessor); - - virtual ~CoarseToFineBlock3DConnector() {} - - bool isLocalConnector(); - bool isRemoteConnector(); - - virtual void init()=0; - - void sendTransmitterDataSize(); - void receiveTransmitterDataSize(); - - void prepareForSend(); - void sendVectors(); - - void prepareForReceive(); - void receiveVectors(); - - virtual void fillSendVectors()=0; - virtual void distributeReceiveVectors() = 0; - - bool isInterpolationConnectorCF() { return true; } - bool isInterpolationConnectorFC() { return false; } - - void prepareForSendX1() {} - void prepareForSendX2() {} - void prepareForSendX3() {} - - void sendVectorsX1() {} - void sendVectorsX2() {} - void sendVectorsX3() {} - - void prepareForReceiveX1() {} - void prepareForReceiveX2() {} - void prepareForReceiveX3() {} - - void receiveVectorsX1() {} - void receiveVectorsX2() {} - void receiveVectorsX3() {} - -protected: - WPtr<Block3D> block; //dieser nvd sendet daten und die empfangenen werden diesem nvd zugeordnet - VectorTransmitterPtr sender00, receiver00, - sender01, receiver01, - sender10, receiver10, - sender11, receiver11; - - InterpolationProcessorPtr iprocessor; - -}; - - - - -#endif - diff --git a/src/cpu/VirtualFluidsCore/Connectors/CoarseToFineNodeSetBlock3DConnector.cpp b/src/cpu/VirtualFluidsCore/Connectors/CoarseToFineNodeSetBlock3DConnector.cpp deleted file mode 100644 index 09deeee47..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/CoarseToFineNodeSetBlock3DConnector.cpp +++ /dev/null @@ -1,1384 +0,0 @@ -#include "CoarseToFineNodeSetBlock3DConnector.h" -#include "DataSet3D.h" - - -//////////////////////////////////////////////////////////////////////////// -CoarseToFineNodeSetBlock3DConnector::CoarseToFineNodeSetBlock3DConnector(SPtr<Block3D> block, - VectorTransmitterPtr sender00, VectorTransmitterPtr receiver00, - VectorTransmitterPtr sender01, VectorTransmitterPtr receiver01, - VectorTransmitterPtr sender10, VectorTransmitterPtr receiver10, - VectorTransmitterPtr sender11, VectorTransmitterPtr receiver11, - int sendDir, InterpolationProcessorPtr iprocessor) : CoarseToFineBlock3DConnector(block, sender00, receiver00, - sender01, receiver01, - sender10, receiver10, - sender11, receiver11, - sendDir, iprocessor) -{ -} -////////////////////////////////////////////////////////////////////////// -void CoarseToFineNodeSetBlock3DConnector::init() -{ - bMaxX1 = (int)block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX1(); - bMaxX2 = (int)block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX2(); - bMaxX3 = (int)block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX3(); - - minX1 = 0; - minX2 = 0; - minX3 = 0; - maxX1 = bMaxX1 - 1; - maxX2 = bMaxX2 - 1; - maxX3 = bMaxX3 - 1; - - minHalfX1 = 0; - minHalfX2 = 0; - minHalfX3 = 0; - - maxHalfX1 = 0; - maxHalfX2 = 0; - maxHalfX3 = 0; - - if (Utilities::isEven(bMaxX1)) - { - minHalfX1 = bMaxX1 / 2 - 1; - maxHalfX1 = bMaxX1 / 2 - 1; - } - else if (Utilities::isOdd(bMaxX1)) - { - minHalfX1 = bMaxX1 / 2; - maxHalfX1 = bMaxX1 / 2 - 1; - } - - if (Utilities::isEven(bMaxX2)) - { - minHalfX2 = bMaxX2 / 2 - 1; - maxHalfX2 = bMaxX2 / 2 - 1; - } - else if (Utilities::isOdd(bMaxX2)) - { - minHalfX2 = bMaxX2 / 2; - maxHalfX2 = bMaxX2 / 2 - 1; - } - - if (Utilities::isEven(bMaxX3)) - { - minHalfX3 = bMaxX3 / 2 - 1; - maxHalfX3 = bMaxX3 / 2 - 1; - } - else if (Utilities::isOdd(bMaxX3)) - { - minHalfX3 = bMaxX3 / 2; - maxHalfX3 = bMaxX3 / 2 - 1; - } - - //int sendSize = 0; - LBMReal initValue = -999.0; - - int sendDataPerNode = 27/*f*/; - int iCellSize = 8; //size of interpolation cell - - findCFCells(); - findFCCells(); - - ////////////////////////////////////////////////////// - //Debug - ////////////////////////////////////////////////////// - if (block.lock()->getGlobalID() == 2234) - { - int test = 0; - } - - if (sender00) sender00->getData().resize(iNodeSetSender00.size()*iCellSize*sendDataPerNode, initValue); - else sender00 = VectorTransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); - if (sender01) sender01->getData().resize(iNodeSetSender01.size()*iCellSize*sendDataPerNode, initValue); - else sender01 = VectorTransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); - if (sender10) sender10->getData().resize(iNodeSetSender10.size()*iCellSize*sendDataPerNode, initValue); - else sender10 = VectorTransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); - if (sender11) sender11->getData().resize(iNodeSetSender11.size()*iCellSize*sendDataPerNode, initValue); - else sender11 = VectorTransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); - - if (!receiver00) receiver00 = VectorTransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); - if (!receiver01) receiver01 = VectorTransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); - if (!receiver10) receiver10 = VectorTransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); - if (!receiver11) receiver11 = VectorTransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); -} -////////////////////////////////////////////////////////////////////////// - -void CoarseToFineNodeSetBlock3DConnector::findCFCells(int lMinX1, int lMinX2, int lMinX3, int lMaxX1, int lMaxX2, int lMaxX3, INodeSet &inodes) -{ - int ix1, ix2, ix3; - LBMReal x1off, x2off, x3off; - - SPtr<DistributionArray3D> fFrom = block.lock()->getKernel()->getDataSet()->getFdistributions(); - SPtr<BCArray3D> bcArray = block.lock()->getKernel()->getBCProcessor()->getBCArray(); - - for (ix3 = lMinX3; ix3<=lMaxX3; ix3++) - { - for (ix2 = lMinX2; ix2<=lMaxX2; ix2++) - { - for (ix1 = lMinX1; ix1<=lMaxX1; ix1++) - { - D3Q27ICell icellC; - - int howManySolids = iprocessor->iCellHowManySolids(bcArray, ix1, ix2, ix3); - - if (howManySolids == 0 || howManySolids == 8) - { - x1off = 0.0; - x2off = 0.0; - x3off = 0.0; - } - else - { - if (!iprocessor->findNeighborICell(bcArray, fFrom, icellC, bMaxX1, bMaxX2, bMaxX3, ix1, ix2, ix3, x1off, x2off, x3off)) - { - std::string err = "For "+block.lock()->toString()+" x1="+UbSystem::toString(ix1)+", x2=" + UbSystem::toString(ix2)+", x3=" + UbSystem::toString(ix3)+ - " 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)); - } - } - - INodeVector inv; - inv.push_back(ix1 + (int)x1off); - inv.push_back(ix2 + (int)x2off); - inv.push_back(ix3 + (int)x3off); - inv.push_back((int)x1off); - inv.push_back((int)x2off); - inv.push_back((int)x3off); - //inodes.insert(inv); - inodes.push_back(inv); - } - } - } -} -////////////////////////////////////////////////////////////////////////// -//template< typename VectorTransmitter > -void CoarseToFineNodeSetBlock3DConnector::findCFCells() -{ - using namespace D3Q27System; - - int lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3; - - switch (sendDir) - { - //faces - case E: case W: - if (sendDir == E) - { - lMinX1 = maxX1 - 2; - lMaxX1 = lMinX1; - } - else if (sendDir == W) - { - lMinX1 = 1; - lMaxX1 = lMinX1; - } - - if (sender00) - { - lMinX2 = minX2; - lMaxX2 = maxHalfX2; - lMinX3 = minX3; - lMaxX3 = maxHalfX3; - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetSender00); - } - if (sender10) - { - lMinX2 = minHalfX2; - lMaxX2 = maxX2 - 1; - lMinX3 = minX3; - lMaxX3 = maxHalfX3; - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetSender10); - } - if (sender01) - { - lMinX2 = minX2; - lMaxX2 = maxHalfX2; - lMinX3 = minHalfX3; - lMaxX3 = maxX3 - 1; - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetSender01); - } - if (sender11) - { - lMinX2 = minHalfX2; - lMaxX2 = maxX2 - 1; - lMinX3 = minHalfX3; - lMaxX3 = maxX3 - 1; - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetSender11); - } - break; - case N: case S: - if (sendDir == N) - { - lMinX2 = maxX2 - 2; - lMaxX2 = lMinX2; - } - else if (sendDir == S) - { - lMinX2 = 1; - lMaxX2 = lMinX2; - } - - if (sender00) - { - lMinX1 = minX1; - lMaxX1 = maxHalfX1; - lMinX3 = minX3; - lMaxX3 = maxHalfX3; - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetSender00); - } - if (sender10) - { - lMinX1 = minHalfX1; - lMaxX1 = maxX1 - 1; - lMinX3 = minX3; - lMaxX3 = maxHalfX3; - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetSender10); - } - if (sender01) - { - lMinX1 = minX1; - lMaxX1 = maxHalfX1; - lMinX3 = minHalfX3; - lMaxX3 = maxX3 - 1; - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetSender01); - } - if (sender11) - { - lMinX1 = minHalfX1; - lMaxX1 = maxX1 - 1; - lMinX3 = minHalfX3; - lMaxX3 = maxX3 - 1; - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetSender11); - } - break; - case T: case B: - if (sendDir == T) - { - lMinX3 = maxX3 - 2; - lMaxX3 = lMinX3; - } - else if (sendDir == B) - { - lMinX3 = 1; - lMaxX3 = lMinX3; - } - - if (sender00) - { - lMinX1 = minX1; - lMaxX1 = maxHalfX1; - lMinX2 = minX2; - lMaxX2 = maxHalfX2; - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetSender00); - } - if (sender10) - { - lMinX1 = minHalfX1; - lMaxX1 = maxX1 - 1; - lMinX2 = minX2; - lMaxX2 = maxHalfX2; - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetSender10); - } - if (sender01) - { - lMinX1 = minX1; - lMaxX1 = maxHalfX1; - lMinX2 = minHalfX2; - lMaxX2 = maxX2 - 1; - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetSender01); - } - if (sender11) - { - lMinX1 = minHalfX1; - lMaxX1 = maxX1 - 1; - lMinX2 = minHalfX2; - lMaxX2 = maxX2 - 1; - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetSender11); - } - break; - //edges - //N-S-E-W - case NE: case SW: case SE: case NW: - if (sendDir == NE) - { - lMinX1 = maxX1 - 2; - lMaxX1 = lMinX1 + 1; - lMinX2 = maxX2 - 2; - lMaxX2 = lMinX2 + 1; - } - else if (sendDir == SW) - { - lMinX1 = 0; - lMaxX1 = lMinX1 + 1; - lMinX2 = 0; - lMaxX2 = lMinX2 + 1; - } - else if (sendDir == SE) - { - lMinX1 = maxX1 - 2; - lMaxX1 = lMinX1 + 1; - lMinX2 = 0; - lMaxX2 = lMinX2 + 1; - } - else if (sendDir == NW) - { - lMinX1 = 0; - lMaxX1 = lMinX1 + 1; - lMinX2 = maxX2 - 2; - lMaxX2 = lMinX2 + 1; - } - - if (sender00) - { - lMinX3 = minX3; - lMaxX3 = maxHalfX3; - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetSender00); - } - if (sender10) - { - lMinX3 = minHalfX3; - lMaxX3 = maxX3 - 1; - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetSender10); - } - break; - //T-B-E-W - case TE: case BW: case BE: case TW: - if (sendDir == TE) - { - lMinX1 = maxX1 - 2; - lMaxX1 = lMinX1 + 1; - lMinX3 = maxX3 - 2; - lMaxX3 = lMinX3 + 1; - } - else if (sendDir == BW) - { - lMinX1 = 0; - lMaxX1 = lMinX1 + 2; - lMinX3 = 0; - lMaxX3 = lMinX3 + 2; - } - else if (sendDir == BE) - { - lMinX1 = maxX1 - 2; - lMaxX1 = lMinX1 + 1; - lMinX3 = 0; - lMaxX3 = lMinX3 + 1; - } - else if (sendDir == TW) - { - lMinX1 = 0; - lMaxX1 = lMinX1 + 1; - lMinX3 = maxX3 - 2; - lMaxX3 = lMinX3 + 1; - } - - if (sender00) - { - lMinX2 = minX2; - lMaxX2 = maxHalfX2; - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetSender00); - } - if (sender10) - { - lMinX2 = minHalfX2; - lMaxX2 = maxX2 - 1; - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetSender10); - } - break; - //T-B-N-S - case TN: case BS: case BN: case TS: - if (sendDir == TN) - { - lMinX2 = maxX2 - 2; - lMaxX2 = lMinX2 + 1; - lMinX3 = maxX3 - 3; - lMaxX3 = lMinX3 + 1; - } - else if (sendDir == BS) - { - lMinX2 = 0; - lMaxX2 = lMinX2 + 1; - lMinX3 = 0; - lMaxX3 = lMinX3 + 1; - } - else if (sendDir == BN) - { - lMinX2 = maxX2 - 2; - lMaxX2 = lMinX2 + 1; - lMinX3 = 0; - lMaxX3 = lMinX3 + 1; - } - else if (sendDir == TS) - { - lMinX2 = 0; - lMaxX2 = lMinX2 + 1; - lMinX3 = maxX3 - 2; - lMaxX3 = lMinX3 + 1; - } - - if (sender00) - { - lMinX1 = minX1; - lMaxX1 = maxHalfX1; - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetSender00); - } - if (sender10) - { - lMinX1 = minHalfX1; - lMaxX1 = maxX1 - 1; - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetSender10); - } - break; - //corners - case TNE: case TNW: case TSE: case TSW: case BNE: case BNW: case BSE: case BSW: - if (sendDir == TNE) - { - lMinX1 = maxX1-2; - lMaxX1 = maxX1-1; - lMinX2 = maxX2-2; - lMaxX2 = maxX2-1; - lMinX3 = maxX3-2; - lMaxX3 = maxX3-1; - } - else if (sendDir == TNW) - { - lMinX1 = 0; - lMaxX1 = 1; - lMinX2 = maxX2-2; - lMaxX2 = maxX2-1; - lMinX3 = maxX3-2; - lMaxX3 = maxX3-1; - } - else if (sendDir == TSE) - { - lMinX1 = maxX1-2; - lMaxX1 = maxX1-1; - lMinX2 = 0; - lMaxX2 = 1; - lMinX3 = maxX3-2; - lMaxX3 = maxX3-1; - } - else if (sendDir == TSW) - { - lMinX1 = 0; - lMaxX1 = 1; - lMinX2 = 0; - lMaxX2 = 1; - lMinX3 = maxX3-2; - lMaxX3 = maxX3-1; - } - else if (sendDir == BNE) - { - lMinX1 = maxX1-2; - lMaxX1 = maxX1-1; - lMinX2 = maxX2-2; - lMaxX2 = maxX2-1; - lMinX3 = 0; - lMaxX3 = 1; - } - else if (sendDir == BNW) - { - lMinX1 = 0; - lMaxX1 = 1; - lMinX2 = maxX2-2; - lMaxX2 = maxX2-1; - lMinX3 = 0; - lMaxX3 = 1; - } - else if (sendDir == BSE) - { - lMinX1 = maxX1-2; - lMaxX1 = maxX1-1; - lMinX2 = 0; - lMaxX2 = 1; - lMinX3 = 0; - lMaxX3 = 1; - } - else if (sendDir == BSW) - { - lMinX1 = 0; - lMaxX1 = 1; - lMinX2 = 0; - lMaxX2 = 1; - lMinX3 = 0; - lMaxX3 = 1; - } - if (sender00) - { - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetSender00); - } - break; - } -} -////////////////////////////////////////////////////////////////////////// -//template< typename VectorTransmitter > -void CoarseToFineNodeSetBlock3DConnector::fillSendVectors() -{ - using namespace D3Q27System; - - SPtr<DistributionArray3D> fFrom = block.lock()->getKernel()->getDataSet()->getFdistributions(); - - int index00 = 0; - int index01 = 0; - int index10 = 0; - int index11 = 0; - - vector_type& data00 = this->sender00->getData(); - vector_type& data01 = this->sender01->getData(); - vector_type& data10 = this->sender10->getData(); - vector_type& data11 = this->sender11->getData(); - - for(INodeVector inode : iNodeSetSender00) - { - D3Q27ICell icellC; - D3Q27ICell icellF; - iprocessor->readICell(fFrom, icellC, inode[0], inode[1], inode[2]); - iprocessor->interpolateCoarseToFine(icellC, icellF, inode[3], inode[4], inode[5]); - writeICellFtoData(data00, index00, icellF); - } - for(INodeVector inode : iNodeSetSender01) - { - D3Q27ICell icellC; - D3Q27ICell icellF; - iprocessor->readICell(fFrom, icellC, inode[0], inode[1], inode[2]); - iprocessor->interpolateCoarseToFine(icellC, icellF, inode[3], inode[4], inode[5]); - writeICellFtoData(data01, index01, icellF); - } - for(INodeVector inode : iNodeSetSender10) - { - D3Q27ICell icellC; - D3Q27ICell icellF; - iprocessor->readICell(fFrom, icellC, inode[0], inode[1], inode[2]); - iprocessor->interpolateCoarseToFine(icellC, icellF, inode[3], inode[4], inode[5]); - writeICellFtoData(data10, index10, icellF); - } - for(INodeVector inode : iNodeSetSender11) - { - D3Q27ICell icellC; - D3Q27ICell icellF; - iprocessor->readICell(fFrom, icellC, inode[0], inode[1], inode[2]); - iprocessor->interpolateCoarseToFine(icellC, icellF, inode[3], inode[4], inode[5]); - writeICellFtoData(data11, index11, icellF); - } -} -////////////////////////////////////////////////////////////////////////// - -void CoarseToFineNodeSetBlock3DConnector::writeICellFtoData(vector_type& data, int& index, D3Q27ICell& icellF) -{ - writeNodeToVector(data, index, icellF.BSW); - writeNodeToVector(data, index, icellF.BSE); - writeNodeToVector(data, index, icellF.BNW); - writeNodeToVector(data, index, icellF.BNE); - writeNodeToVector(data, index, icellF.TSW); - writeNodeToVector(data, index, icellF.TSE); - writeNodeToVector(data, index, icellF.TNW); - writeNodeToVector(data, index, icellF.TNE); -} -////////////////////////////////////////////////////////////////////////// - -void CoarseToFineNodeSetBlock3DConnector::writeNodeToVector(vector_type& data, int& index, LBMReal* inode) -{ - for (int i = D3Q27System::STARTF; i < D3Q27System::ENDF+1; i++) - { - data[index++] = inode[i]; - } -} -////////////////////////////////////////////////////////////////////////// - -void CoarseToFineNodeSetBlock3DConnector::findFCCells(int lMinX1, int lMinX2, int lMinX3, int lMaxX1, int lMaxX2, int lMaxX3, INodeSet &inodes) -{ - int ix1, ix2, ix3; - - for (ix3 = lMinX3; ix3<=lMaxX3; ix3++) - { - for (ix2 = lMinX2; ix2<=lMaxX2; ix2++) - { - for (ix1 = lMinX1; ix1<=lMaxX1; ix1++) - { - INodeVector inv; - inv.push_back(ix1); - inv.push_back(ix2); - inv.push_back(ix3); - //inodes.insert(inv); - inodes.push_back(inv); - } - } - } -} -////////////////////////////////////////////////////////////////////////// -//template< typename VectorTransmitter > -void CoarseToFineNodeSetBlock3DConnector::findFCCells() -{ - using namespace D3Q27System; - - int lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3; - int lMin2X1, lMin2X2, lMin2X3, lMax2X1, lMax2X2, lMax2X3; - int lMin3X1, lMin3X2, lMin3X3, lMax3X1, lMax3X2, lMax3X3; - int dummy; - - switch (sendDir) - { - - ////////////////////////////////////////////////////// - //Debug - ////////////////////////////////////////////////////// - // if (block.lock()->getGlobalID() == 2234) - // { - // int test = 0; - // } - - //faces - case E: case W: - if (sendDir == E) - { - lMin1X1 = maxX1 - 3; - lMax1X1 = lMin1X1; - } - else if (sendDir == W) - { - lMin1X1 = 3; - lMax1X1 = lMin1X1; - } - - //int TminX1 = lMinX1; int TminX2 = lMinX2; int TminX3 = lMinX3; int TmaxX1 = lMaxX1; int TmaxX2 = lMaxX2; int TmaxX3 = lMaxX3; - - //if (block.lock()->hasInterpolationFlagCF(E)) - //{ - // if (maxX1==TmaxX1) maxX1 -= 2; - //} - //if (block.lock()->hasInterpolationFlagCF(W)) - //{ - // if (minX1==TminX1) minX1 += 2; - //} - //if (block.lock()->hasInterpolationFlagCF(N)) - //{ - // if (maxX2==TmaxX2) maxX2 -= 2; - //} - //if (block.lock()->hasInterpolationFlagCF(S)) - //{ - // if (minX2==TminX2) minX2 += 2; - //} - //if (block.lock()->hasInterpolationFlagCF(T)) - //{ - // if (maxX3==TmaxX3) maxX3 -= 2; - //} - //if (block.lock()->hasInterpolationFlagCF(B)) - //{ - // if (minX3==TminX3) minX3 += 2; - //} - if (receiver00) - { - lMin1X2 = minX2; - lMax1X2 = maxHalfX2; - lMin1X3 = minX3; - lMax1X3 = maxHalfX3; - getLocalMinMax(dummy, lMin1X2, lMin1X3, dummy, dummy, dummy); - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetReceiver00); - } - if (receiver10) - { - lMin1X2 = minHalfX2; - lMax1X2 = maxX2 - 1; - lMin1X3 = minX3; - lMax1X3 = maxHalfX3; - getLocalMinMax(dummy, dummy, lMin1X3, dummy, lMax1X2, dummy); - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetReceiver10); - } - if (receiver01) - { - lMin1X2 = minX2; - lMax1X2 = maxHalfX2; - lMin1X3 = minHalfX3; - lMax1X3 = maxX3 - 1; - getLocalMinMax(dummy, lMin1X2, dummy, dummy, dummy, lMax1X3); - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetReceiver01); - } - if (receiver11) - { - lMin1X2 = minHalfX2; - lMax1X2 = maxX2 - 1; - lMin1X3 = minHalfX3; - lMax1X3 = maxX3 - 1; - getLocalMinMax(dummy, dummy, dummy, dummy, lMax1X2, lMax1X3); - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetReceiver11); - } - break; - case N: case S: - if (sendDir == N) - { - lMin1X2 = maxX2 - 3; - lMax1X2 = lMin1X2; - } - else if (sendDir == S) - { - lMin1X2 = 3; - lMax1X2 = lMin1X2; - } - - if (receiver00) - { - lMin1X1 = minX1; - lMax1X1 = maxHalfX1; - lMin1X3 = minX3; - lMax1X3 = maxHalfX3; - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetReceiver00); - } - if (receiver10) - { - lMin1X1 = minHalfX1; - lMax1X1 = maxX1 - 1; - lMin1X3 = minX3; - lMax1X3 = maxHalfX3; - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetReceiver10); - } - if (receiver01) - { - lMin1X1 = minX1; - lMax1X1 = maxHalfX1; - lMin1X3 = minHalfX3; - lMax1X3 = maxX3 - 1; - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetReceiver01); - } - if (receiver11) - { - lMin1X1 = minHalfX1; - lMax1X1 = maxX1 - 1; - lMin1X3 = minHalfX3; - lMax1X3 = maxX3 - 1; - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetReceiver11); - } - break; - case T: case B: - if (sendDir == T) - { - lMin1X3 = maxX3 - 3; - lMax1X3 = lMin1X3; - } - else if (sendDir == B) - { - lMin1X3 = 3; - lMax1X3 = lMin1X3; - } - - if (receiver00) - { - lMin1X1 = minX1; - lMax1X1 = maxHalfX1; - lMin1X2 = minX2; - lMax1X2 = maxHalfX2; - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetReceiver00); - } - if (receiver10) - { - lMin1X1 = minHalfX1; - lMax1X1 = maxX1 - 1; - lMin1X2 = minX2; - lMax1X2 = maxHalfX2; - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetReceiver10); - } - if (receiver01) - { - lMin1X1 = minX1; - lMax1X1 = maxHalfX1; - lMin1X2 = minHalfX2; - lMax1X2 = maxX2 - 1; - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetReceiver01); - } - if (receiver11) - { - lMin1X1 = minHalfX1; - lMax1X1 = maxX1 - 1; - lMin1X2 = minHalfX2; - lMax1X2 = maxX2 - 1; - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetReceiver11); - } - break; - //edges - //N-S-E-W - case NE: case SW: case SE: case NW: - if (sendDir == NE) - { - lMin1X1 = maxX1 - 3; - lMax1X1 = lMin1X1 + 2; - lMin1X2 = maxX2 - 3; - lMax1X2 = lMin1X2; - - lMin2X1 = maxX1 - 3; - lMax2X1 = lMin2X1; - lMin2X2 = maxX2 - 3; - lMax2X2 = lMin2X2 + 2; - } - else if (sendDir == SW) - { - lMin1X1 = 1; - lMax1X1 = lMin1X1 + 2; - lMin1X2 = 3; - lMax1X2 = lMin1X2; - - lMin2X1 = 3; - lMax2X1 = lMin2X1; - lMin2X2 = 1; - lMax2X2 = lMin2X2 + 2; - } - else if (sendDir == SE) - { - lMin1X1 = maxX1 - 3; - lMax1X1 = lMin1X1 + 2; - lMin1X2 = 3; - lMax1X2 = lMin1X2; - - lMin2X1 = maxX1 - 3; - lMax2X1 = lMin2X1; - lMin2X2 = 1; - lMax2X2 = lMin2X2 + 2; - } - else if (sendDir == NW) - { - lMin1X1 = 1; - lMax1X1 = lMin1X1 + 2; - lMin1X2 = maxX2 - 3; - lMax1X2 = lMin1X2; - - lMin2X1 = 3; - lMax2X1 = lMin2X1; - lMin2X2 = maxX2 - 3; - lMax2X2 = lMin2X2 + 2; - } - - if (receiver00) - { - lMin1X3 = minX3; - lMax1X3 = maxHalfX3; - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetReceiver00); - } - if (receiver10) - { - lMin1X3 = minHalfX3; - lMax1X3 = maxX3 - 1; - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetReceiver10); - } - - if (receiver00) - { - lMin2X3 = minX3; - lMax2X3 = maxHalfX3; - findFCCells(lMin2X1, lMin2X2, lMin2X3, lMax2X1, lMax2X2, lMax2X3, iNodeSetReceiver00); - } - if (receiver10) - { - lMin2X3 = minHalfX3; - lMax2X3 = maxX3 - 1; - findFCCells(lMin2X1, lMin2X2, lMin2X3, lMax2X1, lMax2X2, lMax2X3, iNodeSetReceiver10); - } - break; - //T-B-E-W - case TE: case BW: case BE: case TW: - if (sendDir == TE) - { - lMin1X1 = maxX1 - 3; - lMax1X1 = lMin1X1 + 2; - lMin1X3 = maxX3 - 3; - lMax1X3 = lMin1X3; - - lMin2X1 = maxX1 - 3; - lMax2X1 = lMin2X1; - lMin2X3 = maxX3 - 3; - lMax2X3 = lMin2X3 + 2; - } - else if (sendDir == BW) - { - lMin1X1 = 1; - lMax1X1 = lMin1X1 + 2; - lMin1X3 = 3; - lMax1X3 = lMin1X3; - - lMin2X1 = 3; - lMax2X1 = lMin2X1; - lMin2X3 = 1; - lMax2X3 = lMin2X3 + 2; - } - else if (sendDir == BE) - { - lMin1X1 = maxX1 - 3; - lMax1X1 = lMin1X1 + 2; - lMin1X3 = 3; - lMax1X3 = lMin1X3; - - - lMin2X1 = maxX1 - 3; - lMax2X1 = lMin2X1; - lMin2X3 = 1; - lMax2X3 = lMin2X3 + 2; - } - else if (sendDir == TW) - { - lMin1X1 = 1; - lMax1X1 = lMin1X1 + 2; - lMin1X3 = maxX3 - 3; - lMax1X3 = lMin1X3; - - lMin2X1 = 3; - lMax2X1 = lMin2X1; - lMin2X3 = maxX3 - 3; - lMax2X3 = lMin2X3 + 2; - } - - if (receiver00) - { - lMin1X2 = minX2; - lMax1X2 = maxHalfX2; - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetReceiver00); - } - if (receiver10) - { - lMin1X2 = minHalfX2; - lMax1X2 = maxX2 - 1; - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetReceiver10); - } - - if (receiver00) - { - lMin2X2 = minX2; - lMax2X2 = maxHalfX2; - findFCCells(lMin2X1, lMin2X2, lMin2X3, lMax2X1, lMax2X2, lMax2X3, iNodeSetReceiver00); - } - if (receiver10) - { - lMin2X2 = minHalfX2; - lMax2X2 = maxX2 - 1; - findFCCells(lMin2X1, lMin2X2, lMin2X3, lMax2X1, lMax2X2, lMax2X3, iNodeSetReceiver10); - } - break; - //T-B-N-S - case TN: case BS: case BN: case TS: - if (sendDir == TN) - { - lMin1X2 = maxX2 - 3; - lMax1X2 = lMin1X2 + 2; - lMin1X3 = maxX3 - 3; - lMax1X3 = lMin1X3; - - lMin2X2 = maxX2 - 3; - lMax2X2 = lMin2X2; - lMin2X3 = maxX3 - 3; - lMax2X3 = lMin2X3 + 2; - } - else if (sendDir == BS) - { - lMin1X2 = 1; - lMax1X2 = lMin1X2 + 2; - lMin1X3 = 3; - lMax1X3 = lMin1X3; - - lMin2X2 = 3; - lMax2X2 = lMin2X2; - lMin2X3 = 1; - lMax2X3 = lMin2X3 + 2; - } - else if (sendDir == BN) - { - lMin1X2 = maxX2 - 3; - lMax1X2 = lMin1X2 + 2; - lMin1X3 = 3; - lMax1X3 = lMin1X3; - - lMin2X2 = maxX2 - 3; - lMax2X2 = lMin2X2; - lMin2X3 = 1; - lMax2X3 = lMin2X3 + 2; - } - else if (sendDir == TS) - { - lMin1X2 = 1; - lMax1X2 = lMin1X2 + 2; - lMin1X3 = maxX3 - 3; - lMax1X3 = lMin1X3; - - lMin2X2 = 3; - lMax2X2 = lMin2X2; - lMin2X3 = maxX3 - 3; - lMax2X3 = lMin2X3 + 2; - } - - if (receiver00) - { - lMin1X1 = minX1; - lMax1X1 = maxHalfX1; - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetReceiver00); - } - if (receiver10) - { - lMin1X1 = minHalfX1; - lMax1X1 = maxX1 - 1; - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetReceiver10); - } - - if (receiver00) - { - lMin2X1 = minX1; - lMax2X1 = maxHalfX1; - findFCCells(lMin2X1, lMin2X2, lMin2X3, lMax2X1, lMax2X2, lMax2X3, iNodeSetReceiver00); - } - if (receiver10) - { - lMin2X1 = minHalfX1; - lMax2X1 = maxX1 - 1; - findFCCells(lMin2X1, lMin2X2, lMin2X3, lMax2X1, lMax2X2, lMax2X3, iNodeSetReceiver10); - } - break; - //corners - case TNE: case TNW: case TSE: case TSW: case BNE: case BNW: case BSE: case BSW: - if (sendDir == TNE) - { - lMin1X1 = maxX1 - 3; - lMax1X1 = maxX1 - 2; - lMin1X2 = maxX2 - 3; - lMax1X2 = maxX2 - 1; - lMin1X3 = maxX3 - 3; - lMax1X3 = maxX3 - 1; - - lMin2X1 = maxX1 - 3; - lMax2X1 = maxX1 - 1; - lMin2X2 = maxX2 - 3; - lMax2X2 = maxX2 - 2; - lMin2X3 = maxX3 - 3; - lMax2X3 = maxX3 - 1; - - lMin3X1 = maxX1 - 3; - lMax3X1 = maxX1 - 1; - lMin3X2 = maxX2 - 3; - lMax3X2 = maxX2 - 1; - lMin3X3 = maxX3 - 3; - lMax3X3 = maxX3 - 2; - } - else if (sendDir == TNW) - { - lMin1X1 = 3; - lMax1X1 = 3; - lMin1X2 = maxX2 - 3; - lMax1X2 = maxX2 - 1; - lMin1X3 = maxX3 - 3; - lMax1X3 = maxX3 - 1; - - lMin2X1 = 1; - lMax2X1 = 3; - lMin2X2 = maxX2 - 3; - lMax2X2 = maxX2 - 2; - lMin2X3 = maxX3 - 3; - lMax2X3 = maxX3; - - lMin3X1 = 1; - lMax3X1 = 3; - lMin3X2 = maxX2 - 3; - lMax3X2 = maxX2 - 1; - lMin3X3 = maxX3 - 3; - lMax3X3 = maxX3 - 2; - } - else if (sendDir == TSE) - { - lMin1X1 = maxX1 - 3; - lMax1X1 = maxX1 - 2; - lMin1X2 = 1; - lMax1X2 = 3; - lMin1X3 = maxX3 - 3; - lMax1X3 = maxX3; - - lMin2X1 = maxX1 - 3; - lMax2X1 = maxX1 - 1; - lMin2X2 = 3; - lMax2X2 = 3; - lMin2X3 = maxX3 - 3; - lMax2X3 = maxX3; - - lMin3X1 = maxX1 - 3; - lMax3X1 = maxX1 - 1; - lMin3X2 = 1; - lMax3X2 = 3; - lMin3X3 = maxX3 - 3; - lMax3X3 = maxX3 - 2; - } - else if (sendDir == TSW) - { - lMin1X1 = 3; - lMax1X1 = 3; - lMin1X2 = 1; - lMax1X2 = 3; - lMin1X3 = maxX3 - 3; - lMax1X3 = maxX3 - 1; - - lMin2X1 = 1; - lMax2X1 = 3; - lMin2X2 = 3; - lMax2X2 = 3; - lMin2X3 = maxX3 - 3; - lMax2X3 = maxX3 - 1; - - lMin3X1 = 1; - lMax3X1 = 3; - lMin3X2 = 1; - lMax3X2 = 3; - lMin3X3 = maxX3 - 3; - lMax3X3 = maxX3 - 2; - } - else if (sendDir == BNE) - { - lMin1X1 = maxX1 - 3; - lMax1X1 = maxX1 - 2; - lMin1X2 = maxX2 - 3; - lMax1X2 = maxX2 - 1; - lMin1X3 = 1; - lMax1X3 = 3; - - lMin2X1 = maxX1 - 3; - lMax2X1 = maxX1 - 1; - lMin2X2 = maxX2 - 3; - lMax2X2 = maxX2 - 2; - lMin2X3 = 1; - lMax2X3 = 3; - - lMin3X1 = maxX1 - 3; - lMax3X1 = maxX1 - 1; - lMin3X2 = maxX2 - 3; - lMax3X2 = maxX2 - 1; - lMin3X3 = 3; - lMax3X3 = 3; - } - else if (sendDir == BNW) - { - lMin1X1 = 3; - lMax1X1 = 3; - lMin1X2 = maxX2 - 3; - lMax1X2 = maxX2 - 1; - lMin1X3 = 1; - lMax1X3 = 3; - - lMin2X1 = 1; - lMax2X1 = 3; - lMin2X2 = maxX2 - 3; - lMax2X2 = maxX2 - 2; - lMin2X3 = 1; - lMax2X3 = 3; - - lMin3X1 = 1; - lMax3X1 = 3; - lMin3X2 = maxX2 - 3; - lMax3X2 = maxX2 - 1; - lMin3X3 = 3; - lMax3X3 = 3; - } - else if (sendDir == BSE) - { - lMin1X1 = maxX1 - 3; - lMax1X1 = maxX1 - 2; - lMin1X2 = 1; - lMax1X2 = 3; - lMin1X3 = 1; - lMax1X3 = 3; - - lMin2X1 = maxX1 - 3; - lMax2X1 = maxX1 - 1; - lMin2X2 = 3; - lMax2X2 = 3; - lMin2X3 = 1; - lMax2X3 = 3; - - lMin3X1 = maxX1 - 3; - lMax3X1 = maxX1 - 1; - lMin3X2 = 1; - lMax3X2 = 3; - lMin3X3 = 3; - lMax3X3 = 3; - } - else if (sendDir == BSW) - { - lMin1X1 = 3; - lMax1X1 = 3; - lMin1X2 = 1; - lMax1X2 = 3; - lMin1X3 = 1; - lMax1X3 = 3; - - lMin2X1 = 1; - lMax2X1 = 3; - lMin2X2 = 3; - lMax2X2 = 3; - lMin2X3 = 1; - lMax2X3 = 3; - - lMin3X1 = 1; - lMax3X1 = 3; - lMin3X2 = 1; - lMax3X2 = 3; - lMin3X3 = 3; - lMax3X3 = 3; - } - if (receiver00) - { - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetReceiver00); - } - if (receiver00) - { - findFCCells(lMin2X1, lMin2X2, lMin2X3, lMax2X1, lMax2X2, lMax2X3, iNodeSetReceiver00); - } - if (receiver00) - { - findFCCells(lMin3X1, lMin3X2, lMin3X3, lMax3X1, lMax3X2, lMax3X3, iNodeSetReceiver00); - } - break; - } -} -////////////////////////////////////////////////////////////////////////// -//template< typename VectorTransmitter > -void CoarseToFineNodeSetBlock3DConnector::distributeReceiveVectors() -{ - using namespace D3Q27System; - - SPtr<DistributionArray3D> fTo = block.lock()->getKernel()->getDataSet()->getFdistributions(); - - int index00 = 0; - int index01 = 0; - int index10 = 0; - int index11 = 0; - - vector_type& data00 = this->receiver00->getData(); - vector_type& data01 = this->receiver01->getData(); - vector_type& data10 = this->receiver10->getData(); - vector_type& data11 = this->receiver11->getData(); - - for(INodeVector inode : iNodeSetReceiver00) - { - LBMReal icellC[27]; - this->readICellCfromData(data00, index00, icellC); - iprocessor->writeINodeInv(fTo, icellC, inode[0], inode[1], inode[2]); - } - for(INodeVector inode : iNodeSetReceiver01) - { - LBMReal icellC[27]; - this->readICellCfromData(data01, index01, icellC); - iprocessor->writeINodeInv(fTo, icellC, inode[0], inode[1], inode[2]); - } - for(INodeVector inode : iNodeSetReceiver10) - { - LBMReal icellC[27]; - this->readICellCfromData(data10, index10, icellC); - iprocessor->writeINodeInv(fTo, icellC, inode[0], inode[1], inode[2]); - } - for(INodeVector inode : iNodeSetReceiver11) - { - LBMReal icellC[27]; - this->readICellCfromData(data11, index11, icellC); - iprocessor->writeINodeInv(fTo, icellC, inode[0], inode[1], inode[2]); - } -} -////////////////////////////////////////////////////////////////////////// - -void CoarseToFineNodeSetBlock3DConnector::readICellCfromData(vector_type& data, int& index, LBMReal* icellC) -{ - for (int i = D3Q27System::STARTF; i < D3Q27System::ENDF+1; i++) - { - icellC[i] = data[index++]; - } -} -////////////////////////////////////////////////////////////////////////// - -void CoarseToFineNodeSetBlock3DConnector::getLocalMinMax(int& minX1, int& minX2, int& minX3, int& maxX1, int& maxX2, int& maxX3) -{ - using namespace D3Q27System; - int TminX1 = minX1; int TminX2 = minX2; int TminX3 = minX3; int TmaxX1 = maxX1; int TmaxX2 = maxX2; int TmaxX3 = maxX3; - - if (block.lock()->hasInterpolationFlagCF(E)) - { - if (maxX1==TmaxX1) maxX1 -= 2; - } - if (block.lock()->hasInterpolationFlagCF(W)) - { - if (minX1==TminX1) minX1 += 2; - } - if (block.lock()->hasInterpolationFlagCF(N)) - { - if (maxX2==TmaxX2) maxX2 -= 2; - } - if (block.lock()->hasInterpolationFlagCF(S)) - { - if (minX2==TminX2) minX2 += 2; - } - if (block.lock()->hasInterpolationFlagCF(T)) - { - if (maxX3==TmaxX3) maxX3 -= 2; - } - if (block.lock()->hasInterpolationFlagCF(B)) - { - if (minX3==TminX3) minX3 += 2; - } - - //E-W-N-S - if (block.lock()->hasInterpolationFlagCF(NE) && !block.lock()->hasInterpolationFlagCF(N) && !block.lock()->hasInterpolationFlagCF(E)) - { - if (maxX1==TmaxX1) maxX1 -= 2; - if (maxX2==TmaxX2) maxX2 -= 2; - } - if (block.lock()->hasInterpolationFlagCF(SW) && !block.lock()->hasInterpolationFlagCF(W) && !block.lock()->hasInterpolationFlagCF(S)) - { - if (minX1==TminX1) minX1 += 2; - if (minX2==TminX2) minX2 += 2; - } - if (block.lock()->hasInterpolationFlagCF(SE) && !block.lock()->hasInterpolationFlagCF(E) && !block.lock()->hasInterpolationFlagCF(S)) - { - if (maxX1==TmaxX1) maxX1 -= 2; - if (minX2==TminX2) minX2 += 2; - } - if (block.lock()->hasInterpolationFlagCF(NW) && !block.lock()->hasInterpolationFlagCF(N) && !block.lock()->hasInterpolationFlagCF(W)) - { - if (minX1==TminX1) minX1 += 2; - if (maxX2==TmaxX2) maxX2 -= 2; - } - - // ////T-B-E-W - if (block.lock()->hasInterpolationFlagCF(TE) && !block.lock()->hasInterpolationFlagCF(E) && !block.lock()->hasInterpolationFlagCF(T)) - { - if (maxX1==TmaxX1) maxX1 -= 2; - if (maxX3==TmaxX3) maxX3 -= 2; - } - if (block.lock()->hasInterpolationFlagCF(BW) && !block.lock()->hasInterpolationFlagCF(W) && !block.lock()->hasInterpolationFlagCF(B)) - { - if (minX1==TminX1) minX1 += 2; - if (minX3==TminX3) minX3 += 2; - } - if (block.lock()->hasInterpolationFlagCF(BE) && !block.lock()->hasInterpolationFlagCF(E) && !block.lock()->hasInterpolationFlagCF(B)) - { - if (maxX1==TmaxX1) maxX1 -= 2; - if (minX3==TminX3) minX3 += 2; - } - if (block.lock()->hasInterpolationFlagCF(TW) && !block.lock()->hasInterpolationFlagCF(W) && !block.lock()->hasInterpolationFlagCF(T)) - { - if (minX1==TminX1) minX1 += 2; - if (maxX3==TmaxX3) maxX3 -= 2; - } - - - ////T-B-N-S - if (block.lock()->hasInterpolationFlagCF(TN) && !block.lock()->hasInterpolationFlagCF(N) && !block.lock()->hasInterpolationFlagCF(T)) - { - if (maxX2==TmaxX2) maxX2 -= 2; - if (maxX3==TmaxX3) maxX3 -= 2; - } - if (block.lock()->hasInterpolationFlagCF(BS) && !block.lock()->hasInterpolationFlagCF(S) && !block.lock()->hasInterpolationFlagCF(B)) - { - if (minX2==TminX2) minX2 += 2; - if (minX3==TminX3) minX3 += 2; - } - if (block.lock()->hasInterpolationFlagCF(BN) && !block.lock()->hasInterpolationFlagCF(N) && !block.lock()->hasInterpolationFlagCF(B)) - { - if (maxX2==TmaxX2) maxX2 -= 2; - if (minX3==TminX3) minX3 += 2; - } - if (block.lock()->hasInterpolationFlagCF(TS) && !block.lock()->hasInterpolationFlagCF(S) && !block.lock()->hasInterpolationFlagCF(T)) - { - if (minX2==TminX2) minX2 += 2; - if (maxX3==TmaxX3) maxX3 -= 2; - } -} - - diff --git a/src/cpu/VirtualFluidsCore/Connectors/CoarseToFineNodeSetBlock3DConnector.h b/src/cpu/VirtualFluidsCore/Connectors/CoarseToFineNodeSetBlock3DConnector.h deleted file mode 100644 index ffa1740a7..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/CoarseToFineNodeSetBlock3DConnector.h +++ /dev/null @@ -1,103 +0,0 @@ -//! \file CoarseToFineNodeSetBlock3DConnector.h -//! \class CoarseToFineNodeSetBlock3DConnector -//! \brief Connector interpolates and sends data from coarse level to fine. -//! \author Konstantin Kutscher -//! \date 18.05.2015 - -#ifndef CoarseToFineNodeSetBlock3DConnector_H -#define CoarseToFineNodeSetBlock3DConnector_H - -#include <vector> -#include <set> - -//#include "basics/transmitter/TbTransmitter.h" -//#include "basics/transmitter/TbTransmitterLocal.h" -//#include "basics/container/CbVector.h" -#include "CoarseToFineBlock3DConnector.h" -#include "D3Q27System.h" -#include "Block3D.h" -#include "LBMKernel.h" -#include "BCProcessor.h" -#include "InterpolationProcessor.h" -#include "MathUtil.hpp" -#include "Grid3D.h" -#include <PointerDefinitions.h> - - -class Block3D; - -//daten werden in einen vector (dieser befindet sich im transmitter) kopiert -//der vector wird via transmitter uebertragen -//transmitter kann ein lokal, MPI, RCG, CTL oder was auch immer fuer ein -//transmitter sein, der von Transmitter abgeleitet ist ;-) - - -// send direction: E<->W N<->S T<->B -// --------- x3 x3 x2 -// | 01 | 11 | ^ ^ ^ -// |----+----| +-> x2 +->x1 +->x1 -// | 00 | 10 | -// --------- - - -class CoarseToFineNodeSetBlock3DConnector : public CoarseToFineBlock3DConnector -{ -public: - CoarseToFineNodeSetBlock3DConnector(SPtr<Block3D> block, - VectorTransmitterPtr sender00, VectorTransmitterPtr receiver00, - VectorTransmitterPtr sender01, VectorTransmitterPtr receiver01, - VectorTransmitterPtr sender10, VectorTransmitterPtr receiver10, - VectorTransmitterPtr sender11, VectorTransmitterPtr receiver11, - int sendDir, InterpolationProcessorPtr iprocessor); - - void init(); - - void fillSendVectors(); - void distributeReceiveVectors(); - -protected: - typedef std::vector< int > INodeVector; - typedef std::vector < INodeVector > INodeSet; - INodeSet iNodeSetSender00; - INodeSet iNodeSetSender01; - INodeSet iNodeSetSender10; - INodeSet iNodeSetSender11; - INodeSet iNodeSetReceiver00; - INodeSet iNodeSetReceiver01; - INodeSet iNodeSetReceiver10; - INodeSet iNodeSetReceiver11; - - void writeICellFtoData(vector_type& data, int& index, D3Q27ICell& icellF); - void writeNodeToVector(vector_type& data, int& index, LBMReal* inode); - void readICellCfromData(vector_type& data, int& index, LBMReal* icellC); - - void findCFCells(); - void findCFCells(int lMinX1, int lMinX2, int lMinX3, int lMaxX1, int lMaxX2, int lMaxX3, INodeSet &inodes); - - void findFCCells(); - void findFCCells(int lMinX1, int lMinX2, int lMinX3, int lMaxX1, int lMaxX2, int lMaxX3, INodeSet &inodes); - - void getLocalMinMax(int& minX1, int& minX2, int& minX3, int& maxX1, int& maxX2, int& maxX3); - - int bMaxX1, bMaxX2, bMaxX3; - - int minX1; - int minX2; - int minX3; - - int maxX1; - int maxX2; - int maxX3; - - int minHalfX1; - int minHalfX2; - int minHalfX3; - - int maxHalfX1; - int maxHalfX2; - int maxHalfX3; -}; - - - -#endif diff --git a/src/cpu/VirtualFluidsCore/Connectors/ConnectorFactory.h b/src/cpu/VirtualFluidsCore/Connectors/ConnectorFactory.h deleted file mode 100644 index 0e4cf6a3a..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/ConnectorFactory.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef ConnectorFactory_h__ -#define ConnectorFactory_h__ - -#include "Block3DConnector.h" -#include "TransmitterType.h" -#include "InterpolationProcessor.h" -#include "FineToCoarseBlock3DConnector.h" - -#include <PointerDefinitions.h> - -class ConnectorFactory -{ -public: - ConnectorFactory() {}; - virtual ~ConnectorFactory() {}; - - virtual SPtr<Block3DConnector> createSameLevelDirectConnector(SPtr<Block3D> from, SPtr<Block3D> to, int sendDir) = 0; - virtual SPtr<Block3DConnector> createSameLevelVectorConnector(SPtr<Block3D> block, - VectorTransmitterPtr sender, - VectorTransmitterPtr receiver, - int sendDir) = 0; - virtual SPtr<Block3DConnector> createCoarseToFineConnector(SPtr<Block3D> block, - VectorTransmitterPtr sender00, VectorTransmitterPtr receiver00, - VectorTransmitterPtr sender01, VectorTransmitterPtr receiver01, - VectorTransmitterPtr sender10, VectorTransmitterPtr receiver10, - VectorTransmitterPtr sender11, VectorTransmitterPtr receiver11, - int sendDir, InterpolationProcessorPtr iprocessor) = 0; - virtual SPtr<Block3DConnector> createFineToCoarseConnector(SPtr<Block3D> block, - VectorTransmitterPtr sender, - VectorTransmitterPtr receiver, - int sendDir, - InterpolationProcessorPtr iprocessor, - FineToCoarseBlock3DConnector::CFconnectorType connType) = 0; - -protected: -private: -}; -#endif // ConnectorFactory_h__ diff --git a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETCFOffVectorConnector.cpp b/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETCFOffVectorConnector.cpp deleted file mode 100644 index 73c14fb69..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETCFOffVectorConnector.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "D3Q27ETCFOffVectorConnector.h" diff --git a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETCFOffVectorConnector.h b/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETCFOffVectorConnector.h deleted file mode 100644 index f4a3571ae..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETCFOffVectorConnector.h +++ /dev/null @@ -1,1940 +0,0 @@ -/** -* @file D3Q27ETCFOffVectorConnector.h -* @class D3Q27ETCFOffVectorConnector -* @brief Interpolation from coarse level to fine. -* @author Kostyantyn Kucher and Ehsan Fard -* @date 08.06.2011 -*/ -#ifndef D3Q27ETCFOffVectorConnector_H -#define D3Q27ETCFOffVectorConnector_H - -#include <vector> - -#include "basics/transmitter/TbTransmitter.h" -#include "basics/transmitter/TbTransmitterLocal.h" -#include "basics/container/CbVector.h" -#include "Block3DConnector.h" -#include "D3Q27System.h" -#include "Block3D.h" -#include "LBMKernel.h" -#include "InterpolationProcessor.h" -#include "MathUtil.hpp" -#include "Grid3D.h" -#include <PointerDefinitions.h> - -#include "D3Q27ETFCOffVectorConnector.h" -#include "BCProcessor.h" - -class Block3D; - -//daten werden in einen vector (dieser befindet sich im transmitter) kopiert -//der vector wird via transmitter uebertragen -//transmitter kann ein lokal, MPI, RCG, CTL oder was auch immer fuer ein -//transmitter sein, der von Transmitter abgeleitet ist ;-) - -//sendrichtung: E<->W N<->S T<->B -// --------- x3 x3 x2 -// | NW | NE | ^ ^ ^ -// |----+----| +-> x2 +->x1 +->x1 -// | SW | SE | -// --------- -// NW==even-odd, SW==even-even, SE==odd-even, NE==odd-odd - -template< typename VectorTransmitter > -class D3Q27ETCFOffVectorConnector : public Block3DConnector -{ -public: - typedef typename VectorTransmitter::value_type vector_type; - typedef SPtr< VectorTransmitter > VectorTransmitterPtr; -public: - D3Q27ETCFOffVectorConnector(SPtr<Block3D> block, - VectorTransmitterPtr senderEvenEvenSW, VectorTransmitterPtr receiverEvenEvenSW, - VectorTransmitterPtr senderEvenOddNW, VectorTransmitterPtr receiverEvenOddNW, - VectorTransmitterPtr senderOddEvenSE, VectorTransmitterPtr receiverOddEvenSE, - VectorTransmitterPtr senderOddOddNE, VectorTransmitterPtr receiverOddOddNE, - int sendDir, InterpolationProcessorPtr iprocessor); - - bool isLocalConnector(); - bool isRemoteConnector(); - void init(); - - void sendTransmitterDataSize(); - void receiveTransmitterDataSize(); - - void prepareForSend(); - void sendVectors(); - - void prepareForReceive(); - void receiveVectors(); - - void fillSendVectors(); - void distributeReceiveVectors(); - - bool isInterpolationConnectorCF() { return true; } - bool isInterpolationConnectorFC() { return false; } - - double getSendRecieveTime(); - - void prepareForSendX1() {} - void prepareForSendX2() {} - void prepareForSendX3() {} - - void sendVectorsX1() {} - void sendVectorsX2() {} - void sendVectorsX3() {} - - void prepareForReceiveX1() {} - void prepareForReceiveX2() {} - void prepareForReceiveX3() {} - - void receiveVectorsX1() {} - void receiveVectorsX2() {} - void receiveVectorsX3() {} - -protected: - WPtr<Block3D> block; //dieser nvd sendet daten und die empfangenen werden diesem nvd zugeordnet - VectorTransmitterPtr senderEvenEvenSW, receiverEvenEvenSW, - senderEvenOddNW, receiverEvenOddNW, - senderOddEvenSE, receiverOddEvenSE, - senderOddOddNE, receiverOddOddNE; - - InterpolationProcessorPtr iprocessor; - - void writeICellFtoData(vector_type& data, int& index, D3Q27ICell& icellF); - void writeNodeToVector(vector_type& data, int& index, LBMReal* inode); - void getLocalMinMax(const int& gMin, const int& gMax, const bool& even, int& lMin, int& lMax, const bool& dataDistribution); - void getLocalMinMax(int& minX1, int& minX2, int& minX3, int& maxX1, int& maxX2, int& maxX3); - void getLocalMinMax(int& minX1, int& minX2, int& minX3, int& maxX1, int& maxX2, int& maxX3, CFconnectorType connType); - void fillSendVectorExt(SPtr<DistributionArray3D> fFrom, const int& lMinX1, const int& lMinX2, const int& lMinX3, const int& lMaxX1, const int& lMaxX2, const int& lMaxX3, vector_type& data, int& index); - - void distributeReceiveVector(SPtr<DistributionArray3D> fTo, const int& lMinX1, const int& lMinX2, const int& lMinX3, const int& lMaxX1, const int& lMaxX2, const int& lMaxX3, vector_type& data, int& index); - void readICellCfromData(vector_type& data, int& index, LBMReal* icellC); - - void findCFnodes(); - void findCFnodes(SPtr<DistributionArray3D> fFrom, const int& lMinX1, const int& lMinX2, const int& lMinX3, const int& lMaxX1, const int& lMaxX2, const int& lMaxX3, vector_type& data, int& index); - - int bMaxX1, bMaxX2, bMaxX3; -}; - -//////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -D3Q27ETCFOffVectorConnector<VectorTransmitter>::D3Q27ETCFOffVectorConnector(SPtr<Block3D> block, - VectorTransmitterPtr senderEvenEvenSW, VectorTransmitterPtr receiverEvenEvenSW, - VectorTransmitterPtr senderEvenOddNW, VectorTransmitterPtr receiverEvenOddNW, - VectorTransmitterPtr senderOddEvenSE, VectorTransmitterPtr receiverOddEvenSE, - VectorTransmitterPtr senderOddOddNE, VectorTransmitterPtr receiverOddOddNE, - int sendDir, InterpolationProcessorPtr iprocessor) : Block3DConnector(sendDir) - , block(block) - , senderEvenEvenSW(senderEvenEvenSW) - , senderEvenOddNW(senderEvenOddNW) - , senderOddEvenSE(senderOddEvenSE) - , senderOddOddNE(senderOddOddNE) - , receiverEvenEvenSW(receiverEvenEvenSW) - , receiverEvenOddNW(receiverEvenOddNW) - , receiverOddEvenSE(receiverOddEvenSE) - , receiverOddOddNE(receiverOddOddNE) - , iprocessor(iprocessor) -{ - if (!(sendDir == D3Q27System::E || sendDir == D3Q27System::W || sendDir == D3Q27System::N || sendDir == D3Q27System::S || sendDir == D3Q27System::T || sendDir == D3Q27System::B - || sendDir == D3Q27System::NE || sendDir == D3Q27System::SW || sendDir == D3Q27System::SE || sendDir == D3Q27System::NW - || sendDir == D3Q27System::TE || sendDir == D3Q27System::BW || sendDir == D3Q27System::BE || sendDir == D3Q27System::TW - || sendDir == D3Q27System::TN || sendDir == D3Q27System::BS || sendDir == D3Q27System::BN || sendDir == D3Q27System::TS - || sendDir == D3Q27System::TNE || sendDir == D3Q27System::TNW || sendDir == D3Q27System::TSE || sendDir == D3Q27System::TSW - || sendDir == D3Q27System::BNE || sendDir == D3Q27System::BNW || sendDir == D3Q27System::BSE || sendDir == D3Q27System::BSW - )) - { - throw UbException(UB_EXARGS, "invalid constructor for this direction"); - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -bool D3Q27ETCFOffVectorConnector<VectorTransmitter>::isLocalConnector() -{ - return !this->isRemoteConnector(); -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -bool D3Q27ETCFOffVectorConnector<VectorTransmitter>::isRemoteConnector() -{ - return ((senderOddOddNE && senderOddOddNE->isRemoteTransmitter()) || (receiverOddOddNE && receiverOddOddNE->isRemoteTransmitter()) - || (senderEvenEvenSW && senderEvenEvenSW->isRemoteTransmitter()) || (receiverEvenEvenSW && receiverEvenEvenSW->isRemoteTransmitter()) - || (senderEvenOddNW && senderEvenOddNW->isRemoteTransmitter()) || (receiverEvenOddNW && receiverEvenOddNW->isRemoteTransmitter()) - || (senderOddEvenSE && senderOddEvenSE->isRemoteTransmitter()) || (receiverOddEvenSE && receiverOddEvenSE->isRemoteTransmitter())); -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETCFOffVectorConnector<VectorTransmitter>::sendTransmitterDataSize() -{ - if (senderEvenEvenSW) - { - UBLOG(logDEBUG5, "D3Q27ETCFOffVectorConnector<VectorTransmitter>::sendTransmitterDataSize()-senderEvenEvenSW " << block.lock()->toString() << " sendDir=" << sendDir); - senderEvenEvenSW->sendDataSize(); - } - if (senderEvenOddNW) - { - UBLOG(logDEBUG5, "D3Q27ETCFOffVectorConnector<VectorTransmitter>::sendTransmitterDataSize()-senderEvenOddNW " << block.lock()->toString() << "sendDir=" << sendDir); - senderEvenOddNW->sendDataSize(); - } - if (senderOddEvenSE) - { - UBLOG(logDEBUG5, "D3Q27ETCFOffVectorConnector<VectorTransmitter>::sendTransmitterDataSize()-senderOddEvenSE " << block.lock()->toString() + "sendDir=" << sendDir); - senderOddEvenSE->sendDataSize(); - } - if (senderOddOddNE) - { - UBLOG(logDEBUG5, "D3Q27ETCFOffVectorConnector<VectorTransmitter>::sendTransmitterDataSize()-senderOddOddNE " << block.lock()->toString() << "sendDir=" << sendDir); - senderOddOddNE->sendDataSize(); - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETCFOffVectorConnector<VectorTransmitter>::receiveTransmitterDataSize() -{ - if (receiverEvenEvenSW) - { - UBLOG(logDEBUG5, "D3Q27ETCFOffVectorConnector<VectorTransmitter>::receiveTransmitterDataSize()-receiverEvenEvenSW " << block.lock()->toString() << "sendDir=" << sendDir); - receiverEvenEvenSW->receiveDataSize(); - } - if (receiverEvenOddNW) - { - UBLOG(logDEBUG5, "D3Q27ETCFOffVectorConnector<VectorTransmitter>::receiveTransmitterDataSize()-receiverEvenOddNW " << block.lock()->toString() << "sendDir=" << sendDir); - receiverEvenOddNW->receiveDataSize(); - } - if (receiverOddEvenSE) - { - UBLOG(logDEBUG5, "D3Q27ETCFOffVectorConnector<VectorTransmitter>::receiveTransmitterDataSize()-receiverOddEvenSE " << block.lock()->toString() << "sendDir=" << sendDir); - receiverOddEvenSE->receiveDataSize(); - } - if (receiverOddOddNE) - { - UBLOG(logDEBUG5, "D3Q27ETCFOffVectorConnector<VectorTransmitter>::receiveTransmitterDataSize()-receiverOddOddNE " << block.lock()->toString() << "sendDir=" << sendDir); - receiverOddOddNE->receiveDataSize(); - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETCFOffVectorConnector<VectorTransmitter>::prepareForSend() -{ - if (senderEvenEvenSW) senderEvenEvenSW->prepareForSend(); - if (senderEvenOddNW) senderEvenOddNW->prepareForSend(); - if (senderOddEvenSE) senderOddEvenSE->prepareForSend(); - if (senderOddOddNE) senderOddOddNE->prepareForSend(); -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETCFOffVectorConnector<VectorTransmitter>::sendVectors() -{ - if (senderEvenEvenSW) senderEvenEvenSW->sendData(); - if (senderEvenOddNW) senderEvenOddNW->sendData(); - if (senderOddEvenSE) senderOddEvenSE->sendData(); - if (senderOddOddNE) senderOddOddNE->sendData(); -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETCFOffVectorConnector<VectorTransmitter>::prepareForReceive() -{ - if (receiverEvenEvenSW) receiverEvenEvenSW->prepareForReceive(); - if (receiverEvenOddNW) receiverEvenOddNW->prepareForReceive(); - if (receiverOddEvenSE) receiverOddEvenSE->prepareForReceive(); - if (receiverOddOddNE) receiverOddOddNE->prepareForReceive(); -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETCFOffVectorConnector<VectorTransmitter>::receiveVectors() -{ - if (receiverEvenEvenSW) receiverEvenEvenSW->receiveData(); - if (receiverEvenOddNW) receiverEvenOddNW->receiveData(); - if (receiverOddEvenSE) receiverOddEvenSE->receiveData(); - if (receiverOddOddNE) receiverOddOddNE->receiveData(); -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETCFOffVectorConnector<VectorTransmitter>::init() -{ - using namespace D3Q27System; - - bMaxX1 = (int)block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX1(); - bMaxX2 = (int)block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX2(); - bMaxX3 = (int)block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX3(); - - int sendSize = 0; - LBMReal initValue = -999.0; - - int sendDataPerNode = 27/*f*/; - int iCellSize = 8; //size of interpolation cell - - switch (this->sendDir) - { - case E: case W: sendSize = bMaxX2*bMaxX3*sendDataPerNode*iCellSize; break; - case N: case S: sendSize = bMaxX1*bMaxX3*sendDataPerNode*iCellSize; break; - case T: case B: sendSize = bMaxX1*bMaxX2*sendDataPerNode*iCellSize; break; - case NE: case SW:case SE: case NW: sendSize = 2 * bMaxX3*sendDataPerNode*iCellSize; break; - case TE: case BW:case BE: case TW: sendSize = 2 * bMaxX2*sendDataPerNode*iCellSize; break; - case TN: case BS:case BN: case TS: sendSize = 2 * bMaxX1*sendDataPerNode*iCellSize; break; - case TNE: case TNW:case TSE: case TSW:case BNE: case BNW:case BSE: case BSW: sendSize = 6 * bMaxX1*sendDataPerNode*iCellSize; break; - default: throw UbException(UB_EXARGS, "direction not allowed in this constructor"); - } - if (senderEvenEvenSW) senderEvenEvenSW->getData().resize(sendSize, initValue); - else senderEvenEvenSW = VectorTransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); - if (senderEvenOddNW) senderEvenOddNW->getData().resize(sendSize, initValue); - else senderEvenOddNW = VectorTransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); - if (senderOddEvenSE) senderOddEvenSE->getData().resize(sendSize, initValue); - else senderOddEvenSE = VectorTransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); - if (senderOddOddNE) senderOddOddNE->getData().resize(sendSize, initValue); - else senderOddOddNE = VectorTransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); - - if (!receiverEvenEvenSW) receiverEvenEvenSW = VectorTransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); - if (!receiverEvenOddNW) receiverEvenOddNW = VectorTransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); - if (!receiverOddEvenSE) receiverOddEvenSE = VectorTransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); - if (!receiverOddOddNE) receiverOddOddNE = VectorTransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); - - //findCFnodes(); -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETCFOffVectorConnector< VectorTransmitter>::fillSendVectors() -{ - using namespace D3Q27System; - - SPtr<DistributionArray3D> fFrom = block.lock()->getKernel()->getDataSet()->getFdistributions(); - int maxX1 = (int)fFrom->getNX1(); - int maxX2 = (int)fFrom->getNX2(); - int maxX3 = (int)fFrom->getNX3(); - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int indexEvEv = 0; - int indexEvOd = 0; - int indexOdEv = 0; - int indexOdOd = 0; - - vector_type& dataEvEv = this->senderEvenEvenSW->getData(); - vector_type& dataEvOd = this->senderEvenOddNW->getData(); - vector_type& dataOdEv = this->senderOddEvenSE->getData(); - vector_type& dataOdOd = this->senderOddOddNE->getData(); - - int lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3; - //int lMinX1_2, lMinX2_2, lMinX3_2, lMaxX1_2, lMaxX2_2, lMaxX3_2; - - //for coners - int lMinX1W = 1; - int lMaxX1W = 2; - - int lMinX1E = maxX1 - 3; - int lMaxX1E = maxX1 - 2; - - int lMinX2S = 1; - int lMaxX2S = 2; - - int lMinX2N = maxX2 - 3; - int lMaxX2N = maxX2 - 2; - - int lMinX3B = 1; - int lMaxX3B = 2; - - int lMinX3T = maxX3 - 3; - int lMaxX3T = maxX3 - 2; - - - switch (sendDir) - { - case E: - lMinX1 = maxX1 - 3; - lMaxX1 = lMinX1 + 1; - - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, false); - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, false); - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvOd, indexEvOd); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, false); - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, false); - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdOd, indexOdOd); - break; - case W: - /////////////////////////////////////// - ///DEBUG - //if (block.lock()->getGlobalID() == 5780) - //{ - // int test = 0; - //} - ////////////// - lMinX1 = 1; - lMaxX1 = lMinX1 + 1; - - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, false); - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, false); - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvOd, indexEvOd); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, false); - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, false); - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdOd, indexOdOd); - break; - case N: - lMinX2 = maxX2 - 3; - lMaxX2 = lMinX2 + 1; - - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, false); - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, false); - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvOd, indexEvOd); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, false); - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, false); - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdOd, indexOdOd); - break; - case S: - lMinX2 = 1; - lMaxX2 = lMinX2 + 1; - - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, false); - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, false); - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvOd, indexEvOd); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, false); - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, false); - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdOd, indexOdOd); - break; - case T: - lMinX3 = maxX3 - 3; - lMaxX3 = lMinX3 + 1; - - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, false); - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, false); - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvOd, indexEvOd); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, false); - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, false); - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdOd, indexOdOd); - break; - case B: - lMinX3 = 1; - lMaxX3 = lMinX3 + 1; - - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, false); - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, false); - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvOd, indexEvOd); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, false); - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, false); - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdOd, indexOdOd); - break; - ///N-S-E-W - case NE: - lMinX1 = maxX1 - 3; - lMaxX1 = lMinX1 + 2; - lMinX2 = maxX2 - 3; - lMaxX2 = lMinX2 + 2; - - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - case SW: - lMinX1 = 0; - lMaxX1 = lMinX1 + 2; - lMinX2 = 0; - lMaxX2 = lMinX2 + 2; - - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - case SE: - lMinX1 = maxX1 - 3; - lMaxX1 = lMinX1 + 2; - lMinX2 = 0; - lMaxX2 = lMinX2 + 2; - - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - case NW: - lMinX1 = 0; - lMaxX1 = lMinX1 + 2; - lMinX2 = maxX2 - 3; - lMaxX2 = lMinX2 + 2; - - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - /////T-B-E-W - case TE: - lMinX1 = maxX1 - 3; - lMaxX1 = lMinX1 + 2; - lMinX3 = maxX3 - 3; - lMaxX3 = lMinX3 + 2; - - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - case BW: - lMinX1 = 0; - lMaxX1 = lMinX1 + 2; - lMinX3 = 0; - lMaxX3 = lMinX3 + 2; - - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - case BE: - lMinX1 = maxX1 - 3; - lMaxX1 = lMinX1 + 2; - lMinX3 = 0; - lMaxX3 = lMinX3 + 2; - - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - case TW: - lMinX1 = 0; - lMaxX1 = lMinX1 + 2; - lMinX3 = maxX3 - 3; - lMaxX3 = lMinX3 + 2; - - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - //// - /////T-B-N-S - case TN: - lMinX2 = maxX2 - 3; - lMaxX2 = lMinX2 + 2; - lMinX3 = maxX3 - 3; - lMaxX3 = lMinX3 + 2; - - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - case BS: - lMinX2 = 0; - lMaxX2 = lMinX2 + 2; - lMinX3 = 0; - lMaxX3 = lMinX3 + 2; - - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - case BN: - lMinX2 = maxX2 - 3; - lMaxX2 = lMinX2 + 2; - lMinX3 = 0; - lMaxX3 = lMinX3 + 2; - - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - case TS: - lMinX2 = 0; - lMaxX2 = lMinX2 + 2; - lMinX3 = maxX3 - 3; - lMaxX3 = lMinX3 + 2; - - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, false); - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - - //TNE - case TNE: - lMinX1 = maxX1 - 3; - lMaxX1 = maxX1 - 1; - lMinX2 = maxX2 - 3; - lMaxX2 = maxX2 - 1; - lMinX3 = maxX3 - 3; - lMaxX3 = maxX3 - 1; - - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - break; - // TNW - case TNW: - lMinX1 = 0; - lMaxX1 = 2; - lMinX2 = maxX2 - 3; - lMaxX2 = maxX2 - 1; - lMinX3 = maxX3 - 3; - lMaxX3 = maxX3 - 1; - - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - break; - // TSE - case TSE: - lMinX1 = maxX1 - 3; - lMaxX1 = maxX1 - 1; - lMinX2 = 0; - lMaxX2 = 2; - lMinX3 = maxX3 - 3; - lMaxX3 = maxX3 - 1; - - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - break; - // TSW - case TSW: - lMinX1 = 0; - lMaxX1 = 2; - lMinX2 = 0; - lMaxX2 = 2; - lMinX3 = maxX3 - 3; - lMaxX3 = maxX3 - 1; - - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - break; - // BNE - case BNE: - lMinX1 = maxX1 - 3; - lMaxX1 = maxX1 - 1; - lMinX2 = maxX2 - 3; - lMaxX2 = maxX2 - 1; - lMinX3 = 0; - lMaxX3 = 2; - - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - break; - // BNW - case BNW: - lMinX1 = 0; - lMaxX1 = 2; - lMinX2 = maxX2 - 3; - lMaxX2 = maxX2 - 1; - lMinX3 = 0; - lMaxX3 = 2; - - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - break; - // BSE - case BSE: - lMinX1 = maxX1 - 3; - lMaxX1 = maxX1 - 1; - lMinX2 = 0; - lMaxX2 = 2; - lMinX3 = 0; - lMaxX3 = 2; - - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - break; - // BSW - case BSW: - lMinX1 = 0; - lMaxX1 = 2; - lMinX2 = 0; - lMaxX2 = 2; - lMinX3 = 0; - lMaxX3 = 2; - - fillSendVectorExt(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - break; - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETCFOffVectorConnector< VectorTransmitter>::getLocalMinMax(const int& gMin, const int& gMax, const bool& even, int& lMin, int& lMax, const bool& dataDistribution) -{ - int halfEven = 0; - int halfOdd = 0; - int dCoef = 0; - - if (dataDistribution) - dCoef = 1; - - if (Utilities::isOdd(gMax)) - { - halfEven = gMax / 2; - halfOdd = gMax / 2; - } - if (Utilities::isEven(gMax)) - { - halfEven = gMax / 2; - halfOdd = gMax / 2 - 1 + dCoef; - } - - switch (even) - { - case true: - lMin = gMin + dCoef; - lMax = lMin + halfEven - dCoef; - break; - case false: - lMin = gMin + halfOdd; - lMax = gMax - 1; - break; - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETCFOffVectorConnector< VectorTransmitter>::fillSendVectorExt(SPtr<DistributionArray3D> fFrom, const int& lMinX1, const int& lMinX2, const int& lMinX3, const int& lMaxX1, const int& lMaxX2, const int& lMaxX3, vector_type& data, int& index) -{ - if (data.size() == 0) return; - int ix1, ix2, ix3; - LBMReal xoff, yoff, zoff; - SPtr<BCArray3D> bcArray = block.lock()->getKernel()->getBCProcessor()->getBCArray(); - - for (ix3 = lMinX3; ix3 < lMaxX3; ix3++) - { - for (ix2 = lMinX2; ix2 < lMaxX2; ix2++) - { - for (ix1 = lMinX1; ix1 < lMaxX1; ix1++) - { - D3Q27ICell icellC; - D3Q27ICell icellF; - - int howManySolids = iprocessor->iCellHowManySolids(bcArray, ix1, ix2, ix3); - - if (howManySolids == 0 || howManySolids == 8) - { - iprocessor->readICell(fFrom, icellC, ix1, ix2, ix3); - xoff = 0.0; - yoff = 0.0; - zoff = 0.0; - } - else - { - if (!iprocessor->findNeighborICell(bcArray, fFrom, icellC, bMaxX1, bMaxX2, bMaxX3, ix1, ix2, ix3, xoff, yoff, zoff)) - { - std::string err = "For " + block.lock()->toString() + " x1=" + UbSystem::toString(ix1) + ", x2=" + UbSystem::toString(ix2) + ", x3=" + UbSystem::toString(ix3) + - " 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)); - } - } - - iprocessor->interpolateCoarseToFine(icellC, icellF, xoff, yoff, zoff); - this->writeICellFtoData(data, index, icellF); - } - } - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETCFOffVectorConnector< VectorTransmitter>::writeICellFtoData(vector_type& data, int& index, D3Q27ICell& icellF) -{ - writeNodeToVector(data, index, icellF.BSW); - writeNodeToVector(data, index, icellF.BSE); - writeNodeToVector(data, index, icellF.BNW); - writeNodeToVector(data, index, icellF.BNE); - writeNodeToVector(data, index, icellF.TSW); - writeNodeToVector(data, index, icellF.TSE); - writeNodeToVector(data, index, icellF.TNW); - writeNodeToVector(data, index, icellF.TNE); -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETCFOffVectorConnector< VectorTransmitter>::writeNodeToVector(vector_type& data, int& index, LBMReal* inode) -{ - for (int i = D3Q27System::STARTF; i < D3Q27System::ENDF + 1; i++) - { - data[index++] = inode[i]; - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETCFOffVectorConnector< VectorTransmitter>::distributeReceiveVectors() -{ - using namespace D3Q27System; - - SPtr<DistributionArray3D> fTo = block.lock()->getKernel()->getDataSet()->getFdistributions(); - int maxX1 = (int)fTo->getNX1(); - int maxX2 = (int)fTo->getNX2(); - int maxX3 = (int)fTo->getNX3(); - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int indexEvEv = 0; - int indexEvOd = 0; - int indexOdEv = 0; - int indexOdOd = 0; - - vector_type& dataEvEv = this->receiverEvenEvenSW->getData(); - vector_type& dataEvOd = this->receiverEvenOddNW->getData(); - vector_type& dataOdEv = this->receiverOddEvenSE->getData(); - vector_type& dataOdOd = this->receiverOddOddNE->getData(); - - int lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3; - int dummy; - - //for coners - int lMinX1W = 3; - int lMaxX1W = 3; - - int lMinX1E = maxX1 - 3; - int lMaxX1E = maxX1 - 2; - - int lMinX2S = 1; - int lMaxX2S = 3; - - int lMinX2N = maxX2 - 3; - int lMaxX2N = maxX2 - 2; - - int lMinX3B = 1; - int lMaxX3B = 3; - - int lMinX3T = maxX3 - 3; - int lMaxX3T = maxX3 - 2; - - /////////////////////////////////////// - ///DEBUG - //if (block.lock()->getGlobalID() == 5780) - //{ - // int test = 0; - //} - ////////////// - - switch (sendDir) - { - case E: - lMinX1 = maxX1 - 4; - lMaxX1 = lMinX1 + 1; - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, true); - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, lMinX2, lMinX3, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, true); - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, lMinX2, dummy, dummy, dummy, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvOd, indexEvOd); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, true); - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, lMinX3, dummy, lMaxX2, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, true); - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, dummy, dummy, lMaxX2, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdOd, indexOdOd); - break; - case W: - /////////////////////////////////////// - ///DEBUG - //if (block.lock()->getGlobalID() == 5780) - //{ - // int test = 0; - //} - ////////////// - lMinX1 = 3; - lMaxX1 = lMinX1 + 1; - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, true); - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, lMinX2, lMinX3, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, true); - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, lMinX2, dummy, dummy, dummy, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvOd, indexEvOd); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, true); - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, lMinX3, dummy, lMaxX2, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, true); - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, dummy, dummy, lMaxX2, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdOd, indexOdOd); - break; - case N: - lMinX2 = maxX2 - 4; - lMaxX2 = lMinX2 + 1; - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, true); - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, true); - getLocalMinMax(lMinX1, dummy, lMinX3, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, true); - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, true); - getLocalMinMax(lMinX1, dummy, dummy, dummy, dummy, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvOd, indexEvOd); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, true); - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, lMinX3, lMaxX1, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, true); - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, dummy, lMaxX1, dummy, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdOd, indexOdOd); - break; - case S: - lMinX2 = 3; - lMaxX2 = lMinX2 + 1; - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, true); - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, true); - getLocalMinMax(lMinX1, dummy, lMinX3, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, true); - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, true); - getLocalMinMax(lMinX1, dummy, dummy, dummy, dummy, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvOd, indexEvOd); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, true); - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, lMinX3, lMaxX1, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, true); - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, dummy, lMaxX1, dummy, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdOd, indexOdOd); - break; - case T: - lMinX3 = maxX3 - 4; - lMaxX3 = lMinX3 + 1; - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, true); - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, true); - getLocalMinMax(lMinX1, lMinX2, dummy, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, true); - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, true); - getLocalMinMax(lMinX1, dummy, dummy, dummy, lMaxX2, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvOd, indexEvOd); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, true); - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, lMinX2, dummy, lMaxX1, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, true); - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, dummy, dummy, lMaxX1, lMaxX2, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdOd, indexOdOd); - break; - case B: - lMinX3 = 3; - lMaxX3 = lMinX3 + 1; - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, true); - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, true); - getLocalMinMax(lMinX1, lMinX2, dummy, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, true); - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, true); - getLocalMinMax(lMinX1, dummy, dummy, dummy, lMaxX2, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvOd, indexEvOd); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, true); - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, lMinX2, dummy, lMaxX1, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, true); - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, dummy, dummy, lMaxX1, lMaxX2, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdOd, indexOdOd); - break; - - // /////E-W-N-S - case NE: - lMinX1 = maxX1 - 4; - lMaxX1 = lMinX1 + 3; - lMinX2 = maxX2 - 4; - lMaxX2 = lMinX2 + 1; - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, lMinX3, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, dummy, dummy, dummy, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - lMinX1 = maxX1 - 4; - lMaxX1 = lMinX1 + 1; - lMinX2 = maxX2 - 4; - lMaxX2 = lMinX2 + 3; - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, lMinX3, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, dummy, dummy, dummy, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - case SW: - lMinX1 = 1; - lMaxX1 = lMinX1 + 3; - lMinX2 = 3; - lMaxX2 = lMinX2 + 1; - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, lMinX3, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, dummy, dummy, dummy, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - lMinX1 = 3; - lMaxX1 = lMinX1 + 1; - lMinX2 = 1; - lMaxX2 = lMinX2 + 3; - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, lMinX3, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, dummy, dummy, dummy, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - case SE: - lMinX1 = maxX1 - 4; - lMaxX1 = lMinX1 + 3; - lMinX2 = 3; - lMaxX2 = lMinX2 + 1; - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, lMinX3, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, dummy, dummy, dummy, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - lMinX1 = maxX1 - 4; - lMaxX1 = lMinX1 + 1; - lMinX2 = 1; - lMaxX2 = lMinX2 + 3; - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, lMinX3, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, dummy, dummy, dummy, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - case NW: - lMinX1 = 1; - lMaxX1 = lMinX1 + 3; - lMinX2 = maxX2 - 4; - lMaxX2 = lMinX2 + 1; - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, lMinX3, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, dummy, dummy, dummy, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - lMinX1 = 3; - lMaxX1 = lMinX1 + 1; - lMinX2 = maxX2 - 4; - lMaxX2 = lMinX2 + 3; - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, lMinX3, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, true); - getLocalMinMax(dummy, dummy, dummy, dummy, dummy, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - // /////T-B-E-W - case TE: - lMinX1 = maxX1 - 4; - lMaxX1 = lMinX1 + 3; - lMinX3 = maxX3 - 4; - lMaxX3 = lMinX3 + 1; - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, lMinX2, dummy, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, dummy, dummy, dummy, lMaxX2, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - lMinX1 = maxX1 - 4; - lMaxX1 = lMinX1 + 1; - lMinX3 = maxX3 - 4; - lMaxX3 = lMinX3 + 3; - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, lMinX2, dummy, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, dummy, dummy, dummy, lMaxX2, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - case BW: - lMinX1 = 1; - lMaxX1 = lMinX1 + 3; - lMinX3 = 3; - lMaxX3 = lMinX3 + 1; - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, lMinX2, dummy, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, dummy, dummy, dummy, lMaxX2, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - lMinX1 = 3; - lMaxX1 = lMinX1 + 1; - lMinX3 = 1; - lMaxX3 = lMinX3 + 3; - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, lMinX2, dummy, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, dummy, dummy, dummy, lMaxX2, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - case BE: - lMinX1 = maxX1 - 4; - lMaxX1 = lMinX1 + 3; - lMinX3 = 3; - lMaxX3 = lMinX3 + 1; - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, lMinX2, dummy, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, dummy, dummy, dummy, lMaxX2, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - lMinX1 = maxX1 - 4; - lMaxX1 = lMinX1 + 1; - lMinX3 = 1; - lMaxX3 = lMinX3 + 3; - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, lMinX2, dummy, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, dummy, dummy, dummy, lMaxX2, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - case TW: - lMinX1 = 1; - lMaxX1 = lMinX1 + 3; - lMinX3 = maxX3 - 4; - lMaxX3 = lMinX3 + 1; - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, lMinX2, dummy, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, dummy, dummy, dummy, lMaxX2, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - lMinX1 = 3; - lMaxX1 = lMinX1 + 1; - lMinX3 = maxX3 - 4; - lMaxX3 = lMinX3 + 3; - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, lMinX2, dummy, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, true); - getLocalMinMax(dummy, dummy, dummy, dummy, lMaxX2, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - /////////////////////////T-N-B-S - case TN: - lMinX2 = maxX2 - 4; - lMaxX2 = lMinX2 + 3; - lMinX3 = maxX3 - 4; - lMaxX3 = lMinX3 + 1; - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, true); - getLocalMinMax(lMinX1, dummy, dummy, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, true); - getLocalMinMax(dummy, dummy, dummy, lMaxX1, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - lMinX2 = maxX2 - 4; - lMaxX2 = lMinX2 + 1; - lMinX3 = maxX3 - 4; - lMaxX3 = lMinX3 + 3; - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, true); - getLocalMinMax(lMinX1, dummy, dummy, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, true); - getLocalMinMax(dummy, dummy, dummy, lMaxX1, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - case BS: - lMinX2 = 1; - lMaxX2 = lMinX2 + 3; - lMinX3 = 3; - lMaxX3 = lMinX3 + 1; - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, true); - getLocalMinMax(lMinX1, dummy, dummy, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, true); - getLocalMinMax(dummy, dummy, dummy, lMaxX1, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - lMinX2 = 3; - lMaxX2 = lMinX2 + 1; - lMinX3 = 1; - lMaxX3 = lMinX3 + 3; - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, true); - getLocalMinMax(lMinX1, dummy, dummy, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, true); - getLocalMinMax(dummy, dummy, dummy, lMaxX1, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - - case BN: - lMinX2 = maxX2 - 4; - lMaxX2 = lMinX2 + 3; - lMinX3 = 3; - lMaxX3 = lMinX3 + 1; - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, true); - getLocalMinMax(lMinX1, dummy, dummy, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, true); - getLocalMinMax(dummy, dummy, dummy, lMaxX1, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - lMinX2 = maxX2 - 4; - lMaxX2 = lMinX2 + 1; - lMinX3 = 1; - lMaxX3 = lMinX3 + 3; - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, true); - getLocalMinMax(lMinX1, dummy, dummy, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, true); - getLocalMinMax(dummy, dummy, dummy, lMaxX1, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - case TS: - lMinX2 = 1; - lMaxX2 = lMinX2 + 3; - lMinX3 = maxX3 - 4; - lMaxX3 = lMinX3 + 1; - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, true); - getLocalMinMax(lMinX1, dummy, dummy, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, true); - getLocalMinMax(dummy, dummy, dummy, lMaxX1, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - lMinX2 = 3; - lMaxX2 = lMinX2 + 1; - lMinX3 = maxX3 - 4; - lMaxX3 = lMinX3 + 3; - getLocalMinMax(minX1, maxX1, true, lMinX1, lMaxX1, true); - getLocalMinMax(lMinX1, dummy, dummy, dummy, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1, maxX1, false, lMinX1, lMaxX1, true); - getLocalMinMax(dummy, dummy, dummy, lMaxX1, dummy, dummy); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - break; - - //TNE - case TNE: - lMinX1 = maxX1 - 4; - lMaxX1 = maxX1 - 3; - lMinX2 = maxX2 - 4; - lMaxX2 = maxX2 - 1; - lMinX3 = maxX3 - 4; - lMaxX3 = maxX3 - 1; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - lMinX1 = maxX1 - 4; - lMaxX1 = maxX1 - 1; - lMinX2 = maxX2 - 4; - lMaxX2 = maxX2 - 3; - lMinX3 = maxX3 - 4; - lMaxX3 = maxX3 - 1; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - lMinX1 = maxX1 - 4; - lMaxX1 = maxX1 - 1; - lMinX2 = maxX2 - 4; - lMaxX2 = maxX2 - 1; - lMinX3 = maxX3 - 4; - lMaxX3 = maxX3 - 3; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - break; - // TNW - case TNW: - lMinX1 = 3; - lMaxX1 = 4; - lMinX2 = maxX2 - 4; - lMaxX2 = maxX2 - 1; - lMinX3 = maxX3 - 4; - lMaxX3 = maxX3 - 1; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - lMinX1 = 1; - lMaxX1 = 4; - lMinX2 = maxX2 - 4; - lMaxX2 = maxX2 - 3; - lMinX3 = maxX3 - 4; - lMaxX3 = maxX3 - 1; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - lMinX1 = 1; - lMaxX1 = 4; - lMinX2 = maxX2 - 4; - lMaxX2 = maxX2 - 1; - lMinX3 = maxX3 - 4; - lMaxX3 = maxX3 - 3; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - break; - // TSE - case TSE: - lMinX1 = maxX1 - 4; - lMaxX1 = maxX1 - 3; - lMinX2 = 1; - lMaxX2 = 4; - lMinX3 = maxX3 - 4; - lMaxX3 = maxX3 - 1; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - lMinX1 = maxX1 - 4; - lMaxX1 = maxX1 - 1; - lMinX2 = 3; - lMaxX2 = 4; - lMinX3 = maxX3 - 4; - lMaxX3 = maxX3 - 1; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - lMinX1 = maxX1 - 4; - lMaxX1 = maxX1 - 1; - lMinX2 = 1; - lMaxX2 = 4; - lMinX3 = maxX3 - 4; - lMaxX3 = maxX3 - 3; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - break; - // TSW - case TSW: - lMinX1 = 3; - lMaxX1 = 4; - lMinX2 = 1; - lMaxX2 = 4; - lMinX3 = maxX3 - 4; - lMaxX3 = maxX3 - 1; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - lMinX1 = 1; - lMaxX1 = 4; - lMinX2 = 3; - lMaxX2 = 4; - lMinX3 = maxX3 - 4; - lMaxX3 = maxX3 - 1; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - lMinX1 = 1; - lMaxX1 = 4; - lMinX2 = 1; - lMaxX2 = 4; - lMinX3 = maxX3 - 4; - lMaxX3 = maxX3 - 3; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - break; - // BNE - case BNE: - lMinX1 = maxX1 - 4; - lMaxX1 = maxX1 - 3; - lMinX2 = maxX2 - 4; - lMaxX2 = maxX2 - 1; - lMinX3 = 1; - lMaxX3 = 4; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - lMinX1 = maxX1 - 4; - lMaxX1 = maxX1 - 1; - lMinX2 = maxX2 - 4; - lMaxX2 = maxX2 - 3; - lMinX3 = 1; - lMaxX3 = 4; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - lMinX1 = maxX1 - 4; - lMaxX1 = maxX1 - 1; - lMinX2 = maxX2 - 4; - lMaxX2 = maxX2 - 1; - lMinX3 = 3; - lMaxX3 = 4; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - break; - // BNW - case BNW: - lMinX1 = 3; - lMaxX1 = 4; - lMinX2 = maxX2 - 4; - lMaxX2 = maxX2 - 1; - lMinX3 = 1; - lMaxX3 = 4; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - lMinX1 = 1; - lMaxX1 = 4; - lMinX2 = maxX2 - 4; - lMaxX2 = maxX2 - 3; - lMinX3 = 1; - lMaxX3 = 4; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - lMinX1 = 1; - lMaxX1 = 4; - lMinX2 = maxX2 - 4; - lMaxX2 = maxX2 - 1; - lMinX3 = 3; - lMaxX3 = 4; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - break; - // BSE - case BSE: - lMinX1 = maxX1 - 4; - lMaxX1 = maxX1 - 3; - lMinX2 = 1; - lMaxX2 = 4; - lMinX3 = 1; - lMaxX3 = 4; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - lMinX1 = maxX1 - 4; - lMaxX1 = maxX1 - 1; - lMinX2 = 3; - lMaxX2 = 4; - lMinX3 = 1; - lMaxX3 = 4; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - lMinX1 = maxX1 - 4; - lMaxX1 = maxX1 - 1; - lMinX2 = 1; - lMaxX2 = 4; - lMinX3 = 3; - lMaxX3 = 4; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - break; - // BSW - case BSW: - lMinX1 = 3; - lMaxX1 = 4; - lMinX2 = 1; - lMaxX2 = 4; - lMinX3 = 1; - lMaxX3 = 4; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - lMinX1 = 1; - lMaxX1 = 4; - lMinX2 = 3; - lMaxX2 = 4; - lMinX3 = 1; - lMaxX3 = 4; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - lMinX1 = 1; - lMaxX1 = 4; - lMinX2 = 1; - lMaxX2 = 4; - lMinX3 = 3; - lMaxX3 = 4; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - break; - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETCFOffVectorConnector< VectorTransmitter>::distributeReceiveVector(SPtr<DistributionArray3D> fTo, const int& lMinX1, const int& lMinX2, const int& lMinX3, const int& lMaxX1, const int& lMaxX2, const int& lMaxX3, vector_type& data, int& index) -{ - if (data.size() == 0) return; - - int ix1, ix2, ix3; - for (ix3 = lMinX3; ix3 < lMaxX3; ix3++) - { - for (ix2 = lMinX2; ix2 < lMaxX2; ix2++) - { - for (ix1 = lMinX1; ix1 < lMaxX1; ix1++) - { - LBMReal icellC[27]; - this->readICellCfromData(data, index, icellC); - iprocessor->writeINodeInv(fTo, icellC, ix1, ix2, ix3); - } - } - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETCFOffVectorConnector< VectorTransmitter>::readICellCfromData(vector_type& data, int& index, LBMReal* icellC) -{ - for (int i = D3Q27System::STARTF; i < D3Q27System::ENDF + 1; i++) - { - icellC[i] = data[index++]; - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETCFOffVectorConnector< VectorTransmitter>::getLocalMinMax(int& minX1, int& minX2, int& minX3, int& maxX1, int& maxX2, int& maxX3) -{ - using namespace D3Q27System; - int TminX1 = minX1; int TminX2 = minX2; int TminX3 = minX3; int TmaxX1 = maxX1; int TmaxX2 = maxX2; int TmaxX3 = maxX3; - - if (block.lock()->hasInterpolationFlagCF(E)) - { - if (maxX1 == TmaxX1) maxX1 -= 2; - } - if (block.lock()->hasInterpolationFlagCF(W)) - { - if (minX1 == TminX1) minX1 += 2; - } - if (block.lock()->hasInterpolationFlagCF(N)) - { - if (maxX2 == TmaxX2) maxX2 -= 2; - } - if (block.lock()->hasInterpolationFlagCF(S)) - { - if (minX2 == TminX2) minX2 += 2; - } - if (block.lock()->hasInterpolationFlagCF(T)) - { - if (maxX3 == TmaxX3) maxX3 -= 2; - } - if (block.lock()->hasInterpolationFlagCF(B)) - { - if (minX3 == TminX3) minX3 += 2; - } - - //E-W-N-S - if (block.lock()->hasInterpolationFlagCF(NE) && !block.lock()->hasInterpolationFlagCF(N) && !block.lock()->hasInterpolationFlagCF(E)) - { - if (maxX1 == TmaxX1) maxX1 -= 2; - if (maxX2 == TmaxX2) maxX2 -= 2; - } - if (block.lock()->hasInterpolationFlagCF(SW) && !block.lock()->hasInterpolationFlagCF(W) && !block.lock()->hasInterpolationFlagCF(S)) - { - if (minX1 == TminX1) minX1 += 2; - if (minX2 == TminX2) minX2 += 2; - } - if (block.lock()->hasInterpolationFlagCF(SE) && !block.lock()->hasInterpolationFlagCF(E) && !block.lock()->hasInterpolationFlagCF(S)) - { - if (maxX1 == TmaxX1) maxX1 -= 2; - if (minX2 == TminX2) minX2 += 2; - } - if (block.lock()->hasInterpolationFlagCF(NW) && !block.lock()->hasInterpolationFlagCF(N) && !block.lock()->hasInterpolationFlagCF(W)) - { - if (minX1 == TminX1) minX1 += 2; - if (maxX2 == TmaxX2) maxX2 -= 2; - } - - // ////T-B-E-W - if (block.lock()->hasInterpolationFlagCF(TE) && !block.lock()->hasInterpolationFlagCF(E) && !block.lock()->hasInterpolationFlagCF(T)) - { - if (maxX1 == TmaxX1) maxX1 -= 2; - if (maxX3 == TmaxX3) maxX3 -= 2; - } - if (block.lock()->hasInterpolationFlagCF(BW) && !block.lock()->hasInterpolationFlagCF(W) && !block.lock()->hasInterpolationFlagCF(B)) - { - if (minX1 == TminX1) minX1 += 2; - if (minX3 == TminX3) minX3 += 2; - } - if (block.lock()->hasInterpolationFlagCF(BE) && !block.lock()->hasInterpolationFlagCF(E) && !block.lock()->hasInterpolationFlagCF(B)) - { - if (maxX1 == TmaxX1) maxX1 -= 2; - if (minX3 == TminX3) minX3 += 2; - } - if (block.lock()->hasInterpolationFlagCF(TW) && !block.lock()->hasInterpolationFlagCF(W) && !block.lock()->hasInterpolationFlagCF(T)) - { - if (minX1 == TminX1) minX1 += 2; - if (maxX3 == TmaxX3) maxX3 -= 2; - } - - - ////T-B-N-S - if (block.lock()->hasInterpolationFlagCF(TN) && !block.lock()->hasInterpolationFlagCF(N) && !block.lock()->hasInterpolationFlagCF(T)) - { - if (maxX2 == TmaxX2) maxX2 -= 2; - if (maxX3 == TmaxX3) maxX3 -= 2; - } - if (block.lock()->hasInterpolationFlagCF(BS) && !block.lock()->hasInterpolationFlagCF(S) && !block.lock()->hasInterpolationFlagCF(B)) - { - if (minX2 == TminX2) minX2 += 2; - if (minX3 == TminX3) minX3 += 2; - } - if (block.lock()->hasInterpolationFlagCF(BN) && !block.lock()->hasInterpolationFlagCF(N) && !block.lock()->hasInterpolationFlagCF(B)) - { - if (maxX2 == TmaxX2) maxX2 -= 2; - if (minX3 == TminX3) minX3 += 2; - } - if (block.lock()->hasInterpolationFlagCF(TS) && !block.lock()->hasInterpolationFlagCF(S) && !block.lock()->hasInterpolationFlagCF(T)) - { - if (minX2 == TminX2) minX2 += 2; - if (maxX3 == TmaxX3) maxX3 -= 2; - } - - //if (block.lock()->hasInterpolationFlagCF(D3Q27System::TNE)&&!block.lock()->hasInterpolationFlagCF(D3Q27System::TE)&&!block.lock()->hasInterpolationFlagCF(D3Q27System::TN)&&!block.lock()->hasInterpolationFlagCF(D3Q27System::NE)&&!block.lock()->hasInterpolationFlagCF(D3Q27System::T)&&!block.lock()->hasInterpolationFlagCF(D3Q27System::N) && !block.lock()->hasInterpolationFlagCF(D3Q27System::E)) - //if (!block.lock()->hasInterpolationFlagCF(D3Q27System::TE)&&!block.lock()->hasInterpolationFlagCF(D3Q27System::T)&& !block.lock()->hasInterpolationFlagCF(D3Q27System::E)) - //{ - // if (maxX1==TmaxX1) maxX1 -= 2; - // if (maxX2==TmaxX2) maxX2 -= 2; - // if (maxX3==TmaxX3) maxX3 -= 2; - //} -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETCFOffVectorConnector< VectorTransmitter>::getLocalMinMax(int& minX1, int& minX2, int& minX3, int& maxX1, int& maxX2, int& maxX3, CFconnectorType connType) -{ - using namespace D3Q27System; - int TminX1 = minX1; int TminX2 = minX2; int TminX3 = minX3; int TmaxX1 = maxX1; int TmaxX2 = maxX2; int TmaxX3 = maxX3; - - if (block.lock()->hasInterpolationFlagCF(E)) - { - if (maxX1 == TmaxX1) maxX1 -= 2; - } - if (block.lock()->hasInterpolationFlagCF(W)) - { - if (minX1 == TminX1) minX1 += 2; - } - if (block.lock()->hasInterpolationFlagCF(N)) - { - if (maxX2 == TmaxX2) maxX2 -= 2; - } - if (block.lock()->hasInterpolationFlagCF(S)) - { - if (minX2 == TminX2) minX2 += 2; - } - if (block.lock()->hasInterpolationFlagCF(T)) - { - if (maxX3 == TmaxX3) maxX3 -= 2; - } - if (block.lock()->hasInterpolationFlagCF(B)) - { - if (minX3 == TminX3) minX3 += 2; - } - - //E-W-N-S - if (block.lock()->hasInterpolationFlagCF(NE) && !block.lock()->hasInterpolationFlagCF(N) && !block.lock()->hasInterpolationFlagCF(E)) - { - if (maxX1 == TmaxX1) maxX1 -= 2; - if (maxX2 == TmaxX2) maxX2 -= 2; - } - if (block.lock()->hasInterpolationFlagCF(SW) && !block.lock()->hasInterpolationFlagCF(W) && !block.lock()->hasInterpolationFlagCF(S)) - { - if (minX1 == TminX1) minX1 += 2; - if (minX2 == TminX2) minX2 += 2; - } - if (block.lock()->hasInterpolationFlagCF(SE) && !block.lock()->hasInterpolationFlagCF(E) && !block.lock()->hasInterpolationFlagCF(S)) - { - if (maxX1 == TmaxX1) maxX1 -= 2; - if (minX2 == TminX2) minX2 += 2; - } - if (block.lock()->hasInterpolationFlagCF(NW) && !block.lock()->hasInterpolationFlagCF(N) && !block.lock()->hasInterpolationFlagCF(W)) - { - if (minX1 == TminX1) minX1 += 2; - if (maxX2 == TmaxX2) maxX2 -= 2; - } - - // ////T-B-E-W - if (block.lock()->hasInterpolationFlagCF(TE) && !block.lock()->hasInterpolationFlagCF(E) && !block.lock()->hasInterpolationFlagCF(T)) - { - if (maxX1 == TmaxX1) maxX1 -= 2; - if (maxX3 == TmaxX3) maxX3 -= 2; - } - if (block.lock()->hasInterpolationFlagCF(BW) && !block.lock()->hasInterpolationFlagCF(W) && !block.lock()->hasInterpolationFlagCF(B)) - { - if (minX1 == TminX1) minX1 += 2; - if (minX3 == TminX3) minX3 += 2; - } - if (block.lock()->hasInterpolationFlagCF(BE) && !block.lock()->hasInterpolationFlagCF(E) && !block.lock()->hasInterpolationFlagCF(B)) - { - if (maxX1 == TmaxX1) maxX1 -= 2; - if (minX3 == TminX3) minX3 += 2; - } - if (block.lock()->hasInterpolationFlagCF(TW) && !block.lock()->hasInterpolationFlagCF(W) && !block.lock()->hasInterpolationFlagCF(T)) - { - if (minX1 == TminX1) minX1 += 2; - if (maxX3 == TmaxX3) maxX3 -= 2; - } - - - ////T-B-N-S - if (block.lock()->hasInterpolationFlagCF(TN) && !block.lock()->hasInterpolationFlagCF(N) && !block.lock()->hasInterpolationFlagCF(T)) - { - if (maxX2 == TmaxX2) maxX2 -= 2; - if (maxX3 == TmaxX3) maxX3 -= 2; - } - if (block.lock()->hasInterpolationFlagCF(BS) && !block.lock()->hasInterpolationFlagCF(S) && !block.lock()->hasInterpolationFlagCF(B)) - { - if (minX2 == TminX2) minX2 += 2; - if (minX3 == TminX3) minX3 += 2; - } - if (block.lock()->hasInterpolationFlagCF(BN) && !block.lock()->hasInterpolationFlagCF(N) && !block.lock()->hasInterpolationFlagCF(B)) - { - if (maxX2 == TmaxX2) maxX2 -= 2; - if (minX3 == TminX3) minX3 += 2; - } - if (block.lock()->hasInterpolationFlagCF(TS) && !block.lock()->hasInterpolationFlagCF(S) && !block.lock()->hasInterpolationFlagCF(T)) - { - if (minX2 == TminX2) minX2 += 2; - if (maxX3 == TmaxX3) maxX3 -= 2; - } - - //if (block.lock()->hasInterpolationFlagCF(D3Q27System::TNE)&&!block.lock()->hasInterpolationFlagCF(D3Q27System::TE)&&!block.lock()->hasInterpolationFlagCF(D3Q27System::TN)&&!block.lock()->hasInterpolationFlagCF(D3Q27System::NE)&&!block.lock()->hasInterpolationFlagCF(D3Q27System::T)&&!block.lock()->hasInterpolationFlagCF(D3Q27System::N) && !block.lock()->hasInterpolationFlagCF(D3Q27System::E)) - //{ - // if (maxX1==TmaxX1) maxX1 -= 2; - // if (maxX2==TmaxX2) maxX2 -= 2; - // if (maxX3==TmaxX3) maxX3 -= 2; - //} -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETCFOffVectorConnector< VectorTransmitter>::findCFnodes() -{ - SPtr<DistributionArray3D> fFrom = block.lock()->getKernel()->getDataSet()->getFdistributions(); - int maxX1 = (int)fFrom->getNX1(); - int maxX2 = (int)fFrom->getNX2(); - int maxX3 = (int)fFrom->getNX3(); - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int indexEvEv = 0; - int indexEvOd = 0; - int indexOdEv = 0; - int indexOdOd = 0; - - vector_type& dataEvEv = this->senderEvenEvenSW->getData(); - vector_type& dataEvOd = this->senderEvenOddNW->getData(); - vector_type& dataOdEv = this->senderOddEvenSE->getData(); - vector_type& dataOdOd = this->senderOddOddNE->getData(); - - int lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3; - - using namespace D3Q27System; - if (block.lock()->hasInterpolationFlagCF(W)) - { - lMinX1 = 1; - lMaxX1 = lMinX1 + 1; - - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, false); - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, false); - findCFnodes(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX2, maxX2, true, lMinX2, lMaxX2, false); - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, false); - findCFnodes(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvOd, indexEvOd); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, false); - getLocalMinMax(minX3, maxX3, true, lMinX3, lMaxX3, false); - findCFnodes(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - - getLocalMinMax(minX2, maxX2, false, lMinX2, lMaxX2, false); - getLocalMinMax(minX3, maxX3, false, lMinX3, lMaxX3, false); - findCFnodes(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdOd, indexOdOd); - } - if (block.lock()->hasInterpolationFlagCF(TN) && !block.lock()->hasInterpolationFlagCF(N) && !block.lock()->hasInterpolationFlagCF(T)) - { - lMinX2 = maxX2 - 3; - lMaxX2 = lMinX2 + 1; - lMinX3 = maxX3 - 3; - lMaxX3 = lMinX3 + 1; - - getLocalMinMax(minX1 + 1, maxX1, true, lMinX1, lMaxX1, false); - findCFnodes(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataEvEv, indexEvEv); - - getLocalMinMax(minX1 + 1, maxX1, false, lMinX1, lMaxX1, false); - findCFnodes(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, dataOdEv, indexOdEv); - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETCFOffVectorConnector< VectorTransmitter>::findCFnodes(SPtr<DistributionArray3D> fFrom, const int& lMinX1, const int& lMinX2, const int& lMinX3, const int& lMaxX1, const int& lMaxX2, const int& lMaxX3, vector_type& data, int& index) -{ - if (data.size() == 0) return; - int ix1, ix2, ix3; - LBMReal xoff, yoff, zoff; - SPtr<BCArray3D> bcArray = block.lock()->getKernel()->getBCProcessor()->getBCArray(); - - for (ix3 = lMinX3; ix3 < lMaxX3; ix3++) - { - for (ix2 = lMinX2; ix2 < lMaxX2; ix2++) - { - for (ix1 = lMinX1; ix1 < lMaxX1; ix1++) - { - D3Q27ICell icellC; - D3Q27ICell icellF; - - int howManySolids = iprocessor->iCellHowManySolids(bcArray, ix1, ix2, ix3); - - if (howManySolids == 0 || howManySolids == 8) - { - iprocessor->readICell(fFrom, icellC, ix1, ix2, ix3); - xoff = 0.0; - yoff = 0.0; - zoff = 0.0; - } - else - { - if (!iprocessor->findNeighborICell(bcArray, fFrom, icellC, bMaxX1, bMaxX2, bMaxX3, ix1, ix2, ix3, xoff, yoff, zoff)) - { - std::string err = "For " + block.lock()->toString() + " x1=" + UbSystem::toString(ix1) + ", x2=" + UbSystem::toString(ix2) + ", x3=" + UbSystem::toString(ix3) + - " 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"; - //UBLOG(logINFO, err); - UB_THROW(UbException(UB_EXARGS, err)); - } - } - - iprocessor->interpolateCoarseToFine(icellC, icellF, xoff, yoff, zoff); - this->writeICellFtoData(data, index, icellF); - //for (int iix3 = ix3; iix3<=ix3+1; iix3++) - //{ - // for (int iix2 = ix2; iix2<=ix2+1; iix2++) - // { - // for (int iix1 = ix1; iix1<=ix1+1; iix1++) - // { - // bcArray->setInterfaceCF(iix1, iix2, iix3); - // } - // } - //} - - } - } - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -double D3Q27ETCFOffVectorConnector<VectorTransmitter>::getSendRecieveTime() -{ - return 0; -} - -#endif diff --git a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFCOffVectorConnector.cpp b/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFCOffVectorConnector.cpp deleted file mode 100644 index 41e9f74ca..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFCOffVectorConnector.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "D3Q27ETFCOffVectorConnector.h" - - diff --git a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFCOffVectorConnector.h b/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFCOffVectorConnector.h deleted file mode 100644 index 59c6539a1..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFCOffVectorConnector.h +++ /dev/null @@ -1,1437 +0,0 @@ -/** -* @file D3Q27ETFCOffVectorConnector.h -* @class D3Q27ETFCVectorConnector -* @brief Interpolation from fine level to coarse. -* @author Kostyantyn Kucher and Ehsan Fard -* @date 08.06.2011 -*/ -#ifndef D3Q27ETFCOffVectorConnector_H -#define D3Q27ETFCOffVectorConnector_H - -#include <vector> - -#include "basics/transmitter/TbTransmitter.h" -#include "Block3DConnector.h" -#include "D3Q27System.h" -#include "Block3D.h" -#include "Grid3D.h" -#include "LBMKernel.h" -#include "InterpolationProcessor.h" -#include "MathUtil.hpp" -#include <PointerDefinitions.h> - -#include "BCProcessor.h" -#include "DataSet3D.h" - -class Block3D; - -enum CFconnectorType {EvenOddNW, EvenEvenSW, OddEvenSE, OddOddNE}; - -//daten werden in einen vector (dieser befindet sich im transmitter) kopiert -//der vector wird via transmitter uebertragen -//transmitter kann ein lokal, MPI, RCG, CTL oder was auch immer fuer ein -//transmitter sein, der von Transmitter abgeleitet ist ;-) - -template< typename VectorTransmitter > -class D3Q27ETFCOffVectorConnector : public Block3DConnector -{ -public: - -protected: - typedef typename VectorTransmitter::value_type vector_type; - typedef SPtr< VectorTransmitter > VectorTransmitterPtr; -public: - D3Q27ETFCOffVectorConnector(SPtr<Block3D> block, VectorTransmitterPtr sender, VectorTransmitterPtr receiver, int sendDir, - InterpolationProcessorPtr iprocessor, CFconnectorType connType); - - bool isLocalConnector(); - bool isRemoteConnector(); - void init(); - - void sendTransmitterDataSize(); - void receiveTransmitterDataSize(); - - void prepareForSend(); - void sendVectors(); - - void prepareForReceive(); - void receiveVectors(); - - void fillSendVectors(); - void distributeReceiveVectors(); - - bool isInterpolationConnectorCF() { return false; } - bool isInterpolationConnectorFC() { return true; } - - double getSendRecieveTime(); - - void prepareForSendX1() {} - void prepareForSendX2() {} - void prepareForSendX3() {} - - void sendVectorsX1(){} - void sendVectorsX2(){} - void sendVectorsX3(){} - - void prepareForReceiveX1() {} - void prepareForReceiveX2() {} - void prepareForReceiveX3() {} - - void receiveVectorsX1() {} - void receiveVectorsX2() {} - void receiveVectorsX3() {} - -protected: - WPtr<Block3D> block; //dieser nvd sendet daten und die empfangenen werden diesem nvd zugeordnet - //gegenstelle muss "inversen" connector besitzen - VectorTransmitterPtr sender, receiver; - - InterpolationProcessorPtr iprocessor; - - CFconnectorType connType; - - void writeICellCtoData(vector_type& data, int& index, LBMReal* icellC); - void writeNodeToVector(vector_type& data, int& index, LBMReal* inode); - void getLocalMinMax(int& minX1, int& minX2, int& minX3, int& maxX1, int& maxX2, int& maxX3); - void getLocalMinMax(int& minX1, int& minX2, int& minX3, int& maxX1, int& maxX2, int& maxX3, CFconnectorType connType); - void getLocalMinMaxCF(int gMax, int& lMin, int& lMax); - void fillSendVector(SPtr<DistributionArray3D> fFrom, const int& lMinX1, const int& lMinX2, const int& lMinX3, const int& lMaxX1, const int& lMaxX2, const int& lMaxX3, vector_type& data, int& index); - - void distributeReceiveVector(SPtr<DistributionArray3D> fTo, const int& lMinX1, const int& lMinX2, const int& lMinX3, const int& lMaxX1, const int& lMaxX2, const int& lMaxX3, vector_type& data, int& index); - void readICellFfromData(vector_type& data, int& index, D3Q27ICell& icellF); - void readNodeFromVector(vector_type& data, int& index, LBMReal* inode); - void getLocalOffsets(const int& gMax, int& oMin); - void getLocalMins(int& minX1, int& minX2, int& minX3, const int& oMinX1, const int& oMinX2, const int& oMinX3); - - int bMaxX1, bMaxX2, bMaxX3; -}; -//////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -D3Q27ETFCOffVectorConnector<VectorTransmitter>::D3Q27ETFCOffVectorConnector(SPtr<Block3D> block, VectorTransmitterPtr sender, - VectorTransmitterPtr receiver, int sendDir, - InterpolationProcessorPtr iprocessor, - CFconnectorType connType) - : Block3DConnector(sendDir) - , block(block) - , sender(sender) - , receiver(receiver) - , iprocessor(iprocessor) - , connType(connType) -{ - if( !( sendDir==D3Q27System::E || sendDir==D3Q27System::W || sendDir==D3Q27System::N || sendDir==D3Q27System::S || sendDir==D3Q27System::T || sendDir==D3Q27System::B - || sendDir==D3Q27System::NE || sendDir==D3Q27System::SW || sendDir==D3Q27System::SE || sendDir==D3Q27System::NW - || sendDir==D3Q27System::TE || sendDir==D3Q27System::BW || sendDir==D3Q27System::BE || sendDir==D3Q27System::TW - || sendDir==D3Q27System::TN || sendDir==D3Q27System::BS || sendDir==D3Q27System::BN || sendDir==D3Q27System::TS - - || sendDir==D3Q27System::TNE || sendDir==D3Q27System::TNW || sendDir==D3Q27System::TSE || sendDir==D3Q27System::TSW - || sendDir==D3Q27System::BNE || sendDir==D3Q27System::BNW || sendDir==D3Q27System::BSE || sendDir==D3Q27System::BSW - - ) ) - { - throw UbException(UB_EXARGS,"invalid constructor for this direction"); - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -bool D3Q27ETFCOffVectorConnector<VectorTransmitter>::isLocalConnector() -{ - return !this->isRemoteConnector(); -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -bool D3Q27ETFCOffVectorConnector<VectorTransmitter>::isRemoteConnector() -{ - return sender->isRemoteTransmitter() || receiver->isRemoteTransmitter(); -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETFCOffVectorConnector<VectorTransmitter>::sendTransmitterDataSize() -{ - if(sender) - { - UBLOG(logDEBUG5, "D3Q27ETFCOffVectorConnector<VectorTransmitter>::sendTransmitterDataSize()"<<block.lock()->toString()+"sendDir="<<sendDir); - sender->sendDataSize(); - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETFCOffVectorConnector<VectorTransmitter>::receiveTransmitterDataSize() -{ - if(receiver) - { - UBLOG(logDEBUG5, "D3Q27ETFCOffVectorConnector<VectorTransmitter>::receiveTransmitterDataSize()"<<block.lock()->toString()<<"sendDir="<<sendDir); - receiver->receiveDataSize(); - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETFCOffVectorConnector<VectorTransmitter>::prepareForSend() -{ - if(sender) sender->prepareForSend(); -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETFCOffVectorConnector<VectorTransmitter>::sendVectors() -{ - if(sender) sender->sendData(); -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETFCOffVectorConnector<VectorTransmitter>::prepareForReceive() -{ - if(receiver) receiver->prepareForReceive(); -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETFCOffVectorConnector<VectorTransmitter>::receiveVectors() -{ - if(receiver) receiver->receiveData(); -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETFCOffVectorConnector<VectorTransmitter>::init() -{ - using namespace D3Q27System; - - bMaxX1 = (int)block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX1(); - bMaxX2 = (int)block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX2(); - bMaxX3 = (int)block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX3(); - - int sendSize = 0; - LBMReal initValue = -999.0; - - int sendDataPerNode = 27/*f*/; - int iCellSize = 1; //size of interpolation cell - - switch(this->sendDir) - { - case E : case W : sendSize = (bMaxX2-1)/2*(bMaxX3-1)/2*sendDataPerNode*iCellSize; break; - case N : case S : sendSize = (bMaxX1-1)/2*(bMaxX3-1)/2*sendDataPerNode*iCellSize; break; - case T : case B : sendSize = (bMaxX1-1)/2*(bMaxX2-1)/2*sendDataPerNode*iCellSize; break; - case NE : case SW :case SE : case NW : sendSize = (3*bMaxX3-3)*sendDataPerNode*iCellSize; break; // buffer overhead, should be (3*bMaxX3-6) for even bMax3 - case TE : case BW :case BE : case TW : sendSize = (3*bMaxX2-3)*sendDataPerNode*iCellSize; break; - case TN : case BS :case BN : case TS : sendSize = (3*bMaxX1-3)*sendDataPerNode*iCellSize; break; - case TNE: case TNW:case TSE: case TSW:case BNE: case BNW:case BSE: case BSW: sendSize = 3*(3*bMaxX1-3)*sendDataPerNode*iCellSize; break; - default: throw UbException(UB_EXARGS,"direction not allowed in this constructor"); - } - sender->getData().resize(sendSize, initValue); -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETFCOffVectorConnector< VectorTransmitter>::fillSendVectors() -{ - using namespace D3Q27System; - - SPtr<DistributionArray3D> fFrom = block.lock()->getKernel()->getDataSet()->getFdistributions(); - int maxX1 = (int)fFrom->getNX1(); - int maxX2 = (int)fFrom->getNX2(); - int maxX3 = (int)fFrom->getNX3(); - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int oMinX1, oMinX2, oMinX3; - getLocalOffsets(maxX1, oMinX1); - getLocalOffsets(maxX2, oMinX2); - getLocalOffsets(maxX3, oMinX3); - - int lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3; - int index = 0; - vector_type& data = sender->getData(); - - lMinX1 = minX1+1; lMinX2 = minX2+1; lMinX3 = minX3+1; - lMaxX1 = maxX1-2; lMaxX2 = maxX2-2; lMaxX3 = maxX3-2; - - /////////////////////////////////////// - ///DEBUG -#ifdef _DEBUG - if (block.lock()->getGlobalID() == 2558) - { - int test = 0; - } -#endif - ////////////// - - switch(sendDir) - { - case E: - getLocalMinMax(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3); - getLocalMins(lMinX1, lMinX2, lMinX3, oMinX1, oMinX2, oMinX3); - lMinX1 = maxX1-7; - lMaxX1 = lMinX1 + 1; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - case W: - /////////////////////////////////////// - ///DEBUG -#ifdef _DEBUG - if (block.lock()->getGlobalID() == 2516) - { - int test = 0; - } -#endif - ////////////// - //getLocalMinMax(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, none); - getLocalMinMax(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3); - getLocalMins(lMinX1, lMinX2, lMinX3, oMinX1, oMinX2, oMinX3); - lMinX1 = 5; - lMaxX1 = lMinX1 + 1; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - case N: - getLocalMinMax(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3); - getLocalMins(lMinX1, lMinX2, lMinX3, oMinX1, oMinX2, oMinX3); - lMinX2 = maxX2-7; - lMaxX2 = lMinX2 + 1; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - case S: - getLocalMinMax(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3); - getLocalMins(lMinX1, lMinX2, lMinX3, oMinX1, oMinX2, oMinX3); - lMinX2 = 5; - lMaxX2 = lMinX2 + 1; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - case T: - getLocalMinMax(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3); - getLocalMins(lMinX1, lMinX2, lMinX3, oMinX1, oMinX2, oMinX3); - lMinX3 = maxX3-7; - lMaxX3 = lMinX3 + 1; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - case B: - getLocalMinMax(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3); - getLocalMins(lMinX1, lMinX2, lMinX3, oMinX1, oMinX2, oMinX3); - lMinX3 = 5; - lMaxX3 = lMinX3 + 1; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - // ////N-S-E-W - case NE: - getLocalMinMax(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3); - getLocalMins(lMinX1, lMinX2, lMinX3, oMinX1, oMinX2, oMinX3); - lMinX1 = maxX1-7; - lMaxX1 = lMinX1 +5; - lMinX2 = maxX2-7; - lMaxX2 = lMinX2 + 1; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = maxX1-7; - lMaxX1 = lMinX1 + 1; - lMinX2 = maxX2-7; - lMaxX2 = lMinX2 + 5; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - case SW: - - getLocalMinMax(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3); - getLocalMins(lMinX1, lMinX2, lMinX3, oMinX1, oMinX2, oMinX3); - lMinX1 = 1; - lMaxX1 = lMinX1 + 5; - lMinX2 = 5; - lMaxX2 = lMinX2 + 1; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = 5; - lMaxX1 = lMinX1 + 1; - lMinX2 = 1; - lMaxX2 = lMinX2 + 5; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - case SE: - getLocalMinMax(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3); - getLocalMins(lMinX1, lMinX2, lMinX3, oMinX1, oMinX2, oMinX3); - lMinX1 = maxX1-7; - lMaxX1 = lMinX1 +5; - lMinX2 = 5; - lMaxX2 = lMinX2 + 1; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = maxX1-7; - lMaxX1 = lMinX1 + 1; - lMinX2 = 1; - lMaxX2 = lMinX2 + 5; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - break; - - case NW: - getLocalMinMax(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3); - getLocalMins(lMinX1, lMinX2, lMinX3, oMinX1, oMinX2, oMinX3); - lMinX1 = 1; - lMaxX1 = lMinX1 + 5; - lMinX2 = maxX2-7; - lMaxX2 = lMinX2 + 1; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = 5; - lMaxX1 = lMinX1 + 1; - lMinX2 = maxX2-7; - lMaxX2 = lMinX2 + 5; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; -//////T-B-E-W - case TE: - getLocalMinMax(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3); - getLocalMins(lMinX1, lMinX2, lMinX3, oMinX1, oMinX2, oMinX3); - lMinX1 = maxX1-7; - lMaxX1 = lMinX1 +5; - lMinX3 = maxX3-7; - lMaxX3 = lMinX3 + 1; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = maxX1-7; - lMaxX1 = lMinX1 + 1; - lMinX3 = maxX3-7; - lMaxX3 = lMinX3 + 5; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - case BW: - getLocalMinMax(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3); - getLocalMins(lMinX1, lMinX2, lMinX3, oMinX1, oMinX2, oMinX3); - lMinX1 = 1; - lMaxX1 = lMinX1 + 5; - lMinX3 = 5; - lMaxX3 = lMinX3 + 1; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = 5; - lMaxX1 = lMinX1 + 1; - lMinX3 = 1; - lMaxX3 = lMinX3 + 5; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - case BE: - getLocalMinMax(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3); - getLocalMins(lMinX1, lMinX2, lMinX3, oMinX1, oMinX2, oMinX3); - lMinX1 = maxX1-7; - lMaxX1 = lMinX1 +5; - lMinX3 = 5; - lMaxX3 = lMinX3 + 1; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = maxX1-7; - lMaxX1 = lMinX1 + 1; - lMinX3 = 1; - lMaxX3 = lMinX3 + 5; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - case TW: - getLocalMinMax(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3); - getLocalMins(lMinX1, lMinX2, lMinX3, oMinX1, oMinX2, oMinX3); - lMinX1 = 1; - lMaxX1 = lMinX1 + 5; - lMinX3 = maxX3-7; - lMaxX3 = lMinX3 + 1; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = 5; - lMaxX1 = lMinX1 + 1; - lMinX3 = maxX3-7; - lMaxX3 = lMinX3 + 5; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; -///////////////T-B-N-S -// - case TN: - getLocalMinMax(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3); - getLocalMins(lMinX1, lMinX2, lMinX3, oMinX1, oMinX2, oMinX3); - lMinX2 = maxX2-7; - lMaxX2 = lMinX2 + 5; - lMinX3 = maxX3-7; - lMaxX3 = lMinX3 + 1; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX2 = maxX2-7; - lMaxX2 = lMinX2 + 1; - lMinX3 = maxX3-7; - lMaxX3 = lMinX3 + 5; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - case BS: - getLocalMinMax(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3); - getLocalMins(lMinX1, lMinX2, lMinX3, oMinX1, oMinX2, oMinX3); - lMinX2 = 1; - lMaxX2 = lMinX2 + 5; - lMinX3 = 5; - lMaxX3 = lMinX3 + 1; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX2 = 5; - lMaxX2 = lMinX2 + 1; - lMinX3 = 1; - lMaxX3 = lMinX3 + 5; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - case BN: - getLocalMinMax(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3); - getLocalMins(lMinX1, lMinX2, lMinX3, oMinX1, oMinX2, oMinX3); - lMinX2 = maxX2-7; - lMaxX2 = lMinX2 + 5; - lMinX3 = 5; - lMaxX3 = lMinX3 + 1; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX2 = maxX2-7; - lMaxX2 = lMinX2 + 1; - lMinX3 = 1; - lMaxX3 = lMinX3 + 5; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - case TS: - getLocalMinMax(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3); - getLocalMins(lMinX1, lMinX2, lMinX3, oMinX1, oMinX2, oMinX3); - lMinX2 = 1; - lMaxX2 = lMinX2 + 5; - lMinX3 = maxX3-7; - lMaxX3 = lMinX3 + 1; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX2 = 5; - lMaxX2 = lMinX2 + 1; - lMinX3 = maxX3-7; - lMaxX3 = lMinX3 + 5; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - //TNE - case TNE: - lMinX1 = maxX1-7; - lMaxX1 = maxX1-6; - lMinX2 = maxX2-7; - lMaxX2 = maxX2-2; - lMinX3 = maxX3-7; - lMaxX3 = maxX3-2; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = maxX1-7; - lMaxX1 = maxX1-2; - lMinX2 = maxX2-7; - lMaxX2 = maxX2-6; - lMinX3 = maxX3-7; - lMaxX3 = maxX3-2; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = maxX1-7; - lMaxX1 = maxX1-2; - lMinX2 = maxX2-7; - lMaxX2 = maxX2-2; - lMinX3 = maxX3-7; - lMaxX3 = maxX3-6; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - - //TNW - case TNW: - lMinX1 = 5; - lMaxX1 = 6; - lMinX2 = maxX2-7; - lMaxX2 = maxX2-2; - lMinX3 = maxX3-7; - lMaxX3 = maxX3-2; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = 1; - lMaxX1 = 6; - lMinX2 = maxX2-7; - lMaxX2 = maxX2-6; - lMinX3 = maxX3-7; - lMaxX3 = maxX3-2; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = 1; - lMaxX1 = 6; - lMinX2 = maxX2-7; - lMaxX2 = maxX2-2; - lMinX3 = maxX3-7; - lMaxX3 = maxX3-6; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - break; - - // TSE - case TSE: - lMinX1 = maxX1-7; - lMaxX1 = maxX1-6; - lMinX2 = 1; - lMaxX2 = 6; - lMinX3 = maxX3-7; - lMaxX3 = maxX3-2; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = maxX1-7; - lMaxX1 = maxX1-2; - lMinX2 = 5; - lMaxX2 = 6; - lMinX3 = maxX3-7; - lMaxX3 = maxX3-2; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = maxX1-7; - lMaxX1 = maxX1-2; - lMinX2 = 1; - lMaxX2 = 6; - lMinX3 = maxX3-7; - lMaxX3 = maxX3-6; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - break; - // TSW - case TSW: - lMinX1 = 5; - lMaxX1 = 6; - lMinX2 = 1; - lMaxX2 = 6; - lMinX3 = maxX3-7; - lMaxX3 = maxX3-2; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = 1; - lMaxX1 = 6; - lMinX2 = 5; - lMaxX2 = 6; - lMinX3 = maxX3-7; - lMaxX3 = maxX3-2; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = 1; - lMaxX1 = 6; - lMinX2 = 1; - lMaxX2 = 6; - lMinX3 = maxX3-7; - lMaxX3 = maxX3-6; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - break; - // BNE - case BNE: - lMinX1 = maxX1-7; - lMaxX1 = maxX1-6; - lMinX2 = maxX2-7; - lMaxX2 = maxX2-2; - lMinX3 = 1; - lMaxX3 = 6; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = maxX1-7; - lMaxX1 = maxX1-2; - lMinX2 = maxX2-7; - lMaxX2 = maxX2-6; - lMinX3 = 1; - lMaxX3 = 6; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = maxX1-7; - lMaxX1 = maxX1-2; - lMinX2 = maxX2-7; - lMaxX2 = maxX2-2; - lMinX3 = 5; - lMaxX3 = 6; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - break; - // BNW - case BNW: - lMinX1 = 5; - lMaxX1 = 6; - lMinX2 = maxX2-7; - lMaxX2 = maxX2-2; - lMinX3 = 1; - lMaxX3 = 6; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = 1; - lMaxX1 = 6; - lMinX2 = maxX2-7; - lMaxX2 = maxX2-6; - lMinX3 = 1; - lMaxX3 = 6; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = 1; - lMaxX1 = 6; - lMinX2 = maxX2-7; - lMaxX2 = maxX2-2; - lMinX3 = 5; - lMaxX3 = 6; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - break; - - - // BSE - case BSE: - lMinX1 = maxX1-7; - lMaxX1 = maxX1-6; - lMinX2 = 1; - lMaxX2 = 6; - lMinX3 = 1; - lMaxX3 = 6; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = maxX1-7; - lMaxX1 = maxX1-2; - lMinX2 = 5; - lMaxX2 = 6; - lMinX3 = 1; - lMaxX3 = 6; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = maxX1-7; - lMaxX1 = maxX1-2; - lMinX2 = 1; - lMaxX2 = 6; - lMinX3 = 5; - lMaxX3 = 6; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - break; - - //BSW - case BSW: - lMinX1 = 5; - lMaxX1 = 6; - lMinX2 = 1; - lMaxX2 = 6; - lMinX3 = 1; - lMaxX3 = 6; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = 1; - lMaxX1 = 6; - lMinX2 = 5; - lMaxX2 = 6; - lMinX3 = 1; - lMaxX3 = 6; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - lMinX1 = 1; - lMaxX1 = 6; - lMinX2 = 1; - lMaxX2 = 6; - lMinX3 = 5; - lMaxX3 = 6; - fillSendVector(fFrom, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - - break; - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETFCOffVectorConnector< VectorTransmitter>::fillSendVector(SPtr<DistributionArray3D> fFrom, const int& lMinX1, const int& lMinX2, const int& lMinX3, const int& lMaxX1, const int& lMaxX2, const int& lMaxX3, vector_type& data, int& index) -{ - int ix1, ix2, ix3; - LBMReal xoff, yoff, zoff; - SPtr<BCArray3D> bcArray = block.lock()->getKernel()->getBCProcessor()->getBCArray(); - - for (ix3=lMinX3; ix3<lMaxX3; ix3+=2) - { - for (ix2=lMinX2; ix2<lMaxX2; ix2+=2) - { - for (ix1=lMinX1; ix1<lMaxX1; ix1+=2) - { - LBMReal icellC[27]; - D3Q27ICell icellF; - - int howManySolids= iprocessor->iCellHowManySolids(bcArray, ix1, ix2, ix3); - - if(howManySolids == 0 || howManySolids == 8) - { - iprocessor->readICell(fFrom, icellF, ix1, ix2, ix3); - xoff=0.0; - yoff=0.0; - zoff=0.0; - } - else - { - if(!iprocessor->findNeighborICell(bcArray, fFrom, icellF, bMaxX1, bMaxX2, bMaxX3, ix1, ix2, ix3, xoff, yoff, zoff)) - { - std::string err = "For "+block.lock()->toString()+" x1="+UbSystem::toString(ix1)+", x2=" + UbSystem::toString(ix2)+", x3=" + UbSystem::toString(ix3)+ - " 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"; - //UBLOG(logINFO, err); - UB_THROW(UbException(UB_EXARGS, err)); - } - } - - iprocessor->interpolateFineToCoarse(icellF, icellC, xoff, yoff, zoff); - this->writeICellCtoData(data, index, icellC); - } - } - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETFCOffVectorConnector< VectorTransmitter>::writeICellCtoData(vector_type& data, int& index, LBMReal* icellC) -{ - for (int i = D3Q27System::STARTF; i < D3Q27System::ENDF+1; i++) - { - data[index++] = icellC[i]; - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETFCOffVectorConnector< VectorTransmitter>::getLocalMinMaxCF(int gMax, int& lMin, int& lMax) -{ - if (Utilities::isOdd(gMax)) - { - if(connType == OddEvenSE || connType == OddOddNE) - { - lMin = 1; - lMax = gMax; - } - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETFCOffVectorConnector< VectorTransmitter>::distributeReceiveVectors() -{ - using namespace D3Q27System; - - SPtr<DistributionArray3D> fTo = block.lock()->getKernel()->getDataSet()->getFdistributions(); - int maxX1 = (int)fTo->getNX1(); - int maxX2 = (int)fTo->getNX2(); - int maxX3 = (int)fTo->getNX3(); - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3; - int index = 0; - vector_type& data = receiver->getData(); - - lMinX1 = minX1; lMinX2 = minX2; lMinX3 = minX3; - lMaxX1 = maxX1-1; lMaxX2 = maxX2-1; lMaxX3 = maxX3-1; - - switch(sendDir) - { - case E: - lMinX1 = maxX1-4; - lMaxX1 = lMinX1 + 1; - getLocalMinMaxCF(maxX2, lMinX2, lMaxX2); - getLocalMinMaxCF(maxX3, lMinX3, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - case W: - /////////////////////////////////////// - ///DEBUG - //if (block.lock()->getGlobalID() == 2554) - //{ - // int test = 0; - //} - ////////////// - lMinX1 = 2; - lMaxX1 = lMinX1 + 1; - getLocalMinMaxCF(maxX2, lMinX2, lMaxX2); - getLocalMinMaxCF(maxX3, lMinX3, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - case N: - lMinX2 = maxX2-4; - lMaxX2 = lMinX2 + 1; - getLocalMinMaxCF(maxX1, lMinX1, lMaxX1); - getLocalMinMaxCF(maxX3, lMinX3, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - case S: - lMinX2 = 2; - lMaxX2 = lMinX2 + 1; - getLocalMinMaxCF(maxX1, lMinX1, lMaxX1); - getLocalMinMaxCF(maxX3, lMinX3, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - case T: - lMinX3 = maxX3-4; - lMaxX3 = lMinX3 + 1; - getLocalMinMaxCF(maxX1, lMinX1, lMaxX1); - getLocalMinMaxCF(maxX2, lMinX2, lMaxX2); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - case B: - lMinX3 = 2; - lMaxX3 = lMinX3 + 1; - getLocalMinMaxCF(maxX1, lMinX1, lMaxX1); - getLocalMinMaxCF(maxX2, lMinX2, lMaxX2); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - /////E-W-N-S - case NE: - lMinX1 = maxX1-4; - lMaxX1 = lMinX1 + 3; - lMinX2 = maxX2-4; - lMaxX2 = lMinX2 + 3; - getLocalMinMaxCF(maxX3, lMinX3, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - case SW: - lMinX1 = 0; - lMaxX1 = lMinX1 + 3; - lMinX2 = 0; - lMaxX2 = lMinX2 + 3; - getLocalMinMaxCF(maxX3, lMinX3, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - case SE: - lMinX1 = maxX1-4; - lMaxX1 = lMinX1 + 3; - lMinX2 = 0; - lMaxX2 = lMinX2 + 3; - getLocalMinMaxCF(maxX3, lMinX3, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - case NW: - lMinX1 = 0; - lMaxX1 = lMinX1 + 3; - lMinX2 = maxX2-4; - lMaxX2 = lMinX2 + 3; - getLocalMinMaxCF(maxX3, lMinX3, lMaxX3); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - // - // /////T-B-E-W - case TE: - lMinX1 = maxX1-4; - lMaxX1 = lMinX1 + 3; - lMinX3 = maxX3-4; - lMaxX3 = lMinX3 + 3; - getLocalMinMaxCF(maxX2, lMinX2, lMaxX2); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - case BW: - lMinX1 = 0; - lMaxX1 = lMinX1 + 3; - lMinX3 = 0; - lMaxX3 = lMinX3 + 3; - getLocalMinMaxCF(maxX2, lMinX2, lMaxX2); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - case BE: - lMinX1 = maxX1-4; - lMaxX1 = lMinX1 + 3; - lMinX3 = 0; - lMaxX3 = lMinX3 + 3; - getLocalMinMaxCF(maxX2, lMinX2, lMaxX2); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - case TW: - lMinX1 = 0; - lMaxX1 = lMinX1 + 3; - lMinX3 = maxX3-4; - lMaxX3 = lMinX3 + 3; - getLocalMinMaxCF(maxX2, lMinX2, lMaxX2); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - // ////////////////T-B-N-S - // - case TN: - lMinX2 = maxX2-4; - lMaxX2 = lMinX2 + 3; - lMinX3 = maxX3-4; - lMaxX3 = lMinX3 + 3; - getLocalMinMaxCF(maxX1, lMinX1, lMaxX1); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - case BS: - lMinX2 = 0; - lMaxX2 = lMinX2 + 3; - lMinX3 = 0; - lMaxX3 = lMinX3 + 3; - getLocalMinMaxCF(maxX1, lMinX1, lMaxX1); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - case BN: - lMinX2 = maxX2-4; - lMaxX2 = lMinX2 + 3; - lMinX3 = 0; - lMaxX3 = lMinX3 + 3; - getLocalMinMaxCF(maxX1, lMinX1, lMaxX1); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - case TS: - lMinX2 = 0; - lMaxX2 = lMinX2 + 3; - lMinX3 = maxX3-4; - lMaxX3 = lMinX3 + 3; - getLocalMinMaxCF(maxX1, lMinX1, lMaxX1); - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - - // //TNE - case TNE: - lMinX1 = maxX1-4; - lMaxX1 = maxX1-1; - lMinX2 = maxX2-4; - lMaxX2 = maxX2-1; - lMinX3 = maxX3-4; - lMaxX3 = maxX3-1; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - // TNW - case TNW: - lMinX1 = 0; - lMaxX1 = 3; - lMinX2 = maxX2-4; - lMaxX2 = maxX2-1; - lMinX3 = maxX3-4; - lMaxX3 = maxX3-1; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - // TSE - case TSE: - lMinX1 = maxX1-4; - lMaxX1 = maxX1-1; - lMinX2 = 0; - lMaxX2 = 3; - lMinX3 = maxX3-4; - lMaxX3 = maxX3-1; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - // TSW - case TSW: - lMinX1 = 0; - lMaxX1 = 3; - lMinX2 = 0; - lMaxX2 = 3; - lMinX3 = maxX3-4; - lMaxX3 = maxX3-1; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - // BNE - case BNE: - lMinX1 = maxX1-4; - lMaxX1 = maxX1-1; - lMinX2 = maxX2-4; - lMaxX2 = maxX2-1; - lMinX3 = 0; - lMaxX3 = 3; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - // BNW - case BNW: - lMinX1 = 0; - lMaxX1 = 3; - lMinX2 = maxX2-4; - lMaxX2 = maxX2-1; - lMinX3 = 0; - lMaxX3 = 3; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - // BSE - case BSE: - lMinX1 = maxX1-4; - lMaxX1 = maxX1-1; - lMinX2 = 0; - lMaxX2 = 3; - lMinX3 = 0; - lMaxX3 = 3; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - //BSW - case BSW: - lMinX1 = 0; - lMaxX1 = 3; - lMinX2 = 0; - lMaxX2 = 3; - lMinX3 = 0; - lMaxX3 = 3; - distributeReceiveVector(fTo, lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, data, index); - break; - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETFCOffVectorConnector< VectorTransmitter>::distributeReceiveVector(SPtr<DistributionArray3D> fTo, const int& lMinX1, const int& lMinX2, const int& lMinX3, const int& lMaxX1, const int& lMaxX2, const int& lMaxX3, vector_type& data, int& index) -{ - if(data.size() == 0) return; - - int ix1, ix2, ix3; - for (ix3=lMinX3; ix3<lMaxX3; ix3+=2) - { - for (ix2=lMinX2; ix2<lMaxX2; ix2+=2) - { - for (ix1=lMinX1; ix1<lMaxX1; ix1+=2) - { - D3Q27ICell icellF; - this->readICellFfromData(data, index, icellF); - iprocessor->writeICellInv(fTo, icellF, ix1, ix2, ix3); - } - } - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETFCOffVectorConnector< VectorTransmitter>::readICellFfromData(vector_type& data, int& index, D3Q27ICell& icellF) -{ - readNodeFromVector(data, index, icellF.BSW); - readNodeFromVector(data, index, icellF.BSE); - readNodeFromVector(data, index, icellF.BNW); - readNodeFromVector(data, index, icellF.BNE); - readNodeFromVector(data, index, icellF.TSW); - readNodeFromVector(data, index, icellF.TSE); - readNodeFromVector(data, index, icellF.TNW); - readNodeFromVector(data, index, icellF.TNE); -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETFCOffVectorConnector< VectorTransmitter>::readNodeFromVector(vector_type& data, int& index, LBMReal* inode) -{ - for (int i = D3Q27System::STARTF; i < D3Q27System::ENDF+1; i++) - { - inode[i] = data[index++]; - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETFCOffVectorConnector< VectorTransmitter>::getLocalMinMax(int& minX1, int& minX2, int& minX3, int& maxX1, int& maxX2, int& maxX3) -{ - using namespace D3Q27System; - int TminX1=minX1; int TminX2=minX2; int TminX3=minX3; int TmaxX1=maxX1; int TmaxX2=maxX2; int TmaxX3=maxX3; - - if(block.lock()->hasInterpolationFlagFC(E)) - { - if (maxX1==TmaxX1) maxX1 -= 3; - } - if(block.lock()->hasInterpolationFlagFC(W)) - { - if (minX1==TminX1) minX1 += 4; - } - if(block.lock()->hasInterpolationFlagFC(N)) - { - if (maxX2==TmaxX2) maxX2 -= 3; - } - if(block.lock()->hasInterpolationFlagFC(S)) - { - if (minX2==TminX2) minX2 += 4; - } - if(block.lock()->hasInterpolationFlagFC(T)) - { - if (maxX3==TmaxX3) maxX3 -= 3; - } - if(block.lock()->hasInterpolationFlagFC(B)) - { - if (minX3==TminX3) minX3 += 4; - } - - //////////// - /////E-W-N-S - if(block.lock()->hasInterpolationFlagFC(NE)&& !block.lock()->hasInterpolationFlagFC(N) && !block.lock()->hasInterpolationFlagFC(E)) - { - if (maxX1==TmaxX1) maxX1 -= 3; - if (maxX2==TmaxX2) maxX2 -= 3; - } - if(block.lock()->hasInterpolationFlagFC(SW)&& !block.lock()->hasInterpolationFlagFC(W) && !block.lock()->hasInterpolationFlagFC(S)) - { - if (minX1==TminX1) minX1 += 4; - if (minX2==TminX2) minX2 += 4; - } - if(block.lock()->hasInterpolationFlagFC(SE)&& !block.lock()->hasInterpolationFlagFC(E) && !block.lock()->hasInterpolationFlagFC(S)) - { - if (maxX1==TmaxX1) maxX1 -= 3; - if (minX2==TminX2) minX2 += 4; - } - if(block.lock()->hasInterpolationFlagFC(NW)&& !block.lock()->hasInterpolationFlagFC(N) && !block.lock()->hasInterpolationFlagFC(W)) - { - if (minX1==TminX1) minX1 += 4; - if (maxX2==TmaxX2) maxX2 -= 3; - } - - //////T-B-E-W - if(block.lock()->hasInterpolationFlagFC(TE) && !block.lock()->hasInterpolationFlagFC(E) && !block.lock()->hasInterpolationFlagFC(T)) - { - if (maxX1==TmaxX1) maxX1 -= 3; - if (maxX3==TmaxX3) maxX3 -= 3; - } - if(block.lock()->hasInterpolationFlagFC(BW)&& !block.lock()->hasInterpolationFlagFC(W) && !block.lock()->hasInterpolationFlagFC(B)) - { - if (minX1==TminX1) minX1 += 4; - if (minX3==TminX3) minX3 += 4; - } - if(block.lock()->hasInterpolationFlagFC(BE)&& !block.lock()->hasInterpolationFlagFC(E) && !block.lock()->hasInterpolationFlagFC(B)) - { - if (maxX1==TmaxX1) maxX1 -= 3; - if (minX3==TminX3) minX3 += 4; - } - if(block.lock()->hasInterpolationFlagFC(TW)&& !block.lock()->hasInterpolationFlagFC(W) && !block.lock()->hasInterpolationFlagFC(T)) - { - if (minX1==TminX1) minX1 += 4; - if (maxX3==TmaxX3) maxX3 -= 3; - } - - - ////T-B-N-S - if(block.lock()->hasInterpolationFlagFC(TN)&& !block.lock()->hasInterpolationFlagFC(N) && !block.lock()->hasInterpolationFlagFC(T)) - { - if (maxX2==TmaxX2) maxX2 -= 3; - if (maxX3==TmaxX3) maxX3 -= 3; - } - if(block.lock()->hasInterpolationFlagFC(BS)&& !block.lock()->hasInterpolationFlagFC(S) && !block.lock()->hasInterpolationFlagFC(B)) - { - if (minX2==TminX2) minX2 += 4; - if (minX3==TminX3) minX3 += 4; - } - if(block.lock()->hasInterpolationFlagFC(BN)&& !block.lock()->hasInterpolationFlagFC(N) && !block.lock()->hasInterpolationFlagFC(B)) - { - if (maxX2==TmaxX2) maxX2 -= 3; - if (minX3==TminX3) minX3 += 4; - } - if(block.lock()->hasInterpolationFlagFC(TS) && !block.lock()->hasInterpolationFlagFC(S) && !block.lock()->hasInterpolationFlagFC(T)) - { - if (minX2==TminX2) minX2 += 4; - if (maxX3==TmaxX3) maxX3 -= 3; - } - - //if (block.lock()->hasInterpolationFlagFC(D3Q27System::TNE)&&!block.lock()->hasInterpolationFlagFC(D3Q27System::TE)&&!block.lock()->hasInterpolationFlagFC(D3Q27System::TN)&&!block.lock()->hasInterpolationFlagFC(D3Q27System::NE)&&!block.lock()->hasInterpolationFlagFC(D3Q27System::T)&&!block.lock()->hasInterpolationFlagFC(D3Q27System::N) && !block.lock()->hasInterpolationFlagFC(D3Q27System::E)) - //if (!block.lock()->hasInterpolationFlagFC(D3Q27System::TE)&&!block.lock()->hasInterpolationFlagFC(D3Q27System::T) && !block.lock()->hasInterpolationFlagFC(D3Q27System::E)) - //{ - // if (maxX1==TmaxX1) maxX1 -= 3; - // if (maxX2==TmaxX2) maxX2 -= 3; - // if (maxX3==TmaxX3) maxX3 -= 3; - //} -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETFCOffVectorConnector< VectorTransmitter>::getLocalMinMax(int& minX1, int& minX2, int& minX3, int& maxX1, int& maxX2, int& maxX3, CFconnectorType connType) -{ - using namespace D3Q27System; - int TminX1 = minX1; int TminX2 = minX2; int TminX3 = minX3; int TmaxX1 = maxX1; int TmaxX2 = maxX2; int TmaxX3 = maxX3; - - if (block.lock()->hasInterpolationFlagFC(E)) - { - if (maxX1==TmaxX1) maxX1 -= 3; - } - if (block.lock()->hasInterpolationFlagFC(W)) - { - if (minX1==TminX1) minX1 += 4; - } - if (block.lock()->hasInterpolationFlagFC(N)) - { - if (maxX2==TmaxX2) maxX2 -= 3; - } - if (block.lock()->hasInterpolationFlagFC(S)) - { - if (minX2==TminX2) minX2 += 4; - } - if (block.lock()->hasInterpolationFlagFC(T)) - { - if (maxX3==TmaxX3) maxX3 -= 3; - } - if (block.lock()->hasInterpolationFlagFC(B)) - { - if (minX3==TminX3) minX3 += 4; - } - - //////////// - /////E-W-N-S - if (block.lock()->hasInterpolationFlagFC(NE)&& !block.lock()->hasInterpolationFlagFC(N) && !block.lock()->hasInterpolationFlagFC(E)) - { - if (maxX1==TmaxX1) maxX1 -= 3; - if (maxX2==TmaxX2) maxX2 -= 3; - } - if (block.lock()->hasInterpolationFlagFC(SW)&& !block.lock()->hasInterpolationFlagFC(W) && !block.lock()->hasInterpolationFlagFC(S)) - { - if (minX1==TminX1) minX1 += 4; - if (minX2==TminX2) minX2 += 4; - } - if (block.lock()->hasInterpolationFlagFC(SE)&& !block.lock()->hasInterpolationFlagFC(E) && !block.lock()->hasInterpolationFlagFC(S)) - { - if (maxX1==TmaxX1) maxX1 -= 3; - if (minX2==TminX2) minX2 += 4; - } - if (block.lock()->hasInterpolationFlagFC(NW)&& !block.lock()->hasInterpolationFlagFC(N) && !block.lock()->hasInterpolationFlagFC(W)) - { - if (minX1==TminX1) minX1 += 4; - if (maxX2==TmaxX2) maxX2 -= 3; - } - - //////T-B-E-W - if (block.lock()->hasInterpolationFlagFC(TE) && !block.lock()->hasInterpolationFlagFC(E) && !block.lock()->hasInterpolationFlagFC(T)) - { - if (maxX1==TmaxX1) maxX1 -= 3; - if (maxX3==TmaxX3) maxX3 -= 3; - } - if (block.lock()->hasInterpolationFlagFC(BW)&& !block.lock()->hasInterpolationFlagFC(W) && !block.lock()->hasInterpolationFlagFC(B)) - { - if (minX1==TminX1) minX1 += 4; - if (minX3==TminX3) minX3 += 4; - } - if (block.lock()->hasInterpolationFlagFC(BE)&& !block.lock()->hasInterpolationFlagFC(E) && !block.lock()->hasInterpolationFlagFC(B)) - { - if (maxX1==TmaxX1) maxX1 -= 3; - if (minX3==TminX3) minX3 += 4; - } - if (block.lock()->hasInterpolationFlagFC(TW)&& !block.lock()->hasInterpolationFlagFC(W) && !block.lock()->hasInterpolationFlagFC(T)) - { - if (minX1==TminX1) minX1 += 4; - if (maxX3==TmaxX3) maxX3 -= 3; - } - - - ////T-B-N-S - if (block.lock()->hasInterpolationFlagFC(TN)&& !block.lock()->hasInterpolationFlagFC(N) && !block.lock()->hasInterpolationFlagFC(T)) - { - if (maxX2==TmaxX2) maxX2 -= 3; - if (maxX3==TmaxX3) maxX3 -= 3; - } - if (block.lock()->hasInterpolationFlagFC(BS)&& !block.lock()->hasInterpolationFlagFC(S) && !block.lock()->hasInterpolationFlagFC(B)) - { - if (minX2==TminX2) minX2 += 4; - if (minX3==TminX3) minX3 += 4; - } - if (block.lock()->hasInterpolationFlagFC(BN)&& !block.lock()->hasInterpolationFlagFC(N) && !block.lock()->hasInterpolationFlagFC(B)) - { - if (maxX2==TmaxX2) maxX2 -= 3; - if (minX3==TminX3) minX3 += 4; - } - if (block.lock()->hasInterpolationFlagFC(TS) && !block.lock()->hasInterpolationFlagFC(S) && !block.lock()->hasInterpolationFlagFC(T)) - { - if (minX2==TminX2) minX2 += 4; - if (maxX3==TmaxX3) maxX3 -= 3; - } - - //if (block.lock()->hasInterpolationFlagFC(D3Q27System::TNE)&&!block.lock()->hasInterpolationFlagFC(D3Q27System::TE)&&!block.lock()->hasInterpolationFlagFC(D3Q27System::TN)&&!block.lock()->hasInterpolationFlagFC(D3Q27System::NE)&&!block.lock()->hasInterpolationFlagFC(D3Q27System::T)&&!block.lock()->hasInterpolationFlagFC(D3Q27System::N) && !block.lock()->hasInterpolationFlagFC(D3Q27System::E)) - //{ - // if (maxX1==TmaxX1) maxX1 -= 3; - // if (maxX2==TmaxX2) maxX2 -= 3; - // if (maxX3==TmaxX3) maxX3 -= 3; - //} -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETFCOffVectorConnector< VectorTransmitter>::getLocalOffsets(const int& gMax, int& oMin) -{ - if (Utilities::isEven(gMax)) - { - oMin = 0; - } - if (Utilities::isOdd(gMax)) - { - oMin = -1; - } - -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -void D3Q27ETFCOffVectorConnector< VectorTransmitter>::getLocalMins(int& minX1, int& minX2, int& minX3, const int& oMinX1, const int& oMinX2, const int& oMinX3) -{ - using namespace D3Q27System; - - switch(sendDir) - { - case E: case W: - if(connType == OddEvenSE) - minX2 += oMinX2; - if(connType == OddOddNE) - { - minX2 += oMinX2; - minX3 += oMinX3; - } - if(connType == EvenOddNW) - minX3 += oMinX3; - break; - case N: case S: - if(connType == OddEvenSE) - minX1 += oMinX1; - if(connType == OddOddNE) - { - minX1 += oMinX1; - minX3 += oMinX3; - } - if(connType == EvenOddNW) - minX3 += oMinX3; - break; - case T: case B: - if(connType == OddEvenSE) - minX1 += oMinX1; - if(connType == OddOddNE) - { - minX1 += oMinX1; - minX2 += oMinX2; - } - if(connType == EvenOddNW) - minX2 += oMinX2; - break; - - ///// - case NE: case SW: case SE: case NW: - //case SW: - if(connType == OddEvenSE) - //minX2 += oMinX2; - if(connType == OddOddNE) - { - //minX2 += oMinX2; - minX3 += oMinX3; - } - if(connType == EvenOddNW) - minX3 += oMinX3; - break; - - ////// - case TE: case BW: case BE: case TW: - if(connType == OddEvenSE) - // minX1 += oMinX1; - if(connType == OddOddNE) - { - // minX1 += oMinX1; - minX2 += oMinX2; - } - if(connType == EvenOddNW) - minX2 += oMinX2; - break; - - // ////// - case TN: case BS: case BN: case TS: - if(connType == OddEvenSE) - minX1 += oMinX1; - if(connType == OddOddNE) - { - minX1 += oMinX1; - //minX3 += oMinX3; - } - if(connType == EvenOddNW) - //minX3 += oMinX3; - break; - - // ///// - // case TNE: case TNW: case TSE: case TSW: case BNE: case BNW: case BSE: case BSW: - // if(connType == OddEvenSE) - // // minX1 += oMinX1; - // if(connType == OddOddNE) - // { - // //minX1 += oMinX1; - // //minX3 += oMinX3; - // } - // if(connType == EvenOddNW) - // //minX3 += oMinX3; - // break; - } -} -////////////////////////////////////////////////////////////////////////// -template< typename VectorTransmitter > -double D3Q27ETFCOffVectorConnector<VectorTransmitter>::getSendRecieveTime() -{ - return 0; -} - -#endif diff --git a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFullDirectConnector.cpp b/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFullDirectConnector.cpp index 19c579993..26802ce3f 100644 --- a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFullDirectConnector.cpp +++ b/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFullDirectConnector.cpp @@ -1,210 +1,243 @@ -#include "D3Q27ETFullDirectConnector.h" -#include "LBMKernel.h" -#include "D3Q27EsoTwist3DSplittedVector.h" -#include "DataSet3D.h" - -using namespace std; - -D3Q27ETFullDirectConnector::D3Q27ETFullDirectConnector(SPtr<Block3D> from, SPtr<Block3D> to, int sendDir) - : LocalBlock3DConnector(from, to, sendDir) - -{ - -} -////////////////////////////////////////////////////////////////////////// -void D3Q27ETFullDirectConnector::init() -{ - maxX1 = (int)this->from.lock()->getKernel()->getDataSet()->getFdistributions()->getNX1() - 1; - maxX2 = (int)this->from.lock()->getKernel()->getDataSet()->getFdistributions()->getNX2() - 1; - maxX3 = (int)this->from.lock()->getKernel()->getDataSet()->getFdistributions()->getNX3() - 1; - - fFrom = dynamicPointerCast<EsoTwist3D>(from.lock()->getKernel()->getDataSet()->getFdistributions()); - fTo = dynamicPointerCast<EsoTwist3D>(to.lock()->getKernel()->getDataSet()->getFdistributions()); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27ETFullDirectConnector::sendVectors() -{ - localDistributionsFrom = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fFrom)->getLocalDistributions(); - nonLocalDistributionsFrom = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fFrom)->getNonLocalDistributions(); - zeroDistributionsFrom = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fFrom)->getZeroDistributions(); - - localDistributionsTo = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fTo)->getLocalDistributions(); - nonLocalDistributionsTo = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fTo)->getNonLocalDistributions(); - zeroDistributionsTo = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fTo)->getZeroDistributions(); - - //EAST - if (sendDir == D3Q27System::E) - { - for (int x3 = 1; x3 < maxX3; x3++) - { - for (int x2 = 1; x2 < maxX2; x2++) - { - exchangeData(maxX1 - 1, x2, x3, 0, x2, x3); - } - } - } - //WEST - else if (sendDir == D3Q27System::W) - { - for (int x3 = 1; x3 < maxX3; x3++) - { - for (int x2 = 1; x2 < maxX2; x2++) - { - exchangeData(1, x2, x3, maxX1, x2, x3); - } - } - } - //NORTH - else if (sendDir == D3Q27System::N) - { - for (int x3 = 1; x3 < maxX3; x3++) - { - for (int x1 = 1; x1 < maxX1; x1++) - { - exchangeData(x1, maxX2 - 1, x3, x1, 0, x3); - } - } - } - //SOUTH - else if (sendDir == D3Q27System::S) - { - for (int x3 = 1; x3 < maxX3; x3++) - { - for (int x1 = 1; x1 < maxX1; x1++) - { - exchangeData(x1, 1, x3, x1, maxX2, x3); - } - } - } - - //TOP - else if (sendDir == D3Q27System::T) - { - for (int x2 = 1; x2 < maxX2; x2++) - { - for (int x1 = 1; x1 < maxX1; x1++) - { - exchangeData(x1, x2, maxX3 - 1, x1, x2, 0); - } - } - } - //BOTTOM - else if (sendDir == D3Q27System::B) - { - for (int x2 = 1; x2 < maxX2; x2++) - { - for (int x1 = 1; x1 < maxX1; x1++) - { - exchangeData(x1, x2, 1, x1, x2, maxX3); - } - } - } - //NORTHEAST - else if (sendDir == D3Q27System::NE) - { - for (int x3 = 1; x3 < maxX3; x3++) - { - exchangeData(maxX1 - 1, maxX2 - 1, x3, 0, 0, x3); - } - } - //NORTHWEST - else if (sendDir == D3Q27System::NW) - { - for (int x3 = 1; x3 < maxX3; x3++) - { - exchangeData(1, maxX2 - 1, x3, maxX1, 0, x3); - } - } - //SOUTHWEST - else if (sendDir == D3Q27System::SW) - { - for (int x3 = 1; x3 < maxX3; x3++) - { - exchangeData(1, 1, x3, maxX1, maxX2, x3); - } - } - //SOUTHEAST - else if (sendDir == D3Q27System::SE) - { - for (int x3 = 1; x3 < maxX3; x3++) - { - exchangeData(maxX1 - 1, 1, x3, 0, maxX2, x3); - } - } - else if (sendDir == D3Q27System::TE) - for (int x2 = 1; x2 < maxX2; x2++) - { - exchangeData(maxX1 - 1, x2, maxX3 - 1, 0, x2, 0); - } - else if (sendDir == D3Q27System::BW) - for (int x2 = 1; x2 < maxX2; x2++) - { - exchangeData(1, x2, 1, maxX1, x2, maxX3); - } - else if (sendDir == D3Q27System::BE) - for (int x2 = 1; x2 < maxX2; x2++) - { - exchangeData(maxX1 - 1, x2, 1, 0, x2, maxX3); - } - else if (sendDir == D3Q27System::TW) - for (int x2 = 1; x2 < maxX2; x2++) - { - exchangeData(1, x2, maxX3 - 1, maxX1, x2, 0); - } - else if (sendDir == D3Q27System::TN) - for (int x1 = 1; x1 < maxX1; x1++) - { - exchangeData(x1, maxX2 - 1, maxX3 - 1, x1, 0, 0); - } - else if (sendDir == D3Q27System::BS) - for (int x1 = 1; x1 < maxX1; x1++) - { - exchangeData(x1, 1, 1, x1, maxX2, maxX3); - } - else if (sendDir == D3Q27System::BN) - for (int x1 = 1; x1 < maxX1; x1++) - { - exchangeData(x1, maxX2 - 1, 1, x1, 0, maxX3); - } - - else if (sendDir == D3Q27System::TS) - for (int x1 = 1; x1 < maxX1; x1++) - { - exchangeData(x1, 1, maxX3 - 1, x1, maxX2, 0); - } - - else if (sendDir == D3Q27System::TSW) - { - exchangeData(1, 1, maxX3 - 1, maxX1, maxX2, 0); - } - else if (sendDir == D3Q27System::TSE) - { - exchangeData(maxX1 - 1, 1, maxX3 - 1, 0, maxX2, 0); - } - else if (sendDir == D3Q27System::TNW) - { - exchangeData(1, maxX2 - 1, maxX3 - 1, maxX1, 0, 0); - } - else if (sendDir == D3Q27System::TNE) - { - exchangeData(maxX1 - 1, maxX2 - 1, maxX3 - 1, 0, 0, 0); - } - else if (sendDir == D3Q27System::BSW) - { - exchangeData(1, 1, 1, maxX1, maxX2, maxX3); - } - else if (sendDir == D3Q27System::BSE) - { - exchangeData(maxX1 - 1, 1, 1, 0, maxX2, maxX3); - } - else if (sendDir == D3Q27System::BNW) - { - exchangeData(1, maxX2 - 1, 1, maxX1, 0, maxX3); - } - else if (sendDir == D3Q27System::BNE) - { - exchangeData(maxX1 - 1, maxX2 - 1, 1, 0, 0, maxX3); - } - else UB_THROW(UbException(UB_EXARGS, "unknown dir")); -} - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file D3Q27ETFullDirectConnector.cpp +//! \ingroup Connectors +//! \author Konstantin Kutscher +//======================================================================================= + +#include "D3Q27ETFullDirectConnector.h" +#include "LBMKernel.h" +#include "D3Q27EsoTwist3DSplittedVector.h" +#include "DataSet3D.h" + +using namespace std; + +D3Q27ETFullDirectConnector::D3Q27ETFullDirectConnector(SPtr<Block3D> from, SPtr<Block3D> to, int sendDir) + : LocalBlock3DConnector(from, to, sendDir) + +{ + +} +////////////////////////////////////////////////////////////////////////// +void D3Q27ETFullDirectConnector::init() +{ + maxX1 = (int)this->from.lock()->getKernel()->getDataSet()->getFdistributions()->getNX1() - 1; + maxX2 = (int)this->from.lock()->getKernel()->getDataSet()->getFdistributions()->getNX2() - 1; + maxX3 = (int)this->from.lock()->getKernel()->getDataSet()->getFdistributions()->getNX3() - 1; + + fFrom = dynamic_pointer_cast<EsoTwist3D>(from.lock()->getKernel()->getDataSet()->getFdistributions()); + fTo = dynamic_pointer_cast<EsoTwist3D>(to.lock()->getKernel()->getDataSet()->getFdistributions()); +} +////////////////////////////////////////////////////////////////////////// +void D3Q27ETFullDirectConnector::sendVectors() +{ + localDistributionsFrom = dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(this->fFrom)->getLocalDistributions(); + nonLocalDistributionsFrom = dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(this->fFrom)->getNonLocalDistributions(); + zeroDistributionsFrom = dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(this->fFrom)->getZeroDistributions(); + + localDistributionsTo = dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(this->fTo)->getLocalDistributions(); + nonLocalDistributionsTo = dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(this->fTo)->getNonLocalDistributions(); + zeroDistributionsTo = dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(this->fTo)->getZeroDistributions(); + + //EAST + if (sendDir == D3Q27System::E) + { + for (int x3 = 1; x3 < maxX3; x3++) + { + for (int x2 = 1; x2 < maxX2; x2++) + { + exchangeData(maxX1 - 1, x2, x3, 0, x2, x3); + } + } + } + //WEST + else if (sendDir == D3Q27System::W) + { + for (int x3 = 1; x3 < maxX3; x3++) + { + for (int x2 = 1; x2 < maxX2; x2++) + { + exchangeData(1, x2, x3, maxX1, x2, x3); + } + } + } + //NORTH + else if (sendDir == D3Q27System::N) + { + for (int x3 = 1; x3 < maxX3; x3++) + { + for (int x1 = 1; x1 < maxX1; x1++) + { + exchangeData(x1, maxX2 - 1, x3, x1, 0, x3); + } + } + } + //SOUTH + else if (sendDir == D3Q27System::S) + { + for (int x3 = 1; x3 < maxX3; x3++) + { + for (int x1 = 1; x1 < maxX1; x1++) + { + exchangeData(x1, 1, x3, x1, maxX2, x3); + } + } + } + + //TOP + else if (sendDir == D3Q27System::T) + { + for (int x2 = 1; x2 < maxX2; x2++) + { + for (int x1 = 1; x1 < maxX1; x1++) + { + exchangeData(x1, x2, maxX3 - 1, x1, x2, 0); + } + } + } + //BOTTOM + else if (sendDir == D3Q27System::B) + { + for (int x2 = 1; x2 < maxX2; x2++) + { + for (int x1 = 1; x1 < maxX1; x1++) + { + exchangeData(x1, x2, 1, x1, x2, maxX3); + } + } + } + //NORTHEAST + else if (sendDir == D3Q27System::NE) + { + for (int x3 = 1; x3 < maxX3; x3++) + { + exchangeData(maxX1 - 1, maxX2 - 1, x3, 0, 0, x3); + } + } + //NORTHWEST + else if (sendDir == D3Q27System::NW) + { + for (int x3 = 1; x3 < maxX3; x3++) + { + exchangeData(1, maxX2 - 1, x3, maxX1, 0, x3); + } + } + //SOUTHWEST + else if (sendDir == D3Q27System::SW) + { + for (int x3 = 1; x3 < maxX3; x3++) + { + exchangeData(1, 1, x3, maxX1, maxX2, x3); + } + } + //SOUTHEAST + else if (sendDir == D3Q27System::SE) + { + for (int x3 = 1; x3 < maxX3; x3++) + { + exchangeData(maxX1 - 1, 1, x3, 0, maxX2, x3); + } + } + else if (sendDir == D3Q27System::TE) + for (int x2 = 1; x2 < maxX2; x2++) + { + exchangeData(maxX1 - 1, x2, maxX3 - 1, 0, x2, 0); + } + else if (sendDir == D3Q27System::BW) + for (int x2 = 1; x2 < maxX2; x2++) + { + exchangeData(1, x2, 1, maxX1, x2, maxX3); + } + else if (sendDir == D3Q27System::BE) + for (int x2 = 1; x2 < maxX2; x2++) + { + exchangeData(maxX1 - 1, x2, 1, 0, x2, maxX3); + } + else if (sendDir == D3Q27System::TW) + for (int x2 = 1; x2 < maxX2; x2++) + { + exchangeData(1, x2, maxX3 - 1, maxX1, x2, 0); + } + else if (sendDir == D3Q27System::TN) + for (int x1 = 1; x1 < maxX1; x1++) + { + exchangeData(x1, maxX2 - 1, maxX3 - 1, x1, 0, 0); + } + else if (sendDir == D3Q27System::BS) + for (int x1 = 1; x1 < maxX1; x1++) + { + exchangeData(x1, 1, 1, x1, maxX2, maxX3); + } + else if (sendDir == D3Q27System::BN) + for (int x1 = 1; x1 < maxX1; x1++) + { + exchangeData(x1, maxX2 - 1, 1, x1, 0, maxX3); + } + + else if (sendDir == D3Q27System::TS) + for (int x1 = 1; x1 < maxX1; x1++) + { + exchangeData(x1, 1, maxX3 - 1, x1, maxX2, 0); + } + + else if (sendDir == D3Q27System::TSW) + { + exchangeData(1, 1, maxX3 - 1, maxX1, maxX2, 0); + } + else if (sendDir == D3Q27System::TSE) + { + exchangeData(maxX1 - 1, 1, maxX3 - 1, 0, maxX2, 0); + } + else if (sendDir == D3Q27System::TNW) + { + exchangeData(1, maxX2 - 1, maxX3 - 1, maxX1, 0, 0); + } + else if (sendDir == D3Q27System::TNE) + { + exchangeData(maxX1 - 1, maxX2 - 1, maxX3 - 1, 0, 0, 0); + } + else if (sendDir == D3Q27System::BSW) + { + exchangeData(1, 1, 1, maxX1, maxX2, maxX3); + } + else if (sendDir == D3Q27System::BSE) + { + exchangeData(maxX1 - 1, 1, 1, 0, maxX2, maxX3); + } + else if (sendDir == D3Q27System::BNW) + { + exchangeData(1, maxX2 - 1, 1, maxX1, 0, maxX3); + } + else if (sendDir == D3Q27System::BNE) + { + exchangeData(maxX1 - 1, maxX2 - 1, 1, 0, 0, maxX3); + } + else UB_THROW(UbException(UB_EXARGS, "unknown dir")); +} + diff --git a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFullDirectConnector.h b/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFullDirectConnector.h index 654c7da9b..052ade199 100644 --- a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFullDirectConnector.h +++ b/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFullDirectConnector.h @@ -1,83 +1,107 @@ -/** -* @file D3Q27ETFullDirectConnector.h -* @brief Connector send and receive full distribution in shared memory -* -* @author Konstantin Kutscher -* @date 28.04.2016 -*/ -#ifndef D3Q27ETFULLDIRECTCONNECTOR_H -#define D3Q27ETFULLDIRECTCONNECTOR_H - -#include "LocalBlock3DConnector.h" -#include "Block3D.h" -#include "D3Q27System.h" -#include "basics/container/CbArray3D.h" -#include "basics/container/CbArray4D.h" -#include "EsoTwist3D.h" - -//! \brief Exchange data between blocks. -//! \details Connector send and receive full distributions between two blocks in shared memory. -//! \author Konstantin Kutscher - -class D3Q27ETFullDirectConnector : public LocalBlock3DConnector -{ -public: - D3Q27ETFullDirectConnector(SPtr<Block3D> from, SPtr<Block3D> to, int sendDir); - void init(); - void sendVectors(); - -protected: - inline void exchangeData(int x1From, int x2From, int x3From, int x1To, int x2To, int x3To); -private: - int maxX1; - int maxX2; - int maxX3; - - CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributionsFrom; - CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsFrom; - CbArray3D <LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributionsFrom; - - CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributionsTo; - CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsTo; - CbArray3D <LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributionsTo; - - SPtr<EsoTwist3D> fFrom; - SPtr<EsoTwist3D> fTo; -}; - - -////////////////////////////////////////////////////////////////////////// -inline void D3Q27ETFullDirectConnector::exchangeData(int x1From, int x2From, int x3From, int x1To, int x2To, int x3To) -{ - (*this->localDistributionsTo)(D3Q27System::ET_E, x1To, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_E, x1From, x2From, x3From); - (*this->localDistributionsTo)(D3Q27System::ET_N, x1To, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_N, x1From, x2From, x3From); - (*this->localDistributionsTo)(D3Q27System::ET_T, x1To, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_T, x1From, x2From, x3From); - (*this->localDistributionsTo)(D3Q27System::ET_NE, x1To, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_NE, x1From, x2From, x3From); - (*this->localDistributionsTo)(D3Q27System::ET_NW, x1To + 1, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_NW, x1From + 1, x2From, x3From); - (*this->localDistributionsTo)(D3Q27System::ET_TE, x1To, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_TE, x1From, x2From, x3From); - (*this->localDistributionsTo)(D3Q27System::ET_TW, x1To + 1, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_TW, x1From + 1, x2From, x3From); - (*this->localDistributionsTo)(D3Q27System::ET_TN, x1To, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_TN, x1From, x2From, x3From); - (*this->localDistributionsTo)(D3Q27System::ET_TS, x1To, x2To + 1, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_TS, x1From, x2From + 1, x3From); - (*this->localDistributionsTo)(D3Q27System::ET_TNE, x1To, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_TNE, x1From, x2From, x3From); - (*this->localDistributionsTo)(D3Q27System::ET_TNW, x1To + 1, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_TNW, x1From + 1, x2From, x3From); - (*this->localDistributionsTo)(D3Q27System::ET_TSE, x1To, x2To + 1, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_TSE, x1From, x2From + 1, x3From); - (*this->localDistributionsTo)(D3Q27System::ET_TSW, x1To + 1, x2To + 1, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_TSW, x1From + 1, x2From + 1, x3From); - - (*this->nonLocalDistributionsTo)(D3Q27System::ET_W, x1To + 1, x2To, x3To) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_W, x1From + 1, x2From, x3From); - (*this->nonLocalDistributionsTo)(D3Q27System::ET_S, x1To, x2To + 1, x3To) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_S, x1From, x2From + 1, x3From); - (*this->nonLocalDistributionsTo)(D3Q27System::ET_B, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_B, x1From, x2From, x3From + 1); - (*this->nonLocalDistributionsTo)(D3Q27System::ET_SW, x1To + 1, x2To + 1, x3To) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_SW, x1From + 1, x2From + 1, x3From); - (*this->nonLocalDistributionsTo)(D3Q27System::ET_SE, x1To, x2To + 1, x3To) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_SE, x1From, x2From + 1, x3From); - (*this->nonLocalDistributionsTo)(D3Q27System::ET_BW, x1To + 1, x2To, x3To + 1) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_BW, x1From + 1, x2From, x3From + 1); - (*this->nonLocalDistributionsTo)(D3Q27System::ET_BE, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_BE, x1From, x2From, x3From + 1); - (*this->nonLocalDistributionsTo)(D3Q27System::ET_BS, x1To, x2To + 1, x3To + 1) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_BS, x1From, x2From + 1, x3From + 1); - (*this->nonLocalDistributionsTo)(D3Q27System::ET_BN, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_BN, x1From, x2From, x3From + 1); - (*this->nonLocalDistributionsTo)(D3Q27System::ET_BSW, x1To + 1, x2To + 1, x3To + 1) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_BSW, x1From + 1, x2From + 1, x3From + 1); - (*this->nonLocalDistributionsTo)(D3Q27System::ET_BSE, x1To, x2To + 1, x3To + 1) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_BSE, x1From, x2From + 1, x3From + 1); - (*this->nonLocalDistributionsTo)(D3Q27System::ET_BNW, x1To + 1, x2To, x3To + 1) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_BNW, x1From + 1, x2From, x3From + 1); - (*this->nonLocalDistributionsTo)(D3Q27System::ET_BNE, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_BNE, x1From, x2From, x3From + 1); - - (*this->zeroDistributionsTo)(x1To, x2To, x3To) = (*this->zeroDistributionsFrom)(x1From, x2From, x3From); -} -#endif - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file D3Q27ETFullDirectConnector.h +//! \ingroup Connectors +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef D3Q27ETFULLDIRECTCONNECTOR_H +#define D3Q27ETFULLDIRECTCONNECTOR_H + +#include "LocalBlock3DConnector.h" +#include "Block3D.h" +#include "D3Q27System.h" +#include "basics/container/CbArray3D.h" +#include "basics/container/CbArray4D.h" +#include "EsoTwist3D.h" + +//! \brief Exchange data between blocks. +//! \details Connector send and receive full distributions between two blocks in shared memory. +class D3Q27ETFullDirectConnector : public LocalBlock3DConnector +{ +public: + D3Q27ETFullDirectConnector(SPtr<Block3D> from, SPtr<Block3D> to, int sendDir); + void init(); + void sendVectors(); + +protected: + inline void exchangeData(int x1From, int x2From, int x3From, int x1To, int x2To, int x3To); +private: + int maxX1; + int maxX2; + int maxX3; + + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributionsFrom; + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsFrom; + CbArray3D <LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributionsFrom; + + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributionsTo; + CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributionsTo; + CbArray3D <LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributionsTo; + + SPtr<EsoTwist3D> fFrom; + SPtr<EsoTwist3D> fTo; +}; + + +////////////////////////////////////////////////////////////////////////// +inline void D3Q27ETFullDirectConnector::exchangeData(int x1From, int x2From, int x3From, int x1To, int x2To, int x3To) +{ + (*this->localDistributionsTo)(D3Q27System::ET_E, x1To, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_E, x1From, x2From, x3From); + (*this->localDistributionsTo)(D3Q27System::ET_N, x1To, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_N, x1From, x2From, x3From); + (*this->localDistributionsTo)(D3Q27System::ET_T, x1To, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_T, x1From, x2From, x3From); + (*this->localDistributionsTo)(D3Q27System::ET_NE, x1To, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_NE, x1From, x2From, x3From); + (*this->localDistributionsTo)(D3Q27System::ET_NW, x1To + 1, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_NW, x1From + 1, x2From, x3From); + (*this->localDistributionsTo)(D3Q27System::ET_TE, x1To, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_TE, x1From, x2From, x3From); + (*this->localDistributionsTo)(D3Q27System::ET_TW, x1To + 1, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_TW, x1From + 1, x2From, x3From); + (*this->localDistributionsTo)(D3Q27System::ET_TN, x1To, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_TN, x1From, x2From, x3From); + (*this->localDistributionsTo)(D3Q27System::ET_TS, x1To, x2To + 1, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_TS, x1From, x2From + 1, x3From); + (*this->localDistributionsTo)(D3Q27System::ET_TNE, x1To, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_TNE, x1From, x2From, x3From); + (*this->localDistributionsTo)(D3Q27System::ET_TNW, x1To + 1, x2To, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_TNW, x1From + 1, x2From, x3From); + (*this->localDistributionsTo)(D3Q27System::ET_TSE, x1To, x2To + 1, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_TSE, x1From, x2From + 1, x3From); + (*this->localDistributionsTo)(D3Q27System::ET_TSW, x1To + 1, x2To + 1, x3To) = (*this->localDistributionsFrom)(D3Q27System::ET_TSW, x1From + 1, x2From + 1, x3From); + + (*this->nonLocalDistributionsTo)(D3Q27System::ET_W, x1To + 1, x2To, x3To) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_W, x1From + 1, x2From, x3From); + (*this->nonLocalDistributionsTo)(D3Q27System::ET_S, x1To, x2To + 1, x3To) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_S, x1From, x2From + 1, x3From); + (*this->nonLocalDistributionsTo)(D3Q27System::ET_B, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_B, x1From, x2From, x3From + 1); + (*this->nonLocalDistributionsTo)(D3Q27System::ET_SW, x1To + 1, x2To + 1, x3To) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_SW, x1From + 1, x2From + 1, x3From); + (*this->nonLocalDistributionsTo)(D3Q27System::ET_SE, x1To, x2To + 1, x3To) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_SE, x1From, x2From + 1, x3From); + (*this->nonLocalDistributionsTo)(D3Q27System::ET_BW, x1To + 1, x2To, x3To + 1) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_BW, x1From + 1, x2From, x3From + 1); + (*this->nonLocalDistributionsTo)(D3Q27System::ET_BE, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_BE, x1From, x2From, x3From + 1); + (*this->nonLocalDistributionsTo)(D3Q27System::ET_BS, x1To, x2To + 1, x3To + 1) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_BS, x1From, x2From + 1, x3From + 1); + (*this->nonLocalDistributionsTo)(D3Q27System::ET_BN, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_BN, x1From, x2From, x3From + 1); + (*this->nonLocalDistributionsTo)(D3Q27System::ET_BSW, x1To + 1, x2To + 1, x3To + 1) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_BSW, x1From + 1, x2From + 1, x3From + 1); + (*this->nonLocalDistributionsTo)(D3Q27System::ET_BSE, x1To, x2To + 1, x3To + 1) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_BSE, x1From, x2From + 1, x3From + 1); + (*this->nonLocalDistributionsTo)(D3Q27System::ET_BNW, x1To + 1, x2To, x3To + 1) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_BNW, x1From + 1, x2From, x3From + 1); + (*this->nonLocalDistributionsTo)(D3Q27System::ET_BNE, x1To, x2To, x3To + 1) = (*this->nonLocalDistributionsFrom)(D3Q27System::ET_BNE, x1From, x2From, x3From + 1); + + (*this->zeroDistributionsTo)(x1To, x2To, x3To) = (*this->zeroDistributionsFrom)(x1From, x2From, x3From); +} +#endif + diff --git a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFullVectorConnector.cpp b/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFullVectorConnector.cpp deleted file mode 100644 index 13594fd55..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFullVectorConnector.cpp +++ /dev/null @@ -1,468 +0,0 @@ -#include "D3Q27ETFullVectorConnector.h" -#include "D3Q27EsoTwist3DSplittedVector.h" -#include "LBMKernel.h" -#include "DataSet3D.h" -////////////////////////////////////////////////////////////////////////// -D3Q27ETFullVectorConnector::D3Q27ETFullVectorConnector(SPtr<Block3D> block - , VectorTransmitterPtr sender - , VectorTransmitterPtr receiver - , int sendDir) - : RemoteBlock3DConnector(block, sender, receiver, sendDir) -{ - if (!block || !sender || !receiver) - UB_THROW(UbException(UB_EXARGS, "sender or receiver == NULL!!")); - -} -////////////////////////////////////////////////////////////////////////// -void D3Q27ETFullVectorConnector::init() -{ - maxX1 = (int)block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX1() - 1; - maxX2 = (int)block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX2() - 1; - maxX3 = (int)block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX3() - 1; - - fDis = dynamicPointerCast<EsoTwist3D>(block.lock()->getKernel()->getDataSet()->getFdistributions()); - - int anz = 27; - switch (sendDir) - { - case D3Q27System::ZERO: UB_THROW(UbException(UB_EXARGS, "ZERO not allowed")); break; - case D3Q27System::E: - case D3Q27System::W: sender->getData().resize(maxX2*maxX3*anz, 0.0); break; - case D3Q27System::N: - case D3Q27System::S: sender->getData().resize(maxX1*maxX3*anz, 0.0); break; - case D3Q27System::T: - case D3Q27System::B: sender->getData().resize(maxX1*maxX2*anz, 0.0); break; - - case D3Q27System::NE: - case D3Q27System::SW: - case D3Q27System::SE: - case D3Q27System::NW: sender->getData().resize(maxX3*anz, 0.0); break; - - case D3Q27System::TE: - case D3Q27System::BW: - case D3Q27System::BE: - case D3Q27System::TW: sender->getData().resize(maxX2*anz, 0.0); break; - - case D3Q27System::TN: - case D3Q27System::BS: - case D3Q27System::BN: - case D3Q27System::TS: sender->getData().resize(maxX1*anz, 0.0); break; - - case D3Q27System::TNE: - case D3Q27System::BSW: - case D3Q27System::BNE: - case D3Q27System::TSW: - case D3Q27System::TSE: - case D3Q27System::BNW: - case D3Q27System::BSE: - case D3Q27System::TNW: sender->getData().resize(anz, 0.0); break; - - default: UB_THROW(UbException(UB_EXARGS, "unknown sendDir")); - } -} -////////////////////////////////////////////////////////////////////////// -void D3Q27ETFullVectorConnector::fillSendVectors() -{ - localDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fDis)->getLocalDistributions(); - nonLocalDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fDis)->getNonLocalDistributions(); - zeroDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fDis)->getZeroDistributions(); - - vector_type& sdata = sender->getData(); - - int index = 0; - //EAST - if (sendDir == D3Q27System::E) - { - for (int x3 = 1; x3 < maxX3; x3++) - { - for (int x2 = 1; x2 < maxX2; x2++) - { - fillData(sdata, index, maxX1 - 1, x2, x3); - } - } - } - //WEST - else if (sendDir == D3Q27System::W) - { - for (int x3 = 1; x3 < maxX3; x3++) - { - for (int x2 = 1; x2 < maxX2; x2++) - { - fillData(sdata, index, 1, x2, x3); - } - } - } - //NORTH - else if (sendDir == D3Q27System::N) - { - for (int x3 = 1; x3 < maxX3; x3++) - { - for (int x1 = 1; x1 < maxX1; x1++) - { - fillData(sdata, index, x1, maxX2 - 1, x3); - } - } - } - //SOUTH - else if (sendDir == D3Q27System::S) - { - for (int x3 = 1; x3 < maxX3; x3++) - { - for (int x1 = 1; x1 < maxX1; x1++) - { - fillData(sdata, index, x1, 1, x3); - } - } - } - //TOP - else if (sendDir == D3Q27System::T) - { - for (int x2 = 1; x2 < maxX2; x2++) - { - for (int x1 = 1; x1 < maxX1; x1++) - { - fillData(sdata, index, x1, x2, maxX3 - 1); - } - } - } - //BOTTOM - else if (sendDir == D3Q27System::B) - { - for (int x2 = 1; x2 < maxX2; x2++) - { - for (int x1 = 1; x1 < maxX1; x1++) - { - fillData(sdata, index, x1, x2, 1); - } - } - } - //NE NW SW SE - else if (sendDir == D3Q27System::NE || sendDir == D3Q27System::NW || sendDir == D3Q27System::SW || sendDir == D3Q27System::SE) - { - int x1 = 0; - int x2 = 0; - switch (sendDir) - { - case D3Q27System::NE: - x1 = maxX1 - 1; - x2 = maxX2 - 1; - break; - case D3Q27System::NW: - x1 = 1; - x2 = maxX2 - 1; - break; - case D3Q27System::SW: - x1 = 1; - x2 = 1; - break; - case D3Q27System::SE: - x1 = maxX1 - 1; - x2 = 1; - break; - } - for (int x3 = 1; x3 < maxX3; x3++) - { - fillData(sdata, index, x1, x2, x3); - } - } - //TE TW BW BE - else if (sendDir == D3Q27System::TE || sendDir == D3Q27System::TW || sendDir == D3Q27System::BW || sendDir == D3Q27System::BE) - { - int x1 = 0; - int x3 = 0; - switch (sendDir) - { - case D3Q27System::TE: - x1 = maxX1 - 1; - x3 = maxX3 - 1; - break; - case D3Q27System::TW: - x1 = 1; - x3 = maxX3 - 1; - break; - case D3Q27System::BW: - x1 = 1; - x3 = 1; - break; - case D3Q27System::BE: - x1 = maxX1 - 1; - x3 = 1; - break; - } - for (int x2 = 1; x2 < maxX2; x2++) - { - fillData(sdata, index, x1, x2, x3); - } - } - //TN BN BS TS - else if (sendDir == D3Q27System::TN || sendDir == D3Q27System::BN || sendDir == D3Q27System::BS || sendDir == D3Q27System::TS) - { - int x2 = 0; - int x3 = 0; - switch (sendDir) - { - case D3Q27System::TN: - x3 = maxX3 - 1; - x2 = maxX2 - 1; - break; - case D3Q27System::BN: - x3 = 1; - x2 = maxX2 - 1; - break; - case D3Q27System::BS: - x3 = 1; - x2 = 1; - break; - case D3Q27System::TS: - x3 = maxX3 - 1; - x2 = 1; - break; - } - for (int x1 = 1; x1 < maxX1; x1++) - { - fillData(sdata, index, x1, x2, x3); - } - } - //TNE TNW TSW TSE BNE BNW BSW BSE - else if (sendDir == D3Q27System::TNE || sendDir == D3Q27System::TNW || sendDir == D3Q27System::TSW || sendDir == D3Q27System::TSE - || sendDir == D3Q27System::BNE || sendDir == D3Q27System::BNW || sendDir == D3Q27System::BSW || sendDir == D3Q27System::BSE) - { - int x1 = 0; - int x2 = 0; - int x3 = 0; - switch (sendDir) - { - case D3Q27System::TNE: x1 = maxX1 - 1; x2 = maxX2 - 1; x3 = maxX3 - 1; break; - case D3Q27System::TNW: x1 = 1; x2 = maxX2 - 1; x3 = maxX3 - 1; break; - case D3Q27System::TSW: x1 = 1; x2 = 1; x3 = maxX3 - 1; break; - case D3Q27System::TSE: x1 = maxX1 - 1; x2 = 1; x3 = maxX3 - 1; break; - case D3Q27System::BNE: x1 = maxX1 - 1; x2 = maxX2 - 1; x3 = 1; break; - case D3Q27System::BNW: x1 = 1; x2 = maxX2 - 1; x3 = 1; break; - case D3Q27System::BSW: x1 = 1; x2 = 1; x3 = 1; break; - case D3Q27System::BSE: x1 = maxX1 - 1; x2 = 1; x3 = 1; break; - } - fillData(sdata, index, x1, x2, x3); - } - else UB_THROW(UbException(UB_EXARGS, "unknown dir")); -} -//////////////////////////////////////////////////////////////////////// -void D3Q27ETFullVectorConnector::distributeReceiveVectors() -{ - /*e.g. connector sendet nach EAST --> empfaengt daten aus WEST ;-)*/ - - localDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fDis)->getLocalDistributions(); - nonLocalDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fDis)->getNonLocalDistributions(); - zeroDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(this->fDis)->getZeroDistributions(); - - vector_type& rdata = receiver->getData(); - - int index = 0; - - if (sendDir == D3Q27System::W) - { - for (int x3 = 1; x3 < maxX3; x3++) - { - for (int x2 = 1; x2 < maxX2; x2++) - { - distributeData(rdata, index, 0, x2, x3); - } - } - } - else if (sendDir == D3Q27System::E) - { - for (int x3 = 1; x3 < maxX3; x3++) - { - for (int x2 = 1; x2 < maxX2; x2++) - { - distributeData(rdata, index, maxX1, x2, x3); - } - } - } - else if (sendDir == D3Q27System::S) - { - for (int x3 = 1; x3 < maxX3; x3++) - { - for (int x1 = 1; x1 < maxX1; x1++) - { - distributeData(rdata, index, x1, 0, x3); - } - } - } - else if (sendDir == D3Q27System::N) - { - for (int x3 = 1; x3 < maxX3; x3++) - { - for (int x1 = 1; x1 < maxX1; x1++) - { - distributeData(rdata, index, x1, maxX2, x3); - } - } - } - else if (sendDir == D3Q27System::B) - { - for (int x2 = 1; x2 < maxX2; x2++) - { - for (int x1 = 1; x1 < maxX1; x1++) - { - distributeData(rdata, index, x1, x2, 0); - } - } - } - else if (sendDir == D3Q27System::T) - { - for (int x2 = 1; x2 < maxX2; x2++) - { - for (int x1 = 1; x1 < maxX1; x1++) - { - distributeData(rdata, index, x1, x2, maxX3); - } - } - } - //NE NW SW SE - else if (sendDir == D3Q27System::NE || sendDir == D3Q27System::NW || sendDir == D3Q27System::SW || sendDir == D3Q27System::SE) - { - int x1 = 0; - int x2 = 0; - switch (sendDir) //wenn sendir NE dann kommen werte von SW - { - case D3Q27System::NE: - x1 = maxX1; - x2 = maxX2; - break; - case D3Q27System::NW: - x1 = 0; - x2 = maxX2; - break; - case D3Q27System::SW: - x1 = 0; - x2 = 0; - break; - case D3Q27System::SE: - x1 = maxX1; - x2 = 0; - break; - } - for (int x3 = 1; x3 < maxX3; x3++) - { - distributeData(rdata, index, x1, x2, x3); - } - - } - //TE TW BW BE - else if (sendDir == D3Q27System::TE || sendDir == D3Q27System::TW || sendDir == D3Q27System::BW || sendDir == D3Q27System::BE) - - { - int x1 = 0; - int x3 = 0; - switch (sendDir) //wenn sendir NE dann kommen werte von SW - { - case D3Q27System::TE: - x1 = maxX1; - x3 = maxX3; - break; - case D3Q27System::TW: - x1 = 0; - x3 = maxX3; - break; - case D3Q27System::BW: - x1 = 0; - x3 = 0; - break; - case D3Q27System::BE: - x1 = maxX1; - x3 = 0; - break; - } - for (int x2 = 1; x2 < maxX2; x2++) - { - distributeData(rdata, index, x1, x2, x3); - } - } - //TN BN BS TS - else if (sendDir == D3Q27System::TN || sendDir == D3Q27System::BN || sendDir == D3Q27System::BS || sendDir == D3Q27System::TS) - { - int x2 = 0; - int x3 = 0; - switch (sendDir) - { - case D3Q27System::TN: - x3 = maxX3; - x2 = maxX2; - break; - case D3Q27System::BN: - x3 = 0; - x2 = maxX2; - break; - case D3Q27System::BS: - x3 = 0; - x2 = 0; - break; - case D3Q27System::TS: - x3 = maxX3; - x2 = 0; - break; - - } - for (int x1 = 1; x1 < maxX1; x1++) - { - distributeData(rdata, index, x1, x2, x3); - } - } - //TNE TNW TSW TSE BNE BNW BSW BSE - else if (sendDir == D3Q27System::TNE || sendDir == D3Q27System::TNW || sendDir == D3Q27System::TSW || sendDir == D3Q27System::TSE - || sendDir == D3Q27System::BNE || sendDir == D3Q27System::BNW || sendDir == D3Q27System::BSW || sendDir == D3Q27System::BSE) - { - int x1 = 0; - int x2 = 0; - int x3 = 0; - - switch (sendDir) - { - case D3Q27System::TNE: - x1 = maxX1; - x2 = maxX2; - x3 = maxX3; - break; - case D3Q27System::TNW: - x1 = 0; - x2 = maxX2; - x3 = maxX3; - break; - case D3Q27System::TSW: - x1 = 0; - x2 = 0; - x3 = maxX3; - break; - case D3Q27System::TSE: - x1 = maxX1; - x2 = 0; - x3 = maxX3; - break; - case D3Q27System::BNE: - x1 = maxX1; - x2 = maxX2; - x3 = 0; - break; - case D3Q27System::BNW: - x1 = 0; - x2 = maxX2; - x3 = 0; - break; - case D3Q27System::BSW: - x1 = 0; - x2 = 0; - x3 = 0; - break; - case D3Q27System::BSE: - x1 = maxX1; - x2 = 0; - x3 = 0; - break; - } - distributeData(rdata, index, x1, x2, x3); - } - else UB_THROW(UbException(UB_EXARGS, "unknown dir")); -} -////////////////////////////////////////////////////////////////////////// - - diff --git a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFullVectorConnector.h b/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFullVectorConnector.h deleted file mode 100644 index b0ecb0ee6..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETFullVectorConnector.h +++ /dev/null @@ -1,118 +0,0 @@ -#ifndef D3Q27ETFULLVECTORCONNECTOR_H -#define D3Q27ETFULLVECTORCONNECTOR_H - -#include <vector> - -#include "RemoteBlock3DConnector.h" -#include "D3Q27System.h" -#include "Block3D.h" -#include "LBMKernel.h" -#include "EsoTwistD3Q27System.h" -#include "basics/container/CbArray3D.h" -#include "basics/container/CbArray4D.h" -#include "EsoTwist3D.h" - - -//daten werden in einen vector (dieser befindet sich im transmitter) kopiert -//der vector wird via transmitter uebertragen -//transmitter kann ein lokal, MPI, RCG, CTL oder was auch immer fuer ein -//transmitter sein, der von Transmitter abgeleitet ist ;-) -class D3Q27ETFullVectorConnector : public RemoteBlock3DConnector -{ -public: - D3Q27ETFullVectorConnector(SPtr<Block3D> block - , VectorTransmitterPtr sender - , VectorTransmitterPtr receiver - , int sendDir); - - void init(); - - void fillSendVectors(); - void distributeReceiveVectors(); - -protected: - inline void fillData(vector_type& sdata, int& index, int x1, int x2, int x3); - inline void distributeData(vector_type& rdata, int& index, int x1, int x2, int x3); -private: - int maxX1; - int maxX2; - int maxX3; - - CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributions; - CbArray4D <LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions; - CbArray3D <LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributions; - - SPtr<EsoTwist3D> fDis; - -}; - -////////////////////////////////////////////////////////////////////////// -inline void D3Q27ETFullVectorConnector::fillData(vector_type& sdata, int& index, int x1, int x2, int x3) -{ - sdata[index++] = (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3); - sdata[index++] = (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3); - sdata[index++] = (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3); - sdata[index++] = (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3); - sdata[index++] = (*this->localDistributions)(D3Q27System::ET_NW, x1 + 1, x2, x3); - sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3); - sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TW, x1 + 1, x2, x3); - sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3); - sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TS, x1, x2 + 1, x3); - sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3); - sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TNW, x1 + 1, x2, x3); - sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2 + 1, x3); - sdata[index++] = (*this->localDistributions)(D3Q27System::ET_TSW, x1 + 1, x2 + 1, x3); - - sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_W, x1 + 1, x2, x3); - sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2 + 1, x3); - sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3 + 1); - sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1 + 1, x2 + 1, x3); - sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2 + 1, x3); - sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1 + 1, x2, x3 + 1); - sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3 + 1); - sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2 + 1, x3 + 1); - sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3 + 1); - sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1 + 1, x2 + 1, x3 + 1); - sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2 + 1, x3 + 1); - sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1 + 1, x2, x3 + 1); - sdata[index++] = (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3 + 1); - - sdata[index++] = (*this->zeroDistributions)(x1, x2, x3); -} -////////////////////////////////////////////////////////////////////////// -inline void D3Q27ETFullVectorConnector::distributeData(vector_type& rdata, int& index, int x1, int x2, int x3) -{ - (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3) = rdata[index++]; - (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3) = rdata[index++]; - (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3) = rdata[index++]; - (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3) = rdata[index++]; - (*this->localDistributions)(D3Q27System::ET_NW, x1 + 1, x2, x3) = rdata[index++]; - (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3) = rdata[index++]; - (*this->localDistributions)(D3Q27System::ET_TW, x1 + 1, x2, x3) = rdata[index++]; - (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3) = rdata[index++]; - (*this->localDistributions)(D3Q27System::ET_TS, x1, x2 + 1, x3) = rdata[index++]; - (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3) = rdata[index++]; - (*this->localDistributions)(D3Q27System::ET_TNW, x1 + 1, x2, x3) = rdata[index++]; - (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2 + 1, x3) = rdata[index++]; - (*this->localDistributions)(D3Q27System::ET_TSW, x1 + 1, x2 + 1, x3) = rdata[index++]; - - (*this->nonLocalDistributions)(D3Q27System::ET_W, x1 + 1, x2, x3) = rdata[index++]; - (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2 + 1, x3) = rdata[index++]; - (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3 + 1) = rdata[index++]; - (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1 + 1, x2 + 1, x3) = rdata[index++]; - (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2 + 1, x3) = rdata[index++]; - (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1 + 1, x2, x3 + 1) = rdata[index++]; - (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3 + 1) = rdata[index++]; - (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2 + 1, x3 + 1) = rdata[index++]; - (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3 + 1) = rdata[index++]; - (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1 + 1, x2 + 1, x3 + 1) = rdata[index++]; - (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2 + 1, x3 + 1) = rdata[index++]; - (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1 + 1, x2, x3 + 1) = rdata[index++]; - (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3 + 1) = rdata[index++]; - - (*this->zeroDistributions)(x1, x2, x3) = rdata[index++]; -} - - -#endif //D3Q27VECTORCONNECTOR_H - diff --git a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETOffConnectorFactory.cpp b/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETOffConnectorFactory.cpp deleted file mode 100644 index afdcb3bdf..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETOffConnectorFactory.cpp +++ /dev/null @@ -1,38 +0,0 @@ -//#include "D3Q27ETOffConnectorFactory.h" -//#include "TransmitterType.h" -//#include "D3Q27ETCFOffVectorConnector.h" -//#include "D3Q27ETFCOffVectorConnector.h" -//#include "D3Q27ETFCVectorConnector.h" -//#include "FineToCoarseBlock3DConnector.h" -// -//D3Q27ETOffConnectorFactory::D3Q27ETOffConnectorFactory() -//{ -//} -//////////////////////////////////////////////////////////////////////////// -//D3Q27ETOffConnectorFactory::~D3Q27ETOffConnectorFactory() -//{ -//} -//////////////////////////////////////////////////////////////////////////// -//SPtr<Block3DConnector> D3Q27ETOffConnectorFactory::createCoarseToFineConnector(SPtr<Block3D> block, -// VectorTransmitterPtr sender00, VectorTransmitterPtr receiver00, -// VectorTransmitterPtr sender01, VectorTransmitterPtr receiver01, -// VectorTransmitterPtr sender10, VectorTransmitterPtr receiver10, -// VectorTransmitterPtr sender11, VectorTransmitterPtr receiver11, -// int sendDir, D3Q27InterpolationProcessorPtr iprocessor) -//{ -// return SPtr<Block3DConnector>(new D3Q27ETCFOffVectorConnector<VectorTransmitter>(block, -// sender00, receiver00, sender01, receiver01, -// sender10, receiver10, sender11, receiver11, -// sendDir, iprocessor)); -//} -//////////////////////////////////////////////////////////////////////////// -//SPtr<Block3DConnector> D3Q27ETOffConnectorFactory::createFineToCoarseConnector(SPtr<Block3D> block, -// VectorTransmitterPtr sender, -// VectorTransmitterPtr receiver, -// int sendDir, -// D3Q27InterpolationProcessorPtr iprocessor, -// FineToCoarseBlock3DConnector::CFconnectorType connType) -//{ -// return SPtr<Block3DConnector>(new D3Q27ETFCOffVectorConnector<VectorTransmitter>(block, -// sender, receiver, sendDir, iprocessor, connType)); -//} diff --git a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETOffConnectorFactory.h b/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETOffConnectorFactory.h deleted file mode 100644 index 1db2868f4..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/D3Q27ETOffConnectorFactory.h +++ /dev/null @@ -1,34 +0,0 @@ -//#ifndef D3Q27ETOffConnectorFactory_h__ -//#define D3Q27ETOffConnectorFactory_h__ -// -//#include "Block3DConnectorFactory.h" -// -//#include <PointerDefinitions.h> -//class D3Q27ETOffConnectorFactory; -//typedef SPtr<D3Q27ETOffConnectorFactory> D3Q27ETOffSPtr<ConnectorFactory>; -// -//class D3Q27ETOffConnectorFactory : public Block3DConnectorFactory -//{ -//public: -// D3Q27ETOffConnectorFactory(); -// virtual ~D3Q27ETOffConnectorFactory(); -// -// virtual SPtr<Block3DConnector> createCoarseToFineConnector(SPtr<Block3D> block, -// VectorTransmitterPtr sender00, VectorTransmitterPtr receiver00, -// VectorTransmitterPtr sender01, VectorTransmitterPtr receiver01, -// VectorTransmitterPtr sender10, VectorTransmitterPtr receiver10, -// VectorTransmitterPtr sender11, VectorTransmitterPtr receiver11, -// int sendDir, D3Q27InterpolationProcessorPtr iprocessor); -// -// virtual SPtr<Block3DConnector> createFineToCoarseConnector(SPtr<Block3D> block, -// VectorTransmitterPtr sender, -// VectorTransmitterPtr receiver, -// int sendDir, -// D3Q27InterpolationProcessorPtr iprocessor, -// FineToCoarseBlock3DConnector::CFconnectorType connType); -// -//private: -// -//}; -//#endif // D3Q27ETOffConnectorFactory_h__ - diff --git a/src/cpu/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.cpp b/src/cpu/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.cpp deleted file mode 100644 index ff8f85aa5..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include "FineToCoarseBlock3DConnector.h" - -//////////////////////////////////////////////////////////////////////////// -FineToCoarseBlock3DConnector::FineToCoarseBlock3DConnector(SPtr<Block3D> block, VectorTransmitterPtr sender, - VectorTransmitterPtr receiver, int sendDir, - InterpolationProcessorPtr iprocessor, - CFconnectorType connType) - : Block3DConnector(sendDir) - , block(block) - , sender(sender) - , receiver(receiver) - , iprocessor(iprocessor) - , connType(connType) -{ - if (!(sendDir==D3Q27System::E || sendDir==D3Q27System::W || sendDir==D3Q27System::N || sendDir==D3Q27System::S || sendDir==D3Q27System::T || sendDir==D3Q27System::B - || sendDir==D3Q27System::NE || sendDir==D3Q27System::SW || sendDir==D3Q27System::SE || sendDir==D3Q27System::NW - || sendDir==D3Q27System::TE || sendDir==D3Q27System::BW || sendDir==D3Q27System::BE || sendDir==D3Q27System::TW - || sendDir==D3Q27System::TN || sendDir==D3Q27System::BS || sendDir==D3Q27System::BN || sendDir==D3Q27System::TS - - || sendDir==D3Q27System::TNE || sendDir==D3Q27System::TNW || sendDir==D3Q27System::TSE || sendDir==D3Q27System::TSW - || sendDir==D3Q27System::BNE || sendDir==D3Q27System::BNW || sendDir==D3Q27System::BSE || sendDir==D3Q27System::BSW - - )) - { - throw UbException(UB_EXARGS, "invalid constructor for this direction"); - } -} -////////////////////////////////////////////////////////////////////////// -bool FineToCoarseBlock3DConnector::isLocalConnector() -{ - return !this->isRemoteConnector(); -} -////////////////////////////////////////////////////////////////////////// -bool FineToCoarseBlock3DConnector::isRemoteConnector() -{ - return sender->isRemoteTransmitter() || receiver->isRemoteTransmitter(); -} -////////////////////////////////////////////////////////////////////////// -void FineToCoarseBlock3DConnector::sendTransmitterDataSize() -{ - if (sender) - { - UBLOG(logDEBUG5, "FineToCoarseBlock3DConnector<VectorTransmitter>::sendTransmitterDataSize()"<<block.lock()->toString()+"sendDir="<<sendDir); - sender->sendDataSize(); - } -} -////////////////////////////////////////////////////////////////////////// -void FineToCoarseBlock3DConnector::receiveTransmitterDataSize() -{ - if (receiver) - { - UBLOG(logDEBUG5, "FineToCoarseBlock3DConnector<VectorTransmitter>::receiveTransmitterDataSize()"<<block.lock()->toString()<<"sendDir="<<sendDir); - receiver->receiveDataSize(); - } -} -////////////////////////////////////////////////////////////////////////// -void FineToCoarseBlock3DConnector::prepareForSend() -{ - if (sender) sender->prepareForSend(); -} -////////////////////////////////////////////////////////////////////////// -void FineToCoarseBlock3DConnector::sendVectors() -{ - if (sender) sender->sendData(); -} -////////////////////////////////////////////////////////////////////////// -void FineToCoarseBlock3DConnector::prepareForReceive() -{ - if (receiver) receiver->prepareForReceive(); -} -////////////////////////////////////////////////////////////////////////// -void FineToCoarseBlock3DConnector::receiveVectors() -{ - if (receiver) receiver->receiveData(); -} - - diff --git a/src/cpu/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.h b/src/cpu/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.h deleted file mode 100644 index f90c5340b..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/FineToCoarseBlock3DConnector.h +++ /dev/null @@ -1,95 +0,0 @@ -//! \file FineToCoarseBlock3DConnector.h -//! \brief Base class for connectors that interpolates and sends data from fine level to coarse. -//! \author Konstantin Kutscher -//! \date 21.05.2015 - -#ifndef FineToCoarseBlock3DConnector_H -#define FineToCoarseBlock3DConnector_H - -#include "TransmitterType.h" -#include "Block3DConnector.h" -#include "D3Q27System.h" -#include "Block3D.h" -#include "LBMKernel.h" -#include "InterpolationProcessor.h" - -#include <PointerDefinitions.h> - - -class Block3D; - -//! \class FineToCoarseBlock3DConnector -//! \brief Base class for connectors that interpolates and sends data from fine level to coarse. -//! \details The data is copied in a vector (this is located in the transmitter). -//! The vector is transmitted via transmitter. -//! The transmitter can be a local, MPI, RCG, CTL or whatever -//! which a transmitter that is derived from transmitter base class. -//! -//! four fine blocks inside a coarse block: -//! -//! | | | -//! |:--:|:---| -//! | 01 | 11 | -//! | 00 | 10 | -//! -//! send direction: -//! -//! |E<->W | N<->S | T<->B | -//! |--------|---------|--------| -//! | x3 | x3 | x2 | -//! | ^ | ^ | ^ | -//! | +->x2 | +->x1 | +->x1| - -class FineToCoarseBlock3DConnector : public Block3DConnector -{ -public: - enum CFconnectorType { Type00, Type10, Type01, Type11 }; -public: - FineToCoarseBlock3DConnector(SPtr<Block3D> block, VectorTransmitterPtr sender, VectorTransmitterPtr receiver, int sendDir, InterpolationProcessorPtr iprocessor, CFconnectorType connType); - - bool isLocalConnector(); - bool isRemoteConnector(); - - void sendTransmitterDataSize(); - void receiveTransmitterDataSize(); - - void prepareForSend(); - void sendVectors(); - - void prepareForReceive(); - void receiveVectors(); - - virtual void init()=0; - virtual void fillSendVectors()=0; - virtual void distributeReceiveVectors()=0; - - bool isInterpolationConnectorCF() { return false; } - bool isInterpolationConnectorFC() { return true; } - - void prepareForSendX1() {} - void prepareForSendX2() {} - void prepareForSendX3() {} - - void sendVectorsX1() {} - void sendVectorsX2() {} - void sendVectorsX3() {} - - void prepareForReceiveX1() {} - void prepareForReceiveX2() {} - void prepareForReceiveX3() {} - - void receiveVectorsX1() {} - void receiveVectorsX2() {} - void receiveVectorsX3() {} - -protected: - WPtr<Block3D> block; - VectorTransmitterPtr sender, receiver; - InterpolationProcessorPtr iprocessor; - CFconnectorType connType; -}; - - - -#endif - diff --git a/src/cpu/VirtualFluidsCore/Connectors/FineToCoarseNodeSetBlock3DConnector.cpp b/src/cpu/VirtualFluidsCore/Connectors/FineToCoarseNodeSetBlock3DConnector.cpp deleted file mode 100644 index d589c6e5c..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/FineToCoarseNodeSetBlock3DConnector.cpp +++ /dev/null @@ -1,1235 +0,0 @@ -#include "FineToCoarseNodeSetBlock3DConnector.h" -#include "BCProcessor.h" -#include "DataSet3D.h" - - -////////////////////////////////////////////////////////////////////////// -FineToCoarseNodeSetBlock3DConnector::FineToCoarseNodeSetBlock3DConnector(SPtr<Block3D> block, VectorTransmitterPtr sender, VectorTransmitterPtr receiver, - int sendDir, InterpolationProcessorPtr iprocessor, CFconnectorType connType) : FineToCoarseBlock3DConnector(block, sender, receiver, sendDir, iprocessor, connType) -{ - -} -////////////////////////////////////////////////////////////////////////// -void FineToCoarseNodeSetBlock3DConnector::init() -{ - bMaxX1 = (int)FineToCoarseBlock3DConnector::block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX1(); - bMaxX2 = (int)FineToCoarseBlock3DConnector::block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX2(); - bMaxX3 = (int)FineToCoarseBlock3DConnector::block.lock()->getKernel()->getDataSet()->getFdistributions()->getNX3(); - - minX1 = 0; - minX2 = 0; - minX3 = 0; - maxX1 = bMaxX1 - 1; - maxX2 = bMaxX2 - 1; - maxX3 = bMaxX3 - 1; - - minOffX1 = 0; - minOffX2 = 0; - minOffX3 = 0; - - maxOffX1 = 0; - maxOffX2 = 0; - maxOffX3 = 0; - - if (Utilities::isEven(bMaxX1)) - { - minOffX1 = 0; - maxOffX1 = 0; - } - else if (Utilities::isOdd(bMaxX1)) - { - minOffX1 = 1; - maxOffX1 = -1; - } - - if (Utilities::isEven(bMaxX2)) - { - minOffX2 = 0; - maxOffX2 = 0; - } - else if (Utilities::isOdd(bMaxX2)) - { - minOffX2 = 1; - maxOffX2 = -1; - } - - if (Utilities::isEven(bMaxX3)) - { - minOffX3 = 0; - maxOffX3 = 0; - } - else if (Utilities::isOdd(bMaxX3)) - { - minOffX3 = 1; - maxOffX3 = -1; - } - - //int sendSize = 0; - LBMReal initValue = -999.0; - - int sendDataPerNode = 27/*f*/; - int iCellSize = 1; //size of interpolation cell - - findFCCells(); - findCFCells(); - - ////////////////////////////////////////////////////// - //Debug - ////////////////////////////////////////////////////// - if (FineToCoarseBlock3DConnector::block.lock()->getGlobalID() == 2183) - { - int test = 0; - } - - - if (FineToCoarseBlock3DConnector::sender) FineToCoarseBlock3DConnector::sender->getData().resize(iNodeSetSender.size()*iCellSize*sendDataPerNode, initValue); - else FineToCoarseBlock3DConnector::sender = VectorTransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); - - if (!FineToCoarseBlock3DConnector::receiver) FineToCoarseBlock3DConnector::receiver = VectorTransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); -} -////////////////////////////////////////////////////////////////////////// -void FineToCoarseNodeSetBlock3DConnector::findFCCells(int lMinX1, int lMinX2, int lMinX3, int lMaxX1, int lMaxX2, int lMaxX3, INodeSet &inodes) -{ - ////////////////////////////////////////////////////// - //Debug - ////////////////////////////////////////////////////// - if (FineToCoarseBlock3DConnector::block.lock()->getGlobalID() == 2183) - { - int test = 0; - } - - - int ix1, ix2, ix3; - LBMReal x1off, x2off, x3off; - - SPtr<DistributionArray3D> fFrom = FineToCoarseBlock3DConnector::block.lock()->getKernel()->getDataSet()->getFdistributions(); - SPtr<BCArray3D> bcArray = FineToCoarseBlock3DConnector::block.lock()->getKernel()->getBCProcessor()->getBCArray(); - - for (ix3 = lMinX3; ix3<=lMaxX3; ix3 += 2) - { - for (ix2 = lMinX2; ix2<=lMaxX2; ix2 += 2) - { - for (ix1 = lMinX1; ix1<=lMaxX1; ix1 += 2) - { - D3Q27ICell icellC; - - int howManySolids = FineToCoarseBlock3DConnector::iprocessor->iCellHowManySolids(bcArray, ix1, ix2, ix3); - - if (howManySolids == 0 || howManySolids == 8) - { - x1off = 0.0; - x2off = 0.0; - x3off = 0.0; - } - else - { - if (!iprocessor->findNeighborICell(bcArray, fFrom, icellC, bMaxX1, bMaxX2, bMaxX3, ix1, ix2, ix3, x1off, x2off, x3off)) - { - std::string err = "For "+FineToCoarseBlock3DConnector::block.lock()->toString()+" x1="+UbSystem::toString(ix1)+", x2=" + UbSystem::toString(ix2)+", x3=" + UbSystem::toString(ix3)+ - " 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)); - } - } - - INodeVector inv; - inv.push_back(ix1 + (int)x1off); - inv.push_back(ix2 + (int)x2off); - inv.push_back(ix3 + (int)x3off); - inv.push_back((int)x1off); - inv.push_back((int)x2off); - inv.push_back((int)x3off); - //inodes.insert(inv); - inodes.push_back(inv); - } - } - } -} -////////////////////////////////////////////////////////////////////////// - -void FineToCoarseNodeSetBlock3DConnector::findFCCells() -{ - using namespace D3Q27System; - - int lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3; - int lMin2X1, lMin2X2, lMin2X3, lMax2X1, lMax2X2, lMax2X3; - int lMin3X1, lMin3X2, lMin3X3, lMax3X1, lMax3X2, lMax3X3; - - //lMin1X1 = minX1+1; lMin1X2 = minX2+1; lMin1X3 = minX3+1; - //lMax1X1 = maxX1-1; lMax1X2 = maxX2-1; lMax1X3 = maxX3-1; - //getLocalMinMax(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3); - - //lMin2X1 = minX1+1; lMin2X2 = minX2+1; lMin2X3 = minX3+1; - //lMax2X1 = maxX1-1; lMax2X2 = maxX2-1; lMax2X3 = maxX3-1; - //getLocalMinMax(lMin2X1, lMin2X2, lMin2X3, lMax2X1, lMax2X2, lMax2X3); - - //lMin3X1 = minX1+1; lMin3X2 = minX2+1; lMin3X3 = minX3+1; - //lMax3X1 = maxX1-1; lMax3X2 = maxX2-1; lMax3X3 = maxX3-1; - //getLocalMinMax(lMin3X1, lMin3X2, lMin3X3, lMax3X1, lMax3X2, lMax3X3); - - switch (sendDir) - { - //faces - case E: case W: - if (sendDir == E) - { - lMin1X1 = maxX1 - 6; - lMax1X1 = lMin1X1; - } - else if (sendDir == W) - { - lMin1X1 = 5; - lMax1X1 = lMin1X1; - } - - if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type00) - { - lMin1X2 = minX2; - lMax1X2 = maxX2 + maxOffX2 - 1; - lMin1X3 = minX3; - lMax1X3 = maxX3 + maxOffX3 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type10) - { - lMin1X2 = minX2 + minOffX2; - lMax1X2 = maxX2 - 1; - lMin1X3 = minX3; - lMax1X3 = maxX3 + maxOffX3 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type01) - { - lMin1X2 = minX2; - lMax1X2 = maxX2 + maxOffX2 - 1; - lMin1X3 = minX3 + minOffX3; - lMax1X3 = maxX3 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type11) - { - lMin1X2 = minX2 + minOffX2; - lMax1X2 = maxX2 - 1; - lMin1X3 = minX3 + minOffX3; - lMax1X3 = maxX3 - 1; - } - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetSender); - break; - case N: case S: - if (sendDir == N) - { - lMin1X2 = maxX2 - 6; - lMax1X2 = lMin1X2; - } - else if (sendDir == S) - { - lMin1X2 = 5; - lMax1X2 = lMin1X2; - } - - if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type00) - { - lMin1X1 = minX1; - lMax1X1 = maxX1 + maxOffX1 - 1; - lMin1X3 = minX3; - lMax1X3 = maxX3 + maxOffX3 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type10) - { - lMin1X1 = minX1 + minOffX1; - lMax1X1 = maxX1 - 1; - lMin1X3 = minX3; - lMax1X3 = maxX3 + maxOffX3 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type01) - { - lMin1X1 = minX1; - lMax1X1 = maxX1 + maxOffX1 - 1; - lMin1X3 = minX3 + minOffX3; - lMax1X3 = maxX3; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type11) - { - lMin1X1 = minX1 + minOffX1; - lMax1X1 = maxX1 - 1; - lMin1X3 = minX3 + minOffX3; - lMax1X3 = maxX3 - 1; - } - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetSender); - break; - case T: case B: - if (sendDir == T) - { - lMin1X3 = maxX3 - 6; - lMax1X3 = lMin1X3; - } - else if (sendDir == B) - { - lMin1X3 = 5; - lMax1X3 = lMin1X3; - } - - if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type00) - { - lMin1X1 = minX1; - lMax1X1 = maxX1 + maxOffX1 - 1; - lMin1X2 = minX2; - lMax1X2 = maxX2 + maxOffX2 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type10) - { - lMin1X1 = minX1 + minOffX1; - lMax1X1 = maxX1 - 1; - lMin1X2 = minX2; - lMax1X2 = maxX2 + maxOffX2 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type01) - { - lMin1X1 = minX1; - lMax1X1 = maxX1 + maxOffX1 - 1; - lMin1X2 = minX2 + minOffX2; - lMax1X2 = maxX2 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type11) - { - lMin1X1 = minX1 + minOffX1; - lMax1X1 = maxX1 - 1; - lMin1X2 = minX2 + minOffX2; - lMax1X2 = maxX2 - 1; - } - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetSender); - break; - //edges - //N-S-E-W - case NE: case SW: case SE: case NW: - if (sendDir == NE) - { - lMin1X1 = maxX1 - 6; - lMax1X1 = lMin1X1 + 4; - lMin1X2 = maxX2 - 6; - lMax1X2 = lMin1X2; - - lMin2X1 = maxX1 - 6; - lMax2X1 = lMin2X1; - lMin2X2 = maxX2 - 6; - lMax2X2 = lMin2X2 + 4; - } - else if (sendDir == SW) - { - lMin1X1 = 1; - lMax1X1 = lMin1X1 + 4; - lMin1X2 = 5; - lMax1X2 = lMin1X2; - - lMin2X1 = 5; - lMax2X1 = lMin2X1; - lMin2X2 = 1; - lMax2X2 = lMin2X2 + 4; - } - else if (sendDir == SE) - { - lMin1X1 = maxX1 - 6; - lMax1X1 = lMin1X1 + 4; - lMin1X2 = 5; - lMax1X2 = lMin1X2; - - lMin2X1 = maxX1 - 6; - lMax2X1 = lMin2X1; - lMin2X2 = 1; - lMax2X2 = lMin2X2 + 4; - } - else if (sendDir == NW) - { - lMin1X1 = 1; - lMax1X1 = lMin1X1 + 4; - lMin1X2 = maxX2 - 6; - lMax1X2 = lMin1X2; - - lMin2X1 = 5; - lMax2X1 = lMin2X1; - lMin2X2 = maxX2 - 6; - lMax2X2 = lMin2X2 + 4; - } - - if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type00) - { - lMin1X3 = minX3; - lMax1X3 = maxX3 + maxOffX3 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type10) - { - lMin1X3 = minX3 + minOffX3; - lMax1X3 = maxX3 - 1; - } - - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetSender); - findFCCells(lMin2X1, lMin2X2, lMin1X3, lMax2X1, lMax2X2, lMax1X3, iNodeSetSender); - - break; - //T-B-E-W - case TE: case BW: case BE: case TW: - if (sendDir == TE) - { - lMin1X1 = maxX1 - 6; - lMax1X1 = lMin1X1 + 4; - lMin1X3 = maxX3 - 6; - lMax1X3 = lMin1X3; - - lMin2X1 = maxX1 - 6; - lMax2X1 = lMin2X1; - lMin2X3 = maxX3 - 6; - lMax2X3 = lMin2X3 + 4; - } - else if (sendDir == BW) - { - lMin1X1 = 1; - lMax1X1 = lMin1X1 + 4; - lMin1X3 = 5; - lMax1X3 = lMin1X3; - - lMin2X1 = 5; - lMax2X1 = lMin2X1; - lMin2X3 = 1; - lMax2X3 = lMin2X3 + 4; - } - else if (sendDir == BE) - { - lMin1X1 = maxX1 - 6; - lMax1X1 = lMin1X1 + 4; - lMin1X3 = 5; - lMax1X3 = lMin1X3; - - - lMin2X1 = maxX1 - 6; - lMax2X1 = lMin2X1; - lMin2X3 = 1; - lMax2X3 = lMin2X3 + 4; - } - else if (sendDir == TW) - { - lMin1X1 = 1; - lMax1X1 = lMin1X1 + 5; - lMin1X3 = maxX3 - 6; - lMax1X3 = lMin1X3; - - lMin2X1 = 5; - lMax2X1 = lMin2X1; - lMin2X3 = maxX3 - 6; - lMax2X3 = lMin2X3 + 4; - } - - if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type00) - { - lMin1X2 = minX2; - lMax1X2 = maxX2 + maxOffX2 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type10) - { - lMin1X2 = minX2 + minOffX2; - lMax1X2 = maxX2 - 1; - } - - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetSender); - findFCCells(lMin2X1, lMin1X2, lMin2X3, lMax2X1, lMax1X2, lMax2X3, iNodeSetSender); - break; - //T-B-N-S - case TN: case BS: case BN: case TS: - if (sendDir == TN) - { - lMin1X2 = maxX2 - 6; - lMax1X2 = lMin1X2 + 4; - lMin1X3 = maxX3 - 6; - lMax1X3 = lMin1X3; - - lMin2X2 = maxX2 - 6; - lMax2X2 = lMin2X2; - lMin2X3 = maxX3 - 6; - lMax2X3 = lMin2X3 + 4; - } - else if (sendDir == BS) - { - lMin1X2 = 1; - lMax1X2 = lMin1X2 + 4; - lMin1X3 = 5; - lMax1X3 = lMin1X3; - - lMin2X2 = 5; - lMax2X2 = lMin2X2; - lMin2X3 = 1; - lMax2X3 = lMin2X3 + 4; - } - else if (sendDir == BN) - { - lMin1X2 = maxX2 - 6; - lMax1X2 = lMin1X2 + 4; - lMin1X3 = 5; - lMax1X3 = lMin1X3; - - lMin2X2 = maxX2 - 6; - lMax2X2 = lMin2X2; - lMin2X3 = 1; - lMax2X3 = lMin2X3 + 4; - } - else if (sendDir == TS) - { - lMin1X2 = 1; - lMax1X2 = lMin1X2 + 4; - lMin1X3 = maxX3 - 6; - lMax1X3 = lMin1X3; - - lMin2X2 = 5; - lMax2X2 = lMin2X2; - lMin2X3 = maxX3 - 6; - lMax2X3 = lMin2X3 + 4; - } - - if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type00) - { - lMin1X1 = minX1; - lMax1X1 = maxX1 + maxOffX1 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type10) - { - lMin1X1 = minX1 + minOffX1; - lMax1X1 = maxX1 - 1; - } - - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetSender); - findFCCells(lMin1X1, lMin2X2, lMin2X3, lMax1X1, lMax2X2, lMax2X3, iNodeSetSender); - break; - //corners - case TNE: case TNW: case TSE: case TSW: case BNE: case BNW: case BSE: case BSW: - if (sendDir == TNE) - { - lMin1X1 = maxX1-6; - lMax1X1 = maxX1-6; - lMin1X2 = maxX2-6; - lMax1X2 = maxX2-2; - lMin1X3 = maxX3-6; - lMax1X3 = maxX3-2; - - lMin2X1 = maxX1-6; - lMax2X1 = maxX1-2; - lMin2X2 = maxX2-6; - lMax2X2 = maxX2-6; - lMin2X3 = maxX3-6; - lMax2X3 = maxX3-1; - - lMin3X1 = maxX1-6; - lMax3X1 = maxX1-2; - lMin3X2 = maxX2-6; - lMax3X2 = maxX2-2; - lMin3X3 = maxX3-6; - lMax3X3 = maxX3-5; - } - else if (sendDir == TNW) - { - lMin1X1 = 5; - lMax1X1 = 5; - lMin1X2 = maxX2-6; - lMax1X2 = maxX2-2; - lMin1X3 = maxX3-6; - lMax1X3 = maxX3-2; - - lMin2X1 = 1; - lMax2X1 = 5; - lMin2X2 = maxX2-6; - lMax2X2 = maxX2-6; - lMin2X3 = maxX3-6; - lMax2X3 = maxX3-2; - - lMin3X1 = 1; - lMax3X1 = 5; - lMin3X2 = maxX2-6; - lMax3X2 = maxX2-2; - lMin3X3 = maxX3-6; - lMax3X3 = maxX3-6; - } - else if (sendDir == TSE) - { - lMin1X1 = maxX1-6; - lMax1X1 = maxX1-6; - lMin1X2 = 1; - lMax1X2 = 5; - lMin1X3 = maxX3-6; - lMax1X3 = maxX3-2; - - lMin2X1 = maxX1-6; - lMax2X1 = maxX1-2; - lMin2X2 = 5; - lMax2X2 = 5; - lMin2X3 = maxX3-6; - lMax2X3 = maxX3-2; - - lMin3X1 = maxX1-6; - lMax3X1 = maxX1-2; - lMin3X2 = 1; - lMax3X2 = 5; - lMin3X3 = maxX3-6; - lMax3X3 = maxX3-6; - } - else if (sendDir == TSW) - { - lMin1X1 = 5; - lMax1X1 = 5; - lMin1X2 = 1; - lMax1X2 = 5; - lMin1X3 = maxX3-6; - lMax1X3 = maxX3-2; - - lMin2X1 = 1; - lMax2X1 = 5; - lMin2X2 = 5; - lMax2X2 = 5; - lMin2X3 = maxX3-6; - lMax2X3 = maxX3-2; - - lMin3X1 = 1; - lMax3X1 = 5; - lMin3X2 = 1; - lMax3X2 = 5; - lMin3X3 = maxX3-6; - lMax3X3 = maxX3-6; - } - else if (sendDir == BNE) - { - lMin1X1 = maxX1-6; - lMax1X1 = maxX1-6; - lMin1X2 = maxX2-6; - lMax1X2 = maxX2-2; - lMin1X3 = 1; - lMax1X3 = 5; - - lMin2X1 = maxX1-6; - lMax2X1 = maxX1-2; - lMin2X2 = maxX2-6; - lMax2X2 = maxX2-6; - lMin2X3 = 1; - lMax2X3 = 5; - - lMin3X1 = maxX1-6; - lMax3X1 = maxX1-2; - lMin3X2 = maxX2-6; - lMax3X2 = maxX2-2; - lMin3X3 = 5; - lMax3X3 = 5; - } - else if (sendDir == BNW) - { - lMin1X1 = 5; - lMax1X1 = 5; - lMin1X2 = maxX2-6; - lMax1X2 = maxX2-2; - lMin1X3 = 1; - lMax1X3 = 5; - - lMin2X1 = 1; - lMax2X1 = 5; - lMin2X2 = maxX2-6; - lMax2X2 = maxX2-6; - lMin2X3 = 1; - lMax2X3 = 5; - - lMin3X1 = 1; - lMax3X1 = 5; - lMin3X2 = maxX2-6; - lMax3X2 = maxX2-2; - lMin3X3 = 5; - lMax3X3 = 5; - } - else if (sendDir == BSE) - { - lMin1X1 = maxX1-6; - lMax1X1 = maxX1-6; - lMin1X2 = 1; - lMax1X2 = 5; - lMin1X3 = 1; - lMax1X3 = 5; - - lMin2X1 = maxX1-6; - lMax2X1 = maxX1-2; - lMin2X2 = 5; - lMax2X2 = 5; - lMin2X3 = 1; - lMax2X3 = 5; - - lMin3X1 = maxX1-5; - lMax3X1 = maxX1-2; - lMin3X2 = 1; - lMax3X2 = 5; - lMin3X3 = 5; - lMax3X3 = 5; - } - else if (sendDir == BSW) - { - lMin1X1 = 5; - lMax1X1 = 5; - lMin1X2 = 1; - lMax1X2 = 5; - lMin1X3 = 1; - lMax1X3 = 5; - - lMin2X1 = 1; - lMax2X1 = 5; - lMin2X2 = 5; - lMax2X2 = 5; - lMin2X3 = 1; - lMax2X3 = 5; - - lMin3X1 = 1; - lMax3X1 = 5; - lMin3X2 = 1; - lMax3X2 = 5; - lMin3X3 = 5; - lMax3X3 = 5; - } - findFCCells(lMin1X1, lMin1X2, lMin1X3, lMax1X1, lMax1X2, lMax1X3, iNodeSetSender); - findFCCells(lMin2X1, lMin2X2, lMin2X3, lMax2X1, lMax2X2, lMax2X3, iNodeSetSender); - findFCCells(lMin3X1, lMin3X2, lMin3X3, lMax3X1, lMax3X2, lMax3X3, iNodeSetSender); - break; - } -} -////////////////////////////////////////////////////////////////////////// -void FineToCoarseNodeSetBlock3DConnector::fillSendVectors() -{ - using namespace D3Q27System; - - SPtr<DistributionArray3D> fFrom = block.lock()->getKernel()->getDataSet()->getFdistributions(); - - int index = 0; - - vector_type& data = this->sender->getData(); - - for(INodeVector inode : iNodeSetSender) - { - LBMReal icellC[27]; - D3Q27ICell icellF; - iprocessor->readICell(fFrom, icellF, inode[0], inode[1], inode[2]); - iprocessor->interpolateFineToCoarse(icellF, icellC, inode[3], inode[4], inode[5]); - writeICellCtoData(data, index, icellC); - } - -} -////////////////////////////////////////////////////////////////////////// -void FineToCoarseNodeSetBlock3DConnector::readICellFfromData(vector_type& data, int& index, D3Q27ICell& icellF) -{ - readNodeFromVector(data, index, icellF.BSW); - readNodeFromVector(data, index, icellF.BSE); - readNodeFromVector(data, index, icellF.BNW); - readNodeFromVector(data, index, icellF.BNE); - readNodeFromVector(data, index, icellF.TSW); - readNodeFromVector(data, index, icellF.TSE); - readNodeFromVector(data, index, icellF.TNW); - readNodeFromVector(data, index, icellF.TNE); -} -////////////////////////////////////////////////////////////////////////// -void FineToCoarseNodeSetBlock3DConnector::readNodeFromVector(vector_type& data, int& index, LBMReal* inode) -{ - for (int i = D3Q27System::STARTF; i < D3Q27System::ENDF+1; i++) - { - inode[i] = data[index++]; - } -} -////////////////////////////////////////////////////////////////////////// -void FineToCoarseNodeSetBlock3DConnector::writeICellCtoData(vector_type& data, int& index, LBMReal* icellC) -{ - for (int i = D3Q27System::STARTF; i < D3Q27System::ENDF+1; i++) - { - data[index++] = icellC[i]; - } -} -////////////////////////////////////////////////////////////////////////// -void FineToCoarseNodeSetBlock3DConnector::findCFCells(int lMinX1, int lMinX2, int lMinX3, int lMaxX1, int lMaxX2, int lMaxX3, INodeSet &inodes) -{ - int ix1, ix2, ix3; - - for (ix3 = lMinX3; ix3<=lMaxX3; ix3 += 2) - { - for (ix2 = lMinX2; ix2<=lMaxX2; ix2 += 2) - { - for (ix1 = lMinX1; ix1<=lMaxX1; ix1 += 2) - { - INodeVector inv; - inv.push_back(ix1); - inv.push_back(ix2); - inv.push_back(ix3); - //inodes.insert(inv); - inodes.push_back(inv); - } - } - } -} -////////////////////////////////////////////////////////////////////////// -void FineToCoarseNodeSetBlock3DConnector::findCFCells() -{ - using namespace D3Q27System; - - int lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3; - - ////////////////////////////////////////////////////// - //Debug - ////////////////////////////////////////////////////// - if (block.lock()->getGlobalID() == 2183) - { - int test = 0; - } - - switch (sendDir) - { - //faces - case E: case W: - if (sendDir == E) - { - lMinX1 = maxX1 - 3; - lMaxX1 = lMinX1; - } - else if (sendDir == W) - { - lMinX1 = 2; - lMaxX1 = lMinX1; - } - - if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type00) - { - lMinX2 = minX2; - lMaxX2 = maxX2 + maxOffX2 - 1; - lMinX3 = minX3; - lMaxX3 = maxX3 + maxOffX3 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type10) - { - lMinX2 = minX2 + minOffX2; - lMaxX2 = maxX2 - 1; - lMinX3 = minX3; - lMaxX3 = maxX3 + maxOffX3 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type01) - { - lMinX2 = minX2; - lMaxX2 = maxX2 + maxOffX2 - 1; - lMinX3 = minX3 + minOffX3; - lMaxX3 = maxX3 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type11) - { - lMinX2 = minX2 + minOffX2; - lMaxX2 = maxX2 - 1; - lMinX3 = minX3 + minOffX3; - lMaxX3 = maxX3 - 1; - } - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetReceiver); - break; - case N: case S: - if (sendDir == N) - { - lMinX2 = maxX2 - 3; - lMaxX2 = lMinX2; - } - else if (sendDir == S) - { - lMinX2 = 2; - lMaxX2 = lMinX2; - } - - if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type00) - { - lMinX1 = minX1; - lMaxX1 = maxX1 + maxOffX1 - 1; - lMinX3 = minX3; - lMaxX3 = maxX3 + maxOffX3 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type10) - { - lMinX1 = minX1 + minOffX1; - lMaxX1 = maxX1; - lMinX3 = minX3; - lMaxX3 = maxX3 + maxOffX3 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type01) - { - lMinX1 = minX1; - lMaxX1 = maxX1 + maxOffX1 - 1; - lMinX3 = minX3 + minOffX3; - lMaxX3 = maxX3 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type11) - { - lMinX1 = minX1 + minOffX1; - lMaxX1 = maxX1 - 1; - lMinX3 = minX3 + minOffX3; - lMaxX3 = maxX3 - 1; - } - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetReceiver); - break; - case T: case B: - if (sendDir == T) - { - lMinX3 = maxX3 - 3; - lMaxX3 = lMinX3; - } - else if (sendDir == B) - { - lMinX3 = 2; - lMaxX3 = lMinX3; - } - - if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type00) - { - lMinX1 = minX1; - lMaxX1 = maxX1 + maxOffX1 - 1; - lMinX2 = minX2; - lMaxX2 = maxX2 + maxOffX2 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type10) - { - lMinX1 = minX1 + minOffX1; - lMaxX1 = maxX1 - 1; - lMinX2 = minX2; - lMaxX2 = maxX2 + maxOffX2 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type01) - { - lMinX1 = minX1; - lMaxX1 = maxX1 + maxOffX1 - 1; - lMinX2 = minX2 + minOffX2; - lMaxX2 = maxX2 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type11) - { - lMinX1 = minX1 + minOffX1; - lMaxX1 = maxX1 - 1; - lMinX2 = minX2 + minOffX2; - lMaxX2 = maxX2 - 1; - } - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetReceiver); - break; - - //edges - //N-S-E-W - case NE: case SW: case SE: case NW: - if (sendDir == NE) - { - lMinX1 = maxX1 - 3; - lMaxX1 = lMinX1 + 2; - lMinX2 = maxX2 - 3; - lMaxX2 = lMinX2 + 2; - } - else if (sendDir == SW) - { - lMinX1 = 0; - lMaxX1 = lMinX1 + 3; - lMinX2 = 0; - lMaxX2 = lMinX2 + 3; - } - else if (sendDir == SE) - { - lMinX1 = maxX1 - 3; - lMaxX1 = lMinX1 + 2; - lMinX2 = 0; - lMaxX2 = lMinX2 + 2; - } - else if (sendDir == NW) - { - lMinX1 = 0; - lMaxX1 = lMinX1 + 2; - lMinX2 = maxX2 - 3; - lMaxX2 = lMinX2 + 2; - } - - if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type00) - { - lMinX3 = minX3; - lMaxX3 = maxX3 + maxOffX3 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type10) - { - lMinX3 = minX3 + minOffX3; - lMaxX3 = maxX3 - 1; - } - - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetReceiver); - break; - //T-B-E-W - case TE: case BW: case BE: case TW: - if (sendDir == TE) - { - lMinX1 = maxX1 - 3; - lMaxX1 = lMinX1 + 2; - lMinX3 = maxX3 - 3; - lMaxX3 = lMinX3 + 2; - } - else if (sendDir == BW) - { - lMinX1 = 0; - lMaxX1 = lMinX1 + 2; - lMinX3 = 0; - lMaxX3 = lMinX3 + 2; - } - else if (sendDir == BE) - { - lMinX1 = maxX1 - 3; - lMaxX1 = lMinX1 + 2; - lMinX3 = 0; - lMaxX3 = lMinX3 + 2; - } - else if (sendDir == TW) - { - lMinX1 = 0; - lMaxX1 = lMinX1 + 2; - lMinX3 = maxX3 - 3; - lMaxX3 = lMinX3 + 2; - } - - if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type00) - { - lMinX2 = minX2; - lMaxX2 = maxX2 + maxOffX2 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type10) - { - lMinX2 = minX2 + minOffX2; - lMaxX2 = maxX2 - 1; - } - - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetReceiver); - break; - //T-B-N-S - case TN: case BS: case BN: case TS: - if (sendDir == TN) - { - lMinX2 = maxX2 - 3; - lMaxX2 = lMinX2 + 2; - lMinX3 = maxX3 - 3; - lMaxX3 = lMinX3 + 2; - } - else if (sendDir == BS) - { - lMinX2 = 0; - lMaxX2 = lMinX2 + 2; - lMinX3 = 0; - lMaxX3 = lMinX3 + 2; - } - else if (sendDir == BN) - { - lMinX2 = maxX2 - 3; - lMaxX2 = lMinX2 + 2; - lMinX3 = 0; - lMaxX3 = lMinX3 + 2; - } - else if (sendDir == TS) - { - lMinX2 = 0; - lMaxX2 = lMinX2 + 2; - lMinX3 = maxX3 - 3; - lMaxX3 = lMinX3 + 2; - } - - if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type00) - { - lMinX1 = minX1; - lMaxX1 = maxX1 + maxOffX1 - 1; - } - else if (FineToCoarseBlock3DConnector::connType ==FineToCoarseBlock3DConnector::Type10) - { - lMinX1 = minX1 + minOffX1; - lMaxX1 = maxX1 - 1; - } - - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetReceiver); - break; - //corners - case TNE: case TNW: case TSE: case TSW: case BNE: case BNW: case BSE: case BSW: - if (sendDir == TNE) - { - lMinX1 = maxX1 - 3; - lMaxX1 = maxX1 - 1; - lMinX2 = maxX2 - 3; - lMaxX2 = maxX2 - 1; - lMinX3 = maxX3 - 3; - lMaxX3 = maxX3 - 1; - } - else if (sendDir == TNW) - { - lMinX1 = 0; - lMaxX1 = 2; - lMinX2 = maxX2 - 3; - lMaxX2 = maxX2 - 1; - lMinX3 = maxX3 - 3; - lMaxX3 = maxX3 - 1; - } - else if (sendDir == TSE) - { - lMinX1 = maxX1 - 3; - lMaxX1 = maxX1 - 1; - lMinX2 = 0; - lMaxX2 = 2; - lMinX3 = maxX3 - 3; - lMaxX3 = maxX3 - 1; - } - else if (sendDir == TSW) - { - lMinX1 = 0; - lMaxX1 = 2; - lMinX2 = 0; - lMaxX2 = 2; - lMinX3 = maxX3 - 3; - lMaxX3 = maxX3 - 1; - } - else if (sendDir == BNE) - { - lMinX1 = maxX1 - 3; - lMaxX1 = maxX1 - 1; - lMinX2 = maxX2 - 3; - lMaxX2 = maxX2 - 1; - lMinX3 = 0; - lMaxX3 = 2; - } - else if (sendDir == BNW) - { - lMinX1 = 0; - lMaxX1 = 2; - lMinX2 = maxX2 - 3; - lMaxX2 = maxX2 - 1; - lMinX3 = 0; - lMaxX3 = 2; - } - else if (sendDir == BSE) - { - lMinX1 = maxX1 - 3; - lMaxX1 = maxX1 - 1; - lMinX2 = 0; - lMaxX2 = 2; - lMinX3 = 0; - lMaxX3 = 2; - } - else if (sendDir == BSW) - { - lMinX1 = 0; - lMaxX1 = 2; - lMinX2 = 0; - lMaxX2 = 2; - lMinX3 = 0; - lMaxX3 = 2; - } - findCFCells(lMinX1, lMinX2, lMinX3, lMaxX1, lMaxX2, lMaxX3, iNodeSetReceiver); - break; - } -} -////////////////////////////////////////////////////////////////////////// -void FineToCoarseNodeSetBlock3DConnector::distributeReceiveVectors() -{ - using namespace D3Q27System; - - SPtr<DistributionArray3D> fTo = FineToCoarseBlock3DConnector::block.lock()->getKernel()->getDataSet()->getFdistributions(); - - int index = 0; - - vector_type& data = this->receiver->getData(); - - for(INodeVector inode : iNodeSetReceiver) - { - D3Q27ICell icellF; - this->readICellFfromData(data, index, icellF); - iprocessor->writeICellInv(fTo, icellF, inode[0], inode[1], inode[2]); - } -} -////////////////////////////////////////////////////////////////////////// -// -//void FineToCoarseNodeSetBlock3DConnector::getLocalMinMax(int& minX1, int& minX2, int& minX3, int& maxX1, int& maxX2, int& maxX3) -//{ -// using namespace D3Q27System; -// int TminX1 = minX1; int TminX2 = minX2; int TminX3 = minX3; int TmaxX1 = maxX1; int TmaxX2 = maxX2; int TmaxX3 = maxX3; -// -// if (block.lock()->hasInterpolationFlagFC(E)) -// { -// if (maxX1==TmaxX1) maxX1 -= 2; -// } -// if (block.lock()->hasInterpolationFlagFC(W)) -// { -// if (minX1==TminX1) minX1 += 4; -// } -// if (block.lock()->hasInterpolationFlagFC(N)) -// { -// if (maxX2==TmaxX2) maxX2 -= 2; -// } -// if (block.lock()->hasInterpolationFlagFC(S)) -// { -// if (minX2==TminX2) minX2 += 4; -// } -// if (block.lock()->hasInterpolationFlagFC(T)) -// { -// if (maxX3==TmaxX3) maxX3 -= 2; -// } -// if (block.lock()->hasInterpolationFlagFC(B)) -// { -// if (minX3==TminX3) minX3 += 4; -// } -// -// //////////// -// /////E-W-N-S -// if (block.lock()->hasInterpolationFlagFC(NE)&& !block.lock()->hasInterpolationFlagFC(N) && !block.lock()->hasInterpolationFlagFC(E)) -// { -// if (maxX1==TmaxX1) maxX1 -= 2; -// if (maxX2==TmaxX2) maxX2 -= 2; -// } -// if (block.lock()->hasInterpolationFlagFC(SW)&& !block.lock()->hasInterpolationFlagFC(W) && !block.lock()->hasInterpolationFlagFC(S)) -// { -// if (minX1==TminX1) minX1 += 4; -// if (minX2==TminX2) minX2 += 4; -// } -// if (block.lock()->hasInterpolationFlagFC(SE)&& !block.lock()->hasInterpolationFlagFC(E) && !block.lock()->hasInterpolationFlagFC(S)) -// { -// if (maxX1==TmaxX1) maxX1 -= 2; -// if (minX2==TminX2) minX2 += 4; -// } -// if (block.lock()->hasInterpolationFlagFC(NW)&& !block.lock()->hasInterpolationFlagFC(N) && !block.lock()->hasInterpolationFlagFC(W)) -// { -// if (minX1==TminX1) minX1 += 4; -// if (maxX2==TmaxX2) maxX2 -= 2; -// } -// -// //////T-B-E-W -// if (block.lock()->hasInterpolationFlagFC(TE) && !block.lock()->hasInterpolationFlagFC(E) && !block.lock()->hasInterpolationFlagFC(T)) -// { -// if (maxX1==TmaxX1) maxX1 -= 2; -// if (maxX3==TmaxX3) maxX3 -= 2; -// } -// if (block.lock()->hasInterpolationFlagFC(BW)&& !block.lock()->hasInterpolationFlagFC(W) && !block.lock()->hasInterpolationFlagFC(B)) -// { -// if (minX1==TminX1) minX1 += 4; -// if (minX3==TminX3) minX3 += 4; -// } -// if (block.lock()->hasInterpolationFlagFC(BE)&& !block.lock()->hasInterpolationFlagFC(E) && !block.lock()->hasInterpolationFlagFC(B)) -// { -// if (maxX1==TmaxX1) maxX1 -= 2; -// if (minX3==TminX3) minX3 += 4; -// } -// if (block.lock()->hasInterpolationFlagFC(TW)&& !block.lock()->hasInterpolationFlagFC(W) && !block.lock()->hasInterpolationFlagFC(T)) -// { -// if (minX1==TminX1) minX1 += 4; -// if (maxX3==TmaxX3) maxX3 -= 2; -// } -// -// -// ////T-B-N-S -// if (block.lock()->hasInterpolationFlagFC(TN)&& !block.lock()->hasInterpolationFlagFC(N) && !block.lock()->hasInterpolationFlagFC(T)) -// { -// if (maxX2==TmaxX2) maxX2 -= 2; -// if (maxX3==TmaxX3) maxX3 -= 2; -// } -// if (block.lock()->hasInterpolationFlagFC(BS)&& !block.lock()->hasInterpolationFlagFC(S) && !block.lock()->hasInterpolationFlagFC(B)) -// { -// if (minX2==TminX2) minX2 += 4; -// if (minX3==TminX3) minX3 += 4; -// } -// if (block.lock()->hasInterpolationFlagFC(BN)&& !block.lock()->hasInterpolationFlagFC(N) && !block.lock()->hasInterpolationFlagFC(B)) -// { -// if (maxX2==TmaxX2) maxX2 -= 2; -// if (minX3==TminX3) minX3 += 4; -// } -// if (block.lock()->hasInterpolationFlagFC(TS) && !block.lock()->hasInterpolationFlagFC(S) && !block.lock()->hasInterpolationFlagFC(T)) -// { -// if (minX2==TminX2) minX2 += 4; -// if (maxX3==TmaxX3) maxX3 -= 2; -// } -//} -////////////////////////////////////////////////////////////////////////// - diff --git a/src/cpu/VirtualFluidsCore/Connectors/FineToCoarseNodeSetBlock3DConnector.h b/src/cpu/VirtualFluidsCore/Connectors/FineToCoarseNodeSetBlock3DConnector.h deleted file mode 100644 index 1f4051a66..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/FineToCoarseNodeSetBlock3DConnector.h +++ /dev/null @@ -1,78 +0,0 @@ -/// \file CoarseToFineNodeSetBlock3DConnector.h -/// \class CoarseToFineNodeSetBlock3DConnector -/// \brief Connector interpolates and sends data from coarse level to fine. -/// \author Konstantin Kutscher -/// \date 21.05.2015 - -#ifndef FineToCoarseNodeSetBlock3DConnector_H -#define FineToCoarseNodeSetBlock3DConnector_H - -#include <vector> -#include "FineToCoarseBlock3DConnector.h" -#include "D3Q27System.h" -#include "Block3D.h" -#include "Grid3D.h" -#include "LBMKernel.h" -#include "InterpolationProcessor.h" -#include "MathUtil.hpp" -#include <PointerDefinitions.h> - - -class Block3D; - -//daten werden in einen vector (dieser befindet sich im transmitter) kopiert -//der vector wird via transmitter uebertragen -//transmitter kann ein lokal, MPI, RCG, CTL oder was auch immer fuer ein -//transmitter sein, der von Transmitter abgeleitet ist ;-) - -class FineToCoarseNodeSetBlock3DConnector : public FineToCoarseBlock3DConnector -{ -public: - FineToCoarseNodeSetBlock3DConnector(SPtr<Block3D> block, VectorTransmitterPtr sender, VectorTransmitterPtr receiver, int sendDir, InterpolationProcessorPtr iprocessor, CFconnectorType connType); - void init(); - void fillSendVectors(); - void distributeReceiveVectors(); -protected: - typedef std::vector< int > INodeVector; - typedef std::vector < INodeVector > INodeSet; - INodeSet iNodeSetSender; - INodeSet iNodeSetReceiver; - - void readICellFfromData(vector_type& data, int& index, D3Q27ICell& icellF); - void readNodeFromVector(vector_type& data, int& index, LBMReal* inode); - - void writeICellCtoData(vector_type& data, int& index, LBMReal* icellC); - - void findFCCells(); - void findFCCells(int lMinX1, int lMinX2, int lMinX3, int lMaxX1, int lMaxX2, int lMaxX3, INodeSet &inodes); - - void findCFCells(); - void findCFCells(int lMinX1, int lMinX2, int lMinX3, int lMaxX1, int lMaxX2, int lMaxX3, INodeSet &inodes); - - //void getLocalMinMax(int& minX1, int& minX2, int& minX3, int& maxX1, int& maxX2, int& maxX3); - - - int bMaxX1, bMaxX2, bMaxX3; - - int minX1; - int minX2; - int minX3; - - int maxX1; - int maxX2; - int maxX3; - - int minOffX1; - int minOffX2; - int minOffX3; - - int maxOffX1; - int maxOffX2; - int maxOffX3; -}; - - - - - -#endif diff --git a/src/cpu/VirtualFluidsCore/Connectors/LocalBlock3DConnector.h b/src/cpu/VirtualFluidsCore/Connectors/LocalBlock3DConnector.h index cab9a684e..c57e1f6e0 100644 --- a/src/cpu/VirtualFluidsCore/Connectors/LocalBlock3DConnector.h +++ b/src/cpu/VirtualFluidsCore/Connectors/LocalBlock3DConnector.h @@ -1,58 +1,74 @@ -#ifndef LocalBlock3DConnector_H -#define LocalBlock3DConnector_H - -#include "Block3DConnector.h" -#include "Block3D.h" -#include "PointerDefinitions.h" - -class LocalBlock3DConnector : public Block3DConnector -{ -public: - LocalBlock3DConnector(SPtr<Block3D> from, SPtr<Block3D> to, int sendDir) - : Block3DConnector(sendDir) - , from(from) - , to(to) - { - - } - virtual ~LocalBlock3DConnector() {} - void sendTransmitterDataSize() {} - void receiveTransmitterDataSize() {} - virtual void init() = 0; - void prepareForReceive() {} - void prepareForSend() {} - void fillSendVectors() {} - virtual void sendVectors()=0; - void receiveVectors() {} - - void distributeReceiveVectors() {} - - bool isLocalConnector() { return true; } - bool isRemoteConnector() { return false; } - bool isInterpolationConnectorCF() { return false; } - bool isInterpolationConnectorFC() { return false; } - - double getSendRecieveTime(); - - void prepareForSendX1() {} - void prepareForSendX2() {} - void prepareForSendX3() {} - - void sendVectorsX1() {} - void sendVectorsX2() {} - void sendVectorsX3() {} - - void prepareForReceiveX1() {} - void prepareForReceiveX2() {} - void prepareForReceiveX3() {} - - void receiveVectorsX1() {} - void receiveVectorsX2() {} - void receiveVectorsX3() {} - -protected: - WPtr<Block3D> from; - WPtr<Block3D> to; -}; - -#endif //LocalBlock3DConnector_H +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file LocalBlock3DConnector.h +//! \ingroup Connectors +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef LocalBlock3DConnector_H +#define LocalBlock3DConnector_H + +#include "Block3DConnector.h" +#include "Block3D.h" +#include "PointerDefinitions.h" + +//! A class provides an interface for connectors in shared memory +class LocalBlock3DConnector : public Block3DConnector +{ +public: + LocalBlock3DConnector(SPtr<Block3D> from, SPtr<Block3D> to, int sendDir) + : Block3DConnector(sendDir) + , from(from) + , to(to) + { + + } + virtual ~LocalBlock3DConnector() {} + void sendTransmitterDataSize() {} + void receiveTransmitterDataSize() {} + virtual void init() = 0; + void prepareForReceive() {} + void prepareForSend() {} + void fillSendVectors() {} + virtual void sendVectors()=0; + void receiveVectors() {} + + void distributeReceiveVectors() {} + + bool isLocalConnector() { return true; } + bool isRemoteConnector() { return false; } + bool isInterpolationConnectorCF() { return false; } + bool isInterpolationConnectorFC() { return false; } + +protected: + WPtr<Block3D> from; + WPtr<Block3D> to; +}; + +#endif //LocalBlock3DConnector_H diff --git a/src/cpu/VirtualFluidsCore/Connectors/RemoteBlock3DConnector.cpp b/src/cpu/VirtualFluidsCore/Connectors/RemoteBlock3DConnector.cpp deleted file mode 100644 index 388df6c2a..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/RemoteBlock3DConnector.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include "RemoteBlock3DConnector.h" - -////////////////////////////////////////////////////////////////////////// -RemoteBlock3DConnector::RemoteBlock3DConnector(SPtr<Block3D> block - , VectorTransmitterPtr sender - , VectorTransmitterPtr receiver - , int sendDir) - : Block3DConnector(sendDir) - , block(block) - , sender(sender) - , receiver(receiver) -{ - if (!block || !sender || !receiver) - UB_THROW(UbException(UB_EXARGS, "sender or receiver == NULL!!")); -} -////////////////////////////////////////////////////////////////////////// - -bool RemoteBlock3DConnector::isLocalConnector() -{ - return !this->isRemoteConnector(); -} -////////////////////////////////////////////////////////////////////////// - -bool RemoteBlock3DConnector::isRemoteConnector() -{ - return ((sender && sender->isRemoteTransmitter()) - || (receiver && receiver->isRemoteTransmitter())); -} -////////////////////////////////////////////////////////////////////////// - -void RemoteBlock3DConnector::sendTransmitterDataSize() -{ - assert(sender !=NULL); sender->sendDataSize(); -} -////////////////////////////////////////////////////////////////////////// - -void RemoteBlock3DConnector::receiveTransmitterDataSize() -{ - assert(receiver!=NULL); receiver->receiveDataSize(); -} -////////////////////////////////////////////////////////////////////////// - -void RemoteBlock3DConnector::prepareForSend() -{ - assert(sender !=NULL); sender->prepareForSend(); -} -////////////////////////////////////////////////////////////////////////// - -void RemoteBlock3DConnector::sendVectors() -{ - assert(sender !=NULL); sender->sendData(); -} -////////////////////////////////////////////////////////////////////////// - -void RemoteBlock3DConnector::prepareForReceive() -{ - assert(receiver!=NULL); receiver->prepareForReceive(); -} -////////////////////////////////////////////////////////////////////////// - -void RemoteBlock3DConnector::receiveVectors() -{ - assert(receiver!=NULL); receiver->receiveData(); -} diff --git a/src/cpu/VirtualFluidsCore/Connectors/RemoteBlock3DConnector.h b/src/cpu/VirtualFluidsCore/Connectors/RemoteBlock3DConnector.h deleted file mode 100644 index 8db7d5ee7..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/RemoteBlock3DConnector.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef RemoteBlock3DConnector_H -#define RemoteBlock3DConnector_H - -#include <vector> - -#include "TransmitterType.h" -#include "Block3DConnector.h" -#include "D3Q27System.h" -#include "Block3D.h" -#include "LBMKernel.h" -#include "EsoTwistD3Q27System.h" - - -//daten werden in einen vector (dieser befindet sich im transmitter) kopiert -//der vector wird via transmitter uebertragen -//transmitter kann ein lokal, MPI, RCG, CTL oder was auch immer fuer ein -//transmitter sein, der von Transmitter abgeleitet ist ;-) -class RemoteBlock3DConnector : public Block3DConnector -{ -public: - RemoteBlock3DConnector(SPtr<Block3D> block - , VectorTransmitterPtr sender - , VectorTransmitterPtr receiver - , int sendDir); - - bool isLocalConnector(); - bool isRemoteConnector(); - - virtual void init() = 0; - - void sendTransmitterDataSize(); - void receiveTransmitterDataSize(); - - void prepareForSend(); - void sendVectors(); - - void prepareForReceive(); - void receiveVectors(); - - virtual void fillSendVectors() = 0; - virtual void distributeReceiveVectors() = 0; - - bool isInterpolationConnectorCF() { return false; } - bool isInterpolationConnectorFC() { return false; } - - double getSendRecieveTime() { return 0; } - - void prepareForSendX1() {} - void prepareForSendX2() {} - void prepareForSendX3() {} - - void sendVectorsX1() {} - void sendVectorsX2() {} - void sendVectorsX3() {} - - void prepareForReceiveX1() {} - void prepareForReceiveX2() {} - void prepareForReceiveX3() {} - - void receiveVectorsX1() {} - void receiveVectorsX2() {} - void receiveVectorsX3() {} - -protected: - WPtr<Block3D> block; - VectorTransmitterPtr sender; - VectorTransmitterPtr receiver; -}; - - -#endif //RemoteBlock3DConnector_H - diff --git a/src/cpu/VirtualFluidsCore/Connectors/TransmitterType.h b/src/cpu/VirtualFluidsCore/Connectors/TransmitterType.h deleted file mode 100644 index a68d3c5fa..000000000 --- a/src/cpu/VirtualFluidsCore/Connectors/TransmitterType.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef TransmitterType_h__ -#define TransmitterType_h__ - -#include "basics/transmitter/TbTransmitter.h" -#include "basics/transmitter/TbTransmitterLocal.h" -#include "basics/container/CbVector.h" -#include "D3Q27System.h" -#include <PointerDefinitions.h> - - -typedef TbTransmitter< CbVector< LBMReal > > VectorTransmitter; -typedef VectorTransmitter::value_type vector_type; -typedef SPtr< TbTransmitter< CbVector< LBMReal > > > VectorTransmitterPtr; - -#endif // TransmitterType_h__ - diff --git a/src/cpu/VirtualFluidsCore/Data/CMakePackage.txt b/src/cpu/VirtualFluidsCore/Data/CMakePackage.txt index 9354d3d00..1b8416f01 100644 --- a/src/cpu/VirtualFluidsCore/Data/CMakePackage.txt +++ b/src/cpu/VirtualFluidsCore/Data/CMakePackage.txt @@ -1,2 +1,2 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) +GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) diff --git a/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSoA.cpp b/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSoA.cpp deleted file mode 100644 index a1053e787..000000000 --- a/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSoA.cpp +++ /dev/null @@ -1,594 +0,0 @@ -#include "D3Q27EsoTwist3DSoA.h" -#include <D3Q27System.h> -#include "EsoTwistD3Q27System.h" - -D3Q27EsoTwist3DSoA::D3Q27EsoTwist3DSoA() -{ -} -////////////////////////////////////////////////////////////////////////// -D3Q27EsoTwist3DSoA::D3Q27EsoTwist3DSoA( const size_t& nx1, const size_t& nx2, const size_t& nx3, LBMReal value ) -{ - this->NX1 = nx1; - this->NX2 = nx2; - this->NX3 = nx3; - - d.E = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.W = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.N = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.S = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.T = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.B = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.NE = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.SW = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.SE = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.NW = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.TE = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.BW = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.BE = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.TW = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.TN = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.BS = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.BN = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.TS = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.TNE = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.TNW = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.TSE = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.TSW = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.BNE = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.BNW = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.BSE = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.BSW = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1+1, nx2+1, nx3+1, value)); - d.ZERO= CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1, nx2, nx3, value)); -} -////////////////////////////////////////////////////////////////////////// -D3Q27EsoTwist3DSoA::~D3Q27EsoTwist3DSoA() -{ - -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSoA::swap() -{ - std::swap(d.E , d.W ); - std::swap(d.N , d.S ); - std::swap(d.T , d.B ); - std::swap(d.NE , d.SW ); - std::swap(d.NW , d.SE ); - std::swap(d.TE , d.BW ); - std::swap(d.TW , d.BE ); - std::swap(d.TN , d.BS ); - std::swap(d.TS , d.BN ); - std::swap(d.TNE, d.BSW); - std::swap(d.TNW, d.BSE); - std::swap(d.TSE, d.BNW); - std::swap(d.TSW, d.BNE); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSoA::getDistribution(LBMReal* const f, size_t x1, size_t x2, size_t x3) -{ - size_t x1p = x1 + 1; - size_t x2p = x2 + 1; - size_t x3p = x3 + 1; - - f[D3Q27System::E] = (*d.E)(x1,x2,x3); - f[D3Q27System::N] = (*d.N)(x1,x2,x3); - f[D3Q27System::T] = (*d.T)(x1,x2,x3); - f[D3Q27System::NE] = (*d.NE)(x1,x2,x3); - f[D3Q27System::NW] = (*d.NW)(x1p,x2,x3); - f[D3Q27System::TE] = (*d.TE)(x1,x2,x3); - f[D3Q27System::TW] = (*d.TW)(x1p,x2,x3); - f[D3Q27System::TN] = (*d.TN)(x1,x2,x3); - f[D3Q27System::TS] = (*d.TS)(x1,x2p,x3); - f[D3Q27System::TNE] = (*d.TNE)(x1,x2,x3); - f[D3Q27System::TNW] = (*d.TNW)(x1p,x2,x3); - f[D3Q27System::TSE] = (*d.TSE)(x1,x2p,x3); - f[D3Q27System::TSW] = (*d.TSW)(x1p,x2p,x3); - - f[D3Q27System::W ] = (*d.W)(x1p,x2,x3); - f[D3Q27System::S ] = (*d.S)(x1,x2p,x3); - f[D3Q27System::B ] = (*d.B)(x1,x2,x3p); - f[D3Q27System::SW] = (*d.SW)(x1p,x2p,x3); - f[D3Q27System::SE] = (*d.SE)(x1,x2p,x3); - f[D3Q27System::BW] = (*d.BW)(x1p,x2,x3p); - f[D3Q27System::BE] = (*d.BE)(x1,x2,x3p); - f[D3Q27System::BS] = (*d.BS)(x1,x2p,x3p); - f[D3Q27System::BN] = (*d.BN)(x1,x2,x3p); - f[D3Q27System::BSW] = (*d.BSW)(x1p,x2p,x3p); - f[D3Q27System::BSE] = (*d.BSE)(x1,x2p,x3p); - f[D3Q27System::BNW] = (*d.BNW)(x1p,x2,x3p); - f[D3Q27System::BNE] = (*d.BNE)(x1,x2,x3p); - - f[D3Q27System::ZERO] = (*d.ZERO)(x1,x2,x3); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSoA::setDistribution(const LBMReal* const f, size_t x1, size_t x2, size_t x3) -{ - size_t x1p = x1 + 1; - size_t x2p = x2 + 1; - size_t x3p = x3 + 1; - - (*d.E)(x1,x2,x3) = f[D3Q27System::INV_E]; - (*d.N)(x1,x2,x3) = f[D3Q27System::INV_N]; - (*d.T)(x1,x2,x3) = f[D3Q27System::INV_T]; - (*d.NE)(x1,x2,x3) = f[D3Q27System::INV_NE]; - (*d.NW)(x1p,x2,x3) = f[D3Q27System::INV_NW]; - (*d.TE)(x1,x2,x3) = f[D3Q27System::INV_TE]; - (*d.TW)(x1p,x2,x3) = f[D3Q27System::INV_TW]; - (*d.TN)(x1,x2,x3) = f[D3Q27System::INV_TN]; - (*d.TS)(x1,x2p,x3) = f[D3Q27System::INV_TS]; - (*d.TNE)(x1,x2,x3) = f[D3Q27System::INV_TNE]; - (*d.TNW)(x1p,x2,x3) = f[D3Q27System::INV_TNW]; - (*d.TSE)(x1,x2p,x3) = f[D3Q27System::INV_TSE]; - (*d.TSW)(x1p,x2p,x3) = f[D3Q27System::INV_TSW]; - - (*d.W)(x1p,x2,x3) = f[D3Q27System::INV_W ]; - (*d.S)(x1,x2p,x3) = f[D3Q27System::INV_S ]; - (*d.B)(x1,x2,x3p) = f[D3Q27System::INV_B ]; - (*d.SW)(x1p,x2p,x3) = f[D3Q27System::INV_SW]; - (*d.SE)(x1,x2p,x3) = f[D3Q27System::INV_SE]; - (*d.BW)(x1p,x2,x3p) = f[D3Q27System::INV_BW]; - (*d.BE)(x1,x2,x3p) = f[D3Q27System::INV_BE]; - (*d.BS)(x1,x2p,x3p) = f[D3Q27System::INV_BS]; - (*d.BN)(x1,x2,x3p) = f[D3Q27System::INV_BN]; - (*d.BSW)(x1p,x2p,x3p) = f[D3Q27System::INV_BSW]; - (*d.BSE)(x1,x2p,x3p) = f[D3Q27System::INV_BSE]; - (*d.BNW)(x1p,x2,x3p) = f[D3Q27System::INV_BNW]; - (*d.BNE)(x1,x2,x3p) = f[D3Q27System::INV_BNE]; - - (*d.ZERO)(x1,x2,x3) = f[D3Q27System::ZERO]; -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSoA::getDistributionInv(LBMReal* const f, size_t x1, size_t x2, size_t x3) -{ - f[D3Q27System::INV_E] = (*d.E)(x1,x2,x3); - f[D3Q27System::INV_N] = (*d.N)(x1,x2,x3); - f[D3Q27System::INV_T] = (*d.T)(x1,x2,x3); - f[D3Q27System::INV_NE] = (*d.NE)(x1,x2,x3); - f[D3Q27System::INV_NW] = (*d.NW)(x1+1,x2,x3); - f[D3Q27System::INV_TE] = (*d.TE)(x1,x2,x3); - f[D3Q27System::INV_TW] = (*d.TW)(x1+1,x2,x3); - f[D3Q27System::INV_TN] = (*d.TN)(x1,x2,x3); - f[D3Q27System::INV_TS] = (*d.TS)(x1,x2+1,x3); - f[D3Q27System::INV_TNE] = (*d.TNE)(x1,x2,x3); - f[D3Q27System::INV_TNW] = (*d.TNW)(x1+1,x2,x3); - f[D3Q27System::INV_TSE] = (*d.TSE)(x1,x2+1,x3); - f[D3Q27System::INV_TSW] = (*d.TSW)(x1+1,x2+1,x3); - - f[D3Q27System::INV_W ] = (*d.W)(x1+1,x2,x3 ); - f[D3Q27System::INV_S ] = (*d.S)(x1,x2+1,x3 ); - f[D3Q27System::INV_B ] = (*d.B)(x1,x2,x3+1 ); - f[D3Q27System::INV_SW] = (*d.SW)(x1+1,x2+1,x3 ); - f[D3Q27System::INV_SE] = (*d.SE)(x1,x2+1,x3 ); - f[D3Q27System::INV_BW] = (*d.BW)(x1+1,x2,x3+1 ); - f[D3Q27System::INV_BE] = (*d.BE)(x1,x2,x3+1 ); - f[D3Q27System::INV_BS] = (*d.BS)(x1,x2+1,x3+1 ); - f[D3Q27System::INV_BN] = (*d.BN)(x1,x2,x3+1 ); - f[D3Q27System::INV_BSW] = (*d.BSW)(x1+1,x2+1,x3+1); - f[D3Q27System::INV_BSE] = (*d.BSE)(x1,x2+1,x3+1); - f[D3Q27System::INV_BNW] = (*d.BNW)(x1+1,x2,x3+1); - f[D3Q27System::INV_BNE] = (*d.BNE)(x1,x2,x3+1); - - f[D3Q27System::ZERO] = (*d.ZERO)(x1,x2,x3); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSoA::setDistributionInv(const LBMReal* const f, size_t x1, size_t x2, size_t x3) -{ - //(*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = f[D3Q27System::E]; - //(*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = f[D3Q27System::N]; - //(*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = f[D3Q27System::T]; - //(*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = f[D3Q27System::NE]; - //(*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3) = f[D3Q27System::NW]; - //(*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = f[D3Q27System::TE]; - //(*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3) = f[D3Q27System::TW]; - //(*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = f[D3Q27System::TN]; - //(*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3) = f[D3Q27System::TS]; - //(*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = f[D3Q27System::TNE]; - //(*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3) = f[D3Q27System::TNW]; - //(*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3) = f[D3Q27System::TSE]; - //(*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3) = f[D3Q27System::TSW]; - - //(*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ) = f[D3Q27System::W ]; - //(*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ) = f[D3Q27System::S ]; - //(*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ) = f[D3Q27System::B ]; - //(*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ) = f[D3Q27System::SW]; - //(*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ) = f[D3Q27System::SE]; - //(*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ) = f[D3Q27System::BW]; - //(*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ) = f[D3Q27System::BE]; - //(*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ) = f[D3Q27System::BS]; - //(*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ) = f[D3Q27System::BN]; - //(*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1) = f[D3Q27System::BSW]; - //(*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1) = f[D3Q27System::BSE]; - //(*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1) = f[D3Q27System::BNW]; - //(*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1) = f[D3Q27System::BNE]; - - //(*this->zeroDistributions)(x1,x2,x3) = f[D3Q27System::ZERO]; -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSoA::setDistributionForDirection(const LBMReal* const f, size_t x1, size_t x2, size_t x3, unsigned long int direction) -{ - //bool directionFlag = false; - //if ((direction & EsoTwistD3Q27System::etE) == EsoTwistD3Q27System::etE) - // (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ) = f[D3Q27System::E]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etW) == EsoTwistD3Q27System::etW) - // (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = f[D3Q27System::W]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etS) == EsoTwistD3Q27System::etS) - // (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = f[D3Q27System::S]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etN) == EsoTwistD3Q27System::etN) - // (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ) = f[D3Q27System::N]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etB) == EsoTwistD3Q27System::etB) - // (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = f[D3Q27System::B]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etT) == EsoTwistD3Q27System::etT) - // (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ) = f[D3Q27System::T]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etSW) == EsoTwistD3Q27System::etSW) - // (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = f[D3Q27System::SW]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etNE) == EsoTwistD3Q27System::etNE) - // (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ) = f[D3Q27System::NE]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etNW) == EsoTwistD3Q27System::etNW) - // (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ) = f[D3Q27System::NW]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etSE) == EsoTwistD3Q27System::etSE) - // (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3) = f[D3Q27System::SE]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etBW) == EsoTwistD3Q27System::etBW) - // (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = f[D3Q27System::BW]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etTE) == EsoTwistD3Q27System::etTE) - // (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ) = f[D3Q27System::TE]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etTW) == EsoTwistD3Q27System::etTW) - // (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ) = f[D3Q27System::TW]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etBE) == EsoTwistD3Q27System::etBE) - // (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3) = f[D3Q27System::BE]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etBS) == EsoTwistD3Q27System::etBS) - // (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = f[D3Q27System::BS]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etTN) == EsoTwistD3Q27System::etTN) - // (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ) = f[D3Q27System::TN]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etTS) == EsoTwistD3Q27System::etTS) - // (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ) = f[D3Q27System::TS]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etBN) == EsoTwistD3Q27System::etBN) - // (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3) = f[D3Q27System::BN]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etBSW) == EsoTwistD3Q27System::etBSW) - // (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = f[D3Q27System::BSW]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etTNE) == EsoTwistD3Q27System::etTNE) - // (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1) = f[D3Q27System::TNE]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etBSE) == EsoTwistD3Q27System::etBSE) - // (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3) = f[D3Q27System::BSE]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etTNW) == EsoTwistD3Q27System::etTNW) - // (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1) = f[D3Q27System::TNW]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etBNW) == EsoTwistD3Q27System::etBNW) - // (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3) = f[D3Q27System::BNW]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etTSE) == EsoTwistD3Q27System::etTSE) - // (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1) = f[D3Q27System::TSE]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etBNE) == EsoTwistD3Q27System::etBNE) - // (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3) = f[D3Q27System::BNE]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::etTSW) == EsoTwistD3Q27System::etTSW) - // (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1) = f[D3Q27System::TSW]; directionFlag=true; - //if ((direction & EsoTwistD3Q27System::ZERO) == EsoTwistD3Q27System::ZERO) - // (*this->zeroDistributions)(x1,x2,x3) = f[D3Q27System::ZERO]; directionFlag=true; -//#ifdef _DEBUG -// if(!directionFlag)UB_THROW( UbException(UB_EXARGS, "Direction didn't find") ); -//#endif //DEBUG -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSoA::setDistributionForDirection(LBMReal f, size_t x1, size_t x2, size_t x3, int direction) -{ - //switch (direction) - //{ - //case D3Q27System::E : - // (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ) = f; - // break; - //case D3Q27System::W : - // (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = f; - // break; - //case D3Q27System::S : - // (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = f; - // break; - //case D3Q27System::N : - // (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ) = f; - // break; - //case D3Q27System::B : - // (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = f; - // break; - //case D3Q27System::T : - // (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ) = f; - // break; - //case D3Q27System::SW : - // (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = f; - // break; - //case D3Q27System::NE : - // (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ) = f; - // break; - //case D3Q27System::NW : - // (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ) = f; - // break; - //case D3Q27System::SE : - // (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3) = f; - // break; - //case D3Q27System::BW : - // (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = f; - // break; - //case D3Q27System::TE : - // (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ) = f; - // break; - //case D3Q27System::TW : - // (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ) = f; - // break; - //case D3Q27System::BE : - // (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3) = f; - // break; - //case D3Q27System::BS : - // (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = f; - // break; - //case D3Q27System::TN : - // (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ) = f; - // break; - //case D3Q27System::TS : - // (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ) = f; - // break; - //case D3Q27System::BN : - // (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3) = f; - // break; - //case D3Q27System::BSW : - // (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = f; - // break; - //case D3Q27System::TNE : - // (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1) = f; - // break; - //case D3Q27System::BSE : - // (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3) = f; - // break; - //case D3Q27System::TNW : - // (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1) = f; - // break; - //case D3Q27System::BNW : - // (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3) = f; - // break; - //case D3Q27System::TSE : - // (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1) = f; - // break; - //case D3Q27System::BNE : - // (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3) = f; - // break; - //case D3Q27System::TSW : - // (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1) = f; - // break; - //case D3Q27System::ZERO : - // (*this->zeroDistributions)(x1,x2,x3) = f; - // break; - //default: - // UB_THROW( UbException(UB_EXARGS, "Direction didn't find") ); - //} -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSoA::setDistributionInvForDirection(const LBMReal* const f, size_t x1, size_t x2, size_t x3, unsigned long int direction) -{ -// bool directionFlag = false; -// if ((direction & EsoTwistD3Q27System::etE) == EsoTwistD3Q27System::etE) -// (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = f[D3Q27System::E]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etW) == EsoTwistD3Q27System::etW) -// (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ) = f[D3Q27System::W]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etS) == EsoTwistD3Q27System::etS) -// (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ) = f[D3Q27System::S]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etN) == EsoTwistD3Q27System::etN) -// (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = f[D3Q27System::N]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etB) == EsoTwistD3Q27System::etB) -// (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ) = f[D3Q27System::B]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etT) == EsoTwistD3Q27System::etT) -// (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = f[D3Q27System::T]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etSW) == EsoTwistD3Q27System::etSW) -// (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ) = f[D3Q27System::SW]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etNE) == EsoTwistD3Q27System::etNE) -// (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = f[D3Q27System::NE]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etNW) == EsoTwistD3Q27System::etNW) -// (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3) = f[D3Q27System::NW]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etSE) == EsoTwistD3Q27System::etSE) -// (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ) = f[D3Q27System::SE]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etBW) == EsoTwistD3Q27System::etBW) -// (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ) = f[D3Q27System::BW]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etTE) == EsoTwistD3Q27System::etTE) -// (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = f[D3Q27System::TE]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etTW) == EsoTwistD3Q27System::etTW) -// (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3) = f[D3Q27System::TW]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etBE) == EsoTwistD3Q27System::etBE) -// (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ) = f[D3Q27System::BE]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etBS) == EsoTwistD3Q27System::etBS) -// (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ) = f[D3Q27System::BS]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etTN) == EsoTwistD3Q27System::etTN) -// (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = f[D3Q27System::TN]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etTS) == EsoTwistD3Q27System::etTS) -// (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3) = f[D3Q27System::TS]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etBN) == EsoTwistD3Q27System::etBN) -// (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ) = f[D3Q27System::BN]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etBSW) == EsoTwistD3Q27System::etBSW) -// (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1) = f[D3Q27System::BSW]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etTNE) == EsoTwistD3Q27System::etTNE) -// (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = f[D3Q27System::TNE]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etBSE) == EsoTwistD3Q27System::etBSE) -// (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1) = f[D3Q27System::BSE]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etTNW) == EsoTwistD3Q27System::etTNW) -// (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3) = f[D3Q27System::TNW]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etBNW) == EsoTwistD3Q27System::etBNW) -// (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1) = f[D3Q27System::BNW]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etTSE) == EsoTwistD3Q27System::etTSE) -// (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3) = f[D3Q27System::TSE]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etBNE) == EsoTwistD3Q27System::etBNE) -// (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1)= f[D3Q27System::BNE]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::etTSW) == EsoTwistD3Q27System::etTSW) -// (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3) = f[D3Q27System::TSW]; directionFlag=true; -// if ((direction & EsoTwistD3Q27System::ZERO) == EsoTwistD3Q27System::ZERO) -// (*this->zeroDistributions)(x1,x2,x3) = f[D3Q27System::ZERO]; directionFlag=true; -//#ifdef _DEBUG -// if(!directionFlag)UB_THROW( UbException(UB_EXARGS, "Direction didn't find") ); -//#endif //DEBUG -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSoA::setDistributionInvForDirection(LBMReal f, size_t x1, size_t x2, size_t x3, unsigned long int direction) -{ - //switch (direction) - //{ - //case D3Q27System::E : - // (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = f; - // break; - //case D3Q27System::W : - // (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ) = f; - // break; - //case D3Q27System::S : - // (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ) = f; - // break; - //case D3Q27System::N : - // (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = f; - // break; - //case D3Q27System::B : - // (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ) = f; - // break; - //case D3Q27System::T : - // (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = f; - // break; - //case D3Q27System::SW : - // (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ) = f; - // break; - //case D3Q27System::NE : - // (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = f; - // break; - //case D3Q27System::NW : - // (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3) = f; - // break; - //case D3Q27System::SE : - // (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ) = f; - // break; - //case D3Q27System::BW : - // (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ) = f; - // break; - //case D3Q27System::TE : - // (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = f; - // break; - //case D3Q27System::TW : - // (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3) = f; - // break; - //case D3Q27System::BE : - // (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ) = f; - // break; - //case D3Q27System::BS : - // (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ) = f; - // break; - //case D3Q27System::TN : - // (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = f; - // break; - //case D3Q27System::TS : - // (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3) = f; - // break; - //case D3Q27System::BN : - // (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ) = f; - // break; - //case D3Q27System::BSW : - // (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1) = f; - // break; - //case D3Q27System::TNE : - // (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = f; - // break; - //case D3Q27System::BSE : - // (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1) = f; - // break; - //case D3Q27System::TNW : - // (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3) = f; - // break; - //case D3Q27System::BNW : - // (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1) = f; - // break; - //case D3Q27System::TSE : - // (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3) = f; - // break; - //case D3Q27System::BNE : - // (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1) = f; - // break; - //case D3Q27System::TSW : - // (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3) = f; - // break; - //case D3Q27System::ZERO : - // (*this->zeroDistributions)(x1,x2,x3) = f; - // break; - //default: - // UB_THROW( UbException(UB_EXARGS, "Direction didn't find") ); - //} -} -////////////////////////////////////////////////////////////////////////// -LBMReal D3Q27EsoTwist3DSoA::getDistributionInvForDirection(size_t x1, size_t x2, size_t x3, int direction) -{ - //switch (direction) - //{ - //case D3Q27System::E : - // return (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ); - //case D3Q27System::W : - // return (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3); - //case D3Q27System::S : - // return (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3); - //case D3Q27System::N : - // return (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ); - //case D3Q27System::B : - // return (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3); - //case D3Q27System::T : - // return (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ); - //case D3Q27System::SW : - // return (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3); - //case D3Q27System::NE : - // return (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ); - //case D3Q27System::NW : - // return (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ); - //case D3Q27System::SE : - // return (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3); - //case D3Q27System::BW : - // return (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3); - //case D3Q27System::TE : - // return (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ); - //case D3Q27System::TW : - // return (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ); - //case D3Q27System::BE : - // return (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3); - //case D3Q27System::BS : - // return (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3); - //case D3Q27System::TN : - // return (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ); - //case D3Q27System::TS : - // return (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ); - //case D3Q27System::BN : - // return (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3); - //case D3Q27System::BSW : - // return (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3); - //case D3Q27System::TNE : - // return (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1); - //case D3Q27System::BSE : - // return (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3); - //case D3Q27System::TNW : - // return (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1); - //case D3Q27System::BNW : - // return (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3); - //case D3Q27System::TSE : - // return (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1); - //case D3Q27System::BNE : - // return (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3); - //case D3Q27System::TSW : - // return (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1); - //case D3Q27System::ZERO : - // return (*this->zeroDistributions)(x1,x2,x3); - //default: - // UB_THROW( UbException(UB_EXARGS, "Direction didn't find") ); - //} - return 0; -} -////////////////////////////////////////////////////////////////////////// -size_t D3Q27EsoTwist3DSoA::getNX1() const -{ - return NX1; -} -////////////////////////////////////////////////////////////////////////// -size_t D3Q27EsoTwist3DSoA::getNX2() const -{ - return NX2; -} -////////////////////////////////////////////////////////////////////////// -size_t D3Q27EsoTwist3DSoA::getNX3() const -{ - return NX3; -} -////////////////////////////////////////////////////////////////////////// -Distributions D3Q27EsoTwist3DSoA::getDistributions() -{ - return d; -} -////////////////////////////////////////////////////////////////////////// - diff --git a/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSoA.h b/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSoA.h deleted file mode 100644 index 94e362c2b..000000000 --- a/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSoA.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef D3Q27EsoTwist3DSoA_h -#define D3Q27EsoTwist3DSoA_h - -#include "EsoTwist3D.h" -//#include "D3Q27System.h" -//#include "basics/container/CbArray4D.h" -#include <basics/container/CbArray3D.h> -//#include <boost/serialization/serialization.hpp> -//#include <boost/serialization/base_object.hpp> - - -struct Distributions -{ - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr E; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr W; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr N; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr S; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr T; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr B; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr NE; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr SW; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr SE; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr NW; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr TE; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr BW; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr BE; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr TW; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr TN; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr BS; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr BN; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr TS; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr TNE; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr TNW; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr TSE; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr TSW; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr BNE; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr BNW; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr BSE; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr BSW; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr ZERO; -}; - - -class D3Q27EsoTwist3DSoA : public EsoTwist3D -{ -public: - D3Q27EsoTwist3DSoA(); - D3Q27EsoTwist3DSoA(const size_t& nx1, const size_t& nx2, const size_t& nx3, LBMReal value); - ////////////////////////////////////////////////////////////////////////// - ~D3Q27EsoTwist3DSoA(); - ////////////////////////////////////////////////////////////////////////// - void swap(); - ////////////////////////////////////////////////////////////////////////// - virtual void getDistribution( LBMReal* const f, size_t x1, size_t x2, size_t x3); - ////////////////////////////////////////////////////////////////////////// - virtual void setDistribution(const LBMReal* const f, size_t x1, size_t x2, size_t x3); - //////////////////////////////////////////////////////////////////////// - virtual void getDistributionInv( LBMReal* const f, size_t x1, size_t x2, size_t x3); - ////////////////////////////////////////////////////////////////////////// - virtual void setDistributionInv(const LBMReal* const f, size_t x1, size_t x2, size_t x3); - ////////////////////////////////////////////////////////////////////////// - virtual void setDistributionForDirection(const LBMReal* const f, size_t x1, size_t x2, size_t x3, unsigned long int direction); - ////////////////////////////////////////////////////////////////////////// - virtual void setDistributionForDirection(LBMReal f, size_t x1, size_t x2, size_t x3, int direction); - ////////////////////////////////////////////////////////////////////////// - virtual LBMReal getDistributionInvForDirection(size_t x1, size_t x2, size_t x3, int direction); - ////////////////////////////////////////////////////////////////////////// - virtual void setDistributionInvForDirection(const LBMReal* const f, size_t x1, size_t x2, size_t x3, unsigned long int direction); - ////////////////////////////////////////////////////////////////////////// - virtual void setDistributionInvForDirection(LBMReal f, size_t x1, size_t x2, size_t x3, unsigned long int direction); - ////////////////////////////////////////////////////////////////////////// - virtual LBMReal getDistributionForDirection(size_t x1, size_t x2, size_t x3, int direction); - ////////////////////////////////////////////////////////////////////////// - size_t getNX1() const; - ////////////////////////////////////////////////////////////////////////// - size_t getNX2() const; - ////////////////////////////////////////////////////////////////////////// - size_t getNX3() const; - ////////////////////////////////////////////////////////////////////////// - Distributions getDistributions(); - ////////////////////////////////////////////////////////////////////////// - void getDistributionAfterLastStep(LBMReal* const f, size_t x1, size_t x2, size_t x3); - -protected: - Distributions d; - size_t NX1, NX2, NX3; - -}; - -#endif - diff --git a/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSplittedVector.cpp b/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSplittedVector.cpp index d048f9c58..5ed36627d 100644 --- a/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSplittedVector.cpp +++ b/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSplittedVector.cpp @@ -1,653 +1,686 @@ -#include "D3Q27EsoTwist3DSplittedVector.h" -#include "EsoTwistD3Q27System.h" - -D3Q27EsoTwist3DSplittedVector::D3Q27EsoTwist3DSplittedVector() -{ -} -////////////////////////////////////////////////////////////////////////// -D3Q27EsoTwist3DSplittedVector::D3Q27EsoTwist3DSplittedVector( size_t nx1, size_t nx2, size_t nx3, LBMReal value ) -{ - this->NX1 = nx1; - this->NX2 = nx2; - this->NX3 = nx3; - - this->localDistributions = CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal,IndexerX4X3X2X1>(13, nx1+1, nx2+1, nx3+1, value)); - this->nonLocalDistributions = CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal,IndexerX4X3X2X1>(13, nx1+1, nx2+1, nx3+1, value)); - - this->zeroDistributions = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1, nx2, nx3, value)); -} -////////////////////////////////////////////////////////////////////////// -D3Q27EsoTwist3DSplittedVector::~D3Q27EsoTwist3DSplittedVector() -{ - -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSplittedVector::swap() -{ - std::swap( this->localDistributions, this->nonLocalDistributions ); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSplittedVector::getDistribution(LBMReal* const f, size_t x1, size_t x2, size_t x3) -{ - f[D3Q27System::E] = (*this->localDistributions)(D3Q27System::ET_E, x1,x2,x3); - f[D3Q27System::N] = (*this->localDistributions)(D3Q27System::ET_N,x1,x2,x3); - f[D3Q27System::T] = (*this->localDistributions)(D3Q27System::ET_T,x1,x2,x3); - f[D3Q27System::NE] = (*this->localDistributions)(D3Q27System::ET_NE,x1,x2,x3); - f[D3Q27System::NW] = (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2,x3); - f[D3Q27System::TE] = (*this->localDistributions)(D3Q27System::ET_TE,x1,x2,x3); - f[D3Q27System::TW] = (*this->localDistributions)(D3Q27System::ET_TW, x1+1,x2,x3); - f[D3Q27System::TN] = (*this->localDistributions)(D3Q27System::ET_TN,x1,x2,x3); - f[D3Q27System::TS] = (*this->localDistributions)(D3Q27System::ET_TS,x1,x2+1,x3); - f[D3Q27System::TNE] = (*this->localDistributions)(D3Q27System::ET_TNE,x1,x2,x3); - f[D3Q27System::TNW] = (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2,x3); - f[D3Q27System::TSE] = (*this->localDistributions)(D3Q27System::ET_TSE,x1,x2+1,x3); - f[D3Q27System::TSW] = (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3); - - f[D3Q27System::W ] = (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2,x3 ); - f[D3Q27System::S ] = (*this->nonLocalDistributions)(D3Q27System::ET_S,x1,x2+1,x3 ); - f[D3Q27System::B ] = (*this->nonLocalDistributions)(D3Q27System::ET_B,x1,x2,x3+1 ); - f[D3Q27System::SW] = (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ); - f[D3Q27System::SE] = (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1,x2+1,x3 ); - f[D3Q27System::BW] = (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2,x3+1 ); - f[D3Q27System::BE] = (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1,x2,x3+1 ); - f[D3Q27System::BS] = (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1,x2+1,x3+1 ); - f[D3Q27System::BN] = (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1,x2,x3+1 ); - f[D3Q27System::BSW] = (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1); - f[D3Q27System::BSE] = (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1,x2+1,x3+1); - f[D3Q27System::BNW] = (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2,x3+1); - f[D3Q27System::BNE] = (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1,x2,x3+1); - - f[D3Q27System::ZERO] = (*this->zeroDistributions)(x1,x2,x3); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSplittedVector::setDistribution(const LBMReal* const f, size_t x1, size_t x2, size_t x3) -{ - (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = f[D3Q27System::INV_E]; - (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = f[D3Q27System::INV_N]; - (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = f[D3Q27System::INV_T]; - (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = f[D3Q27System::INV_NE]; - (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3) = f[D3Q27System::INV_NW]; - (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = f[D3Q27System::INV_TE]; - (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3) = f[D3Q27System::INV_TW]; - (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = f[D3Q27System::INV_TN]; - (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3) = f[D3Q27System::INV_TS]; - (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = f[D3Q27System::INV_TNE]; - (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3) = f[D3Q27System::INV_TNW]; - (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3) = f[D3Q27System::INV_TSE]; - (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3) = f[D3Q27System::INV_TSW]; - - (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ) = f[D3Q27System::INV_W ]; - (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ) = f[D3Q27System::INV_S ]; - (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ) = f[D3Q27System::INV_B ]; - (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ) = f[D3Q27System::INV_SW]; - (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ) = f[D3Q27System::INV_SE]; - (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ) = f[D3Q27System::INV_BW]; - (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ) = f[D3Q27System::INV_BE]; - (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ) = f[D3Q27System::INV_BS]; - (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ) = f[D3Q27System::INV_BN]; - (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1) = f[D3Q27System::INV_BSW]; - (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1) = f[D3Q27System::INV_BSE]; - (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1) = f[D3Q27System::INV_BNW]; - (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1) = f[D3Q27System::INV_BNE]; - - (*this->zeroDistributions)(x1,x2,x3) = f[D3Q27System::ZERO]; -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSplittedVector::getDistributionInv(LBMReal* const f, size_t x1, size_t x2, size_t x3) -{ - f[D3Q27System::INV_E] = (*this->localDistributions)(D3Q27System::ET_E, x1,x2,x3); - f[D3Q27System::INV_N] = (*this->localDistributions)(D3Q27System::ET_N,x1,x2,x3); - f[D3Q27System::INV_T] = (*this->localDistributions)(D3Q27System::ET_T,x1,x2,x3); - f[D3Q27System::INV_NE] = (*this->localDistributions)(D3Q27System::ET_NE,x1,x2,x3); - f[D3Q27System::INV_NW] = (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2,x3); - f[D3Q27System::INV_TE] = (*this->localDistributions)(D3Q27System::ET_TE,x1,x2,x3); - f[D3Q27System::INV_TW] = (*this->localDistributions)(D3Q27System::ET_TW, x1+1,x2,x3); - f[D3Q27System::INV_TN] = (*this->localDistributions)(D3Q27System::ET_TN,x1,x2,x3); - f[D3Q27System::INV_TS] = (*this->localDistributions)(D3Q27System::ET_TS,x1,x2+1,x3); - f[D3Q27System::INV_TNE] = (*this->localDistributions)(D3Q27System::ET_TNE,x1,x2,x3); - f[D3Q27System::INV_TNW] = (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2,x3); - f[D3Q27System::INV_TSE] = (*this->localDistributions)(D3Q27System::ET_TSE,x1,x2+1,x3); - f[D3Q27System::INV_TSW] = (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3); - - f[D3Q27System::INV_W ] = (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2,x3 ); - f[D3Q27System::INV_S ] = (*this->nonLocalDistributions)(D3Q27System::ET_S,x1,x2+1,x3 ); - f[D3Q27System::INV_B ] = (*this->nonLocalDistributions)(D3Q27System::ET_B,x1,x2,x3+1 ); - f[D3Q27System::INV_SW] = (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ); - f[D3Q27System::INV_SE] = (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1,x2+1,x3 ); - f[D3Q27System::INV_BW] = (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2,x3+1 ); - f[D3Q27System::INV_BE] = (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1,x2,x3+1 ); - f[D3Q27System::INV_BS] = (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1,x2+1,x3+1 ); - f[D3Q27System::INV_BN] = (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1,x2,x3+1 ); - f[D3Q27System::INV_BSW] = (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1); - f[D3Q27System::INV_BSE] = (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1,x2+1,x3+1); - f[D3Q27System::INV_BNW] = (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2,x3+1); - f[D3Q27System::INV_BNE] = (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1,x2,x3+1); - - f[D3Q27System::ZERO] = (*this->zeroDistributions)(x1,x2,x3); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSplittedVector::setDistributionInv(const LBMReal* const f, size_t x1, size_t x2, size_t x3) -{ - (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = f[D3Q27System::E]; - (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = f[D3Q27System::N]; - (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = f[D3Q27System::T]; - (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = f[D3Q27System::NE]; - (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3) = f[D3Q27System::NW]; - (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = f[D3Q27System::TE]; - (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3) = f[D3Q27System::TW]; - (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = f[D3Q27System::TN]; - (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3) = f[D3Q27System::TS]; - (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = f[D3Q27System::TNE]; - (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3) = f[D3Q27System::TNW]; - (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3) = f[D3Q27System::TSE]; - (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3) = f[D3Q27System::TSW]; - - (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ) = f[D3Q27System::W ]; - (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ) = f[D3Q27System::S ]; - (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ) = f[D3Q27System::B ]; - (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ) = f[D3Q27System::SW]; - (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ) = f[D3Q27System::SE]; - (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ) = f[D3Q27System::BW]; - (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ) = f[D3Q27System::BE]; - (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ) = f[D3Q27System::BS]; - (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ) = f[D3Q27System::BN]; - (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1) = f[D3Q27System::BSW]; - (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1) = f[D3Q27System::BSE]; - (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1) = f[D3Q27System::BNW]; - (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1) = f[D3Q27System::BNE]; - - (*this->zeroDistributions)(x1,x2,x3) = f[D3Q27System::ZERO]; -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSplittedVector::setDistributionForDirection(const LBMReal* const f, size_t x1, size_t x2, size_t x3, unsigned long int direction) -{ - bool directionFlag = false; - if ((direction & EsoTwistD3Q27System::etE) == EsoTwistD3Q27System::etE) - (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ) = f[D3Q27System::E]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etW) == EsoTwistD3Q27System::etW) - (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = f[D3Q27System::W]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etS) == EsoTwistD3Q27System::etS) - (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = f[D3Q27System::S]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etN) == EsoTwistD3Q27System::etN) - (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ) = f[D3Q27System::N]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etB) == EsoTwistD3Q27System::etB) - (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = f[D3Q27System::B]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etT) == EsoTwistD3Q27System::etT) - (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ) = f[D3Q27System::T]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etSW) == EsoTwistD3Q27System::etSW) - (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = f[D3Q27System::SW]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etNE) == EsoTwistD3Q27System::etNE) - (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ) = f[D3Q27System::NE]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etNW) == EsoTwistD3Q27System::etNW) - (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ) = f[D3Q27System::NW]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etSE) == EsoTwistD3Q27System::etSE) - (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3) = f[D3Q27System::SE]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etBW) == EsoTwistD3Q27System::etBW) - (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = f[D3Q27System::BW]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etTE) == EsoTwistD3Q27System::etTE) - (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ) = f[D3Q27System::TE]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etTW) == EsoTwistD3Q27System::etTW) - (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ) = f[D3Q27System::TW]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etBE) == EsoTwistD3Q27System::etBE) - (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3) = f[D3Q27System::BE]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etBS) == EsoTwistD3Q27System::etBS) - (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = f[D3Q27System::BS]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etTN) == EsoTwistD3Q27System::etTN) - (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ) = f[D3Q27System::TN]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etTS) == EsoTwistD3Q27System::etTS) - (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ) = f[D3Q27System::TS]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etBN) == EsoTwistD3Q27System::etBN) - (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3) = f[D3Q27System::BN]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etBSW) == EsoTwistD3Q27System::etBSW) - (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = f[D3Q27System::BSW]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etTNE) == EsoTwistD3Q27System::etTNE) - (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1) = f[D3Q27System::TNE]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etBSE) == EsoTwistD3Q27System::etBSE) - (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3) = f[D3Q27System::BSE]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etTNW) == EsoTwistD3Q27System::etTNW) - (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1) = f[D3Q27System::TNW]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etBNW) == EsoTwistD3Q27System::etBNW) - (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3) = f[D3Q27System::BNW]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etTSE) == EsoTwistD3Q27System::etTSE) - (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1) = f[D3Q27System::TSE]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etBNE) == EsoTwistD3Q27System::etBNE) - (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3) = f[D3Q27System::BNE]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etTSW) == EsoTwistD3Q27System::etTSW) - (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1) = f[D3Q27System::TSW]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::ZERO) == EsoTwistD3Q27System::ZERO) - (*this->zeroDistributions)(x1,x2,x3) = f[D3Q27System::ZERO]; directionFlag=true; -#ifdef _DEBUG - if(!directionFlag)UB_THROW( UbException(UB_EXARGS, "Direction didn't find") ); -#endif //DEBUG -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSplittedVector::setDistributionForDirection(LBMReal f, size_t x1, size_t x2, size_t x3, int direction) -{ - switch (direction) - { - case D3Q27System::E : - (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ) = f; - break; - case D3Q27System::W : - (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = f; - break; - case D3Q27System::S : - (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = f; - break; - case D3Q27System::N : - (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ) = f; - break; - case D3Q27System::B : - (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = f; - break; - case D3Q27System::T : - (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ) = f; - break; - case D3Q27System::SW : - (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = f; - break; - case D3Q27System::NE : - (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ) = f; - break; - case D3Q27System::NW : - (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ) = f; - break; - case D3Q27System::SE : - (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3) = f; - break; - case D3Q27System::BW : - (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = f; - break; - case D3Q27System::TE : - (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ) = f; - break; - case D3Q27System::TW : - (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ) = f; - break; - case D3Q27System::BE : - (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3) = f; - break; - case D3Q27System::BS : - (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = f; - break; - case D3Q27System::TN : - (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ) = f; - break; - case D3Q27System::TS : - (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ) = f; - break; - case D3Q27System::BN : - (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3) = f; - break; - case D3Q27System::BSW : - (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = f; - break; - case D3Q27System::TNE : - (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1) = f; - break; - case D3Q27System::BSE : - (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3) = f; - break; - case D3Q27System::TNW : - (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1) = f; - break; - case D3Q27System::BNW : - (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3) = f; - break; - case D3Q27System::TSE : - (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1) = f; - break; - case D3Q27System::BNE : - (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3) = f; - break; - case D3Q27System::TSW : - (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1) = f; - break; - case D3Q27System::ZERO : - (*this->zeroDistributions)(x1,x2,x3) = f; - break; - default: - UB_THROW( UbException(UB_EXARGS, "Direction didn't find") ); - } -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSplittedVector::setDistributionInvForDirection(const LBMReal* const f, size_t x1, size_t x2, size_t x3, unsigned long int direction) -{ - bool directionFlag = false; - if ((direction & EsoTwistD3Q27System::etE) == EsoTwistD3Q27System::etE) - (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = f[D3Q27System::E]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etW) == EsoTwistD3Q27System::etW) - (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ) = f[D3Q27System::W]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etS) == EsoTwistD3Q27System::etS) - (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ) = f[D3Q27System::S]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etN) == EsoTwistD3Q27System::etN) - (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = f[D3Q27System::N]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etB) == EsoTwistD3Q27System::etB) - (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ) = f[D3Q27System::B]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etT) == EsoTwistD3Q27System::etT) - (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = f[D3Q27System::T]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etSW) == EsoTwistD3Q27System::etSW) - (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ) = f[D3Q27System::SW]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etNE) == EsoTwistD3Q27System::etNE) - (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = f[D3Q27System::NE]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etNW) == EsoTwistD3Q27System::etNW) - (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3) = f[D3Q27System::NW]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etSE) == EsoTwistD3Q27System::etSE) - (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ) = f[D3Q27System::SE]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etBW) == EsoTwistD3Q27System::etBW) - (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ) = f[D3Q27System::BW]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etTE) == EsoTwistD3Q27System::etTE) - (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = f[D3Q27System::TE]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etTW) == EsoTwistD3Q27System::etTW) - (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3) = f[D3Q27System::TW]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etBE) == EsoTwistD3Q27System::etBE) - (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ) = f[D3Q27System::BE]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etBS) == EsoTwistD3Q27System::etBS) - (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ) = f[D3Q27System::BS]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etTN) == EsoTwistD3Q27System::etTN) - (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = f[D3Q27System::TN]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etTS) == EsoTwistD3Q27System::etTS) - (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3) = f[D3Q27System::TS]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etBN) == EsoTwistD3Q27System::etBN) - (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ) = f[D3Q27System::BN]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etBSW) == EsoTwistD3Q27System::etBSW) - (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1) = f[D3Q27System::BSW]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etTNE) == EsoTwistD3Q27System::etTNE) - (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = f[D3Q27System::TNE]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etBSE) == EsoTwistD3Q27System::etBSE) - (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1) = f[D3Q27System::BSE]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etTNW) == EsoTwistD3Q27System::etTNW) - (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3) = f[D3Q27System::TNW]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etBNW) == EsoTwistD3Q27System::etBNW) - (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1) = f[D3Q27System::BNW]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etTSE) == EsoTwistD3Q27System::etTSE) - (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3) = f[D3Q27System::TSE]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etBNE) == EsoTwistD3Q27System::etBNE) - (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1)= f[D3Q27System::BNE]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::etTSW) == EsoTwistD3Q27System::etTSW) - (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3) = f[D3Q27System::TSW]; directionFlag=true; - if ((direction & EsoTwistD3Q27System::ZERO) == EsoTwistD3Q27System::ZERO) - (*this->zeroDistributions)(x1,x2,x3) = f[D3Q27System::ZERO]; directionFlag=true; -#ifdef _DEBUG - if(!directionFlag)UB_THROW( UbException(UB_EXARGS, "Direction didn't find") ); -#endif //DEBUG -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSplittedVector::setDistributionInvForDirection(LBMReal f, size_t x1, size_t x2, size_t x3, unsigned long int direction) -{ - switch (direction) - { - case D3Q27System::E : - (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = f; - break; - case D3Q27System::W : - (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ) = f; - break; - case D3Q27System::S : - (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ) = f; - break; - case D3Q27System::N : - (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = f; - break; - case D3Q27System::B : - (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ) = f; - break; - case D3Q27System::T : - (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = f; - break; - case D3Q27System::SW : - (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ) = f; - break; - case D3Q27System::NE : - (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = f; - break; - case D3Q27System::NW : - (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3) = f; - break; - case D3Q27System::SE : - (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ) = f; - break; - case D3Q27System::BW : - (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ) = f; - break; - case D3Q27System::TE : - (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = f; - break; - case D3Q27System::TW : - (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3) = f; - break; - case D3Q27System::BE : - (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ) = f; - break; - case D3Q27System::BS : - (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ) = f; - break; - case D3Q27System::TN : - (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = f; - break; - case D3Q27System::TS : - (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3) = f; - break; - case D3Q27System::BN : - (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ) = f; - break; - case D3Q27System::BSW : - (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1) = f; - break; - case D3Q27System::TNE : - (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = f; - break; - case D3Q27System::BSE : - (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1) = f; - break; - case D3Q27System::TNW : - (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3) = f; - break; - case D3Q27System::BNW : - (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1) = f; - break; - case D3Q27System::TSE : - (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3) = f; - break; - case D3Q27System::BNE : - (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1) = f; - break; - case D3Q27System::TSW : - (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3) = f; - break; - case D3Q27System::ZERO : - (*this->zeroDistributions)(x1,x2,x3) = f; - break; - default: - UB_THROW( UbException(UB_EXARGS, "Direction didn't find") ); - } -} -////////////////////////////////////////////////////////////////////////// -LBMReal D3Q27EsoTwist3DSplittedVector::getDistributionForDirection(size_t x1, size_t x2, size_t x3, int direction) -{ - switch (direction) - { - case D3Q27System::W : - return (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ); - case D3Q27System::E : - return (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3); - case D3Q27System::N : - return (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3); - case D3Q27System::S : - return (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ); - case D3Q27System::T : - return (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3); - case D3Q27System::B : - return (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ); - case D3Q27System::NE : - return (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3); - case D3Q27System::SW : - return (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ); - case D3Q27System::SE : - return (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ); - case D3Q27System::NW : - return (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3); - case D3Q27System::TE : - return (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3); - case D3Q27System::BW : - return (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ); - case D3Q27System::BE : - return (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ); - case D3Q27System::TW : - return (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3); - case D3Q27System::TN : - return (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3); - case D3Q27System::BS : - return (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ); - case D3Q27System::BN : - return (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ); - case D3Q27System::TS : - return (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3); - case D3Q27System::TNE : - return (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3); - case D3Q27System::BSW : - return (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1); - case D3Q27System::TNW : - return (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3); - case D3Q27System::BSE : - return (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1); - case D3Q27System::TSE : - return (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3); - case D3Q27System::BNW : - return (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1); - case D3Q27System::TSW : - return (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3); - case D3Q27System::BNE : - return (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1); - case D3Q27System::ZERO : - return (*this->zeroDistributions)(x1,x2,x3); - default: - UB_THROW( UbException(UB_EXARGS, "Direction didn't find") ); - } -} -////////////////////////////////////////////////////////////////////////// -LBMReal D3Q27EsoTwist3DSplittedVector::getDistributionInvForDirection(size_t x1, size_t x2, size_t x3, int direction) -{ - switch (direction) - { - case D3Q27System::E : - return (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ); - case D3Q27System::W : - return (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3); - case D3Q27System::S : - return (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3); - case D3Q27System::N : - return (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ); - case D3Q27System::B : - return (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3); - case D3Q27System::T : - return (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ); - case D3Q27System::SW : - return (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3); - case D3Q27System::NE : - return (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ); - case D3Q27System::NW : - return (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ); - case D3Q27System::SE : - return (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3); - case D3Q27System::BW : - return (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3); - case D3Q27System::TE : - return (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ); - case D3Q27System::TW : - return (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ); - case D3Q27System::BE : - return (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3); - case D3Q27System::BS : - return (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3); - case D3Q27System::TN : - return (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ); - case D3Q27System::TS : - return (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ); - case D3Q27System::BN : - return (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3); - case D3Q27System::BSW : - return (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3); - case D3Q27System::TNE : - return (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1); - case D3Q27System::BSE : - return (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3); - case D3Q27System::TNW : - return (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1); - case D3Q27System::BNW : - return (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3); - case D3Q27System::TSE : - return (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1); - case D3Q27System::BNE : - return (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3); - case D3Q27System::TSW : - return (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1); - case D3Q27System::ZERO : - return (*this->zeroDistributions)(x1,x2,x3); - default: - UB_THROW( UbException(UB_EXARGS, "Direction didn't find") ); - } -} -////////////////////////////////////////////////////////////////////////// -size_t D3Q27EsoTwist3DSplittedVector::getNX1() const -{ - return NX1; -} -////////////////////////////////////////////////////////////////////////// -size_t D3Q27EsoTwist3DSplittedVector::getNX2() const -{ - return NX2; -} -////////////////////////////////////////////////////////////////////////// -size_t D3Q27EsoTwist3DSplittedVector::getNX3() const -{ - return NX3; -} -////////////////////////////////////////////////////////////////////////// -CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr D3Q27EsoTwist3DSplittedVector::getLocalDistributions() -{ - return this->localDistributions; -} -////////////////////////////////////////////////////////////////////////// -CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr D3Q27EsoTwist3DSplittedVector::getNonLocalDistributions() -{ - return this->nonLocalDistributions; -} -////////////////////////////////////////////////////////////////////////// -CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr D3Q27EsoTwist3DSplittedVector::getZeroDistributions() -{ - return this->zeroDistributions; -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSplittedVector::setNX1(size_t newNX1) -{ - NX1 = newNX1; -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSplittedVector::setNX2(size_t newNX2) -{ - NX2 = newNX2; -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSplittedVector::setNX3(size_t newNX3) -{ - NX3 = newNX3; -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSplittedVector::setLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr array) -{ - localDistributions = array; -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSplittedVector::setNonLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr array) -{ - nonLocalDistributions = array; -} -////////////////////////////////////////////////////////////////////////// -void D3Q27EsoTwist3DSplittedVector::setZeroDistributions(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr array) -{ - zeroDistributions = array; -} - -////////////////////////////////////////////////////////////////////////// - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file D3Q27EsoTwist3DSplittedVector.cpp +//! \ingroup Data +//! \author Konstantin Kutscher +//======================================================================================= + +#include "D3Q27EsoTwist3DSplittedVector.h" +#include "EsoTwistD3Q27System.h" + +D3Q27EsoTwist3DSplittedVector::D3Q27EsoTwist3DSplittedVector() +{ +} +////////////////////////////////////////////////////////////////////////// +D3Q27EsoTwist3DSplittedVector::D3Q27EsoTwist3DSplittedVector( size_t nx1, size_t nx2, size_t nx3, LBMReal value ) +{ + this->NX1 = nx1; + this->NX2 = nx2; + this->NX3 = nx3; + + this->localDistributions = CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal,IndexerX4X3X2X1>(13, nx1+1, nx2+1, nx3+1, value)); + this->nonLocalDistributions = CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal,IndexerX4X3X2X1>(13, nx1+1, nx2+1, nx3+1, value)); + + this->restDistributions = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1, nx2, nx3, value)); +} +////////////////////////////////////////////////////////////////////////// +D3Q27EsoTwist3DSplittedVector::~D3Q27EsoTwist3DSplittedVector() +{ + +} +////////////////////////////////////////////////////////////////////////// +void D3Q27EsoTwist3DSplittedVector::swap() +{ + std::swap( this->localDistributions, this->nonLocalDistributions ); +} +////////////////////////////////////////////////////////////////////////// +void D3Q27EsoTwist3DSplittedVector::getDistribution(LBMReal* const f, size_t x1, size_t x2, size_t x3) +{ + f[D3Q27System::E] = (*this->localDistributions)(D3Q27System::ET_E, x1,x2,x3); + f[D3Q27System::N] = (*this->localDistributions)(D3Q27System::ET_N,x1,x2,x3); + f[D3Q27System::T] = (*this->localDistributions)(D3Q27System::ET_T,x1,x2,x3); + f[D3Q27System::NE] = (*this->localDistributions)(D3Q27System::ET_NE,x1,x2,x3); + f[D3Q27System::NW] = (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2,x3); + f[D3Q27System::TE] = (*this->localDistributions)(D3Q27System::ET_TE,x1,x2,x3); + f[D3Q27System::TW] = (*this->localDistributions)(D3Q27System::ET_TW, x1+1,x2,x3); + f[D3Q27System::TN] = (*this->localDistributions)(D3Q27System::ET_TN,x1,x2,x3); + f[D3Q27System::TS] = (*this->localDistributions)(D3Q27System::ET_TS,x1,x2+1,x3); + f[D3Q27System::TNE] = (*this->localDistributions)(D3Q27System::ET_TNE,x1,x2,x3); + f[D3Q27System::TNW] = (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2,x3); + f[D3Q27System::TSE] = (*this->localDistributions)(D3Q27System::ET_TSE,x1,x2+1,x3); + f[D3Q27System::TSW] = (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3); + + f[D3Q27System::W ] = (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2,x3 ); + f[D3Q27System::S ] = (*this->nonLocalDistributions)(D3Q27System::ET_S,x1,x2+1,x3 ); + f[D3Q27System::B ] = (*this->nonLocalDistributions)(D3Q27System::ET_B,x1,x2,x3+1 ); + f[D3Q27System::SW] = (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ); + f[D3Q27System::SE] = (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1,x2+1,x3 ); + f[D3Q27System::BW] = (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2,x3+1 ); + f[D3Q27System::BE] = (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1,x2,x3+1 ); + f[D3Q27System::BS] = (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1,x2+1,x3+1 ); + f[D3Q27System::BN] = (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1,x2,x3+1 ); + f[D3Q27System::BSW] = (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1); + f[D3Q27System::BSE] = (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1,x2+1,x3+1); + f[D3Q27System::BNW] = (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2,x3+1); + f[D3Q27System::BNE] = (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1,x2,x3+1); + + f[D3Q27System::REST] = (*this->restDistributions)(x1,x2,x3); +} +////////////////////////////////////////////////////////////////////////// +void D3Q27EsoTwist3DSplittedVector::setDistribution(const LBMReal* const f, size_t x1, size_t x2, size_t x3) +{ + (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = f[D3Q27System::INV_E]; + (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = f[D3Q27System::INV_N]; + (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = f[D3Q27System::INV_T]; + (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = f[D3Q27System::INV_NE]; + (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3) = f[D3Q27System::INV_NW]; + (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = f[D3Q27System::INV_TE]; + (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3) = f[D3Q27System::INV_TW]; + (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = f[D3Q27System::INV_TN]; + (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3) = f[D3Q27System::INV_TS]; + (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = f[D3Q27System::INV_TNE]; + (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3) = f[D3Q27System::INV_TNW]; + (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3) = f[D3Q27System::INV_TSE]; + (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3) = f[D3Q27System::INV_TSW]; + + (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ) = f[D3Q27System::INV_W ]; + (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ) = f[D3Q27System::INV_S ]; + (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ) = f[D3Q27System::INV_B ]; + (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ) = f[D3Q27System::INV_SW]; + (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ) = f[D3Q27System::INV_SE]; + (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ) = f[D3Q27System::INV_BW]; + (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ) = f[D3Q27System::INV_BE]; + (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ) = f[D3Q27System::INV_BS]; + (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ) = f[D3Q27System::INV_BN]; + (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1) = f[D3Q27System::INV_BSW]; + (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1) = f[D3Q27System::INV_BSE]; + (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1) = f[D3Q27System::INV_BNW]; + (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1) = f[D3Q27System::INV_BNE]; + + (*this->restDistributions)(x1,x2,x3) = f[D3Q27System::REST]; +} +////////////////////////////////////////////////////////////////////////// +void D3Q27EsoTwist3DSplittedVector::getDistributionInv(LBMReal* const f, size_t x1, size_t x2, size_t x3) +{ + f[D3Q27System::INV_E] = (*this->localDistributions)(D3Q27System::ET_E, x1,x2,x3); + f[D3Q27System::INV_N] = (*this->localDistributions)(D3Q27System::ET_N,x1,x2,x3); + f[D3Q27System::INV_T] = (*this->localDistributions)(D3Q27System::ET_T,x1,x2,x3); + f[D3Q27System::INV_NE] = (*this->localDistributions)(D3Q27System::ET_NE,x1,x2,x3); + f[D3Q27System::INV_NW] = (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2,x3); + f[D3Q27System::INV_TE] = (*this->localDistributions)(D3Q27System::ET_TE,x1,x2,x3); + f[D3Q27System::INV_TW] = (*this->localDistributions)(D3Q27System::ET_TW, x1+1,x2,x3); + f[D3Q27System::INV_TN] = (*this->localDistributions)(D3Q27System::ET_TN,x1,x2,x3); + f[D3Q27System::INV_TS] = (*this->localDistributions)(D3Q27System::ET_TS,x1,x2+1,x3); + f[D3Q27System::INV_TNE] = (*this->localDistributions)(D3Q27System::ET_TNE,x1,x2,x3); + f[D3Q27System::INV_TNW] = (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2,x3); + f[D3Q27System::INV_TSE] = (*this->localDistributions)(D3Q27System::ET_TSE,x1,x2+1,x3); + f[D3Q27System::INV_TSW] = (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3); + + f[D3Q27System::INV_W ] = (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2,x3 ); + f[D3Q27System::INV_S ] = (*this->nonLocalDistributions)(D3Q27System::ET_S,x1,x2+1,x3 ); + f[D3Q27System::INV_B ] = (*this->nonLocalDistributions)(D3Q27System::ET_B,x1,x2,x3+1 ); + f[D3Q27System::INV_SW] = (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ); + f[D3Q27System::INV_SE] = (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1,x2+1,x3 ); + f[D3Q27System::INV_BW] = (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2,x3+1 ); + f[D3Q27System::INV_BE] = (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1,x2,x3+1 ); + f[D3Q27System::INV_BS] = (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1,x2+1,x3+1 ); + f[D3Q27System::INV_BN] = (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1,x2,x3+1 ); + f[D3Q27System::INV_BSW] = (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1); + f[D3Q27System::INV_BSE] = (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1,x2+1,x3+1); + f[D3Q27System::INV_BNW] = (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2,x3+1); + f[D3Q27System::INV_BNE] = (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1,x2,x3+1); + + f[D3Q27System::REST] = (*this->restDistributions)(x1,x2,x3); +} +////////////////////////////////////////////////////////////////////////// +void D3Q27EsoTwist3DSplittedVector::setDistributionInv(const LBMReal* const f, size_t x1, size_t x2, size_t x3) +{ + (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = f[D3Q27System::E]; + (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = f[D3Q27System::N]; + (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = f[D3Q27System::T]; + (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = f[D3Q27System::NE]; + (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3) = f[D3Q27System::NW]; + (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = f[D3Q27System::TE]; + (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3) = f[D3Q27System::TW]; + (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = f[D3Q27System::TN]; + (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3) = f[D3Q27System::TS]; + (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = f[D3Q27System::TNE]; + (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3) = f[D3Q27System::TNW]; + (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3) = f[D3Q27System::TSE]; + (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3) = f[D3Q27System::TSW]; + + (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ) = f[D3Q27System::W ]; + (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ) = f[D3Q27System::S ]; + (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ) = f[D3Q27System::B ]; + (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ) = f[D3Q27System::SW]; + (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ) = f[D3Q27System::SE]; + (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ) = f[D3Q27System::BW]; + (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ) = f[D3Q27System::BE]; + (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ) = f[D3Q27System::BS]; + (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ) = f[D3Q27System::BN]; + (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1) = f[D3Q27System::BSW]; + (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1) = f[D3Q27System::BSE]; + (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1) = f[D3Q27System::BNW]; + (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1) = f[D3Q27System::BNE]; + + (*this->restDistributions)(x1,x2,x3) = f[D3Q27System::REST]; +} +////////////////////////////////////////////////////////////////////////// +void D3Q27EsoTwist3DSplittedVector::setDistributionForDirection(const LBMReal* const f, size_t x1, size_t x2, size_t x3, unsigned long int direction) +{ + bool directionFlag = false; + if ((direction & EsoTwistD3Q27System::etE) == EsoTwistD3Q27System::etE) + (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ) = f[D3Q27System::E]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etW) == EsoTwistD3Q27System::etW) + (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = f[D3Q27System::W]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etS) == EsoTwistD3Q27System::etS) + (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = f[D3Q27System::S]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etN) == EsoTwistD3Q27System::etN) + (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ) = f[D3Q27System::N]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etB) == EsoTwistD3Q27System::etB) + (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = f[D3Q27System::B]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etT) == EsoTwistD3Q27System::etT) + (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ) = f[D3Q27System::T]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etSW) == EsoTwistD3Q27System::etSW) + (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = f[D3Q27System::SW]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etNE) == EsoTwistD3Q27System::etNE) + (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ) = f[D3Q27System::NE]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etNW) == EsoTwistD3Q27System::etNW) + (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ) = f[D3Q27System::NW]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etSE) == EsoTwistD3Q27System::etSE) + (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3) = f[D3Q27System::SE]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etBW) == EsoTwistD3Q27System::etBW) + (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = f[D3Q27System::BW]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etTE) == EsoTwistD3Q27System::etTE) + (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ) = f[D3Q27System::TE]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etTW) == EsoTwistD3Q27System::etTW) + (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ) = f[D3Q27System::TW]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etBE) == EsoTwistD3Q27System::etBE) + (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3) = f[D3Q27System::BE]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etBS) == EsoTwistD3Q27System::etBS) + (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = f[D3Q27System::BS]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etTN) == EsoTwistD3Q27System::etTN) + (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ) = f[D3Q27System::TN]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etTS) == EsoTwistD3Q27System::etTS) + (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ) = f[D3Q27System::TS]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etBN) == EsoTwistD3Q27System::etBN) + (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3) = f[D3Q27System::BN]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etBSW) == EsoTwistD3Q27System::etBSW) + (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = f[D3Q27System::BSW]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etTNE) == EsoTwistD3Q27System::etTNE) + (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1) = f[D3Q27System::TNE]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etBSE) == EsoTwistD3Q27System::etBSE) + (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3) = f[D3Q27System::BSE]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etTNW) == EsoTwistD3Q27System::etTNW) + (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1) = f[D3Q27System::TNW]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etBNW) == EsoTwistD3Q27System::etBNW) + (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3) = f[D3Q27System::BNW]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etTSE) == EsoTwistD3Q27System::etTSE) + (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1) = f[D3Q27System::TSE]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etBNE) == EsoTwistD3Q27System::etBNE) + (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3) = f[D3Q27System::BNE]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etTSW) == EsoTwistD3Q27System::etTSW) + (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1) = f[D3Q27System::TSW]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::REST) == EsoTwistD3Q27System::REST) + (*this->restDistributions)(x1,x2,x3) = f[D3Q27System::REST]; directionFlag=true; +#ifdef _DEBUG + if(!directionFlag)UB_THROW( UbException(UB_EXARGS, "Direction didn't find") ); +#endif //DEBUG +} +////////////////////////////////////////////////////////////////////////// +void D3Q27EsoTwist3DSplittedVector::setDistributionForDirection(LBMReal f, size_t x1, size_t x2, size_t x3, int direction) +{ + switch (direction) + { + case D3Q27System::E : + (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ) = f; + break; + case D3Q27System::W : + (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = f; + break; + case D3Q27System::S : + (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = f; + break; + case D3Q27System::N : + (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ) = f; + break; + case D3Q27System::B : + (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = f; + break; + case D3Q27System::T : + (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ) = f; + break; + case D3Q27System::SW : + (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = f; + break; + case D3Q27System::NE : + (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ) = f; + break; + case D3Q27System::NW : + (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ) = f; + break; + case D3Q27System::SE : + (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3) = f; + break; + case D3Q27System::BW : + (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = f; + break; + case D3Q27System::TE : + (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ) = f; + break; + case D3Q27System::TW : + (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ) = f; + break; + case D3Q27System::BE : + (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3) = f; + break; + case D3Q27System::BS : + (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = f; + break; + case D3Q27System::TN : + (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ) = f; + break; + case D3Q27System::TS : + (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ) = f; + break; + case D3Q27System::BN : + (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3) = f; + break; + case D3Q27System::BSW : + (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = f; + break; + case D3Q27System::TNE : + (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1) = f; + break; + case D3Q27System::BSE : + (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3) = f; + break; + case D3Q27System::TNW : + (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1) = f; + break; + case D3Q27System::BNW : + (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3) = f; + break; + case D3Q27System::TSE : + (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1) = f; + break; + case D3Q27System::BNE : + (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3) = f; + break; + case D3Q27System::TSW : + (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1) = f; + break; + case D3Q27System::REST : + (*this->restDistributions)(x1,x2,x3) = f; + break; + default: + UB_THROW( UbException(UB_EXARGS, "Direction didn't find") ); + } +} +////////////////////////////////////////////////////////////////////////// +void D3Q27EsoTwist3DSplittedVector::setDistributionInvForDirection(const LBMReal* const f, size_t x1, size_t x2, size_t x3, unsigned long int direction) +{ + bool directionFlag = false; + if ((direction & EsoTwistD3Q27System::etE) == EsoTwistD3Q27System::etE) + (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = f[D3Q27System::E]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etW) == EsoTwistD3Q27System::etW) + (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ) = f[D3Q27System::W]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etS) == EsoTwistD3Q27System::etS) + (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ) = f[D3Q27System::S]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etN) == EsoTwistD3Q27System::etN) + (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = f[D3Q27System::N]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etB) == EsoTwistD3Q27System::etB) + (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ) = f[D3Q27System::B]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etT) == EsoTwistD3Q27System::etT) + (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = f[D3Q27System::T]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etSW) == EsoTwistD3Q27System::etSW) + (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ) = f[D3Q27System::SW]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etNE) == EsoTwistD3Q27System::etNE) + (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = f[D3Q27System::NE]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etNW) == EsoTwistD3Q27System::etNW) + (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3) = f[D3Q27System::NW]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etSE) == EsoTwistD3Q27System::etSE) + (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ) = f[D3Q27System::SE]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etBW) == EsoTwistD3Q27System::etBW) + (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ) = f[D3Q27System::BW]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etTE) == EsoTwistD3Q27System::etTE) + (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = f[D3Q27System::TE]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etTW) == EsoTwistD3Q27System::etTW) + (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3) = f[D3Q27System::TW]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etBE) == EsoTwistD3Q27System::etBE) + (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ) = f[D3Q27System::BE]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etBS) == EsoTwistD3Q27System::etBS) + (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ) = f[D3Q27System::BS]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etTN) == EsoTwistD3Q27System::etTN) + (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = f[D3Q27System::TN]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etTS) == EsoTwistD3Q27System::etTS) + (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3) = f[D3Q27System::TS]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etBN) == EsoTwistD3Q27System::etBN) + (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ) = f[D3Q27System::BN]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etBSW) == EsoTwistD3Q27System::etBSW) + (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1) = f[D3Q27System::BSW]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etTNE) == EsoTwistD3Q27System::etTNE) + (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = f[D3Q27System::TNE]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etBSE) == EsoTwistD3Q27System::etBSE) + (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1) = f[D3Q27System::BSE]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etTNW) == EsoTwistD3Q27System::etTNW) + (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3) = f[D3Q27System::TNW]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etBNW) == EsoTwistD3Q27System::etBNW) + (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1) = f[D3Q27System::BNW]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etTSE) == EsoTwistD3Q27System::etTSE) + (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3) = f[D3Q27System::TSE]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etBNE) == EsoTwistD3Q27System::etBNE) + (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1)= f[D3Q27System::BNE]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::etTSW) == EsoTwistD3Q27System::etTSW) + (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3) = f[D3Q27System::TSW]; directionFlag=true; + if ((direction & EsoTwistD3Q27System::REST) == EsoTwistD3Q27System::REST) + (*this->restDistributions)(x1,x2,x3) = f[D3Q27System::REST]; directionFlag=true; +#ifdef _DEBUG + if(!directionFlag)UB_THROW( UbException(UB_EXARGS, "Direction didn't find") ); +#endif //DEBUG +} +////////////////////////////////////////////////////////////////////////// +void D3Q27EsoTwist3DSplittedVector::setDistributionInvForDirection(LBMReal f, size_t x1, size_t x2, size_t x3, unsigned long int direction) +{ + switch (direction) + { + case D3Q27System::E : + (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = f; + break; + case D3Q27System::W : + (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ) = f; + break; + case D3Q27System::S : + (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ) = f; + break; + case D3Q27System::N : + (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = f; + break; + case D3Q27System::B : + (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ) = f; + break; + case D3Q27System::T : + (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = f; + break; + case D3Q27System::SW : + (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ) = f; + break; + case D3Q27System::NE : + (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = f; + break; + case D3Q27System::NW : + (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3) = f; + break; + case D3Q27System::SE : + (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ) = f; + break; + case D3Q27System::BW : + (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ) = f; + break; + case D3Q27System::TE : + (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = f; + break; + case D3Q27System::TW : + (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3) = f; + break; + case D3Q27System::BE : + (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ) = f; + break; + case D3Q27System::BS : + (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ) = f; + break; + case D3Q27System::TN : + (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = f; + break; + case D3Q27System::TS : + (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3) = f; + break; + case D3Q27System::BN : + (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ) = f; + break; + case D3Q27System::BSW : + (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1) = f; + break; + case D3Q27System::TNE : + (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = f; + break; + case D3Q27System::BSE : + (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1) = f; + break; + case D3Q27System::TNW : + (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3) = f; + break; + case D3Q27System::BNW : + (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1) = f; + break; + case D3Q27System::TSE : + (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3) = f; + break; + case D3Q27System::BNE : + (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1) = f; + break; + case D3Q27System::TSW : + (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3) = f; + break; + case D3Q27System::REST : + (*this->restDistributions)(x1,x2,x3) = f; + break; + default: + UB_THROW( UbException(UB_EXARGS, "Direction didn't find") ); + } +} +////////////////////////////////////////////////////////////////////////// +LBMReal D3Q27EsoTwist3DSplittedVector::getDistributionForDirection(size_t x1, size_t x2, size_t x3, int direction) +{ + switch (direction) + { + case D3Q27System::W : + return (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ); + case D3Q27System::E : + return (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3); + case D3Q27System::N : + return (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3); + case D3Q27System::S : + return (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ); + case D3Q27System::T : + return (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3); + case D3Q27System::B : + return (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ); + case D3Q27System::NE : + return (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3); + case D3Q27System::SW : + return (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ); + case D3Q27System::SE : + return (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ); + case D3Q27System::NW : + return (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3); + case D3Q27System::TE : + return (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3); + case D3Q27System::BW : + return (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ); + case D3Q27System::BE : + return (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ); + case D3Q27System::TW : + return (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3); + case D3Q27System::TN : + return (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3); + case D3Q27System::BS : + return (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ); + case D3Q27System::BN : + return (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ); + case D3Q27System::TS : + return (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3); + case D3Q27System::TNE : + return (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3); + case D3Q27System::BSW : + return (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1); + case D3Q27System::TNW : + return (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3); + case D3Q27System::BSE : + return (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1); + case D3Q27System::TSE : + return (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3); + case D3Q27System::BNW : + return (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1); + case D3Q27System::TSW : + return (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3); + case D3Q27System::BNE : + return (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1); + case D3Q27System::REST : + return (*this->restDistributions)(x1,x2,x3); + default: + UB_THROW( UbException(UB_EXARGS, "Direction didn't find") ); + } +} +////////////////////////////////////////////////////////////////////////// +LBMReal D3Q27EsoTwist3DSplittedVector::getDistributionInvForDirection(size_t x1, size_t x2, size_t x3, int direction) +{ + switch (direction) + { + case D3Q27System::E : + return (*this->nonLocalDistributions)(D3Q27System::ET_W,x1+1,x2, x3 ); + case D3Q27System::W : + return (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3); + case D3Q27System::S : + return (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3); + case D3Q27System::N : + return (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2+1,x3 ); + case D3Q27System::B : + return (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3); + case D3Q27System::T : + return (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3+1 ); + case D3Q27System::SW : + return (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3); + case D3Q27System::NE : + return (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1+1,x2+1,x3 ); + case D3Q27System::NW : + return (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2+1,x3 ); + case D3Q27System::SE : + return (*this->localDistributions)(D3Q27System::ET_NW,x1+1,x2, x3); + case D3Q27System::BW : + return (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3); + case D3Q27System::TE : + return (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1+1,x2, x3+1 ); + case D3Q27System::TW : + return (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3+1 ); + case D3Q27System::BE : + return (*this->localDistributions)(D3Q27System::ET_TW,x1+1,x2, x3); + case D3Q27System::BS : + return (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3); + case D3Q27System::TN : + return (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2+1,x3+1 ); + case D3Q27System::TS : + return (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3+1 ); + case D3Q27System::BN : + return (*this->localDistributions)(D3Q27System::ET_TS,x1, x2+1,x3); + case D3Q27System::BSW : + return (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3); + case D3Q27System::TNE : + return (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1+1,x2+1,x3+1); + case D3Q27System::BSE : + return (*this->localDistributions)(D3Q27System::ET_TNW,x1+1,x2, x3); + case D3Q27System::TNW : + return (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2+1,x3+1); + case D3Q27System::BNW : + return (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2+1,x3); + case D3Q27System::TSE : + return (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1+1,x2, x3+1); + case D3Q27System::BNE : + return (*this->localDistributions)(D3Q27System::ET_TSW,x1+1,x2+1,x3); + case D3Q27System::TSW : + return (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3+1); + case D3Q27System::REST : + return (*this->restDistributions)(x1,x2,x3); + default: + UB_THROW( UbException(UB_EXARGS, "Direction didn't find") ); + } +} +////////////////////////////////////////////////////////////////////////// +size_t D3Q27EsoTwist3DSplittedVector::getNX1() const +{ + return NX1; +} +////////////////////////////////////////////////////////////////////////// +size_t D3Q27EsoTwist3DSplittedVector::getNX2() const +{ + return NX2; +} +////////////////////////////////////////////////////////////////////////// +size_t D3Q27EsoTwist3DSplittedVector::getNX3() const +{ + return NX3; +} +////////////////////////////////////////////////////////////////////////// +CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr D3Q27EsoTwist3DSplittedVector::getLocalDistributions() +{ + return this->localDistributions; +} +////////////////////////////////////////////////////////////////////////// +CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr D3Q27EsoTwist3DSplittedVector::getNonLocalDistributions() +{ + return this->nonLocalDistributions; +} +////////////////////////////////////////////////////////////////////////// +CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr D3Q27EsoTwist3DSplittedVector::getZeroDistributions() +{ + return this->restDistributions; +} +////////////////////////////////////////////////////////////////////////// +void D3Q27EsoTwist3DSplittedVector::setNX1(size_t newNX1) +{ + NX1 = newNX1; +} +////////////////////////////////////////////////////////////////////////// +void D3Q27EsoTwist3DSplittedVector::setNX2(size_t newNX2) +{ + NX2 = newNX2; +} +////////////////////////////////////////////////////////////////////////// +void D3Q27EsoTwist3DSplittedVector::setNX3(size_t newNX3) +{ + NX3 = newNX3; +} +////////////////////////////////////////////////////////////////////////// +void D3Q27EsoTwist3DSplittedVector::setLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr array) +{ + localDistributions = array; +} +////////////////////////////////////////////////////////////////////////// +void D3Q27EsoTwist3DSplittedVector::setNonLocalDistributions(CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr array) +{ + nonLocalDistributions = array; +} +////////////////////////////////////////////////////////////////////////// +void D3Q27EsoTwist3DSplittedVector::setZeroDistributions(CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr array) +{ + restDistributions = array; +} + +////////////////////////////////////////////////////////////////////////// + diff --git a/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSplittedVector.h b/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSplittedVector.h index d6ea365f8..725b845d0 100644 --- a/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSplittedVector.h +++ b/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSplittedVector.h @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file D3Q27EsoTwist3DSplittedVector.h +//! \ingroup Data +//! \author Konstantin Kutscher +//======================================================================================= + #ifndef D3Q27EsoTwist3DSplittedVector_h #define D3Q27EsoTwist3DSplittedVector_h @@ -6,10 +39,16 @@ #include "basics/container/CbArray4D.h" #include "basics/container/CbArray3D.h" +//! \brief Class implements EsoTwist3D +//! \details D3Q27EsoTwist3DSplittedVector uses three vectors to implement Esoteric Twist method class D3Q27EsoTwist3DSplittedVector : public EsoTwist3D { public: D3Q27EsoTwist3DSplittedVector(); + //! \param nx1 number of nodes in x1 direction + //! \param nx2 number of nodes in x2 direction + //! \param nx3 number of nodes in x3 direction + //! \param value initialisation value D3Q27EsoTwist3DSplittedVector(size_t nx1, size_t nx2, size_t nx3, LBMReal value); ////////////////////////////////////////////////////////////////////////// ~D3Q27EsoTwist3DSplittedVector(); @@ -58,7 +97,7 @@ public: protected: CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr localDistributions; CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr zeroDistributions; + CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr restDistributions; size_t NX1, NX2, NX3; friend class MPIIORestartCoProcessor; diff --git a/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSplittedVectorEx.cpp b/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSplittedVectorEx.cpp deleted file mode 100644 index e4dab2518..000000000 --- a/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSplittedVectorEx.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "D3Q27EsoTwist3DSplittedVectorEx.h" - -D3Q27EsoTwist3DSplittedVectorEx::D3Q27EsoTwist3DSplittedVectorEx( int nx1, int nx2, int nx3, LBMReal value ) -{ - this->NX1 = nx1; - this->NX2 = nx2; - this->NX3 = nx3; - - this->localDistributions = CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal,IndexerX4X3X2X1>(13, nx1, nx2, nx3, value)); - this->nonLocalDistributions = CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr(new CbArray4D<LBMReal,IndexerX4X3X2X1>(13, nx1, nx2, nx3, value)); - - this->zeroDistributions = CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal,IndexerX3X2X1>(nx1, nx2, nx3, value)); -} diff --git a/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSplittedVectorEx.h b/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSplittedVectorEx.h deleted file mode 100644 index 72344f4a8..000000000 --- a/src/cpu/VirtualFluidsCore/Data/D3Q27EsoTwist3DSplittedVectorEx.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef D3Q27EsoTwist3DSplittedVectorEx_h -#define D3Q27EsoTwist3DSplittedVectorEx_h - -#include "D3Q27EsoTwist3DSplittedVector.h" - -class D3Q27EsoTwist3DSplittedVectorEx : public D3Q27EsoTwist3DSplittedVector -{ -public: - D3Q27EsoTwist3DSplittedVectorEx(int nx1, int nx2, int nx3, LBMReal value); -protected: -private: -}; - -#endif - diff --git a/src/cpu/VirtualFluidsCore/Data/DataSet3D.h b/src/cpu/VirtualFluidsCore/Data/DataSet3D.h index 4c9f96c0d..296a15065 100644 --- a/src/cpu/VirtualFluidsCore/Data/DataSet3D.h +++ b/src/cpu/VirtualFluidsCore/Data/DataSet3D.h @@ -1,135 +1,169 @@ -#ifndef DataSet3D_h -#define DataSet3D_h - -#include <PointerDefinitions.h> - -#include "basics/container/CbArray4D.h" -#include "basics/container/CbArray3D.h" -#include "DistributionArray3D.h" - -typedef CbArray4D<LBMReal,IndexerX4X3X2X1> AverageValuesArray3D; -typedef CbArray4D<LBMReal,IndexerX4X3X2X1> ShearStressValuesArray3D; -typedef CbArray3D<LBMReal, IndexerX3X2X1> RelaxationFactorArray3D; - -class DataSet3D -{ -public: - SPtr<DistributionArray3D> getFdistributions() const; - void setFdistributions(SPtr<DistributionArray3D> distributions); - - SPtr<AverageValuesArray3D> getAverageDensity() const; - void setAverageDensity(SPtr<AverageValuesArray3D> values); - - SPtr<AverageValuesArray3D> getAverageVelocity() const; - void setAverageVelocity(SPtr<AverageValuesArray3D> values); - - SPtr<AverageValuesArray3D> getAverageFluctuations() const; - void setAverageFluctuations(SPtr<AverageValuesArray3D> values); - - SPtr<AverageValuesArray3D> getAverageTriplecorrelations() const; - void setAverageTriplecorrelations(SPtr<AverageValuesArray3D> values); - - SPtr<AverageValuesArray3D> getAverageValues() const; - void setAverageValues(SPtr<AverageValuesArray3D> values); - - SPtr<ShearStressValuesArray3D> getShearStressValues() const; - void setShearStressValues(SPtr<ShearStressValuesArray3D> values); - - SPtr<RelaxationFactorArray3D> getRelaxationFactor() const; - void setRelaxationFactor(SPtr<RelaxationFactorArray3D> values); -protected: -private: - SPtr<DistributionArray3D> fdistributions; - SPtr<AverageValuesArray3D> averageValues; - - SPtr<AverageValuesArray3D> averageDensity; - SPtr<AverageValuesArray3D> averageVelocity; - SPtr<AverageValuesArray3D> averageFluktuations; - SPtr<AverageValuesArray3D> averageTriplecorrelations; - - SPtr<ShearStressValuesArray3D> shearStressValues; - - SPtr<RelaxationFactorArray3D> relaxationFactor; - -}; - -inline SPtr<DistributionArray3D> DataSet3D::getFdistributions() const -{ - return fdistributions; -} - -inline void DataSet3D::setFdistributions(SPtr<DistributionArray3D> distributions) -{ - fdistributions = distributions; -} - -inline SPtr<AverageValuesArray3D> DataSet3D::getAverageValues() const -{ - return averageValues; -} - -inline void DataSet3D::setAverageValues(SPtr<AverageValuesArray3D> values) -{ - averageValues = values; -} - -inline SPtr<AverageValuesArray3D> DataSet3D::getAverageDensity() const -{ - return averageDensity; -} - -inline void DataSet3D::setAverageDensity(SPtr<AverageValuesArray3D> values) -{ - averageDensity = values; -} - -inline SPtr<AverageValuesArray3D> DataSet3D::getAverageVelocity() const -{ - return averageVelocity; -} - -inline void DataSet3D::setAverageVelocity(SPtr<AverageValuesArray3D> values) -{ - averageVelocity = values; -} - -inline SPtr<AverageValuesArray3D> DataSet3D::getAverageFluctuations() const -{ - return averageFluktuations; -} - -inline void DataSet3D::setAverageFluctuations(SPtr<AverageValuesArray3D> values) -{ - averageFluktuations = values; -} - -inline SPtr<AverageValuesArray3D> DataSet3D::getAverageTriplecorrelations() const -{ - return averageTriplecorrelations; -} - -inline void DataSet3D::setAverageTriplecorrelations(SPtr<AverageValuesArray3D> values) -{ - averageTriplecorrelations = values; -} - -inline SPtr<ShearStressValuesArray3D> DataSet3D::getShearStressValues() const -{ - return shearStressValues; -} - -inline void DataSet3D::setShearStressValues(SPtr<ShearStressValuesArray3D> values) -{ - shearStressValues = values; -} - -inline SPtr<RelaxationFactorArray3D> DataSet3D::getRelaxationFactor() const -{ - return relaxationFactor; -} - -inline void DataSet3D::setRelaxationFactor(SPtr<RelaxationFactorArray3D> values) -{ - relaxationFactor = values; -} -#endif +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file DataSet3D.h +//! \ingroup Data +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef DataSet3D_h +#define DataSet3D_h + +#include <PointerDefinitions.h> + +#include "basics/container/CbArray4D.h" +#include "basics/container/CbArray3D.h" +#include "DistributionArray3D.h" + +typedef CbArray4D<LBMReal,IndexerX4X3X2X1> AverageValuesArray3D; +typedef CbArray4D<LBMReal,IndexerX4X3X2X1> ShearStressValuesArray3D; +typedef CbArray3D<LBMReal, IndexerX3X2X1> RelaxationFactorArray3D; + +//! A class provides an interface for data structures in the kernel. +class DataSet3D +{ +public: + SPtr<DistributionArray3D> getFdistributions() const; + void setFdistributions(SPtr<DistributionArray3D> distributions); + + SPtr<AverageValuesArray3D> getAverageDensity() const; + void setAverageDensity(SPtr<AverageValuesArray3D> values); + + SPtr<AverageValuesArray3D> getAverageVelocity() const; + void setAverageVelocity(SPtr<AverageValuesArray3D> values); + + SPtr<AverageValuesArray3D> getAverageFluctuations() const; + void setAverageFluctuations(SPtr<AverageValuesArray3D> values); + + SPtr<AverageValuesArray3D> getAverageTriplecorrelations() const; + void setAverageTriplecorrelations(SPtr<AverageValuesArray3D> values); + + SPtr<AverageValuesArray3D> getAverageValues() const; + void setAverageValues(SPtr<AverageValuesArray3D> values); + + SPtr<ShearStressValuesArray3D> getShearStressValues() const; + void setShearStressValues(SPtr<ShearStressValuesArray3D> values); + + SPtr<RelaxationFactorArray3D> getRelaxationFactor() const; + void setRelaxationFactor(SPtr<RelaxationFactorArray3D> values); +protected: +private: + SPtr<DistributionArray3D> fdistributions; + SPtr<AverageValuesArray3D> averageValues; + + SPtr<AverageValuesArray3D> averageDensity; + SPtr<AverageValuesArray3D> averageVelocity; + SPtr<AverageValuesArray3D> averageFluktuations; + SPtr<AverageValuesArray3D> averageTriplecorrelations; + + SPtr<ShearStressValuesArray3D> shearStressValues; + + SPtr<RelaxationFactorArray3D> relaxationFactor; + +}; + +inline SPtr<DistributionArray3D> DataSet3D::getFdistributions() const +{ + return fdistributions; +} + +inline void DataSet3D::setFdistributions(SPtr<DistributionArray3D> distributions) +{ + fdistributions = distributions; +} + +inline SPtr<AverageValuesArray3D> DataSet3D::getAverageValues() const +{ + return averageValues; +} + +inline void DataSet3D::setAverageValues(SPtr<AverageValuesArray3D> values) +{ + averageValues = values; +} + +inline SPtr<AverageValuesArray3D> DataSet3D::getAverageDensity() const +{ + return averageDensity; +} + +inline void DataSet3D::setAverageDensity(SPtr<AverageValuesArray3D> values) +{ + averageDensity = values; +} + +inline SPtr<AverageValuesArray3D> DataSet3D::getAverageVelocity() const +{ + return averageVelocity; +} + +inline void DataSet3D::setAverageVelocity(SPtr<AverageValuesArray3D> values) +{ + averageVelocity = values; +} + +inline SPtr<AverageValuesArray3D> DataSet3D::getAverageFluctuations() const +{ + return averageFluktuations; +} + +inline void DataSet3D::setAverageFluctuations(SPtr<AverageValuesArray3D> values) +{ + averageFluktuations = values; +} + +inline SPtr<AverageValuesArray3D> DataSet3D::getAverageTriplecorrelations() const +{ + return averageTriplecorrelations; +} + +inline void DataSet3D::setAverageTriplecorrelations(SPtr<AverageValuesArray3D> values) +{ + averageTriplecorrelations = values; +} + +inline SPtr<ShearStressValuesArray3D> DataSet3D::getShearStressValues() const +{ + return shearStressValues; +} + +inline void DataSet3D::setShearStressValues(SPtr<ShearStressValuesArray3D> values) +{ + shearStressValues = values; +} + +inline SPtr<RelaxationFactorArray3D> DataSet3D::getRelaxationFactor() const +{ + return relaxationFactor; +} + +inline void DataSet3D::setRelaxationFactor(SPtr<RelaxationFactorArray3D> values) +{ + relaxationFactor = values; +} +#endif diff --git a/src/cpu/VirtualFluidsCore/Data/DistributionArray3D.h b/src/cpu/VirtualFluidsCore/Data/DistributionArray3D.h index a49b18fee..4e333b504 100644 --- a/src/cpu/VirtualFluidsCore/Data/DistributionArray3D.h +++ b/src/cpu/VirtualFluidsCore/Data/DistributionArray3D.h @@ -1,30 +1,92 @@ -#ifndef DistributionArray3D_H -#define DistributionArray3D_H - -#include <LBMSystem.h> - -class DistributionArray3D -{ -public: - DistributionArray3D() {}; - virtual ~DistributionArray3D(){}; - virtual size_t getNX1() const = 0; - virtual size_t getNX2() const = 0; - virtual size_t getNX3() const = 0; - virtual void getDistribution(LBMReal* const f, size_t x1, size_t x2, size_t x3) = 0; - virtual void setDistribution(const LBMReal* const f, size_t x1, size_t x2, size_t x3) = 0; - virtual void getDistributionInv( LBMReal* const f, size_t x1, size_t x2, size_t x3) = 0; - virtual void setDistributionInv(const LBMReal* const f, size_t x1, size_t x2, size_t x3) = 0; - virtual void setDistributionForDirection(const LBMReal* const f, size_t x1, size_t x2, size_t x3, unsigned long int direction) = 0; - virtual void setDistributionForDirection(LBMReal f, size_t x1, size_t x2, size_t x3, int direction) = 0; - virtual LBMReal getDistributionInvForDirection(size_t x1, size_t x2, size_t x3, int direction) = 0; - virtual void setDistributionInvForDirection(const LBMReal* const f, size_t x1, size_t x2, size_t x3, unsigned long int direction) = 0; - virtual void setDistributionInvForDirection(LBMReal f, size_t x1, size_t x2, size_t x3, unsigned long int direction) = 0; - virtual LBMReal getDistributionForDirection(size_t x1, size_t x2, size_t x3, int direction) = 0; - virtual void swap() = 0; -protected: -private: - -}; - -#endif +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file DistributionArray3D.h +//! \ingroup Data +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef DistributionArray3D_H +#define DistributionArray3D_H + +#include <LBMSystem.h> + +//! \brief Abstract class of data structure for LBM +class DistributionArray3D +{ +public: + DistributionArray3D() {}; + virtual ~DistributionArray3D(){}; + //! get number of nodes for x1 direction + virtual size_t getNX1() const = 0; + //! get number of nodes for x2 direction + virtual size_t getNX2() const = 0; + //! get number of nodes for x3 direction + virtual size_t getNX3() const = 0; + //! get distribution + //! \param f distribution + //! \param x1 coordinate x1 + //! \param x2 coordinate x2 + //! \param x3 coordinate x3 + virtual void getDistribution(LBMReal* const f, size_t x1, size_t x2, size_t x3) = 0; + //! set distribution + //! \param f distribution + //! \param x1 coordinate x1 + //! \param x2 coordinate x2 + //! \param x3 coordinate x3 + virtual void setDistribution(const LBMReal* const f, size_t x1, size_t x2, size_t x3) = 0; + //! get distribution in inverse order + //! \param f distribution + //! \param x1 coordinate x1 + //! \param x2 coordinate x2 + //! \param x3 coordinate x3 + virtual void getDistributionInv( LBMReal* const f, size_t x1, size_t x2, size_t x3) = 0; + //! set distribution in inverse order + //! \param f distribution + //! \param x1 coordinate x1 + //! \param x1 coordinate x2 + //! \param x1 coordinate x3 + virtual void setDistributionInv(const LBMReal* const f, size_t x1, size_t x2, size_t x3) = 0; + //! set distribution in inverse order + //! \param f distribution + //! \param x1 coordinate x1 + //! \param x1 coordinate x2 + //! \param x1 coordinate x3 + virtual void setDistributionForDirection(const LBMReal* const f, size_t x1, size_t x2, size_t x3, unsigned long int direction) = 0; + virtual void setDistributionForDirection(LBMReal f, size_t x1, size_t x2, size_t x3, int direction) = 0; + virtual LBMReal getDistributionInvForDirection(size_t x1, size_t x2, size_t x3, int direction) = 0; + virtual void setDistributionInvForDirection(const LBMReal* const f, size_t x1, size_t x2, size_t x3, unsigned long int direction) = 0; + virtual void setDistributionInvForDirection(LBMReal f, size_t x1, size_t x2, size_t x3, unsigned long int direction) = 0; + virtual LBMReal getDistributionForDirection(size_t x1, size_t x2, size_t x3, int direction) = 0; + virtual void swap() = 0; +protected: +private: + +}; + +#endif diff --git a/src/cpu/VirtualFluidsCore/Data/EsoTwist3D.h b/src/cpu/VirtualFluidsCore/Data/EsoTwist3D.h index f24a56bf2..6b1178aaa 100644 --- a/src/cpu/VirtualFluidsCore/Data/EsoTwist3D.h +++ b/src/cpu/VirtualFluidsCore/Data/EsoTwist3D.h @@ -1,50 +1,84 @@ -#ifndef ESOTWIST3D_H -#define ESOTWIST3D_H - -#include "DistributionArray3D.h" -#include <LBMSystem.h> - -class EsoTwistD3Q27UnrollArray{}; -class EsoTwistPlusD3Q27UnrollArray{}; -class EsoTwistPlusD3Q19UnrollArray{}; - -class EsoTwist3D : public DistributionArray3D -{ -public: - EsoTwist3D(){}; - virtual ~EsoTwist3D(){}; - ////////////////////////////////////////////////////////////////////////// - virtual void swap() = 0; - ////////////////////////////////////////////////////////////////////////// - virtual void getDistribution(LBMReal* const f, size_t x1, size_t x2, size_t x3) = 0; - ////////////////////////////////////////////////////////////////////////// - virtual void setDistribution(const LBMReal* const f, size_t x1, size_t x2, size_t x3) = 0; - //////////////////////////////////////////////////////////////////////// - virtual void getDistributionInv( LBMReal* const f, size_t x1, size_t x2, size_t x3) = 0; - ////////////////////////////////////////////////////////////////////////// - virtual void setDistributionInv(const LBMReal* const f, size_t x1, size_t x2, size_t x3) = 0; - ////////////////////////////////////////////////////////////////////////// - virtual void setDistributionForDirection(const LBMReal* const f, size_t x1, size_t x2, size_t x3, unsigned long int direction) = 0; - ////////////////////////////////////////////////////////////////////////// - virtual void setDistributionForDirection(LBMReal f, size_t x1, size_t x2, size_t x3, int direction) = 0; - ////////////////////////////////////////////////////////////////////////// - //virtual void getDistributionInvForDirection(LBMReal* const& f, const size_t& x1, const size_t& x2, const size_t& x3, const unsigned long int& direction) = 0; - ////////////////////////////////////////////////////////////////////////// - virtual LBMReal getDistributionInvForDirection(size_t x1, size_t x2, size_t x3, int direction) = 0; - ////////////////////////////////////////////////////////////////////////// - virtual void setDistributionInvForDirection(const LBMReal* const f, size_t x1, size_t x2, size_t x3, unsigned long int direction) = 0; - ////////////////////////////////////////////////////////////////////////// - virtual void setDistributionInvForDirection(LBMReal f, size_t x1, size_t x2, size_t x3, unsigned long int direction) = 0; - ////////////////////////////////////////////////////////////////////////// - virtual LBMReal getDistributionForDirection(size_t x1, size_t x2, size_t x3, int direction) = 0; - ////////////////////////////////////////////////////////////////////////// - virtual size_t getNX1() const = 0; - ////////////////////////////////////////////////////////////////////////// - virtual size_t getNX2() const = 0; - ////////////////////////////////////////////////////////////////////////// - virtual size_t getNX3() const = 0; - ////////////////////////////////////////////////////////////////////////// - -}; - -#endif +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file EsoTwist3D.h +//! \ingroup Data +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef ESOTWIST3D_H +#define ESOTWIST3D_H + +#include "DistributionArray3D.h" +#include <LBMSystem.h> + +//! \brief Abstract class for implementation of Esoteric Twist method +//! \details EsoTwist3D provide an interface for different implementations of Esoteric Twist method +//! <a href="https://doi.org/10.3390/computation5020019"><b>[ Geier et al., (2017), 10.3390/computation5020019]</b></a> +// Geier, M., & Schönherr, M. (2017). Esoteric twist: an efficient in-place streaming algorithmus for the lattice Boltzmann method on massively parallel hardware. Computation, 5(2), 19. + +class EsoTwist3D : public DistributionArray3D +{ +public: + EsoTwist3D(){}; + virtual ~EsoTwist3D(){}; + ////////////////////////////////////////////////////////////////////////// + virtual void swap() = 0; + ////////////////////////////////////////////////////////////////////////// + virtual void getDistribution(LBMReal* const f, size_t x1, size_t x2, size_t x3) = 0; + ////////////////////////////////////////////////////////////////////////// + virtual void setDistribution(const LBMReal* const f, size_t x1, size_t x2, size_t x3) = 0; + //////////////////////////////////////////////////////////////////////// + virtual void getDistributionInv( LBMReal* const f, size_t x1, size_t x2, size_t x3) = 0; + ////////////////////////////////////////////////////////////////////////// + virtual void setDistributionInv(const LBMReal* const f, size_t x1, size_t x2, size_t x3) = 0; + ////////////////////////////////////////////////////////////////////////// + virtual void setDistributionForDirection(const LBMReal* const f, size_t x1, size_t x2, size_t x3, unsigned long int direction) = 0; + ////////////////////////////////////////////////////////////////////////// + virtual void setDistributionForDirection(LBMReal f, size_t x1, size_t x2, size_t x3, int direction) = 0; + ////////////////////////////////////////////////////////////////////////// + //virtual void getDistributionInvForDirection(LBMReal* const& f, const size_t& x1, const size_t& x2, const size_t& x3, const unsigned long int& direction) = 0; + ////////////////////////////////////////////////////////////////////////// + virtual LBMReal getDistributionInvForDirection(size_t x1, size_t x2, size_t x3, int direction) = 0; + ////////////////////////////////////////////////////////////////////////// + virtual void setDistributionInvForDirection(const LBMReal* const f, size_t x1, size_t x2, size_t x3, unsigned long int direction) = 0; + ////////////////////////////////////////////////////////////////////////// + virtual void setDistributionInvForDirection(LBMReal f, size_t x1, size_t x2, size_t x3, unsigned long int direction) = 0; + ////////////////////////////////////////////////////////////////////////// + virtual LBMReal getDistributionForDirection(size_t x1, size_t x2, size_t x3, int direction) = 0; + ////////////////////////////////////////////////////////////////////////// + virtual size_t getNX1() const = 0; + ////////////////////////////////////////////////////////////////////////// + virtual size_t getNX2() const = 0; + ////////////////////////////////////////////////////////////////////////// + virtual size_t getNX3() const = 0; + ////////////////////////////////////////////////////////////////////////// + +}; + +#endif diff --git a/src/cpu/VirtualFluidsCore/Data/EsoTwistD3Q27System.cpp b/src/cpu/VirtualFluidsCore/Data/EsoTwistD3Q27System.cpp index 0de7648ca..5924dc2f9 100644 --- a/src/cpu/VirtualFluidsCore/Data/EsoTwistD3Q27System.cpp +++ b/src/cpu/VirtualFluidsCore/Data/EsoTwistD3Q27System.cpp @@ -1,92 +1,125 @@ -#include "EsoTwistD3Q27System.h" - -//index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 -//f: E, W, N, S, T, B, NE, SW, SE, NW, TE, BW, BE, TW, TN, BS, BN, TS, TNE TNW TSE TSW BNE BNW BSE BSW ZERO -const int EsoTwistD3Q27System::ETX1[EsoTwistD3Q27System::ENDF+1] = { 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0 }; -const int EsoTwistD3Q27System::ETX2[EsoTwistD3Q27System::ENDF+1] = { 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 1, -1, 0, 0, -1, 0, 1, 0, -1, 0, 1, 0 }; -const int EsoTwistD3Q27System::ETX3[EsoTwistD3Q27System::ENDF+1] = { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, -1, 0, 1, 1, 0, 0, -1, 0, -1, 0, 1, 0, 1, 0 }; - -const int EsoTwistD3Q27System::etINVDIR[EsoTwistD3Q27System::ENDF+1] = { D3Q27System::INV_E, - D3Q27System::INV_W, - D3Q27System::INV_N, - D3Q27System::INV_S, - D3Q27System::INV_T, - D3Q27System::INV_B, - D3Q27System::INV_NE, - D3Q27System::INV_SW, - D3Q27System::INV_SE, - D3Q27System::INV_NW, - D3Q27System::INV_TE, - D3Q27System::INV_BW, - D3Q27System::INV_BE, - D3Q27System::INV_TW, - D3Q27System::INV_TN, - D3Q27System::INV_BS, - D3Q27System::INV_BN, - D3Q27System::INV_TS, - D3Q27System::INV_TNE, - D3Q27System::INV_TNW, - D3Q27System::INV_TSE, - D3Q27System::INV_TSW, - D3Q27System::INV_BNE, - D3Q27System::INV_BNW, - D3Q27System::INV_BSE, - D3Q27System::INV_BSW, - D3Q27System::ZERO}; - -const unsigned long int EsoTwistD3Q27System::etDIR[EsoTwistD3Q27System::ENDF+1] = { etE, - etW, - etN, - etS, - etT, - etB, - etNE, - etSW, - etSE, - etNW, - etTE, - etBW, - etBE, - etTW, - etTN, - etBS, - etBN, - etTS, - etTNE, - etTNW, - etTSE, - etTSW, - etBNE, - etBNW, - etBSE, - etBSW, - etZERO}; - - const unsigned long int EsoTwistD3Q27System::etZERO = 1;/*f0 */ - const unsigned long int EsoTwistD3Q27System::etE = 2; /*f1 */ - const unsigned long int EsoTwistD3Q27System::etW = 4; /*f2 */ - const unsigned long int EsoTwistD3Q27System::etN = 8; /*f3 */ - const unsigned long int EsoTwistD3Q27System::etS = 16; /*f4 */ - const unsigned long int EsoTwistD3Q27System::etT = 32; /*f5 */ - const unsigned long int EsoTwistD3Q27System::etB = 64; /*f6 */ - const unsigned long int EsoTwistD3Q27System::etNE = 128; /*f7 */ - const unsigned long int EsoTwistD3Q27System::etSW = 256; /*f8 */ - const unsigned long int EsoTwistD3Q27System::etSE = 512; /*f9 */ - const unsigned long int EsoTwistD3Q27System::etNW = 1024; /*f10*/ - const unsigned long int EsoTwistD3Q27System::etTE = 2048; /*f11*/ - const unsigned long int EsoTwistD3Q27System::etBW = 4096; /*f12*/ - const unsigned long int EsoTwistD3Q27System::etBE = 8192; /*f13*/ - const unsigned long int EsoTwistD3Q27System::etTW = 16384; /*f14*/ - const unsigned long int EsoTwistD3Q27System::etTN = 32768; /*f15*/ - const unsigned long int EsoTwistD3Q27System::etBS = 65536; /*f16*/ - const unsigned long int EsoTwistD3Q27System::etBN = 131072; /*f17*/ - const unsigned long int EsoTwistD3Q27System::etTS = 262144; /*f18*/ - const unsigned long int EsoTwistD3Q27System::etTNE = 524288; - const unsigned long int EsoTwistD3Q27System::etTNW = 1048576; - const unsigned long int EsoTwistD3Q27System::etTSE = 2097152; - const unsigned long int EsoTwistD3Q27System::etTSW = 4194304; - const unsigned long int EsoTwistD3Q27System::etBNE = 8388608; - const unsigned long int EsoTwistD3Q27System::etBNW = 16777216; - const unsigned long int EsoTwistD3Q27System::etBSE = 33554432; -const unsigned long int EsoTwistD3Q27System::etBSW = 67108864; - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file EsoTwistD3Q27System.cpp +//! \ingroup Data +//! \author Konstantin Kutscher +//======================================================================================= + +#include "EsoTwistD3Q27System.h" + +//index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 +//f: E, W, N, S, T, B, NE, SW, SE, NW, TE, BW, BE, TW, TN, BS, BN, TS, TNE TNW TSE TSW BNE BNW BSE BSW REST +const int EsoTwistD3Q27System::ETX1[EsoTwistD3Q27System::ENDF+1] = { 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0 }; +const int EsoTwistD3Q27System::ETX2[EsoTwistD3Q27System::ENDF+1] = { 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 1, -1, 0, 0, -1, 0, 1, 0, -1, 0, 1, 0 }; +const int EsoTwistD3Q27System::ETX3[EsoTwistD3Q27System::ENDF+1] = { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, -1, 0, 1, 1, 0, 0, -1, 0, -1, 0, 1, 0, 1, 0 }; + +const int EsoTwistD3Q27System::etINVDIR[EsoTwistD3Q27System::ENDF+1] = { D3Q27System::INV_E, + D3Q27System::INV_W, + D3Q27System::INV_N, + D3Q27System::INV_S, + D3Q27System::INV_T, + D3Q27System::INV_B, + D3Q27System::INV_NE, + D3Q27System::INV_SW, + D3Q27System::INV_SE, + D3Q27System::INV_NW, + D3Q27System::INV_TE, + D3Q27System::INV_BW, + D3Q27System::INV_BE, + D3Q27System::INV_TW, + D3Q27System::INV_TN, + D3Q27System::INV_BS, + D3Q27System::INV_BN, + D3Q27System::INV_TS, + D3Q27System::INV_TNE, + D3Q27System::INV_TNW, + D3Q27System::INV_TSE, + D3Q27System::INV_TSW, + D3Q27System::INV_BNE, + D3Q27System::INV_BNW, + D3Q27System::INV_BSE, + D3Q27System::INV_BSW, + D3Q27System::REST}; + +const unsigned long int EsoTwistD3Q27System::etDIR[EsoTwistD3Q27System::ENDF+1] = { etE, + etW, + etN, + etS, + etT, + etB, + etNE, + etSW, + etSE, + etNW, + etTE, + etBW, + etBE, + etTW, + etTN, + etBS, + etBN, + etTS, + etTNE, + etTNW, + etTSE, + etTSW, + etBNE, + etBNW, + etBSE, + etBSW, + etZERO}; + + const unsigned long int EsoTwistD3Q27System::etZERO = 1;/*f0 */ + const unsigned long int EsoTwistD3Q27System::etE = 2; /*f1 */ + const unsigned long int EsoTwistD3Q27System::etW = 4; /*f2 */ + const unsigned long int EsoTwistD3Q27System::etN = 8; /*f3 */ + const unsigned long int EsoTwistD3Q27System::etS = 16; /*f4 */ + const unsigned long int EsoTwistD3Q27System::etT = 32; /*f5 */ + const unsigned long int EsoTwistD3Q27System::etB = 64; /*f6 */ + const unsigned long int EsoTwistD3Q27System::etNE = 128; /*f7 */ + const unsigned long int EsoTwistD3Q27System::etSW = 256; /*f8 */ + const unsigned long int EsoTwistD3Q27System::etSE = 512; /*f9 */ + const unsigned long int EsoTwistD3Q27System::etNW = 1024; /*f10*/ + const unsigned long int EsoTwistD3Q27System::etTE = 2048; /*f11*/ + const unsigned long int EsoTwistD3Q27System::etBW = 4096; /*f12*/ + const unsigned long int EsoTwistD3Q27System::etBE = 8192; /*f13*/ + const unsigned long int EsoTwistD3Q27System::etTW = 16384; /*f14*/ + const unsigned long int EsoTwistD3Q27System::etTN = 32768; /*f15*/ + const unsigned long int EsoTwistD3Q27System::etBS = 65536; /*f16*/ + const unsigned long int EsoTwistD3Q27System::etBN = 131072; /*f17*/ + const unsigned long int EsoTwistD3Q27System::etTS = 262144; /*f18*/ + const unsigned long int EsoTwistD3Q27System::etTNE = 524288; + const unsigned long int EsoTwistD3Q27System::etTNW = 1048576; + const unsigned long int EsoTwistD3Q27System::etTSE = 2097152; + const unsigned long int EsoTwistD3Q27System::etTSW = 4194304; + const unsigned long int EsoTwistD3Q27System::etBNE = 8388608; + const unsigned long int EsoTwistD3Q27System::etBNW = 16777216; + const unsigned long int EsoTwistD3Q27System::etBSE = 33554432; +const unsigned long int EsoTwistD3Q27System::etBSW = 67108864; + diff --git a/src/cpu/VirtualFluidsCore/Data/EsoTwistD3Q27System.h b/src/cpu/VirtualFluidsCore/Data/EsoTwistD3Q27System.h index b5924623d..290abf4d0 100644 --- a/src/cpu/VirtualFluidsCore/Data/EsoTwistD3Q27System.h +++ b/src/cpu/VirtualFluidsCore/Data/EsoTwistD3Q27System.h @@ -1,108 +1,142 @@ -#ifndef ESOTWISTD3Q27SYSTEM_H -#define ESOTWISTD3Q27SYSTEM_H - -#include "D3Q27System.h" - -struct EsoTwistD3Q27System -{ - const static int FSTARTDIR = D3Q27System::FSTARTDIR; - const static int FENDDIR = D3Q27System::FENDDIR; //gellerstyle: meint alle frichtungen OHNE f0 - - const static int STARTF = D3Q27System::STARTF; - const static int ENDF = D3Q27System::ENDF; - - const static int STARTDIR = D3Q27System::STARTDIR; - const static int ENDDIR = D3Q27System::ENDDIR; - - static const int ZERO = D3Q27System::ZERO;/*f0 */ - static const int E = D3Q27System::E; /*f1 */ - static const int W = D3Q27System::W; /*f2 */ - static const int N = D3Q27System::N; /*f3 */ - static const int S = D3Q27System::S; /*f4 */ - static const int T = D3Q27System::T; /*f5 */ - static const int B = D3Q27System::B; /*f6 */ - static const int NE = D3Q27System::NE; /*f7 */ - static const int SW = D3Q27System::SW; /*f8 */ - static const int SE = D3Q27System::SE; /*f9 */ - static const int NW = D3Q27System::NW; /*f10*/ - static const int TE = D3Q27System::TE; /*f11*/ - static const int BW = D3Q27System::BW; /*f12*/ - static const int BE = D3Q27System::BE; /*f13*/ - static const int TW = D3Q27System::TW; /*f14*/ - static const int TN = D3Q27System::TN; /*f15*/ - static const int BS = D3Q27System::BS; /*f16*/ - static const int BN = D3Q27System::BN; /*f17*/ - static const int TS = D3Q27System::TS; /*f18*/ - static const int TNE = D3Q27System::TNE; - static const int TNW = D3Q27System::TNW; - static const int TSE = D3Q27System::TSE; - static const int TSW = D3Q27System::TSW; - static const int BNE = D3Q27System::BNE; - static const int BNW = D3Q27System::BNW; - static const int BSE = D3Q27System::BSE; - static const int BSW = D3Q27System::BSW; - - - static const int INV_E = D3Q27System::W; - static const int INV_W = D3Q27System::E; - static const int INV_N = D3Q27System::S; - static const int INV_S = D3Q27System::N; - static const int INV_T = D3Q27System::B; - static const int INV_B = D3Q27System::T; - static const int INV_NE = D3Q27System::SW; - static const int INV_SW = D3Q27System::NE; - static const int INV_SE = D3Q27System::NW; - static const int INV_NW = D3Q27System::SE; - static const int INV_TE = D3Q27System::BW; - static const int INV_BW = D3Q27System::TE; - static const int INV_BE = D3Q27System::TW; - static const int INV_TW = D3Q27System::BE; - static const int INV_TN = D3Q27System::BS; - static const int INV_BS = D3Q27System::TN; - static const int INV_BN = D3Q27System::TS; - static const int INV_TS = D3Q27System::BN; - static const int INV_TNE = D3Q27System::BSW; - static const int INV_TNW = D3Q27System::BSE; - static const int INV_TSE = D3Q27System::BNW; - static const int INV_TSW = D3Q27System::BNE; - static const int INV_BNE = D3Q27System::TSW; - static const int INV_BNW = D3Q27System::TSE; - static const int INV_BSE = D3Q27System::TNW; - static const int INV_BSW = D3Q27System::TNE; - - static const unsigned long int etZERO;// 1;/*f0 */ - static const unsigned long int etE;// 2; /*f1 */ - static const unsigned long int etW;// 4; /*f2 */ - static const unsigned long int etN;// 8; /*f3 */ - static const unsigned long int etS;// 16; /*f4 */ - static const unsigned long int etT;// 32; /*f5 */ - static const unsigned long int etB;// 64; /*f6 */ - static const unsigned long int etNE;// 128; /*f7 */ - static const unsigned long int etSW;// 256; /*f8 */ - static const unsigned long int etSE;// 512; /*f9 */ - static const unsigned long int etNW;// 1024; /*f10*/ - static const unsigned long int etTE;// 2048; /*f11*/ - static const unsigned long int etBW;// 4096; /*f12*/ - static const unsigned long int etBE;// 8192; /*f13*/ - static const unsigned long int etTW;// 16384; /*f14*/ - static const unsigned long int etTN;// 32768; /*f15*/ - static const unsigned long int etBS;// 65536; /*f16*/ - static const unsigned long int etBN;// 131072; /*f17*/ - static const unsigned long int etTS;// 262144; /*f18*/ - static const unsigned long int etTNE;// 524288; - static const unsigned long int etTNW;// 1048576; - static const unsigned long int etTSE;// 2097152; - static const unsigned long int etTSW;// 4194304; - static const unsigned long int etBNE;// 8388608; - static const unsigned long int etBNW;// 16777216; - static const unsigned long int etBSE;// 33554432; - static const unsigned long int etBSW;// = 67108864; - - const static int ETX1[ENDF+1]; - const static int ETX2[ENDF+1]; - const static int ETX3[ENDF+1]; - const static int etINVDIR[ENDF+1]; - const static unsigned long int etDIR[ENDF+1]; -}; - -#endif +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file EsoTwistD3Q27System.h +//! \ingroup Data +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef ESOTWISTD3Q27SYSTEM_H +#define ESOTWISTD3Q27SYSTEM_H + +#include "D3Q27System.h" + +//! +struct EsoTwistD3Q27System +{ + const static int FSTARTDIR = D3Q27System::FSTARTDIR; + const static int FENDDIR = D3Q27System::FENDDIR; //gellerstyle: meint alle frichtungen OHNE f0 + + const static int STARTF = D3Q27System::STARTF; + const static int ENDF = D3Q27System::ENDF; + + const static int STARTDIR = D3Q27System::STARTDIR; + const static int ENDDIR = D3Q27System::ENDDIR; + + static const int REST = D3Q27System::REST;/*f0 */ + static const int E = D3Q27System::E; /*f1 */ + static const int W = D3Q27System::W; /*f2 */ + static const int N = D3Q27System::N; /*f3 */ + static const int S = D3Q27System::S; /*f4 */ + static const int T = D3Q27System::T; /*f5 */ + static const int B = D3Q27System::B; /*f6 */ + static const int NE = D3Q27System::NE; /*f7 */ + static const int SW = D3Q27System::SW; /*f8 */ + static const int SE = D3Q27System::SE; /*f9 */ + static const int NW = D3Q27System::NW; /*f10*/ + static const int TE = D3Q27System::TE; /*f11*/ + static const int BW = D3Q27System::BW; /*f12*/ + static const int BE = D3Q27System::BE; /*f13*/ + static const int TW = D3Q27System::TW; /*f14*/ + static const int TN = D3Q27System::TN; /*f15*/ + static const int BS = D3Q27System::BS; /*f16*/ + static const int BN = D3Q27System::BN; /*f17*/ + static const int TS = D3Q27System::TS; /*f18*/ + static const int TNE = D3Q27System::TNE; + static const int TNW = D3Q27System::TNW; + static const int TSE = D3Q27System::TSE; + static const int TSW = D3Q27System::TSW; + static const int BNE = D3Q27System::BNE; + static const int BNW = D3Q27System::BNW; + static const int BSE = D3Q27System::BSE; + static const int BSW = D3Q27System::BSW; + + + static const int INV_E = D3Q27System::W; + static const int INV_W = D3Q27System::E; + static const int INV_N = D3Q27System::S; + static const int INV_S = D3Q27System::N; + static const int INV_T = D3Q27System::B; + static const int INV_B = D3Q27System::T; + static const int INV_NE = D3Q27System::SW; + static const int INV_SW = D3Q27System::NE; + static const int INV_SE = D3Q27System::NW; + static const int INV_NW = D3Q27System::SE; + static const int INV_TE = D3Q27System::BW; + static const int INV_BW = D3Q27System::TE; + static const int INV_BE = D3Q27System::TW; + static const int INV_TW = D3Q27System::BE; + static const int INV_TN = D3Q27System::BS; + static const int INV_BS = D3Q27System::TN; + static const int INV_BN = D3Q27System::TS; + static const int INV_TS = D3Q27System::BN; + static const int INV_TNE = D3Q27System::BSW; + static const int INV_TNW = D3Q27System::BSE; + static const int INV_TSE = D3Q27System::BNW; + static const int INV_TSW = D3Q27System::BNE; + static const int INV_BNE = D3Q27System::TSW; + static const int INV_BNW = D3Q27System::TSE; + static const int INV_BSE = D3Q27System::TNW; + static const int INV_BSW = D3Q27System::TNE; + + static const unsigned long int etZERO;// 1;/*f0 */ + static const unsigned long int etE;// 2; /*f1 */ + static const unsigned long int etW;// 4; /*f2 */ + static const unsigned long int etN;// 8; /*f3 */ + static const unsigned long int etS;// 16; /*f4 */ + static const unsigned long int etT;// 32; /*f5 */ + static const unsigned long int etB;// 64; /*f6 */ + static const unsigned long int etNE;// 128; /*f7 */ + static const unsigned long int etSW;// 256; /*f8 */ + static const unsigned long int etSE;// 512; /*f9 */ + static const unsigned long int etNW;// 1024; /*f10*/ + static const unsigned long int etTE;// 2048; /*f11*/ + static const unsigned long int etBW;// 4096; /*f12*/ + static const unsigned long int etBE;// 8192; /*f13*/ + static const unsigned long int etTW;// 16384; /*f14*/ + static const unsigned long int etTN;// 32768; /*f15*/ + static const unsigned long int etBS;// 65536; /*f16*/ + static const unsigned long int etBN;// 131072; /*f17*/ + static const unsigned long int etTS;// 262144; /*f18*/ + static const unsigned long int etTNE;// 524288; + static const unsigned long int etTNW;// 1048576; + static const unsigned long int etTSE;// 2097152; + static const unsigned long int etTSW;// 4194304; + static const unsigned long int etBNE;// 8388608; + static const unsigned long int etBNW;// 16777216; + static const unsigned long int etBSE;// 33554432; + static const unsigned long int etBSW;// = 67108864; + + const static int ETX1[ENDF+1]; + const static int ETX2[ENDF+1]; + const static int ETX3[ENDF+1]; + const static int etINVDIR[ENDF+1]; + const static unsigned long int etDIR[ENDF+1]; +}; + +#endif diff --git a/src/cpu/VirtualFluidsCore/Data/VoidData3D.h b/src/cpu/VirtualFluidsCore/Data/VoidData3D.h deleted file mode 100644 index d0fd78170..000000000 --- a/src/cpu/VirtualFluidsCore/Data/VoidData3D.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef VoidData3D_H -#define VoidData3D_H - -#include "EsoTwist3D.h" - - -class VoidData3D : public EsoTwist3D -{ -public: - VoidData3D() {}; - VoidData3D (size_t nx1, size_t nx2, size_t nx3, LBMReal value) - { - this->NX1 = nx1; - this->NX2 = nx2; - this->NX3 = nx3; - } - ~VoidData3D() {}; - size_t getNX1() const { return NX1;} - size_t getNX2() const { return NX2;} - size_t getNX3() const { return NX3;} - void getDistribution(LBMReal* const f, size_t x1, size_t x2, size_t x3) {} - void setDistribution(const LBMReal* const f, size_t x1, size_t x2, size_t x3){} - void getDistributionInv(LBMReal* const f, size_t x1, size_t x2, size_t x3) {} - void setDistributionInv(const LBMReal* const f, size_t x1, size_t x2, size_t x3) {} - void setDistributionForDirection(const LBMReal* const f, size_t x1, size_t x2, size_t x3, unsigned long int direction) {} - void setDistributionForDirection(LBMReal f, size_t x1, size_t x2, size_t x3, int direction) {} - LBMReal getDistributionInvForDirection(size_t x1, size_t x2, size_t x3, int direction) {return 0.0;} - void setDistributionInvForDirection(const LBMReal* const f, size_t x1, size_t x2, size_t x3, unsigned long int direction) {} - void setDistributionInvForDirection(LBMReal f, size_t x1, size_t x2, size_t x3, unsigned long int direction) {} - LBMReal getDistributionForDirection(size_t x1, size_t x2, size_t x3, int direction) {return 0.0;} - void swap() {} -protected: -private: - size_t NX1, NX2, NX3; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/Grid/BasicCalculator.cpp b/src/cpu/VirtualFluidsCore/Grid/BasicCalculator.cpp index 42985c340..9a2ee9647 100644 --- a/src/cpu/VirtualFluidsCore/Grid/BasicCalculator.cpp +++ b/src/cpu/VirtualFluidsCore/Grid/BasicCalculator.cpp @@ -1,399 +1,400 @@ -#include "BasicCalculator.h" - -#include "Block3D.h" -#include "BCProcessor.h" -#include "LBMKernel.h" -#include "Block3DConnector.h" -#include "UbScheduler.h" -#include "UbLogger.h" - -#ifdef _OPENMP -#include <omp.h> -#endif -#define OMP_SCHEDULE guided - -//#define TIMING -//#include "UbTiming.h" - -BasicCalculator::BasicCalculator(SPtr<Grid3D> grid, SPtr<UbScheduler> additionalGhostLayerUpdateScheduler, int numberOfTimeSteps) : - Calculator(grid, additionalGhostLayerUpdateScheduler, numberOfTimeSteps) -{ - -} -////////////////////////////////////////////////////////////////////////// -BasicCalculator::~BasicCalculator() -{ - -} -////////////////////////////////////////////////////////////////////////// -void BasicCalculator::calculate() -{ - UBLOG(logDEBUG1, "OMPCalculator::calculate() - started"); - int calcStep = 0; - try - { - int minInitLevel = minLevel; - int maxInitLevel = maxLevel - minLevel; - int straightStartLevel = minInitLevel; - int internalIterations = 1 << (maxInitLevel - minInitLevel); - int forwardStartLevel; - int threshold; - -#ifdef TIMING - UbTimer timer; - double time[6]; -#endif - - for (calcStep = startTimeStep; calcStep <= numberOfTimeSteps; calcStep++) - { - ////////////////////////////////////////////////////////////////////////// -#ifdef TIMING - UBLOG(logINFO, "calcStep = " << calcStep); -#endif - ////////////////////////////////////////////////////////////////////////// - - for (int staggeredStep = 1; staggeredStep <= internalIterations; staggeredStep++) - { - forwardStartLevel = straightStartLevel; - if (staggeredStep == internalIterations) straightStartLevel = minInitLevel; - else - { - for (straightStartLevel = maxInitLevel, threshold = 1; - (staggeredStep & threshold) != threshold; straightStartLevel--, threshold <<= 1); - } - ////////////////////////////////////////////////////////////////////////// -#ifdef TIMING - timer.resetAndStart(); -#endif - ////////////////////////////////////////////////////////////////////////// - applyPreCollisionBC(straightStartLevel, maxInitLevel); - - //do collision for all blocks - calculateBlocks(straightStartLevel, maxInitLevel, calcStep); - ////////////////////////////////////////////////////////////////////////// -#ifdef TIMING - time[0] = timer.stop(); - UBLOG(logINFO, "calculateBlocks time = " << time[0]); -#endif - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - //exchange data between blocks - exchangeBlockData(straightStartLevel, maxInitLevel); - ////////////////////////////////////////////////////////////////////////// -#ifdef TIMING - time[1] = timer.stop(); - UBLOG(logINFO, "exchangeBlockData time = " << time[1]); -#endif - ////////////////////////////////////////////////////////////////////////// - applyPostCollisionBC(straightStartLevel, maxInitLevel); - ////////////////////////////////////////////////////////////////////////// -#ifdef TIMING - time[2] = timer.stop(); - UBLOG(logINFO, "applyBCs time = " << time[2]); -#endif - ////////////////////////////////////////////////////////////////////////// - //swap distributions in kernel - swapDistributions(straightStartLevel, maxInitLevel); - ////////////////////////////////////////////////////////////////////////// -#ifdef TIMING - time[3] = timer.stop(); - UBLOG(logINFO, "swapDistributions time = " << time[3]); -#endif - ////////////////////////////////////////////////////////////////////////// - if (refinement) - { - if (straightStartLevel < maxInitLevel) - exchangeBlockData(straightStartLevel, maxInitLevel); - ////////////////////////////////////////////////////////////////////////// -#ifdef TIMING - time[4] = timer.stop(); - UBLOG(logINFO, "refinement exchangeBlockData time = " << time[4]); -#endif - ////////////////////////////////////////////////////////////////////////// - //now ghost nodes have actual values - //interpolation of interface nodes between grid levels - interpolation(straightStartLevel, maxInitLevel); - ////////////////////////////////////////////////////////////////////////// -#ifdef TIMING - time[5] = timer.stop(); - UBLOG(logINFO, "refinement interpolation time = " << time[5]); -#endif - ////////////////////////////////////////////////////////////////////////// - } - } - //exchange data between blocks for visualization - if (additionalGhostLayerUpdateScheduler->isDue(calcStep)) - { - exchangeBlockData(straightStartLevel, maxInitLevel); - } - coProcess((double)(calcStep)); - //now ghost nodes have actual values - } - UBLOG(logDEBUG1, "OMPCalculator::calculate() - stoped"); - } - catch (std::exception & e) - { - UBLOG(logERROR, e.what()); - UBLOG(logERROR, " step = " << calcStep); - //throw e; - //exit(EXIT_FAILURE); - } - catch (std::string & s) - { - UBLOG(logERROR, s); - //exit(EXIT_FAILURE); - //throw s; - } - catch (...) - { - UBLOG(logERROR, "unknown exception"); - //exit(EXIT_FAILURE); - //throw; - } -} -////////////////////////////////////////////////////////////////////////// -void BasicCalculator::calculateBlocks(int startLevel, int maxInitLevel, int calcStep) -{ -#ifdef _OPENMP -#pragma omp parallel -#endif - { - SPtr<Block3D> blockTemp; - //startLevel bis maxInitLevel - for (int level = startLevel; level <= maxInitLevel; level++) - { - //timer.resetAndStart(); - //call LBM kernel - int size = (int)blocks[level].size(); -#ifdef _OPENMP -#pragma omp for schedule(OMP_SCHEDULE) -#endif - for (int i = 0; i < size; i++) - { - try - { - blockTemp = blocks[level][i]; - blockTemp->getKernel()->calculate(calcStep); - } - catch (std::exception & e) - { - UBLOG(logERROR, e.what()); - UBLOG(logERROR, blockTemp->toString() << " step = " << calcStep); - std::exit(EXIT_FAILURE); - } - } - //timer.stop(); - //UBLOG(logINFO, "level = " << level << " blocks = " << blocks[level].size() << " collision time = " << timer.getTotalTime()); - } - } -} -////////////////////////////////////////////////////////////////////////// -void BasicCalculator::exchangeBlockData(int startLevel, int maxInitLevel) -{ - //startLevel bis maxInitLevel - for (int level = startLevel; level <= maxInitLevel; level++) - { - //connectorsPrepareLocal(localConns[level]); - connectorsSendLocal(localConns[level]); - //connectorsReceiveLocal(localConns[level]); - - connectorsPrepareRemote(remoteConns[level]); - connectorsSendRemote(remoteConns[level]); - connectorsReceiveRemote(remoteConns[level]); - } -} -////////////////////////////////////////////////////////////////////////// -void BasicCalculator::swapDistributions(int startLevel, int maxInitLevel) -{ -#ifdef _OPENMP -#pragma omp parallel -#endif - { - //startLevel bis maxInitLevel - for (int level = startLevel; level <= maxInitLevel; level++) - { - int size = (int)blocks[level].size(); -#ifdef _OPENMP -#pragma omp for schedule(OMP_SCHEDULE) -#endif - for (int i = 0; i < size; i++) - { - blocks[level][i]->getKernel()->swapDistributions(); - } - } - } -} -////////////////////////////////////////////////////////////////////////// -void BasicCalculator::connectorsPrepareLocal(std::vector< SPtr<Block3DConnector> >& connectors) -{ - int size = (int)connectors.size(); -#ifdef _OPENMP -#pragma omp parallel for schedule(OMP_SCHEDULE) -#endif - for (int i = 0; i < size; i++) - { - try - { - connectors[i]->prepareForReceive(); - connectors[i]->prepareForSend(); - } - catch (std::exception & e) - { - UBLOG(logERROR, e.what()); - std::exit(EXIT_FAILURE); - } - } -} -////////////////////////////////////////////////////////////////////////// -void BasicCalculator::connectorsSendLocal(std::vector< SPtr<Block3DConnector> >& connectors) -{ - int size = (int)connectors.size(); -#ifdef _OPENMP -#pragma omp parallel for schedule(OMP_SCHEDULE) -#endif - for (int i = 0; i < size; i++) - { - try - { - connectors[i]->fillSendVectors(); - connectors[i]->sendVectors(); - } - catch (std::exception & e) - { - UBLOG(logERROR, e.what()); - std::exit(EXIT_FAILURE); - } - } -} -////////////////////////////////////////////////////////////////////////// -void BasicCalculator::connectorsReceiveLocal(std::vector< SPtr<Block3DConnector> >& connectors) -{ - int size = (int)connectors.size(); -#ifdef _OPENMP -#pragma omp parallel for schedule(OMP_SCHEDULE) -#endif - for (int i = 0; i < size; i++) - { - connectors[i]->receiveVectors(); - connectors[i]->distributeReceiveVectors(); - } -} -void BasicCalculator::connectorsPrepareRemote(std::vector< SPtr<Block3DConnector> >& connectors) -{ - int size = (int)connectors.size(); - for (int i = 0; i < size; i++) - { - connectors[i]->prepareForReceive(); - connectors[i]->prepareForSend(); - } -} -////////////////////////////////////////////////////////////////////////// -void BasicCalculator::connectorsSendRemote(std::vector< SPtr<Block3DConnector> >& connectors) -{ - int size = (int)connectors.size(); - for (int i = 0; i < size; i++) - { - connectors[i]->fillSendVectors(); - connectors[i]->sendVectors(); - } -} -////////////////////////////////////////////////////////////////////////// -void BasicCalculator::connectorsReceiveRemote(std::vector< SPtr<Block3DConnector> >& connectors) -{ - int size = (int)connectors.size(); - for (int i = 0; i < size; i++) - { - connectors[i]->receiveVectors(); - connectors[i]->distributeReceiveVectors(); - } -} -////////////////////////////////////////////////////////////////////////// -void BasicCalculator::interpolation(int startLevel, int maxInitLevel) -{ - for (int level = startLevel; level < maxInitLevel; level++) - { - connectorsPrepareLocal(localInterConns[level]); - connectorsPrepareRemote(remoteInterConns[level]); - } - - for (int level = startLevel; level < maxInitLevel; level++) - { - connectorsSendLocal(localInterConns[level]); - connectorsSendRemote(remoteInterConns[level]); - } - - for (int level = startLevel; level < maxInitLevel; level++) - { - connectorsReceiveLocal(localInterConns[level]); - connectorsReceiveRemote(remoteInterConns[level]); - } -} -////////////////////////////////////////////////////////////////////////// -void BasicCalculator::applyPreCollisionBC(int startLevel, int maxInitLevel) -{ - //startLevel bis maxInitLevel - for (int level = startLevel; level <= maxInitLevel; level++) - { - int size = (int)blocks[level].size(); -#ifdef _OPENMP -#pragma omp parallel for schedule(OMP_SCHEDULE) -#endif - for (int i = 0; i < size; i++) - { - try - { - blocks[level][i]->getKernel()->getBCProcessor()->applyPreCollisionBC(); - } - catch (std::exception & e) - { - UBLOG(logERROR, e.what()); - exit(EXIT_FAILURE); - } - catch (std::string & s) - { - UBLOG(logERROR, s); - exit(EXIT_FAILURE); - } - catch (...) - { - UBLOG(logERROR, "unknown exception"); - exit(EXIT_FAILURE); - } - } - } -} -////////////////////////////////////////////////////////////////////////// -void BasicCalculator::applyPostCollisionBC(int startLevel, int maxInitLevel) -{ - //startLevel bis maxInitLevel - for (int level = startLevel; level <= maxInitLevel; level++) - { - int size = (int)blocks[level].size(); -#ifdef _OPENMP -#pragma omp parallel for schedule(OMP_SCHEDULE) -#endif - for (int i = 0; i < size; i++) - { - try - { - blocks[level][i]->getKernel()->getBCProcessor()->applyPostCollisionBC(); - } - catch (std::exception & e) - { - UBLOG(logERROR, e.what()); - exit(EXIT_FAILURE); - } - catch (std::string & s) - { - UBLOG(logERROR, s); - exit(EXIT_FAILURE); - } - catch (...) - { - UBLOG(logERROR, "unknown exception"); - exit(EXIT_FAILURE); - } - } - } -} - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file BasicCalculator.cpp +//! \ingroup Grid +//! \author Konstantin Kutscher +//======================================================================================= + +#include "BasicCalculator.h" + +#include "Block3D.h" +#include "BCProcessor.h" +#include "LBMKernel.h" +#include "Block3DConnector.h" +#include "UbScheduler.h" +#include "UbLogger.h" + +#ifdef _OPENMP +#include <omp.h> +#endif +#define OMP_SCHEDULE guided + +//#define TIMING +//#include "UbTiming.h" + +BasicCalculator::BasicCalculator(SPtr<Grid3D> grid, SPtr<UbScheduler> additionalGhostLayerUpdateScheduler, int numberOfTimeSteps) : + Calculator(grid, additionalGhostLayerUpdateScheduler, numberOfTimeSteps) +{ + +} +////////////////////////////////////////////////////////////////////////// +BasicCalculator::~BasicCalculator() +{ + +} +////////////////////////////////////////////////////////////////////////// +void BasicCalculator::calculate() +{ + UBLOG(logDEBUG1, "BasicCalculator::calculate() - started"); + int calcStep = 0; + try + { + int minInitLevel = minLevel; + int maxInitLevel = maxLevel-minLevel; + int straightStartLevel = minInitLevel; + int internalIterations = 1<<(maxInitLevel-minInitLevel); + int forwardStartLevel; + int threshold; + +#ifdef TIMING + UbTimer timer; + double time[6]; +#endif + + for (calcStep = startTimeStep; calcStep<=numberOfTimeSteps; calcStep++) + { + ////////////////////////////////////////////////////////////////////////// +#ifdef TIMING + UBLOG(logINFO, "calcStep = "<<calcStep); +#endif + ////////////////////////////////////////////////////////////////////////// + + for (int staggeredStep = 1; staggeredStep<=internalIterations; staggeredStep++) + { + forwardStartLevel = straightStartLevel; + if (staggeredStep==internalIterations) straightStartLevel = minInitLevel; + else + { + for (straightStartLevel = maxInitLevel, threshold = 1; + (staggeredStep&threshold)!=threshold; straightStartLevel--, threshold <<= 1); + } + ////////////////////////////////////////////////////////////////////////// +#ifdef TIMING + timer.resetAndStart(); +#endif + ////////////////////////////////////////////////////////////////////////// + applyPreCollisionBC(straightStartLevel, maxInitLevel); + + //do collision for all blocks + calculateBlocks(straightStartLevel, maxInitLevel, calcStep); + ////////////////////////////////////////////////////////////////////////// +#ifdef TIMING + time[0] = timer.stop(); + UBLOG(logINFO, "calculateBlocks time = "<<time[0]); +#endif + ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + //exchange data between blocks + exchangeBlockData(straightStartLevel, maxInitLevel); + ////////////////////////////////////////////////////////////////////////// +#ifdef TIMING + time[1] = timer.stop(); + UBLOG(logINFO, "exchangeBlockData time = "<<time[1]); +#endif + ////////////////////////////////////////////////////////////////////////// + applyPostCollisionBC(straightStartLevel, maxInitLevel); + ////////////////////////////////////////////////////////////////////////// +#ifdef TIMING + time[2] = timer.stop(); + UBLOG(logINFO, "applyBCs time = "<<time[2]); +#endif + ////////////////////////////////////////////////////////////////////////// + //swap distributions in kernel + swapDistributions(straightStartLevel, maxInitLevel); + ////////////////////////////////////////////////////////////////////////// +#ifdef TIMING + time[3] = timer.stop(); + UBLOG(logINFO, "swapDistributions time = "<<time[3]); +#endif + ////////////////////////////////////////////////////////////////////////// + if (refinement) + { + if (straightStartLevel<maxInitLevel) + exchangeBlockData(straightStartLevel, maxInitLevel); + ////////////////////////////////////////////////////////////////////////// +#ifdef TIMING + time[4] = timer.stop(); + UBLOG(logINFO, "refinement exchangeBlockData time = "<<time[4]); +#endif + ////////////////////////////////////////////////////////////////////////// + //now ghost nodes have actual values + //interpolation of interface nodes between grid levels + interpolation(straightStartLevel, maxInitLevel); + ////////////////////////////////////////////////////////////////////////// +#ifdef TIMING + time[5] = timer.stop(); + UBLOG(logINFO, "refinement interpolation time = "<<time[5]); +#endif + ////////////////////////////////////////////////////////////////////////// + } + } + //exchange data between blocks for visualization + if (additionalGhostLayerUpdateScheduler->isDue(calcStep)) + { + exchangeBlockData(straightStartLevel, maxInitLevel); + } + coProcess((double)(calcStep)); + //now ghost nodes have actual values + } + UBLOG(logDEBUG1, "BasicCalculator::calculate() - stoped"); + } + catch (std::exception& e) + { + UBLOG(logERROR, e.what()); + UBLOG(logERROR, " step = "<<calcStep); + //throw; + exit(EXIT_FAILURE); + } + catch (std::string& s) + { + UBLOG(logERROR, s); + exit(EXIT_FAILURE); + } + catch (...) + { + UBLOG(logERROR, "unknown exception"); + exit(EXIT_FAILURE); + } +} +////////////////////////////////////////////////////////////////////////// +void BasicCalculator::calculateBlocks(int startLevel, int maxInitLevel, int calcStep) +{ +#ifdef _OPENMP +#pragma omp parallel +#endif + { + SPtr<Block3D> blockTemp; + try + { + //startLevel bis maxInitLevel + for (int level = startLevel; level<=maxInitLevel; level++) + { + //timer.resetAndStart(); + //call LBM kernel + int size = (int)blocks[level].size(); +#ifdef _OPENMP +#pragma omp for schedule(OMP_SCHEDULE) +#endif + for (int i =0; i<size; i++) + { + blockTemp = blocks[level][i]; + blockTemp->getKernel()->calculate(calcStep); + } + //timer.stop(); + //UBLOG(logINFO, "level = " << level << " blocks = " << blocks[level].size() << " collision time = " << timer.getTotalTime()); + } + } + catch (std::exception& e) + { + UBLOG(logERROR, e.what()); + //UBLOG(logERROR, blockTemp->toString()<<" step = "<<calcStep); + //throw; + exit(EXIT_FAILURE); + } + } +} +////////////////////////////////////////////////////////////////////////// +void BasicCalculator::exchangeBlockData(int startLevel, int maxInitLevel) +{ + //startLevel bis maxInitLevel + for (int level = startLevel; level<=maxInitLevel; level++) + { + //connectorsPrepareLocal(localConns[level]); + connectorsSendLocal(localConns[level]); + //connectorsReceiveLocal(localConns[level]); + + connectorsPrepareRemote(remoteConns[level]); + connectorsSendRemote(remoteConns[level]); + connectorsReceiveRemote(remoteConns[level]); + } +} +////////////////////////////////////////////////////////////////////////// +void BasicCalculator::swapDistributions(int startLevel, int maxInitLevel) +{ +#ifdef _OPENMP +#pragma omp parallel +#endif + { + //from startLevel to maxInitLevel + for (int level = startLevel; level<=maxInitLevel; level++) + { + int size = (int)blocks[level].size(); +#ifdef _OPENMP +#pragma omp for schedule(OMP_SCHEDULE) +#endif + for (int i =0; i<size; i++) + { + blocks[level][i]->getKernel()->swapDistributions(); + } + } + } +} +////////////////////////////////////////////////////////////////////////// +void BasicCalculator::connectorsPrepareLocal(std::vector< SPtr<Block3DConnector> >& connectors) +{ + int size = (int)connectors.size(); +#ifdef _OPENMP +#pragma omp parallel for schedule(OMP_SCHEDULE) +#endif + for (int i =0; i<size; i++) + { + connectors[i]->prepareForReceive(); + connectors[i]->prepareForSend(); + } +} +////////////////////////////////////////////////////////////////////////// +void BasicCalculator::connectorsSendLocal(std::vector< SPtr<Block3DConnector> >& connectors) +{ + int size = (int)connectors.size(); +#ifdef _OPENMP +#pragma omp parallel for schedule(OMP_SCHEDULE) +#endif + for (int i =0; i<size; i++) + { + connectors[i]->fillSendVectors(); + connectors[i]->sendVectors(); + } +} +////////////////////////////////////////////////////////////////////////// +void BasicCalculator::connectorsReceiveLocal(std::vector< SPtr<Block3DConnector> >& connectors) +{ + int size = (int)connectors.size(); +#ifdef _OPENMP +#pragma omp parallel for schedule(OMP_SCHEDULE) +#endif + for (int i =0; i<size; i++) + { + connectors[i]->receiveVectors(); + connectors[i]->distributeReceiveVectors(); + } +} +void BasicCalculator::connectorsPrepareRemote(std::vector< SPtr<Block3DConnector> >& connectors) +{ + int size = (int)connectors.size(); + for (int i =0; i<size; i++) + { + connectors[i]->prepareForReceive(); + connectors[i]->prepareForSend(); + } +} +////////////////////////////////////////////////////////////////////////// +void BasicCalculator::connectorsSendRemote(std::vector< SPtr<Block3DConnector> >& connectors) +{ + int size = (int)connectors.size(); + for (int i =0; i<size; i++) + { + connectors[i]->fillSendVectors(); + connectors[i]->sendVectors(); + } +} +////////////////////////////////////////////////////////////////////////// +void BasicCalculator::connectorsReceiveRemote(std::vector< SPtr<Block3DConnector> >& connectors) +{ + int size = (int)connectors.size(); + for (int i =0; i<size; i++) + { + connectors[i]->receiveVectors(); + connectors[i]->distributeReceiveVectors(); + } +} +////////////////////////////////////////////////////////////////////////// +void BasicCalculator::interpolation(int startLevel, int maxInitLevel) +{ + for (int level = startLevel; level<maxInitLevel; level++) + { + connectorsPrepareLocal(localInterConns[level]); + connectorsPrepareRemote(remoteInterConns[level]); + } + + for (int level = startLevel; level<maxInitLevel; level++) + { + connectorsSendLocal(localInterConns[level]); + connectorsSendRemote(remoteInterConns[level]); + } + + for (int level = startLevel; level<maxInitLevel; level++) + { + connectorsReceiveLocal(localInterConns[level]); + connectorsReceiveRemote(remoteInterConns[level]); + } +} +////////////////////////////////////////////////////////////////////////// +void BasicCalculator::applyPreCollisionBC(int startLevel, int maxInitLevel) +{ + //from startLevel to maxInitLevel + for (int level = startLevel; level<=maxInitLevel; level++) + { + int size = (int)blocks[level].size(); +#ifdef _OPENMP +#pragma omp parallel for schedule(OMP_SCHEDULE) +#endif + for (int i =0; i<size; i++) + { + blocks[level][i]->getKernel()->getBCProcessor()->applyPreCollisionBC(); + } + } +} +////////////////////////////////////////////////////////////////////////// +void BasicCalculator::applyPostCollisionBC(int startLevel, int maxInitLevel) +{ + try{ + //from startLevel to maxInitLevel + for (int level = startLevel; level<=maxInitLevel; level++) + { + int size = (int)blocks[level].size(); +#ifdef _OPENMP +#pragma omp parallel for schedule(OMP_SCHEDULE) +#endif + for (int i =0; i<size; i++) + { + blocks[level][i]->getKernel()->getBCProcessor()->applyPostCollisionBC(); + } + } +} + catch (std::exception& e) + { + UBLOG(logERROR, e.what()); + //UBLOG(logERROR, " step = "<<calcStep); + //throw; + exit(EXIT_FAILURE); + } + catch (std::string& s) + { + UBLOG(logERROR, s); + //throw; + exit(EXIT_FAILURE); + } + catch (...) + { + UBLOG(logERROR, "unknown exception"); + //throw; + exit(EXIT_FAILURE); + } +} + diff --git a/src/cpu/VirtualFluidsCore/Grid/BasicCalculator.h b/src/cpu/VirtualFluidsCore/Grid/BasicCalculator.h index b77ac017f..8137a21c3 100644 --- a/src/cpu/VirtualFluidsCore/Grid/BasicCalculator.h +++ b/src/cpu/VirtualFluidsCore/Grid/BasicCalculator.h @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file BasicCalculator.h +//! \ingroup Grid +//! \author Konstantin Kutscher +//======================================================================================= + #ifndef BasicCalculator_h__ #define BasicCalculator_h__ @@ -6,8 +39,7 @@ class Block3DConnector; //! \class BasicCalculator -//! \brief Class implements basic functionality with MPI + OpenMP parallelization for main calculation loop -//! \author Konstantin Kutscher +//! \brief Class implements basic functionality with OpenMP parallelization for main calculation LBM loop class BasicCalculator : public Calculator { diff --git a/src/cpu/VirtualFluidsCore/Grid/Block3D.cpp b/src/cpu/VirtualFluidsCore/Grid/Block3D.cpp index 05c0b7852..b0aa676dc 100644 --- a/src/cpu/VirtualFluidsCore/Grid/Block3D.cpp +++ b/src/cpu/VirtualFluidsCore/Grid/Block3D.cpp @@ -1,506 +1,532 @@ -#include "Block3D.h" - -#include "Grid3DSystem.h" -#include "Block3DConnector.h" -#include "LBMKernel.h" - - -int Block3D::counter = 0; -////////////////////////////////////////////////////////////////////////// -Block3D::Block3D() : x1(0),x2(0),x3(0) - ,active(true) - ,globalID(-1) - ,rank(-1),part(-1) - ,interpolationFlagCF(0) - ,interpolationFlagFC(0) - ,level(-1) - ,bundle(-1) - ,lrank(-1) - ,localID(-1) -{ -} -////////////////////////////////////////////////////////////////////////// -Block3D::Block3D(int x1, int x2, int x3, int level) - : x1(x1), x2(x2), x3(x3) - ,active(true) - ,globalID(-1) - ,rank(0),part(0) - ,interpolationFlagCF(0) - ,interpolationFlagFC(0) - ,level(level) - ,bundle(0) - ,lrank(-1) - ,localID(-1) -{ - globalID = counter++; -} -////////////////////////////////////////////////////////////////////////// -Block3D::~Block3D() -{ -} -////////////////////////////////////////////////////////////////////////// -bool Block3D::operator==(const Block3D& src) const -{ - return (x1==src.x1 && x2==src.x2 && x3==src.x3); -} -////////////////////////////////////////////////////////////////////////// -bool Block3D::operator!=(const Block3D& src) const -{ - return !(*this==src); -} -////////////////////////////////////////////////////////////////////////// -int Block3D::getX1() const -{ - return this->x1; -} -////////////////////////////////////////////////////////////////////////// -int Block3D::getX2() const -{ - return this->x2; -} -////////////////////////////////////////////////////////////////////////// -int Block3D::getX3() const -{ - return this->x3; -} -////////////////////////////////////////////////////////////////////////// -void Block3D::setActive(bool active) -{ - this->active = active; -} -////////////////////////////////////////////////////////////////////////// -bool Block3D::isActive() const -{ - return this->active; -} -////////////////////////////////////////////////////////////////////////// -bool Block3D::isNotActive() const -{ - return(!this->active); -} -////////////////////////////////////////////////////////////////////////// -void Block3D::setKernel(SPtr<LBMKernel> kernel) -{ - this->kernel = kernel; -} -////////////////////////////////////////////////////////////////////////// -SPtr<ILBMKernel> Block3D::getKernel() const -{ - return this->kernel; -} -////////////////////////////////////////////////////////////////////////// -void Block3D::deleteKernel() -{ - this->kernel = SPtr<LBMKernel>(); -} -////////////////////////////////////////////////////////////////////////// -int Block3D::getBundle() const -{ - return bundle; -} -////////////////////////////////////////////////////////////////////////// -void Block3D::setBundle(int bundle) -{ - this->bundle = bundle; -} -////////////////////////////////////////////////////////////////////////// -void Block3D::setRank(int rank) -{ - this->rank = rank; -} -////////////////////////////////////////////////////////////////////////// -int Block3D::getRank() const -{ - return this->rank; -} -////////////////////////////////////////////////////////////////////////// -void Block3D::setLocalRank(int rank) -{ - this->lrank = rank; -} -////////////////////////////////////////////////////////////////////////// -int Block3D::getLocalRank() const -{ - return this->lrank; -} -////////////////////////////////////////////////////////////////////////// -int Block3D::getGlobalID() const -{ - return this->globalID; -} -////////////////////////////////////////////////////////////////////////// -void Block3D::setGlobalID(int id) -{ - this->globalID = id; -} -////////////////////////////////////////////////////////////////////////// -int Block3D::getLocalID() const -{ - return this->localID; -} -////////////////////////////////////////////////////////////////////////// -void Block3D::setLocalID(int id) -{ - this->localID = id; -} -////////////////////////////////////////////////////////////////////////// -int Block3D::getPart() const -{ - return this->part; -} -////////////////////////////////////////////////////////////////////////// -void Block3D::setPart(int part) -{ - this->part = part; -} -////////////////////////////////////////////////////////////////////////// -int Block3D::getLevel() const -{ - return this->level; -} -////////////////////////////////////////////////////////////////////////// -void Block3D::setLevel(int level) -{ - this->level = level; -} -////////////////////////////////////////////////////////////////////////// -SPtr<Block3DConnector> Block3D::getConnector(int dir) const -{ - for(SPtr<Block3DConnector> c : connectors) - { - if( c ) - { - if(c->getSendDir() == dir) return c; - } - } - return SPtr<Block3DConnector>(); -} -////////////////////////////////////////////////////////////////////////// -void Block3D::setConnector(SPtr<Block3DConnector> connector) -{ - connectors.push_back(connector); -} -////////////////////////////////////////////////////////////////////////// -void Block3D::deleteConnectors() -{ - connectors.clear(); -} -////////////////////////////////////////////////////////////////////////// -bool Block3D::hasConnectors() -{ - for(SPtr<Block3DConnector> c : connectors) - if( c ) return true; - - return false; -} -////////////////////////////////////////////////////////////////////////// -void Block3D::pushBackSameLevelConnectors( std::vector<SPtr<Block3DConnector>>& localSameLevelConnectors - , std::vector<SPtr<Block3DConnector>>& remoteSameLevelConnectors ) -{ - for(int i=0; i<(int)connectors.size(); i++) - { - SPtr<Block3DConnector> connector = this->connectors[i]; - if( this->connectors[i] ) - { - if( connector->isLocalConnector() && !connector->isInterpolationConnectorCF() && !connector->isInterpolationConnectorFC() ) - localSameLevelConnectors.push_back(this->connectors[i]); - else - remoteSameLevelConnectors.push_back(this->connectors[i]); - } - } -} -////////////////////////////////////////////////////////////////////////// -void Block3D::pushBackLocalSameLevelConnectors( std::vector<SPtr<Block3DConnector>>& localSameLevelConnectors ) -{ - for(int i=0; i<(int)connectors.size(); i++) - { - SPtr<Block3DConnector> connector = this->connectors[i]; - if( this->connectors[i] ) - { - if( connector->isLocalConnector() && !connector->isInterpolationConnectorCF() && !connector->isInterpolationConnectorFC() ) - localSameLevelConnectors.push_back(this->connectors[i]); - } - } -} -////////////////////////////////////////////////////////////////////////// -void Block3D::pushBackLocalSameLevelConnectors( std::vector<SPtr<Block3DConnector>>& localSameLevelConnectors, const int& dir) -{ - SPtr<Block3DConnector> connector = this->connectors[dir]; - if( this->connectors[dir] ) - { - if( connector->isLocalConnector() && !connector->isInterpolationConnectorCF() && !connector->isInterpolationConnectorFC() ) - localSameLevelConnectors.push_back(this->connectors[dir]); - } -} -////////////////////////////////////////////////////////////////////////// -void Block3D::pushBackRemoteSameLevelConnectors( std::vector<SPtr<Block3DConnector>>& remoteSameLevelConnectors ) -{ - for(int i=0; i<(int)connectors.size(); i++) - { - SPtr<Block3DConnector> connector = this->connectors[i]; - if( this->connectors[i] ) - { - if( connector->isRemoteConnector() && !connector->isInterpolationConnectorCF() && !connector->isInterpolationConnectorFC() ) - remoteSameLevelConnectors.push_back(this->connectors[i]); - } - } -} -////////////////////////////////////////////////////////////////////////// -void Block3D::pushBackRemoteSameLevelConnectors( std::vector<SPtr<Block3DConnector>>& remoteSameLevelConnectors, const int& dir ) -{ - SPtr<Block3DConnector> connector = this->connectors[dir]; - if( this->connectors[dir] ) - { - if( connector->isRemoteConnector() && !connector->isInterpolationConnectorCF() && !connector->isInterpolationConnectorFC() ) - remoteSameLevelConnectors.push_back(this->connectors[dir]); - } -} -////////////////////////////////////////////////////////////////////////// -void Block3D::pushBackLocalInterpolationConnectorsCF( std::vector<SPtr<Block3DConnector>>& localInterpolationConnectors ) -{ - for(int i=0; i<(int)connectors.size(); i++) - { - SPtr<Block3DConnector> connector = this->connectors[i]; - if( this->connectors[i] ) - { - if( connector->isLocalConnector() && connector->isInterpolationConnectorCF() ) - localInterpolationConnectors.push_back(this->connectors[i]); - } - } -} -////////////////////////////////////////////////////////////////////////// -void Block3D::pushBackRemoteInterpolationConnectorsCF( std::vector<SPtr<Block3DConnector>>& remoteInterpolationConnectors ) -{ - for(int i=0; i<(int)connectors.size(); i++) - { - SPtr<Block3DConnector> connector = this->connectors[i]; - if( this->connectors[i] ) - { - if( connector->isRemoteConnector() && connector->isInterpolationConnectorCF() ) - remoteInterpolationConnectors.push_back(this->connectors[i]); - } - } -} -////////////////////////////////////////////////////////////////////////// -void Block3D::pushBackLocalInterpolationConnectorsFC( std::vector<SPtr<Block3DConnector>>& localInterpolationConnectors ) -{ - for(int i=0; i<(int)connectors.size(); i++) - { - SPtr<Block3DConnector> connector = this->connectors[i]; - if( this->connectors[i] ) - { - if( connector->isLocalConnector() && connector->isInterpolationConnectorFC() ) - localInterpolationConnectors.push_back(this->connectors[i]); - } - } -} -////////////////////////////////////////////////////////////////////////// -void Block3D::pushBackRemoteInterpolationConnectorsFC( std::vector<SPtr<Block3DConnector>>& remoteInterpolationConnectors ) -{ - for(int i=0; i<(int)connectors.size(); i++) - { - SPtr<Block3DConnector> connector = this->connectors[i]; - if( this->connectors[i] ) - { - if( connector->isRemoteConnector() && connector->isInterpolationConnectorFC() ) - remoteInterpolationConnectors.push_back(this->connectors[i]); - } - } -} -////////////////////////////////////////////////////////////////////////// -int Block3D::getNumberOfLocalConnectors() -{ - int count = 0; - for(int i=0; i<(int)connectors.size(); i++) - { - SPtr<Block3DConnector> connector = this->connectors[i]; - if( this->connectors[i] ) - { - if( connector->isLocalConnector() ) count++; - } - } - return count; -} -////////////////////////////////////////////////////////////////////////// -int Block3D::getNumberOfRemoteConnectors() -{ - int count = 0; - for(int i=0; i<(int)connectors.size(); i++) - { - SPtr<Block3DConnector> connector = this->connectors[i]; - if( this->connectors[i] ) - { - if( connector->isRemoteConnector() ) count++; - } - } - return count; -} -////////////////////////////////////////////////////////////////////////// -int Block3D::getNumberOfLocalConnectorsForSurfaces() -{ - int count = 0; - - if(connectors.size() < 6) - return count; - - for(int dir=0; dir<=5; dir++) //Hard coding. It works if you have 0...5 for E, N ... B - { - SPtr<Block3DConnector> connector = this->connectors[dir]; - if( this->connectors[dir] ) - { - if( connector->isLocalConnector() ) count++; - } - } - return count; -} -////////////////////////////////////////////////////////////////////////// -int Block3D::getNumberOfRemoteConnectorsForSurfaces() -{ - int count = 0; - for(int dir=0; dir<=5; dir++) //Hard coding. It works if you have 0...5 for E, N ... B - { - SPtr<Block3DConnector> connector = this->connectors[dir]; - if( this->connectors[dir] ) - { - if( connector->isRemoteConnector() ) count++; - } - } - return count; -} -void Block3D::setCollectionOfInterpolationFlagCF(int flags) -{ - interpolationFlagCF = flags; -} -////////////////////////////////////////////////////////////////////////// -void Block3D::setInterpolationFlagCF(int dir) -{ - UbSystem::setBit(interpolationFlagCF, 1<<dir); -} -////////////////////////////////////////////////////////////////////////// -int Block3D::getCollectionOfInterpolationFlagCF() -{ - return interpolationFlagCF; -} -////////////////////////////////////////////////////////////////////////// -bool Block3D::hasInterpolationFlagCF(int dir) -{ - return UbSystem::bitCheck( interpolationFlagCF, 1<<dir ); -} -void Block3D::setCollectionOfInterpolationFlagFC(int flags) -{ - interpolationFlagFC = flags; -} -////////////////////////////////////////////////////////////////////////// -void Block3D::setInterpolationFlagFC(int dir) -{ - UbSystem::setBit(interpolationFlagFC, 1<<dir); -} -////////////////////////////////////////////////////////////////////////// -int Block3D::getCollectionOfInterpolationFlagFC() -{ - return interpolationFlagFC; -} -////////////////////////////////////////////////////////////////////////// -bool Block3D::hasInterpolationFlagFC(int dir) -{ - return UbSystem::bitCheck( interpolationFlagFC, 1<<dir ); -} -////////////////////////////////////////////////////////////////////////// -bool Block3D::hasInterpolationFlag() -{ - return(interpolationFlagCF!=0 || interpolationFlagFC!=0); -} -////////////////////////////////////////////////////////////////////////// -bool Block3D::hasInterpolationFlag(int direction) -{ - return(hasInterpolationFlagCF(direction) || hasInterpolationFlagFC(direction)); -} -////////////////////////////////////////////////////////////////////////// -bool Block3D::hasInterpolationFlagCF() -{ - return(interpolationFlagCF!=0); -} -////////////////////////////////////////////////////////////////////////// -bool Block3D::hasInterpolationFlagFC() -{ - return(interpolationFlagFC!=0); -} -////////////////////////////////////////////////////////////////////////// -void Block3D::deleteInterpolationFlag() -{ - interpolationFlagFC = 0; - interpolationFlagCF = 0; -} -////////////////////////////////////////////////////////////////////////// -double Block3D::getWorkLoad() -{ - double l = kernel->getCalculationTime(); - l *= static_cast<double>(1<<level); - return l; -} -////////////////////////////////////////////////////////////////////////// -std::string Block3D::toString() -{ - std::stringstream ss; - ss<<"Block3D[(x1,x2,x3,level),"; - ss<<" ("<<this->x1<<", "<<this->x2<<", "<<this->x3<<", "<<this->level<<"), id=" << globalID; - ss<< ", active="<<this->active<< ", bundle="<<this->bundle<< ", rank="<<this->rank<<"]"; - ss<<" connectors:"; - for(std::size_t i=0; i<connectors.size(); i++) - if( connectors[i] ) - { - if(connectors[i]->isLocalConnector()) - ss <<"l."<< Grid3DSystem::getDirectionString(connectors[i]->getSendDir()) << ", "; - if(connectors[i]->isRemoteConnector()) - ss <<"r."<< Grid3DSystem::getDirectionString(connectors[i]->getSendDir()) << ", "; - if(connectors[i]->isInterpolationConnectorCF()) - ss <<"cf."<< Grid3DSystem::getDirectionString(connectors[i]->getSendDir()) << ", "; - if(connectors[i]->isInterpolationConnectorFC()) - ss <<"fc."<< Grid3DSystem::getDirectionString(connectors[i]->getSendDir()) << ", "; - } - return ss.str(); -} -////////////////////////////////////////////////////////////////////////// -void Block3D::setWeight( int rank, int weight ) -{ - std::map<int, int>::iterator it; - if((it = this->weight.find(rank)) != this->weight.end()) - it->second = weight; - else - this->weight.insert(std::make_pair(rank, weight)); -} -////////////////////////////////////////////////////////////////////////// -int Block3D::getWeight( int rank ) -{ - std::map<int, int>::iterator it; - if((it = this->weight.find(rank)) != this->weight.end()) - return it->second; - else - return 0; -} -////////////////////////////////////////////////////////////////////////// -void Block3D::addWeight( int rank, int weight ) -{ - int weight_old = getWeight(rank); - weight += weight_old; - setWeight(rank, weight); -} -////////////////////////////////////////////////////////////////////////// -void Block3D::addWeightForAll( int weight ) -{ - typedef std::map<int, int> wMap; - for (wMap::value_type &w : this->weight) - { - w.second += weight; - } -} -////////////////////////////////////////////////////////////////////////// -void Block3D::clearWeight() -{ - this->weight.clear(); -} -////////////////////////////////////////////////////////////////////////// -int Block3D::getWeightSize() -{ - return static_cast<int>(this->weight.size()); -} +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Block3D.cpp +//! \ingroup Grid +//! \author Konstantin Kutscher +//======================================================================================= + +#include "Block3D.h" + +#include "Grid3DSystem.h" +#include "Block3DConnector.h" +#include "LBMKernel.h" + + +int Block3D::counter = 0; +////////////////////////////////////////////////////////////////////////// +Block3D::Block3D() : x1(0),x2(0),x3(0) + ,active(true) + ,globalID(-1) + ,rank(-1),part(-1) + ,interpolationFlagCF(0) + ,interpolationFlagFC(0) + ,level(-1) + ,bundle(-1) + ,lrank(-1) + ,localID(-1) +{ +} +////////////////////////////////////////////////////////////////////////// +Block3D::Block3D(int x1, int x2, int x3, int level) + : x1(x1), x2(x2), x3(x3) + ,active(true) + ,globalID(-1) + ,rank(0),part(0) + ,interpolationFlagCF(0) + ,interpolationFlagFC(0) + ,level(level) + ,bundle(0) + ,lrank(-1) + ,localID(-1) +{ + globalID = counter++; +} +////////////////////////////////////////////////////////////////////////// +Block3D::~Block3D() +{ +} +////////////////////////////////////////////////////////////////////////// +bool Block3D::operator==(const Block3D& src) const +{ + return (x1==src.x1 && x2==src.x2 && x3==src.x3); +} +////////////////////////////////////////////////////////////////////////// +bool Block3D::operator!=(const Block3D& src) const +{ + return !(*this==src); +} +////////////////////////////////////////////////////////////////////////// +int Block3D::getX1() const +{ + return this->x1; +} +////////////////////////////////////////////////////////////////////////// +int Block3D::getX2() const +{ + return this->x2; +} +////////////////////////////////////////////////////////////////////////// +int Block3D::getX3() const +{ + return this->x3; +} +////////////////////////////////////////////////////////////////////////// +void Block3D::setActive(bool active) +{ + this->active = active; +} +////////////////////////////////////////////////////////////////////////// +bool Block3D::isActive() const +{ + return this->active; +} +////////////////////////////////////////////////////////////////////////// +bool Block3D::isNotActive() const +{ + return(!this->active); +} +////////////////////////////////////////////////////////////////////////// +void Block3D::setKernel(SPtr<LBMKernel> kernel) +{ + this->kernel = kernel; +} +////////////////////////////////////////////////////////////////////////// +SPtr<ILBMKernel> Block3D::getKernel() const +{ + return this->kernel; +} +////////////////////////////////////////////////////////////////////////// +void Block3D::deleteKernel() +{ + this->kernel = SPtr<LBMKernel>(); +} +////////////////////////////////////////////////////////////////////////// +int Block3D::getBundle() const +{ + return bundle; +} +////////////////////////////////////////////////////////////////////////// +void Block3D::setBundle(int bundle) +{ + this->bundle = bundle; +} +////////////////////////////////////////////////////////////////////////// +void Block3D::setRank(int rank) +{ + this->rank = rank; +} +////////////////////////////////////////////////////////////////////////// +int Block3D::getRank() const +{ + return this->rank; +} +////////////////////////////////////////////////////////////////////////// +void Block3D::setLocalRank(int rank) +{ + this->lrank = rank; +} +////////////////////////////////////////////////////////////////////////// +int Block3D::getLocalRank() const +{ + return this->lrank; +} +////////////////////////////////////////////////////////////////////////// +int Block3D::getGlobalID() const +{ + return this->globalID; +} +////////////////////////////////////////////////////////////////////////// +void Block3D::setGlobalID(int id) +{ + this->globalID = id; +} +////////////////////////////////////////////////////////////////////////// +int Block3D::getLocalID() const +{ + return this->localID; +} +////////////////////////////////////////////////////////////////////////// +void Block3D::setLocalID(int id) +{ + this->localID = id; +} +////////////////////////////////////////////////////////////////////////// +int Block3D::getPart() const +{ + return this->part; +} +////////////////////////////////////////////////////////////////////////// +void Block3D::setPart(int part) +{ + this->part = part; +} +////////////////////////////////////////////////////////////////////////// +int Block3D::getLevel() const +{ + return this->level; +} +////////////////////////////////////////////////////////////////////////// +void Block3D::setLevel(int level) +{ + this->level = level; +} +////////////////////////////////////////////////////////////////////////// +SPtr<Block3DConnector> Block3D::getConnector(int dir) const +{ + for(SPtr<Block3DConnector> c : connectors) + { + if( c ) + { + if(c->getSendDir() == dir) return c; + } + } + return SPtr<Block3DConnector>(); +} +////////////////////////////////////////////////////////////////////////// +void Block3D::setConnector(SPtr<Block3DConnector> connector) +{ + connectors.push_back(connector); +} +////////////////////////////////////////////////////////////////////////// +void Block3D::deleteConnectors() +{ + connectors.clear(); +} +////////////////////////////////////////////////////////////////////////// +bool Block3D::hasConnectors() +{ + for(SPtr<Block3DConnector> c : connectors) + if( c ) return true; + + return false; +} +////////////////////////////////////////////////////////////////////////// +void Block3D::pushBackSameLevelConnectors( std::vector<SPtr<Block3DConnector>>& localSameLevelConnectors + , std::vector<SPtr<Block3DConnector>>& remoteSameLevelConnectors ) +{ + for(int i=0; i<(int)connectors.size(); i++) + { + SPtr<Block3DConnector> connector = this->connectors[i]; + if( this->connectors[i] ) + { + if( connector->isLocalConnector() && !connector->isInterpolationConnectorCF() && !connector->isInterpolationConnectorFC() ) + localSameLevelConnectors.push_back(this->connectors[i]); + else + remoteSameLevelConnectors.push_back(this->connectors[i]); + } + } +} +////////////////////////////////////////////////////////////////////////// +void Block3D::pushBackLocalSameLevelConnectors( std::vector<SPtr<Block3DConnector>>& localSameLevelConnectors ) +{ + for(int i=0; i<(int)connectors.size(); i++) + { + SPtr<Block3DConnector> connector = this->connectors[i]; + if( this->connectors[i] ) + { + if( connector->isLocalConnector() && !connector->isInterpolationConnectorCF() && !connector->isInterpolationConnectorFC() ) + localSameLevelConnectors.push_back(this->connectors[i]); + } + } +} +////////////////////////////////////////////////////////////////////////// +void Block3D::pushBackLocalSameLevelConnectors( std::vector<SPtr<Block3DConnector>>& localSameLevelConnectors, const int& dir) +{ + SPtr<Block3DConnector> connector = this->connectors[dir]; + if( this->connectors[dir] ) + { + if( connector->isLocalConnector() && !connector->isInterpolationConnectorCF() && !connector->isInterpolationConnectorFC() ) + localSameLevelConnectors.push_back(this->connectors[dir]); + } +} +////////////////////////////////////////////////////////////////////////// +void Block3D::pushBackRemoteSameLevelConnectors( std::vector<SPtr<Block3DConnector>>& remoteSameLevelConnectors ) +{ + for(int i=0; i<(int)connectors.size(); i++) + { + SPtr<Block3DConnector> connector = this->connectors[i]; + if( this->connectors[i] ) + { + if( connector->isRemoteConnector() && !connector->isInterpolationConnectorCF() && !connector->isInterpolationConnectorFC() ) + remoteSameLevelConnectors.push_back(this->connectors[i]); + } + } +} +////////////////////////////////////////////////////////////////////////// +void Block3D::pushBackRemoteSameLevelConnectors( std::vector<SPtr<Block3DConnector>>& remoteSameLevelConnectors, const int& dir ) +{ + SPtr<Block3DConnector> connector = this->connectors[dir]; + if( this->connectors[dir] ) + { + if( connector->isRemoteConnector() && !connector->isInterpolationConnectorCF() && !connector->isInterpolationConnectorFC() ) + remoteSameLevelConnectors.push_back(this->connectors[dir]); + } +} +////////////////////////////////////////////////////////////////////////// +void Block3D::pushBackLocalInterpolationConnectorsCF( std::vector<SPtr<Block3DConnector>>& localInterpolationConnectors ) +{ + for(int i=0; i<(int)connectors.size(); i++) + { + SPtr<Block3DConnector> connector = this->connectors[i]; + if( this->connectors[i] ) + { + if( connector->isLocalConnector() && connector->isInterpolationConnectorCF() ) + localInterpolationConnectors.push_back(this->connectors[i]); + } + } +} +////////////////////////////////////////////////////////////////////////// +void Block3D::pushBackRemoteInterpolationConnectorsCF( std::vector<SPtr<Block3DConnector>>& remoteInterpolationConnectors ) +{ + for(int i=0; i<(int)connectors.size(); i++) + { + SPtr<Block3DConnector> connector = this->connectors[i]; + if( this->connectors[i] ) + { + if( connector->isRemoteConnector() && connector->isInterpolationConnectorCF() ) + remoteInterpolationConnectors.push_back(this->connectors[i]); + } + } +} +////////////////////////////////////////////////////////////////////////// +void Block3D::pushBackLocalInterpolationConnectorsFC( std::vector<SPtr<Block3DConnector>>& localInterpolationConnectors ) +{ + for(int i=0; i<(int)connectors.size(); i++) + { + SPtr<Block3DConnector> connector = this->connectors[i]; + if( this->connectors[i] ) + { + if( connector->isLocalConnector() && connector->isInterpolationConnectorFC() ) + localInterpolationConnectors.push_back(this->connectors[i]); + } + } +} +////////////////////////////////////////////////////////////////////////// +void Block3D::pushBackRemoteInterpolationConnectorsFC( std::vector<SPtr<Block3DConnector>>& remoteInterpolationConnectors ) +{ + for(int i=0; i<(int)connectors.size(); i++) + { + SPtr<Block3DConnector> connector = this->connectors[i]; + if( this->connectors[i] ) + { + if( connector->isRemoteConnector() && connector->isInterpolationConnectorFC() ) + remoteInterpolationConnectors.push_back(this->connectors[i]); + } + } +} +////////////////////////////////////////////////////////////////////////// +int Block3D::getNumberOfLocalConnectors() +{ + int count = 0; + for(int i=0; i<(int)connectors.size(); i++) + { + SPtr<Block3DConnector> connector = this->connectors[i]; + if( this->connectors[i] ) + { + if( connector->isLocalConnector() ) count++; + } + } + return count; +} +////////////////////////////////////////////////////////////////////////// +int Block3D::getNumberOfRemoteConnectors() +{ + int count = 0; + for(int i=0; i<(int)connectors.size(); i++) + { + SPtr<Block3DConnector> connector = this->connectors[i]; + if( this->connectors[i] ) + { + if( connector->isRemoteConnector() ) count++; + } + } + return count; +} +////////////////////////////////////////////////////////////////////////// +int Block3D::getNumberOfLocalConnectorsForSurfaces() +{ + int count = 0; + + if(connectors.size() < 6) + return count; + + for(int dir=0; dir<=5; dir++) //Hard coding. It works if you have 0...5 for E, N ... B + { + SPtr<Block3DConnector> connector = this->connectors[dir]; + if( this->connectors[dir] ) + { + if( connector->isLocalConnector() ) count++; + } + } + return count; +} +////////////////////////////////////////////////////////////////////////// +int Block3D::getNumberOfRemoteConnectorsForSurfaces() +{ + int count = 0; + for(int dir=0; dir<=5; dir++) //Hard coding. It works if you have 0...5 for E, N ... B + { + SPtr<Block3DConnector> connector = this->connectors[dir]; + if( this->connectors[dir] ) + { + if( connector->isRemoteConnector() ) count++; + } + } + return count; +} +void Block3D::setCollectionOfInterpolationFlagCF(int flags) +{ + interpolationFlagCF = flags; +} +////////////////////////////////////////////////////////////////////////// +void Block3D::setInterpolationFlagCF(int dir) +{ + UbSystem::setBit(interpolationFlagCF, 1<<dir); +} +////////////////////////////////////////////////////////////////////////// +int Block3D::getCollectionOfInterpolationFlagCF() +{ + return interpolationFlagCF; +} +////////////////////////////////////////////////////////////////////////// +bool Block3D::hasInterpolationFlagCF(int dir) +{ + return UbSystem::bitCheck( interpolationFlagCF, 1<<dir ); +} +void Block3D::setCollectionOfInterpolationFlagFC(int flags) +{ + interpolationFlagFC = flags; +} +////////////////////////////////////////////////////////////////////////// +void Block3D::setInterpolationFlagFC(int dir) +{ + UbSystem::setBit(interpolationFlagFC, 1<<dir); +} +////////////////////////////////////////////////////////////////////////// +int Block3D::getCollectionOfInterpolationFlagFC() +{ + return interpolationFlagFC; +} +////////////////////////////////////////////////////////////////////////// +bool Block3D::hasInterpolationFlagFC(int dir) +{ + return UbSystem::bitCheck( interpolationFlagFC, 1<<dir ); +} +////////////////////////////////////////////////////////////////////////// +bool Block3D::hasInterpolationFlag() +{ + return(interpolationFlagCF!=0 || interpolationFlagFC!=0); +} +////////////////////////////////////////////////////////////////////////// +bool Block3D::hasInterpolationFlag(int direction) +{ + return(hasInterpolationFlagCF(direction) || hasInterpolationFlagFC(direction)); +} +////////////////////////////////////////////////////////////////////////// +bool Block3D::hasInterpolationFlagCF() +{ + return(interpolationFlagCF!=0); +} +////////////////////////////////////////////////////////////////////////// +bool Block3D::hasInterpolationFlagFC() +{ + return(interpolationFlagFC!=0); +} +////////////////////////////////////////////////////////////////////////// +void Block3D::deleteInterpolationFlag() +{ + interpolationFlagFC = 0; + interpolationFlagCF = 0; +} +////////////////////////////////////////////////////////////////////////// +std::string Block3D::toString() +{ + std::stringstream ss; + ss<<"Block3D[(x1,x2,x3,level),"; + ss<<" ("<<this->x1<<", "<<this->x2<<", "<<this->x3<<", "<<this->level<<"), id=" << globalID; + ss<< ", active="<<this->active<< ", bundle="<<this->bundle<< ", rank="<<this->rank<<"]"; + ss<<" connectors:"; + for(std::size_t i=0; i<connectors.size(); i++) + if( connectors[i] ) + { + if(connectors[i]->isLocalConnector()) + ss <<"l."<< Grid3DSystem::getDirectionString(connectors[i]->getSendDir()) << ", "; + if(connectors[i]->isRemoteConnector()) + ss <<"r."<< Grid3DSystem::getDirectionString(connectors[i]->getSendDir()) << ", "; + if(connectors[i]->isInterpolationConnectorCF()) + ss <<"cf."<< Grid3DSystem::getDirectionString(connectors[i]->getSendDir()) << ", "; + if(connectors[i]->isInterpolationConnectorFC()) + ss <<"fc."<< Grid3DSystem::getDirectionString(connectors[i]->getSendDir()) << ", "; + } + return ss.str(); +} +////////////////////////////////////////////////////////////////////////// +void Block3D::setWeight( int rank, int weight ) +{ + std::map<int, int>::iterator it; + if((it = this->weight.find(rank)) != this->weight.end()) + it->second = weight; + else + this->weight.insert(std::make_pair(rank, weight)); +} +////////////////////////////////////////////////////////////////////////// +int Block3D::getWeight( int rank ) +{ + std::map<int, int>::iterator it; + if((it = this->weight.find(rank)) != this->weight.end()) + return it->second; + else + return 0; +} +////////////////////////////////////////////////////////////////////////// +void Block3D::addWeight( int rank, int weight ) +{ + int weight_old = getWeight(rank); + weight += weight_old; + setWeight(rank, weight); +} +////////////////////////////////////////////////////////////////////////// +void Block3D::addWeightForAll( int weight ) +{ + typedef std::map<int, int> wMap; + for (wMap::value_type &w : this->weight) + { + w.second += weight; + } +} +////////////////////////////////////////////////////////////////////////// +void Block3D::clearWeight() +{ + this->weight.clear(); +} +////////////////////////////////////////////////////////////////////////// +int Block3D::getWeightSize() +{ + return static_cast<int>(this->weight.size()); +} diff --git a/src/cpu/VirtualFluidsCore/Grid/Block3D.h b/src/cpu/VirtualFluidsCore/Grid/Block3D.h index 79a940717..a47c0c9df 100644 --- a/src/cpu/VirtualFluidsCore/Grid/Block3D.h +++ b/src/cpu/VirtualFluidsCore/Grid/Block3D.h @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Block3D.h +//! \ingroup Grid +//! \author Konstantin Kutscher +//======================================================================================= + #ifndef BLOCK3D_H #define BLOCK3D_H @@ -10,6 +43,7 @@ class Block3DConnector; class LBMKernel; class ILBMKernel; +//! A class implements a block structure class Block3D { public: @@ -98,8 +132,6 @@ public: bool hasInterpolationFlagFC(int dir); bool hasInterpolationFlagFC(); - double getWorkLoad(); - std::string toString() ; static int getMaxGlobalID() { return counter; } diff --git a/src/cpu/VirtualFluidsCore/Grid/CMakePackage.txt b/src/cpu/VirtualFluidsCore/Grid/CMakePackage.txt index 9354d3d00..1b8416f01 100644 --- a/src/cpu/VirtualFluidsCore/Grid/CMakePackage.txt +++ b/src/cpu/VirtualFluidsCore/Grid/CMakePackage.txt @@ -1,2 +1,2 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) +GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) diff --git a/src/cpu/VirtualFluidsCore/Grid/Calculator.cpp b/src/cpu/VirtualFluidsCore/Grid/Calculator.cpp index 0e8916073..bdd85a797 100644 --- a/src/cpu/VirtualFluidsCore/Grid/Calculator.cpp +++ b/src/cpu/VirtualFluidsCore/Grid/Calculator.cpp @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Calculator.cpp +//! \ingroup Grid +//! \author Konstantin Kutscher +//======================================================================================= + #include "Calculator.h" #include "Grid3D.h" diff --git a/src/cpu/VirtualFluidsCore/Grid/Calculator.h b/src/cpu/VirtualFluidsCore/Grid/Calculator.h index ab266aaa2..7816bdc58 100644 --- a/src/cpu/VirtualFluidsCore/Grid/Calculator.h +++ b/src/cpu/VirtualFluidsCore/Grid/Calculator.h @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Calculator.h +//! \ingroup Grid +//! \author Konstantin Kutscher +//======================================================================================= + #ifndef CALCULATOR_H #define CALCULATOR_H @@ -11,8 +44,7 @@ class Block3DConnector; class CoProcessor; //! \class Calculator -//! \brief Abstract class for main calculation loop -//! \author Konstantin Kutscher +//! \brief A base class for main calculation loop class Calculator { diff --git a/src/cpu/VirtualFluidsCore/Grid/Grid3D.cpp b/src/cpu/VirtualFluidsCore/Grid/Grid3D.cpp index 2cbf52fa5..e62153933 100644 --- a/src/cpu/VirtualFluidsCore/Grid/Grid3D.cpp +++ b/src/cpu/VirtualFluidsCore/Grid/Grid3D.cpp @@ -1,8 +1,41 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Grid.cpp +//! \ingroup Grid +//! \author Konstantin Kutscher +//======================================================================================= + #include "Grid3D.h" #include <set> -#include <numerics/geometry3d/CoordinateTransformation3D.h> +#include <geometry3d/CoordinateTransformation3D.h> #include <basics/writer/WbWriterVtkXmlASCII.h> #include "Grid3DVisitor.h" @@ -31,7 +64,7 @@ Grid3D::Grid3D() : nx2(0), nx3(0) { - levelSet.resize(Grid3DSystem::MAXLEVEL + 1); + levelSet.resize(Grid3DSystem::MAXLEVEL+1); } ////////////////////////////////////////////////////////////////////////// Grid3D::Grid3D(SPtr<Communicator> comm) : @@ -49,8 +82,7 @@ Grid3D::Grid3D(SPtr<Communicator> comm) : nx2(0), nx3(0) { - levelSet.resize(Grid3DSystem::MAXLEVEL + 1); - bundle = comm->getBundleID(); + levelSet.resize(Grid3DSystem::MAXLEVEL+1); rank = comm->getProcessID(); } ////////////////////////////////////////////////////////////////////////// @@ -69,8 +101,7 @@ Grid3D::Grid3D(SPtr<Communicator> comm, int blockNx1, int blockNx2, int blockNx3 nx2(gridNx2), nx3(gridNx3) { - levelSet.resize(Grid3DSystem::MAXLEVEL + 1); - bundle = comm->getBundleID(); + levelSet.resize(Grid3DSystem::MAXLEVEL+1); rank = comm->getProcessID(); trafo = SPtr<CoordinateTransformation3D>(new CoordinateTransformation3D(0.0, 0.0, 0.0, (double)blockNx1, (double)blockNx2, (double)blockNx3)); UbTupleInt3 minInd(0, 0, 0); @@ -96,42 +127,42 @@ Grid3D::Interactor3DSet Grid3D::getInteractors() ////////////////////////////////////////////////////////////////////////// void Grid3D::accept(Block3DVisitor& blockVisitor) { - int startLevel = blockVisitor.getStartLevel(); - int stopLevel = blockVisitor.getStopLevel(); + int startLevel = blockVisitor.getStartLevel(); + int stopLevel = blockVisitor.getStopLevel(); if (startLevel < 0 || stopLevel < 0 || startLevel > Grid3DSystem::MAXLEVEL || stopLevel > Grid3DSystem::MAXLEVEL) throw UbException(UB_EXARGS, "not valid level!"); - bool dir = startLevel < stopLevel; + bool dir = startLevel < stopLevel; if (dir) stopLevel += 1; - else stopLevel -= 1; - - //#pragma omp parallel - // { - // for (int l = startLevel; l!=stopLevel;) - // { - // std::vector<SPtr<Block3D>> blockVector; - // getBlocks(l, blockVector); - // int sizeb = (int)blockVector.size(); - // - //#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;) + else stopLevel -= 1; + +//#pragma omp parallel +// { +// for (int l = startLevel; l!=stopLevel;) +// { +// std::vector<SPtr<Block3D>> blockVector; +// getBlocks(l, blockVector); +// int sizeb = (int)blockVector.size(); +// +//#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<SPtr<Block3D>> blockVector; getBlocks(l, blockVector); - for (SPtr<Block3D> b : blockVector) + for(SPtr<Block3D> b : blockVector) { - blockVisitor.visit(shared_from_this(), b); + blockVisitor.visit( shared_from_this(), b ); } - if (dir) l++; + if(dir) l++; else l--; } } @@ -174,18 +205,6 @@ bool Grid3D::deleteBlock(int ix1, int ix2, int ix3, int level) return false; } } -void Grid3D::deleteBlocks() -{ - std::vector < std::vector<SPtr<Block3D> > > blocksVector(25); - int minInitLevel = Grid3DSystem::MINLEVEL; - int maxInitLevel = Grid3DSystem::MAXLEVEL; - for (int level = minInitLevel; level < maxInitLevel; level++) - { - getBlocks(level, blocksVector[level]); - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - deleteBlock(block); - } -} ////////////////////////////////////////////////////////////////////////// void Grid3D::replaceBlock(SPtr<Block3D> block) { @@ -200,16 +219,16 @@ SPtr<Block3D> Grid3D::getBlock(int ix1, int ix2, int ix3, int level) const { if (!this->hasLevel(level)) return SPtr<Block3D>(); - int N1 = (nx1 << level); - int N2 = (nx2 << level); - int N3 = (nx3 << level); + int N1 = (nx1<<level); + int N2 = (nx2<<level); + int N3 = (nx3<<level); - if (!this->isPeriodicX1() && (ix1 > N1 - 1 || ix1 < 0)) return SPtr<Block3D>(); - else if (this->isPeriodicX1() && (ix1 >= N1 - 1 || ix1 < 0)) { ix1 = ((ix1 % N1) + N1) % N1; } - if (!this->isPeriodicX2() && (ix2 > N2 - 1 || ix2 < 0)) return SPtr<Block3D>(); - else if (this->isPeriodicX2() && (ix2 >= N2 - 1 || ix2 < 0)) { ix2 = ((ix2 % N2) + N2) % N2; } - if (!this->isPeriodicX3() && (ix3 > N3 - 1 || ix3 < 0)) return SPtr<Block3D>(); - else if (this->isPeriodicX3() && (ix3 >= N3 - 1 || ix3 < 0)) { ix3 = ((ix3 % N3) + N3) % N3; } + if (!this->isPeriodicX1() && (ix1>N1-1 || ix1<0)) return SPtr<Block3D>(); + else if (this->isPeriodicX1() && (ix1>=N1-1 || ix1<0)) { ix1=((ix1%N1)+N1)%N1; } + if (!this->isPeriodicX2() && (ix2>N2-1 || ix2<0)) return SPtr<Block3D>(); + else if (this->isPeriodicX2() && (ix2>=N2-1 || ix2<0)) { ix2=((ix2%N2)+N2)%N2; } + if (!this->isPeriodicX3() && (ix3>N3-1 || ix3<0)) return SPtr<Block3D>(); + else if (this->isPeriodicX3() && (ix3>=N3-1 || ix3<0)) { ix3=((ix3%N3)+N3)%N3; } Block3DMap::const_iterator it; it = levelSet[level].find(Block3DKey(ix1, ix2, ix3)); @@ -222,7 +241,7 @@ SPtr<Block3D> Grid3D::getBlock(int ix1, int ix2, int ix3, int level) const SPtr<Block3D> Grid3D::getBlock(int id) const { BlockIDMap::const_iterator it; - if ((it = blockIdMap.find(id)) == blockIdMap.end()) + if ((it=blockIdMap.find(id)) == blockIdMap.end()) { return SPtr<Block3D>(); } @@ -230,11 +249,6 @@ SPtr<Block3D> Grid3D::getBlock(int id) const return it->second; } ////////////////////////////////////////////////////////////////////////// -//const Grid3D::Block3DMap& Grid3D::getBlocks(int level) -//{ -// return levelSet[level]; -//} -////////////////////////////////////////////////////////////////////////// Grid3D::BlockIDMap& Grid3D::getBlockIDs() { return blockIdMap; @@ -252,11 +266,11 @@ SPtr<Block3D> Grid3D::getSuperBlock(SPtr<Block3D> block) SPtr<Block3D> Grid3D::getSuperBlock(int ix1, int ix2, int ix3, int level) { if (!this->hasLevel(level)) return SPtr<Block3D>(); - if (level < 1) throw UbException(UB_EXARGS, "level <1"); + if (level < 1) throw UbException(UB_EXARGS, "level <1"); //from Lower Level to higher: >> 1 in x1,x2,x3 SPtr<Block3D> block; - for (int l = level - 1; l >= 0; l--) + for (int l=level-1; l>=0; l--) { ix1 = ix1 >> 1; ix2 = ix2 >> 1; @@ -281,16 +295,16 @@ void Grid3D::getSubBlocks(int ix1, int ix2, int ix3, int level, int levelDepth, { if (!this->getBlock(ix1, ix2, ix3, level)) return; if (level > 0 && !this->getSuperBlock(ix1, ix2, ix3, level)) return; - if (level >= Grid3DSystem::MAXLEVEL) throw UbException(UB_EXARGS, "Level bigger then MAXLEVEL"); + if (level >= Grid3DSystem::MAXLEVEL) throw UbException(UB_EXARGS, "Level bigger then MAXLEVEL"); - int x1[] = { ix1 << 1, (ix1 << 1) + 1 }; - int x2[] = { ix2 << 1, (ix2 << 1) + 1 }; - int x3[] = { ix3 << 1, (ix3 << 1) + 1 }; - int l = level + 1; + int x1[] ={ ix1<<1, (ix1<<1)+1 }; + int x2[] ={ ix2<<1, (ix2<<1)+1 }; + int x3[] ={ ix3<<1, (ix3<<1)+1 }; + int l = level + 1; - for (int i = 0; i < 2; i++) - for (int j = 0; j < 2; j++) - for (int k = 0; k < 2; k++) + for (int i=0; i<2; i++) + for (int j=0; j<2; j++) + for (int k=0; k<2; k++) { SPtr<Block3D> block = this->getBlock(x1[i], x2[j], x3[k], l); if (block) blocks.push_back(block); @@ -303,23 +317,22 @@ bool Grid3D::expandBlock(int ix1, int ix2, int ix3, int level) this->checkLevel(level); SPtr<Block3D> block = this->getBlock(ix1, ix2, ix3, level); - if (!block) throw UbException(UB_EXARGS, "block(x1=" + UbSystem::toString(ix1) + ", x2=" + UbSystem::toString(ix2) + ", x3=" + UbSystem::toString(ix3) + ", l=" + UbSystem::toString(level) + ") is not exist"); - //if(!block->isActive()) throw UbException(UB_EXARGS,"block(x1="+UbSystem::toString(ix1)+", x2="+UbSystem::toString(ix2)+", x3="+UbSystem::toString(ix3)+", l="+UbSystem::toString(level)+") is not active"); + if (!block) throw UbException(UB_EXARGS, "block(x1="+UbSystem::toString(ix1)+", x2="+UbSystem::toString(ix2)+", x3="+UbSystem::toString(ix3)+", l="+UbSystem::toString(level)+") is not exist"); //da bei periodic der eigentliche block andere indizes hat: ix1 = block->getX1(); ix2 = block->getX2(); ix3 = block->getX3(); - int l = level + 1; - if (l > Grid3DSystem::MAXLEVEL) throw UbException(UB_EXARGS, "level > Grid3D::MAXLEVEL"); + int l = level+1; + if (l>Grid3DSystem::MAXLEVEL) throw UbException(UB_EXARGS, "level > Grid3D::MAXLEVEL"); - int west = ix1 << 1; - int east = west + 1; - int south = ix2 << 1; - int north = south + 1; - int bottom = ix3 << 1; - int top = bottom + 1; + int west = ix1<<1; + int east = west+1; + int south = ix2<<1; + int north = south+1; + int bottom = ix3<<1; + int top = bottom+1; SPtr<Block3D> blockBSW = SPtr<Block3D>(new Block3D(west, south, bottom, l)); SPtr<Block3D> blockBSE = SPtr<Block3D>(new Block3D(east, south, bottom, l)); @@ -350,12 +363,12 @@ SPtr<Block3D> Grid3D::collapseBlock(int fix1, int fix2, int fix3, int flevel, in using UbSystem::toString; SPtr<Block3D> 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 (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"); + 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"); + 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: fix1 = fblock->getX1(); @@ -366,15 +379,15 @@ SPtr<Block3D> Grid3D::collapseBlock(int fix1, int fix2, int fix3, int flevel, in int cix2 = fblock->getX2() >> 1; int cix3 = fblock->getX3() >> 1; - int fx1[2] = { cix1 << 1, (cix1 << 1) + 1 }; - int fx2[2] = { cix2 << 1, (cix2 << 1) + 1 }; - int fx3[2] = { cix3 << 1, (cix3 << 1) + 1 }; + int fx1[2] ={ cix1<<1, (cix1<<1)+1 }; + int fx2[2] ={ cix2<<1, (cix2<<1)+1 }; + int fx3[2] ={ cix3<<1, (cix3<<1)+1 }; int clevel = flevel - 1; vector<SPtr<Block3D>> blocks; - for (int i = 0; i < 2; i++) - for (int k = 0; k < 2; k++) - for (int l = 0; l < 2; l++) + for (int i=0; i<2; i++) + for (int k=0; k<2; k++) + for (int l=0; l<2; l++) { this->getSubBlocks(fx1[k], fx2[i], fx3[l], flevel, levelDepth, blocks); while (!blocks.empty()) @@ -398,9 +411,9 @@ SPtr<Block3D> Grid3D::collapseBlock(int fix1, int fix2, int fix3, int flevel, in SPtr<Block3D> cblock = SPtr<Block3D>(new Block3D(cix1, cix2, cix3, clevel)); - for (int i = 0; i < 2; i++) - for (int k = 0; k < 2; k++) - for (int l = 0; l < 2; l++) + for (int i=0; i<2; i++) + for (int k=0; k<2; k++) + for (int l=0; l<2; l++) if (!this->deleteBlock(fx1[k], fx2[i], fx3[l], flevel)) throw UbException(UB_EXARGS, "could not delete block"); @@ -416,9 +429,8 @@ void Grid3D::deleteConnectors() { for (Block3DMap::value_type b : blockMap) { - SPtr<Block3D> block = b.second; + SPtr<Block3D> block = b.second; block->deleteConnectors(); - //block->deleteInterpolationConnectors(); } } } @@ -495,9 +507,9 @@ UbTupleInt3 Grid3D::getBlockIndexes(double blockX1Coord, double blockX2Coord, do double dx = getDeltaX(level); double blockLentghX1, blockLentghX2, blockLentghX3; - blockLentghX1 = blockNx1 * dx; - blockLentghX2 = blockNx2 * dx; - blockLentghX3 = blockNx3 * dx; + blockLentghX1 = blockNx1*dx; + blockLentghX2 = blockNx2*dx; + blockLentghX3 = blockNx3*dx; UbTupleDouble3 org = getBlockWorldCoordinates(0, 0, 0, 0); SPtr<CoordinateTransformation3D> trafo_temp(new CoordinateTransformation3D(val<1>(org), val<2>(org), val<3>(org), blockLentghX1, blockLentghX2, blockLentghX3)); @@ -516,13 +528,13 @@ UbTupleInt3 Grid3D::getBlockIndexes(double blockX1Coord, double blockX2Coord, do UbTupleDouble3 Grid3D::getBlockLengths(const SPtr<Block3D> block) const { int level = block->getLevel(); - double delta = 1.0 / (double)(1 << level); + double delta = 1.0/(double)(1<<level); if (!trafo) makeUbTuple<double, double, double>(delta, delta, delta); - return makeUbTuple(trafo->getX1CoordinateScaling() * delta, - trafo->getX2CoordinateScaling() * delta, - trafo->getX3CoordinateScaling() * delta); + return makeUbTuple(trafo->getX1CoordinateScaling()*delta, + trafo->getX2CoordinateScaling()*delta, + trafo->getX3CoordinateScaling()*delta); } ////////////////////////////////////////////////////////////////////////// UbTupleDouble6 Grid3D::getBlockOversize() const @@ -547,12 +559,12 @@ void Grid3D::setDeltaX(double dx) ////////////////////////////////////////////////////////////////////////// void Grid3D::setDeltaX(double worldUnit, double gridUnit) { - this->orgDeltaX = worldUnit / gridUnit; + this->orgDeltaX = worldUnit/gridUnit; } ////////////////////////////////////////////////////////////////////////// double Grid3D::getDeltaX(int level) const { - double delta = this->orgDeltaX / (double)(1 << level); + double delta = this->orgDeltaX/(double)(1<<level); return delta; } ////////////////////////////////////////////////////////////////////////// @@ -573,9 +585,9 @@ Vector3D Grid3D::getNodeCoordinates(SPtr<Block3D> block, int ix1, int ix2, int i UbTupleDouble3 nodeOffset = this->getNodeOffset(block); double deltaX = getDeltaX(block); - double x1 = val<1>(org) - val<1>(nodeOffset) + (double)ix1 * deltaX; - double x2 = val<2>(org) - val<2>(nodeOffset) + (double)ix2 * deltaX; - double x3 = val<3>(org) - val<3>(nodeOffset) + (double)ix3 * deltaX; + double x1 = val<1>(org) - val<1>(nodeOffset) + (double)ix1*deltaX; + double x2 = val<2>(org) - val<2>(nodeOffset) + (double)ix2*deltaX; + double x3 = val<3>(org) - val<3>(nodeOffset) + (double)ix3*deltaX; return Vector3D(x1, x2, x3); } @@ -587,12 +599,12 @@ UbTupleInt3 Grid3D::getNodeIndexes(SPtr<Block3D> block, double nodeX1Coord, doub double deltaX = getDeltaX(block); int ix1, ix2, ix3; - double ixx1 = (abs(nodeX1Coord - val<1>(org) + val<1>(nodeOffset)) / deltaX); - double ixx2 = (abs(nodeX2Coord - val<2>(org) + val<2>(nodeOffset)) / deltaX); - double ixx3 = (abs(nodeX3Coord - val<3>(org) + val<3>(nodeOffset)) / deltaX); - if (ixx1 - (int)ixx1 > .9999999999) ix1 = (int)ixx1 + 1; else ix1 = (int)ixx1; - if (ixx2 - (int)ixx2 > .9999999999) ix2 = (int)ixx2 + 1; else ix2 = (int)ixx2; - if (ixx3 - (int)ixx3 > .9999999999) ix3 = (int)ixx3 + 1; else ix3 = (int)ixx3; + double ixx1=(abs(nodeX1Coord - val<1>(org) + val<1>(nodeOffset)) / deltaX); + double ixx2=(abs(nodeX2Coord - val<2>(org) + val<2>(nodeOffset)) / deltaX); + double ixx3=(abs(nodeX3Coord - val<3>(org) + val<3>(nodeOffset)) / deltaX); + if (ixx1-(int)ixx1>.9999999999) ix1=(int)ixx1+1; else ix1=(int)ixx1; + if (ixx2-(int)ixx2>.9999999999) ix2=(int)ixx2+1; else ix2=(int)ixx2; + if (ixx3-(int)ixx3>.9999999999) ix3=(int)ixx3+1; else ix3=(int)ixx3; return makeUbTuple(ix1, ix2, ix3); } @@ -613,10 +625,10 @@ UbTupleDouble3 Grid3D::getBlockWorldCoordinates(SPtr<Block3D> block) const ////////////////////////////////////////////////////////////////////////// UbTupleDouble3 Grid3D::getBlockWorldCoordinates(int blockX1Index, int blockX2Index, int blockX3Index, int level) const { - double c1oShiftedLevel = 1.0 / (double)(1 << level); - double x1 = (double)blockX1Index * c1oShiftedLevel; - double x2 = (double)blockX2Index * c1oShiftedLevel; - double x3 = (double)blockX3Index * c1oShiftedLevel; + double c1oShiftedLevel = 1.0/(double)(1<<level); + double x1 = (double)blockX1Index*c1oShiftedLevel; + double x2 = (double)blockX2Index*c1oShiftedLevel; + double x3 = (double)blockX3Index*c1oShiftedLevel; if (!trafo) return UbTupleDouble3(x1, x2, x3); @@ -636,15 +648,15 @@ void Grid3D::checkLevel(int level) { if (level < 0) { - throw UbException(UB_EXARGS, "l(" + UbSystem::toString(level) + (string)")<0"); + throw UbException(UB_EXARGS, "l("+UbSystem::toString(level)+(string)")<0"); } if (level > Grid3DSystem::MAXLEVEL) { - throw UbException(UB_EXARGS, "l(" + UbSystem::toString(level) + (string)")>MAXLEVEL"); + throw UbException(UB_EXARGS, "l("+UbSystem::toString(level)+(string)")>MAXLEVEL"); } if (this->levelSet[level].size() == 0) { - throw UbException(UB_EXARGS, "levelMap for level(" + UbSystem::toString(level) + (string)")==NULL"); + throw UbException(UB_EXARGS, "levelMap for level("+UbSystem::toString(level)+(string)")==NULL"); } } ////////////////////////////////////////////////////////////////////////// @@ -672,7 +684,7 @@ UbTupleInt3 Grid3D::getBlockNX() const SPtr<Block3D> Grid3D::getNeighborBlock(int dir, int ix1, int ix2, int ix3, int level) const { - return this->getBlock(ix1 + Grid3DSystem::EX1[dir], ix2 + Grid3DSystem::EX2[dir], ix3 + Grid3DSystem::EX3[dir], level); + return this->getBlock(ix1+Grid3DSystem::EX1[dir], ix2+Grid3DSystem::EX2[dir], ix3+Grid3DSystem::EX3[dir], level); } ////////////////////////////////////////////////////////////////////////// SPtr<Block3D> Grid3D::getNeighborBlock(int dir, SPtr<Block3D> block) const @@ -686,7 +698,7 @@ SPtr<Block3D> Grid3D::getNeighborBlock(int dir, SPtr<Block3D> block) const ////////////////////////////////////////////////////////////////////////// void Grid3D::getAllNeighbors(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - for (int dir = Grid3DSystem::STARTDIR; dir <= Grid3DSystem::ENDDIR; dir++) + for (int dir=Grid3DSystem::STARTDIR; dir<=Grid3DSystem::ENDDIR; dir++) //for (int dir = Grid3DSystem::STARTDIR; dir<=Grid3DSystem::TS; dir++) { this->getNeighborBlocksForDirection(dir, ix1, ix2, ix3, level, levelDepth, blocks); @@ -710,349 +722,349 @@ void Grid3D::getAllNeighbors(SPtr<Block3D> block, int level, int levelDepth, std */ void Grid3D::getNeighborsNorth(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1, ix2 + 1, ix3, level); + SPtr<Block3D> block = this->getBlock(ix1, ix2+1, ix3, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1, ix2 + 1, ix3, level); + block = this->getSuperBlock(ix1, ix2+1, ix3, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksSouth(ix1, ix2 + 1, ix3, level, blocks, levelDepth); + this->getSubBlocksSouth(ix1, ix2+1, ix3, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsTop(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1, ix2, ix3 + 1, level); + SPtr<Block3D> block = this->getBlock(ix1, ix2, ix3+1, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1, ix2, ix3 + 1, level); + block = this->getSuperBlock(ix1, ix2, ix3+1, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksBottom(ix1, ix2, ix3 + 1, level, blocks, levelDepth); + this->getSubBlocksBottom(ix1, ix2, ix3+1, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsBottom(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1, ix2, ix3 - 1, level); + SPtr<Block3D> block = this->getBlock(ix1, ix2, ix3-1, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1, ix2, ix3 - 1, level); + block = this->getSuperBlock(ix1, ix2, ix3-1, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksTop(ix1, ix2, ix3 - 1, level, blocks, levelDepth); + this->getSubBlocksTop(ix1, ix2, ix3-1, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsSouth(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1, ix2 - 1, ix3, level); + SPtr<Block3D> block = this->getBlock(ix1, ix2-1, ix3, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1, ix2 - 1, ix3, level); + block = this->getSuperBlock(ix1, ix2-1, ix3, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksNorth(ix1, ix2 - 1, ix3, level, blocks, levelDepth); + this->getSubBlocksNorth(ix1, ix2-1, ix3, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsEast(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1 + 1, ix2, ix3, level); + SPtr<Block3D> block = this->getBlock(ix1+1, ix2, ix3, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1 + 1, ix2, ix3, level); + block = this->getSuperBlock(ix1+1, ix2, ix3, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksWest(ix1 + 1, ix2, ix3, level, blocks, levelDepth); + this->getSubBlocksWest(ix1+1, ix2, ix3, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsWest(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1 - 1, ix2, ix3, level); + SPtr<Block3D> block = this->getBlock(ix1-1, ix2, ix3, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1 - 1, ix2, ix3, level); + block = this->getSuperBlock(ix1-1, ix2, ix3, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksEast(ix1 - 1, ix2, ix3, level, blocks, levelDepth); + this->getSubBlocksEast(ix1-1, ix2, ix3, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// // diagonals ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsNorthEast(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1 + 1, ix2 + 1, ix3, level); + SPtr<Block3D> block = this->getBlock(ix1+1, ix2+1, ix3, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1 + 1, ix2 + 1, ix3, level); + block = this->getSuperBlock(ix1+1, ix2+1, ix3, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksSouthWest(ix1 + 1, ix2 + 1, ix3, level, blocks, levelDepth); + this->getSubBlocksSouthWest(ix1+1, ix2+1, ix3, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsNorthWest(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1 - 1, ix2 + 1, ix3, level); + SPtr<Block3D> block = this->getBlock(ix1-1, ix2+1, ix3, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1 - 1, ix2 + 1, ix3, level); + block = this->getSuperBlock(ix1-1, ix2+1, ix3, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksSouthEast(ix1 - 1, ix2 + 1, ix3, level, blocks, levelDepth); + this->getSubBlocksSouthEast(ix1-1, ix2+1, ix3, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsSouthEast(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1 + 1, ix2 - 1, ix3, level); + SPtr<Block3D> block = this->getBlock(ix1+1, ix2-1, ix3, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1 + 1, ix2 - 1, ix3, level); + block = this->getSuperBlock(ix1+1, ix2-1, ix3, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksNorthWest(ix1 + 1, ix2 - 1, ix3, level, blocks, levelDepth); + this->getSubBlocksNorthWest(ix1+1, ix2-1, ix3, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsSouthWest(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1 - 1, ix2 - 1, ix3, level); + SPtr<Block3D> block = this->getBlock(ix1-1, ix2-1, ix3, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1 - 1, ix2 - 1, ix3, level); + block = this->getSuperBlock(ix1-1, ix2-1, ix3, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksNorthEast(ix1 - 1, ix2 - 1, ix3, level, blocks, levelDepth); + this->getSubBlocksNorthEast(ix1-1, ix2-1, ix3, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// // diagonals top ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsTopEast(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1 + 1, ix2, ix3 + 1, level); + SPtr<Block3D> block = this->getBlock(ix1+1, ix2, ix3+1, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1 + 1, ix2, ix3 + 1, level); + block = this->getSuperBlock(ix1+1, ix2, ix3+1, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksBottomWest(ix1 + 1, ix2, ix3 + 1, level, blocks, levelDepth); + this->getSubBlocksBottomWest(ix1+1, ix2, ix3+1, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsTopWest(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1 - 1, ix2, ix3 + 1, level); + SPtr<Block3D> block = this->getBlock(ix1-1, ix2, ix3+1, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1 - 1, ix2, ix3 + 1, level); + block = this->getSuperBlock(ix1-1, ix2, ix3+1, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksBottomEast(ix1 - 1, ix2, ix3 + 1, level, blocks, levelDepth); + this->getSubBlocksBottomEast(ix1-1, ix2, ix3+1, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsTopNorth(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1, ix2 + 1, ix3 + 1, level); + SPtr<Block3D> block = this->getBlock(ix1, ix2+1, ix3+1, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1, ix2 + 1, ix3 + 1, level); + block = this->getSuperBlock(ix1, ix2+1, ix3+1, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksBottomSouth(ix1, ix2 + 1, ix3 + 1, level, blocks, levelDepth); + this->getSubBlocksBottomSouth(ix1, ix2+1, ix3+1, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsTopSouth(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1, ix2 - 1, ix3 + 1, level); + SPtr<Block3D> block = this->getBlock(ix1, ix2-1, ix3+1, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1, ix2 - 1, ix3 + 1, level); + block = this->getSuperBlock(ix1, ix2-1, ix3+1, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksBottomNorth(ix1, ix2 - 1, ix3 + 1, level, blocks, levelDepth); + this->getSubBlocksBottomNorth(ix1, ix2-1, ix3+1, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// // diagonals bottom ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsBottomEast(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1 + 1, ix2, ix3 - 1, level); + SPtr<Block3D> block = this->getBlock(ix1+1, ix2, ix3-1, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1 + 1, ix2, ix3 - 1, level); + block = this->getSuperBlock(ix1+1, ix2, ix3-1, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksTopWest(ix1 + 1, ix2, ix3 - 1, level, blocks, levelDepth); + this->getSubBlocksTopWest(ix1+1, ix2, ix3-1, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsBottomWest(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1 - 1, ix2, ix3 - 1, level); + SPtr<Block3D> block = this->getBlock(ix1-1, ix2, ix3-1, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1 - 1, ix2, ix3 - 1, level); + block = this->getSuperBlock(ix1-1, ix2, ix3-1, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksTopEast(ix1 - 1, ix2, ix3 - 1, level, blocks, levelDepth); + this->getSubBlocksTopEast(ix1-1, ix2, ix3-1, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsBottomNorth(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1, ix2 + 1, ix3 - 1, level); + SPtr<Block3D> block = this->getBlock(ix1, ix2+1, ix3-1, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1, ix2 + 1, ix3 - 1, level); + block = this->getSuperBlock(ix1, ix2+1, ix3-1, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksTopSouth(ix1, ix2 + 1, ix3 - 1, level, blocks, levelDepth); + this->getSubBlocksTopSouth(ix1, ix2+1, ix3-1, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsBottomSouth(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1, ix2 - 1, ix3 - 1, level); + SPtr<Block3D> block = this->getBlock(ix1, ix2-1, ix3-1, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1, ix2 - 1, ix3 - 1, level); + block = this->getSuperBlock(ix1, ix2-1, ix3-1, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksTopNorth(ix1, ix2 - 1, ix3 - 1, level, blocks, levelDepth); + this->getSubBlocksTopNorth(ix1, ix2-1, ix3-1, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsTopNorthEast(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1 + 1, ix2 + 1, ix3 + 1, level); + SPtr<Block3D> block = this->getBlock(ix1+1, ix2+1, ix3+1, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1 + 1, ix2 + 1, ix3 + 1, level); + block = this->getSuperBlock(ix1+1, ix2+1, ix3+1, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksBottomSouthWest(ix1 + 1, ix2 + 1, ix3 + 1, level, blocks, levelDepth); + this->getSubBlocksBottomSouthWest(ix1+1, ix2+1, ix3+1, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsTopNorthWest(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1 - 1, ix2 + 1, ix3 + 1, level); + SPtr<Block3D> block = this->getBlock(ix1-1, ix2+1, ix3+1, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1 - 1, ix2 + 1, ix3 + 1, level); + block = this->getSuperBlock(ix1-1, ix2+1, ix3+1, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksBottomSouthEast(ix1 - 1, ix2 + 1, ix3 + 1, level, blocks, levelDepth); + this->getSubBlocksBottomSouthEast(ix1-1, ix2+1, ix3+1, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsTopSouthEast(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1 + 1, ix2 - 1, ix3 + 1, level); + SPtr<Block3D> block = this->getBlock(ix1+1, ix2-1, ix3+1, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1 + 1, ix2 - 1, ix3 + 1, level); + block = this->getSuperBlock(ix1+1, ix2-1, ix3+1, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksBottomNorthWest(ix1 + 1, ix2 - 1, ix3 + 1, level, blocks, levelDepth); + this->getSubBlocksBottomNorthWest(ix1+1, ix2-1, ix3+1, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsTopSouthWest(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1 - 1, ix2 - 1, ix3 + 1, level); + SPtr<Block3D> block = this->getBlock(ix1-1, ix2-1, ix3+1, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1 - 1, ix2 - 1, ix3 + 1, level); + block = this->getSuperBlock(ix1-1, ix2-1, ix3+1, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksBottomNorthEast(ix1 - 1, ix2 - 1, ix3 + 1, level, blocks, levelDepth); + this->getSubBlocksBottomNorthEast(ix1-1, ix2-1, ix3+1, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsBottomNorthEast(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1 + 1, ix2 + 1, ix3 - 1, level); + SPtr<Block3D> block = this->getBlock(ix1+1, ix2+1, ix3-1, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1 + 1, ix2 + 1, ix3 - 1, level); + block = this->getSuperBlock(ix1+1, ix2+1, ix3-1, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksTopSouthWest(ix1 + 1, ix2 + 1, ix3 - 1, level, blocks, levelDepth); + this->getSubBlocksTopSouthWest(ix1+1, ix2+1, ix3-1, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsBottomNorthWest(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1 - 1, ix2 + 1, ix3 - 1, level); + SPtr<Block3D> block = this->getBlock(ix1-1, ix2+1, ix3-1, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1 - 1, ix2 + 1, ix3 - 1, level); + block = this->getSuperBlock(ix1-1, ix2+1, ix3-1, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksTopSouthEast(ix1 - 1, ix2 + 1, ix3 - 1, level, blocks, levelDepth); + this->getSubBlocksTopSouthEast(ix1-1, ix2+1, ix3-1, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsBottomSouthEast(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1 + 1, ix2 - 1, ix3 - 1, level); + SPtr<Block3D> block = this->getBlock(ix1+1, ix2-1, ix3-1, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1 + 1, ix2 - 1, ix3 - 1, level); + block = this->getSuperBlock(ix1+1, ix2-1, ix3-1, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksTopNorthWest(ix1 + 1, ix2 - 1, ix3 - 1, level, blocks, levelDepth); + this->getSubBlocksTopNorthWest(ix1+1, ix2-1, ix3-1, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborsBottomSouthWest(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) { - SPtr<Block3D> block = this->getBlock(ix1 - 1, ix2 - 1, ix3 - 1, level); + SPtr<Block3D> block = this->getBlock(ix1-1, ix2-1, ix3-1, level); if (block) { blocks.push_back(block); } if (level > 0) { - block = this->getSuperBlock(ix1 - 1, ix2 - 1, ix3 - 1, level); + block = this->getSuperBlock(ix1-1, ix2-1, ix3-1, level); if (block) { blocks.push_back(block); } } - this->getSubBlocksTopNorthEast(ix1 - 1, ix2 - 1, ix3 - 1, level, blocks, levelDepth); + this->getSubBlocksTopNorthEast(ix1-1, ix2-1, ix3-1, level, blocks, levelDepth); } ////////////////////////////////////////////////////////////////////////// void Grid3D::getNeighborBlocksForDirection(int dir, int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>>& blocks) @@ -1085,7 +1097,7 @@ void Grid3D::getNeighborBlocksForDirection(int dir, int ix1, int ix2, int ix3, i case Grid3DSystem::BNW: this->getNeighborsBottomNorthWest(ix1, ix2, ix3, level, levelDepth, blocks); break; case Grid3DSystem::BSE: this->getNeighborsBottomSouthEast(ix1, ix2, ix3, level, levelDepth, blocks); break; case Grid3DSystem::BSW: this->getNeighborsBottomSouthWest(ix1, ix2, ix3, level, levelDepth, blocks); break; - default:throw UbException(UB_EXARGS, "direction " + UbSystem::toString(dir) + " is not exist"); + default:throw UbException(UB_EXARGS, "direction "+UbSystem::toString(dir)+" is not exist"); } } ////////////////////////////////////////////////////////////////////////// @@ -1103,15 +1115,15 @@ void Grid3D::getNeighborsZero(int ix1, int ix2, int ix3, int level, int levelDep this->getSubBlocks(ix1, ix2, ix3, level, levelDepth, blocks); } ////////////////////////////////////////////////////////////////////////// -void Grid3D::getSubBlocksZero(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>>& blockVector, int levelDepth) +void Grid3D::getSubBlocksZero(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector, int levelDepth) { - int x1E = (ix1 << 1) + 1; - int x1W = (ix1 << 1); + int x1E = (ix1 << 1) + 1; + int x1W = (ix1 << 1); int x2S = ix2 << 1; int x2N = x2S + 1; int x3B = ix3 << 1; int x3T = x3B + 1; - int l = level + 1; + int l = level + 1; SPtr<Block3D> block = this->getBlock(x1E, x2S, x3B, l); if (block != NULL) blockVector.push_back(block); @@ -1176,19 +1188,19 @@ void Grid3D::getNeighborBlocksForDirectionWithDirZero(int dir, int ix1, int ix2, case Grid3DSystem::BNW: this->getNeighborsBottomNorthWest(ix1, ix2, ix3, level, levelDepth, blocks); break; case Grid3DSystem::BSE: this->getNeighborsBottomSouthEast(ix1, ix2, ix3, level, levelDepth, blocks); break; case Grid3DSystem::BSW: this->getNeighborsBottomSouthWest(ix1, ix2, ix3, level, levelDepth, blocks); break; - case Grid3DSystem::ZERO: this->getNeighborsZero(ix1, ix2, ix3, level, levelDepth, blocks); break; - default:throw UbException(UB_EXARGS, "direction " + UbSystem::toString(dir) + " is not exist"); + case Grid3DSystem::REST: this->getNeighborsZero(ix1, ix2, ix3, level, levelDepth, blocks); break; + default:throw UbException(UB_EXARGS, "direction "+UbSystem::toString(dir)+" is not exist"); } } ////////////////////////////////////////////////////////////////////////// -void Grid3D::getSubBlocksEast(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>>& blockVector, int levelDepth) +void Grid3D::getSubBlocksEast(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector, int levelDepth) { - int x1 = (ix1 << 1) + 1; + int x1 = (ix1 << 1) + 1; int x2S = ix2 << 1; int x2N = x2S + 1; int x3B = ix3 << 1; int x3T = x3B + 1; - int l = level + 1; + int l = level + 1; SPtr<Block3D> block = this->getBlock(x1, x2S, x3B, l); if (block != NULL) blockVector.push_back(block); @@ -1208,14 +1220,14 @@ void Grid3D::getSubBlocksEast(int ix1, int ix2, int ix3, int level, vector<SPtr< } ////////////////////////////////////////////////////////////////////////// -void Grid3D::getSubBlocksWest(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>>& blockVector, int levelDepth) +void Grid3D::getSubBlocksWest(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector, int levelDepth) { - int x1 = ix1 << 1; + int x1 = ix1 << 1; int x2S = ix2 << 1; int x2N = x2S + 1; int x3B = ix3 << 1; int x3T = x3B + 1; - int l = level + 1; + int l = level + 1; SPtr<Block3D> block = this->getBlock(x1, x2S, x3B, l); if (block != NULL) blockVector.push_back(block); @@ -1234,14 +1246,14 @@ void Grid3D::getSubBlocksWest(int ix1, int ix2, int ix3, int level, vector<SPtr< else if (l < levelDepth) this->getSubBlocksWest(x1, x2N, x3T, l, blockVector, levelDepth); } ////////////////////////////////////////////////////////////////////////// -void Grid3D::getSubBlocksNorth(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>>& blockVector, int levelDepth) +void Grid3D::getSubBlocksNorth(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector, int levelDepth) { int x1W = ix1 << 1; int x1E = x1W + 1; - int x2 = (ix2 << 1) + 1; + int x2 = (ix2 << 1) + 1; int x3B = ix3 << 1; int x3T = x3B + 1; - int l = level + 1; + int l = level + 1; SPtr<Block3D> block = this->getBlock(x1W, x2, x3B, l); if (block != NULL) blockVector.push_back(block); @@ -1260,14 +1272,14 @@ void Grid3D::getSubBlocksNorth(int ix1, int ix2, int ix3, int level, vector<SPtr else if (l < levelDepth) this->getSubBlocksNorth(x1E, x2, x3T, l, blockVector, levelDepth); } ////////////////////////////////////////////////////////////////////////// -void Grid3D::getSubBlocksSouth(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>>& blockVector, int levelDepth) +void Grid3D::getSubBlocksSouth(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector, int levelDepth) { int x1W = ix1 << 1; int x1E = x1W + 1; - int x2 = ix2 << 1; + int x2 = ix2 << 1; int x3B = ix3 << 1; int x3T = x3B + 1; - int l = level + 1; + int l = level + 1; SPtr<Block3D> block = this->getBlock(x1W, x2, x3B, l); if (block != NULL) blockVector.push_back(block); @@ -1286,14 +1298,14 @@ void Grid3D::getSubBlocksSouth(int ix1, int ix2, int ix3, int level, vector<SPtr else if (l < levelDepth) this->getSubBlocksSouth(x1E, x2, x3T, l, blockVector, levelDepth); } ////////////////////////////////////////////////////////////////////////// -void Grid3D::getSubBlocksTop(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>>& blockVector, int levelDepth) +void Grid3D::getSubBlocksTop(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector, int levelDepth) { int x1W = ix1 << 1; int x1E = x1W + 1; int x2S = ix2 << 1; int x2N = x2S + 1; - int x3 = (ix3 << 1) + 1; - int l = level + 1; + int x3 = (ix3 << 1) + 1; + int l = level + 1; SPtr<Block3D> block = this->getBlock(x1W, x2N, x3, l); if (block != NULL) blockVector.push_back(block); @@ -1312,14 +1324,14 @@ void Grid3D::getSubBlocksTop(int ix1, int ix2, int ix3, int level, vector<SPtr<B else if (l < levelDepth) this->getSubBlocksTop(x1E, x2S, x3, l, blockVector, levelDepth); } ////////////////////////////////////////////////////////////////////////// -void Grid3D::getSubBlocksBottom(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>>& blockVector, int levelDepth) +void Grid3D::getSubBlocksBottom(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector, int levelDepth) { int x1W = ix1 << 1; int x1E = x1W + 1; int x2S = ix2 << 1; int x2N = x2S + 1; - int x3 = ix3 << 1; - int l = level + 1; + int x3 = ix3 << 1; + int l = level + 1; SPtr<Block3D> block = this->getBlock(x1W, x2N, x3, l); if (block != NULL) blockVector.push_back(block); @@ -1342,11 +1354,11 @@ void Grid3D::getSubBlocksBottom(int ix1, int ix2, int ix3, int level, vector<SPt ////////////////////////////////////////////////////////////////////////// void Grid3D::getSubBlocksNorthEast(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>>& blockVector, int levelDepth) { - int x1 = (ix1 << 1) + 1; - int x2 = (ix2 << 1) + 1; + int x1 = (ix1 << 1) + 1; + int x2 = (ix2 << 1) + 1; int x3B = (ix3 << 1); - int x3T = x3B + 1; - int l = level + 1; + int x3T = x3B+1; + int l = level + 1; SPtr<Block3D> blockB = this->getBlock(x1, x2, x3B, l); if (blockB) blockVector.push_back(blockB); @@ -1359,11 +1371,11 @@ void Grid3D::getSubBlocksNorthEast(int ix1, int ix2, int ix3, int level, vector< ////////////////////////////////////////////////////////////////////////// void Grid3D::getSubBlocksNorthWest(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>>& blockVector, int levelDepth) { - int x1 = (ix1 << 1); - int x2 = (ix2 << 1) + 1; + int x1 = (ix1 << 1); + int x2 = (ix2 << 1) + 1; int x3B = (ix3 << 1); - int x3T = x3B + 1; - int l = level + 1; + int x3T = x3B+1; + int l = level + 1; SPtr<Block3D> blockB = this->getBlock(x1, x2, x3B, l); if (blockB) blockVector.push_back(blockB); @@ -1376,11 +1388,11 @@ void Grid3D::getSubBlocksNorthWest(int ix1, int ix2, int ix3, int level, vector< ////////////////////////////////////////////////////////////////////////// void Grid3D::getSubBlocksSouthWest(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>>& blockVector, int levelDepth) { - int x1 = ix1 << 1; - int x2 = ix2 << 1; + int x1 = ix1 << 1; + int x2 = ix2 << 1; int x3B = (ix3 << 1); - int x3T = x3B + 1; - int l = level + 1; + int x3T = x3B+1; + int l = level + 1; SPtr<Block3D> blockB = this->getBlock(x1, x2, x3B, l); if (blockB) blockVector.push_back(blockB); @@ -1393,11 +1405,11 @@ void Grid3D::getSubBlocksSouthWest(int ix1, int ix2, int ix3, int level, vector< ////////////////////////////////////////////////////////////////////////// void Grid3D::getSubBlocksSouthEast(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>>& blockVector, int levelDepth) { - int x1 = (ix1 << 1) + 1; - int x2 = ix2 << 1; + int x1 = (ix1 << 1) + 1; + int x2 = ix2 << 1; int x3B = (ix3 << 1); - int x3T = x3B + 1; - int l = level + 1; + int x3T = x3B+1; + int l = level + 1; SPtr<Block3D> blockB = this->getBlock(x1, x2, x3B, l); if (blockB) blockVector.push_back(blockB); @@ -1412,11 +1424,11 @@ void Grid3D::getSubBlocksSouthEast(int ix1, int ix2, int ix3, int level, vector< ////////////////////////////////////////////////////////////////////////// void Grid3D::getSubBlocksTopEast(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>>& blockVector, int levelDepth) { - int x1 = (ix1 << 1) + 1; + int x1 = (ix1 << 1) + 1; int x2S = (ix2 << 1); int x2N = x2S + 1; - int x3 = (ix3 << 1) + 1; - int l = level + 1; + int x3 = (ix3 << 1)+1; + int l = level + 1; SPtr<Block3D> blockN = this->getBlock(x1, x2N, x3, l); if (blockN) blockVector.push_back(blockN); @@ -1429,11 +1441,11 @@ void Grid3D::getSubBlocksTopEast(int ix1, int ix2, int ix3, int level, vector<SP ////////////////////////////////////////////////////////////////////////// void Grid3D::getSubBlocksTopWest(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>>& blockVector, int levelDepth) { - int x1 = ix1 << 1; + int x1 = ix1 << 1; int x2S = ix2 << 1; int x2N = x2S + 1; - int x3 = (ix3 << 1) + 1; - int l = level + 1; + int x3 = (ix3 << 1)+1; + int l = level + 1; SPtr<Block3D> blockN = this->getBlock(x1, x2N, x3, l); if (blockN) blockVector.push_back(blockN); @@ -1446,11 +1458,11 @@ void Grid3D::getSubBlocksTopWest(int ix1, int ix2, int ix3, int level, vector<SP ////////////////////////////////////////////////////////////////////////// void Grid3D::getSubBlocksBottomEast(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>>& blockVector, int levelDepth) { - int x1 = (ix1 << 1) + 1; + int x1 = (ix1 << 1) + 1; int x2S = ix2 << 1; int x2N = x2S + 1; - int x3 = ix3 << 1; - int l = level + 1; + int x3 = ix3 << 1; + int l = level + 1; SPtr<Block3D> blockN = this->getBlock(x1, x2N, x3, l); if (blockN) blockVector.push_back(blockN); @@ -1463,11 +1475,11 @@ void Grid3D::getSubBlocksBottomEast(int ix1, int ix2, int ix3, int level, vector ////////////////////////////////////////////////////////////////////////// void Grid3D::getSubBlocksBottomWest(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>>& blockVector, int levelDepth) { - int x1 = (ix1 << 1); + int x1 = (ix1 << 1); int x2S = (ix2 << 1); int x2N = x2S + 1; - int x3 = ix3 << 1; - int l = level + 1; + int x3 = ix3 << 1; + int l = level + 1; SPtr<Block3D> blockN = this->getBlock(x1, x2N, x3, l); if (blockN) blockVector.push_back(blockN); @@ -1485,9 +1497,9 @@ void Grid3D::getSubBlocksTopNorth(int ix1, int ix2, int ix3, int level, vector<S { int x1E = (ix1 << 1); int x1W = x1E + 1; - int x2 = (ix2 << 1) + 1; - int x3 = (ix3 << 1) + 1; - int l = level + 1; + int x2 = (ix2 << 1)+1; + int x3 = (ix3 << 1)+1; + int l = level + 1; SPtr<Block3D> blockE = this->getBlock(x1E, x2, x3, l); if (blockE) blockVector.push_back(blockE); @@ -1502,9 +1514,9 @@ void Grid3D::getSubBlocksTopSouth(int ix1, int ix2, int ix3, int level, vector<S { int x1E = (ix1 << 1); int x1W = x1E + 1; - int x2 = (ix2 << 1); - int x3 = (ix3 << 1) + 1; - int l = level + 1; + int x2 = (ix2 << 1); + int x3 = (ix3 << 1)+1; + int l = level + 1; SPtr<Block3D> blockE = this->getBlock(x1E, x2, x3, l); if (blockE) blockVector.push_back(blockE); @@ -1519,9 +1531,9 @@ void Grid3D::getSubBlocksBottomNorth(int ix1, int ix2, int ix3, int level, vecto { int x1E = ix1 << 1; int x1W = x1E + 1; - int x2 = (ix2 << 1) + 1; - int x3 = ix3 << 1; - int l = level + 1; + int x2 = (ix2 << 1)+1; + int x3 = ix3 << 1; + int l = level + 1; SPtr<Block3D> blockE = this->getBlock(x1E, x2, x3, l); if (blockE) blockVector.push_back(blockE); @@ -1536,9 +1548,9 @@ void Grid3D::getSubBlocksBottomSouth(int ix1, int ix2, int ix3, int level, vecto { int x1E = (ix1 << 1); int x1W = x1E + 1; - int x2 = ix2 << 1; - int x3 = ix3 << 1; - int l = level + 1; + int x2 = ix2 << 1; + int x3 = ix3 << 1; + int l = level + 1; SPtr<Block3D> blockE = this->getBlock(x1E, x2, x3, l); if (blockE) blockVector.push_back(blockE); @@ -1556,7 +1568,7 @@ void Grid3D::getSubBlocksTopNorthEast(int ix1, int ix2, int ix3, int level, std: int x1 = (ix1 << 1) + 1; int x2 = (ix2 << 1) + 1; int x3 = (ix3 << 1) + 1; - int l = level + 1; + int l = level + 1; SPtr<Block3D> blockTNE = this->getBlock(x1, x2, x3, l); if (blockTNE) blockVector.push_back(blockTNE); @@ -1568,7 +1580,7 @@ void Grid3D::getSubBlocksTopNorthWest(int ix1, int ix2, int ix3, int level, std: int x1 = ix1 << 1; int x2 = (ix2 << 1) + 1; int x3 = (ix3 << 1) + 1; - int l = level + 1; + int l = level + 1; SPtr<Block3D> blockTNW = this->getBlock(x1, x2, x3, l); if (blockTNW) blockVector.push_back(blockTNW); @@ -1578,9 +1590,9 @@ void Grid3D::getSubBlocksTopNorthWest(int ix1, int ix2, int ix3, int level, std: void Grid3D::getSubBlocksTopSouthEast(int ix1, int ix2, int ix3, int level, std::vector<SPtr<Block3D>>& blockVector, int levelDepth) { int x1 = (ix1 << 1) + 1; - int x2 = ix2 << 1; + int x2 = ix2 << 1; int x3 = (ix3 << 1) + 1; - int l = level + 1; + int l = level + 1; SPtr<Block3D> blockTNW = this->getBlock(x1, x2, x3, l); if (blockTNW) blockVector.push_back(blockTNW); @@ -1589,10 +1601,10 @@ void Grid3D::getSubBlocksTopSouthEast(int ix1, int ix2, int ix3, int level, std: ////////////////////////////////////////////////////////////////////////// void Grid3D::getSubBlocksTopSouthWest(int ix1, int ix2, int ix3, int level, std::vector<SPtr<Block3D>>& blockVector, int levelDepth) { - int x1 = ix1 << 1; - int x2 = ix2 << 1; + int x1 = ix1 << 1; + int x2 = ix2 << 1; int x3 = (ix3 << 1) + 1; - int l = level + 1; + int l = level + 1; SPtr<Block3D> blockTSW = this->getBlock(x1, x2, x3, l); if (blockTSW) blockVector.push_back(blockTSW); @@ -1603,8 +1615,8 @@ void Grid3D::getSubBlocksBottomNorthEast(int ix1, int ix2, int ix3, int level, s { int x1 = (ix1 << 1) + 1; int x2 = (ix2 << 1) + 1; - int x3 = ix3 << 1; - int l = level + 1; + int x3 = ix3 << 1; + int l = level + 1; SPtr<Block3D> blockBNE = this->getBlock(x1, x2, x3, l); if (blockBNE) blockVector.push_back(blockBNE); @@ -1613,10 +1625,10 @@ void Grid3D::getSubBlocksBottomNorthEast(int ix1, int ix2, int ix3, int level, s ////////////////////////////////////////////////////////////////////////// void Grid3D::getSubBlocksBottomNorthWest(int ix1, int ix2, int ix3, int level, std::vector<SPtr<Block3D>>& blockVector, int levelDepth) { - int x1 = ix1 << 1; + int x1 = ix1 << 1; int x2 = (ix2 << 1) + 1; - int x3 = ix3 << 1; - int l = level + 1; + int x3 = ix3 << 1; + int l = level + 1; SPtr<Block3D> blockBNW = this->getBlock(x1, x2, x3, l); if (blockBNW) blockVector.push_back(blockBNW); @@ -1626,9 +1638,9 @@ void Grid3D::getSubBlocksBottomNorthWest(int ix1, int ix2, int ix3, int level, s void Grid3D::getSubBlocksBottomSouthEast(int ix1, int ix2, int ix3, int level, std::vector<SPtr<Block3D>>& blockVector, int levelDepth) { int x1 = (ix1 << 1) + 1; - int x2 = ix2 << 1; - int x3 = ix3 << 1; - int l = level + 1; + int x2 = ix2 << 1; + int x3 = ix3 << 1; + int l = level + 1; SPtr<Block3D> blockBSE = this->getBlock(x1, x2, x3, l); if (blockBSE) blockVector.push_back(blockBSE); @@ -1640,7 +1652,7 @@ void Grid3D::getSubBlocksBottomSouthWest(int ix1, int ix2, int ix3, int level, s int x1 = ix1 << 1; int x2 = ix2 << 1; int x3 = ix3 << 1; - int l = level + 1; + int l = level + 1; SPtr<Block3D> blockBSW = this->getBlock(x1, x2, x3, l); if (blockBSW) blockVector.push_back(blockBSW); @@ -1653,7 +1665,6 @@ void Grid3D::getBlocks(int level, std::vector<SPtr<Block3D>>& blockVector) { blockVector.push_back(b.second); } - } ////////////////////////////////////////////////////////////////////////// void Grid3D::getBlocks(int level, int rank, std::vector<SPtr<Block3D>>& blockVector) @@ -1685,13 +1696,13 @@ void Grid3D::getBlocks(int level, int rank, bool active, std::vector<SPtr<Block3 ////////////////////////////////////////////////////////////////////////// int Grid3D::getFinestInitializedLevel() { - for (int i = Grid3DSystem::MAXLEVEL; i >= 0; i--) if (this->levelSet[i].size() > 0) return(i); + for (int i=Grid3DSystem::MAXLEVEL; i>=0; i--) if (this->levelSet[i].size() > 0) return(i); return(-1); } ////////////////////////////////////////////////////////////////////////// int Grid3D::getCoarsestInitializedLevel() { - for (int i = 0; i <= Grid3DSystem::MAXLEVEL; i++) if (this->levelSet[i].size() > 0) return(i); + for (int i=0; i<=Grid3DSystem::MAXLEVEL; i++) if (this->levelSet[i].size() > 0) return(i); return(-1); } ////////////////////////////////////////////////////////////////////////// @@ -1752,46 +1763,46 @@ int Grid3D::getNumberOfBlocks(int level) void Grid3D::getBlocksByCuboid(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, std::vector<SPtr<Block3D>>& blocks) { int coarsestLevel = this->getCoarsestInitializedLevel(); - int finestLevel = this->getFinestInitializedLevel(); + int finestLevel = this->getFinestInitializedLevel(); ////////////////////////////////////////////////////////////////////////// //MINIMALE BLOCK-INDIZES BESTIMMEN // //min: - double dMinX1 = trafo->transformForwardToX1Coordinate(minX1, minX2, minX3) * (1 << finestLevel); - double dMinX2 = trafo->transformForwardToX2Coordinate(minX1, minX2, minX3) * (1 << finestLevel); - double dMinX3 = trafo->transformForwardToX3Coordinate(minX1, minX2, minX3) * (1 << finestLevel); + double dMinX1 = trafo->transformForwardToX1Coordinate(minX1, minX2, minX3)*(1<<finestLevel); + double dMinX2 = trafo->transformForwardToX2Coordinate(minX1, minX2, minX3)*(1<<finestLevel); + double dMinX3 = trafo->transformForwardToX3Coordinate(minX1, minX2, minX3)*(1<<finestLevel); //Achtung, wenn minX1 genau auf grenze zwischen zwei bloecken -> der "kleinere" muss genommen werden, //da beim Transformieren der "groessere" Index rauskommt - int iMinX1 = (int)dMinX1; if (UbMath::zero(dMinX1 - iMinX1)) iMinX1 -= 1; - int iMinX2 = (int)dMinX2; if (UbMath::zero(dMinX2 - iMinX2)) iMinX2 -= 1; - int iMinX3 = (int)dMinX3; if (UbMath::zero(dMinX3 - iMinX3)) iMinX3 -= 1; + int iMinX1 = (int)dMinX1; if (UbMath::zero(dMinX1-iMinX1)) iMinX1-=1; + int iMinX2 = (int)dMinX2; if (UbMath::zero(dMinX2-iMinX2)) iMinX2-=1; + int iMinX3 = (int)dMinX3; if (UbMath::zero(dMinX3-iMinX3)) iMinX3-=1; //max (hier kann die Zusatzabfrage vernachlaessigt werden): - int iMaxX1 = (int)(trafo->transformForwardToX1Coordinate(maxX1, maxX2, maxX3) * (1 << finestLevel)); - int iMaxX2 = (int)(trafo->transformForwardToX2Coordinate(maxX1, maxX2, maxX3) * (1 << finestLevel)); - int iMaxX3 = (int)(trafo->transformForwardToX3Coordinate(maxX1, maxX2, maxX3) * (1 << finestLevel)); + int iMaxX1 = (int)(trafo->transformForwardToX1Coordinate(maxX1, maxX2, maxX3)*(1<<finestLevel)); + int iMaxX2 = (int)(trafo->transformForwardToX2Coordinate(maxX1, maxX2, maxX3)*(1<<finestLevel)); + int iMaxX3 = (int)(trafo->transformForwardToX3Coordinate(maxX1, maxX2, maxX3)*(1<<finestLevel)); SPtr<Block3D> block; //set, um doppelte bloecke zu vermeiden, die u.U. bei periodic auftreten koennen std::set<SPtr<Block3D>> blockset; - for (int level = coarsestLevel; level <= finestLevel; level++) + for (int level=coarsestLevel; level<=finestLevel; level++) { //damit bei negativen werten auch der "kleinere" genommen wird -> floor! - int minx1 = (int)std::floor((double)iMinX1 / (1 << (finestLevel - level))); - int minx2 = (int)std::floor((double)iMinX2 / (1 << (finestLevel - level))); - int minx3 = (int)std::floor((double)iMinX3 / (1 << (finestLevel - level))); - - int maxx1 = iMaxX1 / (1 << (finestLevel - level)); - int maxx2 = iMaxX2 / (1 << (finestLevel - level)); - int maxx3 = iMaxX3 / (1 << (finestLevel - level)); - - for (int ix1 = minx1; ix1 <= maxx1; ix1++) - for (int ix2 = minx2; ix2 <= maxx2; ix2++) - for (int ix3 = minx3; ix3 <= maxx3; ix3++) - if ((block = this->getBlock(ix1, ix2, ix3, level))) + int minx1 = (int)std::floor((double)iMinX1/(1<<(finestLevel-level))); + int minx2 = (int)std::floor((double)iMinX2/(1<<(finestLevel-level))); + int minx3 = (int)std::floor((double)iMinX3/(1<<(finestLevel-level))); + + int maxx1 = iMaxX1/(1<<(finestLevel-level)); + int maxx2 = iMaxX2/(1<<(finestLevel-level)); + int maxx3 = iMaxX3/(1<<(finestLevel-level)); + + for (int ix1=minx1; ix1<=maxx1; ix1++) + for (int ix2=minx2; ix2<=maxx2; ix2++) + for (int ix3=minx3; ix3<=maxx3; ix3++) + if ((block=this->getBlock(ix1, ix2, ix3, level))) { if (block->getRank() == rank) { @@ -1810,29 +1821,29 @@ void Grid3D::getBlocksByCuboid(int level, double minX1, double minX2, double min //MINIMALE BLOCK-INDIZES BESTIMMEN // //min: - double dMinX1 = trafo->transformForwardToX1Coordinate(minX1, minX2, minX3) * (1 << level); - double dMinX2 = trafo->transformForwardToX2Coordinate(minX1, minX2, minX3) * (1 << level); - double dMinX3 = trafo->transformForwardToX3Coordinate(minX1, minX2, minX3) * (1 << level); + double dMinX1 = trafo->transformForwardToX1Coordinate(minX1, minX2, minX3)*(1<<level); + double dMinX2 = trafo->transformForwardToX2Coordinate(minX1, minX2, minX3)*(1<<level); + double dMinX3 = trafo->transformForwardToX3Coordinate(minX1, minX2, minX3)*(1<<level); //Achtung, wenn minX1 genau auf grenze zwischen zwei bloecken -> der "kleinere" muss genommen werden: - int iMinX1 = (int)dMinX1; if (UbMath::zero(dMinX1 - iMinX1)) iMinX1 -= 1; - int iMinX2 = (int)dMinX2; if (UbMath::zero(dMinX2 - iMinX2)) iMinX2 -= 1; - int iMinX3 = (int)dMinX3; if (UbMath::zero(dMinX3 - iMinX3)) iMinX3 -= 1; + int iMinX1 = (int)dMinX1; if (UbMath::zero(dMinX1-iMinX1)) iMinX1-=1; + int iMinX2 = (int)dMinX2; if (UbMath::zero(dMinX2-iMinX2)) iMinX2-=1; + int iMinX3 = (int)dMinX3; if (UbMath::zero(dMinX3-iMinX3)) iMinX3-=1; //max: - int iMaxX1 = (int)(trafo->transformForwardToX1Coordinate(maxX1, maxX2, maxX3) * (1 << level)); - int iMaxX2 = (int)(trafo->transformForwardToX2Coordinate(maxX1, maxX2, maxX3) * (1 << level)); - int iMaxX3 = (int)(trafo->transformForwardToX3Coordinate(maxX1, maxX2, maxX3) * (1 << level)); + int iMaxX1 = (int)(trafo->transformForwardToX1Coordinate(maxX1, maxX2, maxX3)*(1<<level)); + int iMaxX2 = (int)(trafo->transformForwardToX2Coordinate(maxX1, maxX2, maxX3)*(1<<level)); + int iMaxX3 = (int)(trafo->transformForwardToX3Coordinate(maxX1, maxX2, maxX3)*(1<<level)); //set, um doppelte bloecke zu vermeiden, die u.U. bei periodic auftreten koennen std::set<SPtr<Block3D>> blockset; SPtr<Block3D> block; - for (int ix1 = iMinX1; ix1 <= iMaxX1; ix1++) - for (int ix2 = iMinX2; ix2 <= iMaxX2; ix2++) - for (int ix3 = iMinX3; ix3 <= iMaxX3; ix3++) - if ((block = this->getBlock(ix1, ix2, ix3, level))) + for (int ix1=iMinX1; ix1<=iMaxX1; ix1++) + for (int ix2=iMinX2; ix2<=iMaxX2; ix2++) + for (int ix3=iMinX3; ix3<=iMaxX3; ix3++) + if ((block=this->getBlock(ix1, ix2, ix3, level))) { if (block->getRank() == rank) { @@ -1847,46 +1858,46 @@ void Grid3D::getBlocksByCuboid(int level, double minX1, double minX2, double min void Grid3D::getAllBlocksByCuboid(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, std::vector<SPtr<Block3D>>& blocks) { int coarsestLevel = this->getCoarsestInitializedLevel(); - int finestLevel = this->getFinestInitializedLevel(); + int finestLevel = this->getFinestInitializedLevel(); ////////////////////////////////////////////////////////////////////////// //MINIMALE BLOCK-INDIZES BESTIMMEN // //min: - double dMinX1 = trafo->transformForwardToX1Coordinate(minX1, minX2, minX3) * (1 << finestLevel); - double dMinX2 = trafo->transformForwardToX2Coordinate(minX1, minX2, minX3) * (1 << finestLevel); - double dMinX3 = trafo->transformForwardToX3Coordinate(minX1, minX2, minX3) * (1 << finestLevel); + double dMinX1 = trafo->transformForwardToX1Coordinate(minX1, minX2, minX3)*(1<<finestLevel); + double dMinX2 = trafo->transformForwardToX2Coordinate(minX1, minX2, minX3)*(1<<finestLevel); + double dMinX3 = trafo->transformForwardToX3Coordinate(minX1, minX2, minX3)*(1<<finestLevel); //Achtung, wenn minX1 genau auf grenze zwischen zwei bloecken -> der "kleinere" muss genommen werden, //da beim Transformieren der "groessere" Index rauskommt - int iMinX1 = (int)dMinX1; if (UbMath::zero(dMinX1 - iMinX1)) iMinX1 -= 1; - int iMinX2 = (int)dMinX2; if (UbMath::zero(dMinX2 - iMinX2)) iMinX2 -= 1; - int iMinX3 = (int)dMinX3; if (UbMath::zero(dMinX3 - iMinX3)) iMinX3 -= 1; + int iMinX1 = (int)dMinX1; if (UbMath::zero(dMinX1-iMinX1)) iMinX1-=1; + int iMinX2 = (int)dMinX2; if (UbMath::zero(dMinX2-iMinX2)) iMinX2-=1; + int iMinX3 = (int)dMinX3; if (UbMath::zero(dMinX3-iMinX3)) iMinX3-=1; //max (hier kann die Zusatzabfrage vernachlaessigt werden): - int iMaxX1 = (int)(trafo->transformForwardToX1Coordinate(maxX1, maxX2, maxX3) * (1 << finestLevel)); - int iMaxX2 = (int)(trafo->transformForwardToX2Coordinate(maxX1, maxX2, maxX3) * (1 << finestLevel)); - int iMaxX3 = (int)(trafo->transformForwardToX3Coordinate(maxX1, maxX2, maxX3) * (1 << finestLevel)); + int iMaxX1 = (int)(trafo->transformForwardToX1Coordinate(maxX1, maxX2, maxX3)*(1<<finestLevel)); + int iMaxX2 = (int)(trafo->transformForwardToX2Coordinate(maxX1, maxX2, maxX3)*(1<<finestLevel)); + int iMaxX3 = (int)(trafo->transformForwardToX3Coordinate(maxX1, maxX2, maxX3)*(1<<finestLevel)); SPtr<Block3D> block; //set, um doppelte bloecke zu vermeiden, die u.U. bei periodic auftreten koennen std::set<SPtr<Block3D>> blockset; - for (int level = coarsestLevel; level <= finestLevel; level++) + for (int level=coarsestLevel; level<=finestLevel; level++) { //damit bei negativen werten auch der "kleinere" genommen wird -> floor! - int minx1 = (int)std::floor((double)iMinX1 / (1 << (finestLevel - level))); - int minx2 = (int)std::floor((double)iMinX2 / (1 << (finestLevel - level))); - int minx3 = (int)std::floor((double)iMinX3 / (1 << (finestLevel - level))); - - int maxx1 = iMaxX1 / (1 << (finestLevel - level)); - int maxx2 = iMaxX2 / (1 << (finestLevel - level)); - int maxx3 = iMaxX3 / (1 << (finestLevel - level)); - - for (int ix1 = minx1; ix1 <= maxx1; ix1++) - for (int ix2 = minx2; ix2 <= maxx2; ix2++) - for (int ix3 = minx3; ix3 <= maxx3; ix3++) - if ((block = this->getBlock(ix1, ix2, ix3, level))) + int minx1 = (int)std::floor((double)iMinX1/(1<<(finestLevel-level))); + int minx2 = (int)std::floor((double)iMinX2/(1<<(finestLevel-level))); + int minx3 = (int)std::floor((double)iMinX3/(1<<(finestLevel-level))); + + int maxx1 = iMaxX1/(1<<(finestLevel-level)); + int maxx2 = iMaxX2/(1<<(finestLevel-level)); + int maxx3 = iMaxX3/(1<<(finestLevel-level)); + + for (int ix1=minx1; ix1<=maxx1; ix1++) + for (int ix2=minx2; ix2<=maxx2; ix2++) + for (int ix3=minx3; ix3<=maxx3; ix3++) + if ((block=this->getBlock(ix1, ix2, ix3, level))) { if (block) { @@ -1901,11 +1912,11 @@ void Grid3D::getAllBlocksByCuboid(double minX1, double minX2, double minX3, doub ////////////////////////////////////////////////////////////////////////// void Grid3D::calcStartCoordinatesAndDelta(SPtr<Block3D> block, double& worldX1, double& worldX2, double& worldX3, double& deltaX) { - int blocklevel = block->getLevel(); - worldX1 = block->getX1() / (float)(1 << blocklevel); - worldX2 = block->getX2() / (float)(1 << blocklevel); - worldX3 = block->getX3() / (float)(1 << blocklevel); - deltaX = (double)1.0 / (double)(this->blockNx1 * (double)(1 << blocklevel)); + int blocklevel = block->getLevel(); + worldX1 = block->getX1()/(float)(1<<blocklevel); + worldX2 = block->getX2()/(float)(1<<blocklevel); + worldX3 = block->getX3()/(float)(1<<blocklevel); + deltaX = (double)1.0/(double)(this->blockNx1*(double)(1<<blocklevel)); if (this->trafo) { @@ -1913,16 +1924,16 @@ void Grid3D::calcStartCoordinatesAndDelta(SPtr<Block3D> block, double& worldX1, worldX1 = this->trafo->transformBackwardToX1Coordinate(x1tmp, x2tmp, x3tmp); worldX2 = this->trafo->transformBackwardToX2Coordinate(x1tmp, x2tmp, x3tmp); worldX3 = this->trafo->transformBackwardToX3Coordinate(x1tmp, x2tmp, x3tmp); - deltaX = this->trafo->getX1CoordinateScaling() / (double)(this->blockNx1 * (double)(1 << blocklevel)); + deltaX = this->trafo->getX1CoordinateScaling()/(double)(this->blockNx1*(double)(1<<blocklevel)); } } ////////////////////////////////////////////////////////////////////////// void Grid3D::calcStartCoordinatesWithOutOverlap(SPtr<Block3D> block, double& worldX1, double& worldX2, double& worldX3) { - int blocklevel = block->getLevel(); - worldX1 = block->getX1() / (float)(1 << blocklevel); - worldX2 = block->getX2() / (float)(1 << blocklevel); - worldX3 = block->getX3() / (float)(1 << blocklevel); + int blocklevel = block->getLevel(); + worldX1 = block->getX1()/(float)(1<<blocklevel); + worldX2 = block->getX2()/(float)(1<<blocklevel); + worldX3 = block->getX3()/(float)(1<<blocklevel); if (this->trafo) { @@ -2025,57 +2036,4 @@ void Grid3D::renumberBlockIDs() ////////////////////////////////////////////////////////////////////////// -void Grid3D::updateDistributedBlocks(SPtr<Communicator> comm) -{ - - std::vector<int> blocks; - - if (comm->isRoot()) - { - int startLevel = getCoarsestInitializedLevel(); - int stopLevel = getFinestInitializedLevel(); - - for (int l = startLevel; l <= stopLevel; l++) - { - std::vector<SPtr<Block3D>> blockVector; - getBlocks(l, blockVector); - for (SPtr<Block3D> 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 = (int)blocks.size(); - for (int i = 0; i < rsize; i += 5) - { - SPtr<Block3D> 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/src/cpu/VirtualFluidsCore/Grid/Grid3D.h b/src/cpu/VirtualFluidsCore/Grid/Grid3D.h index e27100643..e392b90a0 100644 --- a/src/cpu/VirtualFluidsCore/Grid/Grid3D.h +++ b/src/cpu/VirtualFluidsCore/Grid/Grid3D.h @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Grid.h +//! \ingroup Grid +//! \author Konstantin Kutscher, Soeren Freudiger, Sebastian Geller +//======================================================================================= + #ifndef GRID3D_H #define GRID3D_H @@ -18,10 +51,10 @@ class CoordinateTransformation3D; class Communicator; class Block3D; class Interactor3D; -//class Grid3DVisitor; #define OFFSET 0.5 +//! A class implements block grid ////////////////////////////////////////////////////////////////////////// class Grid3D : public enableSharedFromThis<Grid3D> { @@ -42,7 +75,6 @@ public: void addBlock(SPtr<Block3D> block); bool deleteBlock(SPtr<Block3D> block); bool deleteBlock(int ix1, int ix2, int ix3, int level); - void deleteBlocks(); void deleteBlocks(const std::vector<int>& ids); void replaceBlock(SPtr<Block3D> block); SPtr<Block3D> getBlock(int ix1, int ix2, int ix3, int level) const; @@ -62,11 +94,9 @@ public: void getBlocks(int level, int rank, bool active, std::vector<SPtr<Block3D>>& blockVector); int getNumberOfBlocks(); int getNumberOfBlocks(int level); - //const Block3DMap& getBlocks(int level); BlockIDMap& getBlockIDs(); void deleteBlockIDs(); void renumberBlockIDs(); - void updateDistributedBlocks(SPtr<Communicator> comm); SPtr<Block3D> getSuperBlock(SPtr<Block3D> block); SPtr<Block3D> getSuperBlock(int ix1, int ix2, int ix3, int level); void getSubBlocks(SPtr<Block3D> block, int levelDepth, std::vector<SPtr<Block3D>>& blocks); diff --git a/src/cpu/VirtualFluidsCore/Grid/Grid3DSystem.cpp b/src/cpu/VirtualFluidsCore/Grid/Grid3DSystem.cpp index ea2ecde18..7363f263a 100644 --- a/src/cpu/VirtualFluidsCore/Grid/Grid3DSystem.cpp +++ b/src/cpu/VirtualFluidsCore/Grid/Grid3DSystem.cpp @@ -1,48 +1,81 @@ -#include <Grid3DSystem.h> - -namespace Grid3DSystem -{ - const int INVDIR[] = { INV_E , - INV_W , - INV_N , - INV_S , - INV_T , - INV_B , - INV_NE , - INV_NW , - INV_SE , - INV_SW , - INV_TE , - INV_TW , - INV_BE , - INV_BW , - INV_TN , - INV_TS , - INV_BN , - INV_BS , - INV_TNE, - INV_TNW, - INV_TSE, - INV_TSW, - INV_BNE, - INV_BNW, - INV_BSE, - INV_BSW }; - - //index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 - //direction: E, W, N, S, T, B, NE, SW, SE, NW, TE, BW, BE, TW, TN, BS, BN, TS, TNE TNW TSE TSW BNE BNW BSE BSW - const int EX1[] = { 1, -1, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1 }; - const int EX2[] = { 0, 0, 1, -1, 0, 0, 1, -1, -1, 1, 0, 0, 0, 0, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1 }; - const int EX3[] = { 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1 }; -} - -////////////////////////////////////////////////////////////////////////// -const int& Grid3DSystem::getInvertDirection(const int& direction) -{ -#ifdef _DEBUG - if(direction<STARTDIR || direction>ENDDIR) - throw UbException(UB_EXARGS,"unknown direction"); -#endif - return INVDIR[direction]; -} - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Grid3DSystem.cpp +//! \ingroup Grid +//! \author Konstantin Kutscher +//======================================================================================= + +#include <Grid3DSystem.h> + +namespace Grid3DSystem +{ + const int INVDIR[] = { INV_E , + INV_W , + INV_N , + INV_S , + INV_T , + INV_B , + INV_NE , + INV_NW , + INV_SE , + INV_SW , + INV_TE , + INV_TW , + INV_BE , + INV_BW , + INV_TN , + INV_TS , + INV_BN , + INV_BS , + INV_TNE, + INV_TNW, + INV_TSE, + INV_TSW, + INV_BNE, + INV_BNW, + INV_BSE, + INV_BSW }; + + //index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 + //direction: E, W, N, S, T, B, NE, SW, SE, NW, TE, BW, BE, TW, TN, BS, BN, TS, TNE TNW TSE TSW BNE BNW BSE BSW + const int EX1[] = { 1, -1, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1 }; + const int EX2[] = { 0, 0, 1, -1, 0, 0, 1, -1, -1, 1, 0, 0, 0, 0, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1 }; + const int EX3[] = { 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1 }; +} + +////////////////////////////////////////////////////////////////////////// +const int& Grid3DSystem::getInvertDirection(const int& direction) +{ +#ifdef _DEBUG + if(direction<STARTDIR || direction>ENDDIR) + throw UbException(UB_EXARGS,"unknown direction"); +#endif + return INVDIR[direction]; +} + diff --git a/src/cpu/VirtualFluidsCore/Grid/Grid3DSystem.h b/src/cpu/VirtualFluidsCore/Grid/Grid3DSystem.h index cb472bc50..bbcb21316 100644 --- a/src/cpu/VirtualFluidsCore/Grid/Grid3DSystem.h +++ b/src/cpu/VirtualFluidsCore/Grid/Grid3DSystem.h @@ -1,159 +1,185 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef Grid3DSystem_H -#define Grid3DSystem_H - -#include <cmath> -#include <iostream> -#include <string> - -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbException.h> - - -namespace Grid3DSystem -{ - static const int STARTDIR = 0; - - static const int E /*f1 */ = 0; - static const int W /*f2 */ = 1; - static const int N /*f3 */ = 2; - static const int S /*f4 */ = 3; - static const int T /*f5 */ = 4; - static const int B /*f6 */ = 5; - static const int NE /*f7 */ = 6; - static const int SW /*f8 */ = 7; - static const int SE /*f9 */ = 8; - static const int NW /*f10*/ = 9; - static const int TE /*f11*/ = 10; - static const int BW /*f12*/ = 11; - static const int BE /*f13*/ = 12; - static const int TW /*f14*/ = 13; - static const int TN /*f15*/ = 14; - static const int BS /*f16*/ = 15; - static const int BN /*f17*/ = 16; - static const int TS /*f18*/ = 17; - static const int TNE = 18; - static const int TNW = 19; - static const int TSE = 20; - static const int TSW = 21; - static const int BNE = 22; - static const int BNW = 23; - static const int BSE = 24; - static const int BSW = 25; - static const int ZERO /*f0 */ = 26; - - static const int ENDDIR = 25; - - static const int INV_E = W; - static const int INV_W = E; - static const int INV_N = S; - static const int INV_S = N; - static const int INV_T = B; - static const int INV_B = T; - static const int INV_NE = SW; - static const int INV_NW = SE; - static const int INV_SE = NW; - static const int INV_SW = NE; - static const int INV_TE = BW; - static const int INV_TW = BE; - static const int INV_BE = TW; - static const int INV_BW = TE; - static const int INV_TN = BS; - static const int INV_TS = BN; - static const int INV_BN = TS; - static const int INV_BS = TN; - static const int INV_TNE = BSW; - static const int INV_TNW = BSE; - static const int INV_TSE = BNW; - static const int INV_TSW = BNE; - static const int INV_BNE = TSW; - static const int INV_BNW = TSE; - static const int INV_BSE = TNW; - static const int INV_BSW = TNE; - - extern const int INVDIR[ENDDIR+1]; - - static const int MINLEVEL = 0; - static const int MAXLEVEL = 25; - - extern const int EX1[ENDDIR+1]; - extern const int EX2[ENDDIR+1]; - extern const int EX3[ENDDIR+1]; - - inline std::string getDirectionString(int direction) - { - switch(direction) - { - case E : return "E"; - case W : return "W"; - case N : return "N"; - case S : return "S"; - case T : return "T"; - case B : return "B"; - case NE : return "NE"; - case NW : return "NW"; - case SE : return "SE"; - case SW : return "SW"; - case TE : return "TE"; - case TW : return "TW"; - case BE : return "BE"; - case BW : return "BW"; - case TN : return "TN"; - case TS : return "TS"; - case BN : return "BN"; - case BS : return "BS"; - case TNE : return "TNE"; - case TNW : return "TNW"; - case TSE : return "TSE"; - case TSW : return "TSW"; - case BNE : return "BNE"; - case BNW : return "BNW"; - case BSE : return "BSE"; - case BSW : return "BSW"; - default : return "Cell3DSystem::getDrectionString(...) - unknown dir"; - } - } - static const int& getInvertDirection(const int& direction); - -////////////////////////////////////////////////////////////////////////// - static inline void setNeighborCoordinatesForDirection(int &x1, int &x2,int &x3, const int& direction) - { - switch(direction) - { - case Grid3DSystem::E : x1++; break; - case Grid3DSystem::N : x2++; break; - case Grid3DSystem::T : x3++; break; - case Grid3DSystem::W : x1--; break; - case Grid3DSystem::S : x2--; break; - case Grid3DSystem::B : x3--; break; - case Grid3DSystem::NE : x1++; x2++; break; - case Grid3DSystem::NW : x1--; x2++; break; - case Grid3DSystem::SW : x1--; x2--; break; - case Grid3DSystem::SE : x1++; x2--; break; - case Grid3DSystem::TE : x1++; x3++; break; - case Grid3DSystem::BW : x1--; x3--; break; - case Grid3DSystem::BE : x1++; x3--; break; - case Grid3DSystem::TW : x1--; x3++; break; - case Grid3DSystem::TN : x2++; x3++; break; - case Grid3DSystem::BS : x2--; x3--; break; - case Grid3DSystem::BN : x2++; x3--; break; - case Grid3DSystem::TS : x2--; x3++; break; - case Grid3DSystem::TNE: x1++; x2++; x3++; break; - case Grid3DSystem::TNW: x1--; x2++; x3++; break; - case Grid3DSystem::TSE: x1++; x2--; x3++; break; - case Grid3DSystem::TSW: x1--; x2--; x3++; break; - case Grid3DSystem::BNE: x1++; x2++; x3--; break; - case Grid3DSystem::BNW: x1--; x2++; x3--; break; - case Grid3DSystem::BSE: x1++; x2--; x3--; break; - case Grid3DSystem::BSW: x1--; x2--; x3--; break; - default: throw UbException(UB_EXARGS,"no direction ..."); - } - } -} - -#endif +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Grid3DSystem.h +//! \ingroup Grid +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef Grid3DSystem_H +#define Grid3DSystem_H + +#include <cmath> +#include <iostream> +#include <string> + +#include <basics/utilities/UbMath.h> +#include <basics/utilities/UbException.h> + + +namespace Grid3DSystem +{ + static const int STARTDIR = 0; + + static const int E /*f1 */ = 0; + static const int W /*f2 */ = 1; + static const int N /*f3 */ = 2; + static const int S /*f4 */ = 3; + static const int T /*f5 */ = 4; + static const int B /*f6 */ = 5; + static const int NE /*f7 */ = 6; + static const int SW /*f8 */ = 7; + static const int SE /*f9 */ = 8; + static const int NW /*f10*/ = 9; + static const int TE /*f11*/ = 10; + static const int BW /*f12*/ = 11; + static const int BE /*f13*/ = 12; + static const int TW /*f14*/ = 13; + static const int TN /*f15*/ = 14; + static const int BS /*f16*/ = 15; + static const int BN /*f17*/ = 16; + static const int TS /*f18*/ = 17; + static const int TNE = 18; + static const int TNW = 19; + static const int TSE = 20; + static const int TSW = 21; + static const int BNE = 22; + static const int BNW = 23; + static const int BSE = 24; + static const int BSW = 25; + static const int REST /*f0 */ = 26; + + static const int ENDDIR = 25; + + static const int INV_E = W; + static const int INV_W = E; + static const int INV_N = S; + static const int INV_S = N; + static const int INV_T = B; + static const int INV_B = T; + static const int INV_NE = SW; + static const int INV_NW = SE; + static const int INV_SE = NW; + static const int INV_SW = NE; + static const int INV_TE = BW; + static const int INV_TW = BE; + static const int INV_BE = TW; + static const int INV_BW = TE; + static const int INV_TN = BS; + static const int INV_TS = BN; + static const int INV_BN = TS; + static const int INV_BS = TN; + static const int INV_TNE = BSW; + static const int INV_TNW = BSE; + static const int INV_TSE = BNW; + static const int INV_TSW = BNE; + static const int INV_BNE = TSW; + static const int INV_BNW = TSE; + static const int INV_BSE = TNW; + static const int INV_BSW = TNE; + + extern const int INVDIR[ENDDIR+1]; + + static const int MAXLEVEL = 25; + + extern const int EX1[ENDDIR+1]; + extern const int EX2[ENDDIR+1]; + extern const int EX3[ENDDIR+1]; + + inline std::string getDirectionString(int direction) + { + switch(direction) + { + case E : return "E"; + case W : return "W"; + case N : return "N"; + case S : return "S"; + case T : return "T"; + case B : return "B"; + case NE : return "NE"; + case NW : return "NW"; + case SE : return "SE"; + case SW : return "SW"; + case TE : return "TE"; + case TW : return "TW"; + case BE : return "BE"; + case BW : return "BW"; + case TN : return "TN"; + case TS : return "TS"; + case BN : return "BN"; + case BS : return "BS"; + case TNE : return "TNE"; + case TNW : return "TNW"; + case TSE : return "TSE"; + case TSW : return "TSW"; + case BNE : return "BNE"; + case BNW : return "BNW"; + case BSE : return "BSE"; + case BSW : return "BSW"; + default : return "Cell3DSystem::getDrectionString(...) - unknown dir"; + } + } + static const int& getInvertDirection(const int& direction); + +////////////////////////////////////////////////////////////////////////// + static inline void setNeighborCoordinatesForDirection(int &x1, int &x2,int &x3, const int& direction) + { + switch(direction) + { + case Grid3DSystem::E : x1++; break; + case Grid3DSystem::N : x2++; break; + case Grid3DSystem::T : x3++; break; + case Grid3DSystem::W : x1--; break; + case Grid3DSystem::S : x2--; break; + case Grid3DSystem::B : x3--; break; + case Grid3DSystem::NE : x1++; x2++; break; + case Grid3DSystem::NW : x1--; x2++; break; + case Grid3DSystem::SW : x1--; x2--; break; + case Grid3DSystem::SE : x1++; x2--; break; + case Grid3DSystem::TE : x1++; x3++; break; + case Grid3DSystem::BW : x1--; x3--; break; + case Grid3DSystem::BE : x1++; x3--; break; + case Grid3DSystem::TW : x1--; x3++; break; + case Grid3DSystem::TN : x2++; x3++; break; + case Grid3DSystem::BS : x2--; x3--; break; + case Grid3DSystem::BN : x2++; x3--; break; + case Grid3DSystem::TS : x2--; x3++; break; + case Grid3DSystem::TNE: x1++; x2++; x3++; break; + case Grid3DSystem::TNW: x1--; x2++; x3++; break; + case Grid3DSystem::TSE: x1++; x2--; x3++; break; + case Grid3DSystem::TSW: x1--; x2--; x3++; break; + case Grid3DSystem::BNE: x1++; x2++; x3--; break; + case Grid3DSystem::BNW: x1--; x2++; x3--; break; + case Grid3DSystem::BSE: x1++; x2--; x3--; break; + case Grid3DSystem::BSW: x1--; x2--; x3--; break; + default: throw UbException(UB_EXARGS,"no direction ..."); + } + } +} + +#endif diff --git a/src/cpu/VirtualFluidsCore/IncludsList.cmake b/src/cpu/VirtualFluidsCore/IncludsList.cmake index 878893a4f..13812a833 100644 --- a/src/cpu/VirtualFluidsCore/IncludsList.cmake +++ b/src/cpu/VirtualFluidsCore/IncludsList.cmake @@ -16,20 +16,3 @@ INCLUDE_DIRECTORIES(${SOURCE_DIR}/VirtualFluidsCore/Utilities) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/3rdParty) -IF(${USE_BOOST}) - INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR}) -ENDIF() - -INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH}) -INCLUDE_DIRECTORIES(${METIS_INCLUDEDIR}) -INCLUDE_DIRECTORIES(${ZOLTAN_INCLUDEDIR}) -IF(${USE_VTK}) - INCLUDE_DIRECTORIES(${VTK_INCLUDE_DIRS}) -ENDIF() -IF(${USE_FETOL}) - INCLUDE_DIRECTORIES(${SOURCE_DIR}/VirtualFluidsCore/FETOL) - INCLUDE_DIRECTORIES(${YAML_INCLUDEDIR}) - INCLUDE_DIRECTORIES(${BOND_INCLUDEDIR}) - INCLUDE_DIRECTORIES(${FETOL_INCLUDEDIR}) -ENDIF() - diff --git a/src/cpu/VirtualFluidsCore/Interactors/CMakePackage.txt b/src/cpu/VirtualFluidsCore/Interactors/CMakePackage.txt index 9354d3d00..1b8416f01 100644 --- a/src/cpu/VirtualFluidsCore/Interactors/CMakePackage.txt +++ b/src/cpu/VirtualFluidsCore/Interactors/CMakePackage.txt @@ -1,2 +1,2 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) +GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) diff --git a/src/cpu/VirtualFluidsCore/Interactors/D3Q27Interactor.cpp b/src/cpu/VirtualFluidsCore/Interactors/D3Q27Interactor.cpp index 820324c72..811a04691 100644 --- a/src/cpu/VirtualFluidsCore/Interactors/D3Q27Interactor.cpp +++ b/src/cpu/VirtualFluidsCore/Interactors/D3Q27Interactor.cpp @@ -1,11 +1,46 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file D3Q27Interactor.cpp +//! \ingroup Interactor +//! \author Sören Freudiger +//! \author Sebastian Geller +//! \author Konstantin Kutscher +//======================================================================================= + #include "D3Q27Interactor.h" #include <basics/utilities/UbMath.h> #include <basics/utilities/UbLogger.h> #include <basics/writer/WbWriterVtkXmlBinary.h> -#include <numerics/geometry3d/GbCuboid3D.h> -#include <numerics/geometry3d/GbLine3D.h> +#include <GbCuboid3D.h> +#include <GbLine3D.h> #include "Block3D.h" #include "Grid3D.h" #include "BCArray3D.h" @@ -14,10 +49,6 @@ #include "BCProcessor.h" #include "BCAdapter.h" -//#include <3rdParty/MarchingCubes/MarchingCubes.h> - - - using namespace std; @@ -109,41 +140,10 @@ void D3Q27Interactor::initInteractor(const double& timeStep) else this->unsetTimeDependent(); Interactor3D::initInteractor(timeStep); - - ////calcForces arbeitet nicht korrekt, wenn Geo mit Bloecken - // //unterschiedlicher Leveltiefe diskretisiert -> exception - // //abfrage steht hier, weil es theoretisch sein kann, dass bei parallelen rechnungen - // //genau der block mit dem anderen level auf einem anderen prozess liegt... - // //Update: es kann u.U. passieren, dass Bl�cke in der Liste nicht aktiv sin - // //(falls diese z.B. duch andere Interactoren solid gesetzt wurden) - // //diese werden nicht ber�cksichtigt (auch nicht beid er kraftauswertung sp�ter) - // if(this->isRelevantForForces() ) - // { - // int level = -1; - // for( vector<Block3D*>::const_iterator pos = transBlockSet->begin(); pos!=transBlockSet->end(); ++pos) - // if( (*pos)->isActive() ) - // { - // level = (*pos)->getLevel(); - // break; - // } - // - // bool check = false; - // for( vector<Block3D*>::const_iterator pos = transBlockSet->begin(); pos!=transBlockSet->end(); ++pos) - // if( (*pos)->isActive() && (*pos)->getLevel()!=level) - // { - // throw UbException(UB_EXARGS,"interactor is relevant for forces," - // +(string)" but has transblocks with different levels" - // +(string)" -> not supportet by D3Q27Interactor::getForces()" - // +(string)" -> increase refineWidth"); - // } - // } } ////////////////////////////////////////////////////////////////////////// void D3Q27Interactor::updateInteractor(const double& timestep) { - //UB_THROW( UbException(UB_EXARGS,"toDo") ); - //if(this->isFluid()) return; - UBLOG(logDEBUG5,"D3Q27Interactor::updateInteractor - for timestep = "<<timestep); ////////////////////////////////////////////////////////////////////////// @@ -161,15 +161,11 @@ void D3Q27Interactor::updateInteractor(const double& timestep) if(needTimeDependence) this->setTimeDependent(); else this->unsetTimeDependent(); - //UBLOG(logINFO, "transNodeIndicesMap = "<<transNodeIndicesMap.size()); - for(BcNodeIndicesMap::value_type t : bcNodeIndicesMap) { SPtr<Block3D> block = t.first; std::set< std::vector<int> >& transNodeIndicesSet = t.second; - //UBLOG(logINFO, "transNodeIndicesSet = "<<transNodeIndicesSet.size()); - if(block->isNotActive() || !block) continue; SPtr<ILBMKernel> kernel = block->getKernel(); @@ -188,24 +184,20 @@ void D3Q27Interactor::updateInteractor(const double& timestep) double worldX3 = coords[2]; SPtr<BoundaryConditions> bc = bcArray->getBC(x1,x2,x3); - if(bc) //kann sein, dass die BC durch das solid setzen eines andern interactors geloescht wurde + if(bc) //may be that the BC has been deleted by the solid setting of another interactor { for(size_t i=0; i<bcAdapters.size(); i++) bcAdapters[i]->adaptBC(*this,bc,worldX1,worldX2,worldX3,timestep); } - //else - //{ - // UBLOG(logERROR,"D3Q27Interactor.updateInteractor (Z."<<__LINE__<<"): da ist kein BC dran ... kann aber korrekt sein s.h. code"); - //} } } } ////////////////////////////////////////////////////////////////////////// -// Berechnung findet im realen Koordinatensystem statt !!! -// nicht im normierten ! -//x1,x2,x3 sind die Koordinaten unten links vom "System" -//extendedBoundingGeoOfGeoObject MUSS bereits um delta_x_level in jede richtung vergroesert worden sein fuer SOLID -bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,const double& orgX1,const double& orgX2,const double& orgX3,const double& blockLengthX1,const double& blockLengthX2,const double& blockLengthX3, const double& timestep*/) +// calculation takes place in the real coordinate system !!! +// not normalized! +// x1, x2, x3 are the coordinates at the bottom left of the "system" +// extendedBoundingGeoOfGeoObject MUST already have been magnified by delta_x_level in each direction for SOLID +bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block) { if(!block) return false; @@ -218,8 +210,8 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,con double timestep = 0; - bool oneEntryGotBC = false; //ob ueberhaupt ein eintrag ein BC zugewiesen wurde - bool gotQs = false; //true, wenn "difference" gesetzt wurde + bool oneEntryGotBC = false; + bool gotQs = false; SPtr<BoundaryConditions> bc; SPtr<ILBMKernel> kernel = block->getKernel(); @@ -241,7 +233,7 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,con double dx = grid.lock()->getDeltaX(block); UbTupleDouble3 orgDelta = grid.lock()->getNodeOffset(block); - //anderes boundingRect als in init, da hier das boundrect um ein dx vergroessert werden muss + //other boundingRect than in init, because here the boundrect has to be increased by one dx GbCuboid3D extendedBoundingGeoOfGeoObject( geoObject3D->getX1Minimum()-1.02*dx , geoObject3D->getX2Minimum()-1.02*dx , geoObject3D->getX3Minimum()-1.02*dx @@ -254,7 +246,7 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,con if( geoObject3D->hasRaytracing() || (this->isInverseSolid() && geoObject3D->raytracingSupportsPointsInside() ) ) { - //wenn deltaX1==deltaX2==deltaX3 (muss fuer LB!!) + //if deltaX1==deltaX2==deltaX3 (must for LB!!) if(!UbMath::zero( deltaX1-deltaX2 + deltaX1-deltaX3 + deltaX2-deltaX3 ) ) throw UbException(UB_EXARGS,"fuer den bei LB nicht vorkommenden Fall deltaX1!=deltaX2!=deltaX3 nicht implementiert "); @@ -278,7 +270,7 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,con { for(int ix1=startIX1; ix1<stopIX1; ix1++) { - //TODO weiter untersuchen, ob das nicht ein Fehler ist + //TODO: further, investigate if this is not a mistake if(bcArray->isUndefined(ix1, ix2, ix3)) continue; Vector3D coords = grid.lock()->getNodeCoordinates(block, ix1, ix2, ix3); @@ -286,17 +278,14 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,con internX2 = coords[1]; internX3 = coords[2]; - //point in object test ist ueberfluessig, weil die start und stop indices bereits zuvor - //ermittelt werden -> es werden nur point-IN-cube indizes betrachtet + // Point in the object test is superfluous, since the start and stop indices already exist + // are determined -> only point-in-cube indexes are considered if(extendedBoundingGeoOfGeoObject.isPointInGbObject3D(internX1,internX2,internX3)) { if(this->isSolid() ) { if(this->geoObject3D->isPointInGbObject3D(internX1, internX2, internX3)) { -//#ifdef _OPENMP -// #pragma omp critical (SOLIDNODE_SET_CHANGE) -//#endif { solidNodeIndices.insert(UbTupleInt3(ix1, ix2, ix3)); bcArray->setSolid(ix1,ix2,ix3); @@ -306,13 +295,11 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,con } else if( this->isInverseSolid() ) { - //bei inverse solid sind alle Knoten AUSSERHALB und auf der boundary SOLID + //in inverse solid all nodes are OUTSIDE and on the boundary SOLID if( !this->geoObject3D->isPointInGbObject3D(internX1, internX2, internX3, pointOnBoundary) || pointOnBoundary == true ) { -//#ifdef _OPENMP -// #pragma omp critical (SOLID_SET_CHANGE) -//#endif + { solidNodeIndices.insert(UbTupleInt3(ix1, ix2, ix3)); bcArray->setSolid(ix1,ix2,ix3); @@ -321,18 +308,11 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,con } } - //evtl wurde node von anderen interactoren solid gesetzt (muss hie rein->sonst evtl bei - //ueberschneidender geo -> solidNodeIndicesMap unvollstaendig) if(bcArray->isSolid(ix1,ix2,ix3)) continue; gotQs = false; - //TODO: prüfen was passiert wenn ein Geoobjekt zwischen zwei knoten rausguckt - // * / - //< - // * \ // - //sollen dann keine qs gesetzt werden for(int fdir=D3Q27System::FSTARTDIR; fdir<=D3Q27System::FENDDIR; fdir++) { q = geoObject3D->getIntersectionRaytraceFactor(internX1,internX2,internX3,rayX1[fdir],rayX2[fdir],rayX3[fdir]); @@ -348,22 +328,17 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,con bc = bcArray->getBC(ix1,ix2,ix3); if(!bc) { - //bc = bvd->createD3Q27BoundaryCondition(); //= new D3Q27BoundaryCondition(); bc = SPtr<BoundaryConditions>(new BoundaryConditions); bcArray->setBC(ix1,ix2,ix3,bc); } - //TODO: man muss ueberlegen, wie kann man, dass die Geschwindigkeit auf 0.0 gesetzt werden, vermeiden - //das folgt zu unguenstigen "design rules" - //SG 31.08.2010 das Problem - bewegter Interactor angrenzend an stehenden noslip interactor - // hier sollte die Geschwindigkeit auf 0.0 gesetzt werden + if(bc->hasNoSlipBoundary()) { bc->setBoundaryVelocityX1(0.0); bc->setBoundaryVelocityX2(0.0); bc->setBoundaryVelocityX3(0.0); } - //SG 31.08.2010 - + for(int index=(int)bcAdapters.size()-1; index>=0; --index) bcAdapters[index]->adaptBCForDirection(*this,bc,internX1,internX2,internX3,q,fdir, timestep); } @@ -374,9 +349,6 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,con if(gotQs) { -//#ifdef _OPENMP -// #pragma omp critical (TRANSNODE_SET_CHANGE) -//#endif { oneEntryGotBC = true; @@ -395,9 +367,6 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,con if( !this->geoObject3D->isPointInGbObject3D(internX1, internX2, internX3, pointOnBoundary) || pointOnBoundary == true ) { -//#ifdef _OPENMP -// #pragma omp critical (SOLID_SET_CHANGE) -//#endif { solidNodeIndices.insert(UbTupleInt3(ix1, ix2, ix3)); bcArray->setSolid(ix1,ix2,ix3); @@ -409,10 +378,9 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,con } } } - else //clipping -> langsamer (wird derzeit auch fuer alle inverseSolid objekte verwendet deren raytracing nicht fuer nodes INNERHALB der geo funzt) + else //clipping -> slower (currently also used for all inverse Solid objects whose raytracing does not work for nodes INSIDE the geo) { bool pointOnBoundary = false; - //#pragma omp parallel for private(internX1,internX2,internX3,gotQs,bc,pointOnBoundary ) for(int ix1=startIX1; ix1<stopIX1; ix1++) { for(int ix2=startIX2; ix2<stopIX2; ix2++) @@ -430,7 +398,6 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,con { if( this->isSolid() && this->geoObject3D->isPointInGbObject3D(internX1, internX2, internX3) ) { - //#pragma omp critical (SOLID_SET_CHANGE) { solidNodeIndices.insert(UbTupleInt3(ix1, ix2, ix3)); bcArray->setSolid(ix1,ix2,ix3); @@ -443,7 +410,6 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,con if( !this->geoObject3D->isPointInGbObject3D(internX1, internX2, internX3, pointOnBoundary) || pointOnBoundary == true ) { - //#pragma omp critical (SOLID_SET_CHANGE) { solidNodeIndices.insert(UbTupleInt3(ix1, ix2, ix3)); bcArray->setSolid(ix1,ix2,ix3); @@ -467,7 +433,7 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,con if(clippedLine) { double q=0.0; - if( !this->isInverseSolid() ) //A liegt auf jeden Fall aussen + if( !this->isInverseSolid() ) //A is outside { double distanceAB = pointA.getDistance(&pointB); //pointA to B double distanceAP = UbMath::min(pointA.getDistance(clippedLine->getPoint1()), @@ -480,7 +446,7 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,con if( !clippedLine->getPoint1()->equals(&pointB) && !clippedLine->getPoint2()->equals(&pointB) ) { - //A liegt auf jeden Fall drinnen, clipped line darf B nicht enthalten + //A is inside, a clipped line must not contain B double distanceAB = pointA.getDistance(&pointB); //pointA to B double distanceAP = clippedLine->getLength(); q = distanceAP/distanceAB; @@ -491,7 +457,7 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,con ,pointIsOnBoundary ) && pointIsOnBoundary ) { - //A liegt auf jeden Fall drinnen, B liegt genau auf ObjektBoundary => q=1.0 + //A is definitely inside, B is exactly on ObjectBoundary => q = 1.0 q=1.0; } else @@ -503,12 +469,10 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,con if(UbMath::inClosedInterval(q, 1.0, 1.0)) q = 1.0; if(UbMath::lessEqual(q, 1.0) && UbMath::greater(q, 0.0)) { - //#pragma omp critical (BC_CHANGE) { bc = bcArray->getBC(ix1,ix2,ix3); if(!bc) { - //bc = bvd->createD3Q27BoundaryCondition(); //= new D3Q27BoundaryCondition(); bc = SPtr<BoundaryConditions>(new BoundaryConditions); bcArray->setBC(ix1,ix2,ix3,bc); } @@ -527,7 +491,6 @@ bool D3Q27Interactor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,con if(gotQs) { - //#pragma omp critical (TRANSNODE_SET_CHANGE) { oneEntryGotBC = true; @@ -578,7 +541,7 @@ void D3Q27Interactor::addQsLineSet(std::vector<UbTupleFloat3 >& nodes, std::vect int ix2 = (*setPos)[1]; int ix3 = (*setPos)[2]; - if(bcArray->isFluid(ix1,ix2,ix3)) //es kann sein, dass der node von einem anderen interactor z.B. als solid gemarkt wurde!!! + if(bcArray->isFluid(ix1,ix2,ix3)) //it may be that the node is replaced by another interactor e.g. was marked as solid !!! { if( !bcArray->hasBC(ix1,ix2,ix3) ) continue; SPtr<BoundaryConditions> bc = bcArray->getBC(ix1,ix2,ix3); @@ -646,16 +609,14 @@ vector< pair<GbPoint3D,GbPoint3D> > D3Q27Interactor::getQsLineSet() int blocknx1 = val<1>(blocknx); int blocknx2 = val<2>(blocknx); int blocknx3 = val<3>(blocknx); - // vector<double> deltaT = grid->getD3Q27Calculator()->getDeltaT(); for(SPtr<Block3D> block : bcBlocks) { - SPtr<ILBMKernel> kernel = block->getKernel(); + SPtr<ILBMKernel> kernel = block->getKernel(); SPtr<BCArray3D> bcMatrix = kernel->getBCProcessor()->getBCArray(); UbTupleDouble3 nodeOffset = grid.lock()->getNodeOffset(block); - //double collFactor = ((LbD3Q27Calculator*)grid->getCalculator())->getCollisionsFactors()[block->getLevel()]; - //checken ob obere reihe doppelt im system vorhanden oder nicht + //Check whether top row is double in the system or not bool include_N_Face = false; //x1=[0..blocknx1[ && x3=[0..blocknx3[ bool include_E_Face = false; //x2=[0..blocknx2[ && x3=[0..blocknx3[ bool include_T_Face = false; //x1=[0..blocknx1[ && x2=[0..blocknx2[ @@ -672,8 +633,6 @@ vector< pair<GbPoint3D,GbPoint3D> > D3Q27Interactor::getQsLineSet() if( !block->getConnector(D3Q27System::TE) && include_T_Face && include_E_Face ) include_TE_Edge = true; } - // double dT = deltaT[block->getLevel()]; - map<SPtr<Block3D>, set< std::vector<int> > >::iterator pos = bcNodeIndicesMap.find(block); if(pos==bcNodeIndicesMap.end()) throw UbException(UB_EXARGS,"block nicht in indizes map!!!"+block->toString()); set< std::vector<int> >& transNodeIndicesSet = pos->second; @@ -682,23 +641,21 @@ vector< pair<GbPoint3D,GbPoint3D> > D3Q27Interactor::getQsLineSet() double x1,x2,x3,dx; grid.lock()->calcStartCoordinatesAndDelta(block,x1,x2,x3,dx); - //cout<<"getQs: "<<transBlockSet->size()<<" "<<transNodeIndicesVec.size()<<endl; - for(setPos=transNodeIndicesSet.begin(); setPos!=transNodeIndicesSet.end(); ++setPos) { int ix1 = (*setPos)[0]; int ix2 = (*setPos)[1]; int ix3 = (*setPos)[2]; - if( ( ix1<blocknx1 && ix2<blocknx2 && ix3<blocknx3 ) //std fall + if( ( ix1<blocknx1 && ix2<blocknx2 && ix3<blocknx3 ) || ( include_E_Face && ix1==blocknx1 && ix2<blocknx2 && ix3<blocknx3 ) || ( include_N_Face && ix2==blocknx2 && ix1<blocknx1 && ix3<blocknx3 ) || ( include_T_Face && ix3==blocknx3 && ix1<blocknx1 && ix2<blocknx2 ) || ( include_NE_Edge && ix1==blocknx1 && ix2==blocknx2 ) || ( include_TN_Edge && ix2==blocknx2 && ix3==blocknx3 ) - || ( include_TE_Edge && ix1==blocknx1 && ix3==blocknx3 ) ) //ansonsten doppelt im kraftwert + || ( include_TE_Edge && ix1==blocknx1 && ix3==blocknx3 ) ) { - if(bcMatrix->isFluid(ix1,ix2,ix3)) //es kann sein, dass der node von einem anderen interactor z.B. als solid gemarkt wurde!!! + if(bcMatrix->isFluid(ix1,ix2,ix3)) //it may be that the node is replaced by another interactor e.g. was marked as solid !!! { if( !bcMatrix->hasBC(ix1,ix2,ix3) ) continue; SPtr<BoundaryConditions> bc = bcMatrix->getBC(ix1,ix2,ix3); @@ -754,7 +711,6 @@ vector< pair<GbPoint3D,GbPoint3D> > D3Q27Interactor::getQsLineSet() } } } - //cout<<"getQs: "<<QsLineSet.size()<<endl; return QsLineSet; } diff --git a/src/cpu/VirtualFluidsCore/Interactors/D3Q27Interactor.h b/src/cpu/VirtualFluidsCore/Interactors/D3Q27Interactor.h index 796490116..3410a5a91 100644 --- a/src/cpu/VirtualFluidsCore/Interactors/D3Q27Interactor.h +++ b/src/cpu/VirtualFluidsCore/Interactors/D3Q27Interactor.h @@ -1,90 +1,115 @@ -// _ ___ __ __________ _ __ -// | | / (_)____/ /___ ______ _/ / ____/ /_ __(_)___/ /____ -// | | / / / ___/ __/ / / / __ `/ / /_ / / / / / / __ / ___/ -// | |/ / / / / /_/ /_/ / /_/ / / __/ / / /_/ / / /_/ (__ ) -// |___/_/_/ \__/\__,_/\__,_/_/_/ /_/\__,_/_/\__,_/____/ -// -#ifndef D3Q27INTERACTOR_H -#define D3Q27INTERACTOR_H - -#include <string> -#include <vector> -#include <map> -#include <set> -#include <PointerDefinitions.h> - -#include "UbException.h" -#include "UbTuple.h" -#include "GbPoint3D.h" -#include "Interactor3D.h" -#include "D3Q27System.h" - -class BCAdapter; -class Block3D; -class Grid3D; -class GbObject3D; - -typedef std::map<SPtr<Block3D>, std::set< std::vector<int> > > BcNodeIndicesMap; -typedef std::map<SPtr<Block3D>, std::set< UbTupleInt3 > > SolidNodeIndicesMap; - -class D3Q27Interactor : public Interactor3D -{ -public: - D3Q27Interactor(); - D3Q27Interactor(SPtr<GbObject3D> geoObject3D, SPtr<Grid3D> grid, int type); - D3Q27Interactor(SPtr<GbObject3D> geoObject3D, SPtr<Grid3D> grid, SPtr<BCAdapter> bcAdapter, int type); - D3Q27Interactor(SPtr<GbObject3D> geoObject3D, SPtr<Grid3D> grid, SPtr<BCAdapter> bcAdapter, int type, Interactor3D::Accuracy a); - - virtual ~D3Q27Interactor(); - - void setRelevantForForces(const bool& value) { this->relevantForForces = value; } - bool isRelevantForForces() { return this->relevantForForces; } - - virtual void addBCAdapter(const SPtr<BCAdapter> bcAdapter) { bcAdapters.push_back(bcAdapter); } - void deleteBCAdapter() { bcAdapters.clear(); } - - - virtual void initInteractor(const double& timeStep=0); - void updateInteractor(const double& timestep=0); - - void setReinitWithStoredQs(bool reinitWithStoredQsFlag) { this->reinitWithStoredQsFlag = reinitWithStoredQsFlag; } - - void removeSolidBlocks() { Interactor3D::removeSolidBlocks(); solidNodeIndicesMap.clear(); } - void removeBcBlocks() { Interactor3D::removeBcBlocks(); bcNodeIndicesMap.clear(); } - - bool setDifferencesToGbObject3D(const SPtr<Block3D> block/*, const double& x1, const double& x2, const double& x3, const double& blockLengthX1, const double& blockLengthX2, const double& blockLengthX3, const double& timestep=0*/); - - ObObject* clone() { throw UbException(UB_EXARGS,"not implemented"); } - ObObjectCreator* getCreator(); - - - void writeValidationAVSFile(std::string filename); - virtual std::vector< std::pair<GbPoint3D,GbPoint3D> > getQsLineSet(); - - void addQsLineSet(std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines); - - const BcNodeIndicesMap& getBcNodeIndicesMap() const { return bcNodeIndicesMap; } - -protected: - bool relevantForForces; - bool reinitWithStoredQsFlag; - - std::vector<SPtr<BCAdapter> > bcAdapters; - - - SolidNodeIndicesMap solidNodeIndicesMap; - BcNodeIndicesMap bcNodeIndicesMap; - //!!! es kann sein, dass in diesem interactor - //an eine rpos eine BC gesetzt wurde, aber derselbe node in - //in einem anderen in einen anderen Typ (z.B. Solid) geaendert - //wurde --> es ist keine BC mehr an der stelle! - - void initRayVectors(); - double rayX1[D3Q27System::FENDDIR+1]; - double rayX2[D3Q27System::FENDDIR+1]; - double rayX3[D3Q27System::FENDDIR+1]; - -}; - - -#endif +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file D3Q27Interactor.h +//! \ingroup Interactor +//! \author Sören Freudiger +//! \author Sebastian Geller +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef D3Q27INTERACTOR_H +#define D3Q27INTERACTOR_H + +#include <string> +#include <vector> +#include <map> +#include <set> +#include <PointerDefinitions.h> + +#include "UbException.h" +#include "UbTuple.h" +#include "GbPoint3D.h" +#include "Interactor3D.h" +#include "D3Q27System.h" + +class BCAdapter; +class Block3D; +class Grid3D; +class GbObject3D; + +typedef std::map<SPtr<Block3D>, std::set< std::vector<int> > > BcNodeIndicesMap; +typedef std::map<SPtr<Block3D>, std::set< UbTupleInt3 > > SolidNodeIndicesMap; + +//! \brief A specialized class for grid generation. +//! \details Support standard geometric primitives. +class D3Q27Interactor : public Interactor3D +{ +public: + D3Q27Interactor(); + D3Q27Interactor(SPtr<GbObject3D> geoObject3D, SPtr<Grid3D> grid, int type); + D3Q27Interactor(SPtr<GbObject3D> geoObject3D, SPtr<Grid3D> grid, SPtr<BCAdapter> bcAdapter, int type); + D3Q27Interactor(SPtr<GbObject3D> geoObject3D, SPtr<Grid3D> grid, SPtr<BCAdapter> bcAdapter, int type, Interactor3D::Accuracy a); + + virtual ~D3Q27Interactor(); + + void setRelevantForForces(const bool& value) { this->relevantForForces = value; } + bool isRelevantForForces() { return this->relevantForForces; } + + virtual void addBCAdapter(const SPtr<BCAdapter> bcAdapter) { bcAdapters.push_back(bcAdapter); } + void deleteBCAdapter() { bcAdapters.clear(); } + + + virtual void initInteractor(const double& timeStep=0); + void updateInteractor(const double& timestep=0); + + void setReinitWithStoredQs(bool reinitWithStoredQsFlag) { this->reinitWithStoredQsFlag = reinitWithStoredQsFlag; } + + void removeSolidBlocks() { Interactor3D::removeSolidBlocks(); solidNodeIndicesMap.clear(); } + void removeBcBlocks() { Interactor3D::removeBcBlocks(); bcNodeIndicesMap.clear(); } + + bool setDifferencesToGbObject3D(const SPtr<Block3D> block); + + ObObject* clone() { throw UbException(UB_EXARGS,"not implemented"); } + + + void writeValidationAVSFile(std::string filename); + virtual std::vector< std::pair<GbPoint3D,GbPoint3D> > getQsLineSet(); + + void addQsLineSet(std::vector<UbTupleFloat3 >& nodes, std::vector<UbTupleInt2 >& lines); + + const BcNodeIndicesMap& getBcNodeIndicesMap() const { return bcNodeIndicesMap; } + +protected: + bool relevantForForces; + bool reinitWithStoredQsFlag; + + std::vector<SPtr<BCAdapter> > bcAdapters; + + SolidNodeIndicesMap solidNodeIndicesMap; + BcNodeIndicesMap bcNodeIndicesMap; + + void initRayVectors(); + double rayX1[D3Q27System::FENDDIR+1]; + double rayX2[D3Q27System::FENDDIR+1]; + double rayX3[D3Q27System::FENDDIR+1]; + +}; + + +#endif diff --git a/src/cpu/VirtualFluidsCore/Interactors/D3Q27TriFaceMeshInteractor.cpp b/src/cpu/VirtualFluidsCore/Interactors/D3Q27TriFaceMeshInteractor.cpp deleted file mode 100644 index 3ec38f463..000000000 --- a/src/cpu/VirtualFluidsCore/Interactors/D3Q27TriFaceMeshInteractor.cpp +++ /dev/null @@ -1,1839 +0,0 @@ -#include "D3Q27TriFaceMeshInteractor.h" -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbLogger.h> -#include <basics/utilities/UbStaticPathMap.h> - -#include <basics/writer/WbWriterVtkBinary.h> -#include <basics/writer/WbWriterVtkXmlBinary.h> -#include <basics/writer/WbWriterVtkASCII.h> -#include "basics/writer/WbWriterVtkXmlASCII.h" - -#include <numerics/geometry3d/GbSystem3D.h> -#include <numerics/geometry3d/GbCuboid3D.h> -#include <numerics/geometry3d/GbHalfSpace3D.h> -#include <numerics/geometry3d/GbMeshTools3D.h> -#include "Block3D.h" -#include "Grid3D.h" -#include "BCArray3D.h" -#include "BoundaryConditions.h" -#include "VelocityBCAdapter.h" -#include "LBMKernel.h" -#include "BCProcessor.h" -#include "basics/utilities/UbTiming.h" - -#include <numerics/geometry3d/GbTriFaceMesh3D.h> - -//#include <omp.h> - -#include <stack> -#include "CoordinateTransformation3D.h" - -using namespace std; - -D3Q27TriFaceMeshInteractor::D3Q27TriFaceMeshInteractor() -: D3Q27Interactor(), forceshift(0.0), velocityshift(0.0), forceshiftpolicy(false), velocityshiftpolicy(false), useHalfSpace(true), regardPIOTest(true) -{ - this->stressMode = STRESSNORMAL; -} -////////////////////////////////////////////////////////////////////////// -D3Q27TriFaceMeshInteractor::D3Q27TriFaceMeshInteractor(SPtr<Grid3D> grid, std::string name) -{ - this->stressMode = STRESSNORMAL; -} -////////////////////////////////////////////////////////////////////////// -D3Q27TriFaceMeshInteractor::D3Q27TriFaceMeshInteractor(SPtr<GbTriFaceMesh3D> triFaceMesh, SPtr<Grid3D> grid, SPtr<BCAdapter> 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(SPtr<GbTriFaceMesh3D> triFaceMesh, SPtr<Grid3D> grid, SPtr<BCAdapter> 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; -} -////////////////////////////////////////////////////////////////////////// -D3Q27TriFaceMeshInteractor::~D3Q27TriFaceMeshInteractor() -{ - -} -////////////////////////////////////////////////////////////////////////// -void D3Q27TriFaceMeshInteractor::initInteractor(const double& timeStep) -{ - Interactor3D::initInteractor(timeStep); - setQs(timeStep); -} -////////////////////////////////////////////////////////////////////////// -bool D3Q27TriFaceMeshInteractor::setDifferencesToGbObject3D(const SPtr<Block3D> block/*,const double& orgX1,const double& orgX2,const double& orgX3,const double& blockLengthX1,const double& blockLengthX2,const double& blockLengthX3, const double& timestep*/) -{ - if(!block) return false; - - //UBLOG(logINFO, "D3Q27TriFaceMeshInteractor::setDifferencesToGbObject3D()"); - - bcNodeIndicesMap[block] = set< std::vector<int> >(); - set< std::vector<int> >& transNodeIndices = bcNodeIndicesMap[block]; - solidNodeIndicesMap[block] = set< UbTupleInt3 >(); - set< UbTupleInt3 >& solidNodeIndices = solidNodeIndicesMap[block]; - - - bool oneEntryGotBC = false; //ob ueberhaupt ein eintrag ein BC zugewiesen wurde - bool gotQs = false; //true, wenn "difference" gesetzt wurde - SPtr<BoundaryConditions> bc; - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - - double internX1,internX2,internX3; - - int startIX1 = 0, startIX2 = 0, startIX3 = 0; - int stopIX1 = (int)bcArray->getNX1(), stopIX2 = (int)bcArray->getNX2(), stopIX3 = (int)bcArray->getNX3(); - - double dx = grid.lock()->getDeltaX(block); - UbTupleDouble3 orgDelta = grid.lock()->getNodeOffset(block); - - bool pointOnBoundary = false; - - for(int ix3=startIX3; ix3<stopIX3; ix3++) - { - for(int ix2=startIX2; ix2<stopIX2; ix2++) - { - for(int ix1=startIX1; ix1<stopIX1; ix1++) - { - Vector3D coords = grid.lock()->getNodeCoordinates(block, ix1, ix2, ix3); - internX1 = coords[0]; - internX2 = coords[1]; - internX3 = coords[2]; - - if(this->isSolid() ) - { - if(this->geoObject3D->isPointInGbObject3D(internX1, internX2, internX3)) - { - if(bcArray->isFluid(ix1,ix2,ix3)) - { - solidNodeIndices.insert(UbTupleInt3(ix1, ix2, ix3)); - bcArray->setSolid(ix1,ix2,ix3); - } - } - } - else if( this->isInverseSolid() ) - { - //bei inverse solid sind alle Knoten AUSSERHALB und auf der boundary SOLID - if( !this->geoObject3D->isPointInGbObject3D(internX1, internX2, internX3, pointOnBoundary) || pointOnBoundary == true ) - { - if(bcArray->isFluid(ix1,ix2,ix3)) - { - solidNodeIndices.insert(UbTupleInt3(ix1, ix2, ix3)); - bcArray->setSolid(ix1,ix2,ix3); - } - } - } - } - } - } - - return oneEntryGotBC; -} -////////////////////////////////////////////////////////////////////////// -//E.F. /4/16/2013 -void D3Q27TriFaceMeshInteractor::setQs(const double& timeStep) -{ - UBLOGML(logDEBUG1,"\nLBMTriFaceMeshInteractor - setQs start "); - if( !this->grid.lock() ) throw UbException(UB_EXARGS,"ups, no grid.lock()!!"); - - if( this->reinitWithStoredQsFlag && !bcNodeIndicesAndQsMap.empty() ) - { - this->reinitWithStoredQs(timeStep); - return; - } - - GbTriFaceMesh3D* mesh = dynamic_cast<GbTriFaceMesh3D*>(this->geoObject3D.get()); - - ////////////////////////////////////////////////////////////////////////// - //init bcs - ////////////////////////////////////////////////////////////////////////// - int nofAdapter = (int)this->bcAdapters.size(); - if(nofAdapter==0) std::cout<<"WARNING - D3Q27TriFaceMeshInteractor::initInteractor Warning - no nodeAdapter available for "/*<<this->getName()*/<<std::endl; - bool needTimeDependence = false; - for(int pos=0; pos<nofAdapter; ++pos) - { - this->bcAdapters[pos]->init(this,timeStep); - if(this->bcAdapters[pos]->isTimeDependent()) needTimeDependence = true; - } - if(needTimeDependence) this->setTimeDependent(); - else this->unsetTimeDependent(); - - ////////////////////////////////////////////////////////////////////////// - //grid.lock() info - ////////////////////////////////////////////////////////////////////////// - int coarsestInitLevel = grid.lock()->getCoarsestInitializedLevel(); - int finestInitLevel = grid.lock()->getFinestInitializedLevel(); - - UbTupleInt3 blocknx = grid.lock()->getBlockNX(); - int blocknx1 = val<1>(blocknx); //gilt fuer alle Level - int blocknx2 = val<2>(blocknx); //gilt fuer alle Level - int blocknx3 = val<3>(blocknx); //gilt fuer alle Level - - //grobe Blocklaengen - SPtr<CoordinateTransformation3D> trafo = grid.lock()->getCoordinateTransformator(); - double cblockDeltaX1,cblockDeltaX2,cblockDeltaX3, delta ; - cblockDeltaX1 = cblockDeltaX2 = cblockDeltaX3 = delta = 1.0/(double)(1<<coarsestInitLevel); - if(trafo) - { - cblockDeltaX1 = trafo->getX1CoordinateScaling()*delta; - cblockDeltaX2 = trafo->getX2CoordinateScaling()*delta; - cblockDeltaX3 = trafo->getX3CoordinateScaling()*delta; - } - //levelspezifische blocklaengen und knotenabstaende - std::vector< std::vector<double> > nodeDeltaToNeigh(finestInitLevel+1); - std::vector<float> deltaMinX1(finestInitLevel+1),deltaMinX2(finestInitLevel+1),deltaMinX3(finestInitLevel+1); - std::vector<float> deltaMaxX1(finestInitLevel+1),deltaMaxX2(finestInitLevel+1),deltaMaxX3(finestInitLevel+1); - - //Im Boltzmankontext muss dx1==dx2==dx3 sein!! - assert( UbMath::equal(cblockDeltaX1/(double)blocknx1, cblockDeltaX2/(double)blocknx2 ) ); - assert( UbMath::equal(cblockDeltaX1/(double)blocknx1, cblockDeltaX3/(double)blocknx3 ) ); - - for(int level = coarsestInitLevel; level<=finestInitLevel; level++) - { - double nodeDeltaX1 = cblockDeltaX1/(double)(blocknx1*(1<<(level-coarsestInitLevel))); - double nodeDeltaX2 = cblockDeltaX2/(double)(blocknx2*(1<<(level-coarsestInitLevel))); - double nodeDeltaX3 = cblockDeltaX3/(double)(blocknx3*(1<<(level-coarsestInitLevel))); - - std::vector<double> distNeigh(D3Q27System::FENDDIR+1, 0.0); - D3Q27System::calcDistanceToNeighbors(distNeigh, nodeDeltaX1,nodeDeltaX2,nodeDeltaX3); - //D3Q27System::calcDistanceToNeighbors(distNeigh, nodeDeltaX1); - - - nodeDeltaToNeigh[level].resize(D3Q27System::ENDDIR+1,0.0); - for(int fdir=D3Q27System::FSTARTDIR; fdir<=D3Q27System::FENDDIR; fdir++) - { - nodeDeltaToNeigh[level][fdir] = distNeigh[fdir]; - } - - //im gegensatz zum allg. Cell3DInteractor kann man hier auf max(0.02*blockDeltaX1[level],fabs(...)) verzichten - //da dies nur für blockDeltaCalculator->getMinX1Delta(level)==0.0 benötigt wird. ist im D3Q19... aber nie so - //Geller: kann man nicht diesen befuckten DeltaCalculator weglassen und hier einfach die Formel zum Delta rechnen reinpacken - //SirAnn: klar, mann kann auch weißwuerste am Alex verkaufen... aber zum einen ist das Ding dazu da - // und zum anderen sollt eman mal überlegen: "Formel zum Delta rechnen"->man muss rechnen - // blockDeltaCalculator->getMinX1Delta(level) -> ein geinlinter wert wird geholt - - //TODO: set 5.0 as variable parameter in constructor, default 2.0 - deltaMinX1[level] = (float)( 5.0*nodeDeltaX1); //kein minus da unten -deltaMin - deltaMinX2[level] = (float)( 5.0*nodeDeltaX2); - deltaMinX3[level] = (float)( 5.0*nodeDeltaX3); - deltaMaxX1[level] = (float)( 5.0*nodeDeltaX1); - deltaMaxX2[level] = (float)( 5.0*nodeDeltaX2); - deltaMaxX3[level] = (float)( 5.0*nodeDeltaX3); - } - - ////////////////////////////////////////////////////////////////////////// - //bounding cubes des TriFaceMesh ermitteln (pro level) - ////////////////////////////////////////////////////////////////////////// - //min/max Werte des Dreiecksnetzes holen - double geoMinX1(0.0), geoMinX2(0.0), geoMinX3(0.0), geoMaxX1(0.0), geoMaxX2(0.0), geoMaxX3(0.0); - - geoMinX1 = this->geoObject3D->getX1Minimum(); geoMaxX1 = this->geoObject3D->getX1Maximum(); - geoMinX2 = this->geoObject3D->getX2Minimum(); geoMaxX2 = this->geoObject3D->getX2Maximum(); - geoMinX3 = this->geoObject3D->getX3Minimum(); geoMaxX3 = this->geoObject3D->getX3Maximum(); - - - ////////////////////////////////////////////////////////////////////////// - //DREIECKE: q-Bestimmung - ////////////////////////////////////////////////////////////////////////// - - //notwendige variablen initialisieren (u.a. blockDeltas des groben levels) - float triPoints[3][3]; - float vx1=0.0, vx2=0.0, vx3=0.0; - unsigned counterTriBoxOverlap=0, counterAABBTriFace=0, counterHalfspace=0, counterBilligOBB=0; - std::vector<GbTriFaceMesh3D::TriFace>& triangles = *mesh->getTriangles(); - std::vector<GbTriFaceMesh3D::Vertex>& nodes = *mesh->getNodes(); - std::map< SPtr<Block3D>, std::set< UbTupleInt3 > > tmpSolidNodesFromOtherInteractors; - - int onePercent = UbMath::integerRounding(triangles.size()*0.01); - if(onePercent==0) onePercent=1; - UbTimer setQTimer; setQTimer.start(); - UBLOG(logDEBUG3, " - setQs for "<<(int)triangles.size()<<" triangles"); - - bool solidFromOtherInteractor = false; - float blockMinX[3],blockMaxX[3],boxCenter[3],halfBoxSize[3]; - - for(size_t t=0; t<triangles.size(); t++) - { - ////////////////////////////////////////////////////////////////////////// - // Halfspace zum Dreieck generieren und min/max des Dreiecks ermitteln - ////////////////////////////////////////////////////////////////////////// - GbTriFaceMesh3D::TriFace& triangle = triangles[t]; - - GbTriFaceMesh3D::Vertex& v1 = nodes[triangle.v1]; - GbTriFaceMesh3D::Vertex& v2 = nodes[triangle.v2]; - GbTriFaceMesh3D::Vertex& v3 = nodes[triangle.v3]; - - if(this->isInverseSolid() ) - { - triangle.nx*=(-1); - triangle.ny*=(-1); - triangle.nz*=(-1); - } - GbHalfSpace3D halfSpace( v1.x,v1.y,v1.z,triangle.nx,triangle.ny,triangle.nz ); - - ////////////////////////////////////////////////////////////////////////// - //fuer GbMeshTools3D::triBoxOverlap - ////////////////////////////////////////////////////////////////////////// - triPoints[0][0] = v1.x; triPoints[0][1] = v1.y; triPoints[0][2] = v1.z; - triPoints[1][0] = v2.x; triPoints[1][1] = v2.y; triPoints[1][2] = v2.z; - triPoints[2][0] = v3.x; triPoints[2][1] = v3.y; triPoints[2][2] = v3.z; - - double minX1 = triangle.getMinX(nodes); double maxX1 = triangle.getMaxX(nodes); - double minX2 = triangle.getMinY(nodes); double maxX2 = triangle.getMaxY(nodes); - double minX3 = triangle.getMinZ(nodes); double maxX3 = triangle.getMaxZ(nodes); - - ////////////////////////////////////////////////////////////////////////// - // Schleife ueber alle Level - ////////////////////////////////////////////////////////////////////////// - double e1x1,e1x2,e1x3,e2x1,e2x2,e2x3,px1,px2,px3,a,f,sx1,sx2,sx3,u,qx1,qx2,qx3,v; - bool gotQs = false; - SPtr<BoundaryConditions> bc; - - for(int level=coarsestInitLevel; level<=finestInitLevel; level++) - { - ////////////////////////////////////////////////////////////////////////// - // levelspezifisches BoundCube des Dreicks ermitteln und zugehörige Bloecke beziehen - ////////////////////////////////////////////////////////////////////////// - double boundCubeTriangleMinX1 = minX1-deltaMinX1[level]; double boundCubeTriangleMaxX1 = maxX1+deltaMaxX1[level]; - double boundCubeTriangleMinX2 = minX2-deltaMinX2[level]; double boundCubeTriangleMaxX2 = maxX2+deltaMaxX2[level]; - double boundCubeTriangleMinX3 = minX3-deltaMinX3[level]; double boundCubeTriangleMaxX3 = maxX3+deltaMaxX3[level]; - - GbCuboid3D boundingCubeTriangle( boundCubeTriangleMinX1, boundCubeTriangleMinX2, boundCubeTriangleMinX3 - , boundCubeTriangleMaxX1, boundCubeTriangleMaxX2, boundCubeTriangleMaxX3 ); - - std::vector<SPtr<Block3D>> triBlocks; - grid.lock()->getBlocksByCuboid(level, boundCubeTriangleMinX1, boundCubeTriangleMinX2, boundCubeTriangleMinX3 - , boundCubeTriangleMaxX1, boundCubeTriangleMaxX2, boundCubeTriangleMaxX3, triBlocks ); - - ////////////////////////////////////////////////////////////////////////// - // Schleife ueber bloecke des level, die das dreieck beinhalten - ////////////////////////////////////////////////////////////////////////// - for(std::size_t b=0; b<triBlocks.size(); b++) - { - SPtr<Block3D> block = triBlocks[b]; - - //////////////////////////////////////////////////////////////////////////// - //// Block Dreieck-/test - //////////////////////////////////////////////////////////////////////////// - UbTupleDouble3 coords = grid.lock()->getBlockWorldCoordinates(block); - UbTupleDouble3 deltas = grid.lock()->getBlockLengths(block); - - blockMinX[0] = (float)(val<1>(coords)-deltaMinX1[level]); - blockMinX[1] = (float)(val<2>(coords)-deltaMinX2[level]); - blockMinX[2] = (float)(val<3>(coords)-deltaMinX3[level]); - - blockMaxX[0] = (float)(val<1>(coords)+val<1>(deltas)+deltaMaxX1[level]); - blockMaxX[1] = (float)(val<2>(coords)+val<2>(deltas)+deltaMaxX2[level]); - blockMaxX[2] = (float)(val<3>(coords)+val<3>(deltas)+deltaMaxX3[level]); - - boxCenter[0] = (float)(0.5*(blockMaxX[0]+blockMinX[0])); - boxCenter[1] = (float)(0.5*(blockMaxX[1]+blockMinX[1])); - boxCenter[2] = (float)(0.5*(blockMaxX[2]+blockMinX[2])); - - halfBoxSize[0] = (float)(0.5*(blockMaxX[0]-blockMinX[0])); - halfBoxSize[1] = (float)(0.5*(blockMaxX[1]-blockMinX[1])); - halfBoxSize[2] = (float)(0.5*(blockMaxX[2]-blockMinX[2])); - - //wenn dreieck "vergroesserten cube" nicht schneidet/beruehrt -> keine BC moeglich -> continue - if( !GbMeshTools3D::triBoxOverlap(boxCenter,halfBoxSize,triPoints) ) - { - counterTriBoxOverlap++; - continue; - } - - ////////////////////////////////////////////////////////////////////////// - //Untersuchung der einzelnen nodes - ////////////////////////////////////////////////////////////////////////// - bool blockGotBCs = false; - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcMatrix = kernel->getBCProcessor()->getBCArray(); - - int indexMinX1 = 0; - int indexMinX2 = 0; - int indexMinX3 = 0; - - int indexMaxX1 = (int)bcMatrix->getNX1(); - int indexMaxX2 = (int)bcMatrix->getNX2(); - int indexMaxX3 = (int)bcMatrix->getNX3(); - - std::set< std::vector<int> >& bcNodeIndices = this->bcNodeIndicesMap[block]; - std::set< UbTupleInt3 >& solidsFromOtherInteractors = tmpSolidNodesFromOtherInteractors[block]; - double q, distance; - - double& nodeDx1 = nodeDeltaToNeigh[level][D3Q27System::E]; - double& nodeDx2 = nodeDeltaToNeigh[level][D3Q27System::N]; - double& nodeDx3 = nodeDeltaToNeigh[level][D3Q27System::T]; - - //fuer OBB-Test - double qEinflussDelta = 1.1 * sqrt( nodeDx1*nodeDx1 + nodeDx2*nodeDx2 + nodeDx3*nodeDx3); - - for(int ix3=indexMinX3; ix3<indexMaxX3; ix3++) - { - for(int ix2=indexMinX2; ix2<indexMaxX2; ix2++) - { - for(int ix1=indexMinX1; ix1<indexMaxX1; ix1++) - { - Vector3D pointplane1 = grid.lock()->getNodeCoordinates(block, ix1,ix2,ix3); - double internX1 = pointplane1[0]; - double internX2 = pointplane1[1]; - double internX3 = pointplane1[2]; - - int blx1 = block->getX1(); - int blx2 = block->getX2(); - int blx3 = block->getX3(); - - if(bcMatrix->isSolid(ix1,ix2,ix3) || bcMatrix->isUndefined(ix1,ix2,ix3)) - { - continue; - } - - ////////////////////////////////////////////////////////////////////////// - //Punkt in AABB von Dreieck? - ////////////////////////////////////////////////////////////////////////// - //ehsan changed - bool pointIsOnBoundary = true; - if( !boundingCubeTriangle.isPointInGbObject3D(internX1, internX2, internX3,pointIsOnBoundary) ) - { - counterAABBTriFace++; - continue; - } - //std::cout<<"internX3 "<<internX3<<" internX2"<<internX2<<" internX1 "<<internX1<<"\n"; - ////////////////////////////////////////////////////////////////////////// - // Halbebenentests - ////////////////////////////////////////////////////////////////////////// - distance = halfSpace.getDistance( internX1, internX2, internX3 ); - //Punkt in Halbebene? (nein, wenn distance<0) - if(useHalfSpace && UbMath::less(distance, 0.0) )//== !halfSpace.ptInside(internX1,internX2,internX3) ) - { - counterHalfspace++; - continue; - } - - //BilligOBB-Test: wenn distance > qEinflussDelta -> kein q - if( UbMath::greater( fabs(distance), qEinflussDelta ) ) - { - counterBilligOBB++; - continue; - } - - ///////////////////////////////////////////////////////////////////////////// - //Raytracingfür diskrete Boltzmannrichtungen - ///////////////////////////////////////////////////////////////////////////// - gotQs = false; - bc = SPtr<BoundaryConditions>(); - - //RAYTRACING - diskrete LB-dir zu Dreick - //e1 = v1 - v0 - e1x1 = v2.x-v1.x; - e1x2 = v2.y-v1.y; - e1x3 = v2.z-v1.z; - - //e2 = v2 - v0 - e2x1 = v3.x-v1.x; - e2x2 = v3.y-v1.y; - e2x3 = v3.z-v1.z; - - //s = o - v0 - sx1 = internX1 - v1.x; - sx2 = internX2 - v1.y; - sx3 = internX3 - v1.z; - - for(int fdir=D3Q27System::FSTARTDIR; fdir<=D3Q27System::FENDDIR; fdir++) - { - //p = d x e2 - px1 = this->rayX2[fdir]*e2x3 - this->rayX3[fdir]*e2x2; - px2 = this->rayX3[fdir]*e2x1 - this->rayX1[fdir]*e2x3; - px3 = this->rayX1[fdir]*e2x2 - this->rayX2[fdir]*e2x1; - - //a = e1 dot p - a = e1x1*px1 + e1x2*px2 + e1x3*px3; - if(fabs(a)<1.E-10) continue; - f = 1.0/a; - - //u = f * ( s dot p) - u = f * ( sx1*px1 + sx2*px2 + sx3*px3 ); - if(u<-1.E-10 || u>1.0+1.E-10) continue; - - //q = s x e1 - qx1 = sx2*e1x3 - sx3*e1x2; - qx2 = sx3*e1x1 - sx1*e1x3; - qx3 = sx1*e1x2 - sx2*e1x1; - - //v = f*(e2 dot q) - v = f * (this->rayX1[fdir]*qx1 + this->rayX2[fdir]*qx2 + this->rayX3[fdir]*qx3); - if(v<-1.E-10 || (u+v)>1.0+1.E-10) continue; - - //t = f * (e2 dot q) - q = f * (e2x1*qx1 + e2x2*qx2 + e2x3*qx3); - q /= nodeDeltaToNeigh[level][fdir]; - /////ehsan q///////////////////////////////////////////////////////////////////// - double det=triangle.nx * this->rayX1[fdir]+ triangle.ny * this->rayX2[fdir]+ triangle.nz * this->rayX3[fdir]; - - if(det>-1.E-10) continue; - double d=triangle.nx*v1.x+triangle.ny*v1.y+triangle.nz*v1.z; - double x1= -((-d* this->rayX1[fdir] - triangle.ny *this->rayX2[fdir]* internX1 - triangle.nz *this->rayX3[fdir]* internX1 + triangle.ny *this->rayX1[fdir]* internX2 + triangle.nz* this->rayX1[fdir]* internX3))/det; - double y1= -((-d* this->rayX2[fdir] + triangle.nx* this->rayX2[fdir]* internX1 - triangle.nx* this->rayX1[fdir]* internX2 - triangle.nz* this->rayX3[fdir] *internX2 + triangle.nz* this->rayX2[fdir]* internX3))/det; - double z1= -((-d* this->rayX3[fdir] + triangle.nx* this->rayX3[fdir]* internX1 + triangle.ny* this->rayX3[fdir]* internX2 - triangle.nx* this->rayX1[fdir]* internX3 - triangle.ny* this->rayX2[fdir]* internX3))/det; - double q_ehsan=sqrt((x1-internX1)*(x1-internX1)+(y1-internX2)*(y1-internX2)+(z1-internX3)*(z1-internX3)); - q_ehsan /= nodeDeltaToNeigh[level][fdir]; - q=q_ehsan; - if( UbMath::greater(q, 1.0) || UbMath::lessEqual(q, 0.0) )continue; - - //gefundenes q auf gueltigkeit pruefen - if( UbMath::zero(q) ) - { - //neu (18.05.2010) - //es kann vorkommen, dass bei dünnwandigen geos punkte, die auf einem dreieck liegen, qs bekommen, die durch die geo - //durchgehen. diese punkte werden später jedoch nicht mehr auf solid getestet, da sie ja ne BC bekommen haben - //--> da mind ein q==0.0 für eines der dreiecke -> dort solid setzen - this->solidNodeIndicesMap[block].insert( UbTupleInt3(ix1,ix2,ix3) ); - bcMatrix->setSolid( ix1, ix2, ix3 ); - continue; - } - - if( UbMath::inClosedInterval(q, 1.0, 1.0) ) q = 1.0; - if( UbMath::greater(q, 0.0) && UbMath::lessEqual(q, 1.0) ) - { - gotQs=blockGotBCs=true; - - bc = bcMatrix->getBC(ix1,ix2,ix3); - - //SG 26.08.2010 if(!bc && !bcMatrix->isSolid()) - if(!bc) - { - bc = SPtr<BoundaryConditions>(new BoundaryConditions);; - bcMatrix->setBC(ix1,ix2,ix3,bc); - } - else if( UbMath::less( bc->getQ(fdir), q ) ) //schon ein kuerzeres q voehanden? - { - //neu:: 18.05.2010 - //um falsche qs die evtl durch die "wand" gehen zu vermeiden - //q nur dann neu setzen, wenn neues q kleiner als vorhandenes! - //Zudem: insbesondere an ecken mit zwei BC geos ist nur das - //naehere gueltig - continue; - } - - bc->setBoundaryVelocityX1(vx1); - bc->setBoundaryVelocityX2(vx2); - bc->setBoundaryVelocityX3(vx3); - - for(int index=(int)this->bcAdapters.size()-1; index>=0; --index) - this->bcAdapters[index]->adaptBCForDirection(*this,bc,internX1,internX2,internX3,q,fdir); - - //fuer beschleunigtes wiedereinlesen - if(this->reinitWithStoredQsFlag) - { - bcNodeIndicesAndQsMap[block][ UbTupleInt3(ix1, ix2, ix3) ].resize(D3Q27System::FENDDIR+1+3, -1.0f); - bcNodeIndicesAndQsMap[block][ UbTupleInt3(ix1, ix2, ix3) ][fdir ] = float(q); - bcNodeIndicesAndQsMap[block][ UbTupleInt3(ix1, ix2, ix3) ][D3Q27System::FENDDIR+1+0] = float(internX1); - bcNodeIndicesAndQsMap[block][ UbTupleInt3(ix1, ix2, ix3) ][D3Q27System::FENDDIR+1+1] = float(internX2); - bcNodeIndicesAndQsMap[block][ UbTupleInt3(ix1, ix2, ix3) ][D3Q27System::FENDDIR+1+2] = float(internX3); - } - } - } - - if(gotQs) - { - std::vector<int> p(3); - p[0]=ix1; p[1]=ix2; p[2]=ix3; - bcNodeIndices.insert(p); - - for(int index=(int)this->bcAdapters.size()-1; index>=0; --index) - this->bcAdapters[index]->adaptBC(*this,bc,internX1,internX2,internX3); - } - } - } - } - } - //dynamische Punkte des GbCuboids muessen leider per "Hand" geloescht werden :-( - boundingCubeTriangle.finalize(); - } - } - UBLOGML(logDEBUG1,"\nLBMTriFaceMeshInteractor - setQs end "); -} -////////////////////////////////////////////////////////////////////////// -//Vorgehesnweise -//A – Bestimmung der q's -// 1. fuer jeden Bounding cube eines Dreiecks des netzes werden die Bloecke des Blockgitter ermittelt -// 2. mittels eines Dreieck/Block Verschneidungstest werden weitere nicht relevante Bloecke aussortiert -// (fuer lange „schief“ im Raum stehende Dreicke, bei denen das Bounding Cube suboptimal ist) -// 3. jeder Knoten dieser blöcke wird gegen das bound cube des dreiecks getestet -// 4. Knoten die innerhalb des Cubes aber „innerhalb“ des Netzes liegen werden mittels Halbebenentest aussoriert -// 5. fuer die restliche Knoten erfolgt die q bestimmung mittels effizienter raytracing algorithmen -// fuer die diskreten Boltzmannrichtungen -//B – Setzen der nicht aktiven Bloecke und Solid Nodes -// alle Bloecke des Bounding Cube des Netzes, die mind eine BC erhielten, wurden in A markiert -// 1. fuer nicht markierte Bloecke genuegt EIN pointInObject(Dreicksnetz)-Test um den gesamten Block bei Erfolg als „not active“ zu markieren -// 2. fuer markiertre Bloecke wird ein rekursiver Fuellalgorithmus durchgefuehrt -void D3Q27TriFaceMeshInteractor::initInteractor2(const double& timeStep) -{ - UBLOGML(logDEBUG1,"\nLBMTriFaceMeshInteractor - initInteractor start "); - if( !this->grid.lock() ) throw UbException(UB_EXARGS,"ups, no grid.lock()!!"); - - if( this->reinitWithStoredQsFlag && !bcNodeIndicesAndQsMap.empty() ) - { - this->reinitWithStoredQs(timeStep); - return; - } - - GbTriFaceMesh3D* mesh = dynamic_cast<GbTriFaceMesh3D*>(this->geoObject3D.get()); - - UBLOGML(logDEBUG1,"\nLBMTriFaceMeshInteractor - initInteractor for \""<<mesh->getName()<<" \" t="<<timeStep); - //cout<<" - init basics ..."; - - this->removeBcBlocks(); //hier wird auch die nodeIndicesMap geloescht! - this->removeSolidBlocks(); - - ////////////////////////////////////////////////////////////////////////// - //init bcs - ////////////////////////////////////////////////////////////////////////// - int nofAdapter = (int)this->bcAdapters.size(); - if(nofAdapter==0) std::cout<<"WARNING - D3Q27TriFaceMeshInteractor::initInteractor Warning - no nodeAdapter available for "/*<<this->getName()*/<<std::endl; - bool needTimeDependence = false; - for(int pos=0; pos<nofAdapter; ++pos) - { - this->bcAdapters[pos]->init(this,timeStep); - if(this->bcAdapters[pos]->isTimeDependent()) needTimeDependence = true; - } - if(needTimeDependence) this->setTimeDependent(); - else this->unsetTimeDependent(); - - ////////////////////////////////////////////////////////////////////////// - //grid.lock() info - ////////////////////////////////////////////////////////////////////////// - int coarsestInitLevel = grid.lock()->getCoarsestInitializedLevel(); - int finestInitLevel = grid.lock()->getFinestInitializedLevel(); - - UbTupleInt3 blocknx = grid.lock()->getBlockNX(); - int blocknx1 = val<1>(blocknx); //gilt fuer alle Level - int blocknx2 = val<2>(blocknx); //gilt fuer alle Level - int blocknx3 = val<3>(blocknx); //gilt fuer alle Level - - //grobe Blocklaengen - SPtr<CoordinateTransformation3D> trafo = grid.lock()->getCoordinateTransformator(); - double cblockDeltaX1,cblockDeltaX2,cblockDeltaX3, delta ; - cblockDeltaX1 = cblockDeltaX2 = cblockDeltaX3 = delta = 1.0/(double)(1<<coarsestInitLevel); - if(trafo) - { - cblockDeltaX1 = trafo->getX1CoordinateScaling()*delta; - cblockDeltaX2 = trafo->getX2CoordinateScaling()*delta; - cblockDeltaX3 = trafo->getX3CoordinateScaling()*delta; - } - //levelspezifische blocklaengen und knotenabstaende - std::vector< std::vector<double> > nodeDeltaToNeigh(finestInitLevel+1); - //vector<double> blockDeltaX1(finestInitLevel+1), blockDeltaX2(finestInitLevel+1), blockDeltaX3(finestInitLevel+1); - std::vector<float> deltaMinX1(finestInitLevel+1),deltaMinX2(finestInitLevel+1),deltaMinX3(finestInitLevel+1); - std::vector<float> deltaMaxX1(finestInitLevel+1),deltaMaxX2(finestInitLevel+1),deltaMaxX3(finestInitLevel+1); - - //Im Boltzmankontext muss dx1==dx2==dx3 sein!! - assert( UbMath::equal(cblockDeltaX1/(double)blocknx1, cblockDeltaX2/(double)blocknx2 ) ); - assert( UbMath::equal(cblockDeltaX1/(double)blocknx1, cblockDeltaX3/(double)blocknx3 ) ); - - for(int level = coarsestInitLevel; level<=finestInitLevel; level++) - { - double nodeDelta = cblockDeltaX1/(double)(blocknx1*(1<<(level-coarsestInitLevel))); - - std::vector<double> distNeigh(D3Q27System::FENDDIR+1, 0.0); - D3Q27System::calcDistanceToNeighbors(distNeigh, nodeDelta); - - nodeDeltaToNeigh[level].resize(D3Q27System::ENDDIR+1,0.0); - for(int fdir=D3Q27System::FSTARTDIR; fdir<=D3Q27System::FENDDIR; fdir++) - { - nodeDeltaToNeigh[level][fdir] = distNeigh[fdir]; - } - - //im gegensatz zum allg. Cell3DInteractor kann man hier auf max(0.02*blockDeltaX1[level],fabs(...)) verzichten - //da dies nur für blockDeltaCalculator->getMinX1Delta(level)==0.0 benötigt wird. ist im D3Q19... aber nie so - //Geller: kann man nicht diesen befuckten DeltaCalculator weglassen und hier einfach die Formel zum Delta rechnen reinpacken - //SirAnn: klar, mann kann auch weißwuerste am Alex verkaufen... aber zum einen ist das Ding dazu da - // und zum anderen sollt eman mal überlegen: "Formel zum Delta rechnen"->man muss rechnen - // blockDeltaCalculator->getMinX1Delta(level) -> ein geinlinter wert wird geholt - - deltaMinX1[level] = (float)( 1.2*nodeDelta); //kein minus da unten -deltaMin - deltaMinX2[level] = (float)( 1.2*nodeDelta); - deltaMinX3[level] = (float)( 1.2*nodeDelta); - deltaMaxX1[level] = (float)( 1.2*nodeDelta); - deltaMaxX2[level] = (float)( 1.2*nodeDelta); - deltaMaxX3[level] = (float)( 1.2*nodeDelta); - } - - ////////////////////////////////////////////////////////////////////////// - //bounding cubes des TriFaceMesh ermitteln (pro level) - ////////////////////////////////////////////////////////////////////////// - //min/max Werte des Dreiecksnetzes holen - double geoMinX1(0.0), geoMinX2(0.0), geoMinX3(0.0), geoMaxX1(0.0), geoMaxX2(0.0), geoMaxX3(0.0); - if(this->isSolid() || this->isMoveable()) - { - geoMinX1 = this->geoObject3D->getX1Minimum(); geoMaxX1 = this->geoObject3D->getX1Maximum(); - geoMinX2 = this->geoObject3D->getX2Minimum(); geoMaxX2 = this->geoObject3D->getX2Maximum(); - geoMinX3 = this->geoObject3D->getX3Minimum(); geoMaxX3 = this->geoObject3D->getX3Maximum(); - } - else throw UbException(UB_EXARGS,"only TYPE==SOLID is implemented" ); - - std::map<SPtr<Block3D>,SolidCheckMethod> blocksForSolidCheck; - - for(int level = coarsestInitLevel; level<=finestInitLevel; level++) - { - if(this->isSolid() || this->isMoveable()) - { - //bloecke fuer "bounding cube gesamt" - std::vector<SPtr<Block3D>> tmpblocks; - grid.lock()->getBlocksByCuboid(level,geoMinX1-deltaMinX1[level], geoMinX2-deltaMinX2[level], geoMinX3-deltaMinX3[level], - geoMaxX1+deltaMaxX1[level], geoMaxX2+deltaMaxX2[level], geoMaxX3+deltaMaxX3[level],tmpblocks ); - - for( size_t i=0; i<tmpblocks.size(); i++ ) - blocksForSolidCheck[tmpblocks[i]] = PointInObject; - } - } - - ////////////////////////////////////////////////////////////////////////// - //FE-specific - ////////////////////////////////////////////////////////////////////////// - //bool calcVelocities = false; - //FeTriFaceMesh3D* feMesh = dynamic_cast<FeTriFaceMesh3D*>(mesh); - //std::vector<FeTriFaceMesh3D::VertexAttributes>* attributes = NULL; - //if(feMesh) - //{ - // calcVelocities = true; - // attributes = feMesh->getAttributes(); - //} - - ////////////////////////////////////////////////////////////////////////// - //DREIECKE: q-Bestimmung - ////////////////////////////////////////////////////////////////////////// - - //notwendige variablen initialisieren (u.a. blockDeltas des groben levels) - float triPoints[3][3]; - float vx1=0.0, vx2=0.0, vx3=0.0; - unsigned counterTriBoxOverlap=0, counterAABBTriFace=0, counterHalfspace=0, counterBilligOBB=0; - std::vector<GbTriFaceMesh3D::TriFace>& triangles = *mesh->getTriangles(); - std::vector<GbTriFaceMesh3D::Vertex>& nodes = *mesh->getNodes(); - std::map< SPtr<Block3D>, std::set< std::vector<int> > > tmpSolidNodesFromOtherInteractors; - - int onePercent = UbMath::integerRounding(triangles.size()*0.01); - if(onePercent==0) onePercent=1; - UbTimer setQTimer; setQTimer.start(); - UBLOG(logDEBUG3, " - setQs for "<<(int)triangles.size()<<" triangles"); - - bool solidFromOtherInteractor = false; - float blockMinX[3],blockMaxX[3],boxCenter[3],halfBoxSize[3]; - - for(size_t t=0; t<triangles.size(); t++) - { - //if (t==10577) - //{ - // int ehsan=0; - //} - ////////////////////////////////////////////////////////////////////////// - // Halfspace zum Dreieck generieren und min/max des Dreiecks ermitteln - ////////////////////////////////////////////////////////////////////////// - GbTriFaceMesh3D::TriFace& triangle = triangles[t]; - - GbTriFaceMesh3D::Vertex& v1 = nodes[triangle.v1]; - GbTriFaceMesh3D::Vertex& v2 = nodes[triangle.v2]; - GbTriFaceMesh3D::Vertex& v3 = nodes[triangle.v3]; - - GbHalfSpace3D halfSpace( v1.x,v1.y,v1.z,v2.x,v2.y,v2.z,v3.x,v3.y,v3.z ); - - //if(calcVelocities) - //{ - // FeTriFaceMesh3D::VertexAttributes& vAttribut1 = (*attributes)[triangle.v1]; - // FeTriFaceMesh3D::VertexAttributes& vAttribut2 = (*attributes)[triangle.v2]; - // FeTriFaceMesh3D::VertexAttributes& vAttribut3 = (*attributes)[triangle.v3]; - // vx1 = (float)(UbMath::c1o3*(vAttribut1.getVelocityX()+vAttribut2.getVelocityX()+vAttribut3.getVelocityX())); - // vx2 = (float)(UbMath::c1o3*(vAttribut1.getVelocityY()+vAttribut2.getVelocityY()+vAttribut3.getVelocityY())); - // vx3 = (float)(UbMath::c1o3*(vAttribut1.getVelocityZ()+vAttribut2.getVelocityZ()+vAttribut3.getVelocityZ())); - //} - - ////////////////////////////////////////////////////////////////////////// - //fuer GbMeshTools3D::triBoxOverlap - ////////////////////////////////////////////////////////////////////////// - triPoints[0][0] = v1.x; triPoints[0][1] = v1.y; triPoints[0][2] = v1.z; - triPoints[1][0] = v2.x; triPoints[1][1] = v2.y; triPoints[1][2] = v2.z; - triPoints[2][0] = v3.x; triPoints[2][1] = v3.y; triPoints[2][2] = v3.z; - - double minX1 = triangle.getMinX(nodes); double maxX1 = triangle.getMaxX(nodes); - double minX2 = triangle.getMinY(nodes); double maxX2 = triangle.getMaxY(nodes); - double minX3 = triangle.getMinZ(nodes); double maxX3 = triangle.getMaxZ(nodes); - - ////////////////////////////////////////////////////////////////////////// - // Schleife ueber alle Level - ////////////////////////////////////////////////////////////////////////// - double e1x1,e1x2,e1x3,e2x1,e2x2,e2x3,px1,px2,px3,a,f,sx1,sx2,sx3,u,qx1,qx2,qx3,v; - bool gotQs = false; - SPtr<BoundaryConditions> bc; - - for(int level=coarsestInitLevel; level<=finestInitLevel; level++) - { - ////////////////////////////////////////////////////////////////////////// - // levelspezifisches BoundCube des Dreicks ermitteln und zugehörige Bloecke beziehen - ////////////////////////////////////////////////////////////////////////// - double boundCubeTriangleMinX1 = minX1-deltaMinX1[level]; double boundCubeTriangleMaxX1 = maxX1+deltaMaxX1[level]; - double boundCubeTriangleMinX2 = minX2-deltaMinX2[level]; double boundCubeTriangleMaxX2 = maxX2+deltaMaxX2[level]; - double boundCubeTriangleMinX3 = minX3-deltaMinX3[level]; double boundCubeTriangleMaxX3 = maxX3+deltaMaxX3[level]; - - GbCuboid3D boundingCubeTriangle( boundCubeTriangleMinX1, boundCubeTriangleMinX2, boundCubeTriangleMinX3 - , boundCubeTriangleMaxX1, boundCubeTriangleMaxX2, boundCubeTriangleMaxX3 ); - - std::vector<SPtr<Block3D>> triBlocks; - grid.lock()->getBlocksByCuboid(level, boundCubeTriangleMinX1, boundCubeTriangleMinX2, boundCubeTriangleMinX3 - , boundCubeTriangleMaxX1, boundCubeTriangleMaxX2, boundCubeTriangleMaxX3, triBlocks ); - - ////////////////////////////////////////////////////////////////////////// - // Schleife ueber bloecke des level, die das dreieck beinhalten - ////////////////////////////////////////////////////////////////////////// - for(std::size_t b=0; b<triBlocks.size(); b++) - { - SPtr<Block3D> block = triBlocks[b]; - - //////////////////////////////////////////////////////////////////////////// - //// Block Dreieck-/test - //////////////////////////////////////////////////////////////////////////// - UbTupleDouble3 coords = grid.lock()->getBlockWorldCoordinates(block); - UbTupleDouble3 deltas = grid.lock()->getBlockLengths(block); - - blockMinX[0] = (float)(val<1>(coords)-deltaMinX1[level]); - blockMinX[1] = (float)(val<2>(coords)-deltaMinX2[level]); - blockMinX[2] = (float)(val<3>(coords)-deltaMinX3[level]); - - blockMaxX[0] = (float)(val<1>(coords)+val<1>(deltas)+deltaMaxX1[level]); - blockMaxX[1] = (float)(val<2>(coords)+val<2>(deltas)+deltaMaxX2[level]); - blockMaxX[2] = (float)(val<3>(coords)+val<3>(deltas)+deltaMaxX3[level]); - - boxCenter[0] = (float)(0.5*(blockMaxX[0]+blockMinX[0])); - boxCenter[1] = (float)(0.5*(blockMaxX[1]+blockMinX[1])); - boxCenter[2] = (float)(0.5*(blockMaxX[2]+blockMinX[2])); - - halfBoxSize[0] = (float)(0.5*(blockMaxX[0]-blockMinX[0])); - halfBoxSize[1] = (float)(0.5*(blockMaxX[1]-blockMinX[1])); - halfBoxSize[2] = (float)(0.5*(blockMaxX[2]-blockMinX[2])); - - //wenn dreieck "vergroesserten cube" nicht schneidet/beruehrt -> keine BC moeglich -> continue - if( !GbMeshTools3D::triBoxOverlap(boxCenter,halfBoxSize,triPoints) ) - { - counterTriBoxOverlap++; - continue; - } - - ////////////////////////////////////////////////////////////////////////// - //Untersuchung der einzelnen nodes - ////////////////////////////////////////////////////////////////////////// - bool blockGotBCs = false; - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcMatrix = kernel->getBCProcessor()->getBCArray(); - - int indexMinX1 = 0; - int indexMinX2 = 0; - int indexMinX3 = 0; - - int indexMaxX1 = (int)bcMatrix->getNX1(); - int indexMaxX2 = (int)bcMatrix->getNX2(); - int indexMaxX3 = (int)bcMatrix->getNX3(); - - std::set< std::vector<int> >& bcNodeIndices = this->bcNodeIndicesMap[block]; - std::set< std::vector<int> >& solidsFromOtherInteractors = tmpSolidNodesFromOtherInteractors[block]; - double q, internX1, internX2, internX3,distance; - - double& nodeDx1 = nodeDeltaToNeigh[level][D3Q27System::E]; - double& nodeDx2 = nodeDeltaToNeigh[level][D3Q27System::N]; - double& nodeDx3 = nodeDeltaToNeigh[level][D3Q27System::T]; - - //fuer OBB-Test - double qEinflussDelta = 1.1 * sqrt( nodeDx1*nodeDx1 + nodeDx2*nodeDx2 + nodeDx3*nodeDx3); - - for(int ix3=indexMinX3; ix3<indexMaxX3; ix3++) - { - internX3 = val<3>(coords)+nodeDx3*ix3-0.5*nodeDx3; - for(int ix2=indexMinX2; ix2<indexMaxX2; ix2++) - { - internX2 = val<2>(coords)+nodeDx2*ix2-0.5*nodeDx2; - for(int ix1=indexMinX1; ix1<indexMaxX1; ix1++) - { - - int blx1 =block->getX1(); - int blx2 = block->getX2(); - int blx3 = block->getX3(); - - if (blx1==0&&blx2==1&&blx3==0) - { - //if (ix2==39&&ix3==4) - if (ix2==39&&ix3==4) - { - int seb=0; - } - - } - //Problem: wenn voher der punkt durch eine andere geo not active gesetzt wird und - //dieser nun uebersprungen wird, dann hat man spaeter beim fuellalgorithmus luecken - //in der front und der block wird u.U. faelschlicher weise komplett solid markiert - //Lsg: positionen merken und erst Nach dem fuellarlgo wieder auf not active setzen :-) - solidFromOtherInteractor = false; - if(bcMatrix->isSolid(ix1,ix2,ix3)) - { - if(this->reinitWithStoredQsFlag) - { - solidFromOtherInteractor = true; //hier muss man weitermachen - //SG //oje - std::vector<int> p(3); - p[0]=ix1; p[1]=ix2; p[2]=ix3; - solidsFromOtherInteractors.insert( p ); - } - else - { - //SG //oje - std::vector<int> p(3); - p[0]=ix1; p[1]=ix2; p[2]=ix3; - solidsFromOtherInteractors.insert(p); - //SG continue; - solidFromOtherInteractor = true; - } - } - - internX1 = val<1>(coords)+nodeDx1*ix1-0.5*nodeDx1; - - ////////////////////////////////////////////////////////////////////////// - //Punkt in AABB von Dreieck? - ////////////////////////////////////////////////////////////////////////// - //ehsan changedâ—˜ - bool pointIsOnBoundary = false; - if( !boundingCubeTriangle.isPointInGbObject3D(internX1, internX2, internX3,pointIsOnBoundary) ) - // if( !boundingCubeTriangle.isPointInGbObject3D(internX1, internX2, internX3) ) - { - counterAABBTriFace++; - continue; - } - - ////////////////////////////////////////////////////////////////////////// - // Halbebenentests - ////////////////////////////////////////////////////////////////////////// - distance = halfSpace.getDistance( internX1, internX2, internX3 ); - - //Punkt in Halbebene? (nein, wenn distance<0) - if(useHalfSpace && UbMath::less(distance, 0.0) )//== !halfSpace.ptInside(internX1,internX2,internX3) ) - { - counterHalfspace++; - continue; - } - - //BilligOBB-Test: wenn distance > qEinflussDelta -> kein q - if( UbMath::greater( fabs(distance), qEinflussDelta ) ) - { - counterBilligOBB++; - continue; - } - - ///////////////////////////////////////////////////////////////////////////// - //Raytracingfür diskrete Boltzmannrichtungen - ///////////////////////////////////////////////////////////////////////////// - gotQs = false; - bc = SPtr<BoundaryConditions>(); - - //RAYTRACING - diskrete LB-dir zu Dreick - //e1 = v1 - v0 - e1x1 = v2.x-v1.x; - e1x2 = v2.y-v1.y; - e1x3 = v2.z-v1.z; - - //e2 = v2 - v0 - e2x1 = v3.x-v1.x; - e2x2 = v3.y-v1.y; - e2x3 = v3.z-v1.z; - - //s = o - v0 - sx1 = internX1 - v1.x; - sx2 = internX2 - v1.y; - sx3 = internX3 - v1.z; - - for(int fdir=D3Q27System::FSTARTDIR; fdir<=D3Q27System::FENDDIR; fdir++) - { - //p = d x e2 - px1 = this->rayX2[fdir]*e2x3 - this->rayX3[fdir]*e2x2; - px2 = this->rayX3[fdir]*e2x1 - this->rayX1[fdir]*e2x3; - px3 = this->rayX1[fdir]*e2x2 - this->rayX2[fdir]*e2x1; - - //a = e1 dot p - a = e1x1*px1 + e1x2*px2 + e1x3*px3; - if(fabs(a)<1.E-10) continue; - f = 1.0/a; - - //u = f * ( s dot p) - u = f * ( sx1*px1 + sx2*px2 + sx3*px3 ); - if(u<-1.E-10 || u>1.0+1.E-10) continue; - - //q = s x e1 - qx1 = sx2*e1x3 - sx3*e1x2; - qx2 = sx3*e1x1 - sx1*e1x3; - qx3 = sx1*e1x2 - sx2*e1x1; - - //v = f*(e2 dot q) - v = f * (this->rayX1[fdir]*qx1 + this->rayX2[fdir]*qx2 + this->rayX3[fdir]*qx3); - if(v<-1.E-10 || (u+v)>1.0+1.E-10) continue; - - //t = f * (e2 dot q) - q = f * (e2x1*qx1 + e2x2*qx2 + e2x3*qx3); - q /= nodeDeltaToNeigh[level][fdir]; - - //gefundenes q auf gueltigkeit pruefen - if( UbMath::zero(q) ) - { - //neu (18.05.2010) - //es kann vorkommen, dass bei dünnwandigen geos punkte, die auf einem dreieck liegen, qs bekommen, die durch die geo - //durchgehen. diese punkte werden später jedoch nicht mehr auf solid getestet, da sie ja ne BC bekommen haben - //--> da mind ein q==0.0 für eines der dreiecke -> dort solid setzen - this->solidNodeIndicesMap[block].insert( UbTupleInt3(ix1,ix2,ix3) ); - bcMatrix->setSolid( ix1, ix2, ix3 ); - continue; - } - - if( UbMath::inClosedInterval(q, 1.0, 1.0) ) q = 1.0; - if( UbMath::greater(q, 0.0) && UbMath::lessEqual(q, 1.0) ) - { - //if( !solidFromOtherInteractor ) //--> Knoten schon solid-->BC setzen ueberfluessig - //SG changed to - //if( solidFromOtherInteractor ) //--> Knoten schon solid-->BC setzen ueberfluessig - { - //SG 26.08.2010 muss bereits hierhin, da das continue sonst den Knoten nicht als transNode fürs - //markiert - gotQs=blockGotBCs=true; - - bc = bcMatrix->getBC(ix1,ix2,ix3); - - //SG 26.08.2010 if(!bc && !bcMatrix->isSolid()) - if(!bc) - { - bc = SPtr<BoundaryConditions>(new BoundaryConditions);; - bcMatrix->setBC(ix1,ix2,ix3,bc); - } - else if( UbMath::less( bc->getQ(fdir), q ) ) //schon ein kuerzeres q voehanden? - { - //neu:: 18.05.2010 - //um falsche qs die evtl durch die "wand" gehen zu vermeiden - //q nur dann neu setzen, wenn neues q kleiner als vorhandenes! - //Zudem: insbesondere an ecken mit zwei BC geos ist nur das - //naehere gueltig - continue; - } - - bc->setBoundaryVelocityX1(vx1); - bc->setBoundaryVelocityX2(vx2); - bc->setBoundaryVelocityX3(vx3); - - for(int index=(int)this->bcAdapters.size()-1; index>=0; --index) - this->bcAdapters[index]->adaptBCForDirection(*this,bc,internX1,internX2,internX3,q,fdir); - - //SG 26.08.2010 gotQs=blockGotBCs=true; - } - //fuer beschleunigtes wiedereinlesen - if(this->reinitWithStoredQsFlag) - { - bcNodeIndicesAndQsMap[block][ UbTupleInt3(ix1, ix2, ix3) ].resize(D3Q27System::FENDDIR+1+3, -1.0f); - bcNodeIndicesAndQsMap[block][ UbTupleInt3(ix1, ix2, ix3) ][fdir ] = float(q); - bcNodeIndicesAndQsMap[block][ UbTupleInt3(ix1, ix2, ix3) ][D3Q27System::FENDDIR+1+0] = float(internX1); - bcNodeIndicesAndQsMap[block][ UbTupleInt3(ix1, ix2, ix3) ][D3Q27System::FENDDIR+1+1] = float(internX2); - bcNodeIndicesAndQsMap[block][ UbTupleInt3(ix1, ix2, ix3) ][D3Q27System::FENDDIR+1+2] = float(internX3); - } - } - } - - if(gotQs) - { - std::vector<int> p(3); - p[0]=ix1; p[1]=ix2; p[2]=ix3; - bcNodeIndices.insert(p); - - for(int index=(int)this->bcAdapters.size()-1; index>=0; --index) - this->bcAdapters[index]->adaptBC(*this,bc,internX1,internX2,internX3); - } - } - } - } - //Block wird für scanline-check "anmelden", dieser wird dann spaeter zu "transBlocks" hinzugefuegt - if(blockGotBCs) - { - blocksForSolidCheck[block] = ScanLine; - } - // bvd->getTimer().stop(); - } - //dynamische Punkte des GbCuboids muessen leider per "Hand" geloescht werden :-( - boundingCubeTriangle.finalize(); - } - } - setQTimer.stop(); - - UBLOG(logDEBUG1," - setQs for "/*<< this->getName()*/ << " - " <<(int)triangles.size()<<" triangles: 100% done in "<<setQTimer.getTotalTime()<<"sec"); - UBLOG(logDEBUG1," * rejected blocks with tribox overlap test : " << counterTriBoxOverlap); - UBLOG(logDEBUG1," * rejected nodes with AABB test : " << counterAABBTriFace); - UBLOG(logDEBUG1," * rejected nodes with halfspace test : " << counterHalfspace); - UBLOG(logDEBUG1," * rejected nodes with OBB test : " << counterBilligOBB); - - typedef std::map<SPtr<Block3D>,SolidCheckMethod>::iterator BlockSolidCheckMethodIterator; - - ////////////////////////////////////////////////////////////////////////// - // SOLID checks - ////////////////////////////////////////////////////////////////////////// - if( regardPIOTest ) - { - int pointInObjectCounter = 0; - int scanlineCounter = 0; - int counter = 0; - - //sollte die matrix groesse zu gross sein und der rekursive floodFill mehr speicher - //benoetigen als der Stack hergibt -> keinen floodFill verwenden! - void (D3Q27TriFaceMeshInteractor::*gridFill)(CbArray3D<FLAGS>&, const short&, const short&, const short&, const FLAGS&) = NULL; - /*if(blocknx1*blocknx2*blocknx3 < 200000 ) gridFill = &D3Q27TriFaceMeshInteractor::recursiveGridFill;*/ - /*else */ gridFill = &D3Q27TriFaceMeshInteractor::iterativeGridFill; - - UBLOG(logDEBUG1," - setSolids for "<< blocksForSolidCheck.size() << " blocks"); - - UbTimer scanLineTimer; - UbTimer solidTimer; - solidTimer.start(); - - for(BlockSolidCheckMethodIterator pos=blocksForSolidCheck.begin(); pos!=blocksForSolidCheck.end(); ++pos) - { - SPtr<Block3D> const& block = pos->first; - int level = block->getLevel(); - - UbTupleDouble3 coords = grid.lock()->getBlockWorldCoordinates(block); - - //Bloecke, die keinerlei Verschneidung mit Dreicken bzw. deren BoundCubes hatten - //hier: durch inside/outside Tests EINES knotens gilt fuer ALLE Knoten des blockes - if( pos->second == PointInObject ) - { - pointInObjectCounter++; - if(mesh->isPointInGbObject3D(val<1>(coords),val<2>(coords),val<3>(coords)) ) - { - //block->setActive(false); - //this->solidBlocks.push_back(block); - } - } - //Bloecke, die Verschneidung mit Dreicken bzw. deren BoundCubes hatten - //scanline algortihmus. dieser berücksichtigt durch weitere tests, dass innerhalb evtl schon andere - //geos bcs gesetzt haben. es werden ausschließelich solids gesetzt (also keine FLUIDS oder neuen BCs) - else if( pos->second == ScanLine ) - { - scanlineCounter++; - scanLineTimer.start(); - - SPtr<ILBMKernel> kernel = block->getKernel(); - if(!kernel) throw UbException(UB_EXARGS,"na sowas kein kernel bzw. kernel=NULL (2)"); - SPtr<BCArray3D> bcMatrix = kernel->getBCProcessor()->getBCArray(); - - // bvd->getTimer().start(); - int indexMinX1 = 0; - int indexMinX2 = 0; - int indexMinX3 = 0; - int indexMaxX1 = (int)bcMatrix->getNX1(); - int indexMaxX2 = (int)bcMatrix->getNX2(); - int indexMaxX3 = (int)bcMatrix->getNX3(); - - //quick and dirty - blocknx1 = indexMaxX1; - blocknx2 = indexMaxX2; - blocknx3 = indexMaxX3; - - std::set< UbTupleInt3 >& solidNodeIndices = this->solidNodeIndicesMap[block]; - - float nodeDeltaX1 = (float)nodeDeltaToNeigh[level][D3Q27System::E]; - float nodeDeltaX2 = (float)nodeDeltaToNeigh[level][D3Q27System::N]; - float nodeDeltaX3 = (float)nodeDeltaToNeigh[level][D3Q27System::T]; - - //flagfield matrix initialisieren - CbArray3D<FLAGS> flagField(blocknx1,blocknx2,blocknx3,UNDEF_FLAG); - - //hier gesetzte bcs markieren - std::set< std::vector<int> >& transNodeIndices = this->bcNodeIndicesMap[block]; - std::set< std::vector<int> >::iterator setPos; - for(setPos=transNodeIndices.begin(); setPos!=transNodeIndices.end(); ++setPos) - flagField( (*setPos)[0], (*setPos)[1], (*setPos)[2] ) = BC_FLAG; - - //solids die bereits durch andere interaktoren gesetzt wurden (wurden oben gespeichert) - //ist EMPTY bei reinitWithStoredQsFlag == true - //SG 28.08.2010 std::set< UbTupleInt3 >& tmpSolidNodeIndices = tmpSolidNodesFromOtherInteractors[block]; - //SG 28.08.2010 if(reinitWithStoredQsFlag && !tmpSolidNodeIndices.empty() ) throw UbException(UB_EXARGS, "tmpSolidNodeIndices darf bei reinitWithStoredQsFlag==true keine Knoten enthalten"); - //SG 28.08.2010 for(setPos=tmpSolidNodeIndices.begin(); setPos!=tmpSolidNodeIndices.end(); ++setPos) - //SG 28.08.2010 flagField( val<1>(*setPos), val<2>(*setPos), val<3>(*setPos) ) = OLDSOLID_FLAG; - - //flagfield matrix belegen - for(int bx3=0; bx3<blocknx3; ++bx3) - { - for(int bx2=0; bx2<blocknx2; ++bx2) - { - for(int bx1=0; bx1<blocknx1; ++bx1) - { - - if (bx2==9&&bx3==29) - { - int ride=0; - } - if( flagField(bx1,bx2,bx3)==UNDEF_FLAG ) - { - if( mesh->isPointInGbObject3D( val<1>(coords) + bx1*nodeDeltaX1 - 0.5*nodeDeltaX1 - , val<2>(coords) + bx2*nodeDeltaX2 - 0.5*nodeDeltaX2 - , val<3>(coords) + bx3*nodeDeltaX3 - 0.5*nodeDeltaX3) ) - { - (this->*gridFill)(flagField,bx1,bx2,bx3,SOLID_FLAG); - } - else - { - (this->*gridFill)(flagField,bx1,bx2,bx3,FLUID_FLAG); - } - } - - if( flagField(bx1,bx2,bx3)==SOLID_FLAG ) - { - //hier ist noch das Problem, das "alle" solid in die solidNodeIndices kommen - //evtl. Abhilfe durch einführen eines anderen Flags bei tmpSolidNodeIndices .. - solidNodeIndices.insert(UbTupleInt3(bx1,bx2,bx3)); - bcMatrix->setSolid(bx1,bx2,bx3); - } - //SG 28.08.2010 else if( flagField(bx1,bx2,bx3)==OLDSOLID_FLAG ) - //SG 28.08.2010 { - //SG 28.08.2010 bcMatrix->setSolid(bx1,bx2,bx3); - //SG 28.08.2010 } - } - } - } - - //SG 28.08.2010 halt danach setzen, damit die BCs die fälschlicherweise gesetzt wurden korrigiert werden - std::set< std::vector<int> >& tmpSolidNodeIndices = tmpSolidNodesFromOtherInteractors[block]; - for(setPos=tmpSolidNodeIndices.begin(); setPos!=tmpSolidNodeIndices.end(); ++setPos) - bcMatrix->setSolid((*setPos)[0], (*setPos)[1], (*setPos)[2] ); - - //block hat in initInteractor mind eine BC erhalten -> transBlock - this->bcBlocks.push_back(block); - scanLineTimer.stop(); - - // bvd->getTimer().stop(); - } - else throw UbException(UB_EXARGS,"unknown option for in object test"); - } - - solidTimer.stop(); - - UBLOG(logDEBUG1, " - setSolids for "<<blocksForSolidCheck.size()<<" blocks: 100% done in "<<solidTimer.getTotalTime()<<"s"); - UBLOG(logDEBUG1, " * pointInObject for "<<pointInObjectCounter<<" blocks in "<<solidTimer.getTotalTime()-scanLineTimer.getTotalTime()<<"s"); - UBLOG(logDEBUG1, " * flood fill for "<<scanlineCounter <<" blocks in "<<scanLineTimer.getTotalTime()<<" secs"); - UBLOG(logDEBUG1, "LBMTriFaceMeshInteractor::initInteractor for \""<<mesh->getName()<<"\" done in "<<setQTimer.getTotalTime()+solidTimer.getTotalTime()<<"s"); - } - - //calcForces arbeitet nicht korrekt, wenn Geo mit Bloecken - //unterschiedlicher Leveltiefe diskretisiert -> exception - //abfrage steht hier, weil es theoretisch sein kann, dass bei parallelen rechnungen - //genau der block mit dem anderen level auf einem anderen prozess liegt... - //Update: es kann u.U. passieren, dass Blöcke in der Liste nicht aktiv sin - //(falls diese z.B. duch andere Interactoren solid gesetzt wurden) - //diese werden nicht berücksichtigt (auch nicht beid er kraftauswertung später) - //if( this->isRelevantForForces() ) - //{ - // int level = -1; - // for( std::vector<SPtr<Block3D>>::const_iterator pos = this->transBlocks.begin(); pos!=this->transBlocks.end(); ++pos) - // if( (*pos)->isActive() ) - // { - // level = (*pos)->getLevel(); - // break; - // } - - // bool check = false; - // for( std::vector<SPtr<Block3D>>::const_iterator pos = this->transBlocks.begin(); pos!=this->transBlocks.end(); ++pos) - // if( (*pos)->isActive() && (*pos)->getLevel()!=level) - // { - // (*pos)->setRank(1000); - // check = true; - // UbTupleDouble3 coords = grid.lock()->getBlockWorldCoordinates((*pos)); - // std::cout<<(*pos)->getLevel()<<","<<(*pos)->getX1()<<","<<(*pos)->getX2()<<","<<(*pos)->getX3()<<std::endl; - // std::cout<<std::setprecision(15)<<val<1>(coords)<<","<<val<2>(coords)<<","<<val<3>(coords)<<std::endl<<std::endl; - - // } - // if(check) - // { - // //this->grid.lock()->writeBlocks(UbStaticPathMap::getPath(UbStaticPathMap::GLOBAL)+"/error_grid",0, WbWriterVtkXmlASCII::getInstance(), false); - - // throw UbException(UB_EXARGS,"interactor is relevant for forces," - // +(std::string)" but has transblocks with different levels (wrote error_grid)" - // +(std::string)" -> not supportet by LBMInteractor::getForces()" - // +(std::string)" -> increase refineWidth"); - - // } - //} -} -////////////////////////////////////////////////////////////////////////// -void D3Q27TriFaceMeshInteractor::refineBlockGridToLevel(int level, double startDistance, double stopDistance) -{ - UBLOG(logDEBUG1, "D3Q27TriFaceMeshInteractor::refineBlockGridToLevel - start"); - - //ToDo: evtl checken, ob man noch einen HalbraumCheck für StopDistance einbaut - // oder ob man schneller ist, wenn man gar keinen halbraum test macht... - if(!grid.lock()) - throw UbException(UB_EXARGS,"Grid isn't exist!"); - if( UbMath::greater(startDistance,0.0) ) - throw UbException(UB_EXARGS,"startDistance>0.0 not supported by this interactor"); - if( UbMath::less(stopDistance,0.0) ) - throw UbException(UB_EXARGS,"stopDistance<0.0 not supported by this interactor"); - - SPtr<Grid3D> bgrid = this->grid.lock(); - GbTriFaceMesh3D& mesh = dynamic_cast<GbTriFaceMesh3D&>(*this->geoObject3D.get()); - - int coarsestLevel = bgrid->getCoarsestInitializedLevel(); - - std::vector<GbTriFaceMesh3D::TriFace>& triangles = *mesh.getTriangles(); - std::vector<GbTriFaceMesh3D::Vertex>& nodes = *mesh.getNodes(); - - double minX1,minX2,minX3,maxX1,maxX2,maxX3; - float blockMinX[3],blockMaxX[3],boxCenter[3],halfBoxSize[3]; - 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]; - GbTriFaceMesh3D::Vertex& v2 = nodes[triangle.v2]; - GbTriFaceMesh3D::Vertex& v3 = nodes[triangle.v3]; - - //dreick muss normal besitzen! - assert( !UbMath::zero(triangle.nx) || !UbMath::zero(triangle.ny) || !UbMath::zero(triangle.nz) ); - //Normale muss normiert sein! - assert( (fabs(std::sqrt( triangle.nx*triangle.nx + triangle.ny*triangle.ny + triangle.nz*triangle.nz ))-1.0f)<1.0E-6); - - //Halfspace um startDistance entgegen normale verscheiebn, ansonsten werden spaeter - //zu testende bloecke auf der dreicksrueckseite nicht getestet!!! - GbHalfSpace3D halfSpace( v1.x+startDistance*triangle.nx, v1.y+startDistance*triangle.ny, v1.z+startDistance*triangle.nz - , v2.x+startDistance*triangle.nx, v2.y+startDistance*triangle.ny, v2.z+startDistance*triangle.nz - , v3.x+startDistance*triangle.nx, v3.y+startDistance*triangle.ny, v3.z+startDistance*triangle.nz ); - - //Boundingbox um massgebliches dx erweitern -> zur Bestimmung der zu testenden Bloecke - if( triangle.nx>1.0E-8 ) { minX1 = triangle.getMinX(nodes)+1.05*triangle.nx*startDistance; - maxX1 = triangle.getMaxX(nodes)+1.05*triangle.nx*stopDistance; } - else { minX1 = triangle.getMinX(nodes)+1.05*triangle.nx*stopDistance; - maxX1 = triangle.getMaxX(nodes)+1.05*triangle.nx*startDistance; } - - if( triangle.ny>1.0E-8 ) { minX2 = triangle.getMinY(nodes)+1.05*triangle.ny*startDistance; - maxX2 = triangle.getMaxY(nodes)+1.05*triangle.ny*stopDistance; } - else { minX2 = triangle.getMinY(nodes)+1.05*triangle.ny*stopDistance; - maxX2 = triangle.getMaxY(nodes)+1.05*triangle.ny*startDistance; } - - if( triangle.nz>1.0E-8 ) { minX3 = triangle.getMinZ(nodes)+1.05*triangle.nz*startDistance; - maxX3 = triangle.getMaxZ(nodes)+1.05*triangle.nz*stopDistance; } - else { minX3 = triangle.getMinZ(nodes)+1.05*triangle.nz*stopDistance; - maxX3 = triangle.getMaxZ(nodes)+1.05*triangle.nz*startDistance; } - - - int flag = 0; - //Levelweise alle Bloecke holen, die erweiterte BB schneiden - //und bearbeiten - for(int l=coarsestLevel; l<level; l++) - { - std::vector<SPtr<Block3D>> consideredBlocks; - bgrid->getBlocksByCuboid(l,minX1, minX2, minX3, maxX1, maxX2, maxX3, consideredBlocks); - double x1a,x2a,x3a,x1b,x2b,x3b; - - for(size_t b=0; b<consideredBlocks.size(); b++) - { - SPtr<Block3D> block = consideredBlocks[b]; - if(block->getLevel()>=level) continue; - - //start coordinaten des blocks ermitteln - UbTupleDouble3 coords = bgrid->getBlockWorldCoordinates(block); - UbTupleDouble3 deltas = bgrid->getBlockLengths(block); - - //Check, ob block komplett im Halbraum - x1a = val<1>(coords); x1b = val<1>(coords)+val<1>(deltas); - x2a = val<2>(coords); x2b = val<2>(coords)+val<2>(deltas); - x3a = val<3>(coords); x3b = val<3>(coords)+val<3>(deltas); - - flag = 0; - if( !halfSpace.ptInside(x1a,x2a,x3a) ) flag |= (1<<0); //1 - if( !halfSpace.ptInside(x1b,x2a,x3a) ) flag |= (1<<1); //2 - if( !halfSpace.ptInside(x1b,x2b,x3a) ) flag |= (1<<2); //4 - if( !halfSpace.ptInside(x1a,x2b,x3a) ) flag |= (1<<3); //8 - if( !halfSpace.ptInside(x1a,x2a,x3b) ) flag |= (1<<4); //16 - if( !halfSpace.ptInside(x1b,x2a,x3b) ) flag |= (1<<5); //32 - if( !halfSpace.ptInside(x1b,x2b,x3b) ) flag |= (1<<6); //64 - if( !halfSpace.ptInside(x1a,x2b,x3b) ) flag |= (1<<7); //128 - - - if( true && flag!=255 ) - { - //blockseite ermitteln (skalarprodukt dreiecks-normale, vector (midTri->midCub) ) - //je nachdem muss für den massgeblichen block start oder stopdistance verwendet werden - //liegt block auf pos seite -> stopdistance ansonsten startdistance - double skalarprod = triangle.nx * ( 0.5*(x1a+x1b)-triangle.getX1Centroid(nodes) ) - + triangle.ny * ( 0.5*(x2a+x2b)-triangle.getX2Centroid(nodes) ) - + triangle.nz * ( 0.5*(x3a+x3b)-triangle.getX3Centroid(nodes) ); - - double blockdelta = 1.05*stopDistance; - if (skalarprod<1.E-8 ) blockdelta = -1.05*startDistance; //startDistance<0!! - else if( fabs(skalarprod)<1.E-8) blockdelta = 1.05*UbMath::max(-startDistance,stopDistance); - - //block anpassen - blockMinX[0] = (float)(val<1>(coords)-blockdelta ); - blockMinX[1] = (float)(val<2>(coords)-blockdelta ); - blockMinX[2] = (float)(val<3>(coords)-blockdelta ); - - blockMaxX[0] = (float)(val<1>(coords)+val<1>(deltas)+blockdelta ); - blockMaxX[1] = (float)(val<2>(coords)+val<2>(deltas)+blockdelta ); - blockMaxX[2] = (float)(val<3>(coords)+val<3>(deltas)+blockdelta ); - - boxCenter[0] = (float)(0.5*(blockMaxX[0]+blockMinX[0])); - boxCenter[1] = (float)(0.5*(blockMaxX[1]+blockMinX[1])); - boxCenter[2] = (float)(0.5*(blockMaxX[2]+blockMinX[2])); - - halfBoxSize[0] = (float)(0.5*(blockMaxX[0]-blockMinX[0])); - halfBoxSize[1] = (float)(0.5*(blockMaxX[1]-blockMinX[1])); - halfBoxSize[2] = (float)(0.5*(blockMaxX[2]-blockMinX[2])); - - GbTriFaceMesh3D::Vertex& v1 = nodes[triangle.v1]; - GbTriFaceMesh3D::Vertex& v2 = nodes[triangle.v2]; - GbTriFaceMesh3D::Vertex& v3 = nodes[triangle.v3]; - - triPoints[0][0] = v1.x; triPoints[0][1] = v1.y; triPoints[0][2] = v1.z; - triPoints[1][0] = v2.x; triPoints[1][1] = v2.y; triPoints[1][2] = v2.z; - triPoints[2][0] = v3.x; triPoints[2][1] = v3.y; triPoints[2][2] = v3.z; - - //wenn block dreick schneidet, dann muss er verfeinert werden - if( GbMeshTools3D::triBoxOverlap(boxCenter,halfBoxSize,triPoints) ) - { - bgrid->expandBlock(block->getX1(), block->getX2(),block->getX3(),block->getLevel()); - } - } - } - } - } - UBLOG(logDEBUG1, " - refine done"); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27TriFaceMeshInteractor::updateMovedGeometry(const double& timeStep) -{ - -} -//////////////////////////////////////////////////////////////////////////// -void D3Q27TriFaceMeshInteractor::recursiveGridFill(CbArray3D<FLAGS>& flagfield, const short& xs, const short& ys, const short& zs, const FLAGS& type) -{ - // Algorithmus zum Füllen eines Polyeders, ausgehend vom Saatpunkt xs,ys,zs - - //Saatknoten einfärben - if( flagfield(xs,ys,zs)==UNDEF_FLAG ) - { - flagfield(xs,ys,zs) = type; - - if ( flagfield.indicesInRange( xs+1, ys , zs ) ) this->recursiveGridFill(flagfield,xs+1, ys , zs ,type); - if ( flagfield.indicesInRange( xs , ys+1, zs ) ) this->recursiveGridFill(flagfield,xs , ys+1, zs ,type); - if ( flagfield.indicesInRange( xs , ys , zs+1 ) ) this->recursiveGridFill(flagfield,xs , ys , zs+1,type); - if ( flagfield.indicesInRange( xs-1, ys , zs ) ) this->recursiveGridFill(flagfield,xs-1, ys , zs ,type); - if ( flagfield.indicesInRange( xs , ys-1, zs ) ) this->recursiveGridFill(flagfield,xs , ys-1, zs ,type); - if ( flagfield.indicesInRange( xs , ys , zs-1 ) ) this->recursiveGridFill(flagfield,xs , ys , zs-1,type); - } -} -////////////////////////////////////////////////////////////////////////// -void D3Q27TriFaceMeshInteractor::iterativeGridFill(CbArray3D<FLAGS>& flagfield, const short& xs, const short& ys, const short& zs, const FLAGS& type) -{ - std::stack< UbTupleInt3 > stck; - stck.push( UbTupleInt3(xs,ys,zs) ); - - int x,y,z; - - while( !stck.empty() ) - { - x = val<1>( stck.top() ); - y = val<2>( stck.top() ); - z = val<3>( stck.top() ); - stck.pop(); - - FLAGS& flagType = flagfield( x, y, z ); - - if( flagType == UNDEF_FLAG ) - { - flagType = type; - - if ( flagfield.indicesInRange( x+1, y , z ) ) stck.push( UbTupleInt3( x+1, y , z ) ); - if ( flagfield.indicesInRange( x , y+1, z ) ) stck.push( UbTupleInt3( x , y+1, z ) ); - if ( flagfield.indicesInRange( x , y , z+1 ) ) stck.push( UbTupleInt3( x , y , z+1 ) ); - if ( flagfield.indicesInRange( x-1, y , z ) ) stck.push( UbTupleInt3( x-1, y , z ) ); - if ( flagfield.indicesInRange( x , y-1, z ) ) stck.push( UbTupleInt3( x , y-1, z ) ); - if ( flagfield.indicesInRange( x , y , z-1 ) ) stck.push( UbTupleInt3( x , y , z-1 ) ); - } - } - return; -} -////////////////////////////////////////////////////////////////////////// -UbTupleDouble3 D3Q27TriFaceMeshInteractor::getForces() -{ - //FeTriFaceMesh3D* feMesh = dynamic_cast<FeTriFaceMesh3D*>(this->geoObject3D.get()); - //if(!feMesh) - //{ - // return D3Q19AMRInteractor::getForces(); - //} - ////return getForcesTriangle(); - //this->calculateForces(); - - double forceX1=0.0; - double forceX2=0.0; - double forceX3=0.0; - - //double area = 0.0; - - //vector<FeTriFaceMesh3D::VertexAttributes>* attributes = feMesh->getAttributes(); - - //for(size_t i=0; i<attributes->size(); i++) - //{ - // FeTriFaceMesh3D::VertexAttributes& attribut = (*attributes)[i]; - // area = attribut.getArea(); - // forceX1 += attribut.getFX()*area; - // forceX2 += attribut.getFY()*area; - // forceX3 += attribut.getFZ()*area; - //} - return UbTupleDouble3(forceX1,forceX2,forceX3); -} -////////////////////////////////////////////////////////////////////////// -UbTupleDouble3 D3Q27TriFaceMeshInteractor::getForcesTriangle() -{ - double forceX1=0.0; - double forceX2=0.0; - double forceX3=0.0; - - //D3Q19BlockGrid& grid.lock() = dynamic_cast<D3Q19BlockGrid&>(*this->grid.lock()); - //// CoordinateTransformation3D *trafo = this->grid.lock()->getTransformation(); - //// int minLevel = this->grid.lock()->getFinestInitializedLevel(); - //// double scaleX = trafo->getX1CoordinateScaling()/(1<<minLevel); - //// double scaleY = trafo->getX2CoordinateScaling()/(1<<minLevel); - //// double scaleZ = trafo->getX3CoordinateScaling()/(1<<minLevel); - //// int blocknx1 = grid.lock()->getBlockNX1(); - //// int blocknx2 = grid.lock()->getBlockNX2(); - //// int blocknx3 = grid.lock()->getBlockNX3(); - //// double xOffset = trafo->getX1CoordinateOffset(); - //// double yOffset = trafo->getX2CoordinateOffset(); - //// double zOffset = trafo->getX3CoordinateOffset(); - //vector<D3Q19Real> collFactors = ((D3Q19Calculator*)grid.lock()->getCalculator())->getCollisionsFactors(); - - ////for (int i=0;i<(int)gbTriangle3DInteractors.size(); i++) - ////{ - //// GbTriangle3D* tri = (GbTriangle3D*)gbTriangle3DInteractors[i]->getGbObject3D(); - - //// double px0 = tri->getX1Centroid(); - //// double py0 = tri->getX2Centroid(); - //// double pz0 = tri->getX3Centroid(); - //// double px = px0-xOffset; - //// double py = py0-yOffset; - //// double pz = pz0-zOffset; - //// px = px/scaleX; - //// py = py/scaleY; - //// pz = pz/scaleZ; - //// int x1 = (int)px; - //// int y1 = (int)py; - //// int z1 = (int)pz; - //// AMR3DBlock* block = this->grid.lock()->getBlock(x1,y1,z1,minLevel); - //// if(!block) block = this->grid.lock()->getSuperBlock(x1,y1,z1,minLevel); - //// if(!block) throw UbException(__FILE__,__LINE__,"kein Block ..."); - - //// double collFactor = collFactors[block->getLevel()]; - //// double nodeDistance = grid.lock()->getNodeDeltaX(block->getLevel()); - //// double bertX1 = ((px0-xOffset)/(1000.*nodeDistance)); - //// double bertX2 = ((py0-yOffset)/(1000.*nodeDistance)); - //// double bertX3 = ((pz0-zOffset)/(1000.*nodeDistance)); - //// int abstaendeX1 = (int)(bertX1*1000.); - //// int abstaendeX2 = (int)(bertX2*1000.); - //// int abstaendeX3 = (int)(bertX3*1000.); - //// int posW = abstaendeX1 - block->getX1Index()*blocknx1; - //// int posS = abstaendeX2 - block->getX2Index()*blocknx2; - //// int posB = abstaendeX3 - block->getX3Index()*blocknx3; - //// int posE=posW+1; - //// int posN=posS+1; - //// int posT=posB+1; - - //// D3Q19BlockDescriptor *bvd = dynamic_cast<D3Q19BlockDescriptor*>(block->getBlockDescriptor()); - //// if(!bvd) throw UbException(__FILE__,__LINE__,"kein Bvd ..."); - - //// CbUniformMatrix4D<double,IndexerX1X2X3X4>* tempdistributions = bvd->getTempDistributionMatrix(); - //// D3Q19BCMatrix<D3Q19BoundaryCondition> *bcMatrix = bvd->getBcMatrix(); - - //// UbTupleDouble6 stresses; - //// double dX = px0-this->geoObject3D->getX1Centroid(); - //// double dY = py0-this->geoObject3D->getX2Centroid(); - //// double dZ = pz0-this->geoObject3D->getX3Centroid(); - //// if(dX<=0.0 && dY<=0.0 && dZ<=0.0) - //// { - //// double *fWSB = tempdistributions->getStartAdressOfSortedArray(posW,posS,posB,0); - //// if(bcMatrix->isFluid(posW,posS,posB)) stresses = D3Q19System::getIncompStresses(fWSB, collFactor ); - //// else cout<<__LINE__<<" nicht fluid ..."; - //// } - //// else if(dX<=0.0 && dY>0.0 && dZ<=0.0) - //// { - //// double *fWNB = tempdistributions->getStartAdressOfSortedArray(posW,posN,posB,0); - //// if(bcMatrix->isFluid(posW,posN,posB)) stresses = D3Q19System::getIncompStresses(fWNB, collFactor ); - //// else cout<<__LINE__<<" nicht fluid ..."; - //// } - //// else if(dX<=0.0 && dY<=0.0 && dZ>0.0) - //// { - //// double *fWST = tempdistributions->getStartAdressOfSortedArray(posW,posS,posT,0); - //// if(bcMatrix->isFluid(posW,posS,posT)) stresses = D3Q19System::getIncompStresses(fWST, collFactor ); - //// else cout<<__LINE__<<" nicht fluid ..."; - //// } - //// else if(dX<=0.0 && dY>0.0 && dZ>0.0) - //// { - //// double *fWNT = tempdistributions->getStartAdressOfSortedArray(posW,posN,posT,0); - //// if(bcMatrix->isFluid(posW,posN,posT)) stresses = D3Q19System::getIncompStresses(fWNT, collFactor ); - //// else cout<<__LINE__<<" nicht fluid ..."; - //// } - //// else if(dX>0.0 && dY<=0.0 && dZ<=0.0) - //// { - //// double *fESB = tempdistributions->getStartAdressOfSortedArray(posE,posS,posB,0); - //// if(bcMatrix->isFluid(posE,posS,posB)) stresses = D3Q19System::getIncompStresses(fESB, collFactor ); - //// else cout<<__LINE__<<" nicht fluid ..."; - //// } - //// else if(dX>0.0 && dY>0.0 && dZ<=0.0) - //// { - //// double *fENB = tempdistributions->getStartAdressOfSortedArray(posE,posN,posB,0); - //// if(bcMatrix->isFluid(posE,posN,posB)) stresses = D3Q19System::getIncompStresses(fENB, collFactor ); - //// else cout<<__LINE__<<" nicht fluid ..."; - //// } - //// else if(dX>0.0 && dY<=0.0 && dZ>0.0) - //// { - //// double *fEST = tempdistributions->getStartAdressOfSortedArray(posE,posS,posT,0); - //// if(bcMatrix->isFluid(posE,posS,posT)) stresses = D3Q19System::getIncompStresses(fEST, collFactor ); - //// else cout<<__LINE__<<" nicht fluid ..."; - //// } - //// else if(dX>0.0 && dY>0.0 && dZ>0.0) - //// { - //// double *fENT = tempdistributions->getStartAdressOfSortedArray(posE,posN,posT,0); - //// if(bcMatrix->isFluid(posE,posN,posT)) stresses = D3Q19System::getIncompStresses(fENT, collFactor ); - //// else cout<<__LINE__<<" nicht fluid ..."; - //// } - //// else cout<<"punkt mit:"<<dX<<" "<<dY<<" "<<dZ<<" ist nicht bei \n"; - - //// double S11 = val<1>(stresses); - //// double S22 = val<2>(stresses); - //// double S33 = val<3>(stresses); - //// double S12 = val<4>(stresses); - //// double S13 = val<5>(stresses); - //// double S23 = val<6>(stresses); - - //// GbVector3D normal = tri->getNormal(); - //// double nx = normal.X1(); - //// double ny = normal.X2(); - //// double nz = normal.X3(); - //// double area = tri->getArea(); - - //// double Fx1 = area*(S11*nx+S12*ny+S13*nz); - //// double Fy1 = area*(S12*nx+S22*ny+S23*nz); - //// double Fz1 = area*(S13*nx+S23*ny+S33*nz); - //// forceX1 += Fx1; - //// forceX2 += Fy1; - //// forceX3 += Fz1; - ////} - return UbTupleDouble3(forceX1,forceX2,forceX3); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27TriFaceMeshInteractor::calculateForces() -{ - //FeTriFaceMesh3D* feMesh = dynamic_cast<FeTriFaceMesh3D*>(this->geoObject3D.get()); - //if(!feMesh) throw UbException(UB_EXARGS,"geoObject is not a FeTriFaceMesh3D!"); - - //if(this->stressMode == STRESSNORMAL) this->calculateStresses(); - //else if(this->stressMode == STRESSALTERNATIV) this->calculateStressesAlternativ(); - - //vector<FeTriFaceMesh3D::VertexAttributes>* attributes = feMesh->getAttributes(); - - //for (int i=0;i<(int)attributes->size() ;i++) - //{ - // FeTriFaceMesh3D::VertexAttributes& attribut = (*attributes)[i]; - // attribut.setFX(0.0); - // attribut.setFY(0.0); - // attribut.setFZ(0.0); - // attribut.setArea(0.0); - //} - //vector<GbTriFaceMesh3D::TriFace>& triangles = *feMesh->getTriangles(); - //vector<GbTriFaceMesh3D::Vertex>& nodes = *feMesh->getNodes(); - //for (size_t i=0; i<triangles.size(); i++) - //{ - // GbTriFaceMesh3D::TriFace& triangle = triangles[i]; - // FeTriFaceMesh3D::VertexAttributes& vAttribut1 = (*attributes)[triangle.v1]; - // FeTriFaceMesh3D::VertexAttributes& vAttribut2 = (*attributes)[triangle.v2]; - // FeTriFaceMesh3D::VertexAttributes& vAttribut3 = (*attributes)[triangle.v3]; - // UbTupleDouble6& stressesP1 = vAttribut1.getStresses(); - // UbTupleDouble6& stressesP2 = vAttribut2.getStresses(); - // UbTupleDouble6& stressesP3 = vAttribut3.getStresses(); - // double p1S11 = val<1>(stressesP1); double p2S11 = val<1>(stressesP2); double p3S11 = val<1>(stressesP3); - // double p1S22 = val<2>(stressesP1); double p2S22 = val<2>(stressesP2); double p3S22 = val<2>(stressesP3); - // double p1S33 = val<3>(stressesP1); double p2S33 = val<3>(stressesP2); double p3S33 = val<3>(stressesP3); - // double p1S12 = val<4>(stressesP1); double p2S12 = val<4>(stressesP2); double p3S12 = val<4>(stressesP3); - // double p1S13 = val<5>(stressesP1); double p2S13 = val<5>(stressesP2); double p3S13 = val<5>(stressesP3); - // double p1S23 = val<6>(stressesP1); double p2S23 = val<6>(stressesP2); double p3S23 = val<6>(stressesP3); - - // triangle.calculateNormal(nodes); - // double nx = triangle.nx; - // double ny = triangle.ny; - // double nz = triangle.nz; - // double area = 0.3333*triangle.getArea(nodes); - - // if(UbMath::lessEqual(area,0.0)) cout<<__FILE__<<" "<<__LINE__<<" area <= 0 "<<endl; - - // double Fx1 = area*(0.333*(p1S11*nx+p1S12*ny+p1S13*nz)+0.333*(p2S11*nx+p2S12*ny+p2S13*nz)+0.333*(p3S11*nx+p3S12*ny+p3S13*nz)); - // double Fx2 = Fx1; - // double Fx3 = Fx1; - - // double Fy1 = area*(0.333*(p1S12*nx+p1S22*ny+p1S23*nz)+0.333*(p2S12*nx+p2S22*ny+p2S23*nz)+0.333*(p3S12*nx+p3S22*ny+p3S23*nz)); - // double Fy2 = Fy1; - // double Fy3 = Fy1; - - // double Fz1 = area*(0.333*(p1S13*nx+p1S23*ny+p1S33*nz)+0.333*(p2S13*nx+p2S23*ny+p2S33*nz)+0.333*(p3S13*nx+p3S23*ny+p3S33*nz)); - // double Fz2 = Fz1; - // double Fz3 = Fz1; - // // cout<<Fx1<<" "<<Fy1<<" "<<Fz1<<endl; - // vAttribut1.addFX(Fx1); vAttribut2.addFX(Fx2); vAttribut3.addFX(Fx3); - // vAttribut1.addFY(Fy1); vAttribut2.addFY(Fy2); vAttribut3.addFY(Fy3); - // vAttribut1.addFZ(Fz1); vAttribut2.addFZ(Fz2); vAttribut3.addFZ(Fz3); - // vAttribut1.addArea(area); vAttribut2.addArea(area); vAttribut3.addArea(area); - //} - //for (size_t i=0; i<attributes->size(); i++) - //{ - // FeTriFaceMesh3D::VertexAttributes& attribut = (*attributes)[i]; - - // double newFX = attribut.getFX()/attribut.getArea(); - // double newFY = attribut.getFY()/attribut.getArea(); - // double newFZ = attribut.getFZ()/attribut.getArea(); - // //if(i==100) cout<<"F:"<<newFX<<" "<<newFY<<" "<<newFZ<<endl; - // //double oldFX = p->getOldFX(); - // //double oldFY = p->getOldFY(); - // //int alphaSteps = p->getFilteringSteps(); - // //double alpha = 1.0; - // //if(alphaSteps != 0) - // //{ - // // alpha = (1.0-alphaSteps*0.1); - // // // cout<<p->toString()<<" alpha:"<<alpha<<" steps:"<<alphaSteps<<endl; - // // p->reduceFilteringSteps(); - // //} - // //newFX = (1.-alpha)*oldFX+alpha*newFX; - // //newFY = (1.-alpha)*oldFY+alpha*newFY; - - // attribut.setFX(newFX); - // attribut.setFY(newFY); - // attribut.setFZ(newFZ); - // //cout<<i<<" "<<newFX<<" "<<newFY<<" "<<newFZ<<endl; - // //cout<<i<<" "<<p->toString()<<endl; - - //} -} -////////////////////////////////////////////////////////////////////////// -string D3Q27TriFaceMeshInteractor::toString() -{ - stringstream ss; - ss<< "D3Q27TriFaceMeshInteractor[label=D3Q27TriFaceMeshInteractor"; - if(this->isSolid()) ss<<", solid"; - if(this->isInverseSolid()) ss<<", inversesolid"; - if(this->isTimeDependent()) ss<<", timedependent"; - if(geoObject3D!=NULL) ss<<", AMR3DInteractor: "<<geoObject3D->toString(); - ss<<"]"; - - return ss.str(); -} -////////////////////////////////////////////////////////////////////////// -void D3Q27TriFaceMeshInteractor::reinitWithStoredQs( const double& timeStep ) -{ - //alle solid Bloecke wieder solid setzen - std::vector<SPtr<Block3D>>& solidBlocks = this->getSolidBlockSet(); - for(size_t i=0; i<solidBlocks.size(); i++) - { - solidBlocks[i]->setActive(false); //<- quick n dirty - } - - //alle solid-nodes wieder solid setzen (solids die quasi in den TransBloecken liegen) - std::map<SPtr<Block3D>, std::set< UbTupleInt3 > >::iterator it1; - for( it1=this->solidNodeIndicesMap.begin(); it1!=this->solidNodeIndicesMap.end(); ++it1 ) - { - SPtr<Block3D> block = it1->first; - - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcMatrix = kernel->getBCProcessor()->getBCArray(); - std::set< UbTupleInt3 >& indicesSet = it1->second; - - for( std::set< UbTupleInt3 >::iterator setIt=indicesSet.begin(); setIt!=indicesSet.end(); ++setIt ) - { - bcMatrix->setSolid( val<1>(*setIt), val<2>(*setIt), val<3>(*setIt) ); - } - } - - //BCS WIEDERHERSTELLEN - std::map<SPtr<Block3D>, std::map< UbTupleInt3, std::vector<float> > >::iterator it; - for( it=bcNodeIndicesAndQsMap.begin(); it!=bcNodeIndicesAndQsMap.end(); ++it ) - { - SPtr<Block3D> block = it->first; - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcMatrix = kernel->getBCProcessor()->getBCArray(); - - std::map< UbTupleInt3, std::vector<float> >::iterator it2; - for( it2=it->second.begin(); it2!=it->second.end(); ++it2 ) - { - const UbTupleInt3& pos = it2->first; - std::vector< float > qs = it2->second; - - //SG_27.08.2010 - if(bcMatrix->isSolid(val<1>(pos), val<2>(pos), val<3>(pos))) continue; - - SPtr<BoundaryConditions> bc = bcMatrix->getBC( val<1>(pos), val<2>(pos), val<3>(pos) ); - if(!bc) - { - bc = SPtr<BoundaryConditions>(new BoundaryConditions); - bcMatrix->setBC( val<1>(pos), val<2>(pos), val<3>(pos), bc ); - } - - double x1w = qs[D3Q27System::FENDDIR+1+0]; - double x2w = qs[D3Q27System::FENDDIR+1+1]; - double x3w = qs[D3Q27System::FENDDIR+1+2]; - - - //TODO: HACK GEHOERT NICHT HIERHIER!!! - start - //es handelt sich un ein statisches Objekt und beim Propeller gibt - // es Schwierigkeiten an den Flügelspitzen, dass kann daher kommen, - //dass dort zuviel bc-flaggs sind und mit Geschwindigkeit ergibt dies ziemlich grosse Werte - bc->setBoundaryVelocityX1(0.0); - bc->setBoundaryVelocityX2(0.0); - bc->setBoundaryVelocityX3(0.0); - //TODO: HACK GEHOERT NICHT HIERHIER!!! - end - - bool gotQs = false; - for(int fdir=D3Q27System::FSTARTDIR; fdir<=D3Q27System::FENDDIR; fdir++) - { - if( UbMath::greater(qs[fdir], -1.0) && UbMath::less( qs[fdir], bc->getQ(fdir) ) ) - { - gotQs = true; - for(size_t index=0; index<this->bcAdapters.size(); index++) - this->bcAdapters[index]->adaptBCForDirection( *this, bc, x1w, x2w, x3w, qs[fdir], fdir); - } - } - - if(gotQs) - for(size_t index=0; index<this->bcAdapters.size(); index++) - this->bcAdapters[index]->adaptBC( *this, bc, x1w, x2w, x3w); - } - } -} -////////////////////////////////////////////////////////////////////////// -void D3Q27TriFaceMeshInteractor::updateInteractor( const double& timestep/*=0*/ ) -{ - UB_THROW( UbException("D3Q27TriFaceMeshInteractor::updateInteractor - toDo") ); -} - - - - - - diff --git a/src/cpu/VirtualFluidsCore/Interactors/D3Q27TriFaceMeshInteractor.h b/src/cpu/VirtualFluidsCore/Interactors/D3Q27TriFaceMeshInteractor.h deleted file mode 100644 index 3e2428d0c..000000000 --- a/src/cpu/VirtualFluidsCore/Interactors/D3Q27TriFaceMeshInteractor.h +++ /dev/null @@ -1,106 +0,0 @@ -#ifndef D3Q19AMRTRIFACEMESHINTERACTOR_H -#define D3Q19AMRTRIFACEMESHINTERACTOR_H - -#include <string> -#include <vector> -#include <map> -#include <PointerDefinitions.h> - -#include "D3Q27Interactor.h" -#include "CbArray3D.h" - -class GbObject3D; -class Grid3D; -class BCAdapter; -class GbTriFaceMesh3D; -class Block3D; - -class D3Q27TriFaceMeshInteractor : public D3Q27Interactor -{ -public: - static const int STRESSNORMAL=0; - static const int STRESSALTERNATIV=1; - - D3Q27TriFaceMeshInteractor(); - D3Q27TriFaceMeshInteractor(SPtr<Grid3D> grid, std::string name="D3Q27TriFaceMeshInteractor"); - D3Q27TriFaceMeshInteractor(SPtr<GbObject3D> geoObject3D, SPtr<Grid3D> grid, int type); - D3Q27TriFaceMeshInteractor(SPtr<GbTriFaceMesh3D> triFaceMesh, SPtr<Grid3D> grid, SPtr<BCAdapter> bcAdapter, int type); - D3Q27TriFaceMeshInteractor(SPtr<GbTriFaceMesh3D> triFaceMesh, SPtr<Grid3D> grid, SPtr<BCAdapter> bcAdapter, int type, Interactor3D::Accuracy a); - //D3Q27TriFaceMeshInteractor(SPtr<GbTriFaceMesh3D> triFaceMesh, D3Q27BoundaryConditionAdapterPtr bcAdapter, int type, std::string name="D3Q27TriFaceMeshInteractor"); - - ~D3Q27TriFaceMeshInteractor(); - - virtual void initInteractor(const double& timeStep=0); - virtual void initInteractor2(const double& timeStep=0); - - void updateInteractor(const double& timestep=0); - - void updateMovedGeometry(const double& timeStep=0); - void setQs(const double& timeStep); - void refineBlockGridToLevel(int level, double startDistance, double stopDistance); - - bool setDifferencesToGbObject3D(const SPtr<Block3D> block/*,const double& orgX1,const double& orgX2,const double& orgX3,const double& blockLengthX1,const double& blockLengthX2,const double& blockLengthX3, const double& timestep=0*/); - - void setRegardPointInObjectTest( bool opt ) { this->regardPIOTest = opt; } - - ObObject* clone() { throw UbException(UB_EXARGS,"not implemented"); } - ObObjectCreator* getCreator(); - - UbTupleDouble3 getForces(); - UbTupleDouble3 getForcesTriangle(); - - void setStressMode(int stressMode) { this->stressMode = stressMode; } - void setUseHalfSpaceCheck(bool useHalfSpace ) { this->useHalfSpace = useHalfSpace; } - //void setReinitWithStoredQs(bool reinitWithStoredQsFlag) { this->reinitWithStoredQsFlag = reinitWithStoredQsFlag; } - - void calculateForces(); - void calculateStresses(); - void calculateStressesAlternativ(); - - void calcStressesLine(UbTupleDouble6& stresses, const double& weight, const UbTupleDouble6& stvW, const UbTupleDouble6& stvE ); - void calcStressesFace(UbTupleDouble6& stresses, const double& weightX, const double& weightY, const UbTupleDouble6& stvSW, const UbTupleDouble6& stvSE, const UbTupleDouble6& stvNE, const UbTupleDouble6& stvNW ); - void calcStressesCube(UbTupleDouble6& stresses, const double& weightX, const double& weightY, const double& weightZ, const UbTupleDouble6& stvBSW, const UbTupleDouble6& stvBSE, const UbTupleDouble6& stvBNE, const UbTupleDouble6& stvBNW, const UbTupleDouble6& stvTSW, const UbTupleDouble6& stvTSE, const UbTupleDouble6& stvTNE, const UbTupleDouble6& stvTNW ); - - void calculatePressure(); - void calcPressureLine(double &p, const double& weight, const double& pW, const double& pE ); - void calcPressureFace(double &p, const double& weightX, const double& weightY, const double& pSW, const double& pSE, const double& pNE, const double& pNW ); - void calcPressureCube(double &p, const double& weightX, const double& weightY, const double& weightZ, const double& pBSW, const double& pBSE, const double& pBNE, const double& pBNW, const double& pTSW, const double& pTSE, const double& pTNE, const double& pTNW ); - - void setForceShift(double forceshift) { this->forceshift = forceshift; this->forceshiftpolicy = true; } - void setVelocityShift(double velocityshift) { this->velocityshift = velocityshift; this->velocityshiftpolicy = true; } - double getForceShift() { return this->forceshift; } - double getVelocityShift() { return this->velocityshift; } - bool getForceShiftPolicy() { return forceshiftpolicy;} - bool getVelocityShiftPolicy() { return velocityshiftpolicy;} - - void clearBcNodeIndicesAndQsMap() { this->bcNodeIndicesAndQsMap.clear();} - - virtual std::string toString(); - - -protected: - int stressMode; - - double forceshift; - double velocityshift; - bool forceshiftpolicy; - bool velocityshiftpolicy; - bool useHalfSpace; - bool regardPIOTest; - - void reinitWithStoredQs(const double& timeStep); - // bool reinitWithStoredQsFlag; - std::map< SPtr<Block3D>, std::map < UbTupleInt3, std::vector< float > > > bcNodeIndicesAndQsMap; //!!! es kann sein, dass in diesem interactor - //an eine rpos eine BC gesetzt wurde, aber derselbe node in - //in einem anderen in einen anderen Typ (z.B. Solid) geaendert - //wurde --> es ist keine BC mehr an der stelle! - - enum SolidCheckMethod { ScanLine, PointInObject }; - - enum FLAGS { BC_FLAG, UNDEF_FLAG, FLUID_FLAG, SOLID_FLAG, OLDSOLID_FLAG }; - void recursiveGridFill(CbArray3D<FLAGS>& flagfield, const short& xs, const short& ys, const short& zs, const FLAGS& type); - void iterativeGridFill(CbArray3D<FLAGS>& flagfield, const short& xs, const short& ys, const short& zs, const FLAGS& type); -}; - - -#endif diff --git a/src/cpu/VirtualFluidsCore/Interactors/Interactor3D.cpp b/src/cpu/VirtualFluidsCore/Interactors/Interactor3D.cpp index 17adeb82a..f7fdab60f 100644 --- a/src/cpu/VirtualFluidsCore/Interactors/Interactor3D.cpp +++ b/src/cpu/VirtualFluidsCore/Interactors/Interactor3D.cpp @@ -1,316 +1,346 @@ -#include "Interactor3D.h" - - - -#include <fstream> -#include <numerics/geometry3d/GbCuboid3D.h> -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbFileOutput.h> -#include "UbException.h" - -#include "Grid3D.h" -#include "Block3D.h" -#include "GbObject3D.h" - - -using namespace std; - -const int Interactor3D::SOLID = (1<<0); //1 -const int Interactor3D::INVERSESOLID = (1<<1); //2 -const int Interactor3D::TIMEDEPENDENT = (1<<2); //4 //zeitlich -const int Interactor3D::FLUID = (1<<3); //8 -const int Interactor3D::MOVEABLE = (1<<4); //16 // geometrisch -const int Interactor3D::CHANGENOTNECESSARY = (1<<5); //32 - - - -////////////////////////////////////////////////////////////////////////// -Interactor3D::Interactor3D() - : type(SOLID) -{ - -} -////////////////////////////////////////////////////////////////////////// -Interactor3D::Interactor3D(SPtr<Grid3D> grid, int type) - : type(type) - , grid(grid) -{ - -} -////////////////////////////////////////////////////////////////////////// -Interactor3D::Interactor3D(SPtr<GbObject3D> geoObject3D, SPtr<Grid3D> grid, int type) - : geoObject3D(geoObject3D) - , grid(grid) - , type(type) - , accuracy(SIMPLE) -{ - -} -////////////////////////////////////////////////////////////////////////// -Interactor3D::Interactor3D(SPtr<GbObject3D> geoObject3D, SPtr<Grid3D> grid, int type, Interactor3D::Accuracy a) - : geoObject3D(geoObject3D) - , grid(grid) - , type(type) - , accuracy(a) -{ - -} -////////////////////////////////////////////////////////////////////////// -Interactor3D::~Interactor3D() -{ -} -////////////////////////////////////////////////////////////////////////// -bool Interactor3D::arePointsInsideGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta) -{ - bool result = true; - for (double ix3=minX3; ix3<=maxX3; ix3+=delta) - for (double ix2=minX2; ix2<=maxX2; ix2+=delta) - for (double ix1=minX1; ix1<=maxX1; ix1+=delta) - result = result && this->geoObject3D->isPointInGbObject3D(ix1, ix2, ix3); - - return result; -} -////////////////////////////////////////////////////////////////////////// -bool Interactor3D::arePointsOutsideGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta) -{ - bool result = true; - for (double ix3=minX3; ix3<=maxX3; ix3+=delta) - for (double ix2=minX2; ix2<=maxX2; ix2+=delta) - for (double ix1=minX1; ix1<=maxX1; ix1+=delta) - result = result && (!this->geoObject3D->isPointInGbObject3D(ix1, ix2, ix3)); - - return result; -} -////////////////////////////////////////////////////////////////////////// -bool Interactor3D::arePointsCuttingGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta) -{ - bool result = true; - for (double ix3=minX3; ix3<=maxX3; ix3+=delta) - for (double ix2=minX2; ix2<=maxX2; ix2+=delta) - for (double ix1=minX1; ix1<=maxX1; ix1+=delta) - result = result || this->geoObject3D->isPointInGbObject3D(ix1, ix2, ix3); - - return result; -} -////////////////////////////////////////////////////////////////////////// -bool Interactor3D::isBlockOutsideGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta) -{ - switch (accuracy) - { - //simple duff - case SIMPLE: - return !this->geoObject3D->isCellInsideOrCuttingGbObject3D(minX1,minX2,minX3,maxX1,maxX2,maxX3); - //test only edges - case EDGES: - return arePointsOutsideGeoObject(minX1, minX2, minX3, maxX1, minX2, minX3, delta) && - arePointsOutsideGeoObject(minX1, maxX2, minX3, maxX1, maxX2, minX3, delta) && - arePointsOutsideGeoObject(minX1, minX2, maxX3, maxX1, minX2, maxX3, delta) && - arePointsOutsideGeoObject(minX1, maxX2, maxX3, maxX1, maxX2, maxX3, delta) && - - arePointsOutsideGeoObject(minX1, minX2, minX3, minX1, maxX2, minX3, delta) && - arePointsOutsideGeoObject(maxX1, minX2, minX3, maxX1, maxX2, minX3, delta) && - arePointsOutsideGeoObject(minX1, minX2, maxX3, maxX1, minX2, maxX3, delta) && - arePointsOutsideGeoObject(maxX1, minX2, maxX3, maxX1, maxX2, maxX3, delta) && - - arePointsOutsideGeoObject(minX1, minX2, minX3, minX1, maxX2, maxX3, delta) && - arePointsOutsideGeoObject(maxX1, minX2, minX3, maxX1, maxX2, maxX3, delta) && - arePointsOutsideGeoObject(minX1, maxX2, minX3, maxX1, minX2, maxX3, delta) && - arePointsOutsideGeoObject(maxX1, maxX2, minX3, maxX1, maxX2, maxX3, delta); - //test only faces - case FACES: - return arePointsOutsideGeoObject(minX1, minX2, minX3, minX1, maxX2, maxX3, delta) && - arePointsOutsideGeoObject(maxX1, minX2, minX3, maxX1, maxX2, maxX3, delta) && - arePointsOutsideGeoObject(minX1, minX2, minX3, maxX1, minX2, maxX3, delta) && - arePointsOutsideGeoObject(minX1, maxX2, minX3, maxX1, maxX2, maxX3, delta) && - arePointsOutsideGeoObject(minX1, minX2, minX3, maxX1, maxX2, minX3, delta) && - arePointsOutsideGeoObject(minX1, minX2, maxX3, maxX1, maxX2, maxX3, delta); - //test all points - case POINTS: - return arePointsOutsideGeoObject(minX1, minX2, minX3, maxX1, maxX2, maxX3, delta); - default: - UB_THROW( UbException(UB_EXARGS, "Accuracy isn't correct") ); - break; - } -} -////////////////////////////////////////////////////////////////////////// -bool Interactor3D::isBlockInsideGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta) -{ - switch (accuracy) - { - //simple duff - case SIMPLE: - return this->geoObject3D->isCellInsideGbObject3D(minX1,minX2,minX3,maxX1,maxX2,maxX3); - //test only edges - case EDGES: - return arePointsInsideGeoObject(minX1, minX2, minX3, maxX1, minX2, minX3, delta) && - arePointsInsideGeoObject(minX1, maxX2, minX3, maxX1, maxX2, minX3, delta) && - arePointsInsideGeoObject(minX1, minX2, maxX3, maxX1, minX2, maxX3, delta) && - arePointsInsideGeoObject(minX1, maxX2, maxX3, maxX1, maxX2, maxX3, delta) && - - arePointsInsideGeoObject(minX1, minX2, minX3, minX1, maxX2, minX3, delta) && - arePointsInsideGeoObject(maxX1, minX2, minX3, maxX1, maxX2, minX3, delta) && - arePointsInsideGeoObject(minX1, minX2, maxX3, maxX1, minX2, maxX3, delta) && - arePointsInsideGeoObject(maxX1, minX2, maxX3, maxX1, maxX2, maxX3, delta) && - - arePointsInsideGeoObject(minX1, minX2, minX3, minX1, maxX2, maxX3, delta) && - arePointsInsideGeoObject(maxX1, minX2, minX3, maxX1, maxX2, maxX3, delta) && - arePointsInsideGeoObject(minX1, maxX2, minX3, maxX1, minX2, maxX3, delta) && - arePointsInsideGeoObject(maxX1, maxX2, minX3, maxX1, maxX2, maxX3, delta); - //test only faces - case FACES: - return arePointsInsideGeoObject(minX1, minX2, minX3, minX1, maxX2, maxX3, delta) && - arePointsInsideGeoObject(maxX1, minX2, minX3, maxX1, maxX2, maxX3, delta) && - arePointsInsideGeoObject(minX1, minX2, minX3, maxX1, minX2, maxX3, delta) && - arePointsInsideGeoObject(minX1, maxX2, minX3, maxX1, maxX2, maxX3, delta) && - arePointsInsideGeoObject(minX1, minX2, minX3, maxX1, maxX2, minX3, delta) && - arePointsInsideGeoObject(minX1, minX2, maxX3, maxX1, maxX2, maxX3, delta); - //test all points - case POINTS: - return arePointsInsideGeoObject(minX1, minX2, minX3, maxX1, maxX2, maxX3, delta); - default: - UB_THROW( UbException(UB_EXARGS, "Accuracy isn't correct") ); - break; - } -} -////////////////////////////////////////////////////////////////////////// -bool Interactor3D::isBlockCuttingGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta) -{ - switch (accuracy) - { - //simple duff - case SIMPLE: - return this->geoObject3D->isCellCuttingGbObject3D(minX1,minX2,minX3,maxX1,maxX2,maxX3); - //test only edges - case EDGES: - return arePointsCuttingGeoObject(minX1, minX2, minX3, maxX1, minX2, minX3, delta) || - arePointsCuttingGeoObject(minX1, maxX2, minX3, maxX1, maxX2, minX3, delta) || - arePointsCuttingGeoObject(minX1, minX2, maxX3, maxX1, minX2, maxX3, delta) || - arePointsCuttingGeoObject(minX1, maxX2, maxX3, maxX1, maxX2, maxX3, delta) || - - arePointsCuttingGeoObject(minX1, minX2, minX3, minX1, maxX2, minX3, delta) || - arePointsCuttingGeoObject(maxX1, minX2, minX3, maxX1, maxX2, minX3, delta) || - arePointsCuttingGeoObject(minX1, minX2, maxX3, maxX1, minX2, maxX3, delta) || - arePointsCuttingGeoObject(maxX1, minX2, maxX3, maxX1, maxX2, maxX3, delta) || - - arePointsCuttingGeoObject(minX1, minX2, minX3, minX1, maxX2, maxX3, delta) || - arePointsCuttingGeoObject(maxX1, minX2, minX3, maxX1, maxX2, maxX3, delta) || - arePointsCuttingGeoObject(minX1, maxX2, minX3, maxX1, minX2, maxX3, delta) || - arePointsCuttingGeoObject(maxX1, maxX2, minX3, maxX1, maxX2, maxX3, delta); - //test only faceCutting - case FACES: - return arePointsCuttingGeoObject(minX1, minX2, minX3, minX1, maxX2, maxX3, delta) || - arePointsCuttingGeoObject(maxX1, minX2, minX3, maxX1, maxX2, maxX3, delta) || - arePointsCuttingGeoObject(minX1, minX2, minX3, maxX1, minX2, maxX3, delta) || - arePointsCuttingGeoObject(minX1, maxX2, minX3, maxX1, maxX2, maxX3, delta) || - arePointsCuttingGeoObject(minX1, minX2, minX3, maxX1, maxX2, minX3, delta) || - arePointsCuttingGeoObject(minX1, minX2, maxX3, maxX1, maxX2, maxX3, delta); - //test all pointCutting - case POINTS: - return arePointsCuttingGeoObject(minX1, minX2, minX3, maxX1, maxX2, maxX3, delta); - default: - UB_THROW( UbException(UB_EXARGS, "Accuracy isn't correct") ); - break; - } -} -////////////////////////////////////////////////////////////////////////// -void Interactor3D::setSolidBlock(SPtr<Block3D> block) -{ - double minX1,minX2,minX3,maxX1,maxX2,maxX3; - - double deltaX = grid.lock()->getDeltaX(block); - UbTupleDouble3 blockLengths = grid.lock()->getBlockLengths(block); - UbTupleDouble3 org = grid.lock()->getBlockWorldCoordinates(block); - UbTupleDouble3 nodeOffset = grid.lock()->getNodeOffset(block); - - //coordinates of block without ghost layer - minX1 = val<1>(org) + val<1>(nodeOffset); - minX2 = val<2>(org) + val<2>(nodeOffset); - minX3 = val<3>(org) + val<3>(nodeOffset); - maxX1 = val<1>(org) + val<1>(blockLengths) - val<1>(nodeOffset); - maxX2 = val<2>(org) + val<2>(blockLengths) - val<2>(nodeOffset); - maxX3 = val<3>(org) + val<3>(blockLengths) - val<3>(nodeOffset); - - if(this->isInverseSolid()) - { - if(isBlockOutsideGeoObject(minX1, minX2, minX3, maxX1, maxX2, maxX3, deltaX)) - { - block->setActive(false); - this->solidBlocks.push_back(block); - } - } - else //solid - { - if(isBlockInsideGeoObject(minX1, minX2, minX3, maxX1, maxX2, maxX3, deltaX)) - { - block->setActive(false); - this->solidBlocks.push_back(block); - } - } -} -////////////////////////////////////////////////////////////////////////// -void Interactor3D::setBCBlock(SPtr<Block3D> block) -{ - double minX1,minX2,minX3,maxX1,maxX2,maxX3; - - double deltaX = grid.lock()->getDeltaX(block); - UbTupleDouble3 blockLengths = grid.lock()->getBlockLengths(block); - UbTupleDouble3 org = grid.lock()->getBlockWorldCoordinates(block); - UbTupleDouble3 nodeOffset = grid.lock()->getNodeOffset(block); - - //coordinates of block with ghost layer - minX1 = val<1>(org) - val<1>(nodeOffset); - minX2 = val<2>(org) - val<2>(nodeOffset); - minX3 = val<3>(org) - val<3>(nodeOffset); - maxX1 = val<1>(org) + val<1>(blockLengths) + val<1>(nodeOffset); - maxX2 = val<2>(org) + val<2>(blockLengths) + val<2>(nodeOffset); - maxX3 = val<3>(org) + val<3>(blockLengths) + val<3>(nodeOffset); - - if(isBlockCuttingGeoObject(minX1, minX2, minX3, maxX1, maxX2, maxX3, deltaX)) - this->bcBlocks.push_back(block); -} - -UbTupleDouble3 Interactor3D::getForces() -{ - UB_THROW( UbException("UbTupleDouble3 getForces() - gehoert in die abgeleitete klasse") ); -} -void Interactor3D::setID(int id) -{ - this->id = id; -} -////////////////////////////////////////////////////////////////////////// -int Interactor3D::getID() -{ - return id; -} -////////////////////////////////////////////////////////////////////////// -void Interactor3D::setActive() -{ - active = true; -} -////////////////////////////////////////////////////////////////////////// -void Interactor3D::setInactive() -{ - active = false; -} -////////////////////////////////////////////////////////////////////////// -bool Interactor3D::isActive() -{ - return active; -} -////////////////////////////////////////////////////////////////////////// -void Interactor3D::initInteractor(const double& timeStep) -{ - //UBLOG(logINFO, "transBlocks.size = "<<transBlocks.size()); - - for(SPtr<Block3D> block : bcBlocks) - { - this->setDifferencesToGbObject3D(block); - } -} -////////////////////////////////////////////////////////////////////////// -void Interactor3D::updateInteractor(const double& timeStep) -{ - UB_THROW( UbException("Interactor3D::updateInteractor - toDo") ); -} -////////////////////////////////////////////////////////////////////////// - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Interactor3D.cpp +//! \ingroup Interactor +//! \author Konstantin Kutscher +//======================================================================================= + +#include "Interactor3D.h" + +#include <fstream> +#include <geometry3d/GbCuboid3D.h> +#include <basics/utilities/UbMath.h> +#include "UbException.h" + +#include "Grid3D.h" +#include "Block3D.h" +#include "GbObject3D.h" + + +using namespace std; + +const int Interactor3D::SOLID = (1<<0); //1 +const int Interactor3D::INVERSESOLID = (1<<1); //2 +const int Interactor3D::TIMEDEPENDENT = (1<<2); //4 //zeitlich +const int Interactor3D::FLUID = (1<<3); //8 +const int Interactor3D::MOVEABLE = (1<<4); //16 // geometrisch +const int Interactor3D::CHANGENOTNECESSARY = (1<<5); //32 + + + +////////////////////////////////////////////////////////////////////////// +Interactor3D::Interactor3D() + : type(SOLID) +{ + +} +////////////////////////////////////////////////////////////////////////// +Interactor3D::Interactor3D(SPtr<Grid3D> grid, int type) + : type(type) + , grid(grid) +{ + +} +////////////////////////////////////////////////////////////////////////// +Interactor3D::Interactor3D(SPtr<GbObject3D> geoObject3D, SPtr<Grid3D> grid, int type) + : geoObject3D(geoObject3D) + , grid(grid) + , type(type) + , accuracy(SIMPLE) +{ + +} +////////////////////////////////////////////////////////////////////////// +Interactor3D::Interactor3D(SPtr<GbObject3D> geoObject3D, SPtr<Grid3D> grid, int type, Interactor3D::Accuracy a) + : geoObject3D(geoObject3D) + , grid(grid) + , type(type) + , accuracy(a) +{ + +} +////////////////////////////////////////////////////////////////////////// +Interactor3D::~Interactor3D() +{ +} +////////////////////////////////////////////////////////////////////////// +bool Interactor3D::arePointsInsideGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta) +{ + bool result = true; + for (double ix3=minX3; ix3<=maxX3; ix3+=delta) + for (double ix2=minX2; ix2<=maxX2; ix2+=delta) + for (double ix1=minX1; ix1<=maxX1; ix1+=delta) + result = result && this->geoObject3D->isPointInGbObject3D(ix1, ix2, ix3); + + return result; +} +////////////////////////////////////////////////////////////////////////// +bool Interactor3D::arePointsOutsideGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta) +{ + bool result = true; + for (double ix3=minX3; ix3<=maxX3; ix3+=delta) + for (double ix2=minX2; ix2<=maxX2; ix2+=delta) + for (double ix1=minX1; ix1<=maxX1; ix1+=delta) + result = result && (!this->geoObject3D->isPointInGbObject3D(ix1, ix2, ix3)); + + return result; +} +////////////////////////////////////////////////////////////////////////// +bool Interactor3D::arePointsCuttingGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta) +{ + bool result = true; + for (double ix3=minX3; ix3<=maxX3; ix3+=delta) + for (double ix2=minX2; ix2<=maxX2; ix2+=delta) + for (double ix1=minX1; ix1<=maxX1; ix1+=delta) + result = result || this->geoObject3D->isPointInGbObject3D(ix1, ix2, ix3); + + return result; +} +////////////////////////////////////////////////////////////////////////// +bool Interactor3D::isBlockOutsideGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta) +{ + switch (accuracy) + { + //simple duff + case SIMPLE: + return !this->geoObject3D->isCellInsideOrCuttingGbObject3D(minX1,minX2,minX3,maxX1,maxX2,maxX3); + //test only edges + case EDGES: + return arePointsOutsideGeoObject(minX1, minX2, minX3, maxX1, minX2, minX3, delta) && + arePointsOutsideGeoObject(minX1, maxX2, minX3, maxX1, maxX2, minX3, delta) && + arePointsOutsideGeoObject(minX1, minX2, maxX3, maxX1, minX2, maxX3, delta) && + arePointsOutsideGeoObject(minX1, maxX2, maxX3, maxX1, maxX2, maxX3, delta) && + + arePointsOutsideGeoObject(minX1, minX2, minX3, minX1, maxX2, minX3, delta) && + arePointsOutsideGeoObject(maxX1, minX2, minX3, maxX1, maxX2, minX3, delta) && + arePointsOutsideGeoObject(minX1, minX2, maxX3, maxX1, minX2, maxX3, delta) && + arePointsOutsideGeoObject(maxX1, minX2, maxX3, maxX1, maxX2, maxX3, delta) && + + arePointsOutsideGeoObject(minX1, minX2, minX3, minX1, maxX2, maxX3, delta) && + arePointsOutsideGeoObject(maxX1, minX2, minX3, maxX1, maxX2, maxX3, delta) && + arePointsOutsideGeoObject(minX1, maxX2, minX3, maxX1, minX2, maxX3, delta) && + arePointsOutsideGeoObject(maxX1, maxX2, minX3, maxX1, maxX2, maxX3, delta); + //test only faces + case FACES: + return arePointsOutsideGeoObject(minX1, minX2, minX3, minX1, maxX2, maxX3, delta) && + arePointsOutsideGeoObject(maxX1, minX2, minX3, maxX1, maxX2, maxX3, delta) && + arePointsOutsideGeoObject(minX1, minX2, minX3, maxX1, minX2, maxX3, delta) && + arePointsOutsideGeoObject(minX1, maxX2, minX3, maxX1, maxX2, maxX3, delta) && + arePointsOutsideGeoObject(minX1, minX2, minX3, maxX1, maxX2, minX3, delta) && + arePointsOutsideGeoObject(minX1, minX2, maxX3, maxX1, maxX2, maxX3, delta); + //test all points + case POINTS: + return arePointsOutsideGeoObject(minX1, minX2, minX3, maxX1, maxX2, maxX3, delta); + default: + UB_THROW( UbException(UB_EXARGS, "Accuracy isn't correct") ); + break; + } +} +////////////////////////////////////////////////////////////////////////// +bool Interactor3D::isBlockInsideGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta) +{ + switch (accuracy) + { + //simple duff + case SIMPLE: + return this->geoObject3D->isCellInsideGbObject3D(minX1,minX2,minX3,maxX1,maxX2,maxX3); + //test only edges + case EDGES: + return arePointsInsideGeoObject(minX1, minX2, minX3, maxX1, minX2, minX3, delta) && + arePointsInsideGeoObject(minX1, maxX2, minX3, maxX1, maxX2, minX3, delta) && + arePointsInsideGeoObject(minX1, minX2, maxX3, maxX1, minX2, maxX3, delta) && + arePointsInsideGeoObject(minX1, maxX2, maxX3, maxX1, maxX2, maxX3, delta) && + + arePointsInsideGeoObject(minX1, minX2, minX3, minX1, maxX2, minX3, delta) && + arePointsInsideGeoObject(maxX1, minX2, minX3, maxX1, maxX2, minX3, delta) && + arePointsInsideGeoObject(minX1, minX2, maxX3, maxX1, minX2, maxX3, delta) && + arePointsInsideGeoObject(maxX1, minX2, maxX3, maxX1, maxX2, maxX3, delta) && + + arePointsInsideGeoObject(minX1, minX2, minX3, minX1, maxX2, maxX3, delta) && + arePointsInsideGeoObject(maxX1, minX2, minX3, maxX1, maxX2, maxX3, delta) && + arePointsInsideGeoObject(minX1, maxX2, minX3, maxX1, minX2, maxX3, delta) && + arePointsInsideGeoObject(maxX1, maxX2, minX3, maxX1, maxX2, maxX3, delta); + //test only faces + case FACES: + return arePointsInsideGeoObject(minX1, minX2, minX3, minX1, maxX2, maxX3, delta) && + arePointsInsideGeoObject(maxX1, minX2, minX3, maxX1, maxX2, maxX3, delta) && + arePointsInsideGeoObject(minX1, minX2, minX3, maxX1, minX2, maxX3, delta) && + arePointsInsideGeoObject(minX1, maxX2, minX3, maxX1, maxX2, maxX3, delta) && + arePointsInsideGeoObject(minX1, minX2, minX3, maxX1, maxX2, minX3, delta) && + arePointsInsideGeoObject(minX1, minX2, maxX3, maxX1, maxX2, maxX3, delta); + //test all points + case POINTS: + return arePointsInsideGeoObject(minX1, minX2, minX3, maxX1, maxX2, maxX3, delta); + default: + UB_THROW( UbException(UB_EXARGS, "Accuracy isn't correct") ); + break; + } +} +////////////////////////////////////////////////////////////////////////// +bool Interactor3D::isBlockCuttingGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta) +{ + switch (accuracy) + { + //simple duff + case SIMPLE: + return this->geoObject3D->isCellCuttingGbObject3D(minX1,minX2,minX3,maxX1,maxX2,maxX3); + //test only edges + case EDGES: + return arePointsCuttingGeoObject(minX1, minX2, minX3, maxX1, minX2, minX3, delta) || + arePointsCuttingGeoObject(minX1, maxX2, minX3, maxX1, maxX2, minX3, delta) || + arePointsCuttingGeoObject(minX1, minX2, maxX3, maxX1, minX2, maxX3, delta) || + arePointsCuttingGeoObject(minX1, maxX2, maxX3, maxX1, maxX2, maxX3, delta) || + + arePointsCuttingGeoObject(minX1, minX2, minX3, minX1, maxX2, minX3, delta) || + arePointsCuttingGeoObject(maxX1, minX2, minX3, maxX1, maxX2, minX3, delta) || + arePointsCuttingGeoObject(minX1, minX2, maxX3, maxX1, minX2, maxX3, delta) || + arePointsCuttingGeoObject(maxX1, minX2, maxX3, maxX1, maxX2, maxX3, delta) || + + arePointsCuttingGeoObject(minX1, minX2, minX3, minX1, maxX2, maxX3, delta) || + arePointsCuttingGeoObject(maxX1, minX2, minX3, maxX1, maxX2, maxX3, delta) || + arePointsCuttingGeoObject(minX1, maxX2, minX3, maxX1, minX2, maxX3, delta) || + arePointsCuttingGeoObject(maxX1, maxX2, minX3, maxX1, maxX2, maxX3, delta); + //test only faceCutting + case FACES: + return arePointsCuttingGeoObject(minX1, minX2, minX3, minX1, maxX2, maxX3, delta) || + arePointsCuttingGeoObject(maxX1, minX2, minX3, maxX1, maxX2, maxX3, delta) || + arePointsCuttingGeoObject(minX1, minX2, minX3, maxX1, minX2, maxX3, delta) || + arePointsCuttingGeoObject(minX1, maxX2, minX3, maxX1, maxX2, maxX3, delta) || + arePointsCuttingGeoObject(minX1, minX2, minX3, maxX1, maxX2, minX3, delta) || + arePointsCuttingGeoObject(minX1, minX2, maxX3, maxX1, maxX2, maxX3, delta); + //test all pointCutting + case POINTS: + return arePointsCuttingGeoObject(minX1, minX2, minX3, maxX1, maxX2, maxX3, delta); + default: + UB_THROW( UbException(UB_EXARGS, "Accuracy isn't correct") ); + break; + } +} +////////////////////////////////////////////////////////////////////////// +void Interactor3D::setSolidBlock(SPtr<Block3D> block) +{ + double minX1,minX2,minX3,maxX1,maxX2,maxX3; + + double deltaX = grid.lock()->getDeltaX(block); + UbTupleDouble3 blockLengths = grid.lock()->getBlockLengths(block); + UbTupleDouble3 org = grid.lock()->getBlockWorldCoordinates(block); + UbTupleDouble3 nodeOffset = grid.lock()->getNodeOffset(block); + + //coordinates of block without ghost layer + minX1 = val<1>(org) + val<1>(nodeOffset); + minX2 = val<2>(org) + val<2>(nodeOffset); + minX3 = val<3>(org) + val<3>(nodeOffset); + maxX1 = val<1>(org) + val<1>(blockLengths) - val<1>(nodeOffset); + maxX2 = val<2>(org) + val<2>(blockLengths) - val<2>(nodeOffset); + maxX3 = val<3>(org) + val<3>(blockLengths) - val<3>(nodeOffset); + + if(this->isInverseSolid()) + { + if(isBlockOutsideGeoObject(minX1, minX2, minX3, maxX1, maxX2, maxX3, deltaX)) + { + block->setActive(false); + this->solidBlocks.push_back(block); + } + } + else //solid + { + if(isBlockInsideGeoObject(minX1, minX2, minX3, maxX1, maxX2, maxX3, deltaX)) + { + block->setActive(false); + this->solidBlocks.push_back(block); + } + } +} +////////////////////////////////////////////////////////////////////////// +void Interactor3D::setBCBlock(SPtr<Block3D> block) +{ + double minX1,minX2,minX3,maxX1,maxX2,maxX3; + + double deltaX = grid.lock()->getDeltaX(block); + UbTupleDouble3 blockLengths = grid.lock()->getBlockLengths(block); + UbTupleDouble3 org = grid.lock()->getBlockWorldCoordinates(block); + UbTupleDouble3 nodeOffset = grid.lock()->getNodeOffset(block); + + //coordinates of block with ghost layer + minX1 = val<1>(org) - val<1>(nodeOffset); + minX2 = val<2>(org) - val<2>(nodeOffset); + minX3 = val<3>(org) - val<3>(nodeOffset); + maxX1 = val<1>(org) + val<1>(blockLengths) + val<1>(nodeOffset); + maxX2 = val<2>(org) + val<2>(blockLengths) + val<2>(nodeOffset); + maxX3 = val<3>(org) + val<3>(blockLengths) + val<3>(nodeOffset); + + if(isBlockCuttingGeoObject(minX1, minX2, minX3, maxX1, maxX2, maxX3, deltaX)) + this->bcBlocks.push_back(block); +} + +UbTupleDouble3 Interactor3D::getForces() +{ + UB_THROW( UbException("UbTupleDouble3 getForces() - gehoert in die abgeleitete klasse") ); +} +void Interactor3D::setID(int id) +{ + this->id = id; +} +////////////////////////////////////////////////////////////////////////// +int Interactor3D::getID() +{ + return id; +} +////////////////////////////////////////////////////////////////////////// +void Interactor3D::setActive() +{ + active = true; +} +////////////////////////////////////////////////////////////////////////// +void Interactor3D::setInactive() +{ + active = false; +} +////////////////////////////////////////////////////////////////////////// +bool Interactor3D::isActive() +{ + return active; +} +////////////////////////////////////////////////////////////////////////// +void Interactor3D::initInteractor(const double& timeStep) +{ + //UBLOG(logINFO, "transBlocks.size = "<<transBlocks.size()); + + for(SPtr<Block3D> block : bcBlocks) + { + this->setDifferencesToGbObject3D(block); + } +} +////////////////////////////////////////////////////////////////////////// +void Interactor3D::updateInteractor(const double& timeStep) +{ + UB_THROW( UbException("Interactor3D::updateInteractor - toDo") ); +} +////////////////////////////////////////////////////////////////////////// + diff --git a/src/cpu/VirtualFluidsCore/Interactors/Interactor3D.h b/src/cpu/VirtualFluidsCore/Interactors/Interactor3D.h index e5c7c5d72..56390b18c 100644 --- a/src/cpu/VirtualFluidsCore/Interactors/Interactor3D.h +++ b/src/cpu/VirtualFluidsCore/Interactors/Interactor3D.h @@ -1,117 +1,146 @@ -#ifndef INTERACTOR3D_H -#define INTERACTOR3D_H - -#include <vector> -#include <PointerDefinitions.h> - -#include "UbSystem.h" -#include "UbTuple.h" - -class Block3D; -class Grid3D; -class UbFileInput; -class UbFileOutput; -class GbObject3D; -class Block3D; - - - -class Interactor3D : public enableSharedFromThis<Interactor3D> -{ -public: - enum Accuracy{SIMPLE, EDGES, FACES, POINTS}; - Interactor3D(); - Interactor3D(SPtr<Grid3D> grid, int type=Interactor3D::SOLID); - Interactor3D(SPtr<GbObject3D> geoObject3D, SPtr<Grid3D> grid, int type); - //! constructor - //! \param a set accuracy for arePointsInObject() and arePointsNotInObject() - Interactor3D(SPtr<GbObject3D> geoObject3D, SPtr<Grid3D> grid, int type, Interactor3D::Accuracy a); - - virtual ~Interactor3D(); - virtual void initInteractor(const double& timestep=0); - virtual void updateInteractor(const double& timestep=0)=0; - - void setSolidBlock(SPtr<Block3D> block); - void setBCBlock(SPtr<Block3D> block); - - virtual UbTupleDouble3 getForces(); - - void setSolid() { UbSystem::setBit(this->type, SOLID ); } - void setMoveable() { UbSystem::setBit(this->type, MOVEABLE); } - - bool isSolid() { return UbSystem::bitCheck(this->type, SOLID ); } - bool isInverseSolid() { return UbSystem::bitCheck(this->type, INVERSESOLID ); } - bool isTimeDependent() { return UbSystem::bitCheck(this->type, TIMEDEPENDENT); } - bool isMoveable() { return UbSystem::bitCheck(this->type, MOVEABLE ); } - - SPtr<Grid3D> getGrid3D() const { return grid.lock(); } - void setGrid3D(SPtr<Grid3D> grid) { this->grid = grid; } - virtual SPtr<GbObject3D> getGbObject3D() const { return geoObject3D; } - virtual bool setDifferencesToGbObject3D(const SPtr<Block3D> block/*, const double& x1, const double& x2, const double& x3, const double& blockLengthX1, const double& blockLengthX2, const double& blockLengthX3, const double& timestep=0*/) - { - //UBLOG(logINFO, "Interactor3D::setDifferencesToGbObject3D()"); - return false; - } - - virtual std::vector<SPtr<Block3D> >& getBcBlocks() { return this->bcBlocks; } - virtual void removeBcBlocks() { this->bcBlocks.clear(); } - virtual std::vector<SPtr<Block3D> >& getSolidBlockSet() { return this->solidBlocks; } - virtual void removeSolidBlocks() { this->solidBlocks.clear(); } - - void setID(int id); - int getID(); - - void setActive(); - void setInactive(); - bool isActive(); - -protected: - void setTimeDependent() { UbSystem::setBit(this->type , TIMEDEPENDENT); } - void unsetTimeDependent() { UbSystem::unsetBit(this->type, TIMEDEPENDENT); } - - //! detect that points are inside object - //! \param min/max coordinates of bounding box - //! \param delta is delta x - bool arePointsInsideGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta); - - //! detect that points aren't inside object - //! \param min/max coordinates of bounding box - //! \param delta is delta x - bool arePointsOutsideGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta); - - //! detect that points are cutting object - //! \param min/max coordinates of bounding box - //! \param delta is delta x - bool arePointsCuttingGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta); - - bool isBlockOutsideGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta); - bool isBlockInsideGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta); - bool isBlockCuttingGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta); - - int type; - - WPtr<Grid3D> grid; - SPtr<GbObject3D> geoObject3D; - - std::vector<SPtr<Block3D> > bcBlocks; - std::vector<SPtr<Block3D> > solidBlocks; - int accuracy; - - bool active; - int id; - -public: - static const int SOLID ;//= (1<<0); //1 - static const int INVERSESOLID ;//= (1<<1); //2 - static const int TIMEDEPENDENT ;//= (1<<2); //4 //zeitlich - static const int FLUID ;//= (1<<3); //8 - static const int MOVEABLE ;//= (1<<4); //16 // geometrisch - static const int CHANGENOTNECESSARY ;//= (1<<5); //32 - -private: - -}; - - - -#endif +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Interactor3D.h +//! \ingroup Interactor +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef INTERACTOR3D_H +#define INTERACTOR3D_H + +#include <vector> +#include <PointerDefinitions.h> + +#include "UbSystem.h" +#include "UbTuple.h" + +class Block3D; +class Grid3D; +class GbObject3D; + +//! A base class for grid generation. +class Interactor3D : public enableSharedFromThis<Interactor3D> +{ +public: + enum Accuracy{SIMPLE, EDGES, FACES, POINTS}; + Interactor3D(); + Interactor3D(SPtr<Grid3D> grid, int type=Interactor3D::SOLID); + Interactor3D(SPtr<GbObject3D> geoObject3D, SPtr<Grid3D> grid, int type); + //! constructor + //! \param a set accuracy for arePointsInObject() and arePointsNotInObject() + Interactor3D(SPtr<GbObject3D> geoObject3D, SPtr<Grid3D> grid, int type, Interactor3D::Accuracy a); + + virtual ~Interactor3D(); + virtual void initInteractor(const double& timestep=0); + virtual void updateInteractor(const double& timestep=0)=0; + + void setSolidBlock(SPtr<Block3D> block); + void setBCBlock(SPtr<Block3D> block); + + virtual UbTupleDouble3 getForces(); + + void setSolid() { UbSystem::setBit(this->type, SOLID ); } + void setMoveable() { UbSystem::setBit(this->type, MOVEABLE); } + + bool isSolid() { return UbSystem::bitCheck(this->type, SOLID ); } + bool isInverseSolid() { return UbSystem::bitCheck(this->type, INVERSESOLID ); } + bool isTimeDependent() { return UbSystem::bitCheck(this->type, TIMEDEPENDENT); } + bool isMoveable() { return UbSystem::bitCheck(this->type, MOVEABLE ); } + + SPtr<Grid3D> getGrid3D() const { return grid.lock(); } + void setGrid3D(SPtr<Grid3D> grid) { this->grid = grid; } + virtual SPtr<GbObject3D> getGbObject3D() const { return geoObject3D; } + virtual bool setDifferencesToGbObject3D(const SPtr<Block3D> block/*, const double& x1, const double& x2, const double& x3, const double& blockLengthX1, const double& blockLengthX2, const double& blockLengthX3, const double& timestep=0*/) + { + //UBLOG(logINFO, "Interactor3D::setDifferencesToGbObject3D()"); + return false; + } + + virtual std::vector<SPtr<Block3D> >& getBcBlocks() { return this->bcBlocks; } + virtual void removeBcBlocks() { this->bcBlocks.clear(); } + virtual std::vector<SPtr<Block3D> >& getSolidBlockSet() { return this->solidBlocks; } + virtual void removeSolidBlocks() { this->solidBlocks.clear(); } + + void setID(int id); + int getID(); + + void setActive(); + void setInactive(); + bool isActive(); + +protected: + void setTimeDependent() { UbSystem::setBit(this->type , TIMEDEPENDENT); } + void unsetTimeDependent() { UbSystem::unsetBit(this->type, TIMEDEPENDENT); } + + //! detect that points are inside object + //! \param min/max coordinates of bounding box + //! \param delta is delta x + bool arePointsInsideGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta); + + //! detect that points aren't inside object + //! \param min/max coordinates of bounding box + //! \param delta is delta x + bool arePointsOutsideGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta); + + //! detect that points are cutting object + //! \param min/max coordinates of bounding box + //! \param delta is delta x + bool arePointsCuttingGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta); + + bool isBlockOutsideGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta); + bool isBlockInsideGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta); + bool isBlockCuttingGeoObject(double minX1, double minX2, double minX3, double maxX1, double maxX2, double maxX3, double delta); + + int type; + + WPtr<Grid3D> grid; + SPtr<GbObject3D> geoObject3D; + + std::vector<SPtr<Block3D> > bcBlocks; + std::vector<SPtr<Block3D> > solidBlocks; + int accuracy; + + bool active; + int id; + +public: + static const int SOLID ;//= (1<<0); //1 + static const int INVERSESOLID ;//= (1<<1); //2 + static const int TIMEDEPENDENT ;//= (1<<2); //4 //zeitlich + static const int FLUID ;//= (1<<3); //8 + static const int MOVEABLE ;//= (1<<4); //16 // geometrisch + static const int CHANGENOTNECESSARY ;//= (1<<5); //32 + +private: + +}; + + + +#endif diff --git a/src/cpu/VirtualFluidsCore/Interactors/InteractorsHelper.cpp b/src/cpu/VirtualFluidsCore/Interactors/InteractorsHelper.cpp index 2d11b43f9..ff6fe730c 100644 --- a/src/cpu/VirtualFluidsCore/Interactors/InteractorsHelper.cpp +++ b/src/cpu/VirtualFluidsCore/Interactors/InteractorsHelper.cpp @@ -1,86 +1,78 @@ -#include "InteractorsHelper.h" - -#include <Grid3DVisitor.h> -#include <Grid3D.h> -#include <Interactor3D.h> -#include "Block3D.h" -#include "Communicator.h" -#include "SetSolidBlocksBlockVisitor.h" -#include "SetBcBlocksBlockVisitor.h" - - -InteractorsHelper::InteractorsHelper(SPtr<Grid3D> grid, SPtr<Grid3DVisitor> visitor, bool deleteBlocks) : - grid(grid), visitor(visitor), deleteBlocks(deleteBlocks) -{ - -} -////////////////////////////////////////////////////////////////////////// -InteractorsHelper::~InteractorsHelper() -{ - -} -////////////////////////////////////////////////////////////////////////// -void InteractorsHelper::addInteractor( SPtr<Interactor3D> interactor ) -{ - interactors.push_back(interactor); -} -////////////////////////////////////////////////////////////////////////// -void InteractorsHelper::setBC() -{ - for(SPtr<Interactor3D> i : interactors) - i->initInteractor(); -} - -void InteractorsHelper::sendDomainDecompositionVisitor() const -{ - grid->accept( visitor ); -} - -////////////////////////////////////////////////////////////////////////// -void InteractorsHelper::selectBlocks() -{ - sendDomainDecompositionVisitor(); - deleteSolidBlocks(); - - sendDomainDecompositionVisitor(); - setBcBlocks(); -} -////////////////////////////////////////////////////////////////////////// -void InteractorsHelper::deleteSolidBlocks() -{ - for(SPtr<Interactor3D> interactor : interactors) - { - SetSolidBlocksBlockVisitor v(interactor); - grid->accept(v); - if (deleteBlocks) - { - std::vector<SPtr<Block3D>>& sb = interactor->getSolidBlockSet(); - solidBlocks.insert(solidBlocks.end(), sb.begin(), sb.end()); - interactor->removeSolidBlocks(); - } - } - - if (deleteBlocks) updateGrid(); -} -////////////////////////////////////////////////////////////////////////// -void InteractorsHelper::setBcBlocks() -{ - for(const SPtr<Interactor3D> interactor : interactors) - { - SetBcBlocksBlockVisitor v(interactor); - grid->accept(v); - } -} -////////////////////////////////////////////////////////////////////////// -void InteractorsHelper::updateGrid() -{ - std::vector<int> ids; - - for(const SPtr<Block3D> block : solidBlocks) - ids.push_back(block->getGlobalID()); - - std::vector<int> rids; - Communicator::getInstance()->allGather(ids, rids); - grid->deleteBlocks(rids); -} - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file InteractorsHelper.cpp +//! \ingroup Interactor +//! \author Konstantin Kutscher +//======================================================================================= + +#include "InteractorsHelper.h" + +#include <Grid3DVisitor.h> +#include <Grid3D.h> +#include <Interactor3D.h> +#include "Block3D.h" +#include "SetSolidBlocksBlockVisitor.h" +#include "SetBcBlocksBlockVisitor.h" + + +InteractorsHelper::InteractorsHelper(SPtr<Grid3D> grid) :grid(grid) +{ + +} +////////////////////////////////////////////////////////////////////////// +InteractorsHelper::~InteractorsHelper() +{ + +} +////////////////////////////////////////////////////////////////////////// +void InteractorsHelper::addInteractor( SPtr<Interactor3D> interactor ) +{ + interactors.push_back(interactor); +} +////////////////////////////////////////////////////////////////////////// +void InteractorsHelper::setBC() +{ + for(SPtr<Interactor3D> i : interactors) + i->initInteractor(); +} +////////////////////////////////////////////////////////////////////////// +void InteractorsHelper::selectBlocks() +{ + setBcBlocks(); +} +////////////////////////////////////////////////////////////////////////// +void InteractorsHelper::setBcBlocks() +{ + for(const SPtr<Interactor3D> interactor : interactors) + { + SetBcBlocksBlockVisitor v(interactor); + grid->accept(v); + } +} + diff --git a/src/cpu/VirtualFluidsCore/Interactors/InteractorsHelper.h b/src/cpu/VirtualFluidsCore/Interactors/InteractorsHelper.h index 6380ba132..29ed01a16 100644 --- a/src/cpu/VirtualFluidsCore/Interactors/InteractorsHelper.h +++ b/src/cpu/VirtualFluidsCore/Interactors/InteractorsHelper.h @@ -1,38 +1,66 @@ -#ifndef SolidBlocksHelper_h -#define SolidBlocksHelper_h - -#include <vector> -#include <PointerDefinitions.h> - - -class Interactor3D; -class Block3D; -class Grid3D; -class Grid3DVisitor; - -class InteractorsHelper -{ -public: - InteractorsHelper(SPtr<Grid3D> grid, SPtr<Grid3DVisitor> visitor, bool deleteBlocks=true); - ~InteractorsHelper(); - - void addInteractor(SPtr<Interactor3D> interactor); - void selectBlocks(); - void setBC(); - void sendDomainDecompositionVisitor() const; - -protected: - void deleteSolidBlocks(); - void setBcBlocks(); - -private: - void updateGrid(); - - std::vector<SPtr<Interactor3D> > interactors; - SPtr<Grid3D> grid; - std::vector<SPtr<Block3D> > solidBlocks; - SPtr<Grid3DVisitor> visitor; - bool deleteBlocks; -}; - -#endif +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file InteractorsHelper.h +//! \ingroup Interactor +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef InteractorsHelper_h +#define InteractorsHelper_h + +#include <vector> +#include <PointerDefinitions.h> + + +class Interactor3D; +class Block3D; +class Grid3D; +class Grid3DVisitor; + +//! A helper class for grid generation. +class InteractorsHelper +{ +public: + InteractorsHelper(SPtr<Grid3D> grid); + ~InteractorsHelper(); + + void addInteractor(SPtr<Interactor3D> interactor); + void selectBlocks(); + void setBC(); +protected: + void setBcBlocks(); +private: + std::vector<SPtr<Interactor3D> > interactors; + SPtr<Grid3D> grid; + std::vector<SPtr<Block3D> > solidBlocks; + SPtr<Grid3DVisitor> visitor; + bool deleteBlocks; +}; + +#endif diff --git a/src/cpu/VirtualFluidsCore/Interactors/package.include b/src/cpu/VirtualFluidsCore/Interactors/package.include deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/cpu/VirtualFluidsCore/LBM/BGKLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/BGKLBMKernel.cpp deleted file mode 100644 index f91a4197a..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/BGKLBMKernel.cpp +++ /dev/null @@ -1,299 +0,0 @@ -#include "BGKLBMKernel.h" -#include "D3Q27System.h" -#include "D3Q27EsoTwist3DSplittedVector.h" -#include "D3Q27EsoTwist3DSoA.h" -#include "DataSet3D.h" -#include "BCProcessor.h" -#include "BCArray3D.h" - -//#define PROOF_CORRECTNESS - -////////////////////////////////////////////////////////////////////////// -BGKLBMKernel::BGKLBMKernel() -{ - this->compressible = false; -} -////////////////////////////////////////////////////////////////////////// -BGKLBMKernel::~BGKLBMKernel(void) -{ - -} -////////////////////////////////////////////////////////////////////////// -void BGKLBMKernel::initDataSet() -{ - SPtr<DistributionArray3D> d(new D3Q27EsoTwist3DSplittedVector(nx[0]+2, nx[1]+2, nx[2]+2, -999.9)); - dataSet->setFdistributions(d); -} -////////////////////////////////////////////////////////////////////////// -SPtr<LBMKernel> BGKLBMKernel::clone() -{ - SPtr<LBMKernel> kernel(new BGKLBMKernel()); - std::dynamic_pointer_cast<BGKLBMKernel>(kernel)->initDataSet(); - kernel->setCollisionFactor(this->collFactor); - kernel->setBCProcessor(bcProcessor->clone(kernel)); - kernel->setWithForcing(withForcing); - kernel->setForcingX1(muForcingX1); - kernel->setForcingX2(muForcingX2); - kernel->setForcingX3(muForcingX3); - kernel->setIndex(ix1, ix2, ix3); - return kernel; -} -////////////////////////////////////////////////////////////////////////// -void BGKLBMKernel::calculate(int step) -{ - using namespace D3Q27System; - - //initializing of forcing stuff - if (withForcing) - { - muForcingX1.DefineVar("x1",&muX1); muForcingX1.DefineVar("x2",&muX2); muForcingX1.DefineVar("x3",&muX3); - muForcingX2.DefineVar("x1",&muX1); muForcingX2.DefineVar("x2",&muX2); muForcingX2.DefineVar("x3",&muX3); - muForcingX3.DefineVar("x1",&muX1); muForcingX3.DefineVar("x2",&muX2); muForcingX3.DefineVar("x3",&muX3); - forcingX1 = 0; - forcingX2 = 0; - forcingX3 = 0; - } - ///////////////////////////////////// - - localDistributions = std::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getLocalDistributions(); - nonLocalDistributions = std::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getNonLocalDistributions(); - zeroDistributions = std::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getZeroDistributions(); - - SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); - LBMReal f[D3Q27System::ENDF+1]; - LBMReal feq[D3Q27System::ENDF+1]; - LBMReal drho,vx1,vx2,vx3; - const int bcArrayMaxX1 = (int)bcArray->getNX1(); - const int bcArrayMaxX2 = (int)bcArray->getNX2(); - const int bcArrayMaxX3 = (int)bcArray->getNX3(); - - int minX1 = ghostLayerWidth; - int minX2 = ghostLayerWidth; - int minX3 = ghostLayerWidth; - int maxX1 = bcArrayMaxX1-ghostLayerWidth; - int maxX2 = bcArrayMaxX2-ghostLayerWidth; - int maxX3 = bcArrayMaxX3-ghostLayerWidth; - - for(int x3 = minX3; x3 < maxX3; x3++) - { - for(int x2 = minX2; x2 < maxX2; x2++) - { - for(int x1 = minX1; x1 < maxX1; x1++) - { - if(!bcArray->isSolid(x1,x2,x3) && !bcArray->isUndefined(x1,x2,x3)) - { - int x1p = x1 + 1; - int x2p = x2 + 1; - int x3p = x3 + 1; - ////////////////////////////////////////////////////////////////////////// - //read distribution - //////////////////////////////////////////////////////////////////////////// - f[ZERO] = (*this->zeroDistributions)(x1,x2,x3); - - f[E] = (*this->localDistributions)(D3Q27System::ET_E, x1,x2,x3); - f[N] = (*this->localDistributions)(D3Q27System::ET_N,x1,x2,x3); - f[T] = (*this->localDistributions)(D3Q27System::ET_T,x1,x2,x3); - f[NE] = (*this->localDistributions)(D3Q27System::ET_NE,x1,x2,x3); - f[NW] = (*this->localDistributions)(D3Q27System::ET_NW,x1p,x2,x3); - f[TE] = (*this->localDistributions)(D3Q27System::ET_TE,x1,x2,x3); - f[TW] = (*this->localDistributions)(D3Q27System::ET_TW, x1p,x2,x3); - f[TN] = (*this->localDistributions)(D3Q27System::ET_TN,x1,x2,x3); - f[TS] = (*this->localDistributions)(D3Q27System::ET_TS,x1,x2p,x3); - f[TNE] = (*this->localDistributions)(D3Q27System::ET_TNE,x1,x2,x3); - f[TNW] = (*this->localDistributions)(D3Q27System::ET_TNW,x1p,x2,x3); - f[TSE] = (*this->localDistributions)(D3Q27System::ET_TSE,x1,x2p,x3); - f[TSW] = (*this->localDistributions)(D3Q27System::ET_TSW,x1p,x2p,x3); - - f[W ] = (*this->nonLocalDistributions)(D3Q27System::ET_W,x1p,x2,x3 ); - f[S ] = (*this->nonLocalDistributions)(D3Q27System::ET_S,x1,x2p,x3 ); - f[B ] = (*this->nonLocalDistributions)(D3Q27System::ET_B,x1,x2,x3p ); - f[SW] = (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1p,x2p,x3 ); - f[SE] = (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1,x2p,x3 ); - f[BW] = (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1p,x2,x3p ); - f[BE] = (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1,x2,x3p ); - f[BS] = (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1,x2p,x3p ); - f[BN] = (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1,x2,x3p ); - f[BSW] = (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1p,x2p,x3p); - f[BSE] = (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1,x2p,x3p); - f[BNW] = (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1p,x2,x3p); - f[BNE] = (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1,x2,x3p); - ////////////////////////////////////////////////////////////////////////// - - drho = f[ZERO] + f[E] + f[W] + f[N] + f[S] + f[T] + f[B] - + f[NE] + f[SW] + f[SE] + f[NW] + f[TE] + f[BW] + f[BE] - + f[TW] + f[TN] + f[BS] + f[BN] + f[TS] + f[TNE] + f[TSW] - + f[TSE] + f[TNW] + f[BNE] + f[BSW] + f[BSE] + f[BNW]; - - vx1 = f[E] - f[W] + f[NE] - f[SW] + f[SE] - f[NW] + f[TE] - f[BW] - + f[BE] - f[TW] + f[TNE] - f[TSW] + f[TSE] - f[TNW] + f[BNE] - f[BSW] - + f[BSE] - f[BNW]; - - vx2 = f[N] - f[S] + f[NE] - f[SW] - f[SE] + f[NW] + f[TN] - f[BS] + f[BN] - - f[TS] + f[TNE] - f[TSW] - f[TSE] + f[TNW] + f[BNE] - f[BSW] - f[BSE] - + f[BNW]; - - vx3 = f[T] - f[B] + f[TE] - f[BW] - f[BE] + f[TW] + f[TN] - f[BS] - f[BN] - + f[TS] + f[TNE] + f[TSW] + f[TSE] + f[TNW] - f[BNE] - f[BSW] - f[BSE] - - f[BNW]; - - LBMReal cu_sq=1.5*(vx1*vx1+vx2*vx2+vx3*vx3); - - feq[ZERO] = c8o27*(drho-cu_sq); - feq[E] = c2o27*(drho+3.0*( vx1 )+c9o2*( vx1 )*( vx1 )-cu_sq); - feq[W] = c2o27*(drho+3.0*(-vx1 )+c9o2*(-vx1 )*(-vx1 )-cu_sq); - feq[N] = c2o27*(drho+3.0*( vx2)+c9o2*( vx2)*( vx2)-cu_sq); - feq[S] = c2o27*(drho+3.0*( -vx2)+c9o2*( -vx2)*( -vx2)-cu_sq); - feq[T] = c2o27*(drho+3.0*( vx3 )+c9o2*( vx3)*( vx3)-cu_sq); - feq[B] = c2o27*(drho+3.0*( -vx3)+c9o2*( -vx3)*( -vx3)-cu_sq); - feq[NE] = c1o54*(drho+3.0*( vx1+vx2)+c9o2*( vx1+vx2)*( vx1+vx2)-cu_sq); - feq[SW] = c1o54*(drho+3.0*(-vx1-vx2)+c9o2*(-vx1-vx2)*(-vx1-vx2)-cu_sq); - feq[SE] = c1o54*(drho+3.0*( vx1-vx2)+c9o2*( vx1-vx2)*( vx1-vx2)-cu_sq); - feq[NW] = c1o54*(drho+3.0*(-vx1+vx2)+c9o2*(-vx1+vx2)*(-vx1+vx2)-cu_sq); - feq[TE] = c1o54*(drho+3.0*( vx1+vx3)+c9o2*( vx1+vx3)*( vx1+vx3)-cu_sq); - feq[BW] = c1o54*(drho+3.0*(-vx1-vx3)+c9o2*(-vx1-vx3)*(-vx1-vx3)-cu_sq); - feq[BE] = c1o54*(drho+3.0*( vx1-vx3)+c9o2*( vx1-vx3)*( vx1-vx3)-cu_sq); - feq[TW] = c1o54*(drho+3.0*(-vx1+vx3)+c9o2*(-vx1+vx3)*(-vx1+vx3)-cu_sq); - feq[TN] = c1o54*(drho+3.0*( vx2+vx3)+c9o2*( vx2+vx3)*( vx2+vx3)-cu_sq); - feq[BS] = c1o54*(drho+3.0*(-vx2-vx3)+c9o2*(-vx2-vx3)*(-vx2-vx3)-cu_sq); - feq[BN] = c1o54*(drho+3.0*( vx2-vx3)+c9o2*( vx2-vx3)*( vx2-vx3)-cu_sq); - feq[TS] = c1o54*(drho+3.0*(-vx2+vx3)+c9o2*(-vx2+vx3)*(-vx2+vx3)-cu_sq); - feq[TNE]= c1o216*(drho+3.0*( vx1+vx2+vx3)+c9o2*( vx1+vx2+vx3)*( vx1+vx2+vx3)-cu_sq); - feq[BSW]= c1o216*(drho+3.0*(-vx1-vx2-vx3)+c9o2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3)-cu_sq); - feq[BNE]= c1o216*(drho+3.0*( vx1+vx2-vx3)+c9o2*( vx1+vx2-vx3)*( vx1+vx2-vx3)-cu_sq); - feq[TSW]= c1o216*(drho+3.0*(-vx1-vx2+vx3)+c9o2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3)-cu_sq); - feq[TSE]= c1o216*(drho+3.0*( vx1-vx2+vx3)+c9o2*( vx1-vx2+vx3)*( vx1-vx2+vx3)-cu_sq); - feq[BNW]= c1o216*(drho+3.0*(-vx1+vx2-vx3)+c9o2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3)-cu_sq); - feq[BSE]= c1o216*(drho+3.0*( vx1-vx2-vx3)+c9o2*( vx1-vx2-vx3)*( vx1-vx2-vx3)-cu_sq); - feq[TNW]= c1o216*(drho+3.0*(-vx1+vx2+vx3)+c9o2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3)-cu_sq); - - //Relaxation - f[ZERO] += (feq[ZERO]-f[ZERO])*collFactor; - f[E] += (feq[E]-f[E])*collFactor; - f[W] += (feq[W]-f[W])*collFactor; - f[N] += (feq[N]-f[N])*collFactor; - f[S] += (feq[S]-f[S])*collFactor; - f[T] += (feq[T]-f[T])*collFactor; - f[B] += (feq[B]-f[B])*collFactor; - f[NE] += (feq[NE]-f[NE])*collFactor; - f[SW] += (feq[SW]-f[SW])*collFactor; - f[SE] += (feq[SE]-f[SE])*collFactor; - f[NW] += (feq[NW]-f[NW])*collFactor; - f[TE] += (feq[TE]-f[TE])*collFactor; - f[BW] += (feq[BW]-f[BW])*collFactor; - f[BE] += (feq[BE]-f[BE])*collFactor; - f[TW] += (feq[TW]-f[TW])*collFactor; - f[TN] += (feq[TN]-f[TN])*collFactor; - f[BS] += (feq[BS]-f[BS])*collFactor; - f[BN] += (feq[BN]-f[BN])*collFactor; - f[TS] += (feq[TS]-f[TS])*collFactor; - - f[TNE] += (feq[TNE]-f[TNE])*collFactor; - f[BSW] += (feq[BSW]-f[BSW])*collFactor; - f[BNE] += (feq[BNE]-f[BNE])*collFactor; - f[TSW] += (feq[TSW]-f[TSW])*collFactor; - f[TSE] += (feq[TSE]-f[TSE])*collFactor; - f[BNW] += (feq[BNW]-f[BNW])*collFactor; - f[BSE] += (feq[BSE]-f[BSE])*collFactor; - f[TNW] += (feq[TNW]-f[TNW])*collFactor; - - ////////////////////////////////////////////////////////////////////////// - //forcing - if (withForcing) - { - muX1 = x1+ix1*bcArrayMaxX1; - muX2 = x2+ix2*bcArrayMaxX2; - muX3 = x3+ix3*bcArrayMaxX3; - - forcingX1 = muForcingX1.Eval(); - forcingX2 = muForcingX2.Eval(); - forcingX3 = muForcingX3.Eval(); - - f[ZERO] += 0.0 ; - f[E ] += 3.0*c2o27 * (forcingX1) ; - f[W ] += 3.0*c2o27 * (-forcingX1) ; - f[N ] += 3.0*c2o27 * (forcingX2) ; - f[S ] += 3.0*c2o27 * (-forcingX2) ; - f[T ] += 3.0*c2o27 * (forcingX3) ; - f[B ] += 3.0*c2o27 * (-forcingX3); - f[NE ] += 3.0*c1o54 * ( forcingX1+forcingX2 ) ; - f[SW ] += 3.0*c1o54 * (-forcingX1-forcingX2 ) ; - f[SE ] += 3.0*c1o54 * ( forcingX1-forcingX2 ) ; - f[NW ] += 3.0*c1o54 * (-forcingX1+forcingX2 ) ; - f[TE ] += 3.0*c1o54 * ( forcingX1 +forcingX3) ; - f[BW ] += 3.0*c1o54 * (-forcingX1 -forcingX3) ; - f[BE ] += 3.0*c1o54 * ( forcingX1 -forcingX3) ; - f[TW ] += 3.0*c1o54 * (-forcingX1 +forcingX3) ; - f[TN ] += 3.0*c1o54 * ( forcingX2+forcingX3) ; - f[BS ] += 3.0*c1o54 * ( -forcingX2-forcingX3) ; - f[BN ] += 3.0*c1o54 * ( forcingX2-forcingX3) ; - f[TS ] += 3.0*c1o54 * ( -forcingX2+forcingX3) ; - f[TNE] += 3.0*c1o216* ( forcingX1+forcingX2+forcingX3) ; - f[BSW] += 3.0*c1o216* (-forcingX1-forcingX2-forcingX3) ; - f[BNE] += 3.0*c1o216* ( forcingX1+forcingX2-forcingX3) ; - f[TSW] += 3.0*c1o216* (-forcingX1-forcingX2+forcingX3) ; - f[TSE] += 3.0*c1o216* ( forcingX1-forcingX2+forcingX3) ; - f[BNW] += 3.0*c1o216* (-forcingX1+forcingX2-forcingX3) ; - f[BSE] += 3.0*c1o216* ( forcingX1-forcingX2-forcingX3) ; - f[TNW] += 3.0*c1o216* (-forcingX1+forcingX2+forcingX3) ; - } - ////////////////////////////////////////////////////////////////////////// -#ifdef PROOF_CORRECTNESS - LBMReal rho_post = f[ZERO] + f[E] + f[W] + f[N] + f[S] + f[T] + f[B] - + f[NE] + f[SW] + f[SE] + f[NW] + f[TE] + f[BW] + f[BE] - + f[TW] + f[TN] + f[BS] + f[BN] + f[TS] + f[TNE] + f[TSW] - + f[TSE] + f[TNW] + f[BNE] + f[BSW] + f[BSE] + f[BNW]; - LBMReal dif = drho - rho_post; -#ifdef SINGLEPRECISION - if(dif > 10.0E-7 || dif < -10.0E-7) -#else - if(dif > 10.0E-15 || dif < -10.0E-15) -#endif - { - UB_THROW(UbException(UB_EXARGS,"rho is not correct")); - } -#endif - ////////////////////////////////////////////////////////////////////////// - //write distribution - ////////////////////////////////////////////////////////////////////////// - (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = f[D3Q27System::INV_E]; - (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = f[D3Q27System::INV_N]; - (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = f[D3Q27System::INV_T]; - (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = f[D3Q27System::INV_NE]; - (*this->localDistributions)(D3Q27System::ET_NW,x1p,x2, x3) = f[D3Q27System::INV_NW]; - (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = f[D3Q27System::INV_TE]; - (*this->localDistributions)(D3Q27System::ET_TW,x1p,x2, x3) = f[D3Q27System::INV_TW]; - (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = f[D3Q27System::INV_TN]; - (*this->localDistributions)(D3Q27System::ET_TS,x1, x2p,x3) = f[D3Q27System::INV_TS]; - (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = f[D3Q27System::INV_TNE]; - (*this->localDistributions)(D3Q27System::ET_TNW,x1p,x2, x3) = f[D3Q27System::INV_TNW]; - (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2p,x3) = f[D3Q27System::INV_TSE]; - (*this->localDistributions)(D3Q27System::ET_TSW,x1p,x2p,x3) = f[D3Q27System::INV_TSW]; - - (*this->nonLocalDistributions)(D3Q27System::ET_W,x1p,x2, x3 ) = f[D3Q27System::INV_W ]; - (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2p,x3 ) = f[D3Q27System::INV_S ]; - (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3p ) = f[D3Q27System::INV_B ]; - (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1p,x2p,x3 ) = f[D3Q27System::INV_SW]; - (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2p,x3 ) = f[D3Q27System::INV_SE]; - (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1p,x2, x3p ) = f[D3Q27System::INV_BW]; - (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3p ) = f[D3Q27System::INV_BE]; - (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2p,x3p ) = f[D3Q27System::INV_BS]; - (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3p ) = f[D3Q27System::INV_BN]; - (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1p,x2p,x3p) = f[D3Q27System::INV_BSW]; - (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2p,x3p) = f[D3Q27System::INV_BSE]; - (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1p,x2, x3p) = f[D3Q27System::INV_BNW]; - (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3p) = f[D3Q27System::INV_BNE]; - - (*this->zeroDistributions)(x1,x2,x3) = f[D3Q27System::ZERO]; - ////////////////////////////////////////////////////////////////////////// - - - } - } - } - } -} -////////////////////////////////////////////////////////////////////////// -double BGKLBMKernel::getCalculationTime() -{ - return 0.0; -} diff --git a/src/cpu/VirtualFluidsCore/LBM/BGKLBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/BGKLBMKernel.h deleted file mode 100644 index d3b7cefb1..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/BGKLBMKernel.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef LBMKERNELETD3Q27BGK_H -#define LBMKERNELETD3Q27BGK_H - -#include "LBMKernel.h" -#include "basics/container/CbArray4D.h" -#include "basics/container/CbArray3D.h" - - - -class BGKLBMKernel : public LBMKernel -{ -public: - BGKLBMKernel(); - ~BGKLBMKernel(void); - void calculate(int step)override; - SPtr<LBMKernel> clone()override; - double getCalculationTime() override; - -private: - void initDataSet(); - //void collideAllCompressible(); - //void collideAllIncompressible(); - - CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr localDistributions; - CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr zeroDistributions; - - mu::value_type muX1,muX2,muX3; - LBMReal forcingX1; - LBMReal forcingX2; - LBMReal forcingX3; - - -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/LBM/CMakePackage.txt b/src/cpu/VirtualFluidsCore/LBM/CMakePackage.txt index 9354d3d00..1b8416f01 100644 --- a/src/cpu/VirtualFluidsCore/LBM/CMakePackage.txt +++ b/src/cpu/VirtualFluidsCore/LBM/CMakePackage.txt @@ -1,2 +1,2 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) +GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) diff --git a/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulant4thOrderViscosityLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulant4thOrderViscosityLBMKernel.cpp deleted file mode 100644 index dfcec6ec2..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulant4thOrderViscosityLBMKernel.cpp +++ /dev/null @@ -1,1075 +0,0 @@ -#include "CompressibleCumulant4thOrderViscosityLBMKernel.h" -#include "D3Q27System.h" -#include "InterpolationProcessor.h" -#include "D3Q27EsoTwist3DSplittedVector.h" -#include <math.h> -#include "DataSet3D.h" -#include "LBMKernel.h" -#include "Block3D.h" - -#define PROOF_CORRECTNESS - -////////////////////////////////////////////////////////////////////////// -CompressibleCumulant4thOrderViscosityLBMKernel::CompressibleCumulant4thOrderViscosityLBMKernel() -{ - this->compressible = true; - this->bulkViscosity = 0; - this->OxxPyyPzz = 1.0; -} -////////////////////////////////////////////////////////////////////////// -CompressibleCumulant4thOrderViscosityLBMKernel::~CompressibleCumulant4thOrderViscosityLBMKernel(void) -{ - -} -////////////////////////////////////////////////////////////////////////// -void CompressibleCumulant4thOrderViscosityLBMKernel::initDataSet() -{ - SPtr<DistributionArray3D> d(new D3Q27EsoTwist3DSplittedVector(nx[0]+2, nx[1]+2, nx[2]+2, -999.9)); - dataSet->setFdistributions(d); -} -////////////////////////////////////////////////////////////////////////// -SPtr<LBMKernel> CompressibleCumulant4thOrderViscosityLBMKernel::clone() -{ - SPtr<LBMKernel> kernel(new CompressibleCumulant4thOrderViscosityLBMKernel()); - kernel->setNX(nx); - dynamicPointerCast<CompressibleCumulant4thOrderViscosityLBMKernel>(kernel)->initDataSet(); - kernel->setCollisionFactor(this->collFactor); - kernel->setBCProcessor(bcProcessor->clone(kernel)); - kernel->setWithForcing(withForcing); - kernel->setForcingX1(muForcingX1); - kernel->setForcingX2(muForcingX2); - kernel->setForcingX3(muForcingX3); - kernel->setIndex(ix1, ix2, ix3); - kernel->setDeltaT(deltaT); - kernel->setBlock(block.lock()); - - if (bulkViscosity != 0) - { - OxxPyyPzz = LBMSystem::calcOmega2(bulkViscosity, block.lock()->getLevel()); - } - else - { - OxxPyyPzz = one; - } - - dynamicPointerCast<CompressibleCumulant4thOrderViscosityLBMKernel>(kernel)->OxxPyyPzz = this->OxxPyyPzz; - - return kernel; -} -////////////////////////////////////////////////////////////////////////// -void CompressibleCumulant4thOrderViscosityLBMKernel::calculate(int step) -{ - using namespace D3Q27System; - using namespace std; - - //timer.resetAndStart(); - - //initializing of forcing stuff - if (withForcing) - { - muForcingX1.DefineVar("x1", &muX1); muForcingX1.DefineVar("x2", &muX2); muForcingX1.DefineVar("x3", &muX3); - muForcingX2.DefineVar("x1", &muX1); muForcingX2.DefineVar("x2", &muX2); muForcingX2.DefineVar("x3", &muX3); - muForcingX3.DefineVar("x1", &muX1); muForcingX3.DefineVar("x2", &muX2); muForcingX3.DefineVar("x3", &muX3); - - muDeltaT = deltaT; - - muForcingX1.DefineVar("dt", &muDeltaT); - muForcingX2.DefineVar("dt", &muDeltaT); - muForcingX3.DefineVar("dt", &muDeltaT); - - muNu = (1.0/3.0)*(1.0/collFactor - 1.0/2.0); - - muForcingX1.DefineVar("nu", &muNu); - muForcingX2.DefineVar("nu", &muNu); - muForcingX3.DefineVar("nu", &muNu); - - LBMReal forcingX1 = 0; - LBMReal forcingX2 = 0; - LBMReal forcingX3 = 0; - } - ///////////////////////////////////// - - localDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getLocalDistributions(); - nonLocalDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getNonLocalDistributions(); - zeroDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getZeroDistributions(); - - SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); - - const int bcArrayMaxX1 = (int)bcArray->getNX1(); - const int bcArrayMaxX2 = (int)bcArray->getNX2(); - const int bcArrayMaxX3 = (int)bcArray->getNX3(); - - int minX1 = ghostLayerWidth; - int minX2 = ghostLayerWidth; - int minX3 = ghostLayerWidth; - int maxX1 = bcArrayMaxX1-ghostLayerWidth; - int maxX2 = bcArrayMaxX2-ghostLayerWidth; - int maxX3 = bcArrayMaxX3-ghostLayerWidth; - - LBMReal omega = collFactor; - //LBMReal OxyyPxzz = eight*(-two+omega)*(one+two*omega)/(-eight-fourteen*omega+seven*omega*omega);//one; - //LBMReal OxyyMxzz = eight*(-two+omega)*(-seven+four*omega)/(fiftysix-fifty*omega+nine*omega*omega);//one; - //LBMReal Oxyz = twentyfour*(-two+omega)*(-two-seven*omega+three*omega*omega)/(fourtyeight+c152*omega-c130*omega*omega+twentynine*omega*omega*omega); - LBMReal OxyyPxzz = 8.0*(omega-2.0)*(OxxPyyPzz*(3.0*omega-1.0)-5.0*omega)/(8.0*(5.0-2.0*omega)*omega+OxxPyyPzz*(8.0+omega*(9.0*omega-26.0))); - LBMReal OxyyMxzz = 8.0*(omega-2.0)*(omega+OxxPyyPzz*(3.0*omega-7.0))/(OxxPyyPzz*(56.0-42.0*omega+9.0*omega*omega)-8.0*omega); - LBMReal Oxyz = 24.0*(omega-2.0)*(4.0*omega*omega+omega*OxxPyyPzz*(18.0-13.0*omega)+OxxPyyPzz*OxxPyyPzz*(2.0+omega*(6.0*omega-11.0)))/(16.0*omega*omega*(omega-6.0)-2.0*omega*OxxPyyPzz*(216.0+5.0*omega*(9.0*omega-46.0))+OxxPyyPzz*OxxPyyPzz*(omega*(3.0*omega-10.0)*(15.0*omega-28.0)-48.0)); - - //LBMReal A = (four + two*omega - three*omega*omega) / (two - seven*omega + five*omega*omega); - //LBMReal B = (four + twentyeight*omega - fourteen*omega*omega) / (six - twentyone*omega + fiveteen*omega*omega); - - LBMReal A = (4.0*omega*omega+2.0*omega*OxxPyyPzz*(omega-6.0)+OxxPyyPzz*OxxPyyPzz*(omega*(10.0-3.0*omega)-4.0))/((omega-OxxPyyPzz)*(OxxPyyPzz*(2.0+3.0*omega)-8.0*omega)); - LBMReal B = (4.0*omega*OxxPyyPzz*(9.0*omega-16.0)-4.0*omega*omega-2.0*OxxPyyPzz*OxxPyyPzz*(2.0+9.0*omega*(omega-2.0)))/(3.0*(omega-OxxPyyPzz)*(OxxPyyPzz*(2.0+3.0*omega)-8.0*omega)); - - for (int x3 = minX3; x3 < maxX3; x3++) - { - for (int x2 = minX2; x2 < maxX2; x2++) - { - for (int x1 = minX1; x1 < maxX1; x1++) - { - if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) - { - int x1p = x1 + 1; - int x2p = x2 + 1; - int x3p = x3 + 1; - ////////////////////////////////////////////////////////////////////////// - //read distribution - //////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - - //E N T - //c c c - ////////// - //W S B - //a a a - - //Rest ist b - - //mfxyz - //a - negative - //b - null - //c - positive - - // a b c - //-1 0 1 - - LBMReal mfcbb = (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3); - LBMReal mfbcb = (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3); - LBMReal mfbbc = (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3); - LBMReal mfccb = (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3); - LBMReal mfacb = (*this->localDistributions)(D3Q27System::ET_NW, x1p, x2, x3); - LBMReal mfcbc = (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3); - LBMReal mfabc = (*this->localDistributions)(D3Q27System::ET_TW, x1p, x2, x3); - LBMReal mfbcc = (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3); - LBMReal mfbac = (*this->localDistributions)(D3Q27System::ET_TS, x1, x2p, x3); - LBMReal mfccc = (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3); - LBMReal mfacc = (*this->localDistributions)(D3Q27System::ET_TNW, x1p, x2, x3); - LBMReal mfcac = (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2p, x3); - LBMReal mfaac = (*this->localDistributions)(D3Q27System::ET_TSW, x1p, x2p, x3); - - LBMReal mfabb = (*this->nonLocalDistributions)(D3Q27System::ET_W, x1p, x2, x3); - LBMReal mfbab = (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2p, x3); - LBMReal mfbba = (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3p); - LBMReal mfaab = (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1p, x2p, x3); - LBMReal mfcab = (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2p, x3); - LBMReal mfaba = (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1p, x2, x3p); - LBMReal mfcba = (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3p); - LBMReal mfbaa = (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2p, x3p); - LBMReal mfbca = (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3p); - LBMReal mfaaa = (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1p, x2p, x3p); - LBMReal mfcaa = (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2p, x3p); - LBMReal mfaca = (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1p, x2, x3p); - LBMReal mfcca = (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3p); - - LBMReal mfbbb = (*this->zeroDistributions)(x1, x2, x3); - - //////////////////////////////////////////////////////////////////////////////////// - LBMReal drho = ((((mfccc+mfaaa)+(mfaca+mfcac))+((mfacc+mfcaa)+(mfaac+mfcca)))+ - (((mfbac+mfbca)+(mfbaa+mfbcc))+((mfabc+mfcba)+(mfaba+mfcbc))+((mfacb+mfcab)+(mfaab+mfccb)))+ - ((mfabb+mfcbb)+(mfbab+mfbcb))+(mfbba+mfbbc))+mfbbb; - - LBMReal rho = one+drho; - //////////////////////////////////////////////////////////////////////////////////// - LBMReal vvx = ((((mfccc-mfaaa)+(mfcac-mfaca))+((mfcaa-mfacc)+(mfcca-mfaac)))+ - (((mfcba-mfabc)+(mfcbc-mfaba))+((mfcab-mfacb)+(mfccb-mfaab)))+ - (mfcbb-mfabb))/rho; - LBMReal vvy = ((((mfccc-mfaaa)+(mfaca-mfcac))+((mfacc-mfcaa)+(mfcca-mfaac)))+ - (((mfbca-mfbac)+(mfbcc-mfbaa))+((mfacb-mfcab)+(mfccb-mfaab)))+ - (mfbcb-mfbab))/rho; - LBMReal vvz = ((((mfccc-mfaaa)+(mfcac-mfaca))+((mfacc-mfcaa)+(mfaac-mfcca)))+ - (((mfbac-mfbca)+(mfbcc-mfbaa))+((mfabc-mfcba)+(mfcbc-mfaba)))+ - (mfbbc-mfbba))/rho; - //////////////////////////////////////////////////////////////////////////////////// - - //forcing - /////////////////////////////////////////////////////////////////////////////////////////// - if (withForcing) - { - muX1 = static_cast<double>(x1-1+ix1*maxX1); - muX2 = static_cast<double>(x2-1+ix2*maxX2); - muX3 = static_cast<double>(x3-1+ix3*maxX3); - - forcingX1 = muForcingX1.Eval(); - forcingX2 = muForcingX2.Eval(); - forcingX3 = muForcingX3.Eval(); - - vvx += forcingX1*deltaT*0.5; // X - vvy += forcingX2*deltaT*0.5; // Y - vvz += forcingX3*deltaT*0.5; // Z - } - /////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - LBMReal oMdrho = one; // comp special - //////////////////////////////////////////////////////////////////////////////////// - LBMReal m0, m1, m2; - LBMReal vx2; - LBMReal vy2; - LBMReal vz2; - vx2 = vvx*vvx; - vy2 = vvy*vvy; - vz2 = vvz*vvz; - //////////////////////////////////////////////////////////////////////////////////// - LBMReal wadjust; - LBMReal qudricLimitP = 0.01;// * 0.0001f; - LBMReal qudricLimitM = 0.01;// * 0.0001f; - LBMReal qudricLimitD = 0.01;// * 0.001f; - //LBMReal s9 = minusomega; - //test - //s9 = 0.; - //////////////////////////////////////////////////////////////////////////////////// - //Hin - //////////////////////////////////////////////////////////////////////////////////// - // mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Z - Dir - m2 = mfaaa+mfaac; - m1 = mfaac-mfaaa; - m0 = m2+mfaab; - mfaaa = m0; - m0 += c1o36 * oMdrho; - mfaab = m1-m0 * vvz; - mfaac = m2-two* m1 * vvz+vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaba+mfabc; - m1 = mfabc-mfaba; - m0 = m2+mfabb; - mfaba = m0; - m0 += c1o9 * oMdrho; - mfabb = m1-m0 * vvz; - mfabc = m2-two* m1 * vvz+vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaca+mfacc; - m1 = mfacc-mfaca; - m0 = m2+mfacb; - mfaca = m0; - m0 += c1o36 * oMdrho; - mfacb = m1-m0 * vvz; - mfacc = m2-two* m1 * vvz+vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbaa+mfbac; - m1 = mfbac-mfbaa; - m0 = m2+mfbab; - mfbaa = m0; - m0 += c1o9 * oMdrho; - mfbab = m1-m0 * vvz; - mfbac = m2-two* m1 * vvz+vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbba+mfbbc; - m1 = mfbbc-mfbba; - m0 = m2+mfbbb; - mfbba = m0; - m0 += c4o9 * oMdrho; - mfbbb = m1-m0 * vvz; - mfbbc = m2-two* m1 * vvz+vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbca+mfbcc; - m1 = mfbcc-mfbca; - m0 = m2+mfbcb; - mfbca = m0; - m0 += c1o9 * oMdrho; - mfbcb = m1-m0 * vvz; - mfbcc = m2-two* m1 * vvz+vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcaa+mfcac; - m1 = mfcac-mfcaa; - m0 = m2+mfcab; - mfcaa = m0; - m0 += c1o36 * oMdrho; - mfcab = m1-m0 * vvz; - mfcac = m2-two* m1 * vvz+vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcba+mfcbc; - m1 = mfcbc-mfcba; - m0 = m2+mfcbb; - mfcba = m0; - m0 += c1o9 * oMdrho; - mfcbb = m1-m0 * vvz; - mfcbc = m2-two* m1 * vvz+vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcca+mfccc; - m1 = mfccc-mfcca; - m0 = m2+mfccb; - mfcca = m0; - m0 += c1o36 * oMdrho; - mfccb = m1-m0 * vvz; - mfccc = m2-two* m1 * vvz+vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - // mit 1/6, 0, 1/18, 2/3, 0, 2/9, 1/6, 0, 1/18 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Y - Dir - m2 = mfaaa+mfaca; - m1 = mfaca-mfaaa; - m0 = m2+mfaba; - mfaaa = m0; - m0 += c1o6 * oMdrho; - mfaba = m1-m0 * vvy; - mfaca = m2-two* m1 * vvy+vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaab+mfacb; - m1 = mfacb-mfaab; - m0 = m2+mfabb; - mfaab = m0; - mfabb = m1-m0 * vvy; - mfacb = m2-two* m1 * vvy+vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaac+mfacc; - m1 = mfacc-mfaac; - m0 = m2+mfabc; - mfaac = m0; - m0 += c1o18 * oMdrho; - mfabc = m1-m0 * vvy; - mfacc = m2-two* m1 * vvy+vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbaa+mfbca; - m1 = mfbca-mfbaa; - m0 = m2+mfbba; - mfbaa = m0; - m0 += c2o3 * oMdrho; - mfbba = m1-m0 * vvy; - mfbca = m2-two* m1 * vvy+vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbab+mfbcb; - m1 = mfbcb-mfbab; - m0 = m2+mfbbb; - mfbab = m0; - mfbbb = m1-m0 * vvy; - mfbcb = m2-two* m1 * vvy+vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbac+mfbcc; - m1 = mfbcc-mfbac; - m0 = m2+mfbbc; - mfbac = m0; - m0 += c2o9 * oMdrho; - mfbbc = m1-m0 * vvy; - mfbcc = m2-two* m1 * vvy+vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcaa+mfcca; - m1 = mfcca-mfcaa; - m0 = m2+mfcba; - mfcaa = m0; - m0 += c1o6 * oMdrho; - mfcba = m1-m0 * vvy; - mfcca = m2-two* m1 * vvy+vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcab+mfccb; - m1 = mfccb-mfcab; - m0 = m2+mfcbb; - mfcab = m0; - mfcbb = m1-m0 * vvy; - mfccb = m2-two* m1 * vvy+vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcac+mfccc; - m1 = mfccc-mfcac; - m0 = m2+mfcbc; - mfcac = m0; - m0 += c1o18 * oMdrho; - mfcbc = m1-m0 * vvy; - mfccc = m2-two* m1 * vvy+vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - // mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // X - Dir - m2 = mfaaa+mfcaa; - m1 = mfcaa-mfaaa; - m0 = m2+mfbaa; - mfaaa = m0; - m0 += one* oMdrho; - mfbaa = m1-m0 * vvx; - mfcaa = m2-two* m1 * vvx+vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaba+mfcba; - m1 = mfcba-mfaba; - m0 = m2+mfbba; - mfaba = m0; - mfbba = m1-m0 * vvx; - mfcba = m2-two* m1 * vvx+vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaca+mfcca; - m1 = mfcca-mfaca; - m0 = m2+mfbca; - mfaca = m0; - m0 += c1o3 * oMdrho; - mfbca = m1-m0 * vvx; - mfcca = m2-two* m1 * vvx+vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaab+mfcab; - m1 = mfcab-mfaab; - m0 = m2+mfbab; - mfaab = m0; - mfbab = m1-m0 * vvx; - mfcab = m2-two* m1 * vvx+vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfabb+mfcbb; - m1 = mfcbb-mfabb; - m0 = m2+mfbbb; - mfabb = m0; - mfbbb = m1-m0 * vvx; - mfcbb = m2-two* m1 * vvx+vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfacb+mfccb; - m1 = mfccb-mfacb; - m0 = m2+mfbcb; - mfacb = m0; - mfbcb = m1-m0 * vvx; - mfccb = m2-two* m1 * vvx+vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaac+mfcac; - m1 = mfcac-mfaac; - m0 = m2+mfbac; - mfaac = m0; - m0 += c1o3 * oMdrho; - mfbac = m1-m0 * vvx; - mfcac = m2-two* m1 * vvx+vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfabc+mfcbc; - m1 = mfcbc-mfabc; - m0 = m2+mfbbc; - mfabc = m0; - mfbbc = m1-m0 * vvx; - mfcbc = m2-two* m1 * vvx+vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfacc+mfccc; - m1 = mfccc-mfacc; - m0 = m2+mfbcc; - mfacc = m0; - m0 += c1o9 * oMdrho; - mfbcc = m1-m0 * vvx; - mfccc = m2-two* m1 * vvx+vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - - - //////////////////////////////////////////////////////////////////////////////////// - // Cumulants - //////////////////////////////////////////////////////////////////////////////////// - - //LBMReal OxxPyyPzz = one; // bulk viscosity - - //////////////////////////////////////////////////////////// - //3. - ////////////////////////////// - //LBMReal OxyyPxzz = one;//three * (two - omega) / (three - omega);// - //LBMReal OxyyMxzz = one;//six * (two - omega) / (six - omega);// - //LBMReal Oxyz = one;//twelve * (two - omega) / (twelve + omega);// - - //LBMReal OxyyPxzz = eight*(-two+omega)*(one+two*omega)/(-eight-fourteen*omega+seven*omega*omega);//one; - - //LBMReal OxyyMxzz = eight*(-two+omega)*(-seven+four*omega)/(fiftysix-fifty*omega+nine*omega*omega);//one; - - //LBMReal Oxyz = twentyfour*(-two+omega)*(-two-seven*omega+three*omega*omega)/(fourtyeight+c152*omega-c130*omega*omega+twentynine*omega*omega*omega); - ////////////////////////////// - //LBMReal OxyyPxzz = two-omega;// - //LBMReal OxyyMxzz = two-omega;// - ////////////////////////////// - //LBMReal OxyyPxzz = (eight * (omega - two)) / (omega - eight);//Ginzburg - //LBMReal OxyyMxzz = (eight * (omega - two)) / (omega - eight);//Ginzburg - ////////////////////////////// - //LBMReal OxyyPxzz = omega;//BGK - //LBMReal OxyyMxzz = omega;//BGK - ////////////////////////////// - //LBMReal OxyyPxzz = (one + omega) / two;//1P5 - //LBMReal OxyyMxzz = (one + omega) / two;//1P5 - ////////////////////////////// - //LBMReal OxyyPxzz = (three - omega) / two;//0P5 - //LBMReal OxyyMxzz = (three - omega) / two;//0P5 - ////////////////////////////// - //LBMReal OxyyPxzz = (one + (eight * (omega - two)) / (omega - eight)) / two;//one + Ginzburg / two ... Car - //LBMReal OxyyMxzz = (one + (eight * (omega - two)) / (omega - eight)) / two;//one + Ginzburg / two ... Car - //////////////////////////////////////////////////////////// - //4. - ////////////////////////////// - LBMReal O4 = one; - ////////////////////////////// - //LBMReal O4 = omega;//TRT - //////////////////////////////////////////////////////////// - //5. - ////////////////////////////// - LBMReal O5 = one; - //////////////////////////////////////////////////////////// - //6. - ////////////////////////////// - LBMReal O6 = one; - //////////////////////////////////////////////////////////// - - - //central moments to cumulants - //4. - LBMReal CUMcbb = mfcbb-((mfcaa+c1o3) * mfabb+two * mfbba * mfbab)/rho; //ab 15.05.2015 verwendet - LBMReal CUMbcb = mfbcb-((mfaca+c1o3) * mfbab+two * mfbba * mfabb)/rho; //ab 15.05.2015 verwendet - LBMReal CUMbbc = mfbbc-((mfaac+c1o3) * mfbba+two * mfbab * mfabb)/rho; //ab 15.05.2015 verwendet - - LBMReal CUMcca = mfcca-(((mfcaa * mfaca+two * mfbba * mfbba)+c1o3 * (mfcaa+mfaca))/rho-c1o9*(drho/rho)); - LBMReal CUMcac = mfcac-(((mfcaa * mfaac+two * mfbab * mfbab)+c1o3 * (mfcaa+mfaac))/rho-c1o9*(drho/rho)); - LBMReal CUMacc = mfacc-(((mfaac * mfaca+two * mfabb * mfabb)+c1o3 * (mfaac+mfaca))/rho-c1o9*(drho/rho)); - - //5. - LBMReal CUMbcc = mfbcc-((mfaac * mfbca+mfaca * mfbac+four * mfabb * mfbbb+two * (mfbab * mfacb+mfbba * mfabc))+c1o3 * (mfbca+mfbac))/rho; - LBMReal CUMcbc = mfcbc-((mfaac * mfcba+mfcaa * mfabc+four * mfbab * mfbbb+two * (mfabb * mfcab+mfbba * mfbac))+c1o3 * (mfcba+mfabc))/rho; - LBMReal CUMccb = mfccb-((mfcaa * mfacb+mfaca * mfcab+four * mfbba * mfbbb+two * (mfbab * mfbca+mfabb * mfcba))+c1o3 * (mfacb+mfcab))/rho; - - //6. - - LBMReal CUMccc = mfccc+((-four * mfbbb * mfbbb - -(mfcaa * mfacc+mfaca * mfcac+mfaac * mfcca) - -four * (mfabb * mfcbb+mfbab * mfbcb+mfbba * mfbbc) - -two * (mfbca * mfbac+mfcba * mfabc+mfcab * mfacb))/rho - +(four * (mfbab * mfbab * mfaca+mfabb * mfabb * mfcaa+mfbba * mfbba * mfaac) - +two * (mfcaa * mfaca * mfaac) - +sixteen * mfbba * mfbab * mfabb)/(rho * rho) - -c1o3 * (mfacc+mfcac+mfcca)/rho - -c1o9 * (mfcaa+mfaca+mfaac)/rho - +(two * (mfbab * mfbab+mfabb * mfabb+mfbba * mfbba) - +(mfaac * mfaca+mfaac * mfcaa+mfaca * mfcaa)+c1o3 *(mfaac+mfaca+mfcaa))/(rho * rho) * c2o3 - +c1o27*((drho * drho-drho)/(rho*rho))); - //+ c1o27*(one -three/rho +two/(rho*rho))); - - - - - //2. - // linear combinations - LBMReal mxxPyyPzz = mfcaa+mfaca+mfaac; - LBMReal mxxMyy = mfcaa-mfaca; - LBMReal mxxMzz = mfcaa-mfaac; - - ////////////////////////////////////////////////////////////////////////// - // LBMReal magicBulk=(CUMacc+CUMcac+CUMcca)*(one/OxxPyyPzz-c1o2)*c3o2*8.; - - ////////////////////////////////////////////////////////////////////////// - //limiter-Scheise Teil 1 - //LBMReal oxxyy,oxxzz,oxy,oxz,oyz; - //LBMReal smag=0.001; - //oxxyy = omega+(one-omega)*fabs(mxxMyy)/(fabs(mxxMyy)+smag); - //oxxzz = omega+(one-omega)*fabs(mxxMzz)/(fabs(mxxMzz)+smag); - //oxy = omega+(one-omega)*fabs(mfbba)/(fabs(mfbba)+smag); - //oxz = omega+(one-omega)*fabs(mfbab)/(fabs(mfbab)+smag); - //oyz = omega+(one-omega)*fabs(mfabb)/(fabs(mfabb)+smag); - - //////////////////////////////////////////////////////////////////////////// - ////Teil 1b - //LBMReal constante = 1000.0; - //LBMReal nuEddi = constante * fabs(mxxPyyPzz); - //LBMReal omegaLimit = one / (one / omega + three * nuEddi); - - //{ - // LBMReal dxux = c1o2 * (-omegaLimit) *(mxxMyy + mxxMzz) + OxxPyyPzz * (mfaaa - mxxPyyPzz); - // LBMReal dyuy = dxux + omegaLimit * c3o2 * mxxMyy; - // LBMReal dzuz = dxux + omegaLimit * c3o2 * mxxMzz; - - ////relax - //mxxPyyPzz += OxxPyyPzz*(mfaaa - mxxPyyPzz)- three * (one - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz); - //mxxMyy += omegaLimit * (-mxxMyy) - three * (one + c1o2 * (-omegaLimit)) * (vx2 * dxux + vy2 * dyuy); - //mxxMzz += omegaLimit * (-mxxMzz) - three * (one + c1o2 * (-omegaLimit)) * (vx2 * dxux + vz2 * dzuz); - - //} - //mfabb += omegaLimit * (-mfabb); - //mfbab += omegaLimit * (-mfbab); - //mfbba += omegaLimit * (-mfbba); - //////////////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //incl. correction (hat noch nicht so gut funktioniert...Optimierungsbedarf??) - - LBMReal dxux = c1o2 * (-omega) *(mxxMyy+mxxMzz)+c1o2 * OxxPyyPzz * (mfaaa-mxxPyyPzz); - LBMReal dyuy = dxux+omega * c3o2 * mxxMyy; - LBMReal dzuz = dxux+omega * c3o2 * mxxMzz; - - LBMReal Dxy =-three*omega*mfbba; - LBMReal Dxz =-three*omega*mfbab; - LBMReal Dyz =-three*omega*mfabb; - - - - //relax - - wadjust = OxxPyyPzz+(one-OxxPyyPzz)*fabs((mfaaa-mxxPyyPzz))/(fabs((mfaaa-mxxPyyPzz))+qudricLimitD); - mxxPyyPzz += wadjust*(mfaaa-mxxPyyPzz)-three * (one-c1o2 * OxxPyyPzz) * (vx2 * dxux+vy2 * dyuy+vz2 * dzuz); - - // mxxPyyPzz += OxxPyyPzz*(mfaaa-mxxPyyPzz)-three * (one-c1o2 * OxxPyyPzz) * (vx2 * dxux+vy2 * dyuy+vz2 * dzuz);//-magicBulk*OxxPyyPzz; - mxxMyy += omega * (-mxxMyy)-three * (one+c1o2 * (-omega)) * (vx2 * dxux-vy2 * dyuy); - mxxMzz += omega * (-mxxMzz)-three * (one+c1o2 * (-omega)) * (vx2 * dxux-vz2 * dzuz); - - ////////////////////////////////////////////////////////////////////////// - //limiter-Scheise Teil 2 - //mxxMyy += oxxyy * (-mxxMyy) - three * (one + c1o2 * (-omega)) * (vx2 * dxux + vy2 * dyuy); - //mxxMzz += oxxzz * (-mxxMzz) - three * (one + c1o2 * (-omega)) * (vx2 * dxux + vz2 * dzuz); - ////////////////////////////////////////////////////////////////////////// - - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - ////no correction - //mxxPyyPzz += OxxPyyPzz*(mfaaa-mxxPyyPzz);//-magicBulk*OxxPyyPzz; - //mxxMyy += -(-omega) * (-mxxMyy); - //mxxMzz += -(-omega) * (-mxxMzz); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - mfabb += omega * (-mfabb); - mfbab += omega * (-mfbab); - mfbba += omega * (-mfbba); - - ////////////////////////////////////////////////////////////////////////// - //limiter-Scheise Teil 3 - //mfabb += oyz * (-mfabb); - //mfbab += oxz * (-mfbab); - //mfbba += oxy * (-mfbba); - ////////////////////////////////////////////////////////////////////////// - - // linear combinations back - mfcaa = c1o3 * (mxxMyy+mxxMzz+mxxPyyPzz); - mfaca = c1o3 * (-two* mxxMyy+mxxMzz+mxxPyyPzz); - mfaac = c1o3 * (mxxMyy-two* mxxMzz+mxxPyyPzz); - - //3. - // linear combinations - - LBMReal mxxyPyzz = mfcba+mfabc; - LBMReal mxxyMyzz = mfcba-mfabc; - - LBMReal mxxzPyyz = mfcab+mfacb; - LBMReal mxxzMyyz = mfcab-mfacb; - - LBMReal mxyyPxzz = mfbca+mfbac; - LBMReal mxyyMxzz = mfbca-mfbac; - - //relax - ////////////////////////////////////////////////////////////////////////// - //das ist der limiter - wadjust = Oxyz+(one-Oxyz)*fabs(mfbbb)/(fabs(mfbbb)+qudricLimitD); - mfbbb += wadjust * (-mfbbb); - wadjust = OxyyPxzz+(one-OxyyPxzz)*fabs(mxxyPyzz)/(fabs(mxxyPyzz)+qudricLimitP); - mxxyPyzz += wadjust * (-mxxyPyzz); - wadjust = OxyyMxzz+(one-OxyyMxzz)*fabs(mxxyMyzz)/(fabs(mxxyMyzz)+qudricLimitM); - mxxyMyzz += wadjust * (-mxxyMyzz); - wadjust = OxyyPxzz+(one-OxyyPxzz)*fabs(mxxzPyyz)/(fabs(mxxzPyyz)+qudricLimitP); - mxxzPyyz += wadjust * (-mxxzPyyz); - wadjust = OxyyMxzz+(one-OxyyMxzz)*fabs(mxxzMyyz)/(fabs(mxxzMyyz)+qudricLimitM); - mxxzMyyz += wadjust * (-mxxzMyyz); - wadjust = OxyyPxzz+(one-OxyyPxzz)*fabs(mxyyPxzz)/(fabs(mxyyPxzz)+qudricLimitP); - mxyyPxzz += wadjust * (-mxyyPxzz); - wadjust = OxyyMxzz+(one-OxyyMxzz)*fabs(mxyyMxzz)/(fabs(mxyyMxzz)+qudricLimitM); - mxyyMxzz += wadjust * (-mxyyMxzz); - ////////////////////////////////////////////////////////////////////////// - //ohne limiter - //mfbbb += OxyyMxzz * (-mfbbb); - //mxxyPyzz += OxyyPxzz * (-mxxyPyzz); - //mxxyMyzz += OxyyMxzz * (-mxxyMyzz); - //mxxzPyyz += OxyyPxzz * (-mxxzPyyz); - //mxxzMyyz += OxyyMxzz * (-mxxzMyyz); - //mxyyPxzz += OxyyPxzz * (-mxyyPxzz); - //mxyyMxzz += OxyyMxzz * (-mxyyMxzz); - ////////////////////////////////////////////////////////////////////////// - - //// linear combinations back - mfcba = (mxxyMyzz+mxxyPyzz) * c1o2; - mfabc = (-mxxyMyzz+mxxyPyzz) * c1o2; - mfcab = (mxxzMyyz+mxxzPyyz) * c1o2; - mfacb = (-mxxzMyyz+mxxzPyyz) * c1o2; - mfbca = (mxyyMxzz+mxyyPxzz) * c1o2; - mfbac = (-mxyyMxzz+mxyyPxzz) * c1o2; - - //4. - ////////////////////////////////////////////////////////////////////////// - //mit limiter - // wadjust = O4+(one-O4)*fabs(CUMacc)/(fabs(CUMacc)+qudricLimit); - //CUMacc += wadjust * (-CUMacc); - // wadjust = O4+(one-O4)*fabs(CUMcac)/(fabs(CUMcac)+qudricLimit); - //CUMcac += wadjust * (-CUMcac); - // wadjust = O4+(one-O4)*fabs(CUMcca)/(fabs(CUMcca)+qudricLimit); - //CUMcca += wadjust * (-CUMcca); - - // wadjust = O4+(one-O4)*fabs(CUMbbc)/(fabs(CUMbbc)+qudricLimit); - //CUMbbc += wadjust * (-CUMbbc); - // wadjust = O4+(one-O4)*fabs(CUMbcb)/(fabs(CUMbcb)+qudricLimit); - //CUMbcb += wadjust * (-CUMbcb); - // wadjust = O4+(one-O4)*fabs(CUMcbb)/(fabs(CUMcbb)+qudricLimit); - //CUMcbb += wadjust * (-CUMcbb); - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - - - //ohne limiter - //CUMacc += O4 * (-CUMacc); - //CUMcac += O4 * (-CUMcac); - //CUMcca += O4 * (-CUMcca); - - //CUMbbc += O4 * (-CUMbbc); - //CUMbcb += O4 * (-CUMbcb); - //CUMcbb += O4 * (-CUMcbb); - CUMacc = -O4*(one / omega - c1o2) * (dyuy + dzuz) * c2o3 * A + (one - O4) * (CUMacc); - CUMcac = -O4*(one / omega - c1o2) * (dxux + dzuz) * c2o3 * A + (one - O4) * (CUMcac); - CUMcca = -O4*(one / omega - c1o2) * (dyuy + dxux) * c2o3 * A + (one - O4) * (CUMcca); - CUMbbc = -O4*(one / omega - c1o2) * Dxy * c1o3 * B + (one - O4) * (CUMbbc); - CUMbcb = -O4*(one / omega - c1o2) * Dxz * c1o3 * B + (one - O4) * (CUMbcb); - CUMcbb = -O4*(one / omega - c1o2) * Dyz * c1o3 * B + (one - O4) * (CUMcbb); - ////////////////////////////////////////////////////////////////////////// - - - //5. - CUMbcc += O5 * (-CUMbcc); - CUMcbc += O5 * (-CUMcbc); - CUMccb += O5 * (-CUMccb); - - //6. - CUMccc += O6 * (-CUMccc); - - - - //back cumulants to central moments - //4. - mfcbb = CUMcbb+((mfcaa+c1o3) * mfabb+two * mfbba * mfbab)/rho; - mfbcb = CUMbcb+((mfaca+c1o3) * mfbab+two * mfbba * mfabb)/rho; - mfbbc = CUMbbc+((mfaac+c1o3) * mfbba+two * mfbab * mfabb)/rho; - - mfcca = CUMcca+(((mfcaa * mfaca+two * mfbba * mfbba)+c1o3 * (mfcaa+mfaca))/rho-c1o9*(drho/rho));//(one/rho-one)); - mfcac = CUMcac+(((mfcaa * mfaac+two * mfbab * mfbab)+c1o3 * (mfcaa+mfaac))/rho-c1o9*(drho/rho));//(one/rho-one)); - mfacc = CUMacc+(((mfaac * mfaca+two * mfabb * mfabb)+c1o3 * (mfaac+mfaca))/rho-c1o9*(drho/rho));//(one/rho-one)); - - //5. - mfbcc = CUMbcc+((mfaac * mfbca+mfaca * mfbac+four * mfabb * mfbbb+two * (mfbab * mfacb+mfbba * mfabc))+c1o3 * (mfbca+mfbac))/rho; - mfcbc = CUMcbc+((mfaac * mfcba+mfcaa * mfabc+four * mfbab * mfbbb+two * (mfabb * mfcab+mfbba * mfbac))+c1o3 * (mfcba+mfabc))/rho; - mfccb = CUMccb+((mfcaa * mfacb+mfaca * mfcab+four * mfbba * mfbbb+two * (mfbab * mfbca+mfabb * mfcba))+c1o3 * (mfacb+mfcab))/rho; - - //6. - - mfccc = CUMccc-((-four * mfbbb * mfbbb - -(mfcaa * mfacc+mfaca * mfcac+mfaac * mfcca) - -four * (mfabb * mfcbb+mfbab * mfbcb+mfbba * mfbbc) - -two * (mfbca * mfbac+mfcba * mfabc+mfcab * mfacb))/rho - +(four * (mfbab * mfbab * mfaca+mfabb * mfabb * mfcaa+mfbba * mfbba * mfaac) - +two * (mfcaa * mfaca * mfaac) - +sixteen * mfbba * mfbab * mfabb)/(rho * rho) - -c1o3 * (mfacc+mfcac+mfcca)/rho - -c1o9 * (mfcaa+mfaca+mfaac)/rho - +(two * (mfbab * mfbab+mfabb * mfabb+mfbba * mfbba) - +(mfaac * mfaca+mfaac * mfcaa+mfaca * mfcaa)+c1o3 *(mfaac+mfaca+mfcaa))/(rho * rho) * c2o3 - +c1o27*((drho * drho-drho)/(rho*rho))); - //////////////////////////////////////////////////////////////////////////////////// - //forcing - mfbaa=-mfbaa; - mfaba=-mfaba; - mfaab=-mfaab; - ////////////////////////////////////////////////////////////////////////////////////// - - //////////////////////////////////////////////////////////////////////////////////// - //back - //////////////////////////////////////////////////////////////////////////////////// - //mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Z - Dir - m0 = mfaac * c1o2+mfaab * (vvz-c1o2)+(mfaaa+one* oMdrho) * (vz2-vvz) * c1o2; - m1 = -mfaac-two* mfaab * vvz+mfaaa * (one-vz2)-one* oMdrho * vz2; - m2 = mfaac * c1o2+mfaab * (vvz+c1o2)+(mfaaa+one* oMdrho) * (vz2+vvz) * c1o2; - mfaaa = m0; - mfaab = m1; - mfaac = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfabc * c1o2+mfabb * (vvz-c1o2)+mfaba * (vz2-vvz) * c1o2; - m1 = -mfabc-two* mfabb * vvz+mfaba * (one-vz2); - m2 = mfabc * c1o2+mfabb * (vvz+c1o2)+mfaba * (vz2+vvz) * c1o2; - mfaba = m0; - mfabb = m1; - mfabc = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacc * c1o2+mfacb * (vvz-c1o2)+(mfaca+c1o3 * oMdrho) * (vz2-vvz) * c1o2; - m1 = -mfacc-two* mfacb * vvz+mfaca * (one-vz2)-c1o3 * oMdrho * vz2; - m2 = mfacc * c1o2+mfacb * (vvz+c1o2)+(mfaca+c1o3 * oMdrho) * (vz2+vvz) * c1o2; - mfaca = m0; - mfacb = m1; - mfacc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfbac * c1o2+mfbab * (vvz-c1o2)+mfbaa * (vz2-vvz) * c1o2; - m1 = -mfbac-two* mfbab * vvz+mfbaa * (one-vz2); - m2 = mfbac * c1o2+mfbab * (vvz+c1o2)+mfbaa * (vz2+vvz) * c1o2; - mfbaa = m0; - mfbab = m1; - mfbac = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbbc * c1o2+mfbbb * (vvz-c1o2)+mfbba * (vz2-vvz) * c1o2; - m1 = -mfbbc-two* mfbbb * vvz+mfbba * (one-vz2); - m2 = mfbbc * c1o2+mfbbb * (vvz+c1o2)+mfbba * (vz2+vvz) * c1o2; - mfbba = m0; - mfbbb = m1; - mfbbc = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcc * c1o2+mfbcb * (vvz-c1o2)+mfbca * (vz2-vvz) * c1o2; - m1 = -mfbcc-two* mfbcb * vvz+mfbca * (one-vz2); - m2 = mfbcc * c1o2+mfbcb * (vvz+c1o2)+mfbca * (vz2+vvz) * c1o2; - mfbca = m0; - mfbcb = m1; - mfbcc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcac * c1o2+mfcab * (vvz-c1o2)+(mfcaa+c1o3 * oMdrho) * (vz2-vvz) * c1o2; - m1 = -mfcac-two* mfcab * vvz+mfcaa * (one-vz2)-c1o3 * oMdrho * vz2; - m2 = mfcac * c1o2+mfcab * (vvz+c1o2)+(mfcaa+c1o3 * oMdrho) * (vz2+vvz) * c1o2; - mfcaa = m0; - mfcab = m1; - mfcac = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfcbc * c1o2+mfcbb * (vvz-c1o2)+mfcba * (vz2-vvz) * c1o2; - m1 = -mfcbc-two* mfcbb * vvz+mfcba * (one-vz2); - m2 = mfcbc * c1o2+mfcbb * (vvz+c1o2)+mfcba * (vz2+vvz) * c1o2; - mfcba = m0; - mfcbb = m1; - mfcbc = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2+mfccb * (vvz-c1o2)+(mfcca+c1o9 * oMdrho) * (vz2-vvz) * c1o2; - m1 = -mfccc-two* mfccb * vvz+mfcca * (one-vz2)-c1o9 * oMdrho * vz2; - m2 = mfccc * c1o2+mfccb * (vvz+c1o2)+(mfcca+c1o9 * oMdrho) * (vz2+vvz) * c1o2; - mfcca = m0; - mfccb = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - //mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Y - Dir - m0 = mfaca * c1o2+mfaba * (vvy-c1o2)+(mfaaa+c1o6 * oMdrho) * (vy2-vvy) * c1o2; - m1 = -mfaca-two* mfaba * vvy+mfaaa * (one-vy2)-c1o6 * oMdrho * vy2; - m2 = mfaca * c1o2+mfaba * (vvy+c1o2)+(mfaaa+c1o6 * oMdrho) * (vy2+vvy) * c1o2; - mfaaa = m0; - mfaba = m1; - mfaca = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacb * c1o2+mfabb * (vvy-c1o2)+(mfaab+c2o3 * oMdrho) * (vy2-vvy) * c1o2; - m1 = -mfacb-two* mfabb * vvy+mfaab * (one-vy2)-c2o3 * oMdrho * vy2; - m2 = mfacb * c1o2+mfabb * (vvy+c1o2)+(mfaab+c2o3 * oMdrho) * (vy2+vvy) * c1o2; - mfaab = m0; - mfabb = m1; - mfacb = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacc * c1o2+mfabc * (vvy-c1o2)+(mfaac+c1o6 * oMdrho) * (vy2-vvy) * c1o2; - m1 = -mfacc-two* mfabc * vvy+mfaac * (one-vy2)-c1o6 * oMdrho * vy2; - m2 = mfacc * c1o2+mfabc * (vvy+c1o2)+(mfaac+c1o6 * oMdrho) * (vy2+vvy) * c1o2; - mfaac = m0; - mfabc = m1; - mfacc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfbca * c1o2+mfbba * (vvy-c1o2)+mfbaa * (vy2-vvy) * c1o2; - m1 = -mfbca-two* mfbba * vvy+mfbaa * (one-vy2); - m2 = mfbca * c1o2+mfbba * (vvy+c1o2)+mfbaa * (vy2+vvy) * c1o2; - mfbaa = m0; - mfbba = m1; - mfbca = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcb * c1o2+mfbbb * (vvy-c1o2)+mfbab * (vy2-vvy) * c1o2; - m1 = -mfbcb-two* mfbbb * vvy+mfbab * (one-vy2); - m2 = mfbcb * c1o2+mfbbb * (vvy+c1o2)+mfbab * (vy2+vvy) * c1o2; - mfbab = m0; - mfbbb = m1; - mfbcb = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcc * c1o2+mfbbc * (vvy-c1o2)+mfbac * (vy2-vvy) * c1o2; - m1 = -mfbcc-two* mfbbc * vvy+mfbac * (one-vy2); - m2 = mfbcc * c1o2+mfbbc * (vvy+c1o2)+mfbac * (vy2+vvy) * c1o2; - mfbac = m0; - mfbbc = m1; - mfbcc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcca * c1o2+mfcba * (vvy-c1o2)+(mfcaa+c1o18 * oMdrho) * (vy2-vvy) * c1o2; - m1 = -mfcca-two* mfcba * vvy+mfcaa * (one-vy2)-c1o18 * oMdrho * vy2; - m2 = mfcca * c1o2+mfcba * (vvy+c1o2)+(mfcaa+c1o18 * oMdrho) * (vy2+vvy) * c1o2; - mfcaa = m0; - mfcba = m1; - mfcca = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccb * c1o2+mfcbb * (vvy-c1o2)+(mfcab+c2o9 * oMdrho) * (vy2-vvy) * c1o2; - m1 = -mfccb-two* mfcbb * vvy+mfcab * (one-vy2)-c2o9 * oMdrho * vy2; - m2 = mfccb * c1o2+mfcbb * (vvy+c1o2)+(mfcab+c2o9 * oMdrho) * (vy2+vvy) * c1o2; - mfcab = m0; - mfcbb = m1; - mfccb = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2+mfcbc * (vvy-c1o2)+(mfcac+c1o18 * oMdrho) * (vy2-vvy) * c1o2; - m1 = -mfccc-two* mfcbc * vvy+mfcac * (one-vy2)-c1o18 * oMdrho * vy2; - m2 = mfccc * c1o2+mfcbc * (vvy+c1o2)+(mfcac+c1o18 * oMdrho) * (vy2+vvy) * c1o2; - mfcac = m0; - mfcbc = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - //mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // X - Dir - m0 = mfcaa * c1o2+mfbaa * (vvx-c1o2)+(mfaaa+c1o36 * oMdrho) * (vx2-vvx) * c1o2; - m1 = -mfcaa-two* mfbaa * vvx+mfaaa * (one-vx2)-c1o36 * oMdrho * vx2; - m2 = mfcaa * c1o2+mfbaa * (vvx+c1o2)+(mfaaa+c1o36 * oMdrho) * (vx2+vvx) * c1o2; - mfaaa = m0; - mfbaa = m1; - mfcaa = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcba * c1o2+mfbba * (vvx-c1o2)+(mfaba+c1o9 * oMdrho) * (vx2-vvx) * c1o2; - m1 = -mfcba-two* mfbba * vvx+mfaba * (one-vx2)-c1o9 * oMdrho * vx2; - m2 = mfcba * c1o2+mfbba * (vvx+c1o2)+(mfaba+c1o9 * oMdrho) * (vx2+vvx) * c1o2; - mfaba = m0; - mfbba = m1; - mfcba = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcca * c1o2+mfbca * (vvx-c1o2)+(mfaca+c1o36 * oMdrho) * (vx2-vvx) * c1o2; - m1 = -mfcca-two* mfbca * vvx+mfaca * (one-vx2)-c1o36 * oMdrho * vx2; - m2 = mfcca * c1o2+mfbca * (vvx+c1o2)+(mfaca+c1o36 * oMdrho) * (vx2+vvx) * c1o2; - mfaca = m0; - mfbca = m1; - mfcca = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcab * c1o2+mfbab * (vvx-c1o2)+(mfaab+c1o9 * oMdrho) * (vx2-vvx) * c1o2; - m1 = -mfcab-two* mfbab * vvx+mfaab * (one-vx2)-c1o9 * oMdrho * vx2; - m2 = mfcab * c1o2+mfbab * (vvx+c1o2)+(mfaab+c1o9 * oMdrho) * (vx2+vvx) * c1o2; - mfaab = m0; - mfbab = m1; - mfcab = m2; - ///////////b//////////////////////////////////////////////////////////////////////// - m0 = mfcbb * c1o2+mfbbb * (vvx-c1o2)+(mfabb+c4o9 * oMdrho) * (vx2-vvx) * c1o2; - m1 = -mfcbb-two* mfbbb * vvx+mfabb * (one-vx2)-c4o9 * oMdrho * vx2; - m2 = mfcbb * c1o2+mfbbb * (vvx+c1o2)+(mfabb+c4o9 * oMdrho) * (vx2+vvx) * c1o2; - mfabb = m0; - mfbbb = m1; - mfcbb = m2; - ///////////b//////////////////////////////////////////////////////////////////////// - m0 = mfccb * c1o2+mfbcb * (vvx-c1o2)+(mfacb+c1o9 * oMdrho) * (vx2-vvx) * c1o2; - m1 = -mfccb-two* mfbcb * vvx+mfacb * (one-vx2)-c1o9 * oMdrho * vx2; - m2 = mfccb * c1o2+mfbcb * (vvx+c1o2)+(mfacb+c1o9 * oMdrho) * (vx2+vvx) * c1o2; - mfacb = m0; - mfbcb = m1; - mfccb = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcac * c1o2+mfbac * (vvx-c1o2)+(mfaac+c1o36 * oMdrho) * (vx2-vvx) * c1o2; - m1 = -mfcac-two* mfbac * vvx+mfaac * (one-vx2)-c1o36 * oMdrho * vx2; - m2 = mfcac * c1o2+mfbac * (vvx+c1o2)+(mfaac+c1o36 * oMdrho) * (vx2+vvx) * c1o2; - mfaac = m0; - mfbac = m1; - mfcac = m2; - ///////////c//////////////////////////////////////////////////////////////////////// - m0 = mfcbc * c1o2+mfbbc * (vvx-c1o2)+(mfabc+c1o9 * oMdrho) * (vx2-vvx) * c1o2; - m1 = -mfcbc-two* mfbbc * vvx+mfabc * (one-vx2)-c1o9 * oMdrho * vx2; - m2 = mfcbc * c1o2+mfbbc * (vvx+c1o2)+(mfabc+c1o9 * oMdrho) * (vx2+vvx) * c1o2; - mfabc = m0; - mfbbc = m1; - mfcbc = m2; - ///////////c//////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2+mfbcc * (vvx-c1o2)+(mfacc+c1o36 * oMdrho) * (vx2-vvx) * c1o2; - m1 = -mfccc-two* mfbcc * vvx+mfacc * (one-vx2)-c1o36 * oMdrho * vx2; - m2 = mfccc * c1o2+mfbcc * (vvx+c1o2)+(mfacc+c1o36 * oMdrho) * (vx2+vvx) * c1o2; - mfacc = m0; - mfbcc = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - //proof correctness - ////////////////////////////////////////////////////////////////////////// -#ifdef PROOF_CORRECTNESS - LBMReal drho_post = (mfaaa+mfaac+mfaca+mfcaa+mfacc+mfcac+mfccc+mfcca) - +(mfaab+mfacb+mfcab+mfccb)+(mfaba+mfabc+mfcba+mfcbc)+(mfbaa+mfbac+mfbca+mfbcc) - +(mfabb+mfcbb)+(mfbab+mfbcb)+(mfbba+mfbbc)+mfbbb; - //LBMReal dif = fabs(rho - rho_post); - LBMReal dif = drho - drho_post; -#ifdef SINGLEPRECISION - if (dif > 10.0E-7 || dif < -10.0E-7) -#else - if (dif > 10.0E-15 || dif < -10.0E-15) -#endif - { - UB_THROW(UbException(UB_EXARGS, "rho="+UbSystem::toString(drho)+", rho_post="+UbSystem::toString(drho_post) - +" dif="+UbSystem::toString(dif) - +" rho is not correct for node "+UbSystem::toString(x1)+","+UbSystem::toString(x2)+","+UbSystem::toString(x3) - +" in " + block.lock()->toString()+" step = "+UbSystem::toString(step))); - } -#endif - ////////////////////////////////////////////////////////////////////////// - //write distribution - ////////////////////////////////////////////////////////////////////////// - (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3) = mfabb; - (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3) = mfbab; - (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3) = mfbba; - (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3) = mfaab; - (*this->localDistributions)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab; - (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3) = mfaba; - (*this->localDistributions)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba; - (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa; - (*this->localDistributions)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca; - (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa; - (*this->localDistributions)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa; - (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca; - (*this->localDistributions)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca; - - (*this->nonLocalDistributions)(D3Q27System::ET_W, x1p, x2, x3) = mfcbb; - (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2p, x3) = mfbcb; - (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc; - (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1p, x2p, x3) = mfccb; - (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2p, x3) = mfacb; - (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc; - (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc; - (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc; - (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac; - (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc; - (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc; - (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac; - (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac; - - (*this->zeroDistributions)(x1, x2, x3) = mfbbb; - ////////////////////////////////////////////////////////////////////////// - - } - } - } - } - //timer.stop(); -} -////////////////////////////////////////////////////////////////////////// -double CompressibleCumulant4thOrderViscosityLBMKernel::getCalculationTime() -{ - //return timer.getDuration(); - return timer.getTotalTime(); -} -////////////////////////////////////////////////////////////////////////// -void CompressibleCumulant4thOrderViscosityLBMKernel::setBulkViscosity(LBMReal value) -{ - bulkViscosity = value; -} - -////////////////////////////////////////////////////////////////////////// -//void CompressibleCumulant4thOrderViscosityLBMKernel::setBulkOmegaToOmega(bool value) -//{ -// bulkOmegaToOmega = value; -//} - -//void CompressibleCumulant4thOrderViscosityLBMKernel::setViscosityFlag(bool vf) -//{ -// viscosityFlag = vf; -//} diff --git a/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulant4thOrderViscosityLBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulant4thOrderViscosityLBMKernel.h deleted file mode 100644 index d10ea218f..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulant4thOrderViscosityLBMKernel.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef CompressibleCumulant4thOrderViscosityLBMKernel_h__ -#define CompressibleCumulant4thOrderViscosityLBMKernel_h__ - -#include "LBMKernel.h" -#include "BCProcessor.h" -#include "D3Q27System.h" -#include "basics/utilities/UbTiming.h" -#include "basics/container/CbArray4D.h" -#include "basics/container/CbArray3D.h" - -//! \brief compressible cumulant LBM kernel. -//! \details CFD solver that use Cascaded Cumulant Lattice Boltzmann method for D3Q27 model -//! \author K. Kutscher, M. Geier -class CompressibleCumulant4thOrderViscosityLBMKernel : public LBMKernel -{ -public: - //! This option set relaxation parameter: NORMAL - enum Parameter{NORMAL, MAGIC}; -public: - CompressibleCumulant4thOrderViscosityLBMKernel(); - virtual ~CompressibleCumulant4thOrderViscosityLBMKernel(void); - virtual void calculate(int step); - virtual SPtr<LBMKernel> clone(); - double getCalculationTime() override; - //! The value should not be equal to a shear viscosity - void setBulkViscosity(LBMReal value); -protected: - virtual void initDataSet(); - LBMReal f[D3Q27System::ENDF+1]; - - UbTimer timer; - - CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr localDistributions; - CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr zeroDistributions; - - mu::value_type muX1,muX2,muX3; - mu::value_type muDeltaT; - mu::value_type muNu; - LBMReal forcingX1; - LBMReal forcingX2; - LBMReal forcingX3; - - // bulk viscosity - LBMReal OxxPyyPzz; //omega2 (bulk viscosity) - LBMReal bulkViscosity; - -}; -#endif // CompressibleCumulant4thOrderViscosityLBMKernel_h__ - - diff --git a/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp deleted file mode 100644 index dd9725b1e..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp +++ /dev/null @@ -1,1049 +0,0 @@ -#include "CompressibleCumulantLBMKernel.h" -#include "D3Q27System.h" -#include "InterpolationProcessor.h" -#include "D3Q27EsoTwist3DSplittedVector.h" -#include <math.h> -#include "DataSet3D.h" -#include "Block3D.h" - -#define PROOF_CORRECTNESS - -////////////////////////////////////////////////////////////////////////// -CompressibleCumulantLBMKernel::CompressibleCumulantLBMKernel() -{ - this->compressible = true; - this->parameter = NORMAL; - this->OxyyMxzz = 1.0; - this->compressible = true; - this->bulkOmegaToOmega = false; - this->OxxPyyPzz = 1.0; -} -////////////////////////////////////////////////////////////////////////// -CompressibleCumulantLBMKernel::~CompressibleCumulantLBMKernel(void) -{ - -} -////////////////////////////////////////////////////////////////////////// -void CompressibleCumulantLBMKernel::initDataSet() -{ - SPtr<DistributionArray3D> d(new D3Q27EsoTwist3DSplittedVector(nx[0]+2, nx[1]+2, nx[2]+2, -999.9)); - dataSet->setFdistributions(d); -} -////////////////////////////////////////////////////////////////////////// -SPtr<LBMKernel> CompressibleCumulantLBMKernel::clone() -{ - SPtr<LBMKernel> kernel(new CompressibleCumulantLBMKernel()); - kernel->setNX(nx); - dynamicPointerCast<CompressibleCumulantLBMKernel>(kernel)->initDataSet(); - kernel->setCollisionFactor(this->collFactor); - kernel->setBCProcessor(bcProcessor->clone(kernel)); - kernel->setWithForcing(withForcing); - kernel->setForcingX1(muForcingX1); - kernel->setForcingX2(muForcingX2); - kernel->setForcingX3(muForcingX3); - kernel->setIndex(ix1, ix2, ix3); - kernel->setDeltaT(deltaT); - kernel->setBlock(block.lock()); - - switch (parameter) - { - case NORMAL: - dynamicPointerCast<CompressibleCumulantLBMKernel>(kernel)->OxyyMxzz = 1.0; - break; - case MAGIC: - dynamicPointerCast<CompressibleCumulantLBMKernel>(kernel)->OxyyMxzz = 2.0 +(-collFactor); - break; - } - - if (bulkOmegaToOmega) - { - dynamicPointerCast<CompressibleCumulantLBMKernel>(kernel)->OxxPyyPzz = collFactor; - } - else - { - dynamicPointerCast<CompressibleCumulantLBMKernel>(kernel)->OxxPyyPzz = one; - } - return kernel; -} -////////////////////////////////////////////////////////////////////////// -void CompressibleCumulantLBMKernel::calculate(int step) -{ - using namespace D3Q27System; - using namespace std; - - //timer.resetAndStart(); - - //initializing of forcing stuff - if (withForcing) - { - muForcingX1.DefineVar("x1", &muX1); muForcingX1.DefineVar("x2", &muX2); muForcingX1.DefineVar("x3", &muX3); - muForcingX2.DefineVar("x1", &muX1); muForcingX2.DefineVar("x2", &muX2); muForcingX2.DefineVar("x3", &muX3); - muForcingX3.DefineVar("x1", &muX1); muForcingX3.DefineVar("x2", &muX2); muForcingX3.DefineVar("x3", &muX3); - - muDeltaT = deltaT; - - muForcingX1.DefineVar("dt", &muDeltaT); - muForcingX2.DefineVar("dt", &muDeltaT); - muForcingX3.DefineVar("dt", &muDeltaT); - - muNu = (1.0/3.0)*(1.0/collFactor - 1.0/2.0); - - muForcingX1.DefineVar("nu", &muNu); - muForcingX2.DefineVar("nu", &muNu); - muForcingX3.DefineVar("nu", &muNu); - - LBMReal forcingX1 = 0; - LBMReal forcingX2 = 0; - LBMReal forcingX3 = 0; - } - ///////////////////////////////////// - - localDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getLocalDistributions(); - nonLocalDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getNonLocalDistributions(); - zeroDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getZeroDistributions(); - - SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); - - const int bcArrayMaxX1 = (int)bcArray->getNX1(); - const int bcArrayMaxX2 = (int)bcArray->getNX2(); - const int bcArrayMaxX3 = (int)bcArray->getNX3(); - - int minX1 = ghostLayerWidth; - int minX2 = ghostLayerWidth; - int minX3 = ghostLayerWidth; - int maxX1 = bcArrayMaxX1-ghostLayerWidth; - int maxX2 = bcArrayMaxX2-ghostLayerWidth; - int maxX3 = bcArrayMaxX3-ghostLayerWidth; - - LBMReal omega = collFactor; - - - //#pragma omp parallel num_threads(8) - { - // int i = omp_get_thread_num(); - // printf_s("Hello from thread %d\n", i); - //} - //#pragma omp for - for (int x3 = minX3; x3 < maxX3; x3++) - { - for (int x2 = minX2; x2 < maxX2; x2++) - { - for (int x1 = minX1; x1 < maxX1; x1++) - { - if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) - { - int x1p = x1 + 1; - int x2p = x2 + 1; - int x3p = x3 + 1; - ////////////////////////////////////////////////////////////////////////// - //read distribution - //////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - - //E N T - //c c c - ////////// - //W S B - //a a a - - //Rest ist b - - //mfxyz - //a - negative - //b - null - //c - positive - - // a b c - //-1 0 1 - - LBMReal mfcbb = (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3); - LBMReal mfbcb = (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3); - LBMReal mfbbc = (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3); - LBMReal mfccb = (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3); - LBMReal mfacb = (*this->localDistributions)(D3Q27System::ET_NW, x1p, x2, x3); - LBMReal mfcbc = (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3); - LBMReal mfabc = (*this->localDistributions)(D3Q27System::ET_TW, x1p, x2, x3); - LBMReal mfbcc = (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3); - LBMReal mfbac = (*this->localDistributions)(D3Q27System::ET_TS, x1, x2p, x3); - LBMReal mfccc = (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3); - LBMReal mfacc = (*this->localDistributions)(D3Q27System::ET_TNW, x1p, x2, x3); - LBMReal mfcac = (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2p, x3); - LBMReal mfaac = (*this->localDistributions)(D3Q27System::ET_TSW, x1p, x2p, x3); - - LBMReal mfabb = (*this->nonLocalDistributions)(D3Q27System::ET_W, x1p, x2, x3); - LBMReal mfbab = (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2p, x3); - LBMReal mfbba = (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3p); - LBMReal mfaab = (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1p, x2p, x3); - LBMReal mfcab = (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2p, x3); - LBMReal mfaba = (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1p, x2, x3p); - LBMReal mfcba = (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3p); - LBMReal mfbaa = (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2p, x3p); - LBMReal mfbca = (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3p); - LBMReal mfaaa = (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1p, x2p, x3p); - LBMReal mfcaa = (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2p, x3p); - LBMReal mfaca = (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1p, x2, x3p); - LBMReal mfcca = (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3p); - - LBMReal mfbbb = (*this->zeroDistributions)(x1, x2, x3); - - //////////////////////////////////////////////////////////////////////////////////// - LBMReal drho = ((((mfccc+mfaaa)+(mfaca+mfcac))+((mfacc+mfcaa)+(mfaac+mfcca)))+ - (((mfbac+mfbca)+(mfbaa+mfbcc))+((mfabc+mfcba)+(mfaba+mfcbc))+((mfacb+mfcab)+(mfaab+mfccb)))+ - ((mfabb+mfcbb)+(mfbab+mfbcb))+(mfbba+mfbbc))+mfbbb; - - LBMReal rho = one+drho; - //////////////////////////////////////////////////////////////////////////////////// - LBMReal vvx = ((((mfccc-mfaaa)+(mfcac-mfaca))+((mfcaa-mfacc)+(mfcca-mfaac)))+ - (((mfcba-mfabc)+(mfcbc-mfaba))+((mfcab-mfacb)+(mfccb-mfaab)))+ - (mfcbb-mfabb))/rho; - LBMReal vvy = ((((mfccc-mfaaa)+(mfaca-mfcac))+((mfacc-mfcaa)+(mfcca-mfaac)))+ - (((mfbca-mfbac)+(mfbcc-mfbaa))+((mfacb-mfcab)+(mfccb-mfaab)))+ - (mfbcb-mfbab))/rho; - LBMReal vvz = ((((mfccc-mfaaa)+(mfcac-mfaca))+((mfacc-mfcaa)+(mfaac-mfcca)))+ - (((mfbac-mfbca)+(mfbcc-mfbaa))+((mfabc-mfcba)+(mfcbc-mfaba)))+ - (mfbbc-mfbba))/rho; - //////////////////////////////////////////////////////////////////////////////////// - - //forcing - /////////////////////////////////////////////////////////////////////////////////////////// - if (withForcing) - { - muX1 = static_cast<double>(x1-1+ix1*maxX1); - muX2 = static_cast<double>(x2-1+ix2*maxX2); - muX3 = static_cast<double>(x3-1+ix3*maxX3); - - forcingX1 = muForcingX1.Eval(); - forcingX2 = muForcingX2.Eval(); - forcingX3 = muForcingX3.Eval(); - - vvx += forcingX1*deltaT*0.5; // X - vvy += forcingX2*deltaT*0.5; // Y - vvz += forcingX3*deltaT*0.5; // Z - } - /////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - LBMReal oMdrho = one; // comp special - //////////////////////////////////////////////////////////////////////////////////// - LBMReal m0, m1, m2; - LBMReal vx2; - LBMReal vy2; - LBMReal vz2; - vx2 = vvx*vvx; - vy2 = vvy*vvy; - vz2 = vvz*vvz; - //////////////////////////////////////////////////////////////////////////////////// - //LBMReal wadjust; - //LBMReal qudricLimitP = 0.01f;// * 0.0001f; - //LBMReal qudricLimitM = 0.01f;// * 0.0001f; - //LBMReal qudricLimitD = 0.01f;// * 0.001f; - //LBMReal s9 = minusomega; - //test - //s9 = 0.; - //////////////////////////////////////////////////////////////////////////////////// - //Hin - //////////////////////////////////////////////////////////////////////////////////// - // mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Z - Dir - m2 = mfaaa+mfaac; - m1 = mfaac-mfaaa; - m0 = m2+mfaab; - mfaaa = m0; - m0 += c1o36 * oMdrho; - mfaab = m1-m0 * vvz; - mfaac = m2-two* m1 * vvz+vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaba+mfabc; - m1 = mfabc-mfaba; - m0 = m2+mfabb; - mfaba = m0; - m0 += c1o9 * oMdrho; - mfabb = m1-m0 * vvz; - mfabc = m2-two* m1 * vvz+vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaca+mfacc; - m1 = mfacc-mfaca; - m0 = m2+mfacb; - mfaca = m0; - m0 += c1o36 * oMdrho; - mfacb = m1-m0 * vvz; - mfacc = m2-two* m1 * vvz+vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbaa+mfbac; - m1 = mfbac-mfbaa; - m0 = m2+mfbab; - mfbaa = m0; - m0 += c1o9 * oMdrho; - mfbab = m1-m0 * vvz; - mfbac = m2-two* m1 * vvz+vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbba+mfbbc; - m1 = mfbbc-mfbba; - m0 = m2+mfbbb; - mfbba = m0; - m0 += c4o9 * oMdrho; - mfbbb = m1-m0 * vvz; - mfbbc = m2-two* m1 * vvz+vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbca+mfbcc; - m1 = mfbcc-mfbca; - m0 = m2+mfbcb; - mfbca = m0; - m0 += c1o9 * oMdrho; - mfbcb = m1-m0 * vvz; - mfbcc = m2-two* m1 * vvz+vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcaa+mfcac; - m1 = mfcac-mfcaa; - m0 = m2+mfcab; - mfcaa = m0; - m0 += c1o36 * oMdrho; - mfcab = m1-m0 * vvz; - mfcac = m2-two* m1 * vvz+vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcba+mfcbc; - m1 = mfcbc-mfcba; - m0 = m2+mfcbb; - mfcba = m0; - m0 += c1o9 * oMdrho; - mfcbb = m1-m0 * vvz; - mfcbc = m2-two* m1 * vvz+vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcca+mfccc; - m1 = mfccc-mfcca; - m0 = m2+mfccb; - mfcca = m0; - m0 += c1o36 * oMdrho; - mfccb = m1-m0 * vvz; - mfccc = m2-two* m1 * vvz+vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - // mit 1/6, 0, 1/18, 2/3, 0, 2/9, 1/6, 0, 1/18 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Y - Dir - m2 = mfaaa+mfaca; - m1 = mfaca-mfaaa; - m0 = m2+mfaba; - mfaaa = m0; - m0 += c1o6 * oMdrho; - mfaba = m1-m0 * vvy; - mfaca = m2-two* m1 * vvy+vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaab+mfacb; - m1 = mfacb-mfaab; - m0 = m2+mfabb; - mfaab = m0; - mfabb = m1-m0 * vvy; - mfacb = m2-two* m1 * vvy+vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaac+mfacc; - m1 = mfacc-mfaac; - m0 = m2+mfabc; - mfaac = m0; - m0 += c1o18 * oMdrho; - mfabc = m1-m0 * vvy; - mfacc = m2-two* m1 * vvy+vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbaa+mfbca; - m1 = mfbca-mfbaa; - m0 = m2+mfbba; - mfbaa = m0; - m0 += c2o3 * oMdrho; - mfbba = m1-m0 * vvy; - mfbca = m2-two* m1 * vvy+vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbab+mfbcb; - m1 = mfbcb-mfbab; - m0 = m2+mfbbb; - mfbab = m0; - mfbbb = m1-m0 * vvy; - mfbcb = m2-two* m1 * vvy+vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbac+mfbcc; - m1 = mfbcc-mfbac; - m0 = m2+mfbbc; - mfbac = m0; - m0 += c2o9 * oMdrho; - mfbbc = m1-m0 * vvy; - mfbcc = m2-two* m1 * vvy+vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcaa+mfcca; - m1 = mfcca-mfcaa; - m0 = m2+mfcba; - mfcaa = m0; - m0 += c1o6 * oMdrho; - mfcba = m1-m0 * vvy; - mfcca = m2-two* m1 * vvy+vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcab+mfccb; - m1 = mfccb-mfcab; - m0 = m2+mfcbb; - mfcab = m0; - mfcbb = m1-m0 * vvy; - mfccb = m2-two* m1 * vvy+vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcac+mfccc; - m1 = mfccc-mfcac; - m0 = m2+mfcbc; - mfcac = m0; - m0 += c1o18 * oMdrho; - mfcbc = m1-m0 * vvy; - mfccc = m2-two* m1 * vvy+vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - // mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // X - Dir - m2 = mfaaa+mfcaa; - m1 = mfcaa-mfaaa; - m0 = m2+mfbaa; - mfaaa = m0; - m0 += one* oMdrho; - mfbaa = m1-m0 * vvx; - mfcaa = m2-two* m1 * vvx+vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaba+mfcba; - m1 = mfcba-mfaba; - m0 = m2+mfbba; - mfaba = m0; - mfbba = m1-m0 * vvx; - mfcba = m2-two* m1 * vvx+vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaca+mfcca; - m1 = mfcca-mfaca; - m0 = m2+mfbca; - mfaca = m0; - m0 += c1o3 * oMdrho; - mfbca = m1-m0 * vvx; - mfcca = m2-two* m1 * vvx+vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaab+mfcab; - m1 = mfcab-mfaab; - m0 = m2+mfbab; - mfaab = m0; - mfbab = m1-m0 * vvx; - mfcab = m2-two* m1 * vvx+vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfabb+mfcbb; - m1 = mfcbb-mfabb; - m0 = m2+mfbbb; - mfabb = m0; - mfbbb = m1-m0 * vvx; - mfcbb = m2-two* m1 * vvx+vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfacb+mfccb; - m1 = mfccb-mfacb; - m0 = m2+mfbcb; - mfacb = m0; - mfbcb = m1-m0 * vvx; - mfccb = m2-two* m1 * vvx+vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaac+mfcac; - m1 = mfcac-mfaac; - m0 = m2+mfbac; - mfaac = m0; - m0 += c1o3 * oMdrho; - mfbac = m1-m0 * vvx; - mfcac = m2-two* m1 * vvx+vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfabc+mfcbc; - m1 = mfcbc-mfabc; - m0 = m2+mfbbc; - mfabc = m0; - mfbbc = m1-m0 * vvx; - mfcbc = m2-two* m1 * vvx+vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfacc+mfccc; - m1 = mfccc-mfacc; - m0 = m2+mfbcc; - mfacc = m0; - m0 += c1o9 * oMdrho; - mfbcc = m1-m0 * vvx; - mfccc = m2-two* m1 * vvx+vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - - - //////////////////////////////////////////////////////////////////////////////////// - // Cumulants - //////////////////////////////////////////////////////////////////////////////////// - - //LBMReal OxxPyyPzz = one; // bulk viscosity - - //////////////////////////////////////////////////////////// - //3. - ////////////////////////////// - LBMReal OxyyPxzz = one;//three * (two - omega) / (three - omega);// - //LBMReal OxyyMxzz = one;//six * (two - omega) / (six - omega);// - LBMReal Oxyz = one;//twelve * (two - omega) / (twelve + omega);// - ////////////////////////////// - //LBMReal OxyyPxzz = two-omega;// - //LBMReal OxyyMxzz = two-omega;// - ////////////////////////////// - //LBMReal OxyyPxzz = (eight * (omega - two)) / (omega - eight);//Ginzburg - //LBMReal OxyyMxzz = (eight * (omega - two)) / (omega - eight);//Ginzburg - ////////////////////////////// - //LBMReal OxyyPxzz = omega;//BGK - //LBMReal OxyyMxzz = omega;//BGK - ////////////////////////////// - //LBMReal OxyyPxzz = (one + omega) / two;//1P5 - //LBMReal OxyyMxzz = (one + omega) / two;//1P5 - ////////////////////////////// - //LBMReal OxyyPxzz = (three - omega) / two;//0P5 - //LBMReal OxyyMxzz = (three - omega) / two;//0P5 - ////////////////////////////// - //LBMReal OxyyPxzz = (one + (eight * (omega - two)) / (omega - eight)) / two;//one + Ginzburg / two ... Car - //LBMReal OxyyMxzz = (one + (eight * (omega - two)) / (omega - eight)) / two;//one + Ginzburg / two ... Car - //////////////////////////////////////////////////////////// - //4. - ////////////////////////////// - LBMReal O4 = one; - ////////////////////////////// - //LBMReal O4 = omega;//TRT - //////////////////////////////////////////////////////////// - //5. - ////////////////////////////// - LBMReal O5 = one; - //////////////////////////////////////////////////////////// - //6. - ////////////////////////////// - LBMReal O6 = one; - //////////////////////////////////////////////////////////// - - - //central moments to cumulants - //4. - LBMReal CUMcbb = mfcbb-((mfcaa+c1o3) * mfabb+two * mfbba * mfbab)/rho; //ab 15.05.2015 verwendet - LBMReal CUMbcb = mfbcb-((mfaca+c1o3) * mfbab+two * mfbba * mfabb)/rho; //ab 15.05.2015 verwendet - LBMReal CUMbbc = mfbbc-((mfaac+c1o3) * mfbba+two * mfbab * mfabb)/rho; //ab 15.05.2015 verwendet - - LBMReal CUMcca = mfcca-(((mfcaa * mfaca+two * mfbba * mfbba)+c1o3 * (mfcaa+mfaca))/rho-c1o9*(drho/rho)); - LBMReal CUMcac = mfcac-(((mfcaa * mfaac+two * mfbab * mfbab)+c1o3 * (mfcaa+mfaac))/rho-c1o9*(drho/rho)); - LBMReal CUMacc = mfacc-(((mfaac * mfaca+two * mfabb * mfabb)+c1o3 * (mfaac+mfaca))/rho-c1o9*(drho/rho)); - - //5. - LBMReal CUMbcc = mfbcc-((mfaac * mfbca+mfaca * mfbac+four * mfabb * mfbbb+two * (mfbab * mfacb+mfbba * mfabc))+c1o3 * (mfbca+mfbac))/rho; - LBMReal CUMcbc = mfcbc-((mfaac * mfcba+mfcaa * mfabc+four * mfbab * mfbbb+two * (mfabb * mfcab+mfbba * mfbac))+c1o3 * (mfcba+mfabc))/rho; - LBMReal CUMccb = mfccb-((mfcaa * mfacb+mfaca * mfcab+four * mfbba * mfbbb+two * (mfbab * mfbca+mfabb * mfcba))+c1o3 * (mfacb+mfcab))/rho; - - //6. - - LBMReal CUMccc = mfccc+((-four * mfbbb * mfbbb - -(mfcaa * mfacc+mfaca * mfcac+mfaac * mfcca) - -four * (mfabb * mfcbb+mfbab * mfbcb+mfbba * mfbbc) - -two * (mfbca * mfbac+mfcba * mfabc+mfcab * mfacb))/rho - +(four * (mfbab * mfbab * mfaca+mfabb * mfabb * mfcaa+mfbba * mfbba * mfaac) - +two * (mfcaa * mfaca * mfaac) - +sixteen * mfbba * mfbab * mfabb)/(rho * rho) - -c1o3 * (mfacc+mfcac+mfcca)/rho - -c1o9 * (mfcaa+mfaca+mfaac)/rho - +(two * (mfbab * mfbab+mfabb * mfabb+mfbba * mfbba) - +(mfaac * mfaca+mfaac * mfcaa+mfaca * mfcaa)+c1o3 *(mfaac+mfaca+mfcaa))/(rho * rho) * c2o3 - +c1o27*((drho * drho-drho)/(rho*rho))); - //+ c1o27*(one -three/rho +two/(rho*rho))); - - - - - //2. - // linear combinations - LBMReal mxxPyyPzz = mfcaa+mfaca+mfaac; - LBMReal mxxMyy = mfcaa-mfaca; - LBMReal mxxMzz = mfcaa-mfaac; - - ////////////////////////////////////////////////////////////////////////// - // LBMReal magicBulk=(CUMacc+CUMcac+CUMcca)*(one/OxxPyyPzz-c1o2)*c3o2*8.; - - ////////////////////////////////////////////////////////////////////////// - //limiter-Scheise Teil 1 - //LBMReal oxxyy,oxxzz,oxy,oxz,oyz; - //LBMReal smag=0.001; - //oxxyy = omega+(one-omega)*fabs(mxxMyy)/(fabs(mxxMyy)+smag); - //oxxzz = omega+(one-omega)*fabs(mxxMzz)/(fabs(mxxMzz)+smag); - //oxy = omega+(one-omega)*fabs(mfbba)/(fabs(mfbba)+smag); - //oxz = omega+(one-omega)*fabs(mfbab)/(fabs(mfbab)+smag); - //oyz = omega+(one-omega)*fabs(mfabb)/(fabs(mfabb)+smag); - - //////////////////////////////////////////////////////////////////////////// - ////Teil 1b - //LBMReal constante = 1000.0; - //LBMReal nuEddi = constante * fabs(mxxPyyPzz); - //LBMReal omegaLimit = one / (one / omega + three * nuEddi); - - //{ - // LBMReal dxux = c1o2 * (-omegaLimit) *(mxxMyy + mxxMzz) + OxxPyyPzz * (mfaaa - mxxPyyPzz); - // LBMReal dyuy = dxux + omegaLimit * c3o2 * mxxMyy; - // LBMReal dzuz = dxux + omegaLimit * c3o2 * mxxMzz; - - ////relax - //mxxPyyPzz += OxxPyyPzz*(mfaaa - mxxPyyPzz)- three * (one - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz); - //mxxMyy += omegaLimit * (-mxxMyy) - three * (one + c1o2 * (-omegaLimit)) * (vx2 * dxux + vy2 * dyuy); - //mxxMzz += omegaLimit * (-mxxMzz) - three * (one + c1o2 * (-omegaLimit)) * (vx2 * dxux + vz2 * dzuz); - - //} - //mfabb += omegaLimit * (-mfabb); - //mfbab += omegaLimit * (-mfbab); - //mfbba += omegaLimit * (-mfbba); - //////////////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //incl. correction (hat noch nicht so gut funktioniert...Optimierungsbedarf??) - { - LBMReal dxux = c1o2 * (-omega) *(mxxMyy+mxxMzz)+c1o2 * OxxPyyPzz * (mfaaa-mxxPyyPzz); - LBMReal dyuy = dxux+omega * c3o2 * mxxMyy; - LBMReal dzuz = dxux+omega * c3o2 * mxxMzz; - - //relax - mxxPyyPzz += OxxPyyPzz*(mfaaa-mxxPyyPzz)-three * (one-c1o2 * OxxPyyPzz) * (vx2 * dxux+vy2 * dyuy+vz2 * dzuz);//-magicBulk*OxxPyyPzz; - mxxMyy += omega * (-mxxMyy)-three * (one+c1o2 * (-omega)) * (vx2 * dxux-vy2 * dyuy); - mxxMzz += omega * (-mxxMzz)-three * (one+c1o2 * (-omega)) * (vx2 * dxux-vz2 * dzuz); - - ////////////////////////////////////////////////////////////////////////// - //limiter-Scheise Teil 2 - //mxxMyy += oxxyy * (-mxxMyy) - three * (one + c1o2 * (-omega)) * (vx2 * dxux + vy2 * dyuy); - //mxxMzz += oxxzz * (-mxxMzz) - three * (one + c1o2 * (-omega)) * (vx2 * dxux + vz2 * dzuz); - ////////////////////////////////////////////////////////////////////////// - - } - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - ////no correction - //mxxPyyPzz += OxxPyyPzz*(mfaaa-mxxPyyPzz);//-magicBulk*OxxPyyPzz; - //mxxMyy += -(-omega) * (-mxxMyy); - //mxxMzz += -(-omega) * (-mxxMzz); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - mfabb += omega * (-mfabb); - mfbab += omega * (-mfbab); - mfbba += omega * (-mfbba); - - ////////////////////////////////////////////////////////////////////////// - //limiter-Scheise Teil 3 - //mfabb += oyz * (-mfabb); - //mfbab += oxz * (-mfbab); - //mfbba += oxy * (-mfbba); - ////////////////////////////////////////////////////////////////////////// - - // linear combinations back - mfcaa = c1o3 * (mxxMyy+mxxMzz+mxxPyyPzz); - mfaca = c1o3 * (-two* mxxMyy+mxxMzz+mxxPyyPzz); - mfaac = c1o3 * (mxxMyy-two* mxxMzz+mxxPyyPzz); - - //3. - // linear combinations - - LBMReal mxxyPyzz = mfcba+mfabc; - LBMReal mxxyMyzz = mfcba-mfabc; - - LBMReal mxxzPyyz = mfcab+mfacb; - LBMReal mxxzMyyz = mfcab-mfacb; - - LBMReal mxyyPxzz = mfbca+mfbac; - LBMReal mxyyMxzz = mfbca-mfbac; - - //relax - ////////////////////////////////////////////////////////////////////////// - //das ist der limiter - //wadjust = Oxyz+(one-Oxyz)*fabs(mfbbb)/(fabs(mfbbb)+qudricLimitD); - //mfbbb += wadjust * (-mfbbb); - //wadjust = OxyyPxzz+(one-OxyyPxzz)*fabs(mxxyPyzz)/(fabs(mxxyPyzz)+qudricLimitP); - //mxxyPyzz += wadjust * (-mxxyPyzz); - //wadjust = OxyyMxzz+(one-OxyyMxzz)*fabs(mxxyMyzz)/(fabs(mxxyMyzz)+qudricLimitM); - //mxxyMyzz += wadjust * (-mxxyMyzz); - //wadjust = OxyyPxzz+(one-OxyyPxzz)*fabs(mxxzPyyz)/(fabs(mxxzPyyz)+qudricLimitP); - //mxxzPyyz += wadjust * (-mxxzPyyz); - //wadjust = OxyyMxzz+(one-OxyyMxzz)*fabs(mxxzMyyz)/(fabs(mxxzMyyz)+qudricLimitM); - //mxxzMyyz += wadjust * (-mxxzMyyz); - //wadjust = OxyyPxzz+(one-OxyyPxzz)*fabs(mxyyPxzz)/(fabs(mxyyPxzz)+qudricLimitP); - //mxyyPxzz += wadjust * (-mxyyPxzz); - //wadjust = OxyyMxzz+(one-OxyyMxzz)*fabs(mxyyMxzz)/(fabs(mxyyMxzz)+qudricLimitM); - //mxyyMxzz += wadjust * (-mxyyMxzz); - ////////////////////////////////////////////////////////////////////////// - //ohne limiter - mfbbb += OxyyMxzz * (-mfbbb); - mxxyPyzz += OxyyPxzz * (-mxxyPyzz); - mxxyMyzz += OxyyMxzz * (-mxxyMyzz); - mxxzPyyz += OxyyPxzz * (-mxxzPyyz); - mxxzMyyz += OxyyMxzz * (-mxxzMyyz); - mxyyPxzz += OxyyPxzz * (-mxyyPxzz); - mxyyMxzz += OxyyMxzz * (-mxyyMxzz); - ////////////////////////////////////////////////////////////////////////// - - //// linear combinations back - mfcba = (mxxyMyzz+mxxyPyzz) * c1o2; - mfabc = (-mxxyMyzz+mxxyPyzz) * c1o2; - mfcab = (mxxzMyyz+mxxzPyyz) * c1o2; - mfacb = (-mxxzMyyz+mxxzPyyz) * c1o2; - mfbca = (mxyyMxzz+mxyyPxzz) * c1o2; - mfbac = (-mxyyMxzz+mxyyPxzz) * c1o2; - - //4. - ////////////////////////////////////////////////////////////////////////// - //mit limiter - // wadjust = O4+(one-O4)*fabs(CUMacc)/(fabs(CUMacc)+qudricLimit); - //CUMacc += wadjust * (-CUMacc); - // wadjust = O4+(one-O4)*fabs(CUMcac)/(fabs(CUMcac)+qudricLimit); - //CUMcac += wadjust * (-CUMcac); - // wadjust = O4+(one-O4)*fabs(CUMcca)/(fabs(CUMcca)+qudricLimit); - //CUMcca += wadjust * (-CUMcca); - - // wadjust = O4+(one-O4)*fabs(CUMbbc)/(fabs(CUMbbc)+qudricLimit); - //CUMbbc += wadjust * (-CUMbbc); - // wadjust = O4+(one-O4)*fabs(CUMbcb)/(fabs(CUMbcb)+qudricLimit); - //CUMbcb += wadjust * (-CUMbcb); - // wadjust = O4+(one-O4)*fabs(CUMcbb)/(fabs(CUMcbb)+qudricLimit); - //CUMcbb += wadjust * (-CUMcbb); - ////////////////////////////////////////////////////////////////////////// - //ohne limiter - CUMacc += O4 * (-CUMacc); - CUMcac += O4 * (-CUMcac); - CUMcca += O4 * (-CUMcca); - - CUMbbc += O4 * (-CUMbbc); - CUMbcb += O4 * (-CUMbcb); - CUMcbb += O4 * (-CUMcbb); - ////////////////////////////////////////////////////////////////////////// - - - //5. - CUMbcc += O5 * (-CUMbcc); - CUMcbc += O5 * (-CUMcbc); - CUMccb += O5 * (-CUMccb); - - //6. - CUMccc += O6 * (-CUMccc); - - - - //back cumulants to central moments - //4. - mfcbb = CUMcbb+((mfcaa+c1o3) * mfabb+two * mfbba * mfbab)/rho; - mfbcb = CUMbcb+((mfaca+c1o3) * mfbab+two * mfbba * mfabb)/rho; - mfbbc = CUMbbc+((mfaac+c1o3) * mfbba+two * mfbab * mfabb)/rho; - - mfcca = CUMcca+(((mfcaa * mfaca+two * mfbba * mfbba)+c1o3 * (mfcaa+mfaca))/rho-c1o9*(drho/rho));//(one/rho-one)); - mfcac = CUMcac+(((mfcaa * mfaac+two * mfbab * mfbab)+c1o3 * (mfcaa+mfaac))/rho-c1o9*(drho/rho));//(one/rho-one)); - mfacc = CUMacc+(((mfaac * mfaca+two * mfabb * mfabb)+c1o3 * (mfaac+mfaca))/rho-c1o9*(drho/rho));//(one/rho-one)); - - //5. - mfbcc = CUMbcc+((mfaac * mfbca+mfaca * mfbac+four * mfabb * mfbbb+two * (mfbab * mfacb+mfbba * mfabc))+c1o3 * (mfbca+mfbac))/rho; - mfcbc = CUMcbc+((mfaac * mfcba+mfcaa * mfabc+four * mfbab * mfbbb+two * (mfabb * mfcab+mfbba * mfbac))+c1o3 * (mfcba+mfabc))/rho; - mfccb = CUMccb+((mfcaa * mfacb+mfaca * mfcab+four * mfbba * mfbbb+two * (mfbab * mfbca+mfabb * mfcba))+c1o3 * (mfacb+mfcab))/rho; - - //6. - - mfccc = CUMccc-((-four * mfbbb * mfbbb - -(mfcaa * mfacc+mfaca * mfcac+mfaac * mfcca) - -four * (mfabb * mfcbb+mfbab * mfbcb+mfbba * mfbbc) - -two * (mfbca * mfbac+mfcba * mfabc+mfcab * mfacb))/rho - +(four * (mfbab * mfbab * mfaca+mfabb * mfabb * mfcaa+mfbba * mfbba * mfaac) - +two * (mfcaa * mfaca * mfaac) - +sixteen * mfbba * mfbab * mfabb)/(rho * rho) - -c1o3 * (mfacc+mfcac+mfcca)/rho - -c1o9 * (mfcaa+mfaca+mfaac)/rho - +(two * (mfbab * mfbab+mfabb * mfabb+mfbba * mfbba) - +(mfaac * mfaca+mfaac * mfcaa+mfaca * mfcaa)+c1o3 *(mfaac+mfaca+mfcaa))/(rho * rho) * c2o3 - +c1o27*((drho * drho-drho)/(rho*rho))); - //////////////////////////////////////////////////////////////////////////////////// - //forcing - mfbaa=-mfbaa; - mfaba=-mfaba; - mfaab=-mfaab; - ////////////////////////////////////////////////////////////////////////////////////// - - //////////////////////////////////////////////////////////////////////////////////// - //back - //////////////////////////////////////////////////////////////////////////////////// - //mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Z - Dir - m0 = mfaac * c1o2+mfaab * (vvz-c1o2)+(mfaaa+one* oMdrho) * (vz2-vvz) * c1o2; - m1 = -mfaac-two* mfaab * vvz+mfaaa * (one-vz2)-one* oMdrho * vz2; - m2 = mfaac * c1o2+mfaab * (vvz+c1o2)+(mfaaa+one* oMdrho) * (vz2+vvz) * c1o2; - mfaaa = m0; - mfaab = m1; - mfaac = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfabc * c1o2+mfabb * (vvz-c1o2)+mfaba * (vz2-vvz) * c1o2; - m1 = -mfabc-two* mfabb * vvz+mfaba * (one-vz2); - m2 = mfabc * c1o2+mfabb * (vvz+c1o2)+mfaba * (vz2+vvz) * c1o2; - mfaba = m0; - mfabb = m1; - mfabc = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacc * c1o2+mfacb * (vvz-c1o2)+(mfaca+c1o3 * oMdrho) * (vz2-vvz) * c1o2; - m1 = -mfacc-two* mfacb * vvz+mfaca * (one-vz2)-c1o3 * oMdrho * vz2; - m2 = mfacc * c1o2+mfacb * (vvz+c1o2)+(mfaca+c1o3 * oMdrho) * (vz2+vvz) * c1o2; - mfaca = m0; - mfacb = m1; - mfacc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfbac * c1o2+mfbab * (vvz-c1o2)+mfbaa * (vz2-vvz) * c1o2; - m1 = -mfbac-two* mfbab * vvz+mfbaa * (one-vz2); - m2 = mfbac * c1o2+mfbab * (vvz+c1o2)+mfbaa * (vz2+vvz) * c1o2; - mfbaa = m0; - mfbab = m1; - mfbac = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbbc * c1o2+mfbbb * (vvz-c1o2)+mfbba * (vz2-vvz) * c1o2; - m1 = -mfbbc-two* mfbbb * vvz+mfbba * (one-vz2); - m2 = mfbbc * c1o2+mfbbb * (vvz+c1o2)+mfbba * (vz2+vvz) * c1o2; - mfbba = m0; - mfbbb = m1; - mfbbc = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcc * c1o2+mfbcb * (vvz-c1o2)+mfbca * (vz2-vvz) * c1o2; - m1 = -mfbcc-two* mfbcb * vvz+mfbca * (one-vz2); - m2 = mfbcc * c1o2+mfbcb * (vvz+c1o2)+mfbca * (vz2+vvz) * c1o2; - mfbca = m0; - mfbcb = m1; - mfbcc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcac * c1o2+mfcab * (vvz-c1o2)+(mfcaa+c1o3 * oMdrho) * (vz2-vvz) * c1o2; - m1 = -mfcac-two* mfcab * vvz+mfcaa * (one-vz2)-c1o3 * oMdrho * vz2; - m2 = mfcac * c1o2+mfcab * (vvz+c1o2)+(mfcaa+c1o3 * oMdrho) * (vz2+vvz) * c1o2; - mfcaa = m0; - mfcab = m1; - mfcac = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfcbc * c1o2+mfcbb * (vvz-c1o2)+mfcba * (vz2-vvz) * c1o2; - m1 = -mfcbc-two* mfcbb * vvz+mfcba * (one-vz2); - m2 = mfcbc * c1o2+mfcbb * (vvz+c1o2)+mfcba * (vz2+vvz) * c1o2; - mfcba = m0; - mfcbb = m1; - mfcbc = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2+mfccb * (vvz-c1o2)+(mfcca+c1o9 * oMdrho) * (vz2-vvz) * c1o2; - m1 = -mfccc-two* mfccb * vvz+mfcca * (one-vz2)-c1o9 * oMdrho * vz2; - m2 = mfccc * c1o2+mfccb * (vvz+c1o2)+(mfcca+c1o9 * oMdrho) * (vz2+vvz) * c1o2; - mfcca = m0; - mfccb = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - //mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Y - Dir - m0 = mfaca * c1o2+mfaba * (vvy-c1o2)+(mfaaa+c1o6 * oMdrho) * (vy2-vvy) * c1o2; - m1 = -mfaca-two* mfaba * vvy+mfaaa * (one-vy2)-c1o6 * oMdrho * vy2; - m2 = mfaca * c1o2+mfaba * (vvy+c1o2)+(mfaaa+c1o6 * oMdrho) * (vy2+vvy) * c1o2; - mfaaa = m0; - mfaba = m1; - mfaca = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacb * c1o2+mfabb * (vvy-c1o2)+(mfaab+c2o3 * oMdrho) * (vy2-vvy) * c1o2; - m1 = -mfacb-two* mfabb * vvy+mfaab * (one-vy2)-c2o3 * oMdrho * vy2; - m2 = mfacb * c1o2+mfabb * (vvy+c1o2)+(mfaab+c2o3 * oMdrho) * (vy2+vvy) * c1o2; - mfaab = m0; - mfabb = m1; - mfacb = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacc * c1o2+mfabc * (vvy-c1o2)+(mfaac+c1o6 * oMdrho) * (vy2-vvy) * c1o2; - m1 = -mfacc-two* mfabc * vvy+mfaac * (one-vy2)-c1o6 * oMdrho * vy2; - m2 = mfacc * c1o2+mfabc * (vvy+c1o2)+(mfaac+c1o6 * oMdrho) * (vy2+vvy) * c1o2; - mfaac = m0; - mfabc = m1; - mfacc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfbca * c1o2+mfbba * (vvy-c1o2)+mfbaa * (vy2-vvy) * c1o2; - m1 = -mfbca-two* mfbba * vvy+mfbaa * (one-vy2); - m2 = mfbca * c1o2+mfbba * (vvy+c1o2)+mfbaa * (vy2+vvy) * c1o2; - mfbaa = m0; - mfbba = m1; - mfbca = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcb * c1o2+mfbbb * (vvy-c1o2)+mfbab * (vy2-vvy) * c1o2; - m1 = -mfbcb-two* mfbbb * vvy+mfbab * (one-vy2); - m2 = mfbcb * c1o2+mfbbb * (vvy+c1o2)+mfbab * (vy2+vvy) * c1o2; - mfbab = m0; - mfbbb = m1; - mfbcb = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcc * c1o2+mfbbc * (vvy-c1o2)+mfbac * (vy2-vvy) * c1o2; - m1 = -mfbcc-two* mfbbc * vvy+mfbac * (one-vy2); - m2 = mfbcc * c1o2+mfbbc * (vvy+c1o2)+mfbac * (vy2+vvy) * c1o2; - mfbac = m0; - mfbbc = m1; - mfbcc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcca * c1o2+mfcba * (vvy-c1o2)+(mfcaa+c1o18 * oMdrho) * (vy2-vvy) * c1o2; - m1 = -mfcca-two* mfcba * vvy+mfcaa * (one-vy2)-c1o18 * oMdrho * vy2; - m2 = mfcca * c1o2+mfcba * (vvy+c1o2)+(mfcaa+c1o18 * oMdrho) * (vy2+vvy) * c1o2; - mfcaa = m0; - mfcba = m1; - mfcca = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccb * c1o2+mfcbb * (vvy-c1o2)+(mfcab+c2o9 * oMdrho) * (vy2-vvy) * c1o2; - m1 = -mfccb-two* mfcbb * vvy+mfcab * (one-vy2)-c2o9 * oMdrho * vy2; - m2 = mfccb * c1o2+mfcbb * (vvy+c1o2)+(mfcab+c2o9 * oMdrho) * (vy2+vvy) * c1o2; - mfcab = m0; - mfcbb = m1; - mfccb = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2+mfcbc * (vvy-c1o2)+(mfcac+c1o18 * oMdrho) * (vy2-vvy) * c1o2; - m1 = -mfccc-two* mfcbc * vvy+mfcac * (one-vy2)-c1o18 * oMdrho * vy2; - m2 = mfccc * c1o2+mfcbc * (vvy+c1o2)+(mfcac+c1o18 * oMdrho) * (vy2+vvy) * c1o2; - mfcac = m0; - mfcbc = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - //mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // X - Dir - m0 = mfcaa * c1o2+mfbaa * (vvx-c1o2)+(mfaaa+c1o36 * oMdrho) * (vx2-vvx) * c1o2; - m1 = -mfcaa-two* mfbaa * vvx+mfaaa * (one-vx2)-c1o36 * oMdrho * vx2; - m2 = mfcaa * c1o2+mfbaa * (vvx+c1o2)+(mfaaa+c1o36 * oMdrho) * (vx2+vvx) * c1o2; - mfaaa = m0; - mfbaa = m1; - mfcaa = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcba * c1o2+mfbba * (vvx-c1o2)+(mfaba+c1o9 * oMdrho) * (vx2-vvx) * c1o2; - m1 = -mfcba-two* mfbba * vvx+mfaba * (one-vx2)-c1o9 * oMdrho * vx2; - m2 = mfcba * c1o2+mfbba * (vvx+c1o2)+(mfaba+c1o9 * oMdrho) * (vx2+vvx) * c1o2; - mfaba = m0; - mfbba = m1; - mfcba = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcca * c1o2+mfbca * (vvx-c1o2)+(mfaca+c1o36 * oMdrho) * (vx2-vvx) * c1o2; - m1 = -mfcca-two* mfbca * vvx+mfaca * (one-vx2)-c1o36 * oMdrho * vx2; - m2 = mfcca * c1o2+mfbca * (vvx+c1o2)+(mfaca+c1o36 * oMdrho) * (vx2+vvx) * c1o2; - mfaca = m0; - mfbca = m1; - mfcca = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcab * c1o2+mfbab * (vvx-c1o2)+(mfaab+c1o9 * oMdrho) * (vx2-vvx) * c1o2; - m1 = -mfcab-two* mfbab * vvx+mfaab * (one-vx2)-c1o9 * oMdrho * vx2; - m2 = mfcab * c1o2+mfbab * (vvx+c1o2)+(mfaab+c1o9 * oMdrho) * (vx2+vvx) * c1o2; - mfaab = m0; - mfbab = m1; - mfcab = m2; - ///////////b//////////////////////////////////////////////////////////////////////// - m0 = mfcbb * c1o2+mfbbb * (vvx-c1o2)+(mfabb+c4o9 * oMdrho) * (vx2-vvx) * c1o2; - m1 = -mfcbb-two* mfbbb * vvx+mfabb * (one-vx2)-c4o9 * oMdrho * vx2; - m2 = mfcbb * c1o2+mfbbb * (vvx+c1o2)+(mfabb+c4o9 * oMdrho) * (vx2+vvx) * c1o2; - mfabb = m0; - mfbbb = m1; - mfcbb = m2; - ///////////b//////////////////////////////////////////////////////////////////////// - m0 = mfccb * c1o2+mfbcb * (vvx-c1o2)+(mfacb+c1o9 * oMdrho) * (vx2-vvx) * c1o2; - m1 = -mfccb-two* mfbcb * vvx+mfacb * (one-vx2)-c1o9 * oMdrho * vx2; - m2 = mfccb * c1o2+mfbcb * (vvx+c1o2)+(mfacb+c1o9 * oMdrho) * (vx2+vvx) * c1o2; - mfacb = m0; - mfbcb = m1; - mfccb = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcac * c1o2+mfbac * (vvx-c1o2)+(mfaac+c1o36 * oMdrho) * (vx2-vvx) * c1o2; - m1 = -mfcac-two* mfbac * vvx+mfaac * (one-vx2)-c1o36 * oMdrho * vx2; - m2 = mfcac * c1o2+mfbac * (vvx+c1o2)+(mfaac+c1o36 * oMdrho) * (vx2+vvx) * c1o2; - mfaac = m0; - mfbac = m1; - mfcac = m2; - ///////////c//////////////////////////////////////////////////////////////////////// - m0 = mfcbc * c1o2+mfbbc * (vvx-c1o2)+(mfabc+c1o9 * oMdrho) * (vx2-vvx) * c1o2; - m1 = -mfcbc-two* mfbbc * vvx+mfabc * (one-vx2)-c1o9 * oMdrho * vx2; - m2 = mfcbc * c1o2+mfbbc * (vvx+c1o2)+(mfabc+c1o9 * oMdrho) * (vx2+vvx) * c1o2; - mfabc = m0; - mfbbc = m1; - mfcbc = m2; - ///////////c//////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2+mfbcc * (vvx-c1o2)+(mfacc+c1o36 * oMdrho) * (vx2-vvx) * c1o2; - m1 = -mfccc-two* mfbcc * vvx+mfacc * (one-vx2)-c1o36 * oMdrho * vx2; - m2 = mfccc * c1o2+mfbcc * (vvx+c1o2)+(mfacc+c1o36 * oMdrho) * (vx2+vvx) * c1o2; - mfacc = m0; - mfbcc = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - //proof correctness - ////////////////////////////////////////////////////////////////////////// -#ifdef PROOF_CORRECTNESS - LBMReal drho_post = (mfaaa+mfaac+mfaca+mfcaa+mfacc+mfcac+mfccc+mfcca) - +(mfaab+mfacb+mfcab+mfccb)+(mfaba+mfabc+mfcba+mfcbc)+(mfbaa+mfbac+mfbca+mfbcc) - +(mfabb+mfcbb)+(mfbab+mfbcb)+(mfbba+mfbbc)+mfbbb; - //LBMReal dif = fabs(rho - rho_post); - LBMReal dif = drho - drho_post; -#ifdef SINGLEPRECISION - if (dif > 10.0E-7 || dif < -10.0E-7) -#else - if (dif > 10.0E-15 || dif < -10.0E-15) -#endif - { - UB_THROW(UbException(UB_EXARGS, "rho="+UbSystem::toString(drho)+", rho_post="+UbSystem::toString(drho_post) - +" dif="+UbSystem::toString(dif) - +" rho is not correct for node "+UbSystem::toString(x1)+","+UbSystem::toString(x2)+","+UbSystem::toString(x3) - +" in " + block.lock()->toString()+" step = "+UbSystem::toString(step))); - } -#endif - ////////////////////////////////////////////////////////////////////////// - //write distribution - ////////////////////////////////////////////////////////////////////////// - (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3) = mfabb; - (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3) = mfbab; - (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3) = mfbba; - (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3) = mfaab; - (*this->localDistributions)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab; - (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3) = mfaba; - (*this->localDistributions)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba; - (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa; - (*this->localDistributions)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca; - (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa; - (*this->localDistributions)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa; - (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca; - (*this->localDistributions)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca; - - (*this->nonLocalDistributions)(D3Q27System::ET_W, x1p, x2, x3) = mfcbb; - (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2p, x3) = mfbcb; - (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc; - (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1p, x2p, x3) = mfccb; - (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2p, x3) = mfacb; - (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc; - (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc; - (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc; - (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac; - (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc; - (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc; - (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac; - (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac; - - (*this->zeroDistributions)(x1, x2, x3) = mfbbb; - ////////////////////////////////////////////////////////////////////////// - - } - } - } - } - - } - - //timer.stop(); -} -////////////////////////////////////////////////////////////////////////// -double CompressibleCumulantLBMKernel::getCalculationTime() -{ - //return timer.getDuration(); - return timer.getTotalTime(); -} -////////////////////////////////////////////////////////////////////////// -void CompressibleCumulantLBMKernel::setBulkOmegaToOmega(bool value) -{ - bulkOmegaToOmega = value; -} -////////////////////////////////////////////////////////////////////////// -void CompressibleCumulantLBMKernel::setRelaxationParameter(Parameter p) -{ - parameter = p; -} diff --git a/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.h deleted file mode 100644 index bfededbe6..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef CompressibleCumulantLBMKernel_h__ -#define CompressibleCumulantLBMKernel_h__ - -#include "LBMKernel.h" -#include "BCProcessor.h" -#include "D3Q27System.h" -#include "basics/utilities/UbTiming.h" -#include "basics/container/CbArray4D.h" -#include "basics/container/CbArray3D.h" - -//! \brief 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 LBMKernel -{ -public: - //! This option set relaxation parameter: NORMAL - enum Parameter{NORMAL, MAGIC}; -public: - CompressibleCumulantLBMKernel(); - virtual ~CompressibleCumulantLBMKernel(void); - virtual void calculate(int step); - virtual SPtr<LBMKernel> clone(); - double getCalculationTime(); - void setBulkOmegaToOmega(bool value); - void setRelaxationParameter(Parameter p); -protected: - virtual void initDataSet(); - LBMReal f[D3Q27System::ENDF+1]; - - UbTimer timer; - - LBMReal OxyyMxzz; - Parameter parameter; - - CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr localDistributions; - CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr zeroDistributions; - - mu::value_type muX1,muX2,muX3; - mu::value_type muDeltaT; - mu::value_type muNu; - LBMReal forcingX1; - LBMReal forcingX2; - LBMReal forcingX3; - - // bulk viscosity - bool bulkOmegaToOmega; - LBMReal OxxPyyPzz; -}; -#endif // CompressibleCumulantLBMKernel_h__ - - diff --git a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.cpp b/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.cpp deleted file mode 100644 index 36910694c..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.cpp +++ /dev/null @@ -1,722 +0,0 @@ -#include "CompressibleOffsetInterpolationProcessor.h" -#include "D3Q27System.h" - - - -CompressibleOffsetInterpolationProcessor::CompressibleOffsetInterpolationProcessor() - : omegaC(0.0), omegaF(0.0) -{ - //forcingC = 0; //9.99685e-7; - //forcingF = 0; //forcingC*0.5; -} -////////////////////////////////////////////////////////////////////////// -CompressibleOffsetInterpolationProcessor::CompressibleOffsetInterpolationProcessor(LBMReal omegaC, LBMReal omegaF) - : omegaC(omegaC), omegaF(omegaF) -{ - -} -////////////////////////////////////////////////////////////////////////// -CompressibleOffsetInterpolationProcessor::~CompressibleOffsetInterpolationProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -InterpolationProcessorPtr CompressibleOffsetInterpolationProcessor::clone() -{ - InterpolationProcessorPtr iproc = InterpolationProcessorPtr (new CompressibleOffsetInterpolationProcessor(this->omegaC, this->omegaF)); - //dynamicPointerCast<D3Q27IncompressibleOffsetInterpolationProcessor>(iproc)->forcingC = forcingC; - //dynamicPointerCast<D3Q27IncompressibleOffsetInterpolationProcessor>(iproc)->forcingF = forcingF; - return iproc; -} -////////////////////////////////////////////////////////////////////////// -void CompressibleOffsetInterpolationProcessor::setOmegas( LBMReal omegaC, LBMReal omegaF ) -{ - this->omegaC = omegaC; - this->omegaF = omegaF; -} -////////////////////////////////////////////////////////////////////////// -void CompressibleOffsetInterpolationProcessor::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 CompressibleOffsetInterpolationProcessor::interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF, LBMReal xoff, LBMReal yoff, LBMReal zoff) -{ - setOffsets(xoff, yoff, zoff); - calcInterpolatedCoefficiets(icellC, omegaC, 0.5); - calcInterpolatedNodeCF(icellF.BSW, omegaF, -0.25, -0.25, -0.25, calcPressBSW(), -1, -1, -1); - calcInterpolatedNodeCF(icellF.BNE, omegaF, 0.25, 0.25, -0.25, calcPressBNE(), 1, 1, -1); - calcInterpolatedNodeCF(icellF.TNW, omegaF, -0.25, 0.25, 0.25, calcPressTNW(), -1, 1, 1); - calcInterpolatedNodeCF(icellF.TSE, omegaF, 0.25, -0.25, 0.25, calcPressTSE(), 1, -1, 1); - calcInterpolatedNodeCF(icellF.BNW, omegaF, -0.25, 0.25, -0.25, calcPressBNW(), -1, 1, -1); - calcInterpolatedNodeCF(icellF.BSE, omegaF, 0.25, -0.25, -0.25, calcPressBSE(), 1, -1, -1); - calcInterpolatedNodeCF(icellF.TSW, omegaF, -0.25, -0.25, 0.25, calcPressTSW(), -1, -1, 1); - calcInterpolatedNodeCF(icellF.TNE, omegaF, 0.25, 0.25, 0.25, calcPressTNE(), 1, 1, 1); -} -////////////////////////////////////////////////////////////////////////// -void CompressibleOffsetInterpolationProcessor::interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC, LBMReal xoff, LBMReal yoff, LBMReal zoff) -{ - setOffsets(xoff, yoff, zoff); - calcInterpolatedCoefficiets(icellF, omegaF, 2.0); - calcInterpolatedNodeFC(icellC, omegaC); -} -////////////////////////////////////////////////////////////////////////// -void CompressibleOffsetInterpolationProcessor::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 drho = 0.0; - D3Q27System::calcCompMacroscopicValues(f,drho,vx1,vx2,vx3); - - press = drho; //interpolate rho! - - kxy = -3.*omega*((((f[TSW]+f[BNE])-(f[TNW]+f[BSE]))+((f[BSW]+f[TNE])-(f[BNW]+f[TSE])))+((f[SW]+f[NE])-(f[NW]+f[SE]))/(one + drho)-(vx1*vx2));// might not be optimal MG 25.2.13 - kyz = -3.*omega*((((f[BSW]+f[TNE])-(f[TSE]+f[BNW]))+((f[BSE]+f[TNW])-(f[TSW]+f[BNE])))+((f[BS]+f[TN])-(f[TS]+f[BN]))/(one + drho)-(vx2*vx3)); - kxz = -3.*omega*((((f[BNW]+f[TSE])-(f[TSW]+f[BNE]))+((f[BSW]+f[TNE])-(f[BSE]+f[TNW])))+((f[BW]+f[TE])-(f[TW]+f[BE]))/(one + drho)-(vx1*vx3)); - kxxMyy = -3./2.*omega*((((f[BW]+f[TE])-(f[BS]+f[TN]))+((f[TW]+f[BE])-(f[TS]+f[BN])))+((f[W]+f[E])-(f[S]+f[N]))/(one + drho)-(vx1*vx1-vx2*vx2)); - kxxMzz = -3./2.*omega*((((f[NW]+f[SE])-(f[BS]+f[TN]))+((f[SW]+f[NE])-(f[TS]+f[BN])))+((f[W]+f[E])-(f[B]+f[T]))/(one + drho)-(vx1*vx1-vx3*vx3)); -} -////////////////////////////////////////////////////////////////////////// -void CompressibleOffsetInterpolationProcessor::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); - - //LBMReal dxRho=c1o4*((press_NET-press_SWB)+(press_SET-press_NWB)+(press_NEB-press_SWT)+(press_SEB-press_NWT)); - //LBMReal dyRho=c1o4*((press_NET-press_SWB)-(press_SET-press_NWB)+(press_NEB-press_SWT)-(press_SEB-press_NWT)); - //LBMReal dzRho=c1o4*((press_NET-press_SWB)+(press_SET-press_NWB)-(press_NEB-press_SWT)-(press_SEB-press_NWT)); - - // kxyFromfcNEQ_SWT+=vx1_SWT*dyRho+vx2_SWT*dxRho; - // kxyFromfcNEQ_NWT+=vx1_NWT*dyRho+vx2_NWT*dxRho; - // kxyFromfcNEQ_NET+=vx1_NET*dyRho+vx2_NET*dxRho; - // kxyFromfcNEQ_SET+=vx1_SET*dyRho+vx2_SET*dxRho; - // kxyFromfcNEQ_SWB+=vx1_SWB*dyRho+vx2_SWB*dxRho; - // kxyFromfcNEQ_NWB+=vx1_NWB*dyRho+vx2_NWB*dxRho; - // kxyFromfcNEQ_NEB+=vx1_NEB*dyRho+vx2_NEB*dxRho; - // kxyFromfcNEQ_SEB+=vx1_SEB*dyRho+vx2_SEB*dxRho; - - // kyzFromfcNEQ_SWT+=vx3_SWT*dyRho+vx2_SWT*dzRho; - // kyzFromfcNEQ_NWT+=vx3_NWT*dyRho+vx2_NWT*dzRho; - // kyzFromfcNEQ_NET+=vx3_NET*dyRho+vx2_NET*dzRho; - // kyzFromfcNEQ_SET+=vx3_SET*dyRho+vx2_SET*dzRho; - // kyzFromfcNEQ_SWB+=vx3_SWB*dyRho+vx2_SWB*dzRho; - // kyzFromfcNEQ_NWB+=vx3_NWB*dyRho+vx2_NWB*dzRho; - // kyzFromfcNEQ_NEB+=vx3_NEB*dyRho+vx2_NEB*dzRho; - // kyzFromfcNEQ_SEB+=vx3_SEB*dyRho+vx2_SEB*dzRho; - - // kxzFromfcNEQ_SWT+=vx1_SWT*dzRho+vx3_SWT*dxRho; - // kxzFromfcNEQ_NWT+=vx1_NWT*dzRho+vx3_NWT*dxRho; - // kxzFromfcNEQ_NET+=vx1_NET*dzRho+vx3_NET*dxRho; - // kxzFromfcNEQ_SET+=vx1_SET*dzRho+vx3_SET*dxRho; - // kxzFromfcNEQ_SWB+=vx1_SWB*dzRho+vx3_SWB*dxRho; - // kxzFromfcNEQ_NWB+=vx1_NWB*dzRho+vx3_NWB*dxRho; - // kxzFromfcNEQ_NEB+=vx1_NEB*dzRho+vx3_NEB*dxRho; - // kxzFromfcNEQ_SEB+=vx1_SEB*dzRho+vx3_SEB*dxRho; - - // kxxMyyFromfcNEQ_SWT+=vx1_SWT*dxRho-vx2_SWT*dyRho; - // kxxMyyFromfcNEQ_NWT+=vx1_NWT*dxRho-vx2_NWT*dyRho; - // kxxMyyFromfcNEQ_NET+=vx1_NET*dxRho-vx2_NET*dyRho; - // kxxMyyFromfcNEQ_SET+=vx1_SET*dxRho-vx2_SET*dyRho; - // kxxMyyFromfcNEQ_SWB+=vx1_SWB*dxRho-vx2_SWB*dyRho; - // kxxMyyFromfcNEQ_NWB+=vx1_NWB*dxRho-vx2_NWB*dyRho; - // kxxMyyFromfcNEQ_NEB+=vx1_NEB*dxRho-vx2_NEB*dyRho; - // kxxMyyFromfcNEQ_SEB+=vx1_SEB*dxRho-vx2_SEB*dyRho; - - // kxxMzzFromfcNEQ_SWT+=vx1_SWT*dxRho-vx3_SWT*dzRho; - // kxxMzzFromfcNEQ_NWT+=vx1_NWT*dxRho-vx3_NWT*dzRho; - // kxxMzzFromfcNEQ_NET+=vx1_NET*dxRho-vx3_NET*dzRho; - // kxxMzzFromfcNEQ_SET+=vx1_SET*dxRho-vx3_SET*dzRho; - // kxxMzzFromfcNEQ_SWB+=vx1_SWB*dxRho-vx3_SWB*dzRho; - // kxxMzzFromfcNEQ_NWB+=vx1_NWB*dxRho-vx3_NWB*dzRho; - // kxxMzzFromfcNEQ_NEB+=vx1_NEB*dxRho-vx3_NEB*dzRho; - // kxxMzzFromfcNEQ_SEB+=vx1_SEB*dxRho-vx3_SEB*dzRho; - - - //kxxMzzFromfcNEQ_SWT=0.0; - //kxxMzzFromfcNEQ_NWT=0.0; - //kxxMzzFromfcNEQ_NET=0.0; - //kxxMzzFromfcNEQ_SET=0.0; - //kxxMzzFromfcNEQ_SWB=0.0; - //kxxMzzFromfcNEQ_NWB=0.0; - //kxxMzzFromfcNEQ_NEB=0.0; - //kxxMzzFromfcNEQ_SEB=0.0; - - - - - - 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; - - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - kxyAverage =0;//(kxyFromfcNEQ_SWB+ - //kxyFromfcNEQ_SWT+ - //kxyFromfcNEQ_SET+ - //kxyFromfcNEQ_SEB+ - //kxyFromfcNEQ_NWB+ - //kxyFromfcNEQ_NWT+ - //kxyFromfcNEQ_NET+ - //kxyFromfcNEQ_NEB)*c1o8-(ay+bx); - kyzAverage =0;//(kyzFromfcNEQ_SWB+ - //kyzFromfcNEQ_SWT+ - //kyzFromfcNEQ_SET+ - //kyzFromfcNEQ_SEB+ - //kyzFromfcNEQ_NWB+ - //kyzFromfcNEQ_NWT+ - //kyzFromfcNEQ_NET+ - //kyzFromfcNEQ_NEB)*c1o8-(bz+cy); - kxzAverage =0;//(kxzFromfcNEQ_SWB+ - //kxzFromfcNEQ_SWT+ - //kxzFromfcNEQ_SET+ - //kxzFromfcNEQ_SEB+ - //kxzFromfcNEQ_NWB+ - //kxzFromfcNEQ_NWT+ - //kxzFromfcNEQ_NET+ - //kxzFromfcNEQ_NEB)*c1o8-(az+cx); - kxxMyyAverage =0;//(kxxMyyFromfcNEQ_SWB+ - //kxxMyyFromfcNEQ_SWT+ - //kxxMyyFromfcNEQ_SET+ - //kxxMyyFromfcNEQ_SEB+ - //kxxMyyFromfcNEQ_NWB+ - //kxxMyyFromfcNEQ_NWT+ - //kxxMyyFromfcNEQ_NET+ - //kxxMyyFromfcNEQ_NEB)*c1o8-(ax-by); - kxxMzzAverage =0;//(kxxMzzFromfcNEQ_SWB+ - //kxxMzzFromfcNEQ_SWT+ - //kxxMzzFromfcNEQ_SET+ - //kxxMzzFromfcNEQ_SEB+ - //kxxMzzFromfcNEQ_NWB+ - //kxxMzzFromfcNEQ_NWT+ - //kxxMzzFromfcNEQ_NET+ - //kxxMzzFromfcNEQ_NEB)*c1o8-(ax-cz); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // - // 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-kxxMzzAverage-kxxMyyAverage))/(27.*o)); - f_N = eps_new*((2*(ax - 2*by + cz+2*kxxMyyAverage-kxxMzzAverage))/(27.*o)); - f_T = eps_new*((2*(ax + by - 2*cz-kxxMyyAverage+2*kxxMzzAverage))/(27.*o)); - f_NE = eps_new*(-(ax + 3*ay + 3*bx + by - 2*cz+2*kxxMyyAverage-kxxMyyAverage+3*kxyAverage)/(54.*o)); - f_SE = eps_new*(-(ax - 3*ay - 3*bx + by - 2*cz+2*kxxMyyAverage-kxxMyyAverage-3*kxyAverage)/(54.*o)); - f_TE = eps_new*(-(ax + 3*az - 2*by + 3*cx + cz+2*kxxMyyAverage-kxxMzzAverage+3*kxzAverage)/(54.*o)); - f_BE = eps_new*(-(ax - 3*az - 2*by - 3*cx + cz+2*kxxMyyAverage-kxxMzzAverage-3*kxzAverage)/(54.*o)); - f_TN = eps_new*(-(-2*ax + by + 3*bz + 3*cy + cz-kxxMyyAverage-kxxMzzAverage+3*kyzAverage)/(54.*o)); - f_BN = eps_new*(-(-2*ax + by - 3*bz - 3*cy + cz-kxxMyyAverage-kxxMzzAverage-3*kyzAverage)/(54.*o)); - f_ZERO = 0.; - f_TNE = eps_new*(-(ay + az + bx + bz + cx + cy+kxyAverage+kxzAverage+kyzAverage)/(72.*o)); - f_TSW = eps_new*((-ay + az - bx + bz + cx + cy-kxyAverage+kxzAverage+kyzAverage)/(72.*o)); - f_TSE = eps_new*((ay - az + bx + bz - cx + cy+kxyAverage-kxzAverage+kyzAverage)/(72.*o)); - f_TNW = eps_new*((ay + az + bx - bz + cx - cy+kxyAverage+kxzAverage-kyzAverage)/(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 CompressibleOffsetInterpolationProcessor::calcInterpolatedNodeCF(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); - - ////////////////////////////////////////////////////////////////////////// - //DRAFT - //vx1 -= forcingF*0.5; - ////////////////////////////////////////////////////////////////////////// - - LBMReal feq[ENDF+1]; - D3Q27System::calcCompFeq(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 CompressibleOffsetInterpolationProcessor::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 CompressibleOffsetInterpolationProcessor::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 CompressibleOffsetInterpolationProcessor::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 CompressibleOffsetInterpolationProcessor::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 CompressibleOffsetInterpolationProcessor::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 CompressibleOffsetInterpolationProcessor::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 CompressibleOffsetInterpolationProcessor::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 CompressibleOffsetInterpolationProcessor::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 CompressibleOffsetInterpolationProcessor::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.; - - ////////////////////////////////////////////////////////////////////////// - //DRAFT - //vx1 -= forcingC*0.5; - ////////////////////////////////////////////////////////////////////////// - - LBMReal feq[ENDF+1]; - D3Q27System::calcCompFeq(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 = eps_new*((2*(-2*ax + by + cz-kxxMzzAverage-kxxMyyAverage))/(27.*o)); - f_N = eps_new*((2*(ax - 2*by + cz+2*kxxMyyAverage-kxxMzzAverage))/(27.*o)); - f_T = eps_new*((2*(ax + by - 2*cz-kxxMyyAverage+2*kxxMzzAverage))/(27.*o)); - f_NE = eps_new*(-(ax + 3*ay + 3*bx + by - 2*cz+2*kxxMyyAverage-kxxMyyAverage+3*kxyAverage)/(54.*o)); - f_SE = eps_new*(-(ax - 3*ay - 3*bx + by - 2*cz+2*kxxMyyAverage-kxxMyyAverage-3*kxyAverage)/(54.*o)); - f_TE = eps_new*(-(ax + 3*az - 2*by + 3*cx + cz+2*kxxMyyAverage-kxxMzzAverage+3*kxzAverage)/(54.*o)); - f_BE = eps_new*(-(ax - 3*az - 2*by - 3*cx + cz+2*kxxMyyAverage-kxxMzzAverage-3*kxzAverage)/(54.*o)); - f_TN = eps_new*(-(-2*ax + by + 3*bz + 3*cy + cz-kxxMyyAverage-kxxMzzAverage+3*kyzAverage)/(54.*o)); - f_BN = eps_new*(-(-2*ax + by - 3*bz - 3*cy + cz-kxxMyyAverage-kxxMzzAverage-3*kyzAverage)/(54.*o)); - f_ZERO = 0.; - f_TNE = eps_new*(-(ay + az + bx + bz + cx + cy+kxyAverage+kxzAverage+kyzAverage)/(72.*o)); - f_TSW = eps_new*((-ay + az - bx + bz + cx + cy-kxyAverage+kxzAverage+kyzAverage)/(72.*o)); - f_TSE = eps_new*((ay - az + bx + bz - cx + cy+kxyAverage-kxzAverage+kyzAverage)/(72.*o)); - f_TNW = eps_new*((ay + az + bx - bz + cx - cy+kxyAverage+kxzAverage-kyzAverage)/(72.*o)); - - 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 CompressibleOffsetInterpolationProcessor::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 CompressibleOffsetInterpolationProcessor::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/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.h b/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.h deleted file mode 100644 index 2f3da5f03..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef CompressibleOffsetInterpolationProcessor_H_ -#define CompressibleOffsetInterpolationProcessor_H_ - -#include "InterpolationProcessor.h" -#include "D3Q27System.h" - -////////////////////////////////////////////////////////////////////////// -//it works only for cascaded LBM -//super compact interpolation method by Martin Geier -////////////////////////////////////////////////////////////////////////// - -class CompressibleOffsetInterpolationProcessor; - -class CompressibleOffsetInterpolationProcessor : public InterpolationProcessor -{ -public: - CompressibleOffsetInterpolationProcessor(); - CompressibleOffsetInterpolationProcessor(LBMReal omegaC, LBMReal omegaF); - virtual ~CompressibleOffsetInterpolationProcessor(); - 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); - void interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC); - void interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC, LBMReal xoff, LBMReal yoff, LBMReal zoff); - //LBMReal forcingC, forcingF; -protected: -private: - 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*/; - - LBMReal kxyAverage, kyzAverage, kxzAverage, kxxMyyAverage, kxxMzzAverage; - - LBMReal a,b,c; - - 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 calcInterpolatedNodeCF(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 CompressibleOffsetInterpolationProcessor::interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF) -{ - this->interpolateCoarseToFine(icellC, icellF, 0.0, 0.0, 0.0); -} -////////////////////////////////////////////////////////////////////////// -inline void CompressibleOffsetInterpolationProcessor::interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC) -{ - this->interpolateFineToCoarse(icellF, icellC, 0.0, 0.0, 0.0); -} - -#endif diff --git a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetMomentsInterpolationProcessor.cpp b/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetMomentsInterpolationProcessor.cpp deleted file mode 100644 index d9d986851..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetMomentsInterpolationProcessor.cpp +++ /dev/null @@ -1,1289 +0,0 @@ -#include "CompressibleOffsetMomentsInterpolationProcessor.h" -#include "D3Q27System.h" - - - -CompressibleOffsetMomentsInterpolationProcessor::CompressibleOffsetMomentsInterpolationProcessor() - : omegaC(0.0), omegaF(0.0) -{ - this->bulkViscosity = 0.0; - this->shearViscosity = 0.0; - this->OxxPyyPzzC = one; - this->OxxPyyPzzF = one; -} -////////////////////////////////////////////////////////////////////////// -CompressibleOffsetMomentsInterpolationProcessor::CompressibleOffsetMomentsInterpolationProcessor(LBMReal omegaC, LBMReal omegaF) - : omegaC(omegaC), omegaF(omegaF) -{ - this->bulkViscosity = 0.0; - this->shearViscosity = 0.0; - this->OxxPyyPzzC = one; - this->OxxPyyPzzF = one; -} -////////////////////////////////////////////////////////////////////////// -CompressibleOffsetMomentsInterpolationProcessor::~CompressibleOffsetMomentsInterpolationProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -InterpolationProcessorPtr CompressibleOffsetMomentsInterpolationProcessor::clone() -{ - InterpolationProcessorPtr iproc = InterpolationProcessorPtr (new CompressibleOffsetMomentsInterpolationProcessor(this->omegaC, this->omegaF)); - - dynamicPointerCast<CompressibleOffsetMomentsInterpolationProcessor>(iproc)->OxxPyyPzzC = this->OxxPyyPzzC; - dynamicPointerCast<CompressibleOffsetMomentsInterpolationProcessor>(iproc)->OxxPyyPzzF = this->OxxPyyPzzF; - - return iproc; -} -////////////////////////////////////////////////////////////////////////// -void CompressibleOffsetMomentsInterpolationProcessor::setOmegas( LBMReal omegaC, LBMReal omegaF ) -{ - this->omegaC = omegaC; - this->omegaF = omegaF; - - LBMReal dtC = (3.0*shearViscosity)/((1/omegaC)-0.5); - LBMReal dtF = (3.0*shearViscosity)/((1/omegaF)-0.5); - - if (bulkViscosity != 0) - { - this->OxxPyyPzzC = LBMSystem::calcOmega2(bulkViscosity, dtC); - this->OxxPyyPzzF = LBMSystem::calcOmega2(bulkViscosity, dtF); - } - else - { - this->OxxPyyPzzC = one; - this->OxxPyyPzzF = one; - } -} -////////////////////////////////////////////////////////////////////////// -void CompressibleOffsetMomentsInterpolationProcessor::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 CompressibleOffsetMomentsInterpolationProcessor::interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF, LBMReal xoff, LBMReal yoff, LBMReal zoff) -{ - setOffsets(xoff, yoff, zoff); - calcInterpolatedCoefficiets(icellC, omegaC, 0.5); - calcInterpolatedNodeCF(icellF.BSW, omegaF, -0.25, -0.25, -0.25, calcPressBSW(), -1, -1, -1); - calcInterpolatedNodeCF(icellF.BNE, omegaF, 0.25, 0.25, -0.25, calcPressBNE(), 1, 1, -1); - calcInterpolatedNodeCF(icellF.TNW, omegaF, -0.25, 0.25, 0.25, calcPressTNW(), -1, 1, 1); - calcInterpolatedNodeCF(icellF.TSE, omegaF, 0.25, -0.25, 0.25, calcPressTSE(), 1, -1, 1); - calcInterpolatedNodeCF(icellF.BNW, omegaF, -0.25, 0.25, -0.25, calcPressBNW(), -1, 1, -1); - calcInterpolatedNodeCF(icellF.BSE, omegaF, 0.25, -0.25, -0.25, calcPressBSE(), 1, -1, -1); - calcInterpolatedNodeCF(icellF.TSW, omegaF, -0.25, -0.25, 0.25, calcPressTSW(), -1, -1, 1); - calcInterpolatedNodeCF(icellF.TNE, omegaF, 0.25, 0.25, 0.25, calcPressTNE(), 1, 1, 1); -} -////////////////////////////////////////////////////////////////////////// -void CompressibleOffsetMomentsInterpolationProcessor::interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC, LBMReal xoff, LBMReal yoff, LBMReal zoff) -{ - setOffsets(xoff, yoff, zoff); - calcInterpolatedCoefficiets(icellF, omegaF, 2.0); - calcInterpolatedNodeFC(icellC, omegaC); -} -////////////////////////////////////////////////////////////////////////// -void CompressibleOffsetMomentsInterpolationProcessor::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 drho = 0.0; - D3Q27System::calcCompMacroscopicValues(f,drho,vx1,vx2,vx3); - - press = drho; //interpolate rho! - - kxy = -3.*omega*((((f[TSW]+f[BNE])-(f[TNW]+f[BSE]))+((f[BSW]+f[TNE])-(f[BNW]+f[TSE])))+((f[SW]+f[NE])-(f[NW]+f[SE]))/(one + drho)-(vx1*vx2));// might not be optimal MG 25.2.13 - kyz = -3.*omega*((((f[BSW]+f[TNE])-(f[TSE]+f[BNW]))+((f[BSE]+f[TNW])-(f[TSW]+f[BNE])))+((f[BS]+f[TN])-(f[TS]+f[BN]))/(one + drho)-(vx2*vx3)); - kxz = -3.*omega*((((f[BNW]+f[TSE])-(f[TSW]+f[BNE]))+((f[BSW]+f[TNE])-(f[BSE]+f[TNW])))+((f[BW]+f[TE])-(f[TW]+f[BE]))/(one + drho)-(vx1*vx3)); - kxxMyy = -3./2.*omega*((((f[BW]+f[TE])-(f[BS]+f[TN]))+((f[TW]+f[BE])-(f[TS]+f[BN])))+((f[W]+f[E])-(f[S]+f[N]))/(one + drho)-(vx1*vx1-vx2*vx2)); - kxxMzz = -3./2.*omega*((((f[NW]+f[SE])-(f[BS]+f[TN]))+((f[SW]+f[NE])-(f[TS]+f[BN])))+((f[W]+f[E])-(f[B]+f[T]))/(one + drho)-(vx1*vx1-vx3*vx3)); -} -////////////////////////////////////////////////////////////////////////// -void CompressibleOffsetMomentsInterpolationProcessor::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); - - //LBMReal dxRho=c1o4*((press_NET-press_SWB)+(press_SET-press_NWB)+(press_NEB-press_SWT)+(press_SEB-press_NWT)); - //LBMReal dyRho=c1o4*((press_NET-press_SWB)-(press_SET-press_NWB)+(press_NEB-press_SWT)-(press_SEB-press_NWT)); - //LBMReal dzRho=c1o4*((press_NET-press_SWB)+(press_SET-press_NWB)-(press_NEB-press_SWT)-(press_SEB-press_NWT)); - - // kxyFromfcNEQ_SWT+=vx1_SWT*dyRho+vx2_SWT*dxRho; - // kxyFromfcNEQ_NWT+=vx1_NWT*dyRho+vx2_NWT*dxRho; - // kxyFromfcNEQ_NET+=vx1_NET*dyRho+vx2_NET*dxRho; - // kxyFromfcNEQ_SET+=vx1_SET*dyRho+vx2_SET*dxRho; - // kxyFromfcNEQ_SWB+=vx1_SWB*dyRho+vx2_SWB*dxRho; - // kxyFromfcNEQ_NWB+=vx1_NWB*dyRho+vx2_NWB*dxRho; - // kxyFromfcNEQ_NEB+=vx1_NEB*dyRho+vx2_NEB*dxRho; - // kxyFromfcNEQ_SEB+=vx1_SEB*dyRho+vx2_SEB*dxRho; - - // kyzFromfcNEQ_SWT+=vx3_SWT*dyRho+vx2_SWT*dzRho; - // kyzFromfcNEQ_NWT+=vx3_NWT*dyRho+vx2_NWT*dzRho; - // kyzFromfcNEQ_NET+=vx3_NET*dyRho+vx2_NET*dzRho; - // kyzFromfcNEQ_SET+=vx3_SET*dyRho+vx2_SET*dzRho; - // kyzFromfcNEQ_SWB+=vx3_SWB*dyRho+vx2_SWB*dzRho; - // kyzFromfcNEQ_NWB+=vx3_NWB*dyRho+vx2_NWB*dzRho; - // kyzFromfcNEQ_NEB+=vx3_NEB*dyRho+vx2_NEB*dzRho; - // kyzFromfcNEQ_SEB+=vx3_SEB*dyRho+vx2_SEB*dzRho; - - // kxzFromfcNEQ_SWT+=vx1_SWT*dzRho+vx3_SWT*dxRho; - // kxzFromfcNEQ_NWT+=vx1_NWT*dzRho+vx3_NWT*dxRho; - // kxzFromfcNEQ_NET+=vx1_NET*dzRho+vx3_NET*dxRho; - // kxzFromfcNEQ_SET+=vx1_SET*dzRho+vx3_SET*dxRho; - // kxzFromfcNEQ_SWB+=vx1_SWB*dzRho+vx3_SWB*dxRho; - // kxzFromfcNEQ_NWB+=vx1_NWB*dzRho+vx3_NWB*dxRho; - // kxzFromfcNEQ_NEB+=vx1_NEB*dzRho+vx3_NEB*dxRho; - // kxzFromfcNEQ_SEB+=vx1_SEB*dzRho+vx3_SEB*dxRho; - - // kxxMyyFromfcNEQ_SWT+=vx1_SWT*dxRho-vx2_SWT*dyRho; - // kxxMyyFromfcNEQ_NWT+=vx1_NWT*dxRho-vx2_NWT*dyRho; - // kxxMyyFromfcNEQ_NET+=vx1_NET*dxRho-vx2_NET*dyRho; - // kxxMyyFromfcNEQ_SET+=vx1_SET*dxRho-vx2_SET*dyRho; - // kxxMyyFromfcNEQ_SWB+=vx1_SWB*dxRho-vx2_SWB*dyRho; - // kxxMyyFromfcNEQ_NWB+=vx1_NWB*dxRho-vx2_NWB*dyRho; - // kxxMyyFromfcNEQ_NEB+=vx1_NEB*dxRho-vx2_NEB*dyRho; - // kxxMyyFromfcNEQ_SEB+=vx1_SEB*dxRho-vx2_SEB*dyRho; - - // kxxMzzFromfcNEQ_SWT+=vx1_SWT*dxRho-vx3_SWT*dzRho; - // kxxMzzFromfcNEQ_NWT+=vx1_NWT*dxRho-vx3_NWT*dzRho; - // kxxMzzFromfcNEQ_NET+=vx1_NET*dxRho-vx3_NET*dzRho; - // kxxMzzFromfcNEQ_SET+=vx1_SET*dxRho-vx3_SET*dzRho; - // kxxMzzFromfcNEQ_SWB+=vx1_SWB*dxRho-vx3_SWB*dzRho; - // kxxMzzFromfcNEQ_NWB+=vx1_NWB*dxRho-vx3_NWB*dzRho; - // kxxMzzFromfcNEQ_NEB+=vx1_NEB*dxRho-vx3_NEB*dzRho; - // kxxMzzFromfcNEQ_SEB+=vx1_SEB*dxRho-vx3_SEB*dzRho; - - - //kxxMzzFromfcNEQ_SWT=0.0; - //kxxMzzFromfcNEQ_NWT=0.0; - //kxxMzzFromfcNEQ_NET=0.0; - //kxxMzzFromfcNEQ_SET=0.0; - //kxxMzzFromfcNEQ_SWB=0.0; - //kxxMzzFromfcNEQ_NWB=0.0; - //kxxMzzFromfcNEQ_NEB=0.0; - //kxxMzzFromfcNEQ_SEB=0.0; - - - - - - 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; - - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - kxyAverage =0;//(kxyFromfcNEQ_SWB+ - //kxyFromfcNEQ_SWT+ - //kxyFromfcNEQ_SET+ - //kxyFromfcNEQ_SEB+ - //kxyFromfcNEQ_NWB+ - //kxyFromfcNEQ_NWT+ - //kxyFromfcNEQ_NET+ - //kxyFromfcNEQ_NEB)*c1o8-(ay+bx); - kyzAverage =0;//(kyzFromfcNEQ_SWB+ - //kyzFromfcNEQ_SWT+ - //kyzFromfcNEQ_SET+ - //kyzFromfcNEQ_SEB+ - //kyzFromfcNEQ_NWB+ - //kyzFromfcNEQ_NWT+ - //kyzFromfcNEQ_NET+ - //kyzFromfcNEQ_NEB)*c1o8-(bz+cy); - kxzAverage =0;//(kxzFromfcNEQ_SWB+ - //kxzFromfcNEQ_SWT+ - //kxzFromfcNEQ_SET+ - //kxzFromfcNEQ_SEB+ - //kxzFromfcNEQ_NWB+ - //kxzFromfcNEQ_NWT+ - //kxzFromfcNEQ_NET+ - //kxzFromfcNEQ_NEB)*c1o8-(az+cx); - kxxMyyAverage =0;//(kxxMyyFromfcNEQ_SWB+ - //kxxMyyFromfcNEQ_SWT+ - //kxxMyyFromfcNEQ_SET+ - //kxxMyyFromfcNEQ_SEB+ - //kxxMyyFromfcNEQ_NWB+ - //kxxMyyFromfcNEQ_NWT+ - //kxxMyyFromfcNEQ_NET+ - //kxxMyyFromfcNEQ_NEB)*c1o8-(ax-by); - kxxMzzAverage =0;//(kxxMzzFromfcNEQ_SWB+ - //kxxMzzFromfcNEQ_SWT+ - //kxxMzzFromfcNEQ_SET+ - //kxxMzzFromfcNEQ_SEB+ - //kxxMzzFromfcNEQ_NWB+ - //kxxMzzFromfcNEQ_NWT+ - //kxxMzzFromfcNEQ_NET+ - //kxxMzzFromfcNEQ_NEB)*c1o8-(ax-cz); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // - // 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-kxxMzzAverage-kxxMyyAverage))/(27.*o)); - f_N = eps_new*((2*(ax - 2*by + cz+2*kxxMyyAverage-kxxMzzAverage))/(27.*o)); - f_T = eps_new*((2*(ax + by - 2*cz-kxxMyyAverage+2*kxxMzzAverage))/(27.*o)); - f_NE = eps_new*(-(ax + 3*ay + 3*bx + by - 2*cz+2*kxxMyyAverage-kxxMyyAverage+3*kxyAverage)/(54.*o)); - f_SE = eps_new*(-(ax - 3*ay - 3*bx + by - 2*cz+2*kxxMyyAverage-kxxMyyAverage-3*kxyAverage)/(54.*o)); - f_TE = eps_new*(-(ax + 3*az - 2*by + 3*cx + cz+2*kxxMyyAverage-kxxMzzAverage+3*kxzAverage)/(54.*o)); - f_BE = eps_new*(-(ax - 3*az - 2*by - 3*cx + cz+2*kxxMyyAverage-kxxMzzAverage-3*kxzAverage)/(54.*o)); - f_TN = eps_new*(-(-2*ax + by + 3*bz + 3*cy + cz-kxxMyyAverage-kxxMzzAverage+3*kyzAverage)/(54.*o)); - f_BN = eps_new*(-(-2*ax + by - 3*bz - 3*cy + cz-kxxMyyAverage-kxxMzzAverage-3*kyzAverage)/(54.*o)); - f_ZERO = 0.; - f_TNE = eps_new*(-(ay + az + bx + bz + cx + cy+kxyAverage+kxzAverage+kyzAverage)/(72.*o)); - f_TSW = eps_new*((-ay + az - bx + bz + cx + cy-kxyAverage+kxzAverage+kyzAverage)/(72.*o)); - f_TSE = eps_new*((ay - az + bx + bz - cx + cy+kxyAverage-kxzAverage+kyzAverage)/(72.*o)); - f_TNW = eps_new*((ay + az + bx - bz + cx - cy+kxyAverage+kxzAverage-kyzAverage)/(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 CompressibleOffsetMomentsInterpolationProcessor::calcInterpolatedNodeCF(LBMReal* f, LBMReal omega, LBMReal x, LBMReal y, LBMReal z, LBMReal press, LBMReal xs, LBMReal ys, LBMReal zs) -{ - using namespace D3Q27System; - - LBMReal eps_new = 0.5; - LBMReal o = omega; - //bulk viscosity - LBMReal oP = OxxPyyPzzF; - - 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 mfcbb = zeroReal; - LBMReal mfabb = zeroReal; - LBMReal mfbcb = zeroReal; - LBMReal mfbab = zeroReal; - LBMReal mfbbc = zeroReal; - LBMReal mfbba = zeroReal; - LBMReal mfccb = zeroReal; - LBMReal mfaab = zeroReal; - LBMReal mfcab = zeroReal; - LBMReal mfacb = zeroReal; - LBMReal mfcbc = zeroReal; - LBMReal mfaba = zeroReal; - LBMReal mfcba = zeroReal; - LBMReal mfabc = zeroReal; - LBMReal mfbcc = zeroReal; - LBMReal mfbaa = zeroReal; - LBMReal mfbca = zeroReal; - LBMReal mfbac = zeroReal; - LBMReal mfbbb = zeroReal; - LBMReal mfccc = zeroReal; - LBMReal mfaac = zeroReal; - LBMReal mfcac = zeroReal; - LBMReal mfacc = zeroReal; - LBMReal mfcca = zeroReal; - LBMReal mfaaa = zeroReal; - LBMReal mfcaa = zeroReal; - LBMReal mfaca = zeroReal; - - mfaaa = press; // if drho is interpolated directly - - LBMReal vx1Sq = vx1*vx1; - LBMReal vx2Sq = vx2*vx2; - LBMReal vx3Sq = vx3*vx3; - LBMReal oMdrho = one; - - //2.f - - // linear combinations - LBMReal mxxPyyPzz = mfaaa - c2o3*(ax + by + two*axx*x + bxy*x + axy*y + two*byy*y + axz*z + byz*z + bxyz*x*z + axyz*y*z + cz - cxz*x + cyz*y + cxyz*x*y + two*czz*z)*eps_new / oP* (one + press); - LBMReal mxxMyy = -c2o3*(ax - by + kxxMyyAverage + two*axx*x - bxy*x + axy*y - two*byy*y + axz*z - byz*z - bxyz*x*z + axyz*y*z)*eps_new/o * (one + press); - LBMReal mxxMzz = -c2o3*(ax - cz + kxxMzzAverage + two*axx*x - cxz*x + axy*y - cyz*y - cxyz*x*y + axz*z - two*czz*z + axyz*y*z)*eps_new/o * (one + press); - - mfabb = -c1o3 * (bz + cy + kyzAverage + bxz*x + cxy*x + byz*y + two*cyy*y + bxyz*x*y + two*bzz*z + cyz*z + cxyz*x*z)*eps_new/o * (one + press); - mfbab = -c1o3 * (az + cx + kxzAverage + axz*x + two*cxx*x + ayz*y + cxy*y + axyz*x*y + two*azz*z + cxz*z + cxyz*y*z)*eps_new/o * (one + press); - mfbba = -c1o3 * (ay + bx + kxyAverage + axy*x + two*bxx*x + two*ayy*y + bxy*y + ayz*z + bxz*z + axyz*x*z + bxyz*y*z)*eps_new/o * (one + press); - - // linear combinations back - mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz) ; - mfaca = c1o3 * (-two * mxxMyy + mxxMzz + mxxPyyPzz) ; - mfaac = c1o3 * (mxxMyy - two * mxxMzz + mxxPyyPzz) ; - - //three - mfbbb = zeroReal; - LBMReal mxxyPyzz = zeroReal; - LBMReal mxxyMyzz = zeroReal; - LBMReal mxxzPyyz = zeroReal; - LBMReal mxxzMyyz = zeroReal; - LBMReal mxyyPxzz = zeroReal; - LBMReal mxyyMxzz = zeroReal; - - // linear combinations back - mfcba = (mxxyMyzz + mxxyPyzz) * c1o2; - mfabc = (-mxxyMyzz + mxxyPyzz) * c1o2; - mfcab = (mxxzMyyz + mxxzPyyz) * c1o2; - mfacb = (-mxxzMyyz + mxxzPyyz) * c1o2; - mfbca = (mxyyMxzz + mxyyPxzz) * c1o2; - mfbac = (-mxyyMxzz + mxyyPxzz) * c1o2; - - //4.f - mfacc = mfaaa*c1o9; - mfcac = mfacc; - mfcca = mfacc; - - //5. - - //6. - - mfccc = mfaaa*c1o27; - //////////////////////////////////////////////////////////////////////////////////// - //back - //////////////////////////////////////////////////////////////////////////////////// - //mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Z - Dir - LBMReal m0 = mfaac * c1o2 + mfaab * (vx3 - c1o2) + (mfaaa + one * oMdrho) * (vx3Sq - vx3) * c1o2; - LBMReal m1 = -mfaac - two * mfaab * vx3 + mfaaa * (one - vx3Sq) - one * oMdrho * vx3Sq; - LBMReal m2 = mfaac * c1o2 + mfaab * (vx3 + c1o2) + (mfaaa + one * oMdrho) * (vx3Sq + vx3) * c1o2; - mfaaa = m0; - mfaab = m1; - mfaac = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfabc * c1o2 + mfabb * (vx3 - c1o2) + mfaba * (vx3Sq - vx3) * c1o2; - m1 = -mfabc - two * mfabb * vx3 + mfaba * (one - vx3Sq); - m2 = mfabc * c1o2 + mfabb * (vx3 + c1o2) + mfaba * (vx3Sq + vx3) * c1o2; - mfaba = m0; - mfabb = m1; - mfabc = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacc * c1o2 + mfacb * (vx3 - c1o2) + (mfaca + c1o3 * oMdrho) * (vx3Sq - vx3) * c1o2; - m1 = -mfacc - two * mfacb * vx3 + mfaca * (one - vx3Sq) - c1o3 * oMdrho * vx3Sq; - m2 = mfacc * c1o2 + mfacb * (vx3 + c1o2) + (mfaca + c1o3 * oMdrho) * (vx3Sq + vx3) * c1o2; - mfaca = m0; - mfacb = m1; - mfacc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfbac * c1o2 + mfbab * (vx3 - c1o2) + mfbaa * (vx3Sq - vx3) * c1o2; - m1 = -mfbac - two * mfbab * vx3 + mfbaa * (one - vx3Sq); - m2 = mfbac * c1o2 + mfbab * (vx3 + c1o2) + mfbaa * (vx3Sq + vx3) * c1o2; - mfbaa = m0; - mfbab = m1; - mfbac = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbbc * c1o2 + mfbbb * (vx3 - c1o2) + mfbba * (vx3Sq - vx3) * c1o2; - m1 = -mfbbc - two * mfbbb * vx3 + mfbba * (one - vx3Sq); - m2 = mfbbc * c1o2 + mfbbb * (vx3 + c1o2) + mfbba * (vx3Sq + vx3) * c1o2; - mfbba = m0; - mfbbb = m1; - mfbbc = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcc * c1o2 + mfbcb * (vx3 - c1o2) + mfbca * (vx3Sq - vx3) * c1o2; - m1 = -mfbcc - two * mfbcb * vx3 + mfbca * (one - vx3Sq); - m2 = mfbcc * c1o2 + mfbcb * (vx3 + c1o2) + mfbca * (vx3Sq + vx3) * c1o2; - mfbca = m0; - mfbcb = m1; - mfbcc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcac * c1o2 + mfcab * (vx3 - c1o2) + (mfcaa + c1o3 * oMdrho) * (vx3Sq - vx3) * c1o2; - m1 = -mfcac - two * mfcab * vx3 + mfcaa * (one - vx3Sq) - c1o3 * oMdrho * vx3Sq; - m2 = mfcac * c1o2 + mfcab * (vx3 + c1o2) + (mfcaa + c1o3 * oMdrho) * (vx3Sq + vx3) * c1o2; - mfcaa = m0; - mfcab = m1; - mfcac = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfcbc * c1o2 + mfcbb * (vx3 - c1o2) + mfcba * (vx3Sq - vx3) * c1o2; - m1 = -mfcbc - two * mfcbb * vx3 + mfcba * (one - vx3Sq); - m2 = mfcbc * c1o2 + mfcbb * (vx3 + c1o2) + mfcba * (vx3Sq + vx3) * c1o2; - mfcba = m0; - mfcbb = m1; - mfcbc = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2 + mfccb * (vx3 - c1o2) + (mfcca + c1o9 * oMdrho) * (vx3Sq - vx3) * c1o2; - m1 = -mfccc - two * mfccb * vx3 + mfcca * (one - vx3Sq) - c1o9 * oMdrho * vx3Sq; - m2 = mfccc * c1o2 + mfccb * (vx3 + c1o2) + (mfcca + c1o9 * oMdrho) * (vx3Sq + vx3) * c1o2; - mfcca = m0; - mfccb = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - //mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Y - Dir - m0 = mfaca * c1o2 + mfaba * (vx2 - c1o2) + (mfaaa + c1o6 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfaca - two * mfaba * vx2 + mfaaa * (one - vx2Sq) - c1o6 * oMdrho * vx2Sq; - m2 = mfaca * c1o2 + mfaba * (vx2 + c1o2) + (mfaaa + c1o6 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfaaa = m0; - mfaba = m1; - mfaca = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacb * c1o2 + mfabb * (vx2 - c1o2) + (mfaab + c2o3 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfacb - two * mfabb * vx2 + mfaab * (one - vx2Sq) - c2o3 * oMdrho * vx2Sq; - m2 = mfacb * c1o2 + mfabb * (vx2 + c1o2) + (mfaab + c2o3 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfaab = m0; - mfabb = m1; - mfacb = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacc * c1o2 + mfabc * (vx2 - c1o2) + (mfaac + c1o6 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfacc - two * mfabc * vx2 + mfaac * (one - vx2Sq) - c1o6 * oMdrho * vx2Sq; - m2 = mfacc * c1o2 + mfabc * (vx2 + c1o2) + (mfaac + c1o6 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfaac = m0; - mfabc = m1; - mfacc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfbca * c1o2 + mfbba * (vx2 - c1o2) + mfbaa * (vx2Sq - vx2) * c1o2; - m1 = -mfbca - two * mfbba * vx2 + mfbaa * (one - vx2Sq); - m2 = mfbca * c1o2 + mfbba * (vx2 + c1o2) + mfbaa * (vx2Sq + vx2) * c1o2; - mfbaa = m0; - mfbba = m1; - mfbca = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcb * c1o2 + mfbbb * (vx2 - c1o2) + mfbab * (vx2Sq - vx2) * c1o2; - m1 = -mfbcb - two * mfbbb * vx2 + mfbab * (one - vx2Sq); - m2 = mfbcb * c1o2 + mfbbb * (vx2 + c1o2) + mfbab * (vx2Sq + vx2) * c1o2; - mfbab = m0; - mfbbb = m1; - mfbcb = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcc * c1o2 + mfbbc * (vx2 - c1o2) + mfbac * (vx2Sq - vx2) * c1o2; - m1 = -mfbcc - two * mfbbc * vx2 + mfbac * (one - vx2Sq); - m2 = mfbcc * c1o2 + mfbbc * (vx2 + c1o2) + mfbac * (vx2Sq + vx2) * c1o2; - mfbac = m0; - mfbbc = m1; - mfbcc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcca * c1o2 + mfcba * (vx2 - c1o2) + (mfcaa + c1o18 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfcca - two * mfcba * vx2 + mfcaa * (one - vx2Sq) - c1o18 * oMdrho * vx2Sq; - m2 = mfcca * c1o2 + mfcba * (vx2 + c1o2) + (mfcaa + c1o18 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfcaa = m0; - mfcba = m1; - mfcca = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccb * c1o2 + mfcbb * (vx2 - c1o2) + (mfcab + c2o9 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfccb - two * mfcbb * vx2 + mfcab * (one - vx2Sq) - c2o9 * oMdrho * vx2Sq; - m2 = mfccb * c1o2 + mfcbb * (vx2 + c1o2) + (mfcab + c2o9 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfcab = m0; - mfcbb = m1; - mfccb = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2 + mfcbc * (vx2 - c1o2) + (mfcac + c1o18 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfccc - two * mfcbc * vx2 + mfcac * (one - vx2Sq) - c1o18 * oMdrho * vx2Sq; - m2 = mfccc * c1o2 + mfcbc * (vx2 + c1o2) + (mfcac + c1o18 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfcac = m0; - mfcbc = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - //mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // X - Dir - m0 = mfcaa * c1o2 + mfbaa * (vx1 - c1o2) + (mfaaa + c1o36 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcaa - two * mfbaa * vx1 + mfaaa * (one - vx1Sq) - c1o36 * oMdrho * vx1Sq; - m2 = mfcaa * c1o2 + mfbaa * (vx1 + c1o2) + (mfaaa + c1o36 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaaa = m0; - mfbaa = m1; - mfcaa = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcba * c1o2 + mfbba * (vx1 - c1o2) + (mfaba + c1o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcba - two * mfbba * vx1 + mfaba * (one - vx1Sq) - c1o9 * oMdrho * vx1Sq; - m2 = mfcba * c1o2 + mfbba * (vx1 + c1o2) + (mfaba + c1o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaba = m0; - mfbba = m1; - mfcba = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcca * c1o2 + mfbca * (vx1 - c1o2) + (mfaca + c1o36 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcca - two * mfbca * vx1 + mfaca * (one - vx1Sq) - c1o36 * oMdrho * vx1Sq; - m2 = mfcca * c1o2 + mfbca * (vx1 + c1o2) + (mfaca + c1o36 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaca = m0; - mfbca = m1; - mfcca = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcab * c1o2 + mfbab * (vx1 - c1o2) + (mfaab + c1o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcab - two * mfbab * vx1 + mfaab * (one - vx1Sq) - c1o9 * oMdrho * vx1Sq; - m2 = mfcab * c1o2 + mfbab * (vx1 + c1o2) + (mfaab + c1o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaab = m0; - mfbab = m1; - mfcab = m2; - ///////////b//////////////////////////////////////////////////////////////////////// - m0 = mfcbb * c1o2 + mfbbb * (vx1 - c1o2) + (mfabb + c4o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcbb - two * mfbbb * vx1 + mfabb * (one - vx1Sq) - c4o9 * oMdrho * vx1Sq; - m2 = mfcbb * c1o2 + mfbbb * (vx1 + c1o2) + (mfabb + c4o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfabb = m0; - mfbbb = m1; - mfcbb = m2; - ///////////b//////////////////////////////////////////////////////////////////////// - m0 = mfccb * c1o2 + mfbcb * (vx1 - c1o2) + (mfacb + c1o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfccb - two * mfbcb * vx1 + mfacb * (one - vx1Sq) - c1o9 * oMdrho * vx1Sq; - m2 = mfccb * c1o2 + mfbcb * (vx1 + c1o2) + (mfacb + c1o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfacb = m0; - mfbcb = m1; - mfccb = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcac * c1o2 + mfbac * (vx1 - c1o2) + (mfaac + c1o36 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcac - two * mfbac * vx1 + mfaac * (one - vx1Sq) - c1o36 * oMdrho * vx1Sq; - m2 = mfcac * c1o2 + mfbac * (vx1 + c1o2) + (mfaac + c1o36 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaac = m0; - mfbac = m1; - mfcac = m2; - ///////////c//////////////////////////////////////////////////////////////////////// - m0 = mfcbc * c1o2 + mfbbc * (vx1 - c1o2) + (mfabc + c1o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcbc - two * mfbbc * vx1 + mfabc * (one - vx1Sq) - c1o9 * oMdrho * vx1Sq; - m2 = mfcbc * c1o2 + mfbbc * (vx1 + c1o2) + (mfabc + c1o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfabc = m0; - mfbbc = m1; - mfcbc = m2; - ///////////c//////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2 + mfbcc * (vx1 - c1o2) + (mfacc + c1o36 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfccc - two * mfbcc * vx1 + mfacc * (one - vx1Sq) - c1o36 * oMdrho * vx1Sq; - m2 = mfccc * c1o2 + mfbcc * (vx1 + c1o2) + (mfacc + c1o36 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfacc = m0; - mfbcc = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - - f[E] = mfcbb; - f[W] = mfabb; - f[N] = mfbcb; - f[S] = mfbab; - f[T] = mfbbc; - f[B] = mfbba; - f[NE] = mfccb; - f[SW] = mfaab; - f[SE] = mfcab; - f[NW] = mfacb; - f[TE] = mfcbc; - f[BW] = mfaba; - f[BE] = mfcba; - f[TW] = mfabc; - f[TN] = mfbcc; - f[BS] = mfbaa; - f[BN] = mfbca; - f[TS] = mfbac; - f[ZERO] = mfbbb; - f[TNE] = mfccc; - f[TSE] = mfcac; - f[BNE] = mfcca; - f[BSE] = mfcaa; - f[TNW] = mfacc; - f[TSW] = mfaac; - f[BNW] = mfaca; - f[BSW] = mfaaa; -} -////////////////////////////////////////////////////////////////////////// -//Position SWB -0.25, -0.25, -0.25 -LBMReal CompressibleOffsetMomentsInterpolationProcessor::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 CompressibleOffsetMomentsInterpolationProcessor::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 CompressibleOffsetMomentsInterpolationProcessor::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 CompressibleOffsetMomentsInterpolationProcessor::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 CompressibleOffsetMomentsInterpolationProcessor::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 CompressibleOffsetMomentsInterpolationProcessor::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 CompressibleOffsetMomentsInterpolationProcessor::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 CompressibleOffsetMomentsInterpolationProcessor::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 CompressibleOffsetMomentsInterpolationProcessor::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 eps_new = 2.; - LBMReal o = omega; - //bulk viscosity - LBMReal oP = OxxPyyPzzC; - - LBMReal mfcbb = zeroReal; - LBMReal mfabb = zeroReal; - LBMReal mfbcb = zeroReal; - LBMReal mfbab = zeroReal; - LBMReal mfbbc = zeroReal; - LBMReal mfbba = zeroReal; - LBMReal mfccb = zeroReal; - LBMReal mfaab = zeroReal; - LBMReal mfcab = zeroReal; - LBMReal mfacb = zeroReal; - LBMReal mfcbc = zeroReal; - LBMReal mfaba = zeroReal; - LBMReal mfcba = zeroReal; - LBMReal mfabc = zeroReal; - LBMReal mfbcc = zeroReal; - LBMReal mfbaa = zeroReal; - LBMReal mfbca = zeroReal; - LBMReal mfbac = zeroReal; - LBMReal mfbbb = zeroReal; - LBMReal mfccc = zeroReal; - LBMReal mfaac = zeroReal; - LBMReal mfcac = zeroReal; - LBMReal mfacc = zeroReal; - LBMReal mfcca = zeroReal; - LBMReal mfaaa = zeroReal; - LBMReal mfcaa = zeroReal; - LBMReal mfaca = zeroReal; - - mfaaa = press; // if drho is interpolated directly - - LBMReal vx1Sq = vx1*vx1; - LBMReal vx2Sq = vx2*vx2; - LBMReal vx3Sq = vx3*vx3; - LBMReal oMdrho = one; - //oMdrho = one - mfaaa; - - //2.f - // linear combinations - -///////////////////////// - LBMReal mxxPyyPzz = mfaaa -c2o3*(ax+by+cz)*eps_new/oP*(one+press); - - LBMReal mxxMyy = -c2o3*((ax - by)+kxxMyyAverage)*eps_new/o * (one + press); - LBMReal mxxMzz = -c2o3*((ax - cz)+kxxMzzAverage)*eps_new/o * (one + press); - - mfabb = -c1o3 * ((bz + cy)+kyzAverage)*eps_new/o * (one + press); - mfbab = -c1o3 * ((az + cx)+kxzAverage)*eps_new/o * (one + press); - mfbba = -c1o3 * ((ay + bx)+kxyAverage)*eps_new/o * (one + press); - - //////////////////////// - // linear combinations back - mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); - mfaca = c1o3 * (-two * mxxMyy + mxxMzz + mxxPyyPzz); - mfaac = c1o3 * (mxxMyy - two * mxxMzz + mxxPyyPzz); - - //three - mfbbb = zeroReal; - - LBMReal mxxyPyzz = zeroReal; - LBMReal mxxyMyzz = zeroReal; - LBMReal mxxzPyyz = zeroReal; - LBMReal mxxzMyyz = zeroReal; - LBMReal mxyyPxzz = zeroReal; - LBMReal mxyyMxzz = zeroReal; - - // linear combinations back - mfcba = (mxxyMyzz + mxxyPyzz) * c1o2; - mfabc = (-mxxyMyzz + mxxyPyzz) * c1o2; - mfcab = (mxxzMyyz + mxxzPyyz) * c1o2; - mfacb = (-mxxzMyyz + mxxzPyyz) * c1o2; - mfbca = (mxyyMxzz + mxyyPxzz) * c1o2; - mfbac = (-mxyyMxzz + mxyyPxzz) * c1o2; - - //4.f - mfacc = mfaaa*c1o9; - mfcac = mfacc; - mfcca = mfacc; - //5. - - //6. - mfccc = mfaaa*c1o27; - //////////////////////////////////////////////////////////////////////////////////// - //back - //////////////////////////////////////////////////////////////////////////////////// - //mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Z - Dir - LBMReal m0 = mfaac * c1o2 + mfaab * (vx3 - c1o2) + (mfaaa + one * oMdrho) * (vx3Sq - vx3) * c1o2; - LBMReal m1 = -mfaac - two * mfaab * vx3 + mfaaa * (one - vx3Sq) - one * oMdrho * vx3Sq; - LBMReal m2 = mfaac * c1o2 + mfaab * (vx3 + c1o2) + (mfaaa + one * oMdrho) * (vx3Sq + vx3) * c1o2; - mfaaa = m0; - mfaab = m1; - mfaac = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfabc * c1o2 + mfabb * (vx3 - c1o2) + mfaba * (vx3Sq - vx3) * c1o2; - m1 = -mfabc - two * mfabb * vx3 + mfaba * (one - vx3Sq); - m2 = mfabc * c1o2 + mfabb * (vx3 + c1o2) + mfaba * (vx3Sq + vx3) * c1o2; - mfaba = m0; - mfabb = m1; - mfabc = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacc * c1o2 + mfacb * (vx3 - c1o2) + (mfaca + c1o3 * oMdrho) * (vx3Sq - vx3) * c1o2; - m1 = -mfacc - two * mfacb * vx3 + mfaca * (one - vx3Sq) - c1o3 * oMdrho * vx3Sq; - m2 = mfacc * c1o2 + mfacb * (vx3 + c1o2) + (mfaca + c1o3 * oMdrho) * (vx3Sq + vx3) * c1o2; - mfaca = m0; - mfacb = m1; - mfacc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfbac * c1o2 + mfbab * (vx3 - c1o2) + mfbaa * (vx3Sq - vx3) * c1o2; - m1 = -mfbac - two * mfbab * vx3 + mfbaa * (one - vx3Sq); - m2 = mfbac * c1o2 + mfbab * (vx3 + c1o2) + mfbaa * (vx3Sq + vx3) * c1o2; - mfbaa = m0; - mfbab = m1; - mfbac = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbbc * c1o2 + mfbbb * (vx3 - c1o2) + mfbba * (vx3Sq - vx3) * c1o2; - m1 = -mfbbc - two * mfbbb * vx3 + mfbba * (one - vx3Sq); - m2 = mfbbc * c1o2 + mfbbb * (vx3 + c1o2) + mfbba * (vx3Sq + vx3) * c1o2; - mfbba = m0; - mfbbb = m1; - mfbbc = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcc * c1o2 + mfbcb * (vx3 - c1o2) + mfbca * (vx3Sq - vx3) * c1o2; - m1 = -mfbcc - two * mfbcb * vx3 + mfbca * (one - vx3Sq); - m2 = mfbcc * c1o2 + mfbcb * (vx3 + c1o2) + mfbca * (vx3Sq + vx3) * c1o2; - mfbca = m0; - mfbcb = m1; - mfbcc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcac * c1o2 + mfcab * (vx3 - c1o2) + (mfcaa + c1o3 * oMdrho) * (vx3Sq - vx3) * c1o2; - m1 = -mfcac - two * mfcab * vx3 + mfcaa * (one - vx3Sq) - c1o3 * oMdrho * vx3Sq; - m2 = mfcac * c1o2 + mfcab * (vx3 + c1o2) + (mfcaa + c1o3 * oMdrho) * (vx3Sq + vx3) * c1o2; - mfcaa = m0; - mfcab = m1; - mfcac = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfcbc * c1o2 + mfcbb * (vx3 - c1o2) + mfcba * (vx3Sq - vx3) * c1o2; - m1 = -mfcbc - two * mfcbb * vx3 + mfcba * (one - vx3Sq); - m2 = mfcbc * c1o2 + mfcbb * (vx3 + c1o2) + mfcba * (vx3Sq + vx3) * c1o2; - mfcba = m0; - mfcbb = m1; - mfcbc = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2 + mfccb * (vx3 - c1o2) + (mfcca + c1o9 * oMdrho) * (vx3Sq - vx3) * c1o2; - m1 = -mfccc - two * mfccb * vx3 + mfcca * (one - vx3Sq) - c1o9 * oMdrho * vx3Sq; - m2 = mfccc * c1o2 + mfccb * (vx3 + c1o2) + (mfcca + c1o9 * oMdrho) * (vx3Sq + vx3) * c1o2; - mfcca = m0; - mfccb = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - //mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Y - Dir - m0 = mfaca * c1o2 + mfaba * (vx2 - c1o2) + (mfaaa + c1o6 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfaca - two * mfaba * vx2 + mfaaa * (one - vx2Sq) - c1o6 * oMdrho * vx2Sq; - m2 = mfaca * c1o2 + mfaba * (vx2 + c1o2) + (mfaaa + c1o6 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfaaa = m0; - mfaba = m1; - mfaca = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacb * c1o2 + mfabb * (vx2 - c1o2) + (mfaab + c2o3 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfacb - two * mfabb * vx2 + mfaab * (one - vx2Sq) - c2o3 * oMdrho * vx2Sq; - m2 = mfacb * c1o2 + mfabb * (vx2 + c1o2) + (mfaab + c2o3 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfaab = m0; - mfabb = m1; - mfacb = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacc * c1o2 + mfabc * (vx2 - c1o2) + (mfaac + c1o6 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfacc - two * mfabc * vx2 + mfaac * (one - vx2Sq) - c1o6 * oMdrho * vx2Sq; - m2 = mfacc * c1o2 + mfabc * (vx2 + c1o2) + (mfaac + c1o6 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfaac = m0; - mfabc = m1; - mfacc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfbca * c1o2 + mfbba * (vx2 - c1o2) + mfbaa * (vx2Sq - vx2) * c1o2; - m1 = -mfbca - two * mfbba * vx2 + mfbaa * (one - vx2Sq); - m2 = mfbca * c1o2 + mfbba * (vx2 + c1o2) + mfbaa * (vx2Sq + vx2) * c1o2; - mfbaa = m0; - mfbba = m1; - mfbca = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcb * c1o2 + mfbbb * (vx2 - c1o2) + mfbab * (vx2Sq - vx2) * c1o2; - m1 = -mfbcb - two * mfbbb * vx2 + mfbab * (one - vx2Sq); - m2 = mfbcb * c1o2 + mfbbb * (vx2 + c1o2) + mfbab * (vx2Sq + vx2) * c1o2; - mfbab = m0; - mfbbb = m1; - mfbcb = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcc * c1o2 + mfbbc * (vx2 - c1o2) + mfbac * (vx2Sq - vx2) * c1o2; - m1 = -mfbcc - two * mfbbc * vx2 + mfbac * (one - vx2Sq); - m2 = mfbcc * c1o2 + mfbbc * (vx2 + c1o2) + mfbac * (vx2Sq + vx2) * c1o2; - mfbac = m0; - mfbbc = m1; - mfbcc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcca * c1o2 + mfcba * (vx2 - c1o2) + (mfcaa + c1o18 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfcca - two * mfcba * vx2 + mfcaa * (one - vx2Sq) - c1o18 * oMdrho * vx2Sq; - m2 = mfcca * c1o2 + mfcba * (vx2 + c1o2) + (mfcaa + c1o18 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfcaa = m0; - mfcba = m1; - mfcca = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccb * c1o2 + mfcbb * (vx2 - c1o2) + (mfcab + c2o9 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfccb - two * mfcbb * vx2 + mfcab * (one - vx2Sq) - c2o9 * oMdrho * vx2Sq; - m2 = mfccb * c1o2 + mfcbb * (vx2 + c1o2) + (mfcab + c2o9 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfcab = m0; - mfcbb = m1; - mfccb = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2 + mfcbc * (vx2 - c1o2) + (mfcac + c1o18 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfccc - two * mfcbc * vx2 + mfcac * (one - vx2Sq) - c1o18 * oMdrho * vx2Sq; - m2 = mfccc * c1o2 + mfcbc * (vx2 + c1o2) + (mfcac + c1o18 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfcac = m0; - mfcbc = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - //mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // X - Dir - m0 = mfcaa * c1o2 + mfbaa * (vx1 - c1o2) + (mfaaa + c1o36 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcaa - two * mfbaa * vx1 + mfaaa * (one - vx1Sq) - c1o36 * oMdrho * vx1Sq; - m2 = mfcaa * c1o2 + mfbaa * (vx1 + c1o2) + (mfaaa + c1o36 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaaa = m0; - mfbaa = m1; - mfcaa = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcba * c1o2 + mfbba * (vx1 - c1o2) + (mfaba + c1o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcba - two * mfbba * vx1 + mfaba * (one - vx1Sq) - c1o9 * oMdrho * vx1Sq; - m2 = mfcba * c1o2 + mfbba * (vx1 + c1o2) + (mfaba + c1o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaba = m0; - mfbba = m1; - mfcba = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcca * c1o2 + mfbca * (vx1 - c1o2) + (mfaca + c1o36 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcca - two * mfbca * vx1 + mfaca * (one - vx1Sq) - c1o36 * oMdrho * vx1Sq; - m2 = mfcca * c1o2 + mfbca * (vx1 + c1o2) + (mfaca + c1o36 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaca = m0; - mfbca = m1; - mfcca = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcab * c1o2 + mfbab * (vx1 - c1o2) + (mfaab + c1o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcab - two * mfbab * vx1 + mfaab * (one - vx1Sq) - c1o9 * oMdrho * vx1Sq; - m2 = mfcab * c1o2 + mfbab * (vx1 + c1o2) + (mfaab + c1o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaab = m0; - mfbab = m1; - mfcab = m2; - ///////////b//////////////////////////////////////////////////////////////////////// - m0 = mfcbb * c1o2 + mfbbb * (vx1 - c1o2) + (mfabb + c4o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcbb - two * mfbbb * vx1 + mfabb * (one - vx1Sq) - c4o9 * oMdrho * vx1Sq; - m2 = mfcbb * c1o2 + mfbbb * (vx1 + c1o2) + (mfabb + c4o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfabb = m0; - mfbbb = m1; - mfcbb = m2; - ///////////b//////////////////////////////////////////////////////////////////////// - m0 = mfccb * c1o2 + mfbcb * (vx1 - c1o2) + (mfacb + c1o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfccb - two * mfbcb * vx1 + mfacb * (one - vx1Sq) - c1o9 * oMdrho * vx1Sq; - m2 = mfccb * c1o2 + mfbcb * (vx1 + c1o2) + (mfacb + c1o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfacb = m0; - mfbcb = m1; - mfccb = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcac * c1o2 + mfbac * (vx1 - c1o2) + (mfaac + c1o36 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcac - two * mfbac * vx1 + mfaac * (one - vx1Sq) - c1o36 * oMdrho * vx1Sq; - m2 = mfcac * c1o2 + mfbac * (vx1 + c1o2) + (mfaac + c1o36 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaac = m0; - mfbac = m1; - mfcac = m2; - ///////////c//////////////////////////////////////////////////////////////////////// - m0 = mfcbc * c1o2 + mfbbc * (vx1 - c1o2) + (mfabc + c1o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcbc - two * mfbbc * vx1 + mfabc * (one - vx1Sq) - c1o9 * oMdrho * vx1Sq; - m2 = mfcbc * c1o2 + mfbbc * (vx1 + c1o2) + (mfabc + c1o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfabc = m0; - mfbbc = m1; - mfcbc = m2; - ///////////c//////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2 + mfbcc * (vx1 - c1o2) + (mfacc + c1o36 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfccc - two * mfbcc * vx1 + mfacc * (one - vx1Sq) - c1o36 * oMdrho * vx1Sq; - m2 = mfccc * c1o2 + mfbcc * (vx1 + c1o2) + (mfacc + c1o36 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfacc = m0; - mfbcc = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - - f[E] = mfcbb; - f[W] = mfabb; - f[N] = mfbcb; - f[S] = mfbab; - f[T] = mfbbc; - f[B] = mfbba; - f[NE] = mfccb; - f[SW] = mfaab; - f[SE] = mfcab; - f[NW] = mfacb; - f[TE] = mfcbc; - f[BW] = mfaba; - f[BE] = mfcba; - f[TW] = mfabc; - f[TN] = mfbcc; - f[BS] = mfbaa; - f[BN] = mfbca; - f[TS] = mfbac; - f[ZERO] = mfbbb; - f[TNE] = mfccc; - f[TSE] = mfcac; - f[BNE] = mfcca; - f[BSE] = mfcaa; - f[TNW] = mfacc; - f[TSW] = mfaac; - f[BNW] = mfaca; - f[BSW] = mfaaa; -} -////////////////////////////////////////////////////////////////////////// -void CompressibleOffsetMomentsInterpolationProcessor::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 CompressibleOffsetMomentsInterpolationProcessor::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)); -} -////////////////////////////////////////////////////////////////////////// -void CompressibleOffsetMomentsInterpolationProcessor::setBulkViscosity(LBMReal shearViscosity, LBMReal bulkViscosity) -{ - this->shearViscosity = shearViscosity; - this->bulkViscosity = bulkViscosity; -} - diff --git a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetMomentsInterpolationProcessor.h b/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetMomentsInterpolationProcessor.h deleted file mode 100644 index 8b40c00d2..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetMomentsInterpolationProcessor.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef CompressibleOffsetMomentsInterpolationProcessor_H_ -#define CompressibleOffsetMomentsInterpolationProcessor_H_ - -#include "InterpolationProcessor.h" -#include "D3Q27System.h" - -////////////////////////////////////////////////////////////////////////// -//it works only for cascaded LBM -//super compact interpolation method by Martin Geier -////////////////////////////////////////////////////////////////////////// - -class CompressibleOffsetMomentsInterpolationProcessor; - -class CompressibleOffsetMomentsInterpolationProcessor : public InterpolationProcessor -{ -public: - CompressibleOffsetMomentsInterpolationProcessor(); - CompressibleOffsetMomentsInterpolationProcessor(LBMReal omegaC, LBMReal omegaF); - virtual ~CompressibleOffsetMomentsInterpolationProcessor(); - 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); - void interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC); - void interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC, LBMReal xoff, LBMReal yoff, LBMReal zoff); - void setBulkViscosity(LBMReal shearViscosity, LBMReal bulkViscosity); -protected: -private: - 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*/; - - LBMReal kxyAverage, kyzAverage, kxzAverage, kxxMyyAverage, kxxMzzAverage; - - LBMReal a,b,c; - - // bulk viscosity - LBMReal shearViscosity; - LBMReal bulkViscosity; - LBMReal OxxPyyPzzC; - LBMReal OxxPyyPzzF; - - 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 calcInterpolatedNodeCF(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 CompressibleOffsetMomentsInterpolationProcessor::interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF) -{ - this->interpolateCoarseToFine(icellC, icellF, 0.0, 0.0, 0.0); -} -////////////////////////////////////////////////////////////////////////// -inline void CompressibleOffsetMomentsInterpolationProcessor::interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC) -{ - this->interpolateFineToCoarse(icellF, icellC, 0.0, 0.0, 0.0); -} - -#endif diff --git a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetSquarePressureInterpolationProcessor.cpp b/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetSquarePressureInterpolationProcessor.cpp deleted file mode 100644 index 44be4234f..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetSquarePressureInterpolationProcessor.cpp +++ /dev/null @@ -1,1288 +0,0 @@ -#include "CompressibleOffsetSquarePressureInterpolationProcessor.h" -#include "D3Q27System.h" - - - -CompressibleOffsetSquarePressureInterpolationProcessor::CompressibleOffsetSquarePressureInterpolationProcessor() - : omegaC(0.0), omegaF(0.0) -{ - this->bulkOmegaToOmega = false; - this->OxxPyyPzzC = one; - this->OxxPyyPzzF = one; -} -////////////////////////////////////////////////////////////////////////// -CompressibleOffsetSquarePressureInterpolationProcessor::CompressibleOffsetSquarePressureInterpolationProcessor(LBMReal omegaC, LBMReal omegaF) - : omegaC(omegaC), omegaF(omegaF) -{ - this->bulkOmegaToOmega = false; - this->OxxPyyPzzC = one; - this->OxxPyyPzzF = one; -} -////////////////////////////////////////////////////////////////////////// -CompressibleOffsetSquarePressureInterpolationProcessor::~CompressibleOffsetSquarePressureInterpolationProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -InterpolationProcessorPtr CompressibleOffsetSquarePressureInterpolationProcessor::clone() -{ - InterpolationProcessorPtr iproc = InterpolationProcessorPtr (new CompressibleOffsetSquarePressureInterpolationProcessor(this->omegaC, this->omegaF)); - if (bulkOmegaToOmega) - { - dynamicPointerCast<CompressibleOffsetSquarePressureInterpolationProcessor>(iproc)->OxxPyyPzzC = omegaC; - dynamicPointerCast<CompressibleOffsetSquarePressureInterpolationProcessor>(iproc)->OxxPyyPzzF = omegaF; - } - else - { - dynamicPointerCast<CompressibleOffsetSquarePressureInterpolationProcessor>(iproc)->OxxPyyPzzC = one; - dynamicPointerCast<CompressibleOffsetSquarePressureInterpolationProcessor>(iproc)->OxxPyyPzzF = one; - } - return iproc; -} -////////////////////////////////////////////////////////////////////////// -void CompressibleOffsetSquarePressureInterpolationProcessor::setOmegas( LBMReal omegaC, LBMReal omegaF ) -{ - this->omegaC = omegaC; - this->omegaF = omegaF; -} -////////////////////////////////////////////////////////////////////////// -void CompressibleOffsetSquarePressureInterpolationProcessor::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 CompressibleOffsetSquarePressureInterpolationProcessor::interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF, LBMReal xoff, LBMReal yoff, LBMReal zoff) -{ - setOffsets(xoff, yoff, zoff); - calcInterpolatedCoefficiets(icellC, omegaC, 0.5); - calcInterpolatedNodeCF(icellF.BSW, omegaF, -0.25, -0.25, -0.25, calcPressBSW(), -1, -1, -1); - calcInterpolatedNodeCF(icellF.BNE, omegaF, 0.25, 0.25, -0.25, calcPressBNE(), 1, 1, -1); - calcInterpolatedNodeCF(icellF.TNW, omegaF, -0.25, 0.25, 0.25, calcPressTNW(), -1, 1, 1); - calcInterpolatedNodeCF(icellF.TSE, omegaF, 0.25, -0.25, 0.25, calcPressTSE(), 1, -1, 1); - calcInterpolatedNodeCF(icellF.BNW, omegaF, -0.25, 0.25, -0.25, calcPressBNW(), -1, 1, -1); - calcInterpolatedNodeCF(icellF.BSE, omegaF, 0.25, -0.25, -0.25, calcPressBSE(), 1, -1, -1); - calcInterpolatedNodeCF(icellF.TSW, omegaF, -0.25, -0.25, 0.25, calcPressTSW(), -1, -1, 1); - calcInterpolatedNodeCF(icellF.TNE, omegaF, 0.25, 0.25, 0.25, calcPressTNE(), 1, 1, 1); -} -////////////////////////////////////////////////////////////////////////// -void CompressibleOffsetSquarePressureInterpolationProcessor::interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC, LBMReal xoff, LBMReal yoff, LBMReal zoff) -{ - setOffsets(xoff, yoff, zoff); - calcInterpolatedCoefficiets(icellF, omegaF, 2.0); - calcInterpolatedNodeFC(icellC, omegaC); -} -////////////////////////////////////////////////////////////////////////// -void CompressibleOffsetSquarePressureInterpolationProcessor::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 drho = 0.0; - D3Q27System::calcCompMacroscopicValues(f,drho,vx1,vx2,vx3); - - press = drho; //interpolate rho! - - kxy = -3.*omega*((((f[TSW]+f[BNE])-(f[TNW]+f[BSE]))+((f[BSW]+f[TNE])-(f[BNW]+f[TSE])))+((f[SW]+f[NE])-(f[NW]+f[SE]))/(one + drho)-(vx1*vx2));// might not be optimal MG 25.2.13 - kyz = -3.*omega*((((f[BSW]+f[TNE])-(f[TSE]+f[BNW]))+((f[BSE]+f[TNW])-(f[TSW]+f[BNE])))+((f[BS]+f[TN])-(f[TS]+f[BN]))/(one + drho)-(vx2*vx3)); - kxz = -3.*omega*((((f[BNW]+f[TSE])-(f[TSW]+f[BNE]))+((f[BSW]+f[TNE])-(f[BSE]+f[TNW])))+((f[BW]+f[TE])-(f[TW]+f[BE]))/(one + drho)-(vx1*vx3)); - kxxMyy = -3./2.*omega*((((f[BW]+f[TE])-(f[BS]+f[TN]))+((f[TW]+f[BE])-(f[TS]+f[BN])))+((f[W]+f[E])-(f[S]+f[N]))/(one + drho)-(vx1*vx1-vx2*vx2)); - kxxMzz = -3./2.*omega*((((f[NW]+f[SE])-(f[BS]+f[TN]))+((f[SW]+f[NE])-(f[TS]+f[BN])))+((f[W]+f[E])-(f[B]+f[T]))/(one + drho)-(vx1*vx1-vx3*vx3)); -} -////////////////////////////////////////////////////////////////////////// -void CompressibleOffsetSquarePressureInterpolationProcessor::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); - - //LBMReal dxRho=c1o4*((press_NET-press_SWB)+(press_SET-press_NWB)+(press_NEB-press_SWT)+(press_SEB-press_NWT)); - //LBMReal dyRho=c1o4*((press_NET-press_SWB)-(press_SET-press_NWB)+(press_NEB-press_SWT)-(press_SEB-press_NWT)); - //LBMReal dzRho=c1o4*((press_NET-press_SWB)+(press_SET-press_NWB)-(press_NEB-press_SWT)-(press_SEB-press_NWT)); - - // kxyFromfcNEQ_SWT+=vx1_SWT*dyRho+vx2_SWT*dxRho; - // kxyFromfcNEQ_NWT+=vx1_NWT*dyRho+vx2_NWT*dxRho; - // kxyFromfcNEQ_NET+=vx1_NET*dyRho+vx2_NET*dxRho; - // kxyFromfcNEQ_SET+=vx1_SET*dyRho+vx2_SET*dxRho; - // kxyFromfcNEQ_SWB+=vx1_SWB*dyRho+vx2_SWB*dxRho; - // kxyFromfcNEQ_NWB+=vx1_NWB*dyRho+vx2_NWB*dxRho; - // kxyFromfcNEQ_NEB+=vx1_NEB*dyRho+vx2_NEB*dxRho; - // kxyFromfcNEQ_SEB+=vx1_SEB*dyRho+vx2_SEB*dxRho; - - // kyzFromfcNEQ_SWT+=vx3_SWT*dyRho+vx2_SWT*dzRho; - // kyzFromfcNEQ_NWT+=vx3_NWT*dyRho+vx2_NWT*dzRho; - // kyzFromfcNEQ_NET+=vx3_NET*dyRho+vx2_NET*dzRho; - // kyzFromfcNEQ_SET+=vx3_SET*dyRho+vx2_SET*dzRho; - // kyzFromfcNEQ_SWB+=vx3_SWB*dyRho+vx2_SWB*dzRho; - // kyzFromfcNEQ_NWB+=vx3_NWB*dyRho+vx2_NWB*dzRho; - // kyzFromfcNEQ_NEB+=vx3_NEB*dyRho+vx2_NEB*dzRho; - // kyzFromfcNEQ_SEB+=vx3_SEB*dyRho+vx2_SEB*dzRho; - - // kxzFromfcNEQ_SWT+=vx1_SWT*dzRho+vx3_SWT*dxRho; - // kxzFromfcNEQ_NWT+=vx1_NWT*dzRho+vx3_NWT*dxRho; - // kxzFromfcNEQ_NET+=vx1_NET*dzRho+vx3_NET*dxRho; - // kxzFromfcNEQ_SET+=vx1_SET*dzRho+vx3_SET*dxRho; - // kxzFromfcNEQ_SWB+=vx1_SWB*dzRho+vx3_SWB*dxRho; - // kxzFromfcNEQ_NWB+=vx1_NWB*dzRho+vx3_NWB*dxRho; - // kxzFromfcNEQ_NEB+=vx1_NEB*dzRho+vx3_NEB*dxRho; - // kxzFromfcNEQ_SEB+=vx1_SEB*dzRho+vx3_SEB*dxRho; - - // kxxMyyFromfcNEQ_SWT+=vx1_SWT*dxRho-vx2_SWT*dyRho; - // kxxMyyFromfcNEQ_NWT+=vx1_NWT*dxRho-vx2_NWT*dyRho; - // kxxMyyFromfcNEQ_NET+=vx1_NET*dxRho-vx2_NET*dyRho; - // kxxMyyFromfcNEQ_SET+=vx1_SET*dxRho-vx2_SET*dyRho; - // kxxMyyFromfcNEQ_SWB+=vx1_SWB*dxRho-vx2_SWB*dyRho; - // kxxMyyFromfcNEQ_NWB+=vx1_NWB*dxRho-vx2_NWB*dyRho; - // kxxMyyFromfcNEQ_NEB+=vx1_NEB*dxRho-vx2_NEB*dyRho; - // kxxMyyFromfcNEQ_SEB+=vx1_SEB*dxRho-vx2_SEB*dyRho; - - // kxxMzzFromfcNEQ_SWT+=vx1_SWT*dxRho-vx3_SWT*dzRho; - // kxxMzzFromfcNEQ_NWT+=vx1_NWT*dxRho-vx3_NWT*dzRho; - // kxxMzzFromfcNEQ_NET+=vx1_NET*dxRho-vx3_NET*dzRho; - // kxxMzzFromfcNEQ_SET+=vx1_SET*dxRho-vx3_SET*dzRho; - // kxxMzzFromfcNEQ_SWB+=vx1_SWB*dxRho-vx3_SWB*dzRho; - // kxxMzzFromfcNEQ_NWB+=vx1_NWB*dxRho-vx3_NWB*dzRho; - // kxxMzzFromfcNEQ_NEB+=vx1_NEB*dxRho-vx3_NEB*dzRho; - // kxxMzzFromfcNEQ_SEB+=vx1_SEB*dxRho-vx3_SEB*dzRho; - - - //kxxMzzFromfcNEQ_SWT=0.0; - //kxxMzzFromfcNEQ_NWT=0.0; - //kxxMzzFromfcNEQ_NET=0.0; - //kxxMzzFromfcNEQ_SET=0.0; - //kxxMzzFromfcNEQ_SWB=0.0; - //kxxMzzFromfcNEQ_NWB=0.0; - //kxxMzzFromfcNEQ_NEB=0.0; - //kxxMzzFromfcNEQ_SEB=0.0; - - - - - - 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; - - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - kxyAverage =0;//(kxyFromfcNEQ_SWB+ - //kxyFromfcNEQ_SWT+ - //kxyFromfcNEQ_SET+ - //kxyFromfcNEQ_SEB+ - //kxyFromfcNEQ_NWB+ - //kxyFromfcNEQ_NWT+ - //kxyFromfcNEQ_NET+ - //kxyFromfcNEQ_NEB)*c1o8-(ay+bx); - kyzAverage =0;//(kyzFromfcNEQ_SWB+ - //kyzFromfcNEQ_SWT+ - //kyzFromfcNEQ_SET+ - //kyzFromfcNEQ_SEB+ - //kyzFromfcNEQ_NWB+ - //kyzFromfcNEQ_NWT+ - //kyzFromfcNEQ_NET+ - //kyzFromfcNEQ_NEB)*c1o8-(bz+cy); - kxzAverage =0;//(kxzFromfcNEQ_SWB+ - //kxzFromfcNEQ_SWT+ - //kxzFromfcNEQ_SET+ - //kxzFromfcNEQ_SEB+ - //kxzFromfcNEQ_NWB+ - //kxzFromfcNEQ_NWT+ - //kxzFromfcNEQ_NET+ - //kxzFromfcNEQ_NEB)*c1o8-(az+cx); - kxxMyyAverage =0;//(kxxMyyFromfcNEQ_SWB+ - //kxxMyyFromfcNEQ_SWT+ - //kxxMyyFromfcNEQ_SET+ - //kxxMyyFromfcNEQ_SEB+ - //kxxMyyFromfcNEQ_NWB+ - //kxxMyyFromfcNEQ_NWT+ - //kxxMyyFromfcNEQ_NET+ - //kxxMyyFromfcNEQ_NEB)*c1o8-(ax-by); - kxxMzzAverage =0;//(kxxMzzFromfcNEQ_SWB+ - //kxxMzzFromfcNEQ_SWT+ - //kxxMzzFromfcNEQ_SET+ - //kxxMzzFromfcNEQ_SEB+ - //kxxMzzFromfcNEQ_NWB+ - //kxxMzzFromfcNEQ_NWT+ - //kxxMzzFromfcNEQ_NET+ - //kxxMzzFromfcNEQ_NEB)*c1o8-(ax-cz); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // - // 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-kxxMzzAverage-kxxMyyAverage))/(27.*o)); - f_N = eps_new*((2*(ax - 2*by + cz+2*kxxMyyAverage-kxxMzzAverage))/(27.*o)); - f_T = eps_new*((2*(ax + by - 2*cz-kxxMyyAverage+2*kxxMzzAverage))/(27.*o)); - f_NE = eps_new*(-(ax + 3*ay + 3*bx + by - 2*cz+2*kxxMyyAverage-kxxMyyAverage+3*kxyAverage)/(54.*o)); - f_SE = eps_new*(-(ax - 3*ay - 3*bx + by - 2*cz+2*kxxMyyAverage-kxxMyyAverage-3*kxyAverage)/(54.*o)); - f_TE = eps_new*(-(ax + 3*az - 2*by + 3*cx + cz+2*kxxMyyAverage-kxxMzzAverage+3*kxzAverage)/(54.*o)); - f_BE = eps_new*(-(ax - 3*az - 2*by - 3*cx + cz+2*kxxMyyAverage-kxxMzzAverage-3*kxzAverage)/(54.*o)); - f_TN = eps_new*(-(-2*ax + by + 3*bz + 3*cy + cz-kxxMyyAverage-kxxMzzAverage+3*kyzAverage)/(54.*o)); - f_BN = eps_new*(-(-2*ax + by - 3*bz - 3*cy + cz-kxxMyyAverage-kxxMzzAverage-3*kyzAverage)/(54.*o)); - f_ZERO = 0.; - f_TNE = eps_new*(-(ay + az + bx + bz + cx + cy+kxyAverage+kxzAverage+kyzAverage)/(72.*o)); - f_TSW = eps_new*((-ay + az - bx + bz + cx + cy-kxyAverage+kxzAverage+kyzAverage)/(72.*o)); - f_TSE = eps_new*((ay - az + bx + bz - cx + cy+kxyAverage-kxzAverage+kyzAverage)/(72.*o)); - f_TNW = eps_new*((ay + az + bx - bz + cx - cy+kxyAverage+kxzAverage-kyzAverage)/(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 CompressibleOffsetSquarePressureInterpolationProcessor::calcInterpolatedNodeCF(LBMReal* f, LBMReal omega, LBMReal x, LBMReal y, LBMReal z, LBMReal press, LBMReal xs, LBMReal ys, LBMReal zs) -{ - using namespace D3Q27System; - - LBMReal eps_new = 0.5; - LBMReal o = omega; - //bulk viscosity - LBMReal oP = OxxPyyPzzF; - - 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 laplaceRho = (xoff!=0.0 || yoff!=0.0 || zoff!= 0.0) ? 0.0 :(-3.0*(by*by+ax*ax+cz*cz)-6.0*(ay*bx+bz*cy+az*cx))*(1.0+rho); - - rho=rho+laplaceRho*(3.0/16.0); - - 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 mfcbb = zeroReal; - LBMReal mfabb = zeroReal; - LBMReal mfbcb = zeroReal; - LBMReal mfbab = zeroReal; - LBMReal mfbbc = zeroReal; - LBMReal mfbba = zeroReal; - LBMReal mfccb = zeroReal; - LBMReal mfaab = zeroReal; - LBMReal mfcab = zeroReal; - LBMReal mfacb = zeroReal; - LBMReal mfcbc = zeroReal; - LBMReal mfaba = zeroReal; - LBMReal mfcba = zeroReal; - LBMReal mfabc = zeroReal; - LBMReal mfbcc = zeroReal; - LBMReal mfbaa = zeroReal; - LBMReal mfbca = zeroReal; - LBMReal mfbac = zeroReal; - LBMReal mfbbb = zeroReal; - LBMReal mfccc = zeroReal; - LBMReal mfaac = zeroReal; - LBMReal mfcac = zeroReal; - LBMReal mfacc = zeroReal; - LBMReal mfcca = zeroReal; - LBMReal mfaaa = zeroReal; - LBMReal mfcaa = zeroReal; - LBMReal mfaca = zeroReal; - - mfaaa = rho; // if drho is interpolated directly - - LBMReal vx1Sq = vx1*vx1; - LBMReal vx2Sq = vx2*vx2; - LBMReal vx3Sq = vx3*vx3; - LBMReal oMdrho = one; - - //2.f - - // linear combinations - LBMReal mxxPyyPzz = mfaaa - c2o3*(ax + by + two*axx*x + bxy*x + axy*y + two*byy*y + axz*z + byz*z + bxyz*x*z + axyz*y*z + cz - cxz*x + cyz*y + cxyz*x*y + two*czz*z)*eps_new / oP* (one + press); - LBMReal mxxMyy = -c2o3*(ax - by + kxxMyyAverage + two*axx*x - bxy*x + axy*y - two*byy*y + axz*z - byz*z - bxyz*x*z + axyz*y*z)*eps_new/o * (one + press); - LBMReal mxxMzz = -c2o3*(ax - cz + kxxMzzAverage + two*axx*x - cxz*x + axy*y - cyz*y - cxyz*x*y + axz*z - two*czz*z + axyz*y*z)*eps_new/o * (one + press); - - mfabb = -c1o3 * (bz + cy + kyzAverage + bxz*x + cxy*x + byz*y + two*cyy*y + bxyz*x*y + two*bzz*z + cyz*z + cxyz*x*z)*eps_new/o * (one + press); - mfbab = -c1o3 * (az + cx + kxzAverage + axz*x + two*cxx*x + ayz*y + cxy*y + axyz*x*y + two*azz*z + cxz*z + cxyz*y*z)*eps_new/o * (one + press); - mfbba = -c1o3 * (ay + bx + kxyAverage + axy*x + two*bxx*x + two*ayy*y + bxy*y + ayz*z + bxz*z + axyz*x*z + bxyz*y*z)*eps_new/o * (one + press); - - // linear combinations back - mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz) ; - mfaca = c1o3 * (-two * mxxMyy + mxxMzz + mxxPyyPzz) ; - mfaac = c1o3 * (mxxMyy - two * mxxMzz + mxxPyyPzz) ; - - //three - mfbbb = zeroReal; - LBMReal mxxyPyzz = zeroReal; - LBMReal mxxyMyzz = zeroReal; - LBMReal mxxzPyyz = zeroReal; - LBMReal mxxzMyyz = zeroReal; - LBMReal mxyyPxzz = zeroReal; - LBMReal mxyyMxzz = zeroReal; - - // linear combinations back - mfcba = (mxxyMyzz + mxxyPyzz) * c1o2; - mfabc = (-mxxyMyzz + mxxyPyzz) * c1o2; - mfcab = (mxxzMyyz + mxxzPyyz) * c1o2; - mfacb = (-mxxzMyyz + mxxzPyyz) * c1o2; - mfbca = (mxyyMxzz + mxyyPxzz) * c1o2; - mfbac = (-mxyyMxzz + mxyyPxzz) * c1o2; - - //4.f - mfacc = mfaaa*c1o9; - mfcac = mfacc; - mfcca = mfacc; - - //5. - - //6. - - mfccc = mfaaa*c1o27; - //////////////////////////////////////////////////////////////////////////////////// - //back - //////////////////////////////////////////////////////////////////////////////////// - //mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Z - Dir - LBMReal m0 = mfaac * c1o2 + mfaab * (vx3 - c1o2) + (mfaaa + one * oMdrho) * (vx3Sq - vx3) * c1o2; - LBMReal m1 = -mfaac - two * mfaab * vx3 + mfaaa * (one - vx3Sq) - one * oMdrho * vx3Sq; - LBMReal m2 = mfaac * c1o2 + mfaab * (vx3 + c1o2) + (mfaaa + one * oMdrho) * (vx3Sq + vx3) * c1o2; - mfaaa = m0; - mfaab = m1; - mfaac = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfabc * c1o2 + mfabb * (vx3 - c1o2) + mfaba * (vx3Sq - vx3) * c1o2; - m1 = -mfabc - two * mfabb * vx3 + mfaba * (one - vx3Sq); - m2 = mfabc * c1o2 + mfabb * (vx3 + c1o2) + mfaba * (vx3Sq + vx3) * c1o2; - mfaba = m0; - mfabb = m1; - mfabc = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacc * c1o2 + mfacb * (vx3 - c1o2) + (mfaca + c1o3 * oMdrho) * (vx3Sq - vx3) * c1o2; - m1 = -mfacc - two * mfacb * vx3 + mfaca * (one - vx3Sq) - c1o3 * oMdrho * vx3Sq; - m2 = mfacc * c1o2 + mfacb * (vx3 + c1o2) + (mfaca + c1o3 * oMdrho) * (vx3Sq + vx3) * c1o2; - mfaca = m0; - mfacb = m1; - mfacc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfbac * c1o2 + mfbab * (vx3 - c1o2) + mfbaa * (vx3Sq - vx3) * c1o2; - m1 = -mfbac - two * mfbab * vx3 + mfbaa * (one - vx3Sq); - m2 = mfbac * c1o2 + mfbab * (vx3 + c1o2) + mfbaa * (vx3Sq + vx3) * c1o2; - mfbaa = m0; - mfbab = m1; - mfbac = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbbc * c1o2 + mfbbb * (vx3 - c1o2) + mfbba * (vx3Sq - vx3) * c1o2; - m1 = -mfbbc - two * mfbbb * vx3 + mfbba * (one - vx3Sq); - m2 = mfbbc * c1o2 + mfbbb * (vx3 + c1o2) + mfbba * (vx3Sq + vx3) * c1o2; - mfbba = m0; - mfbbb = m1; - mfbbc = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcc * c1o2 + mfbcb * (vx3 - c1o2) + mfbca * (vx3Sq - vx3) * c1o2; - m1 = -mfbcc - two * mfbcb * vx3 + mfbca * (one - vx3Sq); - m2 = mfbcc * c1o2 + mfbcb * (vx3 + c1o2) + mfbca * (vx3Sq + vx3) * c1o2; - mfbca = m0; - mfbcb = m1; - mfbcc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcac * c1o2 + mfcab * (vx3 - c1o2) + (mfcaa + c1o3 * oMdrho) * (vx3Sq - vx3) * c1o2; - m1 = -mfcac - two * mfcab * vx3 + mfcaa * (one - vx3Sq) - c1o3 * oMdrho * vx3Sq; - m2 = mfcac * c1o2 + mfcab * (vx3 + c1o2) + (mfcaa + c1o3 * oMdrho) * (vx3Sq + vx3) * c1o2; - mfcaa = m0; - mfcab = m1; - mfcac = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfcbc * c1o2 + mfcbb * (vx3 - c1o2) + mfcba * (vx3Sq - vx3) * c1o2; - m1 = -mfcbc - two * mfcbb * vx3 + mfcba * (one - vx3Sq); - m2 = mfcbc * c1o2 + mfcbb * (vx3 + c1o2) + mfcba * (vx3Sq + vx3) * c1o2; - mfcba = m0; - mfcbb = m1; - mfcbc = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2 + mfccb * (vx3 - c1o2) + (mfcca + c1o9 * oMdrho) * (vx3Sq - vx3) * c1o2; - m1 = -mfccc - two * mfccb * vx3 + mfcca * (one - vx3Sq) - c1o9 * oMdrho * vx3Sq; - m2 = mfccc * c1o2 + mfccb * (vx3 + c1o2) + (mfcca + c1o9 * oMdrho) * (vx3Sq + vx3) * c1o2; - mfcca = m0; - mfccb = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - //mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Y - Dir - m0 = mfaca * c1o2 + mfaba * (vx2 - c1o2) + (mfaaa + c1o6 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfaca - two * mfaba * vx2 + mfaaa * (one - vx2Sq) - c1o6 * oMdrho * vx2Sq; - m2 = mfaca * c1o2 + mfaba * (vx2 + c1o2) + (mfaaa + c1o6 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfaaa = m0; - mfaba = m1; - mfaca = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacb * c1o2 + mfabb * (vx2 - c1o2) + (mfaab + c2o3 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfacb - two * mfabb * vx2 + mfaab * (one - vx2Sq) - c2o3 * oMdrho * vx2Sq; - m2 = mfacb * c1o2 + mfabb * (vx2 + c1o2) + (mfaab + c2o3 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfaab = m0; - mfabb = m1; - mfacb = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacc * c1o2 + mfabc * (vx2 - c1o2) + (mfaac + c1o6 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfacc - two * mfabc * vx2 + mfaac * (one - vx2Sq) - c1o6 * oMdrho * vx2Sq; - m2 = mfacc * c1o2 + mfabc * (vx2 + c1o2) + (mfaac + c1o6 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfaac = m0; - mfabc = m1; - mfacc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfbca * c1o2 + mfbba * (vx2 - c1o2) + mfbaa * (vx2Sq - vx2) * c1o2; - m1 = -mfbca - two * mfbba * vx2 + mfbaa * (one - vx2Sq); - m2 = mfbca * c1o2 + mfbba * (vx2 + c1o2) + mfbaa * (vx2Sq + vx2) * c1o2; - mfbaa = m0; - mfbba = m1; - mfbca = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcb * c1o2 + mfbbb * (vx2 - c1o2) + mfbab * (vx2Sq - vx2) * c1o2; - m1 = -mfbcb - two * mfbbb * vx2 + mfbab * (one - vx2Sq); - m2 = mfbcb * c1o2 + mfbbb * (vx2 + c1o2) + mfbab * (vx2Sq + vx2) * c1o2; - mfbab = m0; - mfbbb = m1; - mfbcb = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcc * c1o2 + mfbbc * (vx2 - c1o2) + mfbac * (vx2Sq - vx2) * c1o2; - m1 = -mfbcc - two * mfbbc * vx2 + mfbac * (one - vx2Sq); - m2 = mfbcc * c1o2 + mfbbc * (vx2 + c1o2) + mfbac * (vx2Sq + vx2) * c1o2; - mfbac = m0; - mfbbc = m1; - mfbcc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcca * c1o2 + mfcba * (vx2 - c1o2) + (mfcaa + c1o18 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfcca - two * mfcba * vx2 + mfcaa * (one - vx2Sq) - c1o18 * oMdrho * vx2Sq; - m2 = mfcca * c1o2 + mfcba * (vx2 + c1o2) + (mfcaa + c1o18 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfcaa = m0; - mfcba = m1; - mfcca = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccb * c1o2 + mfcbb * (vx2 - c1o2) + (mfcab + c2o9 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfccb - two * mfcbb * vx2 + mfcab * (one - vx2Sq) - c2o9 * oMdrho * vx2Sq; - m2 = mfccb * c1o2 + mfcbb * (vx2 + c1o2) + (mfcab + c2o9 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfcab = m0; - mfcbb = m1; - mfccb = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2 + mfcbc * (vx2 - c1o2) + (mfcac + c1o18 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfccc - two * mfcbc * vx2 + mfcac * (one - vx2Sq) - c1o18 * oMdrho * vx2Sq; - m2 = mfccc * c1o2 + mfcbc * (vx2 + c1o2) + (mfcac + c1o18 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfcac = m0; - mfcbc = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - //mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // X - Dir - m0 = mfcaa * c1o2 + mfbaa * (vx1 - c1o2) + (mfaaa + c1o36 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcaa - two * mfbaa * vx1 + mfaaa * (one - vx1Sq) - c1o36 * oMdrho * vx1Sq; - m2 = mfcaa * c1o2 + mfbaa * (vx1 + c1o2) + (mfaaa + c1o36 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaaa = m0; - mfbaa = m1; - mfcaa = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcba * c1o2 + mfbba * (vx1 - c1o2) + (mfaba + c1o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcba - two * mfbba * vx1 + mfaba * (one - vx1Sq) - c1o9 * oMdrho * vx1Sq; - m2 = mfcba * c1o2 + mfbba * (vx1 + c1o2) + (mfaba + c1o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaba = m0; - mfbba = m1; - mfcba = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcca * c1o2 + mfbca * (vx1 - c1o2) + (mfaca + c1o36 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcca - two * mfbca * vx1 + mfaca * (one - vx1Sq) - c1o36 * oMdrho * vx1Sq; - m2 = mfcca * c1o2 + mfbca * (vx1 + c1o2) + (mfaca + c1o36 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaca = m0; - mfbca = m1; - mfcca = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcab * c1o2 + mfbab * (vx1 - c1o2) + (mfaab + c1o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcab - two * mfbab * vx1 + mfaab * (one - vx1Sq) - c1o9 * oMdrho * vx1Sq; - m2 = mfcab * c1o2 + mfbab * (vx1 + c1o2) + (mfaab + c1o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaab = m0; - mfbab = m1; - mfcab = m2; - ///////////b//////////////////////////////////////////////////////////////////////// - m0 = mfcbb * c1o2 + mfbbb * (vx1 - c1o2) + (mfabb + c4o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcbb - two * mfbbb * vx1 + mfabb * (one - vx1Sq) - c4o9 * oMdrho * vx1Sq; - m2 = mfcbb * c1o2 + mfbbb * (vx1 + c1o2) + (mfabb + c4o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfabb = m0; - mfbbb = m1; - mfcbb = m2; - ///////////b//////////////////////////////////////////////////////////////////////// - m0 = mfccb * c1o2 + mfbcb * (vx1 - c1o2) + (mfacb + c1o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfccb - two * mfbcb * vx1 + mfacb * (one - vx1Sq) - c1o9 * oMdrho * vx1Sq; - m2 = mfccb * c1o2 + mfbcb * (vx1 + c1o2) + (mfacb + c1o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfacb = m0; - mfbcb = m1; - mfccb = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcac * c1o2 + mfbac * (vx1 - c1o2) + (mfaac + c1o36 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcac - two * mfbac * vx1 + mfaac * (one - vx1Sq) - c1o36 * oMdrho * vx1Sq; - m2 = mfcac * c1o2 + mfbac * (vx1 + c1o2) + (mfaac + c1o36 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaac = m0; - mfbac = m1; - mfcac = m2; - ///////////c//////////////////////////////////////////////////////////////////////// - m0 = mfcbc * c1o2 + mfbbc * (vx1 - c1o2) + (mfabc + c1o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcbc - two * mfbbc * vx1 + mfabc * (one - vx1Sq) - c1o9 * oMdrho * vx1Sq; - m2 = mfcbc * c1o2 + mfbbc * (vx1 + c1o2) + (mfabc + c1o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfabc = m0; - mfbbc = m1; - mfcbc = m2; - ///////////c//////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2 + mfbcc * (vx1 - c1o2) + (mfacc + c1o36 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfccc - two * mfbcc * vx1 + mfacc * (one - vx1Sq) - c1o36 * oMdrho * vx1Sq; - m2 = mfccc * c1o2 + mfbcc * (vx1 + c1o2) + (mfacc + c1o36 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfacc = m0; - mfbcc = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - - f[E] = mfcbb; - f[W] = mfabb; - f[N] = mfbcb; - f[S] = mfbab; - f[T] = mfbbc; - f[B] = mfbba; - f[NE] = mfccb; - f[SW] = mfaab; - f[SE] = mfcab; - f[NW] = mfacb; - f[TE] = mfcbc; - f[BW] = mfaba; - f[BE] = mfcba; - f[TW] = mfabc; - f[TN] = mfbcc; - f[BS] = mfbaa; - f[BN] = mfbca; - f[TS] = mfbac; - f[ZERO] = mfbbb; - f[TNE] = mfccc; - f[TSE] = mfcac; - f[BNE] = mfcca; - f[BSE] = mfcaa; - f[TNW] = mfacc; - f[TSW] = mfaac; - f[BNW] = mfaca; - f[BSW] = mfaaa; -} -////////////////////////////////////////////////////////////////////////// -//Position SWB -0.25, -0.25, -0.25 -LBMReal CompressibleOffsetSquarePressureInterpolationProcessor::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 CompressibleOffsetSquarePressureInterpolationProcessor::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 CompressibleOffsetSquarePressureInterpolationProcessor::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 CompressibleOffsetSquarePressureInterpolationProcessor::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 CompressibleOffsetSquarePressureInterpolationProcessor::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 CompressibleOffsetSquarePressureInterpolationProcessor::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 CompressibleOffsetSquarePressureInterpolationProcessor::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 CompressibleOffsetSquarePressureInterpolationProcessor::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 CompressibleOffsetSquarePressureInterpolationProcessor::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 laplaceRho = (xoff!=0.0 || yoff!=0.0 || zoff!= 0.0) ? 0.0 :(-3.0*(by*by+ax*ax+cz*cz)-6.0*(ay*bx+bz*cy+az*cx))*(1.0+rho); - - rho=rho-laplaceRho*0.25; - - LBMReal eps_new = 2.0; - LBMReal o = omega; - //bulk viscosity - LBMReal oP = OxxPyyPzzC; - - LBMReal mfcbb = zeroReal; - LBMReal mfabb = zeroReal; - LBMReal mfbcb = zeroReal; - LBMReal mfbab = zeroReal; - LBMReal mfbbc = zeroReal; - LBMReal mfbba = zeroReal; - LBMReal mfccb = zeroReal; - LBMReal mfaab = zeroReal; - LBMReal mfcab = zeroReal; - LBMReal mfacb = zeroReal; - LBMReal mfcbc = zeroReal; - LBMReal mfaba = zeroReal; - LBMReal mfcba = zeroReal; - LBMReal mfabc = zeroReal; - LBMReal mfbcc = zeroReal; - LBMReal mfbaa = zeroReal; - LBMReal mfbca = zeroReal; - LBMReal mfbac = zeroReal; - LBMReal mfbbb = zeroReal; - LBMReal mfccc = zeroReal; - LBMReal mfaac = zeroReal; - LBMReal mfcac = zeroReal; - LBMReal mfacc = zeroReal; - LBMReal mfcca = zeroReal; - LBMReal mfaaa = zeroReal; - LBMReal mfcaa = zeroReal; - LBMReal mfaca = zeroReal; - - mfaaa = rho; // if drho is interpolated directly - - LBMReal vx1Sq = vx1*vx1; - LBMReal vx2Sq = vx2*vx2; - LBMReal vx3Sq = vx3*vx3; - LBMReal oMdrho = one; - //oMdrho = one - mfaaa; - - //2.f - // linear combinations - -///////////////////////// - LBMReal mxxPyyPzz = mfaaa -c2o3*(ax+by+cz)*eps_new/oP*(one+press); - - LBMReal mxxMyy = -c2o3*((ax - by)+kxxMyyAverage)*eps_new/o * (one + press); - LBMReal mxxMzz = -c2o3*((ax - cz)+kxxMzzAverage)*eps_new/o * (one + press); - - mfabb = -c1o3 * ((bz + cy)+kyzAverage)*eps_new/o * (one + press); - mfbab = -c1o3 * ((az + cx)+kxzAverage)*eps_new/o * (one + press); - mfbba = -c1o3 * ((ay + bx)+kxyAverage)*eps_new/o * (one + press); - - //////////////////////// - // linear combinations back - mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); - mfaca = c1o3 * (-two * mxxMyy + mxxMzz + mxxPyyPzz); - mfaac = c1o3 * (mxxMyy - two * mxxMzz + mxxPyyPzz); - - //three - mfbbb = zeroReal; - - LBMReal mxxyPyzz = zeroReal; - LBMReal mxxyMyzz = zeroReal; - LBMReal mxxzPyyz = zeroReal; - LBMReal mxxzMyyz = zeroReal; - LBMReal mxyyPxzz = zeroReal; - LBMReal mxyyMxzz = zeroReal; - - // linear combinations back - mfcba = (mxxyMyzz + mxxyPyzz) * c1o2; - mfabc = (-mxxyMyzz + mxxyPyzz) * c1o2; - mfcab = (mxxzMyyz + mxxzPyyz) * c1o2; - mfacb = (-mxxzMyyz + mxxzPyyz) * c1o2; - mfbca = (mxyyMxzz + mxyyPxzz) * c1o2; - mfbac = (-mxyyMxzz + mxyyPxzz) * c1o2; - - //4.f - mfacc = mfaaa*c1o9; - mfcac = mfacc; - mfcca = mfacc; - //5. - - //6. - mfccc = mfaaa*c1o27; - //////////////////////////////////////////////////////////////////////////////////// - //back - //////////////////////////////////////////////////////////////////////////////////// - //mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Z - Dir - LBMReal m0 = mfaac * c1o2 + mfaab * (vx3 - c1o2) + (mfaaa + one * oMdrho) * (vx3Sq - vx3) * c1o2; - LBMReal m1 = -mfaac - two * mfaab * vx3 + mfaaa * (one - vx3Sq) - one * oMdrho * vx3Sq; - LBMReal m2 = mfaac * c1o2 + mfaab * (vx3 + c1o2) + (mfaaa + one * oMdrho) * (vx3Sq + vx3) * c1o2; - mfaaa = m0; - mfaab = m1; - mfaac = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfabc * c1o2 + mfabb * (vx3 - c1o2) + mfaba * (vx3Sq - vx3) * c1o2; - m1 = -mfabc - two * mfabb * vx3 + mfaba * (one - vx3Sq); - m2 = mfabc * c1o2 + mfabb * (vx3 + c1o2) + mfaba * (vx3Sq + vx3) * c1o2; - mfaba = m0; - mfabb = m1; - mfabc = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacc * c1o2 + mfacb * (vx3 - c1o2) + (mfaca + c1o3 * oMdrho) * (vx3Sq - vx3) * c1o2; - m1 = -mfacc - two * mfacb * vx3 + mfaca * (one - vx3Sq) - c1o3 * oMdrho * vx3Sq; - m2 = mfacc * c1o2 + mfacb * (vx3 + c1o2) + (mfaca + c1o3 * oMdrho) * (vx3Sq + vx3) * c1o2; - mfaca = m0; - mfacb = m1; - mfacc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfbac * c1o2 + mfbab * (vx3 - c1o2) + mfbaa * (vx3Sq - vx3) * c1o2; - m1 = -mfbac - two * mfbab * vx3 + mfbaa * (one - vx3Sq); - m2 = mfbac * c1o2 + mfbab * (vx3 + c1o2) + mfbaa * (vx3Sq + vx3) * c1o2; - mfbaa = m0; - mfbab = m1; - mfbac = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbbc * c1o2 + mfbbb * (vx3 - c1o2) + mfbba * (vx3Sq - vx3) * c1o2; - m1 = -mfbbc - two * mfbbb * vx3 + mfbba * (one - vx3Sq); - m2 = mfbbc * c1o2 + mfbbb * (vx3 + c1o2) + mfbba * (vx3Sq + vx3) * c1o2; - mfbba = m0; - mfbbb = m1; - mfbbc = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcc * c1o2 + mfbcb * (vx3 - c1o2) + mfbca * (vx3Sq - vx3) * c1o2; - m1 = -mfbcc - two * mfbcb * vx3 + mfbca * (one - vx3Sq); - m2 = mfbcc * c1o2 + mfbcb * (vx3 + c1o2) + mfbca * (vx3Sq + vx3) * c1o2; - mfbca = m0; - mfbcb = m1; - mfbcc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcac * c1o2 + mfcab * (vx3 - c1o2) + (mfcaa + c1o3 * oMdrho) * (vx3Sq - vx3) * c1o2; - m1 = -mfcac - two * mfcab * vx3 + mfcaa * (one - vx3Sq) - c1o3 * oMdrho * vx3Sq; - m2 = mfcac * c1o2 + mfcab * (vx3 + c1o2) + (mfcaa + c1o3 * oMdrho) * (vx3Sq + vx3) * c1o2; - mfcaa = m0; - mfcab = m1; - mfcac = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfcbc * c1o2 + mfcbb * (vx3 - c1o2) + mfcba * (vx3Sq - vx3) * c1o2; - m1 = -mfcbc - two * mfcbb * vx3 + mfcba * (one - vx3Sq); - m2 = mfcbc * c1o2 + mfcbb * (vx3 + c1o2) + mfcba * (vx3Sq + vx3) * c1o2; - mfcba = m0; - mfcbb = m1; - mfcbc = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2 + mfccb * (vx3 - c1o2) + (mfcca + c1o9 * oMdrho) * (vx3Sq - vx3) * c1o2; - m1 = -mfccc - two * mfccb * vx3 + mfcca * (one - vx3Sq) - c1o9 * oMdrho * vx3Sq; - m2 = mfccc * c1o2 + mfccb * (vx3 + c1o2) + (mfcca + c1o9 * oMdrho) * (vx3Sq + vx3) * c1o2; - mfcca = m0; - mfccb = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - //mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Y - Dir - m0 = mfaca * c1o2 + mfaba * (vx2 - c1o2) + (mfaaa + c1o6 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfaca - two * mfaba * vx2 + mfaaa * (one - vx2Sq) - c1o6 * oMdrho * vx2Sq; - m2 = mfaca * c1o2 + mfaba * (vx2 + c1o2) + (mfaaa + c1o6 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfaaa = m0; - mfaba = m1; - mfaca = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacb * c1o2 + mfabb * (vx2 - c1o2) + (mfaab + c2o3 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfacb - two * mfabb * vx2 + mfaab * (one - vx2Sq) - c2o3 * oMdrho * vx2Sq; - m2 = mfacb * c1o2 + mfabb * (vx2 + c1o2) + (mfaab + c2o3 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfaab = m0; - mfabb = m1; - mfacb = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacc * c1o2 + mfabc * (vx2 - c1o2) + (mfaac + c1o6 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfacc - two * mfabc * vx2 + mfaac * (one - vx2Sq) - c1o6 * oMdrho * vx2Sq; - m2 = mfacc * c1o2 + mfabc * (vx2 + c1o2) + (mfaac + c1o6 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfaac = m0; - mfabc = m1; - mfacc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfbca * c1o2 + mfbba * (vx2 - c1o2) + mfbaa * (vx2Sq - vx2) * c1o2; - m1 = -mfbca - two * mfbba * vx2 + mfbaa * (one - vx2Sq); - m2 = mfbca * c1o2 + mfbba * (vx2 + c1o2) + mfbaa * (vx2Sq + vx2) * c1o2; - mfbaa = m0; - mfbba = m1; - mfbca = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcb * c1o2 + mfbbb * (vx2 - c1o2) + mfbab * (vx2Sq - vx2) * c1o2; - m1 = -mfbcb - two * mfbbb * vx2 + mfbab * (one - vx2Sq); - m2 = mfbcb * c1o2 + mfbbb * (vx2 + c1o2) + mfbab * (vx2Sq + vx2) * c1o2; - mfbab = m0; - mfbbb = m1; - mfbcb = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcc * c1o2 + mfbbc * (vx2 - c1o2) + mfbac * (vx2Sq - vx2) * c1o2; - m1 = -mfbcc - two * mfbbc * vx2 + mfbac * (one - vx2Sq); - m2 = mfbcc * c1o2 + mfbbc * (vx2 + c1o2) + mfbac * (vx2Sq + vx2) * c1o2; - mfbac = m0; - mfbbc = m1; - mfbcc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcca * c1o2 + mfcba * (vx2 - c1o2) + (mfcaa + c1o18 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfcca - two * mfcba * vx2 + mfcaa * (one - vx2Sq) - c1o18 * oMdrho * vx2Sq; - m2 = mfcca * c1o2 + mfcba * (vx2 + c1o2) + (mfcaa + c1o18 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfcaa = m0; - mfcba = m1; - mfcca = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccb * c1o2 + mfcbb * (vx2 - c1o2) + (mfcab + c2o9 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfccb - two * mfcbb * vx2 + mfcab * (one - vx2Sq) - c2o9 * oMdrho * vx2Sq; - m2 = mfccb * c1o2 + mfcbb * (vx2 + c1o2) + (mfcab + c2o9 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfcab = m0; - mfcbb = m1; - mfccb = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2 + mfcbc * (vx2 - c1o2) + (mfcac + c1o18 * oMdrho) * (vx2Sq - vx2) * c1o2; - m1 = -mfccc - two * mfcbc * vx2 + mfcac * (one - vx2Sq) - c1o18 * oMdrho * vx2Sq; - m2 = mfccc * c1o2 + mfcbc * (vx2 + c1o2) + (mfcac + c1o18 * oMdrho) * (vx2Sq + vx2) * c1o2; - mfcac = m0; - mfcbc = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - //mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // X - Dir - m0 = mfcaa * c1o2 + mfbaa * (vx1 - c1o2) + (mfaaa + c1o36 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcaa - two * mfbaa * vx1 + mfaaa * (one - vx1Sq) - c1o36 * oMdrho * vx1Sq; - m2 = mfcaa * c1o2 + mfbaa * (vx1 + c1o2) + (mfaaa + c1o36 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaaa = m0; - mfbaa = m1; - mfcaa = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcba * c1o2 + mfbba * (vx1 - c1o2) + (mfaba + c1o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcba - two * mfbba * vx1 + mfaba * (one - vx1Sq) - c1o9 * oMdrho * vx1Sq; - m2 = mfcba * c1o2 + mfbba * (vx1 + c1o2) + (mfaba + c1o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaba = m0; - mfbba = m1; - mfcba = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcca * c1o2 + mfbca * (vx1 - c1o2) + (mfaca + c1o36 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcca - two * mfbca * vx1 + mfaca * (one - vx1Sq) - c1o36 * oMdrho * vx1Sq; - m2 = mfcca * c1o2 + mfbca * (vx1 + c1o2) + (mfaca + c1o36 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaca = m0; - mfbca = m1; - mfcca = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcab * c1o2 + mfbab * (vx1 - c1o2) + (mfaab + c1o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcab - two * mfbab * vx1 + mfaab * (one - vx1Sq) - c1o9 * oMdrho * vx1Sq; - m2 = mfcab * c1o2 + mfbab * (vx1 + c1o2) + (mfaab + c1o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaab = m0; - mfbab = m1; - mfcab = m2; - ///////////b//////////////////////////////////////////////////////////////////////// - m0 = mfcbb * c1o2 + mfbbb * (vx1 - c1o2) + (mfabb + c4o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcbb - two * mfbbb * vx1 + mfabb * (one - vx1Sq) - c4o9 * oMdrho * vx1Sq; - m2 = mfcbb * c1o2 + mfbbb * (vx1 + c1o2) + (mfabb + c4o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfabb = m0; - mfbbb = m1; - mfcbb = m2; - ///////////b//////////////////////////////////////////////////////////////////////// - m0 = mfccb * c1o2 + mfbcb * (vx1 - c1o2) + (mfacb + c1o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfccb - two * mfbcb * vx1 + mfacb * (one - vx1Sq) - c1o9 * oMdrho * vx1Sq; - m2 = mfccb * c1o2 + mfbcb * (vx1 + c1o2) + (mfacb + c1o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfacb = m0; - mfbcb = m1; - mfccb = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcac * c1o2 + mfbac * (vx1 - c1o2) + (mfaac + c1o36 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcac - two * mfbac * vx1 + mfaac * (one - vx1Sq) - c1o36 * oMdrho * vx1Sq; - m2 = mfcac * c1o2 + mfbac * (vx1 + c1o2) + (mfaac + c1o36 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfaac = m0; - mfbac = m1; - mfcac = m2; - ///////////c//////////////////////////////////////////////////////////////////////// - m0 = mfcbc * c1o2 + mfbbc * (vx1 - c1o2) + (mfabc + c1o9 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfcbc - two * mfbbc * vx1 + mfabc * (one - vx1Sq) - c1o9 * oMdrho * vx1Sq; - m2 = mfcbc * c1o2 + mfbbc * (vx1 + c1o2) + (mfabc + c1o9 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfabc = m0; - mfbbc = m1; - mfcbc = m2; - ///////////c//////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2 + mfbcc * (vx1 - c1o2) + (mfacc + c1o36 * oMdrho) * (vx1Sq - vx1) * c1o2; - m1 = -mfccc - two * mfbcc * vx1 + mfacc * (one - vx1Sq) - c1o36 * oMdrho * vx1Sq; - m2 = mfccc * c1o2 + mfbcc * (vx1 + c1o2) + (mfacc + c1o36 * oMdrho) * (vx1Sq + vx1) * c1o2; - mfacc = m0; - mfbcc = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - - f[E] = mfcbb; - f[W] = mfabb; - f[N] = mfbcb; - f[S] = mfbab; - f[T] = mfbbc; - f[B] = mfbba; - f[NE] = mfccb; - f[SW] = mfaab; - f[SE] = mfcab; - f[NW] = mfacb; - f[TE] = mfcbc; - f[BW] = mfaba; - f[BE] = mfcba; - f[TW] = mfabc; - f[TN] = mfbcc; - f[BS] = mfbaa; - f[BN] = mfbca; - f[TS] = mfbac; - f[ZERO] = mfbbb; - f[TNE] = mfccc; - f[TSE] = mfcac; - f[BNE] = mfcca; - f[BSE] = mfcaa; - f[TNW] = mfacc; - f[TSW] = mfaac; - f[BNW] = mfaca; - f[BSW] = mfaaa; -} -////////////////////////////////////////////////////////////////////////// -void CompressibleOffsetSquarePressureInterpolationProcessor::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 CompressibleOffsetSquarePressureInterpolationProcessor::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)); -} -////////////////////////////////////////////////////////////////////////// -void CompressibleOffsetSquarePressureInterpolationProcessor::setBulkOmegaToOmega(bool value) -{ - bulkOmegaToOmega = value; -} - diff --git a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetSquarePressureInterpolationProcessor.h b/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetSquarePressureInterpolationProcessor.h deleted file mode 100644 index 48aed6665..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetSquarePressureInterpolationProcessor.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef CompressibleOffsetSquarePressureInterpolationProcessor_H_ -#define CompressibleOffsetSquarePressureInterpolationProcessor_H_ - -#include "InterpolationProcessor.h" -#include "D3Q27System.h" - -////////////////////////////////////////////////////////////////////////// -//it works only for cascaded LBM -//super compact interpolation method by Martin Geier -////////////////////////////////////////////////////////////////////////// - -class CompressibleOffsetSquarePressureInterpolationProcessor; - -class CompressibleOffsetSquarePressureInterpolationProcessor : public InterpolationProcessor -{ -public: - CompressibleOffsetSquarePressureInterpolationProcessor(); - CompressibleOffsetSquarePressureInterpolationProcessor(LBMReal omegaC, LBMReal omegaF); - virtual ~CompressibleOffsetSquarePressureInterpolationProcessor(); - 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); - void interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC); - void interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC, LBMReal xoff, LBMReal yoff, LBMReal zoff); - void setBulkOmegaToOmega(bool value); -protected: -private: - 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*/; - - LBMReal kxyAverage, kyzAverage, kxzAverage, kxxMyyAverage, kxxMzzAverage; - - LBMReal a,b,c; - - // bulk viscosity - bool bulkOmegaToOmega; - LBMReal OxxPyyPzzC; - LBMReal OxxPyyPzzF; - - 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 calcInterpolatedNodeCF(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 CompressibleOffsetSquarePressureInterpolationProcessor::interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF) -{ - this->interpolateCoarseToFine(icellC, icellF, 0.0, 0.0, 0.0); -} -////////////////////////////////////////////////////////////////////////// -inline void CompressibleOffsetSquarePressureInterpolationProcessor::interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC) -{ - this->interpolateFineToCoarse(icellF, icellC, 0.0, 0.0, 0.0); -} - -#endif diff --git a/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.cpp new file mode 100644 index 000000000..79f0a586a --- /dev/null +++ b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.cpp @@ -0,0 +1,648 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file CumulantK17LBMKernel.cpp +//! \ingroup LBM +//! \author Konstantin Kutscher, Martin Geier +//======================================================================================= + +#include "CumulantK17LBMKernel.h" +#include "D3Q27System.h" +#include "D3Q27EsoTwist3DSplittedVector.h" +#include <math.h> +#include "DataSet3D.h" +#include "LBMKernel.h" +#include "Block3D.h" +#include "BCArray3D.h" + +#define PROOF_CORRECTNESS + +using namespace UbMath; + +////////////////////////////////////////////////////////////////////////// +CumulantK17LBMKernel::CumulantK17LBMKernel() +{ + this->compressible = true; +} +////////////////////////////////////////////////////////////////////////// +CumulantK17LBMKernel::~CumulantK17LBMKernel(void) +{ + +} +////////////////////////////////////////////////////////////////////////// +void CumulantK17LBMKernel::initDataSet() +{ + SPtr<DistributionArray3D> d(new D3Q27EsoTwist3DSplittedVector(nx[0] + 2, nx[1] + 2, nx[2] + 2, -999.9)); + dataSet->setFdistributions(d); +} +////////////////////////////////////////////////////////////////////////// +SPtr<LBMKernel> CumulantK17LBMKernel::clone() +{ + SPtr<LBMKernel> kernel(new CumulantK17LBMKernel()); + kernel->setNX(nx); + std::dynamic_pointer_cast<CumulantK17LBMKernel>(kernel)->initDataSet(); + kernel->setCollisionFactor(this->collFactor); + kernel->setBCProcessor(bcProcessor->clone(kernel)); + kernel->setWithForcing(withForcing); + kernel->setForcingX1(muForcingX1); + kernel->setForcingX2(muForcingX2); + kernel->setForcingX3(muForcingX3); + kernel->setIndex(ix1, ix2, ix3); + kernel->setDeltaT(deltaT); + kernel->setBlock(block.lock()); + + return kernel; +} +////////////////////////////////////////////////////////////////////////// +void CumulantK17LBMKernel::calculate(int step) +{ + ////////////////////////////////////////////////////////////////////////// + //! Cumulant K17 Kernel is based on + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! and + //! <a href="https://doi.org/10.1016/j.jcp.2017.07.004"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.07.004 ]</b></a> + //! + //! The cumulant kernel is executed in the following steps + //! + //////////////////////////////////////////////////////////////////////////////// + //! - Get node index coordinates from thredIdx, blockIdx, blockDim and gridDim. + //! + using namespace D3Q27System; + using namespace std; + + //initializing of forcing stuff + if (withForcing) + { + muForcingX1.DefineVar("x1", &muX1); muForcingX1.DefineVar("x2", &muX2); muForcingX1.DefineVar("x3", &muX3); + muForcingX2.DefineVar("x1", &muX1); muForcingX2.DefineVar("x2", &muX2); muForcingX2.DefineVar("x3", &muX3); + muForcingX3.DefineVar("x1", &muX1); muForcingX3.DefineVar("x2", &muX2); muForcingX3.DefineVar("x3", &muX3); + + muDeltaT = deltaT; + + muForcingX1.DefineVar("dt", &muDeltaT); + muForcingX2.DefineVar("dt", &muDeltaT); + muForcingX3.DefineVar("dt", &muDeltaT); + + muNu = (1.0 / 3.0) * (1.0 / collFactor - 1.0 / 2.0); + + muForcingX1.DefineVar("nu", &muNu); + muForcingX2.DefineVar("nu", &muNu); + muForcingX3.DefineVar("nu", &muNu); + + LBMReal forcingX1 = 0; + LBMReal forcingX2 = 0; + LBMReal forcingX3 = 0; + } + ///////////////////////////////////// + + localDistributions = dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getLocalDistributions(); + nonLocalDistributions = dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getNonLocalDistributions(); + restDistributions = dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getZeroDistributions(); + + SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); + + const int bcArrayMaxX1 = (int)bcArray->getNX1(); + const int bcArrayMaxX2 = (int)bcArray->getNX2(); + const int bcArrayMaxX3 = (int)bcArray->getNX3(); + + int minX1 = ghostLayerWidth; + int minX2 = ghostLayerWidth; + int minX3 = ghostLayerWidth; + int maxX1 = bcArrayMaxX1 - ghostLayerWidth; + int maxX2 = bcArrayMaxX2 - ghostLayerWidth; + int maxX3 = bcArrayMaxX3 - ghostLayerWidth; + + LBMReal omega = collFactor; + + for (int x3 = minX3; x3 < maxX3; x3++) + { + for (int x2 = minX2; x2 < maxX2; x2++) + { + for (int x1 = minX1; x1 < maxX1; x1++) + { + if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) + { + int x1p = x1 + 1; + int x2p = x2 + 1; + int x3p = x3 + 1; + ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + //! - Read distributions: style of reading and writing the distributions from/to stored arrays dependent on timestep is based on the esoteric twist algorithm + //! <a href="https://doi.org/10.3390/computation5020019"><b>[ M. Geier et al. (2017), DOI:10.3390/computation5020019 ]</b></a> + //! + //////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + + //E N T + //c c c + ////////// + //W S B + //a a a + + //Rest is b + + //mfxyz + //a - negative + //b - null + //c - positive + + // a b c + //-1 0 1 + + LBMReal mfcbb = (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3); + LBMReal mfbcb = (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3); + LBMReal mfbbc = (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3); + LBMReal mfccb = (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3); + LBMReal mfacb = (*this->localDistributions)(D3Q27System::ET_NW, x1p, x2, x3); + LBMReal mfcbc = (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3); + LBMReal mfabc = (*this->localDistributions)(D3Q27System::ET_TW, x1p, x2, x3); + LBMReal mfbcc = (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3); + LBMReal mfbac = (*this->localDistributions)(D3Q27System::ET_TS, x1, x2p, x3); + LBMReal mfccc = (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3); + LBMReal mfacc = (*this->localDistributions)(D3Q27System::ET_TNW, x1p, x2, x3); + LBMReal mfcac = (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2p, x3); + LBMReal mfaac = (*this->localDistributions)(D3Q27System::ET_TSW, x1p, x2p, x3); + + LBMReal mfabb = (*this->nonLocalDistributions)(D3Q27System::ET_W, x1p, x2, x3); + LBMReal mfbab = (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2p, x3); + LBMReal mfbba = (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3p); + LBMReal mfaab = (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1p, x2p, x3); + LBMReal mfcab = (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2p, x3); + LBMReal mfaba = (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1p, x2, x3p); + LBMReal mfcba = (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3p); + LBMReal mfbaa = (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2p, x3p); + LBMReal mfbca = (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3p); + LBMReal mfaaa = (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1p, x2p, x3p); + LBMReal mfcaa = (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2p, x3p); + LBMReal mfaca = (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1p, x2, x3p); + LBMReal mfcca = (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3p); + + LBMReal mfbbb = (*this->restDistributions)(x1, x2, x3); + + //////////////////////////////////////////////////////////////////////////////////// + //! - Calculate density and velocity using pyramid summation for low round-off errors as in Eq. (J1)-(J3) + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! + LBMReal drho = ((((mfccc + mfaaa) + (mfaca + mfcac)) + ((mfacc + mfcaa) + (mfaac + mfcca))) + + (((mfbac + mfbca) + (mfbaa + mfbcc)) + ((mfabc + mfcba) + (mfaba + mfcbc)) + ((mfacb + mfcab) + (mfaab + mfccb))) + + ((mfabb + mfcbb) + (mfbab + mfbcb)) + (mfbba + mfbbc)) + mfbbb; + + LBMReal rho = c1 + drho; + LBMReal OOrho = c1 / rho; + //////////////////////////////////////////////////////////////////////////////////// + LBMReal vvx = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfcaa - mfacc) + (mfcca - mfaac))) + + (((mfcba - mfabc) + (mfcbc - mfaba)) + ((mfcab - mfacb) + (mfccb - mfaab))) + + (mfcbb - mfabb)) / rho; + LBMReal vvy = ((((mfccc - mfaaa) + (mfaca - mfcac)) + ((mfacc - mfcaa) + (mfcca - mfaac))) + + (((mfbca - mfbac) + (mfbcc - mfbaa)) + ((mfacb - mfcab) + (mfccb - mfaab))) + + (mfbcb - mfbab)) / rho; + LBMReal vvz = ((((mfccc - mfaaa) + (mfcac - mfaca)) + ((mfacc - mfcaa) + (mfaac - mfcca))) + + (((mfbac - mfbca) + (mfbcc - mfbaa)) + ((mfabc - mfcba) + (mfcbc - mfaba))) + + (mfbbc - mfbba)) / rho; + //////////////////////////////////////////////////////////////////////////////////// + //forcing + /////////////////////////////////////////////////////////////////////////////////////////// + if (withForcing) + { + muX1 = static_cast<double>(x1 - 1 + ix1 * maxX1); + muX2 = static_cast<double>(x2 - 1 + ix2 * maxX2); + muX3 = static_cast<double>(x3 - 1 + ix3 * maxX3); + + forcingX1 = muForcingX1.Eval(); + forcingX2 = muForcingX2.Eval(); + forcingX3 = muForcingX3.Eval(); + + //////////////////////////////////////////////////////////////////////////////////// + //! - Add half of the acceleration (body force) to the velocity as in Eq. (42) + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! + vvx += forcingX1 * deltaT * c1o2; // X + vvy += forcingX2 * deltaT * c1o2; // Y + vvz += forcingX3 * deltaT * c1o2; // Z + } + /////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////// + LBMReal oMdrho = c1; + //////////////////////////////////////////////////////////////////////////////////// + // calculate the square of velocities for this lattice node + LBMReal vx2 = vvx * vvx; + LBMReal vy2 = vvy * vvy; + LBMReal vz2 = vvz * vvz; + //////////////////////////////////////////////////////////////////////////////////// + //! - Set relaxation limiters for third order cumulants to default value \f$ \lambda=0.001 \f$ according to section 6 in + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + LBMReal wadjust; + LBMReal qudricLimitP = c1o100; + LBMReal qudricLimitM = c1o100; + LBMReal qudricLimitD = c1o100; + //////////////////////////////////////////////////////////////////////////////////// + //! - Chimera transform from well conditioned distributions to central moments as defined in Appendix J in + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! see also Eq. (6)-(14) in + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + forwardInverseChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, c36, c1o36); + forwardInverseChimeraWithK(mfaba, mfabb, mfabc, vvz, vz2, c9, c1o9); + forwardInverseChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, c36, c1o36); + forwardInverseChimeraWithK(mfbaa, mfbab, mfbac, vvz, vz2, c9, c1o9); + forwardInverseChimeraWithK(mfbba, mfbbb, mfbbc, vvz, vz2, c9o4, c4o9); + forwardInverseChimeraWithK(mfbca, mfbcb, mfbcc, vvz, vz2, c9, c1o9); + forwardInverseChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, c36, c1o36); + forwardInverseChimeraWithK(mfcba, mfcbb, mfcbc, vvz, vz2, c9, c1o9); + forwardInverseChimeraWithK(mfcca, mfccb, mfccc, vvz, vz2, c36, c1o36); + + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + forwardInverseChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, c6, c1o6); + forwardChimera(mfaab, mfabb, mfacb, vvy, vy2); + forwardInverseChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, c18, c1o18); + forwardInverseChimeraWithK(mfbaa, mfbba, mfbca, vvy, vy2, c3o2, c2o3); + forwardChimera(mfbab, mfbbb, mfbcb, vvy, vy2); + forwardInverseChimeraWithK(mfbac, mfbbc, mfbcc, vvy, vy2, c9o2, c2o9); + forwardInverseChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, c6, c1o6); + forwardChimera(mfcab, mfcbb, mfccb, vvy, vy2); + forwardInverseChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, c18, c1o18); + + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + forwardInverseChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, c1, c1); + forwardChimera(mfaba, mfbba, mfcba, vvx, vx2); + forwardInverseChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, c3, c1o3); + forwardChimera(mfaab, mfbab, mfcab, vvx, vx2); + forwardChimera(mfabb, mfbbb, mfcbb, vvx, vx2); + forwardChimera(mfacb, mfbcb, mfccb, vvx, vx2); + forwardInverseChimeraWithK(mfaac, mfbac, mfcac, vvx, vx2, c3, c1o3); + forwardChimera(mfabc, mfbbc, mfcbc, vvx, vx2); + forwardInverseChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, c9, c1o9); + + //////////////////////////////////////////////////////////////////////////////////// + //! - Setting relaxation rates for non-hydrodynamic cumulants (default values). Variable names and equations according to + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! => [NAME IN PAPER]=[NAME IN CODE]=[DEFAULT VALUE]. + //! - Trace of second order cumulants \f$ C_{200}+C_{020}+C_{002} \f$ used to adjust bulk viscosity:\f$\omega_2=OxxPyyPzz=1.0 \f$. + //! - Third order cumulants \f$ C_{120}+C_{102} \f$, \f$ C_{210}+C_{012} \f$, \f$ C_{201}+C_{021} \f$: \f$\omega_3=OxyyPxzz\f$ set according to Eq. (111) with simplifications assuming \f$\omega_2=1.0\f$. + //! - Third order cumulants \f$ C_{120}-C_{102} \f$, \f$ C_{210}-C_{012} \f$, \f$ C_{201}-C_{021} \f$: \f$\omega_4 = OxyyMxzz\f$ set according to Eq. (112) with simplifications assuming \f$\omega_2 = 1.0\f$. + //! - Third order cumulants \f$ C_{111} \f$: \f$\omega_5 = Oxyz\f$ set according to Eq. (113) with simplifications assuming \f$\omega_2 = 1.0\f$ (modify for different bulk viscosity). + //! - Fourth order cumulants \f$ C_{220} \f$, \f$ C_{202} \f$, \f$ C_{022} \f$, \f$ C_{211} \f$, \f$ C_{121} \f$, \f$ C_{112} \f$: for simplification all set to the same default value \f$ \omega_6=\omega_7=\omega_8=O4=1.0 \f$. + //! - Fifth order cumulants \f$ C_{221}\f$, \f$C_{212}\f$, \f$C_{122}\f$: \f$\omega_9=O5=1.0\f$. + //! - Sixth order cumulant \f$ C_{222}\f$: \f$\omega_{10}=O6=1.0\f$. + //! + //////////////////////////////////////////////////////////// + //2. + LBMReal OxxPyyPzz = c1; + //////////////////////////////////////////////////////////// + //3. + LBMReal OxyyPxzz = c8 * (-c2 + omega) * ( c1 + c2*omega) / (-c8 - c14*omega + c7*omega*omega); + LBMReal OxyyMxzz = c8 * (-c2 + omega) * (-c7 + c4*omega) / (c56 - c50*omega + c9*omega*omega); + LBMReal Oxyz = c24 * (-c2 + omega) * (-c2 - c7*omega + c3*omega*omega) / (c48 + c152*omega - c130*omega*omega + c29*omega*omega*omega); + //////////////////////////////////////////////////////////// + //4. + LBMReal O4 = c1; + //////////////////////////////////////////////////////////// + //5. + LBMReal O5 = c1; + //////////////////////////////////////////////////////////// + //6. + LBMReal O6 = c1; + + //////////////////////////////////////////////////////////////////////////////////// + //! - A and B: parameters for fourth order convergence of the diffusion term according to Eq. (114) and (115) + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! with simplifications assuming \f$\omega_2 = 1.0\f$ (modify for different bulk viscosity). + //! + LBMReal A = (c4 + c2*omega - c3*omega*omega) / (c2 - c7*omega + c5*omega*omega); + LBMReal B = (c4 + c28*omega - c14*omega*omega) / (c6 - c21*omega + c15*omega*omega); + + //////////////////////////////////////////////////////////////////////////////////// + //! - Compute cumulants from central moments according to Eq. (20)-(23) in + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + //////////////////////////////////////////////////////////// + //4. + LBMReal CUMcbb = mfcbb - ((mfcaa + c1o3) * mfabb + c2 * mfbba * mfbab) * OOrho; + LBMReal CUMbcb = mfbcb - ((mfaca + c1o3) * mfbab + c2 * mfbba * mfabb) * OOrho; + LBMReal CUMbbc = mfbbc - ((mfaac + c1o3) * mfbba + c2 * mfbab * mfabb) * OOrho; + + LBMReal CUMcca = mfcca - (((mfcaa * mfaca + c2 * mfbba * mfbba) + c1o3 * (mfcaa + mfaca)) * OOrho - c1o9 * (drho * OOrho)); + LBMReal CUMcac = mfcac - (((mfcaa * mfaac + c2 * mfbab * mfbab) + c1o3 * (mfcaa + mfaac)) * OOrho - c1o9 * (drho * OOrho)); + LBMReal CUMacc = mfacc - (((mfaac * mfaca + c2 * mfabb * mfabb) + c1o3 * (mfaac + mfaca)) * OOrho - c1o9 * (drho * OOrho)); + //////////////////////////////////////////////////////////// + //5. + LBMReal CUMbcc = mfbcc - ((mfaac * mfbca + mfaca * mfbac + c4 * mfabb * mfbbb + c2 * (mfbab * mfacb + mfbba * mfabc)) + c1o3 * (mfbca + mfbac)) * OOrho; + LBMReal CUMcbc = mfcbc - ((mfaac * mfcba + mfcaa * mfabc + c4 * mfbab * mfbbb + c2 * (mfabb * mfcab + mfbba * mfbac)) + c1o3 * (mfcba + mfabc)) * OOrho; + LBMReal CUMccb = mfccb - ((mfcaa * mfacb + mfaca * mfcab + c4 * mfbba * mfbbb + c2 * (mfbab * mfbca + mfabb * mfcba)) + c1o3 * (mfacb + mfcab)) * OOrho; + //////////////////////////////////////////////////////////// + //6. + LBMReal CUMccc = mfccc + ((-c4 * mfbbb * mfbbb + - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) + - c4 * (mfabb * mfcbb + mfbab * mfbcb + mfbba * mfbbc) + - c2 * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) * OOrho + + (c4 * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + + c2 * (mfcaa * mfaca * mfaac) + + c16 * mfbba * mfbab * mfabb) * OOrho * OOrho + - c1o3 * (mfacc + mfcac + mfcca) * OOrho + - c1o9 * (mfcaa + mfaca + mfaac) * OOrho + + (c2 * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa) + c1o3 * (mfaac + mfaca + mfcaa)) * OOrho * OOrho * c2o3 + + c1o27 * ((drho * drho - drho) * OOrho * OOrho)); + + //////////////////////////////////////////////////////////////////////////////////// + //! - Compute linear combinations of second and third order cumulants + //! + //////////////////////////////////////////////////////////// + //2. + LBMReal mxxPyyPzz = mfcaa + mfaca + mfaac; + LBMReal mxxMyy = mfcaa - mfaca; + LBMReal mxxMzz = mfcaa - mfaac; + //////////////////////////////////////////////////////////// + //3. + LBMReal mxxyPyzz = mfcba + mfabc; + LBMReal mxxyMyzz = mfcba - mfabc; + + LBMReal mxxzPyyz = mfcab + mfacb; + LBMReal mxxzMyyz = mfcab - mfacb; + + LBMReal mxyyPxzz = mfbca + mfbac; + LBMReal mxyyMxzz = mfbca - mfbac; + + //////////////////////////////////////////////////////////////////////////////////// + //incl. correction + //////////////////////////////////////////////////////////// + //! - Compute velocity gradients from second order cumulants according to Eq. (27)-(32) + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! Further explanations of the correction in viscosity in Appendix H of + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! Note that the division by rho is omitted here as we need rho times the gradients later. + //! + LBMReal Dxy = -c3 * omega * mfbba; + LBMReal Dxz = -c3 * omega * mfbab; + LBMReal Dyz = -c3 * omega * mfabb; + LBMReal dxux = c1o2 * (-omega) * (mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz * (mfaaa - mxxPyyPzz); + LBMReal dyuy = dxux + omega * c3o2 * mxxMyy; + LBMReal dzuz = dxux + omega * c3o2 * mxxMzz; + //////////////////////////////////////////////////////////// + //! - Relaxation of second order cumulants with correction terms according to Eq. (33)-(35) in + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + mxxPyyPzz += OxxPyyPzz * (mfaaa - mxxPyyPzz) - c3 * (c1 - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz); + mxxMyy += omega * (-mxxMyy) - c3 * (c1 + c1o2 * (-omega)) * (vx2 * dxux - vy2 * dyuy); + mxxMzz += omega * (-mxxMzz) - c3 * (c1 + c1o2 * (-omega)) * (vx2 * dxux - vz2 * dzuz); + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ////no correction + //mxxPyyPzz += OxxPyyPzz*(mfaaa - mxxPyyPzz); + //mxxMyy += -(-omega) * (-mxxMyy); + //mxxMzz += -(-omega) * (-mxxMzz); + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + mfabb += omega * (-mfabb); + mfbab += omega * (-mfbab); + mfbba += omega * (-mfbba); + + //////////////////////////////////////////////////////////////////////////////////// + //relax + ////////////////////////////////////////////////////////////////////////// + // incl. limiter + //! - Relaxation of third order cumulants including limiter according to Eq. (116)-(123) + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + wadjust = Oxyz + (c1 - Oxyz) * abs(mfbbb) / (abs(mfbbb) + qudricLimitD); + mfbbb += wadjust * (-mfbbb); + wadjust = OxyyPxzz + (c1 - OxyyPxzz) * abs(mxxyPyzz) / (abs(mxxyPyzz) + qudricLimitP); + mxxyPyzz += wadjust * (-mxxyPyzz); + wadjust = OxyyMxzz + (c1 - OxyyMxzz) * abs(mxxyMyzz) / (abs(mxxyMyzz) + qudricLimitM); + mxxyMyzz += wadjust * (-mxxyMyzz); + wadjust = OxyyPxzz + (c1 - OxyyPxzz) * abs(mxxzPyyz) / (abs(mxxzPyyz) + qudricLimitP); + mxxzPyyz += wadjust * (-mxxzPyyz); + wadjust = OxyyMxzz + (c1 - OxyyMxzz) * abs(mxxzMyyz) / (abs(mxxzMyyz) + qudricLimitM); + mxxzMyyz += wadjust * (-mxxzMyyz); + wadjust = OxyyPxzz + (c1 - OxyyPxzz) * abs(mxyyPxzz) / (abs(mxyyPxzz) + qudricLimitP); + mxyyPxzz += wadjust * (-mxyyPxzz); + wadjust = OxyyMxzz + (c1 - OxyyMxzz) * abs(mxyyMxzz) / (abs(mxyyMxzz) + qudricLimitM); + mxyyMxzz += wadjust * (-mxyyMxzz); + ////////////////////////////////////////////////////////////////////////// + // no limiter + //mfbbb += OxyyMxzz * (-mfbbb); + //mxxyPyzz += OxyyPxzz * (-mxxyPyzz); + //mxxyMyzz += OxyyMxzz * (-mxxyMyzz); + //mxxzPyyz += OxyyPxzz * (-mxxzPyyz); + //mxxzMyyz += OxyyMxzz * (-mxxzMyyz); + //mxyyPxzz += OxyyPxzz * (-mxyyPxzz); + //mxyyMxzz += OxyyMxzz * (-mxyyMxzz); + + //////////////////////////////////////////////////////////////////////////////////// + //! - Compute inverse linear combinations of second and third order cumulants + //! + mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); + mfaca = c1o3 * (-c2 * mxxMyy + mxxMzz + mxxPyyPzz); + mfaac = c1o3 * (mxxMyy - c2 * mxxMzz + mxxPyyPzz); + + mfcba = (mxxyMyzz + mxxyPyzz) * c1o2; + mfabc = (-mxxyMyzz + mxxyPyzz) * c1o2; + mfcab = (mxxzMyyz + mxxzPyyz) * c1o2; + mfacb = (-mxxzMyyz + mxxzPyyz) * c1o2; + mfbca = (mxyyMxzz + mxyyPxzz) * c1o2; + mfbac = (-mxyyMxzz + mxyyPxzz) * c1o2; + ////////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////////// + //4. + // no limiter + //! - Relax fourth order cumulants to modified equilibrium for fourth order convergence of diffusion according to Eq. (43)-(48) + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + CUMacc = -O4 * (c1 / omega - c1o2) * (dyuy + dzuz) * c2o3 * A + (c1 - O4) * (CUMacc); + CUMcac = -O4 * (c1 / omega - c1o2) * (dxux + dzuz) * c2o3 * A + (c1 - O4) * (CUMcac); + CUMcca = -O4 * (c1 / omega - c1o2) * (dyuy + dxux) * c2o3 * A + (c1 - O4) * (CUMcca); + CUMbbc = -O4 * (c1 / omega - c1o2) * Dxy * c1o3 * B + (c1 - O4) * (CUMbbc); + CUMbcb = -O4 * (c1 / omega - c1o2) * Dxz * c1o3 * B + (c1 - O4) * (CUMbcb); + CUMcbb = -O4 * (c1 / omega - c1o2) * Dyz * c1o3 * B + (c1 - O4) * (CUMcbb); + + ////////////////////////////////////////////////////////////////////////// + //5. + CUMbcc += O5 * (-CUMbcc); + CUMcbc += O5 * (-CUMcbc); + CUMccb += O5 * (-CUMccb); + + ////////////////////////////////////////////////////////////////////////// + //6. + CUMccc += O6 * (-CUMccc); + + //////////////////////////////////////////////////////////////////////////////////// + //! - Compute central moments from post collision cumulants according to Eq. (53)-(56) in + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + + ////////////////////////////////////////////////////////////////////////// + //4. + mfcbb = CUMcbb + c1o3 * ((c3 * mfcaa + c1) * mfabb + c6 * mfbba * mfbab) * OOrho; + mfbcb = CUMbcb + c1o3 * ((c3 * mfaca + c1) * mfbab + c6 * mfbba * mfabb) * OOrho; + mfbbc = CUMbbc + c1o3 * ((c3 * mfaac + c1) * mfbba + c6 * mfbab * mfabb) * OOrho; + + mfcca = CUMcca + (((mfcaa * mfaca + c2 * mfbba * mfbba) * c9 + c3 * (mfcaa + mfaca)) * OOrho - (drho * OOrho)) * c1o9; + mfcac = CUMcac + (((mfcaa * mfaac + c2 * mfbab * mfbab) * c9 + c3 * (mfcaa + mfaac)) * OOrho - (drho * OOrho)) * c1o9; + mfacc = CUMacc + (((mfaac * mfaca + c2 * mfabb * mfabb) * c9 + c3 * (mfaac + mfaca)) * OOrho - (drho * OOrho)) * c1o9; + + ////////////////////////////////////////////////////////////////////////// + //5. + mfbcc = CUMbcc + c1o3 * (c3 * (mfaac * mfbca + mfaca * mfbac + c4 * mfabb * mfbbb + c2 * (mfbab * mfacb + mfbba * mfabc)) + (mfbca + mfbac)) * OOrho; + mfcbc = CUMcbc + c1o3 * (c3 * (mfaac * mfcba + mfcaa * mfabc + c4 * mfbab * mfbbb + c2 * (mfabb * mfcab + mfbba * mfbac)) + (mfcba + mfabc)) * OOrho; + mfccb = CUMccb + c1o3 * (c3 * (mfcaa * mfacb + mfaca * mfcab + c4 * mfbba * mfbbb + c2 * (mfbab * mfbca + mfabb * mfcba)) + (mfacb + mfcab)) * OOrho; + + ////////////////////////////////////////////////////////////////////////// + //6. + mfccc = CUMccc - ((-c4 * mfbbb * mfbbb + - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) + - c4 * (mfabb * mfcbb + mfbab * mfbcb + mfbba * mfbbc) + - c2 * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) * OOrho + + (c4 * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) + + c2 * (mfcaa * mfaca * mfaac) + + c16 * mfbba * mfbab * mfabb) * OOrho * OOrho + - c1o3 * (mfacc + mfcac + mfcca) * OOrho + - c1o9 * (mfcaa + mfaca + mfaac) * OOrho + + (c2 * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) + + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa) + c1o3 * (mfaac + mfaca + mfcaa)) * OOrho * OOrho * c2o3 + + c1o27 * ((drho * drho - drho) * OOrho * OOrho)); + + + //////////////////////////////////////////////////////////////////////////////////// + //! - Add acceleration (body force) to first order cumulants according to Eq. (85)-(87) in + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! + mfbaa = -mfbaa; + mfaba = -mfaba; + mfaab = -mfaab; + //////////////////////////////////////////////////////////////////////////////////// + + //////////////////////////////////////////////////////////////////////////////////// + //! - Chimera transform from central moments to well conditioned distributions as defined in Appendix J in + //! <a href="https://doi.org/10.1016/j.camwa.2015.05.001"><b>[ M. Geier et al. (2015), DOI:10.1016/j.camwa.2015.05.001 ]</b></a> + //! see also Eq. (88)-(96) in + //! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> + //! + //////////////////////////////////////////////////////////////////////////////////// + // X - Dir + backwardInverseChimeraWithK(mfaaa, mfbaa, mfcaa, vvx, vx2, c1, c1); + backwardChimera(mfaba, mfbba, mfcba, vvx, vx2); + backwardInverseChimeraWithK(mfaca, mfbca, mfcca, vvx, vx2, c3, c1o3); + backwardChimera(mfaab, mfbab, mfcab, vvx, vx2); + backwardChimera(mfabb, mfbbb, mfcbb, vvx, vx2); + backwardChimera(mfacb, mfbcb, mfccb, vvx, vx2); + backwardInverseChimeraWithK(mfaac, mfbac, mfcac, vvx, vx2, c3, c1o3); + backwardChimera(mfabc, mfbbc, mfcbc, vvx, vx2); + backwardInverseChimeraWithK(mfacc, mfbcc, mfccc, vvx, vx2, c9, c1o9); + + //////////////////////////////////////////////////////////////////////////////////// + // Y - Dir + backwardInverseChimeraWithK(mfaaa, mfaba, mfaca, vvy, vy2, c6, c1o6); + backwardChimera(mfaab, mfabb, mfacb, vvy, vy2); + backwardInverseChimeraWithK(mfaac, mfabc, mfacc, vvy, vy2, c18, c1o18); + backwardInverseChimeraWithK(mfbaa, mfbba, mfbca, vvy, vy2, c3o2, c2o3); + backwardChimera(mfbab, mfbbb, mfbcb, vvy, vy2); + backwardInverseChimeraWithK(mfbac, mfbbc, mfbcc, vvy, vy2, c9o2, c2o9); + backwardInverseChimeraWithK(mfcaa, mfcba, mfcca, vvy, vy2, c6, c1o6); + backwardChimera(mfcab, mfcbb, mfccb, vvy, vy2); + backwardInverseChimeraWithK(mfcac, mfcbc, mfccc, vvy, vy2, c18, c1o18); + + //////////////////////////////////////////////////////////////////////////////////// + // Z - Dir + backwardInverseChimeraWithK(mfaaa, mfaab, mfaac, vvz, vz2, c36, c1o36); + backwardInverseChimeraWithK(mfaba, mfabb, mfabc, vvz, vz2, c9, c1o9); + backwardInverseChimeraWithK(mfaca, mfacb, mfacc, vvz, vz2, c36, c1o36); + backwardInverseChimeraWithK(mfbaa, mfbab, mfbac, vvz, vz2, c9, c1o9); + backwardInverseChimeraWithK(mfbba, mfbbb, mfbbc, vvz, vz2, c9o4, c4o9); + backwardInverseChimeraWithK(mfbca, mfbcb, mfbcc, vvz, vz2, c9, c1o9); + backwardInverseChimeraWithK(mfcaa, mfcab, mfcac, vvz, vz2, c36, c1o36); + backwardInverseChimeraWithK(mfcba, mfcbb, mfcbc, vvz, vz2, c9, c1o9); + backwardInverseChimeraWithK(mfcca, mfccb, mfccc, vvz, vz2, c36, c1o36); + //////////////////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////////// + //proof correctness + ////////////////////////////////////////////////////////////////////////// +#ifdef PROOF_CORRECTNESS + LBMReal drho_post = (mfaaa + mfaac + mfaca + mfcaa + mfacc + mfcac + mfccc + mfcca) + + (mfaab + mfacb + mfcab + mfccb) + (mfaba + mfabc + mfcba + mfcbc) + (mfbaa + mfbac + mfbca + mfbcc) + + (mfabb + mfcbb) + (mfbab + mfbcb) + (mfbba + mfbbc) + mfbbb; + LBMReal dif = drho - drho_post; +#ifdef SINGLEPRECISION + if (dif > 10.0E-7 || dif < -10.0E-7) +#else + if (dif > 10.0E-15 || dif < -10.0E-15) +#endif + { + UB_THROW(UbException(UB_EXARGS, "rho=" + UbSystem::toString(drho) + ", rho_post=" + UbSystem::toString(drho_post) + + " dif=" + UbSystem::toString(dif) + + " rho is not correct for node " + UbSystem::toString(x1) + "," + UbSystem::toString(x2) + "," + UbSystem::toString(x3) + + " in " + block.lock()->toString() + " step = " + UbSystem::toString(step))); + } +#endif + //////////////////////////////////////////////////////////////////////////////////// + //! - Write distributions: style of reading and writing the distributions from/to stored arrays dependent on timestep is based on the esoteric twist algorithm + //! <a href="https://doi.org/10.3390/computation5020019"><b>[ M. Geier et al. (2017), DOI:10.3390/computation5020019 ]</b></a> + //! + (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3) = mfabb; + (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3) = mfbab; + (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3) = mfbba; + (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3) = mfaab; + (*this->localDistributions)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab; + (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3) = mfaba; + (*this->localDistributions)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba; + (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa; + (*this->localDistributions)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca; + (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa; + (*this->localDistributions)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa; + (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca; + (*this->localDistributions)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca; + + (*this->nonLocalDistributions)(D3Q27System::ET_W, x1p, x2, x3) = mfcbb; + (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2p, x3) = mfbcb; + (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc; + (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1p, x2p, x3) = mfccb; + (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2p, x3) = mfacb; + (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc; + (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc; + (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc; + (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac; + (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc; + (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc; + (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac; + (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac; + + (*this->restDistributions)(x1, x2, x3) = mfbbb; + ////////////////////////////////////////////////////////////////////////// + + } + } + } + } +} +////////////////////////////////////////////////////////////////////////// + diff --git a/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.h new file mode 100644 index 000000000..47b9a550a --- /dev/null +++ b/src/cpu/VirtualFluidsCore/LBM/CumulantK17LBMKernel.h @@ -0,0 +1,146 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file CumulantK17LBMKernel.h +//! \ingroup LBM +//! \author Konstantin Kutscher, Martin Geier +//======================================================================================= + +#ifndef CumulantK17LBMKernel_h__ +#define CumulantK17LBMKernel_h__ + +#include "LBMKernel.h" +#include "BCProcessor.h" +#include "D3Q27System.h" +#include "basics/utilities/UbTiming.h" +#include "basics/container/CbArray4D.h" +#include "basics/container/CbArray3D.h" + +//! \brief Compressible cumulant LBM kernel. +//! \details LBM implementation that use Cascaded Cumulant Lattice Boltzmann method for D3Q27 model +//! +//! The model is publisched in +//! <a href="http://dx.doi.org/10.1016/j.jcp.2017.05.040"><b>[ Geier et al., (2017), 10.1016/j.jcp.2017.05.040]</b></a>, +//! <a href="http://dx.doi.org/10.1016/j.jcp.2017.07.004"><b>[ Geier et al., (2017), 10.1016/j.jcp.2017.07.004]</b></a> +//! +class CumulantK17LBMKernel : public LBMKernel +{ +public: + CumulantK17LBMKernel(); + virtual ~CumulantK17LBMKernel(void); + virtual void calculate(int step); + virtual SPtr<LBMKernel> clone(); + +protected: + inline void forwardInverseChimeraWithK(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K); + inline void backwardInverseChimeraWithK(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K); + inline void forwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2); + inline void backwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2); + + virtual void initDataSet(); + LBMReal f[D3Q27System::ENDF + 1]; + + CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributions; + CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions; + CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr restDistributions; + + mu::value_type muX1, muX2, muX3; + mu::value_type muDeltaT; + mu::value_type muNu; + LBMReal forcingX1; + LBMReal forcingX2; + LBMReal forcingX3; +}; + +//////////////////////////////////////////////////////////////////////////////// +//! \brief forward chimera transformation \ref forwardInverseChimeraWithK +//! Transformation from distributions to central moments according to Eq. (6)-(14) in +//! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> +//! Modified for lower round-off errors. +//////////////////////////////////////////////////////////////////////////////// +inline void CumulantK17LBMKernel::forwardInverseChimeraWithK(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K) +{ + using namespace UbMath; + LBMReal m2 = mfa + mfc; + LBMReal m1 = mfc - mfa; + LBMReal m0 = m2 + mfb; + mfa = m0; + m0 *= Kinverse; + m0 += c1; + mfb = (m1 * Kinverse - m0 * vv) * K; + mfc = ((m2 - c2 * m1 * vv) * Kinverse + v2 * m0) * K; +} +//////////////////////////////////////////////////////////////////////////////// +//! \brief backward chimera transformation \ref backwardInverseChimeraWithK +//! Transformation from central moments to distributions according to Eq. (57)-(65) in +//! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> +//! Modified for lower round-off errors. +//////////////////////////////////////////////////////////////////////////////// +inline void CumulantK17LBMKernel::backwardInverseChimeraWithK(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2, LBMReal Kinverse, LBMReal K) +{ + using namespace UbMath; + LBMReal m0 = (((mfc - mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + c1) * (v2 - vv) * c1o2) * K; + LBMReal m1 = (((mfa - mfc) - c2 * mfb * vv) * Kinverse + (mfa * Kinverse + c1) * (-v2)) * K; + mfc = (((mfc + mfb) * c1o2 + mfb * vv) * Kinverse + (mfa * Kinverse + c1) * (v2 + vv) * c1o2) * K; + mfa = m0; + mfb = m1; +} +//////////////////////////////////////////////////////////////////////////////// +//! \brief forward chimera transformation \ref forwardChimera +//! Transformation from distributions to central moments according to Eq. (6)-(14) in +//! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> +//! for \f$ K_{abc}=0 \f$. This is to avoid unnessary floating point operations. +//! Modified for lower round-off errors. +//////////////////////////////////////////////////////////////////////////////// +inline void CumulantK17LBMKernel::forwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2) +{ + using namespace UbMath; + LBMReal m1 = (mfa + mfc) + mfb; + LBMReal m2 = mfc - mfa; + mfc = (mfc + mfa) + (v2 * m1 - c2 * vv * m2); + mfb = m2 - vv * m1; + mfa = m1; +} +//////////////////////////////////////////////////////////////////////////////// +//! \brief backward chimera transformation \ref backwardChimera +//! Transformation from central moments to distributions according to Eq. (57)-(65) in +//! <a href="https://doi.org/10.1016/j.jcp.2017.05.040"><b>[ M. Geier et al. (2017), DOI:10.1016/j.jcp.2017.05.040 ]</b></a> +//! for \f$ K_{abc}=0 \f$. This is to avoid unnessary floating point operations. +//! Modified for lower round-off errors. +//////////////////////////////////////////////////////////////////////////////// +inline void CumulantK17LBMKernel::backwardChimera(LBMReal& mfa, LBMReal& mfb, LBMReal& mfc, LBMReal vv, LBMReal v2) +{ + using namespace UbMath; + LBMReal ma = (mfc + mfa * (v2 - vv)) * c1o2 + mfb * (vv - c1o2); + LBMReal mb = ((mfa - mfc) - mfa * v2) - c2 * mfb * vv; + mfc = (mfc + mfa * (v2 + vv)) * c1o2 + mfb * (vv + c1o2); + mfb = mb; + mfa = ma; +} + +#endif // CumulantK17LBMKernel_h__ \ No newline at end of file diff --git a/src/cpu/VirtualFluidsCore/LBM/D3Q27System.cpp b/src/cpu/VirtualFluidsCore/LBM/D3Q27System.cpp index c56164ab3..e61805572 100644 --- a/src/cpu/VirtualFluidsCore/LBM/D3Q27System.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/D3Q27System.cpp @@ -1,195 +1,196 @@ -#include "D3Q27System.h" -namespace D3Q27System -{ - //index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18//falsch - //f: ZERO, E, W, N, S, T, B, NE, SW, SE, NW, TE, BW, BE, TW, TN, BS, BN, TS, TNE TNW TSE TSW BNE BNW BSE BSW - //const int EX1[] = { 0, 1, -1, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1 }; - //const int EX2[] = { 0, 0, 0, 1, -1, 0, 0, 1, -1, -1, 1, 0, 0, 0, 0, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1 }; - //const int EX3[] = { 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1 }; - - //index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 - //f: E, W, N, S, T, B, NE, SW, SE, NW, TE, BW, BE, TW, TN, BS, BN, TS, TNE TNW TSE TSW BNE BNW BSE BSW - const int DX1[] = { 1, -1, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1 }; - const int DX2[] = { 0, 0, 1, -1, 0, 0, 1, -1, -1, 1, 0, 0, 0, 0, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1 }; - const int DX3[] = { 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1 }; - - ////index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 - ////f: E, W, N, S, T, B, NE, SW, SE, NW, TE, BW, BE, TW, TN, BS, BN, TS, TNE TNW TSE TSW BNE BNW BSE BSW - const double WEIGTH[] = { c2o27, c2o27, c2o27, c2o27, c2o27, c2o27, c1o54, c1o54, c1o54, c1o54, c1o54, c1o54, c1o54, c1o54, c1o54, c1o54, c1o54, c1o54, c1o216, c1o216, c1o216, c1o216, c1o216, c1o216, c1o216, c1o216 , c8o27 }; - - - const int INVDIR[] = { - INV_E, - INV_W, - INV_N, - INV_S, - INV_T, - INV_B, - INV_NE, - INV_SW, - INV_SE, - INV_NW, - INV_TE, - INV_BW, - INV_BE, - INV_TW, - INV_TN, - INV_BS, - INV_BN, - INV_TS, - INV_TNE, - INV_TNW, - INV_TSE, - INV_TSW, - INV_BNE, - INV_BNW, - INV_BSE, - INV_BSW }; - - - // The x,y,z component for each normalized direction - const double cNorm[3][ENDDIR] = { - { - double(DX1[0]), double(DX1[1]), - double(DX1[2]), double(DX1[3]), - double(DX1[4]), double(DX1[5]), - double(DX1[6]) / std::sqrt(double(2)), double(DX1[7]) / std::sqrt(double(2)), - double(DX1[8]) / std::sqrt(double(2)), double(DX1[9]) / std::sqrt(double(2)), - double(DX1[10]) / std::sqrt(double(2)), double(DX1[11]) / std::sqrt(double(2)), - double(DX1[12]) / std::sqrt(double(2)), double(DX1[13]) / std::sqrt(double(2)), - double(DX1[14]), double(DX1[15]), - double(DX1[16]), double(DX1[17]), - double(DX1[18]) / std::sqrt(double(3)), double(DX1[19]) / std::sqrt(double(3)), - double(DX1[20]) / std::sqrt(double(3)), double(DX1[21]) / std::sqrt(double(3)), - double(DX1[22]) / std::sqrt(double(3)), double(DX1[23]) / std::sqrt(double(3)), - double(DX1[24]) / std::sqrt(double(3)), double(DX1[25]) / std::sqrt(double(3)) - },{ - double(DX2[0]), double(DX2[1]), - double(DX2[2]), double(DX2[3]), - double(DX2[4]), double(DX2[5]), - double(DX2[6]) / std::sqrt(double(2)), double(DX2[7]) / std::sqrt(double(2)), - double(DX2[8]) / std::sqrt(double(2)), double(DX2[9]) / std::sqrt(double(2)), - double(DX2[10]), double(DX2[11]), - double(DX2[12]), double(DX2[13]), - double(DX2[14]) / std::sqrt(double(2)), double(DX2[15]) / std::sqrt(double(2)), - double(DX2[16]) / std::sqrt(double(2)), double(DX2[17]) / std::sqrt(double(2)), - double(DX2[18]) / std::sqrt(double(3)), double(DX2[19]) / std::sqrt(double(3)), - double(DX2[20]) / std::sqrt(double(3)), double(DX2[21]) / std::sqrt(double(3)), - double(DX2[22]) / std::sqrt(double(3)), double(DX2[23]) / std::sqrt(double(3)), - double(DX2[24]) / std::sqrt(double(3)), double(DX2[25]) / std::sqrt(double(3)) - },{ - double(DX3[0]), double(DX3[1]), - double(DX3[2]), double(DX3[3]), - double(DX3[4]), double(DX3[5]), - double(DX3[6]), double(DX3[7]), - double(DX3[8]), double(DX3[9]), - double(DX3[10]) / std::sqrt(double(2)), double(DX3[11]) / std::sqrt(double(2)), - double(DX3[12]) / std::sqrt(double(2)), double(DX3[13]) / std::sqrt(double(2)), - double(DX3[14]) / std::sqrt(double(2)), double(DX3[15]) / std::sqrt(double(2)), - double(DX3[16]) / std::sqrt(double(2)), double(DX3[17]) / std::sqrt(double(2)), - double(DX3[18]) / std::sqrt(double(3)), double(DX3[19]) / std::sqrt(double(3)), - double(DX3[20]) / std::sqrt(double(3)), double(DX3[21]) / std::sqrt(double(3)), - double(DX3[22]) / std::sqrt(double(3)), double(DX3[23]) / std::sqrt(double(3)), - double(DX3[24]) / std::sqrt(double(3)), double(DX3[25]) / std::sqrt(double(3)) - } - }; - -} - -//const int FSTARTDIR = 0; -//const int FENDDIR = 25; //D3Q27 - -//const int STARTF = 0; -//const int ENDF = 26; //D3Q27 - -//const int EX1[ENDF+1]; -//const int EX2[ENDF+1]; -//const int EX3[ENDF+1]; - -//const int STARTDIR = 0; -//const int ENDDIR = 26; //alle geometrischen richtungen - -//const int DX1[ENDDIR+1]; -//const int DX2[ENDDIR+1]; -//const int DX3[ENDDIR+1]; - - -//const int E /*f1 */ = 0; -//const int W /*f2 */ = 1; -//const int N /*f3 */ = 2; -//const int S /*f4 */ = 3; -//const int T /*f5 */ = 4; -//const int B /*f6 */ = 5; -//const int NE /*f7 */ = 6; -//const int SW /*f8 */ = 7; -//const int SE /*f9 */ = 8; -//const int NW /*f10*/ = 9; -//const int TE /*f11*/ = 10; -//const int BW /*f12*/ = 11; -//const int BE /*f13*/ = 12; -//const int TW /*f14*/ = 13; -//const int TN /*f15*/ = 14; -//const int BS /*f16*/ = 15; -//const int BN /*f17*/ = 16; -//const int TS /*f18*/ = 17; -//const int TNE = 18; -//const int TNW = 19; -//const int TSE = 20; -//const int TSW = 21; -//const int BNE = 22; -//const int BNW = 23; -//const int BSE = 24; -//const int BSW = 25; -//const int ZERO /*f0 */ = 26; - -//const int INV_E = W; -//const int INV_W = E; -//const int INV_N = S; -//const int INV_S = N; -//const int INV_T = B; -//const int INV_B = T; -//const int INV_NE = SW; -//const int INV_SW = NE; -//const int INV_SE = NW; -//const int INV_NW = SE; -//const int INV_TE = BW; -//const int INV_BW = TE; -//const int INV_BE = TW; -//const int INV_TW = BE; -//const int INV_TN = BS; -//const int INV_BS = TN; -//const int INV_BN = TS; -//const int INV_TS = BN; -//const int INV_TNE = BSW; -//const int INV_TNW = BSE; -//const int INV_TSE = BNW; -//const int INV_TSW = BNE; -//const int INV_BNE = TSW; -//const int INV_BNW = TSE; -//const int INV_BSE = TNW; -//const int INV_BSW = TNE; - -//const int INVDIR[ENDDIR+1]; - -//const int M_RHO = 0; -//const int M_EN = 1; -//const int M_EPS = 2; -//const int M_JX1 = 3; -//const int M_QX1 = 4; -//const int M_JX2 = 5; -//const int M_QX2 = 6; -//const int M_JX3 = 7; -//const int M_QX3 = 8; -//const int M_3PX1X1 = 9; -//const int M_3PIX1X1 = 10; -//const int M_PWW = 11; -//const int M_PIWW = 12; -//const int M_PX1X2 = 13; -//const int M_PX2X3 = 14; -//const int M_PX1X3 = 15; -//const int M_MX1 = 16; -//const int M_MX2 = 17; -//const int M_MX3 = 18; - -//const int STARTM = 0; -//const int ENDM = 18; //D3Q27 +#include "D3Q27System.h" +namespace D3Q27System +{ + using namespace UbMath; + //index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18//falsch + //f: REST, E, W, N, S, T, B, NE, SW, SE, NW, TE, BW, BE, TW, TN, BS, BN, TS, TNE TNW TSE TSW BNE BNW BSE BSW + //const int EX1[] = { 0, 1, -1, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1 }; + //const int EX2[] = { 0, 0, 0, 1, -1, 0, 0, 1, -1, -1, 1, 0, 0, 0, 0, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1 }; + //const int EX3[] = { 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1 }; + + //index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 + //f: E, W, N, S, T, B, NE, SW, SE, NW, TE, BW, BE, TW, TN, BS, BN, TS, TNE TNW TSE TSW BNE BNW BSE BSW + const int DX1[] = { 1, -1, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1 }; + const int DX2[] = { 0, 0, 1, -1, 0, 0, 1, -1, -1, 1, 0, 0, 0, 0, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1 }; + const int DX3[] = { 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1 }; + + ////index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 + ////f: E, W, N, S, T, B, NE, SW, SE, NW, TE, BW, BE, TW, TN, BS, BN, TS, TNE TNW TSE TSW BNE BNW BSE BSW + const double WEIGTH[] = { c2o27, c2o27, c2o27, c2o27, c2o27, c2o27, c1o54, c1o54, c1o54, c1o54, c1o54, c1o54, c1o54, c1o54, c1o54, c1o54, c1o54, c1o54, c1o216, c1o216, c1o216, c1o216, c1o216, c1o216, c1o216, c1o216 , c8o27 }; + + + const int INVDIR[] = { + INV_E, + INV_W, + INV_N, + INV_S, + INV_T, + INV_B, + INV_NE, + INV_SW, + INV_SE, + INV_NW, + INV_TE, + INV_BW, + INV_BE, + INV_TW, + INV_TN, + INV_BS, + INV_BN, + INV_TS, + INV_TNE, + INV_TNW, + INV_TSE, + INV_TSW, + INV_BNE, + INV_BNW, + INV_BSE, + INV_BSW }; + + + // The x,y,z component for each normalized direction + const double cNorm[3][ENDDIR] = { + { + double(DX1[0]), double(DX1[1]), + double(DX1[2]), double(DX1[3]), + double(DX1[4]), double(DX1[5]), + double(DX1[6]) / std::sqrt(double(2)), double(DX1[7]) / std::sqrt(double(2)), + double(DX1[8]) / std::sqrt(double(2)), double(DX1[9]) / std::sqrt(double(2)), + double(DX1[10]) / std::sqrt(double(2)), double(DX1[11]) / std::sqrt(double(2)), + double(DX1[12]) / std::sqrt(double(2)), double(DX1[13]) / std::sqrt(double(2)), + double(DX1[14]), double(DX1[15]), + double(DX1[16]), double(DX1[17]), + double(DX1[18]) / std::sqrt(double(3)), double(DX1[19]) / std::sqrt(double(3)), + double(DX1[20]) / std::sqrt(double(3)), double(DX1[21]) / std::sqrt(double(3)), + double(DX1[22]) / std::sqrt(double(3)), double(DX1[23]) / std::sqrt(double(3)), + double(DX1[24]) / std::sqrt(double(3)), double(DX1[25]) / std::sqrt(double(3)) + },{ + double(DX2[0]), double(DX2[1]), + double(DX2[2]), double(DX2[3]), + double(DX2[4]), double(DX2[5]), + double(DX2[6]) / std::sqrt(double(2)), double(DX2[7]) / std::sqrt(double(2)), + double(DX2[8]) / std::sqrt(double(2)), double(DX2[9]) / std::sqrt(double(2)), + double(DX2[10]), double(DX2[11]), + double(DX2[12]), double(DX2[13]), + double(DX2[14]) / std::sqrt(double(2)), double(DX2[15]) / std::sqrt(double(2)), + double(DX2[16]) / std::sqrt(double(2)), double(DX2[17]) / std::sqrt(double(2)), + double(DX2[18]) / std::sqrt(double(3)), double(DX2[19]) / std::sqrt(double(3)), + double(DX2[20]) / std::sqrt(double(3)), double(DX2[21]) / std::sqrt(double(3)), + double(DX2[22]) / std::sqrt(double(3)), double(DX2[23]) / std::sqrt(double(3)), + double(DX2[24]) / std::sqrt(double(3)), double(DX2[25]) / std::sqrt(double(3)) + },{ + double(DX3[0]), double(DX3[1]), + double(DX3[2]), double(DX3[3]), + double(DX3[4]), double(DX3[5]), + double(DX3[6]), double(DX3[7]), + double(DX3[8]), double(DX3[9]), + double(DX3[10]) / std::sqrt(double(2)), double(DX3[11]) / std::sqrt(double(2)), + double(DX3[12]) / std::sqrt(double(2)), double(DX3[13]) / std::sqrt(double(2)), + double(DX3[14]) / std::sqrt(double(2)), double(DX3[15]) / std::sqrt(double(2)), + double(DX3[16]) / std::sqrt(double(2)), double(DX3[17]) / std::sqrt(double(2)), + double(DX3[18]) / std::sqrt(double(3)), double(DX3[19]) / std::sqrt(double(3)), + double(DX3[20]) / std::sqrt(double(3)), double(DX3[21]) / std::sqrt(double(3)), + double(DX3[22]) / std::sqrt(double(3)), double(DX3[23]) / std::sqrt(double(3)), + double(DX3[24]) / std::sqrt(double(3)), double(DX3[25]) / std::sqrt(double(3)) + } + }; + +} + +//const int FSTARTDIR = 0; +//const int FENDDIR = 25; //D3Q27 + +//const int STARTF = 0; +//const int ENDF = 26; //D3Q27 + +//const int EX1[ENDF+1]; +//const int EX2[ENDF+1]; +//const int EX3[ENDF+1]; + +//const int STARTDIR = 0; +//const int ENDDIR = 26; //alle geometrischen richtungen + +//const int DX1[ENDDIR+1]; +//const int DX2[ENDDIR+1]; +//const int DX3[ENDDIR+1]; + + +//const int E /*f1 */ = 0; +//const int W /*f2 */ = 1; +//const int N /*f3 */ = 2; +//const int S /*f4 */ = 3; +//const int T /*f5 */ = 4; +//const int B /*f6 */ = 5; +//const int NE /*f7 */ = 6; +//const int SW /*f8 */ = 7; +//const int SE /*f9 */ = 8; +//const int NW /*f10*/ = 9; +//const int TE /*f11*/ = 10; +//const int BW /*f12*/ = 11; +//const int BE /*f13*/ = 12; +//const int TW /*f14*/ = 13; +//const int TN /*f15*/ = 14; +//const int BS /*f16*/ = 15; +//const int BN /*f17*/ = 16; +//const int TS /*f18*/ = 17; +//const int TNE = 18; +//const int TNW = 19; +//const int TSE = 20; +//const int TSW = 21; +//const int BNE = 22; +//const int BNW = 23; +//const int BSE = 24; +//const int BSW = 25; +//const int REST /*f0 */ = 26; + +//const int INV_E = W; +//const int INV_W = E; +//const int INV_N = S; +//const int INV_S = N; +//const int INV_T = B; +//const int INV_B = T; +//const int INV_NE = SW; +//const int INV_SW = NE; +//const int INV_SE = NW; +//const int INV_NW = SE; +//const int INV_TE = BW; +//const int INV_BW = TE; +//const int INV_BE = TW; +//const int INV_TW = BE; +//const int INV_TN = BS; +//const int INV_BS = TN; +//const int INV_BN = TS; +//const int INV_TS = BN; +//const int INV_TNE = BSW; +//const int INV_TNW = BSE; +//const int INV_TSE = BNW; +//const int INV_TSW = BNE; +//const int INV_BNE = TSW; +//const int INV_BNW = TSE; +//const int INV_BSE = TNW; +//const int INV_BSW = TNE; + +//const int INVDIR[ENDDIR+1]; + +//const int M_RHO = 0; +//const int M_EN = 1; +//const int M_EPS = 2; +//const int M_JX1 = 3; +//const int M_QX1 = 4; +//const int M_JX2 = 5; +//const int M_QX2 = 6; +//const int M_JX3 = 7; +//const int M_QX3 = 8; +//const int M_3PX1X1 = 9; +//const int M_3PIX1X1 = 10; +//const int M_PWW = 11; +//const int M_PIWW = 12; +//const int M_PX1X2 = 13; +//const int M_PX2X3 = 14; +//const int M_PX1X3 = 15; +//const int M_MX1 = 16; +//const int M_MX2 = 17; +//const int M_MX3 = 18; + +//const int STARTM = 0; +//const int ENDM = 18; //D3Q27 diff --git a/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h b/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h index 6ae3bf70e..9e1426a06 100644 --- a/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h +++ b/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h @@ -1,778 +1,594 @@ -#ifndef D3Q27SYSTEM_H -#define D3Q27SYSTEM_H - -#include <cmath> -#include <string> -#include <iostream> - -#ifdef RCF_USE_SF_SERIALIZATION - #include <SF/Serializer.hpp> - - #if CAB_RCF <= 903 - #include <SF/SerializeEnum.hpp> - #endif -#endif //RCF_USE_SF_SERIALIZATION - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbTuple.h> -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbSystem.h> -//#include "Patch3DSystem.h" -#include "LBMSystem.h" - -/*=========================================================================*/ -/* D3Q27System */ -/* */ -/** -class for global system-functions -<BR><BR> -@author <A HREF="mailto:kucher@irmb.tu-bs.de">K. Kucher</A> -@version 1.0 - 22.10.09 -*/ - -/* -usage: ... -*/ - - -#ifndef SWIG - using namespace UbMath; -#endif - -namespace D3Q27System -{ - //enum COLLISIONMODEL { UNDEFINED, INCOMPLBGKMODEL, COMPLBGKMODEL, COMPLBGKWTMODEL, INCOMPLBGKLESMODEL, INCOMPLBGKNONNEWTONIANMODEL - // , INCOMPGLBEJTMODEL, COMPGLBEJTMODEL, COMPGLBEJTWTMODEL, INCOMPGLBEJTLESMODEL, INCOMPGLBEJTWALEMODEL - // , CASCADEDMODEL}; - // - // #if defined(RCF_USE_SF_SERIALIZATION) && (CAB_RCF <= 903) - // SF_SERIALIZE_ENUM(COLLISIONMODEL) //muss im namespace stehen, sonst funzt es nicht! - // #endif - - ///*=====================================================================*/ - //std::string toString(const COLLISIONMODEL& model); - ///*=====================================================================*/ - //COLLISIONMODEL getCollModelByString(const std::string& str); - ///*=====================================================================*/ - - ///*=====================================================================*/ - //static bool isCompModel(const COLLISIONMODEL& model) - //{ - // switch(model) - // { - // case COMPLBGKMODEL : return true; - // case COMPLBGKWTMODEL : return true; - // case COMPGLBEJTWTMODEL : return true; - // case COMPGLBEJTMODEL : return true; - // case CASCADEDMODEL : return true; - // - // case INCOMPLBGKMODEL : return false; - // case INCOMPGLBEJTMODEL : return false; - // case INCOMPLBGKLESMODEL : return false; - // case INCOMPGLBEJTLESMODEL : return false; - // case INCOMPGLBEJTWALEMODEL : return false; - // case INCOMPLBGKNONNEWTONIANMODEL : return false; - - // default: throw UbException(UB_EXARGS,"unknown model"); - // } - //} - ///*=====================================================================*/ - //static bool isGLBEModel(const COLLISIONMODEL& model) - //{ - // switch(model) - // { - // case COMPGLBEJTWTMODEL : return true; - // case COMPGLBEJTMODEL : return true; - // case INCOMPGLBEJTMODEL : return true; - // case INCOMPGLBEJTLESMODEL : return true; - // case INCOMPGLBEJTWALEMODEL : return false; - - // case COMPLBGKMODEL : return false; - // case COMPLBGKWTMODEL : return false; - // case INCOMPLBGKMODEL : return false; - // case INCOMPLBGKLESMODEL : return false; - // case INCOMPLBGKNONNEWTONIANMODEL : return false; - - // default: throw UbException(UB_EXARGS,"unknown model"); - // } - //} - //static bool isLESModel(const COLLISIONMODEL& model) - //{ - // switch(model) - // { - // case INCOMPGLBEJTLESMODEL : return true; - // case INCOMPLBGKLESMODEL : return true; - // case INCOMPGLBEJTWALEMODEL : return true; - // - // case COMPGLBEJTWTMODEL : return false; - // case COMPGLBEJTMODEL : return false; - // case INCOMPGLBEJTMODEL : return false; - // case COMPLBGKMODEL : return false; - // case COMPLBGKWTMODEL : return false; - // case INCOMPLBGKMODEL : return false; - // case INCOMPLBGKNONNEWTONIANMODEL : return false; - - // default: throw UbException(UB_EXARGS,"unknown model"); - // } - //} - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - //DIRECTION STUFF - static const int FSTARTDIR = 0; - static const int FENDDIR = 25; //D3Q27 - - //static const int FSTARTDIR = 1; - //static const int FENDDIR = 26; //D3Q27 - - static const int STARTF = 0; - static const int ENDF = 26; //D3Q27 - - //extern const int EX1[ENDF+1]; - //extern const int EX2[ENDF+1]; - //extern const int EX3[ENDF+1]; - - static const int STARTDIR = 0; - static const int ENDDIR = 26; //alle geometrischen richtungen - - extern const int DX1[ENDDIR+1]; - extern const int DX2[ENDDIR+1]; - extern const int DX3[ENDDIR+1]; - extern const double WEIGTH[ENDDIR+1]; - - extern const double cNorm[3][ENDDIR]; - - //static const int ZERO /*f0 */ = 0; - //static const int E /*f1 */ = 1; - //static const int W /*f2 */ = 2; - //static const int N /*f3 */ = 3; - //static const int S /*f4 */ = 4; - //static const int T /*f5 */ = 5; - //static const int B /*f6 */ = 6; - //static const int NE /*f7 */ = 7; - //static const int SW /*f8 */ = 8; - //static const int SE /*f9 */ = 9; - //static const int NW /*f10*/ = 10; - //static const int TE /*f11*/ = 11; - //static const int BW /*f12*/ = 12; - //static const int BE /*f13*/ = 13; - //static const int TW /*f14*/ = 14; - //static const int TN /*f15*/ = 15; - //static const int BS /*f16*/ = 16; - //static const int BN /*f17*/ = 17; - //static const int TS /*f18*/ = 18; - //static const int TNE = 19; - //static const int TNW = 20; - //static const int TSE = 21; - //static const int TSW = 22; - //static const int BNE = 23; - //static const int BNW = 24; - //static const int BSE = 25; - //static const int BSW = 26; - - static const int E /*f1 */ = 0; - static const int W /*f2 */ = 1; - static const int N /*f3 */ = 2; - static const int S /*f4 */ = 3; - static const int T /*f5 */ = 4; - static const int B /*f6 */ = 5; - static const int NE /*f7 */ = 6; - static const int SW /*f8 */ = 7; - static const int SE /*f9 */ = 8; - static const int NW /*f10*/ = 9; - static const int TE /*f11*/ = 10; - static const int BW /*f12*/ = 11; - static const int BE /*f13*/ = 12; - static const int TW /*f14*/ = 13; - static const int TN /*f15*/ = 14; - static const int BS /*f16*/ = 15; - static const int BN /*f17*/ = 16; - static const int TS /*f18*/ = 17; - static const int TNE = 18; - static const int TNW = 19; - static const int TSE = 20; - static const int TSW = 21; - static const int BNE = 22; - static const int BNW = 23; - static const int BSE = 24; - static const int BSW = 25; - static const int ZERO /*f0 */ = 26; - - static const int INV_E = W; - static const int INV_W = E; - static const int INV_N = S; - static const int INV_S = N; - static const int INV_T = B; - static const int INV_B = T; - static const int INV_NE = SW; - static const int INV_SW = NE; - static const int INV_SE = NW; - static const int INV_NW = SE; - static const int INV_TE = BW; - static const int INV_BW = TE; - static const int INV_BE = TW; - static const int INV_TW = BE; - static const int INV_TN = BS; - static const int INV_BS = TN; - static const int INV_BN = TS; - static const int INV_TS = BN; - static const int INV_TNE = BSW; - static const int INV_TNW = BSE; - static const int INV_TSE = BNW; - static const int INV_TSW = BNE; - static const int INV_BNE = TSW; - static const int INV_BNW = TSE; - static const int INV_BSE = TNW; - static const int INV_BSW = TNE; - - extern const int INVDIR[ENDDIR+1]; - - static const int ET_E = 0; - static const int ET_W = 0; - static const int ET_N = 1; - static const int ET_S = 1; - static const int ET_T = 2; - static const int ET_B = 2; - static const int ET_NE = 3; - static const int ET_SW = 3; - static const int ET_SE = 4; - static const int ET_NW = 4; - static const int ET_TE = 5; - static const int ET_BW = 5; - static const int ET_BE = 6; - static const int ET_TW = 6; - static const int ET_TN = 7; - static const int ET_BS = 7; - static const int ET_BN = 8; - static const int ET_TS = 8; - static const int ET_TNE = 9; - static const int ET_BSW = 9; - static const int ET_TNW = 10; - static const int ET_BSE = 10; - static const int ET_TSE = 11; - static const int ET_BNW = 11; - static const int ET_TSW = 12; - static const int ET_BNE = 12; - - static const int M_RHO = 0; - static const int M_EN = 1; - static const int M_EPS = 2; - static const int M_JX1 = 3; - static const int M_QX1 = 4; - static const int M_JX2 = 5; - static const int M_QX2 = 6; - static const int M_JX3 = 7; - static const int M_QX3 = 8; - static const int M_3PX1X1 = 9; - static const int M_3PIX1X1 = 10; - static const int M_PWW = 11; - static const int M_PIWW = 12; - static const int M_PX1X2 = 13; - static const int M_PX2X3 = 14; - static const int M_PX1X3 = 15; - static const int M_MX1 = 16; - static const int M_MX2 = 17; - static const int M_MX3 = 18; - - static const int STARTM = 0; - static const int ENDM = 18; //D3Q27 - - - - ////////////////////////////////////////////////////////////////////////// - //MACROSCOPIC VALUES - /*=====================================================================*/ - static LBMReal getDensity(const LBMReal* const& f/*[27]*/) - { - return ((f[TNE] + f[BSW])+(f[TSE]+f[BNW]))+((f[BSE]+f[TNW])+ (f[TSW]+f[BNE])) - +(((f[NE] + f[SW]) + (f[SE] + f[NW]))+((f[TE] + f[BW])+(f[BE]+ f[TW])) - +((f[BN] + f[TS]) + (f[TN] + f[BS])))+((f[E] + f[W])+(f[N] + f[S]) - +(f[T] + f[B]))+f[ZERO]; - } - /*=====================================================================*/ - //ACHTUNG: gilt nicht fuer alle modelle -> praedikat verwenden anstelle static! toDo - static LBMReal getPressure(const LBMReal* const& f/*[27]*/) - { - return REAL_CAST( c1o3 )*getDensity(f); - } - /*=====================================================================*/ - static LBMReal getIncompVelocityX1(const LBMReal* const& f/*[27]*/) - { - return ((((f[TNE]-f[BSW]) + (f[TSE]-f[BNW])) + ((f[BSE]-f[TNW]) + (f[BNE]-f[TSW]))) + - (((f[BE]-f[TW]) + (f[TE]-f[BW])) + ((f[SE]-f[NW]) + (f[NE]-f[SW]))) + - (f[E]-f[W])); - } - /*=====================================================================*/ - static LBMReal getIncompVelocityX2(const LBMReal* const& f/*[27]*/) - { - return ((((f[TNE]-f[BSW]) + (f[BNW]-f[TSE])) + ((f[TNW]-f[BSE]) + (f[BNE]-f[TSW]))) + - (((f[BN]-f[TS]) + (f[TN]-f[BS])) + ((f[NW]-f[SE]) + (f[NE]-f[SW]))) + - (f[N]-f[S])); - } - /*=====================================================================*/ - static LBMReal getIncompVelocityX3(const LBMReal* const& f/*[27]*/) - { - return ((((f[TNE] - f[BSW]) + (f[TSE] - f[BNW])) + ((f[TNW] - f[BSE]) + (f[TSW] - f[BNE]))) + - (((f[TS] - f[BN]) + (f[TN] - f[BS])) + ((f[TW] - f[BE]) + (f[TE] - f[BW]))) + - (f[T] - f[B])); - } - /*=====================================================================*/ - static void calcDensity(const LBMReal* const& f/*[27]*/, LBMReal& rho) - { - rho = ((f[TNE] + f[BSW])+(f[TSE]+f[BNW]))+((f[BSE]+f[TNW])+ (f[TSW]+f[BNE])) - +(((f[NE] + f[SW]) + (f[SE] + f[NW]))+((f[TE] + f[BW])+(f[BE]+ f[TW])) - +((f[BN] + f[TS]) + (f[TN] + f[BS])))+((f[E] + f[W])+(f[N] + f[S]) - +(f[T] + f[B]))+f[ZERO]; - - } - /*=====================================================================*/ - static void calcIncompVelocityX1(const LBMReal* const& f/*[27]*/, LBMReal& vx1) - { - vx1 = ((((f[TNE]-f[BSW]) + (f[TSE]-f[BNW])) + ((f[BSE]-f[TNW]) + (f[BNE]-f[TSW]))) + - (((f[BE]-f[TW]) + (f[TE]-f[BW])) + ((f[SE]-f[NW]) + (f[NE]-f[SW]))) + - (f[E]-f[W])); - } - /*=====================================================================*/ - static void calcIncompVelocityX2(const LBMReal* const& f/*[27]*/, LBMReal& vx2) - { - vx2 = ((((f[TNE]-f[BSW]) + (f[BNW]-f[TSE])) + ((f[TNW]-f[BSE]) + (f[BNE]-f[TSW]))) + - (((f[BN]-f[TS]) + (f[TN]-f[BS])) + ((f[NW]-f[SE]) + (f[NE]-f[SW]))) + - (f[N]-f[S])); - } - /*=====================================================================*/ - static void calcIncompVelocityX3(const LBMReal* const& f/*[27]*/, LBMReal& vx3) - { - vx3 =((((f[TNE]-f[BSW]) + (f[TSE]-f[BNW])) + ((f[TNW]-f[BSE]) + (f[TSW]-f[BNE]))) + - (((f[TS]-f[BN]) + (f[TN]-f[BS])) + ((f[TW]-f[BE]) + (f[TE]-f[BW]))) + - (f[T]-f[B])); - } - /*=====================================================================*/ - static LBMReal getCompVelocityX1(const LBMReal* const& f/*[27]*/) - { - return ((((f[TNE]-f[BSW]) + (f[TSE]-f[BNW])) + ((f[BSE]-f[TNW]) + (f[BNE]-f[TSW]))) + - (((f[BE]-f[TW]) + (f[TE]-f[BW])) + ((f[SE]-f[NW]) + (f[NE]-f[SW]))) + - (f[E]-f[W]))/getDensity(f); - } - /*=====================================================================*/ - static LBMReal getCompVelocityX2(const LBMReal* const& f/*[27]*/) - { - return ((((f[TNE]-f[BSW]) + (f[BNW]-f[TSE])) + ((f[TNW]-f[BSE]) + (f[BNE]-f[TSW]))) + - (((f[BN]-f[TS]) + (f[TN]-f[BS])) + ((f[NW]-f[SE]) + (f[NE]-f[SW]))) + - (f[N]-f[S]))/getDensity(f); - } - /*=====================================================================*/ - static LBMReal getCompVelocityX3(const LBMReal* const& f/*[27]*/) - { - return ((((f[TNE]-f[BSW]) + (f[TSE]-f[BNW])) + ((f[TNW]-f[BSE]) + (f[TSW]-f[BNE]))) + - (((f[TS]-f[BN]) + (f[TN]-f[BS])) + ((f[TW]-f[BE]) + (f[TE]-f[BW]))) + - (f[T]-f[B]))/getDensity(f); - } - /*=====================================================================*/ - static void calcCompVelocityX1(const LBMReal* const& f/*[27]*/, LBMReal& vx1) - { - vx1 = ((((f[TNE]-f[BSW]) + (f[TSE]-f[BNW])) + ((f[BSE]-f[TNW]) + (f[BNE]-f[TSW]))) + - (((f[BE]-f[TW]) + (f[TE]-f[BW])) + ((f[SE]-f[NW]) + (f[NE]-f[SW]))) + - (f[E]-f[W]))/getDensity(f); - } - /*=====================================================================*/ - static void calcCompVelocityX2(const LBMReal* const& f/*[27]*/, LBMReal& vx2) - { - vx2 = ((((f[TNE]-f[BSW]) + (f[BNW]-f[TSE])) + ((f[TNW]-f[BSE]) + (f[BNE]-f[TSW]))) + - (((f[BN]-f[TS]) + (f[TN]-f[BS])) + ((f[NW]-f[SE]) + (f[NE]-f[SW]))) + - (f[N]-f[S]))/getDensity(f); - } - /*=====================================================================*/ - static void calcCompVelocityX3(const LBMReal* const& f/*[27]*/, LBMReal& vx3) - { - vx3 = ((((f[TNE]-f[BSW]) + (f[TSE]-f[BNW])) + ((f[TNW]-f[BSE]) + (f[TSW]-f[BNE]))) + - (((f[TS]-f[BN]) + (f[TN]-f[BS])) + ((f[TW]-f[BE]) + (f[TE]-f[BW]))) + - (f[T]-f[B]))/getDensity(f); - } - /*=====================================================================*/ - static void calcIncompMacroscopicValues(const LBMReal* const& f/*[27]*/, LBMReal& rho, LBMReal& vx1, LBMReal& vx2, LBMReal& vx3) - { - D3Q27System::calcDensity(f, rho); - D3Q27System::calcIncompVelocityX1(f, vx1); - D3Q27System::calcIncompVelocityX2(f, vx2); - D3Q27System::calcIncompVelocityX3(f, vx3); - } - - /*=====================================================================*/ - static void calcCompMacroscopicValues(const LBMReal* const& f/*[27]*/, LBMReal& drho, LBMReal& vx1, LBMReal& vx2, LBMReal& vx3) - { - D3Q27System::calcDensity(f, drho); - D3Q27System::calcIncompVelocityX1(f, vx1); - D3Q27System::calcIncompVelocityX2(f, vx2); - D3Q27System::calcIncompVelocityX3(f, vx3); - LBMReal rho = drho+one; - vx1/=rho; - vx2/=rho; - vx3/=rho; - } - ////////////////////////////////////////////////////////////////////////// - static LBMReal getCompFeqForDirection(const int& direction, const LBMReal& drho,const LBMReal& vx1,const LBMReal& vx2,const LBMReal& vx3) - { - LBMReal cu_sq=1.5*(vx1*vx1+vx2*vx2+vx3*vx3); - - //switch(direction) - //{ - // case ZERO : return REAL_CAST( c8o27*rho*(1.0-cu_sq)); - // case E : return REAL_CAST( c2o27*rho*(1.0+3.0*( vx1 )+c9o2*( vx1 )*( vx1 )-cu_sq)); - // case W : return REAL_CAST( c2o27*rho*(1.0+3.0*(-vx1 )+c9o2*(-vx1 )*(-vx1 )-cu_sq)); - // case N : return REAL_CAST( c2o27*rho*(1.0+3.0*( vx2)+c9o2*( vx2)*( vx2)-cu_sq)); - // case S : return REAL_CAST( c2o27*rho*(1.0+3.0*( -vx2)+c9o2*( -vx2)*( -vx2)-cu_sq)); - // case T : return REAL_CAST( c2o27*rho*(1.0+3.0*( vx3 )+c9o2*( vx3)*( vx3)-cu_sq)); - // case B : return REAL_CAST( c2o27*rho*(1.0+3.0*( -vx3)+c9o2*( -vx3)*( -vx3)-cu_sq)); - // case NE : return REAL_CAST( c1o54*rho*(1.0+3.0*( vx1+vx2)+c9o2*( vx1+vx2)*( vx1+vx2)-cu_sq)); - // case SW : return REAL_CAST( c1o54*rho*(1.0+3.0*(-vx1-vx2)+c9o2*(-vx1-vx2)*(-vx1-vx2)-cu_sq)); - // case SE : return REAL_CAST( c1o54*rho*(1.0+3.0*( vx1-vx2)+c9o2*( vx1-vx2)*( vx1-vx2)-cu_sq)); - // case NW : return REAL_CAST( c1o54*rho*(1.0+3.0*(-vx1+vx2)+c9o2*(-vx1+vx2)*(-vx1+vx2)-cu_sq)); - // case TE : return REAL_CAST( c1o54*rho*(1.0+3.0*( vx1+vx3)+c9o2*( vx1+vx3)*( vx1+vx3)-cu_sq)); - // case BW : return REAL_CAST( c1o54*rho*(1.0+3.0*(-vx1-vx3)+c9o2*(-vx1-vx3)*(-vx1-vx3)-cu_sq)); - // case BE : return REAL_CAST( c1o54*rho*(1.0+3.0*( vx1-vx3)+c9o2*( vx1-vx3)*( vx1-vx3)-cu_sq)); - // case TW : return REAL_CAST( c1o54*rho*(1.0+3.0*(-vx1+vx3)+c9o2*(-vx1+vx3)*(-vx1+vx3)-cu_sq)); - // case TN : return REAL_CAST( c1o54*rho*(1.0+3.0*( vx2+vx3)+c9o2*( vx2+vx3)*( vx2+vx3)-cu_sq)); - // case BS : return REAL_CAST( c1o54*rho*(1.0+3.0*(-vx2-vx3)+c9o2*(-vx2-vx3)*(-vx2-vx3)-cu_sq)); - // case BN : return REAL_CAST( c1o54*rho*(1.0+3.0*( vx2-vx3)+c9o2*( vx2-vx3)*( vx2-vx3)-cu_sq)); - // case TS : return REAL_CAST( c1o54*rho*(1.0+3.0*(-vx2+vx3)+c9o2*(-vx2+vx3)*(-vx2+vx3)-cu_sq)); - // case TNE : return REAL_CAST(c1o216*rho*(1.0+3.0*( vx1+vx2+vx3)+c9o2*( vx1+vx2+vx3)*( vx1+vx2+vx3)-cu_sq)); - // case BSW : return REAL_CAST(c1o216*rho*(1.0+3.0*(-vx1-vx2-vx3)+c9o2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3)-cu_sq)); - // case BNE : return REAL_CAST(c1o216*rho*(1.0+3.0*( vx1+vx2-vx3)+c9o2*( vx1+vx2-vx3)*( vx1+vx2-vx3)-cu_sq)); - // case TSW : return REAL_CAST(c1o216*rho*(1.0+3.0*(-vx1-vx2+vx3)+c9o2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3)-cu_sq)); - // case TSE : return REAL_CAST(c1o216*rho*(1.0+3.0*( vx1-vx2+vx3)+c9o2*( vx1-vx2+vx3)*( vx1-vx2+vx3)-cu_sq)); - // case BNW : return REAL_CAST(c1o216*rho*(1.0+3.0*(-vx1+vx2-vx3)+c9o2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3)-cu_sq)); - // case BSE : return REAL_CAST(c1o216*rho*(1.0+3.0*( vx1-vx2-vx3)+c9o2*( vx1-vx2-vx3)*( vx1-vx2-vx3)-cu_sq)); - // case TNW : return REAL_CAST(c1o216*rho*(1.0+3.0*(-vx1+vx2+vx3)+c9o2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3)-cu_sq)); - // default: throw UbException(UB_EXARGS,"unknown dir"); - //} - - - ////----- - LBMReal rho = drho+one; - switch (direction) - { - case ZERO: return REAL_CAST(c8o27*(drho+rho*(-cu_sq))); - case E: return REAL_CAST(c2o27*(drho+rho*(3.0*(vx1)+c9o2*(vx1)*(vx1)-cu_sq))); - case W: return REAL_CAST(c2o27*(drho+rho*(3.0*(-vx1)+c9o2*(-vx1)*(-vx1)-cu_sq))); - case N: return REAL_CAST(c2o27*(drho+rho*(3.0*(vx2)+c9o2*(vx2)*(vx2)-cu_sq))); - case S: return REAL_CAST(c2o27*(drho+rho*(3.0*(-vx2)+c9o2*(-vx2)*(-vx2)-cu_sq))); - case T: return REAL_CAST(c2o27*(drho+rho*(3.0*(vx3)+c9o2*(vx3)*(vx3)-cu_sq))); - case B: return REAL_CAST(c2o27*(drho+rho*(3.0*(-vx3)+c9o2*(-vx3)*(-vx3)-cu_sq))); - case NE: return REAL_CAST(c1o54*(drho+rho*(3.0*(vx1+vx2)+c9o2*(vx1+vx2)*(vx1+vx2)-cu_sq))); - case SW: return REAL_CAST(c1o54*(drho+rho*(3.0*(-vx1-vx2)+c9o2*(-vx1-vx2)*(-vx1-vx2)-cu_sq))); - case SE: return REAL_CAST(c1o54*(drho+rho*(3.0*(vx1-vx2)+c9o2*(vx1-vx2)*(vx1-vx2)-cu_sq))); - case NW: return REAL_CAST(c1o54*(drho+rho*(3.0*(-vx1+vx2)+c9o2*(-vx1+vx2)*(-vx1+vx2)-cu_sq))); - case TE: return REAL_CAST(c1o54*(drho+rho*(3.0*(vx1+vx3)+c9o2*(vx1+vx3)*(vx1+vx3)-cu_sq))); - case BW: return REAL_CAST(c1o54*(drho+rho*(3.0*(-vx1-vx3)+c9o2*(-vx1-vx3)*(-vx1-vx3)-cu_sq))); - case BE: return REAL_CAST(c1o54*(drho+rho*(3.0*(vx1-vx3)+c9o2*(vx1-vx3)*(vx1-vx3)-cu_sq))); - case TW: return REAL_CAST(c1o54*(drho+rho*(3.0*(-vx1+vx3)+c9o2*(-vx1+vx3)*(-vx1+vx3)-cu_sq))); - case TN: return REAL_CAST(c1o54*(drho+rho*(3.0*(vx2+vx3)+c9o2*(vx2+vx3)*(vx2+vx3)-cu_sq))); - case BS: return REAL_CAST(c1o54*(drho+rho*(3.0*(-vx2-vx3)+c9o2*(-vx2-vx3)*(-vx2-vx3)-cu_sq))); - case BN: return REAL_CAST(c1o54*(drho+rho*(3.0*(vx2-vx3)+c9o2*(vx2-vx3)*(vx2-vx3)-cu_sq))); - case TS: return REAL_CAST(c1o54*(drho+rho*(3.0*(-vx2+vx3)+c9o2*(-vx2+vx3)*(-vx2+vx3)-cu_sq))); - case TNE: return REAL_CAST(c1o216*(drho+rho*(3.0*(vx1+vx2+vx3)+c9o2*(vx1+vx2+vx3)*(vx1+vx2+vx3)-cu_sq))); - case BSW: return REAL_CAST(c1o216*(drho+rho*(3.0*(-vx1-vx2-vx3)+c9o2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3)-cu_sq))); - case BNE: return REAL_CAST(c1o216*(drho+rho*(3.0*(vx1+vx2-vx3)+c9o2*(vx1+vx2-vx3)*(vx1+vx2-vx3)-cu_sq))); - case TSW: return REAL_CAST(c1o216*(drho+rho*(3.0*(-vx1-vx2+vx3)+c9o2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3)-cu_sq))); - case TSE: return REAL_CAST(c1o216*(drho+rho*(3.0*(vx1-vx2+vx3)+c9o2*(vx1-vx2+vx3)*(vx1-vx2+vx3)-cu_sq))); - case BNW: return REAL_CAST(c1o216*(drho+rho*(3.0*(-vx1+vx2-vx3)+c9o2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3)-cu_sq))); - case BSE: return REAL_CAST(c1o216*(drho+rho*(3.0*(vx1-vx2-vx3)+c9o2*(vx1-vx2-vx3)*(vx1-vx2-vx3)-cu_sq))); - case TNW: return REAL_CAST(c1o216*(drho+rho*(3.0*(-vx1+vx2+vx3)+c9o2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3)-cu_sq))); - default: throw UbException(UB_EXARGS, "unknown dir"); - } - - } - ////////////////////////////////////////////////////////////////////////// - static void calcCompFeq(LBMReal* const& feq/*[27]*/,const LBMReal& drho,const LBMReal& vx1,const LBMReal& vx2,const LBMReal& vx3) - { - //LBMReal cu_sq=1.5*(vx1*vx1+vx2*vx2+vx3*vx3); - - //feq[ZERO] = c8o27*rho*(1.0-cu_sq); - //feq[E] = c2o27*rho*(1.0+3.0*( vx1 )+c9o2*( vx1 )*( vx1 )-cu_sq); - //feq[W] = c2o27*rho*(1.0+3.0*(-vx1 )+c9o2*(-vx1 )*(-vx1 )-cu_sq); - //feq[N] = c2o27*rho*(1.0+3.0*( vx2)+c9o2*( vx2)*( vx2)-cu_sq); - //feq[S] = c2o27*rho*(1.0+3.0*( -vx2)+c9o2*( -vx2)*( -vx2)-cu_sq); - //feq[T] = c2o27*rho*(1.0+3.0*( vx3 )+c9o2*( vx3)*( vx3)-cu_sq); - //feq[B] = c2o27*rho*(1.0+3.0*( -vx3)+c9o2*( -vx3)*( -vx3)-cu_sq); - //feq[NE] = c1o54*rho*(1.0+3.0*( vx1+vx2)+c9o2*( vx1+vx2)*( vx1+vx2)-cu_sq); - //feq[SW] = c1o54*rho*(1.0+3.0*(-vx1-vx2)+c9o2*(-vx1-vx2)*(-vx1-vx2)-cu_sq); - //feq[SE] = c1o54*rho*(1.0+3.0*( vx1-vx2)+c9o2*( vx1-vx2)*( vx1-vx2)-cu_sq); - //feq[NW] = c1o54*rho*(1.0+3.0*(-vx1+vx2)+c9o2*(-vx1+vx2)*(-vx1+vx2)-cu_sq); - //feq[TE] = c1o54*rho*(1.0+3.0*( vx1+vx3)+c9o2*( vx1+vx3)*( vx1+vx3)-cu_sq); - //feq[BW] = c1o54*rho*(1.0+3.0*(-vx1-vx3)+c9o2*(-vx1-vx3)*(-vx1-vx3)-cu_sq); - //feq[BE] = c1o54*rho*(1.0+3.0*( vx1-vx3)+c9o2*( vx1-vx3)*( vx1-vx3)-cu_sq); - //feq[TW] = c1o54*rho*(1.0+3.0*(-vx1+vx3)+c9o2*(-vx1+vx3)*(-vx1+vx3)-cu_sq); - //feq[TN] = c1o54*rho*(1.0+3.0*( vx2+vx3)+c9o2*( vx2+vx3)*( vx2+vx3)-cu_sq); - //feq[BS] = c1o54*rho*(1.0+3.0*(-vx2-vx3)+c9o2*(-vx2-vx3)*(-vx2-vx3)-cu_sq); - //feq[BN] = c1o54*rho*(1.0+3.0*( vx2-vx3)+c9o2*( vx2-vx3)*( vx2-vx3)-cu_sq); - //feq[TS] = c1o54*rho*(1.0+3.0*(-vx2+vx3)+c9o2*(-vx2+vx3)*(-vx2+vx3)-cu_sq); - //feq[TNE] = c1o216*rho*(1.0+3.0*( vx1+vx2+vx3)+c9o2*( vx1+vx2+vx3)*( vx1+vx2+vx3)-cu_sq); - //feq[BSW] = c1o216*rho*(1.0+3.0*(-vx1-vx2-vx3)+c9o2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3)-cu_sq); - //feq[BNE] = c1o216*rho*(1.0+3.0*( vx1+vx2-vx3)+c9o2*( vx1+vx2-vx3)*( vx1+vx2-vx3)-cu_sq); - //feq[TSW] = c1o216*rho*(1.0+3.0*(-vx1-vx2+vx3)+c9o2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3)-cu_sq); - //feq[TSE] = c1o216*rho*(1.0+3.0*( vx1-vx2+vx3)+c9o2*( vx1-vx2+vx3)*( vx1-vx2+vx3)-cu_sq); - //feq[BNW] = c1o216*rho*(1.0+3.0*(-vx1+vx2-vx3)+c9o2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3)-cu_sq); - //feq[BSE] = c1o216*rho*(1.0+3.0*( vx1-vx2-vx3)+c9o2*( vx1-vx2-vx3)*( vx1-vx2-vx3)-cu_sq); - //feq[TNW] = c1o216*rho*(1.0+3.0*(-vx1+vx2+vx3)+c9o2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3)-cu_sq); - - ////////////////////////////////////////////////////////////////////////// - - LBMReal cu_sq = 1.5*(vx1*vx1+vx2*vx2+vx3*vx3); - LBMReal rho = drho+one; - - feq[ZERO] = c8o27*(drho+rho*(-cu_sq)); - feq[E] = c2o27*(drho+rho*(3.0*(vx1)+c9o2*(vx1)*(vx1)-cu_sq)); - feq[W] = c2o27*(drho+rho*(3.0*(-vx1)+c9o2*(-vx1)*(-vx1)-cu_sq)); - feq[N] = c2o27*(drho+rho*(3.0*(vx2)+c9o2*(vx2)*(vx2)-cu_sq)); - feq[S] = c2o27*(drho+rho*(3.0*(-vx2)+c9o2*(-vx2)*(-vx2)-cu_sq)); - feq[T] = c2o27*(drho+rho*(3.0*(vx3)+c9o2*(vx3)*(vx3)-cu_sq)); - feq[B] = c2o27*(drho+rho*(3.0*(-vx3)+c9o2*(-vx3)*(-vx3)-cu_sq)); - feq[NE] = c1o54*(drho+rho*(3.0*(vx1+vx2)+c9o2*(vx1+vx2)*(vx1+vx2)-cu_sq)); - feq[SW] = c1o54*(drho+rho*(3.0*(-vx1-vx2)+c9o2*(-vx1-vx2)*(-vx1-vx2)-cu_sq)); - feq[SE] = c1o54*(drho+rho*(3.0*(vx1-vx2)+c9o2*(vx1-vx2)*(vx1-vx2)-cu_sq)); - feq[NW] = c1o54*(drho+rho*(3.0*(-vx1+vx2)+c9o2*(-vx1+vx2)*(-vx1+vx2)-cu_sq)); - feq[TE] = c1o54*(drho+rho*(3.0*(vx1+vx3)+c9o2*(vx1+vx3)*(vx1+vx3)-cu_sq)); - feq[BW] = c1o54*(drho+rho*(3.0*(-vx1-vx3)+c9o2*(-vx1-vx3)*(-vx1-vx3)-cu_sq)); - feq[BE] = c1o54*(drho+rho*(3.0*(vx1-vx3)+c9o2*(vx1-vx3)*(vx1-vx3)-cu_sq)); - feq[TW] = c1o54*(drho+rho*(3.0*(-vx1+vx3)+c9o2*(-vx1+vx3)*(-vx1+vx3)-cu_sq)); - feq[TN] = c1o54*(drho+rho*(3.0*(vx2+vx3)+c9o2*(vx2+vx3)*(vx2+vx3)-cu_sq)); - feq[BS] = c1o54*(drho+rho*(3.0*(-vx2-vx3)+c9o2*(-vx2-vx3)*(-vx2-vx3)-cu_sq)); - feq[BN] = c1o54*(drho+rho*(3.0*(vx2-vx3)+c9o2*(vx2-vx3)*(vx2-vx3)-cu_sq)); - feq[TS] = c1o54*(drho+rho*(3.0*(-vx2+vx3)+c9o2*(-vx2+vx3)*(-vx2+vx3)-cu_sq)); - feq[TNE] = c1o216*(drho+rho*(3.0*(vx1+vx2+vx3)+c9o2*(vx1+vx2+vx3)*(vx1+vx2+vx3)-cu_sq)); - feq[BSW] = c1o216*(drho+rho*(3.0*(-vx1-vx2-vx3)+c9o2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3)-cu_sq)); - feq[BNE] = c1o216*(drho+rho*(3.0*(vx1+vx2-vx3)+c9o2*(vx1+vx2-vx3)*(vx1+vx2-vx3)-cu_sq)); - feq[TSW] = c1o216*(drho+rho*(3.0*(-vx1-vx2+vx3)+c9o2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3)-cu_sq)); - feq[TSE] = c1o216*(drho+rho*(3.0*(vx1-vx2+vx3)+c9o2*(vx1-vx2+vx3)*(vx1-vx2+vx3)-cu_sq)); - feq[BNW] = c1o216*(drho+rho*(3.0*(-vx1+vx2-vx3)+c9o2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3)-cu_sq)); - feq[BSE] = c1o216*(drho+rho*(3.0*(vx1-vx2-vx3)+c9o2*(vx1-vx2-vx3)*(vx1-vx2-vx3)-cu_sq)); - feq[TNW] = c1o216*(drho+rho*(3.0*(-vx1+vx2+vx3)+c9o2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3)-cu_sq)); - } - ////////////////////////////////////////////////////////////////////////// - static LBMReal getIncompFeqForDirection(const int& direction,const LBMReal& drho, const LBMReal& vx1,const LBMReal& vx2,const LBMReal& vx3) - { - LBMReal cu_sq=1.5f*(vx1*vx1+vx2*vx2+vx3*vx3); - - switch(direction) - { - case ZERO : return REAL_CAST( c8o27*(drho-cu_sq)); - case E : return REAL_CAST( c2o27*(drho+3.0*( vx1 )+c9o2*( vx1 )*( vx1 )-cu_sq)); - case W : return REAL_CAST( c2o27*(drho+3.0*(-vx1 )+c9o2*(-vx1 )*(-vx1 )-cu_sq)); - case N : return REAL_CAST( c2o27*(drho+3.0*( vx2)+c9o2*( vx2)*( vx2)-cu_sq)); - case S : return REAL_CAST( c2o27*(drho+3.0*( -vx2)+c9o2*( -vx2)*( -vx2)-cu_sq)); - case T : return REAL_CAST( c2o27*(drho+3.0*( vx3 )+c9o2*( vx3)*( vx3)-cu_sq)); - case B : return REAL_CAST( c2o27*(drho+3.0*( -vx3)+c9o2*( -vx3)*( -vx3)-cu_sq)); - case NE : return REAL_CAST( c1o54*(drho+3.0*( vx1+vx2)+c9o2*( vx1+vx2)*( vx1+vx2)-cu_sq)); - case SW : return REAL_CAST( c1o54*(drho+3.0*(-vx1-vx2)+c9o2*(-vx1-vx2)*(-vx1-vx2)-cu_sq)); - case SE : return REAL_CAST( c1o54*(drho+3.0*( vx1-vx2)+c9o2*( vx1-vx2)*( vx1-vx2)-cu_sq)); - case NW : return REAL_CAST( c1o54*(drho+3.0*(-vx1+vx2)+c9o2*(-vx1+vx2)*(-vx1+vx2)-cu_sq)); - case TE : return REAL_CAST( c1o54*(drho+3.0*( vx1+vx3)+c9o2*( vx1+vx3)*( vx1+vx3)-cu_sq)); - case BW : return REAL_CAST( c1o54*(drho+3.0*(-vx1-vx3)+c9o2*(-vx1-vx3)*(-vx1-vx3)-cu_sq)); - case BE : return REAL_CAST( c1o54*(drho+3.0*( vx1-vx3)+c9o2*( vx1-vx3)*( vx1-vx3)-cu_sq)); - case TW : return REAL_CAST( c1o54*(drho+3.0*(-vx1+vx3)+c9o2*(-vx1+vx3)*(-vx1+vx3)-cu_sq)); - case TN : return REAL_CAST( c1o54*(drho+3.0*( vx2+vx3)+c9o2*( vx2+vx3)*( vx2+vx3)-cu_sq)); - case BS : return REAL_CAST( c1o54*(drho+3.0*(-vx2-vx3)+c9o2*(-vx2-vx3)*(-vx2-vx3)-cu_sq)); - case BN : return REAL_CAST( c1o54*(drho+3.0*( vx2-vx3)+c9o2*( vx2-vx3)*( vx2-vx3)-cu_sq)); - case TS : return REAL_CAST( c1o54*(drho+3.0*(-vx2+vx3)+c9o2*(-vx2+vx3)*(-vx2+vx3)-cu_sq)); - case TNE : return REAL_CAST(c1o216*(drho+3.0*( vx1+vx2+vx3)+c9o2*( vx1+vx2+vx3)*( vx1+vx2+vx3)-cu_sq)); - case BSW : return REAL_CAST(c1o216*(drho+3.0*(-vx1-vx2-vx3)+c9o2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3)-cu_sq)); - case BNE : return REAL_CAST(c1o216*(drho+3.0*( vx1+vx2-vx3)+c9o2*( vx1+vx2-vx3)*( vx1+vx2-vx3)-cu_sq)); - case TSW : return REAL_CAST(c1o216*(drho+3.0*(-vx1-vx2+vx3)+c9o2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3)-cu_sq)); - case TSE : return REAL_CAST(c1o216*(drho+3.0*( vx1-vx2+vx3)+c9o2*( vx1-vx2+vx3)*( vx1-vx2+vx3)-cu_sq)); - case BNW : return REAL_CAST(c1o216*(drho+3.0*(-vx1+vx2-vx3)+c9o2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3)-cu_sq)); - case BSE : return REAL_CAST(c1o216*(drho+3.0*( vx1-vx2-vx3)+c9o2*( vx1-vx2-vx3)*( vx1-vx2-vx3)-cu_sq)); - case TNW : return REAL_CAST(c1o216*(drho+3.0*(-vx1+vx2+vx3)+c9o2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3)-cu_sq)); - default: throw UbException(UB_EXARGS,"unknown dir"); - } - } - ////////////////////////////////////////////////////////////////////////// - static void calcIncompFeq(LBMReal* const& feq/*[27]*/,const LBMReal& drho,const LBMReal& vx1,const LBMReal& vx2,const LBMReal& vx3) - { - LBMReal cu_sq=1.5*(vx1*vx1+vx2*vx2+vx3*vx3); - - feq[ZERO] = c8o27*(drho-cu_sq); - feq[E] = c2o27*(drho+3.0*( vx1 )+c9o2*( vx1 )*( vx1 )-cu_sq); - feq[W] = c2o27*(drho+3.0*(-vx1 )+c9o2*(-vx1 )*(-vx1 )-cu_sq); - feq[N] = c2o27*(drho+3.0*( vx2)+c9o2*( vx2)*( vx2)-cu_sq); - feq[S] = c2o27*(drho+3.0*( -vx2)+c9o2*( -vx2)*( -vx2)-cu_sq); - feq[T] = c2o27*(drho+3.0*( vx3 )+c9o2*( vx3)*( vx3)-cu_sq); - feq[B] = c2o27*(drho+3.0*( -vx3)+c9o2*( -vx3)*( -vx3)-cu_sq); - feq[NE] = c1o54*(drho+3.0*( vx1+vx2)+c9o2*( vx1+vx2)*( vx1+vx2)-cu_sq); - feq[SW] = c1o54*(drho+3.0*(-vx1-vx2)+c9o2*(-vx1-vx2)*(-vx1-vx2)-cu_sq); - feq[SE] = c1o54*(drho+3.0*( vx1-vx2)+c9o2*( vx1-vx2)*( vx1-vx2)-cu_sq); - feq[NW] = c1o54*(drho+3.0*(-vx1+vx2)+c9o2*(-vx1+vx2)*(-vx1+vx2)-cu_sq); - feq[TE] = c1o54*(drho+3.0*( vx1+vx3)+c9o2*( vx1+vx3)*( vx1+vx3)-cu_sq); - feq[BW] = c1o54*(drho+3.0*(-vx1-vx3)+c9o2*(-vx1-vx3)*(-vx1-vx3)-cu_sq); - feq[BE] = c1o54*(drho+3.0*( vx1-vx3)+c9o2*( vx1-vx3)*( vx1-vx3)-cu_sq); - feq[TW] = c1o54*(drho+3.0*(-vx1+vx3)+c9o2*(-vx1+vx3)*(-vx1+vx3)-cu_sq); - feq[TN] = c1o54*(drho+3.0*( vx2+vx3)+c9o2*( vx2+vx3)*( vx2+vx3)-cu_sq); - feq[BS] = c1o54*(drho+3.0*(-vx2-vx3)+c9o2*(-vx2-vx3)*(-vx2-vx3)-cu_sq); - feq[BN] = c1o54*(drho+3.0*( vx2-vx3)+c9o2*( vx2-vx3)*( vx2-vx3)-cu_sq); - feq[TS] = c1o54*(drho+3.0*(-vx2+vx3)+c9o2*(-vx2+vx3)*(-vx2+vx3)-cu_sq); - feq[TNE] = c1o216*(drho+3.0*( vx1+vx2+vx3)+c9o2*( vx1+vx2+vx3)*( vx1+vx2+vx3)-cu_sq); - feq[BSW] = c1o216*(drho+3.0*(-vx1-vx2-vx3)+c9o2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3)-cu_sq); - feq[BNE] = c1o216*(drho+3.0*( vx1+vx2-vx3)+c9o2*( vx1+vx2-vx3)*( vx1+vx2-vx3)-cu_sq); - feq[TSW] = c1o216*(drho+3.0*(-vx1-vx2+vx3)+c9o2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3)-cu_sq); - feq[TSE] = c1o216*(drho+3.0*( vx1-vx2+vx3)+c9o2*( vx1-vx2+vx3)*( vx1-vx2+vx3)-cu_sq); - feq[BNW] = c1o216*(drho+3.0*(-vx1+vx2-vx3)+c9o2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3)-cu_sq); - feq[BSE] = c1o216*(drho+3.0*( vx1-vx2-vx3)+c9o2*( vx1-vx2-vx3)*( vx1-vx2-vx3)-cu_sq); - feq[TNW] = c1o216*(drho+3.0*(-vx1+vx2+vx3)+c9o2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3)-cu_sq); - } - ////////////////////////////////////////////////////////////////////////// - static inline float getBoundaryVelocityForDirection(const int& direction, const float& bcVelocityX1,const float& bcVelocityX2,const float& bcVelocityX3) - { - switch(direction) - { - case E: return (float)( UbMath::c4o9*(+bcVelocityX1) ); - case W: return (float)( UbMath::c4o9*(-bcVelocityX1) ); - case N: return (float)( UbMath::c4o9*(+bcVelocityX2) ); - case S: return (float)( UbMath::c4o9*(-bcVelocityX2) ); - case T: return (float)( UbMath::c4o9*(+bcVelocityX3) ); - case B: return (float)( UbMath::c4o9*(-bcVelocityX3) ); - case NE: return (float)( UbMath::c1o9*(+bcVelocityX1+bcVelocityX2 ) ); - case SW: return (float)( UbMath::c1o9*(-bcVelocityX1-bcVelocityX2 ) ); - case SE: return (float)( UbMath::c1o9*(+bcVelocityX1-bcVelocityX2 ) ); - case NW: return (float)( UbMath::c1o9*(-bcVelocityX1+bcVelocityX2 ) ); - case TE: return (float)( UbMath::c1o9*(+bcVelocityX1 +bcVelocityX3) ); - case BW: return (float)( UbMath::c1o9*(-bcVelocityX1 -bcVelocityX3) ); - case BE: return (float)( UbMath::c1o9*(+bcVelocityX1 -bcVelocityX3) ); - case TW: return (float)( UbMath::c1o9*(-bcVelocityX1 +bcVelocityX3) ); - case TN: return (float)( UbMath::c1o9*( +bcVelocityX2+bcVelocityX3) ); - case BS: return (float)( UbMath::c1o9*( -bcVelocityX2-bcVelocityX3) ); - case BN: return (float)( UbMath::c1o9*( +bcVelocityX2-bcVelocityX3) ); - case TS: return (float)( UbMath::c1o9*( -bcVelocityX2+bcVelocityX3) ); - case TNE: return (float)( UbMath::c1o36*(+bcVelocityX1+bcVelocityX2+bcVelocityX3) ); - case BSW: return (float)( UbMath::c1o36*(-bcVelocityX1-bcVelocityX2-bcVelocityX3) ); - case BNE: return (float)( UbMath::c1o36*(+bcVelocityX1+bcVelocityX2-bcVelocityX3) ); - case TSW: return (float)( UbMath::c1o36*(-bcVelocityX1-bcVelocityX2+bcVelocityX3) ); - case TSE: return (float)( UbMath::c1o36*(+bcVelocityX1-bcVelocityX2+bcVelocityX3) ); - case BNW: return (float)( UbMath::c1o36*(-bcVelocityX1+bcVelocityX2-bcVelocityX3) ); - case BSE: return (float)( UbMath::c1o36*(+bcVelocityX1-bcVelocityX2-bcVelocityX3) ); - case TNW: return (float)( UbMath::c1o36*(-bcVelocityX1+bcVelocityX2+bcVelocityX3) ); - default: throw UbException(UB_EXARGS,"unknown direction"); - } - } - /*=====================================================================*/ - static const int& getInvertDirection(const int& direction) - { - #ifdef _DEBUG - if(direction<STARTDIR || direction>ENDDIR) - throw UbException(UB_EXARGS,"unknown direction"); - #endif - return INVDIR[direction]; - } - /*=====================================================================*/ - static void getLBMDirections(std::vector<int>& dirs, bool onlyLBdirs = false) - { - std::vector<int> D3Q27Dirs; - if(onlyLBdirs) /*FSTARTDIR->FENDDIR*/ - { - dirs.resize(FENDDIR+1); - for(int dir=FSTARTDIR; dir<=FENDDIR; ++dir) - dirs[dir] = dir; - } - else /*STARTDIR->ENDDIR*/ - { - dirs.resize(ENDDIR+1); - for(int dir=STARTDIR; dir<=ENDDIR; ++dir) - dirs[dir] = dir; - } - } -////////////////////////////////////////////////////////////////////////// - static std::vector<int> getEX(const int& exn) - { - std::vector<int> ex; - ex.resize(ENDDIR+1); - switch (exn) - { - case 1: - for(int dir=STARTDIR; dir<ENDDIR; ++dir) - ex[dir] = DX1[dir]; - break; - case 2: - for(int dir=STARTDIR; dir<ENDDIR; ++dir) - ex[dir] = DX2[dir]; - break; - case 3: - for(int dir=STARTDIR; dir<ENDDIR; ++dir) - ex[dir] = DX3[dir]; - break; - } - return ex; - } -////////////////////////////////////////////////////////////////////////// - static inline void calcDistanceToNeighbors(std::vector<double>& distNeigh, const double& deltaX1) - { - //distNeigh.resize(FENDDIR+1, UbMath::sqrt2*deltaX1); - double sqrt3 = UbMath::sqrt3; - double sqrt2 = UbMath::sqrt2; - distNeigh[E] = distNeigh[W] = distNeigh[N] = deltaX1; - distNeigh[S] = distNeigh[T] = distNeigh[B] = deltaX1; - distNeigh[NE] = distNeigh[NW] = distNeigh[SW] = distNeigh[SE] = sqrt2*deltaX1; - distNeigh[TE] = distNeigh[TN] = distNeigh[TW] = distNeigh[TS] = sqrt2*deltaX1; - distNeigh[BE] = distNeigh[BN] = distNeigh[BW] = distNeigh[BS] = sqrt2*deltaX1; - distNeigh[TNE] = distNeigh[TNW] = distNeigh[TSE] = distNeigh[TSW] = sqrt3*deltaX1; - distNeigh[BNE] = distNeigh[BNW] = distNeigh[BSE] = distNeigh[BSW] = sqrt3*deltaX1; - } -////////////////////////////////////////////////////////////////////////// - static inline void calcDistanceToNeighbors(std::vector<double>& distNeigh, const double& deltaX1,const double& deltaX2,const double& deltaX3) - { - //distNeigh.resize(FENDDIR+1, UbMath::sqrt2*deltaX1); - double sqrt3 = UbMath::sqrt3; - double sqrt2 = UbMath::sqrt2; - distNeigh[E] = distNeigh[W] = deltaX1; - distNeigh[N] = distNeigh[S] = deltaX2; - distNeigh[T] = distNeigh[B] = deltaX3; - distNeigh[NE] = distNeigh[NW] = distNeigh[SW] = distNeigh[SE] = sqrt(deltaX1*deltaX1+deltaX2*deltaX2); - distNeigh[TE] = distNeigh[TN] = distNeigh[TW] = distNeigh[TS] = sqrt(deltaX1*deltaX1+deltaX3*deltaX3); - distNeigh[BE] = distNeigh[BN] = distNeigh[BW] = distNeigh[BS] = sqrt(deltaX2*deltaX2+deltaX3*deltaX3); - distNeigh[TNE] = distNeigh[TNW] = distNeigh[TSE] = distNeigh[TSW] = sqrt(deltaX1*deltaX1+deltaX2*deltaX2+deltaX3*deltaX3); - distNeigh[BNE] = distNeigh[BNW] = distNeigh[BSE] = distNeigh[BSW] = sqrt(deltaX1*deltaX1+deltaX2*deltaX2+deltaX3*deltaX3); - } -////////////////////////////////////////////////////////////////////////// - static inline void initRayVectors(double* const& rayX1, double* const& rayX2, double* const& rayX3) - { - int fdir; - double c1oS2 = UbMath::one_over_sqrt2; - double c1oS3 = UbMath::one_over_sqrt3; - fdir = E; rayX1[fdir] = 1.0; rayX2[fdir] = 0.0; rayX3[fdir] = 0.0; - fdir = W; rayX1[fdir] = -1.0; rayX2[fdir] = 0.0; rayX3[fdir] = 0.0; - fdir = N; rayX1[fdir] = 0.0; rayX2[fdir] = 1.0; rayX3[fdir] = 0.0; - fdir = S; rayX1[fdir] = 0.0; rayX2[fdir] = -1.0; rayX3[fdir] = 0.0; - fdir = T; rayX1[fdir] = 0.0; rayX2[fdir] = 0.0; rayX3[fdir] = 1.0; - fdir = B; rayX1[fdir] = 0.0; rayX2[fdir] = 0.0; rayX3[fdir] = -1.0; - fdir = NE; rayX1[fdir] = c1oS2; rayX2[fdir] = c1oS2; rayX3[fdir] = 0.0; - fdir = SW; rayX1[fdir] = -c1oS2; rayX2[fdir] = -c1oS2; rayX3[fdir] = 0.0; - fdir = SE; rayX1[fdir] = c1oS2; rayX2[fdir] = -c1oS2; rayX3[fdir] = 0.0; - fdir = NW; rayX1[fdir] = -c1oS2; rayX2[fdir] = c1oS2; rayX3[fdir] = 0.0; - fdir = TE; rayX1[fdir] = c1oS2; rayX2[fdir] = 0.0; rayX3[fdir] = c1oS2; - fdir = BW; rayX1[fdir] = -c1oS2; rayX2[fdir] = 0.0; rayX3[fdir] = -c1oS2; - fdir = BE; rayX1[fdir] = c1oS2; rayX2[fdir] = 0.0; rayX3[fdir] = -c1oS2; - fdir = TW; rayX1[fdir] = -c1oS2; rayX2[fdir] = 0.0; rayX3[fdir] = c1oS2; - fdir = TN; rayX1[fdir] = 0.0; rayX2[fdir] = c1oS2; rayX3[fdir] = c1oS2; - fdir = BS; rayX1[fdir] = 0.0; rayX2[fdir] =-c1oS2; rayX3[fdir] = -c1oS2; - fdir = BN; rayX1[fdir] = 0.0; rayX2[fdir] = c1oS2; rayX3[fdir] = -c1oS2; - fdir = TS; rayX1[fdir] = 0.0; rayX2[fdir] =-c1oS2; rayX3[fdir] = c1oS2; - fdir = TNE; rayX1[fdir] = c1oS3; rayX2[fdir] = c1oS3; rayX3[fdir] = c1oS3; - fdir = TNW; rayX1[fdir] = -c1oS3; rayX2[fdir] = c1oS3; rayX3[fdir] = c1oS3; - fdir = TSE; rayX1[fdir] = c1oS3; rayX2[fdir] = -c1oS3; rayX3[fdir] = c1oS3; - fdir = TSW; rayX1[fdir] = -c1oS3; rayX2[fdir] = -c1oS3; rayX3[fdir] = c1oS3; - fdir = BNE; rayX1[fdir] = c1oS3; rayX2[fdir] = c1oS3; rayX3[fdir] = -c1oS3; - fdir = BNW; rayX1[fdir] = -c1oS3; rayX2[fdir] = c1oS3; rayX3[fdir] = -c1oS3; - fdir = BSE; rayX1[fdir] = c1oS3; rayX2[fdir] = -c1oS3; rayX3[fdir] = -c1oS3; - fdir = BSW; rayX1[fdir] = -c1oS3; rayX2[fdir] = -c1oS3; rayX3[fdir] = -c1oS3; - } -////////////////////////////////////////////////////////////////////////// - static inline LBMReal calcPress(const LBMReal* const f, LBMReal rho, LBMReal vx1, LBMReal vx2, LBMReal vx3) - { - LBMReal op=1.0; - return ((f[E]+f[W]+f[N]+f[S]+f[T]+f[B]+2.*(f[NE]+f[SW]+f[SE]+f[NW]+f[TE]+f[BW]+f[BE]+f[TW]+f[TN]+f[BS]+f[BN]+f[TS])+ - 3.*(f[TNE]+f[TSW]+f[TSE]+f[TNW]+f[BNE]+f[BSW]+f[BSE]+f[BNW])-(vx1*vx1+vx2*vx2+vx3*vx3))*(1-0.5*op)+op*0.5*(rho))*c1o3; - - } -} - -#endif - - - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file D3Q27System.h +//! \ingroup LBM +//! \author Konstantin Kutscher, Sebastian Geller, Sören Freudiger +//======================================================================================= + +#ifndef D3Q27SYSTEM_H +#define D3Q27SYSTEM_H + +#include <cmath> +#include <string> +#include <iostream> + +#include "UbException.h" +#include "UbMath.h" +#include "LBMSystem.h" + +//! \brief namespace for global system-functions +namespace D3Q27System +{ + ////////////////////////////////////////////////////////////////////////// + //DIRECTION STUFF + static const int FSTARTDIR = 0; + static const int FENDDIR = 25; //D3Q27 + + static const int STARTF = 0; + static const int ENDF = 26; //D3Q27 + + static const int STARTDIR = 0; + static const int ENDDIR = 26; //all geometric directions + + extern const int DX1[ENDDIR+1]; + extern const int DX2[ENDDIR+1]; + extern const int DX3[ENDDIR+1]; + extern const double WEIGTH[ENDDIR+1]; + + extern const double cNorm[3][ENDDIR]; + + static const int E = 0; + static const int W = 1; + static const int N = 2; + static const int S = 3; + static const int T = 4; + static const int B = 5; + static const int NE = 6; + static const int SW = 7; + static const int SE = 8; + static const int NW = 9; + static const int TE = 10; + static const int BW = 11; + static const int BE = 12; + static const int TW = 13; + static const int TN = 14; + static const int BS = 15; + static const int BN = 16; + static const int TS = 17; + static const int TNE = 18; + static const int TNW = 19; + static const int TSE = 20; + static const int TSW = 21; + static const int BNE = 22; + static const int BNW = 23; + static const int BSE = 24; + static const int BSW = 25; + static const int REST = 26; + + static const int INV_E = W; + static const int INV_W = E; + static const int INV_N = S; + static const int INV_S = N; + static const int INV_T = B; + static const int INV_B = T; + static const int INV_NE = SW; + static const int INV_SW = NE; + static const int INV_SE = NW; + static const int INV_NW = SE; + static const int INV_TE = BW; + static const int INV_BW = TE; + static const int INV_BE = TW; + static const int INV_TW = BE; + static const int INV_TN = BS; + static const int INV_BS = TN; + static const int INV_BN = TS; + static const int INV_TS = BN; + static const int INV_TNE = BSW; + static const int INV_TNW = BSE; + static const int INV_TSE = BNW; + static const int INV_TSW = BNE; + static const int INV_BNE = TSW; + static const int INV_BNW = TSE; + static const int INV_BSE = TNW; + static const int INV_BSW = TNE; + + extern const int INVDIR[ENDDIR+1]; + + static const int ET_E = 0; + static const int ET_W = 0; + static const int ET_N = 1; + static const int ET_S = 1; + static const int ET_T = 2; + static const int ET_B = 2; + static const int ET_NE = 3; + static const int ET_SW = 3; + static const int ET_SE = 4; + static const int ET_NW = 4; + static const int ET_TE = 5; + static const int ET_BW = 5; + static const int ET_BE = 6; + static const int ET_TW = 6; + static const int ET_TN = 7; + static const int ET_BS = 7; + static const int ET_BN = 8; + static const int ET_TS = 8; + static const int ET_TNE = 9; + static const int ET_BSW = 9; + static const int ET_TNW = 10; + static const int ET_BSE = 10; + static const int ET_TSE = 11; + static const int ET_BNW = 11; + static const int ET_TSW = 12; + static const int ET_BNE = 12; + + + ////////////////////////////////////////////////////////////////////////// + //MACROSCOPIC VALUES + /*=====================================================================*/ + static LBMReal getDensity(const LBMReal* const& f/*[27]*/) + { + return ((f[TNE] + f[BSW])+(f[TSE]+f[BNW]))+((f[BSE]+f[TNW])+ (f[TSW]+f[BNE])) + +(((f[NE] + f[SW]) + (f[SE] + f[NW]))+((f[TE] + f[BW])+(f[BE]+ f[TW])) + +((f[BN] + f[TS]) + (f[TN] + f[BS])))+((f[E] + f[W])+(f[N] + f[S]) + +(f[T] + f[B]))+f[REST]; + } + /*=====================================================================*/ + //ATTENTION: does not apply to all models -> use certificate instead of static! to do + static LBMReal getPressure(const LBMReal* const& f/*[27]*/) + { + return REAL_CAST( UbMath::c1o3 )*getDensity(f); + } + /*=====================================================================*/ + static LBMReal getIncompVelocityX1(const LBMReal* const& f/*[27]*/) + { + return ((((f[TNE]-f[BSW]) + (f[TSE]-f[BNW])) + ((f[BSE]-f[TNW]) + (f[BNE]-f[TSW]))) + + (((f[BE]-f[TW]) + (f[TE]-f[BW])) + ((f[SE]-f[NW]) + (f[NE]-f[SW]))) + + (f[E]-f[W])); + } + /*=====================================================================*/ + static LBMReal getIncompVelocityX2(const LBMReal* const& f/*[27]*/) + { + return ((((f[TNE]-f[BSW]) + (f[BNW]-f[TSE])) + ((f[TNW]-f[BSE]) + (f[BNE]-f[TSW]))) + + (((f[BN]-f[TS]) + (f[TN]-f[BS])) + ((f[NW]-f[SE]) + (f[NE]-f[SW]))) + + (f[N]-f[S])); + } + /*=====================================================================*/ + static LBMReal getIncompVelocityX3(const LBMReal* const& f/*[27]*/) + { + return ((((f[TNE] - f[BSW]) + (f[TSE] - f[BNW])) + ((f[TNW] - f[BSE]) + (f[TSW] - f[BNE]))) + + (((f[TS] - f[BN]) + (f[TN] - f[BS])) + ((f[TW] - f[BE]) + (f[TE] - f[BW]))) + + (f[T] - f[B])); + } + /*=====================================================================*/ + static void calcDensity(const LBMReal* const& f/*[27]*/, LBMReal& rho) + { + rho = ((f[TNE] + f[BSW])+(f[TSE]+f[BNW]))+((f[BSE]+f[TNW])+ (f[TSW]+f[BNE])) + +(((f[NE] + f[SW]) + (f[SE] + f[NW]))+((f[TE] + f[BW])+(f[BE]+ f[TW])) + +((f[BN] + f[TS]) + (f[TN] + f[BS])))+((f[E] + f[W])+(f[N] + f[S]) + +(f[T] + f[B]))+f[REST]; + + } + /*=====================================================================*/ + static void calcIncompVelocityX1(const LBMReal* const& f/*[27]*/, LBMReal& vx1) + { + vx1 = ((((f[TNE]-f[BSW]) + (f[TSE]-f[BNW])) + ((f[BSE]-f[TNW]) + (f[BNE]-f[TSW]))) + + (((f[BE]-f[TW]) + (f[TE]-f[BW])) + ((f[SE]-f[NW]) + (f[NE]-f[SW]))) + + (f[E]-f[W])); + } + /*=====================================================================*/ + static void calcIncompVelocityX2(const LBMReal* const& f/*[27]*/, LBMReal& vx2) + { + vx2 = ((((f[TNE]-f[BSW]) + (f[BNW]-f[TSE])) + ((f[TNW]-f[BSE]) + (f[BNE]-f[TSW]))) + + (((f[BN]-f[TS]) + (f[TN]-f[BS])) + ((f[NW]-f[SE]) + (f[NE]-f[SW]))) + + (f[N]-f[S])); + } + /*=====================================================================*/ + static void calcIncompVelocityX3(const LBMReal* const& f/*[27]*/, LBMReal& vx3) + { + vx3 =((((f[TNE]-f[BSW]) + (f[TSE]-f[BNW])) + ((f[TNW]-f[BSE]) + (f[TSW]-f[BNE]))) + + (((f[TS]-f[BN]) + (f[TN]-f[BS])) + ((f[TW]-f[BE]) + (f[TE]-f[BW]))) + + (f[T]-f[B])); + } + /*=====================================================================*/ + static LBMReal getCompVelocityX1(const LBMReal* const& f/*[27]*/) + { + return ((((f[TNE]-f[BSW]) + (f[TSE]-f[BNW])) + ((f[BSE]-f[TNW]) + (f[BNE]-f[TSW]))) + + (((f[BE]-f[TW]) + (f[TE]-f[BW])) + ((f[SE]-f[NW]) + (f[NE]-f[SW]))) + + (f[E]-f[W]))/getDensity(f); + } + /*=====================================================================*/ + static LBMReal getCompVelocityX2(const LBMReal* const& f/*[27]*/) + { + return ((((f[TNE]-f[BSW]) + (f[BNW]-f[TSE])) + ((f[TNW]-f[BSE]) + (f[BNE]-f[TSW]))) + + (((f[BN]-f[TS]) + (f[TN]-f[BS])) + ((f[NW]-f[SE]) + (f[NE]-f[SW]))) + + (f[N]-f[S]))/getDensity(f); + } + /*=====================================================================*/ + static LBMReal getCompVelocityX3(const LBMReal* const& f/*[27]*/) + { + return ((((f[TNE]-f[BSW]) + (f[TSE]-f[BNW])) + ((f[TNW]-f[BSE]) + (f[TSW]-f[BNE]))) + + (((f[TS]-f[BN]) + (f[TN]-f[BS])) + ((f[TW]-f[BE]) + (f[TE]-f[BW]))) + + (f[T]-f[B]))/getDensity(f); + } + /*=====================================================================*/ + static void calcCompVelocityX1(const LBMReal* const& f/*[27]*/, LBMReal& vx1) + { + vx1 = ((((f[TNE]-f[BSW]) + (f[TSE]-f[BNW])) + ((f[BSE]-f[TNW]) + (f[BNE]-f[TSW]))) + + (((f[BE]-f[TW]) + (f[TE]-f[BW])) + ((f[SE]-f[NW]) + (f[NE]-f[SW]))) + + (f[E]-f[W]))/getDensity(f); + } + /*=====================================================================*/ + static void calcCompVelocityX2(const LBMReal* const& f/*[27]*/, LBMReal& vx2) + { + vx2 = ((((f[TNE]-f[BSW]) + (f[BNW]-f[TSE])) + ((f[TNW]-f[BSE]) + (f[BNE]-f[TSW]))) + + (((f[BN]-f[TS]) + (f[TN]-f[BS])) + ((f[NW]-f[SE]) + (f[NE]-f[SW]))) + + (f[N]-f[S]))/getDensity(f); + } + /*=====================================================================*/ + static void calcCompVelocityX3(const LBMReal* const& f/*[27]*/, LBMReal& vx3) + { + vx3 = ((((f[TNE]-f[BSW]) + (f[TSE]-f[BNW])) + ((f[TNW]-f[BSE]) + (f[TSW]-f[BNE]))) + + (((f[TS]-f[BN]) + (f[TN]-f[BS])) + ((f[TW]-f[BE]) + (f[TE]-f[BW]))) + + (f[T]-f[B]))/getDensity(f); + } + /*=====================================================================*/ + static void calcIncompMacroscopicValues(const LBMReal* const& f/*[27]*/, LBMReal& rho, LBMReal& vx1, LBMReal& vx2, LBMReal& vx3) + { + D3Q27System::calcDensity(f, rho); + D3Q27System::calcIncompVelocityX1(f, vx1); + D3Q27System::calcIncompVelocityX2(f, vx2); + D3Q27System::calcIncompVelocityX3(f, vx3); + } + + /*=====================================================================*/ + static void calcCompMacroscopicValues(const LBMReal* const& f/*[27]*/, LBMReal& drho, LBMReal& vx1, LBMReal& vx2, LBMReal& vx3) + { + D3Q27System::calcDensity(f, drho); + D3Q27System::calcIncompVelocityX1(f, vx1); + D3Q27System::calcIncompVelocityX2(f, vx2); + D3Q27System::calcIncompVelocityX3(f, vx3); + LBMReal rho = drho+UbMath::c1; + vx1/=rho; + vx2/=rho; + vx3/=rho; + } + ////////////////////////////////////////////////////////////////////////// + static LBMReal getCompFeqForDirection(const int& direction, const LBMReal& drho,const LBMReal& vx1,const LBMReal& vx2,const LBMReal& vx3) + { + using namespace UbMath; + + LBMReal cu_sq=1.5*(vx1*vx1+vx2*vx2+vx3*vx3); + + ////----- + LBMReal rho = drho+c1; + switch (direction) + { + case REST: return REAL_CAST(c8o27*(drho+rho*(-cu_sq))); + case E: return REAL_CAST(c2o27*(drho+rho*(3.0*(vx1)+c9o2*(vx1)*(vx1)-cu_sq))); + case W: return REAL_CAST(c2o27*(drho+rho*(3.0*(-vx1)+c9o2*(-vx1)*(-vx1)-cu_sq))); + case N: return REAL_CAST(c2o27*(drho+rho*(3.0*(vx2)+c9o2*(vx2)*(vx2)-cu_sq))); + case S: return REAL_CAST(c2o27*(drho+rho*(3.0*(-vx2)+c9o2*(-vx2)*(-vx2)-cu_sq))); + case T: return REAL_CAST(c2o27*(drho+rho*(3.0*(vx3)+c9o2*(vx3)*(vx3)-cu_sq))); + case B: return REAL_CAST(c2o27*(drho+rho*(3.0*(-vx3)+c9o2*(-vx3)*(-vx3)-cu_sq))); + case NE: return REAL_CAST(c1o54*(drho+rho*(3.0*(vx1+vx2)+c9o2*(vx1+vx2)*(vx1+vx2)-cu_sq))); + case SW: return REAL_CAST(c1o54*(drho+rho*(3.0*(-vx1-vx2)+c9o2*(-vx1-vx2)*(-vx1-vx2)-cu_sq))); + case SE: return REAL_CAST(c1o54*(drho+rho*(3.0*(vx1-vx2)+c9o2*(vx1-vx2)*(vx1-vx2)-cu_sq))); + case NW: return REAL_CAST(c1o54*(drho+rho*(3.0*(-vx1+vx2)+c9o2*(-vx1+vx2)*(-vx1+vx2)-cu_sq))); + case TE: return REAL_CAST(c1o54*(drho+rho*(3.0*(vx1+vx3)+c9o2*(vx1+vx3)*(vx1+vx3)-cu_sq))); + case BW: return REAL_CAST(c1o54*(drho+rho*(3.0*(-vx1-vx3)+c9o2*(-vx1-vx3)*(-vx1-vx3)-cu_sq))); + case BE: return REAL_CAST(c1o54*(drho+rho*(3.0*(vx1-vx3)+c9o2*(vx1-vx3)*(vx1-vx3)-cu_sq))); + case TW: return REAL_CAST(c1o54*(drho+rho*(3.0*(-vx1+vx3)+c9o2*(-vx1+vx3)*(-vx1+vx3)-cu_sq))); + case TN: return REAL_CAST(c1o54*(drho+rho*(3.0*(vx2+vx3)+c9o2*(vx2+vx3)*(vx2+vx3)-cu_sq))); + case BS: return REAL_CAST(c1o54*(drho+rho*(3.0*(-vx2-vx3)+c9o2*(-vx2-vx3)*(-vx2-vx3)-cu_sq))); + case BN: return REAL_CAST(c1o54*(drho+rho*(3.0*(vx2-vx3)+c9o2*(vx2-vx3)*(vx2-vx3)-cu_sq))); + case TS: return REAL_CAST(c1o54*(drho+rho*(3.0*(-vx2+vx3)+c9o2*(-vx2+vx3)*(-vx2+vx3)-cu_sq))); + case TNE: return REAL_CAST(c1o216*(drho+rho*(3.0*(vx1+vx2+vx3)+c9o2*(vx1+vx2+vx3)*(vx1+vx2+vx3)-cu_sq))); + case BSW: return REAL_CAST(c1o216*(drho+rho*(3.0*(-vx1-vx2-vx3)+c9o2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3)-cu_sq))); + case BNE: return REAL_CAST(c1o216*(drho+rho*(3.0*(vx1+vx2-vx3)+c9o2*(vx1+vx2-vx3)*(vx1+vx2-vx3)-cu_sq))); + case TSW: return REAL_CAST(c1o216*(drho+rho*(3.0*(-vx1-vx2+vx3)+c9o2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3)-cu_sq))); + case TSE: return REAL_CAST(c1o216*(drho+rho*(3.0*(vx1-vx2+vx3)+c9o2*(vx1-vx2+vx3)*(vx1-vx2+vx3)-cu_sq))); + case BNW: return REAL_CAST(c1o216*(drho+rho*(3.0*(-vx1+vx2-vx3)+c9o2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3)-cu_sq))); + case BSE: return REAL_CAST(c1o216*(drho+rho*(3.0*(vx1-vx2-vx3)+c9o2*(vx1-vx2-vx3)*(vx1-vx2-vx3)-cu_sq))); + case TNW: return REAL_CAST(c1o216*(drho+rho*(3.0*(-vx1+vx2+vx3)+c9o2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3)-cu_sq))); + default: throw UbException(UB_EXARGS, "unknown dir"); + } + + } + ////////////////////////////////////////////////////////////////////////// + static void calcCompFeq(LBMReal* const& feq/*[27]*/,const LBMReal& drho,const LBMReal& vx1,const LBMReal& vx2,const LBMReal& vx3) + { + using namespace UbMath; + + LBMReal cu_sq = 1.5*(vx1*vx1+vx2*vx2+vx3*vx3); + LBMReal rho = drho+c1; + + feq[REST] = c8o27*(drho+rho*(-cu_sq)); + feq[E] = c2o27*(drho+rho*(3.0*(vx1)+c9o2*(vx1)*(vx1)-cu_sq)); + feq[W] = c2o27*(drho+rho*(3.0*(-vx1)+c9o2*(-vx1)*(-vx1)-cu_sq)); + feq[N] = c2o27*(drho+rho*(3.0*(vx2)+c9o2*(vx2)*(vx2)-cu_sq)); + feq[S] = c2o27*(drho+rho*(3.0*(-vx2)+c9o2*(-vx2)*(-vx2)-cu_sq)); + feq[T] = c2o27*(drho+rho*(3.0*(vx3)+c9o2*(vx3)*(vx3)-cu_sq)); + feq[B] = c2o27*(drho+rho*(3.0*(-vx3)+c9o2*(-vx3)*(-vx3)-cu_sq)); + feq[NE] = c1o54*(drho+rho*(3.0*(vx1+vx2)+c9o2*(vx1+vx2)*(vx1+vx2)-cu_sq)); + feq[SW] = c1o54*(drho+rho*(3.0*(-vx1-vx2)+c9o2*(-vx1-vx2)*(-vx1-vx2)-cu_sq)); + feq[SE] = c1o54*(drho+rho*(3.0*(vx1-vx2)+c9o2*(vx1-vx2)*(vx1-vx2)-cu_sq)); + feq[NW] = c1o54*(drho+rho*(3.0*(-vx1+vx2)+c9o2*(-vx1+vx2)*(-vx1+vx2)-cu_sq)); + feq[TE] = c1o54*(drho+rho*(3.0*(vx1+vx3)+c9o2*(vx1+vx3)*(vx1+vx3)-cu_sq)); + feq[BW] = c1o54*(drho+rho*(3.0*(-vx1-vx3)+c9o2*(-vx1-vx3)*(-vx1-vx3)-cu_sq)); + feq[BE] = c1o54*(drho+rho*(3.0*(vx1-vx3)+c9o2*(vx1-vx3)*(vx1-vx3)-cu_sq)); + feq[TW] = c1o54*(drho+rho*(3.0*(-vx1+vx3)+c9o2*(-vx1+vx3)*(-vx1+vx3)-cu_sq)); + feq[TN] = c1o54*(drho+rho*(3.0*(vx2+vx3)+c9o2*(vx2+vx3)*(vx2+vx3)-cu_sq)); + feq[BS] = c1o54*(drho+rho*(3.0*(-vx2-vx3)+c9o2*(-vx2-vx3)*(-vx2-vx3)-cu_sq)); + feq[BN] = c1o54*(drho+rho*(3.0*(vx2-vx3)+c9o2*(vx2-vx3)*(vx2-vx3)-cu_sq)); + feq[TS] = c1o54*(drho+rho*(3.0*(-vx2+vx3)+c9o2*(-vx2+vx3)*(-vx2+vx3)-cu_sq)); + feq[TNE] = c1o216*(drho+rho*(3.0*(vx1+vx2+vx3)+c9o2*(vx1+vx2+vx3)*(vx1+vx2+vx3)-cu_sq)); + feq[BSW] = c1o216*(drho+rho*(3.0*(-vx1-vx2-vx3)+c9o2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3)-cu_sq)); + feq[BNE] = c1o216*(drho+rho*(3.0*(vx1+vx2-vx3)+c9o2*(vx1+vx2-vx3)*(vx1+vx2-vx3)-cu_sq)); + feq[TSW] = c1o216*(drho+rho*(3.0*(-vx1-vx2+vx3)+c9o2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3)-cu_sq)); + feq[TSE] = c1o216*(drho+rho*(3.0*(vx1-vx2+vx3)+c9o2*(vx1-vx2+vx3)*(vx1-vx2+vx3)-cu_sq)); + feq[BNW] = c1o216*(drho+rho*(3.0*(-vx1+vx2-vx3)+c9o2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3)-cu_sq)); + feq[BSE] = c1o216*(drho+rho*(3.0*(vx1-vx2-vx3)+c9o2*(vx1-vx2-vx3)*(vx1-vx2-vx3)-cu_sq)); + feq[TNW] = c1o216*(drho+rho*(3.0*(-vx1+vx2+vx3)+c9o2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3)-cu_sq)); + } + ////////////////////////////////////////////////////////////////////////// + static LBMReal getIncompFeqForDirection(const int& direction,const LBMReal& drho, const LBMReal& vx1,const LBMReal& vx2,const LBMReal& vx3) + { + using namespace UbMath; + + LBMReal cu_sq=1.5f*(vx1*vx1+vx2*vx2+vx3*vx3); + + switch(direction) + { + case REST : return REAL_CAST( c8o27*(drho-cu_sq)); + case E : return REAL_CAST( c2o27*(drho+3.0*( vx1 )+c9o2*( vx1 )*( vx1 )-cu_sq)); + case W : return REAL_CAST( c2o27*(drho+3.0*(-vx1 )+c9o2*(-vx1 )*(-vx1 )-cu_sq)); + case N : return REAL_CAST( c2o27*(drho+3.0*( vx2)+c9o2*( vx2)*( vx2)-cu_sq)); + case S : return REAL_CAST( c2o27*(drho+3.0*( -vx2)+c9o2*( -vx2)*( -vx2)-cu_sq)); + case T : return REAL_CAST( c2o27*(drho+3.0*( vx3 )+c9o2*( vx3)*( vx3)-cu_sq)); + case B : return REAL_CAST( c2o27*(drho+3.0*( -vx3)+c9o2*( -vx3)*( -vx3)-cu_sq)); + case NE : return REAL_CAST( c1o54*(drho+3.0*( vx1+vx2)+c9o2*( vx1+vx2)*( vx1+vx2)-cu_sq)); + case SW : return REAL_CAST( c1o54*(drho+3.0*(-vx1-vx2)+c9o2*(-vx1-vx2)*(-vx1-vx2)-cu_sq)); + case SE : return REAL_CAST( c1o54*(drho+3.0*( vx1-vx2)+c9o2*( vx1-vx2)*( vx1-vx2)-cu_sq)); + case NW : return REAL_CAST( c1o54*(drho+3.0*(-vx1+vx2)+c9o2*(-vx1+vx2)*(-vx1+vx2)-cu_sq)); + case TE : return REAL_CAST( c1o54*(drho+3.0*( vx1+vx3)+c9o2*( vx1+vx3)*( vx1+vx3)-cu_sq)); + case BW : return REAL_CAST( c1o54*(drho+3.0*(-vx1-vx3)+c9o2*(-vx1-vx3)*(-vx1-vx3)-cu_sq)); + case BE : return REAL_CAST( c1o54*(drho+3.0*( vx1-vx3)+c9o2*( vx1-vx3)*( vx1-vx3)-cu_sq)); + case TW : return REAL_CAST( c1o54*(drho+3.0*(-vx1+vx3)+c9o2*(-vx1+vx3)*(-vx1+vx3)-cu_sq)); + case TN : return REAL_CAST( c1o54*(drho+3.0*( vx2+vx3)+c9o2*( vx2+vx3)*( vx2+vx3)-cu_sq)); + case BS : return REAL_CAST( c1o54*(drho+3.0*(-vx2-vx3)+c9o2*(-vx2-vx3)*(-vx2-vx3)-cu_sq)); + case BN : return REAL_CAST( c1o54*(drho+3.0*( vx2-vx3)+c9o2*( vx2-vx3)*( vx2-vx3)-cu_sq)); + case TS : return REAL_CAST( c1o54*(drho+3.0*(-vx2+vx3)+c9o2*(-vx2+vx3)*(-vx2+vx3)-cu_sq)); + case TNE : return REAL_CAST(c1o216*(drho+3.0*( vx1+vx2+vx3)+c9o2*( vx1+vx2+vx3)*( vx1+vx2+vx3)-cu_sq)); + case BSW : return REAL_CAST(c1o216*(drho+3.0*(-vx1-vx2-vx3)+c9o2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3)-cu_sq)); + case BNE : return REAL_CAST(c1o216*(drho+3.0*( vx1+vx2-vx3)+c9o2*( vx1+vx2-vx3)*( vx1+vx2-vx3)-cu_sq)); + case TSW : return REAL_CAST(c1o216*(drho+3.0*(-vx1-vx2+vx3)+c9o2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3)-cu_sq)); + case TSE : return REAL_CAST(c1o216*(drho+3.0*( vx1-vx2+vx3)+c9o2*( vx1-vx2+vx3)*( vx1-vx2+vx3)-cu_sq)); + case BNW : return REAL_CAST(c1o216*(drho+3.0*(-vx1+vx2-vx3)+c9o2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3)-cu_sq)); + case BSE : return REAL_CAST(c1o216*(drho+3.0*( vx1-vx2-vx3)+c9o2*( vx1-vx2-vx3)*( vx1-vx2-vx3)-cu_sq)); + case TNW : return REAL_CAST(c1o216*(drho+3.0*(-vx1+vx2+vx3)+c9o2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3)-cu_sq)); + default: throw UbException(UB_EXARGS,"unknown dir"); + } + } + ////////////////////////////////////////////////////////////////////////// + static void calcIncompFeq(LBMReal* const& feq/*[27]*/,const LBMReal& drho,const LBMReal& vx1,const LBMReal& vx2,const LBMReal& vx3) + { + using namespace UbMath; + + LBMReal cu_sq=1.5*(vx1*vx1+vx2*vx2+vx3*vx3); + + feq[REST] = c8o27*(drho-cu_sq); + feq[E] = c2o27*(drho+3.0*( vx1 )+c9o2*( vx1 )*( vx1 )-cu_sq); + feq[W] = c2o27*(drho+3.0*(-vx1 )+c9o2*(-vx1 )*(-vx1 )-cu_sq); + feq[N] = c2o27*(drho+3.0*( vx2)+c9o2*( vx2)*( vx2)-cu_sq); + feq[S] = c2o27*(drho+3.0*( -vx2)+c9o2*( -vx2)*( -vx2)-cu_sq); + feq[T] = c2o27*(drho+3.0*( vx3 )+c9o2*( vx3)*( vx3)-cu_sq); + feq[B] = c2o27*(drho+3.0*( -vx3)+c9o2*( -vx3)*( -vx3)-cu_sq); + feq[NE] = c1o54*(drho+3.0*( vx1+vx2)+c9o2*( vx1+vx2)*( vx1+vx2)-cu_sq); + feq[SW] = c1o54*(drho+3.0*(-vx1-vx2)+c9o2*(-vx1-vx2)*(-vx1-vx2)-cu_sq); + feq[SE] = c1o54*(drho+3.0*( vx1-vx2)+c9o2*( vx1-vx2)*( vx1-vx2)-cu_sq); + feq[NW] = c1o54*(drho+3.0*(-vx1+vx2)+c9o2*(-vx1+vx2)*(-vx1+vx2)-cu_sq); + feq[TE] = c1o54*(drho+3.0*( vx1+vx3)+c9o2*( vx1+vx3)*( vx1+vx3)-cu_sq); + feq[BW] = c1o54*(drho+3.0*(-vx1-vx3)+c9o2*(-vx1-vx3)*(-vx1-vx3)-cu_sq); + feq[BE] = c1o54*(drho+3.0*( vx1-vx3)+c9o2*( vx1-vx3)*( vx1-vx3)-cu_sq); + feq[TW] = c1o54*(drho+3.0*(-vx1+vx3)+c9o2*(-vx1+vx3)*(-vx1+vx3)-cu_sq); + feq[TN] = c1o54*(drho+3.0*( vx2+vx3)+c9o2*( vx2+vx3)*( vx2+vx3)-cu_sq); + feq[BS] = c1o54*(drho+3.0*(-vx2-vx3)+c9o2*(-vx2-vx3)*(-vx2-vx3)-cu_sq); + feq[BN] = c1o54*(drho+3.0*( vx2-vx3)+c9o2*( vx2-vx3)*( vx2-vx3)-cu_sq); + feq[TS] = c1o54*(drho+3.0*(-vx2+vx3)+c9o2*(-vx2+vx3)*(-vx2+vx3)-cu_sq); + feq[TNE] = c1o216*(drho+3.0*( vx1+vx2+vx3)+c9o2*( vx1+vx2+vx3)*( vx1+vx2+vx3)-cu_sq); + feq[BSW] = c1o216*(drho+3.0*(-vx1-vx2-vx3)+c9o2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3)-cu_sq); + feq[BNE] = c1o216*(drho+3.0*( vx1+vx2-vx3)+c9o2*( vx1+vx2-vx3)*( vx1+vx2-vx3)-cu_sq); + feq[TSW] = c1o216*(drho+3.0*(-vx1-vx2+vx3)+c9o2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3)-cu_sq); + feq[TSE] = c1o216*(drho+3.0*( vx1-vx2+vx3)+c9o2*( vx1-vx2+vx3)*( vx1-vx2+vx3)-cu_sq); + feq[BNW] = c1o216*(drho+3.0*(-vx1+vx2-vx3)+c9o2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3)-cu_sq); + feq[BSE] = c1o216*(drho+3.0*( vx1-vx2-vx3)+c9o2*( vx1-vx2-vx3)*( vx1-vx2-vx3)-cu_sq); + feq[TNW] = c1o216*(drho+3.0*(-vx1+vx2+vx3)+c9o2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3)-cu_sq); + } + ////////////////////////////////////////////////////////////////////////// + static inline float getBoundaryVelocityForDirection(const int& direction, const float& bcVelocityX1,const float& bcVelocityX2,const float& bcVelocityX3) + { + using namespace UbMath; + + switch(direction) + { + case E: return (float)( UbMath::c4o9*(+bcVelocityX1) ); + case W: return (float)( UbMath::c4o9*(-bcVelocityX1) ); + case N: return (float)( UbMath::c4o9*(+bcVelocityX2) ); + case S: return (float)( UbMath::c4o9*(-bcVelocityX2) ); + case T: return (float)( UbMath::c4o9*(+bcVelocityX3) ); + case B: return (float)( UbMath::c4o9*(-bcVelocityX3) ); + case NE: return (float)( UbMath::c1o9*(+bcVelocityX1+bcVelocityX2 ) ); + case SW: return (float)( UbMath::c1o9*(-bcVelocityX1-bcVelocityX2 ) ); + case SE: return (float)( UbMath::c1o9*(+bcVelocityX1-bcVelocityX2 ) ); + case NW: return (float)( UbMath::c1o9*(-bcVelocityX1+bcVelocityX2 ) ); + case TE: return (float)( UbMath::c1o9*(+bcVelocityX1 +bcVelocityX3) ); + case BW: return (float)( UbMath::c1o9*(-bcVelocityX1 -bcVelocityX3) ); + case BE: return (float)( UbMath::c1o9*(+bcVelocityX1 -bcVelocityX3) ); + case TW: return (float)( UbMath::c1o9*(-bcVelocityX1 +bcVelocityX3) ); + case TN: return (float)( UbMath::c1o9*( +bcVelocityX2+bcVelocityX3) ); + case BS: return (float)( UbMath::c1o9*( -bcVelocityX2-bcVelocityX3) ); + case BN: return (float)( UbMath::c1o9*( +bcVelocityX2-bcVelocityX3) ); + case TS: return (float)( UbMath::c1o9*( -bcVelocityX2+bcVelocityX3) ); + case TNE: return (float)( UbMath::c1o36*(+bcVelocityX1+bcVelocityX2+bcVelocityX3) ); + case BSW: return (float)( UbMath::c1o36*(-bcVelocityX1-bcVelocityX2-bcVelocityX3) ); + case BNE: return (float)( UbMath::c1o36*(+bcVelocityX1+bcVelocityX2-bcVelocityX3) ); + case TSW: return (float)( UbMath::c1o36*(-bcVelocityX1-bcVelocityX2+bcVelocityX3) ); + case TSE: return (float)( UbMath::c1o36*(+bcVelocityX1-bcVelocityX2+bcVelocityX3) ); + case BNW: return (float)( UbMath::c1o36*(-bcVelocityX1+bcVelocityX2-bcVelocityX3) ); + case BSE: return (float)( UbMath::c1o36*(+bcVelocityX1-bcVelocityX2-bcVelocityX3) ); + case TNW: return (float)( UbMath::c1o36*(-bcVelocityX1+bcVelocityX2+bcVelocityX3) ); + default: throw UbException(UB_EXARGS,"unknown direction"); + } + } + /*=====================================================================*/ + static const int& getInvertDirection(const int& direction) + { + #ifdef _DEBUG + if(direction<STARTDIR || direction>ENDDIR) + throw UbException(UB_EXARGS,"unknown direction"); + #endif + return INVDIR[direction]; + } + /*=====================================================================*/ + static void getLBMDirections(std::vector<int>& dirs, bool onlyLBdirs = false) + { + std::vector<int> D3Q27Dirs; + if(onlyLBdirs) /*FSTARTDIR->FENDDIR*/ + { + dirs.resize(FENDDIR+1); + for(int dir=FSTARTDIR; dir<=FENDDIR; ++dir) + dirs[dir] = dir; + } + else /*STARTDIR->ENDDIR*/ + { + dirs.resize(ENDDIR+1); + for(int dir=STARTDIR; dir<=ENDDIR; ++dir) + dirs[dir] = dir; + } + } +////////////////////////////////////////////////////////////////////////// + static std::vector<int> getEX(const int& exn) + { + std::vector<int> ex; + ex.resize(ENDDIR+1); + switch (exn) + { + case 1: + for(int dir=STARTDIR; dir<ENDDIR; ++dir) + ex[dir] = DX1[dir]; + break; + case 2: + for(int dir=STARTDIR; dir<ENDDIR; ++dir) + ex[dir] = DX2[dir]; + break; + case 3: + for(int dir=STARTDIR; dir<ENDDIR; ++dir) + ex[dir] = DX3[dir]; + break; + } + return ex; + } +////////////////////////////////////////////////////////////////////////// + static inline void calcDistanceToNeighbors(std::vector<double>& distNeigh, const double& deltaX1) + { + //distNeigh.resize(FENDDIR+1, UbMath::sqrt2*deltaX1); + double sqrt3 = UbMath::sqrt3; + double sqrt2 = UbMath::sqrt2; + distNeigh[E] = distNeigh[W] = distNeigh[N] = deltaX1; + distNeigh[S] = distNeigh[T] = distNeigh[B] = deltaX1; + distNeigh[NE] = distNeigh[NW] = distNeigh[SW] = distNeigh[SE] = sqrt2*deltaX1; + distNeigh[TE] = distNeigh[TN] = distNeigh[TW] = distNeigh[TS] = sqrt2*deltaX1; + distNeigh[BE] = distNeigh[BN] = distNeigh[BW] = distNeigh[BS] = sqrt2*deltaX1; + distNeigh[TNE] = distNeigh[TNW] = distNeigh[TSE] = distNeigh[TSW] = sqrt3*deltaX1; + distNeigh[BNE] = distNeigh[BNW] = distNeigh[BSE] = distNeigh[BSW] = sqrt3*deltaX1; + } +////////////////////////////////////////////////////////////////////////// + static inline void calcDistanceToNeighbors(std::vector<double>& distNeigh, const double& deltaX1,const double& deltaX2,const double& deltaX3) + { + //distNeigh.resize(FENDDIR+1, UbMath::sqrt2*deltaX1); + double sqrt3 = UbMath::sqrt3; + double sqrt2 = UbMath::sqrt2; + distNeigh[E] = distNeigh[W] = deltaX1; + distNeigh[N] = distNeigh[S] = deltaX2; + distNeigh[T] = distNeigh[B] = deltaX3; + distNeigh[NE] = distNeigh[NW] = distNeigh[SW] = distNeigh[SE] = sqrt(deltaX1*deltaX1+deltaX2*deltaX2); + distNeigh[TE] = distNeigh[TN] = distNeigh[TW] = distNeigh[TS] = sqrt(deltaX1*deltaX1+deltaX3*deltaX3); + distNeigh[BE] = distNeigh[BN] = distNeigh[BW] = distNeigh[BS] = sqrt(deltaX2*deltaX2+deltaX3*deltaX3); + distNeigh[TNE] = distNeigh[TNW] = distNeigh[TSE] = distNeigh[TSW] = sqrt(deltaX1*deltaX1+deltaX2*deltaX2+deltaX3*deltaX3); + distNeigh[BNE] = distNeigh[BNW] = distNeigh[BSE] = distNeigh[BSW] = sqrt(deltaX1*deltaX1+deltaX2*deltaX2+deltaX3*deltaX3); + } +////////////////////////////////////////////////////////////////////////// + static inline void initRayVectors(double* const& rayX1, double* const& rayX2, double* const& rayX3) + { + using namespace UbMath; + + int fdir; + double c1oS2 = UbMath::one_over_sqrt2; + double c1oS3 = UbMath::one_over_sqrt3; + fdir = E; rayX1[fdir] = 1.0; rayX2[fdir] = 0.0; rayX3[fdir] = 0.0; + fdir = W; rayX1[fdir] = -1.0; rayX2[fdir] = 0.0; rayX3[fdir] = 0.0; + fdir = N; rayX1[fdir] = 0.0; rayX2[fdir] = 1.0; rayX3[fdir] = 0.0; + fdir = S; rayX1[fdir] = 0.0; rayX2[fdir] = -1.0; rayX3[fdir] = 0.0; + fdir = T; rayX1[fdir] = 0.0; rayX2[fdir] = 0.0; rayX3[fdir] = 1.0; + fdir = B; rayX1[fdir] = 0.0; rayX2[fdir] = 0.0; rayX3[fdir] = -1.0; + fdir = NE; rayX1[fdir] = c1oS2; rayX2[fdir] = c1oS2; rayX3[fdir] = 0.0; + fdir = SW; rayX1[fdir] = -c1oS2; rayX2[fdir] = -c1oS2; rayX3[fdir] = 0.0; + fdir = SE; rayX1[fdir] = c1oS2; rayX2[fdir] = -c1oS2; rayX3[fdir] = 0.0; + fdir = NW; rayX1[fdir] = -c1oS2; rayX2[fdir] = c1oS2; rayX3[fdir] = 0.0; + fdir = TE; rayX1[fdir] = c1oS2; rayX2[fdir] = 0.0; rayX3[fdir] = c1oS2; + fdir = BW; rayX1[fdir] = -c1oS2; rayX2[fdir] = 0.0; rayX3[fdir] = -c1oS2; + fdir = BE; rayX1[fdir] = c1oS2; rayX2[fdir] = 0.0; rayX3[fdir] = -c1oS2; + fdir = TW; rayX1[fdir] = -c1oS2; rayX2[fdir] = 0.0; rayX3[fdir] = c1oS2; + fdir = TN; rayX1[fdir] = 0.0; rayX2[fdir] = c1oS2; rayX3[fdir] = c1oS2; + fdir = BS; rayX1[fdir] = 0.0; rayX2[fdir] =-c1oS2; rayX3[fdir] = -c1oS2; + fdir = BN; rayX1[fdir] = 0.0; rayX2[fdir] = c1oS2; rayX3[fdir] = -c1oS2; + fdir = TS; rayX1[fdir] = 0.0; rayX2[fdir] =-c1oS2; rayX3[fdir] = c1oS2; + fdir = TNE; rayX1[fdir] = c1oS3; rayX2[fdir] = c1oS3; rayX3[fdir] = c1oS3; + fdir = TNW; rayX1[fdir] = -c1oS3; rayX2[fdir] = c1oS3; rayX3[fdir] = c1oS3; + fdir = TSE; rayX1[fdir] = c1oS3; rayX2[fdir] = -c1oS3; rayX3[fdir] = c1oS3; + fdir = TSW; rayX1[fdir] = -c1oS3; rayX2[fdir] = -c1oS3; rayX3[fdir] = c1oS3; + fdir = BNE; rayX1[fdir] = c1oS3; rayX2[fdir] = c1oS3; rayX3[fdir] = -c1oS3; + fdir = BNW; rayX1[fdir] = -c1oS3; rayX2[fdir] = c1oS3; rayX3[fdir] = -c1oS3; + fdir = BSE; rayX1[fdir] = c1oS3; rayX2[fdir] = -c1oS3; rayX3[fdir] = -c1oS3; + fdir = BSW; rayX1[fdir] = -c1oS3; rayX2[fdir] = -c1oS3; rayX3[fdir] = -c1oS3; + } +////////////////////////////////////////////////////////////////////////// + static inline LBMReal calcPress(const LBMReal* const f, LBMReal rho, LBMReal vx1, LBMReal vx2, LBMReal vx3) + { + using namespace UbMath; + LBMReal OxxPyyPzz = c1; + return ((f[E]+f[W]+f[N]+f[S]+f[T]+f[B]+c2*(f[NE]+f[SW]+f[SE]+f[NW]+f[TE]+f[BW]+f[BE]+f[TW]+f[TN]+f[BS]+f[BN]+f[TS])+ + c3*(f[TNE]+f[TSW]+f[TSE]+f[TNW]+f[BNE]+f[BSW]+f[BSE]+f[BNW])-(vx1*vx1+vx2*vx2+vx3*vx3))*(c1-c1o2*OxxPyyPzz)+OxxPyyPzz*c1o2*(rho))*c1o3; + } +} + +#endif + + + diff --git a/src/cpu/VirtualFluidsCore/LBM/ICell.h b/src/cpu/VirtualFluidsCore/LBM/ICell.h deleted file mode 100644 index f9a05924b..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/ICell.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef ICell_H -#define ICell_H - -#include "LBMSystem.h" -#include <vector> - -struct ICell3D -{ - ICell3D(int size); - - std::vector<LBMReal> TSW; - std::vector<LBMReal> TNW; - std::vector<LBMReal> TNE; - std::vector<LBMReal> TSE; - std::vector<LBMReal> BSW; - std::vector<LBMReal> BNW; - std::vector<LBMReal> BNE; - std::vector<LBMReal> BSE; -}; - -ICell3D::ICell3D(int size) -{ - TSW.resize(size); - TNW.resize(size); - TNE.resize(size); - TSE.resize(size); - BSW.resize(size); - BNW.resize(size); - BNE.resize(size); - BSE.resize(size); -} - -#endif diff --git a/src/cpu/VirtualFluidsCore/LBM/ILBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/ILBMKernel.h index dcd47af52..526bdd2fe 100644 --- a/src/cpu/VirtualFluidsCore/LBM/ILBMKernel.h +++ b/src/cpu/VirtualFluidsCore/LBM/ILBMKernel.h @@ -1,19 +1,51 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file ILBMKernel.h +//! \ingroup LBM +//! \author Konstantin Kutscher +//======================================================================================= + #ifndef I_LBMKERNEL_H #define I_LBMKERNEL_H #include <PointerDefinitions.h> - class BCProcessor; class DataSet3D; +//! Abstract class provides interface for LBM kernel class ILBMKernel { public: virtual ~ILBMKernel() {}; virtual void calculate(int step) = 0; - virtual double getCalculationTime() = 0; virtual void swapDistributions() = 0; virtual bool getCompressible() const = 0; diff --git a/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.cpp deleted file mode 100644 index a5e082a2c..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.cpp +++ /dev/null @@ -1,902 +0,0 @@ -#include "IncompressibleCumulantLBMKernel.h" -#include "D3Q27System.h" -#include "InterpolationProcessor.h" -#include "D3Q27EsoTwist3DSplittedVector.h" -#include "DataSet3D.h" -#include <math.h> -#include "Block3D.h" - -#define PROOF_CORRECTNESS - -////////////////////////////////////////////////////////////////////////// -IncompressibleCumulantLBMKernel::IncompressibleCumulantLBMKernel() -{ - this->parameter = NORMAL; - this->OxyyMxzz = 1.0; - this->compressible = false; -} -////////////////////////////////////////////////////////////////////////// -IncompressibleCumulantLBMKernel::~IncompressibleCumulantLBMKernel(void) -{ - -} -////////////////////////////////////////////////////////////////////////// -void IncompressibleCumulantLBMKernel::initDataSet() -{ - SPtr<DistributionArray3D> d(new D3Q27EsoTwist3DSplittedVector(nx[0]+2, nx[1]+2, nx[2]+2, -999.9)); - dataSet->setFdistributions(d); -} -////////////////////////////////////////////////////////////////////////// -SPtr<LBMKernel> IncompressibleCumulantLBMKernel::clone() -{ - SPtr<LBMKernel> kernel(new IncompressibleCumulantLBMKernel()); - kernel->setNX(nx); - dynamicPointerCast<IncompressibleCumulantLBMKernel>(kernel)->initDataSet(); - kernel->setCollisionFactor(this->collFactor); - kernel->setBCProcessor(bcProcessor->clone(kernel)); - kernel->setWithForcing(withForcing); - kernel->setForcingX1(muForcingX1); - kernel->setForcingX2(muForcingX2); - kernel->setForcingX3(muForcingX3); - kernel->setIndex(ix1, ix2, ix3); - kernel->setDeltaT(deltaT); - kernel->setBlock(block.lock()); - - switch (parameter) - { - case NORMAL: - dynamicPointerCast<IncompressibleCumulantLBMKernel>(kernel)->OxyyMxzz = 1.0; - break; - case MAGIC: - dynamicPointerCast<IncompressibleCumulantLBMKernel>(kernel)->OxyyMxzz = 2.0 +(-collFactor); - break; - } - return kernel; -} -////////////////////////////////////////////////////////////////////////// -void IncompressibleCumulantLBMKernel::calculate(int step) -{ - using namespace D3Q27System; - using namespace std; - - //timer.resetAndStart(); - - //initializing of forcing stuff - if (withForcing) - { - muForcingX1.DefineVar("x1", &muX1); muForcingX1.DefineVar("x2", &muX2); muForcingX1.DefineVar("x3", &muX3); - muForcingX2.DefineVar("x1", &muX1); muForcingX2.DefineVar("x2", &muX2); muForcingX2.DefineVar("x3", &muX3); - muForcingX3.DefineVar("x1", &muX1); muForcingX3.DefineVar("x2", &muX2); muForcingX3.DefineVar("x3", &muX3); - - muDeltaT = deltaT; - - muForcingX1.DefineVar("dt", &muDeltaT); - muForcingX2.DefineVar("dt", &muDeltaT); - muForcingX3.DefineVar("dt", &muDeltaT); - - muNu = (1.0/3.0)*(1.0/collFactor - 1.0/2.0); - - muForcingX1.DefineVar("nu", &muNu); - muForcingX2.DefineVar("nu", &muNu); - muForcingX3.DefineVar("nu", &muNu); - - LBMReal forcingX1 = 0; - LBMReal forcingX2 = 0; - LBMReal forcingX3 = 0; - } - ///////////////////////////////////// - - localDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getLocalDistributions(); - nonLocalDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getNonLocalDistributions(); - zeroDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getZeroDistributions(); - - SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); - - const int bcArrayMaxX1 = (int)bcArray->getNX1(); - const int bcArrayMaxX2 = (int)bcArray->getNX2(); - const int bcArrayMaxX3 = (int)bcArray->getNX3(); - - int minX1 = ghostLayerWidth; - int minX2 = ghostLayerWidth; - int minX3 = ghostLayerWidth; - int maxX1 = bcArrayMaxX1-ghostLayerWidth; - int maxX2 = bcArrayMaxX2-ghostLayerWidth; - int maxX3 = bcArrayMaxX3-ghostLayerWidth; - - for (int x3 = minX3; x3 < maxX3; x3++) - { - for (int x2 = minX2; x2 < maxX2; x2++) - { - for (int x1 = minX1; x1 < maxX1; x1++) - { - if (!bcArray->isSolid(x1, x2, x3) && !bcArray->isUndefined(x1, x2, x3)) - { - int x1p = x1 + 1; - int x2p = x2 + 1; - int x3p = x3 + 1; - ////////////////////////////////////////////////////////////////////////// - //read distribution - //////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - - //E N T - //c c c - ////////// - //W S B - //a a a - - //Rest ist b - - //mfxyz - //a - negative - //b - null - //c - positive - - // a b c - //-1 0 1 - - LBMReal mfcbb = (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3); - LBMReal mfbcb = (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3); - LBMReal mfbbc = (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3); - LBMReal mfccb = (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3); - LBMReal mfacb = (*this->localDistributions)(D3Q27System::ET_NW, x1p, x2, x3); - LBMReal mfcbc = (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3); - LBMReal mfabc = (*this->localDistributions)(D3Q27System::ET_TW, x1p, x2, x3); - LBMReal mfbcc = (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3); - LBMReal mfbac = (*this->localDistributions)(D3Q27System::ET_TS, x1, x2p, x3); - LBMReal mfccc = (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3); - LBMReal mfacc = (*this->localDistributions)(D3Q27System::ET_TNW, x1p, x2, x3); - LBMReal mfcac = (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2p, x3); - LBMReal mfaac = (*this->localDistributions)(D3Q27System::ET_TSW, x1p, x2p, x3); - - LBMReal mfabb = (*this->nonLocalDistributions)(D3Q27System::ET_W, x1p, x2, x3); - LBMReal mfbab = (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2p, x3); - LBMReal mfbba = (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3p); - LBMReal mfaab = (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1p, x2p, x3); - LBMReal mfcab = (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2p, x3); - LBMReal mfaba = (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1p, x2, x3p); - LBMReal mfcba = (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3p); - LBMReal mfbaa = (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2p, x3p); - LBMReal mfbca = (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3p); - LBMReal mfaaa = (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1p, x2p, x3p); - LBMReal mfcaa = (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2p, x3p); - LBMReal mfaca = (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1p, x2, x3p); - LBMReal mfcca = (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3p); - - LBMReal mfbbb = (*this->zeroDistributions)(x1, x2, x3); - - LBMReal m0, m1, m2; - - LBMReal rho=(mfaaa+mfaac+mfaca+mfcaa+mfacc+mfcac+mfccc+mfcca) - +(mfaab+mfacb+mfcab+mfccb)+(mfaba+mfabc+mfcba+mfcbc)+(mfbaa+mfbac+mfbca+mfbcc) - +(mfabb+mfcbb)+(mfbab+mfbcb)+(mfbba+mfbbc)+mfbbb; - - LBMReal vvx =((((mfccc-mfaaa) + (mfcac-mfaca)) + ((mfcaa-mfacc) + (mfcca-mfaac))) + - (((mfcba-mfabc) + (mfcbc-mfaba)) + ((mfcab-mfacb) + (mfccb-mfaab))) + - (mfcbb-mfabb)); - LBMReal vvy =((((mfccc-mfaaa) + (mfaca-mfcac)) + ((mfacc-mfcaa) + (mfcca-mfaac))) + - (((mfbca-mfbac) + (mfbcc-mfbaa)) + ((mfacb-mfcab) + (mfccb-mfaab))) + - (mfbcb-mfbab)); - LBMReal vvz =((((mfccc-mfaaa) + (mfcac-mfaca)) + ((mfacc-mfcaa) + (mfaac-mfcca))) + - (((mfbac-mfbca) + (mfbcc-mfbaa)) + ((mfabc-mfcba) + (mfcbc-mfaba))) + - (mfbbc-mfbba)); - - //forcing - /////////////////////////////////////////////////////////////////////////////////////////// - if (withForcing) - { - muX1 = static_cast<double>(x1-1+ix1*maxX1); - muX2 = static_cast<double>(x2-1+ix2*maxX2); - muX3 = static_cast<double>(x3-1+ix3*maxX3); - - forcingX1 = muForcingX1.Eval(); - forcingX2 = muForcingX2.Eval(); - forcingX3 = muForcingX3.Eval(); - - vvx += forcingX1*deltaT*0.5; // X - vvy += forcingX2*deltaT*0.5; // Y - vvz += forcingX3*deltaT*0.5; // Z - } - /////////////////////////////////////////////////////////////////////////////////////////// - LBMReal oMdrho; - - oMdrho=mfccc+mfaaa; - m0=mfaca+mfcac; - m1=mfacc+mfcaa; - m2=mfaac+mfcca; - oMdrho+=m0; - m1+=m2; - oMdrho+=m1; - m0=mfbac+mfbca; - m1=mfbaa+mfbcc; - m0+=m1; - m1=mfabc+mfcba; - m2=mfaba+mfcbc; - m1+=m2; - m0+=m1; - m1=mfacb+mfcab; - m2=mfaab+mfccb; - m1+=m2; - m0+=m1; - oMdrho+=m0; - m0=mfabb+mfcbb; - m1=mfbab+mfbcb; - m2=mfbba+mfbbc; - m0+=m1+m2; - m0+=mfbbb; //hat gefehlt - oMdrho = 1. - (oMdrho + m0); - - LBMReal vx2; - LBMReal vy2; - LBMReal vz2; - vx2=vvx*vvx; - vy2=vvy*vvy; - vz2=vvz*vvz; - //////////////////////////////////////////////////////////////////////////////////// - LBMReal wadjust; - LBMReal qudricLimit = 0.01; - //////////////////////////////////////////////////////////////////////////////////// - //Hin - //////////////////////////////////////////////////////////////////////////////////// - // mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Z - Dir - m2 = mfaaa + mfaac; - m1 = mfaac - mfaaa; - m0 = m2 + mfaab; - mfaaa = m0; - m0 += c1o36 * oMdrho; - mfaab = m1 - m0 * vvz; - mfaac = m2 - 2. * m1 * vvz + vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaba + mfabc; - m1 = mfabc - mfaba; - m0 = m2 + mfabb; - mfaba = m0; - m0 += c1o9 * oMdrho; - mfabb = m1 - m0 * vvz; - mfabc = m2 - 2. * m1 * vvz + vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaca + mfacc; - m1 = mfacc - mfaca; - m0 = m2 + mfacb; - mfaca = m0; - m0 += c1o36 * oMdrho; - mfacb = m1 - m0 * vvz; - mfacc = m2 - 2. * m1 * vvz + vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbaa + mfbac; - m1 = mfbac - mfbaa; - m0 = m2 + mfbab; - mfbaa = m0; - m0 += c1o9 * oMdrho; - mfbab = m1 - m0 * vvz; - mfbac = m2 - 2. * m1 * vvz + vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbba + mfbbc; - m1 = mfbbc - mfbba; - m0 = m2 + mfbbb; - mfbba = m0; - m0 += c4o9 * oMdrho; - mfbbb = m1 - m0 * vvz; - mfbbc = m2 - 2. * m1 * vvz + vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbca + mfbcc; - m1 = mfbcc - mfbca; - m0 = m2 + mfbcb; - mfbca = m0; - m0 += c1o9 * oMdrho; - mfbcb = m1 - m0 * vvz; - mfbcc = m2 - 2. * m1 * vvz + vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcaa + mfcac; - m1 = mfcac - mfcaa; - m0 = m2 + mfcab; - mfcaa = m0; - m0 += c1o36 * oMdrho; - mfcab = m1 - m0 * vvz; - mfcac = m2 - 2. * m1 * vvz + vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcba + mfcbc; - m1 = mfcbc - mfcba; - m0 = m2 + mfcbb; - mfcba = m0; - m0 += c1o9 * oMdrho; - mfcbb = m1 - m0 * vvz; - mfcbc = m2 - 2. * m1 * vvz + vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcca + mfccc; - m1 = mfccc - mfcca; - m0 = m2 + mfccb; - mfcca = m0; - m0 += c1o36 * oMdrho; - mfccb = m1 - m0 * vvz; - mfccc = m2 - 2. * m1 * vvz + vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - // mit 1/6, 0, 1/18, 2/3, 0, 2/9, 1/6, 0, 1/18 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Y - Dir - m2 = mfaaa + mfaca; - m1 = mfaca - mfaaa; - m0 = m2 + mfaba; - mfaaa = m0; - m0 += c1o6 * oMdrho; - mfaba = m1 - m0 * vvy; - mfaca = m2 - 2. * m1 * vvy + vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaab + mfacb; - m1 = mfacb - mfaab; - m0 = m2 + mfabb; - mfaab = m0; - mfabb = m1 - m0 * vvy; - mfacb = m2 - 2. * m1 * vvy + vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaac + mfacc; - m1 = mfacc - mfaac; - m0 = m2 + mfabc; - mfaac = m0; - m0 += c1o18 * oMdrho; - mfabc = m1 - m0 * vvy; - mfacc = m2 - 2. * m1 * vvy + vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbaa + mfbca; - m1 = mfbca - mfbaa; - m0 = m2 + mfbba; - mfbaa = m0; - m0 += c2o3 * oMdrho; - mfbba = m1 - m0 * vvy; - mfbca = m2 - 2. * m1 * vvy + vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbab + mfbcb; - m1 = mfbcb - mfbab; - m0 = m2 + mfbbb; - mfbab = m0; - mfbbb = m1 - m0 * vvy; - mfbcb = m2 - 2. * m1 * vvy + vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbac + mfbcc; - m1 = mfbcc - mfbac; - m0 = m2 + mfbbc; - mfbac = m0; - m0 += c2o9 * oMdrho; - mfbbc = m1 - m0 * vvy; - mfbcc = m2 - 2. * m1 * vvy + vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcaa + mfcca; - m1 = mfcca - mfcaa; - m0 = m2 + mfcba; - mfcaa = m0; - m0 += c1o6 * oMdrho; - mfcba = m1 - m0 * vvy; - mfcca = m2 - 2. * m1 * vvy + vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcab + mfccb; - m1 = mfccb - mfcab; - m0 = m2 + mfcbb; - mfcab = m0; - mfcbb = m1 - m0 * vvy; - mfccb = m2 - 2. * m1 * vvy + vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcac + mfccc; - m1 = mfccc - mfcac; - m0 = m2 + mfcbc; - mfcac = m0; - m0 += c1o18 * oMdrho; - mfcbc = m1 - m0 * vvy; - mfccc = m2 - 2. * m1 * vvy + vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - // mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // X - Dir - m2 = mfaaa + mfcaa; - m1 = mfcaa - mfaaa; - m0 = m2 + mfbaa; - mfaaa = m0; - m0 += 1. * oMdrho; - mfbaa = m1 - m0 * vvx; - mfcaa = m2 - 2. * m1 * vvx + vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaba + mfcba; - m1 = mfcba - mfaba; - m0 = m2 + mfbba; - mfaba = m0; - mfbba = m1 - m0 * vvx; - mfcba = m2 - 2. * m1 * vvx + vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaca + mfcca; - m1 = mfcca - mfaca; - m0 = m2 + mfbca; - mfaca = m0; - m0 += c1o3 * oMdrho; - mfbca = m1 - m0 * vvx; - mfcca = m2 - 2. * m1 * vvx + vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaab + mfcab; - m1 = mfcab - mfaab; - m0 = m2 + mfbab; - mfaab = m0; - mfbab = m1 - m0 * vvx; - mfcab = m2 - 2. * m1 * vvx + vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfabb + mfcbb; - m1 = mfcbb - mfabb; - m0 = m2 + mfbbb; - mfabb = m0; - mfbbb = m1 - m0 * vvx; - mfcbb = m2 - 2. * m1 * vvx + vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfacb + mfccb; - m1 = mfccb - mfacb; - m0 = m2 + mfbcb; - mfacb = m0; - mfbcb = m1 - m0 * vvx; - mfccb = m2 - 2. * m1 * vvx + vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaac + mfcac; - m1 = mfcac - mfaac; - m0 = m2 + mfbac; - mfaac = m0; - m0 += c1o3 * oMdrho; - mfbac = m1 - m0 * vvx; - mfcac = m2 - 2. * m1 * vvx + vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfabc + mfcbc; - m1 = mfcbc - mfabc; - m0 = m2 + mfbbc; - mfabc = m0; - mfbbc = m1 - m0 * vvx; - mfcbc = m2 - 2. * m1 * vvx + vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfacc + mfccc; - m1 = mfccc - mfacc; - m0 = m2 + mfbcc; - mfacc = m0; - m0 += c1o9 * oMdrho; - mfbcc = m1 - m0 * vvx; - mfccc = m2 - 2. * m1 * vvx + vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - // Cumulants - //////////////////////////////////////////////////////////////////////////////////// - LBMReal OxxPyyPzz = 1.; //omega2 or bulk viscosity - LBMReal OxyyPxzz = 1.;//-s9;//2+s9;// - //LBMReal OxyyMxzz = 1.;//2+s9;// - LBMReal O4 = 1.; - LBMReal O5 = 1.; - LBMReal O6 = 1.; - - //Cum 4. - //LBMReal CUMcbb = mfcbb - ((mfcaa + c1o3 * oMdrho) * mfabb + 2. * mfbba * mfbab); // till 18.05.2015 - //LBMReal CUMbcb = mfbcb - ((mfaca + c1o3 * oMdrho) * mfbab + 2. * mfbba * mfabb); // till 18.05.2015 - //LBMReal CUMbbc = mfbbc - ((mfaac + c1o3 * oMdrho) * mfbba + 2. * mfbab * mfabb); // till 18.05.2015 - - LBMReal CUMcbb = mfcbb - ((mfcaa + c1o3) * mfabb + 2. * mfbba * mfbab); - LBMReal CUMbcb = mfbcb - ((mfaca + c1o3) * mfbab + 2. * mfbba * mfabb); - LBMReal CUMbbc = mfbbc - ((mfaac + c1o3) * mfbba + 2. * mfbab * mfabb); - - LBMReal CUMcca = mfcca - ((mfcaa * mfaca + 2. * mfbba * mfbba) + c1o3 * (mfcaa + mfaca) * oMdrho + c1o9*(oMdrho-1.)*oMdrho); - LBMReal CUMcac = mfcac - ((mfcaa * mfaac + 2. * mfbab * mfbab) + c1o3 * (mfcaa + mfaac) * oMdrho + c1o9*(oMdrho-1.)*oMdrho); - LBMReal CUMacc = mfacc - ((mfaac * mfaca + 2. * mfabb * mfabb) + c1o3 * (mfaac + mfaca) * oMdrho + c1o9*(oMdrho-1.)*oMdrho); - - //Cum 5. - LBMReal CUMbcc = mfbcc - (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + 2. * (mfbab * mfacb + mfbba * mfabc)) - c1o3 * (mfbca + mfbac) * oMdrho; - LBMReal CUMcbc = mfcbc - (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + 2. * (mfabb * mfcab + mfbba * mfbac)) - c1o3 * (mfcba + mfabc) * oMdrho; - LBMReal CUMccb = mfccb - (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + 2. * (mfbab * mfbca + mfabb * mfcba)) - c1o3 * (mfacb + mfcab) * oMdrho; - - //Cum 6. - LBMReal CUMccc = mfccc +((-4. * mfbbb * mfbbb - - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) - - 4. * (mfabb * mfcbb + mfbab * mfbcb + mfbba * mfbbc) - - 2. * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) - +(4. * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) - + 2. * (mfcaa * mfaca * mfaac) - + 16. * mfbba * mfbab * mfabb) - - c1o3* (mfacc + mfcac + mfcca) * oMdrho -c1o9*oMdrho*oMdrho - - c1o9* (mfcaa + mfaca + mfaac) * oMdrho*(1.-2.* oMdrho)- c1o27* oMdrho * oMdrho*(-2.* oMdrho) - +(2. * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) - + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa)) * c2o3*oMdrho) +c1o27*oMdrho; - - //2. - // linear combinations - LBMReal mxxPyyPzz = mfcaa + mfaca + mfaac; - LBMReal mxxMyy = mfcaa - mfaca; - LBMReal mxxMzz = mfcaa - mfaac; - - LBMReal dxux = -c1o2 * collFactor *(mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz*(mfaaa - mxxPyyPzz); - LBMReal dyuy = dxux + collFactor * c3o2 * mxxMyy; - LBMReal dzuz = dxux + collFactor * c3o2 * mxxMzz; - - //relax - mxxPyyPzz += OxxPyyPzz*(mfaaa - mxxPyyPzz)- 3. * (1. - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz); - mxxMyy += collFactor * (-mxxMyy) - 3. * (1. - c1o2 * collFactor) * (vx2 * dxux - vy2 * dyuy); - mxxMzz += collFactor * (-mxxMzz) - 3. * (1. - c1o2 * collFactor) * (vx2 * dxux - vz2 * dzuz); - - mfabb += collFactor * (-mfabb); - mfbab += collFactor * (-mfbab); - mfbba += collFactor * (-mfbba); - - // linear combinations back - mfcaa = c1o3 * (mxxMyy + mxxMzz + mxxPyyPzz); - mfaca = c1o3 * (-2. * mxxMyy + mxxMzz + mxxPyyPzz); - mfaac = c1o3 * (mxxMyy - 2. * mxxMzz + mxxPyyPzz); - - //3. - // linear combinations - LBMReal mxxyPyzz = mfcba + mfabc; - LBMReal mxxyMyzz = mfcba - mfabc; - - LBMReal mxxzPyyz = mfcab + mfacb; - LBMReal mxxzMyyz = mfcab - mfacb; - - LBMReal mxyyPxzz = mfbca + mfbac; - LBMReal mxyyMxzz = mfbca - mfbac; - - //relax - wadjust = OxyyMxzz+(1.-OxyyMxzz)*fabs(mfbbb)/(fabs(mfbbb)+qudricLimit); - mfbbb += wadjust * (-mfbbb); - wadjust = OxyyPxzz+(1.-OxyyPxzz)*fabs(mxxyPyzz)/(fabs(mxxyPyzz)+qudricLimit); - mxxyPyzz += wadjust * (-mxxyPyzz); - wadjust = OxyyMxzz+(1.-OxyyMxzz)*fabs(mxxyMyzz)/(fabs(mxxyMyzz)+qudricLimit); - mxxyMyzz += wadjust * (-mxxyMyzz); - wadjust = OxyyPxzz+(1.-OxyyPxzz)*fabs(mxxzPyyz)/(fabs(mxxzPyyz)+qudricLimit); - mxxzPyyz += wadjust * (-mxxzPyyz); - wadjust = OxyyMxzz+(1.-OxyyMxzz)*fabs(mxxzMyyz)/(fabs(mxxzMyyz)+qudricLimit); - mxxzMyyz += wadjust * (-mxxzMyyz); - wadjust = OxyyPxzz+(1.-OxyyPxzz)*fabs(mxyyPxzz)/(fabs(mxyyPxzz)+qudricLimit); - mxyyPxzz += wadjust * (-mxyyPxzz); - wadjust = OxyyMxzz+(1.-OxyyMxzz)*fabs(mxyyMxzz)/(fabs(mxyyMxzz)+qudricLimit); - mxyyMxzz += wadjust * (-mxyyMxzz); - - // linear combinations back - mfcba = (mxxyMyzz + mxxyPyzz) * c1o2; - mfabc = (-mxxyMyzz + mxxyPyzz) * c1o2; - mfcab = (mxxzMyyz + mxxzPyyz) * c1o2; - mfacb = (-mxxzMyyz + mxxzPyyz) * c1o2; - mfbca = (mxyyMxzz + mxyyPxzz) * c1o2; - mfbac = (-mxyyMxzz + mxyyPxzz) * c1o2; - - //4. - CUMacc += O4 * (-CUMacc); - CUMcac += O4 * (-CUMcac); - CUMcca += O4 * (-CUMcca); - - CUMbbc += O4 * (-CUMbbc); - CUMbcb += O4 * (-CUMbcb); - CUMcbb += O4 * (-CUMcbb); - - //5. - CUMbcc += O5 * (-CUMbcc); - CUMcbc += O5 * (-CUMcbc); - CUMccb += O5 * (-CUMccb); - - //6. - CUMccc += O6 * (-CUMccc); - - //back cumulants to central moments - //4. - //mfcbb = CUMcbb + ((mfcaa + c1o3 * oMdrho) * mfabb + 2. * mfbba * mfbab); // till 18.05.2015 - //mfbcb = CUMbcb + ((mfaca + c1o3 * oMdrho) * mfbab + 2. * mfbba * mfabb); // till 18.05.2015 - //mfbbc = CUMbbc + ((mfaac + c1o3 * oMdrho) * mfbba + 2. * mfbab * mfabb); // till 18.05.2015 - - mfcbb = CUMcbb + ((mfcaa + c1o3) * mfabb + 2. * mfbba * mfbab); - mfbcb = CUMbcb + ((mfaca + c1o3) * mfbab + 2. * mfbba * mfabb); - mfbbc = CUMbbc + ((mfaac + c1o3) * mfbba + 2. * mfbab * mfabb); - - mfcca = CUMcca + (mfcaa * mfaca + 2. * mfbba * mfbba) + c1o3 * (mfcaa + mfaca) * oMdrho + c1o9*(oMdrho-1)*oMdrho; - mfcac = CUMcac + (mfcaa * mfaac + 2. * mfbab * mfbab) + c1o3 * (mfcaa + mfaac) * oMdrho + c1o9*(oMdrho-1)*oMdrho; - mfacc = CUMacc + (mfaac * mfaca + 2. * mfabb * mfabb) + c1o3 * (mfaac + mfaca) * oMdrho + c1o9*(oMdrho-1)*oMdrho; - - //5. - mfbcc = CUMbcc + (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + 2. * (mfbab * mfacb + mfbba * mfabc)) + c1o3 * (mfbca + mfbac) * oMdrho; - mfcbc = CUMcbc + (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + 2. * (mfabb * mfcab + mfbba * mfbac)) + c1o3 * (mfcba + mfabc) * oMdrho; - mfccb = CUMccb + (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + 2. * (mfbab * mfbca + mfabb * mfcba)) + c1o3 * (mfacb + mfcab) * oMdrho; - - //6. - mfccc = CUMccc -((-4. * mfbbb * mfbbb - - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) - - 4. * (mfabb * mfcbb + mfbac * mfbca + mfbba * mfbbc) - - 2. * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) - +(4. * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) - + 2. * (mfcaa * mfaca * mfaac) - + 16. * mfbba * mfbab * mfabb) - - c1o3* (mfacc + mfcac + mfcca) * oMdrho -c1o9*oMdrho*oMdrho - - c1o9* (mfcaa + mfaca + mfaac) * oMdrho*(1.-2.* oMdrho)- c1o27* oMdrho * oMdrho*(-2.* oMdrho) - +(2. * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) - + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa)) * c2o3*oMdrho) -c1o27*oMdrho; - - //////////////////////////////////////////////////////////////////////////////////// - //forcing - mfbaa=-mfbaa; - mfaba=-mfaba; - mfaab=-mfaab; - ////////////////////////////////////////////////////////////////////////////////////// - - //////////////////////////////////////////////////////////////////////////////////// - //back - //////////////////////////////////////////////////////////////////////////////////// - //mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Z - Dir - m0 = mfaac * c1o2 + mfaab * (vvz - c1o2) + (mfaaa + 1. * oMdrho) * (vz2 - vvz) * c1o2; - m1 = -mfaac - 2. * mfaab * vvz + mfaaa * (1. - vz2) - 1. * oMdrho * vz2; - m2 = mfaac * c1o2 + mfaab * (vvz + c1o2) + (mfaaa + 1. * oMdrho) * (vz2 + vvz) * c1o2; - mfaaa = m0; - mfaab = m1; - mfaac = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfabc * c1o2 + mfabb * (vvz - c1o2) + mfaba * (vz2 - vvz) * c1o2; - m1 = -mfabc - 2. * mfabb * vvz + mfaba * (1. - vz2); - m2 = mfabc * c1o2 + mfabb * (vvz + c1o2) + mfaba * (vz2 + vvz) * c1o2; - mfaba = m0; - mfabb = m1; - mfabc = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacc * c1o2 + mfacb * (vvz - c1o2) + (mfaca + c1o3 * oMdrho) * (vz2 - vvz) * c1o2; - m1 = -mfacc - 2. * mfacb * vvz + mfaca * (1. - vz2) - c1o3 * oMdrho * vz2; - m2 = mfacc * c1o2 + mfacb * (vvz + c1o2) + (mfaca + c1o3 * oMdrho) * (vz2 + vvz) * c1o2; - mfaca = m0; - mfacb = m1; - mfacc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfbac * c1o2 + mfbab * (vvz - c1o2) + mfbaa * (vz2 - vvz) * c1o2; - m1 = -mfbac - 2. * mfbab * vvz + mfbaa * (1. - vz2); - m2 = mfbac * c1o2 + mfbab * (vvz + c1o2) + mfbaa * (vz2 + vvz) * c1o2; - mfbaa = m0; - mfbab = m1; - mfbac = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbbc * c1o2 + mfbbb * (vvz - c1o2) + mfbba * (vz2 - vvz) * c1o2; - m1 = -mfbbc - 2. * mfbbb * vvz + mfbba * (1. - vz2); - m2 = mfbbc * c1o2 + mfbbb * (vvz + c1o2) + mfbba * (vz2 + vvz) * c1o2; - mfbba = m0; - mfbbb = m1; - mfbbc = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcc * c1o2 + mfbcb * (vvz - c1o2) + mfbca * (vz2 - vvz) * c1o2; - m1 = -mfbcc - 2. * mfbcb * vvz + mfbca * (1. - vz2); - m2 = mfbcc * c1o2 + mfbcb * (vvz + c1o2) + mfbca * (vz2 + vvz) * c1o2; - mfbca = m0; - mfbcb = m1; - mfbcc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcac * c1o2 + mfcab * (vvz - c1o2) + (mfcaa + c1o3 * oMdrho) * (vz2 - vvz) * c1o2; - m1 = -mfcac - 2. * mfcab * vvz + mfcaa * (1. - vz2) - c1o3 * oMdrho * vz2; - m2 = mfcac * c1o2 + mfcab * (vvz + c1o2) + (mfcaa + c1o3 * oMdrho) * (vz2 + vvz) * c1o2; - mfcaa = m0; - mfcab = m1; - mfcac = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfcbc * c1o2 + mfcbb * (vvz - c1o2) + mfcba * (vz2 - vvz) * c1o2; - m1 = -mfcbc - 2. * mfcbb * vvz + mfcba * (1. - vz2); - m2 = mfcbc * c1o2 + mfcbb * (vvz + c1o2) + mfcba * (vz2 + vvz) * c1o2; - mfcba = m0; - mfcbb = m1; - mfcbc = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2 + mfccb * (vvz - c1o2) + (mfcca + c1o9 * oMdrho) * (vz2 - vvz) * c1o2; - m1 = -mfccc - 2. * mfccb * vvz + mfcca * (1. - vz2) - c1o9 * oMdrho * vz2; - m2 = mfccc * c1o2 + mfccb * (vvz + c1o2) + (mfcca + c1o9 * oMdrho) * (vz2 + vvz) * c1o2; - mfcca = m0; - mfccb = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - //mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Y - Dir - m0 = mfaca * c1o2 + mfaba * (vvy - c1o2) + (mfaaa + c1o6 * oMdrho) * (vy2 - vvy) * c1o2; - m1 = -mfaca - 2. * mfaba * vvy + mfaaa * (1. - vy2) - c1o6 * oMdrho * vy2; - m2 = mfaca * c1o2 + mfaba * (vvy + c1o2) + (mfaaa + c1o6 * oMdrho) * (vy2 + vvy) * c1o2; - mfaaa = m0; - mfaba = m1; - mfaca = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacb * c1o2 + mfabb * (vvy - c1o2) + (mfaab + c2o3 * oMdrho) * (vy2 - vvy) * c1o2; - m1 = -mfacb - 2. * mfabb * vvy + mfaab * (1. - vy2) - c2o3 * oMdrho * vy2; - m2 = mfacb * c1o2 + mfabb * (vvy + c1o2) + (mfaab + c2o3 * oMdrho) * (vy2 + vvy) * c1o2; - mfaab = m0; - mfabb = m1; - mfacb = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacc * c1o2 + mfabc * (vvy - c1o2) + (mfaac + c1o6 * oMdrho) * (vy2 - vvy) * c1o2; - m1 = -mfacc - 2. * mfabc * vvy + mfaac * (1. - vy2) - c1o6 * oMdrho * vy2; - m2 = mfacc * c1o2 + mfabc * (vvy + c1o2) + (mfaac + c1o6 * oMdrho) * (vy2 + vvy) * c1o2; - mfaac = m0; - mfabc = m1; - mfacc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfbca * c1o2 + mfbba * (vvy - c1o2) + mfbaa * (vy2 - vvy) * c1o2; - m1 = -mfbca - 2. * mfbba * vvy + mfbaa * (1. - vy2); - m2 = mfbca * c1o2 + mfbba * (vvy + c1o2) + mfbaa * (vy2 + vvy) * c1o2; - mfbaa = m0; - mfbba = m1; - mfbca = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcb * c1o2 + mfbbb * (vvy - c1o2) + mfbab * (vy2 - vvy) * c1o2; - m1 = -mfbcb - 2. * mfbbb * vvy + mfbab * (1. - vy2); - m2 = mfbcb * c1o2 + mfbbb * (vvy + c1o2) + mfbab * (vy2 + vvy) * c1o2; - mfbab = m0; - mfbbb = m1; - mfbcb = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcc * c1o2 + mfbbc * (vvy - c1o2) + mfbac * (vy2 - vvy) * c1o2; - m1 = -mfbcc - 2. * mfbbc * vvy + mfbac * (1. - vy2); - m2 = mfbcc * c1o2 + mfbbc * (vvy + c1o2) + mfbac * (vy2 + vvy) * c1o2; - mfbac = m0; - mfbbc = m1; - mfbcc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcca * c1o2 + mfcba * (vvy - c1o2) + (mfcaa + c1o18 * oMdrho) * (vy2 - vvy) * c1o2; - m1 = -mfcca - 2. * mfcba * vvy + mfcaa * (1. - vy2) - c1o18 * oMdrho * vy2; - m2 = mfcca * c1o2 + mfcba * (vvy + c1o2) + (mfcaa + c1o18 * oMdrho) * (vy2 + vvy) * c1o2; - mfcaa = m0; - mfcba = m1; - mfcca = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccb * c1o2 + mfcbb * (vvy - c1o2) + (mfcab + c2o9 * oMdrho) * (vy2 - vvy) * c1o2; - m1 = -mfccb - 2. * mfcbb * vvy + mfcab * (1. - vy2) - c2o9 * oMdrho * vy2; - m2 = mfccb * c1o2 + mfcbb * (vvy + c1o2) + (mfcab + c2o9 * oMdrho) * (vy2 + vvy) * c1o2; - mfcab = m0; - mfcbb = m1; - mfccb = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2 + mfcbc * (vvy - c1o2) + (mfcac + c1o18 * oMdrho) * (vy2 - vvy) * c1o2; - m1 = -mfccc - 2. * mfcbc * vvy + mfcac * (1. - vy2) - c1o18 * oMdrho * vy2; - m2 = mfccc * c1o2 + mfcbc * (vvy + c1o2) + (mfcac + c1o18 * oMdrho) * (vy2 + vvy) * c1o2; - mfcac = m0; - mfcbc = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - //mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // X - Dir - m0 = mfcaa * c1o2 + mfbaa * (vvx - c1o2) + (mfaaa + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; - m1 = -mfcaa - 2. * mfbaa * vvx + mfaaa * (1. - vx2) - c1o36 * oMdrho * vx2; - m2 = mfcaa * c1o2 + mfbaa * (vvx + c1o2) + (mfaaa + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; - mfaaa = m0; - mfbaa = m1; - mfcaa = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcba * c1o2 + mfbba * (vvx - c1o2) + (mfaba + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; - m1 = -mfcba - 2. * mfbba * vvx + mfaba * (1. - vx2) - c1o9 * oMdrho * vx2; - m2 = mfcba * c1o2 + mfbba * (vvx + c1o2) + (mfaba + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; - mfaba = m0; - mfbba = m1; - mfcba = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcca * c1o2 + mfbca * (vvx - c1o2) + (mfaca + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; - m1 = -mfcca - 2. * mfbca * vvx + mfaca * (1. - vx2) - c1o36 * oMdrho * vx2; - m2 = mfcca * c1o2 + mfbca * (vvx + c1o2) + (mfaca + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; - mfaca = m0; - mfbca = m1; - mfcca = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcab * c1o2 + mfbab * (vvx - c1o2) + (mfaab + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; - m1 = -mfcab - 2. * mfbab * vvx + mfaab * (1. - vx2) - c1o9 * oMdrho * vx2; - m2 = mfcab * c1o2 + mfbab * (vvx + c1o2) + (mfaab + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; - mfaab = m0; - mfbab = m1; - mfcab = m2; - ///////////b//////////////////////////////////////////////////////////////////////// - m0 = mfcbb * c1o2 + mfbbb * (vvx - c1o2) + (mfabb + c4o9 * oMdrho) * (vx2 - vvx) * c1o2; - m1 = -mfcbb - 2. * mfbbb * vvx + mfabb * (1. - vx2) - c4o9 * oMdrho * vx2; - m2 = mfcbb * c1o2 + mfbbb * (vvx + c1o2) + (mfabb + c4o9 * oMdrho) * (vx2 + vvx) * c1o2; - mfabb = m0; - mfbbb = m1; - mfcbb = m2; - ///////////b//////////////////////////////////////////////////////////////////////// - m0 = mfccb * c1o2 + mfbcb * (vvx - c1o2) + (mfacb + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; - m1 = -mfccb - 2. * mfbcb * vvx + mfacb * (1. - vx2) - c1o9 * oMdrho * vx2; - m2 = mfccb * c1o2 + mfbcb * (vvx + c1o2) + (mfacb + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; - mfacb = m0; - mfbcb = m1; - mfccb = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcac * c1o2 + mfbac * (vvx - c1o2) + (mfaac + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; - m1 = -mfcac - 2. * mfbac * vvx + mfaac * (1. - vx2) - c1o36 * oMdrho * vx2; - m2 = mfcac * c1o2 + mfbac * (vvx + c1o2) + (mfaac + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; - mfaac = m0; - mfbac = m1; - mfcac = m2; - ///////////c//////////////////////////////////////////////////////////////////////// - m0 = mfcbc * c1o2 + mfbbc * (vvx - c1o2) + (mfabc + c1o9 * oMdrho) * (vx2 - vvx) * c1o2; - m1 = -mfcbc - 2. * mfbbc * vvx + mfabc * (1. - vx2) - c1o9 * oMdrho * vx2; - m2 = mfcbc * c1o2 + mfbbc * (vvx + c1o2) + (mfabc + c1o9 * oMdrho) * (vx2 + vvx) * c1o2; - mfabc = m0; - mfbbc = m1; - mfcbc = m2; - ///////////c//////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2 + mfbcc * (vvx - c1o2) + (mfacc + c1o36 * oMdrho) * (vx2 - vvx) * c1o2; - m1 = -mfccc - 2. * mfbcc * vvx + mfacc * (1. - vx2) - c1o36 * oMdrho * vx2; - m2 = mfccc * c1o2 + mfbcc * (vvx + c1o2) + (mfacc + c1o36 * oMdrho) * (vx2 + vvx) * c1o2; - mfacc = m0; - mfbcc = m1; - mfccc = m2; - - ////////////////////////////////////////////////////////////////////////// - //proof correctness - ////////////////////////////////////////////////////////////////////////// -#ifdef PROOF_CORRECTNESS - LBMReal rho_post = (mfaaa+mfaac+mfaca+mfcaa+mfacc+mfcac+mfccc+mfcca) - +(mfaab+mfacb+mfcab+mfccb)+(mfaba+mfabc+mfcba+mfcbc)+(mfbaa+mfbac+mfbca+mfbcc) - +(mfabb+mfcbb)+(mfbab+mfbcb)+(mfbba+mfbbc)+mfbbb; - //LBMReal dif = fabs(rho - rho_post); - LBMReal dif = rho - rho_post; -#ifdef SINGLEPRECISION - if (dif > 10.0E-7 || dif < -10.0E-7) -#else - if (dif > 10.0E-15 || dif < -10.0E-15) -#endif - { - UB_THROW(UbException(UB_EXARGS, "rho="+UbSystem::toString(rho)+", rho_post="+UbSystem::toString(rho_post) - +" dif="+UbSystem::toString(dif) - +" rho is not correct for node "+UbSystem::toString(x1)+","+UbSystem::toString(x2)+","+UbSystem::toString(x3) - +" in " + block.lock()->toString()+" step = "+UbSystem::toString(step))); - } -#endif - ////////////////////////////////////////////////////////////////////////// - //write distribution - ////////////////////////////////////////////////////////////////////////// - (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3) = mfabb; - (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3) = mfbab; - (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3) = mfbba; - (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3) = mfaab; - (*this->localDistributions)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab; - (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3) = mfaba; - (*this->localDistributions)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba; - (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa; - (*this->localDistributions)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca; - (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa; - (*this->localDistributions)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa; - (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca; - (*this->localDistributions)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca; - - (*this->nonLocalDistributions)(D3Q27System::ET_W, x1p, x2, x3) = mfcbb; - (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2p, x3) = mfbcb; - (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc; - (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1p, x2p, x3) = mfccb; - (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2p, x3) = mfacb; - (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc; - (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc; - (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc; - (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac; - (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc; - (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc; - (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac; - (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac; - - (*this->zeroDistributions)(x1, x2, x3) = mfbbb; - ////////////////////////////////////////////////////////////////////////// - - } - } - } - } - //timer.stop(); -} -////////////////////////////////////////////////////////////////////////// -double IncompressibleCumulantLBMKernel::getCalculationTime() -{ - //return timer.getDuration(); - return timer.getTotalTime(); -} -////////////////////////////////////////////////////////////////////////// -void IncompressibleCumulantLBMKernel::setRelaxationParameter(Parameter p) -{ - parameter = p; -} - diff --git a/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.h deleted file mode 100644 index c4eb162cf..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.h +++ /dev/null @@ -1,49 +0,0 @@ -//Cascaded Cumulant LBM - -#ifndef IncompressibleCumulantLBMKernel_H -#define IncompressibleCumulantLBMKernel_H - -#include "LBMKernel.h" -#include "BCProcessor.h" -#include "D3Q27System.h" -#include "basics/utilities/UbTiming.h" -#include "basics/container/CbArray4D.h" -#include "basics/container/CbArray3D.h" - -//! \brief Cascaded Cumulant LBM kernel. -//! \details CFD solver that use Cascaded Cumulant Lattice Boltzmann method for D3Q27 model -//! \author K. Kutscher, M. Geier -class IncompressibleCumulantLBMKernel : public LBMKernel -{ -public: - //! This option set relaxation parameter: NORMAL - enum Parameter{NORMAL, MAGIC}; -public: - IncompressibleCumulantLBMKernel(); - virtual ~IncompressibleCumulantLBMKernel(void); - virtual void calculate(int step); - virtual SPtr<LBMKernel> clone(); - double getCalculationTime(); - void setRelaxationParameter(Parameter p); -protected: - virtual void initDataSet(); - LBMReal f[D3Q27System::ENDF+1]; - - UbTimer timer; - - LBMReal OxyyMxzz; - Parameter parameter; - - CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr localDistributions; - CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr zeroDistributions; - - mu::value_type muX1,muX2,muX3; - mu::value_type muDeltaT; - mu::value_type muNu; - LBMReal forcingX1; - LBMReal forcingX2; - LBMReal forcingX3; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.cpp deleted file mode 100644 index 7c8c2d94e..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.cpp +++ /dev/null @@ -1,1011 +0,0 @@ -#include "IncompressibleCumulantWithSpongeLayerLBMKernel.h" -#include "D3Q27System.h" -#include "D3Q27EsoTwist3DSplittedVector.h" -#include <math.h> -#include "DataSet3D.h" -#include "BCArray3D.h" -#include "Block3D.h" - -#define PROOF_CORRECTNESS - -////////////////////////////////////////////////////////////////////////// -IncompressibleCumulantWithSpongeLayerLBMKernel::IncompressibleCumulantWithSpongeLayerLBMKernel() -{ - -} -////////////////////////////////////////////////////////////////////////// -IncompressibleCumulantWithSpongeLayerLBMKernel::~IncompressibleCumulantWithSpongeLayerLBMKernel(void) -{ - -} -////////////////////////////////////////////////////////////////////////// -void IncompressibleCumulantWithSpongeLayerLBMKernel::initDataSet() -{ - SPtr<DistributionArray3D> d(new D3Q27EsoTwist3DSplittedVector(nx[0]+2, nx[1]+2, nx[2]+2, -999.9)); - dataSet->setFdistributions(d); -} -////////////////////////////////////////////////////////////////////////// -void IncompressibleCumulantWithSpongeLayerLBMKernel::setRelaxFactorParam(int vdir, double vL1, double vdx, double vSP) -{ - direction = vdir; - L1 = vL1; - dx = vdx; - SP = vSP; -} -////////////////////////////////////////////////////////////////////////// -void IncompressibleCumulantWithSpongeLayerLBMKernel::initRelaxFactor(int vdir, double vL1, double vdx, double vSP) -{ - direction = vdir; - L1 = vL1; - dx = vdx; - SP = vSP; - - double sizeX = L1 / dx; - double sizeSP = SP / dx; - double muX1, muX2, muX3; - - LBMReal spongeFactor; - - SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); - - const int bcArrayMaxX1 = (int)bcArray->getNX1(); - const int bcArrayMaxX2 = (int)bcArray->getNX2(); - const int bcArrayMaxX3 = (int)bcArray->getNX3(); - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - int maxX1 = bcArrayMaxX1 - ghostLayerWidth - 1; - int maxX2 = bcArrayMaxX2 - ghostLayerWidth - 1; - int maxX3 = bcArrayMaxX3 - ghostLayerWidth - 1; - - SPtr<RelaxationFactorArray3D> relaxationFactorPtr = CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr(new CbArray3D<LBMReal, IndexerX3X2X1>(maxX1, maxX2, maxX3)); - dataSet->setRelaxationFactor(relaxationFactorPtr); - - for (int x3 = minX3; x3 < maxX3; x3++) - { - for (int x2 = minX2; x2 < maxX2; x2++) - { - for (int x1 = minX1; x1 < maxX1; x1++) - { - switch (direction) - { - case D3Q27System::E: - muX1 = (double)(x1 + ix1 * maxX1); - if (muX1 >= (sizeX - sizeSP) / deltaT) - spongeFactor = (sizeX - (muX1 * deltaT + 1)) / sizeSP / 2.0 + 0.5; - else spongeFactor = 1.0; - break; - case D3Q27System::W: - muX1 = (double)(x1 + ix1 * maxX1); - if (muX1 <= sizeSP / deltaT) - spongeFactor = (sizeSP - (muX1 * deltaT + 1)) / sizeSP / 2.0 + 0.5; - else spongeFactor = 1.0; - break; - case D3Q27System::N: - muX2 = (double)(x2 + ix2 * maxX2); - if (muX2 >= (sizeX - sizeSP) / deltaT) - spongeFactor = (sizeX - (muX2 * deltaT + 1)) / sizeSP / 2.0 + 0.5; - else spongeFactor = 1.0; - break; - case D3Q27System::S: - muX2 = (double)(x2 + ix2 * maxX2); - if (muX2 <= sizeSP / deltaT) - spongeFactor = (sizeSP - (muX2 * deltaT + 1)) / sizeSP / 2.0 + 0.5; - else spongeFactor = 1.0; - break; - case D3Q27System::T: - muX3 = (double)(x3 + ix3 * maxX3); - if (muX3 >= (sizeX - sizeSP) / deltaT) - spongeFactor = (sizeX - (muX3 * deltaT + 1)) / sizeSP / 2.0 + 0.5; - else spongeFactor = 1.0; - break; - case D3Q27System::B: - muX3 = (double)(x3 + ix3 * maxX3); - if (muX3 <= sizeSP / deltaT) - spongeFactor = (sizeSP - (muX3 * deltaT + 1)) / sizeSP / 2.0 + 0.5; - else spongeFactor = 1.0; - break; - default: throw UbException(UB_EXARGS, "unknown dir"); - } - (*relaxationFactorPtr)(x1, x2, x3) = spongeFactor; - } - } - } -} - -////////////////////////////////////////////////////////////////////////// -SPtr<LBMKernel> IncompressibleCumulantWithSpongeLayerLBMKernel::clone() -{ - SPtr<LBMKernel> kernel(new IncompressibleCumulantWithSpongeLayerLBMKernel()); - kernel->setNX(nx); - dynamicPointerCast<IncompressibleCumulantWithSpongeLayerLBMKernel>(kernel)->initDataSet(); - kernel->setCollisionFactor(this->collFactor); - kernel->setBCProcessor(bcProcessor->clone(kernel)); - kernel->setWithForcing(withForcing); - kernel->setForcingX1(muForcingX1); - kernel->setForcingX2(muForcingX2); - kernel->setForcingX3(muForcingX3); - kernel->setIndex(ix1, ix2, ix3); - kernel->setDeltaT(deltaT); - kernel->setBlock(block.lock()); - - switch (parameter) - { - case NORMAL: - dynamicPointerCast<IncompressibleCumulantWithSpongeLayerLBMKernel>(kernel)->OxyyMxzz = 1.0; - break; - case MAGIC: - dynamicPointerCast<IncompressibleCumulantWithSpongeLayerLBMKernel>(kernel)->OxyyMxzz = 2.0 +(-collFactor); - break; - } - - kernel->setWithSpongeLayer(withSpongeLayer); - if(withSpongeLayer) kernel->setSpongeLayer(muSpongeLayer); - dynamicPointerCast<IncompressibleCumulantWithSpongeLayerLBMKernel>(kernel)->initRelaxFactor(direction, L1, dx, SP); - return kernel; -} -////////////////////////////////////////////////////////////////////////// -void IncompressibleCumulantWithSpongeLayerLBMKernel::calculate(int step) -{ - using namespace D3Q27System; - using namespace std; - - if(!withSpongeLayer) - { - UB_THROW(UbException(UB_EXARGS,"Sponge layer isn't initialized!")); - } - //initializing of forcing stuff - //if (withForcing) - //{ - // muForcingX1.DefineVar("x1",&muX1); muForcingX1.DefineVar("x2",&muX2); muForcingX1.DefineVar("x3",&muX3); - // muForcingX2.DefineVar("x1",&muX1); muForcingX2.DefineVar("x2",&muX2); muForcingX2.DefineVar("x3",&muX3); - // muForcingX3.DefineVar("x1",&muX1); muForcingX3.DefineVar("x2",&muX2); muForcingX3.DefineVar("x3",&muX3); - - // muDeltaT = deltaT; - - // muForcingX1.DefineVar("dx",&muDeltaT); - // muForcingX2.DefineVar("dx",&muDeltaT); - // muForcingX3.DefineVar("dx",&muDeltaT); - - // muNu = (1.0/3.0)*(1.0/collFactor - 1.0/2.0); - - // muForcingX1.DefineVar("nu",&muNu); - // muForcingX2.DefineVar("nu",&muNu); - // muForcingX3.DefineVar("nu",&muNu); - - // LBMReal forcingX1 = 0; - // LBMReal forcingX2 = 0; - // LBMReal forcingX3 = 0; - //} - ///////////////////////////////////// - //initialization of sponge layer variables - //if (withSpongeLayer) - //{ - //muDeltaT = deltaT; - //muSpongeLayer.DefineVar("dt",&muDeltaT); - //muSpongeLayer.DefineVar("x1",&muX1); muSpongeLayer.DefineVar("x2",&muX2); muSpongeLayer.DefineVar("x3",&muX3); - //} - ///////////////////////////////////// - - localDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getLocalDistributions(); - nonLocalDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getNonLocalDistributions(); - zeroDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getZeroDistributions(); - - SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); - SPtr<RelaxationFactorArray3D> relaxationFactorPtr = dataSet->getRelaxationFactor(); - - const int bcArrayMaxX1 = (int)bcArray->getNX1(); - const int bcArrayMaxX2 = (int)bcArray->getNX2(); - const int bcArrayMaxX3 = (int)bcArray->getNX3(); - - int minX1 = ghostLayerWidth; - int minX2 = ghostLayerWidth; - int minX3 = ghostLayerWidth; - int maxX1 = bcArrayMaxX1-ghostLayerWidth-1; - int maxX2 = bcArrayMaxX2-ghostLayerWidth-1; - int maxX3 = bcArrayMaxX3-ghostLayerWidth-1; - - LBMReal collFactor0 = collFactor; - LBMReal spongeFactor; - - for(int x3 = minX3; x3 <= maxX3; x3++) - { - for(int x2 = minX2; x2 <= maxX2; x2++) - { - for(int x1 = minX1; x1 <= maxX1; x1++) - { - if(!bcArray->isSolid(x1,x2,x3) && !bcArray->isUndefined(x1,x2,x3)) - { - int x1p = x1 + 1; - int x2p = x2 + 1; - int x3p = x3 + 1; - ////////////////////////////////////////////////////////////////////////// - //read distribution - //////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - - //E N T - //c c c - ////////// - //W S B - //a a a - - //Rest ist b - - LBMReal mfcbb = (*this->localDistributions)(D3Q27System::ET_E, x1,x2,x3); - LBMReal mfbcb = (*this->localDistributions)(D3Q27System::ET_N,x1,x2,x3); - LBMReal mfbbc = (*this->localDistributions)(D3Q27System::ET_T,x1,x2,x3); - LBMReal mfccb = (*this->localDistributions)(D3Q27System::ET_NE,x1,x2,x3); - LBMReal mfacb = (*this->localDistributions)(D3Q27System::ET_NW,x1p,x2,x3); - LBMReal mfcbc = (*this->localDistributions)(D3Q27System::ET_TE,x1,x2,x3); - LBMReal mfabc = (*this->localDistributions)(D3Q27System::ET_TW, x1p,x2,x3); - LBMReal mfbcc = (*this->localDistributions)(D3Q27System::ET_TN,x1,x2,x3); - LBMReal mfbac = (*this->localDistributions)(D3Q27System::ET_TS,x1,x2p,x3); - LBMReal mfccc = (*this->localDistributions)(D3Q27System::ET_TNE,x1,x2,x3); - LBMReal mfacc = (*this->localDistributions)(D3Q27System::ET_TNW,x1p,x2,x3); - LBMReal mfcac = (*this->localDistributions)(D3Q27System::ET_TSE,x1,x2p,x3); - LBMReal mfaac = (*this->localDistributions)(D3Q27System::ET_TSW,x1p,x2p,x3); - - LBMReal mfabb = (*this->nonLocalDistributions)(D3Q27System::ET_W,x1p,x2,x3 ); - LBMReal mfbab = (*this->nonLocalDistributions)(D3Q27System::ET_S,x1,x2p,x3 ); - LBMReal mfbba = (*this->nonLocalDistributions)(D3Q27System::ET_B,x1,x2,x3p ); - LBMReal mfaab = (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1p,x2p,x3 ); - LBMReal mfcab = (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1,x2p,x3 ); - LBMReal mfaba = (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1p,x2,x3p ); - LBMReal mfcba = (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1,x2,x3p ); - LBMReal mfbaa = (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1,x2p,x3p ); - LBMReal mfbca = (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1,x2,x3p ); - LBMReal mfaaa = (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1p,x2p,x3p); - LBMReal mfcaa = (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1,x2p,x3p); - LBMReal mfaca = (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1p,x2,x3p); - LBMReal mfcca = (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1,x2,x3p); - - LBMReal mfbbb = (*this->zeroDistributions)(x1,x2,x3); - - LBMReal m0, m1, m2; - - LBMReal rho=(mfaaa+mfaac+mfaca+mfcaa+mfacc+mfcac+mfccc+mfcca) - +(mfaab+mfacb+mfcab+mfccb)+(mfaba+mfabc+mfcba+mfcbc)+(mfbaa+mfbac+mfbca+mfbcc) - +(mfabb+mfcbb)+(mfbab+mfbcb)+(mfbba+mfbbc)+mfbbb; - - LBMReal vvx =((((mfccc-mfaaa) + (mfcac-mfaca)) + ((mfcaa-mfacc) + (mfcca-mfaac))) + - (((mfcba-mfabc) + (mfcbc-mfaba)) + ((mfcab-mfacb) + (mfccb-mfaab))) + - (mfcbb-mfabb)); - LBMReal vvy =((((mfccc-mfaaa) + (mfaca-mfcac)) + ((mfacc-mfcaa) + (mfcca-mfaac))) + - (((mfbca-mfbac) + (mfbcc-mfbaa)) + ((mfacb-mfcab) + (mfccb-mfaab))) + - (mfbcb-mfbab)); - LBMReal vvz =((((mfccc-mfaaa) + (mfcac-mfaca)) + ((mfacc-mfcaa) + (mfaac-mfcca))) + - (((mfbac-mfbca) + (mfbcc-mfbaa)) + ((mfabc-mfcba) + (mfcbc-mfaba))) + - (mfbbc-mfbba)); - ////////////////////////////////////////////////////////////////////////// - //forcing - /////////////////////////////////////////////////////////////////////////////////////////// - //if (withForcing) - //{ - // muX1 = (double)(x1-1+ix1*maxX1); - // muX2 = (double)(x2-1+ix2*maxX2); - // muX3 = (double)(x3-1+ix3*maxX3); - - // forcingX1 = muForcingX1.Eval(); - // forcingX2 = muForcingX2.Eval(); - // forcingX3 = muForcingX3.Eval(); - - // vvx += forcingX1*0.5; // X - // vvy += forcingX2*0.5; // Y - // vvz += forcingX3*0.5; // Z - //} - /////////////////////////////////////////////////////////////////////////////////////////// - //sponge layer - /////////////////////////////////////////////////////////////////////////////////////////// - //if (withSpongeLayer) - //{ - //if (!withForcing) - //{ - //lk// muX1 = (double)(x1-1+ix1*maxX1); - //muX2 = (double)(x2-1+ix2*maxX2); - //muX3 = (double)(x3-1+ix3*maxX3); - //} - //spongeFactor ist von Funktion in muSpongeLayer abhängich und variiert zwischen 1 (nix tun) und 0.5 (collFactor etwa auf 1); - //lk //LBMReal spongeFactor = muSpongeLayer.Eval(); - - //if (spongeFactor == 0.5) - //{ - // int Test=0; - //} - - //if(muX3 == ix3*maxX3/2 && muX2==ix2*maxX2/2) - // UBLOG(logINFO," x1="<<muX1<<" spongeFactor = " << spongeFactor <<" collFactor="<<collFactor); - - spongeFactor = (*relaxationFactorPtr)(x1-1, x2-1, x3-1); - collFactor *= spongeFactor; - //if(muX3 == ix3*maxX3/2 && muX2==ix2*maxX2/2) - // UBLOG(logINFO," x1="<<muX1<<" spongeFactor = " << spongeFactor <<" collFactor="<<collFactor); - - //} - ////////////////////////////////////////////////////////////////////////// - - LBMReal oMdrho; - - oMdrho=mfccc+mfaaa; - m0=mfaca+mfcac; - m1=mfacc+mfcaa; - m2=mfaac+mfcca; - oMdrho+=m0; - m1+=m2; - oMdrho+=m1; - m0=mfbac+mfbca; - m1=mfbaa+mfbcc; - m0+=m1; - m1=mfabc+mfcba; - m2=mfaba+mfcbc; - m1+=m2; - m0+=m1; - m1=mfacb+mfcab; - m2=mfaab+mfccb; - m1+=m2; - m0+=m1; - oMdrho+=m0; - m0=mfabb+mfcbb; - m1=mfbab+mfbcb; - m2=mfbba+mfbbc; - m0+=m1+m2; - m0+=mfbbb; //hat gefehlt - oMdrho = 1. - (oMdrho + m0); - - LBMReal vx2; - LBMReal vy2; - LBMReal vz2; - vx2=vvx*vvx; - vy2=vvy*vvy; - vz2=vvz*vvz; - //////////////////////////////////////////////////////////////////////////////////// - LBMReal wadjust; - LBMReal qudricLimit = 0.01; - //////////////////////////////////////////////////////////////////////////////////// - //Hin - //////////////////////////////////////////////////////////////////////////////////// - // mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Z - Dir - m2 = mfaaa + mfaac; - m1 = mfaac - mfaaa; - m0 = m2 + mfaab; - mfaaa = m0; - m0 += c1o36 * oMdrho; - mfaab = m1 - m0 * vvz; - mfaac = m2 - 2. * m1 * vvz + vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaba + mfabc; - m1 = mfabc - mfaba; - m0 = m2 + mfabb; - mfaba = m0; - m0 += c1o9 * oMdrho; - mfabb = m1 - m0 * vvz; - mfabc = m2 - 2. * m1 * vvz + vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaca + mfacc; - m1 = mfacc - mfaca; - m0 = m2 + mfacb; - mfaca = m0; - m0 += c1o36 * oMdrho; - mfacb = m1 - m0 * vvz; - mfacc = m2 - 2. * m1 * vvz + vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbaa + mfbac; - m1 = mfbac - mfbaa; - m0 = m2 + mfbab; - mfbaa = m0; - m0 += c1o9 * oMdrho; - mfbab = m1 - m0 * vvz; - mfbac = m2 - 2. * m1 * vvz + vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbba + mfbbc; - m1 = mfbbc - mfbba; - m0 = m2 + mfbbb; - mfbba = m0; - m0 += c4o9 * oMdrho; - mfbbb = m1 - m0 * vvz; - mfbbc = m2 - 2. * m1 * vvz + vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbca + mfbcc; - m1 = mfbcc - mfbca; - m0 = m2 + mfbcb; - mfbca = m0; - m0 += c1o9 * oMdrho; - mfbcb = m1 - m0 * vvz; - mfbcc = m2 - 2. * m1 * vvz + vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcaa + mfcac; - m1 = mfcac - mfcaa; - m0 = m2 + mfcab; - mfcaa = m0; - m0 += c1o36 * oMdrho; - mfcab = m1 - m0 * vvz; - mfcac = m2 - 2. * m1 * vvz + vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcba + mfcbc; - m1 = mfcbc - mfcba; - m0 = m2 + mfcbb; - mfcba = m0; - m0 += c1o9 * oMdrho; - mfcbb = m1 - m0 * vvz; - mfcbc = m2 - 2. * m1 * vvz + vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcca + mfccc; - m1 = mfccc - mfcca; - m0 = m2 + mfccb; - mfcca = m0; - m0 += c1o36 * oMdrho; - mfccb = m1 - m0 * vvz; - mfccc = m2 - 2. * m1 * vvz + vz2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - // mit 1/6, 0, 1/18, 2/3, 0, 2/9, 1/6, 0, 1/18 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Y - Dir - m2 = mfaaa + mfaca; - m1 = mfaca - mfaaa; - m0 = m2 + mfaba; - mfaaa = m0; - m0 += c1o6 * oMdrho; - mfaba = m1 - m0 * vvy; - mfaca = m2 - 2. * m1 * vvy + vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaab + mfacb; - m1 = mfacb - mfaab; - m0 = m2 + mfabb; - mfaab = m0; - mfabb = m1 - m0 * vvy; - mfacb = m2 - 2. * m1 * vvy + vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaac + mfacc; - m1 = mfacc - mfaac; - m0 = m2 + mfabc; - mfaac = m0; - m0 += c1o18 * oMdrho; - mfabc = m1 - m0 * vvy; - mfacc = m2 - 2. * m1 * vvy + vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbaa + mfbca; - m1 = mfbca - mfbaa; - m0 = m2 + mfbba; - mfbaa = m0; - m0 += c2o3 * oMdrho; - mfbba = m1 - m0 * vvy; - mfbca = m2 - 2. * m1 * vvy + vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbab + mfbcb; - m1 = mfbcb - mfbab; - m0 = m2 + mfbbb; - mfbab = m0; - mfbbb = m1 - m0 * vvy; - mfbcb = m2 - 2. * m1 * vvy + vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfbac + mfbcc; - m1 = mfbcc - mfbac; - m0 = m2 + mfbbc; - mfbac = m0; - m0 += c2o9 * oMdrho; - mfbbc = m1 - m0 * vvy; - mfbcc = m2 - 2. * m1 * vvy + vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcaa + mfcca; - m1 = mfcca - mfcaa; - m0 = m2 + mfcba; - mfcaa = m0; - m0 += c1o6 * oMdrho; - mfcba = m1 - m0 * vvy; - mfcca = m2 - 2. * m1 * vvy + vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcab + mfccb; - m1 = mfccb - mfcab; - m0 = m2 + mfcbb; - mfcab = m0; - mfcbb = m1 - m0 * vvy; - mfccb = m2 - 2. * m1 * vvy + vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfcac + mfccc; - m1 = mfccc - mfcac; - m0 = m2 + mfcbc; - mfcac = m0; - m0 += c1o18 * oMdrho; - mfcbc = m1 - m0 * vvy; - mfccc = m2 - 2. * m1 * vvy + vy2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - // mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // X - Dir - m2 = mfaaa + mfcaa; - m1 = mfcaa - mfaaa; - m0 = m2 + mfbaa; - mfaaa = m0; - m0 += 1. * oMdrho; - mfbaa = m1 - m0 * vvx; - mfcaa = m2 - 2. * m1 * vvx + vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaba + mfcba; - m1 = mfcba - mfaba; - m0 = m2 + mfbba; - mfaba = m0; - mfbba = m1 - m0 * vvx; - mfcba = m2 - 2. * m1 * vvx + vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaca + mfcca; - m1 = mfcca - mfaca; - m0 = m2 + mfbca; - mfaca = m0; - m0 += c1o3 * oMdrho; - mfbca = m1 - m0 * vvx; - mfcca = m2 - 2. * m1 * vvx + vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaab + mfcab; - m1 = mfcab - mfaab; - m0 = m2 + mfbab; - mfaab = m0; - mfbab = m1 - m0 * vvx; - mfcab = m2 - 2. * m1 * vvx + vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfabb + mfcbb; - m1 = mfcbb - mfabb; - m0 = m2 + mfbbb; - mfabb = m0; - mfbbb = m1 - m0 * vvx; - mfcbb = m2 - 2. * m1 * vvx + vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfacb + mfccb; - m1 = mfccb - mfacb; - m0 = m2 + mfbcb; - mfacb = m0; - mfbcb = m1 - m0 * vvx; - mfccb = m2 - 2. * m1 * vvx + vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfaac + mfcac; - m1 = mfcac - mfaac; - m0 = m2 + mfbac; - mfaac = m0; - m0 += c1o3 * oMdrho; - mfbac = m1 - m0 * vvx; - mfcac = m2 - 2. * m1 * vvx + vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfabc + mfcbc; - m1 = mfcbc - mfabc; - m0 = m2 + mfbbc; - mfabc = m0; - mfbbc = m1 - m0 * vvx; - mfcbc = m2 - 2. * m1 * vvx + vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - m2 = mfacc + mfccc; - m1 = mfccc - mfacc; - m0 = m2 + mfbcc; - mfacc = m0; - m0 += c1o9 * oMdrho; - mfbcc = m1 - m0 * vvx; - mfccc = m2 - 2. * m1 * vvx + vx2 * m0; - //////////////////////////////////////////////////////////////////////////////////// - // Cumulants - //////////////////////////////////////////////////////////////////////////////////// - LBMReal OxxPyyPzz = 1.; - LBMReal OxyyPxzz = 1.;//-s9;//2+s9;// - //LBMReal OxyyMxzz = 1.;//2+s9;// - LBMReal O4 = 1.; - LBMReal O5 = 1.; - LBMReal O6 = 1.; - - //Cum 4. - LBMReal CUMcbb = mfcbb - ((mfcaa + c1o3 * oMdrho) * mfabb + 2. * mfbba * mfbab); - LBMReal CUMbcb = mfbcb - ((mfaca + c1o3 * oMdrho) * mfbab + 2. * mfbba * mfabb); - LBMReal CUMbbc = mfbbc - ((mfaac + c1o3 * oMdrho) * mfbba + 2. * mfbab * mfabb); - - LBMReal CUMcca = mfcca - (mfcaa * mfaca + 2. * mfbba * mfbba) + c1o3 * (mfcaa + mfaca) * oMdrho + c1o9*(oMdrho-1)*oMdrho; - LBMReal CUMcac = mfcac - (mfcaa * mfaac + 2. * mfbab * mfbab) + c1o3 * (mfcaa + mfaac) * oMdrho + c1o9*(oMdrho-1)*oMdrho; - LBMReal CUMacc = mfacc - (mfaac * mfaca + 2. * mfabb * mfabb) + c1o3 * (mfaac + mfaca) * oMdrho + c1o9*(oMdrho-1)*oMdrho; - - //Cum 5. - LBMReal CUMbcc = mfbcc - (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + 2. * (mfbab * mfacb + mfbba * mfabc)) - c1o3 * (mfbca + mfbac) * oMdrho; - LBMReal CUMcbc = mfcbc - (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + 2. * (mfabb * mfcab + mfbba * mfbac)) - c1o3 * (mfcba + mfabc) * oMdrho; - LBMReal CUMccb = mfccb - (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + 2. * (mfbab * mfbca + mfabb * mfcba)) - c1o3 * (mfacb + mfcab) * oMdrho; - - //Cum 6. - LBMReal CUMccc = mfccc +((-4. * mfbbb * mfbbb - - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) - - 4. * (mfabb * mfcbb + mfbab * mfbcb + mfbba * mfbbc) - - 2. * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) - +( 4. * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) - + 2. * (mfcaa * mfaca * mfaac) - + 16. * mfbba * mfbab * mfabb) - - c1o3* (mfacc + mfcac + mfcca) * oMdrho -c1o9*oMdrho*oMdrho - - c1o9* (mfcaa + mfaca + mfaac) * oMdrho*(1.-2.* oMdrho)- c1o27* oMdrho * oMdrho*(-2.* oMdrho) - +( 2. * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) - + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa)) * c2o3*oMdrho) +c1o27*oMdrho; - - //2. - // linear combinations - LBMReal mxxPyyPzz = mfcaa + mfaca + mfaac; - LBMReal mxxMyy = mfcaa - mfaca; - LBMReal mxxMzz = mfcaa - mfaac; - - LBMReal dxux = -c1o2 * collFactor *(mxxMyy + mxxMzz) + c1o2 * OxxPyyPzz*(mfaaa - mxxPyyPzz); - LBMReal dyuy = dxux + collFactor * c3o2 * mxxMyy; - LBMReal dzuz = dxux + collFactor * c3o2 * mxxMzz; - - //relax - mxxPyyPzz += OxxPyyPzz*(mfaaa - mxxPyyPzz)- 3. * (1. - c1o2 * OxxPyyPzz) * (vx2 * dxux + vy2 * dyuy + vz2 * dzuz); - mxxMyy += collFactor * (-mxxMyy) - 3. * (1. - c1o2 * collFactor) * (vx2 * dxux - vy2 * dyuy); - mxxMzz += collFactor * (-mxxMzz) - 3. * (1. - c1o2 * collFactor) * (vx2 * dxux - vz2 * dzuz); - - mfabb += collFactor * (-mfabb); - mfbab += collFactor * (-mfbab); - mfbba += collFactor * (-mfbba); - - // linear combinations back - mfcaa = c1o3 * ( mxxMyy + mxxMzz + mxxPyyPzz); - mfaca = c1o3 * (-2. * mxxMyy + mxxMzz + mxxPyyPzz); - mfaac = c1o3 * ( mxxMyy - 2. * mxxMzz + mxxPyyPzz); - - //3. - // linear combinations - LBMReal mxxyPyzz = mfcba + mfabc; - LBMReal mxxyMyzz = mfcba - mfabc; - - LBMReal mxxzPyyz = mfcab + mfacb; - LBMReal mxxzMyyz = mfcab - mfacb; - - LBMReal mxyyPxzz = mfbca + mfbac; - LBMReal mxyyMxzz = mfbca - mfbac; - - //relax - wadjust = OxyyMxzz+(1.-OxyyMxzz)*fabs(mfbbb)/(fabs(mfbbb)+qudricLimit); - mfbbb += wadjust * (-mfbbb); - wadjust = OxyyPxzz+(1.-OxyyPxzz)*fabs(mxxyPyzz)/(fabs(mxxyPyzz)+qudricLimit); - mxxyPyzz += wadjust * (-mxxyPyzz); - wadjust = OxyyMxzz+(1.-OxyyMxzz)*fabs(mxxyMyzz)/(fabs(mxxyMyzz)+qudricLimit); - mxxyMyzz += wadjust * (-mxxyMyzz); - wadjust = OxyyPxzz+(1.-OxyyPxzz)*fabs(mxxzPyyz)/(fabs(mxxzPyyz)+qudricLimit); - mxxzPyyz += wadjust * (-mxxzPyyz); - wadjust = OxyyMxzz+(1.-OxyyMxzz)*fabs(mxxzMyyz)/(fabs(mxxzMyyz)+qudricLimit); - mxxzMyyz += wadjust * (-mxxzMyyz); - wadjust = OxyyPxzz+(1.-OxyyPxzz)*fabs(mxyyPxzz)/(fabs(mxyyPxzz)+qudricLimit); - mxyyPxzz += wadjust * (-mxyyPxzz); - wadjust = OxyyMxzz+(1.-OxyyMxzz)*fabs(mxyyMxzz)/(fabs(mxyyMxzz)+qudricLimit); - mxyyMxzz += wadjust * (-mxyyMxzz); - - // linear combinations back - mfcba = ( mxxyMyzz + mxxyPyzz) * c1o2; - mfabc = (-mxxyMyzz + mxxyPyzz) * c1o2; - mfcab = ( mxxzMyyz + mxxzPyyz) * c1o2; - mfacb = (-mxxzMyyz + mxxzPyyz) * c1o2; - mfbca = ( mxyyMxzz + mxyyPxzz) * c1o2; - mfbac = (-mxyyMxzz + mxyyPxzz) * c1o2; - - //4. - CUMacc += O4 * (-CUMacc); - CUMcac += O4 * (-CUMcac); - CUMcca += O4 * (-CUMcca); - - CUMbbc += O4 * (-CUMbbc); - CUMbcb += O4 * (-CUMbcb); - CUMcbb += O4 * (-CUMcbb); - - //5. - CUMbcc += O5 * (-CUMbcc); - CUMcbc += O5 * (-CUMcbc); - CUMccb += O5 * (-CUMccb); - - //6. - CUMccc += O6 * (-CUMccc); - - //back cumulants to central moments - //4. - mfcbb = CUMcbb + ((mfcaa + c1o3 * oMdrho) * mfabb + 2. * mfbba * mfbab); - mfbcb = CUMbcb + ((mfaca + c1o3 * oMdrho) * mfbab + 2. * mfbba * mfabb); - mfbbc = CUMbbc + ((mfaac + c1o3 * oMdrho) * mfbba + 2. * mfbab * mfabb); - - mfcca = CUMcca + (mfcaa * mfaca + 2. * mfbba * mfbba) + c1o3 * (mfcaa + mfaca) * oMdrho + c1o9*(oMdrho-1)*oMdrho; - mfcac = CUMcac + (mfcaa * mfaac + 2. * mfbab * mfbab) + c1o3 * (mfcaa + mfaac) * oMdrho + c1o9*(oMdrho-1)*oMdrho; - mfacc = CUMacc + (mfaac * mfaca + 2. * mfabb * mfabb) + c1o3 * (mfaac + mfaca) * oMdrho + c1o9*(oMdrho-1)*oMdrho; - - //5. - mfbcc = CUMbcc + (mfaac * mfbca + mfaca * mfbac + 4. * mfabb * mfbbb + 2. * (mfbab * mfacb + mfbba * mfabc)) + c1o3 * (mfbca + mfbac) * oMdrho; - mfcbc = CUMcbc + (mfaac * mfcba + mfcaa * mfabc + 4. * mfbab * mfbbb + 2. * (mfabb * mfcab + mfbba * mfbac)) + c1o3 * (mfcba + mfabc) * oMdrho; - mfccb = CUMccb + (mfcaa * mfacb + mfaca * mfcab + 4. * mfbba * mfbbb + 2. * (mfbab * mfbca + mfabb * mfcba)) + c1o3 * (mfacb + mfcab) * oMdrho; - - //6. - mfccc = CUMccc -((-4. * mfbbb * mfbbb - - (mfcaa * mfacc + mfaca * mfcac + mfaac * mfcca) - - 4. * (mfabb * mfcbb + mfbac * mfbca + mfbba * mfbbc) - - 2. * (mfbca * mfbac + mfcba * mfabc + mfcab * mfacb)) - +( 4. * (mfbab * mfbab * mfaca + mfabb * mfabb * mfcaa + mfbba * mfbba * mfaac) - + 2. * (mfcaa * mfaca * mfaac) - + 16. * mfbba * mfbab * mfabb) - - c1o3* (mfacc + mfcac + mfcca) * oMdrho -c1o9*oMdrho*oMdrho - - c1o9* (mfcaa + mfaca + mfaac) * oMdrho*(1.-2.* oMdrho)- c1o27* oMdrho * oMdrho*(-2.* oMdrho) - +( 2. * (mfbab * mfbab + mfabb * mfabb + mfbba * mfbba) - + (mfaac * mfaca + mfaac * mfcaa + mfaca * mfcaa)) * c2o3*oMdrho) -c1o27*oMdrho; - - //////////////////////////////////////////////////////////////////////////////////// - //forcing - mfbaa=-mfbaa; - mfaba=-mfaba; - mfaab=-mfaab; - ////////////////////////////////////////////////////////////////////////////////////// - - //////////////////////////////////////////////////////////////////////////////////// - //back - //////////////////////////////////////////////////////////////////////////////////// - //mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Z - Dir - m0 = mfaac * c1o2 + mfaab * (vvz - c1o2) + (mfaaa + 1. * oMdrho) * ( vz2 - vvz) * c1o2; - m1 = -mfaac - 2. * mfaab * vvz + mfaaa * (1. - vz2) - 1. * oMdrho * vz2; - m2 = mfaac * c1o2 + mfaab * (vvz + c1o2) + (mfaaa + 1. * oMdrho) * ( vz2 + vvz) * c1o2; - mfaaa = m0; - mfaab = m1; - mfaac = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfabc * c1o2 + mfabb * (vvz - c1o2) + mfaba * ( vz2 - vvz) * c1o2; - m1 = -mfabc - 2. * mfabb * vvz + mfaba * (1. - vz2); - m2 = mfabc * c1o2 + mfabb * (vvz + c1o2) + mfaba * ( vz2 + vvz) * c1o2; - mfaba = m0; - mfabb = m1; - mfabc = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacc * c1o2 + mfacb * (vvz - c1o2) + (mfaca + c1o3 * oMdrho) * ( vz2 - vvz) * c1o2; - m1 = -mfacc - 2. * mfacb * vvz + mfaca * (1. - vz2) - c1o3 * oMdrho * vz2; - m2 = mfacc * c1o2 + mfacb * (vvz + c1o2) + (mfaca + c1o3 * oMdrho) * ( vz2 + vvz) * c1o2; - mfaca = m0; - mfacb = m1; - mfacc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfbac * c1o2 + mfbab * (vvz - c1o2) + mfbaa * ( vz2 - vvz) * c1o2; - m1 = -mfbac - 2. * mfbab * vvz + mfbaa * (1. - vz2); - m2 = mfbac * c1o2 + mfbab * (vvz + c1o2) + mfbaa * ( vz2 + vvz) * c1o2; - mfbaa = m0; - mfbab = m1; - mfbac = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbbc * c1o2 + mfbbb * (vvz - c1o2) + mfbba * ( vz2 - vvz) * c1o2; - m1 = -mfbbc - 2. * mfbbb * vvz + mfbba * (1. - vz2); - m2 = mfbbc * c1o2 + mfbbb * (vvz + c1o2) + mfbba * ( vz2 + vvz) * c1o2; - mfbba = m0; - mfbbb = m1; - mfbbc = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcc * c1o2 + mfbcb * (vvz - c1o2) + mfbca * ( vz2 - vvz) * c1o2; - m1 = -mfbcc - 2. * mfbcb * vvz + mfbca * (1. - vz2); - m2 = mfbcc * c1o2 + mfbcb * (vvz + c1o2) + mfbca * ( vz2 + vvz) * c1o2; - mfbca = m0; - mfbcb = m1; - mfbcc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcac * c1o2 + mfcab * (vvz - c1o2) + (mfcaa + c1o3 * oMdrho) * ( vz2 - vvz) * c1o2; - m1 = -mfcac - 2. * mfcab * vvz + mfcaa * (1. - vz2) - c1o3 * oMdrho * vz2; - m2 = mfcac * c1o2 + mfcab * (vvz + c1o2) + (mfcaa + c1o3 * oMdrho) * ( vz2 + vvz) * c1o2; - mfcaa = m0; - mfcab = m1; - mfcac = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfcbc * c1o2 + mfcbb * (vvz - c1o2) + mfcba * ( vz2 - vvz) * c1o2; - m1 = -mfcbc - 2. * mfcbb * vvz + mfcba * (1. - vz2); - m2 = mfcbc * c1o2 + mfcbb * (vvz + c1o2) + mfcba * ( vz2 + vvz) * c1o2; - mfcba = m0; - mfcbb = m1; - mfcbc = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2 + mfccb * (vvz - c1o2) + (mfcca + c1o9 * oMdrho) * ( vz2 - vvz) * c1o2; - m1 = -mfccc - 2. * mfccb * vvz + mfcca * (1. - vz2) - c1o9 * oMdrho * vz2; - m2 = mfccc * c1o2 + mfccb * (vvz + c1o2) + (mfcca + c1o9 * oMdrho) * ( vz2 + vvz) * c1o2; - mfcca = m0; - mfccb = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - //mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // Y - Dir - m0 = mfaca * c1o2 + mfaba * (vvy - c1o2) + (mfaaa + c1o6 * oMdrho) * ( vy2 - vvy) * c1o2; - m1 = -mfaca - 2. * mfaba * vvy + mfaaa * (1. - vy2) - c1o6 * oMdrho * vy2; - m2 = mfaca * c1o2 + mfaba * (vvy + c1o2) + (mfaaa + c1o6 * oMdrho) * ( vy2 + vvy) * c1o2; - mfaaa = m0; - mfaba = m1; - mfaca = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacb * c1o2 + mfabb * (vvy - c1o2) + (mfaab + c2o3 * oMdrho) * ( vy2 - vvy) * c1o2; - m1 = -mfacb - 2. * mfabb * vvy + mfaab * (1. - vy2) - c2o3 * oMdrho * vy2; - m2 = mfacb * c1o2 + mfabb * (vvy + c1o2) + (mfaab + c2o3 * oMdrho) * ( vy2 + vvy) * c1o2; - mfaab = m0; - mfabb = m1; - mfacb = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfacc * c1o2 + mfabc * (vvy - c1o2) + (mfaac + c1o6 * oMdrho) * ( vy2 - vvy) * c1o2; - m1 = -mfacc - 2. * mfabc * vvy + mfaac * (1. - vy2) - c1o6 * oMdrho * vy2; - m2 = mfacc * c1o2 + mfabc * (vvy + c1o2) + (mfaac + c1o6 * oMdrho) * ( vy2 + vvy) * c1o2; - mfaac = m0; - mfabc = m1; - mfacc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfbca * c1o2 + mfbba * (vvy - c1o2) + mfbaa * ( vy2 - vvy) * c1o2; - m1 = -mfbca - 2. * mfbba * vvy + mfbaa * (1. - vy2); - m2 = mfbca * c1o2 + mfbba * (vvy + c1o2) + mfbaa * ( vy2 + vvy) * c1o2; - mfbaa = m0; - mfbba = m1; - mfbca = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcb * c1o2 + mfbbb * (vvy - c1o2) + mfbab * ( vy2 - vvy) * c1o2; - m1 = -mfbcb - 2. * mfbbb * vvy + mfbab * (1. - vy2); - m2 = mfbcb * c1o2 + mfbbb * (vvy + c1o2) + mfbab * ( vy2 + vvy) * c1o2; - mfbab = m0; - mfbbb = m1; - mfbcb = m2; - /////////b////////////////////////////////////////////////////////////////////////// - m0 = mfbcc * c1o2 + mfbbc * (vvy - c1o2) + mfbac * ( vy2 - vvy) * c1o2; - m1 = -mfbcc - 2. * mfbbc * vvy + mfbac * (1. - vy2); - m2 = mfbcc * c1o2 + mfbbc * (vvy + c1o2) + mfbac * ( vy2 + vvy) * c1o2; - mfbac = m0; - mfbbc = m1; - mfbcc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcca * c1o2 + mfcba * (vvy - c1o2) + (mfcaa + c1o18 * oMdrho) * ( vy2 - vvy) * c1o2; - m1 = -mfcca - 2. * mfcba * vvy + mfcaa * (1. - vy2) - c1o18 * oMdrho * vy2; - m2 = mfcca * c1o2 + mfcba * (vvy + c1o2) + (mfcaa + c1o18 * oMdrho) * ( vy2 + vvy) * c1o2; - mfcaa = m0; - mfcba = m1; - mfcca = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccb * c1o2 + mfcbb * (vvy - c1o2) + (mfcab + c2o9 * oMdrho) * ( vy2 - vvy) * c1o2; - m1 = -mfccb - 2. * mfcbb * vvy + mfcab * (1. - vy2) - c2o9 * oMdrho * vy2; - m2 = mfccb * c1o2 + mfcbb * (vvy + c1o2) + (mfcab + c2o9 * oMdrho) * ( vy2 + vvy) * c1o2; - mfcab = m0; - mfcbb = m1; - mfccb = m2; - /////////c////////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2 + mfcbc * (vvy - c1o2) + (mfcac + c1o18 * oMdrho) * ( vy2 - vvy) * c1o2; - m1 = -mfccc - 2. * mfcbc * vvy + mfcac * (1. - vy2) - c1o18 * oMdrho * vy2; - m2 = mfccc * c1o2 + mfcbc * (vvy + c1o2) + (mfcac + c1o18 * oMdrho) * ( vy2 + vvy) * c1o2; - mfcac = m0; - mfcbc = m1; - mfccc = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - //mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren - //////////////////////////////////////////////////////////////////////////////////// - // X - Dir - m0 = mfcaa * c1o2 + mfbaa * (vvx - c1o2) + (mfaaa + c1o36 * oMdrho) * ( vx2 - vvx) * c1o2; - m1 = -mfcaa - 2. * mfbaa * vvx + mfaaa * (1. - vx2) - c1o36 * oMdrho * vx2; - m2 = mfcaa * c1o2 + mfbaa * (vvx + c1o2) + (mfaaa + c1o36 * oMdrho) * ( vx2 + vvx) * c1o2; - mfaaa = m0; - mfbaa = m1; - mfcaa = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcba * c1o2 + mfbba * (vvx - c1o2) + (mfaba + c1o9 * oMdrho) * ( vx2 - vvx) * c1o2; - m1 = -mfcba - 2. * mfbba * vvx + mfaba * (1. - vx2) - c1o9 * oMdrho * vx2; - m2 = mfcba * c1o2 + mfbba * (vvx + c1o2) + (mfaba + c1o9 * oMdrho) * ( vx2 + vvx) * c1o2; - mfaba = m0; - mfbba = m1; - mfcba = m2; - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcca * c1o2 + mfbca * (vvx - c1o2) + (mfaca + c1o36 * oMdrho) * ( vx2 - vvx) * c1o2; - m1 = -mfcca - 2. * mfbca * vvx + mfaca * (1. - vx2) - c1o36 * oMdrho * vx2; - m2 = mfcca * c1o2 + mfbca * (vvx + c1o2) + (mfaca + c1o36 * oMdrho) * ( vx2 + vvx) * c1o2; - mfaca = m0; - mfbca = m1; - mfcca = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcab * c1o2 + mfbab * (vvx - c1o2) + (mfaab + c1o9 * oMdrho) * ( vx2 - vvx) * c1o2; - m1 = -mfcab - 2. * mfbab * vvx + mfaab * (1. - vx2) - c1o9 * oMdrho * vx2; - m2 = mfcab * c1o2 + mfbab * (vvx + c1o2) + (mfaab + c1o9 * oMdrho) * ( vx2 + vvx) * c1o2; - mfaab = m0; - mfbab = m1; - mfcab = m2; - ///////////b//////////////////////////////////////////////////////////////////////// - m0 = mfcbb * c1o2 + mfbbb * (vvx - c1o2) + (mfabb + c4o9 * oMdrho) * ( vx2 - vvx) * c1o2; - m1 = -mfcbb - 2. * mfbbb * vvx + mfabb * (1. - vx2) - c4o9 * oMdrho * vx2; - m2 = mfcbb * c1o2 + mfbbb * (vvx + c1o2) + (mfabb + c4o9 * oMdrho) * ( vx2 + vvx) * c1o2; - mfabb = m0; - mfbbb = m1; - mfcbb = m2; - ///////////b//////////////////////////////////////////////////////////////////////// - m0 = mfccb * c1o2 + mfbcb * (vvx - c1o2) + (mfacb + c1o9 * oMdrho) * ( vx2 - vvx) * c1o2; - m1 = -mfccb - 2. * mfbcb * vvx + mfacb * (1. - vx2) - c1o9 * oMdrho * vx2; - m2 = mfccb * c1o2 + mfbcb * (vvx + c1o2) + (mfacb + c1o9 * oMdrho) * ( vx2 + vvx) * c1o2; - mfacb = m0; - mfbcb = m1; - mfccb = m2; - //////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////// - m0 = mfcac * c1o2 + mfbac * (vvx - c1o2) + (mfaac + c1o36 * oMdrho) * ( vx2 - vvx) * c1o2; - m1 = -mfcac - 2. * mfbac * vvx + mfaac * (1. - vx2) - c1o36 * oMdrho * vx2; - m2 = mfcac * c1o2 + mfbac * (vvx + c1o2) + (mfaac + c1o36 * oMdrho) * ( vx2 + vvx) * c1o2; - mfaac = m0; - mfbac = m1; - mfcac = m2; - ///////////c//////////////////////////////////////////////////////////////////////// - m0 = mfcbc * c1o2 + mfbbc * (vvx - c1o2) + (mfabc + c1o9 * oMdrho) * ( vx2 - vvx) * c1o2; - m1 = -mfcbc - 2. * mfbbc * vvx + mfabc * (1. - vx2) - c1o9 * oMdrho * vx2; - m2 = mfcbc * c1o2 + mfbbc * (vvx + c1o2) + (mfabc + c1o9 * oMdrho) * ( vx2 + vvx) * c1o2; - mfabc = m0; - mfbbc = m1; - mfcbc = m2; - ///////////c//////////////////////////////////////////////////////////////////////// - m0 = mfccc * c1o2 + mfbcc * (vvx - c1o2) + (mfacc + c1o36 * oMdrho) * ( vx2 - vvx) * c1o2; - m1 = -mfccc - 2. * mfbcc * vvx + mfacc * (1. - vx2) - c1o36 * oMdrho * vx2; - m2 = mfccc * c1o2 + mfbcc * (vvx + c1o2) + (mfacc + c1o36 * oMdrho) * ( vx2 + vvx) * c1o2; - mfacc = m0; - mfbcc = m1; - mfccc = m2; - - ////////////////////////////////////////////////////////////////////////// - //proof correctness - ////////////////////////////////////////////////////////////////////////// -#ifdef PROOF_CORRECTNESS - LBMReal rho_post = (mfaaa+mfaac+mfaca+mfcaa+mfacc+mfcac+mfccc+mfcca) - +(mfaab+mfacb+mfcab+mfccb)+(mfaba+mfabc+mfcba+mfcbc)+(mfbaa+mfbac+mfbca+mfbcc) - +(mfabb+mfcbb)+(mfbab+mfbcb)+(mfbba+mfbbc)+mfbbb; - //LBMReal dif = fabs(rho - rho_post); - LBMReal dif = rho - rho_post; -#ifdef SINGLEPRECISION - if(dif > 10.0E-7 || dif < -10.0E-7) -#else - if(dif > 10.0E-15 || dif < -10.0E-15) -#endif - { - UB_THROW(UbException(UB_EXARGS,"rho="+UbSystem::toString(rho)+", rho_post="+UbSystem::toString(rho_post) - +" dif="+UbSystem::toString(dif) - +" rho is not correct for node "+UbSystem::toString(x1)+","+UbSystem::toString(x2)+","+UbSystem::toString(x3) - +" in " + block.lock()->toString()+" step = "+UbSystem::toString(step))); - } -#endif - ////////////////////////////////////////////////////////////////////////// - //write distribution - ////////////////////////////////////////////////////////////////////////// - (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = mfabb; - (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = mfbab; - (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = mfbba; - (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = mfaab; - (*this->localDistributions)(D3Q27System::ET_NW,x1p,x2, x3) = mfcab; - (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = mfaba; - (*this->localDistributions)(D3Q27System::ET_TW,x1p,x2, x3) = mfcba; - (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = mfbaa; - (*this->localDistributions)(D3Q27System::ET_TS,x1, x2p,x3) = mfbca; - (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = mfaaa; - (*this->localDistributions)(D3Q27System::ET_TNW,x1p,x2, x3) = mfcaa; - (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2p,x3) = mfaca; - (*this->localDistributions)(D3Q27System::ET_TSW,x1p,x2p,x3) = mfcca; - - (*this->nonLocalDistributions)(D3Q27System::ET_W,x1p,x2, x3 ) = mfcbb; - (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2p,x3 ) = mfbcb; - (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3p ) = mfbbc; - (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1p,x2p,x3 ) = mfccb; - (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2p,x3 ) = mfacb; - (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1p,x2, x3p ) = mfcbc; - (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3p ) = mfabc; - (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2p,x3p ) = mfbcc; - (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3p ) = mfbac; - (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1p,x2p,x3p) = mfccc; - (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2p,x3p) = mfacc; - (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1p,x2, x3p) = mfcac; - (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3p) = mfaac; - - (*this->zeroDistributions)(x1,x2,x3) = mfbbb; - ////////////////////////////////////////////////////////////////////////// - - collFactor = collFactor0; - - } - } - } - } -} - diff --git a/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.h deleted file mode 100644 index 980edc26e..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef IncompressibleCumulantWithSpongeLayerLBMKernel_H -#define IncompressibleCumulantWithSpongeLayerLBMKernel_H - -#include "IncompressibleCumulantLBMKernel.h" - -//! \brief Cascaded Cumulant LBM kernel. -//! \details CFD solver with sponge layer that use Cascaded Cumulant Lattice Boltzmann method for D3Q27 model <br> -//! variable spongeFactor is depending on funktion in muSpongeLayer and varies between 1 (do nothing) und 0.5 (collFactor about 1); -//! Initialization in test case (example): <br> -//! \code{.cpp} -//! int sizeSP=8; //width of sponge layer in blocks -//! mu::Parser spongeLayer; -//! spongeLayer.SetExpr("x1>=(sizeX-sizeSP)/dt ? (sizeX-(x1+1))/sizeSP/2.0 + 0.5 : 1.0"); -//! spongeLayer.DefineConst("sizeX", nx[0]*blocknx[0]); // width of grid for X in coarse nodes -//! spongeLayer.DefineConst("sizeSP", sizeSP*blocknx[0]); // width of sponge layer in coarse nodes -//! kernel->setWithSpongeLayer(true); -//! kernel->setSpongeLayer(spongeLayer); -//! \endcode -//! \author K. Kucher, M. Geier, A. Karanchuk -class IncompressibleCumulantWithSpongeLayerLBMKernel : public IncompressibleCumulantLBMKernel -{ -public: - IncompressibleCumulantWithSpongeLayerLBMKernel(); - virtual ~IncompressibleCumulantWithSpongeLayerLBMKernel(void); - SPtr<LBMKernel> clone(); - void calculate(int step); - void initRelaxFactor(int vdir, double vL1, double vdx, double vSP); - //! \param vdir where the sponge layer is placed - //! \param vL1 length of simulation domain - //! \param vdx subgrid space - //! \param vSP length of sponge layer - void setRelaxFactorParam(int vdir, double vL1, double vdx, double vSP); -protected: - void initDataSet(); - LBMReal OxyyMxzz; - int direction; - double L1; - double dx; - double SP; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/LBM/IncompressibleOffsetInterpolationProcessor.cpp b/src/cpu/VirtualFluidsCore/LBM/IncompressibleOffsetInterpolationProcessor.cpp deleted file mode 100644 index 2e780550b..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/IncompressibleOffsetInterpolationProcessor.cpp +++ /dev/null @@ -1,794 +0,0 @@ -#include "IncompressibleOffsetInterpolationProcessor.h" -#include "D3Q27System.h" - - - -IncompressibleOffsetInterpolationProcessor::IncompressibleOffsetInterpolationProcessor() - : omegaC(0.0), omegaF(0.0) -{ - //forcingC = 0; //9.99685e-7; - //forcingF = 0; //forcingC*0.5; -} -////////////////////////////////////////////////////////////////////////// -IncompressibleOffsetInterpolationProcessor::IncompressibleOffsetInterpolationProcessor(LBMReal omegaC, LBMReal omegaF) - : omegaC(omegaC), omegaF(omegaF) -{ - -} -////////////////////////////////////////////////////////////////////////// -IncompressibleOffsetInterpolationProcessor::~IncompressibleOffsetInterpolationProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -InterpolationProcessorPtr IncompressibleOffsetInterpolationProcessor::clone() -{ - InterpolationProcessorPtr iproc = InterpolationProcessorPtr (new IncompressibleOffsetInterpolationProcessor(this->omegaC, this->omegaF)); - //dynamicPointerCast<D3Q27IncompressibleOffsetInterpolationProcessor>(iproc)->forcingC = forcingC; - //dynamicPointerCast<D3Q27IncompressibleOffsetInterpolationProcessor>(iproc)->forcingF = forcingF; - return iproc; -} -////////////////////////////////////////////////////////////////////////// -void IncompressibleOffsetInterpolationProcessor::setOmegas( LBMReal omegaC, LBMReal omegaF ) -{ - this->omegaC = omegaC; - this->omegaF = omegaF; -} -////////////////////////////////////////////////////////////////////////// -void IncompressibleOffsetInterpolationProcessor::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 IncompressibleOffsetInterpolationProcessor::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 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 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; - - //UBLOG(logINFO,"D3Q27System::BW = " << D3Q27System::BW); - //UBLOG(logINFO,"BW = " << BW); - - LBMReal rho = 0.0; - D3Q27System::calcIncompMacroscopicValues(f,rho,vx1,vx2,vx3); - - ////////////////////////////////////////////////////////////////////////// - //DRAFT - //if (omega == omegaC) - //{ - // vx1 += forcingC*0.5; - //} - //else - //{ - // vx1 += forcingF*0.5; - //} - ////////////////////////////////////////////////////////////////////////// - - //press = D3Q27System::calcPress(f,rho,vx1,vx2,vx3); - press = rho; //interpolate rho! - - kxy = -3.*omega*((((f[TSW]+f[BNE])-(f[TNW]+f[BSE]))+((f[BSW]+f[TNE])-(f[BNW]+f[TSE])))+((f[SW]+f[NE])-(f[NW]+f[SE]))-(vx1*vx2));// might not be optimal MG 25.2.13 - kyz = -3.*omega*((((f[BSW]+f[TNE])-(f[TSE]+f[BNW]))+((f[BSE]+f[TNW])-(f[TSW]+f[BNE])))+((f[BS]+f[TN])-(f[TS]+f[BN]))-(vx2*vx3)); - kxz = -3.*omega*((((f[BNW]+f[TSE])-(f[TSW]+f[BNE]))+((f[BSW]+f[TNE])-(f[BSE]+f[TNW])))+((f[BW]+f[TE])-(f[TW]+f[BE]))-(vx1*vx3)); - kxxMyy = -3./2.*omega*((((f[D3Q27System::BW]+f[TE])-(f[BS]+f[TN]))+((f[TW]+f[BE])-(f[TS]+f[BN])))+((f[W]+f[E])-(f[S]+f[N]))-(vx1*vx1-vx2*vx2)); - kxxMzz = -3./2.*omega*((((f[NW]+f[SE])-(f[BS]+f[TN]))+((f[SW]+f[NE])-(f[TS]+f[BN])))+((f[W]+f[E])-(f[B]+f[T]))-(vx1*vx1-vx3*vx3)); - //kxxMzz = -3./2.*omega*(((((f[NW]+f[SE])-(f[BS]+f[TN]))+((f[SW]+f[NE])-(f[17]+f[BN])))+((f[W]+f[E])-(f[B]+f[T])))-(vx1*vx1-vx3*vx3)); - - //UBLOG(logINFO, "t1 = "<<(((f[NW]+f[SE])-(f[BS]+f[TN]))+((f[SW]+f[NE])-(f[17]+f[BN])))+((f[W]+f[E])-(f[B]+f[T]))); - //UBLOG(logINFO, "kxxMzz = "<<kxxMzz); - - //UBLOG(logINFO,"f[BW] = " << f[BW] << " BW = " << BW); - //UBLOG(logINFO,"f[BE] = " << f[BE] << " BE = " << BE); - //UBLOG(logINFO,"f[NW] = " << f[NW] << " NW = " << NW); - //UBLOG(logINFO,"f[SE] = " << f[SE] << " SE = " << SE); - //UBLOG(logINFO,"f[BS] = " << f[BS] << " BS = " << BS); - //UBLOG(logINFO,"f[TN] = " << f[TN] << " TN = " << TN); -} -////////////////////////////////////////////////////////////////////////// -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; - 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); - - //LBMReal dxRho=c1o4*((press_NET-press_SWB)+(press_SET-press_NWB)+(press_NEB-press_SWT)+(press_SEB-press_NWT)); - //LBMReal dyRho=c1o4*((press_NET-press_SWB)-(press_SET-press_NWB)+(press_NEB-press_SWT)-(press_SEB-press_NWT)); - //LBMReal dzRho=c1o4*((press_NET-press_SWB)+(press_SET-press_NWB)-(press_NEB-press_SWT)-(press_SEB-press_NWT)); - - // kxyFromfcNEQ_SWT+=vx1_SWT*dyRho+vx2_SWT*dxRho; - // kxyFromfcNEQ_NWT+=vx1_NWT*dyRho+vx2_NWT*dxRho; - // kxyFromfcNEQ_NET+=vx1_NET*dyRho+vx2_NET*dxRho; - // kxyFromfcNEQ_SET+=vx1_SET*dyRho+vx2_SET*dxRho; - // kxyFromfcNEQ_SWB+=vx1_SWB*dyRho+vx2_SWB*dxRho; - // kxyFromfcNEQ_NWB+=vx1_NWB*dyRho+vx2_NWB*dxRho; - // kxyFromfcNEQ_NEB+=vx1_NEB*dyRho+vx2_NEB*dxRho; - // kxyFromfcNEQ_SEB+=vx1_SEB*dyRho+vx2_SEB*dxRho; - - // kyzFromfcNEQ_SWT+=vx3_SWT*dyRho+vx2_SWT*dzRho; - // kyzFromfcNEQ_NWT+=vx3_NWT*dyRho+vx2_NWT*dzRho; - // kyzFromfcNEQ_NET+=vx3_NET*dyRho+vx2_NET*dzRho; - // kyzFromfcNEQ_SET+=vx3_SET*dyRho+vx2_SET*dzRho; - // kyzFromfcNEQ_SWB+=vx3_SWB*dyRho+vx2_SWB*dzRho; - // kyzFromfcNEQ_NWB+=vx3_NWB*dyRho+vx2_NWB*dzRho; - // kyzFromfcNEQ_NEB+=vx3_NEB*dyRho+vx2_NEB*dzRho; - // kyzFromfcNEQ_SEB+=vx3_SEB*dyRho+vx2_SEB*dzRho; - - // kxzFromfcNEQ_SWT+=vx1_SWT*dzRho+vx3_SWT*dxRho; - // kxzFromfcNEQ_NWT+=vx1_NWT*dzRho+vx3_NWT*dxRho; - // kxzFromfcNEQ_NET+=vx1_NET*dzRho+vx3_NET*dxRho; - // kxzFromfcNEQ_SET+=vx1_SET*dzRho+vx3_SET*dxRho; - // kxzFromfcNEQ_SWB+=vx1_SWB*dzRho+vx3_SWB*dxRho; - // kxzFromfcNEQ_NWB+=vx1_NWB*dzRho+vx3_NWB*dxRho; - // kxzFromfcNEQ_NEB+=vx1_NEB*dzRho+vx3_NEB*dxRho; - // kxzFromfcNEQ_SEB+=vx1_SEB*dzRho+vx3_SEB*dxRho; - - // kxxMyyFromfcNEQ_SWT+=vx1_SWT*dxRho-vx2_SWT*dyRho; - // kxxMyyFromfcNEQ_NWT+=vx1_NWT*dxRho-vx2_NWT*dyRho; - // kxxMyyFromfcNEQ_NET+=vx1_NET*dxRho-vx2_NET*dyRho; - // kxxMyyFromfcNEQ_SET+=vx1_SET*dxRho-vx2_SET*dyRho; - // kxxMyyFromfcNEQ_SWB+=vx1_SWB*dxRho-vx2_SWB*dyRho; - // kxxMyyFromfcNEQ_NWB+=vx1_NWB*dxRho-vx2_NWB*dyRho; - // kxxMyyFromfcNEQ_NEB+=vx1_NEB*dxRho-vx2_NEB*dyRho; - // kxxMyyFromfcNEQ_SEB+=vx1_SEB*dxRho-vx2_SEB*dyRho; - - // kxxMzzFromfcNEQ_SWT+=vx1_SWT*dxRho-vx3_SWT*dzRho; - // kxxMzzFromfcNEQ_NWT+=vx1_NWT*dxRho-vx3_NWT*dzRho; - // kxxMzzFromfcNEQ_NET+=vx1_NET*dxRho-vx3_NET*dzRho; - // kxxMzzFromfcNEQ_SET+=vx1_SET*dxRho-vx3_SET*dzRho; - // kxxMzzFromfcNEQ_SWB+=vx1_SWB*dxRho-vx3_SWB*dzRho; - // kxxMzzFromfcNEQ_NWB+=vx1_NWB*dxRho-vx3_NWB*dzRho; - // kxxMzzFromfcNEQ_NEB+=vx1_NEB*dxRho-vx3_NEB*dzRho; - // kxxMzzFromfcNEQ_SEB+=vx1_SEB*dxRho-vx3_SEB*dzRho; - - - //kxxMzzFromfcNEQ_SWT=0.0; - //kxxMzzFromfcNEQ_NWT=0.0; - //kxxMzzFromfcNEQ_NET=0.0; - //kxxMzzFromfcNEQ_SET=0.0; - //kxxMzzFromfcNEQ_SWB=0.0; - //kxxMzzFromfcNEQ_NWB=0.0; - //kxxMzzFromfcNEQ_NEB=0.0; - //kxxMzzFromfcNEQ_SEB=0.0; - - - - - - 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; - - /////////////////////BÖSE!!! - //axx=0; ayy=0; azz=0; - //bxx=0; byy=0; bzz=0; - //cxx=0; cyy=0; czz=0; - ////////////////////!!!BÖSE - - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //kxyAverage =(kxyFromfcNEQ_SWB+ - // kxyFromfcNEQ_SWT+ - // kxyFromfcNEQ_SET+ - // kxyFromfcNEQ_SEB+ - // kxyFromfcNEQ_NWB+ - // kxyFromfcNEQ_NWT+ - // kxyFromfcNEQ_NET+ - // kxyFromfcNEQ_NEB)*c1o8-(ay+bx); - //kyzAverage =(kyzFromfcNEQ_SWB+ - // kyzFromfcNEQ_SWT+ - // kyzFromfcNEQ_SET+ - // kyzFromfcNEQ_SEB+ - // kyzFromfcNEQ_NWB+ - // kyzFromfcNEQ_NWT+ - // kyzFromfcNEQ_NET+ - // kyzFromfcNEQ_NEB)*c1o8-(bz+cy); - //kxzAverage =(kxzFromfcNEQ_SWB+ - // kxzFromfcNEQ_SWT+ - // kxzFromfcNEQ_SET+ - // kxzFromfcNEQ_SEB+ - // kxzFromfcNEQ_NWB+ - // kxzFromfcNEQ_NWT+ - // kxzFromfcNEQ_NET+ - // kxzFromfcNEQ_NEB)*c1o8-(az+cx); - //kxxMyyAverage =(kxxMyyFromfcNEQ_SWB+ - // kxxMyyFromfcNEQ_SWT+ - // kxxMyyFromfcNEQ_SET+ - // kxxMyyFromfcNEQ_SEB+ - // kxxMyyFromfcNEQ_NWB+ - // kxxMyyFromfcNEQ_NWT+ - // kxxMyyFromfcNEQ_NET+ - // kxxMyyFromfcNEQ_NEB)*c1o8-(ax-by); - //kxxMzzAverage =(kxxMzzFromfcNEQ_SWB+ - // kxxMzzFromfcNEQ_SWT+ - // kxxMzzFromfcNEQ_SET+ - // kxxMzzFromfcNEQ_SEB+ - // kxxMzzFromfcNEQ_NWB+ - // kxxMzzFromfcNEQ_NWT+ - // kxxMzzFromfcNEQ_NET+ - // kxxMzzFromfcNEQ_NEB)*c1o8-(ax-cz); - kxyAverage =0;//(kxyFromfcNEQ_SWB+ - //kxyFromfcNEQ_SWT+ - //kxyFromfcNEQ_SET+ - //kxyFromfcNEQ_SEB+ - //kxyFromfcNEQ_NWB+ - //kxyFromfcNEQ_NWT+ - //kxyFromfcNEQ_NET+ - //kxyFromfcNEQ_NEB)*c1o8-(ay+bx); - kyzAverage =0;//(kyzFromfcNEQ_SWB+ - //kyzFromfcNEQ_SWT+ - //kyzFromfcNEQ_SET+ - //kyzFromfcNEQ_SEB+ - //kyzFromfcNEQ_NWB+ - //kyzFromfcNEQ_NWT+ - //kyzFromfcNEQ_NET+ - //kyzFromfcNEQ_NEB)*c1o8-(bz+cy); - kxzAverage =0;//(kxzFromfcNEQ_SWB+ - //kxzFromfcNEQ_SWT+ - //kxzFromfcNEQ_SET+ - //kxzFromfcNEQ_SEB+ - //kxzFromfcNEQ_NWB+ - //kxzFromfcNEQ_NWT+ - //kxzFromfcNEQ_NET+ - //kxzFromfcNEQ_NEB)*c1o8-(az+cx); - kxxMyyAverage =0;//(kxxMyyFromfcNEQ_SWB+ - //kxxMyyFromfcNEQ_SWT+ - //kxxMyyFromfcNEQ_SET+ - //kxxMyyFromfcNEQ_SEB+ - //kxxMyyFromfcNEQ_NWB+ - //kxxMyyFromfcNEQ_NWT+ - //kxxMyyFromfcNEQ_NET+ - //kxxMyyFromfcNEQ_NEB)*c1o8-(ax-by); - kxxMzzAverage =0;//(kxxMzzFromfcNEQ_SWB+ - //kxxMzzFromfcNEQ_SWT+ - //kxxMzzFromfcNEQ_SET+ - //kxxMzzFromfcNEQ_SEB+ - //kxxMzzFromfcNEQ_NWB+ - //kxxMzzFromfcNEQ_NWT+ - //kxxMzzFromfcNEQ_NET+ - //kxxMzzFromfcNEQ_NEB)*c1o8-(ax-cz); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // - // 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-kxxMzzAverage-kxxMyyAverage))/(27.*o)); - f_N = eps_new*((2*(ax - 2*by + cz+2*kxxMyyAverage-kxxMzzAverage))/(27.*o)); - f_T = eps_new*((2*(ax + by - 2*cz-kxxMyyAverage+2*kxxMzzAverage))/(27.*o)); - f_NE = eps_new*(-(ax + 3*ay + 3*bx + by - 2*cz+2*kxxMyyAverage-kxxMyyAverage+3*kxyAverage)/(54.*o)); - f_SE = eps_new*(-(ax - 3*ay - 3*bx + by - 2*cz+2*kxxMyyAverage-kxxMyyAverage-3*kxyAverage)/(54.*o)); - f_TE = eps_new*(-(ax + 3*az - 2*by + 3*cx + cz+2*kxxMyyAverage-kxxMzzAverage+3*kxzAverage)/(54.*o)); - f_BE = eps_new*(-(ax - 3*az - 2*by - 3*cx + cz+2*kxxMyyAverage-kxxMzzAverage-3*kxzAverage)/(54.*o)); - f_TN = eps_new*(-(-2*ax + by + 3*bz + 3*cy + cz-kxxMyyAverage-kxxMzzAverage+3*kyzAverage)/(54.*o)); - f_BN = eps_new*(-(-2*ax + by - 3*bz - 3*cy + cz-kxxMyyAverage-kxxMzzAverage-3*kyzAverage)/(54.*o)); - f_ZERO = 0.; - f_TNE = eps_new*(-(ay + az + bx + bz + cx + cy+kxyAverage+kxzAverage+kyzAverage)/(72.*o)); - f_TSW = eps_new*((-ay + az - bx + bz + cx + cy-kxyAverage+kxzAverage+kyzAverage)/(72.*o)); - f_TSE = eps_new*((ay - az + bx + bz - cx + cy+kxyAverage-kxzAverage+kyzAverage)/(72.*o)); - f_TNW = eps_new*((ay + az + bx - bz + cx - cy+kxyAverage+kxzAverage-kyzAverage)/(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 IncompressibleOffsetInterpolationProcessor::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); - - ////////////////////////////////////////////////////////////////////////// - //DRAFT - //vx1 -= forcingF*0.5; - ////////////////////////////////////////////////////////////////////////// - - LBMReal feq[ENDF+1]; - D3Q27System::calcIncompFeq(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 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) + - 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 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) + - 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 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) + - 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 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) + - 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 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) + - 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 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) + - 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 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) + - 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 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) + - 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 IncompressibleOffsetInterpolationProcessor::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.; - - ////////////////////////////////////////////////////////////////////////// - //DRAFT - //vx1 -= forcingC*0.5; - ////////////////////////////////////////////////////////////////////////// - - LBMReal feq[ENDF+1]; - D3Q27System::calcIncompFeq(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 = eps_new*((2*(-2*ax + by + cz-kxxMzzAverage-kxxMyyAverage))/(27.*o)); - f_N = eps_new*((2*(ax - 2*by + cz+2*kxxMyyAverage-kxxMzzAverage))/(27.*o)); - f_T = eps_new*((2*(ax + by - 2*cz-kxxMyyAverage+2*kxxMzzAverage))/(27.*o)); - f_NE = eps_new*(-(ax + 3*ay + 3*bx + by - 2*cz+2*kxxMyyAverage-kxxMyyAverage+3*kxyAverage)/(54.*o)); - f_SE = eps_new*(-(ax - 3*ay - 3*bx + by - 2*cz+2*kxxMyyAverage-kxxMyyAverage-3*kxyAverage)/(54.*o)); - f_TE = eps_new*(-(ax + 3*az - 2*by + 3*cx + cz+2*kxxMyyAverage-kxxMzzAverage+3*kxzAverage)/(54.*o)); - f_BE = eps_new*(-(ax - 3*az - 2*by - 3*cx + cz+2*kxxMyyAverage-kxxMzzAverage-3*kxzAverage)/(54.*o)); - f_TN = eps_new*(-(-2*ax + by + 3*bz + 3*cy + cz-kxxMyyAverage-kxxMzzAverage+3*kyzAverage)/(54.*o)); - f_BN = eps_new*(-(-2*ax + by - 3*bz - 3*cy + cz-kxxMyyAverage-kxxMzzAverage-3*kyzAverage)/(54.*o)); - f_ZERO = 0.; - f_TNE = eps_new*(-(ay + az + bx + bz + cx + cy+kxyAverage+kxzAverage+kyzAverage)/(72.*o)); - f_TSW = eps_new*((-ay + az - bx + bz + cx + cy-kxyAverage+kxzAverage+kyzAverage)/(72.*o)); - f_TSE = eps_new*((ay - az + bx + bz - cx + cy+kxyAverage-kxzAverage+kyzAverage)/(72.*o)); - f_TNW = eps_new*((ay + az + bx - bz + cx - cy+kxyAverage+kxzAverage-kyzAverage)/(72.*o)); - - 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 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 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; - 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/src/cpu/VirtualFluidsCore/LBM/IncompressibleOffsetInterpolationProcessor.h b/src/cpu/VirtualFluidsCore/LBM/IncompressibleOffsetInterpolationProcessor.h deleted file mode 100644 index 021eb2d66..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/IncompressibleOffsetInterpolationProcessor.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef IncompressibleOffsetInterpolationProcessor_H_ -#define IncompressibleOffsetInterpolationProcessor_H_ - -#include "InterpolationProcessor.h" -#include "D3Q27System.h" - -////////////////////////////////////////////////////////////////////////// -//it works only for cascaded LBM -//super compact interpolation method by Martin Geier -////////////////////////////////////////////////////////////////////////// - -class IncompressibleOffsetInterpolationProcessor; -typedef SPtr<IncompressibleOffsetInterpolationProcessor> D3Q27IncompressibleOffsetInterpolationProcessorPtr; - -class IncompressibleOffsetInterpolationProcessor : public InterpolationProcessor -{ -public: - 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); - void interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC); - void interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC, LBMReal xoff, LBMReal yoff, LBMReal zoff); - //LBMReal forcingC, forcingF; -protected: -private: - 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*/; - - LBMReal kxyAverage, kyzAverage, kxzAverage, kxxMyyAverage, kxxMzzAverage; - - LBMReal a,b,c; - - 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 IncompressibleOffsetInterpolationProcessor::interpolateCoarseToFine(D3Q27ICell& icellC, D3Q27ICell& icellF) -{ - this->interpolateCoarseToFine(icellC, icellF, 0.0, 0.0, 0.0); -} -////////////////////////////////////////////////////////////////////////// -inline void IncompressibleOffsetInterpolationProcessor::interpolateFineToCoarse(D3Q27ICell& icellF, LBMReal* icellC) -{ - this->interpolateFineToCoarse(icellF, icellC, 0.0, 0.0, 0.0); -} - -#endif diff --git a/src/cpu/VirtualFluidsCore/LBM/InitDensityLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/InitDensityLBMKernel.cpp deleted file mode 100644 index 53b533508..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/InitDensityLBMKernel.cpp +++ /dev/null @@ -1,1071 +0,0 @@ -#include "InitDensityLBMKernel.h" -#include "D3Q27EsoTwist3DSplittedVector.h" -#include "BCProcessor.h" -#include "DataSet3D.h" -#include "BCArray3D.h" - -InitDensityLBMKernel::InitDensityLBMKernel() -{ - this->compressible = false; -} - -InitDensityLBMKernel::~InitDensityLBMKernel() -{ -} - -void InitDensityLBMKernel::initDataSet() -{ - SPtr<DistributionArray3D> d(new D3Q27EsoTwist3DSplittedVector(nx[0]+2, nx[1]+2, nx[2]+2, -999.9)); - dataSet->setFdistributions(d); - v.resize(3, nx[0]+2, nx[1]+2, nx[2]+2); - -} - -SPtr<LBMKernel> InitDensityLBMKernel::clone() -{ - SPtr<LBMKernel> kernel(new InitDensityLBMKernel()); - kernel->setNX(nx); - dynamicPointerCast<InitDensityLBMKernel>(kernel)->initDataSet(); - kernel->setCollisionFactor(this->collFactor); - kernel->setBCProcessor(bcProcessor->clone(kernel)); - kernel->setWithForcing(withForcing); - kernel->setForcingX1(muForcingX1); - kernel->setForcingX2(muForcingX2); - kernel->setForcingX3(muForcingX3); - kernel->setIndex(ix1, ix2, ix3); - kernel->setDeltaT(deltaT); - dynamicPointerCast<InitDensityLBMKernel>(kernel)->OxyyMxzz = 1.0; - return kernel; -} - -void InitDensityLBMKernel::setVelocity(int x1, int x2, int x3, LBMReal vvx, LBMReal vvy, LBMReal vvz) -{ - v(0, x1, x2, x3) = vvx; - v(1, x1, x2, x3) = vvy; - v(2, x1, x2, x3) = vvz; -} - -double InitDensityLBMKernel::getCalculationTime() -{ - return 0; -} - -//void InitDensityLBMKernel::collideAll() -//{ -// using namespace D3Q27System; -// -// localDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getLocalDistributions(); -// nonLocalDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getNonLocalDistributions(); -// zeroDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getZeroDistributions(); -// -// BCArray3D<D3Q27BoundaryCondition>& bcArray = dynamicPointerCast<D3Q27ETBCProcessor>(this->getBCProcessor())->getBCArray(); -// -// const int bcArrayMaxX1 = (int)bcArray->getNX1(); -// const int bcArrayMaxX2 = (int)bcArray->getNX2(); -// const int bcArrayMaxX3 = (int)bcArray->getNX3(); -// -// int minX1 = ghostLayerWidth; -// int minX2 = ghostLayerWidth; -// int minX3 = ghostLayerWidth; -// int maxX1 = bcArrayMaxX1-ghostLayerWidth; -// int maxX2 = bcArrayMaxX2-ghostLayerWidth; -// int maxX3 = bcArrayMaxX3-ghostLayerWidth; -// -// -// for (int x3 = minX3; x3<maxX3; x3++) -// { -// for (int x2 = minX2; x2<maxX2; x2++) -// { -// for (int x1 = minX1; x1<maxX1; x1++) -// { -// if (!bcArray->isSolid(x1, x2, x3)&&!bcArray->isUndefined(x1, x2, x3)) -// { -// int x1p = x1+1; -// int x2p = x2+1; -// int x3p = x3+1; -// ////////////////////////////////////////////////////////////////////////// -// //read distribution -// //////////////////////////////////////////////////////////////////////////// -// ////////////////////////////////////////////////////////////////////////// -// -// //E N T -// //c c c -// ////////// -// //W S B -// //a a a -// -// //Rest ist b -// -// //mfxyz -// //a - negative -// //b - null -// //c - positive -// -// // a b c -// //-1 0 1 -// -// LBMReal mfcbb = (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3); -// LBMReal mfbcb = (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3); -// LBMReal mfbbc = (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3); -// LBMReal mfccb = (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3); -// LBMReal mfacb = (*this->localDistributions)(D3Q27System::ET_NW, x1p, x2, x3); -// LBMReal mfcbc = (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3); -// LBMReal mfabc = (*this->localDistributions)(D3Q27System::ET_TW, x1p, x2, x3); -// LBMReal mfbcc = (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3); -// LBMReal mfbac = (*this->localDistributions)(D3Q27System::ET_TS, x1, x2p, x3); -// LBMReal mfccc = (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3); -// LBMReal mfacc = (*this->localDistributions)(D3Q27System::ET_TNW, x1p, x2, x3); -// LBMReal mfcac = (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2p, x3); -// LBMReal mfaac = (*this->localDistributions)(D3Q27System::ET_TSW, x1p, x2p, x3); -// -// LBMReal mfabb = (*this->nonLocalDistributions)(D3Q27System::ET_W, x1p, x2, x3); -// LBMReal mfbab = (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2p, x3); -// LBMReal mfbba = (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3p); -// LBMReal mfaab = (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1p, x2p, x3); -// LBMReal mfcab = (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2p, x3); -// LBMReal mfaba = (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1p, x2, x3p); -// LBMReal mfcba = (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3p); -// LBMReal mfbaa = (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2p, x3p); -// LBMReal mfbca = (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3p); -// LBMReal mfaaa = (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1p, x2p, x3p); -// LBMReal mfcaa = (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2p, x3p); -// LBMReal mfaca = (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1p, x2, x3p); -// LBMReal mfcca = (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3p); -// -// LBMReal mfbbb = (*this->zeroDistributions)(x1, x2, x3); -// -// LBMReal m0, m1, m2; -// -// LBMReal rho = (mfaaa+mfaac+mfaca+mfcaa+mfacc+mfcac+mfccc+mfcca) -// +(mfaab+mfacb+mfcab+mfccb)+(mfaba+mfabc+mfcba+mfcbc)+(mfbaa+mfbac+mfbca+mfbcc) -// +(mfabb+mfcbb)+(mfbab+mfbcb)+(mfbba+mfbbc)+mfbbb; -// -// //LBMReal vvx = ((((mfccc-mfaaa)+(mfcac-mfaca))+((mfcaa-mfacc)+(mfcca-mfaac)))+ -// // (((mfcba-mfabc)+(mfcbc-mfaba))+((mfcab-mfacb)+(mfccb-mfaab)))+ -// // (mfcbb-mfabb)); -// //LBMReal vvy = ((((mfccc-mfaaa)+(mfaca-mfcac))+((mfacc-mfcaa)+(mfcca-mfaac)))+ -// // (((mfbca-mfbac)+(mfbcc-mfbaa))+((mfacb-mfcab)+(mfccb-mfaab)))+ -// // (mfbcb-mfbab)); -// //LBMReal vvz = ((((mfccc-mfaaa)+(mfcac-mfaca))+((mfacc-mfcaa)+(mfaac-mfcca)))+ -// // (((mfbac-mfbca)+(mfbcc-mfbaa))+((mfabc-mfcba)+(mfcbc-mfaba)))+ -// // (mfbbc-mfbba)); -// -// LBMReal vvx = v(0,x1,x2,x3); -// LBMReal vvy = v(1,x1,x2,x3); -// LBMReal vvz = v(2,x1,x2,x3); -// //LBMReal rho = v(3,x1,x2,x3); -// -// LBMReal oMdrho; -// -// oMdrho = mfccc+mfaaa; -// m0 = mfaca+mfcac; -// m1 = mfacc+mfcaa; -// m2 = mfaac+mfcca; -// oMdrho += m0; -// m1 += m2; -// oMdrho += m1; -// m0 = mfbac+mfbca; -// m1 = mfbaa+mfbcc; -// m0 += m1; -// m1 = mfabc+mfcba; -// m2 = mfaba+mfcbc; -// m1 += m2; -// m0 += m1; -// m1 = mfacb+mfcab; -// m2 = mfaab+mfccb; -// m1 += m2; -// m0 += m1; -// oMdrho += m0; -// m0 = mfabb+mfcbb; -// m1 = mfbab+mfbcb; -// m2 = mfbba+mfbbc; -// m0 += m1+m2; -// m0 += mfbbb; //hat gefehlt -// oMdrho = 1.-(oMdrho+m0); -// -// LBMReal vx2; -// LBMReal vy2; -// LBMReal vz2; -// vx2 = vvx*vvx; -// vy2 = vvy*vvy; -// vz2 = vvz*vvz; -// //////////////////////////////////////////////////////////////////////////////////// -// LBMReal wadjust; -// LBMReal qudricLimit = 0.01; -// //////////////////////////////////////////////////////////////////////////////////// -// //Hin -// //////////////////////////////////////////////////////////////////////////////////// -// // mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren -// //////////////////////////////////////////////////////////////////////////////////// -// // Z - Dir -// m2 = mfaaa+mfaac; -// m1 = mfaac-mfaaa; -// m0 = m2+mfaab; -// mfaaa = m0; -// m0 += c1o36 * oMdrho; -// mfaab = m1-m0 * vvz; -// mfaac = m2-2. * m1 * vvz+vz2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfaba+mfabc; -// m1 = mfabc-mfaba; -// m0 = m2+mfabb; -// mfaba = m0; -// m0 += c1o9 * oMdrho; -// mfabb = m1-m0 * vvz; -// mfabc = m2-2. * m1 * vvz+vz2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfaca+mfacc; -// m1 = mfacc-mfaca; -// m0 = m2+mfacb; -// mfaca = m0; -// m0 += c1o36 * oMdrho; -// mfacb = m1-m0 * vvz; -// mfacc = m2-2. * m1 * vvz+vz2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfbaa+mfbac; -// m1 = mfbac-mfbaa; -// m0 = m2+mfbab; -// mfbaa = m0; -// m0 += c1o9 * oMdrho; -// mfbab = m1-m0 * vvz; -// mfbac = m2-2. * m1 * vvz+vz2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfbba+mfbbc; -// m1 = mfbbc-mfbba; -// m0 = m2+mfbbb; -// mfbba = m0; -// m0 += c4o9 * oMdrho; -// mfbbb = m1-m0 * vvz; -// mfbbc = m2-2. * m1 * vvz+vz2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfbca+mfbcc; -// m1 = mfbcc-mfbca; -// m0 = m2+mfbcb; -// mfbca = m0; -// m0 += c1o9 * oMdrho; -// mfbcb = m1-m0 * vvz; -// mfbcc = m2-2. * m1 * vvz+vz2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfcaa+mfcac; -// m1 = mfcac-mfcaa; -// m0 = m2+mfcab; -// mfcaa = m0; -// m0 += c1o36 * oMdrho; -// mfcab = m1-m0 * vvz; -// mfcac = m2-2. * m1 * vvz+vz2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfcba+mfcbc; -// m1 = mfcbc-mfcba; -// m0 = m2+mfcbb; -// mfcba = m0; -// m0 += c1o9 * oMdrho; -// mfcbb = m1-m0 * vvz; -// mfcbc = m2-2. * m1 * vvz+vz2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfcca+mfccc; -// m1 = mfccc-mfcca; -// m0 = m2+mfccb; -// mfcca = m0; -// m0 += c1o36 * oMdrho; -// mfccb = m1-m0 * vvz; -// mfccc = m2-2. * m1 * vvz+vz2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// //////////////////////////////////////////////////////////////////////////////////// -// // mit 1/6, 0, 1/18, 2/3, 0, 2/9, 1/6, 0, 1/18 Konditionieren -// //////////////////////////////////////////////////////////////////////////////////// -// // Y - Dir -// m2 = mfaaa+mfaca; -// m1 = mfaca-mfaaa; -// m0 = m2+mfaba; -// mfaaa = m0; -// m0 += c1o6 * oMdrho; -// mfaba = m1-m0 * vvy; -// mfaca = m2-2. * m1 * vvy+vy2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfaab+mfacb; -// m1 = mfacb-mfaab; -// m0 = m2+mfabb; -// mfaab = m0; -// mfabb = m1-m0 * vvy; -// mfacb = m2-2. * m1 * vvy+vy2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfaac+mfacc; -// m1 = mfacc-mfaac; -// m0 = m2+mfabc; -// mfaac = m0; -// m0 += c1o18 * oMdrho; -// mfabc = m1-m0 * vvy; -// mfacc = m2-2. * m1 * vvy+vy2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfbaa+mfbca; -// m1 = mfbca-mfbaa; -// m0 = m2+mfbba; -// mfbaa = m0; -// m0 += c2o3 * oMdrho; -// mfbba = m1-m0 * vvy; -// mfbca = m2-2. * m1 * vvy+vy2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfbab+mfbcb; -// m1 = mfbcb-mfbab; -// m0 = m2+mfbbb; -// mfbab = m0; -// mfbbb = m1-m0 * vvy; -// mfbcb = m2-2. * m1 * vvy+vy2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfbac+mfbcc; -// m1 = mfbcc-mfbac; -// m0 = m2+mfbbc; -// mfbac = m0; -// m0 += c2o9 * oMdrho; -// mfbbc = m1-m0 * vvy; -// mfbcc = m2-2. * m1 * vvy+vy2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfcaa+mfcca; -// m1 = mfcca-mfcaa; -// m0 = m2+mfcba; -// mfcaa = m0; -// m0 += c1o6 * oMdrho; -// mfcba = m1-m0 * vvy; -// mfcca = m2-2. * m1 * vvy+vy2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfcab+mfccb; -// m1 = mfccb-mfcab; -// m0 = m2+mfcbb; -// mfcab = m0; -// mfcbb = m1-m0 * vvy; -// mfccb = m2-2. * m1 * vvy+vy2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfcac+mfccc; -// m1 = mfccc-mfcac; -// m0 = m2+mfcbc; -// mfcac = m0; -// m0 += c1o18 * oMdrho; -// mfcbc = m1-m0 * vvy; -// mfccc = m2-2. * m1 * vvy+vy2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// //////////////////////////////////////////////////////////////////////////////////// -// // mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren -// //////////////////////////////////////////////////////////////////////////////////// -// // X - Dir -// m2 = mfaaa+mfcaa; -// m1 = mfcaa-mfaaa; -// m0 = m2+mfbaa; -// mfaaa = m0; -// m0 += 1. * oMdrho; -// mfbaa = m1-m0 * vvx; -// mfcaa = m2-2. * m1 * vvx+vx2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfaba+mfcba; -// m1 = mfcba-mfaba; -// m0 = m2+mfbba; -// mfaba = m0; -// mfbba = m1-m0 * vvx; -// mfcba = m2-2. * m1 * vvx+vx2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfaca+mfcca; -// m1 = mfcca-mfaca; -// m0 = m2+mfbca; -// mfaca = m0; -// m0 += c1o3 * oMdrho; -// mfbca = m1-m0 * vvx; -// mfcca = m2-2. * m1 * vvx+vx2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfaab+mfcab; -// m1 = mfcab-mfaab; -// m0 = m2+mfbab; -// mfaab = m0; -// mfbab = m1-m0 * vvx; -// mfcab = m2-2. * m1 * vvx+vx2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfabb+mfcbb; -// m1 = mfcbb-mfabb; -// m0 = m2+mfbbb; -// mfabb = m0; -// mfbbb = m1-m0 * vvx; -// mfcbb = m2-2. * m1 * vvx+vx2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfacb+mfccb; -// m1 = mfccb-mfacb; -// m0 = m2+mfbcb; -// mfacb = m0; -// mfbcb = m1-m0 * vvx; -// mfccb = m2-2. * m1 * vvx+vx2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfaac+mfcac; -// m1 = mfcac-mfaac; -// m0 = m2+mfbac; -// mfaac = m0; -// m0 += c1o3 * oMdrho; -// mfbac = m1-m0 * vvx; -// mfcac = m2-2. * m1 * vvx+vx2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfabc+mfcbc; -// m1 = mfcbc-mfabc; -// m0 = m2+mfbbc; -// mfabc = m0; -// mfbbc = m1-m0 * vvx; -// mfcbc = m2-2. * m1 * vvx+vx2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// m2 = mfacc+mfccc; -// m1 = mfccc-mfacc; -// m0 = m2+mfbcc; -// mfacc = m0; -// m0 += c1o9 * oMdrho; -// mfbcc = m1-m0 * vvx; -// mfccc = m2-2. * m1 * vvx+vx2 * m0; -// //////////////////////////////////////////////////////////////////////////////////// -// // Cumulants -// //////////////////////////////////////////////////////////////////////////////////// -// LBMReal OxxPyyPzz = 1.; //omega2 or bulk viscosity -// LBMReal OxyyPxzz = 1.;//-s9;//2+s9;// -// //LBMReal OxyyMxzz = 1.;//2+s9;// -// LBMReal O4 = 1.; -// LBMReal O5 = 1.; -// LBMReal O6 = 1.; -// -// //Cum 4. -// //LBMReal CUMcbb = mfcbb - ((mfcaa + c1o3 * oMdrho) * mfabb + 2. * mfbba * mfbab); // till 18.05.2015 -// //LBMReal CUMbcb = mfbcb - ((mfaca + c1o3 * oMdrho) * mfbab + 2. * mfbba * mfabb); // till 18.05.2015 -// //LBMReal CUMbbc = mfbbc - ((mfaac + c1o3 * oMdrho) * mfbba + 2. * mfbab * mfabb); // till 18.05.2015 -// -// LBMReal CUMcbb = mfcbb-((mfcaa+c1o3) * mfabb+2. * mfbba * mfbab); -// LBMReal CUMbcb = mfbcb-((mfaca+c1o3) * mfbab+2. * mfbba * mfabb); -// LBMReal CUMbbc = mfbbc-((mfaac+c1o3) * mfbba+2. * mfbab * mfabb); -// -// LBMReal CUMcca = mfcca-((mfcaa * mfaca+2. * mfbba * mfbba)+c1o3 * (mfcaa+mfaca) * oMdrho+c1o9*(oMdrho-1)*oMdrho); -// LBMReal CUMcac = mfcac-((mfcaa * mfaac+2. * mfbab * mfbab)+c1o3 * (mfcaa+mfaac) * oMdrho+c1o9*(oMdrho-1)*oMdrho); -// LBMReal CUMacc = mfacc-((mfaac * mfaca+2. * mfabb * mfabb)+c1o3 * (mfaac+mfaca) * oMdrho+c1o9*(oMdrho-1)*oMdrho); -// -// //Cum 5. -// LBMReal CUMbcc = mfbcc-(mfaac * mfbca+mfaca * mfbac+4. * mfabb * mfbbb+2. * (mfbab * mfacb+mfbba * mfabc))-c1o3 * (mfbca+mfbac) * oMdrho; -// LBMReal CUMcbc = mfcbc-(mfaac * mfcba+mfcaa * mfabc+4. * mfbab * mfbbb+2. * (mfabb * mfcab+mfbba * mfbac))-c1o3 * (mfcba+mfabc) * oMdrho; -// LBMReal CUMccb = mfccb-(mfcaa * mfacb+mfaca * mfcab+4. * mfbba * mfbbb+2. * (mfbab * mfbca+mfabb * mfcba))-c1o3 * (mfacb+mfcab) * oMdrho; -// -// //Cum 6. -// LBMReal CUMccc = mfccc+((-4. * mfbbb * mfbbb -// -(mfcaa * mfacc+mfaca * mfcac+mfaac * mfcca) -// -4. * (mfabb * mfcbb+mfbab * mfbcb+mfbba * mfbbc) -// -2. * (mfbca * mfbac+mfcba * mfabc+mfcab * mfacb)) -// +(4. * (mfbab * mfbab * mfaca+mfabb * mfabb * mfcaa+mfbba * mfbba * mfaac) -// +2. * (mfcaa * mfaca * mfaac) -// +16. * mfbba * mfbab * mfabb) -// -c1o3* (mfacc+mfcac+mfcca) * oMdrho-c1o9*oMdrho*oMdrho -// -c1o9* (mfcaa+mfaca+mfaac) * oMdrho*(1.-2.* oMdrho)-c1o27* oMdrho * oMdrho*(-2.* oMdrho) -// +(2. * (mfbab * mfbab+mfabb * mfabb+mfbba * mfbba) -// +(mfaac * mfaca+mfaac * mfcaa+mfaca * mfcaa)) * c2o3*oMdrho)+c1o27*oMdrho; -// -// //2. -// // linear combinations -// LBMReal mxxPyyPzz = mfcaa+mfaca+mfaac; -// LBMReal mxxMyy = mfcaa-mfaca; -// LBMReal mxxMzz = mfcaa-mfaac; -// -// LBMReal dxux = -c1o2 * collFactor *(mxxMyy+mxxMzz)+c1o2 * OxxPyyPzz*(mfaaa-mxxPyyPzz); -// LBMReal dyuy = dxux+collFactor * c3o2 * mxxMyy; -// LBMReal dzuz = dxux+collFactor * c3o2 * mxxMzz; -// -// //relax -// mxxPyyPzz += OxxPyyPzz*(mfaaa-mxxPyyPzz)-3. * (1.-c1o2 * OxxPyyPzz) * (vx2 * dxux+vy2 * dyuy+vz2 * dzuz); -// mxxMyy += collFactor * (-mxxMyy)-3. * (1.-c1o2 * collFactor) * (vx2 * dxux-vy2 * dyuy); -// mxxMzz += collFactor * (-mxxMzz)-3. * (1.-c1o2 * collFactor) * (vx2 * dxux-vz2 * dzuz); -// -// mfabb += collFactor * (-mfabb); -// mfbab += collFactor * (-mfbab); -// mfbba += collFactor * (-mfbba); -// -// // linear combinations back -// mfcaa = c1o3 * (mxxMyy+mxxMzz+mxxPyyPzz); -// mfaca = c1o3 * (-2. * mxxMyy+mxxMzz+mxxPyyPzz); -// mfaac = c1o3 * (mxxMyy-2. * mxxMzz+mxxPyyPzz); -// -// //3. -// // linear combinations -// LBMReal mxxyPyzz = mfcba+mfabc; -// LBMReal mxxyMyzz = mfcba-mfabc; -// -// LBMReal mxxzPyyz = mfcab+mfacb; -// LBMReal mxxzMyyz = mfcab-mfacb; -// -// LBMReal mxyyPxzz = mfbca+mfbac; -// LBMReal mxyyMxzz = mfbca-mfbac; -// -// //relax -// wadjust = OxyyMxzz+(1.-OxyyMxzz)*fabs(mfbbb)/(fabs(mfbbb)+qudricLimit); -// mfbbb += wadjust * (-mfbbb); -// wadjust = OxyyPxzz+(1.-OxyyPxzz)*fabs(mxxyPyzz)/(fabs(mxxyPyzz)+qudricLimit); -// mxxyPyzz += wadjust * (-mxxyPyzz); -// wadjust = OxyyMxzz+(1.-OxyyMxzz)*fabs(mxxyMyzz)/(fabs(mxxyMyzz)+qudricLimit); -// mxxyMyzz += wadjust * (-mxxyMyzz); -// wadjust = OxyyPxzz+(1.-OxyyPxzz)*fabs(mxxzPyyz)/(fabs(mxxzPyyz)+qudricLimit); -// mxxzPyyz += wadjust * (-mxxzPyyz); -// wadjust = OxyyMxzz+(1.-OxyyMxzz)*fabs(mxxzMyyz)/(fabs(mxxzMyyz)+qudricLimit); -// mxxzMyyz += wadjust * (-mxxzMyyz); -// wadjust = OxyyPxzz+(1.-OxyyPxzz)*fabs(mxyyPxzz)/(fabs(mxyyPxzz)+qudricLimit); -// mxyyPxzz += wadjust * (-mxyyPxzz); -// wadjust = OxyyMxzz+(1.-OxyyMxzz)*fabs(mxyyMxzz)/(fabs(mxyyMxzz)+qudricLimit); -// mxyyMxzz += wadjust * (-mxyyMxzz); -// -// // linear combinations back -// mfcba = (mxxyMyzz+mxxyPyzz) * c1o2; -// mfabc = (-mxxyMyzz+mxxyPyzz) * c1o2; -// mfcab = (mxxzMyyz+mxxzPyyz) * c1o2; -// mfacb = (-mxxzMyyz+mxxzPyyz) * c1o2; -// mfbca = (mxyyMxzz+mxyyPxzz) * c1o2; -// mfbac = (-mxyyMxzz+mxyyPxzz) * c1o2; -// -// //4. -// CUMacc += O4 * (-CUMacc); -// CUMcac += O4 * (-CUMcac); -// CUMcca += O4 * (-CUMcca); -// -// CUMbbc += O4 * (-CUMbbc); -// CUMbcb += O4 * (-CUMbcb); -// CUMcbb += O4 * (-CUMcbb); -// -// //5. -// CUMbcc += O5 * (-CUMbcc); -// CUMcbc += O5 * (-CUMcbc); -// CUMccb += O5 * (-CUMccb); -// -// //6. -// CUMccc += O6 * (-CUMccc); -// -// //back cumulants to central moments -// //4. -// //mfcbb = CUMcbb + ((mfcaa + c1o3 * oMdrho) * mfabb + 2. * mfbba * mfbab); // till 18.05.2015 -// //mfbcb = CUMbcb + ((mfaca + c1o3 * oMdrho) * mfbab + 2. * mfbba * mfabb); // till 18.05.2015 -// //mfbbc = CUMbbc + ((mfaac + c1o3 * oMdrho) * mfbba + 2. * mfbab * mfabb); // till 18.05.2015 -// -// mfcbb = CUMcbb+((mfcaa+c1o3) * mfabb+2. * mfbba * mfbab); -// mfbcb = CUMbcb+((mfaca+c1o3) * mfbab+2. * mfbba * mfabb); -// mfbbc = CUMbbc+((mfaac+c1o3) * mfbba+2. * mfbab * mfabb); -// -// mfcca = CUMcca+(mfcaa * mfaca+2. * mfbba * mfbba)+c1o3 * (mfcaa+mfaca) * oMdrho+c1o9*(oMdrho-1)*oMdrho; -// mfcac = CUMcac+(mfcaa * mfaac+2. * mfbab * mfbab)+c1o3 * (mfcaa+mfaac) * oMdrho+c1o9*(oMdrho-1)*oMdrho; -// mfacc = CUMacc+(mfaac * mfaca+2. * mfabb * mfabb)+c1o3 * (mfaac+mfaca) * oMdrho+c1o9*(oMdrho-1)*oMdrho; -// -// //5. -// mfbcc = CUMbcc+(mfaac * mfbca+mfaca * mfbac+4. * mfabb * mfbbb+2. * (mfbab * mfacb+mfbba * mfabc))+c1o3 * (mfbca+mfbac) * oMdrho; -// mfcbc = CUMcbc+(mfaac * mfcba+mfcaa * mfabc+4. * mfbab * mfbbb+2. * (mfabb * mfcab+mfbba * mfbac))+c1o3 * (mfcba+mfabc) * oMdrho; -// mfccb = CUMccb+(mfcaa * mfacb+mfaca * mfcab+4. * mfbba * mfbbb+2. * (mfbab * mfbca+mfabb * mfcba))+c1o3 * (mfacb+mfcab) * oMdrho; -// -// //6. -// mfccc = CUMccc-((-4. * mfbbb * mfbbb -// -(mfcaa * mfacc+mfaca * mfcac+mfaac * mfcca) -// -4. * (mfabb * mfcbb+mfbac * mfbca+mfbba * mfbbc) -// -2. * (mfbca * mfbac+mfcba * mfabc+mfcab * mfacb)) -// +(4. * (mfbab * mfbab * mfaca+mfabb * mfabb * mfcaa+mfbba * mfbba * mfaac) -// +2. * (mfcaa * mfaca * mfaac) -// +16. * mfbba * mfbab * mfabb) -// -c1o3* (mfacc+mfcac+mfcca) * oMdrho-c1o9*oMdrho*oMdrho -// -c1o9* (mfcaa+mfaca+mfaac) * oMdrho*(1.-2.* oMdrho)-c1o27* oMdrho * oMdrho*(-2.* oMdrho) -// +(2. * (mfbab * mfbab+mfabb * mfabb+mfbba * mfbba) -// +(mfaac * mfaca+mfaac * mfcaa+mfaca * mfcaa)) * c2o3*oMdrho)-c1o27*oMdrho; -// -// mfaab = 0.0; -// mfaba = 0.0; -// mfbaa = 0.0; -// -// //mfaab *= -0.5; -// //mfaba *= -0.5; -// //mfbaa *= -0.5; -// -// -// //////////////////////////////////////////////////////////////////////////////////// -// //back -// //////////////////////////////////////////////////////////////////////////////////// -// //mit 1, 0, 1/3, 0, 0, 0, 1/3, 0, 1/9 Konditionieren -// //////////////////////////////////////////////////////////////////////////////////// -// // Z - Dir -// m0 = mfaac * c1o2+mfaab * (vvz-c1o2)+(mfaaa+1. * oMdrho) * (vz2-vvz) * c1o2; -// m1 = -mfaac-2. * mfaab * vvz+mfaaa * (1.-vz2)-1. * oMdrho * vz2; -// m2 = mfaac * c1o2+mfaab * (vvz+c1o2)+(mfaaa+1. * oMdrho) * (vz2+vvz) * c1o2; -// mfaaa = m0; -// mfaab = m1; -// mfaac = m2; -// //////////////////////////////////////////////////////////////////////////////////// -// m0 = mfabc * c1o2+mfabb * (vvz-c1o2)+mfaba * (vz2-vvz) * c1o2; -// m1 = -mfabc-2. * mfabb * vvz+mfaba * (1.-vz2); -// m2 = mfabc * c1o2+mfabb * (vvz+c1o2)+mfaba * (vz2+vvz) * c1o2; -// mfaba = m0; -// mfabb = m1; -// mfabc = m2; -// //////////////////////////////////////////////////////////////////////////////////// -// m0 = mfacc * c1o2+mfacb * (vvz-c1o2)+(mfaca+c1o3 * oMdrho) * (vz2-vvz) * c1o2; -// m1 = -mfacc-2. * mfacb * vvz+mfaca * (1.-vz2)-c1o3 * oMdrho * vz2; -// m2 = mfacc * c1o2+mfacb * (vvz+c1o2)+(mfaca+c1o3 * oMdrho) * (vz2+vvz) * c1o2; -// mfaca = m0; -// mfacb = m1; -// mfacc = m2; -// //////////////////////////////////////////////////////////////////////////////////// -// //////////////////////////////////////////////////////////////////////////////////// -// m0 = mfbac * c1o2+mfbab * (vvz-c1o2)+mfbaa * (vz2-vvz) * c1o2; -// m1 = -mfbac-2. * mfbab * vvz+mfbaa * (1.-vz2); -// m2 = mfbac * c1o2+mfbab * (vvz+c1o2)+mfbaa * (vz2+vvz) * c1o2; -// mfbaa = m0; -// mfbab = m1; -// mfbac = m2; -// /////////b////////////////////////////////////////////////////////////////////////// -// m0 = mfbbc * c1o2+mfbbb * (vvz-c1o2)+mfbba * (vz2-vvz) * c1o2; -// m1 = -mfbbc-2. * mfbbb * vvz+mfbba * (1.-vz2); -// m2 = mfbbc * c1o2+mfbbb * (vvz+c1o2)+mfbba * (vz2+vvz) * c1o2; -// mfbba = m0; -// mfbbb = m1; -// mfbbc = m2; -// /////////b////////////////////////////////////////////////////////////////////////// -// m0 = mfbcc * c1o2+mfbcb * (vvz-c1o2)+mfbca * (vz2-vvz) * c1o2; -// m1 = -mfbcc-2. * mfbcb * vvz+mfbca * (1.-vz2); -// m2 = mfbcc * c1o2+mfbcb * (vvz+c1o2)+mfbca * (vz2+vvz) * c1o2; -// mfbca = m0; -// mfbcb = m1; -// mfbcc = m2; -// //////////////////////////////////////////////////////////////////////////////////// -// //////////////////////////////////////////////////////////////////////////////////// -// m0 = mfcac * c1o2+mfcab * (vvz-c1o2)+(mfcaa+c1o3 * oMdrho) * (vz2-vvz) * c1o2; -// m1 = -mfcac-2. * mfcab * vvz+mfcaa * (1.-vz2)-c1o3 * oMdrho * vz2; -// m2 = mfcac * c1o2+mfcab * (vvz+c1o2)+(mfcaa+c1o3 * oMdrho) * (vz2+vvz) * c1o2; -// mfcaa = m0; -// mfcab = m1; -// mfcac = m2; -// /////////c////////////////////////////////////////////////////////////////////////// -// m0 = mfcbc * c1o2+mfcbb * (vvz-c1o2)+mfcba * (vz2-vvz) * c1o2; -// m1 = -mfcbc-2. * mfcbb * vvz+mfcba * (1.-vz2); -// m2 = mfcbc * c1o2+mfcbb * (vvz+c1o2)+mfcba * (vz2+vvz) * c1o2; -// mfcba = m0; -// mfcbb = m1; -// mfcbc = m2; -// /////////c////////////////////////////////////////////////////////////////////////// -// m0 = mfccc * c1o2+mfccb * (vvz-c1o2)+(mfcca+c1o9 * oMdrho) * (vz2-vvz) * c1o2; -// m1 = -mfccc-2. * mfccb * vvz+mfcca * (1.-vz2)-c1o9 * oMdrho * vz2; -// m2 = mfccc * c1o2+mfccb * (vvz+c1o2)+(mfcca+c1o9 * oMdrho) * (vz2+vvz) * c1o2; -// mfcca = m0; -// mfccb = m1; -// mfccc = m2; -// //////////////////////////////////////////////////////////////////////////////////// -// //////////////////////////////////////////////////////////////////////////////////// -// //mit 1/6, 2/3, 1/6, 0, 0, 0, 1/18, 2/9, 1/18 Konditionieren -// //////////////////////////////////////////////////////////////////////////////////// -// // Y - Dir -// m0 = mfaca * c1o2+mfaba * (vvy-c1o2)+(mfaaa+c1o6 * oMdrho) * (vy2-vvy) * c1o2; -// m1 = -mfaca-2. * mfaba * vvy+mfaaa * (1.-vy2)-c1o6 * oMdrho * vy2; -// m2 = mfaca * c1o2+mfaba * (vvy+c1o2)+(mfaaa+c1o6 * oMdrho) * (vy2+vvy) * c1o2; -// mfaaa = m0; -// mfaba = m1; -// mfaca = m2; -// //////////////////////////////////////////////////////////////////////////////////// -// m0 = mfacb * c1o2+mfabb * (vvy-c1o2)+(mfaab+c2o3 * oMdrho) * (vy2-vvy) * c1o2; -// m1 = -mfacb-2. * mfabb * vvy+mfaab * (1.-vy2)-c2o3 * oMdrho * vy2; -// m2 = mfacb * c1o2+mfabb * (vvy+c1o2)+(mfaab+c2o3 * oMdrho) * (vy2+vvy) * c1o2; -// mfaab = m0; -// mfabb = m1; -// mfacb = m2; -// //////////////////////////////////////////////////////////////////////////////////// -// m0 = mfacc * c1o2+mfabc * (vvy-c1o2)+(mfaac+c1o6 * oMdrho) * (vy2-vvy) * c1o2; -// m1 = -mfacc-2. * mfabc * vvy+mfaac * (1.-vy2)-c1o6 * oMdrho * vy2; -// m2 = mfacc * c1o2+mfabc * (vvy+c1o2)+(mfaac+c1o6 * oMdrho) * (vy2+vvy) * c1o2; -// mfaac = m0; -// mfabc = m1; -// mfacc = m2; -// //////////////////////////////////////////////////////////////////////////////////// -// //////////////////////////////////////////////////////////////////////////////////// -// m0 = mfbca * c1o2+mfbba * (vvy-c1o2)+mfbaa * (vy2-vvy) * c1o2; -// m1 = -mfbca-2. * mfbba * vvy+mfbaa * (1.-vy2); -// m2 = mfbca * c1o2+mfbba * (vvy+c1o2)+mfbaa * (vy2+vvy) * c1o2; -// mfbaa = m0; -// mfbba = m1; -// mfbca = m2; -// /////////b////////////////////////////////////////////////////////////////////////// -// m0 = mfbcb * c1o2+mfbbb * (vvy-c1o2)+mfbab * (vy2-vvy) * c1o2; -// m1 = -mfbcb-2. * mfbbb * vvy+mfbab * (1.-vy2); -// m2 = mfbcb * c1o2+mfbbb * (vvy+c1o2)+mfbab * (vy2+vvy) * c1o2; -// mfbab = m0; -// mfbbb = m1; -// mfbcb = m2; -// /////////b////////////////////////////////////////////////////////////////////////// -// m0 = mfbcc * c1o2+mfbbc * (vvy-c1o2)+mfbac * (vy2-vvy) * c1o2; -// m1 = -mfbcc-2. * mfbbc * vvy+mfbac * (1.-vy2); -// m2 = mfbcc * c1o2+mfbbc * (vvy+c1o2)+mfbac * (vy2+vvy) * c1o2; -// mfbac = m0; -// mfbbc = m1; -// mfbcc = m2; -// //////////////////////////////////////////////////////////////////////////////////// -// //////////////////////////////////////////////////////////////////////////////////// -// m0 = mfcca * c1o2+mfcba * (vvy-c1o2)+(mfcaa+c1o18 * oMdrho) * (vy2-vvy) * c1o2; -// m1 = -mfcca-2. * mfcba * vvy+mfcaa * (1.-vy2)-c1o18 * oMdrho * vy2; -// m2 = mfcca * c1o2+mfcba * (vvy+c1o2)+(mfcaa+c1o18 * oMdrho) * (vy2+vvy) * c1o2; -// mfcaa = m0; -// mfcba = m1; -// mfcca = m2; -// /////////c////////////////////////////////////////////////////////////////////////// -// m0 = mfccb * c1o2+mfcbb * (vvy-c1o2)+(mfcab+c2o9 * oMdrho) * (vy2-vvy) * c1o2; -// m1 = -mfccb-2. * mfcbb * vvy+mfcab * (1.-vy2)-c2o9 * oMdrho * vy2; -// m2 = mfccb * c1o2+mfcbb * (vvy+c1o2)+(mfcab+c2o9 * oMdrho) * (vy2+vvy) * c1o2; -// mfcab = m0; -// mfcbb = m1; -// mfccb = m2; -// /////////c////////////////////////////////////////////////////////////////////////// -// m0 = mfccc * c1o2+mfcbc * (vvy-c1o2)+(mfcac+c1o18 * oMdrho) * (vy2-vvy) * c1o2; -// m1 = -mfccc-2. * mfcbc * vvy+mfcac * (1.-vy2)-c1o18 * oMdrho * vy2; -// m2 = mfccc * c1o2+mfcbc * (vvy+c1o2)+(mfcac+c1o18 * oMdrho) * (vy2+vvy) * c1o2; -// mfcac = m0; -// mfcbc = m1; -// mfccc = m2; -// //////////////////////////////////////////////////////////////////////////////////// -// //////////////////////////////////////////////////////////////////////////////////// -// //mit 1/36, 1/9, 1/36, 1/9, 4/9, 1/9, 1/36, 1/9, 1/36 Konditionieren -// //////////////////////////////////////////////////////////////////////////////////// -// // X - Dir -// m0 = mfcaa * c1o2+mfbaa * (vvx-c1o2)+(mfaaa+c1o36 * oMdrho) * (vx2-vvx) * c1o2; -// m1 = -mfcaa-2. * mfbaa * vvx+mfaaa * (1.-vx2)-c1o36 * oMdrho * vx2; -// m2 = mfcaa * c1o2+mfbaa * (vvx+c1o2)+(mfaaa+c1o36 * oMdrho) * (vx2+vvx) * c1o2; -// mfaaa = m0; -// mfbaa = m1; -// mfcaa = m2; -// //////////////////////////////////////////////////////////////////////////////////// -// m0 = mfcba * c1o2+mfbba * (vvx-c1o2)+(mfaba+c1o9 * oMdrho) * (vx2-vvx) * c1o2; -// m1 = -mfcba-2. * mfbba * vvx+mfaba * (1.-vx2)-c1o9 * oMdrho * vx2; -// m2 = mfcba * c1o2+mfbba * (vvx+c1o2)+(mfaba+c1o9 * oMdrho) * (vx2+vvx) * c1o2; -// mfaba = m0; -// mfbba = m1; -// mfcba = m2; -// //////////////////////////////////////////////////////////////////////////////////// -// m0 = mfcca * c1o2+mfbca * (vvx-c1o2)+(mfaca+c1o36 * oMdrho) * (vx2-vvx) * c1o2; -// m1 = -mfcca-2. * mfbca * vvx+mfaca * (1.-vx2)-c1o36 * oMdrho * vx2; -// m2 = mfcca * c1o2+mfbca * (vvx+c1o2)+(mfaca+c1o36 * oMdrho) * (vx2+vvx) * c1o2; -// mfaca = m0; -// mfbca = m1; -// mfcca = m2; -// //////////////////////////////////////////////////////////////////////////////////// -// //////////////////////////////////////////////////////////////////////////////////// -// m0 = mfcab * c1o2+mfbab * (vvx-c1o2)+(mfaab+c1o9 * oMdrho) * (vx2-vvx) * c1o2; -// m1 = -mfcab-2. * mfbab * vvx+mfaab * (1.-vx2)-c1o9 * oMdrho * vx2; -// m2 = mfcab * c1o2+mfbab * (vvx+c1o2)+(mfaab+c1o9 * oMdrho) * (vx2+vvx) * c1o2; -// mfaab = m0; -// mfbab = m1; -// mfcab = m2; -// ///////////b//////////////////////////////////////////////////////////////////////// -// m0 = mfcbb * c1o2+mfbbb * (vvx-c1o2)+(mfabb+c4o9 * oMdrho) * (vx2-vvx) * c1o2; -// m1 = -mfcbb-2. * mfbbb * vvx+mfabb * (1.-vx2)-c4o9 * oMdrho * vx2; -// m2 = mfcbb * c1o2+mfbbb * (vvx+c1o2)+(mfabb+c4o9 * oMdrho) * (vx2+vvx) * c1o2; -// mfabb = m0; -// mfbbb = m1; -// mfcbb = m2; -// ///////////b//////////////////////////////////////////////////////////////////////// -// m0 = mfccb * c1o2+mfbcb * (vvx-c1o2)+(mfacb+c1o9 * oMdrho) * (vx2-vvx) * c1o2; -// m1 = -mfccb-2. * mfbcb * vvx+mfacb * (1.-vx2)-c1o9 * oMdrho * vx2; -// m2 = mfccb * c1o2+mfbcb * (vvx+c1o2)+(mfacb+c1o9 * oMdrho) * (vx2+vvx) * c1o2; -// mfacb = m0; -// mfbcb = m1; -// mfccb = m2; -// //////////////////////////////////////////////////////////////////////////////////// -// //////////////////////////////////////////////////////////////////////////////////// -// m0 = mfcac * c1o2+mfbac * (vvx-c1o2)+(mfaac+c1o36 * oMdrho) * (vx2-vvx) * c1o2; -// m1 = -mfcac-2. * mfbac * vvx+mfaac * (1.-vx2)-c1o36 * oMdrho * vx2; -// m2 = mfcac * c1o2+mfbac * (vvx+c1o2)+(mfaac+c1o36 * oMdrho) * (vx2+vvx) * c1o2; -// mfaac = m0; -// mfbac = m1; -// mfcac = m2; -// ///////////c//////////////////////////////////////////////////////////////////////// -// m0 = mfcbc * c1o2+mfbbc * (vvx-c1o2)+(mfabc+c1o9 * oMdrho) * (vx2-vvx) * c1o2; -// m1 = -mfcbc-2. * mfbbc * vvx+mfabc * (1.-vx2)-c1o9 * oMdrho * vx2; -// m2 = mfcbc * c1o2+mfbbc * (vvx+c1o2)+(mfabc+c1o9 * oMdrho) * (vx2+vvx) * c1o2; -// mfabc = m0; -// mfbbc = m1; -// mfcbc = m2; -// ///////////c//////////////////////////////////////////////////////////////////////// -// m0 = mfccc * c1o2+mfbcc * (vvx-c1o2)+(mfacc+c1o36 * oMdrho) * (vx2-vvx) * c1o2; -// m1 = -mfccc-2. * mfbcc * vvx+mfacc * (1.-vx2)-c1o36 * oMdrho * vx2; -// m2 = mfccc * c1o2+mfbcc * (vvx+c1o2)+(mfacc+c1o36 * oMdrho) * (vx2+vvx) * c1o2; -// mfacc = m0; -// mfbcc = m1; -// mfccc = m2; -// -// ////////////////////////////////////////////////////////////////////////// -// //proof correctness -// ////////////////////////////////////////////////////////////////////////// -//#ifdef PROOF_CORRECTNESS -// LBMReal rho_post = (mfaaa+mfaac+mfaca+mfcaa+mfacc+mfcac+mfccc+mfcca) -// +(mfaab+mfacb+mfcab+mfccb)+(mfaba+mfabc+mfcba+mfcbc)+(mfbaa+mfbac+mfbca+mfbcc) -// +(mfabb+mfcbb)+(mfbab+mfbcb)+(mfbba+mfbbc)+mfbbb; -// //LBMReal dif = fabs(rho - rho_post); -// LBMReal dif = rho-rho_post; -//#ifdef SINGLEPRECISION -// if (dif>10.0E-7||dif<-10.0E-7) -//#else -// if (dif>10.0E-15||dif<-10.0E-15) -//#endif -// { -// UB_THROW(UbException(UB_EXARGS, "rho="+UbSystem::toString(rho)+", rho_post="+UbSystem::toString(rho_post) -// +" dif="+UbSystem::toString(dif) -// +" rho is not correct for node "+UbSystem::toString(x1)+","+UbSystem::toString(x2)+","+UbSystem::toString(x3))); -// //UBLOG(logERROR,"LBMKernel3DCCLB::collideAll(): rho is not correct for node "+UbSystem::toString(x1)+","+UbSystem::toString(x2)+","+UbSystem::toString(x3)); -// //exit(EXIT_FAILURE); -// } -//#endif -// //////////////////////////////////////////////////////////////////////////// -// ////write distribution -// //////////////////////////////////////////////////////////////////////////// -// (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3) = mfabb; -// (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3) = mfbab; -// (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3) = mfbba; -// (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3) = mfaab; -// (*this->localDistributions)(D3Q27System::ET_NW, x1p, x2, x3) = mfcab; -// (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3) = mfaba; -// (*this->localDistributions)(D3Q27System::ET_TW, x1p, x2, x3) = mfcba; -// (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3) = mfbaa; -// (*this->localDistributions)(D3Q27System::ET_TS, x1, x2p, x3) = mfbca; -// (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3) = mfaaa; -// (*this->localDistributions)(D3Q27System::ET_TNW, x1p, x2, x3) = mfcaa; -// (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2p, x3) = mfaca; -// (*this->localDistributions)(D3Q27System::ET_TSW, x1p, x2p, x3) = mfcca; -// -// (*this->nonLocalDistributions)(D3Q27System::ET_W, x1p, x2, x3) = mfcbb; -// (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2p, x3) = mfbcb; -// (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3p) = mfbbc; -// (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1p, x2p, x3) = mfccb; -// (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2p, x3) = mfacb; -// (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1p, x2, x3p) = mfcbc; -// (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3p) = mfabc; -// (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2p, x3p) = mfbcc; -// (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3p) = mfbac; -// (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1p, x2p, x3p) = mfccc; -// (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2p, x3p) = mfacc; -// (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1p, x2, x3p) = mfcac; -// (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3p) = mfaac; -// -// (*this->zeroDistributions)(x1, x2, x3) = mfbbb; -// //////////////////////////////////////////////////////////////////////////// -// -// } -// } -// } -// } -// -//} - - - - -void InitDensityLBMKernel::calculate(int step) -{ - using namespace D3Q27System; - - localDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getLocalDistributions(); - nonLocalDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getNonLocalDistributions(); - zeroDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getZeroDistributions(); - - SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); - SPtr<BoundaryConditions> bcPtr; - LBMReal f[D3Q27System::ENDF+1]; - LBMReal feq[D3Q27System::ENDF+1]; - LBMReal drho, vx1, vx2, vx3; - const int bcArrayMaxX1 = (int)bcArray->getNX1(); - const int bcArrayMaxX2 = (int)bcArray->getNX2(); - const int bcArrayMaxX3 = (int)bcArray->getNX3(); - - int minX1 = ghostLayerWidth; - int minX2 = ghostLayerWidth; - int minX3 = ghostLayerWidth; - int maxX1 = bcArrayMaxX1-ghostLayerWidth; - int maxX2 = bcArrayMaxX2-ghostLayerWidth; - int maxX3 = bcArrayMaxX3-ghostLayerWidth; - - //collFactor = 1.0/(1.0/2.0+1.0/sqrt(6.0)); - collFactor = 1.0; - - for (int x3 = minX3; x3<maxX3; x3++) - { - for (int x2 = minX2; x2<maxX2; x2++) - { - for (int x1 = minX1; x1<maxX1; x1++) - { - if (!bcArray->isSolid(x1, x2, x3)&&!bcArray->isUndefined(x1, x2, x3)) - { - int x1p = x1+1; - int x2p = x2+1; - int x3p = x3+1; - ////////////////////////////////////////////////////////////////////////// - //read distribution - //////////////////////////////////////////////////////////////////////////// - f[ZERO] = (*this->zeroDistributions)(x1, x2, x3); - - f[E] = (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3); - f[N] = (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3); - f[T] = (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3); - f[NE] = (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3); - f[NW] = (*this->localDistributions)(D3Q27System::ET_NW, x1p, x2, x3); - f[TE] = (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3); - f[TW] = (*this->localDistributions)(D3Q27System::ET_TW, x1p, x2, x3); - f[TN] = (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3); - f[TS] = (*this->localDistributions)(D3Q27System::ET_TS, x1, x2p, x3); - f[TNE] = (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3); - f[TNW] = (*this->localDistributions)(D3Q27System::ET_TNW, x1p, x2, x3); - f[TSE] = (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2p, x3); - f[TSW] = (*this->localDistributions)(D3Q27System::ET_TSW, x1p, x2p, x3); - - f[W] = (*this->nonLocalDistributions)(D3Q27System::ET_W, x1p, x2, x3); - f[S] = (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2p, x3); - f[B] = (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3p); - f[SW] = (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1p, x2p, x3); - f[SE] = (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2p, x3); - f[BW] = (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1p, x2, x3p); - f[BE] = (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3p); - f[BS] = (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2p, x3p); - f[BN] = (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3p); - f[BSW] = (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1p, x2p, x3p); - f[BSE] = (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2p, x3p); - f[BNW] = (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1p, x2, x3p); - f[BNE] = (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3p); - ////////////////////////////////////////////////////////////////////////// - - drho = ((f[TNE]+f[BSW])+(f[TSE]+f[BNW]))+((f[BSE]+f[TNW])+(f[TSW]+f[BNE])) - +(((f[NE]+f[SW])+(f[SE]+f[NW]))+((f[TE]+f[BW])+(f[BE]+f[TW])) - +((f[BN]+f[TS])+(f[TN]+f[BS])))+((f[E]+f[W])+(f[N]+f[S]) - +(f[T]+f[B]))+f[ZERO]; - - //vx1 = ((((f[TNE]-f[BSW])+(f[TSE]-f[BNW]))+((f[BSE]-f[TNW])+(f[BNE]-f[TSW])))+ - // (((f[BE]-f[TW])+(f[TE]-f[BW]))+((f[SE]-f[NW])+(f[NE]-f[SW])))+ - // (f[E]-f[W])); - - //vx2 = ((((f[TNE]-f[BSW])+(f[BNW]-f[TSE]))+((f[TNW]-f[BSE])+(f[BNE]-f[TSW])))+ - // (((f[BN]-f[TS])+(f[TN]-f[BS]))+((f[NW]-f[SE])+(f[NE]-f[SW])))+ - // (f[N]-f[S])); - - //vx3 = ((((f[TNE]-f[BSW])+(f[TSE]-f[BNW]))+((f[TNW]-f[BSE])+(f[TSW]-f[BNE])))+ - // (((f[TS]-f[BN])+(f[TN]-f[BS]))+((f[TW]-f[BE])+(f[TE]-f[BW])))+ - // (f[T]-f[B])); - - vx1 = v(0,x1,x2,x3); - vx2 = v(1,x1,x2,x3); - vx3 = v(2,x1,x2,x3); - - //LBMReal vvx = v(0,x1,x2,x3); - //LBMReal vvy = v(1,x1,x2,x3); - //LBMReal vvz = v(2,x1,x2,x3); - - //vx1 = vx1+(vvx-vx1); - //vx2 = vx2+(vvy-vx2); - //vx3 = vx3+(vvz-vx3); - - LBMReal cu_sq = 1.5*(vx1*vx1+vx2*vx2+vx3*vx3); - - feq[ZERO] = c8o27*(drho-cu_sq); - feq[E] = c2o27*(drho+3.0*(vx1)+c9o2*(vx1)*(vx1)-cu_sq); - feq[W] = c2o27*(drho+3.0*(-vx1)+c9o2*(-vx1)*(-vx1)-cu_sq); - feq[N] = c2o27*(drho+3.0*(vx2)+c9o2*(vx2)*(vx2)-cu_sq); - feq[S] = c2o27*(drho+3.0*(-vx2)+c9o2*(-vx2)*(-vx2)-cu_sq); - feq[T] = c2o27*(drho+3.0*(vx3)+c9o2*(vx3)*(vx3)-cu_sq); - feq[B] = c2o27*(drho+3.0*(-vx3)+c9o2*(-vx3)*(-vx3)-cu_sq); - feq[NE] = c1o54*(drho+3.0*(vx1+vx2)+c9o2*(vx1+vx2)*(vx1+vx2)-cu_sq); - feq[SW] = c1o54*(drho+3.0*(-vx1-vx2)+c9o2*(-vx1-vx2)*(-vx1-vx2)-cu_sq); - feq[SE] = c1o54*(drho+3.0*(vx1-vx2)+c9o2*(vx1-vx2)*(vx1-vx2)-cu_sq); - feq[NW] = c1o54*(drho+3.0*(-vx1+vx2)+c9o2*(-vx1+vx2)*(-vx1+vx2)-cu_sq); - feq[TE] = c1o54*(drho+3.0*(vx1+vx3)+c9o2*(vx1+vx3)*(vx1+vx3)-cu_sq); - feq[BW] = c1o54*(drho+3.0*(-vx1-vx3)+c9o2*(-vx1-vx3)*(-vx1-vx3)-cu_sq); - feq[BE] = c1o54*(drho+3.0*(vx1-vx3)+c9o2*(vx1-vx3)*(vx1-vx3)-cu_sq); - feq[TW] = c1o54*(drho+3.0*(-vx1+vx3)+c9o2*(-vx1+vx3)*(-vx1+vx3)-cu_sq); - feq[TN] = c1o54*(drho+3.0*(vx2+vx3)+c9o2*(vx2+vx3)*(vx2+vx3)-cu_sq); - feq[BS] = c1o54*(drho+3.0*(-vx2-vx3)+c9o2*(-vx2-vx3)*(-vx2-vx3)-cu_sq); - feq[BN] = c1o54*(drho+3.0*(vx2-vx3)+c9o2*(vx2-vx3)*(vx2-vx3)-cu_sq); - feq[TS] = c1o54*(drho+3.0*(-vx2+vx3)+c9o2*(-vx2+vx3)*(-vx2+vx3)-cu_sq); - feq[TNE] = c1o216*(drho+3.0*(vx1+vx2+vx3)+c9o2*(vx1+vx2+vx3)*(vx1+vx2+vx3)-cu_sq); - feq[BSW] = c1o216*(drho+3.0*(-vx1-vx2-vx3)+c9o2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3)-cu_sq); - feq[BNE] = c1o216*(drho+3.0*(vx1+vx2-vx3)+c9o2*(vx1+vx2-vx3)*(vx1+vx2-vx3)-cu_sq); - feq[TSW] = c1o216*(drho+3.0*(-vx1-vx2+vx3)+c9o2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3)-cu_sq); - feq[TSE] = c1o216*(drho+3.0*(vx1-vx2+vx3)+c9o2*(vx1-vx2+vx3)*(vx1-vx2+vx3)-cu_sq); - feq[BNW] = c1o216*(drho+3.0*(-vx1+vx2-vx3)+c9o2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3)-cu_sq); - feq[BSE] = c1o216*(drho+3.0*(vx1-vx2-vx3)+c9o2*(vx1-vx2-vx3)*(vx1-vx2-vx3)-cu_sq); - feq[TNW] = c1o216*(drho+3.0*(-vx1+vx2+vx3)+c9o2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3)-cu_sq); - - //Relaxation - f[ZERO] += (feq[ZERO]-f[ZERO])*collFactor; - f[E] += (feq[E]-f[E])*collFactor; - f[W] += (feq[W]-f[W])*collFactor; - f[N] += (feq[N]-f[N])*collFactor; - f[S] += (feq[S]-f[S])*collFactor; - f[T] += (feq[T]-f[T])*collFactor; - f[B] += (feq[B]-f[B])*collFactor; - f[NE] += (feq[NE]-f[NE])*collFactor; - f[SW] += (feq[SW]-f[SW])*collFactor; - f[SE] += (feq[SE]-f[SE])*collFactor; - f[NW] += (feq[NW]-f[NW])*collFactor; - f[TE] += (feq[TE]-f[TE])*collFactor; - f[BW] += (feq[BW]-f[BW])*collFactor; - f[BE] += (feq[BE]-f[BE])*collFactor; - f[TW] += (feq[TW]-f[TW])*collFactor; - f[TN] += (feq[TN]-f[TN])*collFactor; - f[BS] += (feq[BS]-f[BS])*collFactor; - f[BN] += (feq[BN]-f[BN])*collFactor; - f[TS] += (feq[TS]-f[TS])*collFactor; - - f[TNE] += (feq[TNE]-f[TNE])*collFactor; - f[BSW] += (feq[BSW]-f[BSW])*collFactor; - f[BNE] += (feq[BNE]-f[BNE])*collFactor; - f[TSW] += (feq[TSW]-f[TSW])*collFactor; - f[TSE] += (feq[TSE]-f[TSE])*collFactor; - f[BNW] += (feq[BNW]-f[BNW])*collFactor; - f[BSE] += (feq[BSE]-f[BSE])*collFactor; - f[TNW] += (feq[TNW]-f[TNW])*collFactor; - - ////////////////////////////////////////////////////////////////////////// -#ifdef PROOF_CORRECTNESS - LBMReal rho_post = f[ZERO]+f[E]+f[W]+f[N]+f[S]+f[T]+f[B] - +f[NE]+f[SW]+f[SE]+f[NW]+f[TE]+f[BW]+f[BE] - +f[TW]+f[TN]+f[BS]+f[BN]+f[TS]+f[TNE]+f[TSW] - +f[TSE]+f[TNW]+f[BNE]+f[BSW]+f[BSE]+f[BNW]; - LBMReal dif = drho-rho_post; -#ifdef SINGLEPRECISION - if (dif>10.0E-7||dif<-10.0E-7) -#else - if (dif>10.0E-15||dif<-10.0E-15) -#endif - { - UB_THROW(UbException(UB_EXARGS, "rho is not correct")); - } -#endif - ////////////////////////////////////////////////////////////////////////// - //write distribution - ////////////////////////////////////////////////////////////////////////// - (*this->localDistributions)(D3Q27System::ET_E, x1, x2, x3) = f[D3Q27System::INV_E]; - (*this->localDistributions)(D3Q27System::ET_N, x1, x2, x3) = f[D3Q27System::INV_N]; - (*this->localDistributions)(D3Q27System::ET_T, x1, x2, x3) = f[D3Q27System::INV_T]; - (*this->localDistributions)(D3Q27System::ET_NE, x1, x2, x3) = f[D3Q27System::INV_NE]; - (*this->localDistributions)(D3Q27System::ET_NW, x1p, x2, x3) = f[D3Q27System::INV_NW]; - (*this->localDistributions)(D3Q27System::ET_TE, x1, x2, x3) = f[D3Q27System::INV_TE]; - (*this->localDistributions)(D3Q27System::ET_TW, x1p, x2, x3) = f[D3Q27System::INV_TW]; - (*this->localDistributions)(D3Q27System::ET_TN, x1, x2, x3) = f[D3Q27System::INV_TN]; - (*this->localDistributions)(D3Q27System::ET_TS, x1, x2p, x3) = f[D3Q27System::INV_TS]; - (*this->localDistributions)(D3Q27System::ET_TNE, x1, x2, x3) = f[D3Q27System::INV_TNE]; - (*this->localDistributions)(D3Q27System::ET_TNW, x1p, x2, x3) = f[D3Q27System::INV_TNW]; - (*this->localDistributions)(D3Q27System::ET_TSE, x1, x2p, x3) = f[D3Q27System::INV_TSE]; - (*this->localDistributions)(D3Q27System::ET_TSW, x1p, x2p, x3) = f[D3Q27System::INV_TSW]; - - (*this->nonLocalDistributions)(D3Q27System::ET_W, x1p, x2, x3) = f[D3Q27System::INV_W]; - (*this->nonLocalDistributions)(D3Q27System::ET_S, x1, x2p, x3) = f[D3Q27System::INV_S]; - (*this->nonLocalDistributions)(D3Q27System::ET_B, x1, x2, x3p) = f[D3Q27System::INV_B]; - (*this->nonLocalDistributions)(D3Q27System::ET_SW, x1p, x2p, x3) = f[D3Q27System::INV_SW]; - (*this->nonLocalDistributions)(D3Q27System::ET_SE, x1, x2p, x3) = f[D3Q27System::INV_SE]; - (*this->nonLocalDistributions)(D3Q27System::ET_BW, x1p, x2, x3p) = f[D3Q27System::INV_BW]; - (*this->nonLocalDistributions)(D3Q27System::ET_BE, x1, x2, x3p) = f[D3Q27System::INV_BE]; - (*this->nonLocalDistributions)(D3Q27System::ET_BS, x1, x2p, x3p) = f[D3Q27System::INV_BS]; - (*this->nonLocalDistributions)(D3Q27System::ET_BN, x1, x2, x3p) = f[D3Q27System::INV_BN]; - (*this->nonLocalDistributions)(D3Q27System::ET_BSW, x1p, x2p, x3p) = f[D3Q27System::INV_BSW]; - (*this->nonLocalDistributions)(D3Q27System::ET_BSE, x1, x2p, x3p) = f[D3Q27System::INV_BSE]; - (*this->nonLocalDistributions)(D3Q27System::ET_BNW, x1p, x2, x3p) = f[D3Q27System::INV_BNW]; - (*this->nonLocalDistributions)(D3Q27System::ET_BNE, x1, x2, x3p) = f[D3Q27System::INV_BNE]; - - (*this->zeroDistributions)(x1, x2, x3) = f[D3Q27System::ZERO]; - ////////////////////////////////////////////////////////////////////////// - - - } - } - } - } -} \ No newline at end of file diff --git a/src/cpu/VirtualFluidsCore/LBM/InitDensityLBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/InitDensityLBMKernel.h deleted file mode 100644 index 6b3866f3f..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/InitDensityLBMKernel.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef InitDensityLBMKernel_h__ -#define InitDensityLBMKernel_h__ - -#include "LBMKernel.h" -#include "basics/utilities/UbTiming.h" -#include "CbArray4D.h" -#include "D3Q27System.h" -#include "CbArray3D.h" - -class InitDensityLBMKernel : public LBMKernel -{ -public: - InitDensityLBMKernel(); - ~InitDensityLBMKernel(); - void calculate(int step); - SPtr<LBMKernel> clone(); - void setVelocity(int x1, int x2, int x3, LBMReal vvx, LBMReal vvy, LBMReal vvz); - double getCalculationTime(); -protected: - void initDataSet(); -private: - LBMReal f[D3Q27System::ENDF+1]; - CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributions; - CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions; - CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributions; - LBMReal OxyyMxzz; - CbArray4D<LBMReal, IndexerX4X3X2X1> v; -}; - -#endif // InitDensityLBMKernel_h__ - diff --git a/src/cpu/VirtualFluidsCore/LBM/InterpolationHelper.cpp b/src/cpu/VirtualFluidsCore/LBM/InterpolationHelper.cpp deleted file mode 100644 index 2b4176b53..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/InterpolationHelper.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "InterpolationHelper.h" - - - -InterpolationHelper::InterpolationHelper(InterpolationProcessorPtr iProcessor) : iProcessor(iProcessor) -{ - -} -////////////////////////////////////////////////////////////////////////// -InterpolationHelper::~InterpolationHelper() -{ - -} -////////////////////////////////////////////////////////////////////////// -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 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 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 ) -{ - iProcessor->setOffsets(0.0, 0.0, 0.0); - iProcessor->calcInterpolatedCoefficiets(icellF, omega, 0.0); - iProcessor->calcInterpolatedVelocity(x1, x2, x3, vx1, vx2, vx3); - iProcessor->calcInterpolatedShearStress(x1,x2,x3,tauxx,tauyy,tauzz,tauxy,tauxz,tauyz); -} - -////////////////////////////////////////////////////////////////////////// - diff --git a/src/cpu/VirtualFluidsCore/LBM/InterpolationHelper.h b/src/cpu/VirtualFluidsCore/LBM/InterpolationHelper.h deleted file mode 100644 index 06b9d1943..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/InterpolationHelper.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef D3Q27InterpolationHelper_H_ -#define D3Q27InterpolationHelper_H_ - -#include "InterpolationProcessor.h" - -class InterpolationHelper; -typedef SPtr<InterpolationHelper> InterpolationHelperPtr; - -class InterpolationHelper -{ -public: - 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, - LBMReal &vx1, LBMReal &vx2, LBMReal &vx3, - LBMReal &tauxx, LBMReal &tauyy, LBMReal &tauzz,LBMReal &tauxy, LBMReal &tauxz, LBMReal &tauyz); -protected: -private: - InterpolationProcessorPtr iProcessor; -}; - -#endif - diff --git a/src/cpu/VirtualFluidsCore/LBM/InterpolationProcessor.cpp b/src/cpu/VirtualFluidsCore/LBM/InterpolationProcessor.cpp deleted file mode 100644 index 226775feb..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/InterpolationProcessor.cpp +++ /dev/null @@ -1,313 +0,0 @@ -#include "InterpolationProcessor.h" - - -////////////////////////////////////////////////////////////////////////// -InterpolationProcessor::InterpolationProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -InterpolationProcessor::~InterpolationProcessor() -{ - -} -////////////////////////////////////////////////////////////////////////// -void InterpolationProcessor::readICell(SPtr<DistributionArray3D> f, D3Q27ICell& icell, int x1, int x2, int x3) -{ - f->getDistribution(icell.BSW, x1, x2, x3); - f->getDistribution(icell.BSE, x1+1, x2, x3); - f->getDistribution(icell.BNW, x1, x2+1, x3); - f->getDistribution(icell.BNE, x1+1, x2+1, x3); - f->getDistribution(icell.TSW, x1, x2, x3+1); - f->getDistribution(icell.TSE, x1+1, x2, x3+1); - f->getDistribution(icell.TNW, x1, x2+1, x3+1); - f->getDistribution(icell.TNE, x1+1, x2+1, x3+1); -} -////////////////////////////////////////////////////////////////////////// -void InterpolationProcessor::writeICell(SPtr<DistributionArray3D> f, const D3Q27ICell& icell, int x1, int x2, int x3) -{ - f->setDistribution(icell.BSW, x1, x2, x3); - f->setDistribution(icell.BSE, x1+1, x2, x3); - f->setDistribution(icell.BNW, x1, x2+1, x3); - f->setDistribution(icell.BNE, x1+1, x2+1, x3); - f->setDistribution(icell.TSW, x1, x2, x3+1); - f->setDistribution(icell.TSE, x1+1, x2, x3+1); - f->setDistribution(icell.TNW, x1, x2+1, x3+1); - f->setDistribution(icell.TNE, x1+1, x2+1, x3+1); -} -////////////////////////////////////////////////////////////////////////// -void InterpolationProcessor::writeICellInv(SPtr<DistributionArray3D> 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); - f->setDistributionInv(icell.BNW, x1, x2+1, x3); - f->setDistributionInv(icell.BNE, x1+1, x2+1, x3); - f->setDistributionInv(icell.TSW, x1, x2, x3+1); - f->setDistributionInv(icell.TSE, x1+1, x2, x3+1); - f->setDistributionInv(icell.TNW, x1, x2+1, x3+1); - f->setDistributionInv(icell.TNE, x1+1, x2+1, x3+1); -} -////////////////////////////////////////////////////////////////////////// -void InterpolationProcessor::writeINode(SPtr<DistributionArray3D> f, const LBMReal* const inode, int x1, int x2, int x3) -{ - f->setDistribution(inode, x1, x2, x3); -} -////////////////////////////////////////////////////////////////////////// -void InterpolationProcessor::writeINodeInv(SPtr<DistributionArray3D> f, const LBMReal* const inode, int x1, int x2, int x3) -{ - f->setDistributionInv(inode, x1, x2, x3); -} -////////////////////////////////////////////////////////////////////////// -bool InterpolationProcessor::iCellHasSolid(const SPtr<BCArray3D> bcArray, int x1, int x2, int x3) -{ - for (int ix3 = x3; ix3 <= x3 + 1; ix3++) - for(int ix2 = x2; ix2 <= x2 + 1; ix2++) - for(int ix1 = x1; ix1 <= x1 + 1; ix1++) - { - if(bcArray->isSolid(ix1, ix2, ix3)) - return true; - } - return false; -} -////////////////////////////////////////////////////////////////////////// -bool InterpolationProcessor::findNeighborICell(const SPtr<BCArray3D> bcArray, SPtr<DistributionArray3D> f, - D3Q27ICell& icell, int maxX1, int maxX2, int maxX3, - int x1, int x2, int x3, LBMReal& xoff, LBMReal& yoff, LBMReal& zoff) -{ - m_maxX1 = maxX1; - m_maxX2 = maxX2; - m_maxX3 = maxX3; - - //GoWest - if(inRange(x1-1,x2,x3) && !iCellHasSolid(bcArray, x1-1,x2,x3)) - { - readICell(f,icell,x1-1,x2,x3); - xoff = 1; - yoff = 0; - zoff = 0; - } - //GoEast - else if(inRange(x1+2,x2,x3) && !iCellHasSolid(bcArray, x1+1,x2,x3)) // ist übernächster Knoten auch im Gebiet (Grundknoten bei 0,0,0 - { - readICell(f,icell,x1+1,x2,x3); - xoff = -1; - yoff = 0; - zoff = 0; - } - //GoSouth - else if(inRange(x1,x2-1,x3) && !iCellHasSolid(bcArray, x1,x2-1,x3)) - { - readICell(f,icell,x1,x2-1,x3); - xoff = 0; - yoff = 1; - zoff = 0; - } - //GoNorth - else if(inRange(x1,x2+2,x3) && !iCellHasSolid(bcArray, x1,x2+1,x3)) // ist übernächster Knoten auch im Gebiet (Grundknoten bei 0,0,0 - { - readICell(f,icell,x1,x2+1,x3); - xoff = 0; - yoff = -1; - zoff = 0; - } - //GoBottom - else if(inRange(x1,x2,x3-1) && !iCellHasSolid(bcArray, x1,x2,x3-1)) - { - readICell(f,icell,x1,x2,x3-1); - xoff = 0; - yoff = 0; - zoff = 1; - } - //GoTop - else if(inRange(x1,x2,x3+2) && !iCellHasSolid(bcArray, x1,x2,x3+1)) // ist übernächster Knoten auch im Gebiet (Grundknoten bei 0,0,0 - { - readICell(f,icell,x1,x2,x3+1); - xoff = 0; - yoff = 0; - zoff = -1; - } - //GoNW - else if(inRange(x1-1,x2+2,x3) && !iCellHasSolid(bcArray, x1-1,x2+1,x3)) // ist übernächster Knoten auch im Gebiet (Grundknoten bei 0,0,0 - { - readICell(f,icell,x1-1,x2+1,x3); - xoff = 1; - yoff = -1; - zoff = 0; - } - //GoNE - else if(inRange(x1+2,x2+2,x3) && !iCellHasSolid(bcArray, x1+1,x2+1,x3)) // ist übernächster Knoten auch im Gebiet (Grundknoten bei 0,0,0 - { - readICell(f,icell,x1+1,x2+1,x3); - xoff = -1; - yoff = -1; - zoff = 0; - } - //GoSW - else if(inRange(x1-1,x2-1,x3) && !iCellHasSolid(bcArray, x1-1,x2-1,x3)) // ist übernächster Knoten auch im Gebiet (Grundknoten bei 0,0,0 - { - readICell(f,icell,x1-1,x2-1,x3); - xoff = 1; - yoff = 1; - zoff = 0; - } - //GoSE - else if(inRange(x1+2,x2-1,x3) && !iCellHasSolid(bcArray, x1+1,x2-1,x3)) // ist übernächster Knoten auch im Gebiet (Grundknoten bei 0,0,0 - { - readICell(f,icell,x1+1,x2-1,x3); - xoff = -1; - yoff = 1; - zoff = 0; - } - //GoBW - else if(inRange(x1-1,x2,x3-1) && !iCellHasSolid(bcArray, x1-1,x2,x3-1)) - { - readICell(f,icell,x1-1,x2,x3-1); - xoff = 1; - yoff = 0; - zoff = 1; - } - //GoBE - else if(inRange(x1+2,x2,x3-1) && !iCellHasSolid(bcArray, x1+1,x2,x3-1)) // ist übernächster Knoten auch im Gebiet (Grundknoten bei 0,0,0 - { - readICell(f,icell,x1+1,x2,x3-1); - xoff = -1; - yoff = 0; - zoff = 1; - } - //GoBS - else if(inRange(x1,x2-1,x3-1) && !iCellHasSolid(bcArray, x1,x2-1,x3-1)) - { - readICell(f,icell,x1,x2-1,x3-1); - xoff = 0; - yoff = 1; - zoff = 1; - } - //GoBN - else if(inRange(x1,x2+2,x3-1) && !iCellHasSolid(bcArray, x1,x2+1,x3-1)) // ist übernächster Knoten auch im Gebiet (Grundknoten bei 0,0,0 - { - readICell(f,icell,x1,x2+1,x3-1); - xoff = 0; - yoff = -1; - zoff = 1; - } - //GoTW - else if(inRange(x1-1,x2,x3+2) && !iCellHasSolid(bcArray, x1-1,x2,x3+1)) - { - readICell(f,icell,x1-1,x2,x3+1); - xoff = 1; - yoff = 0; - zoff = -1; - } - //GoTE - else if(inRange(x1+2,x2,x3+2) && !iCellHasSolid(bcArray, x1+1,x2,x3+1)) // ist übernächster Knoten auch im Gebiet (Grundknoten bei 0,0,0 - { - readICell(f,icell,x1+1,x2,x3+1); - xoff = -1; - yoff = 0; - zoff = -1; - } - //GoTS - else if(inRange(x1,x2-1,x3+2) && !iCellHasSolid(bcArray, x1,x2-1,x3+1)) - { - readICell(f,icell,x1,x2-1,x3+1); - xoff = 0; - yoff = 1; - zoff = -1; - } - //GoTN - else if(inRange(x1,x2+2,x3+2) && !iCellHasSolid(bcArray, x1,x2+1,x3+1)) // ist übernächster Knoten auch im Gebiet (Grundknoten bei 0,0,0 - { - readICell(f,icell,x1,x2+1,x3+1); - xoff = 0; - yoff = -1; - zoff = -1; - } - //GoTNW - else if(inRange(x1-1,x2+2,x3+2) && !iCellHasSolid(bcArray, x1-1,x2+1,x3+1)) // ist übernächster Knoten auch im Gebiet (Grundknoten bei 0,0,0 - { - readICell(f,icell,x1-1,x2+1,x3+1); - xoff = 1; - yoff = -1; - zoff = -1; - } - //GoTNE - else if(inRange(x1+2,x2+2,x3+2) && !iCellHasSolid(bcArray, x1+1,x2+1,x3+1)) // ist übernächster Knoten auch im Gebiet (Grundknoten bei 0,0,0 - { - readICell(f,icell,x1+1,x2+1,x3+1); - xoff = -1; - yoff = -1; - zoff = -1; - } - //GoTSE - else if(inRange(x1+2,x2-1,x3+2) && !iCellHasSolid(bcArray, x1+1,x2-1,x3+1)) // ist übernächster Knoten auch im Gebiet (Grundknoten bei 0,0,0 - { - readICell(f,icell,x1+1,x2-1,x3+1); - xoff = -1; - yoff = 1; - zoff = -1; - } - //GoTSW - else if(inRange(x1-1,x2-1,x3+2) && !iCellHasSolid(bcArray, x1-1,x2-1,x3+1)) // ist übernächster Knoten auch im Gebiet (Grundknoten bei 0,0,0 - { - readICell(f,icell,x1-1,x2-1,x3+1); - xoff = 1; - yoff = 1; - zoff = -1; - } - //GoBNW - else if(inRange(x1-1,x2+2,x3-1) && !iCellHasSolid(bcArray, x1-1,x2+1,x3-1)) // ist übernächster Knoten auch im Gebiet (Grundknoten bei 0,0,0 - { - readICell(f,icell,x1-1,x2+1,x3-1); - xoff = 1; - yoff = -1; - zoff = 1; - } - //GoBNE - else if(inRange(x1+2,x2+2,x3-1) && !iCellHasSolid(bcArray, x1+1,x2+1,x3-1)) // ist übernächster Knoten auch im Gebiet (Grundknoten bei 0,0,0 - { - readICell(f,icell,x1+1,x2+1,x3-1); - xoff = -1; - yoff = -1; - zoff = 1; - } - //GoBSE - else if(inRange(x1+2,x2-1,x3-1) && !iCellHasSolid(bcArray, x1+1,x2-1,x3-1)) // ist übernächster Knoten auch im Gebiet (Grundknoten bei 0,0,0 - { - readICell(f,icell,x1+1,x2-1,x3-1); - xoff = -1; - yoff = 1; - zoff = 1; - } - //GoBSW - else if(inRange(x1-1,x2-1,x3-1) && !iCellHasSolid(bcArray, x1-1,x2-1,x3-1)) // ist übernächster Knoten auch im Gebiet (Grundknoten bei 0,0,0 - { - readICell(f,icell,x1-1,x2-1,x3-1); - xoff = 1; - yoff = 1; - zoff = 1; - } - //default - else - { - //std::string err = "For x1="+StringUtil::toString(x1)+", x2=" + StringUtil::toString(x2)+", x3=" + StringUtil::toString(x3)+ - // " 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)); - return 0; - } - return 1; -} -////////////////////////////////////////////////////////////////////////// -int InterpolationProcessor::iCellHowManySolids( const SPtr<BCArray3D> bcArray, int x1, int x2, int x3 ) -{ - int count = 0; - for (int ix3 = x3; ix3 <= x3 + 1; ix3++) - for(int ix2 = x2; ix2 <= x2 + 1; ix2++) - for(int ix1 = x1; ix1 <= x1 + 1; ix1++) - { - if(bcArray->isSolid(ix1, ix2, ix3)) - count++; - } - return count; -} diff --git a/src/cpu/VirtualFluidsCore/LBM/InterpolationProcessor.h b/src/cpu/VirtualFluidsCore/LBM/InterpolationProcessor.h deleted file mode 100644 index bb82aa11b..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/InterpolationProcessor.h +++ /dev/null @@ -1,70 +0,0 @@ -#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 SPtr<InterpolationProcessor> InterpolationProcessorPtr; - -#include "InterpolationHelper.h" - -class InterpolationProcessor -{ -public: - 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(SPtr<DistributionArray3D> f, D3Q27ICell& icell, int x1, int x2, int x3); - static void writeICell(SPtr<DistributionArray3D> f, const D3Q27ICell& icell, int x1, int x2, int x3); - static void writeICellInv(SPtr<DistributionArray3D> f, const D3Q27ICell& icell, int x1, int x2, int x3); - static void writeINode(SPtr<DistributionArray3D> f, const LBMReal* const inode, int x1, int x2, int x3); - static void writeINodeInv(SPtr<DistributionArray3D> f, const LBMReal* const inode, int x1, int x2, int x3); - static bool iCellHasSolid(const SPtr<BCArray3D> bcArray, int x1, int x2, int x3); - static int iCellHowManySolids(const SPtr<BCArray3D> bcArray, int x1, int x2, int x3); - - bool findNeighborICell(const SPtr<BCArray3D> bcArray, SPtr<DistributionArray3D> 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/src/cpu/VirtualFluidsCore/LBM/LBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/LBMKernel.cpp index 256443790..dcb20a053 100644 --- a/src/cpu/VirtualFluidsCore/LBM/LBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/LBMKernel.cpp @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file LBMKernel.cpp +//! \ingroup LBM +//! \author Konstantin Kutscher +//======================================================================================= + #include "LBMKernel.h" #include "DataSet3D.h" #include "BCProcessor.h" diff --git a/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h index f1cc6a3d3..b97ac3d8d 100644 --- a/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h +++ b/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file LBMKernel.h +//! \ingroup LBM +//! \author Konstantin Kutscher +//======================================================================================= + #ifndef LBMKERNEL_H #define LBMKERNEL_H @@ -5,12 +38,14 @@ #include "LBMSystem.h" #include "ILBMKernel.h" #include <array> +#include <limits> #include <MuParser/include/muParser.h> class BCProcessor; class DataSet3D; class Block3D; +//! \brief A base class provides basic functionality for LBM kernel class LBMKernel : public ILBMKernel, public enableSharedFromThis<LBMKernel> { public: @@ -22,7 +57,6 @@ public: virtual SPtr<LBMKernel> clone() = 0; virtual void calculate(int step) = 0; - virtual double getCalculationTime() = 0; void setBCProcessor(SPtr<BCProcessor> bcp); SPtr<BCProcessor> getBCProcessor() const; @@ -70,7 +104,7 @@ public: bool isInsideOfDomain(const int &x1, const int &x2, const int &x3) const; - void swapDistributions(); + void swapDistributions() override; void setNX(std::array<int, 3> nx); std::array<int, 3> getNX(); diff --git a/src/cpu/VirtualFluidsCore/LBM/LBMKernelETD3Q27BGK.cpp b/src/cpu/VirtualFluidsCore/LBM/LBMKernelETD3Q27BGK.cpp deleted file mode 100644 index 55c370e83..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/LBMKernelETD3Q27BGK.cpp +++ /dev/null @@ -1,299 +0,0 @@ -#include "LBMKernelETD3Q27BGK.h" -#include "D3Q27System.h" -#include "D3Q27EsoTwist3DSplittedVector.h" -#include "D3Q27EsoTwist3DSoA.h" -#include "DataSet3D.h" -#include "BCProcessor.h" -#include "BCArray3D.h" - -//#define PROOF_CORRECTNESS - -////////////////////////////////////////////////////////////////////////// -LBMKernelETD3Q27BGK::LBMKernelETD3Q27BGK() -{ - this->compressible = false; -} -////////////////////////////////////////////////////////////////////////// -LBMKernelETD3Q27BGK::~LBMKernelETD3Q27BGK(void) -{ - -} -////////////////////////////////////////////////////////////////////////// -void LBMKernelETD3Q27BGK::initDataSet() -{ - SPtr<DistributionArray3D> d(new D3Q27EsoTwist3DSplittedVector(nx[0]+2, nx[1]+2, nx[2]+2, -999.9)); - dataSet->setFdistributions(d); -} -////////////////////////////////////////////////////////////////////////// -SPtr<LBMKernel> LBMKernelETD3Q27BGK::clone() -{ - SPtr<LBMKernel> kernel(new LBMKernelETD3Q27BGK()); - std::dynamic_pointer_cast<LBMKernelETD3Q27BGK>(kernel)->initDataSet(); - kernel->setCollisionFactor(this->collFactor); - kernel->setBCProcessor(bcProcessor->clone(kernel)); - kernel->setWithForcing(withForcing); - kernel->setForcingX1(muForcingX1); - kernel->setForcingX2(muForcingX2); - kernel->setForcingX3(muForcingX3); - kernel->setIndex(ix1, ix2, ix3); - return kernel; -} -////////////////////////////////////////////////////////////////////////// -void LBMKernelETD3Q27BGK::calculate(int step) -{ - using namespace D3Q27System; - - //initializing of forcing stuff - if (withForcing) - { - muForcingX1.DefineVar("x1",&muX1); muForcingX1.DefineVar("x2",&muX2); muForcingX1.DefineVar("x3",&muX3); - muForcingX2.DefineVar("x1",&muX1); muForcingX2.DefineVar("x2",&muX2); muForcingX2.DefineVar("x3",&muX3); - muForcingX3.DefineVar("x1",&muX1); muForcingX3.DefineVar("x2",&muX2); muForcingX3.DefineVar("x3",&muX3); - forcingX1 = 0; - forcingX2 = 0; - forcingX3 = 0; - } - ///////////////////////////////////// - - localDistributions = std::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getLocalDistributions(); - nonLocalDistributions = std::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getNonLocalDistributions(); - zeroDistributions = std::dynamic_pointer_cast<D3Q27EsoTwist3DSplittedVector>(dataSet->getFdistributions())->getZeroDistributions(); - - SPtr<BCArray3D> bcArray = this->getBCProcessor()->getBCArray(); - LBMReal f[D3Q27System::ENDF+1]; - LBMReal feq[D3Q27System::ENDF+1]; - LBMReal drho,vx1,vx2,vx3; - const int bcArrayMaxX1 = (int)bcArray->getNX1(); - const int bcArrayMaxX2 = (int)bcArray->getNX2(); - const int bcArrayMaxX3 = (int)bcArray->getNX3(); - - int minX1 = ghostLayerWidth; - int minX2 = ghostLayerWidth; - int minX3 = ghostLayerWidth; - int maxX1 = bcArrayMaxX1-ghostLayerWidth; - int maxX2 = bcArrayMaxX2-ghostLayerWidth; - int maxX3 = bcArrayMaxX3-ghostLayerWidth; - - for(int x3 = minX3; x3 < maxX3; x3++) - { - for(int x2 = minX2; x2 < maxX2; x2++) - { - for(int x1 = minX1; x1 < maxX1; x1++) - { - if(!bcArray->isSolid(x1,x2,x3) && !bcArray->isUndefined(x1,x2,x3)) - { - int x1p = x1 + 1; - int x2p = x2 + 1; - int x3p = x3 + 1; - ////////////////////////////////////////////////////////////////////////// - //read distribution - //////////////////////////////////////////////////////////////////////////// - f[ZERO] = (*this->zeroDistributions)(x1,x2,x3); - - f[E] = (*this->localDistributions)(D3Q27System::ET_E, x1,x2,x3); - f[N] = (*this->localDistributions)(D3Q27System::ET_N,x1,x2,x3); - f[T] = (*this->localDistributions)(D3Q27System::ET_T,x1,x2,x3); - f[NE] = (*this->localDistributions)(D3Q27System::ET_NE,x1,x2,x3); - f[NW] = (*this->localDistributions)(D3Q27System::ET_NW,x1p,x2,x3); - f[TE] = (*this->localDistributions)(D3Q27System::ET_TE,x1,x2,x3); - f[TW] = (*this->localDistributions)(D3Q27System::ET_TW, x1p,x2,x3); - f[TN] = (*this->localDistributions)(D3Q27System::ET_TN,x1,x2,x3); - f[TS] = (*this->localDistributions)(D3Q27System::ET_TS,x1,x2p,x3); - f[TNE] = (*this->localDistributions)(D3Q27System::ET_TNE,x1,x2,x3); - f[TNW] = (*this->localDistributions)(D3Q27System::ET_TNW,x1p,x2,x3); - f[TSE] = (*this->localDistributions)(D3Q27System::ET_TSE,x1,x2p,x3); - f[TSW] = (*this->localDistributions)(D3Q27System::ET_TSW,x1p,x2p,x3); - - f[W ] = (*this->nonLocalDistributions)(D3Q27System::ET_W,x1p,x2,x3 ); - f[S ] = (*this->nonLocalDistributions)(D3Q27System::ET_S,x1,x2p,x3 ); - f[B ] = (*this->nonLocalDistributions)(D3Q27System::ET_B,x1,x2,x3p ); - f[SW] = (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1p,x2p,x3 ); - f[SE] = (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1,x2p,x3 ); - f[BW] = (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1p,x2,x3p ); - f[BE] = (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1,x2,x3p ); - f[BS] = (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1,x2p,x3p ); - f[BN] = (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1,x2,x3p ); - f[BSW] = (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1p,x2p,x3p); - f[BSE] = (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1,x2p,x3p); - f[BNW] = (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1p,x2,x3p); - f[BNE] = (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1,x2,x3p); - ////////////////////////////////////////////////////////////////////////// - - drho = f[ZERO] + f[E] + f[W] + f[N] + f[S] + f[T] + f[B] - + f[NE] + f[SW] + f[SE] + f[NW] + f[TE] + f[BW] + f[BE] - + f[TW] + f[TN] + f[BS] + f[BN] + f[TS] + f[TNE] + f[TSW] - + f[TSE] + f[TNW] + f[BNE] + f[BSW] + f[BSE] + f[BNW]; - - vx1 = f[E] - f[W] + f[NE] - f[SW] + f[SE] - f[NW] + f[TE] - f[BW] - + f[BE] - f[TW] + f[TNE] - f[TSW] + f[TSE] - f[TNW] + f[BNE] - f[BSW] - + f[BSE] - f[BNW]; - - vx2 = f[N] - f[S] + f[NE] - f[SW] - f[SE] + f[NW] + f[TN] - f[BS] + f[BN] - - f[TS] + f[TNE] - f[TSW] - f[TSE] + f[TNW] + f[BNE] - f[BSW] - f[BSE] - + f[BNW]; - - vx3 = f[T] - f[B] + f[TE] - f[BW] - f[BE] + f[TW] + f[TN] - f[BS] - f[BN] - + f[TS] + f[TNE] + f[TSW] + f[TSE] + f[TNW] - f[BNE] - f[BSW] - f[BSE] - - f[BNW]; - - LBMReal cu_sq=1.5*(vx1*vx1+vx2*vx2+vx3*vx3); - - feq[ZERO] = c8o27*(drho-cu_sq); - feq[E] = c2o27*(drho+3.0*( vx1 )+c9o2*( vx1 )*( vx1 )-cu_sq); - feq[W] = c2o27*(drho+3.0*(-vx1 )+c9o2*(-vx1 )*(-vx1 )-cu_sq); - feq[N] = c2o27*(drho+3.0*( vx2)+c9o2*( vx2)*( vx2)-cu_sq); - feq[S] = c2o27*(drho+3.0*( -vx2)+c9o2*( -vx2)*( -vx2)-cu_sq); - feq[T] = c2o27*(drho+3.0*( vx3 )+c9o2*( vx3)*( vx3)-cu_sq); - feq[B] = c2o27*(drho+3.0*( -vx3)+c9o2*( -vx3)*( -vx3)-cu_sq); - feq[NE] = c1o54*(drho+3.0*( vx1+vx2)+c9o2*( vx1+vx2)*( vx1+vx2)-cu_sq); - feq[SW] = c1o54*(drho+3.0*(-vx1-vx2)+c9o2*(-vx1-vx2)*(-vx1-vx2)-cu_sq); - feq[SE] = c1o54*(drho+3.0*( vx1-vx2)+c9o2*( vx1-vx2)*( vx1-vx2)-cu_sq); - feq[NW] = c1o54*(drho+3.0*(-vx1+vx2)+c9o2*(-vx1+vx2)*(-vx1+vx2)-cu_sq); - feq[TE] = c1o54*(drho+3.0*( vx1+vx3)+c9o2*( vx1+vx3)*( vx1+vx3)-cu_sq); - feq[BW] = c1o54*(drho+3.0*(-vx1-vx3)+c9o2*(-vx1-vx3)*(-vx1-vx3)-cu_sq); - feq[BE] = c1o54*(drho+3.0*( vx1-vx3)+c9o2*( vx1-vx3)*( vx1-vx3)-cu_sq); - feq[TW] = c1o54*(drho+3.0*(-vx1+vx3)+c9o2*(-vx1+vx3)*(-vx1+vx3)-cu_sq); - feq[TN] = c1o54*(drho+3.0*( vx2+vx3)+c9o2*( vx2+vx3)*( vx2+vx3)-cu_sq); - feq[BS] = c1o54*(drho+3.0*(-vx2-vx3)+c9o2*(-vx2-vx3)*(-vx2-vx3)-cu_sq); - feq[BN] = c1o54*(drho+3.0*( vx2-vx3)+c9o2*( vx2-vx3)*( vx2-vx3)-cu_sq); - feq[TS] = c1o54*(drho+3.0*(-vx2+vx3)+c9o2*(-vx2+vx3)*(-vx2+vx3)-cu_sq); - feq[TNE]= c1o216*(drho+3.0*( vx1+vx2+vx3)+c9o2*( vx1+vx2+vx3)*( vx1+vx2+vx3)-cu_sq); - feq[BSW]= c1o216*(drho+3.0*(-vx1-vx2-vx3)+c9o2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3)-cu_sq); - feq[BNE]= c1o216*(drho+3.0*( vx1+vx2-vx3)+c9o2*( vx1+vx2-vx3)*( vx1+vx2-vx3)-cu_sq); - feq[TSW]= c1o216*(drho+3.0*(-vx1-vx2+vx3)+c9o2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3)-cu_sq); - feq[TSE]= c1o216*(drho+3.0*( vx1-vx2+vx3)+c9o2*( vx1-vx2+vx3)*( vx1-vx2+vx3)-cu_sq); - feq[BNW]= c1o216*(drho+3.0*(-vx1+vx2-vx3)+c9o2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3)-cu_sq); - feq[BSE]= c1o216*(drho+3.0*( vx1-vx2-vx3)+c9o2*( vx1-vx2-vx3)*( vx1-vx2-vx3)-cu_sq); - feq[TNW]= c1o216*(drho+3.0*(-vx1+vx2+vx3)+c9o2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3)-cu_sq); - - //Relaxation - f[ZERO] += (feq[ZERO]-f[ZERO])*collFactor; - f[E] += (feq[E]-f[E])*collFactor; - f[W] += (feq[W]-f[W])*collFactor; - f[N] += (feq[N]-f[N])*collFactor; - f[S] += (feq[S]-f[S])*collFactor; - f[T] += (feq[T]-f[T])*collFactor; - f[B] += (feq[B]-f[B])*collFactor; - f[NE] += (feq[NE]-f[NE])*collFactor; - f[SW] += (feq[SW]-f[SW])*collFactor; - f[SE] += (feq[SE]-f[SE])*collFactor; - f[NW] += (feq[NW]-f[NW])*collFactor; - f[TE] += (feq[TE]-f[TE])*collFactor; - f[BW] += (feq[BW]-f[BW])*collFactor; - f[BE] += (feq[BE]-f[BE])*collFactor; - f[TW] += (feq[TW]-f[TW])*collFactor; - f[TN] += (feq[TN]-f[TN])*collFactor; - f[BS] += (feq[BS]-f[BS])*collFactor; - f[BN] += (feq[BN]-f[BN])*collFactor; - f[TS] += (feq[TS]-f[TS])*collFactor; - - f[TNE] += (feq[TNE]-f[TNE])*collFactor; - f[BSW] += (feq[BSW]-f[BSW])*collFactor; - f[BNE] += (feq[BNE]-f[BNE])*collFactor; - f[TSW] += (feq[TSW]-f[TSW])*collFactor; - f[TSE] += (feq[TSE]-f[TSE])*collFactor; - f[BNW] += (feq[BNW]-f[BNW])*collFactor; - f[BSE] += (feq[BSE]-f[BSE])*collFactor; - f[TNW] += (feq[TNW]-f[TNW])*collFactor; - - ////////////////////////////////////////////////////////////////////////// - //forcing - if (withForcing) - { - muX1 = x1+ix1*bcArrayMaxX1; - muX2 = x2+ix2*bcArrayMaxX2; - muX3 = x3+ix3*bcArrayMaxX3; - - forcingX1 = muForcingX1.Eval(); - forcingX2 = muForcingX2.Eval(); - forcingX3 = muForcingX3.Eval(); - - f[ZERO] += 0.0 ; - f[E ] += 3.0*c2o27 * (forcingX1) ; - f[W ] += 3.0*c2o27 * (-forcingX1) ; - f[N ] += 3.0*c2o27 * (forcingX2) ; - f[S ] += 3.0*c2o27 * (-forcingX2) ; - f[T ] += 3.0*c2o27 * (forcingX3) ; - f[B ] += 3.0*c2o27 * (-forcingX3); - f[NE ] += 3.0*c1o54 * ( forcingX1+forcingX2 ) ; - f[SW ] += 3.0*c1o54 * (-forcingX1-forcingX2 ) ; - f[SE ] += 3.0*c1o54 * ( forcingX1-forcingX2 ) ; - f[NW ] += 3.0*c1o54 * (-forcingX1+forcingX2 ) ; - f[TE ] += 3.0*c1o54 * ( forcingX1 +forcingX3) ; - f[BW ] += 3.0*c1o54 * (-forcingX1 -forcingX3) ; - f[BE ] += 3.0*c1o54 * ( forcingX1 -forcingX3) ; - f[TW ] += 3.0*c1o54 * (-forcingX1 +forcingX3) ; - f[TN ] += 3.0*c1o54 * ( forcingX2+forcingX3) ; - f[BS ] += 3.0*c1o54 * ( -forcingX2-forcingX3) ; - f[BN ] += 3.0*c1o54 * ( forcingX2-forcingX3) ; - f[TS ] += 3.0*c1o54 * ( -forcingX2+forcingX3) ; - f[TNE] += 3.0*c1o216* ( forcingX1+forcingX2+forcingX3) ; - f[BSW] += 3.0*c1o216* (-forcingX1-forcingX2-forcingX3) ; - f[BNE] += 3.0*c1o216* ( forcingX1+forcingX2-forcingX3) ; - f[TSW] += 3.0*c1o216* (-forcingX1-forcingX2+forcingX3) ; - f[TSE] += 3.0*c1o216* ( forcingX1-forcingX2+forcingX3) ; - f[BNW] += 3.0*c1o216* (-forcingX1+forcingX2-forcingX3) ; - f[BSE] += 3.0*c1o216* ( forcingX1-forcingX2-forcingX3) ; - f[TNW] += 3.0*c1o216* (-forcingX1+forcingX2+forcingX3) ; - } - ////////////////////////////////////////////////////////////////////////// -#ifdef PROOF_CORRECTNESS - LBMReal rho_post = f[ZERO] + f[E] + f[W] + f[N] + f[S] + f[T] + f[B] - + f[NE] + f[SW] + f[SE] + f[NW] + f[TE] + f[BW] + f[BE] - + f[TW] + f[TN] + f[BS] + f[BN] + f[TS] + f[TNE] + f[TSW] - + f[TSE] + f[TNW] + f[BNE] + f[BSW] + f[BSE] + f[BNW]; - LBMReal dif = drho - rho_post; -#ifdef SINGLEPRECISION - if(dif > 10.0E-7 || dif < -10.0E-7) -#else - if(dif > 10.0E-15 || dif < -10.0E-15) -#endif - { - UB_THROW(UbException(UB_EXARGS,"rho is not correct")); - } -#endif - ////////////////////////////////////////////////////////////////////////// - //write distribution - ////////////////////////////////////////////////////////////////////////// - (*this->localDistributions)(D3Q27System::ET_E,x1, x2, x3) = f[D3Q27System::INV_E]; - (*this->localDistributions)(D3Q27System::ET_N,x1, x2, x3) = f[D3Q27System::INV_N]; - (*this->localDistributions)(D3Q27System::ET_T,x1, x2, x3) = f[D3Q27System::INV_T]; - (*this->localDistributions)(D3Q27System::ET_NE,x1, x2, x3) = f[D3Q27System::INV_NE]; - (*this->localDistributions)(D3Q27System::ET_NW,x1p,x2, x3) = f[D3Q27System::INV_NW]; - (*this->localDistributions)(D3Q27System::ET_TE,x1, x2, x3) = f[D3Q27System::INV_TE]; - (*this->localDistributions)(D3Q27System::ET_TW,x1p,x2, x3) = f[D3Q27System::INV_TW]; - (*this->localDistributions)(D3Q27System::ET_TN,x1, x2, x3) = f[D3Q27System::INV_TN]; - (*this->localDistributions)(D3Q27System::ET_TS,x1, x2p,x3) = f[D3Q27System::INV_TS]; - (*this->localDistributions)(D3Q27System::ET_TNE,x1, x2, x3) = f[D3Q27System::INV_TNE]; - (*this->localDistributions)(D3Q27System::ET_TNW,x1p,x2, x3) = f[D3Q27System::INV_TNW]; - (*this->localDistributions)(D3Q27System::ET_TSE,x1, x2p,x3) = f[D3Q27System::INV_TSE]; - (*this->localDistributions)(D3Q27System::ET_TSW,x1p,x2p,x3) = f[D3Q27System::INV_TSW]; - - (*this->nonLocalDistributions)(D3Q27System::ET_W,x1p,x2, x3 ) = f[D3Q27System::INV_W ]; - (*this->nonLocalDistributions)(D3Q27System::ET_S,x1, x2p,x3 ) = f[D3Q27System::INV_S ]; - (*this->nonLocalDistributions)(D3Q27System::ET_B,x1, x2, x3p ) = f[D3Q27System::INV_B ]; - (*this->nonLocalDistributions)(D3Q27System::ET_SW,x1p,x2p,x3 ) = f[D3Q27System::INV_SW]; - (*this->nonLocalDistributions)(D3Q27System::ET_SE,x1, x2p,x3 ) = f[D3Q27System::INV_SE]; - (*this->nonLocalDistributions)(D3Q27System::ET_BW,x1p,x2, x3p ) = f[D3Q27System::INV_BW]; - (*this->nonLocalDistributions)(D3Q27System::ET_BE,x1, x2, x3p ) = f[D3Q27System::INV_BE]; - (*this->nonLocalDistributions)(D3Q27System::ET_BS,x1, x2p,x3p ) = f[D3Q27System::INV_BS]; - (*this->nonLocalDistributions)(D3Q27System::ET_BN,x1, x2, x3p ) = f[D3Q27System::INV_BN]; - (*this->nonLocalDistributions)(D3Q27System::ET_BSW,x1p,x2p,x3p) = f[D3Q27System::INV_BSW]; - (*this->nonLocalDistributions)(D3Q27System::ET_BSE,x1, x2p,x3p) = f[D3Q27System::INV_BSE]; - (*this->nonLocalDistributions)(D3Q27System::ET_BNW,x1p,x2, x3p) = f[D3Q27System::INV_BNW]; - (*this->nonLocalDistributions)(D3Q27System::ET_BNE,x1, x2, x3p) = f[D3Q27System::INV_BNE]; - - (*this->zeroDistributions)(x1,x2,x3) = f[D3Q27System::ZERO]; - ////////////////////////////////////////////////////////////////////////// - - - } - } - } - } -} -////////////////////////////////////////////////////////////////////////// -double LBMKernelETD3Q27BGK::getCalculationTime() -{ - return 0.0; -} diff --git a/src/cpu/VirtualFluidsCore/LBM/LBMKernelETD3Q27BGK.h b/src/cpu/VirtualFluidsCore/LBM/LBMKernelETD3Q27BGK.h deleted file mode 100644 index 632a80402..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/LBMKernelETD3Q27BGK.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef LBMKERNELETD3Q27BGK_H -#define LBMKERNELETD3Q27BGK_H - -#include "LBMKernel.h" -#include "basics/container/CbArray4D.h" -#include "basics/container/CbArray3D.h" - - - -class LBMKernelETD3Q27BGK : public LBMKernel -{ -public: - LBMKernelETD3Q27BGK(); - ~LBMKernelETD3Q27BGK(void); - void calculate(int step)override; - SPtr<LBMKernel> clone()override; - double getCalculationTime() override; - -private: - void initDataSet(); - //void collideAllCompressible(); - //void collideAllIncompressible(); - - CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr localDistributions; - CbArray4D<LBMReal,IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions; - CbArray3D<LBMReal,IndexerX3X2X1>::CbArray3DPtr zeroDistributions; - - mu::value_type muX1,muX2,muX3; - LBMReal forcingX1; - LBMReal forcingX2; - LBMReal forcingX3; - - -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/LBM/LBMSystem.cpp b/src/cpu/VirtualFluidsCore/LBM/LBMSystem.cpp index ccb983807..1d0255570 100644 --- a/src/cpu/VirtualFluidsCore/LBM/LBMSystem.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/LBMSystem.cpp @@ -1,6 +1,39 @@ -#include "LBMSystem.h" - -namespace LBMSystem -{ - real SMAG_CONST = REAL_CAST(0.18); -} +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file LBMSystem.cpp +//! \ingroup LBM +//! \author Sebastian Geller +//======================================================================================= + +#include "LBMSystem.h" + +namespace LBMSystem +{ + real SMAG_CONST = REAL_CAST(0.18); +} diff --git a/src/cpu/VirtualFluidsCore/LBM/LBMSystem.h b/src/cpu/VirtualFluidsCore/LBM/LBMSystem.h index 6aae53040..06569fe75 100644 --- a/src/cpu/VirtualFluidsCore/LBM/LBMSystem.h +++ b/src/cpu/VirtualFluidsCore/LBM/LBMSystem.h @@ -1,94 +1,95 @@ -#ifndef LBMSYSTEM_H -#define LBMSYSTEM_H - -#include <cmath> -#include <string> -#include <iostream> - -#ifdef RCF_USE_SF_SERIALIZATION -#include <SF/Serializer.hpp> - -#if CAB_RCF <= 903 -#include <SF/SerializeEnum.hpp> -#endif -#endif //RCF_USE_SF_SERIALIZATION - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbTuple.h> -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbSystem.h> - -/*=========================================================================*/ -/* LBMSystem */ -/* */ -/** -namespace for global system-functions -<BR><BR> -@author <A HREF="mailto:geller@irmb.tu-bs.de">S. Geller</A> -@version 1.0 - 07.01.11 -*/ - -/* -usage: ... -*/ - -namespace LBMSystem -{ -#ifndef SWIG - using namespace UbMath; -#endif - -//#define SINGLEPRECISION - -#ifdef SINGLEPRECISION - typedef float real; - #define REAL_CAST(x) ( (LBMSystem::real)(x) ) -#else - typedef double real; - #define REAL_CAST(x) ( x ) -#endif - - extern real SMAG_CONST; - - ////////////////////////////////////////////////////////////////////////// - //!get LBM deltaT is equal LBM DeltaX - //!deltaT is dependent from grid level - //!for first grid level is deltaT = 1.0 - //!for next grid level 1/2 etc. - static real getDeltaT(int level) - { - return REAL_CAST(1.0/REAL_CAST(1<<level)); - } - - ////////////////////////////////////////////////////////////////////////// - //!calculate collision factor omega = 1.0/(3.0*viscosity/deltaT+0.5) - //!deltaT is dependent from grid level - //!for first grid level is deltaT = 1.0 - //!for next grid level 1/2 etc. - static real calcCollisionFactor(real viscosity, int level) - { - //return REAL_CAST(1.0/(3.0*viscosity/deltaT+0.5)); - return REAL_CAST(1.0/(3.0*viscosity/(1.0/REAL_CAST(1<<level))+0.5)); - } - - //bulk viscosity - static real calcOmega2(real viscosity, int level) - { - return REAL_CAST(1.0/(4.5*viscosity/(1.0/REAL_CAST(1<<level))+0.5)); - } - - static real calcOmega2(real viscosity, real deltaT) - { - return REAL_CAST(1.0/(4.5*viscosity/deltaT+0.5)); - } -} - -//some typedefs for global namespace -typedef LBMSystem::real LBMReal; - -//#define LBMSystem::real LBMReal - - - -#endif - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file LBMSystem.h +//! \ingroup LBM +//! \author Sebastian Geller +//======================================================================================= +#ifndef LBMSYSTEM_H +#define LBMSYSTEM_H + +#include <cmath> +#include <string> +#include <iostream> + + +//! \brief namespace for global system-functions + +namespace LBMSystem +{ + +//#define SINGLEPRECISION + +#ifdef SINGLEPRECISION + typedef float real; + #define REAL_CAST(x) ( (LBMSystem::real)(x) ) +#else + typedef double real; + #define REAL_CAST(x) ( x ) +#endif + + extern real SMAG_CONST; + + ////////////////////////////////////////////////////////////////////////// + //!get LBM deltaT is equal LBM DeltaX + //!deltaT is dependent from grid level + //!for first grid level is deltaT = 1.0 + //!for next grid level 1/2 etc. + static real getDeltaT(int level) + { + return REAL_CAST(1.0/REAL_CAST(1<<level)); + } + + ////////////////////////////////////////////////////////////////////////// + //!calculate collision factor omega = 1.0/(3.0*viscosity/deltaT+0.5) + //!deltaT is dependent from grid level + //!for first grid level is deltaT = 1.0 + //!for next grid level 1/2 etc. + static real calcCollisionFactor(real viscosity, int level) + { + //return REAL_CAST(1.0/(3.0*viscosity/deltaT+0.5)); + return REAL_CAST(1.0/(3.0*viscosity/(1.0/REAL_CAST(1<<level))+0.5)); + } + + //!bulk viscosity + static real calcOmega2(real viscosity, int level) + { + return REAL_CAST(1.0/(4.5*viscosity/(1.0/REAL_CAST(1<<level))+0.5)); + } + //!bulk viscosity + static real calcOmega2(real viscosity, real deltaT) + { + return REAL_CAST(1.0/(4.5*viscosity/deltaT+0.5)); + } +} + +//some typedefs for global namespace +typedef LBMSystem::real LBMReal; + +#endif + diff --git a/src/cpu/VirtualFluidsCore/LBM/LBMUnitConverter.h b/src/cpu/VirtualFluidsCore/LBM/LBMUnitConverter.h index 1af263838..2b1eb8b4e 100644 --- a/src/cpu/VirtualFluidsCore/LBM/LBMUnitConverter.h +++ b/src/cpu/VirtualFluidsCore/LBM/LBMUnitConverter.h @@ -1,196 +1,190 @@ -#ifndef LBMUNITCONVERTER_H -#define LBMUNITCONVERTER_H - -#include <iostream> -#include <iomanip> -#include <string> -#include <sstream> -#include <cmath> - -//#include "LBMUnitConverter.h" - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbFileInput.h> -#include <basics/utilities/UbFileOutput.h> - -// LBMUnitConverter conv( 100 /*L_World*/, 1484/*cs_water*/ , 1000/*rho_water*/ -// , 1000/*L_LB*/ , 1./srqt(3.)/*cs_Lb*/, 1/*rho_Lb*/ ); -// cout<<conv.toString()<<endl; -// -// cout<<"100m = "<< 100 * conv.getFactorLentghWToLb() << "dx " << std::endl; -// cout<<"1000dx = "<< 1000 * conv.getFactorLentghLbToW() << "m " << std::endl; -// -// cout<<"25m/s = "<< 25 * conv.getFactorVelocityWToLb() << "dx/dt " << std::endl; -// cout<<"0.04 dx/dt = "<< 0.04 * conv.getFactorVelocityLbToW() << "m/s " << std::endl; -// -//alternativ -// LBMUnitConverter conv(, 100 /*L_World*/, LBMUnitConverter::WATER, 1000/*L_LB*/ ); - - -class LBMUnitConverter -{ -public: - - enum WORLD_MATERIAL { WATER = 0, SEAWWATER = 1, AIR_20C = 2, OIL = 3 }; - - LBMUnitConverter() : factorLengthLbToW(1.0), - factorTimeLbToW(1.0), - factorMassLbToW(1.0), - refRhoLb(1.0), - factorVelocityLbToW(1.0), - factorViscosityLbToW(1.0), - factorDensityLbToW(1.0), - factorPressureLbToW(1.0) - { - - } - - LBMUnitConverter( const double& refLengthWorld, const double& csWorld, const double& rhoWorld - , const double& refLengthLb , const double& csLb = 1.0/std::sqrt(3.0) , const double& rhoLb = 1.0 ) - { - this->init( refLengthWorld, csWorld, rhoWorld, csWorld, refLengthLb, rhoLb, csLb ); - - } - - LBMUnitConverter( const double& refLengthWorld, WORLD_MATERIAL worldMaterial - , const double& refLengthLb , const double& csLb = 1.0/std::sqrt(3.0) , const double& rhoLb = 1.0 ) - { - double csWorld; - double rhoWorld; - - if ( worldMaterial == WATER ) { csWorld = 1484/*m/s*/; rhoWorld = 1000/*kg/m^3*/; } - else if( worldMaterial == SEAWWATER) { csWorld = 1500/*m/s*/; rhoWorld = 1025/*kg/m^3*/; } - else if( worldMaterial == AIR_20C ) { csWorld = 343/*m/s*/; rhoWorld = 1.290/*kg/m^3*/; } - else if( worldMaterial == OIL ) { csWorld = 1740/*m/s*/; rhoWorld = 830/*kg/m^3*/; } - else throw UbException(UB_EXARGS,"unknown material"); - - this->init( refLengthWorld, csWorld, rhoWorld, csWorld, refLengthLb, rhoLb, csLb ); - - } - - LBMUnitConverter(int dummy, double uReal, double uLB, double nuReal, double nuLB) - { - factorVelocityLbToW = uReal/uLB; - factorViscosityLbToW = nuReal/nuLB; - factorDensityLbToW = factorViscosityLbToW * factorVelocityLbToW * factorVelocityLbToW; - factorPressureLbToW = factorDensityLbToW; - } - - virtual ~LBMUnitConverter() {} - - double getRefRhoLb() { return refRhoLb; } - - double getFactorLentghLbToW() { return factorLengthLbToW; } - double getFactorLentghWToLb() { return 1.0/this->getFactorLentghLbToW(); } - - double getFactorTimeLbToW() { return factorTimeLbToW; } - double getFactorTimeWToLb() { return 1.0/this->getFactorTimeLbToW(); } - - double getFactorVelocityLbToW() { return factorLengthLbToW/factorTimeLbToW; } - double getFactorVelocityWToLb() { return 1.0/this->getFactorVelocityLbToW(); } - - double getFactorViscosityLbToW() { return factorLengthLbToW*factorLengthLbToW/factorTimeLbToW; } - double getFactorViscosityWToLb() { return 1.0/this->getFactorViscosityLbToW(); } - - double getFactorDensityLbToW() { return this->factorMassLbToW/std::pow(factorLengthLbToW,3.0); } - double getFactorDensityWToLb() { return 1.0/this->getFactorDensityLbToW(); } - - double getFactorPressureLbToW() { return this->factorMassLbToW/(std::pow(factorTimeLbToW,2.0)*factorLengthLbToW); } - double getFactorPressureWToLb() { return 1.0/this->getFactorPressureLbToW(); } - - double getFactorMassLbToW() { return this->factorMassLbToW; } - double getFactorMassWToLb() { return 1.0/this->getFactorMassLbToW(); } - - double getFactorForceLbToW() { return factorMassLbToW*factorLengthLbToW/(factorTimeLbToW*factorTimeLbToW); } - double getFactorForceWToLb() { return 1.0/this->getFactorForceLbToW(); } - - double getFactorAccLbToW() { return factorLengthLbToW/(factorTimeLbToW*factorTimeLbToW); } - double getFactorAccWToLb() { return 1.0/this->getFactorAccLbToW(); } - - double getFactorTimeLbToW(double deltaX) const { return factorTimeWithoutDx * deltaX; } - ////////////////////////////////////////////////////////////////////////// - double getFactorVelocityLbToW2() { return factorVelocityLbToW; } - double getFactorDensityLbToW2() { return factorDensityLbToW; } - double getFactorPressureLbToW2() { return factorPressureLbToW; } - - - - /*==========================================================*/ - friend inline std::ostream& operator << (std::ostream& os, LBMUnitConverter c) - { - os<<c.toString(); - return os; - } - /*==========================================================*/ - std::string toString() - { - std::ostringstream out; - out<<"LB --> WORLD" << std::endl; - out<<" * lentgh 1[dx ] = " << std::setw(12) << this->getFactorLentghLbToW() << " [m ] " << std::endl; - out<<" * time 1[dt ] = " << std::setw(12) << this->getFactorTimeLbToW() << " [s ] " << std::endl; - out<<" * mass 1[mass] = " << std::setw(12) << this->getFactorMassLbToW() << " [kg ] " << std::endl; - out<<std::endl; - out<<"WORLD --> LB" << std::endl; - out<<" * lentgh 1[m ] = " << std::setw(12) << this->getFactorLentghWToLb() << " [dx ] " << std::endl; - out<<" * time 1[s ] = " << std::setw(12) << this->getFactorTimeWToLb() << " [dt ] " << std::endl; - out<<" * mass 1[kg ] = " << std::setw(12) << this->getFactorMassWToLb() << " [mass] " << std::endl; - out<<std::endl; - out<<"LB --> WORLD (combined units)" << std::endl; - out<<" * velocity 1 [dx/dt ] = " << std::setw(12) << this->getFactorVelocityLbToW() << " [m/s ]" << std::endl; - out<<" * density 1 [mass/dx^3] = " << std::setw(12) << this->getFactorDensityLbToW() << " [kg/m^3 ]" << std::endl; - out<<" * pressure 1 [F_lb/dx^2] = " << std::setw(12) << this->getFactorPressureLbToW() << " [N/m^2 ]" << std::endl; - out<<" * viscosity 1 [dx^2/dt ] = " << std::setw(12) << this->getFactorViscosityLbToW() << " [m^2/s ]" << std::endl; - out<<" * force 1 [F_lb ] = " << std::setw(12) << this->getFactorForceLbToW() << " [N ]" << std::endl; - out<<" * acceleration 1 [dx/dt^2 ] = " << std::setw(12) << this->getFactorAccLbToW() << " [m/s^2 ]" << std::endl; - out<<std::endl; - out<<"WORLD --> LB (combined units)" << std::endl; - out<<" * velocity 1 [m/s ] = " << std::setw(12) << this->getFactorVelocityWToLb() << " [dx/dt ]" << std::endl; - out<<" * density 1 [kg/m^3 ] = " << std::setw(12) << this->getFactorDensityWToLb() << " [mass/dx^3]" << std::endl; - out<<" * pressure 1 [N/m^2 ] = " << std::setw(12) << this->getFactorPressureWToLb() << " [F_lb/dx^2]" << std::endl; - out<<" * viscosity 1 [m^2/s ] = " << std::setw(12) << this->getFactorViscosityWToLb() << " [dx^2/dt ]" << std::endl; - out<<" * force 1 [N ] = " << std::setw(12) << this->getFactorForceWToLb() << " [F_lb ]" << std::endl; - out<<" * acceleration 1 [m/s^2 ] = " << std::setw(12) << this->getFactorAccWToLb() << " [dx/dt^2 ]" << std::endl; - - return out.str(); - } - /*==========================================================*/ - virtual void write(UbFileOutput* out) - { - out->writeDouble(factorLengthLbToW); - out->writeDouble(factorTimeLbToW ); - out->writeDouble(factorMassLbToW ); - } - /*==========================================================*/ - virtual void read(UbFileInput* in) - { - factorLengthLbToW = in->readDouble(); - factorTimeLbToW = in->readDouble(); - factorMassLbToW = in->readDouble(); - } - - - - void init( const double& refLengthWorld, const double& csWorld, const double& rhoWorld, const double& vWorld, - const double& refLengthLb, const double& rhoLb, const double& vLb ) - { - factorLengthLbToW = refLengthWorld / refLengthLb; - factorTimeLbToW = vLb / vWorld * factorLengthLbToW; - factorMassLbToW = rhoWorld/rhoLb*factorLengthLbToW*factorLengthLbToW*factorLengthLbToW; - factorTimeWithoutDx=vLb/vWorld; - this->refRhoLb = rhoLb; - } - protected: - double factorLengthLbToW; - double factorTimeLbToW; - double factorMassLbToW; - double refRhoLb; - double factorTimeWithoutDx; - - double factorVelocityLbToW; - double factorViscosityLbToW; - double factorDensityLbToW; - double factorPressureLbToW; - -}; - -#endif //LBMUNITCONVERTER_H +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file LBMUnitConverter.h +//! \ingroup LBM +//! \author Sören Freudiger +//======================================================================================= + +#ifndef LBMUNITCONVERTER_H +#define LBMUNITCONVERTER_H + +#include <iostream> +#include <iomanip> +#include <string> +#include <sstream> +#include <cmath> + +#include <basics/utilities/UbException.h> + +//! \brief A class provides converter for LB units <-> SI units +//! \details +//! \code +//! LBMUnitConverter conv( 100 /*L_World*/, 1484/*cs_water*/ , 1000/*rho_water*/ +//! , 1000/*L_LB*/ , 1./srqt(3.)/*cs_Lb*/, 1/*rho_Lb*/ ); +//! cout<<conv.toString()<<endl; +//! +//! cout<<"100m = "<< 100 * conv.getFactorLentghWToLb() << "dx " << std::endl; +//! cout<<"1000dx = "<< 1000 * conv.getFactorLentghLbToW() << "m " << std::endl; +//! +//! cout<<"25m/s = "<< 25 * conv.getFactorVelocityWToLb() << "dx/dt " << std::endl; +//! cout<<"0.04 dx/dt = "<< 0.04 * conv.getFactorVelocityLbToW() << "m/s " << std::endl; +//! \endcode +//! alternative +//! \code +//! LBMUnitConverter conv(, 100 /*L_World*/, LBMUnitConverter::WATER, 1000/*L_LB*/ ); +//! \endcode + +class LBMUnitConverter +{ +public: + + enum WORLD_MATERIAL { WATER = 0, SEAWWATER = 1, AIR_20C = 2, OIL = 3 }; + + LBMUnitConverter() : factorLengthLbToW(1.0), + factorTimeLbToW(1.0), + factorMassLbToW(1.0), + refRhoLb(1.0) + { + + } + + LBMUnitConverter( const double& refLengthWorld, const double& csWorld, const double& rhoWorld + , const double& refLengthLb , const double& csLb = 1.0/std::sqrt(3.0) , const double& rhoLb = 1.0 ) + { + this->init( refLengthWorld, csWorld, rhoWorld, csWorld, refLengthLb, rhoLb, csLb ); + + } + + LBMUnitConverter( const double& refLengthWorld, WORLD_MATERIAL worldMaterial + , const double& refLengthLb , const double& csLb = 1.0/std::sqrt(3.0) , const double& rhoLb = 1.0 ) + { + double csWorld; + double rhoWorld; + + if ( worldMaterial == WATER ) { csWorld = 1484/*m/s*/; rhoWorld = 1000/*kg/m^3*/; } + else if( worldMaterial == SEAWWATER) { csWorld = 1500/*m/s*/; rhoWorld = 1025/*kg/m^3*/; } + else if( worldMaterial == AIR_20C ) { csWorld = 343/*m/s*/; rhoWorld = 1.290/*kg/m^3*/; } + else if( worldMaterial == OIL ) { csWorld = 1740/*m/s*/; rhoWorld = 830/*kg/m^3*/; } + else throw UbException(UB_EXARGS,"unknown material"); + + this->init( refLengthWorld, csWorld, rhoWorld, csWorld, refLengthLb, rhoLb, csLb ); + + } + + virtual ~LBMUnitConverter() {} + + double getRefRhoLb() { return refRhoLb; } + + double getFactorLentghLbToW() { return factorLengthLbToW; } + double getFactorLentghWToLb() { return 1.0/this->getFactorLentghLbToW(); } + + double getFactorTimeLbToW() { return factorTimeLbToW; } + double getFactorTimeWToLb() { return 1.0/this->getFactorTimeLbToW(); } + + double getFactorVelocityLbToW() { return factorLengthLbToW/factorTimeLbToW; } + double getFactorVelocityWToLb() { return 1.0/this->getFactorVelocityLbToW(); } + + double getFactorViscosityLbToW() { return factorLengthLbToW*factorLengthLbToW/factorTimeLbToW; } + double getFactorViscosityWToLb() { return 1.0/this->getFactorViscosityLbToW(); } + + double getFactorDensityLbToW() { return this->factorMassLbToW/std::pow(factorLengthLbToW,3.0); } + double getFactorDensityWToLb() { return 1.0/this->getFactorDensityLbToW(); } + + double getFactorPressureLbToW() { return this->factorMassLbToW/(std::pow(factorTimeLbToW,2.0)*factorLengthLbToW); } + double getFactorPressureWToLb() { return 1.0/this->getFactorPressureLbToW(); } + + double getFactorMassLbToW() { return this->factorMassLbToW; } + double getFactorMassWToLb() { return 1.0/this->getFactorMassLbToW(); } + + double getFactorForceLbToW() { return factorMassLbToW*factorLengthLbToW/(factorTimeLbToW*factorTimeLbToW); } + double getFactorForceWToLb() { return 1.0/this->getFactorForceLbToW(); } + + double getFactorAccLbToW() { return factorLengthLbToW/(factorTimeLbToW*factorTimeLbToW); } + double getFactorAccWToLb() { return 1.0/this->getFactorAccLbToW(); } + + double getFactorTimeLbToW(double deltaX) const { return factorTimeWithoutDx * deltaX; } + + /*==========================================================*/ + friend inline std::ostream& operator << (std::ostream& os, LBMUnitConverter c) + { + os<<c.toString(); + return os; + } + /*==========================================================*/ + std::string toString() + { + std::ostringstream out; + out<<"LB --> WORLD" << std::endl; + out<<" * lentgh 1[dx ] = " << std::setw(12) << this->getFactorLentghLbToW() << " [m ] " << std::endl; + out<<" * time 1[dt ] = " << std::setw(12) << this->getFactorTimeLbToW() << " [s ] " << std::endl; + out<<" * mass 1[mass] = " << std::setw(12) << this->getFactorMassLbToW() << " [kg ] " << std::endl; + out<<std::endl; + out<<"WORLD --> LB" << std::endl; + out<<" * lentgh 1[m ] = " << std::setw(12) << this->getFactorLentghWToLb() << " [dx ] " << std::endl; + out<<" * time 1[s ] = " << std::setw(12) << this->getFactorTimeWToLb() << " [dt ] " << std::endl; + out<<" * mass 1[kg ] = " << std::setw(12) << this->getFactorMassWToLb() << " [mass] " << std::endl; + out<<std::endl; + out<<"LB --> WORLD (combined units)" << std::endl; + out<<" * velocity 1 [dx/dt ] = " << std::setw(12) << this->getFactorVelocityLbToW() << " [m/s ]" << std::endl; + out<<" * density 1 [mass/dx^3] = " << std::setw(12) << this->getFactorDensityLbToW() << " [kg/m^3 ]" << std::endl; + out<<" * pressure 1 [F_lb/dx^2] = " << std::setw(12) << this->getFactorPressureLbToW() << " [N/m^2 ]" << std::endl; + out<<" * viscosity 1 [dx^2/dt ] = " << std::setw(12) << this->getFactorViscosityLbToW() << " [m^2/s ]" << std::endl; + out<<" * force 1 [F_lb ] = " << std::setw(12) << this->getFactorForceLbToW() << " [N ]" << std::endl; + out<<" * acceleration 1 [dx/dt^2 ] = " << std::setw(12) << this->getFactorAccLbToW() << " [m/s^2 ]" << std::endl; + out<<std::endl; + out<<"WORLD --> LB (combined units)" << std::endl; + out<<" * velocity 1 [m/s ] = " << std::setw(12) << this->getFactorVelocityWToLb() << " [dx/dt ]" << std::endl; + out<<" * density 1 [kg/m^3 ] = " << std::setw(12) << this->getFactorDensityWToLb() << " [mass/dx^3]" << std::endl; + out<<" * pressure 1 [N/m^2 ] = " << std::setw(12) << this->getFactorPressureWToLb() << " [F_lb/dx^2]" << std::endl; + out<<" * viscosity 1 [m^2/s ] = " << std::setw(12) << this->getFactorViscosityWToLb() << " [dx^2/dt ]" << std::endl; + out<<" * force 1 [N ] = " << std::setw(12) << this->getFactorForceWToLb() << " [F_lb ]" << std::endl; + out<<" * acceleration 1 [m/s^2 ] = " << std::setw(12) << this->getFactorAccWToLb() << " [dx/dt^2 ]" << std::endl; + + return out.str(); + } + + void init( const double& refLengthWorld, const double& csWorld, const double& rhoWorld, const double& vWorld, + const double& refLengthLb, const double& rhoLb, const double& vLb ) + { + factorLengthLbToW = refLengthWorld / refLengthLb; + factorTimeLbToW = vLb / vWorld * factorLengthLbToW; + factorMassLbToW = rhoWorld/rhoLb*factorLengthLbToW*factorLengthLbToW*factorLengthLbToW; + factorTimeWithoutDx=vLb/vWorld; + this->refRhoLb = rhoLb; + } + + protected: + double factorLengthLbToW; + double factorTimeLbToW; + double factorMassLbToW; + double refRhoLb; + double factorTimeWithoutDx; +}; + +#endif //LBMUNITCONVERTER_H diff --git a/src/cpu/VirtualFluidsCore/LBM/VoidLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/VoidLBMKernel.cpp deleted file mode 100644 index 1d8aef648..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/VoidLBMKernel.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "VoidLBMKernel.h" -#include "VoidData3D.h" -#include "BCProcessor.h" -#include "DataSet3D.h" - -VoidLBMKernel::VoidLBMKernel() -{ - -} -////////////////////////////////////////////////////////////////////////// -VoidLBMKernel::~VoidLBMKernel() -{ - -} -////////////////////////////////////////////////////////////////////////// -void VoidLBMKernel::initDataSet() -{ - SPtr<DistributionArray3D> d(new VoidData3D(nx[0]+2, nx[1]+2, nx[2]+2, -999.9)); - dataSet->setFdistributions(d); -} -////////////////////////////////////////////////////////////////////////// -SPtr<LBMKernel> VoidLBMKernel::clone() -{ - SPtr<LBMKernel> kernel(new VoidLBMKernel()); - kernel->setNX(nx); - dynamicPointerCast<VoidLBMKernel>(kernel)->initDataSet(); - kernel->setCollisionFactor(this->collFactor); - kernel->setBCProcessor(bcProcessor->clone(kernel)); - kernel->setWithForcing(withForcing); - kernel->setForcingX1(muForcingX1); - kernel->setForcingX2(muForcingX2); - kernel->setForcingX3(muForcingX3); - kernel->setIndex(ix1, ix2, ix3); - kernel->setDeltaT(deltaT); - return kernel; -} -////////////////////////////////////////////////////////////////////////// -void VoidLBMKernel::calculate(int step) -{ - -} -////////////////////////////////////////////////////////////////////////// -double VoidLBMKernel::getCalculationTime() -{ - return 0.0; -} diff --git a/src/cpu/VirtualFluidsCore/LBM/VoidLBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/VoidLBMKernel.h deleted file mode 100644 index 68c59a23c..000000000 --- a/src/cpu/VirtualFluidsCore/LBM/VoidLBMKernel.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef VoidLBMKernel_h__ -#define VoidLBMKernel_h__ - -#include "LBMKernel.h" - -class VoidLBMKernel : public LBMKernel -{ -public: - VoidLBMKernel(); - ~VoidLBMKernel(); - SPtr<LBMKernel> clone(); - void calculate(int step); - double getCalculationTime(); - void initDataSet(); -protected: - -}; -#endif // VoidLBMKernel_h__ diff --git a/src/cpu/VirtualFluidsCore/Parallel/BlocksDistributor.cpp b/src/cpu/VirtualFluidsCore/Parallel/BlocksDistributor.cpp deleted file mode 100644 index aa834cc50..000000000 --- a/src/cpu/VirtualFluidsCore/Parallel/BlocksDistributor.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "BlocksDistributor.h" - -BlocksDistributor::BlocksDistributor(SPtr<Grid3D> grid, SPtr<Communicator> comm) : grid(grid), comm(comm) -{ - -} - diff --git a/src/cpu/VirtualFluidsCore/Parallel/BlocksDistributor.h b/src/cpu/VirtualFluidsCore/Parallel/BlocksDistributor.h deleted file mode 100644 index da686dfac..000000000 --- a/src/cpu/VirtualFluidsCore/Parallel/BlocksDistributor.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef BlocksDistributor_H -#define BlocksDistributor_H - -#include "Communicator.h" -#include "Grid3D.h" - -#include <PointerDefinitions.h> - -class BlocksDistributor -{ -public: - BlocksDistributor(SPtr<Grid3D> grid, SPtr<Communicator> comm); - ~BlocksDistributor(); - -protected: -private: - SPtr<Grid3D> grid; - SPtr<Communicator> comm; -}; - -#endif - - diff --git a/src/cpu/VirtualFluidsCore/Parallel/CMakePackage.txt b/src/cpu/VirtualFluidsCore/Parallel/CMakePackage.txt index 9354d3d00..1b8416f01 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/CMakePackage.txt +++ b/src/cpu/VirtualFluidsCore/Parallel/CMakePackage.txt @@ -1,2 +1,2 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) +GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) diff --git a/src/cpu/VirtualFluidsCore/Parallel/Communicator.cpp b/src/cpu/VirtualFluidsCore/Parallel/Communicator.cpp index 72f8bc076..a53a558f4 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/Communicator.cpp +++ b/src/cpu/VirtualFluidsCore/Parallel/Communicator.cpp @@ -1,12 +1,45 @@ -#include "Communicator.h" -#include <basics/utilities/UbException.h> - -SPtr<Communicator> Communicator::instance = SPtr<Communicator>(); -////////////////////////////////////////////////////////////////////////// -SPtr<Communicator> Communicator::getInstance() -{ - if( !instance ) - UB_THROW(UbException(UB_EXARGS,"Communicator isn't initialized correctly! You can not create a new instance of abstract Communicator class!")); - return instance; -} - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Communicator.cpp +//! \ingroup Parallel +//! \author Konstantin Kutscher +//======================================================================================= + +#include "Communicator.h" +#include <basics/utilities/UbException.h> + +SPtr<Communicator> Communicator::instance = SPtr<Communicator>(); +////////////////////////////////////////////////////////////////////////// +SPtr<Communicator> Communicator::getInstance() +{ + if( !instance ) + UB_THROW(UbException(UB_EXARGS,"Communicator isn't initialized correctly! You can not create a new instance of abstract Communicator class!")); + return instance; +} + diff --git a/src/cpu/VirtualFluidsCore/Parallel/Communicator.h b/src/cpu/VirtualFluidsCore/Parallel/Communicator.h index d75ae2241..828c9f5c0 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/Communicator.h +++ b/src/cpu/VirtualFluidsCore/Parallel/Communicator.h @@ -1,58 +1,60 @@ -#ifndef COMMUNICATOR_H -#define COMMUNICATOR_H - -#include <vector> -#include <string> - -#include <PointerDefinitions.h> - -class Communicator -{ -public: - virtual ~Communicator(){} - static SPtr<Communicator> getInstance(); - virtual int getBundleID() = 0; - virtual int getNumberOfBundles() = 0; - virtual int getProcessID() = 0; - virtual int getProcessID(int bundle, int rank) = 0; - virtual int getNumberOfProcesses() = 0; - virtual bool isRoot() = 0; - virtual void* getNativeCommunicator() = 0; - - virtual void sendSerializedObject(std::stringstream& ss, int target) = 0; - virtual void receiveSerializedObject(std::stringstream& ss, int source) = 0; - - virtual int getRoot() = 0; - virtual int getBundleRoot() = 0; - virtual int getProcessRoot() = 0; - virtual int getNumberOfProcessesInBundle(int bundle) = 0; - virtual void barrier() = 0; - virtual void abort(int errorcode) = 0; - - virtual std::vector<std::string> gather(const std::string& str) = 0; - virtual std::vector<int> gather(std::vector<int>& values) = 0; - virtual std::vector<float> gather(std::vector<float>& values) = 0; - virtual std::vector<double> gather(std::vector<double>& values) = 0; - virtual std::vector<unsigned long long> gather(std::vector<unsigned long long>& values) = 0; - - virtual void allGather(std::vector<int>& svalues, std::vector<int>& rvalues) = 0; - virtual void allGather(std::vector<float>& svalues, std::vector<float>& rvalues) = 0; - virtual void allGather(std::vector<double>& svalues, std::vector<double>& rvalues) = 0; - virtual void allGather(std::vector<unsigned long long>& svalues, std::vector<unsigned long long>& rvalues) = 0; - - virtual void broadcast(int& value) = 0; - virtual void broadcast(float& value) = 0; - virtual void broadcast(double& value) = 0; - virtual void broadcast(long int& value) = 0; - virtual void broadcast(std::vector<int>& values) = 0; - virtual void broadcast(std::vector<float>& values) = 0; - virtual void broadcast(std::vector<double>& values) = 0; - virtual void broadcast(std::vector<long int>& values) = 0; -protected: - Communicator(){} - Communicator( const Communicator& ){} - static SPtr<Communicator> instance; -}; - -#endif - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Communicator.h +//! \ingroup Parallel +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef COMMUNICATOR_H +#define COMMUNICATOR_H + +#include <vector> +#include <string> + +#include <PointerDefinitions.h> + +//! \brief An abstract class for communication between processes in parallel computation +class Communicator +{ +public: + virtual ~Communicator(){} + static SPtr<Communicator> getInstance(); + virtual int getProcessID() = 0; + virtual int getNumberOfProcesses() = 0; + virtual bool isRoot() = 0; + virtual int getRoot() = 0; + virtual int getProcessRoot() = 0; +protected: + Communicator(){} + Communicator( const Communicator& ){} + static SPtr<Communicator> instance; +}; + +#endif + diff --git a/src/cpu/VirtualFluidsCore/Parallel/MPICommunicator.cpp b/src/cpu/VirtualFluidsCore/Parallel/MPICommunicator.cpp deleted file mode 100644 index cbd3cdf10..000000000 --- a/src/cpu/VirtualFluidsCore/Parallel/MPICommunicator.cpp +++ /dev/null @@ -1,245 +0,0 @@ -#if defined VF_MPI - -#include "MPICommunicator.h" -#include <mpi.h> - -#include <sstream> -using namespace std; -////////////////////////////////////////////////////////////////////////// -MPICommunicator::MPICommunicator() -{ - //proof if MPI is initialized - int mpiInitialized = (int)false; - MPI_Initialized(&mpiInitialized); - if (!mpiInitialized) - { - MPI_Init(NULL, NULL); - //MPI_Init_thread(NULL, NULL, MPI_THREAD_FUNNELED, NULL); - } - MPI_Comm_rank(MPI_COMM_WORLD, &PID); - MPI_Comm_size(MPI_COMM_WORLD, &numprocs); - //numprocs = 1000; - comm = MPI_COMM_WORLD; - root = 0; -} -////////////////////////////////////////////////////////////////////////// -MPICommunicator::~MPICommunicator() -{ - //proof if MPI is finalized - int _mpiFinalized = (int)false; - MPI_Finalized(&_mpiFinalized); - if (!_mpiFinalized) - { - MPI_Finalize(); - //UBLOG(logINFO, "MPI_Finalize()"); - } - } -////////////////////////////////////////////////////////////////////////// -SPtr<Communicator> MPICommunicator::getInstance() -{ - if( !Communicator::instance ) - Communicator::instance = SPtr<Communicator>(new MPICommunicator()); - return Communicator::instance; -} -////////////////////////////////////////////////////////////////////////// -void MPICommunicator::abort(int errorcode) -{ - MPI_Abort(comm, errorcode); -} -//////////////////////////////////////////////////////////////////////////// -vector<string> MPICommunicator::gather(const string& str) -{ - vector<string> parts; - vector<string> strings; - int scount; - vector<char> rbuf(1); - vector<int> rcounts(1); - MPI_Status status; - - if (PID == root) - { - rcounts.resize(numprocs - 1); - strings.push_back(str); - - for (int i = 1; i < numprocs; i++) - { - MPI_Recv(&rcounts[i-1], 1, MPI_INT, i, 0, comm, &status); - } - for (int i = 1; i < numprocs; i++) - { - rbuf.resize(rcounts[i-1]); - MPI_Recv(&rbuf[0], rcounts[i-1], MPI_CHAR, i, 0, comm, &status); - string s(&rbuf[0], rcounts[i-1]); - if (s != "") strings.push_back(s); - } - } - else - { - scount = (int)str.length(); - MPI_Send(&scount, 1, MPI_INT, root, 0, comm); - MPI_Send((char *)str.c_str(), scount, MPI_CHAR, root, 0, comm); - } - return strings; -} -////////////////////////////////////////////////////////////////////////// -vector<int> MPICommunicator::gather(vector<int>& values) -{ - return gather<int>(values); -} -////////////////////////////////////////////////////////////////////////// -vector<float> MPICommunicator::gather(vector<float>& values) -{ - return gather<float>(values); -} -////////////////////////////////////////////////////////////////////////// -vector<double> MPICommunicator::gather(vector<double>& values) -{ - return gather<double>(values); -} -////////////////////////////////////////////////////////////////////////// -std::vector<unsigned long long> MPICommunicator::gather(std::vector<unsigned long long>& values) -{ - return gather<unsigned long long>(values); -} -////////////////////////////////////////////////////////////////////////// -int MPICommunicator::getProcessID() -{ - return PID; -} -////////////////////////////////////////////////////////////////////////// -int MPICommunicator::getProcessID(int bundle, int rank) -{ - return PID; -} -////////////////////////////////////////////////////////////////////////// -int MPICommunicator::getNumberOfProcesses() -{ - return numprocs; -} -////////////////////////////////////////////////////////////////////////// -void* MPICommunicator::getNativeCommunicator() -{ - return &comm; -} -////////////////////////////////////////////////////////////////////////// -int MPICommunicator::getBundleID() -{ - return 0; -} -////////////////////////////////////////////////////////////////////////// -int MPICommunicator::getNumberOfBundles() -{ - return 1; -} -////////////////////////////////////////////////////////////////////////// -int MPICommunicator::getRoot() -{ - return root; -} -////////////////////////////////////////////////////////////////////////// -int MPICommunicator::getBundleRoot() -{ - return 0; -} -////////////////////////////////////////////////////////////////////////// -int MPICommunicator::getProcessRoot() -{ - return 0; -} -////////////////////////////////////////////////////////////////////////// -int MPICommunicator::getNumberOfProcessesInBundle(int bundle) -{ - return numprocs; -} -////////////////////////////////////////////////////////////////////////// -bool MPICommunicator::isRoot() -{ - return PID == root; -} -////////////////////////////////////////////////////////////////////////// -void MPICommunicator::sendSerializedObject( std::stringstream& ss, int target) -{ - string str = ss.str(); - int scount = static_cast<int> (str.length()); - MPI_Send(&scount,1,MPI_INT,target,0,comm); - MPI_Send((char *)str.c_str(),scount,MPI_CHAR,target,0,comm); -} -////////////////////////////////////////////////////////////////////////// -void MPICommunicator::receiveSerializedObject( std::stringstream& ss, int source ) -{ - vector<char> rbuf; - int rcount; - MPI_Status status; - MPI_Recv(&rcount,1,MPI_INT,source,0,comm,&status); - rbuf.resize(rcount); - MPI_Recv(&rbuf[0],rcount,MPI_CHAR,source,0,comm,&status); - ss.rdbuf()->pubsetbuf(&rbuf[0],rcount); - string str (&rbuf[0]); - ss.str(str); -} -////////////////////////////////////////////////////////////////////////// -void MPICommunicator::barrier() -{ - MPI_Barrier(comm); -} -////////////////////////////////////////////////////////////////////////// -void MPICommunicator::allGather(std::vector<int>& svalues, std::vector<int>& rvalues) -{ - allGather<int>(svalues, rvalues); -} -////////////////////////////////////////////////////////////////////////// -void MPICommunicator::allGather(std::vector<float>& svalues, std::vector<float>& rvalues) -{ - allGather<float>(svalues, rvalues); -} -////////////////////////////////////////////////////////////////////////// -void MPICommunicator::allGather(std::vector<double>& svalues, std::vector<double>& rvalues) -{ - allGather<double>(svalues, rvalues); -} -////////////////////////////////////////////////////////////////////////// -void MPICommunicator::allGather(std::vector<unsigned long long>& svalues, std::vector<unsigned long long>& rvalues) -{ - allGather<unsigned long long>(svalues, rvalues); -} -////////////////////////////////////////////////////////////////////////// -void MPICommunicator::broadcast(std::vector<int>& values) -{ - broadcast<int>(values); -} -////////////////////////////////////////////////////////////////////////// -void MPICommunicator::broadcast(std::vector<float>& values) -{ - broadcast<float>(values); -} -////////////////////////////////////////////////////////////////////////// -void MPICommunicator::broadcast(std::vector<double>& values) -{ - broadcast<double>(values); -} -////////////////////////////////////////////////////////////////////////// -void MPICommunicator::broadcast(std::vector<long int>& values) -{ - broadcast<long int>(values); -} -////////////////////////////////////////////////////////////////////////// -void MPICommunicator::broadcast(int& value) -{ - broadcast<int>(value); -} -////////////////////////////////////////////////////////////////////////// -void MPICommunicator::broadcast(float& value) -{ - broadcast<float>(value); -} -////////////////////////////////////////////////////////////////////////// -void MPICommunicator::broadcast(double& value) -{ - broadcast<double>(value); -} -////////////////////////////////////////////////////////////////////////// -void MPICommunicator::broadcast(long int& value) -{ - broadcast<long int>(value); -} -#endif diff --git a/src/cpu/VirtualFluidsCore/Parallel/MPICommunicator.h b/src/cpu/VirtualFluidsCore/Parallel/MPICommunicator.h deleted file mode 100644 index 041029e04..000000000 --- a/src/cpu/VirtualFluidsCore/Parallel/MPICommunicator.h +++ /dev/null @@ -1,190 +0,0 @@ -#if defined VF_MPI - -#ifndef MPICOMMUNICATOR_H -#define MPICOMMUNICATOR_H - -#include <mpi.h> -#include <vector> -#include <string> -#include <PointerDefinitions.h> -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbLogger.h> -#include "Communicator.h" - - -//! \brief A class uses MPI library to communication. -//! \details Support MPI communication. Implements singleton pattern. -//! \author K. Kutscher - -class MPICommunicator : public Communicator -{ -private: - MPICommunicator(); - MPICommunicator( const MPICommunicator& ){} -public: - ~MPICommunicator(); - static SPtr<Communicator> getInstance(); - int getBundleID(); - int getNumberOfBundles(); - int getProcessID(); - int getProcessID(int bundle, int rank); - int getNumberOfProcesses(); - void* getNativeCommunicator(); - int getRoot(); - int getBundleRoot(); - int getProcessRoot(); - int getNumberOfProcessesInBundle(int bundle); - bool isRoot(); - void abort(int errorcode); - - void sendSerializedObject(std::stringstream& ss, int target); - void receiveSerializedObject(std::stringstream& ss, int source); - - void barrier(); - - std::vector<std::string> gather(const std::string& str); - std::vector<int> gather(std::vector<int>& values); - std::vector<float> gather(std::vector<float>& values); - std::vector<double> gather(std::vector<double>& values); - std::vector<unsigned long long> gather(std::vector<unsigned long long>& values); - - void allGather(std::vector<int>& svalues, std::vector<int>& rvalues); - void allGather(std::vector<float>& svalues, std::vector<float>& rvalues); - void allGather(std::vector<double>& svalues, std::vector<double>& rvalues); - void allGather(std::vector<unsigned long long>& svalues, std::vector<unsigned long long>& rvalues); - - void broadcast(int& value); - void broadcast(float& value); - void broadcast(double& value); - void broadcast(long int& value); - void broadcast(std::vector<int>& values); - void broadcast(std::vector<float>& values); - void broadcast(std::vector<double>& values); - void broadcast(std::vector<long int>& values); - - template <class T> - std::vector<T> gather(std::vector<T>& values); - - template <class T> - void allGather(std::vector<T>& svalues, std::vector<T>& rvalues); - - template <class T> - void broadcast(std::vector<T>& values); - - template <class T> - void broadcast(T& value); - -private: - int numprocs, PID; - MPI_Comm comm; - int root; -}; - -////////////////////////////////////////////////////////////////////////// -template <class T> -std::vector<T> MPICommunicator::gather(std::vector<T>& values) -{ - MPI_Datatype mpiDataType; - if ((std::string)typeid(T).name()==(std::string)typeid(double).name()) mpiDataType = MPI_DOUBLE; - else if ((std::string)typeid(T).name()==(std::string)typeid(float).name()) mpiDataType = MPI_FLOAT; - else if ((std::string)typeid(T).name()==(std::string)typeid(int).name()) mpiDataType = MPI_INT; - else if ((std::string)typeid(T).name()==(std::string)typeid(unsigned long long).name()) mpiDataType = MPI_UNSIGNED_LONG_LONG; - else throw UbException(UB_EXARGS, "no MpiDataType for T"+(std::string)typeid(T).name()); - - int count = static_cast<int> (values.size()); - std::vector<T> rvalues(1); - - if (PID == root) - { - rvalues.resize(numprocs*count); - } - - MPI_Gather(&values[0], count, mpiDataType, &rvalues[0], count, mpiDataType, root, comm); - - return rvalues; -} -////////////////////////////////////////////////////////////////////////// -template <class T> -void MPICommunicator::allGather(std::vector<T>& svalues, std::vector<T>& rvalues) -{ - MPI_Datatype mpiDataType; - if ((std::string)typeid(T).name()==(std::string)typeid(double).name()) mpiDataType = MPI_DOUBLE; - else if ((std::string)typeid(T).name()==(std::string)typeid(float).name()) mpiDataType = MPI_FLOAT; - else if ((std::string)typeid(T).name()==(std::string)typeid(int).name()) mpiDataType = MPI_INT; - else if ((std::string)typeid(T).name()==(std::string)typeid(unsigned long long).name()) mpiDataType = MPI_UNSIGNED_LONG_LONG; - else throw UbException(UB_EXARGS, "no MpiDataType for T"+(std::string)typeid(T).name()); - - int scount; - std::vector<int> displs, rcounts; - - scount = (int)(svalues.size()); - - rcounts.resize(numprocs); - MPI_Allgather(&scount, 1, MPI_INT, &rcounts[0], 1, MPI_INT, comm); - displs.resize(numprocs); - - displs[0] = 0; - for (int i=1; i<numprocs; ++i) - { - displs[i] = displs[i-1]+rcounts[i-1]; - } - - rvalues.resize(displs[numprocs-1]+rcounts[numprocs-1]); - - if (rvalues.size() == 0) - { - rvalues.resize(1); - rvalues[0] = -999; - } - if (scount == 0) - { - svalues.resize(1); - svalues[0] = -999; - } - - MPI_Allgatherv(&svalues[0], scount, mpiDataType, &rvalues[0], &rcounts[0], &displs[0], mpiDataType, comm); -} -////////////////////////////////////////////////////////////////////////// -template <class T> -void MPICommunicator::broadcast(std::vector<T>& values) -{ - MPI_Datatype mpiDataType; - if ((std::string)typeid(T).name()==(std::string)typeid(double).name()) mpiDataType = MPI_DOUBLE; - else if ((std::string)typeid(T).name()==(std::string)typeid(float).name()) mpiDataType = MPI_FLOAT; - else if ((std::string)typeid(T).name()==(std::string)typeid(int).name()) mpiDataType = MPI_INT; - else if ((std::string)typeid(T).name()==(std::string)typeid(long int).name()) mpiDataType = MPI_LONG_INT; - else throw UbException(UB_EXARGS, "no MpiDataType for T"+(std::string)typeid(T).name()); - - int rcount; - if (this->PID == this->root) - { - rcount = (int)values.size(); - } - - MPI_Bcast(&rcount, 1, MPI_INT, this->root, comm); - - if (this->PID != this->root) - { - values.resize(rcount); - } - - MPI_Bcast(&values[0], (int)values.size(), mpiDataType, this->root, comm); -} -////////////////////////////////////////////////////////////////////////// -template <class T> -void MPICommunicator::broadcast(T& value) -{ - MPI_Datatype mpiDataType; - if ((std::string)typeid(T).name() == (std::string)typeid(double).name()) mpiDataType = MPI_DOUBLE; - else if ((std::string)typeid(T).name() == (std::string)typeid(float).name()) mpiDataType = MPI_FLOAT; - else if ((std::string)typeid(T).name() == (std::string)typeid(int).name()) mpiDataType = MPI_INT; - else if ((std::string)typeid(T).name()==(std::string)typeid(long int).name()) mpiDataType = MPI_LONG_INT; - else throw UbException(UB_EXARGS, "no MpiDataType for T" + (std::string)typeid(T).name()); - - MPI_Bcast(&value, 1, mpiDataType, this->root, comm); -} -////////////////////////////////////////////////////////////////////////// - -#endif - -#endif diff --git a/src/cpu/VirtualFluidsCore/Parallel/MPIIODataStructures.h b/src/cpu/VirtualFluidsCore/Parallel/MPIIODataStructures.h deleted file mode 100644 index c50e67cfb..000000000 --- a/src/cpu/VirtualFluidsCore/Parallel/MPIIODataStructures.h +++ /dev/null @@ -1,181 +0,0 @@ -#ifndef _MPI_STRUCTURES_H_ -#define _MPI_STRUCTURES_H_ - -namespace MPIIODataStructures -{ - //! \struct GridParam - //! \brief Structure describes parameters of the grid - //! \details The structure is nessasary to restore the grid correctly - struct GridParam - { - double trafoParams[33]; - double deltaX; - int blockNx1; - int blockNx2; - int blockNx3; - int nx1; - int nx2; - int nx3; - bool periodicX1; - bool periodicX2; - bool periodicX3; - bool active; - bool transformation; - }; - - //! \struct Block3d - //! \brief Structure contains information of the block - //! \details The structure is used to write the data describing the block in the grid when saving the grid - //! and to read it when restoring the grid - struct Block3d - { - int x1; - int x2; - int x3; - int bundle; - int rank; - int lrank; - int part; - int globalID; - int localID; - int level; - int interpolationFlagCF; - int interpolationFlagFC; - int counter; - bool active; - }; - - //! \struct dataSetParam - //! \brief Structure describes parameters of the dataSet that are equal in all blocks - //! \details The structure used to store some parameters needed to restore dataSet arrays - struct dataSetParam - { - int nx1; - int nx2; - int nx3; - int nx[4]; //nx1, nx2, nx3, nx4 - }; - - //! \struct DataSetRestart - //! \brief Structure describes parameters of the dataSet in MPIIORestartCoProcessor format - //! \details The structure is used when reading from the file - struct DataSetRestart - { - double collFactor; - double deltaT; - int x1; - int x2; - int x3; - int level; - int ghostLayerWidth; - bool compressible; - bool withForcing; - }; - - //! \struct DataSetMigration - //! \brief Structure describes parameters of the dataSet in MPIIOMigrationCoProcessor format - //! \details The structure is used to find the needed block in the grid when restoring a dataSet - struct DataSetMigration - { - double collFactor; - double deltaT; - int globalID; - int ghostLayerWidth; - bool compressible; - bool withForcing; - }; - - //! \struct DataSetSmallRead - //! \brief Structure describes parameters of the DataSetSmall in MPIIORestartCoProcessor format - //! \details The structure is used when reading from the file - struct DataSetSmallRestart - { - int x1; - int x2; - int x3; - int level; - }; - //! \struct dataSetSmall - //! \brief Structure containes information identifying the block in MPIIOMigrationCoProcessor format - //! \details The structure is used to find the needed block in the grid when restoring a dataSet arrays - struct DataSetSmallMigration - { - int globalID; - }; - - //! \struct BoundaryCondition - //! \brief Structure containes information about boundary conditions of the block - //! \details The structure is used to write data describing boundary conditions of the blocks when saving the grid - //! and to read it when restoring the grid - struct BoundaryCondition - { - long long noslipBoundaryFlags; // MPI_LONG_LONG - 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; - float q[26]; - - char algorithmType; - }; - - //! \struct boundCondParam - //! \brief Structure describes parameters of the boundaryConditions that are equal in all blocks - //! \details The structure used to store some parameters needed to restore boundaryConditions arrays - struct boundCondParam - { - int nx1; - int nx2; - int nx3; - int bcindexmatrixCount; // how many bcindexmatrix-values in one (any) block - }; - - //! \struct BCAddRead - //! \brief Structure describes parameters of the BCAdd in MPIIORestartCoProcessor format - //! \details The structure is used when reading from the file - struct BCAddRestart - { - int x1; // to find the right block - int x2; - int x3; - int level; - int boundCond_count; // how many BoundaryCondition-structures are in this block - int indexContainer_count; // how many indexContainer-values are in this block - }; - - //! \struct BCAdd - //! \brief Structure containes information identifying the block and some parameters of the arrays - //! \of boundary conditions that are equal in all blocks in MPIIOMigrationCoProcessor format - //! \details The structure is used to find the needed block in the grid when restoring a dataSet - //! and to set common parameters - struct BCAddMigration - { - int globalID; - int boundCond_count; // how many BoundaryCondition-structures are in this block - int indexContainer_count; // how many indexContainer-values are in this block - }; - - struct DSArraysPresence - { - bool isAverageDensityArrayPresent; - bool isAverageVelocityArrayPresent; - bool isAverageFluktuationsArrayPresent; - bool isAverageTripleArrayPresent; - bool isShearStressValArrayPresent; - bool isRelaxationFactorPresent; - }; -}; -#endif \ No newline at end of file diff --git a/src/cpu/VirtualFluidsCore/Parallel/MetisPartitioner.cpp b/src/cpu/VirtualFluidsCore/Parallel/MetisPartitioner.cpp deleted file mode 100644 index c4765ed00..000000000 --- a/src/cpu/VirtualFluidsCore/Parallel/MetisPartitioner.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#if defined VF_METIS - -#include "MetisPartitioner.h" - - -MetisPartitioner::MetisPartitioner() -{ - METIS_SetDefaultOptions(options); - options[METIS_OPTION_NUMBERING] = 0; - vsize = NULL; - tpwgts = NULL; - ubvec = NULL; - - //options[METIS_OPTION_OBJTYPE] = METIS_OBJTYPE_CUT; - ////options[METIS_OPTION_OBJTYPE] = METIS_OBJTYPE_VOL; - - //options[METIS_OPTION_CTYPE] = METIS_CTYPE_SHEM; - //options[METIS_OPTION_IPTYPE] = METIS_IPTYPE_GROW; -} -////////////////////////////////////////////////////////////////////////// -MetisPartitioner::~MetisPartitioner() -{ - -} -////////////////////////////////////////////////////////////////////////// -idx_t* MetisPartitioner::getMetisOptions() -{ - return options; -} -void MetisPartitioner::setMetisOptions(int option, idx_t value) -{ - options[option] = value; -} -////////////////////////////////////////////////////////////////////////// -int MetisPartitioner::partition(int nofParts, MetisPartitioner::PartType ptype) -{ - int rc; - idx_t nvtxs = (idx_t)xadj.size()-1; // number of nodes - idx_t ncon = (idx_t)vwgt.size()/nvtxs; // number Of node constraints; - part.resize(nvtxs); - idx_t edgecutCount = 0; - idx_t nofPartsMetis = (idx_t)nofParts; - - switch (ptype) - { - case MetisPartitioner::RECURSIVE: - if ( nofParts < 1 ) UB_THROW( UbException(UB_EXARGS,"invalid nofParts<1") ); - else if (nofParts == 1) { part.resize(nvtxs, 0); return 0; } - //else if( nofParts > 8 ) UBLOG(logWARNING, "MetisPartitioner::Recursive: !!!Warning!!! best for nofParts<=8 --> Kway is maybe a better option"); - - rc = METIS_PartGraphRecursive(&nvtxs, &ncon, &xadj[0], &adjncy[0], - &vwgt[0], vsize, &adjwgt[0], &nofPartsMetis, - tpwgts, ubvec, options, &edgecutCount, &part[0]); - break; - case MetisPartitioner::KWAY: - if ( nofParts < 1 ) UB_THROW( UbException(UB_EXARGS,"invalid nofParts<1") ); - else if (nofParts == 1) { part.resize(nvtxs, 0); return 0; } - //else if( nofParts < 9 ) UBLOG(logWARNING, "MetisPartitioner::Kway: !!!Warning!!! best for nofParts>8 --> Recursive is maybe a better option"); - - rc = METIS_PartGraphKway(&nvtxs, &ncon, &xadj[0], &adjncy[0], - &vwgt[0], vsize, &adjwgt[0], &nofPartsMetis, - tpwgts, ubvec, options, &edgecutCount, &part[0]); - break; - } - - switch (rc) - { - case METIS_ERROR_INPUT: - throw UbException(UB_EXARGS,"METIS: input error"); - break; - case METIS_ERROR_MEMORY: - throw UbException(UB_EXARGS,"METIS: it could not allocate the required memory"); - break; - case METIS_ERROR: - throw UbException(UB_EXARGS,"METIS: error"); - break; - } - - return edgecutCount; -} -#endif diff --git a/src/cpu/VirtualFluidsCore/Parallel/MetisPartitioner.h b/src/cpu/VirtualFluidsCore/Parallel/MetisPartitioner.h deleted file mode 100644 index 30d68c3e1..000000000 --- a/src/cpu/VirtualFluidsCore/Parallel/MetisPartitioner.h +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @file MetisPartitioner.h -* @brief Class use METIS library for graph-based partitioning. -* @author Kostyantyn Kucher -* @date 22.09.2011 -*/ - -#ifndef METISPARTITIONER_H -#define METISPARTITIONER_H - -#if defined VF_METIS - -#include "metis.h" -#include <vector> -#include <string> -#include <PointerDefinitions.h> -#include "basics/utilities/UbLogger.h" -#include "basics/utilities/UbSystem.h" - -class MetisPartitioner -{ -public: - enum PartType { RECURSIVE, KWAY }; -public: - MetisPartitioner(); - virtual ~MetisPartitioner(); - idx_t* getMetisOptions(); - void setMetisOptions(int option, idx_t value); - int partition(int nofParts, PartType ptype); -public: - std::vector<idx_t> xadj; // adjncy offset of nodes - //(size = n+1, n=nofNodes) - std::vector<idx_t> adjncy; // array that stores the adjacency lists of nodes - //(size = m*2, m= nofEdged, factor 2 because edge A->B AND B->A has to be stored) - std::vector<idx_t> vwgt; // vertex weights (size=n*ncon, ncon=nofNodeWeightsPerNode) - std::vector<idx_t> adjwgt; // array that stores the weights of the adjacency lists - // (size=2*m) - idx_t * vsize; // array that stores the computation weights per node - // (size=n) - - real_t * tpwgts; // holds the wished fratcion of segment i, e.g. tpwgts={0.2, 0.2, 0.6} - // -> patisions 0 and one will get 20% of the weight each and part 3 60%! - // (size=nofPartitions) sum of tpwgts must be 1.0 - - real_t * ubvec; //This is an array of size ncon that specifies the allowed load imbalance tolerance for each constraint. - //For the ith partition and jth constraint the allowed weight is the ubvec[j]*tpwgts[i*ncon+j] fraction - //of the jth’s constraint total weight. The load imbalances must be greater than 1.0. - //A NULL value can be passed indicating that the load imbalance tolerance for each constraint should - //be 1.001 (for ncon=1) or 1.01 (for ncon¿1). - - std::vector<idx_t> part; // This is a vector of size n that upon successful completion stores the partition vector of the graph. - // The numbering of this vector starts from 0 -private: - idx_t options[METIS_NOPTIONS]; -}; - -#endif - -#endif diff --git a/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.cpp b/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.cpp index 527dc8753..fcd745d36 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.cpp +++ b/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.cpp @@ -1,74 +1,75 @@ -#include "NullCommunicator.h" - -NullCommunicator::NullCommunicator() -{ -} -////////////////////////////////////////////////////////////////////////// -NullCommunicator::~NullCommunicator() -{ -} -////////////////////////////////////////////////////////////////////////// -int NullCommunicator::getBundleID() -{ - return 0; -} -////////////////////////////////////////////////////////////////////////// -int NullCommunicator::getNumberOfBundles() -{ - return 0; -} -////////////////////////////////////////////////////////////////////////// -int NullCommunicator::getProcessID() -{ - return 0; -} -////////////////////////////////////////////////////////////////////////// -int NullCommunicator::getNumberOfProcesses() -{ - return 0; -} -////////////////////////////////////////////////////////////////////////// -void* NullCommunicator::getNativeCommunicator() -{ - return NULL; -} -////////////////////////////////////////////////////////////////////////// -int NullCommunicator::getRoot() -{ - return 0; -} -////////////////////////////////////////////////////////////////////////// -int NullCommunicator::getBundleRoot() -{ - return 0; -} -////////////////////////////////////////////////////////////////////////// -int NullCommunicator::getProcessRoot() -{ - return 0; -} -////////////////////////////////////////////////////////////////////////// -std::vector<std::string> NullCommunicator::gather(const std::string& str) -{ - return std::vector<std::string>(); -} -////////////////////////////////////////////////////////////////////////// -std::vector<double> NullCommunicator::gatherDoubles(std::vector<double>& values) -{ - return std::vector<double>(); -} -////////////////////////////////////////////////////////////////////////// -void NullCommunicator::allGatherInts(std::vector<int>& svalues, std::vector<int>& rvalues) -{ - -} -////////////////////////////////////////////////////////////////////////// -void NullCommunicator::sendSerializedObject(std::stringstream& ss, int target) -{ - -} -////////////////////////////////////////////////////////////////////////// -void NullCommunicator::receiveSerializedObject(std::stringstream& ss, int source) -{ - -} +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file NullCommunicator.cpp +//! \ingroup Parallel +//! \author Konstantin Kutscher +//======================================================================================= + +#include "NullCommunicator.h" + +NullCommunicator::NullCommunicator() +{ +} +////////////////////////////////////////////////////////////////////////// +NullCommunicator::~NullCommunicator() +{ +} +////////////////////////////////////////////////////////////////////////// +SPtr<Communicator> NullCommunicator::getInstance() +{ + if( !Communicator::instance ) + Communicator::instance = SPtr<Communicator>(new NullCommunicator()); + return Communicator::instance; +} +////////////////////////////////////////////////////////////////////////// +int NullCommunicator::getProcessID() +{ + return 0; +} +////////////////////////////////////////////////////////////////////////// +int NullCommunicator::getNumberOfProcesses() +{ + return 1; +} +////////////////////////////////////////////////////////////////////////// +bool NullCommunicator::isRoot() +{ + return true; +} +////////////////////////////////////////////////////////////////////////// +int NullCommunicator::getRoot() +{ + return 0; +} +////////////////////////////////////////////////////////////////////////// +int NullCommunicator::getProcessRoot() +{ + return 0; +} + diff --git a/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.h b/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.h index ada19144d..b554ebc00 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.h +++ b/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.h @@ -1,30 +1,60 @@ -#ifndef NullCommunicator_H -#define NullCommunicator_H - -#include "Communicator.h" - -#include <PointerDefinitions.h> - -class NullCommunicator : public Communicator -{ -public: - NullCommunicator(); - ~NullCommunicator(); - int getBundleID(); - int getNumberOfBundles(); - int getProcessID(); - int getNumberOfProcesses(); - void* getNativeCommunicator(); - int getRoot(); - int getBundleRoot(); - int getProcessRoot(); - std::vector<std::string> gather(const std::string& str); - std::vector<double> gatherDoubles(std::vector<double>& values); - void allGatherInts(std::vector<int>& svalues, std::vector<int>& rvalues); - void sendSerializedObject(std::stringstream& ss, int target); - void receiveSerializedObject(std::stringstream& ss, int source); -protected: -private: -}; - -#endif +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file NullCommunicator.h +//! \ingroup Parallel +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef NullCommunicator_H +#define NullCommunicator_H + +#include "Communicator.h" + +#include <PointerDefinitions.h> + +//! \brief A class implements Communicator for shared memory. +//! \details NullCommunicator is only a place-holder. It is only one process in shared memory. +class NullCommunicator : public Communicator +{ + private: + NullCommunicator(); + NullCommunicator( const NullCommunicator& ){} +public: + ~NullCommunicator(); + static SPtr<Communicator> getInstance(); + int getProcessID(); + int getNumberOfProcesses(); + bool isRoot(); + int getRoot(); + int getProcessRoot(); +protected: +private: +}; + +#endif diff --git a/src/cpu/VirtualFluidsCore/Parallel/PriorityQueueDecompositor.cpp b/src/cpu/VirtualFluidsCore/Parallel/PriorityQueueDecompositor.cpp deleted file mode 100644 index 31083a232..000000000 --- a/src/cpu/VirtualFluidsCore/Parallel/PriorityQueueDecompositor.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "PriorityQueueDecompositor.h" - diff --git a/src/cpu/VirtualFluidsCore/Parallel/PriorityQueueDecompositor.h b/src/cpu/VirtualFluidsCore/Parallel/PriorityQueueDecompositor.h deleted file mode 100644 index 67f1e52d4..000000000 --- a/src/cpu/VirtualFluidsCore/Parallel/PriorityQueueDecompositor.h +++ /dev/null @@ -1,68 +0,0 @@ -/** -* @file PriorityQueueDecompositor.h -* @brief Priority Queue for threads decomposition. -* @author Kostyantyn Kucher -* @date 06/06/2011 -*/ -#ifndef PRIORITYQUEUEDECOMPOSITOR_H -#define PRIORITYQUEUEDECOMPOSITOR_H - -#include <algorithm> -#include <vector> -#include <map> - -struct sortMinMax { - bool operator() (int i,int j) const { return (i<j);} -}; - -struct sortMaxMin { - bool operator() (int i,int j) const { return (i>j);} -}; - -template <class T> -class PriorityQueueDecompositor -{ -public: - PriorityQueueDecompositor(const std::vector<T>& objcts, const std::vector<int>& weights, const int& numberOfParts) - { - for (int i = 0; i < (int)objcts.size(); i++) - { - objects.insert(std::pair<int, T>(weights[i], objcts[i])); - } - for (int i = 0; i < numberOfParts; i++) - { - std::vector<T> part; - parts.insert(std::pair<int,std::vector<T> >(0, part)); - } - } - virtual ~PriorityQueueDecompositor() - { - - } - void getDecomposition(std::vector< std::vector<T> >& prts) - { - for( itOb=objects.begin() ; itOb != objects.end(); itOb++) - { - itP = parts.begin(); - int weight = (*itP).first; - std::vector<T> obj = (*itP).second; - parts.erase(itP); - weight += (*itOb).first; - obj.push_back((*itOb).second); - parts.insert(std::pair<int,std::vector<T> >(weight, obj)); - } - - for( itP=parts.begin() ; itP != parts.end(); itP++) - { - prts.push_back((*itP).second); - } - } -protected: -private: - std::multimap<int, T, sortMaxMin> objects; - typename std::multimap<int, T, sortMaxMin>::iterator itOb; - std::multimap<int, std::vector<T>, sortMinMax> parts; - typename std::multimap<int, std::vector<T>, sortMinMax>::iterator itP; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/Parallel/SimpleGeometricPartitioner.h b/src/cpu/VirtualFluidsCore/Parallel/SimpleGeometricPartitioner.h deleted file mode 100644 index 01efd11ef..000000000 --- a/src/cpu/VirtualFluidsCore/Parallel/SimpleGeometricPartitioner.h +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @file SimpleGeometricPartitioner.h -* @author Kostyantyn Kucher -* @date 06/06/2011 -* -* @section DESCRIPTION -* -* This class make simple geometric partitioning. -*/ - -#ifndef SIMPLEGEOMETRICPARTITIONER_H -#define SIMPLEGEOMETRICPARTITIONER_H - -#include "basics/utilities/UbTuple.h" -#include "basics/utilities/UbException.h" -#include "MathUtil.hpp" - -class SimpleGeometricPartitioner -{ -public: - static UbTupleInt3 createDimensions(const int& x, const int& y, const int& z, const int& numberOfProcess) - { - int xyz = x*y*z; - - int p = numberOfProcess; - - if (p == 1) - return UbTupleInt3(1, 1, 1); - - double a = pow(p*pow(x,3.0)/xyz,1.0/3.0); - double b = pow(p*pow(y,3.0)/xyz,1.0/3.0); - double c = pow(p*pow(z,3.0)/xyz,1.0/3.0); - - MaxDim maxDim; - - if(c >= a && c >= b) - maxDim = cDim; - if(b >= a && b >= c) - maxDim = bDim; - if(a >= b && a >= c) - maxDim = aDim; - - int dim1, dim2, dim3; - dim1 = (int)Utilities::cint(a); - dim2 = (int)Utilities::cint(b); - dim3 = (int)Utilities::cint(c); - if(dim1 <= 0) dim1 = 1; - if(dim2 <= 0) dim2 = 1; - if(dim3 <= 0) dim3 = 1; - - switch (maxDim) - { - case aDim: - dim1 = p/(dim2*dim3); - if (dim1*dim2*dim3 != p) - { - dim2 = 1; - dim3 = 1; - dim1 = p; - } - break; - case bDim: - dim2 = p/(dim1*dim3); - if (dim1*dim2*dim3 != p) - { - dim1 = 1; - dim3 = 1; - dim2 = p; - } - break; - case cDim: - dim3 = p/(dim1*dim2); - if (dim1*dim2*dim3 != p) - { - dim1 = 1; - dim2 = 1; - dim3 = p; - } - break; - } - - if (dim1>x || dim2>y || dim3>z) - { - UB_THROW( UbException(UB_EXARGS,"SimpleGeometricPartitioner::createDimensions: Segmentation fault - bad number of prozess") ); - } - - UbTupleInt3 dims(dim1, dim2, dim3); - - return dims; - } - -protected: -private: - enum MaxDim {aDim,bDim,cDim}; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/Parallel/ZoltanPartitioner.cpp b/src/cpu/VirtualFluidsCore/Parallel/ZoltanPartitioner.cpp deleted file mode 100644 index b6ce1ed0a..000000000 --- a/src/cpu/VirtualFluidsCore/Parallel/ZoltanPartitioner.cpp +++ /dev/null @@ -1,204 +0,0 @@ -#if defined VF_ZOLTAN && defined VF_MPI - -#include "ZoltanPartitioner.h" -#include <iostream> -#include <stdlib.h> - -#include "UbSystem.h" - -using namespace std; - -////////////////////////////////////////////////////////////////////////// -ZoltanPartitioner::ZoltanPartitioner(MPI_Comm comm, int rank, int numberOfLocalParts): - comm(comm), rank(rank), numberOfLocalParts(numberOfLocalParts),lb_approach("PARTITION") -{ - int rc; - float ver; - - rc = Zoltan_Initialize(0, NULL, &ver); - - if (rc != ZOLTAN_OK){ - cout<<"Sorry, Zoltan can't be initialized\n"<<endl; - MPI_Finalize(); - exit(0); - } - /****************************************************************** - ** Create a Zoltan library structure for this instance of load - ** balancing. Set the parameters and query functions that will - ** govern the library's calculation. See the Zoltan User's - ** Guide for the definition of these and many other parameters. - ******************************************************************/ - - zz = Zoltan_Create(comm); -} -////////////////////////////////////////////////////////////////////////// -ZoltanPartitioner::~ZoltanPartitioner() -{ - Zoltan_Destroy(&zz); -} -////////////////////////////////////////////////////////////////////////// -void ZoltanPartitioner::partition() -{ - //General parameters - Zoltan_Set_Param(zz, "DEBUG_LEVEL", "0"); - Zoltan_Set_Param(zz, "LB_METHOD", "GRAPH"); - Zoltan_Set_Param(zz, "LB_APPROACH", lb_approach.c_str()); - Zoltan_Set_Param(zz, "NUM_GID_ENTRIES", "1"); - Zoltan_Set_Param(zz, "NUM_LID_ENTRIES", "1"); - Zoltan_Set_Param(zz, "RETURN_LISTS", "ALL"); - string nparts(UbSystem::toString<int>(numberOfLocalParts)); - Zoltan_Set_Param(zz, "NUM_LOCAL_PARTS", nparts.c_str()); - - /* Query functions - defined in simpleQueries.h */ - - Zoltan_Set_Num_Obj_Fn(zz, get_number_of_vertices, &graph); - Zoltan_Set_Obj_List_Fn(zz, get_vertex_list, &graph); - Zoltan_Set_Num_Edges_Multi_Fn(zz, get_num_edges_list, &graph); - Zoltan_Set_Edge_List_Multi_Fn(zz, get_edge_list, &graph); - - /****************************************************************** - ** Zoltan can now partition the graph. - ** In this case, we assume the number of partitions is - ** equal to the number of processes. Process rank 0 will own - ** partition 0, process rank 1 will own partition 1, and so on. - ******************************************************************/ - - int rc = Zoltan_LB_Partition(zz, /* input (all remaining fields are output) */ - &changes, /* 1 if partitioning was changed, 0 otherwise */ - &numGidEntries, /* Number of integers used for a global ID */ - &numLidEntries, /* Number of integers used for a local ID */ - &numImport, /* Number of vertices to be sent to me */ - &importGlobalGids, /* Global IDs of vertices to be sent to me */ - &importLocalGids, /* Local IDs of vertices to be sent to me */ - &importProcs, /* Process rank for source of each incoming vertex */ - &importToPart, /* New partition for each incoming vertex */ - &numExport, /* Number of vertices I must send to other processes*/ - &exportGlobalGids, /* Global IDs of the vertices I must send */ - &exportLocalGids, /* Local IDs of the vertices I must send */ - &exportProcs, /* Process to which I send each of the vertices */ - &exportToPart); /* Partition to which each vertex will belong */ - - - - if (rc != ZOLTAN_OK){ - cout << "Partitioning failed on process " << rank <<"\n" << endl; - MPI_Finalize(); - Zoltan_Destroy(&zz); - exit(0); - } -} -////////////////////////////////////////////////////////////////////////// -void ZoltanPartitioner::setLB_APPROACH(std::string lb_approach) -{ - this->lb_approach = lb_approach; -} -////////////////////////////////////////////////////////////////////////// -void ZoltanPartitioner::setNumberOfLocalParts(int numberOfLocalParts) -{ - this->numberOfLocalParts = numberOfLocalParts; -} -////////////////////////////////////////////////////////////////////////// -// Application defined query functions // -////////////////////////////////////////////////////////////////////////// -int ZoltanPartitioner::get_number_of_vertices(void *data, int *ierr) -{ - ZoltanGraph *graph = (ZoltanGraph *)data; - *ierr = ZOLTAN_OK; - return graph->numLocalVertices; -} -////////////////////////////////////////////////////////////////////////// -void ZoltanPartitioner::get_vertex_list(void *data, int sizeGID, int sizeLID, - ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID, - int wgt_dim, float *obj_wgts, int *ierr) -{ - ZoltanGraph *graph = (ZoltanGraph *)data; - *ierr = ZOLTAN_OK; - - /* In this case, return the IDs of our vertices, but no weights. - * Zoltan will assume equally weighted vertices. - */ - - for (int i=0; i<graph->numLocalVertices; i++){ - globalID[i] = graph->vvertexGID[i]; - localID[i] = i; - } -} -////////////////////////////////////////////////////////////////////////// -void ZoltanPartitioner::get_num_edges_list(void *data, int sizeGID, int sizeLID, - int num_obj, - ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID, - int *numEdges, int *ierr) -{ - ZoltanGraph *graph = (ZoltanGraph *)data; - - if ( (sizeGID != 1) || (sizeLID != 1) || (num_obj != graph->numLocalVertices)){ - *ierr = ZOLTAN_FATAL; - return; - } - - for (int i=0; i < num_obj ; i++){ - numEdges[i] = graph->vnumEdges[i]; - } - - *ierr = ZOLTAN_OK; - return; -} -////////////////////////////////////////////////////////////////////////// -void ZoltanPartitioner::get_edge_list(void *data, int sizeGID, int sizeLID, - int num_obj, ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID, - int *num_edges, - ZOLTAN_ID_PTR nborGID, int *nborProc, - int wgt_dim, float *ewgts, int *ierr) -{ - int *nextNbor, *nextProc; - - ZoltanGraph *graph = (ZoltanGraph *)data; - *ierr = ZOLTAN_OK; - - if ( (sizeGID != 1) || (sizeLID != 1) || - (num_obj != graph->numLocalVertices)|| - (wgt_dim != 0)){ - *ierr = ZOLTAN_FATAL; - return; - } - - nextNbor = (int *)nborGID; - nextProc = nborProc; - - int n=0; - for (int i=0; i < num_obj; i++){ - - /* - * In this case, we are not setting edge weights. Zoltan will - * set each edge to weight 1.0. - */ - - for (int j=0; j < num_edges[i]; j++){ - nborGID[n] = graph->vnborGID[n]; - nborProc[n] = graph->vnborProc[n]; - n++; - } - } - return; -} -////////////////////////////////////////////////////////////////////////// -ZoltanGraph* ZoltanPartitioner::getGraphData() -{ - return &graph; -} -////////////////////////////////////////////////////////////////////////// -void ZoltanPartitioner::getExportData(vector<int>& exportGlobalGids, vector<int>& exportToPart, vector<int>& exportProcs) -{ - for (int i = 0; i < this->numExport; i++) - { - exportGlobalGids.push_back(static_cast<int> (this->exportGlobalGids[i])); - exportToPart.push_back(this->exportToPart[i]); - exportProcs.push_back(this->exportProcs[i]); - } -} -////////////////////////////////////////////////////////////////////////// - bool ZoltanPartitioner::areChanges() - { - return static_cast<bool>(this->changes); - } -#endif diff --git a/src/cpu/VirtualFluidsCore/Parallel/ZoltanPartitioner.h b/src/cpu/VirtualFluidsCore/Parallel/ZoltanPartitioner.h deleted file mode 100644 index 4f5d70d15..000000000 --- a/src/cpu/VirtualFluidsCore/Parallel/ZoltanPartitioner.h +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @file ZoltanPartitioner.h -* @brief Class use Zoltan library for graph-based partitioning. -* @author Kostyantyn Kucher -* @date 10.06.2011 -*/ - -#ifndef ZOLTANPARTITIONER_H -#define ZOLTANPARTITIONER_H - -#if defined VF_ZOLTAN && defined VF_MPI - -#include "zoltan.h" -#include <vector> -#include <string> - -/* Structure to hold graph data */ - -struct ZoltanGraph{ - int numLocalVertices; // total vertices in in this partition - std::vector<int> vvertexGID; // global ID of each of my vertices - std::vector<int> vnumEdges; // number of Edges - std::vector<int> vnborGID; // global ID of neighbors - std::vector<int> vnborProc; // process owning each nbor in nborGID -}; - -struct Zoltan_Output{ - ZOLTAN_ID_PTR importGlobalGids, importLocalGids, exportGlobalGids, exportLocalGids; - int *importProcs, *importToPart, *exportProcs, *exportToPart; - int changes, numGidEntries, numLidEntries, numImport, numExport; -}; - -class ZoltanPartitioner -{ -public: - ZoltanPartitioner(MPI_Comm comm , int rank, int numberOfLocalParts); - virtual ~ZoltanPartitioner(); - void partition(); - ZoltanGraph* getGraphData(); - void setLB_APPROACH(std::string lb_approach); - void setNumberOfLocalParts(int numberOfLocalParts); - void getExportData(std::vector<int>& exportGlobalGids, std::vector<int>& exportToPart, std::vector<int>& exportProcs); - bool areChanges(); - -protected: - static int get_number_of_vertices(void *data, int *ierr); - static void get_vertex_list(void *data, int sizeGID, int sizeLID, - ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID, - int wgt_dim, float *obj_wgts, int *ierr); - static void get_num_edges_list(void *data, int sizeGID, int sizeLID, - int num_obj, - ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID, - int *numEdges, int *ierr); - static void get_edge_list(void *data, int sizeGID, int sizeLID, - int num_obj, ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID, - int *num_edges, - ZOLTAN_ID_PTR nborGID, int *nborProc, - int wgt_dim, float *ewgts, int *ierr); - -private: - MPI_Comm comm; - int rank; - int numberOfLocalParts; - struct Zoltan_Struct *zz; - std::string lb_approach; - ZOLTAN_ID_PTR importGlobalGids, importLocalGids, exportGlobalGids, exportLocalGids; - int *importProcs, *importToPart, *exportProcs, *exportToPart; - int changes, numGidEntries, numLidEntries, numImport, numExport; - ZoltanGraph graph; -}; - -#endif - -#endif diff --git a/src/cpu/VirtualFluidsCore/PointerDefinitions.h b/src/cpu/VirtualFluidsCore/PointerDefinitions.h index 8ecd34ae1..f5cabd1ff 100644 --- a/src/cpu/VirtualFluidsCore/PointerDefinitions.h +++ b/src/cpu/VirtualFluidsCore/PointerDefinitions.h @@ -1,53 +1,53 @@ -/* -* Author: S. Peters -* mail: peters@irmb.tu-bs.de -*/ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file PointerDefinitions.h +//! \ingroup Core +//! \author Soeren Peters +//======================================================================================= #ifndef SHARED_POINTER_H #define SHARED_POINTER_H -#define useStdSmartPointer - -#ifdef useStdSmartPointer - #include <memory> - #define smartPointerNamespace std -#endif - +#include <memory> template <class T> -using SPtr = smartPointerNamespace::shared_ptr<T>; +using SPtr = std::shared_ptr<T>; template <class T> -using WPtr = smartPointerNamespace::weak_ptr<T>; - -//template <class T> -//using UPtr = smartPointerNamespace::unique_ptr<T>; +using WPtr = std::weak_ptr<T>; template <class T> -using enableSharedFromThis = smartPointerNamespace::enable_shared_from_this<T>; - -#define dynamicPointerCast smartPointerNamespace::dynamic_pointer_cast +using UPtr = std::unique_ptr<T>; template <class T> using RPtr = T*; -#endif - -//#ifndef VF_BOOST -// #include <memory> -// #define smartPointerNamespace std -//#else -// #include <boost/enable_shared_from_this.hpp> -// #include <boost/pointer_cast.hpp> -// #include <boost/shared_ptr.hpp> -// #define smartPointerNamespace boost -//#endif -// -//#define SPtr smartPointerNamespace::shared_ptr -// -//#define WPtr smartPointerNamespace::weak_ptr -// -//#define enableSharedFromThis smartPointerNamespace::enable_shared_from_this -// -//#define dynamicPointerCast smartPointerNamespace::dynamic_pointer_cast +template <class T> +using enableSharedFromThis = std::enable_shared_from_this<T>; -//#endif \ No newline at end of file +#endif diff --git a/src/cpu/VirtualFluidsCore/Utilities/CMakePackage.txt b/src/cpu/VirtualFluidsCore/Utilities/CMakePackage.txt index 9354d3d00..1b8416f01 100644 --- a/src/cpu/VirtualFluidsCore/Utilities/CMakePackage.txt +++ b/src/cpu/VirtualFluidsCore/Utilities/CMakePackage.txt @@ -1,2 +1,2 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) +GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) diff --git a/src/cpu/VirtualFluidsCore/Utilities/ChangeRandomQs.hpp b/src/cpu/VirtualFluidsCore/Utilities/ChangeRandomQs.hpp deleted file mode 100644 index 384ed092f..000000000 --- a/src/cpu/VirtualFluidsCore/Utilities/ChangeRandomQs.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef ChangeRandomQs_h__ -#define ChangeRandomQs_h__ - -#include "LBMKernel.h" -#include "IntegrateValuesHelper.h" -#include "BoundaryConditions.h" -#include "BCArray3D.h" -#include "BCProcessor.h" - -namespace Utilities -{ - void ChangeRandomQs(SPtr<IntegrateValuesHelper> integrateValues) - { - std::vector<IntegrateValuesHelper::CalcNodes> cnodes = integrateValues->getCNodes(); - - for(IntegrateValuesHelper::CalcNodes cn : cnodes) - { - SPtr<ILBMKernel> kernel = cn.block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - for(UbTupleInt3 node : cn.nodes) - { - SPtr<BoundaryConditions> bc = bcArray->getBC(val<1>(node), val<2>(node), val<3>(node)); - if (bc) - { - for (int fdir=D3Q27System::FSTARTDIR; fdir<=D3Q27System::FENDDIR; fdir++) - { - if (bc->hasNoSlipBoundaryFlag(fdir)) - { - const int invDir = D3Q27System::INVDIR[fdir]; - float q = bc->getQ(invDir); - //double r = (double)UbRandom::rand(-50, 50); - float r = (float)UbRandom::rand(-10, 10); - float q_temp = q + q/r; - if (q_temp < 0.0) - { - q_temp = 0.0001f; - } - else if (q_temp > 1.0) - { - q_temp = 0.9999f; - } - bc->setQ(q_temp, fdir); - } - } - } - } - } - } - -} -#endif // ChangeRandomQs_h__ diff --git a/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.cpp b/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.cpp deleted file mode 100644 index f10790453..000000000 --- a/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.cpp +++ /dev/null @@ -1,595 +0,0 @@ -#include "CheckpointConverter.h" -#include <MemoryUtil.h> -#include "BoundaryConditions.h" -#include "Block3D.h" -#include "DataSet3D.h" -#include "Grid3D.h" -#include "Communicator.h" -#include "CoordinateTransformation3D.h" -#include <stdio.h> - -#define BLOCK_SIZE 1024 - -using namespace MPIIODataStructures; - -CheckpointConverter::CheckpointConverter(SPtr<Grid3D> grid, const std::string& path, SPtr<Communicator> comm) : - grid(grid), path(path), comm(comm) -{ - UbSystem::makeDirectory(path + "/mpi_io_cp"); - - memset(&boundCondParamStr, 0, sizeof(boundCondParamStr)); - - //------------------------- define MPI types --------------------------------- - - MPI_Datatype typesGP[3] = { MPI_DOUBLE, MPI_INT, MPI_CHAR }; - int blocksGP[3] = { 34, 6, 5 }; - MPI_Aint offsetsGP[3], lbGP, extentGP; - - offsetsGP[0] = 0; - MPI_Type_get_extent(MPI_DOUBLE, &lbGP, &extentGP); - offsetsGP[1] = blocksGP[0] * extentGP; - - MPI_Type_get_extent(MPI_INT, &lbGP, &extentGP); - offsetsGP[2] = offsetsGP[1] + blocksGP[1] * extentGP; - - MPI_Type_create_struct(3, blocksGP, offsetsGP, typesGP, &gridParamType); - MPI_Type_commit(&gridParamType); - - //----------------------------------------------------------------------- - - MPI_Datatype typesBlock[2] = { MPI_INT, MPI_CHAR }; - int blocksBlock[2] = { 13, 1 }; - MPI_Aint offsetsBlock[2], lbBlock, extentBlock; - - offsetsBlock[0] = 0; - MPI_Type_get_extent(MPI_INT, &lbBlock, &extentBlock); - offsetsBlock[1] = blocksBlock[0] * extentBlock; - - MPI_Type_create_struct(2, blocksBlock, offsetsBlock, typesBlock, &block3dType); - MPI_Type_commit(&block3dType); - - //----------------------------------------------------------------------- - - MPI_Datatype typesBC[3] = { MPI_LONG_LONG_INT, MPI_FLOAT, MPI_CHAR }; - int blocksBC[3] = { 5, 38, 1 }; - MPI_Aint offsetsBC[3], lbBC, extentBC; - - offsetsBC[0] = 0; - MPI_Type_get_extent(MPI_LONG_LONG_INT, &lbBC, &extentBC); - offsetsBC[1] = blocksBC[0] * extentBC; - - MPI_Type_get_extent(MPI_FLOAT, &lbBC, &extentBC); - offsetsBC[2] = offsetsBC[1] + blocksBC[1] * extentBC; - - MPI_Type_create_struct(3, blocksBC, offsetsBC, typesBC, &boundCondType); - MPI_Type_commit(&boundCondType); - - //----------------------------------------------------------------------- - - MPI_Type_contiguous(BLOCK_SIZE, boundCondType, &boundCondType1000); - MPI_Type_commit(&boundCondType1000); - - //--------------------------------------- - - MPI_Type_contiguous(7, MPI_INT, &dataSetParamType); - MPI_Type_commit(&dataSetParamType); - - //--------------------------------------- - - MPI_Datatype typesDataSetRead[3] = { MPI_DOUBLE, MPI_INT, MPI_CHAR }; - int blocksDataSetRead[3] = { 2, 5, 2 }; - MPI_Aint offsetsDataSetRead[3], lbDataSetRead, extentDataSetRead; - - offsetsDataSetRead[0] = 0; - MPI_Type_get_extent(MPI_DOUBLE, &lbDataSetRead, &extentDataSetRead); - offsetsDataSetRead[1] = blocksDataSetRead[0] * extentDataSetRead; - - MPI_Type_get_extent(MPI_INT, &lbDataSetRead, &extentDataSetRead); - offsetsDataSetRead[2] = offsetsDataSetRead[1] + blocksDataSetRead[1] * extentDataSetRead; - - MPI_Type_create_struct(3, blocksDataSetRead, offsetsDataSetRead, typesDataSetRead, &dataSetTypeRead); - MPI_Type_commit(&dataSetTypeRead); - - //----------------------------------------------------------------------- - - MPI_Datatype typesDataSetWrite[3] = { MPI_DOUBLE, MPI_INT, MPI_CHAR }; - int blocksDataSetWrite[3] = { 2, 2, 2 }; - MPI_Aint offsetsDataSetWrite[3], lbDataSetWrite, extentDataSetWrite; - - offsetsDataSetWrite[0] = 0; - MPI_Type_get_extent(MPI_DOUBLE, &lbDataSetWrite, &extentDataSetWrite); - offsetsDataSetWrite[1] = blocksDataSetWrite[0] * extentDataSetWrite; - - MPI_Type_get_extent(MPI_INT, &lbDataSetWrite, &extentDataSetWrite); - offsetsDataSetWrite[2] = offsetsDataSetWrite[1] + blocksDataSetWrite[1] * extentDataSetWrite; - - MPI_Type_create_struct(3, blocksDataSetWrite, offsetsDataSetWrite, typesDataSetWrite, &dataSetTypeWrite); - MPI_Type_commit(&dataSetTypeWrite); - -} - -////////////////////////////////////////////////////////////////////////// -CheckpointConverter::~CheckpointConverter() -{ - MPI_Type_free(&gridParamType); - MPI_Type_free(&block3dType); - MPI_Type_free(&boundCondType); - MPI_Type_free(&dataSetParamType); - MPI_Type_free(&dataSetTypeRead); - MPI_Type_free(&dataSetTypeWrite); - MPI_Type_free(&boundCondType1000); -} - -//------------------------------------------- READ ----------------------------------------------- -void CheckpointConverter::convert(int step, int procCount) -{ - UBLOG(logINFO, "UtilConvertor::convert start "); - - convertBlocks(step, procCount); - convertDataSet(step, procCount); - convertBC(step, procCount); - - UBLOG(logINFO, "UtilConvertor::convert finish "); -} - -void CheckpointConverter::convertBlocks(int step, int procCount) -{ - double start, finish; - start = MPI_Wtime(); - - // file to read from - MPI_File file_handlerR; - std::string filenameR = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBlocks.bin"; - int rcR = MPI_File_open(MPI_COMM_WORLD, filenameR.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handlerR); - if (rcR != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filenameR); - - // file to write to - MPI_File file_handlerW; - UbSystem::makeDirectory(path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step)); - std::string filenameW = path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBlocks.bin"; - int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handlerW); - if (rcW != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filenameW); - - // read count of blocks - int blocksCount = 0; - MPI_File_read_at(file_handlerR, 0, &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - Block3d* block3dArray = new Block3d[blocksCount]; - GridParam* gridParameters = new GridParam; - - // calculate the read offset - procCount = 1; // readBlocks and writeBlocks in both MPIIORestartCoProcessor and MPIIOMigrationCoProcessor have size == 1! - MPI_Offset read_offset = (MPI_Offset)(procCount * sizeof(int)); - - // read parameters of the grid and blocks - MPI_File_read_at(file_handlerR, read_offset, gridParameters, 1, gridParamType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + sizeof(GridParam)), &block3dArray[0], blocksCount, block3dType, MPI_STATUS_IGNORE); - - // clear the grid - std::vector<SPtr<Block3D>> blocksVector[25]; - int minInitLevel = this->grid->getCoarsestInitializedLevel(); - if (minInitLevel > -1) - { - int maxInitLevel = this->grid->getFinestInitializedLevel(); - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - grid->getBlocks(level, blocksVector[level]); - for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level - grid->deleteBlock(block); - } - } - - // restore the grid - SPtr<CoordinateTransformation3D> trafo(new CoordinateTransformation3D()); - trafo->Tx1 = gridParameters->trafoParams[0]; - trafo->Tx2 = gridParameters->trafoParams[1]; - trafo->Tx3 = gridParameters->trafoParams[2]; - trafo->Sx1 = gridParameters->trafoParams[3]; - trafo->Sx2 = gridParameters->trafoParams[4]; - trafo->Sx3 = gridParameters->trafoParams[5]; - trafo->alpha = gridParameters->trafoParams[6]; - trafo->beta = gridParameters->trafoParams[7]; - trafo->gamma = gridParameters->trafoParams[8]; - - trafo->toX1factorX1 = gridParameters->trafoParams[9]; - trafo->toX1factorX2 = gridParameters->trafoParams[10]; - trafo->toX1factorX3 = gridParameters->trafoParams[11]; - trafo->toX1delta = gridParameters->trafoParams[12]; - trafo->toX2factorX1 = gridParameters->trafoParams[13]; - trafo->toX2factorX2 = gridParameters->trafoParams[14]; - trafo->toX2factorX3 = gridParameters->trafoParams[15]; - trafo->toX2delta = gridParameters->trafoParams[16]; - trafo->toX3factorX1 = gridParameters->trafoParams[17]; - trafo->toX3factorX2 = gridParameters->trafoParams[18]; - trafo->toX3factorX3 = gridParameters->trafoParams[19]; - trafo->toX3delta = gridParameters->trafoParams[20]; - - trafo->fromX1factorX1 = gridParameters->trafoParams[21]; - trafo->fromX1factorX2 = gridParameters->trafoParams[22]; - trafo->fromX1factorX3 = gridParameters->trafoParams[23]; - trafo->fromX1delta = gridParameters->trafoParams[24]; - trafo->fromX2factorX1 = gridParameters->trafoParams[25]; - trafo->fromX2factorX2 = gridParameters->trafoParams[26]; - trafo->fromX2factorX3 = gridParameters->trafoParams[27]; - trafo->fromX2delta = gridParameters->trafoParams[28]; - trafo->fromX3factorX1 = gridParameters->trafoParams[29]; - trafo->fromX3factorX2 = gridParameters->trafoParams[30]; - trafo->fromX3factorX3 = gridParameters->trafoParams[31]; - trafo->fromX3delta = gridParameters->trafoParams[32]; - - trafo->active = gridParameters->active; - trafo->transformation = gridParameters->transformation; - - grid->setCoordinateTransformator(trafo); - - grid->setDeltaX(gridParameters->deltaX); - grid->setBlockNX(gridParameters->blockNx1, gridParameters->blockNx2, gridParameters->blockNx3); - grid->setNX1(gridParameters->nx1); - grid->setNX2(gridParameters->nx2); - grid->setNX3(gridParameters->nx3); - grid->setPeriodicX1(gridParameters->periodicX1); - grid->setPeriodicX2(gridParameters->periodicX2); - grid->setPeriodicX3(gridParameters->periodicX3); - - // regenerate blocks - for (int n = 0; n < blocksCount; n++) - { - SPtr<Block3D> block(new Block3D(block3dArray[n].x1, block3dArray[n].x2, block3dArray[n].x3, block3dArray[n].level)); - block->setActive(block3dArray[n].active); - block->setBundle(block3dArray[n].bundle); - block->setRank(block3dArray[n].rank); - block->setLocalRank(block3dArray[n].lrank); - block->setGlobalID(block3dArray[n].globalID); - block->setLocalID(block3dArray[n].localID); - block->setPart(block3dArray[n].part); - block->setLevel(block3dArray[n].level); - block->setCollectionOfInterpolationFlagCF(block3dArray[n].interpolationFlagCF); - block->setCollectionOfInterpolationFlagFC(block3dArray[n].interpolationFlagFC); - - grid->addBlock(block); - } - - // renumber blocks - grid->renumberBlockIDs(); - - // refresh globalID in all the blocks - SPtr<Block3D> block; - for (int n = 0; n < blocksCount; n++) - { - block = grid->getBlock(block3dArray[n].x1, block3dArray[n].x2, block3dArray[n].x3, block3dArray[n].level); - block3dArray[n].globalID = block->getGlobalID(); - } - - // write all data to the file - MPI_Offset write_offset = read_offset; - - MPI_File_write_at(file_handlerW, 0, &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handlerW, write_offset, gridParameters, 1, gridParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handlerW, (MPI_Offset)(write_offset + sizeof(GridParam)), &block3dArray[0], blocksCount, block3dType, MPI_STATUS_IGNORE); - - MPI_File_close(&file_handlerR); - MPI_File_close(&file_handlerW); - - finish = MPI_Wtime(); - UBLOG(logINFO, "UtilConvertor::convertBlocks time: " << finish - start << " s"); - - delete gridParameters; - delete[] block3dArray; -} - -void CheckpointConverter::convertDataSet(int step, int procCount) -{ - // file to read from - MPI_File file_handlerR; - std::string filenameR = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSet.bin"; - int rcR = MPI_File_open(MPI_COMM_WORLD, filenameR.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handlerR); - if (rcR != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filenameR); - - // file to write to - MPI_File file_handlerW; - std::string filenameW = path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpDataSet.bin"; - int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handlerW); - if (rcW != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filenameW); - - double start, finish; - start = MPI_Wtime(); - - int blocksCount = 0; - dataSetParam dataSetParamStr1, dataSetParamStr2, dataSetParamStr3; - DataSetRestart* dataSetReadArray; - DataSetMigration* dataSetWriteArray; - size_t doubleCountInBlock; - std::vector<double> doubleValuesArray; - size_t sizeofOneDataSet; - - // calculate the read offset - MPI_Offset read_offset = (MPI_Offset)(procCount * sizeof(int)); - MPI_Offset write_offset; - - for (int pc = 0; pc < procCount; pc++) - { - // read count of blocks and parameters of data arrays - MPI_File_read_at(file_handlerR, (MPI_Offset)(pc * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, read_offset, &dataSetParamStr1, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + sizeof(dataSetParam)), &dataSetParamStr2, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + 2 * sizeof(dataSetParam)), &dataSetParamStr3, 1, dataSetParamType, MPI_STATUS_IGNORE); - doubleCountInBlock = dataSetParamStr1.nx[0] * dataSetParamStr1.nx[1] * dataSetParamStr1.nx[2] * dataSetParamStr1.nx[3] + - dataSetParamStr2.nx[0] * dataSetParamStr2.nx[1] * dataSetParamStr2.nx[2] * dataSetParamStr2.nx[3] + - dataSetParamStr3.nx[0] * dataSetParamStr3.nx[1] * dataSetParamStr3.nx[2] * dataSetParamStr3.nx[3]; - - dataSetReadArray = new DataSetRestart[blocksCount]; - dataSetWriteArray = new DataSetMigration[blocksCount]; - doubleValuesArray.resize(blocksCount * doubleCountInBlock); - - // read data - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + 3 * sizeof(dataSetParam)), dataSetReadArray, blocksCount, dataSetTypeRead, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + 3 * sizeof(dataSetParam) + blocksCount * sizeof(DataSetRestart)), - &doubleValuesArray[0], blocksCount * doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - - // offset to read the data of the next process - read_offset = read_offset + (MPI_Offset)(3 * sizeof(dataSetParam) + blocksCount * (sizeof(DataSetRestart) + doubleCountInBlock * sizeof(double))); - - // write parameters of data arrays - MPI_File_write_at(file_handlerW, (MPI_Offset)0, &dataSetParamStr1, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handlerW, (MPI_Offset)(sizeof(dataSetParam)), &dataSetParamStr2, 1, dataSetParamType, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handlerW, (MPI_Offset)(2 * sizeof(dataSetParam)), &dataSetParamStr3, 1, dataSetParamType, MPI_STATUS_IGNORE); - - sizeofOneDataSet = sizeof(DataSetMigration) + doubleCountInBlock * sizeof(double); - - // write blocks and their data arrays - for (int nb = 0; nb < blocksCount; nb++) - { - SPtr<Block3D> block = grid->getBlock(dataSetReadArray[nb].x1, dataSetReadArray[nb].x2, dataSetReadArray[nb].x3, dataSetReadArray[nb].level); - dataSetWriteArray[nb].globalID = block->getGlobalID(); - dataSetWriteArray[nb].ghostLayerWidth = dataSetReadArray[nb].ghostLayerWidth; - dataSetWriteArray[nb].collFactor = dataSetReadArray[nb].collFactor; - dataSetWriteArray[nb].deltaT = dataSetReadArray[nb].deltaT; - dataSetWriteArray[nb].compressible = dataSetReadArray[nb].compressible; - dataSetWriteArray[nb].withForcing = dataSetReadArray[nb].withForcing; - - write_offset = (MPI_Offset)(3 * sizeof(dataSetParam) + dataSetWriteArray[nb].globalID * sizeofOneDataSet); - MPI_File_write_at(file_handlerW, write_offset, &dataSetWriteArray[nb], 1, dataSetTypeWrite, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handlerW, (MPI_Offset)(write_offset + sizeof(DataSetMigration)), &doubleValuesArray[nb * doubleCountInBlock], - doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - } - - delete[] dataSetReadArray; - delete[] dataSetWriteArray; - } - - MPI_File_close(&file_handlerR); - - MPI_File_sync(file_handlerW); - MPI_File_close(&file_handlerW); - - DSArraysPresence arrPresence; - MPI_File file_handler1; - std::string filename1 = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpArrays.bin"; - int rc = MPI_File_open(MPI_COMM_WORLD, filename1.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handler1); - if (rc != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename1); - MPI_File_read_at(file_handler1, (MPI_Offset)0, &arrPresence, 6, MPI_CHAR, MPI_STATUS_IGNORE); - MPI_File_close(&file_handler1); - - MPI_File file_handler2; - std::string filename2 = path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpArrays.bin"; - int rc2 = MPI_File_open(MPI_COMM_WORLD, filename2.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handler2); - if (rc2 != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filename2); - MPI_File_write_at(file_handler2, (MPI_Offset)0, &arrPresence, 6, MPI_CHAR, MPI_STATUS_IGNORE); - MPI_File_sync(file_handler2); - MPI_File_close(&file_handler2); - - std::string filenameRR = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step); - std::string filenameWW = path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step); - - if (arrPresence.isAverageDensityArrayPresent) - convert___Array(step, procCount, filenameRR + "/cpAverageDensityArray.bin", filenameWW + "/cpAverageDensityArray.bin"); - - if (arrPresence.isAverageVelocityArrayPresent) - convert___Array(step, procCount, filenameRR + "/cpAverageVelocityArray.bin", filenameWW + "/cpAverageVelocityArray.bin"); - - if (arrPresence.isAverageFluktuationsArrayPresent) - convert___Array(step, procCount, filenameRR + "/cpAverageFluktuationsArray.bin", filenameWW + "/cpAverageFluktuationsArray.bin"); - - if (arrPresence.isAverageTripleArrayPresent) - convert___Array(step, procCount, filenameRR + "/cpAverageTripleArray.bin", filenameWW + "/cpAverageTripleArray.bin"); - - if (arrPresence.isShearStressValArrayPresent) - convert___Array(step, procCount, filenameRR + "/cpShearStressValArray.bin", filenameWW + "/cpShearStressValArray.bin"); - - if (arrPresence.isRelaxationFactorPresent) - convert___Array(step, procCount, filenameRR + "/cpRelaxationFactor.bin", filenameWW + "/cpRelaxationFactor.bin"); - - finish = MPI_Wtime(); - UBLOG(logINFO, "UtilConvertor::convertDataSet time: " << finish - start << " s"); - -} - -void CheckpointConverter::convert___Array(int step, int procCount, std::string filenameR, std::string filenameW) -{ - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - MPI_File file_handlerR; - int rcR = MPI_File_open(MPI_COMM_WORLD, filenameR.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handlerR); - if (rcR != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filenameR); - - MPI_File file_handlerW; - int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handlerW); - if (rcW != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filenameW); - - int blocksCount = 0; - dataSetParam dataSetParamStr; - memset(&dataSetParamStr, 0, sizeof(dataSetParam)); - DataSetSmallRestart* dataSetSmallReadArray; - DataSetSmallMigration* dataSetSmallWriteArray; - int doubleCountInBlock; - std::vector<double> doubleValuesArray; - - // calculate the read offset - MPI_Offset read_offset = (MPI_Offset)(procCount * sizeof(int)); - MPI_Offset write_offset; - size_t sizeofOneDataSet; - - for (int pc = 0; pc < procCount; pc++) - { - MPI_File_read_at(file_handlerR, (MPI_Offset)(pc * sizeof(int)), &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, read_offset, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - dataSetSmallReadArray = new DataSetSmallRestart[blocksCount]; - dataSetSmallWriteArray = new DataSetSmallMigration[blocksCount]; - doubleCountInBlock = dataSetParamStr.nx[0] * dataSetParamStr.nx[1] * dataSetParamStr.nx[2] * dataSetParamStr.nx[3]; - doubleValuesArray.resize(blocksCount * doubleCountInBlock); - - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + sizeof(dataSetParam)), dataSetSmallReadArray, blocksCount * 4, MPI_INT, MPI_STATUS_IGNORE); - if (doubleCountInBlock > 0) - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + sizeof(dataSetParam) + blocksCount * sizeof(DataSetSmallRestart)), - &doubleValuesArray[0], blocksCount * doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - - read_offset = read_offset + sizeof(dataSetParam) + blocksCount * (sizeof(DataSetSmallRestart) + doubleCountInBlock * sizeof(double)); - - sizeofOneDataSet = sizeof(DataSetSmallMigration) + doubleCountInBlock * sizeof(double); - - MPI_File_write_at(file_handlerW, 0, &dataSetParamStr, 1, dataSetParamType, MPI_STATUS_IGNORE); - - for (int nb = 0; nb < blocksCount; nb++) - { - SPtr<Block3D> block = grid->getBlock(dataSetSmallReadArray[nb].x1, dataSetSmallReadArray[nb].x2, dataSetSmallReadArray[nb].x3, dataSetSmallReadArray[nb].level); - dataSetSmallWriteArray[nb].globalID = block->getGlobalID(); - - write_offset = (MPI_Offset)(sizeof(dataSetParam) + dataSetSmallWriteArray[nb].globalID * sizeofOneDataSet); - MPI_File_write_at(file_handlerW, write_offset, &dataSetSmallWriteArray[nb], 1, MPI_INT, MPI_STATUS_IGNORE); - MPI_File_write_at(file_handlerW, (MPI_Offset)(write_offset + sizeof(DataSetSmallMigration)), - &doubleValuesArray[nb * doubleCountInBlock], doubleCountInBlock, MPI_DOUBLE, MPI_STATUS_IGNORE); - } - - delete[] dataSetSmallReadArray; - delete[] dataSetSmallWriteArray; - } - MPI_File_close(&file_handlerR); - - MPI_File_sync(file_handlerW); - MPI_File_close(&file_handlerW); - - finish = MPI_Wtime(); - UBLOG(logINFO, "UtilConvertor::convert___Array time: " << finish - start << " s"); - -} - -void CheckpointConverter::convertBC(int step, int procCount) -{ - // file to read from - MPI_File file_handlerR; - std::string filenameR = path + "/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBC.bin"; - int rcR = MPI_File_open(MPI_COMM_WORLD, filenameR.c_str(), MPI_MODE_RDONLY, MPI_INFO_NULL, &file_handlerR); - if (rcR != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filenameR); - - // file to write to - MPI_File file_handlerW; - std::string filenameW = path + "/mig/mpi_io_cp/mpi_io_cp_" + UbSystem::toString(step) + "/cpBC.bin"; - int rcW = MPI_File_open(MPI_COMM_WORLD, filenameW.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &file_handlerW); - if (rcW != MPI_SUCCESS) throw UbException(UB_EXARGS, "couldn't open file " + filenameW); - - double start, finish; - if (comm->isRoot()) start = MPI_Wtime(); - - int blocksCount = 0; - int dataCount1000 = 0; - int dataCount2 = 0; - size_t dataCount; - BCAddRestart* bcAddReadArray; - BCAddMigration* bcAddWriteArray; - BoundaryCondition* bcArray; - BoundaryCondition* nullBouCond = new BoundaryCondition(); - memset(nullBouCond, 0, sizeof(BoundaryCondition)); - int* intArray1; - int* intArray2; - int indexBC; - int indexC; - - MPI_Offset read_offset; - MPI_Offset read_offset1 = (MPI_Offset)(procCount * (3 * sizeof(int) + sizeof(boundCondParam))); - MPI_Offset write_offset = (MPI_Offset)(sizeof(boundCondParam) + grid->getNumberOfBlocks() * sizeof(size_t)); - MPI_Offset write_offsetIndex; - - for (int pc = 0; pc < procCount; pc++) - { - read_offset = (MPI_Offset)(pc * (3 * sizeof(int) + sizeof(boundCondParam))); - - // read count of blocks - MPI_File_read_at(file_handlerR, read_offset, &blocksCount, 1, MPI_INT, MPI_STATUS_IGNORE); - // read count of big BoundaryCondition blocks - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + sizeof(int)), &dataCount1000, 1, MPI_INT, MPI_STATUS_IGNORE); - // read count of indexContainer values in all blocks - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + 2 * sizeof(int)), &dataCount2, 1, MPI_INT, MPI_STATUS_IGNORE); - // read count of bcindexmatrix values in every block - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + 3 * sizeof(int)), &boundCondParamStr, 4, MPI_INT, MPI_STATUS_IGNORE); - //MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset + 3 * sizeof(int)), &boundCondParamStr, 1, boundCondParamType, MPI_STATUS_IGNORE); - - bcAddReadArray = new BCAddRestart[blocksCount]; - bcAddWriteArray = new BCAddMigration[blocksCount]; - dataCount = dataCount1000 * BLOCK_SIZE; - bcArray = new BoundaryCondition[dataCount]; - intArray1 = new int[blocksCount * boundCondParamStr.bcindexmatrixCount]; - intArray2 = new int[dataCount2]; - - // read data arrays - MPI_File_read_at(file_handlerR, read_offset1, bcAddReadArray, blocksCount * 6, MPI_INT, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset1 + blocksCount * sizeof(BCAddRestart)), - &bcArray[0], dataCount1000, boundCondType1000, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset1 + blocksCount * sizeof(BCAddRestart) + dataCount * sizeof(BoundaryCondition)), - &intArray1[0], blocksCount * boundCondParamStr.bcindexmatrixCount, MPI_INT, MPI_STATUS_IGNORE); - MPI_File_read_at(file_handlerR, (MPI_Offset)(read_offset1 + blocksCount * sizeof(BCAddRestart) + dataCount * sizeof(BoundaryCondition) + blocksCount * boundCondParamStr.bcindexmatrixCount * sizeof(int)), - &intArray2[0], dataCount2, MPI_INT, MPI_STATUS_IGNORE); - - // offset to read the data of the next process - read_offset1 = read_offset1 + blocksCount * sizeof(BCAddRestart) + dataCount * sizeof(BoundaryCondition) + (blocksCount * boundCondParamStr.bcindexmatrixCount + dataCount2) * sizeof(int); - - MPI_File_write_at(file_handlerW, 0, &boundCondParamStr, 4, MPI_INT, MPI_STATUS_IGNORE); - - indexBC = 0; - indexC = 0; - // write blocks and their BC data arrays - for (int nb = 0; nb < blocksCount; nb++) - { - SPtr<Block3D> block = grid->getBlock(bcAddReadArray[nb].x1, bcAddReadArray[nb].x2, bcAddReadArray[nb].x3, bcAddReadArray[nb].level); - bcAddWriteArray[nb].globalID = block->getGlobalID(); - bcAddWriteArray[nb].boundCond_count = bcAddReadArray[nb].boundCond_count; // how many BoundaryConditions in this block - bcAddWriteArray[nb].indexContainer_count = bcAddReadArray[nb].indexContainer_count; // how many indexContainer-values in this block - - write_offsetIndex = (MPI_Offset)(sizeof(boundCondParam) + bcAddWriteArray[nb].globalID * sizeof(size_t)); - MPI_File_write_at(file_handlerW, write_offsetIndex, &write_offset, 1, MPI_LONG_LONG_INT, MPI_STATUS_IGNORE); - - MPI_File_write_at(file_handlerW, write_offset, &bcAddWriteArray[nb], 3, MPI_INT, MPI_STATUS_IGNORE); - if (bcAddWriteArray[nb].boundCond_count > 0) - MPI_File_write_at(file_handlerW, (MPI_Offset)(write_offset + sizeof(BCAddMigration)), &bcArray[indexBC], bcAddWriteArray[nb].boundCond_count, boundCondType, MPI_STATUS_IGNORE); - indexBC += bcAddWriteArray[nb].boundCond_count; - - if (boundCondParamStr.bcindexmatrixCount > 0) - MPI_File_write_at(file_handlerW, (MPI_Offset)(write_offset + sizeof(BCAddMigration) + bcAddWriteArray[nb].boundCond_count * sizeof(BoundaryCondition)), - &intArray1[nb * boundCondParamStr.bcindexmatrixCount], boundCondParamStr.bcindexmatrixCount, MPI_INT, MPI_STATUS_IGNORE); - - if (bcAddWriteArray[nb].indexContainer_count > 0) - MPI_File_write_at(file_handlerW, (MPI_Offset)(write_offset + sizeof(BCAddMigration) + bcAddWriteArray[nb].boundCond_count * sizeof(BoundaryCondition) + boundCondParamStr.bcindexmatrixCount * sizeof(int)), - &intArray2[indexC], bcAddWriteArray[nb].indexContainer_count, MPI_INT, MPI_STATUS_IGNORE); - indexC += bcAddWriteArray[nb].indexContainer_count; - - write_offset += sizeof(BCAddMigration) + bcAddWriteArray[nb].boundCond_count * sizeof(BoundaryCondition) + boundCondParamStr.bcindexmatrixCount * sizeof(int) + bcAddWriteArray[nb].indexContainer_count * sizeof(int); - } - - delete[] bcAddReadArray; - delete[] bcAddWriteArray; - delete[] bcArray; - delete[] intArray1; - delete[] intArray2; - } - - delete nullBouCond; - - MPI_File_close(&file_handlerR); - - MPI_File_sync(file_handlerW); - MPI_File_close(&file_handlerW); - - finish = MPI_Wtime(); - UBLOG(logINFO, "UtilConvertor::convertBC time: " << finish - start << " s"); - -} diff --git a/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.h b/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.h deleted file mode 100644 index 7a5ee2e4b..000000000 --- a/src/cpu/VirtualFluidsCore/Utilities/CheckpointConverter.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _UTILITACONVERTOR_H_ -#define _UTILITACONVERTOR_H_ - -#include <mpi.h> -#include <PointerDefinitions.h> -#include <string> -#include <vector> -#include "MPIIODataStructures.h" - -class Grid3D; -class Communicator; - -//! \class UtilConvertor -//! \brief Converts timestep data from MPIIORestartCoProcessor format into MPIIOMigrationCoProcessor format -class CheckpointConverter -{ -public: - CheckpointConverter(SPtr<Grid3D> grid, const std::string& path, SPtr<Communicator> comm); - virtual ~CheckpointConverter(); - - void convert(int step, int procCount); - void convertBlocks(int step, int procCount); - void convertDataSet(int step, int procCount); - void convertBC(int step, int procCount); - void convert___Array(int step, int procCount, std::string filenameR, std::string filenameW); - -protected: - std::string path; - SPtr<Communicator> comm; - SPtr<Grid3D> grid; - -private: - MPI_Datatype gridParamType, block3dType; - MPI_Datatype dataSetParamType, dataSetTypeRead, dataSetTypeWrite; - MPI_Datatype boundCondType, boundCondType1000; - - MPIIODataStructures::boundCondParam boundCondParamStr; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/Utilities/ConfigurationFile.hpp b/src/cpu/VirtualFluidsCore/Utilities/ConfigurationFile.hpp deleted file mode 100644 index 716b6ebad..000000000 --- a/src/cpu/VirtualFluidsCore/Utilities/ConfigurationFile.hpp +++ /dev/null @@ -1,243 +0,0 @@ -#ifndef Configuration_h__ -#define Configuration_h__ - -#include <map> -#include <vector> -#include <sstream> -#include <string> -#include <fstream> -#include <iostream> -#include <stdlib.h> - -//! \brief Simple configuration file -//! \details The Configuration class presented here can read and keep values of any configuration file written in a format like this: -//!# -//!# Simulation parameters -//!# -//! -//!nbDimensions = 2 -//!temperature = 25.001 -//!epsilon = 1.013e-14 -//!writeLogFile = false # NOTE: Set to "true" in debug mode only. -//! # Logging slows down the program. -//!errorMessage = the simulation failed -//!origin = 0.0 0.0 0.0 # x, y, z of origin -//! -//!Example how to use it: -//! -//!ConfigurationFile config; -//!config.load(configname); -//! -//!int nbDimensions = config.getValue<int>("nbDimensions"); -//!float temperature = config.getValue<float>("temperature"); -//!double epsilon = config.getValue<double>("epsilon"); -//!bool writeLogFile = config.getValue<bool>("writeLogFile"); -//!string errorMessage = config.getValue<string>("errorMessage"); -//!vector<double> origin = config.getVector<double>("origin"); -//! -//! \author Konstantin Kutscher - -class ConfigurationFile -{ -public: - //! clear all values - void clear(); - - //! load a configuration file - bool load(const std::string& File); - - //! check if value associated with given key exists - bool contains(const std::string& key) const; - - //! get vector with key - template<class T> - std::vector<T> getVector(const std::string& key) const; - - //! get value with key - template<class T> - T getValue(const std::string& key) const; - -private: - //! the container - std::map<std::string, std::string> data; - - //! get string with key - std::string getString(const std::string& key) const; - - //! remove leading and trailing tabs and spaces - static std::string trim(const std::string& str); - - //! convert string to data type T - template<class T> - T fromString(const std::string& str) const; - - void split(std::vector<std::string>& lst, const std::string& input, const std::string& separators, bool remove_empty = true) const; -}; - - -// ---------------------------------- -// method implementations -// ---------------------------------- - -void ConfigurationFile::clear() -{ - data.clear(); -} -////////////////////////////////////////////////////////////////////////// -bool ConfigurationFile::load(const std::string& file) -{ - std::ifstream inFile(file.c_str()); - - if (!inFile.good()) - { - UB_THROW(UbException(UB_EXARGS, "Cannot read configuration file "+file+"!")); - } - - while (inFile.good() && ! inFile.eof()) - { - std::string line; - getline(inFile, line); - - // filter out comments - if (!line.empty()) - { - size_t pos = line.find('#'); - - if (pos != std::string::npos) - { - line = line.substr(0, pos); - } - } - - // split line into key and value - if (!line.empty()) - { - size_t pos = line.find('='); - - if (pos != std::string::npos) - { - std::string key = trim(line.substr(0, pos)); - std::string value = trim(line.substr(pos + 1)); - - if (!key.empty() && !value.empty()) - { - data[key] = value; - } - } - } - } - - return true; -} -////////////////////////////////////////////////////////////////////////// -bool ConfigurationFile::contains(const std::string& key) const -{ - return data.find(key) != data.end(); -} -////////////////////////////////////////////////////////////////////////// -std::string ConfigurationFile::getString(const std::string& key) const -{ - std::map<std::string, std::string>::const_iterator iter = data.find(key); - - if (iter != data.end()) - { - std::string value = iter->second; - return value; - } - else - { - UB_THROW(UbException(UB_EXARGS, "The parameter \"" + key + "\" is missing!")); - } -} -////////////////////////////////////////////////////////////////////////// -std::string ConfigurationFile::trim(const std::string& str) -{ - size_t first = str.find_first_not_of(" \t\n\r"); - - if (first != std::string::npos) - { - size_t last = str.find_last_not_of(" \t\n\r"); - - return str.substr(first, last - first + 1); - } - else - { - return ""; - } -} -////////////////////////////////////////////////////////////////////////// -template<class T> -std::vector<T> ConfigurationFile::getVector(const std::string& key) const -{ - std::string str = getString(key); - std::vector<T> v; - std::vector<std::string> strings; - split(strings, str, "\t\n\r;, "); - for (std::vector<std::string>::iterator it = strings.begin(); it != strings.end(); ++it) - { - if (*it != "") - { - v.push_back(fromString<T>(*it)); - } - } - return v; -} -////////////////////////////////////////////////////////////////////////// -void ConfigurationFile::split(std::vector<std::string>& lst, const std::string& input, const std::string& separators, bool remove_empty) const -{ - std::ostringstream word; - for (size_t n = 0; n < input.size(); ++n) - { - if (std::string::npos == separators.find(input[n])) - word << input[n]; - else - { - if (!word.str().empty() || !remove_empty) - lst.push_back(word.str()); - word.str(""); - } - } - if (!word.str().empty() || !remove_empty) - lst.push_back(word.str()); -} -////////////////////////////////////////////////////////////////////////// -template<class T> -T ConfigurationFile::fromString(const std::string& str) const -{ - //boolean hack - if (str == "true") - return true; - else if (str == "false") - return false; - ////////////// - std::istringstream stream(str); - T t; - stream >> t; - return t; -} -////////////////////////////////////////////////////////////////////////// -template<class T> -T ConfigurationFile::getValue(const std::string& key) const -{ - std::string str = getString(key); - bool bFlag = false; - if ((std::string)typeid(T).name() == (std::string)typeid(bool).name()) - { - bFlag = true; - } - - std::istringstream iss(str); - T x; - iss >> x; - if (!iss && !bFlag) - UB_THROW(UbException(UB_EXARGS, " cannot convert \"" + str + "\" to type <" + static_cast<std::string>(typeid(x).name()) + ">")); - - if (bFlag) - { - bool value = (str == "true"); - x = value; - } - - return x; -} -#endif // Configuration_h__ diff --git a/src/cpu/VirtualFluidsCore/Utilities/MathUtil.hpp b/src/cpu/VirtualFluidsCore/Utilities/MathUtil.hpp deleted file mode 100644 index ad60a0e54..000000000 --- a/src/cpu/VirtualFluidsCore/Utilities/MathUtil.hpp +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef MATHUTIL_H -#define MATHUTIL_H - -#include <math.h> -#include "MuParser/include/muParser.h" - -namespace Utilities -{ - static bool isEven( int integer ) - { - if ( integer % 2 == 0 ) - return true; - else - return false; - } - - static bool isOdd( int integer ) - { - if ( integer % 2 != 0 ) - return true; - else - return false; - } - - //convert from double to int - static int cint(double x) - { - double intpart; - if (modf(x,&intpart)>=.5) - return static_cast<int> (floor(x)+1); - else - return static_cast<int> (floor(x)); - } - - //create new mu parser for duct parabolic profile - //inflow in X - static mu::Parser getDuctParaboloidX(double Cy, double Hy, double Cz, double Hz, double V) - { - mu::Parser fct; - fct.SetExpr("V*(((-(x2-Cy)^2.0+(Hy/2.0)^2.0)/(Hy/2.0)^2.0)*((-(x3-Cz)^2.0+(Hz/2.0)^2.0)/(Hz/2.0)^2.0))" ); - fct.DefineConst("Cy", Cy); - fct.DefineConst("Hy", Hy); - fct.DefineConst("Cz", Cz); - fct.DefineConst("Hz", Hz); - fct.DefineConst("V" , V ); - return fct; - } - //inflow in Y - static mu::Parser getDuctParaboloidY(double Cx, double Hx, double Cz, double Hz, double V) - { - mu::Parser fct; - fct.SetExpr("V*(((-(x1-Cx)^2.0+(Hx/2.0)^2.0)/(Hx/2.0)^2.0)*((-(x3-Cz)^2.0+(Hz/2.0)^2.0)/(Hz/2.0)^2.0))" ); - fct.DefineConst("Cx", Cx); - fct.DefineConst("Hx", Hx); - fct.DefineConst("Cz", Cz); - fct.DefineConst("Hz", Hz); - fct.DefineConst("V" , V ); - return fct; - } - //inflow in Z - static mu::Parser getDuctParaboloidZ(double Cx, double Hx, double Cy, double Hy, double V) - { - mu::Parser fct; - fct.SetExpr("V*(((-(x1-Cx)^2.0+(Hx/2.0)^2.0)/(Hx/2.0)^2.0)*((-(x2-Cy)^2.0+(Hy/2.0)^2.0)/(Hy/2.0)^2.0))" ); - fct.DefineConst("Cx", Cx); - fct.DefineConst("Hx", Hx); - fct.DefineConst("Cy", Cy); - fct.DefineConst("Hy", Hy); - fct.DefineConst("V" , V ); - return fct; - } - //hash function - static unsigned int RSHash(const std::string& str) - { - unsigned int b = 378551; - unsigned int a = 63689; - unsigned int hash = 0; - - for(std::size_t i = 0; i < str.length(); i++) - { - hash = hash * a + str[i]; - a = a * b; - } - - return hash; - } - //linear interpolation - static double linear_interpolation1D(double x0, double y0, double x1, double y1, double x) - { - double a = (y1 - y0) / (x1 - x0); - double b = -a*x0 + y0; - double y = a * x + b; - return y; - } -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/Utilities/MemoryUtil.h b/src/cpu/VirtualFluidsCore/Utilities/MemoryUtil.h index f94757aa7..c8306083b 100644 --- a/src/cpu/VirtualFluidsCore/Utilities/MemoryUtil.h +++ b/src/cpu/VirtualFluidsCore/Utilities/MemoryUtil.h @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file MemoryUtil.h +//! \ingroup Utilities +//! \author Konstantin Kutscher +//======================================================================================= + #ifndef _MEMORYUTIL_H_ #define _MEMORYUTIL_H_ @@ -13,7 +46,7 @@ #include "stdlib.h" #include "stdio.h" #include "string.h" -#elif (defined(__amd64) || defined(__amd64__) || defined(__unix__) || defined(__CYGWIN__)) && !defined(__AIX__) +#elif (defined(__amd64) || defined(__amd64__) || defined(__unix__)) && !defined(__AIX__) #define MEMORYUTIL_LINUX #include "sys/types.h" #include "sys/sysinfo.h" @@ -23,6 +56,10 @@ #else #error "MemoryUtil::UnknownMachine" #endif + +#if defined(__CYGWIN__) + #define MEMORYUTIL_CYGWIN +#endif ////////////////////////////////////////////////////////////////////////// //MemoryUtil ////////////////////////////////////////////////////////////////////////// @@ -31,7 +68,7 @@ namespace Utilities ////////////////////////////////////////////////////////////////////////// static long long getTotalPhysMem() { - #if defined MEMORYUTIL_WINDOWS + #if defined(MEMORYUTIL_WINDOWS) MEMORYSTATUSEX memInfo; memInfo.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&memInfo); @@ -42,10 +79,10 @@ namespace Utilities long long totalPhysMem = memInfo.totalram; //Multiply in next statement to avoid int overflow on right hand side... totalPhysMem *= memInfo.mem_unit; - #elif defined(MEMORYUTIL_APPLE) - long long totalPhysMem = 0; + #elif defined(MEMORYUTIL_APPLE) + long long totalPhysMem = 0; #else - #error "MemoryUtil::getTotalPhysMem - UnknownMachine" + #error "MemoryUtil::getTotalPhysMem - UnknownMachine" #endif return (long long)totalPhysMem; @@ -53,7 +90,7 @@ namespace Utilities ////////////////////////////////////////////////////////////////////////// static long long getPhysMemUsed() { - #if defined MEMORYUTIL_WINDOWS + #if defined(MEMORYUTIL_WINDOWS) MEMORYSTATUSEX memInfo; memInfo.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&memInfo); @@ -64,16 +101,16 @@ namespace Utilities long long physMemUsed = memInfo.totalram - memInfo.freeram; //Multiply in next statement to avoid int overflow on right hand side... physMemUsed *= memInfo.mem_unit; - #elif defined(MEMORYUTIL_APPLE) + #elif defined(MEMORYUTIL_APPLE) long long physMemUsed = 0; #else - #error "MemoryUtil::getPhysMemUsed - UnknownMachine" + #error "MemoryUtil::getPhysMemUsed - UnknownMachine" #endif return (long long)physMemUsed; } ////////////////////////////////////////////////////////////////////////// -#if defined(MEMORYUTIL_LINUX) || defined(MEMORYUTIL_APPLE) +#if defined(MEMORYUTIL_LINUX) || defined(MEMORYUTIL_APPLE) || defined(MEMORYUTIL_CYGWIN) static int parseLine(char* line){ int i = strlen(line); while (*line < '0' || *line > '9') line++; @@ -101,12 +138,16 @@ namespace Utilities ////////////////////////////////////////////////////////////////////////// static long long getPhysMemUsedByMe() { - #if defined MEMORYUTIL_WINDOWS + #if defined(MEMORYUTIL_WINDOWS) && !defined(__CYGWIN__) PROCESS_MEMORY_COUNTERS pmc; GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)); SIZE_T physMemUsedByMe = pmc.WorkingSetSize; - #elif defined(MEMORYUTIL_LINUX) || defined(MEMORYUTIL_APPLE) + #elif defined(MEMORYUTIL_LINUX) long long physMemUsedByMe = (long long)getValue() * (long long)1024; + #elif defined(MEMORYUTIL_APPLE) + long long physMemUsedByMe = 0; + #elif defined(MEMORYUTIL_CYGWIN) + long long physMemUsedByMe = (long long)getValue() * (long long)1024; #else #error "MemoryUtil::getPhysMemUsedByMe - UnknownMachine" #endif diff --git a/src/cpu/VirtualFluidsCore/Utilities/VoxelMatrixUtil.hpp b/src/cpu/VirtualFluidsCore/Utilities/VoxelMatrixUtil.hpp deleted file mode 100644 index 61a58b639..000000000 --- a/src/cpu/VirtualFluidsCore/Utilities/VoxelMatrixUtil.hpp +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef VoxelMatrixUtil_h__ -#define VoxelMatrixUtil_h__ - -#include "GbCuboid3D.h" -#include "NoSlipBCAdapter.h" -#include "D3Q27Interactor.h" -#include "SetBcBlocksBlockVisitor.h" -#include "Block3D.h" -#include "Grid3D.h" - - -namespace Utilities -{ - void voxelMatrixDiscretisation(SPtr<GbVoxelMatrix3D> matrix, std::string& pathname, int myid, int fileCounter, SPtr<Grid3D> grid, int bounceBackOption, bool vmFile) - { - SPtr<BCAdapter> noSlipPM(new NoSlipBCAdapter(bounceBackOption)); - SPtr<D3Q27Interactor> vmInt = SPtr<D3Q27Interactor>(new D3Q27Interactor(matrix, grid, noSlipPM, Interactor3D::SOLID)); - - if (vmFile) - { - if (myid == 0) matrix->writeToVTKImageDataASCII(pathname + "/geo/vmatrix" + UbSystem::toString(fileCounter)); - } - else - { - GbCuboid3DPtr vmBox(new GbCuboid3D(matrix->getX1Minimum(), matrix->getX2Minimum(), matrix->getX3Minimum(), matrix->getX1Maximum(), matrix->getX2Maximum(), matrix->getX3Maximum())); - if (myid == 0) GbSystem3D::writeGeoObject(vmBox.get(), pathname + "/geo/vmbox" + UbSystem::toString(fileCounter), WbWriterVtkXmlASCII::getInstance()); - } - - //GbCuboid3DPtr vmBox(new GbCuboid3D(matrix->getX1Minimum(), matrix->getX2Minimum(), matrix->getX3Minimum(), matrix->getX1Maximum(), matrix->getX2Maximum(), matrix->getX3Maximum())); - //if (myid == 0) GbSystem3D::writeGeoObject(vmBox.get(), pathname + "/geo/vmbox" + UbSystem::toString(fileCounter), WbWriterVtkXmlASCII::getInstance()); - //SPtr<D3Q27Interactor> vmBoxInt = SPtr<D3Q27Interactor>(new D3Q27Interactor(vmBox, grid, noSlipPM, Interactor3D::SOLID)); - //SetSolidOrBoundaryBlockVisitor v1(vmBoxInt, SetSolidOrBoundaryBlockVisitor::SOLID); - //grid->accept(v1); - //SetSolidOrBoundaryBlockVisitor v2(vmBoxInt, SetSolidOrBoundaryBlockVisitor::BC); - //grid->accept(v2); - - //std::vector<SPtr<Block3D>> blocks; - //std::vector<SPtr<Block3D>>& sb = vmBoxInt->getSolidBlockSet(); - //if (myid == 0) UBLOG(logINFO, "number of solid blocks = " << sb.size()); - //blocks.insert(blocks.end(), sb.begin(), sb.end()); - //std::vector<SPtr<Block3D>>& tb = vmBoxInt->getBcBlocks(); - //if (myid == 0) UBLOG(logINFO, "number of trans blocks = " << tb.size()); - //blocks.insert(blocks.end(), tb.begin(), tb.end()); - - //if (myid == 0) UBLOG(logINFO, "number of blocks = " << blocks.size()); - - //for(SPtr<Block3D> block : blocks) - //{ - // block->setActive(true); - // vmInt->setDifferencesToGbObject3D(block); - //} - - SetBcBlocksBlockVisitor v(vmInt); - grid->accept(v); - vmInt->initInteractor(); - } -} -#endif // VoxelMatrixUtil_h__ - diff --git a/src/cpu/VirtualFluidsCore/Visitors/Block3DVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/Block3DVisitor.h index da6516cb2..0a030629e 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/Block3DVisitor.h +++ b/src/cpu/VirtualFluidsCore/Visitors/Block3DVisitor.h @@ -1,56 +1,90 @@ -#ifndef Block3DVisitor_h -#define Block3DVisitor_h - -#include <PointerDefinitions.h> - -class Block3D; -class Grid3D; - -class Block3DVisitor -{ -public: - Block3DVisitor() : startLevel(-1), stopLevel(-1) - { - } - - Block3DVisitor(int startLevel, int stopLevel) : startLevel(startLevel), stopLevel(stopLevel) - { - } - - virtual ~Block3DVisitor() - { - } - - virtual void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) = 0; - - int getStartLevel() const; - int getStopLevel() const; - void setStartLevel(int level); - void setStopLevel(int level); - -private: - int startLevel; - int stopLevel; -}; -////////////////////////////////////////////////////////////////////////// -inline int Block3DVisitor::getStartLevel() const -{ - return this->startLevel; -} -////////////////////////////////////////////////////////////////////////// -inline int Block3DVisitor::getStopLevel() const -{ - return this->stopLevel; -} -////////////////////////////////////////////////////////////////////////// -inline void Block3DVisitor::setStartLevel(int level) -{ - this->startLevel = level; -} -////////////////////////////////////////////////////////////////////////// -inline void Block3DVisitor::setStopLevel(int level) -{ - this->stopLevel = level; -} - -#endif +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Block3DVisitor.h +//! \ingroup Visitors +//! \author Konstantin Kutscher, Soeren Freudiger, Sebastian Geller +//======================================================================================= + +#ifndef Block3DVisitor_h +#define Block3DVisitor_h + +#include <PointerDefinitions.h> + +class Block3D; +class Grid3D; + +//! Abstract class provides interface for visitor design pettern +class Block3DVisitor +{ +public: + Block3DVisitor() : startLevel(-1), stopLevel(-1) + { + } + + Block3DVisitor(int startLevel, int stopLevel) : startLevel(startLevel), stopLevel(stopLevel) + { + } + + virtual ~Block3DVisitor() + { + } + + virtual void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) = 0; + + int getStartLevel() const; + int getStopLevel() const; + void setStartLevel(int level); + void setStopLevel(int level); + +private: + int startLevel; + int stopLevel; +}; +////////////////////////////////////////////////////////////////////////// +inline int Block3DVisitor::getStartLevel() const +{ + return this->startLevel; +} +////////////////////////////////////////////////////////////////////////// +inline int Block3DVisitor::getStopLevel() const +{ + return this->stopLevel; +} +////////////////////////////////////////////////////////////////////////// +inline void Block3DVisitor::setStartLevel(int level) +{ + this->startLevel = level; +} +////////////////////////////////////////////////////////////////////////// +inline void Block3DVisitor::setStopLevel(int level) +{ + this->stopLevel = level; +} + +#endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/BoundaryConditionsBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/BoundaryConditionsBlockVisitor.cpp index d09e23c07..5135f2db7 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/BoundaryConditionsBlockVisitor.cpp +++ b/src/cpu/VirtualFluidsCore/Visitors/BoundaryConditionsBlockVisitor.cpp @@ -1,9 +1,41 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file BoundaryConditionsBlockVisitor.cpp +//! \ingroup Visitors +//! \author Konstantin Kutscher +//======================================================================================= + #include "BoundaryConditionsBlockVisitor.h" #include "LBMKernel.h" #include "BCProcessor.h" #include "Grid3DSystem.h" #include "D3Q27EsoTwist3DSplittedVector.h" -#include "ThinWallNoSlipBCAlgorithm.h" #include "DataSet3D.h" #include "Grid3D.h" #include "BCAdapter.h" diff --git a/src/cpu/VirtualFluidsCore/Visitors/BoundaryConditionsBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/BoundaryConditionsBlockVisitor.h index 7161108e1..0a8023fb0 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/BoundaryConditionsBlockVisitor.h +++ b/src/cpu/VirtualFluidsCore/Visitors/BoundaryConditionsBlockVisitor.h @@ -1,27 +1,61 @@ -#ifndef BoundaryConditionBlockVisitor_h__ -#define BoundaryConditionBlockVisitor_h__ - -#include <map> -#include <PointerDefinitions.h> - -#include "Block3DVisitor.h" - - -class Grid3D; -class Block3D; -class BCAlgorithm; -class BCAdapter; - -class BoundaryConditionsBlockVisitor : public Block3DVisitor -{ -public: - BoundaryConditionsBlockVisitor(); - virtual ~BoundaryConditionsBlockVisitor(); - - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; - void addBC(SPtr<BCAdapter> bc); -protected: -private: - std::map<char, SPtr<BCAlgorithm> > bcMap; -}; -#endif // BoundaryConditionBlockVisitor_h__ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file BoundaryConditionsBlockVisitor.h +//! \ingroup Visitors +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef BoundaryConditionBlockVisitor_h__ +#define BoundaryConditionBlockVisitor_h__ + +#include <map> +#include <PointerDefinitions.h> + +#include "Block3DVisitor.h" + + +class Grid3D; +class Block3D; +class BCAlgorithm; +class BCAdapter; + +//! \brief set boundary conditions +class BoundaryConditionsBlockVisitor : public Block3DVisitor +{ +public: + BoundaryConditionsBlockVisitor(); + virtual ~BoundaryConditionsBlockVisitor(); + + void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; + void addBC(SPtr<BCAdapter> bc); +protected: +private: + std::map<char, SPtr<BCAlgorithm> > bcMap; +}; +#endif // BoundaryConditionBlockVisitor_h__ diff --git a/src/cpu/VirtualFluidsCore/Visitors/CMakePackage.txt b/src/cpu/VirtualFluidsCore/Visitors/CMakePackage.txt index 9354d3d00..1b8416f01 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/CMakePackage.txt +++ b/src/cpu/VirtualFluidsCore/Visitors/CMakePackage.txt @@ -1,2 +1,2 @@ -GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) -COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) +GET_FILENAME_COMPONENT( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +COLLECT_PACKAGE_DATA_WITH_OPTION(${CURRENT_DIR} ALL_SOURCES) diff --git a/src/cpu/VirtualFluidsCore/Visitors/ChangeBoundaryDensityBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/ChangeBoundaryDensityBlockVisitor.cpp deleted file mode 100644 index d8facc637..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/ChangeBoundaryDensityBlockVisitor.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "ChangeBoundaryDensityBlockVisitor.h" -#include "LBMKernel.h" -#include "Grid3DSystem.h" -#include "BoundaryConditions.h" -#include "BCProcessor.h" -#include "Grid3D.h" -#include "Block3D.h" -#include "BCArray3D.h" - -ChangeBoundaryDensityBlockVisitor::ChangeBoundaryDensityBlockVisitor(float oldBoundaryDensity, float newBoundaryDensity) : -Block3DVisitor(0, Grid3DSystem::MAXLEVEL), -oldBoundaryDensity(oldBoundaryDensity), -newBoundaryDensity(newBoundaryDensity) -{ - -} -////////////////////////////////////////////////////////////////////////// -ChangeBoundaryDensityBlockVisitor::~ChangeBoundaryDensityBlockVisitor() -{ - -} -////////////////////////////////////////////////////////////////////////// -void ChangeBoundaryDensityBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - if (block->getRank() == grid->getRank()) - { - SPtr<ILBMKernel> kernel = block->getKernel(); - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - int maxX1 = (int)bcArray->getNX1(); - int maxX2 = (int)bcArray->getNX2(); - int maxX3 = (int)bcArray->getNX3(); - - 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)) - { - bcPtr = bcArray->getBC(x1, x2, x3); - if (bcPtr) - { - if (bcPtr->hasDensityBoundary()) - { - float bcDensity = bcPtr->getBoundaryDensity(); - if (bcDensity == oldBoundaryDensity) - { - bcPtr->setBoundaryDensity(newBoundaryDensity); - } - } - } - } - } - } - } - } -} diff --git a/src/cpu/VirtualFluidsCore/Visitors/ChangeBoundaryDensityBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/ChangeBoundaryDensityBlockVisitor.h deleted file mode 100644 index 050bb6670..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/ChangeBoundaryDensityBlockVisitor.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef ChangeBoundaryDensityBlockVisitor_h__ -#define ChangeBoundaryDensityBlockVisitor_h__ - -#include <PointerDefinitions.h> - -#include "Block3DVisitor.h" - -class Block3D; -class Grid3D; -class BoundaryConditions; - -class ChangeBoundaryDensityBlockVisitor : public Block3DVisitor -{ -public: - ChangeBoundaryDensityBlockVisitor(float oldBoundaryDensity, float newBoundaryDensity); - virtual ~ChangeBoundaryDensityBlockVisitor(); - - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; -private: - float oldBoundaryDensity; - float newBoundaryDensity; - SPtr<BoundaryConditions> bcPtr; -}; -#endif // ChangeBoundaryDensityBlockVisitor_h__ diff --git a/src/cpu/VirtualFluidsCore/Visitors/CheckRatioBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/CheckRatioBlockVisitor.cpp deleted file mode 100644 index 016589b76..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/CheckRatioBlockVisitor.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "CheckRatioBlockVisitor.h" -#include "Grid3DSystem.h" -#include "Block3D.h" -#include "Grid3D.h" - -CheckRatioBlockVisitor::CheckRatioBlockVisitor(int levelDepth/*shut be maxGridLevel*/, bool includeNotActiveBlocks) - : Block3DVisitor(0, Grid3DSystem::MAXLEVEL) - , levelDepth(levelDepth) - , includeNotActiveBlocks(includeNotActiveBlocks) - , state(true) -{ -} -////////////////////////////////////////////////////////////////////////// -void CheckRatioBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - int ix1, ix2, ix3, level; - ix1 = block->getX1(); - ix2 = block->getX2(); - ix3 = block->getX3(); - level = block->getLevel(); - - int nix1, nix2, nix3, nlev; - int neighix1, neighix2, neighix3, neighlev; - std::vector<SPtr<Block3D>> neighbors; - grid->getAllNeighbors(ix1, ix2, ix3, level, this->levelDepth, neighbors); - bool hasAdded = false; - for (size_t i = 0; i<neighbors.size(); i++) - { - if ((neighbors[i]->isActive()||includeNotActiveBlocks) - &&neighbors[i]->getLevel()>level) - { - neighix1 = neighbors[i]->getX1(); - neighix2 = neighbors[i]->getX2(); - neighix3 = neighbors[i]->getX3(); - neighlev = neighbors[i]->getLevel(); - nix1 = neighix1>>1; - nix2 = neighix2>>1; - nix3 = neighix3>>1; - nlev = neighlev-1; - - if (nlev!=level) - { - //throw UbException(UB_EXARGS, "OverlapBlockVisitor::adaptBlock - leveldifferenz passt nicht, block: "+block->toString()); - //grid->expandBlock(ix1, ix2, ix3, level); - state = state&&false; - falseBlock = block; - - } - else - { - state = state&&true; - } - - //UBLOG(logINFO, "OverlapBlockVisitor::state= "<<state); - - - } - } -} -////////////////////////////////////////////////////////////////////////// -bool CheckRatioBlockVisitor::getState() -{ - return state; -} -////////////////////////////////////////////////////////////////////////// -void CheckRatioBlockVisitor::resetState() -{ - state = true; -} -////////////////////////////////////////////////////////////////////////// -std::string CheckRatioBlockVisitor::getStateString() -{ - return falseBlock->toString(); -} -////////////////////////////////////////////////////////////////////////// diff --git a/src/cpu/VirtualFluidsCore/Visitors/CheckRatioBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/CheckRatioBlockVisitor.h deleted file mode 100644 index d72785b3c..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/CheckRatioBlockVisitor.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef CheckRatioBlockVisitor_H -#define CheckRatioBlockVisitor_H - -#include <string> -#include <PointerDefinitions.h> - -#include "Block3DVisitor.h" - -class Grid3D; -class Block3D; - -class CheckRatioBlockVisitor : public Block3DVisitor -{ -public: - CheckRatioBlockVisitor(int levelDepth, bool includeNotActiveBlocks = true); - - virtual ~CheckRatioBlockVisitor() {} - - bool getState(); - void resetState(); - std::string getStateString(); - - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; - -private: - int levelDepth; - bool includeNotActiveBlocks; - bool state; - SPtr<Block3D> falseBlock; -}; - -#endif //OverlapBlockVisitor_H - diff --git a/src/cpu/VirtualFluidsCore/Visitors/CoarsenCrossAndInsideGbObjectBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/CoarsenCrossAndInsideGbObjectBlockVisitor.cpp deleted file mode 100644 index 4c76abb3e..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/CoarsenCrossAndInsideGbObjectBlockVisitor.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "CoarsenCrossAndInsideGbObjectBlockVisitor.h" -#include "Block3D.h" -#include "Grid3D.h" -#include <numerics/geometry3d/GbObject3D.h> - -CoarsenCrossAndInsideGbObjectBlockVisitor::CoarsenCrossAndInsideGbObjectBlockVisitor() - : Block3DVisitor(), notActive(true) -{ -} -////////////////////////////////////////////////////////////////////////// -CoarsenCrossAndInsideGbObjectBlockVisitor::CoarsenCrossAndInsideGbObjectBlockVisitor(SPtr<GbObject3D> geoObject, int fineLevel, int coarseLevel) - : Block3DVisitor(fineLevel, fineLevel), geoObject(geoObject), notActive(true), coarseLevel(coarseLevel) -{ - -} -////////////////////////////////////////////////////////////////////////// -CoarsenCrossAndInsideGbObjectBlockVisitor::~CoarsenCrossAndInsideGbObjectBlockVisitor() -{ -} -////////////////////////////////////////////////////////////////////////// -void CoarsenCrossAndInsideGbObjectBlockVisitor::visit(const SPtr<Grid3D> grid, SPtr<Block3D> 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/src/cpu/VirtualFluidsCore/Visitors/CoarsenCrossAndInsideGbObjectBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/CoarsenCrossAndInsideGbObjectBlockVisitor.h deleted file mode 100644 index 760d037e7..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/CoarsenCrossAndInsideGbObjectBlockVisitor.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef CoarsenCrossAndInsideGbObjectBlockVisitor_H -#define CoarsenCrossAndInsideGbObjectBlockVisitor_H - -#include <PointerDefinitions.h> - -#include "Block3DVisitor.h" - -class GbObject3D; -class Block3D; -class Grid3D; - -//! \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(SPtr<GbObject3D> geoObject, int fineLevel, int coarseLevel); - virtual ~CoarsenCrossAndInsideGbObjectBlockVisitor(); - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; - ////////////////////////////////////////////////////////////////////////// -protected: - SPtr<GbObject3D> geoObject; - bool notActive; - int coarseLevel; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/ConnectorBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/ConnectorBlockVisitor.cpp deleted file mode 100644 index d4562dd8d..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/ConnectorBlockVisitor.cpp +++ /dev/null @@ -1,472 +0,0 @@ -#include "ConnectorBlockVisitor.h" -#include "Grid3DSystem.h" -#include "ConnectorFactory.h" -#include "InterpolationProcessor.h" -#include "Communicator.h" -#include "Grid3D.h" - -ConnectorBlockVisitor::ConnectorBlockVisitor(SPtr<Communicator> comm, LBMReal nu, InterpolationProcessorPtr iProcessor, SPtr<ConnectorFactory> cFactory) : - Block3DVisitor(0, Grid3DSystem::MAXLEVEL), - comm(comm), - nu(nu), - iProcessor(iProcessor), - cFactory(cFactory) -{ -} -////////////////////////////////////////////////////////////////////////// -ConnectorBlockVisitor::~ConnectorBlockVisitor(void) -{ -} -////////////////////////////////////////////////////////////////////////// -void ConnectorBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - if (!block) return; - - UBLOG(logDEBUG5, "ConnectorBlockVisitor::visit() - start"); - UBLOG(logDEBUG5, block->toString()); - - gridRank = comm->getProcessID(); - grid->setRank(gridRank); - - setSameLevelConnectors(grid, block); - - if (grid->getFinestInitializedLevel() > grid->getCoarsestInitializedLevel()) - setInterpolationConnectors(grid, block); - - if (block->getGlobalID()==2234) - { - UBLOG(logINFO, block->toString()); - } - - UBLOG(logDEBUG5, "ConnectorBlockVisitor::visit() - end"); -} -////////////////////////////////////////////////////////////////////////// -void ConnectorBlockVisitor::setSameLevelConnectors(SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - if (block->getGlobalID()==2234) - { - UBLOG(logINFO, block->toString()); - } - UBLOG(logDEBUG5, "ConnectorBlockVisitor::setSameLevelConnectors() - start"); - int blockRank = block->getRank(); - if (gridRank == blockRank && block->isActive()) - { - block->clearWeight(); - std::vector<SPtr<Block3D>> neighbors; - int ix1 = block->getX1(); - int ix2 = block->getX2(); - int ix3 = block->getX3(); - int level = block->getLevel(); - - for (int dir = 0; dir < D3Q27System::ENDDIR; dir++) - { - SPtr<Block3D> neighBlock = grid->getNeighborBlock(dir, ix1, ix2, ix3, level); - - if (neighBlock) - { - int neighBlockRank = neighBlock->getRank(); - if (blockRank == neighBlockRank && neighBlock->isActive()) - { - SPtr<Block3DConnector> connector; - connector = cFactory->createSameLevelDirectConnector(block, neighBlock, dir); - block->setConnector(connector); - } - else if (blockRank != neighBlockRank && neighBlock->isActive()) - { - setRemoteConnectors(block, neighBlock, dir); - } - } - } - } - UBLOG(logDEBUG5, "ConnectorBlockVisitor::setSameLevelConnectors() - end"); - if (block->getGlobalID()==2234) - { - UBLOG(logINFO, block->toString()); - } -} -////////////////////////////////////////////////////////////////////////// -void ConnectorBlockVisitor::setRemoteConnectors(SPtr<Block3D> sblock, SPtr<Block3D> tblock, int dir) -{ - UBLOG(logDEBUG5, "ConnectorBlockVisitor::setRemoteConnectors() - start"); - CreateTransmittersHelper helper; - CreateTransmittersHelper::TransmitterPtr sender, receiver; - helper.createTransmitters(sblock, tblock, dir, CreateTransmittersHelper::NONE, sender, receiver, comm, CreateTransmittersHelper::MPI); - - - SPtr<Block3DConnector> connector; - connector = cFactory->createSameLevelVectorConnector(sblock, sender, receiver, dir); - sblock->setConnector(connector); - UBLOG(logDEBUG5, "ConnectorBlockVisitor::setRemoteConnectors() - end"); -} -////////////////////////////////////////////////////////////////////////// -void ConnectorBlockVisitor::setInterpolationConnectors(SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - if (block->getGlobalID()==2234) - { - UBLOG(logINFO, block->toString()); - } - UBLOG(logDEBUG5, "ConnectorBlockVisitor::setInterpolationConnectors() - start"); - int blockRank = block->getRank(); - - //search for all blocks with different ranks - if (block->hasInterpolationFlagCF() && block->isActive()) - { - int fbx1 = block->getX1() << 1; - int fbx2 = block->getX2() << 1; - int fbx3 = block->getX3() << 1; - int level = block->getLevel() + 1; - - if (block->hasInterpolationFlagCF(D3Q27System::E)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1+1, fbx2, fbx3, level); - SPtr<Block3D> fblock10 = grid->getBlock(fbx1+1, fbx2+1, fbx3, level); - SPtr<Block3D> fblock01 = grid->getBlock(fbx1+1, fbx2, fbx3+1, level); - SPtr<Block3D> fblock11 = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::E); - } - if (block->hasInterpolationFlagCF(D3Q27System::W)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1, fbx2, fbx3, level); - SPtr<Block3D> fblock10 = grid->getBlock(fbx1, fbx2+1, fbx3, level); - SPtr<Block3D> fblock01 = grid->getBlock(fbx1, fbx2, fbx3+1, level); - SPtr<Block3D> fblock11 = grid->getBlock(fbx1, fbx2+1, fbx3+1, level); - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::W); - } - if (block->hasInterpolationFlagCF(D3Q27System::N)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1, fbx2+1, fbx3, level); - SPtr<Block3D> fblock10 = grid->getBlock(fbx1+1, fbx2+1, fbx3, level); - SPtr<Block3D> fblock01 = grid->getBlock(fbx1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblock11 = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::N); - } - if (block->hasInterpolationFlagCF(D3Q27System::S)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1, fbx2, fbx3, level); - SPtr<Block3D> fblock10 = grid->getBlock(fbx1+1, fbx2, fbx3, level); - SPtr<Block3D> fblock01 = grid->getBlock(fbx1, fbx2, fbx3+1, level); - SPtr<Block3D> fblock11 = grid->getBlock(fbx1+1, fbx2, fbx3+1, level); - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::S); - } - if (block->hasInterpolationFlagCF(D3Q27System::T)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1, fbx2, fbx3+1, level); - SPtr<Block3D> fblock10 = grid->getBlock(fbx1+1, fbx2, fbx3+1, level); - SPtr<Block3D> fblock01 = grid->getBlock(fbx1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblock11 = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::T); - } - if (block->hasInterpolationFlagCF(D3Q27System::B)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1, fbx2, fbx3, level); - SPtr<Block3D> fblock10 = grid->getBlock(fbx1+1, fbx2, fbx3, level); - SPtr<Block3D> fblock01 = grid->getBlock(fbx1, fbx2+1, fbx3, level); - SPtr<Block3D> fblock11 = grid->getBlock(fbx1+1, fbx2+1, fbx3, level); - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::B); - } - - //////NE-NW-SE-SW - if (block->hasInterpolationFlagCF(D3Q27System::NE)&&!block->hasInterpolationFlagCF(D3Q27System::N) && !block->hasInterpolationFlagCF(D3Q27System::E)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1+1, fbx2+1, fbx3+0, level); - SPtr<Block3D> fblock10 = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblock01; - SPtr<Block3D> fblock11; - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::NE); - } - if (block->hasInterpolationFlagCF(D3Q27System::SW)&& !block->hasInterpolationFlagCF(D3Q27System::W) && !block->hasInterpolationFlagCF(D3Q27System::S)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1, fbx2, fbx3, level); - SPtr<Block3D> fblock10 = grid->getBlock(fbx1, fbx2, fbx3+1, level); - SPtr<Block3D> fblock01; - SPtr<Block3D> fblock11; - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::SW); - } - if (block->hasInterpolationFlagCF(D3Q27System::SE)&& !block->hasInterpolationFlagCF(D3Q27System::E) && !block->hasInterpolationFlagCF(D3Q27System::S)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1+1, fbx2, fbx3+0, level); - SPtr<Block3D> fblock10 = grid->getBlock(fbx1+1, fbx2, fbx3+1, level); - SPtr<Block3D> fblock01; - SPtr<Block3D> fblock11; - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::SE); - } - if (block->hasInterpolationFlagCF(D3Q27System::NW)&& !block->hasInterpolationFlagCF(D3Q27System::N) && !block->hasInterpolationFlagCF(D3Q27System::W)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1, fbx2+1, fbx3, level); - SPtr<Block3D> fblock10 = grid->getBlock(fbx1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblock01; - SPtr<Block3D> fblock11; - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::NW); - } - - /////////TE-BW-BE-TW 1-0 - if (block->hasInterpolationFlagCF(D3Q27System::TE)&& !block->hasInterpolationFlagCF(D3Q27System::E) && !block->hasInterpolationFlagCF(D3Q27System::T)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1+1, fbx2+0, fbx3+1, level); - SPtr<Block3D> fblock10 = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblock01; - SPtr<Block3D> fblock11; - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::TE); - } - if (block->hasInterpolationFlagCF(D3Q27System::BW)&& !block->hasInterpolationFlagCF(D3Q27System::W) && !block->hasInterpolationFlagCF(D3Q27System::B)) - { - - SPtr<Block3D> fblock00 = grid->getBlock(fbx1, fbx2+0, fbx3, level); - SPtr<Block3D> fblock10 = grid->getBlock(fbx1, fbx2+1, fbx3, level); - SPtr<Block3D> fblock01; - SPtr<Block3D> fblock11; - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::BW); - } - if (block->hasInterpolationFlagCF(D3Q27System::BE)&& !block->hasInterpolationFlagCF(D3Q27System::E) && !block->hasInterpolationFlagCF(D3Q27System::B)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1+1, fbx2+0, fbx3, level); - SPtr<Block3D> fblock10 = grid->getBlock(fbx1+1, fbx2+1, fbx3, level); - SPtr<Block3D> fblock01; - SPtr<Block3D> fblock11; - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::BE); - } - if (block->hasInterpolationFlagCF(D3Q27System::TW)&& !block->hasInterpolationFlagCF(D3Q27System::W) && !block->hasInterpolationFlagCF(D3Q27System::T)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1, fbx2+0, fbx3+1, level); - SPtr<Block3D> fblock10 = grid->getBlock(fbx1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblock01; - SPtr<Block3D> fblock11; - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::TW); - } - - //////TN-BS-BN-TS - if (block->hasInterpolationFlagCF(D3Q27System::TN)&& !block->hasInterpolationFlagCF(D3Q27System::N) && !block->hasInterpolationFlagCF(D3Q27System::T)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1+0, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblock10 = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblock01; - SPtr<Block3D> fblock11; - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::TN); - } - if (block->hasInterpolationFlagCF(D3Q27System::BS)&& !block->hasInterpolationFlagCF(D3Q27System::S) && !block->hasInterpolationFlagCF(D3Q27System::B)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1+0, fbx2, fbx3, level); - SPtr<Block3D> fblock10 = grid->getBlock(fbx1+1, fbx2, fbx3, level); - SPtr<Block3D> fblock01; - SPtr<Block3D> fblock11; - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::BS); - } - if (block->hasInterpolationFlagCF(D3Q27System::BN)&& !block->hasInterpolationFlagCF(D3Q27System::N) && !block->hasInterpolationFlagCF(D3Q27System::B)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1+0, fbx2+1, fbx3, level); - SPtr<Block3D> fblock10 = grid->getBlock(fbx1+1, fbx2+1, fbx3, level); - SPtr<Block3D> fblock01; - SPtr<Block3D> fblock11; - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::BN); - } - if (block->hasInterpolationFlagCF(D3Q27System::TS)&& !block->hasInterpolationFlagCF(D3Q27System::S) && !block->hasInterpolationFlagCF(D3Q27System::T)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1+0, fbx2, fbx3+1, level); - SPtr<Block3D> fblock10 = grid->getBlock(fbx1+1, fbx2, fbx3+1, level); - SPtr<Block3D> fblock01; - SPtr<Block3D> fblock11; - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::TS); - } - - - - - //////corners - if (block->hasInterpolationFlagCF(D3Q27System::TNE)&&!block->hasInterpolationFlagCF(D3Q27System::TE)&&!block->hasInterpolationFlagCF(D3Q27System::TN)&&!block->hasInterpolationFlagCF(D3Q27System::NE)&&!block->hasInterpolationFlagCF(D3Q27System::T)&&!block->hasInterpolationFlagCF(D3Q27System::N) && !block->hasInterpolationFlagCF(D3Q27System::E)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblock10;// = grid->getBlock(fbx1+1, fbx2+1, fbx3+0, level); - SPtr<Block3D> fblock01;// = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblock11;// = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::TNE); - } - if (block->hasInterpolationFlagCF(D3Q27System::TSW)&&!block->hasInterpolationFlagCF(D3Q27System::TW)&&!block->hasInterpolationFlagCF(D3Q27System::TS)&& !block->hasInterpolationFlagCF(D3Q27System::SW)&& !block->hasInterpolationFlagCF(D3Q27System::T)&& !block->hasInterpolationFlagCF(D3Q27System::W) && !block->hasInterpolationFlagCF(D3Q27System::S)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1, fbx2, fbx3+1, level); - SPtr<Block3D> fblock10;// = grid->getBlock(fbx1, fbx2, fbx3, level); - SPtr<Block3D> fblock01;// = grid->getBlock(fbx1, fbx2, fbx3+1, level); - SPtr<Block3D> fblock11;// = grid->getBlock(fbx1, fbx2, fbx3+1, level); - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::TSW); - } - if (block->hasInterpolationFlagCF(D3Q27System::TSE)&&!block->hasInterpolationFlagCF(D3Q27System::TE)&&!block->hasInterpolationFlagCF(D3Q27System::TS)&& !block->hasInterpolationFlagCF(D3Q27System::SE)&& !block->hasInterpolationFlagCF(D3Q27System::T)&& !block->hasInterpolationFlagCF(D3Q27System::E) && !block->hasInterpolationFlagCF(D3Q27System::S)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1+1, fbx2, fbx3+1, level); - SPtr<Block3D> fblock10;// = grid->getBlock(fbx1+1, fbx2, fbx3+0, level); - SPtr<Block3D> fblock01;// = grid->getBlock(fbx1+1, fbx2, fbx3+1, level); - SPtr<Block3D> fblock11;// = grid->getBlock(fbx1+1, fbx2, fbx3+1, level); - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::TSE); - } - if (block->hasInterpolationFlagCF(D3Q27System::TNW)&&!block->hasInterpolationFlagCF(D3Q27System::TW)&&!block->hasInterpolationFlagCF(D3Q27System::TN)&& !block->hasInterpolationFlagCF(D3Q27System::NW)&& !block->hasInterpolationFlagCF(D3Q27System::T)&& !block->hasInterpolationFlagCF(D3Q27System::N) && !block->hasInterpolationFlagCF(D3Q27System::W)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblock10;// = grid->getBlock(fbx1, fbx2+1, fbx3, level); - SPtr<Block3D> fblock01;// = grid->getBlock(fbx1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblock11;// = grid->getBlock(fbx1, fbx2+1, fbx3+1, level); - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::TNW); - } - if (block->hasInterpolationFlagCF(D3Q27System::BNE)&&!block->hasInterpolationFlagCF(D3Q27System::BE)&&!block->hasInterpolationFlagCF(D3Q27System::BN)&& !block->hasInterpolationFlagCF(D3Q27System::NE)&&!block->hasInterpolationFlagCF(D3Q27System::B)&&!block->hasInterpolationFlagCF(D3Q27System::N) && !block->hasInterpolationFlagCF(D3Q27System::E)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1+1, fbx2+1, fbx3+0, level); - SPtr<Block3D> fblock10;// = grid->getBlock(fbx1+1, fbx2+1, fbx3+0, level); - SPtr<Block3D> fblock01;// = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblock11;// = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::BNE); - } - if (block->hasInterpolationFlagCF(D3Q27System::BSW)&& !block->hasInterpolationFlagCF(D3Q27System::BS)&& !block->hasInterpolationFlagCF(D3Q27System::BW)&& !block->hasInterpolationFlagCF(D3Q27System::SW)&& !block->hasInterpolationFlagCF(D3Q27System::B)&& !block->hasInterpolationFlagCF(D3Q27System::W) && !block->hasInterpolationFlagCF(D3Q27System::S)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1, fbx2, fbx3+0, level); - SPtr<Block3D> fblock10;// = grid->getBlock(fbx1, fbx2, fbx3, level); - SPtr<Block3D> fblock01;// = grid->getBlock(fbx1, fbx2, fbx3+1, level); - SPtr<Block3D> fblock11;// = grid->getBlock(fbx1, fbx2, fbx3+1, level); - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::BSW); - } - if (block->hasInterpolationFlagCF(D3Q27System::BSE)&& !block->hasInterpolationFlagCF(D3Q27System::BS)&& !block->hasInterpolationFlagCF(D3Q27System::BE)&& !block->hasInterpolationFlagCF(D3Q27System::SE)&& !block->hasInterpolationFlagCF(D3Q27System::B)&& !block->hasInterpolationFlagCF(D3Q27System::E) && !block->hasInterpolationFlagCF(D3Q27System::S)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1+1, fbx2, fbx3, level); - SPtr<Block3D> fblock10;// = grid->getBlock(fbx1+1, fbx2, fbx3+0, level); - SPtr<Block3D> fblock01;// = grid->getBlock(fbx1+1, fbx2, fbx3+1, level); - SPtr<Block3D> fblock11;// = grid->getBlock(fbx1+1, fbx2, fbx3+1, level); - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::BSE); - } - if (block->hasInterpolationFlagCF(D3Q27System::BNW)&& !block->hasInterpolationFlagCF(D3Q27System::BN)&& !block->hasInterpolationFlagCF(D3Q27System::BW)&& !block->hasInterpolationFlagCF(D3Q27System::NW)&& !block->hasInterpolationFlagCF(D3Q27System::B)&& !block->hasInterpolationFlagCF(D3Q27System::N) && !block->hasInterpolationFlagCF(D3Q27System::W)) - { - SPtr<Block3D> fblock00 = grid->getBlock(fbx1, fbx2+1, fbx3+0, level); - SPtr<Block3D> fblock10;// = grid->getBlock(fbx1, fbx2+1, fbx3, level); - SPtr<Block3D> fblock01;// = grid->getBlock(fbx1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblock11;// = grid->getBlock(fbx1, fbx2+1, fbx3+1, level); - - setInterpolationConnectors(fblock00, fblock10, fblock01, fblock11, block, D3Q27System::BNW); - } - - } - UBLOG(logDEBUG5, "ConnectorBlockVisitor::setInterpolationConnectors() - end"); -} -////////////////////////////////////////////////////////////////////////// - -void ConnectorBlockVisitor::setInterpolationConnectors(SPtr<Block3D> fblock00, SPtr<Block3D> fblock10, SPtr<Block3D> fblock01, SPtr<Block3D> fblock11, SPtr<Block3D> cBlock, int dir) -{ - UBLOG(logDEBUG5, "ConnectorBlockVisitor::setInterpolationConnectors(...) - start"); - int fblock00Rank = -999, fblock10Rank = -999, fblock01Rank = -999, fblock11Rank = -999; - if (fblock00) fblock00Rank = fblock00->getRank(); - if (fblock01) fblock01Rank = fblock01->getRank(); - if (fblock10) fblock10Rank = fblock10->getRank(); - if (fblock11) fblock11Rank = fblock11->getRank(); - int cBlockRank = cBlock->getRank(); - - LBMReal omegaF; - if (fblock00) omegaF = LBMSystem::calcCollisionFactor(nu, fblock00->getLevel()); - if (fblock01) omegaF = LBMSystem::calcCollisionFactor(nu, fblock01->getLevel()); - if (fblock10) omegaF = LBMSystem::calcCollisionFactor(nu, fblock10->getLevel()); - if (fblock11) omegaF = LBMSystem::calcCollisionFactor(nu, fblock11->getLevel()); - LBMReal omegaC = LBMSystem::calcCollisionFactor(nu, cBlock->getLevel()); - iProcessor->setOmegas(omegaC, omegaF); - - 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, - senderCF10, receiverCF10, - senderCF11, receiverCF11, - senderFC00, receiverFC00, - senderFC01, receiverFC01, - senderFC10, receiverFC10, - senderFC11, receiverFC11; - - if (fblock00) createTransmitters(cBlock, fblock00, dir, CreateTransmittersHelper::SW, senderCF00, receiverCF00, senderFC00, receiverFC00); - if (fblock01) createTransmitters(cBlock, fblock01, dir, CreateTransmittersHelper::NW, senderCF01, receiverCF01, senderFC01, receiverFC01); - if (fblock10) createTransmitters(cBlock, fblock10, dir, CreateTransmittersHelper::SE, senderCF10, receiverCF10, senderFC10, receiverFC10); - if (fblock11) createTransmitters(cBlock, fblock11, dir, CreateTransmittersHelper::NE, senderCF11, receiverCF11, senderFC11, receiverFC11); - - if (cBlockRank == gridRank) - { - SPtr<Block3DConnector> connector = cFactory->createCoarseToFineConnector(cBlock, - senderCF00, receiverCF00, senderCF01, receiverCF01, - senderCF10, receiverCF10, senderCF11, receiverCF11, - dir, cIProcessor); - cBlock->setConnector(connector); - } - if (fblock00 && fblock00Rank == gridRank) - { - SPtr<Block3DConnector> connector = cFactory->createFineToCoarseConnector(fblock00, - senderFC00, receiverFC00, dir, fIProcessor00, FineToCoarseBlock3DConnector::Type00); - fblock00->setConnector(connector); - } - if (fblock01 && fblock01Rank == gridRank) - { - SPtr<Block3DConnector> connector = cFactory->createFineToCoarseConnector(fblock01, - senderFC01, receiverFC01, dir, fIProcessor01, FineToCoarseBlock3DConnector::Type01); - fblock01->setConnector(connector); - } - if (fblock10 && fblock10Rank == gridRank) - { - SPtr<Block3DConnector> connector = cFactory->createFineToCoarseConnector(fblock10, - senderFC10, receiverFC10, dir, fIProcessor10, FineToCoarseBlock3DConnector::Type10); - fblock10->setConnector(connector); - } - if (fblock11 && fblock11Rank == gridRank) - { - SPtr<Block3DConnector> connector = cFactory->createFineToCoarseConnector(fblock11, - senderFC11, receiverFC11, dir, fIProcessor11, FineToCoarseBlock3DConnector::Type11); - fblock11->setConnector(connector); - } - UBLOG(logDEBUG5, "ConnectorBlockVisitor::setInterpolationConnectors(...) - end"); -} -////////////////////////////////////////////////////////////////////////// -void ConnectorBlockVisitor::createTransmitters(SPtr<Block3D> cBlock, SPtr<Block3D> fBlock, int dir, - CreateTransmittersHelper::IBlock ib, - CreateTransmittersHelper::TransmitterPtr& senderCF, - CreateTransmittersHelper::TransmitterPtr& receiverCF, - CreateTransmittersHelper::TransmitterPtr& senderFC, - CreateTransmittersHelper::TransmitterPtr& receiverFC) -{ - UBLOG(logDEBUG5, "ConnectorBlockVisitor::createTransmitters(...) - start"); - CreateTransmittersHelper helper; - bool MPIpool = true; - bool orthogonal = false; - int fBlockRank = fBlock->getRank(); - int cBlockRank = cBlock->getRank(); - if (fBlockRank == cBlockRank && fBlockRank == gridRank) - { - senderCF = receiverFC = CreateTransmittersHelper::TransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); - senderFC = receiverCF = CreateTransmittersHelper::TransmitterPtr(new TbLocalTransmitter< CbVector< LBMReal > >()); - } - else if (cBlockRank == gridRank) - { - helper.createTransmitters(cBlock, fBlock, dir, ib, senderCF, receiverCF, comm, CreateTransmittersHelper::MPI); - } - else if (fBlockRank == gridRank) - { - helper.createTransmitters(fBlock, cBlock, dir, ib, senderFC, receiverFC, comm, CreateTransmittersHelper::MPI); - } - UBLOG(logDEBUG5, "ConnectorBlockVisitor::createTransmitters(...) - end"); -} - diff --git a/src/cpu/VirtualFluidsCore/Visitors/ConnectorBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/ConnectorBlockVisitor.h deleted file mode 100644 index 777d58bd7..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/ConnectorBlockVisitor.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef ConnectorBlockVisitor_H -#define ConnectorBlockVisitor_H - -#include <PointerDefinitions.h> - -#include "Block3DVisitor.h" -#include "D3Q27System.h" -#include "CreateTransmittersHelper.h" - -class Grid3D; -class Block3D; -class InterpolationProcessor; -class ConnectorFactory; - -class ConnectorBlockVisitor : public Block3DVisitor -{ -public: - ConnectorBlockVisitor(SPtr<Communicator> comm, LBMReal nu, SPtr<InterpolationProcessor> iProcessor, SPtr<ConnectorFactory> cFactory); - virtual ~ConnectorBlockVisitor(); - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; - ////////////////////////////////////////////////////////////////////////// -protected: - void setSameLevelConnectors(SPtr<Grid3D> grid, SPtr<Block3D> block); - void setRemoteConnectors(SPtr<Block3D> sblock, SPtr<Block3D> tblock, int dir); - void setInterpolationConnectors(SPtr<Grid3D> grid, SPtr<Block3D> block); - void setInterpolationConnectors(SPtr<Block3D> fBlockSW, SPtr<Block3D> fBlockSE, SPtr<Block3D> fBlockNW, SPtr<Block3D> fBlockNE, SPtr<Block3D> cBlock, int dir); - void createTransmitters(SPtr<Block3D> cBlock, SPtr<Block3D> fBlock, int dir, - CreateTransmittersHelper::IBlock ib, - CreateTransmittersHelper::TransmitterPtr& senderCF, - CreateTransmittersHelper::TransmitterPtr& receiverCF, - CreateTransmittersHelper::TransmitterPtr& senderFC, - CreateTransmittersHelper::TransmitterPtr& receiverFC); - SPtr<Communicator> comm; - int gridRank; - LBMReal nu; - SPtr<InterpolationProcessor> iProcessor; - SPtr<ConnectorFactory> cFactory; -}; - -#endif //ConnectorBlockVisitor_H - diff --git a/src/cpu/VirtualFluidsCore/Visitors/CreateTransmittersHelper.cpp b/src/cpu/VirtualFluidsCore/Visitors/CreateTransmittersHelper.cpp deleted file mode 100644 index 59b967e08..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/CreateTransmittersHelper.cpp +++ /dev/null @@ -1,160 +0,0 @@ -#include "CreateTransmittersHelper.h" -#include <D3Q27System.h> -#include <Communicator.h> -#include <string> - -#ifdef VF_FETOL - #include <FETOLTransmitterBondPool.h> -#endif -#include <MathUtil.hpp> - -unsigned CreateTransmittersHelper::vKey = 0; - -using namespace std; - -////////////////////////////////////////////////////////////////////////// -CreateTransmittersHelper::CreateTransmittersHelper() -{ - -} -////////////////////////////////////////////////////////////////////////// -void CreateTransmittersHelper::createTransmitters(SPtr<Block3D> sblock, SPtr<Block3D> tblock, int dir, IBlock ib, - TransmitterPtr& sender, TransmitterPtr& receiver, SPtr<Communicator> comm, TransmitterType tType) -{ - //SourceBlock - int srcLevel = sblock->getLevel(); - int srcID = sblock->getGlobalID(); - - //TargetBlock - int tgtLevel = tblock->getLevel(); - int tgtID = tblock->getGlobalID(); - - int invDir = D3Q27System::INVDIR[dir]; - - if( srcLevel != tgtLevel ) invDir = dir; - - int srcRank = 0; - int tgtRank = 0; - - if (tType == MPI) - { - srcRank = sblock->getRank(); - tgtRank = tblock->getRank(); - } -#ifdef VF_FETOL - else if (tType == MPI2BOND) - { - srcRank = sblock->getLocalRank(); - tgtRank = tblock->getLocalRank(); - } -#endif - - if (tType == MPI -#ifdef VF_FETOL - || tType == MPI2BOND -#endif - ) - { - string sendPoolKey = generatePoolKey(srcRank, srcLevel, tgtRank, tgtLevel); - string receivePoolKey = generatePoolKey(tgtRank, tgtLevel, srcRank, srcLevel); - - TbCbVectorMpiPool <LBMReal>::MpiPoolPtr sendPool = TbCbVectorMpiPool <LBMReal>::getTbCbVectorMpiPool(sendPoolKey ); - TbCbVectorMpiPool <LBMReal>::MpiPoolPtr recvPool = TbCbVectorMpiPool <LBMReal>::getTbCbVectorMpiPool(receivePoolKey); - - MPI_Comm mpi_comm = *((MPI_Comm*) comm->getNativeCommunicator()); - - if( !sendPool ) sendPool = TbCbVectorMpiPool <LBMReal>::createTbCbVectorMpiPool(sendPoolKey ,tgtRank, generateMPITag(srcLevel, tgtLevel), mpi_comm); - if( !recvPool ) recvPool = TbCbVectorMpiPool <LBMReal>::createTbCbVectorMpiPool(receivePoolKey,tgtRank, generateMPITag(tgtLevel, srcLevel), mpi_comm); - - TbCbVectorMpiPool <LBMReal>::CbVectorKey keyOfSendCbVectorKey = generateVectorKey(sblock->getX1(), sblock->getX2(), sblock->getX3()/*tgtID*/, dir, ib); - TbCbVectorMpiPool <LBMReal>::CbVectorKey keyOfRecvCbVectorKey = generateVectorKey(tblock->getX1(), tblock->getX2(), tblock->getX3()/*srcID*/, invDir, ib); - - //////////////////////////////////////////////////////// - //DEBUG - //int myid = comm->getProcessID(); - //FILE * file; - ////char * name = "d:/temp/sendPoolKey.csv"; - //std::string name = "d:/temp/VectorKey" + UbSystem::toString(myid) + ".csv"; - //file = fopen(name.c_str(), "a"); - //fprintf(file, "%d;%d%;%d;%d;%d;%u;%d;%d%;%d;%d;%d;%u\n", sblock->getX1(), sblock->getX2(), sblock->getX3()/*tgtID*/, dir, ib, keyOfSendCbVectorKey, tblock->getX1(), tblock->getX2(), tblock->getX3()/*srcID*/, invDir, ib, keyOfRecvCbVectorKey); - //fclose(file); - //////////////////////////////////////////////////////// - - //create sender-/receiver - sender = TransmitterPtr( new TbCbVectorSenderMpiPool< LBMReal >(keyOfSendCbVectorKey,sendPool.get()) ); - receiver = TransmitterPtr( new TbCbVectorReceiverMpiPool< LBMReal >(keyOfRecvCbVectorKey,recvPool.get()) ); - } -#ifdef VF_FETOL - if (tType == BOND) - { - int srcBondRank = sblock->getRank(); - int tgtBondRank = tblock->getRank(); - - int sendBondPoolKey = generatePoolKey(srcBondRank,srcLevel,tgtBondRank,tgtLevel); - int receiveBondPoolKey = generatePoolKey(tgtBondRank,tgtLevel,srcBondRank,srcLevel); - - TbCbVectorBondPool <LBMReal>::BondPoolPtr sendPool = TbCbVectorBondPool <LBMReal>::getTbCbVectorBondPool(sendBondPoolKey ); - TbCbVectorBondPool <LBMReal>::BondPoolPtr recvPool = TbCbVectorBondPool <LBMReal>::getTbCbVectorBondPool(receiveBondPoolKey); - - if( !sendPool ) sendPool = TbCbVectorBondPool <LBMReal>::createTbCbVectorBondPool(sendBondPoolKey ,tgtBondRank, generateMPITag(srcLevel, tgtLevel)); - if( !recvPool ) recvPool = TbCbVectorBondPool <LBMReal>::createTbCbVectorBondPool(receiveBondPoolKey,tgtBondRank, generateMPITag(tgtLevel, srcLevel)); - - TbCbVectorBondPool <LBMReal>::CbVectorKey keyOfSendCbVectorKey = generateVectorKey(tgtID, dir, ib); - TbCbVectorBondPool <LBMReal>::CbVectorKey keyOfRecvCbVectorKey = generateVectorKey(srcID, invDir, ib); - - //create sender-/receiver - sender = TransmitterPtr( new TbCbVectorSenderBondPool< LBMReal >(keyOfSendCbVectorKey,sendPool.get()) ); - receiver = TransmitterPtr( new TbCbVectorReceiverBondPool< LBMReal >(keyOfRecvCbVectorKey,recvPool.get()) ); - } -#endif -} -////////////////////////////////////////////////////////////////////////// -int CreateTransmittersHelper::generateMPITag(int srcLevel, int tgtLevel) -{ - //The MPI standard guarantees that integers 0-32767 can be used as tags - if (srcLevel == tgtLevel) - { - return srcLevel; - } - else - { - srcLevel++; - tgtLevel++; - std::string str = UbSystem::toString<int>(srcLevel) + UbSystem::toString<int>(tgtLevel); - int r = UbSystem::stringTo<int>(str); - return r; - } -} -////////////////////////////////////////////////////////////////////////// -string CreateTransmittersHelper::generatePoolKey(int srcRank, int srcLevel, int tgtRank, int tgtLevel) -{ - std::string str; - str = UbSystem::toString<int>(srcLevel); - str += "#"; - str += UbSystem::toString<int>(tgtLevel); - str += "#"; - str += UbSystem::toString<int>(srcRank); - str += "#"; - str += UbSystem::toString<int>(tgtRank); - - return str; -} -////////////////////////////////////////////////////////////////////////// -string CreateTransmittersHelper::generateVectorKey(int x1, int x2, int x3, int dir, IBlock ib) -{ - std::string str; - - str += UbSystem::toString<int>(x1); - str += "#"; - str += UbSystem::toString<int>(x2); - str += "#"; - str += UbSystem::toString<int>(x3); - str += "#"; - str += UbSystem::toString<int>(dir); - str += "#"; - str += UbSystem::toString<int>(ib); - - return str; -} - - diff --git a/src/cpu/VirtualFluidsCore/Visitors/CreateTransmittersHelper.h b/src/cpu/VirtualFluidsCore/Visitors/CreateTransmittersHelper.h deleted file mode 100644 index da1038b5a..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/CreateTransmittersHelper.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef CREATETRANSMITTERSHELPER_H -#define CREATETRANSMITTERSHELPER_H - -#include "Block3D.h" -#include "Communicator.h" - -#include "LBMSystem.h" - -#include <basics/transmitter/TbTransmitter.h> -#include <basics/transmitter/TbTransmitterMpiPool.h> -#include <basics/container/CbVector.h> - -//! \brief The class helps to create Transmitters. -//! \details It is created two types of Transmitters: MPI and BOND -//! \author K. Kucher -class CreateTransmittersHelper -{ -public: - //! Switch between same level and interpolation Connectors. NONE - for same level Connectors; SW, NW, NE, SE - source/target fine blocks in grid interface - enum IBlock {NONE, SW, NW, NE, SE}; - //! Switch between MPI and BOND Transmitters - enum TransmitterType {MPI, BOND, MPI2BOND}; -public: - typedef CbVector <LBMReal> DataType; - typedef SPtr< TbTransmitter< DataType > > TransmitterPtr; -public: - CreateTransmittersHelper(); - void createTransmitters(const SPtr<Block3D> sblock, const SPtr<Block3D> tblock, int dir, IBlock ib, - TransmitterPtr& sender, TransmitterPtr& receiver, SPtr<Communicator> comm, TransmitterType tType); -protected: -private: - std::string generatePoolKey(int srcRank, int srcLevel, int tgtRank, int tgtLevel); - std::string generateVectorKey(int x1, int x2, int x3,/*int id,*/ int dir, IBlock ib); - int generateMPITag(int srcLevel, int tgtLevel); - static unsigned int vKey; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/GenBlocksGridVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/GenBlocksGridVisitor.cpp index 1d3f09c94..4fce3b530 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/GenBlocksGridVisitor.cpp +++ b/src/cpu/VirtualFluidsCore/Visitors/GenBlocksGridVisitor.cpp @@ -1,10 +1,43 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GenBlocksGridVisitor.cpp +//! \ingroup Visitors +//! \author Konstantin Kutscher +//======================================================================================= + #include "GenBlocksGridVisitor.h" #include "Grid3DSystem.h" #include "CoordinateTransformation3D.h" #include "Block3D.h" #include "Grid3D.h" -#include <numerics/geometry3d/GbObject3D.h> +#include <geometry3d/GbObject3D.h> GenBlocksGridVisitor::GenBlocksGridVisitor(SPtr<GbObject3D> boundingBox) : boundingBox(boundingBox) diff --git a/src/cpu/VirtualFluidsCore/Visitors/GenBlocksGridVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/GenBlocksGridVisitor.h index c71797b15..a80e8a626 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/GenBlocksGridVisitor.h +++ b/src/cpu/VirtualFluidsCore/Visitors/GenBlocksGridVisitor.h @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file GenBlocksGridVisitor.h +//! \ingroup Visitors +//! \author Konstantin Kutscher +//======================================================================================= + #ifndef GenBlocksGridVisitor_h #define GenBlocksGridVisitor_h @@ -10,6 +43,7 @@ class GbObject3D; class Grid3D; +//! \brief generate blocks class GenBlocksGridVisitor : public Grid3DVisitor { public: diff --git a/src/cpu/VirtualFluidsCore/Visitors/Grid3DVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/Grid3DVisitor.h index 64f8fd749..5d2117f8b 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/Grid3DVisitor.h +++ b/src/cpu/VirtualFluidsCore/Visitors/Grid3DVisitor.h @@ -1,18 +1,52 @@ -#ifndef Grid3DVisitor_h -#define Grid3DVisitor_h - -#include <PointerDefinitions.h> - - -class Grid3D; - -class Grid3DVisitor -{ -public: - Grid3DVisitor() {} - virtual ~Grid3DVisitor() {} - - virtual void visit(SPtr<Grid3D> grid) = 0; -}; - -#endif +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Grid3DVisitor.h +//! \ingroup Visitors +//! \author Konstantin Kutscher, Soeren Freudiger, Sebastian Geller +//======================================================================================= + +#ifndef Grid3DVisitor_h +#define Grid3DVisitor_h + +#include <PointerDefinitions.h> + + +class Grid3D; + +//! Abstract class provides interface for visitor design pettern +class Grid3DVisitor +{ +public: + Grid3DVisitor() {} + virtual ~Grid3DVisitor() {} + + virtual void visit(SPtr<Grid3D> grid) = 0; +}; + +#endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.cpp index 7f346a239..9ecb9041b 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.cpp +++ b/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.cpp @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file InitDistributionsBlockVisitor.cpp +//! \ingroup Visitors +//! \author Konstantin Kutscher, Soeren Freudiger +//======================================================================================= + #include "InitDistributionsBlockVisitor.h" #include "LBMKernel.h" #include "BCProcessor.h" @@ -249,7 +282,7 @@ void InitDistributionsBlockVisitor::visit(const SPtr<Grid3D> grid, SPtr<Block3D> f[BNW] = f_TSE + feq[BNW]; f[BSE] = f_TNW + feq[BSE]; f[BSW] = f_TNE + feq[BSW]; - f[ZERO] = f_ZERO + feq[ZERO]; + f[REST] = f_ZERO + feq[REST]; //calcFeqsFct(f,rho,vx1,vx2,vx3); //distributions->setDistribution(f, ix1, ix2, ix3); diff --git a/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.h index a192c562e..be95e46b1 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.h +++ b/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsBlockVisitor.h @@ -1,76 +1,101 @@ -#ifndef InitDistributionsBlockVisitor_H -#define InitDistributionsBlockVisitor_H - -#include <PointerDefinitions.h> - -#include "Block3DVisitor.h" -#include "D3Q27System.h" - -#include <MuParser/include/muParser.h> - -/*================================================================================*/ -/* D3Q27ETInitDistributionsBlockVisitor */ -/* */ -/** -more flexible way to initialize flow area -you can define functions to calculate macroscopic values for feq -!!! x1,x2,x3 are automatically defined via this adapter and are the real world -vertex coordinates !!! - -if function is invalid an UbException with detailed information is thrown - -<BR><BR> -@author <A HREF="mailto:muffmolch@gmx.de">S. Freudiger</A> -@version 1.0 - 19.04.08 -*/ - -//! \details example:<BR> -//! D3Q27InitDistributionsBlockVisitor init(1.0,0.0,0.0,0.0);<BR> -//! Bem.: rho=0.0 bei inkompressibel<BR> -//! init.setVx1("0.01*x2");<BR> -//! init.setVx1("0.01*x2^2");<BR> -//! patch.adaptByPatchCriterion(init); - -class Grid3D; -class Block3D; - - -class InitDistributionsBlockVisitor : public Block3DVisitor -{ -public: - typedef std::numeric_limits<LBMReal> D3Q27RealLim; - -public: - InitDistributionsBlockVisitor(); - ////////////////////////////////////////////////////////////////////////// - //automatic vars are: x1,x2, x3 - //ussage example: setVx1("x1*0.01+x2*0.003") - ////////////////////////////////////////////////////////////////////////// - void setVx1( const mu::Parser& parser); - void setVx2( const mu::Parser& parser); - void setVx3( const mu::Parser& parser); - void setRho( const mu::Parser& parser); - - void setVx1( const std::string& muParserString); - void setVx2( const std::string& muParserString); - void setVx3( const std::string& muParserString); - void setRho( const std::string& muParserString); - ////////////////////////////////////////////////////////////////////////// - void setVx1( LBMReal vx1 ); - void setVx2( LBMReal vx2 ); - void setVx3( LBMReal vx3 ); - void setRho( LBMReal rho ); - - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; - -protected: - void checkFunction(mu::Parser fct); - -private: - mu::Parser muVx1; - mu::Parser muVx2; - mu::Parser muVx3; - mu::Parser muRho; -}; - -#endif //D3Q27INITDISTRIBUTIONSPATCHVISITOR_H +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file InitDistributionsBlockVisitor.h +//! \ingroup Visitors +//! \author Konstantin Kutscher, Soeren Freudiger +//======================================================================================= + +#ifndef InitDistributionsBlockVisitor_H +#define InitDistributionsBlockVisitor_H + +#include <PointerDefinitions.h> + +#include "Block3DVisitor.h" +#include "D3Q27System.h" + +#include <MuParser/include/muParser.h> + +class Grid3D; +class Block3D; + +//! \brief A class implements an initialization of the flow area. +//! \details +//! It is more flexible way to initialize flow area. +//! You can define functions to calculate macroscopic values for feq. +//! x1,x2,x3 are automatically defined via this adapter and are the real world +//! vertex coordinates. +//! +//!if function is invalid an UbException with detailed information is thrown +//! +//! Example: +//! \code +//! InitDistributionsBlockVisitor init; +//! init.setVx1("0.01*x2"); +//! init.setVx2("0.01*x2^2"); +//! \endcode + +class InitDistributionsBlockVisitor : public Block3DVisitor +{ +public: + typedef std::numeric_limits<LBMReal> D3Q27RealLim; + +public: + InitDistributionsBlockVisitor(); + ////////////////////////////////////////////////////////////////////////// + //automatic vars are: x1,x2, x3 + //ussage example: setVx1("x1*0.01+x2*0.003") + ////////////////////////////////////////////////////////////////////////// + void setVx1( const mu::Parser& parser); + void setVx2( const mu::Parser& parser); + void setVx3( const mu::Parser& parser); + void setRho( const mu::Parser& parser); + + void setVx1( const std::string& muParserString); + void setVx2( const std::string& muParserString); + void setVx3( const std::string& muParserString); + void setRho( const std::string& muParserString); + ////////////////////////////////////////////////////////////////////////// + void setVx1( LBMReal vx1 ); + void setVx2( LBMReal vx2 ); + void setVx3( LBMReal vx3 ); + void setRho( LBMReal rho ); + + void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; + +protected: + void checkFunction(mu::Parser fct); + +private: + mu::Parser muVx1; + mu::Parser muVx2; + mu::Parser muVx3; + mu::Parser muRho; +}; + +#endif //D3Q27INITDISTRIBUTIONSPATCHVISITOR_H diff --git a/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsFromFileBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsFromFileBlockVisitor.cpp deleted file mode 100644 index 21a42f72b..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsFromFileBlockVisitor.cpp +++ /dev/null @@ -1,258 +0,0 @@ -#include "InitDistributionsFromFileBlockVisitor.h" -#include <basics/utilities/UbFileInputASCII.h> -#include "LBMKernel.h" -#include "BCProcessor.h" -#include "Grid3DSystem.h" -#include "InitDensityLBMKernel.h" -#include "DataSet3D.h" -#include "EsoTwist3D.h" -#include "Grid3D.h" -#include "Block3D.h" -#include "BCArray3D.h" - - -InitDistributionsFromFileBlockVisitor::InitDistributionsFromFileBlockVisitor(LBMReal nu, LBMReal rho, std::string filename) - : Block3DVisitor(0, Grid3DSystem::MAXLEVEL), nu(nu), rho(rho) -{ - UbFileInputASCII in(filename); - if (!in) - { - throw UbException(UB_EXARGS, "could not open file "+filename); - } - - int nodesX1 = in.readInteger(); - int nodesX2 = in.readInteger(); - int nodesX3 = in.readInteger(); - - matrix = CbArray4D<LBMReal, IndexerX4X3X2X1>(3, nodesX1, nodesX2, nodesX3, 0); - - for (int x3 = 0; x3<nodesX3; x3++) - 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(); - } -} -////////////////////////////////////////////////////////////////////////// -InitDistributionsFromFileBlockVisitor::~InitDistributionsFromFileBlockVisitor() -{ -} -////////////////////////////////////////////////////////////////////////// -void InitDistributionsFromFileBlockVisitor::visit(const SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - using namespace D3Q27System; - - if (!block) UB_THROW(UbException(UB_EXARGS, "block is not exist")); - - UbTupleDouble3 blockLengths = grid->getBlockLengths(block); - UbTupleDouble3 nodeOffset = grid->getNodeOffset(block); - double dx = grid->getDeltaX(block); - LBMReal o = LBMSystem::calcCollisionFactor(nu, block->getLevel()); - - - //Funktionszeiger - typedef void(*CalcFeqsFct)(LBMReal* const& /*feq[27]*/, const LBMReal& /*(d)rho*/, const LBMReal& /*vx1*/, const LBMReal& /*vx2*/, const LBMReal& /*vx3*/); - CalcFeqsFct calcFeqsFct = NULL; - - LBMReal vx1, vx2, vx3; - - int gridRank = grid->getRank(); - int blockRank = block->getRank(); - - if (blockRank==gridRank && block->isActive()) - { - SPtr<ILBMKernel> kernel = block->getKernel(); - if (!kernel) - throw UbException(UB_EXARGS, "The LBM kernel isn't exist in block: "+block->toString()); - - if (kernel->getCompressible()) - calcFeqsFct = &D3Q27System::calcCompFeq; - else - calcFeqsFct = &D3Q27System::calcIncompFeq; - - UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); - - SPtr<BCArray3D> bcArray = kernel->getBCProcessor()->getBCArray(); - SPtr<EsoTwist3D> distributions = dynamicPointerCast<EsoTwist3D>(kernel->getDataSet()->getFdistributions()); - - LBMReal f[D3Q27System::ENDF+1]; - - size_t nx1 = distributions->getNX1(); - size_t nx2 = distributions->getNX2(); - size_t nx3 = distributions->getNX3(); - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int maxX1 = (int)bcArray->getNX1(); - int maxX2 = (int)bcArray->getNX2(); - int maxX3 = (int)bcArray->getNX3(); - - int maxMX1 = (int)matrix.getNX2(); - int maxMX2 = (int)matrix.getNX3(); - int maxMX3 = (int)matrix.getNX4(); - - int blockix1 = block->getX1(); - int blockix2 = block->getX2(); - int blockix3 = block->getX3(); - - UbTupleInt3 blockNx = grid->getBlockNX(); - - for (int ix3 = minX1; ix3<maxX3; ix3++) - for (int ix2 = minX2; ix2<maxX2; ix2++) - for (int ix1 = minX1; ix1<maxX1; ix1++) - { - int x1 = blockix1*val<1>(blockNx)+ix1-1; - int x2 = blockix2*val<2>(blockNx)+ix2-1; - int x3 = blockix3*val<3>(blockNx)+ix3-1; - - if (x1==-1) - { - x1 = maxMX1-1; - } - if (x2==-1) - { - x2 = maxMX2-1; - } - if (x3==-1) - { - x3 = maxMX3-1; - } - - if (x1==maxMX1) - { - x1 = 1; - } - if (x2==maxMX2) - { - x2 = 1; - } - if (x3==maxMX3) - { - x3 = 1; - } - - vx1 = matrix(Vx1, x1, x2, x3); - vx2 = matrix(Vx2, x1, x2, x3); - vx3 = matrix(Vx3, x1, x2, x3); - - //int x1p, x2p, x3p; - - ////x-derivative - //if (x1+1 >= maxMX1) x1p = x1; - //else x1p = x1+1; - //double vx1Plusx1 = matrix(Vx1, x1p, x2, x3); - //double vx2Plusx1 = matrix(Vx2, x1p, x2, x3); - //double vx3Plusx1 = matrix(Vx3, x1p, x2, x3); - - //if (x1-1 < minX1) x1p = x1; - //else x1p = x1-1; - //double vx1Minusx1 = matrix(Vx1, x1p, x2, x3); - //double vx2Minusx1 = matrix(Vx2, x1p, x2, x3); - //double vx3Minusx1 = matrix(Vx3, x1p, x2, x3); - - ////y-derivative - //if (x2+1 >= maxMX2) x2p = x2; - //else x2p = x2+1; - //double vx1Plusx2 = matrix(Vx1, x1, x2p, x3); - //double vx2Plusx2 = matrix(Vx2, x1, x2p, x3); - //double vx3Plusx2 = matrix(Vx3, x1, x2p, x3); - - //if (x2-1 < minX2) x2p = x2; - //else x2p = x2-1; - //double vx1Minusx2 = matrix(Vx1, x1, x2p, x3); - //double vx2Minusx2 = matrix(Vx2, x1, x2p, x3); - //double vx3Minusx2 = matrix(Vx3, x1, x2p, x3); - - ////z-derivative - //if (x3+1 >= maxMX3) x3p = x3; - //else x3p = x3+1; - //double vx1Plusx3 = matrix(Vx1, x1, x2, x3p); - //double vx2Plusx3 = matrix(Vx2, x1, x2, x3p); - //double vx3Plusx3 = matrix(Vx3, x1, x2, x3p); - - //if (x3-1 < minX3) x3p = x3; - //else x3p = x3-1; - //double vx1Minusx3 = matrix(Vx1, x1, x2, x3); - //double vx2Minusx3 = matrix(Vx2, x1, x2, x3); - //double vx3Minusx3 = matrix(Vx3, x1, x2, x3); - - //double ax = (vx1Plusx1 - vx1Minusx1) / (2.0); - //double bx = (vx2Plusx1 - vx2Minusx1) / (2.0); - //double cx = (vx3Plusx1 - vx3Minusx1) / (2.0); - - //double ay = (vx1Plusx2 - vx1Minusx2) / (2.0); - //double by = (vx2Plusx2 - vx2Minusx2) / (2.0); - //double cy = (vx3Plusx2 - vx3Minusx2) / (2.0); - - //double az = (vx1Plusx3 - vx1Minusx3) / (2.0); - //double bz = (vx2Plusx3 - vx2Minusx3) / (2.0); - //double cz = (vx3Plusx3 - vx3Minusx3) / (2.0); - //double eps_new = 1.0; - //LBMReal op = 1.; - - //LBMReal feq[27]; - - //calcFeqsFct(feq, rho, vx1, vx2, vx3); - - //double 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)); - //double f_N = f_E + eps_new *((2.*(ax - by)) / (9.*o)); - //double f_T = f_E + eps_new *((2.*(ax - cz)) / (9.*o)); - //double 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)); - //double f_SE = f_NE + eps_new *((ay + bx) / (9.*o)); - //double 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)); - //double f_BE = f_TE + eps_new *((az + cx) / (9.*o)); - //double 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)); - //double f_BN = f_TN + eps_new *((bz + cy) / (9.*o)); - //double f_ZERO = eps_new *((5.*(ax + by + cz)) / (9.*op)); - //double f_TNE = eps_new *(-(ay + az + bx + bz + cx + cy) / (72.*o)); - //double f_TSW = -eps_new *((ay + bx) / (36.*o)) - f_TNE; - //double f_TSE = -eps_new *((az + cx) / (36.*o)) - f_TNE; - //double 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]; - - calcFeqsFct(f, rho, vx1, vx2, vx3); - - distributions->setDistribution(f, ix1, ix2, ix3); - distributions->setDistributionInv(f, ix1, ix2, ix3); - dynamicPointerCast<InitDensityLBMKernel>(kernel)->setVelocity(ix1, ix2, ix3, vx1, vx2, vx3); - } - - } -} -////////////////////////////////////////////////////////////////////////// diff --git a/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsFromFileBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsFromFileBlockVisitor.h deleted file mode 100644 index bf9182a76..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsFromFileBlockVisitor.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef InitDistributionsFromFileBlockVisitor_h__ -#define InitDistributionsFromFileBlockVisitor_h__ - -#include "Block3DVisitor.h" -#include "LBMSystem.h" - -#include "CbArray4D.h" - -class Grid3D; -class Block3D; - -class InitDistributionsFromFileBlockVisitor : public Block3DVisitor -{ -public: - InitDistributionsFromFileBlockVisitor(LBMReal nu, LBMReal rho, std::string file); - ~InitDistributionsFromFileBlockVisitor(); - - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; - -private: - CbArray4D<LBMReal, IndexerX4X3X2X1> matrix; - enum Velocity { Vx1, Vx2, Vx3 }; - LBMReal nu; - LBMReal rho; -}; -#endif // InitDistributionsFromFileBlockVisitor_h__ - - diff --git a/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsWithInterpolationGridVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsWithInterpolationGridVisitor.cpp deleted file mode 100644 index 857cd63a2..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsWithInterpolationGridVisitor.cpp +++ /dev/null @@ -1,610 +0,0 @@ -#include "InitDistributionsWithInterpolationGridVisitor.h" - -#include "mpi.h" - -#include <basics/utilities/UbFileInputASCII.h> -#include "LBMKernel.h" -#include "BCProcessor.h" -#include "Grid3DSystem.h" -#include <CbArray2D.h> -#include "D3Q27EsoTwist3DSplittedVector.h" -#include "InterpolationProcessor.h" -#include "DataSet3D.h" -#include "Grid3D.h" -#include "Block3D.h" - -using namespace std; - -InitDistributionsWithInterpolationGridVisitor::InitDistributionsWithInterpolationGridVisitor(SPtr<Grid3D> oldGrid, InterpolationProcessorPtr iProcessor, LBMReal nu) - : oldGrid(oldGrid), iProcessor(iProcessor), nu(nu) -{ - -} -////////////////////////////////////////////////////////////////////////// -InitDistributionsWithInterpolationGridVisitor::~InitDistributionsWithInterpolationGridVisitor() -{ -} -////////////////////////////////////////////////////////////////////////// -void InitDistributionsWithInterpolationGridVisitor::visit(SPtr<Grid3D> grid) -{ - newGrid = grid; - int minInitLevel = newGrid->getCoarsestInitializedLevel(); - int maxInitLevel = newGrid->getFinestInitializedLevel(); - int newGridRank = newGrid->getRank(); - - for (int l = minInitLevel; l<=maxInitLevel; l++) - { - int n = 0; - vector<SPtr<Block3D>> blockVector; - newGrid->getBlocks(l, blockVector); - vector<SPtr<Block3D>> tBlockID; - - for(SPtr<Block3D> newBlock : blockVector) - { - if (!newBlock) - UB_THROW(UbException(UB_EXARGS, "block is not exist")); - - int newBlockRank = newBlock->getRank(); - int newBlockLevel = newBlock->getLevel(); - - SPtr<Block3D> oldBlock = oldGrid->getBlock(newBlock->getX1(), newBlock->getX2(), newBlock->getX3(), newBlock->getLevel()); - if (oldBlock) - { - int oldBlockRank = oldBlock->getRank(); - if (oldBlockRank == newBlockRank && oldBlock->isActive() && newBlockRank == newGridRank && newBlock->isActive()) - { - copyLocalBlock(oldBlock, newBlock); - } - else - { - copyRemoteBlock(oldBlock, newBlock); - } - } - else - { - int newlevel = newBlock->getLevel(); - Vector3D coords = newGrid->getNodeCoordinates(newBlock, 1, 1, 1); - - UbTupleInt3 oldGridBlockIndexes = oldGrid->getBlockIndexes(coords[0], coords[1], coords[2], newlevel-1); - SPtr<Block3D> oldBlock = oldGrid->getBlock(val<1>(oldGridBlockIndexes), val<2>(oldGridBlockIndexes), val<3>(oldGridBlockIndexes), newlevel-1); - - if (oldBlock) - { - int oldBlockRank = oldBlock->getRank(); - int oldBlockLevel = oldBlock->getLevel(); - - if (oldBlockRank == newBlockRank && oldBlock->isActive() && newBlockRank == newGridRank && newBlock->isActive()) - { - interpolateLocalBlockCoarseToFine(oldBlock, newBlock); - } - else - { - interpolateRemoteBlockCoarseToFine(oldBlock, newBlock); - } - } - else - { - UbTupleInt3 oldGridBlockIndexes = oldGrid->getBlockIndexes(coords[0], coords[1], coords[2], newlevel+1); - SPtr<Block3D> oldBlock = oldGrid->getBlock(val<1>(oldGridBlockIndexes), val<2>(oldGridBlockIndexes), val<3>(oldGridBlockIndexes), newlevel+1); - if (oldBlock) - { - int oldBlockRank = oldBlock->getRank(); - int oldBlockLevel = oldBlock->getLevel(); - - if (oldBlockRank == newBlockRank && oldBlock->isActive() && newBlockRank == newGridRank && newBlock->isActive()) - { - interpolateLocalBlockFineToCoarse(oldBlock, newBlock); - } - else - { - interpolateRemoteBlockFineToCoarse(oldBlock, newBlock); - } - } - } - } - } - } -} -////////////////////////////////////////////////////////////////////////// -void InitDistributionsWithInterpolationGridVisitor::copyLocalBlock(SPtr<Block3D> oldBlock, SPtr<Block3D> newBlock) -{ - SPtr<ILBMKernel> oldKernel = oldBlock->getKernel(); - if (!oldKernel) - throw UbException(UB_EXARGS, "The LBM kernel isn't exist in block: "+oldBlock->toString()); - SPtr<EsoTwist3D> oldDistributions = dynamicPointerCast<EsoTwist3D>(oldKernel->getDataSet()->getFdistributions()); - - SPtr<ILBMKernel> kernel = newBlock->getKernel(); - if (!kernel) - throw UbException(UB_EXARGS, "The LBM kernel isn't exist in new block: "+newBlock->toString()); - kernel->getDataSet()->setFdistributions(oldDistributions); -} -////////////////////////////////////////////////////////////////////////// -void InitDistributionsWithInterpolationGridVisitor::copyRemoteBlock(SPtr<Block3D> oldBlock, SPtr<Block3D> newBlock) -{ - int newGridRank = newGrid->getRank(); - int oldBlockRank = oldBlock->getRank(); - int newBlockRank = newBlock->getRank(); - - if (oldBlockRank == newGridRank && oldBlock->isActive()) - { - SPtr<ILBMKernel> oldKernel = oldBlock->getKernel(); - if (!oldKernel) - throw UbException(UB_EXARGS, "The LBM kernel isn't exist in block: "+oldBlock->toString()); - SPtr<EsoTwist3D> oldDistributions = dynamicPointerCast<EsoTwist3D>(oldKernel->getDataSet()->getFdistributions()); - - CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(oldDistributions)->getLocalDistributions(); - CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(oldDistributions)->getNonLocalDistributions(); - CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(oldDistributions)->getZeroDistributions(); - - MPI_Send(localDistributions->getStartAdressOfSortedArray(0, 0, 0, 0), (int)localDistributions->getDataVector().size(), MPI_DOUBLE, newBlockRank, 0, MPI_COMM_WORLD); - MPI_Send(nonLocalDistributions->getStartAdressOfSortedArray(0, 0, 0, 0), (int)nonLocalDistributions->getDataVector().size(), MPI_DOUBLE, newBlockRank, 0, MPI_COMM_WORLD); - MPI_Send(zeroDistributions->getStartAdressOfSortedArray(0, 0, 0), (int)zeroDistributions->getDataVector().size(), MPI_DOUBLE, newBlockRank, 0, MPI_COMM_WORLD); - } - else if (newBlockRank == newGridRank && newBlock->isActive()) - { - SPtr<ILBMKernel> newKernel = newBlock->getKernel(); - if (!newKernel) - throw UbException(UB_EXARGS, "The LBM kernel isn't exist in new block: "+newBlock->toString()+UbSystem::toString(newGridRank)); - - SPtr<EsoTwist3D> newDistributions = dynamicPointerCast<EsoTwist3D>(newKernel->getDataSet()->getFdistributions()); - - CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(newDistributions)->getLocalDistributions(); - CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(newDistributions)->getNonLocalDistributions(); - CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(newDistributions)->getZeroDistributions(); - - MPI_Recv(localDistributions->getStartAdressOfSortedArray(0, 0, 0, 0), (int)localDistributions->getDataVector().size(), MPI_DOUBLE, oldBlockRank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Recv(nonLocalDistributions->getStartAdressOfSortedArray(0, 0, 0, 0), (int)nonLocalDistributions->getDataVector().size(), MPI_DOUBLE, oldBlockRank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Recv(zeroDistributions->getStartAdressOfSortedArray(0, 0, 0), (int)zeroDistributions->getDataVector().size(), MPI_DOUBLE, oldBlockRank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - } -} -////////////////////////////////////////////////////////////////////////// -void InitDistributionsWithInterpolationGridVisitor::interpolateLocalBlockCoarseToFine(SPtr<Block3D> oldBlock, SPtr<Block3D> newBlock) -{ - D3Q27ICell icellC; - D3Q27ICell icellF; - LBMReal xoff, yoff, zoff; - - LBMReal omegaC = LBMSystem::calcCollisionFactor(nu, oldBlock->getLevel()); - LBMReal omegaF =LBMSystem::calcCollisionFactor(nu, newBlock->getLevel()); - - iProcessor->setOmegas(omegaC, omegaF); - - SPtr<ILBMKernel> oldKernel = oldBlock->getKernel(); - if (!oldKernel) - throw UbException(UB_EXARGS, "The LBM kernel isn't exist in old block: "+oldBlock->toString()); - - SPtr<EsoTwist3D> oldDistributions = dynamicPointerCast<EsoTwist3D>(oldKernel->getDataSet()->getFdistributions()); - - SPtr<BCArray3D> bcArrayOldBlock = oldBlock->getKernel()->getBCProcessor()->getBCArray(); - - SPtr<ILBMKernel> newKernel = newBlock->getKernel(); - if (!newKernel) - throw UbException(UB_EXARGS, "The LBM kernel isn't exist in new block: "+newBlock->toString()); - - SPtr<EsoTwist3D> newDistributions = dynamicPointerCast<EsoTwist3D>(newKernel->getDataSet()->getFdistributions()); - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int maxX1 = (int)newDistributions->getNX1()-1; - int maxX2 = (int)newDistributions->getNX2()-1; - int maxX3 = (int)newDistributions->getNX3()-1; - - int bMaxX1 = (int)newDistributions->getNX1(); - int bMaxX2 = (int)newDistributions->getNX2(); - int bMaxX3 = (int)newDistributions->getNX3(); - - for (int ix3 = minX3; ix3 < maxX3; ix3+=2) - for (int ix2 = minX2; ix2 < maxX2; ix2+=2) - for (int ix1 = minX1; ix1 < maxX1; ix1+=2) - { - Vector3D coords = newGrid->getNodeCoordinates(newBlock, ix1, ix2, ix3); - UbTupleInt3 oldGridIndexMin = oldGrid->getNodeIndexes(oldBlock, coords[0], coords[1], coords[2]); - int howManySolids= iProcessor->iCellHowManySolids(bcArrayOldBlock, val<1>(oldGridIndexMin), val<2>(oldGridIndexMin), val<3>(oldGridIndexMin)); - - if (howManySolids == 0 || howManySolids == 8) - { - iProcessor->readICell(oldDistributions, icellC, val<1>(oldGridIndexMin), val<2>(oldGridIndexMin), val<3>(oldGridIndexMin)); - iProcessor->interpolateCoarseToFine(icellC, icellF); - } - else - { - if (iProcessor->findNeighborICell(bcArrayOldBlock, oldDistributions, icellC, bMaxX1, bMaxX2, bMaxX3, - val<1>(oldGridIndexMin), val<2>(oldGridIndexMin), val<3>(oldGridIndexMin), xoff, yoff, zoff)) - { - //std::string err = "For "+oldBlock->toString()+ - // " x1="+UbSystem::toString(val<1>(oldGridIndexMin))+ - // ", x2=" + UbSystem::toString(val<2>(oldGridIndexMin))+ - // ", x3=" + UbSystem::toString(val<3>(oldGridIndexMin))+ - // " 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)); - iProcessor->interpolateCoarseToFine(icellC, icellF, xoff, yoff, zoff); - } - else - { - for (int i=0; i<27; i++) - { - icellF.BSW[i]=0.0; - icellF.BSE[i]=0.0; - icellF.BNW[i]=0.0; - icellF.BNE[i]=0.0; - icellF.TSW[i]=0.0; - icellF.TSE[i]=0.0; - icellF.TNW[i]=0.0; - icellF.TNE[i]=0.0; - } - // std::string err = "For "+oldBlock->toString()+ - // " x1="+UbSystem::toString(val<1>(oldGridIndexMin))+ - // ", x2=" + UbSystem::toString(val<2>(oldGridIndexMin))+ - // ", x3=" + UbSystem::toString(val<3>(oldGridIndexMin))+ - // " 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); - } - } - - iProcessor->writeICell(newDistributions, icellF, ix1, ix2, ix3); - iProcessor->writeICellInv(newDistributions, icellF, ix1, ix2, ix3); - } -} -////////////////////////////////////////////////////////////////////////// -void InitDistributionsWithInterpolationGridVisitor::interpolateRemoteBlockCoarseToFine(SPtr<Block3D> oldBlock, SPtr<Block3D> newBlock) -{ - int newGridRank = newGrid->getRank(); - int oldBlockRank = oldBlock->getRank(); - int newBlockRank = newBlock->getRank(); - - if (oldBlockRank == newGridRank) - { - SPtr<ILBMKernel> oldKernel = oldBlock->getKernel(); - if (!oldKernel) - throw UbException(UB_EXARGS, "The LBM kernel isn't exist in block: "+oldBlock->toString()); - SPtr<EsoTwist3D> oldDistributions = dynamicPointerCast<EsoTwist3D>(oldKernel->getDataSet()->getFdistributions()); - - CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(oldDistributions)->getLocalDistributions(); - CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(oldDistributions)->getNonLocalDistributions(); - CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(oldDistributions)->getZeroDistributions(); - - MPI_Send(localDistributions->getStartAdressOfSortedArray(0, 0, 0, 0), (int)localDistributions->getDataVector().size(), MPI_DOUBLE, newBlockRank, 0, MPI_COMM_WORLD); - MPI_Send(nonLocalDistributions->getStartAdressOfSortedArray(0, 0, 0, 0), (int)nonLocalDistributions->getDataVector().size(), MPI_DOUBLE, newBlockRank, 0, MPI_COMM_WORLD); - MPI_Send(zeroDistributions->getStartAdressOfSortedArray(0, 0, 0), (int)zeroDistributions->getDataVector().size(), MPI_DOUBLE, newBlockRank, 0, MPI_COMM_WORLD); - - SPtr<BCArray3D> bcArrayOldBlock = oldBlock->getKernel()->getBCProcessor()->getBCArray(); - std::vector< int >& bcDataVector = bcArrayOldBlock->getBcindexmatrixDataVector(); - MPI_Send(&bcDataVector[0], (int)bcDataVector.size(), MPI_INT, newBlockRank, 0, MPI_COMM_WORLD); - } - else if (newBlockRank == newGridRank && newBlock->isActive()) - { - D3Q27ICell icellC; - D3Q27ICell icellF; - LBMReal xoff, yoff, zoff; - - LBMReal omegaC = LBMSystem::calcCollisionFactor(nu, oldBlock->getLevel()); - LBMReal omegaF =LBMSystem::calcCollisionFactor(nu, newBlock->getLevel()); - - iProcessor->setOmegas(omegaC, omegaF); - - SPtr<ILBMKernel> newKernel = newBlock->getKernel(); - if (!newKernel) - throw UbException(UB_EXARGS, "The LBM kernel isn't exist in new block: "+newBlock->toString()); - - SPtr<EsoTwist3D> newDistributions = dynamicPointerCast<EsoTwist3D>(newKernel->getDataSet()->getFdistributions()); - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int maxX1 = (int)newDistributions->getNX1()-1; - int maxX2 = (int)newDistributions->getNX2()-1; - int maxX3 = (int)newDistributions->getNX3()-1; - - int bMaxX1 = (int)newDistributions->getNX1(); - int bMaxX2 = (int)newDistributions->getNX2(); - int bMaxX3 = (int)newDistributions->getNX3(); - - SPtr<EsoTwist3D> oldDistributions(new D3Q27EsoTwist3DSplittedVector(bMaxX1, bMaxX2, bMaxX3, 0)); - - CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(oldDistributions)->getLocalDistributions(); - CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(oldDistributions)->getNonLocalDistributions(); - CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(oldDistributions)->getZeroDistributions(); - - MPI_Recv(localDistributions->getStartAdressOfSortedArray(0, 0, 0, 0), (int)localDistributions->getDataVector().size(), MPI_DOUBLE, oldBlockRank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Recv(nonLocalDistributions->getStartAdressOfSortedArray(0, 0, 0, 0), (int)nonLocalDistributions->getDataVector().size(), MPI_DOUBLE, oldBlockRank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Recv(zeroDistributions->getStartAdressOfSortedArray(0, 0, 0), (int)zeroDistributions->getDataVector().size(), MPI_DOUBLE, oldBlockRank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - - SPtr<BCArray3D> bcArrayOldBlock(new BCArray3D(bMaxX1, bMaxX2, bMaxX3, BCArray3D::FLUID)); - std::vector< int >& bcDataVector = bcArrayOldBlock->getBcindexmatrixDataVector(); - MPI_Recv(&bcDataVector[0], (int)bcDataVector.size(), MPI_INT, oldBlockRank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - - for (int ix3 = minX3; ix3 < maxX3; ix3+=2) - for (int ix2 = minX2; ix2 < maxX2; ix2+=2) - for (int ix1 = minX1; ix1 < maxX1; ix1+=2) - { - Vector3D coords = newGrid->getNodeCoordinates(newBlock, ix1, ix2, ix3); - UbTupleInt3 oldGridIndexMin = oldGrid->getNodeIndexes(oldBlock, coords[0], coords[1], coords[2]); - - int howManySolids= iProcessor->iCellHowManySolids(bcArrayOldBlock, val<1>(oldGridIndexMin), val<2>(oldGridIndexMin), val<3>(oldGridIndexMin)); - - if (howManySolids == 0 || howManySolids == 8) - { - iProcessor->readICell(oldDistributions, icellC, val<1>(oldGridIndexMin), val<2>(oldGridIndexMin), val<3>(oldGridIndexMin)); - iProcessor->interpolateCoarseToFine(icellC, icellF); - } - else - { - if (iProcessor->findNeighborICell(bcArrayOldBlock, oldDistributions, icellC, bMaxX1, bMaxX2, bMaxX3, - val<1>(oldGridIndexMin), val<2>(oldGridIndexMin), val<3>(oldGridIndexMin), xoff, yoff, zoff)) - { - //std::string err = "For "+oldBlock->toString()+ - // " x1="+UbSystem::toString(val<1>(oldGridIndexMin))+ - // ", x2=" + UbSystem::toString(val<2>(oldGridIndexMin))+ - // ", x3=" + UbSystem::toString(val<3>(oldGridIndexMin))+ - // " 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)); - iProcessor->interpolateCoarseToFine(icellC, icellF, xoff, yoff, zoff); - } - else - { - for (int i=0; i<27; i++) - { - icellF.BSW[i]=0.0; - icellF.BSE[i]=0.0; - icellF.BNW[i]=0.0; - icellF.BNE[i]=0.0; - icellF.TSW[i]=0.0; - icellF.TSE[i]=0.0; - icellF.TNW[i]=0.0; - icellF.TNE[i]=0.0; - } - // std::string err = "For "+oldBlock->toString()+ - // " x1="+UbSystem::toString(val<1>(oldGridIndexMin))+ - // ", x2=" + UbSystem::toString(val<2>(oldGridIndexMin))+ - // ", x3=" + UbSystem::toString(val<3>(oldGridIndexMin))+ - // " 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); - } - } - - - - iProcessor->writeICell(newDistributions, icellF, ix1, ix2, ix3); - iProcessor->writeICellInv(newDistributions, icellF, ix1, ix2, ix3); - } - } -} -////////////////////////////////////////////////////////////////////////// -void InitDistributionsWithInterpolationGridVisitor::interpolateLocalBlockFineToCoarse(SPtr<Block3D> oldBlock, SPtr<Block3D> newBlock) -{ - LBMReal icellC[27]; - D3Q27ICell icellF; - LBMReal xoff, yoff, zoff; - - LBMReal omegaF = LBMSystem::calcCollisionFactor(nu, oldBlock->getLevel()); - LBMReal omegaC =LBMSystem::calcCollisionFactor(nu, newBlock->getLevel()); - - iProcessor->setOmegas(omegaC, omegaF); - - SPtr<ILBMKernel> oldKernel = oldBlock->getKernel(); - if (!oldKernel) - throw UbException(UB_EXARGS, "The LBM kernel isn't exist in old block: "+oldBlock->toString()); - - SPtr<EsoTwist3D> oldDistributions = dynamicPointerCast<EsoTwist3D>(oldKernel->getDataSet()->getFdistributions()); - - SPtr<BCArray3D> bcArrayOldBlock = oldBlock->getKernel()->getBCProcessor()->getBCArray(); - - SPtr<ILBMKernel> newKernel = newBlock->getKernel(); - if (!newKernel) - throw UbException(UB_EXARGS, "The LBM kernel isn't exist in new block: "+newBlock->toString()); - - SPtr<EsoTwist3D> newDistributions = dynamicPointerCast<EsoTwist3D>(newKernel->getDataSet()->getFdistributions()); - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int maxX1 = (int)newDistributions->getNX1()-1; - int maxX2 = (int)newDistributions->getNX2()-1; - int maxX3 = (int)newDistributions->getNX3()-1; - - int bMaxX1 = (int)newDistributions->getNX1(); - int bMaxX2 = (int)newDistributions->getNX2(); - int bMaxX3 = (int)newDistributions->getNX3(); - - for (int ix3 = minX3; ix3 < maxX3; ix3+=2) - for (int ix2 = minX2; ix2 < maxX2; ix2+=2) - for (int ix1 = minX1; ix1 < maxX1; ix1+=2) - { - Vector3D coords = newGrid->getNodeCoordinates(newBlock, ix1, ix2, ix3); - UbTupleInt3 oldGridIndexMin = oldGrid->getNodeIndexes(oldBlock, coords[0], coords[1], coords[2]); - - int howManySolids= iProcessor->iCellHowManySolids(bcArrayOldBlock, val<1>(oldGridIndexMin), val<2>(oldGridIndexMin), val<3>(oldGridIndexMin)); - - if (howManySolids == 0 || howManySolids == 8) - { - iProcessor->readICell(oldDistributions, icellF, val<1>(oldGridIndexMin), val<2>(oldGridIndexMin), val<3>(oldGridIndexMin)); - iProcessor->interpolateFineToCoarse(icellF, icellC); - } - else - { - if (iProcessor->findNeighborICell(bcArrayOldBlock, oldDistributions, icellF, bMaxX1, bMaxX2, bMaxX3, - val<1>(oldGridIndexMin), val<2>(oldGridIndexMin), val<3>(oldGridIndexMin), xoff, yoff, zoff)) - { - //std::string err = "For "+oldBlock->toString()+ - // " x1="+UbSystem::toString(val<1>(oldGridIndexMin))+ - // ", x2=" + UbSystem::toString(val<2>(oldGridIndexMin))+ - // ", x3=" + UbSystem::toString(val<3>(oldGridIndexMin))+ - // " 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)); - iProcessor->interpolateFineToCoarse(icellF, icellC, xoff, yoff, zoff); - } - else - { - for (int i=0; i<27; i++) - { - icellF.BSW[i]=0.0; - icellF.BSE[i]=0.0; - icellF.BNW[i]=0.0; - icellF.BNE[i]=0.0; - icellF.TSW[i]=0.0; - icellF.TSE[i]=0.0; - icellF.TNW[i]=0.0; - icellF.TNE[i]=0.0; - } - // std::string err = "For "+oldBlock->toString()+ - // " x1="+UbSystem::toString(val<1>(oldGridIndexMin))+ - // ", x2=" + UbSystem::toString(val<2>(oldGridIndexMin))+ - // ", x3=" + UbSystem::toString(val<3>(oldGridIndexMin))+ - // " 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); - } - } - - iProcessor->writeINode(newDistributions, icellC, ix1, ix2, ix3); - //iProcessor->writeINodeInv(newDistributions, icellC, ix1, ix2, ix3); - } -} -////////////////////////////////////////////////////////////////////////// -void InitDistributionsWithInterpolationGridVisitor::interpolateRemoteBlockFineToCoarse(SPtr<Block3D> oldBlock, SPtr<Block3D> newBlock) -{ - int newGridRank = newGrid->getRank(); - int oldBlockRank = oldBlock->getRank(); - int newBlockRank = newBlock->getRank(); - - if (oldBlockRank == newGridRank) - { - SPtr<ILBMKernel> oldKernel = oldBlock->getKernel(); - if (!oldKernel) - throw UbException(UB_EXARGS, "The LBM kernel isn't exist in block: "+oldBlock->toString()); - SPtr<EsoTwist3D> oldDistributions = dynamicPointerCast<EsoTwist3D>(oldKernel->getDataSet()->getFdistributions()); - - CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(oldDistributions)->getLocalDistributions(); - CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(oldDistributions)->getNonLocalDistributions(); - CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(oldDistributions)->getZeroDistributions(); - - MPI_Send(localDistributions->getStartAdressOfSortedArray(0, 0, 0, 0), (int)localDistributions->getDataVector().size(), MPI_DOUBLE, newBlockRank, 0, MPI_COMM_WORLD); - MPI_Send(nonLocalDistributions->getStartAdressOfSortedArray(0, 0, 0, 0), (int)nonLocalDistributions->getDataVector().size(), MPI_DOUBLE, newBlockRank, 0, MPI_COMM_WORLD); - MPI_Send(zeroDistributions->getStartAdressOfSortedArray(0, 0, 0), (int)zeroDistributions->getDataVector().size(), MPI_DOUBLE, newBlockRank, 0, MPI_COMM_WORLD); - - SPtr<BCArray3D> bcArrayOldBlock = oldBlock->getKernel()->getBCProcessor()->getBCArray(); - std::vector< int >& bcDataVector = bcArrayOldBlock->getBcindexmatrixDataVector(); - MPI_Send(&bcDataVector[0], (int)bcDataVector.size(), MPI_INT, newBlockRank, 0, MPI_COMM_WORLD); - } - else if (newBlockRank == newGridRank && newBlock->isActive()) - { - LBMReal icellC[27]; - D3Q27ICell icellF; - LBMReal xoff, yoff, zoff; - - LBMReal omegaF = LBMSystem::calcCollisionFactor(nu, oldBlock->getLevel()); - LBMReal omegaC =LBMSystem::calcCollisionFactor(nu, newBlock->getLevel()); - - iProcessor->setOmegas(omegaC, omegaF); - - SPtr<ILBMKernel> newKernel = newBlock->getKernel(); - if (!newKernel) - throw UbException(UB_EXARGS, "The LBM kernel isn't exist in new block: "+newBlock->toString()); - - SPtr<EsoTwist3D> newDistributions = dynamicPointerCast<EsoTwist3D>(newKernel->getDataSet()->getFdistributions()); - - int minX1 = 0; - int minX2 = 0; - int minX3 = 0; - - int maxX1 = (int)newDistributions->getNX1()-1; - int maxX2 = (int)newDistributions->getNX2()-1; - int maxX3 = (int)newDistributions->getNX3()-1; - - int bMaxX1 = (int)newDistributions->getNX1(); - int bMaxX2 = (int)newDistributions->getNX2(); - int bMaxX3 = (int)newDistributions->getNX3(); - - SPtr<EsoTwist3D> oldDistributions(new D3Q27EsoTwist3DSplittedVector(bMaxX1, bMaxX2, bMaxX3, 0)); - - CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr localDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(oldDistributions)->getLocalDistributions(); - CbArray4D<LBMReal, IndexerX4X3X2X1>::CbArray4DPtr nonLocalDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(oldDistributions)->getNonLocalDistributions(); - CbArray3D<LBMReal, IndexerX3X2X1>::CbArray3DPtr zeroDistributions = dynamicPointerCast<D3Q27EsoTwist3DSplittedVector>(oldDistributions)->getZeroDistributions(); - - MPI_Recv(localDistributions->getStartAdressOfSortedArray(0, 0, 0, 0), (int)localDistributions->getDataVector().size(), MPI_DOUBLE, oldBlockRank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Recv(nonLocalDistributions->getStartAdressOfSortedArray(0, 0, 0, 0), (int)nonLocalDistributions->getDataVector().size(), MPI_DOUBLE, oldBlockRank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Recv(zeroDistributions->getStartAdressOfSortedArray(0, 0, 0), (int)zeroDistributions->getDataVector().size(), MPI_DOUBLE, oldBlockRank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - - SPtr<BCArray3D> bcArrayOldBlock(new BCArray3D(bMaxX1, bMaxX2, bMaxX3, BCArray3D::FLUID)); - std::vector< int >& bcDataVector = bcArrayOldBlock->getBcindexmatrixDataVector(); - MPI_Recv(&bcDataVector[0], (int)bcDataVector.size(), MPI_INT, oldBlockRank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - - for (int ix3 = minX3; ix3 < maxX3; ix3+=2) - for (int ix2 = minX2; ix2 < maxX2; ix2+=2) - for (int ix1 = minX1; ix1 < maxX1; ix1+=2) - { - Vector3D coords = newGrid->getNodeCoordinates(newBlock, ix1, ix2, ix3); - UbTupleInt3 oldGridIndexMin = oldGrid->getNodeIndexes(oldBlock, coords[0], coords[1], coords[2]); - - int howManySolids= iProcessor->iCellHowManySolids(bcArrayOldBlock, val<1>(oldGridIndexMin), val<2>(oldGridIndexMin), val<3>(oldGridIndexMin)); - - if (howManySolids == 0 || howManySolids == 8) - { - iProcessor->readICell(oldDistributions, icellF, val<1>(oldGridIndexMin), val<2>(oldGridIndexMin), val<3>(oldGridIndexMin)); - iProcessor->interpolateFineToCoarse(icellF, icellC); - } - else - { - if (iProcessor->findNeighborICell(bcArrayOldBlock, oldDistributions, icellF, bMaxX1, bMaxX2, bMaxX3, - val<1>(oldGridIndexMin), val<2>(oldGridIndexMin), val<3>(oldGridIndexMin), xoff, yoff, zoff)) - { - //std::string err = "For "+oldBlock->toString()+ - // " x1="+UbSystem::toString(val<1>(oldGridIndexMin))+ - // ", x2=" + UbSystem::toString(val<2>(oldGridIndexMin))+ - // ", x3=" + UbSystem::toString(val<3>(oldGridIndexMin))+ - // " 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)); - iProcessor->interpolateFineToCoarse(icellF, icellC, xoff, yoff, zoff); - } - else - { - for (int i=0; i<27; i++) - { - icellF.BSW[i]=0.0; - icellF.BSE[i]=0.0; - icellF.BNW[i]=0.0; - icellF.BNE[i]=0.0; - icellF.TSW[i]=0.0; - icellF.TSE[i]=0.0; - icellF.TNW[i]=0.0; - icellF.TNE[i]=0.0; - } - // std::string err = "For "+oldBlock->toString()+ - // " x1="+UbSystem::toString(val<1>(oldGridIndexMin))+ - // ", x2=" + UbSystem::toString(val<2>(oldGridIndexMin))+ - // ", x3=" + UbSystem::toString(val<3>(oldGridIndexMin))+ - // " 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); - } - } - - iProcessor->writeINode(newDistributions, icellC, ix1, ix2, ix3); - //iProcessor->writeINodeInv(newDistributions, icellC, ix1, ix2, ix3); - } - } -} - -////////////////////////////////////////////////////////////////////////// diff --git a/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsWithInterpolationGridVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsWithInterpolationGridVisitor.h deleted file mode 100644 index 3d976b8bb..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/InitDistributionsWithInterpolationGridVisitor.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef InitDistributionsWithCoarseGridBlockVisitor_h__ -#define InitDistributionsWithCoarseGridBlockVisitor_h__ - -#include <PointerDefinitions.h> - -#include "Grid3DVisitor.h" -#include "LBMSystem.h" - -class Grid3D; -class Block3D; -class InterpolationProcessor; - -class InitDistributionsWithInterpolationGridVisitor : public Grid3DVisitor -{ -public: - InitDistributionsWithInterpolationGridVisitor(SPtr<Grid3D> oldGrid, SPtr<InterpolationProcessor> iProcessor, LBMReal nu); - ~InitDistributionsWithInterpolationGridVisitor(); - void visit(SPtr<Grid3D> grid); -private: - void copyLocalBlock(SPtr<Block3D> oldBlock, SPtr<Block3D> newBlock); - void copyRemoteBlock(SPtr<Block3D> oldBlock, SPtr<Block3D> newBlock); - void interpolateLocalBlockCoarseToFine(SPtr<Block3D> oldBlock, SPtr<Block3D> newBlock); - void interpolateRemoteBlockCoarseToFine(SPtr<Block3D> oldBlock, SPtr<Block3D> newBlock); - void interpolateLocalBlockFineToCoarse(SPtr<Block3D> oldBlock, SPtr<Block3D> newBlock); - void interpolateRemoteBlockFineToCoarse(SPtr<Block3D> oldBlock, SPtr<Block3D> newBlock); - - SPtr<Grid3D> newGrid; - SPtr<Grid3D> oldGrid; - LBMReal nu; - - SPtr<InterpolationProcessor> iProcessor; -}; - -#endif // InitDistributionsWithVelocityProfileBlockVisitor_h__ diff --git a/src/cpu/VirtualFluidsCore/Visitors/MetisPartitioningGridVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/MetisPartitioningGridVisitor.cpp deleted file mode 100644 index a996383ef..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/MetisPartitioningGridVisitor.cpp +++ /dev/null @@ -1,322 +0,0 @@ -#if defined VF_METIS && defined VF_MPI - -#include "MetisPartitioningGridVisitor.h" -#include <math.h> -#include "Block3D.h" -#include "Grid3D.h" -#include "Communicator.h" -#include "D3Q27System.h" - -using namespace std; - -MetisPartitioningGridVisitor::MetisPartitioningGridVisitor(SPtr<Communicator> comm, GraphType graphType, int numOfDirs, MetisPartitioner::PartType partType, bool threads, int numberOfThreads) - : Grid3DVisitor(), - numberOfThreads(numberOfThreads), - numOfDirs(numOfDirs), - comm(comm), - threads(threads), - graphType(graphType), - partType(partType) -{ - numberOfProcesses = comm->getNumberOfProcesses(); -} -////////////////////////////////////////////////////////////////////////// -MetisPartitioningGridVisitor::~MetisPartitioningGridVisitor() -{ - -} -////////////////////////////////////////////////////////////////////////// -void MetisPartitioningGridVisitor::visit(SPtr<Grid3D> grid) -{ - UBLOG(logDEBUG1, "MetisPartitioningGridVisitor::visit() - start"); - - this->clear(); - - bundleRoot = comm->getBundleRoot(); - bundleID = comm->getBundleID(); - numberOfBundles = comm->getNumberOfBundles(); - if (numberOfBundles > 1) - { - if (bundleRoot == bundleID && processRoot == processID) - collectData(grid, numberOfBundles, BUNDLE); - comm->broadcast(blockID); - comm->broadcast(parts); - distributePartitionData(grid, BUNDLE); - this->clear(); - } - - processRoot = comm->getProcessRoot(); - processID = comm->getProcessID(); - /*int numberOfProcesses = comm->getNumberOfProcesses();*/ - if (numberOfProcesses > 1) - { - int temp = bundleID; - for (int i = 0; i < numberOfBundles; i++) - { - if (bundleRoot == bundleID && processRoot == processID) - { - bundleID = i; - //numberOfProcesses = comm->getNumberOfProcessesInBundle(i); - collectData(grid, numberOfProcesses, PROCESS); - bundleID = temp; - } - comm->broadcast(blockID); - //UBLOG(logINFO, "blockID="<<blockID.size()); - comm->broadcast(parts); - //UBLOG(logINFO, "parts="<<parts.size()); - distributePartitionData(grid, PROCESS); - } - } - - if (threads) - { - if (numberOfThreads > 1) - { - collectData(grid, numberOfThreads, THREAD); - distributePartitionData(grid, THREAD); - } - } - UBLOG(logDEBUG1, "MetisPartitioningGridVisitor::visit() - end"); -} -////////////////////////////////////////////////////////////////////////// -void MetisPartitioningGridVisitor::collectData(SPtr<Grid3D> grid, int nofSegments, PartLevel level) -{ - clear(); - - switch (graphType) - { - case LevelIntersected: - buildMetisGraphLevelIntersected(grid, nofSegments, level); - break; - case LevelBased: - buildMetisGraphLevelBased(grid, nofSegments, level); - break; - } -} -////////////////////////////////////////////////////////////////////////// -void MetisPartitioningGridVisitor::distributePartitionData(SPtr<Grid3D> grid, PartLevel level) -{ - SPtr<Block3D> block; - - for(size_t p=0; p<parts.size(); p++) - { - block = grid->getBlock(blockID[p]); - if (block) - { - switch (level) - { - case BUNDLE: - block->setBundle(parts[p]); - break; - case PROCESS: - if (numberOfBundles == 1) - { - block->setRank(parts[p]); - } - else - { - block->setLocalRank(parts[p]); - block->setRank(comm->getProcessID(block->getBundle(),parts[p])); - } - break; - case THREAD: - block->setPart(parts[p]); - break; - } - } - } -} -////////////////////////////////////////////////////////////////////////// -void MetisPartitioningGridVisitor::buildMetisGraphLevelIntersected(SPtr<Grid3D> grid, int nofSegments, PartLevel level) -{ - int edges = 0; - const int edgeWeight= 1; - const int edgeWeightChildFactor = 8; - int n = 0; - - for(Grid3D::BlockIDMap::value_type b : grid->getBlockIDs()) - { - SPtr<Block3D> block = b.second; - if (this->getPartitionCondition(block, level)) - { - block->setLocalID(n); - blockID.push_back(block->getGlobalID()); - n++; - } - } - - MetisPartitioner metis; - - for(Grid3D::BlockIDMap::value_type b : grid->getBlockIDs()) - { - const SPtr<Block3D> block = b.second; - if (this->getPartitionCondition(block, level)) - { - metis.xadj.push_back(edges); - //the weights of the vertices are 2^level of grid (1, 2, 4, 8 .....) 1<<level - metis.vwgt.push_back((idx_t)(1<<block->getLevel())); - - for( int dir = 0; dir <= numOfDirs; dir++) - { - SPtr<Block3D> neighBlock = grid->getNeighborBlock(dir, block); - if(neighBlock) - { - if (this->getPartitionCondition(neighBlock, level)) - { - edges++; - metis.adjwgt.push_back(edgeWeight); - metis.adjncy.push_back(neighBlock->getLocalID()); - } - } - } - vector<SPtr<Block3D>> subBlocks; - grid->getSubBlocks(block, 1, subBlocks); - for(SPtr<Block3D> subBlock : subBlocks) - { - if (subBlock) - { - if (this->getPartitionCondition(subBlock, level)) - { - edges++; - metis.adjwgt.push_back(edgeWeight*edgeWeightChildFactor); - metis.adjncy.push_back(subBlock->getLocalID()); - } - } - } - } - } - - metis.xadj.push_back(static_cast<idx_t>(metis.adjncy.size())); - if ((metis.adjncy.size()%2)!=0) - throw UbException(UB_EXARGS,"number of edges is odd - probable adjncy-vector doesn't contain all pairs (A->B) and (B->A)!!!" ); - - - metis.partition(nofSegments, partType); - parts = metis.part; -} -////////////////////////////////////////////////////////////////////////// -void MetisPartitioningGridVisitor::buildMetisGraphLevelBased(SPtr<Grid3D> grid, int nofSegments, PartLevel level) -{ - int minInitLevel = grid->getCoarsestInitializedLevel(); - int maxInitLevel = grid->getFinestInitializedLevel(); - - for(int l = minInitLevel; l<=maxInitLevel;l++) - { - int n = 0; - vector<SPtr<Block3D>> blockVector; - grid->getBlocks(l, blockVector); - vector<SPtr<Block3D>> tBlockID; - - for(SPtr<Block3D> block : blockVector) - { - if (this->getPartitionCondition(block, level)) - { - block->setLocalID(n); - blockID.push_back(block->getGlobalID()); - tBlockID.push_back(block); - n++; - } - } - - if (tBlockID.size() == 0) - { - UB_THROW(UbException(UB_EXARGS,"Blocks for decomposition don't exist!")); - } - - MetisPartitioner metis; - - const int vertexWeight = 1; - int edges = 0; - - for(SPtr<Block3D> block : tBlockID) - { - metis.xadj.push_back(edges); - metis.vwgt.push_back(vertexWeight); - - for( int dir = 0; dir <= numOfDirs; dir++) - { - SPtr<Block3D> neighBlock = grid->getNeighborBlock(dir, block); - if(neighBlock) - { - if (this->getPartitionCondition(neighBlock, level)) - { - edges++; - metis.adjwgt.push_back(getEdgeWeight(dir)); - metis.adjncy.push_back(neighBlock->getLocalID()); - } - } - } - } - metis.xadj.push_back(static_cast<idx_t>(metis.adjncy.size())); - if ((metis.adjncy.size()%2)!=0) - throw UbException(UB_EXARGS,"number of edges is odd - probable adjncy-vector doesn't contain all pairs (A->B) and (B->A)!!!" ); - - int nofBlocks = grid->getNumberOfBlocks(l); - int tnofSegments = nofSegments; - if (nofBlocks < nofSegments) - { - tnofSegments = nofBlocks; - } - metis.partition(tnofSegments, partType); - - for(idx_t p : metis.part) - { - parts.push_back(p); - } - } -} -////////////////////////////////////////////////////////////////////////// -bool MetisPartitioningGridVisitor::getPartitionCondition(SPtr<Block3D> block, PartLevel level) -{ - if (level == BUNDLE) - { - return true; - } - else if(level == PROCESS) - { - if (block->getBundle() == bundleID) - { - return true; - } - } - else if(level == THREAD) - { - if (block->getBundle() == bundleID && block->getRank() == processID) - { - return true; - } - } - - return false; -} -////////////////////////////////////////////////////////////////////////// -void MetisPartitioningGridVisitor::clear() -{ - blockID.clear(); - parts.clear(); -} -////////////////////////////////////////////////////////////////////////// -int MetisPartitioningGridVisitor::getEdgeWeight(int dir) -{ - using namespace D3Q27System; - if (dir <= B) - { - return 100; - } - else if (dir >= NE && dir <= TS) - { - return 10; - } - else if (dir >= TNE) - { - return 1; - } -} -////////////////////////////////////////////////////////////////////////// -void MetisPartitioningGridVisitor::setNumberOfProcesses(int np) -{ - numberOfProcesses = np; -} - - -#endif //VF_METIS diff --git a/src/cpu/VirtualFluidsCore/Visitors/MetisPartitioningGridVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/MetisPartitioningGridVisitor.h deleted file mode 100644 index 0cb2e05a7..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/MetisPartitioningGridVisitor.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef MetisPartitioningGridVisitor_h -#define MetisPartitioningGridVisitor_h - -#if defined VF_METIS && defined VF_MPI - -#include <vector> -#include <PointerDefinitions.h> - -#include "Grid3DVisitor.h" -#include "MetisPartitioner.h" - - -class Communicator; - -//////////////////////////////////////////////////////////////////////// -//! \brief The class implements domain decomposition with METIS library -//! \author Kostyantyn Kucher -////////////////////////////////////////////////////////////////////////// - -class Grid3D; -class Block3D; - -class MetisPartitioningGridVisitor : public Grid3DVisitor -{ -public: - //! This describe different types of decomposition - enum GraphType{LevelIntersected, LevelBased}; - -public: - //! Constructor - //! \param comm - communicator - //! \param graphType - type of decomposition - //! \param numOfDirs - maximum number of neighbors for each process - //! \param threads - on/off decomposition for threads - //! \param numberOfThreads - number of threads - MetisPartitioningGridVisitor(SPtr<Communicator> comm, GraphType graphType, int numOfDirs, MetisPartitioner::PartType partType = MetisPartitioner::KWAY, bool threads = false, int numberOfThreads = 0); - virtual ~MetisPartitioningGridVisitor(); - void visit(SPtr<Grid3D> grid) override; - void setNumberOfProcesses(int np); - -protected: - enum PartLevel {BUNDLE, PROCESS, THREAD}; - void collectData(SPtr<Grid3D> grid, int nofSegments, PartLevel level); - void buildMetisGraphLevelIntersected(SPtr<Grid3D> grid, int nofSegments, PartLevel level); - void buildMetisGraphLevelBased(SPtr<Grid3D> grid, int nofSegments, PartLevel level); - bool getPartitionCondition(SPtr<Block3D> block, PartLevel level); - void distributePartitionData(SPtr<Grid3D> grid, PartLevel level); - void clear(); - int getEdgeWeight(int dir); - int nofSegments; - int numOfDirs; - std::vector<int> blockID; - std::vector<idx_t> parts; - SPtr<Communicator> comm; - int bundleRoot; - int processRoot; - int bundleID; - int processID; - int numberOfBundles; - int numberOfThreads; - bool threads; - GraphType graphType; - MetisPartitioner::PartType partType; - int numberOfProcesses; -}; - -#endif //VF_MPI -#endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/OverlapBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/OverlapBlockVisitor.cpp deleted file mode 100644 index fd56849e0..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/OverlapBlockVisitor.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "OverlapBlockVisitor.h" -#include "Grid3DSystem.h" -#include "Block3D.h" -#include "Grid3D.h" - -OverlapBlockVisitor::OverlapBlockVisitor(int levelDepth/*shut be maxGridLevel*/, bool includeNotActiveBlocks) - : Block3DVisitor(0, Grid3DSystem::MAXLEVEL) - , levelDepth(levelDepth) - , includeNotActiveBlocks(includeNotActiveBlocks) -{ -} -////////////////////////////////////////////////////////////////////////// -void OverlapBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - int ix1, ix2, ix3, level; - ix1 = block->getX1(); - ix2 = block->getX2(); - ix3 = block->getX3(); - level = block->getLevel(); - - int nix1, nix2,nix3, nlev; - int neighix1, neighix2, neighix3, neighlev; - std::vector<SPtr<Block3D>> neighbors; - grid->getAllNeighbors(ix1, ix2, ix3, level, this->levelDepth, neighbors); - bool hasAdded = false; - for(size_t i=0; i<neighbors.size(); i++) - { - if( ( neighbors[i]->isActive() || includeNotActiveBlocks ) - && neighbors[i]->getLevel() > level) - { - neighix1 = neighbors[i]->getX1(); - neighix2 = neighbors[i]->getX2(); - neighix3 = neighbors[i]->getX3(); - neighlev = neighbors[i]->getLevel(); - nix1 = neighix1>>1; - nix2 = neighix2>>1; - nix3 = neighix3>>1; - nlev = neighlev-1; - - if(nlev != level) - { - throw UbException(UB_EXARGS, "OverlapBlockVisitor::adaptBlock - leveldifferenz passt nicht, block: " + block->toString()); - } - - SPtr<Block3D> newBlock = grid->getBlock(nix1,nix2,nix3,nlev); - if(!newBlock) - { - newBlock = SPtr<Block3D>(new Block3D(nix1,nix2,nix3,nlev)); - grid->addBlock(newBlock); - hasAdded=true; - } - } - } -} -////////////////////////////////////////////////////////////////////////// -std::string OverlapBlockVisitor::getSpecificDescription() -{ - std::string str("Overlap:"); - return str; -} diff --git a/src/cpu/VirtualFluidsCore/Visitors/OverlapBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/OverlapBlockVisitor.h deleted file mode 100644 index 454c4a864..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/OverlapBlockVisitor.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef OverlapBlockVisitor_H -#define OverlapBlockVisitor_H - -#include <string> -#include <PointerDefinitions.h> - -#include "Block3DVisitor.h" - -class Grid3D; -class Block3D; - -class OverlapBlockVisitor : public Block3DVisitor -{ -public: - OverlapBlockVisitor(int levelDepth, bool includeNotActiveBlocks = true); - - virtual ~OverlapBlockVisitor(){} - - bool isIterative() { return false; } - - std::string getSpecificDescription(); - - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; - - -private: - int levelDepth; - bool includeNotActiveBlocks; -}; - -#endif //OverlapBlockVisitor_H diff --git a/src/cpu/VirtualFluidsCore/Visitors/PQueuePartitioningGridVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/PQueuePartitioningGridVisitor.cpp deleted file mode 100644 index fad451192..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/PQueuePartitioningGridVisitor.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "PQueuePartitioningGridVisitor.h" - -#include <vector> - -#include "PriorityQueueDecompositor.h" -#include "Grid3D.h" -#include "Block3D.h" -#include "UbLogger.h" - - -PQueuePartitioningGridVisitor::PQueuePartitioningGridVisitor(int numOfParts) : numOfParts(numOfParts) -{ - -} -////////////////////////////////////////////////////////////////////////// -void PQueuePartitioningGridVisitor::visit(SPtr<Grid3D> grid) -{ - UBLOG(logDEBUG5, "PQueuePartitioningGridVisitor::visit() - start"); - std::vector<SPtr<Block3D>> blocks; - std::vector<int> weights; - std::vector< std::vector <SPtr<Block3D>> > parts; - int gridRank = grid->getRank(); - - int minInitLevel = grid->getCoarsestInitializedLevel(); - int maxInitLevel = grid->getFinestInitializedLevel(); - - for(int level = minInitLevel; level<=maxInitLevel; level++) - { - std::vector<SPtr<Block3D>> blockVector; - grid->getBlocks(level, gridRank, true, blockVector); - for(SPtr<Block3D> block : blockVector) - { - if (block) - { - blocks.push_back(block); - weights.push_back(block->getNumberOfLocalConnectors()*(1<<block->getLevel())); - } - } - } - PriorityQueueDecompositor <SPtr<Block3D>> dec = PriorityQueueDecompositor <SPtr<Block3D>> (blocks, weights, numOfParts); - dec.getDecomposition(parts); - - int i = 0; - for(std::vector<SPtr<Block3D>> p : parts) - { - for(SPtr<Block3D> block : p) - { - block->setPart(i); - } - i++; - - } - UBLOG(logDEBUG5, "PQueuePartitioningGridVisitor::visit() - end"); -} diff --git a/src/cpu/VirtualFluidsCore/Visitors/PQueuePartitioningGridVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/PQueuePartitioningGridVisitor.h deleted file mode 100644 index 952b70c97..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/PQueuePartitioningGridVisitor.h +++ /dev/null @@ -1,27 +0,0 @@ -/** -* @file PQueuePartitioningPatchVisitor.h -* @brief Visitor class which apply Priority Queue for threads decomposition. -* @author Kostyantyn Kucher -* @date 06.06.2011 -*/ -#ifndef PQUEUEPARTITIONINGPATCHVISITOR_H -#define PQUEUEPARTITIONINGPATCHVISITOR_H - -#include <PointerDefinitions.h> - -#include "Grid3DVisitor.h" - -class Grid3D; - -class PQueuePartitioningGridVisitor : public Grid3DVisitor -{ -public: - PQueuePartitioningGridVisitor(int numOfParts); - - void visit(SPtr<Grid3D> grid) override; - -private: - int numOfParts; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/RatioBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/RatioBlockVisitor.cpp deleted file mode 100644 index 787313eb7..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/RatioBlockVisitor.cpp +++ /dev/null @@ -1,129 +0,0 @@ -#include "RatioBlockVisitor.h" -#include "Grid3DSystem.h" -#include "Grid3D.h" -#include "Block3D.h" - -RatioBlockVisitor::RatioBlockVisitor(int levelDepth, bool includeNotActiveBlocks) - : Block3DVisitor(0, Grid3DSystem::MAXLEVEL) - , maxLevelRatio(1) - , expandBlocks(true) - , levelDepth(levelDepth) - , includeNotActiveBlocks(includeNotActiveBlocks) -{ - -} -////////////////////////////////////////////////////////////////////////// -void RatioBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - int ix1, ix2, ix3, level; - ix1 = block->getX1(); - ix2 = block->getX2(); - ix3 = block->getX3(); - level = block->getLevel(); - - if( block->isActive() || includeNotActiveBlocks ) - { - if(this->expandBlocks) - { - if(this->lookForExpand(grid,ix1, ix2, ix3, level)) - { - grid->expandBlock(ix1, ix2, ix3, level); - } - } - else - { - if(this->lookForCollapse(grid,ix1, ix2, ix3, level)) - { - grid->collapseBlock(ix1, ix2, ix3, level, levelDepth); - } - } - } -} -////////////////////////////////////////////////////////////////////////// -bool RatioBlockVisitor::lookForExpand(SPtr<Grid3D> grid, const int& ix1, const int& ix2, const int& ix3, const int& level) -{ - std::vector<SPtr<Block3D>> neighbors; - grid->getAllNeighbors(ix1, ix2, ix3, level, this->levelDepth, neighbors); - for(size_t i=0; i<neighbors.size(); i++) - { - if( ( neighbors[i]->isActive() || includeNotActiveBlocks ) - && neighbors[i]->getLevel() > level+this->maxLevelRatio) - { - return true; - } - } - - return false; -} -////////////////////////////////////////////////////////////////////////// -bool RatioBlockVisitor::lookForCollapse(SPtr<Grid3D> grid, const int& ix1, const int& ix2, const int& ix3, const int& level) -{ - std::vector<SPtr<Block3D>> neighbors; - grid->getAllNeighbors(ix1, ix2,ix3, level, this->levelDepth, neighbors); - for(size_t i=0; i<neighbors.size(); i++) - { - if( ( neighbors[i]->isActive() || includeNotActiveBlocks ) - && neighbors[i]->getLevel() < level-this->maxLevelRatio) - { - return true; - } - } - - return false; -} -////////////////////////////////////////////////////////////////////////// -void RatioBlockVisitor::setExpandByAdaptation(bool expandBlocks) -{ - if(this->expandBlocks != expandBlocks) - { - this->expandBlocks = expandBlocks; - - int l1 = Block3DVisitor::getStartLevel(); - int l2 = Block3DVisitor::getStopLevel(); - - if(expandBlocks) { if(l1 < l2) { Block3DVisitor::setStartLevel(l2); Block3DVisitor::setStopLevel(l1); } } - else { if(l2 < l1) { Block3DVisitor::setStartLevel(l2); Block3DVisitor::setStopLevel(l1); } } - } -} -////////////////////////////////////////////////////////////////////////// -void RatioBlockVisitor::setLevelRatio(int ratio) -{ - if(ratio < 1) throw UbException(UB_EXARGS,"illegal ratio specified"); - this->maxLevelRatio = ratio; -} -////////////////////////////////////////////////////////////////////////// -std::string RatioBlockVisitor::getSpecificDescription() -{ - std::string str("Ratio:"); - return str; -} -////////////////////////////////////////////////////////////////////////// -int RatioBlockVisitor::getStartLevel() -{ - int l1 = Block3DVisitor::getStartLevel(); - int l2 = Block3DVisitor::getStopLevel(); - - if(this->expandBlocks) { if(l2 < l1) return(l1); else return(l2); } - else { if(l2 < l1) return(l2); else return(l1); } -} -////////////////////////////////////////////////////////////////////////// -int RatioBlockVisitor::getStopLevel() -{ - int l1 = Block3DVisitor::getStartLevel(); - int l2 = Block3DVisitor::getStopLevel(); - - if(this->expandBlocks) { if(l2 < l1) return(l2); else return(l1); } - else { if(l2 < l1) return(l1); else return(l2); } -} -////////////////////////////////////////////////////////////////////////// -void RatioBlockVisitor::setStartLevel(int level) -{ - if(this->expandBlocks) { if(level >= Block3DVisitor::getStopLevel()) Block3DVisitor::setStartLevel(level); } - else { if(level <= Block3DVisitor::getStopLevel()) Block3DVisitor::setStartLevel(level); } -} -////////////////////////////////////////////////////////////////////////// -void RatioBlockVisitor::setStopLevel(int level) -{ - if(this->expandBlocks) { if(level <= Block3DVisitor::getStartLevel()) Block3DVisitor::setStopLevel(level); } - else { if(level >= Block3DVisitor::getStartLevel()) Block3DVisitor::setStopLevel(level); } -} diff --git a/src/cpu/VirtualFluidsCore/Visitors/RatioBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/RatioBlockVisitor.h deleted file mode 100644 index 26b2dabe8..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/RatioBlockVisitor.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef RatioBlockVisitor_H -#define RatioBlockVisitor_H - -#include <string> -#include <PointerDefinitions.h> - -#include "Block3DVisitor.h" - -class Grid3D; -class Block3D; - -class RatioBlockVisitor : public Block3DVisitor -{ -public: - RatioBlockVisitor(int levelDepth, bool includeNotActiveBlocks = false); - - virtual ~RatioBlockVisitor() {} - - bool expandsByAdaptation() { return this->expandBlocks; } - - void setExpandByAdaptation(bool expandBlocks); - - int getLevelRatio() { return this->maxLevelRatio; } - bool isIterative() { return true; } - - void setLevelRatio(int ratio); - - int getStartLevel(); - int getStopLevel(); - - void setStartLevel(int level); - void setStopLevel(int level); - - std::string getSpecificDescription(); - - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; - -protected: - bool lookForExpand(SPtr<Grid3D> grid, const int& ix1, const int& ix2, const int& ix3, const int& level); - bool lookForCollapse(SPtr<Grid3D> grid, const int& ix1, const int& ix2, const int& ix3, const int& level); - -private: - int maxLevelRatio; - bool expandBlocks; - int levelDepth; - bool includeNotActiveBlocks; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/RatioSmoothBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/RatioSmoothBlockVisitor.cpp deleted file mode 100644 index 462093f55..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/RatioSmoothBlockVisitor.cpp +++ /dev/null @@ -1,145 +0,0 @@ -#include "RatioSmoothBlockVisitor.h" -#include "Grid3DSystem.h" -#include "Block3D.h" -#include "Grid3D.h" - -RatioSmoothBlockVisitor::RatioSmoothBlockVisitor(int levelDepth, bool includeNotActiveBlocks) - : Block3DVisitor(Grid3DSystem::MAXLEVEL, 0) - , maxLevelRatio(1) - , expandBlocks(true) - , levelDepth(levelDepth) - , includeNotActiveBlocks(includeNotActiveBlocks) -{ -} -////////////////////////////////////////////////////////////////////////// -void RatioSmoothBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - int ix1, ix2, ix3, level; - ix1 = block->getX1(); - ix2 = block->getX2(); - ix3 = block->getX3(); - level = block->getLevel(); - - if( block->isActive() || includeNotActiveBlocks ) - { - if(this->expandBlocks) - { - if(this->lookForExpand(grid,ix1, ix2, ix3, level)) - { - grid->expandBlock(ix1, ix2, ix3, level); - } - } - else - { - if(this->lookForCollapse(grid,ix1, ix2, ix3, level)) - { - grid->collapseBlock(ix1, ix2, ix3, level, levelDepth); - } - } - } -} - -////////////////////////////////////////////////////////////////////////// -bool RatioSmoothBlockVisitor::lookForExpand(SPtr<Grid3D> grid, const int& ix1, const int& ix2, const int& ix3, const int& level) -{ - std::vector<SPtr<Block3D>> neighbors; - grid->getAllNeighbors(ix1, ix2, ix3, level, this->levelDepth, neighbors); - int nix1, nix2,nix3, nlev; - for(size_t i=0; i<neighbors.size(); i++) - { - if( ( neighbors[i]->isActive() || includeNotActiveBlocks ) - && neighbors[i]->getLevel() > level) - { - nix1 = (neighbors)[i]->getX1(); - nix2 = (neighbors)[i]->getX2(); - nix3 = (neighbors)[i]->getX3(); - nlev = (neighbors)[i]->getLevel(); - - std::vector<SPtr<Block3D>> neighbors1; - grid->getAllNeighbors(nix1, nix2, nix3, nlev, nlev+1, neighbors1); - for(size_t j=0; j<neighbors1.size(); j++) - { - if( ( neighbors1[j]->isActive() || includeNotActiveBlocks ) - && neighbors1[j]->getLevel() > level+this->maxLevelRatio) - { - return true; - } - } - } - } - return false; -} -////////////////////////////////////////////////////////////////////////// -bool RatioSmoothBlockVisitor::lookForCollapse(SPtr<Grid3D> grid, const int& ix1, const int& ix2, const int& ix3, const int& level) -{ - std::vector<SPtr<Block3D>> neighbors; - grid->getAllNeighbors(ix1, ix2,ix3, level, this->levelDepth, neighbors); - for(size_t i=0; i<neighbors.size(); i++) - { - if( ( neighbors[i]->isActive() || includeNotActiveBlocks ) - && neighbors[i]->getLevel() < level-this->maxLevelRatio) - { - throw UbException(UB_EXARGS," not implemented till now"); - return true; - } - } - - return false; -} -////////////////////////////////////////////////////////////////////////// -void RatioSmoothBlockVisitor::setExpandByAdaptation(bool expandBlocks) -{ - if(this->expandBlocks != expandBlocks) - { - this->expandBlocks = expandBlocks; - - int l1 = Block3DVisitor::getStartLevel(); - int l2 = Block3DVisitor::getStopLevel(); - - if(expandBlocks) { if(l1 < l2) { Block3DVisitor::setStartLevel(l2); Block3DVisitor::setStopLevel(l1); } } - else { if(l2 < l1) { Block3DVisitor::setStartLevel(l2); Block3DVisitor::setStopLevel(l1); } } - } -} -////////////////////////////////////////////////////////////////////////// -void RatioSmoothBlockVisitor::setLevelRatio(int ratio) -{ - if(ratio < 1) throw UbException(UB_EXARGS,"illegal ratio specified"); - this->maxLevelRatio = ratio; -} -////////////////////////////////////////////////////////////////////////// -std::string RatioSmoothBlockVisitor::getSpecificDescription() -{ - std::string str("Ratio:"); - return str; -} -////////////////////////////////////////////////////////////////////////// -int RatioSmoothBlockVisitor::getStartLevel() -{ - int l1 = Block3DVisitor::getStartLevel(); - int l2 = Block3DVisitor::getStopLevel(); - - if(this->expandBlocks) { if(l2 < l1) return(l1); else return(l2); } - else { if(l2 < l1) return(l2); else return(l1); } -} -////////////////////////////////////////////////////////////////////////// -int RatioSmoothBlockVisitor::getStopLevel() -{ - int l1 = Block3DVisitor::getStartLevel(); - int l2 = Block3DVisitor::getStopLevel(); - - if(this->expandBlocks) { if(l2 < l1) return(l2); else return(l1); } - else { if(l2 < l1) return(l1); else return(l2); } -} -////////////////////////////////////////////////////////////////////////// -void RatioSmoothBlockVisitor::setStartLevel(int level) -{ - if(this->expandBlocks) { if(level >= Block3DVisitor::getStopLevel()) Block3DVisitor::setStartLevel(level); } - else { if(level <= Block3DVisitor::getStopLevel()) Block3DVisitor::setStartLevel(level); } -} -////////////////////////////////////////////////////////////////////////// -void RatioSmoothBlockVisitor::setStopLevel(int level) -{ - if(this->expandBlocks) { if(level <= Block3DVisitor::getStartLevel()) Block3DVisitor::setStopLevel(level); } - else { if(level >= Block3DVisitor::getStartLevel()) Block3DVisitor::setStopLevel(level); } -} - diff --git a/src/cpu/VirtualFluidsCore/Visitors/RatioSmoothBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/RatioSmoothBlockVisitor.h deleted file mode 100644 index ab49d2dd4..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/RatioSmoothBlockVisitor.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef RatioSmoothBlockVisitor_H -#define RatioSmoothBlockVisitor_H - -#include <string> - -#include "Block3DVisitor.h" - -class Grid3D; -class Block3D; - -class RatioSmoothBlockVisitor : public Block3DVisitor -{ -public: - RatioSmoothBlockVisitor(int levelDepth, bool includeNotActiveBlocks = false); - - virtual ~RatioSmoothBlockVisitor() {} - - bool expandsByAdaptation() { return this->expandBlocks; } - - void setExpandByAdaptation(bool expandBlocks); - - int getLevelRatio() { return this->maxLevelRatio; } - bool isIterative() { return true; } - - void setLevelRatio(int ratio); - - int getStartLevel(); - int getStopLevel(); - - void setStartLevel(int level); - void setStopLevel(int level); - - std::string getSpecificDescription(); - - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; - -protected: - bool lookForExpand(SPtr<Grid3D> grid, const int& ix1, const int& ix2, const int& ix3, const int& level); - bool lookForCollapse(SPtr<Grid3D> grid, const int& ix1, const int& ix2, const int& ix3, const int& level); - -private: - int maxLevelRatio; - bool expandBlocks; - int levelDepth; - bool includeNotActiveBlocks; - -}; - -#endif //RatioSmoothBlockVisitor_H diff --git a/src/cpu/VirtualFluidsCore/Visitors/RefineAroundGbObjectHelper.cpp b/src/cpu/VirtualFluidsCore/Visitors/RefineAroundGbObjectHelper.cpp deleted file mode 100644 index 133e3f3d1..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/RefineAroundGbObjectHelper.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "RefineAroundGbObjectHelper.h" -#include "RatioBlockVisitor.h" -#include "RatioSmoothBlockVisitor.h" -#include "OverlapBlockVisitor.h" -#include "SetInterpolationDirsBlockVisitor.h" -#include <D3Q27System.h> -#include <Grid3D.h> -#include <D3Q27TriFaceMeshInteractor.h> -#include "Communicator.h" - -RefineAroundGbObjectHelper::RefineAroundGbObjectHelper(SPtr<Grid3D> grid, int refineLevel, SPtr<D3Q27TriFaceMeshInteractor> objectIter, double startDistance, double stopDistance, SPtr<Communicator> comm) : - grid(grid), - refineLevel(refineLevel), - objectIter(objectIter), - startDistance(startDistance), - stopDistance(stopDistance), - comm(comm) -{ -} -////////////////////////////////////////////////////////////////////////// -RefineAroundGbObjectHelper::~RefineAroundGbObjectHelper(void) -{ -} -////////////////////////////////////////////////////////////////////////// -void RefineAroundGbObjectHelper::refine() -{ - UBLOG(logDEBUG5,"RefineCrossAndInsideGbObjectHelper: refine - start"); - - int rank = grid->getRank(); - grid->setRank(0); - - objectIter->refineBlockGridToLevel(refineLevel, startDistance, stopDistance); - - RatioBlockVisitor ratioVisitor(refineLevel); - grid->accept(ratioVisitor); - - RatioSmoothBlockVisitor ratioSmoothVisitor(refineLevel); - grid->accept(ratioSmoothVisitor); - - 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); - - grid->setRank(rank); - - UBLOG(logDEBUG5,"RefineCrossAndInsideGbObjectHelper: refine - end"); -} - diff --git a/src/cpu/VirtualFluidsCore/Visitors/RefineAroundGbObjectHelper.h b/src/cpu/VirtualFluidsCore/Visitors/RefineAroundGbObjectHelper.h deleted file mode 100644 index a4108b06d..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/RefineAroundGbObjectHelper.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef RefineAroundGbObjectHelper_H -#define RefineAroundGbObjectHelper_H - -#include <PointerDefinitions.h> - -class Grid3D; -class Communicator; -class D3Q27TriFaceMeshInteractor; - -//! \brief Refine blocks on base of bounding boxes. -//! \details You need to use <i>addGbObject()</i> to add corresponding bounding boxes. Then call <i>refine()</i>. -//! \author K. Kucher -class RefineAroundGbObjectHelper -{ -public: - //! Constructor - //! \param grid a smart pointer to the grid object - //! \param maxRefineLevel an integer for maximal refinement level - //! \param objectIter a D3Q27TriFaceMeshInteractor object - represent geometry which should be refinement - //! \param startDistance start distance from geometry for refinement - //! \param stopDistance stop distance from geometry for refinement - RefineAroundGbObjectHelper(SPtr<Grid3D> grid, int maxRefineLevel, SPtr<D3Q27TriFaceMeshInteractor> objectIter, double startDistance, double stopDistance, SPtr<Communicator> comm); - virtual ~RefineAroundGbObjectHelper(void); - //! start refinement - void refine(); -private: - SPtr<Grid3D> grid; - SPtr<D3Q27TriFaceMeshInteractor> objectIter; - int refineLevel; - double startDistance, stopDistance; - SPtr<Communicator> comm; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectBlockVisitor.cpp deleted file mode 100644 index 64c7617d9..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectBlockVisitor.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "RefineCrossAndInsideGbObjectBlockVisitor.h" - -#include <numerics/geometry3d/GbObject3D.h> -#include "Grid3D.h" -#include "Block3D.h" - - -RefineCrossAndInsideGbObjectBlockVisitor::RefineCrossAndInsideGbObjectBlockVisitor() -: Block3DVisitor() , notActive(true) -{ -} -////////////////////////////////////////////////////////////////////////// -RefineCrossAndInsideGbObjectBlockVisitor::RefineCrossAndInsideGbObjectBlockVisitor(SPtr<GbObject3D> geoObject, int refineLevel) - : Block3DVisitor(0,refineLevel-1), geoObject(geoObject), notActive(true) -{ - -} -////////////////////////////////////////////////////////////////////////// -RefineCrossAndInsideGbObjectBlockVisitor::~RefineCrossAndInsideGbObjectBlockVisitor() -{ -} -////////////////////////////////////////////////////////////////////////// -void RefineCrossAndInsideGbObjectBlockVisitor::visit(const SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - int level = block->getLevel(); - if( notActive && block->isNotActive() ) return; - if( level > 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->expandBlock(block->getX1(),block->getX2(),block->getX3(),level); - } - - return; -} -////////////////////////////////////////////////////////////////////////// diff --git a/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectBlockVisitor.h deleted file mode 100644 index 0aa4f5b57..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectBlockVisitor.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef RefineCrossAndInsideGbObjectBlockVisitor_H -#define RefineCrossAndInsideGbObjectBlockVisitor_H - -#include <vector> -#include <PointerDefinitions.h> - -#include "Block3DVisitor.h" - -class Grid3D; -class Block3D; -class GbObject3D; - -//! \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. Kucher -class RefineCrossAndInsideGbObjectBlockVisitor : public Block3DVisitor -{ -public: - //! A default constructor - RefineCrossAndInsideGbObjectBlockVisitor(); - //! A constructor - //! \param geoObject a smart pointer to bounding box - //! \param refineLevel an integer for refine on this level - RefineCrossAndInsideGbObjectBlockVisitor(SPtr<GbObject3D> geoObject, int refineLevel); - virtual ~RefineCrossAndInsideGbObjectBlockVisitor(); - - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; -protected: - SPtr<GbObject3D> geoObject; - bool notActive; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectHelper.cpp b/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectHelper.cpp deleted file mode 100644 index c0fc7e369..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectHelper.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "RefineCrossAndInsideGbObjectHelper.h" -#include "RefineCrossAndInsideGbObjectBlockVisitor.h" -#include "RatioBlockVisitor.h" -#include "RatioSmoothBlockVisitor.h" -#include "CheckRatioBlockVisitor.h" -#include "OverlapBlockVisitor.h" -#include "SetInterpolationDirsBlockVisitor.h" -#include <D3Q27System.h> -#include "Communicator.h" -#include <Grid3D.h> -#include <GbObject3D.h> - - -RefineCrossAndInsideGbObjectHelper::RefineCrossAndInsideGbObjectHelper(SPtr<Grid3D> grid, int maxRefineLevel, SPtr<Communicator> comm) : - grid(grid), - maxRefineLevel(maxRefineLevel), - comm(comm) -{ -} -////////////////////////////////////////////////////////////////////////// -RefineCrossAndInsideGbObjectHelper::~RefineCrossAndInsideGbObjectHelper(void) -{ -} -////////////////////////////////////////////////////////////////////////// -void RefineCrossAndInsideGbObjectHelper::refine() -{ - UBLOG(logDEBUG5,"RefineCrossAndInsideGbObjectHelper: refine - start"); - - if (comm->isRoot()) - { - int size = (int)objects.size(); - - for (int i = 0; i<size; i++) - { - RefineCrossAndInsideGbObjectBlockVisitor refVisitor(objects[i], levels[i]); - grid->accept(refVisitor); - } - - //RatioBlockVisitor ratioVisitor(maxRefineLevel); - //grid->accept(ratioVisitor); - - //RatioSmoothBlockVisitor ratioSmoothVisitor(maxRefineLevel); - //grid->accept(ratioSmoothVisitor); - - RatioBlockVisitor ratioVisitor(maxRefineLevel); - CheckRatioBlockVisitor checkRatio(maxRefineLevel); - int count = 0; - - do { - grid->accept(ratioVisitor); - checkRatio.resetState(); - grid->accept(checkRatio); - UBLOG(logINFO, "count = "<<count++<<" state = "<<checkRatio.getState()); - } while (!checkRatio.getState()); - - - OverlapBlockVisitor overlapVisitor(maxRefineLevel, false); - grid->accept(overlapVisitor); - } - - grid->updateDistributedBlocks(comm); - - std::vector<int> dirs; - - for (int i=D3Q27System::E; i<D3Q27System::ENDDIR; i++) - { - dirs.push_back(i); - } - SetInterpolationDirsBlockVisitor interDirsVisitor(dirs); - grid->accept(interDirsVisitor); - UBLOG(logDEBUG5,"RefineCrossAndInsideGbObjectHelper: refine - end"); -} -////////////////////////////////////////////////////////////////////////// -void RefineCrossAndInsideGbObjectHelper::addGbObject( SPtr<GbObject3D> object, int refineLevel ) -{ - objects.push_back(object); - levels.push_back(refineLevel); -} diff --git a/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectHelper.h b/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectHelper.h deleted file mode 100644 index 4d67c1824..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/RefineCrossAndInsideGbObjectHelper.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef RefineCrossAndInsideGbObjectHelper_H -#define RefineCrossAndInsideGbObjectHelper_H - -#include <vector> -#include <PointerDefinitions.h> - -class Communicator; -class Grid3D; -class GbObject3D; - -//! \brief Refine blocks on base of bounding boxes. -//! \details You need to use <i>addGbObject()</i> to add corresponding bounding boxes. Then call <i>refine()</i>. -//! \author K. Kucher -class RefineCrossAndInsideGbObjectHelper -{ -public: - //! Constructor - //! \param grid a smart pointer to the grid object - //! \param maxRefineLevel an integer for maximal refinement level - RefineCrossAndInsideGbObjectHelper(SPtr<Grid3D> grid, int maxRefineLevel, SPtr<Communicator> comm); - virtual ~RefineCrossAndInsideGbObjectHelper(); - //! add geometric object - //! \param object a smart pointer to bounding box - //! \param refineLevel a value of refinement level for corresponding bounding box - void addGbObject(SPtr<GbObject3D> object, int refineLevel); - //! start refinement - void refine(); -private: - SPtr<Grid3D> grid; - std::vector<SPtr<GbObject3D> > objects; - std::vector<int> levels; - int maxRefineLevel; - SPtr<Communicator> comm; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/RefineInterGbObjectsVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/RefineInterGbObjectsVisitor.cpp deleted file mode 100644 index 862ef4788..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/RefineInterGbObjectsVisitor.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "RefineInterGbObjectsVisitor.h" - -#include <numerics/geometry3d/GbObject3D.h> -#include "Grid3D.h" -#include "Block3D.h" - - -RefineInterGbObjectsBlockVisitor::RefineInterGbObjectsBlockVisitor() - : Block3DVisitor(-1, -1) -{ -} -////////////////////////////////////////////////////////////////////////// -RefineInterGbObjectsBlockVisitor::RefineInterGbObjectsBlockVisitor(SPtr<GbObject3D> includeGbObject3D, SPtr<GbObject3D> excludeGbObject3D, int startlevel, int stoplevel) - : Block3DVisitor(startlevel, stoplevel) -{ - this->includeGbObjects3D.push_back(includeGbObject3D); - this->excludeGbObjects3D.push_back(excludeGbObject3D); -} -////////////////////////////////////////////////////////////////////////// -RefineInterGbObjectsBlockVisitor::RefineInterGbObjectsBlockVisitor(std::vector<SPtr<GbObject3D>> includeGbObjects3D, std::vector<SPtr<GbObject3D>> excludeGbObjects3D, int startlevel, int stoplevel) - : Block3DVisitor(startlevel, stoplevel) -{ - this->includeGbObjects3D = includeGbObjects3D; - this->excludeGbObjects3D = excludeGbObjects3D; -} -////////////////////////////////////////////////////////////////////////// -void RefineInterGbObjectsBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - UbTupleDouble3 coords = grid->getBlockWorldCoordinates(block); - UbTupleDouble3 delta = grid->getBlockLengths(block); - - double cellMinX1 = val<1>(coords); - double cellMinX2 = val<2>(coords); - double cellMinX3 = val<3>(coords); - double cellMaxX1 = val<1>(coords)+val<1>(delta); - double cellMaxX2 = val<2>(coords)+val<2>(delta); - double cellMaxX3 = val<3>(coords)+val<3>(delta); - - bool insideInclude = false; - for(size_t i=0; i<includeGbObjects3D.size(); i++) - { - if( includeGbObjects3D[i]->isCellInsideOrCuttingGbObject3D(cellMinX1,cellMinX2,cellMinX3,cellMaxX1,cellMaxX2,cellMaxX3) ) - { - insideInclude = true; - break; - } - } - - bool insideExclude = false; - for(size_t e=0; e<excludeGbObjects3D.size(); e++) - { - if(excludeGbObjects3D[e]->isCellInsideGbObject3D(cellMinX1, cellMinX2, cellMinX3, cellMaxX1, cellMaxX2, cellMaxX3)) - { - insideExclude = true; - break; - } - } - - if(insideInclude && !insideExclude) - { - int ix1, ix2, ix3, level; - ix1 = block->getX1(); - ix2 = block->getX2(); - ix3 = block->getX3(); - level = block->getLevel(); - grid->expandBlock(ix1,ix2,ix3,level); - } -} diff --git a/src/cpu/VirtualFluidsCore/Visitors/RefineInterGbObjectsVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/RefineInterGbObjectsVisitor.h deleted file mode 100644 index 3831f41ce..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/RefineInterGbObjectsVisitor.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef RefineInterGbObjectsVisirtor_H -#define RefineInterGbObjectsVisirtor_H - -#include <vector> -#include <PointerDefinitions.h> - -#include "Block3DVisitor.h" - -class Grid3D; -class Block3D; -class GbObject3D; - -////////////////////////////////////////////////////////////////////////// -class RefineInterGbObjectsBlockVisitor : public Block3DVisitor -{ -public: - RefineInterGbObjectsBlockVisitor(); - RefineInterGbObjectsBlockVisitor(SPtr<GbObject3D> includeGbObject3D, SPtr<GbObject3D> excludeGbObject3D, int startlevel, int stoplevel); - RefineInterGbObjectsBlockVisitor(std::vector<SPtr<GbObject3D> > includeGbObjects3D, std::vector<SPtr<GbObject3D> > excludeGbObjects3D, int startlevel, int stoplevel); - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; - -private: - std::vector<SPtr<GbObject3D> > includeGbObjects3D; - std::vector<SPtr<GbObject3D> > excludeGbObjects3D; -}; - -#endif //RefineInterGbObjectsVisirtor_H diff --git a/src/cpu/VirtualFluidsCore/Visitors/RenumberBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/RenumberBlockVisitor.cpp deleted file mode 100644 index 4319cfa67..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/RenumberBlockVisitor.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "RenumberBlockVisitor.h" -#include "Grid3DSystem.h" -#include "LBMSystem.h" -#include "Grid3D.h" -#include "Block3D.h" - -int RenumberBlockVisitor::counter = 0; - -RenumberBlockVisitor::RenumberBlockVisitor() : -Block3DVisitor(0, Grid3DSystem::MAXLEVEL) -{ - -} -////////////////////////////////////////////////////////////////////////// -void RenumberBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - block->setGlobalID(counter); - Grid3D::BlockIDMap blockIdMap = grid->getBlockIDs(); - blockIdMap.insert(std::make_pair(counter, block)); - counter++; -} - diff --git a/src/cpu/VirtualFluidsCore/Visitors/RenumberBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/RenumberBlockVisitor.h deleted file mode 100644 index ecde03883..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/RenumberBlockVisitor.h +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @file RenumberBlockVisitor.h -* @brief Visitor class which renumber blocks. -* @author Konstantin Kutscher -* @date 06.06.2011 -*/ - -#ifndef RenumberBlockVisitor_h -#define RenumberBlockVisitor_h - -#include "Block3DVisitor.h" - -class Grid3D; -class Block3D; - -//! \brief Visitor class which renumber blocks. -//! \details Visitor class which renumber blocks. -//! \author Konstantin Kutscher -class RenumberBlockVisitor : public Block3DVisitor -{ -public: - RenumberBlockVisitor(); - - virtual ~RenumberBlockVisitor() {} - - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; - -private: - static int counter; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/RenumberGridVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/RenumberGridVisitor.cpp deleted file mode 100644 index 3ddb171f3..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/RenumberGridVisitor.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "RenumberGridVisitor.h" -#include "Grid3DSystem.h" -#include "Grid3D.h" -#include "Block3D.h" -//#include <mpi.h> - -RenumberGridVisitor::RenumberGridVisitor(SPtr<Communicator> com) - : comm(com) -{ -} - -////////////////////////////////////////////////////////////////////////// -void RenumberGridVisitor::visit(SPtr<Grid3D> grid) -{ - int counter = 0; - - //UBLOG(logDEBUG5, "RenumberGridVisitor::visit() - start"); - std::vector<SPtr<Block3D>> blocks; - int gridRank = grid->getRank(); - int size; - //MPI_Comm_size(MPI_COMM_WORLD, &size); - size = comm->getNumberOfProcesses(); - - int minInitLevel = grid->getCoarsestInitializedLevel(); - int maxInitLevel = grid->getFinestInitializedLevel(); - - Grid3D::BlockIDMap& blockIdMap = grid->getBlockIDs(); - blockIdMap.clear(); - - for(int rank = 0; rank < size; rank++) - { - for (int level = minInitLevel; level <= maxInitLevel; level++) - { - std::vector<SPtr<Block3D>> blockVector; - grid->getBlocks(level, blockVector); - for (SPtr<Block3D> block : blockVector) - { - if(block->getRank() == rank) - { - block->setGlobalID(counter); - blockIdMap.insert(std::make_pair(counter, block)); - counter++; - } - } - } - } - - //UBLOG(logDEBUG5, "RenumberGridVisitor::visit() - end"); -} diff --git a/src/cpu/VirtualFluidsCore/Visitors/RenumberGridVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/RenumberGridVisitor.h deleted file mode 100644 index b7005579a..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/RenumberGridVisitor.h +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @file RenumberGridVisitor.h -* @brief Visitor class which renumber blocks. -* @author Konstantin Kutscher -* @date 06.06.2011 -*/ - -#ifndef RenumberGridVisitor_h -#define RenumberGridVisitor_h - -#include "Grid3DVisitor.h" -#include "Communicator.h" - -class Grid3D; - -//! \brief Visitor class which renumber blocks in order: rank->level. -//! \details Visitor class which renumber blocks. -//! \author Konstantin Kutscher -class RenumberGridVisitor : public Grid3DVisitor -{ -public: - RenumberGridVisitor(SPtr<Communicator> com); - - virtual ~RenumberGridVisitor() {} - - void visit(SPtr<Grid3D> grid) override; - -private: - SPtr<Communicator> comm; -// static int counter; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetBcBlocksBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/SetBcBlocksBlockVisitor.cpp index 0e8fcf340..6f90b778c 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/SetBcBlocksBlockVisitor.cpp +++ b/src/cpu/VirtualFluidsCore/Visitors/SetBcBlocksBlockVisitor.cpp @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file SetBcBlocksBlockVisitor.cpp +//! \ingroup Visitors +//! \author Konstantin Kutscher +//======================================================================================= + #include "SetBcBlocksBlockVisitor.h" #include "Interactor3D.h" diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetBcBlocksBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/SetBcBlocksBlockVisitor.h index 9070d5de5..5a01f5959 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/SetBcBlocksBlockVisitor.h +++ b/src/cpu/VirtualFluidsCore/Visitors/SetBcBlocksBlockVisitor.h @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file SetBcBlocksBlockVisitor.h +//! \ingroup Visitors +//! \author Konstantin Kutscher +//======================================================================================= + #ifndef SetBcBlocksBlockVisitor_h__ #define SetBcBlocksBlockVisitor_h__ @@ -9,6 +42,7 @@ class Grid3D; class Block3D; class Interactor3D; +//! \brief A class sets blocks with boundary condition nodes in Interactor3D object. class SetBcBlocksBlockVisitor : public Block3DVisitor { public: diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.cpp index 118b0634a..cec226de2 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.cpp +++ b/src/cpu/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.cpp @@ -1,486 +1,109 @@ -#include "SetConnectorsBlockVisitor.h" -#include "D3Q27ETFullDirectConnector.h" -#include "D3Q27ETFullVectorConnector.h" -#include "D3Q27ETCFOffVectorConnector.h" -#include "D3Q27ETFCOffVectorConnector.h" -#include "Grid3DSystem.h" -#include <basics/transmitter/TbTransmitterLocal.h> - -#include "Communicator.h" -#include "InterpolationProcessor.h" - -SetConnectorsBlockVisitor::SetConnectorsBlockVisitor(SPtr<Communicator> comm, bool fullConnector, int dirs, - LBMReal nue, InterpolationProcessorPtr iProcessor) : -Block3DVisitor(0, Grid3DSystem::MAXLEVEL), - comm(comm), - fullConnector(fullConnector), - dirs(dirs), - nue(nue), - iProcessor(iProcessor) -{ -} -////////////////////////////////////////////////////////////////////////// -SetConnectorsBlockVisitor::~SetConnectorsBlockVisitor(void) -{ -} -////////////////////////////////////////////////////////////////////////// -void SetConnectorsBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - if(!block) return; - - UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::visit() - start"); - UBLOG(logDEBUG5, block->toString()); - - gridRank = comm->getProcessID(); - grid->setRank(gridRank); - - setSameLevelConnectors(grid, block); - - if(grid->getFinestInitializedLevel() > grid->getCoarsestInitializedLevel()) - setInterpolationConnectors(grid, block); - - UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::visit() - end"); -} -////////////////////////////////////////////////////////////////////////// -void SetConnectorsBlockVisitor::setSameLevelConnectors(SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::setSameLevelConnectors() - start"); - int blockRank = block->getRank(); - if (gridRank == blockRank && block->isActive()) - { - block->clearWeight(); - std::vector<SPtr<Block3D>> neighbors; - int ix1 = block->getX1(); - int ix2 = block->getX2(); - int ix3 = block->getX3(); - int level = block->getLevel(); - //grid->getAllNeighbors(ix1, ix2, ix3, level, level, neighbors); - - //if (block->getGlobalID()==2512) - //{ - // int test = 0; - //} - - for( int dir = 0; dir < dirs; dir++) - { - SPtr<Block3D> neighBlock = grid->getNeighborBlock(dir, ix1, ix2, ix3, level); - - if(neighBlock) - { - int neighBlockRank = neighBlock->getRank(); - if(blockRank == neighBlockRank && neighBlock->isActive()) - { - SPtr<Block3DConnector> connector; - connector = SPtr<Block3DConnector>(new D3Q27ETFullDirectConnector( block, neighBlock, dir)); - block->setConnector(connector); - } - else if(blockRank != neighBlockRank && neighBlock->isActive()) - { - setRemoteConnectors(block, neighBlock, dir, fullConnector); - - if(dir >=0 && dir<=5) - { - int weight = block->getWeight(neighBlockRank); - weight++; - block->setWeight(neighBlockRank, weight); - } - } - } - } - - //if (block->getGlobalID()==2794) - //{ - // UBLOG(logINFO, block->toString()); - //} - - int weight = block->getNumberOfLocalConnectorsForSurfaces(); - weight = 6 - weight; - block->addWeightForAll(weight); - } - UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::setSameLevelConnectors() - end"); -} -////////////////////////////////////////////////////////////////////////// -void SetConnectorsBlockVisitor::setRemoteConnectors(SPtr<Block3D> sblock, SPtr<Block3D> tblock, int dir, bool fullConnector) -{ - UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::setRemoteConnectors() - start"); - CreateTransmittersHelper helper; - CreateTransmittersHelper::TransmitterPtr sender, receiver; - helper.createTransmitters(sblock, tblock, dir, CreateTransmittersHelper::NONE, sender, receiver, comm, CreateTransmittersHelper::MPI); - - - SPtr<Block3DConnector> connector; - connector = SPtr<Block3DConnector>(new D3Q27ETFullVectorConnector(sblock, sender, receiver, dir)); - sblock->setConnector(connector); - UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::setRemoteConnectors() - end"); -} -////////////////////////////////////////////////////////////////////////// -void SetConnectorsBlockVisitor::setInterpolationConnectors(SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::setInterpolationConnectors() - start"); - int blockRank = block->getRank(); - if (block->getGlobalID()==394) - { - int test=0; - } - - //search for all blocks with different ranks - if (block->hasInterpolationFlagCF() && block->isActive()) - { - int fbx1 = block->getX1() << 1; - int fbx2 = block->getX2() << 1; - int fbx3 = block->getX3() << 1; - int level = block->getLevel() + 1; - - if( block->hasInterpolationFlagCF(D3Q27System::E)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1+1,fbx2,fbx3,level); - SPtr<Block3D> fblockSE = grid->getBlock(fbx1+1,fbx2+1,fbx3,level); - SPtr<Block3D> fblockNW = grid->getBlock(fbx1+1,fbx2,fbx3+1,level); - SPtr<Block3D> fblockNE = grid->getBlock(fbx1+1,fbx2+1,fbx3+1,level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::E); - } - if( block->hasInterpolationFlagCF(D3Q27System::W)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1,fbx2,fbx3,level); - SPtr<Block3D> fblockSE = grid->getBlock(fbx1,fbx2+1,fbx3,level); - SPtr<Block3D> fblockNW = grid->getBlock(fbx1,fbx2,fbx3+1,level); - SPtr<Block3D> fblockNE = grid->getBlock(fbx1,fbx2+1,fbx3+1,level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::W); - } - if( block->hasInterpolationFlagCF(D3Q27System::N)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1,fbx2+1,fbx3,level); - SPtr<Block3D> fblockSE = grid->getBlock(fbx1+1,fbx2+1,fbx3,level); - SPtr<Block3D> fblockNW = grid->getBlock(fbx1,fbx2+1,fbx3+1,level); - SPtr<Block3D> fblockNE = grid->getBlock(fbx1+1,fbx2+1,fbx3+1,level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::N); - } - if( block->hasInterpolationFlagCF(D3Q27System::S)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1,fbx2,fbx3,level); - SPtr<Block3D> fblockSE = grid->getBlock(fbx1+1,fbx2,fbx3,level); - SPtr<Block3D> fblockNW = grid->getBlock(fbx1,fbx2,fbx3+1,level); - SPtr<Block3D> fblockNE = grid->getBlock(fbx1+1,fbx2,fbx3+1,level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::S); - } - if( block->hasInterpolationFlagCF(D3Q27System::T)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1,fbx2,fbx3+1,level); - SPtr<Block3D> fblockSE = grid->getBlock(fbx1+1,fbx2,fbx3+1,level); - SPtr<Block3D> fblockNW = grid->getBlock(fbx1,fbx2+1,fbx3+1,level); - SPtr<Block3D> fblockNE = grid->getBlock(fbx1+1,fbx2+1,fbx3+1,level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::T); - } - if( block->hasInterpolationFlagCF(D3Q27System::B)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1,fbx2,fbx3,level); - SPtr<Block3D> fblockSE = grid->getBlock(fbx1+1,fbx2,fbx3,level); - SPtr<Block3D> fblockNW = grid->getBlock(fbx1,fbx2+1,fbx3,level); - SPtr<Block3D> fblockNE = grid->getBlock(fbx1+1,fbx2+1,fbx3,level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::B); - } - - //////NE-NW-SE-SW - if( block->hasInterpolationFlagCF(D3Q27System::NE)&&!block->hasInterpolationFlagCF(D3Q27System::N) && !block->hasInterpolationFlagCF(D3Q27System::E)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1+1,fbx2+1,fbx3+0,level); - SPtr<Block3D> fblockSE = grid->getBlock(fbx1+1,fbx2+1,fbx3+1,level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::NE); - } - if( block->hasInterpolationFlagCF(D3Q27System::SW)&& !block->hasInterpolationFlagCF(D3Q27System::W) && !block->hasInterpolationFlagCF(D3Q27System::S)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1,fbx2,fbx3,level); - SPtr<Block3D> fblockSE = grid->getBlock(fbx1,fbx2,fbx3+1,level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1, fbx2, fbx3+1, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1, fbx2, fbx3+1, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::SW); - } - if( block->hasInterpolationFlagCF(D3Q27System::SE)&& !block->hasInterpolationFlagCF(D3Q27System::E) && !block->hasInterpolationFlagCF(D3Q27System::S)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1+1,fbx2,fbx3+0,level); - SPtr<Block3D> fblockSE = grid->getBlock(fbx1+1,fbx2,fbx3+1,level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1+1, fbx2, fbx3+1, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1+1, fbx2, fbx3+1, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::SE); - } - if( block->hasInterpolationFlagCF(D3Q27System::NW)&& !block->hasInterpolationFlagCF(D3Q27System::N) && !block->hasInterpolationFlagCF(D3Q27System::W)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1,fbx2+1,fbx3,level); - SPtr<Block3D> fblockSE = grid->getBlock(fbx1,fbx2+1,fbx3+1,level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1, fbx2+1, fbx3+1, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::NW); - } - - /////////TE-BW-BE-TW 1-0 - if( block->hasInterpolationFlagCF(D3Q27System::TE)&& !block->hasInterpolationFlagCF(D3Q27System::E) && !block->hasInterpolationFlagCF(D3Q27System::T)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1+1,fbx2+0,fbx3+1,level); - SPtr<Block3D> fblockSE = grid->getBlock(fbx1+1,fbx2+1,fbx3+1,level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1+1, fbx2+0, fbx3+1, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::TE); - } - if( block->hasInterpolationFlagCF(D3Q27System::BW)&& !block->hasInterpolationFlagCF(D3Q27System::W) && !block->hasInterpolationFlagCF(D3Q27System::B)) - { - - SPtr<Block3D> fblockSW = grid->getBlock(fbx1,fbx2+0,fbx3,level); - SPtr<Block3D> fblockSE = grid->getBlock(fbx1,fbx2+1,fbx3,level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1, fbx2+0, fbx3, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1, fbx2+1, fbx3, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::BW); - } - if( block->hasInterpolationFlagCF(D3Q27System::BE)&& !block->hasInterpolationFlagCF(D3Q27System::E) && !block->hasInterpolationFlagCF(D3Q27System::B)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1+1,fbx2+0,fbx3,level); - SPtr<Block3D> fblockSE = grid->getBlock(fbx1+1,fbx2+1,fbx3,level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1+1, fbx2+0, fbx3, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1+1, fbx2+1, fbx3, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::BE); - } - if( block->hasInterpolationFlagCF(D3Q27System::TW)&& !block->hasInterpolationFlagCF(D3Q27System::W) && !block->hasInterpolationFlagCF(D3Q27System::T)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1,fbx2+0,fbx3+1,level); - SPtr<Block3D> fblockSE = grid->getBlock(fbx1,fbx2+1,fbx3+1,level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1, fbx2+0, fbx3+1, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1, fbx2+1, fbx3+1, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::TW); - } - - //////TN-BS-BN-TS - if( block->hasInterpolationFlagCF(D3Q27System::TN)&& !block->hasInterpolationFlagCF(D3Q27System::N) && !block->hasInterpolationFlagCF(D3Q27System::T)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1+0,fbx2+1,fbx3+1,level); - SPtr<Block3D> fblockSE = grid->getBlock(fbx1+1,fbx2+1,fbx3+1,level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1+0, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::TN); - } - if( block->hasInterpolationFlagCF(D3Q27System::BS)&& !block->hasInterpolationFlagCF(D3Q27System::S) && !block->hasInterpolationFlagCF(D3Q27System::B)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1+0,fbx2,fbx3,level); - SPtr<Block3D> fblockSE = grid->getBlock(fbx1+1,fbx2,fbx3,level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1+0, fbx2, fbx3, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1+1, fbx2, fbx3, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::BS); - } - if( block->hasInterpolationFlagCF(D3Q27System::BN)&& !block->hasInterpolationFlagCF(D3Q27System::N) && !block->hasInterpolationFlagCF(D3Q27System::B)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1+0,fbx2+1,fbx3,level); - SPtr<Block3D> fblockSE = grid->getBlock(fbx1+1,fbx2+1,fbx3,level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1+0, fbx2+1, fbx3, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1+1, fbx2+1, fbx3, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::BN); - } - if( block->hasInterpolationFlagCF(D3Q27System::TS)&& !block->hasInterpolationFlagCF(D3Q27System::S) && !block->hasInterpolationFlagCF(D3Q27System::T)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1+0,fbx2,fbx3+1,level); - SPtr<Block3D> fblockSE = grid->getBlock(fbx1+1,fbx2,fbx3+1,level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1+0, fbx2, fbx3+1, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1+1, fbx2, fbx3+1, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::TS); - } - - - - - //////corners - if (block->hasInterpolationFlagCF(D3Q27System::TNE)&&!block->hasInterpolationFlagCF(D3Q27System::TE)&&!block->hasInterpolationFlagCF(D3Q27System::TN)&&!block->hasInterpolationFlagCF(D3Q27System::NE)&&!block->hasInterpolationFlagCF(D3Q27System::T)&&!block->hasInterpolationFlagCF(D3Q27System::N) && !block->hasInterpolationFlagCF(D3Q27System::E)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblockSE;// = grid->getBlock(fbx1+1, fbx2+1, fbx3+0, level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::TNE); - } - if (block->hasInterpolationFlagCF(D3Q27System::TSW)&&!block->hasInterpolationFlagCF(D3Q27System::TW)&&!block->hasInterpolationFlagCF(D3Q27System::TS)&& !block->hasInterpolationFlagCF(D3Q27System::SW)&& !block->hasInterpolationFlagCF(D3Q27System::T)&& !block->hasInterpolationFlagCF(D3Q27System::W) && !block->hasInterpolationFlagCF(D3Q27System::S)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1, fbx2, fbx3+1, level); - SPtr<Block3D> fblockSE;// = grid->getBlock(fbx1, fbx2, fbx3, level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1, fbx2, fbx3+1, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1, fbx2, fbx3+1, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::TSW); - } - if (block->hasInterpolationFlagCF(D3Q27System::TSE)&&!block->hasInterpolationFlagCF(D3Q27System::TE)&&!block->hasInterpolationFlagCF(D3Q27System::TS)&& !block->hasInterpolationFlagCF(D3Q27System::SE)&& !block->hasInterpolationFlagCF(D3Q27System::T)&& !block->hasInterpolationFlagCF(D3Q27System::E) && !block->hasInterpolationFlagCF(D3Q27System::S)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1+1, fbx2, fbx3+1, level); - SPtr<Block3D> fblockSE;// = grid->getBlock(fbx1+1, fbx2, fbx3+0, level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1+1, fbx2, fbx3+1, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1+1, fbx2, fbx3+1, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::TSE); - } - if (block->hasInterpolationFlagCF(D3Q27System::TNW)&&!block->hasInterpolationFlagCF(D3Q27System::TW)&&!block->hasInterpolationFlagCF(D3Q27System::TN)&& !block->hasInterpolationFlagCF(D3Q27System::NW)&& !block->hasInterpolationFlagCF(D3Q27System::T)&& !block->hasInterpolationFlagCF(D3Q27System::N) && !block->hasInterpolationFlagCF(D3Q27System::W)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblockSE;// = grid->getBlock(fbx1, fbx2+1, fbx3, level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1, fbx2+1, fbx3+1, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::TNW); - } - if (block->hasInterpolationFlagCF(D3Q27System::BNE)&&!block->hasInterpolationFlagCF(D3Q27System::BE)&&!block->hasInterpolationFlagCF(D3Q27System::BN)&& !block->hasInterpolationFlagCF(D3Q27System::NE)&&!block->hasInterpolationFlagCF(D3Q27System::B)&&!block->hasInterpolationFlagCF(D3Q27System::N) && !block->hasInterpolationFlagCF(D3Q27System::E)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1+1, fbx2+1, fbx3+0, level); - SPtr<Block3D> fblockSE;// = grid->getBlock(fbx1+1, fbx2+1, fbx3+0, level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1+1, fbx2+1, fbx3+1, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::BNE); - } - if (block->hasInterpolationFlagCF(D3Q27System::BSW)&& !block->hasInterpolationFlagCF(D3Q27System::BS)&& !block->hasInterpolationFlagCF(D3Q27System::BW)&& !block->hasInterpolationFlagCF(D3Q27System::SW)&& !block->hasInterpolationFlagCF(D3Q27System::B)&& !block->hasInterpolationFlagCF(D3Q27System::W) && !block->hasInterpolationFlagCF(D3Q27System::S)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1, fbx2, fbx3+0, level); - SPtr<Block3D> fblockSE;// = grid->getBlock(fbx1, fbx2, fbx3, level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1, fbx2, fbx3+1, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1, fbx2, fbx3+1, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::BSW); - } - if (block->hasInterpolationFlagCF(D3Q27System::BSE)&& !block->hasInterpolationFlagCF(D3Q27System::BS)&& !block->hasInterpolationFlagCF(D3Q27System::BE)&& !block->hasInterpolationFlagCF(D3Q27System::SE)&& !block->hasInterpolationFlagCF(D3Q27System::B)&& !block->hasInterpolationFlagCF(D3Q27System::E) && !block->hasInterpolationFlagCF(D3Q27System::S)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1+1, fbx2, fbx3, level); - SPtr<Block3D> fblockSE;// = grid->getBlock(fbx1+1, fbx2, fbx3+0, level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1+1, fbx2, fbx3+1, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1+1, fbx2, fbx3+1, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::BSE); - } - if (block->hasInterpolationFlagCF(D3Q27System::BNW)&& !block->hasInterpolationFlagCF(D3Q27System::BN)&& !block->hasInterpolationFlagCF(D3Q27System::BW)&& !block->hasInterpolationFlagCF(D3Q27System::NW)&& !block->hasInterpolationFlagCF(D3Q27System::B)&& !block->hasInterpolationFlagCF(D3Q27System::N) && !block->hasInterpolationFlagCF(D3Q27System::W)) - { - SPtr<Block3D> fblockSW = grid->getBlock(fbx1, fbx2+1, fbx3+0, level); - SPtr<Block3D> fblockSE;// = grid->getBlock(fbx1, fbx2+1, fbx3, level); - SPtr<Block3D> fblockNW;// = grid->getBlock(fbx1, fbx2+1, fbx3+1, level); - SPtr<Block3D> fblockNE;// = grid->getBlock(fbx1, fbx2+1, fbx3+1, level); - - setInterpolationConnectors(fblockSW, fblockSE, fblockNW, fblockNE, block, D3Q27System::BNW); - } - - } - UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::setInterpolationConnectors() - end"); -} -////////////////////////////////////////////////////////////////////////// -void SetConnectorsBlockVisitor::setInterpolationConnectors(SPtr<Block3D> fBlockSW, SPtr<Block3D> fBlockSE, SPtr<Block3D> fBlockNW, SPtr<Block3D> fBlockNE, SPtr<Block3D> cBlock, int dir) -{ - UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::setInterpolationConnectors(...) - start"); - int fBlockSWRank = -999, fBlockSERank = -999, fBlockNWRank = -999, fBlockNERank = -999; - if(fBlockSW) fBlockSWRank = fBlockSW->getRank(); - if(fBlockNW) fBlockNWRank = fBlockNW->getRank(); - if(fBlockSE) fBlockSERank = fBlockSE->getRank(); - if(fBlockNE) fBlockNERank = fBlockNE->getRank(); - int cBlockRank = cBlock->getRank(); - - LBMReal omegaF; - if(fBlockSW) omegaF =LBMSystem::calcCollisionFactor(nue, fBlockSW->getLevel()); - if(fBlockNW) omegaF =LBMSystem::calcCollisionFactor(nue, fBlockNW->getLevel()); - if(fBlockSE) omegaF =LBMSystem::calcCollisionFactor(nue, fBlockSE->getLevel()); - if(fBlockNE) omegaF =LBMSystem::calcCollisionFactor(nue, fBlockNE->getLevel()); - LBMReal omegaC = LBMSystem::calcCollisionFactor(nue, cBlock->getLevel()); - iProcessor->setOmegas(omegaC, omegaF); - - 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, - senderCFoddEvenSE, receiverCFoddEvenSE, - senderCFoddOddNE, receiverCFoddOddNE, - senderFCevenEvenSW, receiverFCevenEvenSW, - senderFCevenOddNW, receiverFCevenOddNW, - senderFCoddEvenSE, receiverFCoddEvenSE, - senderFCoddOddNE, receiverFCoddOddNE; - - if(fBlockSW) createTransmitters(cBlock, fBlockSW, dir, CreateTransmittersHelper::SW, senderCFevenEvenSW, receiverCFevenEvenSW, senderFCevenEvenSW, receiverFCevenEvenSW); - if(fBlockNW) createTransmitters(cBlock, fBlockNW, dir, CreateTransmittersHelper::NW, senderCFevenOddNW, receiverCFevenOddNW, senderFCevenOddNW, receiverFCevenOddNW); - if(fBlockSE) createTransmitters(cBlock, fBlockSE, dir, CreateTransmittersHelper::SE, senderCFoddEvenSE, receiverCFoddEvenSE, senderFCoddEvenSE, receiverFCoddEvenSE); - if(fBlockNE) createTransmitters(cBlock, fBlockNE, dir, CreateTransmittersHelper::NE, senderCFoddOddNE, receiverCFoddOddNE, senderFCoddOddNE, receiverFCoddOddNE); - - if(cBlockRank == gridRank) - { - SPtr<Block3DConnector> connector(new D3Q27ETCFOffVectorConnector< TbTransmitter< CbVector< LBMReal > > >(cBlock, - senderCFevenEvenSW, receiverCFevenEvenSW, senderCFevenOddNW, receiverCFevenOddNW, - senderCFoddEvenSE, receiverCFoddEvenSE, senderCFoddOddNE, receiverCFoddOddNE, - dir, cIProcessor) ); - cBlock->setConnector(connector); - } - if(fBlockSW && fBlockSWRank == gridRank) - { - SPtr<Block3DConnector> connector( new D3Q27ETFCOffVectorConnector< TbTransmitter< CbVector< LBMReal > > >(fBlockSW, - senderFCevenEvenSW, receiverFCevenEvenSW, dir, fIProcessorSW, EvenEvenSW) ); - fBlockSW->setConnector(connector); - } - if(fBlockNW && fBlockNWRank == gridRank) - { - SPtr<Block3DConnector> connector( new D3Q27ETFCOffVectorConnector< TbTransmitter< CbVector< LBMReal > > >(fBlockNW, - senderFCevenOddNW, receiverFCevenOddNW, dir, fIProcessorNW, EvenOddNW) ); - fBlockNW->setConnector(connector); - } - if(fBlockSE && fBlockSERank == gridRank) - { - SPtr<Block3DConnector> connector( new D3Q27ETFCOffVectorConnector< TbTransmitter< CbVector< LBMReal > > >(fBlockSE, - senderFCoddEvenSE, receiverFCoddEvenSE, dir, fIProcessorSE, OddEvenSE) ); - fBlockSE->setConnector(connector); - } - if(fBlockNE && fBlockNERank == gridRank) - { - SPtr<Block3DConnector> connector( new D3Q27ETFCOffVectorConnector< TbTransmitter< CbVector< LBMReal > > >(fBlockNE, - senderFCoddOddNE, receiverFCoddOddNE, dir, fIProcessorNE, OddOddNE) ); - fBlockNE->setConnector(connector); - } - UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::setInterpolationConnectors(...) - end"); -} -////////////////////////////////////////////////////////////////////////// -void SetConnectorsBlockVisitor::createTransmitters(SPtr<Block3D> cBlock, SPtr<Block3D> fBlock, int dir, - CreateTransmittersHelper::IBlock ib, - CreateTransmittersHelper::TransmitterPtr& senderCF, - CreateTransmittersHelper::TransmitterPtr& receiverCF, - CreateTransmittersHelper::TransmitterPtr& senderFC, - CreateTransmittersHelper::TransmitterPtr& receiverFC) -{ - UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::createTransmitters(...) - start"); - CreateTransmittersHelper helper; - bool MPIpool = true; - bool orthogonal = false; - int fBlockRank = fBlock->getRank(); - int cBlockRank = cBlock->getRank(); - if(fBlockRank == cBlockRank && fBlockRank == gridRank) - { - senderCF = receiverFC = CreateTransmittersHelper::TransmitterPtr( new TbLocalTransmitter< CbVector< LBMReal > >()); - senderFC = receiverCF = CreateTransmittersHelper::TransmitterPtr( new TbLocalTransmitter< CbVector< LBMReal > >()); - } - else if(cBlockRank == gridRank) - { - helper.createTransmitters(cBlock, fBlock, dir, ib, senderCF, receiverCF, comm, CreateTransmittersHelper::MPI); - } - else if(fBlockRank == gridRank) - { - helper.createTransmitters(fBlock, cBlock, dir, ib, senderFC, receiverFC, comm, CreateTransmittersHelper::MPI); - } - UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::createTransmitters(...) - end"); -} - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file SetConnectorsBlockVisitor.cpp +//! \ingroup Visitors +//! \author Konstantin Kutscher +//======================================================================================= + +#include "SetConnectorsBlockVisitor.h" +#include "D3Q27ETFullDirectConnector.h" +#include "Grid3DSystem.h" +#include "Communicator.h" +#include "Grid3D.h" + +SetConnectorsBlockVisitor::SetConnectorsBlockVisitor(SPtr<Communicator> comm, bool fullConnector, int dirs, LBMReal nu) : Block3DVisitor(0, Grid3DSystem::MAXLEVEL), comm(comm), fullConnector(fullConnector), dirs(dirs), nu(nu) +{ +} +////////////////////////////////////////////////////////////////////////// +SetConnectorsBlockVisitor::~SetConnectorsBlockVisitor(void) +{ +} +////////////////////////////////////////////////////////////////////////// +void SetConnectorsBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) +{ + if(!block) return; + + UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::visit() - start"); + UBLOG(logDEBUG5, block->toString()); + + gridRank = comm->getProcessID(); + grid->setRank(gridRank); + + setSameLevelConnectors(grid, block); + + UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::visit() - end"); +} +////////////////////////////////////////////////////////////////////////// +void SetConnectorsBlockVisitor::setSameLevelConnectors(SPtr<Grid3D> grid, SPtr<Block3D> block) +{ + UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::setSameLevelConnectors() - start"); + int blockRank = block->getRank(); + if (gridRank == blockRank && block->isActive()) + { + block->clearWeight(); + std::vector<SPtr<Block3D>> neighbors; + int ix1 = block->getX1(); + int ix2 = block->getX2(); + int ix3 = block->getX3(); + int level = block->getLevel(); + + for( int dir = 0; dir < dirs; dir++) + { + SPtr<Block3D> neighBlock = grid->getNeighborBlock(dir, ix1, ix2, ix3, level); + + if(neighBlock) + { + int neighBlockRank = neighBlock->getRank(); + if(blockRank == neighBlockRank && neighBlock->isActive()) + { + SPtr<Block3DConnector> connector; + connector = SPtr<Block3DConnector>(new D3Q27ETFullDirectConnector( block, neighBlock, dir)); + block->setConnector(connector); + } + //else if(blockRank != neighBlockRank && neighBlock->isActive()) + //{ + // setRemoteConnectors(block, neighBlock, dir, fullConnector); + + // if(dir >=0 && dir<=5) + // { + // int weight = block->getWeight(neighBlockRank); + // weight++; + // block->setWeight(neighBlockRank, weight); + // } + //} + } + } + + // int weight = block->getNumberOfLocalConnectorsForSurfaces(); + //weight = 6 - weight; + //block->addWeightForAll(weight); + } + UBLOG(logDEBUG5, "D3Q27SetConnectorsBlockVisitor::setSameLevelConnectors() - end"); +} + diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.h index c20499dd6..2a829103c 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.h +++ b/src/cpu/VirtualFluidsCore/Visitors/SetConnectorsBlockVisitor.h @@ -1,42 +1,65 @@ -#ifndef SETCONNECTORSBLOCKVISITOR_H -#define SETCONNECTORSBLOCKVISITOR_H - -#include <PointerDefinitions.h> - -#include "Block3DVisitor.h" -#include "D3Q27System.h" - -#include "CreateTransmittersHelper.h" - -class Grid3D; -class Block3D; -class Communicator; -class InterpolationProcessor; - -class SetConnectorsBlockVisitor : public Block3DVisitor -{ -public: - SetConnectorsBlockVisitor(SPtr<Communicator> comm, bool fullConnector, int dirs, LBMReal nue, SPtr<InterpolationProcessor> iProcessor); - virtual ~SetConnectorsBlockVisitor(); - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; - ////////////////////////////////////////////////////////////////////////// -protected: - void setSameLevelConnectors(SPtr<Grid3D> grid, SPtr<Block3D> block); - void setRemoteConnectors(SPtr<Block3D> sblock, SPtr<Block3D> tblock, int dir, bool fullConnector); - void setInterpolationConnectors(SPtr<Grid3D> grid, SPtr<Block3D> block); - void setInterpolationConnectors(SPtr<Block3D> fBlockSW, SPtr<Block3D> fBlockSE, SPtr<Block3D> fBlockNW, SPtr<Block3D> fBlockNE, SPtr<Block3D> cBlock, int dir); - void createTransmitters(SPtr<Block3D> cBlock, SPtr<Block3D> fBlock, int dir, - CreateTransmittersHelper::IBlock ib, - CreateTransmittersHelper::TransmitterPtr& senderCF, - CreateTransmittersHelper::TransmitterPtr& receiverCF, - CreateTransmittersHelper::TransmitterPtr& senderFC, - CreateTransmittersHelper::TransmitterPtr& receiverFC); - SPtr<Communicator> comm; - bool fullConnector; - int dirs; - int gridRank; - LBMReal nue; - SPtr<InterpolationProcessor> iProcessor; -}; - -#endif //D3Q27SETCONNECTORSVISITOR_H +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file SetConnectorsBlockVisitor.h +//! \ingroup Visitors +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef SETCONNECTORSBLOCKVISITOR_H +#define SETCONNECTORSBLOCKVISITOR_H + +#include <PointerDefinitions.h> + +#include "Block3DVisitor.h" +#include "D3Q27System.h" + +class Grid3D; +class Block3D; +class Communicator; +class InterpolationProcessor; + +//! \brief A class sets connectors between blocks. +class SetConnectorsBlockVisitor : public Block3DVisitor +{ +public: + SetConnectorsBlockVisitor(SPtr<Communicator> comm, bool fullConnector, int dirs, LBMReal nu); + virtual ~SetConnectorsBlockVisitor(); + void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; + ////////////////////////////////////////////////////////////////////////// +protected: + void setSameLevelConnectors(SPtr<Grid3D> grid, SPtr<Block3D> block); + SPtr<Communicator> comm; + bool fullConnector; + int dirs; + int gridRank; + LBMReal nu; + SPtr<InterpolationProcessor> iProcessor; +}; + +#endif //SETCONNECTORSBLOCKVISITOR_H diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetForcingBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/SetForcingBlockVisitor.cpp deleted file mode 100644 index 100ee2fe4..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/SetForcingBlockVisitor.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "SetForcingBlockVisitor.h" -#include "Grid3DSystem.h" -#include "LBMSystem.h" -#include "Grid3D.h" -#include "Block3D.h" - -SetForcingBlockVisitor::SetForcingBlockVisitor(LBMReal forcingX1, LBMReal forcingX2, LBMReal forcingX3) : - Block3DVisitor(0, Grid3DSystem::MAXLEVEL), forcingX1(forcingX1), - forcingX2(forcingX2), - forcingX3(forcingX3) -{ - ftype = 0; -} -////////////////////////////////////////////////////////////////////////// -SetForcingBlockVisitor::SetForcingBlockVisitor(const mu::Parser& muForcingX1, const mu::Parser& muForcingX2, const mu::Parser& muForcingX3) : - Block3DVisitor(0, Grid3DSystem::MAXLEVEL), muForcingX1(muForcingX1), - muForcingX2(muForcingX2), - muForcingX3(muForcingX3) - -{ - ftype = 1; -} -////////////////////////////////////////////////////////////////////////// -SetForcingBlockVisitor::SetForcingBlockVisitor(const std::string& sForcingX1, const std::string& sForcingX2, const std::string& sForcingX3) : - Block3DVisitor(0, Grid3DSystem::MAXLEVEL), sForcingX1(sForcingX1), - sForcingX2(sForcingX2), - sForcingX3(sForcingX3) - -{ - ftype = 2; -} -////////////////////////////////////////////////////////////////////////// -void SetForcingBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - if(block->getRank() == grid->getRank()) - { - SPtr<LBMKernel> kernel = dynamicPointerCast<LBMKernel>(block->getKernel()); - if (!kernel) - throw UbException(UB_EXARGS, "LBMKernel is not exist"); - - switch (ftype) - { - case 0: - kernel->setForcingX1(forcingX1); - kernel->setForcingX2(forcingX2); - kernel->setForcingX3(forcingX3); - kernel->setWithForcing(true); - break; - case 1: - kernel->setForcingX1(muForcingX1); - kernel->setForcingX2(muForcingX2); - kernel->setForcingX3(muForcingX3); - kernel->setWithForcing(true); - break; - case 2: - kernel->setForcingX1(sForcingX1); - kernel->setForcingX2(sForcingX2); - kernel->setForcingX3(sForcingX3); - kernel->setWithForcing(true); - break; - default: - kernel->setForcingX1(0.0); - kernel->setForcingX2(0.0); - kernel->setForcingX3(0.0); - kernel->setWithForcing(false); - break; - } - } -} - diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetForcingBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/SetForcingBlockVisitor.h deleted file mode 100644 index 12a9265f3..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/SetForcingBlockVisitor.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef SetForcingBlockVisitor_h -#define SetForcingBlockVisitor_h - -#include "Block3DVisitor.h" -#include "LBMKernel.h" - -class Block3D; -class Grid3D; - -//! \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). -//! \author K. Kucher -class SetForcingBlockVisitor : public Block3DVisitor -{ -public: - SetForcingBlockVisitor(LBMReal forcingX1, LBMReal forcingX2, LBMReal forcingX3); - - SetForcingBlockVisitor(const mu::Parser& muForcingX1, const mu::Parser& muForcingX2, const mu::Parser& muForcingX3); - - SetForcingBlockVisitor(const std::string& sForcingX1, const std::string& sForcingX2, const std::string& sForcingX3); - - virtual ~SetForcingBlockVisitor() {} - - virtual void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; - -private: - int ftype; - LBMReal forcingX1; - LBMReal forcingX2; - LBMReal forcingX3; - mu::Parser muForcingX1; - mu::Parser muForcingX2; - mu::Parser muForcingX3; - std::string sForcingX1; - std::string sForcingX2; - std::string sForcingX3; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetInterpolationDirsBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/SetInterpolationDirsBlockVisitor.cpp deleted file mode 100644 index f98126956..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/SetInterpolationDirsBlockVisitor.cpp +++ /dev/null @@ -1,162 +0,0 @@ -#include "SetInterpolationDirsBlockVisitor.h" -#include "Grid3DSystem.h" -#include <D3Q27System.h> -#include "Grid3D.h" -#include "Block3D.h" - - -SetInterpolationDirsBlockVisitor::SetInterpolationDirsBlockVisitor(std::vector<int>& dirs) : - Block3DVisitor(0, Grid3DSystem::MAXLEVEL), dirs(dirs) -{ - -} -////////////////////////////////////////////////////////////////////////// -void SetInterpolationDirsBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - int ix1, ix2, ix3, level; - ix1 = block->getX1(); - ix2 = block->getX2(); - ix3 = block->getX3(); - level = block->getLevel(); - using namespace D3Q27System; - if(level==0) return; - - SPtr<Block3D> parentblock = grid->getSuperBlock(ix1,ix2,ix3,level); - if(!parentblock) return; - - for(int dir : dirs) - { - SPtr<Block3D> nblock = grid->getNeighborBlock(dir, ix1, ix2, ix3, level); - if(!nblock) - { - SPtr<Block3D> p_nblock = grid->getNeighborBlock(dir, parentblock); - - if (p_nblock) - { - bool flagDir; - switch (dir) - { - case NE: - checkFlagDir(grid, E, N, flagDir, ix1, ix2, ix3, level); - if(!flagDir) continue; - break; - case SW: - checkFlagDir(grid, W, S, flagDir, ix1, ix2, ix3, level); - if(!flagDir) continue; - break; - case SE: - checkFlagDir(grid, E, S, flagDir, ix1, ix2, ix3, level); - if(!flagDir) continue; - break; - case NW: - checkFlagDir(grid, W, N, flagDir, ix1, ix2, ix3, level); - if(!flagDir) continue; - break; - case TE: - checkFlagDir(grid, E, T, flagDir, ix1, ix2, ix3, level); - if(!flagDir)continue; - break; - case BW: - checkFlagDir(grid, W, B, flagDir, ix1, ix2, ix3, level); - if(!flagDir) continue; - break; - case BE: - checkFlagDir(grid, E, B, flagDir, ix1, ix2, ix3, level); - if(!flagDir) continue; - break; - case TW: - checkFlagDir(grid, W, T, flagDir, ix1, ix2, ix3, level); - if(!flagDir) continue; - break; - case TN: - checkFlagDir(grid, N, T, flagDir, ix1, ix2, ix3, level); - if(!flagDir) continue; - break; - case BS: - checkFlagDir(grid, S, B, flagDir, ix1, ix2, ix3, level); - if(!flagDir) continue; - break; - case BN: - checkFlagDir(grid, N, B, flagDir, ix1, ix2, ix3, level); - if(!flagDir) continue; - break; - case TS: - checkFlagDir(grid, S, T, flagDir, ix1, ix2, ix3, level); - if(!flagDir) continue; - break; - case TNE: - checkFlagDir(grid, E, N, T, flagDir, ix1, ix2, ix3, level); - if (!flagDir) continue; - break; - case TSW: - checkFlagDir(grid, W, S, T, flagDir, ix1, ix2, ix3, level); - if (!flagDir) continue; - break; - case TSE: - checkFlagDir(grid, E, S, T, flagDir, ix1, ix2, ix3, level); - if (!flagDir) continue; - break; - case TNW: - checkFlagDir(grid, W, N, T, flagDir, ix1, ix2, ix3, level); - if (!flagDir) continue; - break; - case BNE: - checkFlagDir(grid, E, N, B, flagDir, ix1, ix2, ix3, level); - if (!flagDir) continue; - break; - case BSW: - checkFlagDir(grid, W, S, B, flagDir, ix1, ix2, ix3, level); - if (!flagDir) continue; - break; - case BSE: - checkFlagDir(grid, E, S, B, flagDir, ix1, ix2, ix3, level); - if (!flagDir) continue; - break; - case BNW: - checkFlagDir(grid, W, N, B, flagDir, ix1, ix2, ix3, level); - if (!flagDir) continue; - break; - } - - block->setInterpolationFlagFC(dir); - parentblock->setInterpolationFlagCF(dir); - } - } - } -} -////////////////////////////////////////////////////////////////////////// -//void SetInterpolationDirsBlockVisitor::checkFlagDir(SPtr<Grid3D> grid, int dir1, int dir2, bool &flagDirection, int ix1, int ix2, int ix3, int level) -//{ -// SPtr<Block3D> block1 = grid->getNeighborBlock(dir1, ix1, ix2, ix3, level); -// SPtr<Block3D> block2 = grid->getNeighborBlock(dir2, ix1, ix2, ix3, level); -// if (!((block1 && block2) || (!block1 && !block2))) -// flagDirection = false; -// else -// flagDirection = true; -//} - -void SetInterpolationDirsBlockVisitor::checkFlagDir(SPtr<Grid3D> grid, int dir1, int dir2, bool &flagDirection, int ix1, int ix2, int ix3, int level) -{ - SPtr<Block3D> block1 = grid->getNeighborBlock(dir1, ix1, ix2, ix3, level); - SPtr<Block3D> block2 = grid->getNeighborBlock(dir2, ix1, ix2, ix3, level); - - SPtr<Block3D> pblock = grid->getSuperBlock(ix1,ix2,ix3,level); - SPtr<Block3D> pblock1 = grid->getNeighborBlock(dir1, pblock); - SPtr<Block3D> pblock2 = grid->getNeighborBlock(dir2, pblock); - - if (!((block1 && block2)||(!block1 && !block2)) || !((pblock1 && pblock2)||(!pblock1 && !pblock2))) - flagDirection = false; - else - flagDirection = true; -} -////////////////////////////////////////////////////////////////////////// -void SetInterpolationDirsBlockVisitor::checkFlagDir(SPtr<Grid3D> grid, int dir1, int dir2, int dir3, bool &flagDirection, int ix1, int ix2, int ix3, int level) -{ - SPtr<Block3D> block1 = grid->getNeighborBlock(dir1, ix1, ix2, ix3, level); - SPtr<Block3D> block2 = grid->getNeighborBlock(dir2, ix1, ix2, ix3, level); - SPtr<Block3D> block3 = grid->getNeighborBlock(dir3, ix1, ix2, ix3, level); - if (!((block1 && block2 && block3) || (!block1 && !block2 && !block3))) - flagDirection=false; - else - flagDirection=true; -} diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetInterpolationDirsBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/SetInterpolationDirsBlockVisitor.h deleted file mode 100644 index 7519f9057..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/SetInterpolationDirsBlockVisitor.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef SetInterpolationDirsBlockVisitor_h -#define SetInterpolationDirsBlockVisitor_h - -#include <vector> -#include <PointerDefinitions.h> - -#include "Block3DVisitor.h" - -class Grid3D; -class Block3D; - -class SetInterpolationDirsBlockVisitor : public Block3DVisitor -{ -public: - SetInterpolationDirsBlockVisitor(std::vector<int>& dirs); - - virtual ~SetInterpolationDirsBlockVisitor() {} - - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; - -private: - std::vector<int> dirs; - void checkFlagDir(SPtr<Grid3D> grid, int dir1, int dir2, bool &flagDirection, int ix1, int ix2, int ix3, int level); - void checkFlagDir(SPtr<Grid3D> grid, int dir1, int dir2, int dir3, bool &flagDirection, int ix1, int ix2, int ix3, int level); -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetKernelBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/SetKernelBlockVisitor.cpp index a2987ee43..494e62781 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/SetKernelBlockVisitor.cpp +++ b/src/cpu/VirtualFluidsCore/Visitors/SetKernelBlockVisitor.cpp @@ -1,77 +1,107 @@ -#include "SetKernelBlockVisitor.h" -#include "Grid3DSystem.h" -#include "LBMSystem.h" -#include "DataSet3D.h" -#include "BCProcessor.h" -#include "Grid3D.h" -#include "Block3D.h" -#include "LBMKernel.h" - -////////////////////////////////////////////////////////////////////////// -SetKernelBlockVisitor::SetKernelBlockVisitor(SPtr<LBMKernel> kernel, LBMReal nue, double availMem, double needMem, SetKernelBlockVisitor::Action action) : Block3DVisitor(0, Grid3DSystem::MAXLEVEL), kernel(kernel), nue(nue), action(action), dataSetFlag(true) -{ - if (needMem > availMem) - { - throw UbException(UB_EXARGS, "SetKernelBlockVisitor: Not enough memory!!!"); - } -} -////////////////////////////////////////////////////////////////////////// -void SetKernelBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - if(kernel && (block->getRank() == grid->getRank())) - { - LBMReal collFactor = LBMSystem::calcCollisionFactor(nue, block->getLevel()); - kernel->setCollisionFactor(collFactor); - kernel->setIndex(block->getX1(), block->getX2(), block->getX3()); - kernel->setDeltaT(LBMSystem::getDeltaT(block->getLevel())); - kernel->setBlock(block); - UbTupleInt3 blockNX = grid->getBlockNX(); - kernel->setNX(std::array<int,3>{{val<1>(blockNX), val<2>(blockNX), val<3>(blockNX)}}); - SPtr<LBMKernel> newKernel = kernel->clone(); - - switch (action) - { - case SetKernelBlockVisitor::NewKernel: - block->setKernel(newKernel); - break; - case SetKernelBlockVisitor::ChangeKernel: - { - SPtr<DataSet3D> dataSet = block->getKernel()->getDataSet(); - if (!dataSet) - { - UB_THROW(UbException(UB_EXARGS, "It is not possible to change a DataSet in kernel! Old DataSet is not exist!")); - } - - newKernel->setDataSet(dataSet); - - SPtr<BCProcessor> bcProc = block->getKernel()->getBCProcessor(); - if (!bcProc) - { - UB_THROW(UbException(UB_EXARGS, "It is not possible to change a BCProcessor in kernel! Old BCProcessor is not exist!")); - } - newKernel->setBCProcessor(bcProc); - block->setKernel(newKernel); - } - break; - - case SetKernelBlockVisitor::ChangeKernelWithData: - { - SPtr<BCProcessor> bcProc = block->getKernel()->getBCProcessor(); - if (!bcProc) - { - UB_THROW(UbException(UB_EXARGS, "It is not possible to change a BCProcessor in kernel! Old BCProcessor is not exist!")); - } - newKernel->setBCProcessor(bcProc); - block->setKernel(newKernel); - } - break; - } - - } -} - -void SetKernelBlockVisitor::setNoDataSetFlag(bool flag) -{ - dataSetFlag = flag; -} - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file SetKernelBlockVisitor.cpp +//! \ingroup Visitors +//! \author Konstantin Kutscher +//======================================================================================= + +#include "SetKernelBlockVisitor.h" +#include "Grid3DSystem.h" +#include "LBMSystem.h" +#include "DataSet3D.h" +#include "BCProcessor.h" +#include "Grid3D.h" +#include "Block3D.h" +#include "LBMKernel.h" + +////////////////////////////////////////////////////////////////////////// +SetKernelBlockVisitor::SetKernelBlockVisitor(SPtr<LBMKernel> kernel, LBMReal nue, SetKernelBlockVisitor::Action action) : Block3DVisitor(0, Grid3DSystem::MAXLEVEL), kernel(kernel), nue(nue), action(action), dataSetFlag(true) +{ + +} +////////////////////////////////////////////////////////////////////////// +void SetKernelBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) +{ + if(kernel && (block->getRank() == grid->getRank())) + { + LBMReal collFactor = LBMSystem::calcCollisionFactor(nue, block->getLevel()); + kernel->setCollisionFactor(collFactor); + kernel->setIndex(block->getX1(), block->getX2(), block->getX3()); + kernel->setDeltaT(LBMSystem::getDeltaT(block->getLevel())); + kernel->setBlock(block); + UbTupleInt3 blockNX = grid->getBlockNX(); + kernel->setNX(std::array<int,3>{{val<1>(blockNX), val<2>(blockNX), val<3>(blockNX)}}); + SPtr<LBMKernel> newKernel = kernel->clone(); + + switch (action) + { + case SetKernelBlockVisitor::NewKernel: + block->setKernel(newKernel); + break; + case SetKernelBlockVisitor::ChangeKernel: + { + SPtr<DataSet3D> dataSet = block->getKernel()->getDataSet(); + if (!dataSet) + { + UB_THROW(UbException(UB_EXARGS, "It is not possible to change a DataSet in kernel! Old DataSet is not exist!")); + } + + newKernel->setDataSet(dataSet); + + SPtr<BCProcessor> bcProc = block->getKernel()->getBCProcessor(); + if (!bcProc) + { + UB_THROW(UbException(UB_EXARGS, "It is not possible to change a BCProcessor in kernel! Old BCProcessor is not exist!")); + } + newKernel->setBCProcessor(bcProc); + block->setKernel(newKernel); + } + break; + + case SetKernelBlockVisitor::ChangeKernelWithData: + { + SPtr<BCProcessor> bcProc = block->getKernel()->getBCProcessor(); + if (!bcProc) + { + UB_THROW(UbException(UB_EXARGS, "It is not possible to change a BCProcessor in kernel! Old BCProcessor is not exist!")); + } + newKernel->setBCProcessor(bcProc); + block->setKernel(newKernel); + } + break; + } + + } +} + +void SetKernelBlockVisitor::setNoDataSetFlag(bool flag) +{ + dataSetFlag = flag; +} + diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetKernelBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/SetKernelBlockVisitor.h index 0d5a2cbc9..42778ae1a 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/SetKernelBlockVisitor.h +++ b/src/cpu/VirtualFluidsCore/Visitors/SetKernelBlockVisitor.h @@ -1,36 +1,66 @@ -#ifndef SetKernelBlockVisitor_h -#define SetKernelBlockVisitor_h - -#include <PointerDefinitions.h> - -#include "Block3DVisitor.h" -#include "LBMSystem.h" - -class Grid3D; -class Block3D; -class LBMKernel; - -class SetKernelBlockVisitor : public Block3DVisitor -{ -public: - enum Action { NewKernel, ChangeKernel, ChangeKernelWithData}; - - //SetKernelBlockVisitor(LBMKernel3DPtr kernel, LBMReal nue); - - //SetKernelBlockVisitor(LBMKernel3DPtr kernel, LBMReal nue, double availMem, double needMem); - - SetKernelBlockVisitor(SPtr<LBMKernel> kernel, LBMReal nue, double availMem, double needMem, SetKernelBlockVisitor::Action action = SetKernelBlockVisitor::NewKernel); - virtual ~SetKernelBlockVisitor() {} - - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; - - void setNoDataSetFlag(bool flag); - -private: - SPtr<LBMKernel> kernel; - LBMReal nue; - Action action; - bool dataSetFlag; -}; - -#endif +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file SetKernelBlockVisitor.cpp +//! \ingroup Visitors +//! \author Konstantin Kutscher +//======================================================================================= + +#ifndef SetKernelBlockVisitor_h +#define SetKernelBlockVisitor_h + +#include <PointerDefinitions.h> + +#include "Block3DVisitor.h" +#include "LBMSystem.h" + +class Grid3D; +class Block3D; +class LBMKernel; + +//! \brief A class generates new LBMKernel and associates it with a block. +class SetKernelBlockVisitor : public Block3DVisitor +{ +public: + enum Action { NewKernel, ChangeKernel, ChangeKernelWithData}; + + SetKernelBlockVisitor(SPtr<LBMKernel> kernel, LBMReal nue, SetKernelBlockVisitor::Action action = SetKernelBlockVisitor::NewKernel); + virtual ~SetKernelBlockVisitor() {} + + void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; + + void setNoDataSetFlag(bool flag); + +private: + SPtr<LBMKernel> kernel; + LBMReal nue; + Action action; + bool dataSetFlag; +}; + +#endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetSolidBlocksBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/SetSolidBlocksBlockVisitor.cpp index 7c9342f1c..472d53dee 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/SetSolidBlocksBlockVisitor.cpp +++ b/src/cpu/VirtualFluidsCore/Visitors/SetSolidBlocksBlockVisitor.cpp @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file SetSolidBlocksBlockVisitor.cpp +//! \ingroup Visitors +//! \author Konstantin Kutscher +//======================================================================================= + #include "SetSolidBlocksBlockVisitor.h" #include "Interactor3D.h" diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetSolidBlocksBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/SetSolidBlocksBlockVisitor.h index 1f3d54912..cfac49c75 100644 --- a/src/cpu/VirtualFluidsCore/Visitors/SetSolidBlocksBlockVisitor.h +++ b/src/cpu/VirtualFluidsCore/Visitors/SetSolidBlocksBlockVisitor.h @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ \ +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file SetSolidBlocksBlockVisitor.h +//! \ingroup Visitors +//! \author Konstantin Kutscher +//======================================================================================= + #ifndef SetSolidBlocksBlockVisitor_h__ #define SetSolidBlocksBlockVisitor_h__ @@ -9,6 +42,7 @@ class Grid3D; class Block3D; class Interactor3D; +//! \brief A class sets blocks with solid nodes in Interactor3D object. class SetSolidBlocksBlockVisitor : public Block3DVisitor { public: diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetSpongeLayerBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/SetSpongeLayerBlockVisitor.cpp deleted file mode 100644 index b94958688..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/SetSpongeLayerBlockVisitor.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "SetSpongeLayerBlockVisitor.h" -#include "Grid3DSystem.h" -#include "LBMSystem.h" - -#include "LBMKernel.h" -#include "Grid3D.h" -#include "Block3D.h" - -SetSpongeLayerBlockVisitor::SetSpongeLayerBlockVisitor( const mu::Parser& spongeLayer ) : Block3DVisitor(0, Grid3DSystem::MAXLEVEL), spongeLayer(spongeLayer) -{ - -} -////////////////////////////////////////////////////////////////////////// -SetSpongeLayerBlockVisitor::~SetSpongeLayerBlockVisitor() -{ - -} -////////////////////////////////////////////////////////////////////////// -void SetSpongeLayerBlockVisitor::visit( SPtr<Grid3D> grid, SPtr<Block3D> block ) -{ - if(block->getRank() == grid->getRank()) - { - SPtr<LBMKernel> kernel = dynamicPointerCast<LBMKernel>(block->getKernel()); - if (!kernel) - throw std::runtime_error("SetSpongeLayerBlockVisitor: Kernel is not a LBMKernel"); - kernel->setWithSpongeLayer(true); - kernel->setSpongeLayer(spongeLayer); - } -} - - diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetSpongeLayerBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/SetSpongeLayerBlockVisitor.h deleted file mode 100644 index 92fce3f5a..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/SetSpongeLayerBlockVisitor.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef SetSpongeLayerBlockVisitor_h__ -#define SetSpongeLayerBlockVisitor_h__ - -#include <PointerDefinitions.h> - -#include <MuParser/include/muParser.h> - -#include "Block3DVisitor.h" - -class Grid3D; -class Block3D; - -//! \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). -//! \author K. Kucher -class SetSpongeLayerBlockVisitor : public Block3DVisitor -{ -public: - SetSpongeLayerBlockVisitor(const mu::Parser& spongeLayer); - virtual ~SetSpongeLayerBlockVisitor(); - - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; -protected: -private: - mu::Parser spongeLayer; -}; - -#endif // SetSpongeLayerBlockVisitor_h__ diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetUndefinedNodesBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/SetUndefinedNodesBlockVisitor.cpp deleted file mode 100644 index 5f18117d5..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/SetUndefinedNodesBlockVisitor.cpp +++ /dev/null @@ -1,677 +0,0 @@ -#include "SetUndefinedNodesBlockVisitor.h" -#include "BCArray3D.h" -#include "BoundaryConditions.h" -#include "BCProcessor.h" -#include "Grid3DSystem.h" -#include "D3Q27System.h" -#include "BCArray3D.h" -#include "Grid3D.h" -#include "Block3D.h" -#include "ILBMKernel.h" - - -SetUndefinedNodesBlockVisitor::SetUndefinedNodesBlockVisitor(bool twoTypeOfConnectorsCheck) : Block3DVisitor(0, Grid3DSystem::MAXLEVEL), twoTypeOfConnectorsCheck(twoTypeOfConnectorsCheck) -{ - -} -////////////////////////////////////////////////////////////////////////// -void SetUndefinedNodesBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - if(!block->hasInterpolationFlag()) return; - - SPtr<ILBMKernel> kernel = block->getKernel(); - - if(!kernel && (block->getRank() != grid->getRank())) return; - - //width of ghost layer - //int gl = kernel->getGhostLayerWidth(); - int gl = 0; - - SPtr<BCArray3D> bcMatrix = kernel->getBCProcessor()->getBCArray(); - - int minX1 = gl; - int minX2 = gl; - int minX3 = gl; - - int maxX1 = static_cast<int>(bcMatrix->getNX1())-1-gl; - int maxX2 = static_cast<int>(bcMatrix->getNX2())-1-gl; - int maxX3 = static_cast<int>(bcMatrix->getNX3())-1-gl; - - //int offset = 2; - int offset = 3; - - if(block->hasInterpolationFlag(D3Q27System::E)) - { - int startix1 = maxX1; - int endix1 = maxX1; - if(block->hasInterpolationFlagCF()) startix1 = startix1-offset; - int startix2 = minX2; - int endix2 = maxX2; - int startix3 = minX3; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::W)) - { - int startix1 = minX1; - int endix1 = minX1; - if(block->hasInterpolationFlagCF()) endix1 = endix1+offset; - int startix2 = minX2; - int endix2 = maxX2; - int startix3 = minX3; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::N)) - { - int startix1 = minX1; - int endix1 = maxX1; - int startix2 = maxX2; - int endix2 = maxX2; - if(block->hasInterpolationFlagCF()) startix2 = startix2-offset; - int startix3 = minX3; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::S)) - { - int startix1 = minX1; - int endix1 = maxX1; - int startix2 = minX2; - int endix2 = minX2; - if(block->hasInterpolationFlagCF()) endix2 = endix2+offset; - int startix3 = minX3; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::T)) - { - int startix1 = minX1; - int endix1 = maxX1; - int startix2 = minX2; - int endix2 = maxX2; - int startix3 = maxX3; - int endix3 = maxX3; - if(block->hasInterpolationFlagCF()) startix3 = startix3-offset; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::B)) - { - int startix1 = minX1; - int endix1 = maxX1; - int startix2 = minX2; - int endix2 = maxX2; - int startix3 = minX3; - int endix3 = minX3; - if(block->hasInterpolationFlagCF()) endix3 = endix3+offset; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::NE)) - { - int startix1 = maxX1; - int endix1 = maxX1; - if(block->hasInterpolationFlagCF()) startix1 = startix1-offset; - int startix2 = maxX2; - int endix2 = maxX2; - if(block->hasInterpolationFlagCF()) startix2 = startix2-offset; - int startix3 = minX3; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::SW)) - { - int startix1 = minX1; - int endix1 = minX1; - if(block->hasInterpolationFlagCF()) endix1 = endix1+offset; - int startix2 = minX2; - int endix2 = minX2; - if(block->hasInterpolationFlagCF()) endix2 = endix2+offset; - int startix3 = minX3; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::SE)) - { - int startix1 = maxX1; - int endix1 = maxX1; - if(block->hasInterpolationFlagCF()) startix1 = startix1-offset; - int startix2 = minX2; - int endix2 = minX2; - if(block->hasInterpolationFlagCF()) endix2 = endix2+offset; - int startix3 = minX3; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::NW)) - { - int startix1 = minX1; - int endix1 = minX1; - if(block->hasInterpolationFlagCF()) endix1 = endix1+offset; - int startix2 = maxX2; - int endix2 = maxX2; - if(block->hasInterpolationFlagCF()) startix2 = startix2-offset; - int startix3 = minX3; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::TE)) - { - int startix1 = maxX1; - int endix1 = maxX1; - if(block->hasInterpolationFlagCF()) startix1 = startix1-offset; - int startix2 = minX2; - int endix2 = maxX2; - int startix3 = maxX3; - int endix3 = maxX3; - if(block->hasInterpolationFlagCF()) startix3 = startix3-offset; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::BW)) - { - int startix1 = minX1; - int endix1 = minX1; - if(block->hasInterpolationFlagCF()) endix1 = endix1+offset; - int startix2 = minX2; - int endix2 = maxX2; - int startix3 = minX3; - int endix3 = minX3; - if(block->hasInterpolationFlagCF()) endix3 = endix3+offset; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::BE)) - { - int startix1 = maxX1; - int endix1 = maxX1; - if(block->hasInterpolationFlagCF()) startix1 = startix1-offset; - int startix2 = minX2; - int endix2 = maxX2; - int startix3 = minX3; - int endix3 = minX3; - if(block->hasInterpolationFlagCF()) endix3 = endix3+offset; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::TW)) - { - int startix1 = minX1; - int endix1 = minX1; - if(block->hasInterpolationFlagCF()) endix1 = endix1+offset; - int startix2 = minX2; - int endix2 = maxX2; - int startix3 = maxX3; - int endix3 = maxX3; - if(block->hasInterpolationFlagCF()) startix3 = startix3-offset; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::TN)) - { - int startix1 = minX1; - int endix1 = maxX1; - int startix2 = maxX2; - int endix2 = maxX2; - if(block->hasInterpolationFlagCF()) startix2 = startix2-offset; - int startix3 = maxX3; - int endix3 = maxX3; - if(block->hasInterpolationFlagCF()) startix3 = startix3-offset; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::BS)) - { - int startix1 = minX1; - int endix1 = maxX1; - int startix2 = minX2; - int endix2 = minX2; - if(block->hasInterpolationFlagCF()) endix2 = endix2+offset; - int startix3 = minX3; - int endix3 = minX3; - if(block->hasInterpolationFlagCF()) endix3 = endix3+offset; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::BN)) - { - int startix1 = minX1; - int endix1 = maxX1; - int startix2 = maxX2; - int endix2 = maxX2; - if(block->hasInterpolationFlagCF()) startix2 = startix2-offset; - int startix3 = minX3; - int endix3 = minX3; - if(block->hasInterpolationFlagCF()) endix3 = endix3+offset; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::TS)) - { - int startix1 = minX1; - int endix1 = maxX1; - int startix2 = minX2; - int endix2 = minX2; - if(block->hasInterpolationFlagCF()) endix2 = endix2+offset; - int startix3 = maxX3; - int endix3 = maxX3; - if(block->hasInterpolationFlagCF()) startix3 = startix3-offset; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::TNE)) - { - int startix1 = maxX1; - int endix1 = maxX1; - if(block->hasInterpolationFlagCF()) startix1 = startix1-offset; - int startix2 = maxX2; - int endix2 = maxX2; - if(block->hasInterpolationFlagCF()) startix2 = startix2-offset; - int startix3 = maxX3; - int endix3 = maxX3; - if(block->hasInterpolationFlagCF()) startix3 = startix3-offset; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::TNW)) - { - int startix1 = minX1; - int endix1 = minX1; - if(block->hasInterpolationFlagCF()) endix1 = endix1+offset; - int startix2 = maxX2; - int endix2 = maxX2; - if(block->hasInterpolationFlagCF()) startix2 = startix2-offset; - int startix3 = maxX3; - int endix3 = maxX3; - if(block->hasInterpolationFlagCF()) startix3 = startix3-offset; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::TSE)) - { - int startix1 = maxX1; - int endix1 = maxX1; - if(block->hasInterpolationFlagCF()) startix1 = startix1-offset; - int startix2 = minX2; - int endix2 = minX2; - if(block->hasInterpolationFlagCF()) endix2 = endix2+offset; - int startix3 = maxX3; - int endix3 = maxX3; - if(block->hasInterpolationFlagCF()) startix3 = startix3-offset; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::TSW)) - { - int startix1 = minX1; - int endix1 = minX1; - if(block->hasInterpolationFlagCF()) endix1 = endix1+offset; - int startix2 = minX2; - int endix2 = minX2; - if(block->hasInterpolationFlagCF()) endix2 = endix2+offset; - int startix3 = maxX3; - int endix3 = maxX3; - if(block->hasInterpolationFlagCF()) startix3 = startix3-offset; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::BNE)) - { - int startix1 = maxX1; - int endix1 = maxX1; - if(block->hasInterpolationFlagCF()) startix1 = startix1-offset; - int startix2 = maxX2; - int endix2 = maxX2; - if(block->hasInterpolationFlagCF()) startix2 = startix2-offset; - int startix3 = minX3; - int endix3 = minX3; - if(block->hasInterpolationFlagCF()) endix3 = endix3+offset; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::BNW)) - { - int startix1 = minX1; - int endix1 = minX1; - if(block->hasInterpolationFlagCF()) endix1 = endix1+offset; - int startix2 = maxX2; - int endix2 = maxX2; - if(block->hasInterpolationFlagCF()) startix2 = startix2-offset; - int startix3 = minX3; - int endix3 = minX3; - if(block->hasInterpolationFlagCF()) endix3 = endix3+offset; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::BSE)) - { - int startix1 = maxX1; - int endix1 = maxX1; - if(block->hasInterpolationFlagCF()) startix1 = startix1-offset; - int startix2 = minX2; - int endix2 = minX2; - if(block->hasInterpolationFlagCF()) endix2 = endix2+offset; - int startix3 = minX3; - int endix3 = minX3; - if(block->hasInterpolationFlagCF()) endix3 = endix3+offset; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlag(D3Q27System::BSW)) - { - int startix1 = minX1; - int endix1 = minX1; - if(block->hasInterpolationFlagCF()) endix1 = endix1+offset; - int startix2 = minX2; - int endix2 = minX2; - if(block->hasInterpolationFlagCF()) endix2 = endix2+offset; - int startix3 = minX3; - int endix3 = minX3; - if(block->hasInterpolationFlagCF()) endix3 = endix3+offset; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - - - - ////////////////////////////////////////////////////////////////////////// - int offset2 = 1; - int ll = 0; - - minX1 = ll; - minX2 = ll; - minX3 = ll; - - maxX1 = static_cast<int>(bcMatrix->getNX1())-1-ll; - maxX2 = static_cast<int>(bcMatrix->getNX2())-1-ll; - maxX3 = static_cast<int>(bcMatrix->getNX3())-1-ll; - - if(block->hasInterpolationFlagFC(D3Q27System::E)) - { - int startix1 = maxX1-offset2; - int endix1 = maxX1; - int startix2 = minX2; - int endix2 = maxX2; - int startix3 = minX3; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::W)) - { - int startix1 = minX1; - int endix1 = minX1+offset2; - int startix2 = minX2; - int endix2 = maxX2; - int startix3 = minX3; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::N)) - { - int startix1 = minX1; - int endix1 = maxX1; - int startix2 = maxX2-offset2; - int endix2 = maxX2; - int startix3 = minX3; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::S)) - { - int startix1 = minX1; - int endix1 = maxX1; - int startix2 = minX2; - int endix2 = minX2+offset2; - int startix3 = minX3; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::T)) - { - int startix1 = minX1; - int endix1 = maxX1; - int startix2 = minX2; - int endix2 = maxX2; - int startix3 = maxX3-offset2; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::B)) - { - int startix1 = minX1; - int endix1 = maxX1; - int startix2 = minX2; - int endix2 = maxX2; - int startix3 = minX3; - int endix3 = minX3+offset2; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::NE)) - { - int startix1 = maxX1-offset2; - int endix1 = maxX1; - int startix2 = maxX2-offset2; - int endix2 = maxX2; - int startix3 = minX3; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::SW)) - { - int startix1 = minX1; - int endix1 = minX1+offset2; - int startix2 = minX2; - int endix2 = minX2+offset2; - int startix3 = minX3; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::SE)) - { - int startix1 = maxX1-offset2; - int endix1 = maxX1; - int startix2 = minX2; - int endix2 = minX2+offset2; - int startix3 = minX3; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::NW)) - { - int startix1 = minX1; - int endix1 = minX1+offset2; - int startix2 = maxX2-offset2; - int endix2 = maxX2; - int startix3 = minX3; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::TE)) - { - int startix1 = maxX1-offset2; - int endix1 = maxX1; - int startix2 = minX2; - int endix2 = maxX2; - int startix3 = maxX3-offset2; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::BW)) - { - int startix1 = minX1; - int endix1 = minX1+offset2; - int startix2 = minX2; - int endix2 = maxX2; - int startix3 = minX3; - int endix3 = minX3+offset2; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::BE)) - { - int startix1 = maxX1-offset2; - int endix1 = maxX1; - int startix2 = minX2; - int endix2 = maxX2; - int startix3 = minX3; - int endix3 = minX3+offset2; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::TW)) - { - int startix1 = minX1; - int endix1 = minX1+offset2; - int startix2 = minX2; - int endix2 = maxX2; - int startix3 = maxX3-offset2; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::TN)) - { - int startix1 = minX1; - int endix1 = maxX1; - int startix2 = maxX2-offset2; - int endix2 = maxX2; - int startix3 = maxX3-offset2; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::BS)) - { - int startix1 = minX1; - int endix1 = maxX1; - int startix2 = minX2; - int endix2 = minX2+offset2; - int startix3 = minX3; - int endix3 = minX3+offset2; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::BN)) - { - int startix1 = minX1; - int endix1 = maxX1; - int startix2 = maxX2-offset2; - int endix2 = maxX2; - int startix3 = minX3; - int endix3 = minX3+offset2; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::TS)) - { - int startix1 = minX1; - int endix1 = maxX1; - int startix2 = minX2; - int endix2 = minX2+offset2; - int startix3 = maxX3-offset2; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::TNE)) - { - int startix1 = maxX1-offset2; - int endix1 = maxX1; - int startix2 = maxX2-offset2; - int endix2 = maxX2; - int startix3 = maxX3-offset2; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::TNW)) - { - int startix1 = minX1; - int endix1 = minX1+offset2; - int startix2 = maxX2-offset2; - int endix2 = maxX2; - int startix3 = maxX3-offset2; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::TSE)) - { - int startix1 = maxX1-offset2; - int endix1 = maxX1; - int startix2 = minX2; - int endix2 = minX2+offset2; - int startix3 = maxX3-offset2; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::TSW)) - { - int startix1 = minX1; - int endix1 = minX1+offset2; - int startix2 = minX2; - int endix2 = minX2+offset2; - int startix3 = maxX3-offset2; - int endix3 = maxX3; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::BNE)) - { - int startix1 = maxX1-offset2; - int endix1 = maxX1; - int startix2 = maxX2-offset2; - int endix2 = maxX2; - int startix3 = minX3; - int endix3 = minX3+offset2; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::BNW)) - { - int startix1 = minX1; - int endix1 = minX1+offset2; - int startix2 = maxX2-offset2; - int endix2 = maxX2; - int startix3 = minX3; - int endix3 = minX3+offset2; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::BSE)) - { - int startix1 = maxX1-offset2; - int endix1 = maxX1; - int startix2 = minX2; - int endix2 = minX2+offset2; - int startix3 = minX3; - int endix3 = minX3+offset2; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - if(block->hasInterpolationFlagFC(D3Q27System::BSW)) - { - int startix1 = minX1; - int endix1 = minX1+offset2; - int startix2 = minX2; - int endix2 = minX2+offset2; - int startix3 = minX3; - int endix3 = minX3+offset2; - this->setNodesUndefined(startix1, endix1, startix2, endix2, startix3, endix3, bcMatrix); - } - - //invert scaleCF blocks - if(block->hasInterpolationFlagCF()) - { - if(block->hasInterpolationFlagFC() && twoTypeOfConnectorsCheck) - { - for (int i = D3Q27System::E; i <= D3Q27System::BSW; i++) - { - UBLOG(logINFO, "FC in dir="<<i<<" "<<block->hasInterpolationFlagFC(i)); - } - for (int i = D3Q27System::E; i<=D3Q27System::BSW; i++) - { - UBLOG(logINFO, "CF in dir="<<i<<" "<<block->hasInterpolationFlagCF(i)); - } - throw UbException(UB_EXARGS, "block "+block->toString()+" has CF and FC"); - } - - minX1 = gl; - minX2 = gl; - minX3 = gl; - - maxX1 = static_cast<int>(bcMatrix->getNX1())-1-gl; - maxX2 = static_cast<int>(bcMatrix->getNX2())-1-gl; - maxX3 = static_cast<int>(bcMatrix->getNX3())-1-gl; - - for (int ix3=minX3; ix3<=maxX3; ix3++) - for (int ix2=minX2; ix2<=maxX2; ix2++) - for (int ix1=minX1; ix1<=maxX1; ix1++) - { - if(bcMatrix->isUndefined(ix1, ix2, ix3)) bcMatrix->setFluid(ix1, ix2, ix3); - else bcMatrix->setUndefined(ix1, ix2, ix3); - } - return; - } - -} -////////////////////////////////////////////////////////////////////////// -void SetUndefinedNodesBlockVisitor::setNodesUndefined( int startix1, int endix1, int startix2, int endix2, int startix3, int endix3, SPtr<BCArray3D> bcMatrix ) -{ - for (int ix3=startix3; ix3<=endix3; ix3++) - for (int ix2=startix2; ix2<=endix2; ix2++) - for (int ix1=startix1; ix1<=endix1; ix1++) - { - bcMatrix->setUndefined(ix1, ix2, ix3); - } -} diff --git a/src/cpu/VirtualFluidsCore/Visitors/SetUndefinedNodesBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/SetUndefinedNodesBlockVisitor.h deleted file mode 100644 index 9c47ca3e9..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/SetUndefinedNodesBlockVisitor.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef SetUndefinedNodesBlockVisitor_h -#define SetUndefinedNodesBlockVisitor_h - -#include <PointerDefinitions.h> - -#include "Block3DVisitor.h" - -class Grid3D; -class Block3D; -class BCArray3D; - -class SetUndefinedNodesBlockVisitor : public Block3DVisitor -{ -public: - SetUndefinedNodesBlockVisitor(bool twoTypeOfConnectorsCheck=true); - - virtual ~SetUndefinedNodesBlockVisitor() {} - - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; -protected: - void setNodesUndefined( int startix1, int endix1, int startix2, int endix2, int startix3, int endix3, SPtr<BCArray3D> bcMatix ); -private: - bool twoTypeOfConnectorsCheck; - -}; -#endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.cpp deleted file mode 100644 index 4bbea1fd8..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.cpp +++ /dev/null @@ -1,123 +0,0 @@ -#include "SpongeLayerBlockVisitor.h" -#include "Grid3DSystem.h" -#include "LBMSystem.h" - -#include "Grid3D.h" -#include "Block3D.h" -#include "LBMKernel.h" -#include "UbException.h" -#include "D3Q27System.h" -#include "BCArray3D.h" -#include "BCProcessor.h" -#include <numerics/geometry3d/GbCuboid3D.h> - -using namespace std; - -SpongeLayerBlockVisitor::SpongeLayerBlockVisitor(SPtr<GbCuboid3D> boundingBox, SPtr<LBMKernel> kernel, double nue, int dir) : - Block3DVisitor(0, Grid3DSystem::MAXLEVEL), - boundingBox(boundingBox), - kernel(kernel), - nue(nue), - dir(dir) -{ - -} -////////////////////////////////////////////////////////////////////////// -SpongeLayerBlockVisitor::~SpongeLayerBlockVisitor() -{ - -} -////////////////////////////////////////////////////////////////////////// -void SpongeLayerBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - if (!boundingBox) - { - UB_THROW(UbException(UB_EXARGS, "The bounding box isn't set!")); - } - if (!kernel) - { - UB_THROW(UbException(UB_EXARGS, "The kernel isn't set!")); - } - if (kernel && (block->getRank() == grid->getRank())) - { - UbTupleDouble3 org = grid->getBlockWorldCoordinates(block); - UbTupleDouble3 blockLengths = grid->getBlockLengths(block); - - double minX1 = val<1>(org); - double minX2 = val<2>(org); - double minX3 = val<3>(org); - double maxX1 = val<1>(org)+val<1>(blockLengths); - double maxX2 = val<2>(org)+val<2>(blockLengths); - double maxX3 = val<3>(org)+val<3>(blockLengths); - - if (boundingBox->isCellInsideGbObject3D(minX1, minX2, minX3, maxX1, maxX2, maxX3)) - { - LBMReal collFactor = LBMSystem::calcCollisionFactor(nue, block->getLevel()); - kernel->setCollisionFactor(collFactor); - kernel->setIndex(block->getX1(), block->getX2(), block->getX3()); - kernel->setDeltaT(LBMSystem::getDeltaT(block->getLevel())); - kernel->setBlock(block); - SPtr<LBMKernel> newKernel = kernel->clone(); - - SPtr<DataSet3D> dataSet = block->getKernel()->getDataSet(); - if (!dataSet) - { - UB_THROW(UbException(UB_EXARGS, "It is not possible to change a DataSet in kernel! Old DataSet is not exist!")); - } - - newKernel->setDataSet(dataSet); - - SPtr<BCProcessor> bcProc = block->getKernel()->getBCProcessor(); - if (!bcProc) - { - UB_THROW(UbException(UB_EXARGS, "It is not possible to change a BCProcessor in kernel! Old BCProcessor is not exist!")); - } - newKernel->setBCProcessor(bcProc); - - double oldCollFactor = newKernel->getCollisionFactor(); - - - UbTupleInt3 ixMin = grid->getBlockIndexes(boundingBox->getX1Minimum(),boundingBox->getX2Minimum(),boundingBox->getX3Minimum()); - UbTupleInt3 ixMax = grid->getBlockIndexes(boundingBox->getX1Maximum(),boundingBox->getX2Maximum(),boundingBox->getX3Maximum()); - - double newCollFactor; - - if (dir == D3Q27System::E) - { - int ibX1 = block->getX1(); - int ibMax = val<1>(ixMax)-val<1>(ixMin)+1; - double index = (double)(ibX1-val<1>(ixMin)+1); - newCollFactor = oldCollFactor - (oldCollFactor-1.0)/(double)(ibMax)*index; - } - else if (dir == D3Q27System::W) - { - int ibX1 = block->getX1(); - int ibMax = val<1>(ixMax)-val<1>(ixMin)+1; - double index = (double)(ibX1-val<1>(ixMin)+1); - newCollFactor = (oldCollFactor-1.0)/(double)(ibMax)*index; - } - else if (dir == D3Q27System::T) - { - int ibX3 = block->getX3(); - int ibMax = val<3>(ixMax)-val<3>(ixMin)+1; - double index = (double)(ibX3-val<3>(ixMin)+1); - newCollFactor = oldCollFactor - (oldCollFactor-1.0)/(double)(ibMax)*index; - } - else if (dir == D3Q27System::B) - { - int ibX3 = block->getX3(); - int ibMax = val<3>(ixMax)-val<3>(ixMin)+1; - double index = (double)(ibX3-val<3>(ixMin)+1); - newCollFactor = (oldCollFactor-1.0)/(double)(ibMax)*index; - } - - - newKernel->setCollisionFactor(newCollFactor); - block->setKernel(newKernel); - } - } -} -////////////////////////////////////////////////////////////////////////// - - - diff --git a/src/cpu/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.h deleted file mode 100644 index ec6fbde2d..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/SpongeLayerBlockVisitor.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef SpongeLayerBlockVisitor_h__ -#define SpongeLayerBlockVisitor_h__ - -#include "Block3DVisitor.h" -#include "D3Q27System.h" - -class Grid3D; -class Block3D; -class GbCuboid3D; -class LBMKernel; - -//! \brief Set sponge layer for all blocks inside boundingBox -//! \details This visitor sets viscosity gradient inside bounding box. -//! \author K. Kutscher -class SpongeLayerBlockVisitor : public Block3DVisitor -{ -public: - SpongeLayerBlockVisitor(SPtr<GbCuboid3D> boundingBox, SPtr<LBMKernel> kernel, double nue, int dir); - virtual ~SpongeLayerBlockVisitor(); - - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; - -private: - SPtr<GbCuboid3D> boundingBox; - SPtr<LBMKernel> kernel; - double nue; - int dir; -}; - -#endif // SetSpongeLayerBlockVisitor_h__ diff --git a/src/cpu/VirtualFluidsCore/Visitors/ViscosityBlockVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/ViscosityBlockVisitor.cpp deleted file mode 100644 index e74bb1642..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/ViscosityBlockVisitor.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "ViscosityBlockVisitor.h" -#include "Grid3DSystem.h" -#include "LBMSystem.h" -#include "Block3D.h" -#include "Grid3D.h" -#include "ILBMKernel.h" - -ViscosityBlockVisitor::ViscosityBlockVisitor(LBMReal nu) : -Block3DVisitor(0, Grid3DSystem::MAXLEVEL), nu(nu) -{ - -} -////////////////////////////////////////////////////////////////////////// -void ViscosityBlockVisitor::visit(SPtr<Grid3D> grid, SPtr<Block3D> block) -{ - if (block->getRank() == grid->getRank()) - { - LBMReal collFactor = LBMSystem::calcCollisionFactor(nu, block->getLevel()); - block->getKernel()->setCollisionFactor(collFactor); - } -} - diff --git a/src/cpu/VirtualFluidsCore/Visitors/ViscosityBlockVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/ViscosityBlockVisitor.h deleted file mode 100644 index 1ea9a53d5..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/ViscosityBlockVisitor.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef ViscosityBlockVisitor_h -#define ViscosityBlockVisitor_h - -#include <PointerDefinitions.h> - -#include "Block3DVisitor.h" -#include "LBMSystem.h" - -class Grid3D; -class Block3D; - -class ViscosityBlockVisitor : public Block3DVisitor -{ -public: - ViscosityBlockVisitor(LBMReal nu); - - virtual ~ViscosityBlockVisitor() {} - - void visit(SPtr<Grid3D> grid, SPtr<Block3D> block) override; - -private: - LBMReal nu; -}; - -#endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/ZoltanPartitioningGridVisitor.cpp b/src/cpu/VirtualFluidsCore/Visitors/ZoltanPartitioningGridVisitor.cpp deleted file mode 100644 index 022b9d0ca..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/ZoltanPartitioningGridVisitor.cpp +++ /dev/null @@ -1,148 +0,0 @@ -#if defined VF_ZOLTAN && defined VF_MPI - -#include "ZoltanPartitioningGridVisitor.h" -#include <vector> -#include "UbLogger.h" -#include "UbException.h" -#include "Grid3D.h" -#include "Block3D.h" - -using namespace std; - -ZoltanPartitioningGridVisitor::ZoltanPartitioningGridVisitor(SPtr<Communicator> comm, int numOfDirs, int numOfLocalParts) : -comm(comm), -numOfDirs(numOfDirs), -numOfLocalParts(numOfLocalParts) -{ -} -////////////////////////////////////////////////////////////////////////// -ZoltanPartitioningGridVisitor::~ZoltanPartitioningGridVisitor() -{ - -} -////////////////////////////////////////////////////////////////////////// -void ZoltanPartitioningGridVisitor::visit(SPtr<Grid3D> grid) -{ - UBLOG(logDEBUG5, "ZoltanPartitioningPatchVisitor::visit() - start"); - - //MPI_Comm mpi_comm = *((MPI_Comm*) comm->getNativeCommunicator()); - - //ZoltanPartitioner zp(mpi_comm, comm->getProcessID(), numOfLocalParts); - // - //graph = zp.getGraphData(); - - collectData(grid); - - //zp.partition(); - - //repartGrid(grid, zp); - - UBLOG(logDEBUG5, "ZoltanPartitioningPatchVisitor::visit() - end"); -} -////////////////////////////////////////////////////////////////////////// -void ZoltanPartitioningGridVisitor::collectData(SPtr<Grid3D> grid) -{ - int myRank = comm->getProcessID(); - int numOfProc = comm->getNumberOfProcesses(); - - if (numOfProc < 2) - { - return; - } - - int minInitLevel = grid->getCoarsestInitializedLevel(); - int maxInitLevel = grid->getFinestInitializedLevel(); - - for (int l = minInitLevel; l<=maxInitLevel; l++) - { - MPI_Comm mpi_comm = *((MPI_Comm*)comm->getNativeCommunicator()); - ZoltanPartitioner zp(mpi_comm, comm->getProcessID(), numOfLocalParts); - graph = zp.getGraphData(); - - int n = 0; - vector<SPtr<Block3D>> blockVector; - grid->getBlocks(l, blockVector); - - if (blockVector.size() == 0) - { - UB_THROW(UbException(UB_EXARGS, "Blocks for decomposition don't exist!")); - } - - //Verteilung von Ranks - int rank = 0; - for(SPtr<Block3D> block : blockVector) - { - block->setRank(rank); - block->setPart(rank); - rank++; - if (rank > numOfProc - 1) - rank = 0; - } - - int vertices = 0; - - for(SPtr<Block3D> block : blockVector) - { - if (block->getRank() == myRank) - { - vertices++; - - vertexGID.push_back(block->getGlobalID()); - - int edges = 0; - for (int dir = 0; dir <= numOfDirs; dir++) - { - SPtr<Block3D> neighBlock = (grid->getNeighborBlock(dir, - block->getX1(), block->getX2(), block->getX3(), l)); - - if (neighBlock) - { - edges++; - nborGID.push_back(neighBlock->getGlobalID()); - nborProc.push_back(neighBlock->getRank()); - } - } - numEdges.push_back(edges); - } - } - graph->numLocalVertices = vertices; - graph->vnumEdges = numEdges; - graph->vvertexGID = vertexGID; - graph->vnborGID = nborGID; - graph->vnborProc = nborProc; - - zp.partition(); - repartGrid(grid, zp); - } -} -////////////////////////////////////////////////////////////////////////// -void ZoltanPartitioningGridVisitor::repartGrid(SPtr<Grid3D> grid, ZoltanPartitioner& zp) -{ - if (zp.areChanges()) - { - UBLOG(logDEBUG5, "ZoltanPartitioningPatchVisitor::repartGrid - start" ); - vector<int> sExportGlobalGids, sExportToPart, sExportProcs; - vector<int> rExportGlobalGids, rExportToPart, rExportProcs; - - zp.getExportData(sExportGlobalGids, sExportToPart, sExportProcs); - - comm->allGather(sExportGlobalGids, rExportGlobalGids); - comm->allGather(sExportToPart, rExportToPart); - comm->allGather(sExportProcs, rExportProcs); - - for (int i = 0; i < (int)rExportGlobalGids.size(); i++) - { - if (rExportGlobalGids[i] != -1) - { - SPtr<Block3D> block = grid->getBlock(rExportGlobalGids[i]); - if(block) - { - block->setRank(rExportProcs[i]); - block->setPart(rExportToPart[i]); - } - } - } - UBLOG(logDEBUG5, "ZoltanPartitioningPatchVisitor::repartGrid - end" ); - } -} -#endif diff --git a/src/cpu/VirtualFluidsCore/Visitors/ZoltanPartitioningGridVisitor.h b/src/cpu/VirtualFluidsCore/Visitors/ZoltanPartitioningGridVisitor.h deleted file mode 100644 index 3a328ddc5..000000000 --- a/src/cpu/VirtualFluidsCore/Visitors/ZoltanPartitioningGridVisitor.h +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @file ZoltanPartitioningPatchVisitor.h -* @brief Visitor class wich apply Zoltan library partitioning. -* @author Kostyantyn Kucher -* @date 10.06.2011 -*/ - -#ifndef ZoltanPartitioningGridVisitor_H -#define ZoltanPartitioningGridVisitor_H - -#if defined VF_ZOLTAN && defined VF_MPI - -#include "Grid3DVisitor.h" -#include "Communicator.h" -#include "ZoltanPartitioner.h" - -class ZoltanPartitioningGridVisitor : public Grid3DVisitor -{ -public: - ZoltanPartitioningGridVisitor(SPtr<Communicator> comm, int numOfDirs, int numOfLocalParts = 1); - ~ZoltanPartitioningGridVisitor(); - void visit(SPtr<Grid3D> grid); -protected: - void collectData(SPtr<Grid3D> grid); - void repartGrid(SPtr<Grid3D> grid, ZoltanPartitioner& zp); -private: - SPtr<Communicator> comm; - int numOfDirs; - int numOfLocalParts; - ZoltanGraph *graph; - std::vector<int> vertexGID; - std::vector<int> numEdges; - std::vector<int> nborGID; - std::vector<int> nborProc; -}; - -#endif -#endif -- GitLab