diff --git a/src/patchkernel/volume_mapper.hpp b/src/patchkernel/volume_mapper.hpp index 26dde8b63d..040feb1674 100644 --- a/src/patchkernel/volume_mapper.hpp +++ b/src/patchkernel/volume_mapper.hpp @@ -121,6 +121,7 @@ class VolumeMapper { virtual bool checkPartition() = 0; virtual std::unordered_map > getReceivedMappedIds() = 0; virtual std::unordered_map > getSentMappedIds() = 0; + virtual std::unordered_map > getReceivedReferenceIds() = 0; virtual std::unordered_map > getSentReferenceIds() = 0; #endif diff --git a/src/voloctree/voloctree_mapper.cpp b/src/voloctree/voloctree_mapper.cpp index 31e05fa63f..cdb4cfe950 100644 --- a/src/voloctree/voloctree_mapper.cpp +++ b/src/voloctree/voloctree_mapper.cpp @@ -796,6 +796,43 @@ std::unordered_map> VolOctreeMapper::getSentReferenceIds( return sent; } +/** + * Get the list of the octants of the partitions of the reference mesh, different + * from the local rank, overlapped to the local partition of the mapped mesh. + * + * \result Returns the map with for each rank (key) the list of the octants + * (argument) of the reference mesh overlapped with the local partition of the + * mapped mesh. + */ +std::unordered_map> VolOctreeMapper::getReceivedReferenceIds() +{ + std::unordered_map> received; + + // Use set to retrieve ordered ids from senders using volume mapper mapping + // We loop over the cells of the reference mesh, we ask the mapping for the + // mapped mesh ids of cells overlapping the current cell, we checks for ranks + // and saves non-matching rank cells in the set, rank-by-rank. + + std::unordered_map> rankIdRecv; + + for (Cell & cell : m_mappedPatch->getCells()) { + long id = cell.getId(); + auto info = m_inverseMapping.at(id); + std::size_t idsSize = info.ids.size(); + for (std::size_t i = 0; i < idsSize; ++i) { + if (info.ranks[i] != m_mappedPatch->getRank()) { + rankIdRecv[info.ranks[i]].insert(info.ids[i]); + } + } + } + + for (const auto & rankId : rankIdRecv) { + received[rankId.first].assign(rankId.second.begin(), rankId.second.end()); + } + + return received; +} + /** * Get the list of the octants of the local partition of the mapped mesh * overlapped to a different partition of the reference mesh. diff --git a/src/voloctree/voloctree_mapper.hpp b/src/voloctree/voloctree_mapper.hpp index 57be3d4b5a..4b7dd24931 100644 --- a/src/voloctree/voloctree_mapper.hpp +++ b/src/voloctree/voloctree_mapper.hpp @@ -56,6 +56,7 @@ class VolOctreeMapper: public VolumeMapper { void clearPartitionMapping(); std::unordered_map> getReceivedMappedIds() override; std::unordered_map> getSentMappedIds() override; + std::unordered_map> getReceivedReferenceIds() override; std::unordered_map> getSentReferenceIds() override; #endif