Skip to content
Snippets Groups Projects
Commit 7be0eca6 authored by Anna Wellmann's avatar Anna Wellmann
Browse files

Add method to reorder send and recvIndices

Find all send and recv indices which also are interface cells fine to coarse, coarse (iCellFCC).
Move them to the front of the vector of send and recv indices. Return their number as well.
parent 2c36d79f
No related branches found
No related tags found
1 merge request!104Add Communication Hiding to GPU version
...@@ -86,6 +86,10 @@ public: ...@@ -86,6 +86,10 @@ public:
virtual uint getNumberOfReceiveIndices( int direction, uint level ) = 0; virtual uint getNumberOfReceiveIndices( int direction, uint level ) = 0;
virtual void getSendIndices( int* sendIndices, int direction, int level ) = 0; virtual void getSendIndices( int* sendIndices, int direction, int level ) = 0;
virtual void getReceiveIndices( 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 uint getNumberOfFluidNodes(unsigned int level) const = 0;
virtual void getFluidNodeIndices(uint *fluidNodeIndices, const int level) const = 0; virtual void getFluidNodeIndices(uint *fluidNodeIndices, const int level) const = 0;
......
...@@ -266,6 +266,57 @@ GRIDGENERATOR_EXPORT void LevelGridBuilder::getReceiveIndices(int * receiveIndic ...@@ -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 uint LevelGridBuilder::getNumberOfNodes(unsigned int level) const
{ {
return grids[level]->getSparseSize(); return grids[level]->getSparseSize();
......
...@@ -149,6 +149,11 @@ public: ...@@ -149,6 +149,11 @@ public:
GRIDGENERATOR_EXPORT uint getNumberOfReceiveIndices( int direction, uint level ) override; GRIDGENERATOR_EXPORT uint getNumberOfReceiveIndices( int direction, uint level ) override;
GRIDGENERATOR_EXPORT void getSendIndices( int* sendIndices, int direction, int 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 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;
}; };
......
...@@ -293,6 +293,13 @@ struct LBMSimulationParameter ...@@ -293,6 +293,13 @@ struct LBMSimulationParameter
std::vector<ProcessNeighbor27> recvProcessNeighborX; std::vector<ProcessNeighbor27> recvProcessNeighborX;
std::vector<ProcessNeighbor27> recvProcessNeighborY; std::vector<ProcessNeighbor27> recvProcessNeighborY;
std::vector<ProcessNeighbor27> recvProcessNeighborZ; 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 // 3D domain decomposition convection diffusion
std::vector<ProcessNeighbor27> sendProcessNeighborADX; std::vector<ProcessNeighbor27> sendProcessNeighborADX;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment