Skip to content

Commit

Permalink
Backport of #1015
Browse files Browse the repository at this point in the history
  • Loading branch information
fsimonis committed May 18, 2021
1 parent 0149c8d commit e385063
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
2 changes: 2 additions & 0 deletions docs/changelog/1015.md
@@ -0,0 +1,2 @@
- Fixed gather-scatter communication deadlock with empty master ranks
- Fixed empty received partitions for filtering on slaves
8 changes: 2 additions & 6 deletions src/cplscheme/BaseCouplingScheme.cpp
Expand Up @@ -75,9 +75,7 @@ void BaseCouplingScheme::sendData(m2n::PtrM2N m2n, DataMap sendData)

for (const DataMap::value_type &pair : sendData) {
int size = pair.second->values().size();
if (size > 0) {
m2n->send(pair.second->values().data(), size, pair.second->mesh->getID(), pair.second->getDimensions());
}
m2n->send(pair.second->values().data(), size, pair.second->mesh->getID(), pair.second->getDimensions());
sentDataIDs.push_back(pair.first);
}
PRECICE_DEBUG("Number of sent data sets = " << sentDataIDs.size());
Expand All @@ -91,9 +89,7 @@ void BaseCouplingScheme::receiveData(m2n::PtrM2N m2n, DataMap receiveData)
PRECICE_ASSERT(m2n->isConnected());
for (DataMap::value_type &pair : receiveData) {
int size = pair.second->values().size();
if (size > 0) {
m2n->receive(pair.second->values().data(), size, pair.second->mesh->getID(), pair.second->getDimensions());
}
m2n->receive(pair.second->values().data(), size, pair.second->mesh->getID(), pair.second->getDimensions());
receivedDataIDs.push_back(pair.first);
}
PRECICE_DEBUG("Number of received data sets = " << receivedDataIDs.size());
Expand Down
4 changes: 2 additions & 2 deletions src/m2n/PointToPointCommunication.cpp
Expand Up @@ -581,7 +581,7 @@ void PointToPointCommunication::send(double const *itemsToSend,
int valueDimension)
{

if (_mappings.empty()) {
if (_mappings.empty() || size == 0) {
return;
}

Expand All @@ -605,7 +605,7 @@ void PointToPointCommunication::receive(double *itemsToReceive,
size_t size,
int valueDimension)
{
if (_mappings.empty()) {
if (_mappings.empty() || size == 0) {
return;
}

Expand Down
7 changes: 3 additions & 4 deletions src/partition/ReceivedPartition.cpp
Expand Up @@ -328,17 +328,16 @@ void ReceivedPartition::filterByBoundingBox()
mesh::Mesh filteredMesh("FilteredMesh", _dimensions, _mesh->isFlipNormals(), mesh::Mesh::MESH_ID_UNDEFINED);
mesh::filterMesh(filteredMesh, *_mesh, [&](const mesh::Vertex &v) { return _bb.contains(v); });

if (isAnyProvidedMeshNonEmpty()) {
PRECICE_CHECK(not _mesh->vertices().empty(), errorMeshFilteredOut(_mesh->getName()));
}

PRECICE_DEBUG("Bounding box filter, filtered from "
<< _mesh->vertices().size() << " to " << filteredMesh.vertices().size() << " vertices, "
<< _mesh->edges().size() << " to " << filteredMesh.edges().size() << " edges, and "
<< _mesh->triangles().size() << " to " << filteredMesh.triangles().size() << " triangles.");

_mesh->clear();
_mesh->addMesh(filteredMesh);
if (isAnyProvidedMeshNonEmpty()) {
PRECICE_CHECK(not _mesh->vertices().empty(), errorMeshFilteredOut(_mesh->getName()));
}
} else {
PRECICE_ASSERT(_geometricFilter == NO_FILTER);
}
Expand Down

0 comments on commit e385063

Please sign in to comment.