core
Shared MPI block decomposition + asynchronous ghost-layer exchange (header-only C++20)
Loading...
Searching...
No Matches
peclet::core::amr::DistributedOctree< Dim, Bits > Class Template Reference

#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).
 
Octreelocal ()
 
const Octreelocal () 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< doublefaceNeighborGather (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< doublefaceNeighborGather (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< intcoverLevels (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< doublecoverValues (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"
 

Detailed Description

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
class peclet::core::amr::DistributedOctree< Dim, Bits >

Definition at line 52 of file distributed_octree.hpp.

Member Typedef Documentation

◆ Octree

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
using peclet::core::amr::DistributedOctree< Dim, Bits >::Octree = BlockOctree<Dim, Bits>

Definition at line 54 of file distributed_octree.hpp.

◆ M

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
using peclet::core::amr::DistributedOctree< Dim, Bits >::M = typename Octree::M

Definition at line 55 of file distributed_octree.hpp.

◆ Code

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
using peclet::core::amr::DistributedOctree< Dim, Bits >::Code = typename Octree::Code

Definition at line 56 of file distributed_octree.hpp.

◆ Coord

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
using peclet::core::amr::DistributedOctree< Dim, Bits >::Coord = typename Octree::Coord

Definition at line 57 of file distributed_octree.hpp.

Constructor & Destructor Documentation

◆ DistributedOctree()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
peclet::core::amr::DistributedOctree< Dim, Bits >::DistributedOctree ( )
default

Member Function Documentation

◆ init()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::DistributedOctree< Dim, Bits >::init ( IVec< Dim >  globalRootSize,
unsigned  lmax,
AmrGeometry< Dim >  globalGeo,
std::array< bool, Dim >  periodic,
MPI_Comm  comm = MPI_COMM_WORLD 
)
inline

◆ local() [1/2]

◆ local() [2/2]

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
const Octree & peclet::core::amr::DistributedOctree< Dim, Bits >::local ( ) const
inline

Definition at line 90 of file distributed_octree.hpp.

◆ rank()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
int peclet::core::amr::DistributedOctree< Dim, Bits >::rank ( ) const
inline

Definition at line 91 of file distributed_octree.hpp.

◆ size()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
int peclet::core::amr::DistributedOctree< Dim, Bits >::size ( ) const
inline

Definition at line 92 of file distributed_octree.hpp.

◆ comm()

◆ lmax()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
unsigned peclet::core::amr::DistributedOctree< Dim, Bits >::lmax ( ) const
inline

◆ blockOriginRoot()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
const IVec< Dim > & peclet::core::amr::DistributedOctree< Dim, Bits >::blockOriginRoot ( ) const
inline

Definition at line 95 of file distributed_octree.hpp.

◆ blockBrick()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
const IVec< Dim > & peclet::core::amr::DistributedOctree< Dim, Bits >::blockBrick ( ) const
inline

Definition at line 96 of file distributed_octree.hpp.

◆ globalRootSize()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
const IVec< Dim > & peclet::core::amr::DistributedOctree< Dim, Bits >::globalRootSize ( ) const
inline

◆ blockFineOrigin()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
const IVec< Dim > & peclet::core::amr::DistributedOctree< Dim, Bits >::blockFineOrigin ( ) const
inline

◆ globalFineSize()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
const IVec< Dim > & peclet::core::amr::DistributedOctree< Dim, Bits >::globalFineSize ( ) const
inline

◆ periodic()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
const std::array< bool, Dim > & peclet::core::amr::DistributedOctree< Dim, Bits >::periodic ( ) const
inline

◆ rootSpan()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
Index peclet::core::amr::DistributedOctree< Dim, Bits >::rootSpan ( ) const
inline

Definition at line 101 of file distributed_octree.hpp.

◆ h0()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
double peclet::core::amr::DistributedOctree< Dim, Bits >::h0 ( ) const
inline

◆ globalGeometry()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
const AmrGeometry< Dim > & peclet::core::amr::DistributedOctree< Dim, Bits >::globalGeometry ( ) const
inline

◆ globalRootOf()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
IVec< Dim > peclet::core::amr::DistributedOctree< Dim, Bits >::globalRootOf ( Index  i) const
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().

◆ findGlobalRoot()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
Index peclet::core::amr::DistributedOctree< Dim, Bits >::findGlobalRoot ( const IVec< Dim > &  g) const
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().

◆ localGeometry()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
AmrGeometry< Dim > peclet::core::amr::DistributedOctree< Dim, Bits >::localGeometry ( ) const
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.

◆ globalCode()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
Code peclet::core::amr::DistributedOctree< Dim, Bits >::globalCode ( Index  i) const
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().

◆ balance()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
Index peclet::core::amr::DistributedOctree< Dim, Bits >::balance ( )
inline

◆ rebalance()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
Index peclet::core::amr::DistributedOctree< Dim, Bits >::rebalance ( std::vector< std::vector< double > > &  fields)
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().

◆ faceNeighborGather() [1/2]

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
std::vector< double > peclet::core::amr::DistributedOctree< Dim, Bits >::faceNeighborGather ( const std::vector< double > &  field,
double  sentinel = kNoNeighbor 
) const
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().

◆ buildFaceGatherPlan()

◆ faceNeighborGather() [2/2]

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
std::vector< double > peclet::core::amr::DistributedOctree< Dim, Bits >::faceNeighborGather ( const FaceGatherPlan plan,
const std::vector< double > &  field,
double  sentinel = kNoNeighbor 
) const
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().

◆ buildGatherHaloTopology()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
GatherHaloTopology peclet::core::amr::DistributedOctree< Dim, Bits >::buildGatherHaloTopology ( const FaceGatherPlan plan) const
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().

◆ faceAcross()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
FaceInfo peclet::core::amr::DistributedOctree< Dim, Bits >::faceAcross ( Index  i,
int  axis,
int  dir 
) const
inline

◆ coverLevels()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
std::vector< int > peclet::core::amr::DistributedOctree< Dim, Bits >::coverLevels ( const std::vector< std::array< Coord, Dim > > &  coords) const
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().

◆ coverValues()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
std::vector< double > peclet::core::amr::DistributedOctree< Dim, Bits >::coverValues ( const std::vector< std::array< Coord, Dim > > &  coords,
const std::vector< double > &  field,
double  sentinel = kNoNeighbor 
) const
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().

Member Data Documentation

◆ kNoNeighbor

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
constexpr double peclet::core::amr::DistributedOctree< Dim, Bits >::kNoNeighbor = -1e300
staticconstexpr

gather sentinel for "no neighbour"

Definition at line 59 of file distributed_octree.hpp.


The documentation for this class was generated from the following file: