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

#include <flow.hpp>

Public Types

using Octree = BlockOctree< 3, Bits >
 

Public Member Functions

void init (const Octree &t, Real h0, Vec< 3 > origin=Vec< 3 >{})
 
void initMpi (DistributedOctree< 3, Bits > &d)
 Distributed mode (docs/amr_distributed_flow.md, rung 4): run this solver on one ORB block of a DistributedOctree — the whole step (momentum, pressure, overlays) then executes multi-rank through the LeafHalo ±2 ghost registry established in setSolid.
 
void setDensity (double rho)
 
void setViscosity (double mu)
 
void setDt (double dt)
 
void setBodyForce (double fx, double fy, double fz)
 
void setPressurePCG (bool on)
 Use MG-preconditioned CG for the pressure solve (default) vs plain V-cycles.
 
void setGhostGradient (bool on)
 Directional ghost cell-gradient for the −∇pⁿ predictor and the projection's cell correction (the AMR analog of flow's collocated set_face_interp(9) hybrid): on cut cells the ABC grad3 reads the DECOUPLED p=0 of solid-centered neighbours through partially-open faces — a gauge-dependent O(1/h) gradient error (measured in tests/study_amr_ghost_apriori.cpp).
 
void setGhostProjection (bool on, int matrixOrder=2, int rhsOrder=2)
 FULL directional ghost-cell projection (the AMR port of flow's collocated set_ghost_projection): the pressure system becomes rho·(L_bin + Delta) phi = rho·D_g(u*) — the BINARY-openness FV Laplacian (a face is open iff its sample + both adjacent centers are fluid; preconditioned by the UNCHANGED openness-MG hierarchy built on that openness) plus the wall-anchored closure overlay on the finest-band rows (peclet::core::scheme, shared with flow), solved by MG-preconditioned BiCGStab on the coupled subspace; the constraint is the ghost-closed divergence of the ½/½ face-averaged field.
 
void setCfScheme (int scheme)
 Coarse/fine (2:1) interface scheme (cf_scheme.hpp): 0 = standard two-point flux (default, 1st-order at level boundaries, bit-identical legacy path), 1 = Martin–Cartwright tangential quadratic (2nd-order — measured at C/F rows: divergence 1.95, cell gradient 1.95, momentum SOLUTION 2.0 in test_amr_cf_vector).
 
void setAdvection (bool on)
 Enable momentum advection ∇·(u u) (default OFF ⇒ Stokes).
 
void setImplicitAdvection (bool on)
 Implicit-FOU deferred correction (default ON).
 
void setAdvectionScheme (int s)
 High-order advection scheme: 0 = second-order upwind (SOU, default), 1 = Koren TVD.
 
void setMomentumTol (double tol)
 Relative tolerance for the per-step momentum BiCGStab solve (default 1e-8).
 
void setMomentumMG (bool on)
 Use the Galerkin velocity multigrid (MomentumMG) as the momentum BiCGStab preconditioner.
 
void setVelocityMGStaircase (bool on)
 Choose the momentum-MG coarse-operator strategy: false (default) = Galerkin (MomentumMG, A_c = R·A·P of the exact cut-cell operator); true = rediscretized staircase (VelocityMG, mirroring flow's VelocityMG).
 
void setVelocityMGMinCoarse (Index m)
 Pore-scale cap for the staircase velocity-MG: the coarsest level keeps ≥ this many cells, so it still resolves the immersed feature (a small object that vanishes from the coarse κ classification leaves an inconsistent operator that diverges).
 
void setMomentumGS (bool on)
 Opt-in: use the multicolour Gauss–Seidel smoother in the momentum MG (Galerkin or staircase) instead of weighted Jacobi — ~2× better smoothing (fewer V-cycles / BiCGStab iters), and the strong fine smoother the staircase needs on the cut band.
 
void setMomentumMGSolver (bool on)
 Opt-in (P4): solve the momentum predictor with the velocity multigrid used as the solver — MG-preconditioned defect correction u ← u + M⁻¹(b − A u) iterated to tolerance — instead of BiCGStab with the same MG as a preconditioner.
 
void setOuterIterations (int n, double tol=1e-6)
 Optional Picard outer loop over the lagged advection (mirror of flow's outerIters_): each outer iteration re-freezes the advecting velocity at the latest u and re-solves the predictor, stopping early when the max |Δu| between successive outer iterates falls below tol.
 
template<class SdfFn >
void setSolid (SdfFn &&sdfFn)
 Build the cut-cell operators (host) + upload all device structures.
 
void step (int momIters=100, int presIters=60)
 One incompressible step on device (Stokes, or Navier–Stokes with setAdvection).
 
void project (int presIters=60)
 Pressure projection of the current velocity in place.
 
void finishProjection (Index n)
 Shared projection tail: build the div-free face field from u* + φ, correct the cell velocities (ABC / ghost gradient), rotational pressure update.
 
void beginAdapt ()
 Snapshot the octree topology + (u, p) ahead of an external mesh mutation.
 
template<class SdfFn >
void finishAdapt (SdfFn &&sdfFn)
 Rebuild on the mutated octree and transfer the snapshotted fields onto it.
 
template<class SdfFn >
void rebalanceMpi (SdfFn &&sdfFn)
 Distributed load rebalance (docs/amr_distributed_flow.md, rung 6): re-decompose the octree by leaf count (weighted ORB) and migrate the leaves WITH the state (u, p) to the new owners, then rebuild every solver structure on the new block (full distributed setSolid: new ±2 registry, halos, operators, pressure hierarchy).
 
void setPressure (const std::vector< double > &h)
 Write the accumulated rotational pressure from host (restart / finishAdapt).
 
void zeroSolid (View< double > v)
 Zero a per-leaf field on non-fluid cells (the transferred fields' solid cleanup).
 
std::vector< doubledebugSou (int comp)
 DEBUG: the raw high-order advection ∇·(u u_comp) per cell from the current velocity (== host oracle::AmrFlow::advectTerm).
 
template<class MG >
void runMgVcycle (MG &mg, View< const double > r, View< double > z)
 Run one V-cycle of a momentum MG as a preconditioner: z = M⁻¹ r.
 
void copyToHost (const View< double > &d, std::vector< double > &h) const
 Copy a device View into a host vector (sized n_).
 
void setVelocity (int c, const std::vector< double > &h)
 Set a velocity component from host (testing / initial conditions).
 
std::vector< doublevelocity (int c) const
 Copy a velocity component back to host (single D2H, no host loop — S2a).
 
std::vector< doublepressure () const
 Copy the pressure field back to host (single D2H), (num_leaves,) — the incremental-rotational p.
 
std::vector< doublelocalVector (const View< double > &v) const
 Host copy of the LOCAL rows of a (possibly ghost-extended) per-cell field.
 
std::vector< doublevelocities () const
 All three velocity components interleaved as a flat (n,3) row-major host buffer (out[i*3+c]) with a single device→host transfer (G6): the three independent component Views are packed on-device first (cheap), so the boundary is crossed once rather than three times as repeated velocity(c) calls would.
 
double divNormL2 ()
 L2 norm of the (openness-weighted) divergence of the current velocity — the ghost-closed divergence when the ghost projection is on (its constraint IS the residual diagnostic).
 
double divNormFace ()
 L2 norm of the divergence of the ABC face field uf_ (built each project()): the φ-solve residual, far below the cell field's O(h²) divNormL2 — including across 2:1 interfaces.
 
std::vector< doublefaceField () const
 Copy the divergence-free face field to host (one value per CSR (sub)face, forEachFaceFull order).
 
Index numLeaves () const
 
Index numGhostCells () const
 Distributed: number of ghost slots in the ±2 registry (0 single-rank).
 
bool isFluid (Index i) const
 Per-leaf fluid mask (false inside the solid) — for host-side post-processing / bindings.
 
int lastMomIters () const
 Total momentum BiCGStab iterations (summed over the 3 components) of the last step.
 
int lastPresIters () const
 Pressure PCG iterations of the last step.
 
int lastOuterIters () const
 Picard outer iterations actually run in the last step (1 unless setOuterIterations(>1)).
 
void syncVel ()
 Refresh the ghost tails of the three velocity components (one batched message round).
 
void syncScalar (View< double > v)
 Refresh the ghost tail of one cell scalar (p, φ, Krylov scratch).
 
double allSum (double s) const
 Global sum (identity single-rank).
 
const FvOpgpOp0 ()
 The pressure operator the ghost solver runs on (distributed MG level 0 or presMG_'s).
 
template<class SdfFn >
void prepareDistributed (SdfFn &&sdfFn)
 Install the resolver seams, run every prober to the miss-collect fixpoint, freeze the ±2 halo, hook the solvers.
 
void installGhostMeta ()
 Mirror the halo registry's ghost metadata (block-local lo + level) into mom_ and pres_.
 
void gpProject (View< double > v)
 
void ghostMatvec (View< const double > x, View< double > y)
 
void ghostPrec (View< const double > r, View< double > z)
 
int solveGhostBiCGStab (View< double > x, View< const double > b, int maxIters, double tol=1e-10)
 

Static Public Member Functions

static double maxAbsDiff (View< const double > a, View< const double > b, Index n)
 Max |a − b| over all cells (the Picard outer-loop convergence measure).
 

Detailed Description

template<unsigned Bits = 21u>
class peclet::core::amr::AmrFlow< Bits >

Definition at line 463 of file flow.hpp.

Member Typedef Documentation

◆ Octree

template<unsigned Bits = 21u>
using peclet::core::amr::AmrFlow< Bits >::Octree = BlockOctree<3, Bits>

Definition at line 465 of file flow.hpp.

Member Function Documentation

◆ init()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::init ( const Octree t,
Real  h0,
Vec< 3 >  origin = Vec<3>{} 
)
inline

Definition at line 467 of file flow.hpp.

Referenced by peclet::core::amr::AmrFlow< Bits >::initMpi().

◆ initMpi()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::initMpi ( DistributedOctree< 3, Bits > &  d)
inline

Distributed mode (docs/amr_distributed_flow.md, rung 4): run this solver on one ORB block of a DistributedOctree — the whole step (momentum, pressure, overlays) then executes multi-rank through the LeafHalo ±2 ghost registry established in setSolid.

The octree must be graded + cross-block 2:1 balanced; the origin is the GLOBAL one (every rank samples the geometry at bit-identical world points). Periodic domains only. All the set* configuration calls apply as usual (before setSolid); setSolid / step / project are COLLECTIVE over the octree's communicator. np=1 is bit-identical to init() + the single-rank path on the same octree by construction.

Definition at line 482 of file flow.hpp.

References peclet::core::amr::DistributedOctree< Dim, Bits >::globalGeometry(), peclet::core::amr::DistributedOctree< Dim, Bits >::h0(), peclet::core::amr::AmrFlow< Bits >::init(), and peclet::core::amr::DistributedOctree< Dim, Bits >::local().

◆ setDensity()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setDensity ( double  rho)
inline

Definition at line 486 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

◆ setViscosity()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setViscosity ( double  mu)
inline

Definition at line 487 of file flow.hpp.

◆ setDt()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setDt ( double  dt)
inline

Definition at line 488 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

◆ setBodyForce()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setBodyForce ( double  fx,
double  fy,
double  fz 
)
inline

Definition at line 489 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

◆ setPressurePCG()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setPressurePCG ( bool  on)
inline

Use MG-preconditioned CG for the pressure solve (default) vs plain V-cycles.

Definition at line 491 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

◆ setGhostGradient()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setGhostGradient ( bool  on)
inline

Directional ghost cell-gradient for the −∇pⁿ predictor and the projection's cell correction (the AMR analog of flow's collocated set_face_interp(9) hybrid): on cut cells the ABC grad3 reads the DECOUPLED p=0 of solid-centered neighbours through partially-open faces — a gauge-dependent O(1/h) gradient error (measured in tests/study_amr_ghost_apriori.cpp).

The directional gradient is central where both axis neighbours are fluid-centered and 2nd-order one-sided toward the fluid else — O(h²), gauge-exact. The aperture projection (divergence + φ solve + uf) is UNCHANGED (throat-safe).

DEFAULT ON since 2026-08-18, mirroring flow's collocated default set_collocated_scheme("gauge-exact"). Measured there on two periodic sphere beds (peclet-examples benchmarks/porous-scaling): second order at phi=0.50 AND at a contact-tight phi=0.60, against first order for the plain gradient — which additionally failed to reach steady state within 800 steps on three of five rungs of the dense bed. setGhostGradient(false) restores the legacy path. Call before setSolid.

Definition at line 506 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

◆ setGhostProjection()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setGhostProjection ( bool  on,
int  matrixOrder = 2,
int  rhsOrder = 2 
)
inline

FULL directional ghost-cell projection (the AMR port of flow's collocated set_ghost_projection): the pressure system becomes rho·(L_bin + Delta) phi = rho·D_g(u*) — the BINARY-openness FV Laplacian (a face is open iff its sample + both adjacent centers are fluid; preconditioned by the UNCHANGED openness-MG hierarchy built on that openness) plus the wall-anchored closure overlay on the finest-band rows (peclet::core::scheme, shared with flow), solved by MG-preconditioned BiCGStab on the coupled subspace; the constraint is the ghost-closed divergence of the ½/½ face-averaged field.

Implies setGhostGradient. (matrixOrder, rhsOrder) = closure orders for the implicit matrix vs the RHS divergence; PRODUCTION CANDIDATE (re-framed 2026-08-24 after flow's attractor campaign, flow/doc/collocated_invisible_subspace.md + fluid_only_constraint_plan.md): the ghost projection is the FLUID-ONLY constraint scheme — the only measured collocated architecture that is stable, unique (no attractor family: the aperture scheme's solid-centered pressure DOFs are constraint multipliers its gauge-exact gradient never reads, giving an affine family of steady states selected by march protocol) AND converging (flow clean ladders both beds; Z&H −0.018% at N=128). Default remains OFF (aperture, matching flow's gauge-exact default) until the suite-wide flip decision; select with setGhostProjection(true) == flow's set_collocated_scheme("ghost").

Closure orders: (2, 2) is the DEFAULT and the only order pair cleared for production — flow's hardening Phase A measured the (1, 2) mixed form march-UNSTABLE above ~2000 spheres (an operator/RHS mismatch re-injected each step through the rotational pressure accumulation; flow/doc/ghost_hardening_findings_A.md). (1, 2) stays callable for the existing parity records only. Throws in setSolid if an overlay row's ±2 reach crosses a 2:1 level boundary (finest-band margin). The 2026-08-19 advection-economics retirement (aperture MG-PCG cheaper per step, docs/amr_aperture_advection_plan.md §RESOLVED) still holds as a COST statement; the scheme choice is now a robustness/uniqueness decision. Call before setSolid.

Definition at line 534 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

◆ setCfScheme()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setCfScheme ( int  scheme)
inline

Coarse/fine (2:1) interface scheme (cf_scheme.hpp): 0 = standard two-point flux (default, 1st-order at level boundaries, bit-identical legacy path), 1 = Martin–Cartwright tangential quadratic (2nd-order — measured at C/F rows: divergence 1.95, cell gradient 1.95, momentum SOLUTION 2.0 in test_amr_cf_vector).

Applied to everything the STEADY solution feels: the momentum diffusion (lagged deferred-correction RHS term), the RHS divergence constraint, and the pressure gradients (predictor + cell correction). The pressure MATRIX / MG rails / PCG / ghost BiCGStab stay on the standard consistent operator (at the fixed point φ→0, the matrix C/F order does not move the steady solution — the (1,2)-mixed philosophy). Works in both aperture and ghost-projection modes. Call before setSolid.

Definition at line 548 of file flow.hpp.

◆ setAdvection()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setAdvection ( bool  on)
inline

Enable momentum advection ∇·(u u) (default OFF ⇒ Stokes).

The high-order flux is second-order upwind (SOU) by default; the first-order-upwind part is solved implicitly (folded into the momentum operator) and the (SOU−FOU) difference is the explicit deferred correction — unconditionally stable for the FOU part, exact-SOU at steady state. This is the same implicit-FOU + deferred-SOU scheme as the host oracle::AmrFlow and flow's collocated grid (set_implicit_advection).

Definition at line 555 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

◆ setImplicitAdvection()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setImplicitAdvection ( bool  on)
inline

Implicit-FOU deferred correction (default ON).

OFF ⇒ the whole high-order advection is explicit (no FOU in the operator) — only conditionally stable.

Definition at line 558 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

◆ setAdvectionScheme()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setAdvectionScheme ( int  s)
inline

High-order advection scheme: 0 = second-order upwind (SOU, default), 1 = Koren TVD.

Definition at line 560 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

◆ setMomentumTol()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setMomentumTol ( double  tol)
inline

Relative tolerance for the per-step momentum BiCGStab solve (default 1e-8).

The momentum predictor is one step of a pseudo-transient outer iteration to steady state, so it need not be solved to round-off — a looser tolerance bounds the per-step cost. NOTE on the cost regime: the momentum operator is the Helmholtz (ρ/dt)I − μ∇²; for a physical dt the (ρ/dt) mass term dominates and it is cheap (diagonally dominant). At the large dt used for steady drag, ρ/dt → 0 and it degrades to a bare elliptic Laplacian (a saddle-point Stokes problem) — as hard as the pressure Poisson and, unlike the pressure, solved here per velocity component. Bounding the tolerance (this knob) caps the over-solve; making it actually scale needs the velocity multigrid (setMomentumMG).

Definition at line 570 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

◆ setMomentumMG()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setMomentumMG ( bool  on)
inline

Use the Galerkin velocity multigrid (MomentumMG) as the momentum BiCGStab preconditioner.

This is the scalable momentum solver: the coarse operators are the exact assembled cut-cell operator coarsened by R·A·P, so the V-cycle is a consistent preconditioner and the momentum iteration count stays ~flat with N instead of growing like the Jacobi-preconditioned BiCGStab (the dominant cost at scale and large dt). It only changes the preconditioner (the matvec is the exact operator) ⇒ identical converged step. Call before setSolid (the hierarchy is built there). Default ON.

Definition at line 578 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

◆ setVelocityMGStaircase()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setVelocityMGStaircase ( bool  on)
inline

Choose the momentum-MG coarse-operator strategy: false (default) = Galerkin (MomentumMG, A_c = R·A·P of the exact cut-cell operator); true = rediscretized staircase (VelocityMG, mirroring flow's VelocityMG).

Call before setSolid. Both are device-resident BiCGStab preconditioners; this lets the two be benchmarked head-to-head.

Definition at line 584 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

◆ setVelocityMGMinCoarse()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setVelocityMGMinCoarse ( Index  m)
inline

Pore-scale cap for the staircase velocity-MG: the coarsest level keeps ≥ this many cells, so it still resolves the immersed feature (a small object that vanishes from the coarse κ classification leaves an inconsistent operator that diverges).

Feature-dependent — raise it for small immersed objects. Only affects the staircase strategy.

Definition at line 589 of file flow.hpp.

◆ setMomentumGS()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setMomentumGS ( bool  on)
inline

Opt-in: use the multicolour Gauss–Seidel smoother in the momentum MG (Galerkin or staircase) instead of weighted Jacobi — ~2× better smoothing (fewer V-cycles / BiCGStab iters), and the strong fine smoother the staircase needs on the cut band.

Default off. Call before setSolid.

Definition at line 593 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

◆ setMomentumMGSolver()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setMomentumMGSolver ( bool  on)
inline

Opt-in (P4): solve the momentum predictor with the velocity multigrid used as the solver — MG-preconditioned defect correction u ← u + M⁻¹(b − A u) iterated to tolerance — instead of BiCGStab with the same MG as a preconditioner.

This is the faithful mirror of flow's velocity solve, which uses no Krylov method at all (RB-GS smoother / velocity-MG directly): the momentum operator is diagonally dominant and invertible, so the stationary iteration converges, and unlike BiCGStab it cannot break down on the strongly non-symmetric (D_rescale + FOU) operator (no bi-orthogonal recurrence to lose — the failure mode P5 had to symmetrise the smoother to avoid). With the GS smoother (setMomentumGS) and a velocity-MG (setMomentumMG, default on) this is the full RB-GS/MG flow path; with MG off it degrades to plain damped-Jacobi sweeps (flow's smoothComp). Default off (BiCGStab stays the validated default). Requires setMomentumMG to actually be multigrid-accelerated; otherwise the Richardson iteration converges only slowly.

Definition at line 607 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

◆ setOuterIterations()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setOuterIterations ( int  n,
double  tol = 1e-6 
)
inline

Optional Picard outer loop over the lagged advection (mirror of flow's outerIters_): each outer iteration re-freezes the advecting velocity at the latest u and re-solves the predictor, stopping early when the max |Δu| between successive outer iterates falls below tol.

n = 1 (default) is the single lagged step used until now (no extra cost). Only meaningful with advection on; for Stokes the loop converges in one iteration. n ≥ 1.

Definition at line 614 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

◆ setSolid()

template<unsigned Bits = 21u>
template<class SdfFn >
void peclet::core::amr::AmrFlow< Bits >::setSolid ( SdfFn &&  sdfFn)
inline

Build the cut-cell operators (host) + upload all device structures.

Requires the density / viscosity / dt to be set first (the momentum operator carries ρ/dt and μ).

Definition at line 622 of file flow.hpp.

References peclet::core::amr::MomentumOp::advCoef, peclet::core::amr::MomentumOp::advDiag, peclet::core::amr::MomentumOp::advNbr, peclet::core::amr::MomentumOp::advStart, peclet::core::amr::buildCfDivDelta(), peclet::core::amr::buildCfGradDelta(), peclet::core::amr::buildCfLapDelta(), peclet::core::amr::buildCfUfDelta(), peclet::core::amr::buildFaceGeom(), peclet::core::amr::buildGhostOverlay(), peclet::core::amr::AmrPoisson< Dim, Bits >::buildOpenness(), peclet::core::amr::MomentumOp::diag, peclet::core::amr::MomentumOp::faceCoef, peclet::core::amr::MomentumOp::faceNbr, peclet::core::amr::MomentumOp::faceStart, peclet::core::amr::findPocketCells(), peclet::core::amr::FaceGeom::fluid, peclet::core::amr::MomentumOp::hasAdv, peclet::core::amr::AmrPoisson< Dim, Bits >::init(), peclet::core::amr::makeBinaryOpenFn(), MPI_Allreduce(), MPI_INT, peclet::core::amr::MomentumOp::n, peclet::core::amr::FaceGeom::nbr, peclet::core::amr::BlockOctree< Dim, Bits >::numLeaves(), peclet::core::amr::AmrFlow< Bits >::prepareDistributed(), peclet::core::amr::AmrFlow< Bits >::runMgVcycle(), peclet::core::amr::AmrPoisson< Dim, Bits >::setOrigin(), peclet::core::amr::standard, peclet::core::amr::FaceGeom::start, peclet::core::toDevice(), peclet::core::amr::transferFieldGradients(), peclet::core::amr::BlockOctreeView< Dim, Bits >::upload(), peclet::core::amr::uploadCfCompCsr(), peclet::core::amr::uploadCfCsr(), and peclet::core::amr::uploadGhostOverlay().

Referenced by peclet::core::amr::AmrFlow< Bits >::finishAdapt(), and peclet::core::amr::AmrFlow< Bits >::rebalanceMpi().

◆ step()

◆ project()

◆ finishProjection()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::finishProjection ( Index  n)
inline

Shared projection tail: build the div-free face field from u* + φ, correct the cell velocities (ABC / ghost gradient), rotational pressure update.

div_ holds the projection's RHS divergence (aperture or ghost-closed).

Definition at line 1139 of file flow.hpp.

References peclet::core::amr::applyGhostGrad(), peclet::core::amr::buildFaceField(), peclet::core::amr::cfApply(), peclet::core::amr::cfApplyComp(), peclet::core::amr::correct(), peclet::core::amr::grad3(), peclet::core::amr::presUpdate(), peclet::core::amr::AmrFlow< Bits >::syncScalar(), and peclet::core::amr::transferFieldGradients().

Referenced by peclet::core::amr::AmrFlow< Bits >::project().

◆ beginAdapt()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::beginAdapt ( )
inline

Snapshot the octree topology + (u, p) ahead of an external mesh mutation.

Distributed: the mutation is distributedAdapt (+ the driver's geometry-band re-refinement + balance), which KEEPS the ORB ownership — so the snapshot, the conservative transferField in finishAdapt and the field restore are all block-local per rank, and finishAdapt's setSolid rebuilds the ±2 halo/operators on the new local mesh (collective). For OWNERSHIP changes use rebalanceMpi instead.

Definition at line 1175 of file flow.hpp.

References peclet::core::amr::AmrFlow< Bits >::pressure(), peclet::core::amr::transferFieldGradients(), peclet::core::amr::transferGradients(), and peclet::core::amr::AmrFlow< Bits >::velocity().

◆ finishAdapt()

◆ rebalanceMpi()

template<unsigned Bits = 21u>
template<class SdfFn >
void peclet::core::amr::AmrFlow< Bits >::rebalanceMpi ( SdfFn &&  sdfFn)
inline

Distributed load rebalance (docs/amr_distributed_flow.md, rung 6): re-decompose the octree by leaf count (weighted ORB) and migrate the leaves WITH the state (u, p) to the new owners, then rebuild every solver structure on the new block (full distributed setSolid: new ±2 registry, halos, operators, pressure hierarchy).

Pure redistribution — every cell's u/p value is preserved bit-for-bit; uf restarts from the ½-average fallback for one step (as after finishAdapt). Collective; distributed mode only.

Definition at line 1223 of file flow.hpp.

References peclet::core::amr::AmrFlow< Bits >::pressure(), peclet::core::amr::AmrFlow< Bits >::setPressure(), peclet::core::amr::AmrFlow< Bits >::setSolid(), peclet::core::amr::AmrFlow< Bits >::setVelocity(), peclet::core::amr::transferFieldGradients(), peclet::core::amr::AmrFlow< Bits >::velocity(), and peclet::core::amr::AmrFlow< Bits >::zeroSolid().

◆ setPressure()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setPressure ( const std::vector< double > &  h)
inline

Write the accumulated rotational pressure from host (restart / finishAdapt).

Definition at line 1241 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

Referenced by peclet::core::amr::AmrFlow< Bits >::finishAdapt(), and peclet::core::amr::AmrFlow< Bits >::rebalanceMpi().

◆ zeroSolid()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::zeroSolid ( View< double v)
inline

Zero a per-leaf field on non-fluid cells (the transferred fields' solid cleanup).

Definition at line 1249 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

Referenced by peclet::core::amr::AmrFlow< Bits >::finishAdapt(), and peclet::core::amr::AmrFlow< Bits >::rebalanceMpi().

◆ debugSou()

template<unsigned Bits = 21u>
std::vector< double > peclet::core::amr::AmrFlow< Bits >::debugSou ( int  comp)
inline

DEBUG: the raw high-order advection ∇·(u u_comp) per cell from the current velocity (== host oracle::AmrFlow::advectTerm).

Isolates the SOU kernel from the solve.

Definition at line 1260 of file flow.hpp.

References peclet::core::amr::advectExplicit(), peclet::core::amr::AmrFlow< Bits >::syncVel(), and peclet::core::amr::transferFieldGradients().

◆ runMgVcycle()

template<unsigned Bits = 21u>
template<class MG >
void peclet::core::amr::AmrFlow< Bits >::runMgVcycle ( MG &  mg,
View< const double r,
View< double z 
)
inline

Run one V-cycle of a momentum MG as a preconditioner: z = M⁻¹ r.

Templated on the MG type (MomentumMG or VelocityMG — both expose b(0)/x(0)/vcycle), so the BiCGStab preconditioner is decoupled from the coarse-operator strategy.

Definition at line 1277 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

Referenced by peclet::core::amr::AmrFlow< Bits >::setSolid().

◆ maxAbsDiff()

template<unsigned Bits = 21u>
static double peclet::core::amr::AmrFlow< Bits >::maxAbsDiff ( View< const double a,
View< const double b,
Index  n 
)
inlinestatic

Max |a − b| over all cells (the Picard outer-loop convergence measure).

Definition at line 1296 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

Referenced by peclet::core::amr::AmrFlow< Bits >::step().

◆ copyToHost()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::copyToHost ( const View< double > &  d,
std::vector< double > &  h 
) const
inline

Copy a device View into a host vector (sized n_).

Definition at line 1311 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

◆ setVelocity()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::setVelocity ( int  c,
const std::vector< double > &  h 
)
inline

Set a velocity component from host (testing / initial conditions).

Definition at line 1318 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

Referenced by peclet::core::amr::AmrFlow< Bits >::finishAdapt(), and peclet::core::amr::AmrFlow< Bits >::rebalanceMpi().

◆ velocity()

template<unsigned Bits = 21u>
std::vector< double > peclet::core::amr::AmrFlow< Bits >::velocity ( int  c) const
inline

Copy a velocity component back to host (single D2H, no host loop — S2a).

Local rows only (the distributed ghost tail is an implementation detail).

Definition at line 1326 of file flow.hpp.

References peclet::core::amr::AmrFlow< Bits >::localVector(), and peclet::core::amr::transferFieldGradients().

Referenced by peclet::core::amr::AmrFlow< Bits >::beginAdapt(), and peclet::core::amr::AmrFlow< Bits >::rebalanceMpi().

◆ pressure()

template<unsigned Bits = 21u>
std::vector< double > peclet::core::amr::AmrFlow< Bits >::pressure ( ) const
inline

Copy the pressure field back to host (single D2H), (num_leaves,) — the incremental-rotational p.

Local rows only.

Definition at line 1329 of file flow.hpp.

References peclet::core::amr::AmrFlow< Bits >::localVector().

Referenced by peclet::core::amr::AmrFlow< Bits >::beginAdapt(), and peclet::core::amr::AmrFlow< Bits >::rebalanceMpi().

◆ localVector()

template<unsigned Bits = 21u>
std::vector< double > peclet::core::amr::AmrFlow< Bits >::localVector ( const View< double > &  v) const
inline

Host copy of the LOCAL rows of a (possibly ghost-extended) per-cell field.

Definition at line 1332 of file flow.hpp.

References peclet::core::toVector(), and peclet::core::amr::transferFieldGradients().

Referenced by peclet::core::amr::AmrFlow< Bits >::pressure(), and peclet::core::amr::AmrFlow< Bits >::velocity().

◆ velocities()

template<unsigned Bits = 21u>
std::vector< double > peclet::core::amr::AmrFlow< Bits >::velocities ( ) const
inline

All three velocity components interleaved as a flat (n,3) row-major host buffer (out[i*3+c]) with a single device→host transfer (G6): the three independent component Views are packed on-device first (cheap), so the boundary is crossed once rather than three times as repeated velocity(c) calls would.

Definition at line 1346 of file flow.hpp.

References peclet::core::toVector(), and peclet::core::amr::transferFieldGradients().

◆ divNormL2()

template<unsigned Bits = 21u>
double peclet::core::amr::AmrFlow< Bits >::divNormL2 ( )
inline

L2 norm of the (openness-weighted) divergence of the current velocity — the ghost-closed divergence when the ghost projection is on (its constraint IS the residual diagnostic).

Definition at line 1360 of file flow.hpp.

References peclet::core::amr::AmrFlow< Bits >::allSum(), peclet::core::amr::cfApplyComp(), peclet::core::amr::divergence(), peclet::core::amr::dotPlain(), peclet::core::amr::ghostDivergDelta(), and peclet::core::amr::AmrFlow< Bits >::syncVel().

◆ divNormFace()

template<unsigned Bits = 21u>
double peclet::core::amr::AmrFlow< Bits >::divNormFace ( )
inline

L2 norm of the divergence of the ABC face field uf_ (built each project()): the φ-solve residual, far below the cell field's O(h²) divNormL2 — including across 2:1 interfaces.

Definition at line 1373 of file flow.hpp.

References peclet::core::amr::AmrFlow< Bits >::allSum(), peclet::core::amr::divFaceNorm(), and peclet::core::amr::transferFieldGradients().

◆ faceField()

template<unsigned Bits = 21u>
std::vector< double > peclet::core::amr::AmrFlow< Bits >::faceField ( ) const
inline

Copy the divergence-free face field to host (one value per CSR (sub)face, forEachFaceFull order).

Definition at line 1379 of file flow.hpp.

References peclet::core::toVector().

◆ numLeaves()

template<unsigned Bits = 21u>
Index peclet::core::amr::AmrFlow< Bits >::numLeaves ( ) const
inline

Definition at line 1380 of file flow.hpp.

◆ numGhostCells()

template<unsigned Bits = 21u>
Index peclet::core::amr::AmrFlow< Bits >::numGhostCells ( ) const
inline

Distributed: number of ghost slots in the ±2 registry (0 single-rank).

Definition at line 1382 of file flow.hpp.

◆ isFluid()

template<unsigned Bits = 21u>
bool peclet::core::amr::AmrFlow< Bits >::isFluid ( Index  i) const
inline

Per-leaf fluid mask (false inside the solid) — for host-side post-processing / bindings.

Definition at line 1384 of file flow.hpp.

References peclet::core::amr::transferFieldGradients().

◆ lastMomIters()

template<unsigned Bits = 21u>
int peclet::core::amr::AmrFlow< Bits >::lastMomIters ( ) const
inline

Total momentum BiCGStab iterations (summed over the 3 components) of the last step.

Definition at line 1386 of file flow.hpp.

◆ lastPresIters()

template<unsigned Bits = 21u>
int peclet::core::amr::AmrFlow< Bits >::lastPresIters ( ) const
inline

Pressure PCG iterations of the last step.

Definition at line 1388 of file flow.hpp.

◆ lastOuterIters()

template<unsigned Bits = 21u>
int peclet::core::amr::AmrFlow< Bits >::lastOuterIters ( ) const
inline

Picard outer iterations actually run in the last step (1 unless setOuterIterations(>1)).

Definition at line 1390 of file flow.hpp.

◆ syncVel()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::syncVel ( )
inline

◆ syncScalar()

◆ allSum()

◆ gpOp0()

template<unsigned Bits = 21u>
const FvOp & peclet::core::amr::AmrFlow< Bits >::gpOp0 ( )
inline

The pressure operator the ghost solver runs on (distributed MG level 0 or presMG_'s).

Definition at line 1413 of file flow.hpp.

Referenced by peclet::core::amr::AmrFlow< Bits >::ghostMatvec(), and peclet::core::amr::AmrFlow< Bits >::gpProject().

◆ prepareDistributed()

◆ installGhostMeta()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrFlow< Bits >::installGhostMeta ( )
inline

Mirror the halo registry's ghost metadata (block-local lo + level) into mom_ and pres_.

Definition at line 1463 of file flow.hpp.

References peclet::core::amr::AmrPoisson< Dim, Bits >::setGhosts(), and peclet::core::amr::transferFieldGradients().

Referenced by peclet::core::amr::AmrFlow< Bits >::prepareDistributed().

◆ gpProject()

◆ ghostMatvec()

◆ ghostPrec()

◆ solveGhostBiCGStab()


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