diff --git a/.gitignore b/.gitignore index 3b84a0accf..a12050d8ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ -build/ -release/ -debug/ +build*/ +release*/ +debug*/ CMakeFiles/ *.swp *~ @@ -9,4 +9,5 @@ CMakeFiles/ .directory .settings/ .DS_Store -.vscode \ No newline at end of file +.vscode + diff --git a/src/patchkernel/volume_mapper.cpp b/src/patchkernel/volume_mapper.cpp index 5178a1b77e..9e42a8f71f 100644 --- a/src/patchkernel/volume_mapper.cpp +++ b/src/patchkernel/volume_mapper.cpp @@ -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 */ diff --git a/src/patchkernel/volume_mapper.hpp b/src/patchkernel/volume_mapper.hpp index 05f2f5c1c2..a737533c1a 100644 --- a/src/patchkernel/volume_mapper.hpp +++ b/src/patchkernel/volume_mapper.hpp @@ -108,6 +108,9 @@ class VolumeMapper { void clearMapping(); void clearInverseMapping(); + const VolumeKernel *getReferencePatch() const; + const VolumeKernel *getMappedPatch() const; + const bitpit::PiercedStorage & getMapping() const; const bitpit::PiercedStorage & getInverseMapping() const; diff --git a/src/voloctree/voloctree_mapper.cpp b/src/voloctree/voloctree_mapper.cpp index 6ea1ef829f..704b407076 100644 --- a/src/voloctree/voloctree_mapper.cpp +++ b/src/voloctree/voloctree_mapper.cpp @@ -1229,35 +1229,54 @@ bool VolOctreeMapper::_recoverPartition() clearPartitionMappingLists(); // Locally the mapped mesh build the lists of octants to send - std::map> list_octant; + std::map> list_octant; std::map> list_id; std::map> 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::iterator overlap_ref_rank_begin_it = toreference_rank[m_rank].begin(); + std::vector::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::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); } } @@ -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 &rankOctants = list_octant[reference_rank]; + const std::vector &rankOctants = list_octant[reference_rank]; std::size_t nRankOctants = rankOctants.size(); // Set buffer size @@ -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];