From 776ea0864dfd3c67eb452cdf0dcbf9d1724e53fa Mon Sep 17 00:00:00 2001 From: Anna Wellmann <a.wellmann@tu-bs.de> Date: Wed, 17 Nov 2021 14:05:04 +0100 Subject: [PATCH] Clean up edge node routine and add brackets --- .../Communication/ExchangeData27.cpp | 20 ++++------ .../VirtualFluids_GPU/Parameter/Parameter.cpp | 37 ++++++++++++++----- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp b/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp index 7b8da13a9..288f2dae5 100644 --- a/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp +++ b/src/gpu/VirtualFluids_GPU/Communication/ExchangeData27.cpp @@ -223,10 +223,8 @@ void exchangeCollDataYGPU27(Parameter *para, vf::gpu::Communicator *comm, CudaMe // copy corner received node values from x if (para->getNumberOfProcessNeighborsX(level, "recv") > 0) { for (uint i = 0; i < para->getParH(level)->cornerNodesXtoY.recvPos.size(); i++) { - std::pair<int, int> & recvPosX = para->getParH(level)->cornerNodesXtoY.recvPos[i]; - std::pair<int, int> & sendPosY = para->getParH(level)->cornerNodesXtoY.sendPos[i]; - real &f = para->getParH(level)->recvProcessNeighborX[recvPosX.first].f[0][recvPosX.second]; - para->getParH(level)->sendProcessNeighborY[sendPosY.first].f[0][sendPosY.second] = f; + para->getParH(level)->sendProcessNeighborY[para->getParH(level)->cornerNodesXtoY.sendPos[i].first].f[0][para->getParH(level)->cornerNodesXtoY.sendPos[i].second] = + para->getParH(level)->recvProcessNeighborX[para->getParH(level)->cornerNodesXtoY.recvPos[i].first].f[0][para->getParH(level)->cornerNodesXtoY.recvPos[i].second]; } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -316,20 +314,16 @@ void exchangeCollDataZGPU27(Parameter *para, vf::gpu::Communicator *comm, CudaMe // copy corner received node values from x if (para->getNumberOfProcessNeighborsX(level, "recv") > 0) { for (uint i = 0; i < para->getParH(level)->cornerNodesXtoZ.recvPos.size(); i++) { - std::pair<int, int> &recvPosX = para->getParH(level)->cornerNodesXtoZ.recvPos[i]; - std::pair<int, int> &sendPosZ = para->getParH(level)->cornerNodesXtoZ.sendPos[i]; - real &f = para->getParH(level)->recvProcessNeighborX[recvPosX.first].f[0][recvPosX.second]; - para->getParH(level)->sendProcessNeighborZ[sendPosZ.first].f[0][sendPosZ.second] = f; + para->getParH(level)->sendProcessNeighborZ[para->getParH(level)->cornerNodesXtoZ.sendPos[i].first].f[0][para->getParH(level)->cornerNodesXtoZ.sendPos[i].second] = + para->getParH(level)->recvProcessNeighborX[para->getParH(level)->cornerNodesXtoZ.recvPos[i].first].f[0][para->getParH(level)->cornerNodesXtoZ.recvPos[i].second]; } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // copy corner received node values from y if (para->getNumberOfProcessNeighborsY(level, "recv") > 0) { - for (uint i = 0; i < para->getParH(level)->cornerNodesYtoZ.recvPos.size(); i++) { - std::pair<int, int> &recvPosY = para->getParH(level)->cornerNodesYtoZ.recvPos[i]; - std::pair<int, int> &sendPosZ = para->getParH(level)->cornerNodesYtoZ.sendPos[i]; - real &f = para->getParH(level)->recvProcessNeighborY[recvPosY.first].f[0][recvPosY.second]; - para->getParH(level)->sendProcessNeighborZ[sendPosZ.first].f[0][sendPosZ.second] = f; + for (uint i = 0; i < para->getParH(level)->cornerNodesYtoZ.recvPos.size(); i++) { + para->getParH(level)->sendProcessNeighborZ[para->getParH(level)->cornerNodesYtoZ.sendPos[i].first].f[0][para->getParH(level)->cornerNodesYtoZ.sendPos[i].second] = + para->getParH(level)->recvProcessNeighborY[para->getParH(level)->cornerNodesYtoZ.recvPos[i].first].f[0][para->getParH(level)->cornerNodesYtoZ.recvPos[i].second]; } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp index 78b065bff..bcb50ffd5 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp +++ b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp @@ -2565,66 +2565,83 @@ void Parameter::findCornerNodesCommMultiGPU() { void Parameter::findCornerNodesXY(int level) { for (uint i = 0; i < (unsigned int)(this->getNumberOfProcessNeighborsX(level, "recv")); i++) + { for (int j = 0; j < parH[level]->recvProcessNeighborX[i].numberOfNodes; j++) { int index = parH[level]->recvProcessNeighborX[i].index[j]; bool foundIndex = findIndexInSendNodesXY(level, index); - if (foundIndex) + if (foundIndex){ this->parH[level]->cornerNodesXtoY.recvPos.push_back(std::pair(i, j)); - } + } + } + } + std::cout << "para->cornerNodesXtoY.sendPos.size() " << this->getParH(level)->cornerNodesXtoY.sendPos.size() << std::endl; } bool Parameter::findIndexInSendNodesXY(int level, int index) { for (uint k = 0; k < (unsigned int)(this->getNumberOfProcessNeighborsY(level, "send")); k++) - for (int l = 0; l < parH[level]->sendProcessNeighborY[l].numberOfNodes; l++) + { + for (int l = 0; l < parH[level]->sendProcessNeighborY[k].numberOfNodes; l++) + { if (parH[level]->sendProcessNeighborY[k].index[l] == index) { this->parH[level]->cornerNodesXtoY.sendPos.push_back(std::pair(k, l)); return true; } + } + } return false; } void Parameter::findCornerNodesXZ(int level) { for (uint i = 0; i < (unsigned int)(this->getNumberOfProcessNeighborsX(level, "recv")); i++) + { for (int j = 0; j < parH[level]->recvProcessNeighborX[i].numberOfNodes; j++) { int index = parH[level]->recvProcessNeighborX[i].index[j]; bool foundIndex = findIndexInSendNodesXZ(level, index); - if (foundIndex) + if (foundIndex){ this->parH[level]->cornerNodesXtoZ.recvPos.push_back(std::pair(i, j)); + } } + } } bool Parameter::findIndexInSendNodesXZ(int level, int index) { - for (uint k = 0; k < (unsigned int)(this->getNumberOfProcessNeighborsZ(level, "send")); k++) - for (int l = 0; l < parH[level]->sendProcessNeighborZ[l].numberOfNodes; l++) + for (uint k = 0; k < (unsigned int)(this->getNumberOfProcessNeighborsZ(level, "send")); k++){ + for (int l = 0; l < parH[level]->sendProcessNeighborZ[k].numberOfNodes; l++){ if (parH[level]->sendProcessNeighborZ[k].index[l] == index) { this->parH[level]->cornerNodesXtoZ.sendPos.push_back(std::pair(k, l)); return true; } + } + } return false; } void Parameter::findCornerNodesYZ(int level) { - for (uint i = 0; i < (unsigned int)(this->getNumberOfProcessNeighborsY(level, "recv")); i++) + for (uint i = 0; i < (unsigned int)(this->getNumberOfProcessNeighborsY(level, "recv")); i++){ for (int j = 0; j < parH[level]->recvProcessNeighborY[i].numberOfNodes; j++) { int index = parH[level]->recvProcessNeighborY[i].index[j]; bool foundIndex = findIndexInSendNodesYZ(level, index); - if (foundIndex) + if (foundIndex){ this->parH[level]->cornerNodesYtoZ.recvPos.push_back(std::pair(i, j)); + } } + } } bool Parameter::findIndexInSendNodesYZ(int level, int index) { - for (uint k = 0; k < (unsigned int)(this->getNumberOfProcessNeighborsZ(level, "send")); k++) - for (int l = 0; l < parH[level]->sendProcessNeighborZ[l].numberOfNodes; l++) + for (uint k = 0; k < (unsigned int)(this->getNumberOfProcessNeighborsZ(level, "send")); k++){ + for (int l = 0; l < parH[level]->sendProcessNeighborZ[k].numberOfNodes; l++){ if (parH[level]->sendProcessNeighborZ[k].index[l] == index) { this->parH[level]->cornerNodesYtoZ.sendPos.push_back(std::pair(k, l)); return true; } + } + } return false; } -- GitLab