peclet-amr 0.2.0
Block-local-Morton AMR octree + collocated cut-cell Navier–Stokes solver (header-only C++20, Kokkos + MPI)
Loading...
Searching...
No Matches
peclet::amr::DistributedFlowMultigrid< Dim, Bits > Class Template Reference

#include <distributed_flow_mg.hpp>

Public Types

using DO = DistributedOctree< Dim, Bits >
 
using Octree = typename DO::Octree
 
using Poisson = AmrPoisson< Dim, Bits >
 
using M = typename Octree::M
 
using Code = typename Octree::Code
 
using StagePolicy = PressureStagePolicy
 Which stage fires where the in-place ladder blocks (docs/amr_mg_core_boundary.md §11.1, §9.6, §9.7; the type and its defaults live in mg_predict.hpp so predictPressureLadder reads the same policy).
 

Public Member Functions

template<class OpenFn >
void build (const DO &finest, double h0, OpenFn &&openFn, const LeafHalo< Dim, Bits > *shared0=nullptr, bool liftRoot=true, Index bottomExtent=4)
 Build with cut-cell openness openFn(faceCentreWorld, axis) → [0,1] on the flow's distributed octree (graded + cross-block 2:1 balanced).
 
template<class OpenFn >
void build (const DO &finest, const Vec< Dim > &h0, OpenFn &&openFn, const LeafHalo< Dim, Bits > *shared0=nullptr, bool liftRoot=true, Index bottomExtent=4)
 Phase 3: the finest spacing per axis; every level inherits the aspect ratio (AM1).
 
void buildRaw (const DO &finest, const Vec< Dim > &h0, const std::vector< double > &alphaLocal, bool liftRoot=true, Index bottomExtent=4)
 Build on finest with its level-0 openness GIVEN as raw rows (AmrPoisson::opennessRaw() layout, the numLeaves() LOCAL rows only) instead of sampled from a geometry — the distributed counterpart of Multigrid::buildRaw, and how a sibling-merge or repartition stage continues the ladder on its target (docs/amr_mg_depth.md §6.5): the moved level's α rows are carried over, never re-sampled.
 
void setStagePolicy (const StagePolicy &p)
 
const StagePolicy & stagePolicy () const
 
void setRemoveMean (bool on)
 Per-level nullspace projection for the singular (periodic pure-Neumann) pressure.
 
std::size_t numLevels () const
 
std::size_t numInPlaceLevels () const
 How many of those levels are IN PLACE — octree coarsenings plus lifted levels, i.e.
 
Index liftDepth () const
 How many levels the ladder gained BELOW the root brick by lifting (§6.2).
 
bool hasStage () const
 Whether a STAGE fires below the in-place ladder (docs/amr_mg_depth.md §5.6/§6.5): the coarsest in-place level is still larger than bottomExtent on some axis, so that level moves onto a new decomposition of its own grid and the ladder continues there: the REPLICATED tail (one block on every rank), or — with the stage policy enabled (the default; setStagePolicy) — a sibling merge or a repartition onto fewer ranks (DistributedStage), as core's chooseStageTarget decides.
 
const char * stageKind () const
 "replicated", "sibling" or "repartition", or "none" without a stage.
 
std::size_t numStageLevels () const
 Levels of the continued ladder (its level 0 IS the moved level, so the full ladder is numInPlaceLevels() + numStageLevels() — the convention predictPressureLadder reports).
 
Index stageLeaves (std::size_t L=0) const
 Cells of continued-ladder level L on this rank's target block (GLOBAL counts for the replicated stage).
 
const IVec< Dim > & stageFrom () const
 The global grid the stage moves (the coarsest in-place level's extent).
 
View< double > stageSolution ()
 The moved level's solution on THIS rank's target block.
 
MgStage< Dim, Bits > & stage ()
 The stage itself, for tests and diagnostics.
 
std::string bottomName () const
 "jacobi" | "amg", suffixed by the stage's own spelling — "+tail" for the replicated one (docs/amr_mg_depth.md §6.7).
 
void setBottom (typename Multigrid< Dim, Bits >::Bottom b)
 Select what solves the coarsest level (docs/amr_mg_depth.md §6.6).
 
Index numLeaves (std::size_t L=0) const
 
Index extendedSize (std::size_t L=0) const
 
View< double > x (std::size_t L=0)
 
View< double > b (std::size_t L=0)
 
const FvOp & op (std::size_t L=0) const
 
MPI_Comm comm () const
 
const Poisson & poisson (std::size_t L=0) const
 
const LeafHalo< Dim, Bits > & halo (std::size_t L=0) const
 
void sync (std::size_t L, View< double > v) const
 Refresh the ghost tail of a level-L vector (the PCG matvec hook uses level 0).
 
void vcycle (int pre=2, int post=2, int bottom=40, double omega=0.8, std::size_t L=0)
 One V-cycle on level L (correction scheme), the distributed mirror of Multigrid::vcycle: ghost refresh before every Jacobi sweep / residual, local transfers, Allreduce'd mean removal.
 

Detailed Description

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

Definition at line 109 of file distributed_flow_mg.hpp.

Member Typedef Documentation

◆ DO

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

Definition at line 111 of file distributed_flow_mg.hpp.

◆ Octree

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

Definition at line 112 of file distributed_flow_mg.hpp.

◆ Poisson

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
using peclet::amr::DistributedFlowMultigrid< Dim, Bits >::Poisson = AmrPoisson<Dim, Bits>

Definition at line 113 of file distributed_flow_mg.hpp.

◆ M

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

Definition at line 114 of file distributed_flow_mg.hpp.

◆ Code

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

Definition at line 115 of file distributed_flow_mg.hpp.

◆ StagePolicy

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
using peclet::amr::DistributedFlowMultigrid< Dim, Bits >::StagePolicy = PressureStagePolicy

Which stage fires where the in-place ladder blocks (docs/amr_mg_core_boundary.md §11.1, §9.6, §9.7; the type and its defaults live in mg_predict.hpp so predictPressureLadder reads the same policy).

A negative maxBlockCells is resolved at build to the Allreduce(MAX) of level 0's local LEAF count; a stage's continued ladder inherits the resolved policy. Takes effect at the next build.

Definition at line 174 of file distributed_flow_mg.hpp.

Member Function Documentation

◆ build() [1/2]

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
template<class OpenFn >
void peclet::amr::DistributedFlowMultigrid< Dim, Bits >::build ( const DO &  finest,
double  h0,
OpenFn &&  openFn,
const LeafHalo< Dim, Bits > *  shared0 = nullptr,
bool  liftRoot = true,
Index  bottomExtent = 4 
)
inline

Build with cut-cell openness openFn(faceCentreWorld, axis) → [0,1] on the flow's distributed octree (graded + cross-block 2:1 balanced).

Collective.

shared0 (optional): a FINALIZED LeafHalo whose registry is a superset of level 0's face probes — the distributed AmrFlow passes its ±2 flow registry so the level-0 operator's ghost columns index the SAME extended layout as the flow's cell vectors (φ, the overlay chains, the PCG/BiCGStab scratch): one layout, no cross-indexing. Level-0 probes (±1 face reach incl. finer sub-neighbours) are a subset of the flow's forEachFaceFull discovery, so every probe resolves from the frozen registry.

liftRoot / bottomExtent continue the ladder BELOW the root brick (docs/amr_mg_depth.md §6.2/§6.4): the lift is LOCKSTEP across ranks, so every rank builds the same number of levels and every per-level collective still pairs up.

Definition at line 131 of file distributed_flow_mg.hpp.

References peclet::amr::DistributedFlowMultigrid< Dim, Bits >::build(), and peclet::amr::transferFieldGradients().

Referenced by peclet::amr::DistributedFlowMultigrid< Dim, Bits >::build().

◆ build() [2/2]

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
template<class OpenFn >
void peclet::amr::DistributedFlowMultigrid< Dim, Bits >::build ( const DO &  finest,
const Vec< Dim > &  h0,
OpenFn &&  openFn,
const LeafHalo< Dim, Bits > *  shared0 = nullptr,
bool  liftRoot = true,
Index  bottomExtent = 4 
)
inline

Phase 3: the finest spacing per axis; every level inherits the aspect ratio (AM1).

Definition at line 139 of file distributed_flow_mg.hpp.

References peclet::amr::transferFieldGradients().

◆ buildRaw()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::amr::DistributedFlowMultigrid< Dim, Bits >::buildRaw ( const DO &  finest,
const Vec< Dim > &  h0,
const std::vector< double > &  alphaLocal,
bool  liftRoot = true,
Index  bottomExtent = 4 
)
inline

Build on finest with its level-0 openness GIVEN as raw rows (AmrPoisson::opennessRaw() layout, the numLeaves() LOCAL rows only) instead of sampled from a geometry — the distributed counterpart of Multigrid::buildRaw, and how a sibling-merge or repartition stage continues the ladder on its target (docs/amr_mg_depth.md §6.5): the moved level's α rows are carried over, never re-sampled.

The ghost rows are exchanged from their owners through the level-0 halo, as every coarser level's are. Collective on finest.comm().

Definition at line 159 of file distributed_flow_mg.hpp.

References peclet::amr::transferFieldGradients().

◆ setStagePolicy()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::amr::DistributedFlowMultigrid< Dim, Bits >::setStagePolicy ( const StagePolicy &  p)
inline

Definition at line 175 of file distributed_flow_mg.hpp.

References peclet::amr::transferFieldGradients().

◆ stagePolicy()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
const StagePolicy & peclet::amr::DistributedFlowMultigrid< Dim, Bits >::stagePolicy ( ) const
inline

Definition at line 176 of file distributed_flow_mg.hpp.

◆ setRemoveMean()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::amr::DistributedFlowMultigrid< Dim, Bits >::setRemoveMean ( bool  on)
inline

Per-level nullspace projection for the singular (periodic pure-Neumann) pressure.

The stage's continued ladder follows this flag rather than being pinned on: on the production path flow sets it true, which is docs/amr_mg_depth.md §6.5.1 step 4's setRemoveMean(true), and with it off the stage stays what §6.5 calls it — the continuation of the same V-cycle — so the WORLD==SELF bitwise contract of §10 still holds where the stage fires.

Definition at line 183 of file distributed_flow_mg.hpp.

◆ numLevels()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
std::size_t peclet::amr::DistributedFlowMultigrid< Dim, Bits >::numLevels ( ) const
inline

Definition at line 189 of file distributed_flow_mg.hpp.

◆ numInPlaceLevels()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
std::size_t peclet::amr::DistributedFlowMultigrid< Dim, Bits >::numInPlaceLevels ( ) const
inline

How many of those levels are IN PLACE — octree coarsenings plus lifted levels, i.e.

the ones that keep the ORB and whose transfers are local. A stage's levels (docs/amr_mg_depth.md §6.5) are appended after them. Compare against predictPressureLadder(...).numInPlace().

Definition at line 193 of file distributed_flow_mg.hpp.

◆ liftDepth()

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

How many levels the ladder gained BELOW the root brick by lifting (§6.2).

Definition at line 195 of file distributed_flow_mg.hpp.

◆ hasStage()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
bool peclet::amr::DistributedFlowMultigrid< Dim, Bits >::hasStage ( ) const
inline

Whether a STAGE fires below the in-place ladder (docs/amr_mg_depth.md §5.6/§6.5): the coarsest in-place level is still larger than bottomExtent on some axis, so that level moves onto a new decomposition of its own grid and the ladder continues there: the REPLICATED tail (one block on every rank), or — with the stage policy enabled (the default; setStagePolicy) — a sibling merge or a repartition onto fewer ranks (DistributedStage), as core's chooseStageTarget decides.

Definition at line 202 of file distributed_flow_mg.hpp.

◆ stageKind()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
const char * peclet::amr::DistributedFlowMultigrid< Dim, Bits >::stageKind ( ) const
inline

"replicated", "sibling" or "repartition", or "none" without a stage.

Definition at line 204 of file distributed_flow_mg.hpp.

◆ numStageLevels()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
std::size_t peclet::amr::DistributedFlowMultigrid< Dim, Bits >::numStageLevels ( ) const
inline

Levels of the continued ladder (its level 0 IS the moved level, so the full ladder is numInPlaceLevels() + numStageLevels() — the convention predictPressureLadder reports).

Definition at line 207 of file distributed_flow_mg.hpp.

References peclet::amr::transferFieldGradients().

◆ stageLeaves()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
Index peclet::amr::DistributedFlowMultigrid< Dim, Bits >::stageLeaves ( std::size_t  L = 0) const
inline

Cells of continued-ladder level L on this rank's target block (GLOBAL counts for the replicated stage).

Precondition
hasStage().

Definition at line 210 of file distributed_flow_mg.hpp.

References peclet::amr::transferFieldGradients().

◆ stageFrom()

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

The global grid the stage moves (the coarsest in-place level's extent).

Definition at line 212 of file distributed_flow_mg.hpp.

◆ stageSolution()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
View< double > peclet::amr::DistributedFlowMultigrid< Dim, Bits >::stageSolution ( )
inline

The moved level's solution on THIS rank's target block.

For the replicated stage every rank holds an identical copy, which is what §11.2's cross-rank bitwise check reads.

Definition at line 215 of file distributed_flow_mg.hpp.

◆ stage()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
MgStage< Dim, Bits > & peclet::amr::DistributedFlowMultigrid< Dim, Bits >::stage ( )
inline

The stage itself, for tests and diagnostics.

Precondition
hasStage().

Definition at line 217 of file distributed_flow_mg.hpp.

◆ bottomName()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
std::string peclet::amr::DistributedFlowMultigrid< Dim, Bits >::bottomName ( ) const
inline

"jacobi" | "amg", suffixed by the stage's own spelling — "+tail" for the replicated one (docs/amr_mg_depth.md §6.7).

Without a stage the coarsest in-place level is already at or below bottomExtent, where the 60 damped-Jacobi sweeps are exact.

Definition at line 221 of file distributed_flow_mg.hpp.

◆ setBottom()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::amr::DistributedFlowMultigrid< Dim, Bits >::setBottom ( typename Multigrid< Dim, Bits >::Bottom  b)
inline

Select what solves the coarsest level (docs/amr_mg_depth.md §6.6).

The exact bottom lives in the single-rank Multigrid, so on this path it is the STAGE's bottom: without a stage the coarsest in-place level is at or below bottomExtent and the sweeps there are exact, which is why §6.6 scopes the agglomerated solve to Multigrid and the stage.

COLLECTIVE whenever no stage exists yet: the selection is re-decided by buildStage, which may BUILD the replicated stage (an Allgatherv of the coarsest level) — e.g. Agglomerated at np > 1 on a ladder that stopped at or below bottomExtent. With a stage already built it only re-selects the stage's own bottom; the stage stays. Call it on every rank. Before build it just stores the selection.

Definition at line 237 of file distributed_flow_mg.hpp.

References peclet::amr::DistributedFlowMultigrid< Dim, Bits >::b().

◆ numLeaves()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
Index peclet::amr::DistributedFlowMultigrid< Dim, Bits >::numLeaves ( std::size_t  L = 0) const
inline

Definition at line 244 of file distributed_flow_mg.hpp.

References peclet::amr::transferFieldGradients().

◆ extendedSize()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
Index peclet::amr::DistributedFlowMultigrid< Dim, Bits >::extendedSize ( std::size_t  L = 0) const
inline

Definition at line 245 of file distributed_flow_mg.hpp.

References peclet::amr::transferFieldGradients().

◆ x()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
View< double > peclet::amr::DistributedFlowMultigrid< Dim, Bits >::x ( std::size_t  L = 0)
inline

◆ b()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
View< double > peclet::amr::DistributedFlowMultigrid< Dim, Bits >::b ( std::size_t  L = 0)
inline

◆ op()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
const FvOp & peclet::amr::DistributedFlowMultigrid< Dim, Bits >::op ( std::size_t  L = 0) const
inline

Definition at line 248 of file distributed_flow_mg.hpp.

References peclet::amr::transferFieldGradients().

◆ comm()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
MPI_Comm peclet::amr::DistributedFlowMultigrid< Dim, Bits >::comm ( ) const
inline

Definition at line 249 of file distributed_flow_mg.hpp.

◆ poisson()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
const Poisson & peclet::amr::DistributedFlowMultigrid< Dim, Bits >::poisson ( std::size_t  L = 0) const
inline

Definition at line 250 of file distributed_flow_mg.hpp.

References peclet::amr::transferFieldGradients().

◆ halo()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
const LeafHalo< Dim, Bits > & peclet::amr::DistributedFlowMultigrid< Dim, Bits >::halo ( std::size_t  L = 0) const
inline

Definition at line 251 of file distributed_flow_mg.hpp.

References peclet::amr::transferFieldGradients().

◆ sync()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::amr::DistributedFlowMultigrid< Dim, Bits >::sync ( std::size_t  L,
View< double >  v 
) const
inline

Refresh the ghost tail of a level-L vector (the PCG matvec hook uses level 0).

Definition at line 254 of file distributed_flow_mg.hpp.

References peclet::amr::transferFieldGradients().

◆ vcycle()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::amr::DistributedFlowMultigrid< Dim, Bits >::vcycle ( int  pre = 2,
int  post = 2,
int  bottom = 40,
double  omega = 0.8,
std::size_t  L = 0 
)
inline

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