From d0475a8c8234549f09e68eed2e3cb8494f133349 Mon Sep 17 00:00:00 2001 From: Marco Cisternino Date: Fri, 19 Jan 2024 19:41:37 +0100 Subject: [PATCH 1/4] patchkernel: add volume mapper methods to get the pointers to the meshes --- src/patchkernel/volume_mapper.cpp | 20 ++++++++++++++++++++ src/patchkernel/volume_mapper.hpp | 3 +++ 2 files changed, 23 insertions(+) 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; From 90fcb526576c5b49db47cc5ecc1645268a710ee7 Mon Sep 17 00:00:00 2001 From: Marco Cisternino Date: Fri, 19 Jan 2024 19:43:07 +0100 Subject: [PATCH 2/4] voloctree: rework and fix mapped octant list build algorithm --- src/voloctree/voloctree_mapper.cpp | 63 +++++++++++++++++++----------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/src/voloctree/voloctree_mapper.cpp b/src/voloctree/voloctree_mapper.cpp index 6ea1ef829f..c97c436d36 100644 --- a/src/voloctree/voloctree_mapper.cpp +++ b/src/voloctree/voloctree_mapper.cpp @@ -1232,32 +1232,51 @@ bool VolOctreeMapper::_recoverPartition() 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) { + 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); } } From 6cf65bab082118719b70626897e647f9301c5da2 Mon Sep 17 00:00:00 2001 From: Marco Cisternino Date: Thu, 25 Jan 2024 15:59:00 +0100 Subject: [PATCH 3/4] gitignore: avoid tracking folders whose name starts with debug, release and build --- .gitignore | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 + From e6e0e11bb79f1cf8272cdeddf4308e2d06ea1af8 Mon Sep 17 00:00:00 2001 From: Marco Cisternino Date: Wed, 7 Feb 2024 12:14:27 +0100 Subject: [PATCH 4/4] voloctree: avoid some octant copies in volume mapper recover partition method --- src/voloctree/voloctree_mapper.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/voloctree/voloctree_mapper.cpp b/src/voloctree/voloctree_mapper.cpp index c97c436d36..704b407076 100644 --- a/src/voloctree/voloctree_mapper.cpp +++ b/src/voloctree/voloctree_mapper.cpp @@ -1229,7 +1229,7 @@ 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; @@ -1259,14 +1259,14 @@ bool VolOctreeMapper::_recoverPartition() uint64_t reference_last_morton = partitionLDReference[reference_rank]; uint64_t morton = mappedPatch->getTree().getMorton(idx); while (morton < reference_last_morton) { - Octant oct = *mappedPatch->getTree().getOctant(idx); + 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); + m_partitionIR.list_sent_octantIR.emplace_back(*oct, id, globalId, reference_rank); idx++; if (idx == mappedPatch->getTree().getNumOctants()) { break; @@ -1295,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 @@ -1306,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];