Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix voloctree volume mapper #443

Merged
merged 4 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
build/
release/
debug/
build*/
release*/
debug*/
CMakeFiles/
*.swp
*~
Expand All @@ -9,4 +9,5 @@ CMakeFiles/
.directory
.settings/
.DS_Store
.vscode
.vscode

20 changes: 20 additions & 0 deletions src/patchkernel/volume_mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,26 @@ void VolumeMapper::clearInverseMapping()
m_inverseMapping.unsetKernel(false);
}

/**
* Get a constant point to the reference patch
*
* \return a constant pointer to the reference patch
*/
const bitpit::VolumeKernel *VolumeMapper::getReferencePatch() const
{
return m_referencePatch;
}

/**
* Get a constant point to the mapped patch
*
* \return a constant pointer to the mapped patch
*/
const bitpit::VolumeKernel *VolumeMapper::getMappedPatch() const
{
return m_mappedPatch;
}

/**
* Get direct mapping
*/
Expand Down
3 changes: 3 additions & 0 deletions src/patchkernel/volume_mapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class VolumeMapper {
void clearMapping();
void clearInverseMapping();

const VolumeKernel *getReferencePatch() const;
const VolumeKernel *getMappedPatch() const;

const bitpit::PiercedStorage<mapping::Info> & getMapping() const;
const bitpit::PiercedStorage<mapping::Info> & getInverseMapping() const;

Expand Down
69 changes: 44 additions & 25 deletions src/voloctree/voloctree_mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1229,35 +1229,54 @@ bool VolOctreeMapper::_recoverPartition()
clearPartitionMappingLists();

// Locally the mapped mesh build the lists of octants to send
std::map<int, std::vector<Octant>> list_octant;
std::map<int, std::vector<const Octant*>> list_octant;
std::map<int, std::vector<long>> list_id;
std::map<int, std::vector<long>> list_globalId;
uint32_t idx = 0;
uint64_t morton = mappedPatch->getTree().getLastDescMorton(idx);
for (int reference_rank : toreference_rank[m_rank]) {
uint64_t reference_first_morton = partitionFDReference[reference_rank];
uint64_t reference_last_morton = partitionLDReference[reference_rank];
while (morton < reference_first_morton) {
idx++;
if (idx == mappedPatch->getTree().getNumOctants()) {

// Initialize idx position in mapped tree to the first mapped
// octant inside the overlapping region
std::vector<int>::iterator overlap_ref_rank_begin_it = toreference_rank[m_rank].begin();
std::vector<int>::iterator overlap_ref_rank_end_it = toreference_rank[m_rank].end();
if (overlap_ref_rank_begin_it != overlap_ref_rank_end_it) {
uint32_t first_overlap_map_idx = 0;
int first_overlap_ref_rank = *overlap_ref_rank_begin_it;
uint64_t reference_first_morton = partitionFDReference[first_overlap_ref_rank];
uint64_t first_overlap_map_morton = mappedPatch->getTree().getLastDescMorton(first_overlap_map_idx);
while (first_overlap_map_morton < reference_first_morton) {
first_overlap_map_idx++;
if (first_overlap_map_idx == mappedPatch->getTree().getNumOctants()) {
break;
}
morton = mappedPatch->getTree().getLastDescMorton(idx);
first_overlap_map_morton = mappedPatch->getTree().getLastDescMorton(first_overlap_map_idx);
}
while (morton < reference_last_morton) {
Octant oct = *mappedPatch->getTree().getOctant(idx);
list_octant[reference_rank].push_back(oct);
VolOctree::OctantInfo octantIfo(idx, true);
long id = mappedPatch->getOctantId(octantIfo);
list_id[reference_rank].push_back(id);
long globalId = mappedPatch->getTree().getGlobalIdx(idx);
list_globalId[reference_rank].push_back(globalId);
m_partitionIR.list_sent_octantIR.emplace_back(oct, id, globalId, reference_rank);
idx++;
if (idx == mappedPatch->getTree().getNumOctants()) {
break;

// Fill partitioning info structure with mapped octants in the
// overlapping region
if (first_overlap_map_idx < mappedPatch->getTree().getNumOctants() ) {
uint32_t idx = first_overlap_map_idx;
for (std::vector<int>::iterator ref_rank_it = overlap_ref_rank_begin_it; ref_rank_it != overlap_ref_rank_end_it; ++ref_rank_it) {
int reference_rank = *ref_rank_it;
uint64_t reference_last_morton = partitionLDReference[reference_rank];
uint64_t morton = mappedPatch->getTree().getMorton(idx);
while (morton < reference_last_morton) {
const Octant *oct = mappedPatch->getTree().getOctant(idx);
list_octant[reference_rank].push_back(oct);
VolOctree::OctantInfo octantIfo(idx, true);
long id = mappedPatch->getOctantId(octantIfo);
list_id[reference_rank].push_back(id);
long globalId = mappedPatch->getTree().getGlobalIdx(idx);
list_globalId[reference_rank].push_back(globalId);
m_partitionIR.list_sent_octantIR.emplace_back(*oct, id, globalId, reference_rank);
idx++;
if (idx == mappedPatch->getTree().getNumOctants()) {
break;
}
morton = mappedPatch->getTree().getMorton(idx);
}
if (idx <= mappedPatch->getTree().getNumOctants() && idx > 0) {
--idx;
}
}
morton = mappedPatch->getTree().getMorton(idx);
}
}

Expand All @@ -1276,7 +1295,7 @@ bool VolOctreeMapper::_recoverPartition()
//
// TODO: make accessible global variables in ParaTree
for (int reference_rank : toreference_rank[m_rank]) {
const std::vector<Octant> &rankOctants = list_octant[reference_rank];
const std::vector<const Octant*> &rankOctants = list_octant[reference_rank];
std::size_t nRankOctants = rankOctants.size();

// Set buffer size
Expand All @@ -1287,7 +1306,7 @@ bool VolOctreeMapper::_recoverPartition()
SendBuffer &sendBuffer = octCommunicator.getSendBuffer(reference_rank);
sendBuffer << nRankOctants;
for (std::size_t n = 0; n < nRankOctants; ++n) {
const Octant &octant = rankOctants[n];
const Octant &octant = *rankOctants[n];
sendBuffer << octant;

long id = list_id[reference_rank][n];
Expand Down
Loading