include/pops/runtime/builders/compiled/amr_dsl_block.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_dsl_block.hpp
Go to the documentation of this file.
3#include <pops/coupling/schur/amr/amr_condensed_schur_source_stepper.hpp> // GLOBAL condensed source stage (amr-schur)
14#include <pops/numerics/spatial_operator.hpp> // SourceFreeModel (explicit IMEX half-step, transport only)
15#include <pops/numerics/time/integrators/implicit_stepper.hpp> // backward_euler_source + ImplicitMask (stiff IMEX source)
19#include <pops/runtime/builders/block/block_builder.hpp> // detail::make_poisson_rhs (rhs += elliptic_rhs(U))
20#include <pops/runtime/config/dispatch_tags.hpp> // UNIQUE tag registry (validate_limiter/riemann)
22#include <algorithm> // std::find, std::sort (resolving the partial IMEX mask of a compiled block)
126 // distributed multi-box if bp.distribute_coarse). When replicated, dmap = my_rank() everywhere (the box
127 // lives on each rank; a round-robin would place it on rank 0 only -> out-of-bounds fab elsewhere,
128 // segfault under np>1). The fine seed (allocated below ONLY when refinement is configured) starts on the
130 // (DistributionMapping(nfine, n_ranks())) -> multi-GPU distribution of the fine patches. When distributed,
132 const auto [bac, dm] = coupler_make_coarse_layout(bp.n, bp.distribute_coarse, bp.coarse_max_grid);
138 // Level 1 (central seed fine patch, reshaped by the regrid): allocated ONLY on the explicit/imex path
139 // AND when refinement is actually configured (set_refinement was called -> refine_threshold below its
141 // - amr-schur (Step 2/3) runs MONO-LEVEL: the condensed source stage does not yet carry the multi-level
142 // case (cf. AmrCondensedSchurSourceStepper, guard on the number of fine patches), so a seed would trip
143 // that guard at the first step. Multi-level amr-schur (fine reconstruction + cascade + composite
145 // - NO refinement (ADC-324): with the 1e30 sentinel the build-time regrid below (cpl->regrid(crit)) tags
146 // nothing and amr_regrid_finest is a deliberate no-op on zero tags, so the seed would NEVER be reshaped
147 // or removed -- it would persist as a SINGLE un-chopped fine box on the coarse dmap (box 0 -> rank 0),
148 // dead weight that starves MPI strong-scaling (rank 0 carries its coarse boxes PLUS the whole fine
149 // patch). Gating on refine_threshold keeps the no-refinement hierarchy MONO-LEVEL (n_patches()==0, like
150 // the amr-schur path), so the coarse distributes cleanly. When refinement IS configured the seed is
151 // allocated and the first build regrid chops + distributes it round-robin exactly as before (UNCHANGED).
163 // Coarse seed: COMPLETE conservative state (preferred, set_conservative_state) otherwise density
164 // only (historical). coupler_inject_coarse_to_fine_mb prolongs ALL components (loop k<nc), so the
179 // model-NAMED aux (ADC-291): seed the static named fields onto the coupler's shared aux BEFORE the
180 // first update/step (like density/B_z seeding). The coupler re-applies them in compute_aux each
181 // update, so they persist across regrid and reach every level via the aux injection. Empty -> no-op.
195 // NEWTON OPTIONS of the mono-block IMEX source (wave 3): threaded to cpl->step -> advance_amr ->
196 // backward_euler_source. DEFAULT {} (newton_options not set) = historical constants (2 iters) ->
199 // TIME METHOD mono-block: integer of the flat ABI (bp.time_method) -> AmrTimeMethod, threaded to
203 // Zhang-Shu positivity floor (ADC-259): threaded to cpl->step / advance_transport -> advance_amr ->
204 // compute_face_fluxes + C/F ghost clamp. bp.pos_floor == 0 (default / older flat-ABI .so loader that
210 // explicit/imex source. The stage is built on the COARSE grid by COMPOSING the uniform stage #126
211 // (Density/MomentumX/MomentumY roles of the Model -> clear error HERE if missing). Coarse B_z required
212 // (set_magnetic_field). The model must be SOURCE-FREE (NoSource source brick): advance_transport
213 // then runs NO source (the source is the condensed stage alone), mirror of the uniform path where the
214 // block is added with its transport only (time.hyperbolic) + the separate condensed source stage.
216 // WARNING: OPTION A = INTERMEDIATE. The condensed stage solves the elliptic on the COARSE grid (like the
217 // AMR Poisson compute_aux/solve_fields), then grad phi is injected (piecewise constant) to the fines: the
218 // fine patches refine the TRANSPORT but NOT the elliptic coupling. For a FAITHFUL paper/AMR reproduction
221 // coarsens ONE grid, != AMR hierarchy). This is the fidelity lock, to do AFTER the mono-level parity.
223 // "" = canonical role (historical, bit-identical); otherwise stable ROLE name then block VARIABLE name.
274 // amr-schur Step 2/3: MONO-LEVEL hierarchy (the condensed stage does not carry the multi-level case).
275 // So we do NOT regrid (a regrid would create a fine patch -> multi-level guard of the stage). The
276 // amr-schur regrid will come with the composite Schur/Poisson (Step 4). cf. levels().size() > 1.
285 // consumes phi -- exactly SystemStepper::step_strang (3 solves: head, pre-source, post-source).
293 // LIE (Godunov, 1st order): H(dt); S(dt). A single update() at the head (the source stage reads
301 // tous les substeps. No-op si le modele ne declare pas m.project (HasPointwiseProjection false).
311 // NEWTON OPTIONS threaded to the coupler (mono-block): nopts={} by default => iters=2 historical,
312 // bit-identical; non-default nopts (set_density + pops.IMEX(newton_*)) drives the local Newton.
322 // RESTORATION of the CADENCE PHASE (IO v1, parity with System::set_clock): AmrSystem::set_clock sets
323 // the macro-step counter of the mono-block (the regrid cadence reads *step_state) on restart. Shares the
324 // SAME step_state as the step closure above -> the regrid phase resumes exactly. Without the call,
327 // CFL SPEED: lambda* (HasStabilitySpeed trait) if declared, otherwise max_wave_speed of the coupler
328 // (historical fallback, bit-identical) -- SAME policy as System/make_max_speed, evaluated on the
354 // Index-space signatures of the fine patches (mono-block counterpart of AmrRuntime::patch_boxes).
355 // Captures the SAME cpl as the other hooks (no new lifetime concern), reads the already materialized
367 // Coarse-level (base) box counts (ADC-319, MPI ownership diagnostic): per-rank OWNED fabs of level 0
368 // (local_size()) and the GLOBAL base box count (box_array().size()). Same cpl capture as the other
369 // hooks (no new lifetime concern); a query between steps, zero cost on the hot path. distribute_coarse
370 // -> local < total per rank (distributed coarse transport); replicated/single-box -> local == total.
375 // other hooks (no new lifetime concern). Single-rank: the coupler accessors loop over local_size()
376 // (no gather) -- the facade rejects np>1 / multi-block upstream. These hooks are QUERIES/SETTERS
387 // bit-identical checkpoint gathers the distributed per-level fabs onto rank 0 (COLLECTIVE, all ranks
388 // call). Mono-rank they return the same array as the non-global hooks above (reduce = identity).
453 // [n/4 .. 3n/4-1]^2, refined x2). DISTRIBUTED round-robin DistributionMapping(nfine, n_ranks()),
455 // distributed over the ranks (one per GPU). This is ESSENTIAL under MPI: on the REPLICATED coarse,
456 // if the fine were placed on the same replicated dmap ({my_rank()}), EACH rank would hold a copy
457 // of the fine box and the reflux (all_reduce_sum_inplace of the flux registers) would sum the SAME
516 // wired in multi-block, preferred) otherwise density (component 0, rest at rest) otherwise zero.
537 // advance: ONE AMR transport sub-step of the block (conservative Berger-Oliger + reflux + average_down)
540 // step()). The sub-step loop (substeps) and the stride cadence are CARRIED by AmrRuntime::step,
545 // tmethod (kEuler default) selects SSPRK3 (time='ssprk3') for the explicit transport of the block;
546 // kEuler -> historical forward Euler, bit-identical. The explicit source stays carried by advance_amr.
547 b.advance = [model, rprim, time_method, pos_floor](std::vector<AmrLevelMP>& L, const Box2D& dom,
549 advance_amr<Limiter, Flux>(model, L, dom, dt, per, repl, rprim, /*imex=*/false, NewtonOptions{},
553 // SEMANTICS mirror the IMEX branch of AmrSystemCoupler::step (SourceFreeModel + AmrImplicitSourceStepper),
554 // populated ONLY if imex. (1) EXPLICIT transport on the SOURCE-FREE model (SourceFreeModel<Model>:
555 // flux/CFL of the model, null source) by the SAME AMR engine (conservative reflux); (2) stiff source
556 // IMPLICIT backward_euler_source AT EACH LEVEL (local Newton), with the mask @p implicit_components
557 // carried by the BLOCK (partial IMEX); (3) cascade fine -> coarse (mf_average_down_mb) for the coherence
559 // substeps=1 this is exactly the compile-time IMEX branch, for substeps>1 the runtime SUB-CYCLES the
563 // full backward-Euler, bit-identical to IMEX without a mask). SourceFreeModel<Model> is a concrete
564 // type instantiated IN this TU: its advance_amr<Limiter, Flux> stays compiled (no cross-TU extended
566 // of the source-free half-step stays CONSERVATIVE (recon_prim=false): SAME choice as AmrSystemCoupler::step
567 // (which calls advance_amr on SourceFreeModel with the default), and SourceFreeModel does not expose
568 // the primitive variables anyway (cf. its header). The EXPLICIT block, for its part, keeps recon_prim=rprim.
576 // NEWTON DIAGNOSTICS (OPT-IN, wave 3): we allocate the AGGREGATE report of the block in a shared_ptr
579 // nreport=nullptr -> backward_euler_source FAST path, bit-identical. The RESET of the report is the
591 // (1) explicit source-free transport (-div F only), reflux carries the hyperbolic conservation.
600 // nreport (null without diagnostics) AGGREGATES over the levels: backward_euler_source does its own
601 // max/sum + MPI all_reduce into *nreport (no reset here -> it also accumulates over the sub-steps,
602 // step() having reset at the head of the advance). nreport==nullptr -> fast bit-identical path.
608 // instead of the 2x2 average of its children. Cascade fine -> coarse for the coherence (the mass,
609 // sum of the coarse grid alone, then does not count the patch source twice). Mono-level: empty loop
617 // (HasPointwiseProjection). AmrRuntime::step l'applique PAR NIVEAU a la FIN de l'avance du bloc
618 // (substeps + reflux/cascade faits). Vide sinon -> trajectoire bit-identique. Capture le `model`
619 // concret comme advance / imex_advance (foncteur device-clean, pas de lambda etendue cross-TU).
624 // Contribution of the block to the SUMMED Poisson RHS: rhs += elliptic_rhs(U) on the coarse grid (pure
629 // (HasStabilitySpeed trait) if the model declares it, otherwise max_wave_speed (historical fallback,
674// ADC-359 per-flux branches of dispatch_amr_block, factored so the compressible AMR seam compiles ONE
675// flux per TU (build_amr_block_for_flux -> these). Each body is the corresponding `if (riem == "<flux>")`
676// branch of dispatch_amr_block VERBATIM (same leaves, same hllc/roe `if constexpr` capability guards, same
677// messages); validate_riemann/limiter run in the caller (dispatch_amr_block, or the compressible thin
678// dispatcher python/amr_block_compressible.cpp). dispatch_amr_block (below, unchanged) still serves the
832 // CENTRALIZED VALIDATION (dispatch_tags.hpp registry) BEFORE the dispatch: same tags accepted /
833 // rejected as before, identical messages. The template if/else dispatch that follows is UNCHANGED; the
837 // ADC-359: delegate to the flux-pinned dispatch_amr_block_<flux> helpers above (factored so the
838 // compressible seam compiles one flux per TU). Behavior is unchanged: same leaves, same hllc/roe
859// ADC-359 per-flux branches of dispatch_amr_compiled, factored so the compressible compiled AMR seam
860// compiles ONE flux per TU (build_amr_compiled_for_flux -> these). Each body is the corresponding
861// `if (riem == "<flux>")` branch of dispatch_amr_compiled VERBATIM (same leaves, guards, messages);
862// validate_* run in the caller. dispatch_amr_compiled (below, unchanged) still serves exb/isothermal.
955 // CENTRALIZED VALIDATION (dispatch_tags.hpp registry) BEFORE the dispatch: same tags accepted /
956 // rejected as before. Template if/else dispatch UNCHANGED; per-model hllc/roe capability guards.
959 // ADC-359: delegate to the flux-pinned dispatch_amr_compiled_<flux> helpers above. Behavior unchanged
1038 // PROJECTION PONCTUELLE post-pas (ADC-177) : DESORMAIS CABLEE sur AmrSystem. Appliquee PAR NIVEAU
1041 // AmrRuntime::step -> project_per_level). Cell-local + idempotente : conservation preservee (les
1044 // freezes AmrBuildParams::time_method / passes AmrTimeMethod to dispatch_amr_block (the flat ABI of the
1045 // .so loader does not marshal the method). EXPLICIT rejection rather than a silent kEuler fallback; an
1059 // (1) MONO-BLOCK builder: captures the concrete Model + the scheme, materializes the AmrCouplerMP at the
1060 // lazy build (refine/poisson/density parameters frozen at that point). Historical path, untouched.
1067 // (2) MULTI-BLOCK builder: captures the SAME concrete Model/scheme, materializes the AmrRuntimeBlock of the
1068 // block on the SHARED layout (common to all blocks, created once at ensure_built). Resolves ITSELF
1069 // the partial IMEX mask against cons_vars of the concrete Model (known here), then calls dispatch_amr_block
1071 // the add, there from a ModelSpec at build). FUNCTOR without a cross-TU extended lambda in the kernel:
1072 // dispatch_amr_block captures advance_amr<Limiter, Flux> (named template function), device-clean
1084 // pos_floor (ADC-322): the .so flat ABI now carries the Zhang-Shu floor; forward it to the SAME
1085 // dispatch_amr_block -> build_amr_block leaf as a native multi-block. The compiled path transports
1086 // NEITHER Newton options/state/diagnostics NOR SSPRK3 (rejected at the facade / add_compiled_model),
AmrCondensedSchurSourceStepper: AMR counterpart of the Schur-condensed SOURCE stage (CondensedSchurSo...
AmrCouplerMP: MULTI-PATCH E x B AMR coupler (coarse Poisson -> aux = grad phi -> fine injection -> co...
AMR multi-block engine at RUNTIME (type-erased registry keyed by name).
Multi-species composition on AMR at runtime: the refined counterpart of System.
Builds the closures of a block (time advance + residual + Poisson contribution) from a COMPILED model...
Box2D: the integer index space of a 2D cell-centered Cartesian grid.
BoxArray: the set of boxes tiling a level (disjoint, covering).
Schur-condensed SOURCE stage over an AMR hierarchy.
Definition amr_condensed_schur_source_stepper.hpp:54
void step(std::vector< AmrLevelMP > &levels, MultiFab &coarse_phi, const MultiFab &coarse_bz, int c_bz, Real theta, Real dt)
Condensed SOURCE stage, IN-PLACE on the hierarchy levels and the coarse potential coarse_phi.
Definition amr_condensed_schur_source_stepper.hpp:105
Single block carried on an AMR hierarchy, composed at runtime.
Definition amr_system.hpp:245
POPS_EXPORT void set_compiled_block(int ncomp, double gamma, int substeps, std::function< AmrCompiledHooks(const AmrBuildParams &)> mono_builder, AmrCompiledBlockBuilder multi_builder={}, const std::string &name=std::string(), bool recon_prim=false, bool imex=false, int stride=1, const std::vector< std::string > &implicit_vars={}, const std::vector< std::string > &implicit_roles={}, double pos_floor=0.0)
Registers a COMPILED block (add_compiled_model path, header amr_dsl_block.hpp).
Owning MPI rank of each box, indexed by GLOBAL box index (parallel to a BoxArray).
Definition distribution_mapping.hpp:19
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
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
Parallel seam: minimal MPI abstraction (rank/size + collectives) with serial fallback.
HLLC capability: the model provides the CONTACT wave speed and the STAR STATE on side k.
Definition numerical_flux.hpp:142
Trait OPTIONNEL : PROJECTION PONCTUELLE post-pas U -> project(U, aux) (ADC-177).
Definition physical_model.hpp:154
Roe capability: the model provides its FULL Roe dissipation d = |A_roe(UL, UR)| (UR - UL) – Roe avera...
Definition numerical_flux.hpp:156
OPTIONAL trait: local source frequency mu [1/s] (bound dt <= cfl / max mu, without h).
Definition physical_model.hpp:137
OPTIONAL trait: direct admissible step per cell (bound dt <= min stability_dt, without cfl).
Definition physical_model.hpp:143
OPTIONAL trait: stability speed lambda* replacing max_wave_speed in the block CFL.
Definition physical_model.hpp:131
SINGLE registry of spatial scheme tags (limiters + Riemann fluxes): shared source of truth for ALL di...
DistributionMapping: maps each box (by global index) to its owning MPI rank.
for_each_cell and reductions: the parallelism SEAM over the cells of a Box2D; sync_host / sync_device...
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).
AmrRuntimeBlock dispatch_amr_block_hll(const Model &m, const std::string &lim, const SharedAmrLayout &S, const std::string &name, const std::vector< double > &density, bool has_density, double gamma, int substeps, bool recon_prim, bool imex, int stride, const std::vector< int > &implicit_components, const NewtonOptions &nopts, const std::vector< double > *state, bool newton_diagnostics, AmrTimeMethod time_method, double pos_floor)
Definition amr_dsl_block.hpp:707
std::vector< double > coupler_read_coarse(const MultiFab &U, int n, bool replicated)
Definition amr_coupler_mp.hpp:169
AmrCompiledHooks dispatch_amr_compiled_rusanov(const Model &m, const std::string &lim, const AmrBuildParams &bp)
Definition amr_dsl_block.hpp:864
std::pair< BoxArray, DistributionMapping > coupler_make_coarse_layout(int n, bool distribute, int max_grid)
Definition amr_coupler_mp.hpp:257
AmrCompiledHooks dispatch_amr_compiled(const Model &m, const std::string &lim, const std::string &riem, const AmrBuildParams &bp)
Dispatch of the spatial scheme (limiter x Riemann flux) -> build_amr_compiled.
Definition amr_dsl_block.hpp:953
AmrRuntimeBlock dispatch_amr_block_rusanov(const Model &m, const std::string &lim, const SharedAmrLayout &S, const std::string &name, const std::vector< double > &density, bool has_density, double gamma, int substeps, bool recon_prim, bool imex, int stride, const std::vector< int > &implicit_components, const NewtonOptions &nopts, const std::vector< double > *state, bool newton_diagnostics, AmrTimeMethod time_method, double pos_floor)
Definition amr_dsl_block.hpp:681
AmrRuntimeBlock dispatch_amr_block_hllc(const Model &m, const std::string &lim, const SharedAmrLayout &S, const std::string &name, const std::vector< double > &density, bool has_density, double gamma, int substeps, bool recon_prim, bool imex, int stride, const std::vector< int > &implicit_components, const NewtonOptions &nopts, const std::vector< double > *state, bool newton_diagnostics, AmrTimeMethod time_method, double pos_floor)
Definition amr_dsl_block.hpp:743
std::vector< double > coupler_read_coarse_phi(const MultiFab &aux0, int n, bool replicated)
Definition amr_coupler_mp.hpp:191
void coupler_write_coarse(MultiFab &U, const std::vector< double > &rho, int n, int ncomp, double gamma)
Definition amr_coupler_mp.hpp:112
void amr_schur_source(Coupler &cpl, AmrCondensedSchurSourceStepper &schur, MultiFab &bz_coarse, MultiFab &phi_coarse, double theta, double dt)
A GLOBAL condensed source STAGE on the mono-block coupler hierarchy.
Definition amr_dsl_block.hpp:104
AmrRuntimeBlock dispatch_amr_block(const Model &m, const std::string &lim, const std::string &riem, const SharedAmrLayout &S, const std::string &name, const std::vector< double > &density, bool has_density, double gamma, int substeps, bool recon_prim, bool imex, int stride=1, const std::vector< int > &implicit_components={}, const NewtonOptions &nopts={}, const std::vector< double > *state=nullptr, bool newton_diagnostics=false, AmrTimeMethod time_method=AmrTimeMethod::kEuler, double pos_floor=0.0)
Dispatch of the spatial scheme (limiter x Riemann flux) -> build_amr_block.
Definition amr_dsl_block.hpp:825
void coupler_inject_coarse_to_fine_mb(const MultiFab &Uc, MultiFab &Uf, bool replicated)
Definition amr_coupler_mp.hpp:212
AmrRuntimeBlock dispatch_amr_block_roe(const Model &m, const std::string &lim, const SharedAmrLayout &S, const std::string &name, const std::vector< double > &density, bool has_density, double gamma, int substeps, bool recon_prim, bool imex, int stride, const std::vector< int > &implicit_components, const NewtonOptions &nopts, const std::vector< double > *state, bool newton_diagnostics, AmrTimeMethod time_method, double pos_floor)
Definition amr_dsl_block.hpp:782
SharedAmrLayout make_shared_amr_layout(const AmrBuildParams &bp)
Builds the SHARED layout (PR1): coarse (per the ownership policy) + ONE central FIXED fine patch (the...
Definition amr_dsl_block.hpp:440
AmrCompiledHooks dispatch_amr_compiled_hll(const Model &m, const std::string &lim, const AmrBuildParams &bp)
Definition amr_dsl_block.hpp:878
AmrCompiledHooks dispatch_amr_compiled_hllc(const Model &m, const std::string &lim, const AmrBuildParams &bp)
Definition amr_dsl_block.hpp:901
void apply_pointwise_project_amr(const Model &m, std::vector< AmrLevelMP > &levels)
Definition amr_dsl_block.hpp:65
AmrCompiledHooks dispatch_amr_compiled_roe(const Model &m, const std::string &lim, const AmrBuildParams &bp)
Definition amr_dsl_block.hpp:926
AmrRuntimeBlock build_amr_block(const Model &model, const SharedAmrLayout &S, const std::string &name, const std::vector< double > &density, bool has_density, double gamma, int substeps, bool recon_prim, bool imex, int stride=1, const std::vector< int > &implicit_components={}, const NewtonOptions &nopts={}, const std::vector< double > *state=nullptr, bool newton_diagnostics=false, AmrTimeMethod time_method=AmrTimeMethod::kEuler, double pos_floor=0.0)
Builds ONE type-erased AMR block (AmrRuntimeBlock) on the SHARED layout S, for a composite Model + co...
Definition amr_dsl_block.hpp:497
void amr_write_coarse_bz(MultiFab &bz, const std::vector< double > &field, int n)
Fills the COARSE B_z field (component 0, n*n row-major in GLOBAL indices) from field.
Definition amr_dsl_block.hpp:84
AmrCompiledHooks build_amr_compiled(const Model &model, const AmrBuildParams &bp)
Builds the AMR coupler for a composite Model + concrete (Limiter, Flux) and fills the type-erased hoo...
Definition amr_dsl_block.hpp:120
void coupler_write_coarse_state(MultiFab &U, const std::vector< double > &state, int n, int ncomp)
Definition amr_coupler_mp.hpp:143
Definition amr_hierarchy.hpp:29
Real for_each_cell_reduce_sum(const Box2D &b, F f)
SUM reduction of f(i, j) over box b.
Definition for_each.hpp:199
void throw_registry_dispatch_mismatch(const char *ctx, const char *kind, const std::string &tag)
DEFENSE-IN-DEPTH guard: reached only if a VALID tag (already accepted by validate_*) is routed by NO ...
Definition dispatch_tags.hpp:138
void validate_riemann(const std::string &riem, bool polar=false, const char *ctx="System")
Validates a Riemann FLUX tag against kRiemanns.
Definition dispatch_tags.hpp:111
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
void validate_limiter(const std::string &lim, const char *ctx="System")
Validates a LIMITER tag against kLimiters.
Definition dispatch_tags.hpp:99
void add_compiled_model(AmrSystem &sys, const std::string &name, Model model, const std::string &limiter="minmod", const std::string &riemann="rusanov", const std::string &recon="conservative", const std::string &time="explicit", double gamma=1.4, int substeps=1, int stride=1, const std::vector< std::string > &implicit_vars={}, const std::vector< std::string > &implicit_roles={}, double pos_floor=0.0)
Wires model (concrete CompositeModel) as an AMR block of sys, with the requested scheme.
Definition amr_dsl_block.hpp:1028
Real min_stability_dt_mf(const Model &model, const MultiFab &U, const MultiFab &aux)
Global min of the declared admissible step (HasStabilityDt trait), via max(1/dt) (cf.
Definition wave_speed.hpp:222
std::vector< int > resolve_implicit_components_compiled(const std::string &block, const VariableSet &cons, const std::vector< std::string > &names, const std::vector< std::string > &roles)
Resolves the partial IMEX MASK (implicit_vars / implicit_roles) of a COMPILED block into indices of c...
Definition amr_dsl_block.hpp:979
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 max_source_frequency_mf(const Model &model, const MultiFab &U, const MultiFab &aux)
Global max of the source frequency (HasSourceFrequency trait). 0 if the source does not constrain.
Definition wave_speed.hpp:209
@ kSsprk3
@ kEuler
@ Energy
@ Density
@ MomentumX
@ Custom
@ MomentumY
std::function< void(const MultiFab &, MultiFab &)> make_poisson_rhs(const Model &m)
Block contribution to the Poisson right-hand side: rhs += elliptic_rhs(U) (host loop).
Definition block_builder.hpp:861
VariableRole role_from_name(const std::string &s)
Forward declaration: VariableSet::index_of(const std::string&) resolves a canonical role NAME via rol...
Definition variables.hpp:130
Real max_stability_speed_mf(const Model &model, const MultiFab &U, const MultiFab &aux)
Global max of the STABILITY speed (HasStabilitySpeed trait) – counterpart of max_wave_speed_mf.
Definition wave_speed.hpp:197
Real max_wave_speed_mf(const Model &model, const MultiFab &U, const MultiFab &aux)
max_wave_speed_mf: global max of the wave speed over the whole MultiFab (CFL).
Definition wave_speed.hpp:66
Single-interface numerical flux policies: Rusanov, HLL, HLLC, Roe.
Interface reconstruction policies: MUSCL limiters and WENO5-Z.
AMR inter-level transfer operators (integer ratio r) + parallel_copy.
Cartesian spatial operator: assembles R(U, aux) = -div F + S over the cells of a level.
Frozen parameters passed to the deferred build of the compiled path (add_compiled_model).
Definition amr_system.hpp:84
double schur_theta
theta-scheme of the condensed stage (0.5 = Crank-Nicolson)
Definition amr_system.hpp:110
double refine_threshold
1e30 => no refinement
Definition amr_system.hpp:92
std::function< bool(Real, Real)> wall
conductive wall predicate (empty = none)
Definition amr_system.hpp:94
int coarse_max_grid
tile size of the distributed coarse (0 => n/2)
Definition amr_system.hpp:98
int schur_krylov_max_iters
iteration budget (<= 0 = default 400)
Definition amr_system.hpp:126
BCRec poisson_bc
coarse Poisson BC (resolved by set_poisson)
Definition amr_system.hpp:93
std::vector< double > state
ncomp*n*n, component-major c*n*n + j*n + i; ncomp == Model::n_vars
Definition amr_system.hpp:105
bool imex
time == "imex": stiff implicit source (backward_euler)
Definition amr_system.hpp:91
std::map< int, std::vector< double > > named_aux
Model-NAMED aux fields (ADC-291): component (>= kAuxNamedBase) -> coarse base-level field (n*n row-ma...
Definition amr_system.hpp:119
bool distribute_coarse
distributed multi-box coarse (AMR strong-scaling)
Definition amr_system.hpp:97
bool schur
true: GLOBAL condensed source stage (instead of local explicit/imex)
Definition amr_system.hpp:109
double schur_alpha
electrostatic coupling constant of the condensed stage
Definition amr_system.hpp:111
std::vector< double > density
initial coarse density (component 0), n*n
Definition amr_system.hpp:96
std::map< int, AuxHaloPolicy > named_aux_bc
Per-field aux HALO policies (ADC-369): component -> uniform boundary policy, seeded onto the engine a...
Definition amr_system.hpp:123
double schur_krylov_tol
tolerance of the coarse Krylov solve (<= 0 = default 1e-10)
Definition amr_system.hpp:125
std::vector< double > bz_field
coarse B_z(x,y) field, n*n row-major (required by the condensed stage)
Definition amr_system.hpp:115
bool recon_prim
recon == "primitive" (frozen by add_compiled_model)
Definition amr_system.hpp:90
bool schur_strang
true: Strang splitting H(dt/2) S(dt) H(dt/2); false: Lie H(dt) S(dt)
Definition amr_system.hpp:112
Type-erased closures of a compiled AMR block, produced by amr_dsl_block::build_amr_compiled and insta...
Definition amr_system.hpp:153
std::function< void(double)> step
one macro-step (periodic regrid included)
Definition amr_system.hpp:155
std::function< std::vector< PatchBox >()> patch_boxes
index-space signatures of the fine patches
Definition amr_system.hpp:166
std::function< double()> max_speed
max wave speed (CFL step)
Definition amr_system.hpp:156
std::function< double()> stability_dt
coarse min of the admissible step (0 = does not constrain)
Definition amr_system.hpp:173
std::function< int()> n_patches
number of fine patches
Definition amr_system.hpp:158
std::function< void(int)> set_macro_step
restores the cadence (regrid) phase of the mono-block
Definition amr_system.hpp:179
std::shared_ptr< void > coupler_holder
keeps the AmrCouplerMP<Model> alive
Definition amr_system.hpp:154
std::function< double()> source_frequency
coarse max of mu [1/s] (0 = does not constrain)
Definition amr_system.hpp:171
Bundle (limiter, Riemann flux) expected by AmrCouplerMP::step<Disc>.
Definition amr_dsl_block.hpp:52
Type-erased closures of ONE AMR block, placed on the shared hierarchy.
Definition amr_runtime.hpp:98
WRITE POD handle (raw pointer + strides) over a Fab2D buffer, indexed by (i, j, c) IN GLOBAL INDICES ...
Definition fab2d.hpp:29
POINTWISE auxiliary fields shared with the physics: single coupling channel.
Definition state.hpp:123
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
READ-only handle (const counterpart of Array4): same layout and same contract (POD device-copyable,...
Definition fab2d.hpp:44
Cartesian geometry of a level: index domain + physical bounds [xlo, xhi] x [ylo, yhi].
Definition geometry.hpp:20
Options of the local Newton of the implicit source (backward-Euler).
Definition implicit_stepper.hpp:114
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
A model's variable set: kind (cons/prim), names, size, canonical roles (optional, parallel to names; ...
Definition variables.hpp:58
int index_of(VariableRole role) const
Index of the component carrying role (first occurrence), -1 if absent.
Definition variables.hpp:67
Definition geometric_mg.hpp:66
Kernel device de la PROJECTION PONCTUELLE post-pas (ADC-177) : U(i, j) <- m.project(U(i,...
Definition block_builder.hpp:225
Generated by