diff --git a/src/gpu/GridGenerator/grid/GridBuilder/GridBuilder.h b/src/gpu/GridGenerator/grid/GridBuilder/GridBuilder.h index 55dd905458805b25279faa05eab5bdb3d5118eae..9548cdac7d2be9f0c2317b6b46c7f02764ff5350 100644 --- a/src/gpu/GridGenerator/grid/GridBuilder/GridBuilder.h +++ b/src/gpu/GridGenerator/grid/GridBuilder/GridBuilder.h @@ -86,6 +86,10 @@ public: virtual uint getNumberOfReceiveIndices( int direction, uint level ) = 0; virtual void getSendIndices( int* sendIndices, int direction, int level ) = 0; virtual void getReceiveIndices( int* sendIndices, int direction, int level ) = 0; + virtual void reorderSendRecvIndexForCommAfterFtoC(int *sendIndices, int *recvIndices, + int &numberOfSendNeighborsAfterFtoC, + int &numberOfRecvNeighborsAfterFtoC, uint *iCellFCCBorder, + uint sizeOfICellFCCBorder, int direction, int level) = 0; virtual uint getNumberOfFluidNodes(unsigned int level) const = 0; virtual void getFluidNodeIndices(uint *fluidNodeIndices, const int level) const = 0; diff --git a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp index e4b7861fcf1c8d49325d3748a8286fac1262f004..d9182fc54064ea37c82537ab0470da27211530d0 100644 --- a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp +++ b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.cpp @@ -266,6 +266,57 @@ GRIDGENERATOR_EXPORT void LevelGridBuilder::getReceiveIndices(int * receiveIndic } } +GRIDGENERATOR_EXPORT void LevelGridBuilder::reorderSendRecvIndexForCommAfterFtoC(int *sendIndices, int *recvIndices, + int &numberOfSendNeighborsAfterFtoC, + int &numberOfRecvNeighborsAfterFtoC, + uint* iCellFCCBorder, + uint sizeOfICellFCCBorder, + int direction, int level) +{ + uint numberOfIndices = getNumberOfSendIndices(direction, level); + int sparseIndexSend; + bool isInICellFCCBorder; + std::vector<int> sendIndicesAfterFtoC; + std::vector<int> sendIndicesOther; + std::vector<int> recvIndicesAfterFtoC; + std::vector<int> recvIndicesOther; + + for (uint i = 0; i < numberOfIndices; i++) { + sparseIndexSend = sendIndices[i]; + + // check if sparse index is in ICellFCC border + isInICellFCCBorder = false; + for (uint j = 0; j < sizeOfICellFCCBorder; j++) { + if (iCellFCCBorder[j] == sparseIndexSend) { + isInICellFCCBorder = true; + break; + } + } + + // add index to corresponding vector + if (isInICellFCCBorder) { + sendIndicesAfterFtoC.push_back(sparseIndexSend); + recvIndicesAfterFtoC.push_back(sparseIndexSend); + } else { + sendIndicesOther.push_back(recvIndices[i]); + recvIndicesOther.push_back(recvIndices[i]); + } + } + + numberOfSendNeighborsAfterFtoC = sendIndicesAfterFtoC.size(); + numberOfRecvNeighborsAfterFtoC = recvIndicesAfterFtoC.size(); + + // copy new vectors back to sendIndices and receive indices arrays + for (uint i = 0; i < numberOfSendNeighborsAfterFtoC; i++) { + sendIndices[i] = sendIndicesAfterFtoC[i]; + recvIndices[i] = recvIndicesAfterFtoC[i]; + } + for (uint i = 0; i < sendIndicesOther.size(); i++) { + sendIndices[i + numberOfSendNeighborsAfterFtoC] = sendIndicesOther[i]; + recvIndices[i + numberOfRecvNeighborsAfterFtoC] = recvIndicesOther[i]; + } +} + uint LevelGridBuilder::getNumberOfNodes(unsigned int level) const { return grids[level]->getSparseSize(); diff --git a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h index a3cab9c6eb412b0ca75ba1060d982e8a50e06669..fdaa6e25d2fa97c737581b66b84750ed042e64eb 100644 --- a/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h +++ b/src/gpu/GridGenerator/grid/GridBuilder/LevelGridBuilder.h @@ -149,6 +149,11 @@ public: GRIDGENERATOR_EXPORT uint getNumberOfReceiveIndices( int direction, uint level ) override; GRIDGENERATOR_EXPORT void getSendIndices( int* sendIndices, int direction, int level ) override; GRIDGENERATOR_EXPORT void getReceiveIndices( int* sendIndices, int direction, int level ) override; + GRIDGENERATOR_EXPORT void reorderSendRecvIndexForCommAfterFtoC(int *sendIndices, int *recvIndices, + int &numberOfSendNeighborsAfterFtoC, + int &numberOfRecvNeighborsAfterFtoC, + uint *iCellFCCBorder, uint sizeOfICellFCCBorder, + int direction, int level) override; }; diff --git a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h index 09926c8cb178f7332377fbb5b2445250147127ac..c09a50a8330794f7ed849c700badcfde11d16730 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h +++ b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h @@ -293,6 +293,13 @@ struct LBMSimulationParameter std::vector<ProcessNeighbor27> recvProcessNeighborX; std::vector<ProcessNeighbor27> recvProcessNeighborY; std::vector<ProcessNeighbor27> recvProcessNeighborZ; + + std::vector<int> numberOfSendProcessNeighborsAfterFtoCX; + std::vector<int> numberOfSendProcessNeighborsAfterFtoCY; + std::vector<int> numberOfSendProcessNeighborsAfterFtoCZ; + std::vector<int> numberOfRecvProcessNeighborsAfterFtoCX; + std::vector<int> numberOfRecvProcessNeighborsAfterFtoCY; + std::vector<int> numberOfRecvProcessNeighborsAfterFtoCZ; /////////////////////////////////////////////////////// // 3D domain decomposition convection diffusion std::vector<ProcessNeighbor27> sendProcessNeighborADX;