|
core
Shared MPI block decomposition + asynchronous ghost-layer exchange (header-only C++20)
|
Per-block adaptive octree over block-local Morton codes. More...
#include <block_octree.hpp>
Public Types | |
| using | M = morton::Morton< Dim, Bits > |
| using | Code = typename M::code_type |
| using | Coord = typename M::coord_type |
Public Member Functions | |
| BlockOctree ()=default | |
| BlockOctree (IVec< Dim > brick, unsigned lmax, IVec< Dim > globalOrigin=IVec< Dim >{}) | |
Build a uniform block: a brick (in root cells) of leaves at level lmax. | |
| void | init (IVec< Dim > brick, unsigned lmax, IVec< Dim > globalOrigin=IVec< Dim >{}) |
| void | assign (IVec< Dim > brick, unsigned lmax, IVec< Dim > globalOrigin, std::vector< Code > codes, std::vector< std::uint8_t > levels) |
| Replace the entire leaf set directly (used by load-balancing migration, which rebuilds a block from leaves received from other ranks). | |
| Index | numLeaves () const |
| unsigned | lmax () const |
| const IVec< Dim > & | brick () const |
| const IVec< Dim > & | globalOrigin () const |
| Code | code (Index i) const |
| unsigned | level (Index i) const |
| const std::vector< Code > & | codes () const |
| const std::vector< std::uint8_t > & | levels () const |
| Index | find (Code p) const |
Leaf containing Morton code p, or -1. Host wrapper over amrLocate. | |
| Index | find (const std::array< Coord, Dim > &fine) const |
| Leaf containing fine-unit coordinates, or -1. | |
| std::array< std::array< Coord, Dim >, 2 > | bounds (Index i) const |
Inclusive integer bounds [lo, hi] of leaf i in fine units. | |
| Index | faceNeighbor (Index i, int axis, int dir) const |
The leaf across leaf i's face on axis in direction dir (±1), or -1 if it lies outside the block. | |
| template<class Pred > | |
| Index | refineIf (Pred &&pred) |
Split every leaf for which pred(code, level) is true (and level > 0) into its 2^Dim children one level finer. | |
| bool | refineLeaf (Index i) |
| Refine a single leaf by index. Returns true if it was split. | |
| template<class Pred > | |
| Index | coarsenIf (Pred &&pred) |
Merge complete sibling groups (all 2^Dim children present, all at the same level) whose parent satisfies pred(parentCode, parentLevel). | |
| Index | balance2to1 () |
| Enforce 2:1 (graded) balance within this block: no two face-adjacent leaves differ by more than one level. | |
| bool | isBalanced () const |
| True iff the leaves form a valid 2:1-balanced partition: every face neighbour differs by at most one level. | |
Static Public Member Functions | |
| static constexpr unsigned | bits () |
Static Public Attributes | |
| static constexpr unsigned | octants = M::octants |
Per-block adaptive octree over block-local Morton codes.
Bits is the per-axis code width; the default keeps codes in a built-in 64-bit integer (3D: 21 bits/axis, 2D: 32). A block must satisfy brick[i]*2^lmax <= 2^Bits.
Definition at line 78 of file block_octree.hpp.
| using peclet::core::amr::BlockOctree< Dim, Bits >::M = morton::Morton<Dim, Bits> |
Definition at line 80 of file block_octree.hpp.
| using peclet::core::amr::BlockOctree< Dim, Bits >::Code = typename M::code_type |
Definition at line 81 of file block_octree.hpp.
| using peclet::core::amr::BlockOctree< Dim, Bits >::Coord = typename M::coord_type |
Definition at line 82 of file block_octree.hpp.
|
default |
|
inline |
Build a uniform block: a brick (in root cells) of leaves at level lmax.
globalOrigin is the block's lower corner in the global coarse grid's root-cell coordinates (metadata used by the distributed layer; the local codes here are origin-relative and independent of it).
Definition at line 91 of file block_octree.hpp.
|
inline |
Definition at line 95 of file block_octree.hpp.
Referenced by peclet::core::amr::BarnesHut< Dim, Bits >::build(), and peclet::core::amr::DistributedOctree< Dim, Bits >::init().
|
inline |
Replace the entire leaf set directly (used by load-balancing migration, which rebuilds a block from leaves received from other ranks).
codes are block-local origin codes and levels their parallel levels; they need not be sorted — assign() restores the Z-order invariant. brick/lmax/globalOrigin describe the (possibly new) block geometry the codes are relative to.
Definition at line 119 of file block_octree.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::brick(), peclet::core::amr::BlockOctree< Dim, Bits >::codes(), peclet::core::amr::BlockOctree< Dim, Bits >::globalOrigin(), peclet::core::amr::BlockOctree< Dim, Bits >::levels(), and peclet::core::amr::BlockOctree< Dim, Bits >::lmax().
Referenced by peclet::core::amr::DistributedOctree< Dim, Bits >::rebalance().
|
inline |
Definition at line 130 of file block_octree.hpp.
Referenced by peclet::core::amr::DistributedOctree< Dim, Bits >::balance(), peclet::core::amr::BarnesHut< Dim, Bits >::build(), peclet::core::amr::DistributedOctree< Dim, Bits >::buildFaceGatherPlan(), peclet::core::amr::DistributedOctree< Dim, Bits >::faceNeighborGather(), peclet::core::amr::BlockOctree< Dim, Bits >::find(), peclet::core::amr::flagByIndicator(), peclet::core::amr::DistributedPoissonView< Dim, Bits >::init(), peclet::core::amr::DistributedFvOperator< Dim, Bits >::init(), peclet::core::amr::lohnerIndicatorDistributed(), peclet::core::amr::AmrCutCell< Bits >::numLeaves(), peclet::core::amr::DistributedPoisson< Dim, Bits >::numLeaves(), peclet::core::amr::AmrPoisson< Dim, Bits >::numLeaves(), peclet::core::amr::ScalarTransport< Dim, Bits >::numLeaves(), peclet::core::amr::DistributedOctree< Dim, Bits >::rebalance(), and peclet::core::amr::transferField().
|
inline |
Definition at line 131 of file block_octree.hpp.
Referenced by peclet::core::amr::BlockOctree< Dim, Bits >::assign(), and peclet::core::amr::flagByIndicator().
|
inlinestaticconstexpr |
Definition at line 132 of file block_octree.hpp.
|
inline |
Definition at line 133 of file block_octree.hpp.
Referenced by peclet::core::amr::BlockOctree< Dim, Bits >::assign().
|
inline |
Definition at line 134 of file block_octree.hpp.
Referenced by peclet::core::amr::BlockOctree< Dim, Bits >::assign().
|
inline |
Definition at line 135 of file block_octree.hpp.
Referenced by peclet::core::amr::DistributedOctree< Dim, Bits >::balance(), peclet::core::amr::BarnesHut< Dim, Bits >::build(), peclet::core::amr::BlockOctree< Dim, Bits >::find(), peclet::core::amr::DistributedOctree< Dim, Bits >::globalRootOf(), and peclet::core::amr::transferField().
|
inline |
Definition at line 136 of file block_octree.hpp.
Referenced by peclet::core::amr::AmrPoisson< Dim, Bits >::applyLaplacianQuad(), peclet::core::amr::DistributedOctree< Dim, Bits >::balance(), peclet::core::amr::AmrPoisson< Dim, Bits >::boundaryDiag(), peclet::core::amr::BarnesHut< Dim, Bits >::build(), peclet::core::amr::AmrPoisson< Dim, Bits >::buildOpenness(), peclet::core::amr::AmrPoisson< Dim, Bits >::cellWidth(), peclet::core::amr::ScalarTransport< Dim, Bits >::cellWidth(), peclet::core::amr::AmrPoisson< Dim, Bits >::coarseStar(), peclet::core::amr::DistributedOctree< Dim, Bits >::coverLevels(), peclet::core::amr::flagByIndicator(), peclet::core::amr::ScalarTransport< Dim, Bits >::forEachFace(), peclet::core::amr::AmrPoisson< Dim, Bits >::forEachFaceFull(), peclet::core::amr::AmrPoisson< Dim, Bits >::forEachFaceNeighbor(), peclet::core::amr::AmrPoisson< Dim, Bits >::periodicNeighbor(), peclet::core::amr::DistributedOctree< Dim, Bits >::rebalance(), and peclet::core::amr::transferField().
|
inline |
Definition at line 137 of file block_octree.hpp.
Referenced by peclet::core::amr::BlockOctree< Dim, Bits >::assign().
|
inline |
Definition at line 138 of file block_octree.hpp.
Referenced by peclet::core::amr::BlockOctree< Dim, Bits >::assign().
|
inline |
Leaf containing Morton code p, or -1. Host wrapper over amrLocate.
Definition at line 143 of file block_octree.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::numLeaves().
Referenced by peclet::core::amr::adaptField(), peclet::core::amr::BlockOctree< Dim, Bits >::faceNeighbor(), peclet::core::amr::DistributedOctree< Dim, Bits >::findGlobalRoot(), peclet::core::amr::ScalarTransport< Dim, Bits >::forEachFace(), peclet::core::amr::AmrPoisson< Dim, Bits >::forEachFaceFull(), peclet::core::amr::AmrPoisson< Dim, Bits >::forEachFaceNeighbor(), peclet::core::amr::AmrPoisson< Dim, Bits >::periodicNeighbor(), and peclet::core::amr::transferField().
|
inline |
Leaf containing fine-unit coordinates, or -1.
Definition at line 145 of file block_octree.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::code(), and peclet::core::amr::BlockOctree< Dim, Bits >::find().
Referenced by peclet::core::amr::BlockOctree< Dim, Bits >::find().
|
inline |
Inclusive integer bounds [lo, hi] of leaf i in fine units.
Definition at line 148 of file block_octree.hpp.
Referenced by peclet::core::amr::AmrPoisson< Dim, Bits >::boundaryDiag(), peclet::core::amr::AmrPoisson< Dim, Bits >::buildOpenness(), peclet::core::amr::AmrPoisson< Dim, Bits >::coarseStar(), peclet::core::amr::ScalarTransport< Dim, Bits >::forEachFace(), peclet::core::amr::AmrPoisson< Dim, Bits >::forEachFaceFull(), peclet::core::amr::AmrPoisson< Dim, Bits >::forEachFaceNeighbor(), peclet::core::amr::DistributedOctree< Dim, Bits >::globalCode(), and peclet::core::amr::AmrPoisson< Dim, Bits >::periodicNeighbor().
|
inline |
The leaf across leaf i's face on axis in direction dir (±1), or -1 if it lies outside the block.
With 2:1 balance this lands in a same-, one- coarser-, or one-finer-level neighbour (the corner-most, for the finer case).
Definition at line 162 of file block_octree.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::find().
Referenced by peclet::core::amr::BlockOctree< Dim, Bits >::balance2to1(), peclet::core::amr::BlockOctree< Dim, Bits >::isBalanced(), and peclet::core::amr::transferField().
|
inline |
Split every leaf for which pred(code, level) is true (and level > 0) into its 2^Dim children one level finer.
Returns the number of leaves split. A single forward pass: children of a parent occupy the parent's code range in ascending octant == ascending code order, so the sorted invariant holds without a re-sort.
Definition at line 183 of file block_octree.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::octants.
Referenced by peclet::core::amr::DistributedOctree< Dim, Bits >::balance(), peclet::core::amr::BlockOctree< Dim, Bits >::balance2to1(), peclet::core::amr::BarnesHut< Dim, Bits >::build(), peclet::core::amr::distributedAdapt(), and peclet::core::amr::BlockOctree< Dim, Bits >::refineLeaf().
|
inline |
Refine a single leaf by index. Returns true if it was split.
Definition at line 210 of file block_octree.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::refineIf().
|
inline |
Merge complete sibling groups (all 2^Dim children present, all at the same level) whose parent satisfies pred(parentCode, parentLevel).
Returns the number of groups merged. Siblings are consecutive in the sorted array.
Definition at line 219 of file block_octree.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::octants.
Referenced by peclet::core::amr::adaptField(), and peclet::core::amr::distributedAdapt().
|
inline |
Enforce 2:1 (graded) balance within this block: no two face-adjacent leaves differ by more than one level.
Iterates to a fixpoint; returns the total number of refinements performed. Detection is from the fine side — a leaf at level Lf probes one cell across each face; that point always lands inside a coarser neighbour, so any neighbour with level >= Lf+2 is found and split.
Definition at line 261 of file block_octree.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::faceNeighbor(), and peclet::core::amr::BlockOctree< Dim, Bits >::refineIf().
Referenced by peclet::core::amr::DistributedOctree< Dim, Bits >::balance().
|
inline |
True iff the leaves form a valid 2:1-balanced partition: every face neighbour differs by at most one level.
(Test/debug helper.)
Definition at line 288 of file block_octree.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::faceNeighbor().
|
staticconstexpr |
Definition at line 83 of file block_octree.hpp.
Referenced by peclet::core::amr::BlockOctree< Dim, Bits >::coarsenIf(), and peclet::core::amr::BlockOctree< Dim, Bits >::refineIf().