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

Partially revert "Refactor exchangeIndicesForCommAfterFtoC"

This reverts commit cc7bb07a.

The refactored version using std::find instead of std::unique does not work for vectors containing a zero as a receiving index.  For example this is the case in the app BoundaryLayer --> revert to the old version.
parent 4b9b5534
No related branches found
No related tags found
1 merge request!168Partially revert "Refactor exchangeIndicesForCommAfterFtoC"
...@@ -103,10 +103,10 @@ std::vector<uint> IndexRearrangementForStreams::initSendIndicesForCommAfterFToCZ ...@@ -103,10 +103,10 @@ std::vector<uint> IndexRearrangementForStreams::initSendIndicesForCommAfterFToCZ
std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCX( std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCX(
uint level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const uint level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const
{ {
// fill the receive vector with zeros as placeholders (0 is never a valid fluid node) // fill the receive vector with zeros as placeholders (0 is not a valid fluid node)
// give vector an arbitrary size (larger than needed) // TODO: Find a better way // give vector an arbitrary size (larger than needed) // TODO: Find a better way
std::vector<uint> recvIndicesForCommAfterFtoCPositions( std::vector<uint> recvIndicesForCommAfterFtoCPositions(
(size_t)para->getParH(level)->sendProcessNeighborsAfterFtoCX[indexOfProcessNeighbor].numberOfNodes * 2, 0); (size_t)para->getParH(level)->sendProcessNeighborsAfterFtoCY[indexOfProcessNeighbor].numberOfNodes * 2, 0);
communicator.receive_send( communicator.receive_send(
recvIndicesForCommAfterFtoCPositions.data(), (int)recvIndicesForCommAfterFtoCPositions.size(), recvIndicesForCommAfterFtoCPositions.data(), (int)recvIndicesForCommAfterFtoCPositions.size(),
...@@ -114,16 +114,23 @@ std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCX ...@@ -114,16 +114,23 @@ std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCX
sendIndicesForCommAfterFtoCPositions.data(), (int)sendIndicesForCommAfterFtoCPositions.size(), sendIndicesForCommAfterFtoCPositions.data(), (int)sendIndicesForCommAfterFtoCPositions.size(),
para->getParH(level)->sendProcessNeighborX[indexOfProcessNeighbor].rankNeighbor); para->getParH(level)->sendProcessNeighborX[indexOfProcessNeighbor].rankNeighbor);
// resize receiving vector to correct size (remove all zeros) // resize receiving vector to correct size
auto it = std::find(recvIndicesForCommAfterFtoCPositions.begin(), recvIndicesForCommAfterFtoCPositions.end(), 0); if ((uint)recvIndicesForCommAfterFtoCPositions.size() > 0) {
recvIndicesForCommAfterFtoCPositions.erase(it, recvIndicesForCommAfterFtoCPositions.end()); auto it = std::unique(
recvIndicesForCommAfterFtoCPositions.begin(),
recvIndicesForCommAfterFtoCPositions.end()); // finds the second zero when there are multiple zeros in a row
recvIndicesForCommAfterFtoCPositions.erase(
std::prev(it, 1), // begin erasing at the first zero
recvIndicesForCommAfterFtoCPositions.end()); // TODO: Find a better way
}
return recvIndicesForCommAfterFtoCPositions; return recvIndicesForCommAfterFtoCPositions;
} }
std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCY( std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCY(
uint level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const uint level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const
{ {
// fill the receive vector with zeros as placeholders (0 is never a valid fluid node) // fill the receive vector with zeros as placeholders (0 is not a valid fluid node)
// give vector an arbitrary size (larger than needed) // TODO: Find a better way // give vector an arbitrary size (larger than needed) // TODO: Find a better way
std::vector<uint> recvIndicesForCommAfterFtoCPositions( std::vector<uint> recvIndicesForCommAfterFtoCPositions(
(size_t)para->getParH(level)->sendProcessNeighborsAfterFtoCY[indexOfProcessNeighbor].numberOfNodes * 2, 0); (size_t)para->getParH(level)->sendProcessNeighborsAfterFtoCY[indexOfProcessNeighbor].numberOfNodes * 2, 0);
...@@ -134,16 +141,23 @@ std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCY ...@@ -134,16 +141,23 @@ std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCY
sendIndicesForCommAfterFtoCPositions.data(), (int)sendIndicesForCommAfterFtoCPositions.size(), sendIndicesForCommAfterFtoCPositions.data(), (int)sendIndicesForCommAfterFtoCPositions.size(),
para->getParH(level)->sendProcessNeighborY[indexOfProcessNeighbor].rankNeighbor); para->getParH(level)->sendProcessNeighborY[indexOfProcessNeighbor].rankNeighbor);
// resize receiving vector to correct size (remove all zeros) // resize receiving vector to correct size
auto it = std::find(recvIndicesForCommAfterFtoCPositions.begin(), recvIndicesForCommAfterFtoCPositions.end(), 0); if ((uint)recvIndicesForCommAfterFtoCPositions.size() > 0) {
recvIndicesForCommAfterFtoCPositions.erase(it, recvIndicesForCommAfterFtoCPositions.end()); auto it = std::unique(
recvIndicesForCommAfterFtoCPositions.begin(),
recvIndicesForCommAfterFtoCPositions.end()); // finds the second zero when there are multiple zeros in a row
recvIndicesForCommAfterFtoCPositions.erase(
std::prev(it, 1), // begin erasing at the first zero
recvIndicesForCommAfterFtoCPositions.end()); // TODO: Find a better way
}
return recvIndicesForCommAfterFtoCPositions; return recvIndicesForCommAfterFtoCPositions;
} }
std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCZ( std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCZ(
uint level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const uint level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const
{ {
// fill the receive vector with zeros as placeholders (0 is never a valid fluid node) // fill the receive vector with zeros as placeholders (0 is not a valid fluid node)
// give vector an arbitrary size (larger than needed) // TODO: Find a better way // give vector an arbitrary size (larger than needed) // TODO: Find a better way
std::vector<uint> recvIndicesForCommAfterFtoCPositions( std::vector<uint> recvIndicesForCommAfterFtoCPositions(
(size_t)para->getParH(level)->sendProcessNeighborsAfterFtoCZ[indexOfProcessNeighbor].numberOfNodes * 2, 0); (size_t)para->getParH(level)->sendProcessNeighborsAfterFtoCZ[indexOfProcessNeighbor].numberOfNodes * 2, 0);
...@@ -154,9 +168,16 @@ std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCZ ...@@ -154,9 +168,16 @@ std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCZ
sendIndicesForCommAfterFtoCPositions.data(), (int)sendIndicesForCommAfterFtoCPositions.size(), sendIndicesForCommAfterFtoCPositions.data(), (int)sendIndicesForCommAfterFtoCPositions.size(),
para->getParH(level)->sendProcessNeighborZ[indexOfProcessNeighbor].rankNeighbor); para->getParH(level)->sendProcessNeighborZ[indexOfProcessNeighbor].rankNeighbor);
// resize receiving vector to correct size (remove all zeros) // resize receiving vector to correct size
auto it = std::find(recvIndicesForCommAfterFtoCPositions.begin(), recvIndicesForCommAfterFtoCPositions.end(), 0); if ((uint)recvIndicesForCommAfterFtoCPositions.size() > 0) {
recvIndicesForCommAfterFtoCPositions.erase(it, recvIndicesForCommAfterFtoCPositions.end()); auto it = std::unique(
recvIndicesForCommAfterFtoCPositions.begin(),
recvIndicesForCommAfterFtoCPositions.end()); // finds the second zero when there are multiple zeros in a row
recvIndicesForCommAfterFtoCPositions.erase(
std::prev(it, 1), // begin erasing at the first zero
recvIndicesForCommAfterFtoCPositions.end()); // TODO: Find a better way
}
return recvIndicesForCommAfterFtoCPositions; return recvIndicesForCommAfterFtoCPositions;
} }
......
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