|
core
Shared MPI block decomposition + asynchronous ghost-layer exchange (header-only C++20)
|
#include <distributed_octree.hpp>
Classes | |
| struct | FaceGatherPlan |
Static topology of the face-neighbour gather: which out-slots are filled from a local leaf (directSlot/directLeaf) and which must be gathered from an owner (remoteCoords at remoteSlot). More... | |
| struct | FaceInfo |
Classification of leaf i's face on (axis,dir): {state, global fine probe gc, owner, in-block neighbour localNb}. More... | |
| struct | GatherHaloTopology |
Flattened, value-only topology for the face-neighbour gather, established ONCE: the per-matvec exchange then moves only double values (no coords, no locateGlobal) over a fixed graph — the octree analogue of GridHaloTopology::flatten(). More... | |
Public Types | |
| using | Octree = BlockOctree< Dim, Bits > |
| using | M = typename Octree::M |
| using | Code = typename Octree::Code |
| using | Coord = typename Octree::Coord |
Public Member Functions | |
| DistributedOctree ()=default | |
| void | init (IVec< Dim > globalRootSize, unsigned lmax, AmrGeometry< Dim > globalGeo, std::array< bool, Dim > periodic, MPI_Comm comm=MPI_COMM_WORLD) |
Decompose a globalRootSize grid of root cells over the communicator and build this rank's local block octree (uniform, all leaves at level lmax). | |
| Octree & | local () |
| const Octree & | local () const |
| int | rank () const |
| int | size () const |
| MPI_Comm | comm () const |
| unsigned | lmax () const |
| const IVec< Dim > & | blockOriginRoot () const |
| const IVec< Dim > & | blockBrick () const |
| const IVec< Dim > & | globalRootSize () const |
| const IVec< Dim > & | blockFineOrigin () const |
| const IVec< Dim > & | globalFineSize () const |
| const std::array< bool, Dim > & | periodic () const |
| Index | rootSpan () const |
| double | h0 () const |
| const AmrGeometry< Dim > & | globalGeometry () const |
| IVec< Dim > | globalRootOf (Index i) const |
Global root-cell coordinate of local leaf i (lmax==0: the leaf is one root cell). | |
| Index | findGlobalRoot (const IVec< Dim > &g) const |
Local leaf covering global root-cell g, or -1 if not owned by this rank (lmax==0). | |
| AmrGeometry< Dim > | localGeometry () const |
| World geometry of this rank's block (the global geometry shifted to its origin). | |
| Code | globalCode (Index i) const |
Global Morton code of local leaf i (origin in global fine coordinates). | |
| Index | balance () |
| Bring the whole distributed octree to a 2:1-balanced state. | |
| Index | rebalance (std::vector< std::vector< double > > &fields) |
| Re-decompose by per-root-cell octree-leaf count and migrate leaves (with their field columns) to the new owners. | |
| std::vector< double > | faceNeighborGather (const std::vector< double > &field, double sentinel=kNoNeighbor) const |
| For each local leaf and each of the 2*Dim faces, the neighbouring leaf's field value. | |
| FaceGatherPlan | buildFaceGatherPlan () const |
| std::vector< double > | faceNeighborGather (const FaceGatherPlan &plan, const std::vector< double > &field, double sentinel=kNoNeighbor) const |
| Face-neighbour gather using a precomputed FaceGatherPlan: only the field values move, the classification does not re-run. | |
| GatherHaloTopology | buildGatherHaloTopology (const FaceGatherPlan &plan) const |
| Build the value-only gather topology from a FaceGatherPlan: classify each remote coord by owner (owner==rank folds into the local fills), then ONE NBX round in which each owner learns which of its local leaves to send to each requester (locateGlobal happens here, once — never per matvec). | |
| FaceInfo | faceAcross (Index i, int axis, int dir) const |
| std::vector< int > | coverLevels (const std::vector< std::array< Coord, Dim > > &coords) const |
| For each global fine coord (already wrapped into the domain), the level of the covering leaf on its owner, or -1 if none. | |
| std::vector< double > | coverValues (const std::vector< std::array< Coord, Dim > > &coords, const std::vector< double > &field, double sentinel=kNoNeighbor) const |
For each global fine coord, the covering leaf's field value on its owner (sentinel if none). | |
Static Public Attributes | |
| static constexpr double | kNoNeighbor = -1e300 |
| gather sentinel for "no neighbour" | |
Definition at line 52 of file distributed_octree.hpp.
| using peclet::core::amr::DistributedOctree< Dim, Bits >::Octree = BlockOctree<Dim, Bits> |
Definition at line 54 of file distributed_octree.hpp.
| using peclet::core::amr::DistributedOctree< Dim, Bits >::M = typename Octree::M |
Definition at line 55 of file distributed_octree.hpp.
| using peclet::core::amr::DistributedOctree< Dim, Bits >::Code = typename Octree::Code |
Definition at line 56 of file distributed_octree.hpp.
| using peclet::core::amr::DistributedOctree< Dim, Bits >::Coord = typename Octree::Coord |
Definition at line 57 of file distributed_octree.hpp.
|
default |
|
inline |
Decompose a globalRootSize grid of root cells over the communicator and build this rank's local block octree (uniform, all leaves at level lmax).
Definition at line 65 of file distributed_octree.hpp.
References peclet::core::amr::DistributedOctree< Dim, Bits >::comm(), peclet::core::amr::DistributedOctree< Dim, Bits >::globalRootSize(), peclet::core::amr::BlockOctree< Dim, Bits >::init(), peclet::core::amr::DistributedOctree< Dim, Bits >::lmax(), MPI_Comm_rank(), MPI_Comm_size(), and peclet::core::amr::DistributedOctree< Dim, Bits >::periodic().
|
inline |
Definition at line 89 of file distributed_octree.hpp.
Referenced by peclet::core::amr::distributedAdapt(), peclet::core::amr::DistributedPoissonView< Dim, Bits >::init(), peclet::core::amr::DistributedFvOperator< Dim, Bits >::init(), peclet::core::amr::lohnerIndicatorDistributed(), and peclet::core::amr::DistributedPoisson< Dim, Bits >::numLeaves().
|
inline |
Definition at line 90 of file distributed_octree.hpp.
|
inline |
Definition at line 91 of file distributed_octree.hpp.
|
inline |
Definition at line 92 of file distributed_octree.hpp.
|
inline |
Definition at line 93 of file distributed_octree.hpp.
Referenced by peclet::core::amr::DistributedPoissonView< Dim, Bits >::comm(), peclet::core::amr::DistributedGatherHalo< Dim, Bits >::init(), peclet::core::amr::DistributedOctree< Dim, Bits >::init(), peclet::core::amr::DistributedFvOperator< Dim, Bits >::residual(), peclet::core::amr::DistributedPoisson< Dim, Bits >::residual(), peclet::core::amr::DistributedPoissonView< Dim, Bits >::residual(), peclet::core::amr::DistributedPoisson< Dim, Bits >::residualNorm(), and peclet::core::amr::DistributedPoissonView< Dim, Bits >::residualNorm().
|
inline |
Definition at line 94 of file distributed_octree.hpp.
Referenced by peclet::core::amr::DistributedOctree< Dim, Bits >::init().
|
inline |
Definition at line 95 of file distributed_octree.hpp.
|
inline |
Definition at line 96 of file distributed_octree.hpp.
|
inline |
Definition at line 97 of file distributed_octree.hpp.
Referenced by peclet::core::amr::DistributedOctree< Dim, Bits >::init().
|
inline |
Definition at line 98 of file distributed_octree.hpp.
Referenced by peclet::core::amr::DistributedFvOperator< Dim, Bits >::init().
|
inline |
Definition at line 99 of file distributed_octree.hpp.
Referenced by peclet::core::amr::DistributedFvOperator< Dim, Bits >::init().
|
inline |
Definition at line 100 of file distributed_octree.hpp.
Referenced by peclet::core::amr::DistributedOctree< Dim, Bits >::init().
|
inline |
Definition at line 101 of file distributed_octree.hpp.
|
inline |
Definition at line 102 of file distributed_octree.hpp.
Referenced by peclet::core::amr::DistributedFvOperator< Dim, Bits >::init().
|
inline |
Definition at line 103 of file distributed_octree.hpp.
Referenced by peclet::core::amr::DistributedFvOperator< Dim, Bits >::init().
|
inline |
Global root-cell coordinate of local leaf i (lmax==0: the leaf is one root cell).
Definition at line 106 of file distributed_octree.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::code().
Referenced by peclet::core::amr::DistributedOctree< Dim, Bits >::rebalance().
|
inline |
Local leaf covering global root-cell g, or -1 if not owned by this rank (lmax==0).
Used to build the nested fine↔coarse multigrid transfer maps.
Definition at line 116 of file distributed_octree.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::find().
|
inline |
World geometry of this rank's block (the global geometry shifted to its origin).
Definition at line 128 of file distributed_octree.hpp.
References peclet::core::amr::AmrGeometry< Dim >::origin.
|
inline |
Global Morton code of local leaf i (origin in global fine coordinates).
Definition at line 136 of file distributed_octree.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::bounds().
Referenced by peclet::core::amr::DistributedOctree< Dim, Bits >::rebalance().
|
inline |
Bring the whole distributed octree to a 2:1-balanced state.
Returns the number of refinements this rank performed (local + cross-block).
Definition at line 148 of file distributed_octree.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::balance2to1(), peclet::core::amr::BlockOctree< Dim, Bits >::code(), peclet::core::amr::BlockOctree< Dim, Bits >::level(), MPI_Allreduce(), MPI_LONG, MPI_SUM, peclet::core::amr::BlockOctree< Dim, Bits >::numLeaves(), and peclet::core::amr::BlockOctree< Dim, Bits >::refineIf().
Referenced by peclet::core::amr::distributedAdapt().
|
inline |
Re-decompose by per-root-cell octree-leaf count and migrate leaves (with their field columns) to the new owners.
The global mesh is unchanged — this is a pure redistribution of the same leaves, so it is exactly conservative and every cell's field value is preserved bit-for-bit; only ownership (and hence this rank's local octree + block geometry) changes. Each fields[c] is a column indexed by leaf slot (length numLeaves()); on return each holds the migrated/reordered column matching the new local leaf order.
The caller is responsible for the mesh being 2:1-balanced beforehand (it stays balanced, since the leaf set is untouched). Returns the number of leaves this rank migrated away. MPI-optional: a single rank keeps everything.
Definition at line 221 of file distributed_octree.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::assign(), peclet::core::amr::DistributedOctree< Dim, Bits >::globalCode(), peclet::core::amr::DistributedOctree< Dim, Bits >::globalRootOf(), peclet::core::amr::BlockOctree< Dim, Bits >::level(), MPI_Allreduce(), MPI_DOUBLE, MPI_SUM, and peclet::core::amr::BlockOctree< Dim, Bits >::numLeaves().
|
inline |
For each local leaf and each of the 2*Dim faces, the neighbouring leaf's field value.
Layout: out[i*(2*Dim) + 2*axis + (dir>0 ? 0 : 1)]. Domain boundaries (no neighbour) get sentinel. field is indexed by leaf slot.
Definition at line 338 of file distributed_octree.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::numLeaves().
Referenced by peclet::core::amr::DistributedPoisson< Dim, Bits >::apply(), and peclet::core::amr::lohnerIndicatorDistributed().
|
inline |
Definition at line 428 of file distributed_octree.hpp.
References peclet::core::amr::DistributedOctree< Dim, Bits >::FaceGatherPlan::directLeaf, peclet::core::amr::DistributedOctree< Dim, Bits >::FaceGatherPlan::directSlot, peclet::core::amr::DistributedOctree< Dim, Bits >::FaceGatherPlan::nFaces, peclet::core::amr::BlockOctree< Dim, Bits >::numLeaves(), peclet::core::amr::DistributedOctree< Dim, Bits >::FaceGatherPlan::remoteCoords, and peclet::core::amr::DistributedOctree< Dim, Bits >::FaceGatherPlan::remoteSlot.
Referenced by peclet::core::amr::DistributedPoisson< Dim, Bits >::init(), and peclet::core::amr::DistributedPoissonView< Dim, Bits >::init().
|
inline |
Face-neighbour gather using a precomputed FaceGatherPlan: only the field values move, the classification does not re-run.
Bit-identical to faceNeighborGather(field, sentinel).
Definition at line 458 of file distributed_octree.hpp.
References peclet::core::amr::DistributedOctree< Dim, Bits >::coverValues().
|
inline |
Build the value-only gather topology from a FaceGatherPlan: classify each remote coord by owner (owner==rank folds into the local fills), then ONE NBX round in which each owner learns which of its local leaves to send to each requester (locateGlobal happens here, once — never per matvec).
Definition at line 495 of file distributed_octree.hpp.
References peclet::core::amr::DistributedOctree< Dim, Bits >::GatherHaloTopology::nFaces.
Referenced by peclet::core::amr::DistributedPoissonView< Dim, Bits >::init().
|
inline |
Definition at line 571 of file distributed_octree.hpp.
References peclet::core::amr::DistributedOctree< Dim, Bits >::FaceInfo::state.
Referenced by peclet::core::amr::DistributedFvOperator< Dim, Bits >::init().
|
inline |
For each global fine coord (already wrapped into the domain), the level of the covering leaf on its owner, or -1 if none.
Owner-based request/reply.
Definition at line 579 of file distributed_octree.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::level().
Referenced by peclet::core::amr::DistributedFvOperator< Dim, Bits >::init().
|
inline |
For each global fine coord, the covering leaf's field value on its owner (sentinel if none).
Owner-based request/reply — the per-matvec ghost gather.
Definition at line 606 of file distributed_octree.hpp.
Referenced by peclet::core::amr::DistributedFvOperator< Dim, Bits >::apply(), peclet::core::amr::DistributedOctree< Dim, Bits >::faceNeighborGather(), and peclet::core::amr::DistributedFvOperator< Dim, Bits >::jacobi().
|
staticconstexpr |
gather sentinel for "no neighbour"
Definition at line 59 of file distributed_octree.hpp.