Skip to content

Commit

Permalink
voloctree: add reference mesh received ids getter
Browse files Browse the repository at this point in the history
  • Loading branch information
marcocisternino committed May 4, 2023
1 parent 801c7f7 commit 813e8c9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/patchkernel/volume_mapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class VolumeMapper {
virtual bool checkPartition() = 0;
virtual std::unordered_map<int, std::vector<long> > getReceivedMappedIds() = 0;
virtual std::unordered_map<int, std::vector<long> > getSentMappedIds() = 0;
virtual std::unordered_map<int, std::vector<long> > getReceivedReferenceIds() = 0;
virtual std::unordered_map<int, std::vector<long> > getSentReferenceIds() = 0;
#endif

Expand Down
37 changes: 37 additions & 0 deletions src/voloctree/voloctree_mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,43 @@ std::unordered_map<int, std::vector<long>> 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<int, std::vector<long>> VolOctreeMapper::getReceivedReferenceIds()
{
std::unordered_map<int, std::vector<long>> 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<int, std::set<long>> 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.
Expand Down
1 change: 1 addition & 0 deletions src/voloctree/voloctree_mapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class VolOctreeMapper: public VolumeMapper {
void clearPartitionMapping();
std::unordered_map<int, std::vector<long>> getReceivedMappedIds() override;
std::unordered_map<int, std::vector<long>> getSentMappedIds() override;
std::unordered_map<int, std::vector<long>> getReceivedReferenceIds() override;
std::unordered_map<int, std::vector<long>> getSentReferenceIds() override;
#endif

Expand Down

0 comments on commit 813e8c9

Please sign in to comment.