include/pops/runtime/amr/amr_runtime.hpp Source FileΒΆ
|
adc_cpp 0.3.0
Model-free C++23 core for coupled hyperbolic-elliptic systems on adaptive (AMR) meshes, with MPI and GPU (Kokkos) backends
|
amr_runtime.hpp
Go to the documentation of this file.
3#include <pops/amr/regridding/regrid.hpp> // tag_cells, grow_tags (per-block tags + phi for the union regrid)
4#include <pops/amr/tagging/tag_box.hpp> // TagBox, tag_union (cell-by-cell OR of the tags of all blocks)
6#include <pops/core/state/variables.hpp> // VariableSet, VariableRole, role_from_name (role -> component of coupled sources)
7#include <pops/coupling/amr/amr_coupler_mp.hpp> // detail::coupler_inject_aux_mb (aux injection coarse->fine)
8#include <pops/coupling/amr/amr_regrid_coupler.hpp> // regrid_compute_fine_layout + regrid_field_on_layout (split bricks)
9#include <pops/coupling/system/amr_system_coupler.hpp> // detail::same_layout_or_throw (shared-layout guard)
11#include <pops/coupling/source/coupled_source_program.hpp> // CoupledSourceKernel + CsProgram (flat ABI, P5 bytecode)
12#include <pops/numerics/elliptic/interface/elliptic_problem.hpp> // field_postprocess, FieldPostProcess
15#include <pops/numerics/time/integrators/implicit_stepper.hpp> // NewtonReport (OPT-IN IMEX diagnostics, aggregated per block)
18#include <pops/mesh/layout/patch_box.hpp> // PatchBox: index-space signature of a fine patch (patch_boxes())
24#include <pops/parallel/comm.hpp> // n_ranks() / comm_active(): MPI message+reduction counts (Spec 5 criterion 43)
25#include <pops/runtime/program/profiler.hpp> // Profiler / ProfileScope: AMR phase timings (Spec 5 criterion 43, ADC-479)
33#include <map> // named_aux_: model-named aux fields (comp -> coarse field), re-applied each solve
168 std::function<void(std::vector<AmrLevelMP>&, const Box2D&, Real, Periodicity, bool)> imex_advance;
260 // EXACT layout consistency between blocks (the aux is shared per level): same number of levels,
261 // and per level same BoxArray (boxes AND order), same DistributionMapping, same dx/dy. SAME guard
263 // UNIQUE shared hierarchy. A single block matches itself trivially (the loop over the other blocks
273 // Width of the SHARED aux channel: max of the blocks' aux_comps (>= kAuxBaseComps). Counterpart of
274 // AmrSystemCoupler::system_aux_comps: a block reading an extra field (B_z, T_e) has the room at
275 // each level, a base block ignores the extra components. PR1 does not POPULATE multi-block B_z (no
276 // bz_ here), but we size the channel to the widest anyway so that load_aux<aux_comps<Model>> never
277 // reads out of bounds. Without an extra-field block -> kAuxBaseComps (3) -> allocation strictly
314 // System Poisson right-hand side after the last solve_fields: f = Sum_b elliptic_rhs_b(U_b) on the
468 // --- form validation (before any step, EXPLICIT errors); mirror of System::add_coupled_source.
490 // Resolves (block, role) -> (block index, component) by the block CONSERVATIVE descriptor, like
498 // canonical role name OR a user-defined role label (index_of(string), ADC-292). If the block does
625 // criterion 43): time the restriction cascade into the "average_down" scope + bump its per-solve
626 // count. The scope is per-solve_fields (NOT per-cell), so a profiled run pays one clock pair here;
627 // an unprofiled run constructs nothing (profiler_ null or disabled). See profile_amr_scope below.
639 // 2. SUMMED and CO-LOCATED system RHS: f = Sum_b elliptic_rhs_b(U_b) on the coarse. We reset to
640 // zero then each block ACCUMULATES (+=) its contribution on the SAME cells of the shared coarse
647 // 3. coarse aux = (phi, grad phi) via the SAME clean path as AmrSystemCoupler: fill the ghosts of
655 // BEFORE fill_ghosts (so their ghosts are filled) and the injection (so they reach every level).
656 // No-op when no named field was set; field_postprocess wrote only comps 0..2, so this never clobbers
660 apply_named_aux_bc(); // ADC-369: per-field halo override on the coarse physical ghosts (after the
662 // 4. coarse->fine injection of the aux (parent replicated only at level 1 if coarse replicated).
667 // 5. NAMED multi-elliptic fields (ADC-428): a SECOND elliptic solve per user-named field, written to
688 // SUMMED + CO-LOCATED RHS on the coarse: f = Sum_b named_elliptic_rhs_b[field](U_b), exactly like
707 // Write phi (+ centered grad) into the field's OWN aux components on the coarse valid cells. The
727 // Ghost-fill the named components (shared aux fill: same routing as the default) + per-field halo
728 // override (ADC-369), then inject coarse->fine so the named field reaches every level. We re-fill the
729 // WHOLE aux: the default comps 0..2 were just written by the Poisson block, so their valid cells are
751 // AMR PROFILING (Spec 5 criterion 43): time the WHOLE regrid attempt (tag + cluster + prolong +
752 // re-solve) into the "regrid" scope. RAII -> the scope covers EVERY early-return path below (empty
754 // COUNT is bumped at the tail (++regrid_count_) only when a regrid actually completed -- a no-op
755 // attempt times itself but does not inflate the count. Null/disabled profiler -> no scope object.
758 // (R0) PRECONDITION: fields up to date (aux per level, for the |grad phi| criterion). The per-block
762 // (R1)+(R2) PER-BLOCK TAGS (on the block U at the parent level) + PHI TAGS (on the shared aux).
781 // (R4)+(R5) cross-rank collective reduction (if coarse distributed) + UNIQUE clustering -> SHARED
782 // fine layout. all_reduce_or_inplace is called INSIDE regrid_compute_fine_layout for distributed
789 // all_reduce_or_inplace over the tag grid when the coarse is distributed (multi-rank) -- every rank
790 // must cluster from the SAME gathered tags. Count it as one reduction (np>1 only; serial / single
798 // (R6) COHERENT PROLONG / RESTRICT of ALL blocks on the SAME fb/dmap (including the blocks held by
799 // their stride: their frozen state is present everywhere and contributes to the Poisson, D3). The
800 // ghost width is INHERITED per block (a MUSCL order-2 block carries 2 ghosts; a Minmod block and a
801 // VanLeer one may differ), so the scheme does not read out of bounds at the next step (V2 / risk
809 // (R7) REBUILD OF THE SHARED AUX (one only, width aux_ncomp_) on the new layout + RE-WIRING of the
816 // (V3) SHARED-LAYOUT INVARIANT: all blocks MUST live on EXACTLY the same fb/dmap (boxes, order,
827 // (R8) RESTORATION OF THE COVERAGE INVARIANT: re-solve so that phi / grad phi are consistent with
828 // the new grid AND to trigger the fine -> coarse cascade (mf_average_down_mb, in solve_fields) that
864 // UNION-TAGS REGRID (capstone Phase 2, C.6; D2: BEFORE the macro-step's step, consistent with the
865 // single-block amr_dsl_block.hpp:108). regrid_every_ cadence in MACRO-STEPS, OUTSIDE the substep
868 // macro_step_ > 0 (like the single-block) avoids a regrid at the very first step (the initial grid
873 // System Poisson solved ONCE on the current state (OncePerStep cadence). A HELD block (stride > 1,
874 // outside end-of-window) contributed with its FROZEN state since its last advance: loose coupling
875 // assumed by the multirate, exactly like System::step / AmrSystemCoupler in OncePerStep. phi stays
876 // frozen during the blocks' advance (no per-substep re-solve here). When reached from step_cfl this
877 // re-solves an unchanged state (a second solve), kept on purpose; see the ADC-318 note in step_cfl.
881 // (macro_step_+1) % stride != 0, then CATCHES UP at end-of-window by an effective step stride*dt.
886 // NEWTON DIAGNOSTICS (OPT-IN): RESET of the report at the HEAD of the block advance (parity with
887 // System::AdvanceImex::operator() which resets nreport before its substep loop). The report then
888 // AGGREGATES over all the levels AND substeps of THIS advance (imex_advance accumulates per level
890 // Placed AFTER the stride skip: a HELD block keeps the report of its LAST advance ("last advance"
902 // IMEX splitting is SUB-CYCLED (K Lie steps over bdt/K). The compile-time, for its part, applies
910 // Cell-local + idempotente -> conservation preservee (flux-registres deja regles). No-op si vide.
914 // Inter-species coupled sources AFTER the transport (same order as AmrSystemCoupler: transport then
930 // NOTE (ADC-318): this pre-solve plus step(dt)'s own head solve below is a DOUBLE Poisson solve on
931 // the SAME unchanged state (regrid_every=0 freezes the grid in between). It looks redundant but is
932 // NOT, and is INTENTIONALLY kept. GeometricMG::solve() is warm-started and iterates to a RELATIVE
933 // tolerance (rel_tol 1e-8; abs_tol 0 by default, so its off-step early-exit never fires here), so the
935 // over-converges it by ~rel_tol. Skipping the second solve would therefore NOT be bit-identical; it
936 // drifts the trajectory by ~3e-10 over 20 steps (below the solver tolerance and far below the O(dt^2)
937 // scheme error, but nonzero). The de-dup was declined to preserve the exact historical bit-stream
938 // (SystemStepper::step_cfl avoids the double solve by INLINING its advance, not by skipping a solve).
947 // SystemStepper::step_cfl, evaluated on the COARSE. Empty closures (model without the trait) ->
975 // Declared frequencies of the coupled sources (CoupledSource.frequency): bound on the MACRO-step
984 // PER-CELL frequencies (CoupledSource.frequency with an Expr): mu(U) reduced (MAX) on the COARSE
985 // level of the input blocks (where the AMR CFL lives), GLOBAL all_reduce_max (ALL ranks, neutral
987 // constant. No per-cell source -> empty loop (bit-identical). The Array4 are rebuilt at EACH step
1022 // MPI COLLECTIVE COUNT (Spec 5 criterion 43): one all_reduce_max per per-cell coupled-frequency
1035 // GLOBAL bounds (AmrRuntime::add_dt_bound, parity with System::add_dt_bound): evaluated PER RANK
1045 // MPI COLLECTIVE COUNT (Spec 5 criterion 43): one all_reduce_min per registered global dt bound,
1210 // Index-space signatures of the fine patches (level + inclusive lo/hi corners), for ALL fine levels.
1211 // Read-only of the GLOBAL BoxArray (all boxes/all ranks) already stored -> rank-independent, zero
1212 // communication, NO hot-path cost (query between steps). Mirror of n_patches(): the same box_array()
1213 // that gives the COUNT gives the BOXES. Block 0 representative (SHARED layout, same_layout_or_throw
1214 // guard). Loop k = 1..nlev-1: a single fine level today (ratio 2), correct if a future adds levels
1227 // COARSE-level (base) box counts (ADC-319, MPI ownership diagnostic). Block 0 is the SHARED layout
1228 // (same_layout_or_throw), so its level-0 MultiFab carries the base BoxArray + DistributionMapping
1229 // common to all blocks. local_size() = base boxes OWNED by this rank; box_array().size() = total base
1230 // boxes (all ranks). Mirror of n_patches(): a query between steps, no communication, no hot-path cost.
1234 // ----------------------------------------------------------------------------------------------
1237 // hierarchy. The shared layout is FROZEN at build (make_shared_amr_layout: a deterministic central
1238 // fine patch, regrid_every==0): replaying the SAME composition reproduces the SAME hierarchy, so a
1239 // restart only needs to restore each block's valid cells + phi (no set_hierarchy on the runtime).
1241 // gather), MIRROR of System::state_global / gather_global; mono-rank they are the identity. @p b:
1243 // ----------------------------------------------------------------------------------------------
1253 // c*nf*nf + j*nf + i (nf = nx << k); zeros outside the patches at the fine level. LOCAL fabs only
1270 // Same as block_level_state but all_reduce_sum the per-rank contributions -> every rank holds the
1278 // Restores block @p b at level @p k from @p s (same layout as block_level_state). Writes ONLY the
1279 // VALID cells of the local fabs (the ghosts are redone at the next solve_fields/step, like after a
1304 // Potential phi of level @p k, flat nf*nf row-major, zeros outside patches. Level 0: the multigrid
1305 // WARM-START mg_.phi() (the state reused by the next solve -> bit-identical restart). Level >= 1:
1306 // shared aux comp 0 (recomputed at solve_fields). Mirror of AmrCouplerMP::level_potential; the phi
1320 // Same as level_potential but all_reduce_sum (np>1 gather). COLLECTIVE: all ranks MUST call it.
1349 // component-major indices c*nf*nf + j*nf + i. Shared by block_level_state and its _global gather
1364 // Fills @p out (zero-initialized, size nf*nf) from the LOCAL valid cells of @p P (comp 0) at GLOBAL
1376 // Re-applies the model-NAMED aux fields (ADC-291) onto the COARSE shared aux valid cells. Mirror of
1377 // SystemFieldSolver::apply_named_aux_one (cartesian System): per LOCAL fab (MPI-safe), valid cells
1378 // only, global flat index j*nx+i. The coarse layout is frozen across regrid (only fine levels are
1379 // rebuilt), so the stored coarse field stays valid; solve_fields runs the coarse->fine injection
1398 // NAMED multi-elliptic field (ADC-428): a field name's aux output components + a DEDICATED coarse
1400 // shared_ptr<GeometricMG>: GeometricMG owns Fabs (non-copyable/non-movable), and named_fields_ is a
1401 // std::map (stable nodes), so a heap GeometricMG gives a stable address without making NamedField
1411 // Builds a NAMED elliptic field's dedicated coarse GeometricMG (ADC-428), lazily, IDENTICAL to the
1412 // default mg_ (same coarse geometry / BoxArray / Poisson BC / wall predicate / replication). REUSES the
1413 // native solver -- no operator is reimplemented. The variable / anisotropic permittivity of the default
1414 // Poisson is NOT carried onto a named field (a named field is a plain Laplacian, like the System named
1423 // Reads aux component @p comp of the COARSE level as a GLOBAL n*n row-major field (diagnostic /
1424 // read-back). Same marshaling as detail::coupler_read_coarse_phi (the default potential read-back) but
1425 // for an arbitrary component: local n*n buffer, all_reduce_sum_inplace when the coarse is DISTRIBUTED
1426 // (disjoint boxes -> exact recompose; serial / replicated is identity). Used by named_field_values.
1443 // Per-field aux HALO override (ADC-369) on the COARSE aux, AFTER the shared fill_ghosts. Overrides
1457 // AmrSystem::Impl::block_index (the facade names the blocks; the coupled sources target them by name,
1466 // Resolved reference of a coupled-source field: (block index, component) + the term bytecode program
1467 // (empty for an input). Inputs carry only block/comp; outputs carry in addition the postfix program
1468 // evaluated per cell. We capture the block INDEX (not a fab pointer): the Array4 are rebuilt at each
1475 // A registered coupled source: its inputs, its output terms and its constants, ready to be marshaled
1492 // Coarse BoxArray + conductive-wall predicate stashed at the ctor so a NAMED elliptic field (ADC-428)
1493 // can build its own coarse GeometricMG identical to mg_ (ensure_named_elliptic). mg_ consumes them at
1494 // its construction but does not expose them, so we keep a copy here (cheap; the coarse layout is small).
1510 // PER-CELL frequencies of the coupled sources (CoupledSource.frequency with an Expr): bytecode
1511 // program mu(U) evaluated on the coarse at each step_cfl (MAX + all_reduce_max -> dt <= cfl/max(mu)).
1525 // (n*n row-major). STATIC user fields re-applied by solve_fields each macro-step (so they persist
1528 // Per-field aux HALO policy (ADC-369): component -> uniform boundary policy, applied to the coarse aux
1531 // NAMED multi-elliptic fields (ADC-428): field name -> its aux output components + a DEDICATED coarse
1532 // GeometricMG. The NamedField struct itself is defined higher up (before ensure_named_elliptic, which
1533 // takes it by reference: a parameter type must be visible at the function declaration, unlike a member
1539 // bit-identical). block_tag_: PER-BLOCK tag predicate (D1; same size as blocks_, empty = this block
1540 // tags nothing on its side). phi_tag_: phi tag predicate on |grad phi| (D4; empty = phi does not
1552 // AMR / MPI PROFILING (Spec 5 criterion 43, ADC-479): non-owning pointer to the AmrSystem-owned
1559 // records only when profiler_ is non-null AND enabled. A null/disabled run constructs a cheap inert
1560 // scope (one pointer copy + one clock read) -- the granularity is per-phase, not per-cell, so this
1594 // fill_ghosts wrapped in the "fill_boundary" timing scope + per-call count (Spec 5 criterion 43).
1595 // Under MPI np>1 the ghost fill is a cross-rank halo exchange -> also count one "mpi_messages" (a
AmrCouplerMP: MULTI-PATCH E x B AMR coupler (coarse Poisson -> aux = grad phi -> fine injection -> co...
Umbrella for the AMR MultiFab stack: includes the numerics/time sub-headers in dependency order (flux...
amr_regrid_finest: Berger-Rigoutsos regrid of the finest level (responsibility b).
AmrSystemCoupler: multi-species SYSTEM coupler on AMR (milestone 2.3).
Helpers shared by the three couplers (single-block Coupler, SystemAssembler, AmrSystemCoupler) for th...
Box2D: the integer index space of a 2D cell-centered Cartesian grid.
BoxArray: the set of boxes tiling a level (disjoint, covering).
std::vector< double > level_potential(int k)
Definition amr_runtime.hpp:1309
void set_profiler(runtime::program::Profiler *prof)
AMR / MPI PROFILING SEAM (Spec 5 sec.12.5, ADC-479 criterion 43).
Definition amr_runtime.hpp:1079
void solve_fields()
sync_down (per block) + system coarse Poisson (CO-LOCATED SUMMED RHS) + coarse aux + fine injection.
Definition amr_runtime.hpp:622
Real step_cfl(Real cfl, Real h)
substeps/stride-aware CFL step (runtime counterpart of System::step_cfl, EXACT mirror of its formula)...
Definition amr_runtime.hpp:929
std::vector< AmrLevelMP > & levels(std::size_t b)
Definition amr_runtime.hpp:319
std::function< bool(const ConstArray4 &, int, int)> TagPredicate
Tag predicate of the union regrid: (ConstArray4 of the read field, i, j) -> should we refine ?...
Definition amr_runtime.hpp:330
std::size_t n_coupled_sources() const
Definition amr_runtime.hpp:312
std::vector< PatchBox > patch_boxes() const
Definition amr_runtime.hpp:1216
void set_block_tag_predicate(std::size_t b, TagPredicate crit)
Registers the TAG PREDICATE of block b (D1: PER-BLOCK union criterion).
Definition amr_runtime.hpp:353
Real max_speed()
Max SYSTEM wave speed (max over the blocks) on the current coarse. Requires the aux up to date.
Definition amr_runtime.hpp:1194
std::vector< double > density(std::size_t b) const
Definition amr_runtime.hpp:321
AmrRuntime(const Geometry &geom, const BoxArray &ba_coarse, const BCRec &bcPhi, std::vector< AmrRuntimeBlock > blocks, Periodicity base_per=Periodicity{true, true}, bool replicated_coarse=true, std::function< bool(Real, Real)> active={})
Definition amr_runtime.hpp:238
void coupled_source_step(Real dt)
Applies ALL the registered coupled sources of a step dt, by forward-Euler splitting.
Definition amr_runtime.hpp:571
const NewtonReport & newton_report(const std::string &name) const
NEWTON REPORT (OPT-IN IMEX diagnostics) of block name, AGGREGATED over the levels and substeps of its...
Definition amr_runtime.hpp:1174
void register_named_field(const std::string &field, int phi_comp, int gx_comp, int gy_comp)
Definition amr_runtime.hpp:402
std::vector< double > potential()
Coarse potential (component 0 of the shared aux) as an n*n row-major field.
Definition amr_runtime.hpp:1188
std::vector< double > level_potential_global(int k)
Definition amr_runtime.hpp:1321
void set_named_aux_bc(int comp, AuxHaloPolicy policy)
Registers a per-field aux HALO policy (ADC-369) for the named component comp: solve_fields applies it...
Definition amr_runtime.hpp:384
void add_coupled_frequency(const std::string &label, Real mu)
DECLARED frequency of a coupled source (CoupledSource.frequency, wave-3 audit): step bound dt <= cfl ...
Definition amr_runtime.hpp:1090
void add_coupled_source(const std::vector< std::string > &in_blocks, const std::vector< std::string > &in_roles, const std::vector< double > &consts, const std::vector< std::string > &out_blocks, const std::vector< std::string > &out_roles, const std::vector< int > &prog_ops, const std::vector< int > &prog_args, const std::vector< int > &prog_lens)
Registers an inter-species COUPLED SOURCE (DSL CoupledSource, P5 bytecode) on the runtime facade,...
Definition amr_runtime.hpp:458
void set_block_named_elliptic_rhs(std::size_t b, const std::string &field, std::function< void(const MultiFab &, MultiFab &)> rhs)
Attaches named field's RHS contribution closure (rhs += elliptic_field_rhs(U_b)) to block b.
Definition amr_runtime.hpp:411
void regrid()
UNION-TAGS REGRID (capstone Phase 2, C.6; docs/AMR_REGRID_UNION_TAGS_DESIGN.md, steps R0-R8).
Definition amr_runtime.hpp:746
void set_macro_step(int s)
RESTORES the macro-step counter (IO v1, reserved for restart via AmrSystem::set_clock): without it th...
Definition amr_runtime.hpp:1069
void set_named_aux(int comp, std::vector< Real > field)
Registers a model-NAMED aux field (ADC-291) at shared-channel component comp (= kAuxNamedBase.
Definition amr_runtime.hpp:373
std::vector< double > block_level_state(std::size_t b, int k) const
Definition amr_runtime.hpp:1255
std::vector< double > named_field_values(const std::string &field)
Solved potential of named field as a COARSE n*n row-major field (diagnostic / read-back).
Definition amr_runtime.hpp:428
void solve_named_fields()
Solves every registered NAMED elliptic field (ADC-428) on the coarse, writes phi (+ centered grad) in...
Definition amr_runtime.hpp:678
void step(Real dt)
Advances the system by one macro-step dt.
Definition amr_runtime.hpp:862
bool has_named_field(const std::string &field) const
True if field is a registered named elliptic field.
Definition amr_runtime.hpp:421
void set_phi_tag_predicate(TagPredicate crit)
Registers the PHI TAG PREDICATE (D4: SEPARATE phi criterion, on |grad phi|).
Definition amr_runtime.hpp:363
int macro_step() const
MACRO-STEP counter of the engine (regrid + hold-then-catch-up stride cadence: regrid when macro_step_...
Definition amr_runtime.hpp:1065
const VariableSet & block_cons_vars(std::size_t b) const
Conservative VariableSet (names + physical roles, Model::conservative_vars()) of block b.
Definition amr_runtime.hpp:307
void add_dt_bound(const std::string &label, std::function< double()> fn)
GLOBAL step bound (AMR counterpart of System::add_dt_bound): fn() evaluated once per step_cfl,...
Definition amr_runtime.hpp:1083
const std::string & last_dt_bound() const
ACTIVE bound of the last step_cfl ("transport:<block>" / "source_frequency:<block>" / "stability_dt:<...
Definition amr_runtime.hpp:1168
void add_coupled_frequency_expr(const std::string &label, const std::vector< std::string > &in_blocks, const std::vector< std::string > &in_roles, const std::vector< double > &consts, const std::vector< int > &freq_prog_ops, const std::vector< int > &freq_prog_args)
PER-CELL COUPLED frequency (CoupledSource.frequency with an Expr, refinement of the CONSTANT frequenc...
Definition amr_runtime.hpp:1103
void set_regrid(int every, int grow=2, int margin=2)
Activates the UNION-TAGS REGRID at the cadence every (in macro-steps): every every macro-steps,...
Definition amr_runtime.hpp:339
std::size_t n_named_fields() const
Number of registered named elliptic fields (diagnostic / test).
Definition amr_runtime.hpp:419
void set_block_level_state(std::size_t b, int k, const std::vector< double > &s)
Definition amr_runtime.hpp:1281
std::vector< double > block_level_state_global(std::size_t b, int k) const
Definition amr_runtime.hpp:1272
void set_level_potential(int k, const std::vector< double > &p)
Definition amr_runtime.hpp:1330
ConstArray4 const_array() const
READ handle (POD device-copyable) over this Fab. Valid as long as the Fab lives.
Definition fab2d.hpp:96
Array4 array()
WRITE handle (POD device-copyable) over this Fab. Valid as long as the Fab lives.
Definition fab2d.hpp:91
int solve(Real rel_tol, int max_cycles, Real abs_tol=Real(0))
Definition geometric_mg.hpp:407
Field distributed over a level: decomposition (BoxArray) + distribution (DistributionMapping) + ncomp...
Definition multifab.hpp:33
Fab2D & fab(int li)
Local fab at index li (0 <= li < local_size()), for writing.
Definition multifab.hpp:67
const Box2D & box(int li) const
VALID box of local fab li.
Definition multifab.hpp:71
void set_val(Real v)
Fills all cells (valid + ghosts) of every local fab with v.
Definition multifab.hpp:85
int local_size() const
Number of fabs OWNED by this rank (bound on local indices).
Definition multifab.hpp:65
Definition profiler.hpp:27
void count(const std::string &name, std::int64_t by=1)
Definition profiler.hpp:69
Parallel seam: minimal MPI abstraction (rank/size + collectives) with serial fallback.
Generic COUPLED SOURCE interpreter: postfix bytecode evaluated on device (P5 phase 1).
DistributionMapping: maps each box (by global index) to its owning MPI rank.
DESCRIPTIVE types of the elliptic stage: EllipticProblem (problem definition) and FieldPostProcess (f...
fill_boundary: INTRA-level halo exchange (fills ghosts from neighbors).
GeometricMG: in-house geometric multigrid (V-cycle) for the elliptic operator, Gauss-Seidel smoother ...
Geometry: index-space (Box2D) <-> Cartesian physical-space mapping; PolarGeometry: SIBLING for a glob...
Implicit / IMEX block step as a named CONTRACT.
MultiFab: a field DISTRIBUTED over a level (equivalent of AMReX's MultiFab).
void coupler_inject_aux_mb(const MultiFab &parent, MultiFab &child, bool replicated_parent=true)
Definition amr_coupler_mp.hpp:60
void same_layout_or_throw(const std::vector< std::vector< AmrLevelMP > > &block_levels)
Definition amr_system_coupler.hpp:115
Definition amr_hierarchy.hpp:29
constexpr Real kCflSpeedFloor
Speed FLOOR for the CFL step policies (audit 2026-06, explicit constant instead of the scattered lite...
Definition types.hpp:38
void for_each_cell(const Box2D &b, F f)
Applies f to EACH cell (i, j) of box b (bounds inclusive), via Kokkos::parallel_for (Serial / OpenMP ...
Definition for_each.hpp:138
void mf_average_down_mb(const MultiFab &Uf, MultiFab &Uc)
Definition amr_subcycling.hpp:305
BCRec aux_halo_override(const BCRec &shared, const AuxHaloPolicy &p)
Builds the effective override BCRec for a per-field aux halo: starts from the SHARED aux BC shared (s...
Definition physical_bc.hpp:204
std::pair< BoxArray, DistributionMapping > regrid_compute_fine_layout(TagBox grown, const Box2D &pdom, int pk, int margin, bool coarse_replicated=true)
Compute the fine layout (BoxArray + DistributionMapping) of a Berger-Rigoutsos regrid from the grown ...
Definition amr_regrid_coupler.hpp:53
TagBox tag_union(const std::vector< TagBox > &parts)
Union (cell-by-cell logical OR) of several TagBox sharing EXACTLY the same box.
Definition tag_box.hpp:74
void device_fence()
Device barrier: waits for in-flight kernels to finish before a HOST access to unified memory.
Definition kokkos_env.hpp:43
Real reduce_max_cell(const Box2D &b, F f)
MAX reduction with a REDUCING FUNCTOR: f receives (i, j, Real& acc) and updates acc,...
Definition for_each.hpp:240
void fill_physical_bc(MultiFab &mf, const Box2D &domain, const BCRec &bc)
Fills the physical-face ghosts of ALL components per bc (historical entry point, bit-identical).
Definition physical_bc.hpp:176
std::string roles_csv(const VariableSet &vs)
CSV of a VariableSet's roles (role_name, separator ',').
Definition variables.hpp:172
@ PushReg
@ Sqrt
void field_postprocess(const MultiFab &phi, MultiFab &out, Real cx, Real cy, FieldPostProcess spec)
Definition elliptic_problem.hpp:104
TagBox grow_tags(const TagBox &in, int n, const Box2D &domain)
Grows the tags by n cells (square neighborhood), staying within the domain.
Definition regrid.hpp:58
MultiFab regrid_field_on_layout(const BoxArray &fb, const DistributionMapping &dmap, const MultiFab &par, const MultiFab &old, int pk, int ngf, bool coarse_replicated=true)
Rebuild ONE fine MultiFab on the IMPOSED layout fb / dmap (the same one for all blocks in multi-block...
Definition amr_regrid_coupler.hpp:86
TagBox tag_cells(const MultiFab &mf, const Box2D &domain, Crit crit)
Marks the valid cells where the predicate is true, on a TagBox covering the domain.
Definition regrid.hpp:40
void fill_ghosts(MultiFab &mf, const Box2D &domain, const BCRec &bc)
COMPLETE ghost filling: fill_boundary (interior + periodic, periodicity deduced from bc) THEN fill_ph...
Definition physical_bc.hpp:227
PatchBox: index-space footprint of an AMR fine patch, exposed read-only to Python.
PHYSICAL boundary conditions at the domain edge (BCType, BCRec, fill_physical_bc, fill_ghosts).
Dynamic regrid: (re)builds a fine level from the tagging of a coarse level.
Pointwise types of the physics layer: StateVec<N> (conserved state) and Aux (auxiliary fields from th...
Type-erased closures of ONE AMR block, placed on the shared hierarchy.
Definition amr_runtime.hpp:98
std::function< std::vector< double >(const MultiFab &)> potential
Coarse potential read from the shared aux (component 0) as an n*n row-major field (diagnostic).
Definition amr_runtime.hpp:223
int stride
HOLD-THEN-CATCH-UP cadence of the block (multirate).
Definition amr_runtime.hpp:115
bool newton_diagnostics
NEWTON DIAGNOSTICS (OPT-IN, wave 3: AMR counterpart of System::newton_report).
Definition amr_runtime.hpp:185
std::function< void(std::vector< AmrLevelMP > &, const Box2D &, Real, Periodicity, bool)> advance
Advances the block by ONE substep of size dt: AMR transport (Berger-Oliger + conservative reflux.
Definition amr_runtime.hpp:141
std::function< std::vector< double >()> density
Coarse density (component 0) of the block as a global n*n row-major field (diagnostic).
Definition amr_runtime.hpp:219
std::shared_ptr< std::vector< AmrLevelMP > > levels
Level stack of the block (level 0 = coarse, > 0 = fine patches), ON the shared layout.
Definition amr_runtime.hpp:133
int substeps
EXPLICIT substeps of the block within ITS effective macro-step: the effective step (stride * dt) is s...
Definition amr_runtime.hpp:105
std::function< void(std::vector< AmrLevelMP > &)> project_per_level
POINTWISE PROJECTION post-pas (ADC-177) : U <- project(U, aux) appliquee PAR NIVEAU a la FIN de l'ava...
Definition amr_runtime.hpp:174
std::shared_ptr< NewtonReport > newton_report
Definition amr_runtime.hpp:186
std::function< Real(const MultiFab &, const MultiFab &)> max_speed
Speed driving the block CFL on the coarse.
Definition amr_runtime.hpp:204
std::function< void(const MultiFab &, MultiFab &)> add_elliptic_rhs
Contribution of the block to the Poisson right-hand side: rhs += elliptic_rhs_b(U_b) on the coarse.
Definition amr_runtime.hpp:191
std::function< Real(const MultiFab &, const MultiFab &)> source_frequency
OPTIONAL STEP BOUNDS of the block (AMR StabilityPolicy, audit 2026-06): evaluated on the COARSE (leve...
Definition amr_runtime.hpp:212
std::map< std::string, std::function< void(const MultiFab &, MultiFab &)> > named_elliptic_rhs
Per-NAMED-field elliptic right-hand-side contributions of the block (ADC-428): field name -> closure ...
Definition amr_runtime.hpp:199
std::function< Real()> mass
Mass of component 0 of the block coarse (sum u*dV; cross-rank reduced if distributed).
Definition amr_runtime.hpp:216
int aux_ncomp
Width of the aux channel READ by the block model (aux_comps<Model>(); >= kAuxBaseComps).
Definition amr_runtime.hpp:119
std::function< void(std::vector< AmrLevelMP > &, const Box2D &, Real, Periodicity, bool)> imex_advance
IMEX advance of the block by ONE substep of size dt: (1) EXPLICIT TRANSPORT on the SOURCE-FREE model ...
Definition amr_runtime.hpp:168
bool imex
TEMPORAL TREATMENT of the block: false (default) = EXPLICIT (forward-Euler source,...
Definition amr_runtime.hpp:149
std::function< Real(const MultiFab &, const MultiFab &)> stability_dt
Definition amr_runtime.hpp:213
VariableSet cons_vars
Descriptor of the model CONSERVATIVE variables (names + physical ROLES, Model::conservative_vars()).
Definition amr_runtime.hpp:127
WRITE POD handle (raw pointer + strides) over a Fab2D buffer, indexed by (i, j, c) IN GLOBAL INDICES ...
Definition fab2d.hpp:29
Per-field aux halo policy (ADC-369): a UNIFORM boundary policy for ONE model-named aux component,...
Definition physical_bc.hpp:195
Boundary conditions for the FOUR faces of the domain (type + associated Dirichlet value).
Definition physical_bc.hpp:29
static Box2D from_extents(int nx, int ny)
Box [0, nx-1] x [0, ny-1] covering nx*ny cells from the index origin.
Definition box2d.hpp:42
POPS_HD int nx() const
Width (direction 0). POPS_HD (called from Geometry::dx() in a device kernel).
Definition box2d.hpp:50
POPS_HD int ny() const
Height (direction 1). POPS_HD (called from Geometry::dy() in a device kernel).
Definition box2d.hpp:52
READ-only handle (const counterpart of Array4): same layout and same contract (POD device-copyable,...
Definition fab2d.hpp:44
Definition coupled_source_program.hpp:175
Device functor applying ONE coupled source over a box: captures the PODs by VALUE (input/output Array...
Definition coupled_source_program.hpp:133
int out_comp[kCsMaxTerms]
Definition coupled_source_program.hpp:142
Fixed-capacity postfix program (POD device-copyable): len opcodes, arg read only by PushReg (register...
Definition coupled_source_program.hpp:47
Definition elliptic_problem.hpp:73
Cartesian geometry of a level: index domain + physical bounds [xlo, xhi] x [ylo, yhi].
Definition geometry.hpp:20
POPS_HD Real dy() const
Grid spacing in y (= (yhi - ylo) / domain.ny()). POPS_HD.
Definition geometry.hpp:33
POPS_HD Real dx() const
Grid spacing in x (= (xhi - xlo) / domain.nx()). POPS_HD.
Definition geometry.hpp:31
AGGREGATED report (whole block, all substeps of one advance) of the implicit-source Newton.
Definition implicit_stepper.hpp:165
INDEX-SPACE footprint of an AMR fine patch, exposed to Python by AmrSystem::patch_boxes().
Definition patch_box.hpp:30
Per-direction periodicity: halo wrapping in x and/or y during the exchange (false = open edge,...
Definition fill_boundary.hpp:37
Dense grid of 0/1 markers over a box, input to Berger-Rigoutsos clustering.
Definition tag_box.hpp:35
A model's variable set: kind (cons/prim), names, size, canonical roles (optional, parallel to names; ...
Definition variables.hpp:58
std::vector< VariableRole > roles
parallel to names; empty = roles not provided
Definition variables.hpp:62
int index_of(VariableRole role) const
Index of the component carrying role (first occurrence), -1 if absent.
Definition variables.hpp:67
TagBox: dense grid of markers (0/1) over a region, input to Berger-Rigoutsos clustering.
Descriptor of a model's variables (Vars).
Generated by