include/pops/runtime/amr_system.hpp Source File

adc_cpp: include/pops/runtime/amr_system.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_system.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <pops/mesh/layout/patch_box.hpp> // PatchBox: index-space signature of a fine patch (patch_boxes())
5#include <pops/numerics/time/integrators/implicit_stepper.hpp> // NewtonOptions (Newton options of the IMEX source)
6#include <pops/runtime/export.hpp> // POPS_EXPORT: set_compiled_block resolved by the native AMR loader
7#include <pops/runtime/facade_options.hpp> // SourceStageOptions / CoupledSourceProgram (facade PODs, ADC-214)
9
10#include <functional>
11#include <map>
12#include <memory>
13#include <string>
14#include <vector>
15
38
39namespace pops {
40
41// Forward declarations of the runtime multi-block engine (definitions in amr_runtime.hpp /
42// amr_dsl_block.hpp). set_compiled_block stores a DEFERRED runtime-block BUILDER which, given the
43// SHARED layout materialized at lazy build, returns the type-erased AmrRuntimeBlock of the compiled
44// block: this is what lets SEVERAL compiled blocks (multi-block production DSL) co-exist on the
45// SAME AMR hierarchy, exactly like add_block in native multi-block. We forward-declare so as NOT
46// to weigh down this public header (read by bindings.cpp and the loaders) with amr_runtime.hpp: only
47// the TUs that BUILD/CALL the builder (amr_dsl_block.hpp and python/amr_system.cpp) include the
48// complete definitions; a std::function with incomplete-type signature is legal as long as it is
49// not instantiated with a concrete callable outside those TUs (PIMPL std::function recipe).
50struct AmrRuntimeBlock;
51// Forward-declared for the named-elliptic-field RHS closure signature (ADC-428,
52// set_block_elliptic_field): a std::function with an incomplete-type parameter is legal as long as it is
53// only INSTANTIATED with a concrete callable in the TUs that include the full definition (the native AMR
54// loader / python/bindings/amr/amr_system.cpp), per the PIMPL std::function recipe noted above.
55class MultiFab;
56namespace detail {
57struct SharedAmrLayout;
58}
59
62 int n = 128;
63 double L = 1.0;
64 int regrid_every = 20;
65 bool periodic = true;
75 bool distribute_coarse = false;
79};
80
85 int n = 128;
86 double L = 1.0;
87 int regrid_every = 20;
88 double gamma = 1.4;
89 int substeps = 1;
90 bool recon_prim = false;
91 bool imex = false;
92 double refine_threshold = 1e30;
94 std::function<bool(Real, Real)> wall;
95 bool has_density = false;
96 std::vector<double> density;
97 bool distribute_coarse = false;
99 // FULL initial conservative state (all components), takes priority over `density` when
100 // has_state. ADDED AT THE END OF THE STRUCT: the offsets of the preceding fields are unchanged, so an
101 // older mono-block .so loader (which COPIES bp into its own layout then does not read these fields)
102 // falls back SILENTLY to the historical density path -- no corruption (append-only).
103 bool has_state = false;
104 std::vector<double>
106 // Schur-CONDENSED SOURCE STAGE (amr-schur path, counterpart of System::set_source_stage). ADDED AT THE
107 // END OF THE STRUCT (append-only, same reason as has_state: an older .so loader does not read these
108 // fields and falls back to the historical explicit/imex path). schur==false -> path unchanged.
109 bool schur = false;
110 double schur_theta = 0.5;
111 double schur_alpha = 1.0;
113 false;
114 std::vector<double>
119 std::map<int, std::vector<double>> named_aux;
123 std::map<int, AuxHaloPolicy> named_aux_bc;
124 // Settings of the condensed stage TRANSPORTED by the ABI (audit wave 3, append-only like has_state).
125 double schur_krylov_tol = 0.0;
127 // Field descriptors of the stage ("" = canonical role, bit-identical; otherwise stable role
128 // name OR block variable name, resolved at build against Model::conservative_vars()).
130 // NEWTON OPTIONS of the IMEX source on the MONO-BLOCK path (wave 3: mono-block AMR options wired).
131 // ADDED AT THE END OF THE STRUCT (append-only, same reason as has_state / schur_*: an older .so loader
132 // does not read this field and falls back to the historical Newton with 2 frozen iters). DEFAULT {} =
133 // historical constants (2 / 0 / 0 / 1e-7 / 1.0 / none) -> backward_euler_source path (2a)
134 // bit-identical. Consumed by build_amr_compiled (the mono-block closure passes it to cpl->step).
136 // TEMPORAL METHOD of the block, transported as an INTEGER by the flat ABI (0 == kEuler, historical
137 // before, 1 == kSsprk3). ADDED AT THE END OF THE STRUCT (append-only, same reason as has_state /
138 // schur_* / newton_options: an older .so loader does not read this field and falls back SILENTLY
139 // to 0 == kEuler -- no corruption). Consumed by build_amr_compiled (mono-block -> cpl->step).
140 int time_method = 0; // pops::AmrTimeMethod: 0 kEuler (default), 1 kSsprk3
141 // Zhang-Shu positivity floor (ADC-259): Density-role face-state + C/F-ghost-mean floor on the AMR
142 // transport. ADDED AT THE END OF THE STRUCT (append-only, same reason as has_state / schur_* /
143 // newton_options / time_method: an older flat-ABI .so loader does not read this field and falls
144 // back SILENTLY to 0 -- inactive, bit-identical). Consumed by build_amr_compiled (mono-block ->
145 // cpl->step / advance_transport). The COMPILED .so path now carries it too (ADC-322): the
146 // regenerated loader marshals pos_floor (pops_install_native_amr) into add_compiled_model ->
147 // set_compiled_block, which stores it here (mono) and passes it to the AmrCompiledBlockBuilder (multi).
148 double pos_floor = 0.0;
149};
150
154 std::shared_ptr<void> coupler_holder;
155 std::function<void(double)> step;
156 std::function<double()> max_speed;
157 std::function<double()> mass;
158 std::function<int()> n_patches;
159 std::function<std::vector<double>()> density;
160 std::function<std::vector<double>()> potential;
161 // ADDED AT THE TAIL (additive, moves no existing field): index-space signatures of the fine
162 // patches. Mirror of n_patches (same box_array(), the COUNT becomes the BOXES). The .so loader that
163 // builds this struct is guarded by pops_native_abi_key: a .so generated BEFORE this addition must be
164 // recompiled (the guard already diagnoses it clearly); the tail addition makes it purely additive.
165 std::function<std::vector<PatchBox>()>
167 // ADDED AT THE TAIL (AMR StabilityPolicy, audit 2026-06, additive like patch_boxes): OPTIONAL step
168 // bounds of the block, evaluated on the COARSE level by AmrSystem::step_cfl mono-block. EMPTY if
169 // the model does not declare the HasSourceFrequency / HasStabilityDt traits (bit-identical). The
170 // pops_native_abi_key guard forces regeneration of older .so files (purely additive addition).
171 std::function<double()> source_frequency;
172 std::function<double()>
174 // ADDED AT THE TAIL (IO v1, parity with System::set_clock): restoration of the macro-step counter of
175 // the MONO-BLOCK engine (the AmrCouplerMP coupler carries the regrid-cadence phase in a step_state;
176 // this hook writes it at restart). EMPTY is never the case (the builder always populates it); the
177 // pops_native_abi_key guard forces regeneration of older .so files (purely additive tail addition).
178 std::function<void(int)>
180 // ADDED AT THE TAIL (mono-rank AMR checkpoint/restart, ADC-65; additive like set_macro_step): FULL
181 // CONSERVATIVE state per level (all components) + phi (warm-start) + imposition of a SAVED fine
182 // hierarchy. The mono-block coupler (AmrCouplerMP) carries them; the builder always populates them
183 // (never empty). The pops_native_abi_key guard forces regeneration of older .so files.
184 std::function<int()> n_levels;
185 std::function<int()> n_vars;
186 std::function<std::vector<double>(int)> level_state;
187 std::function<void(int, const std::vector<double>&)>
189 std::function<std::vector<double>(int)> level_potential;
190 std::function<void(int, const std::vector<double>&)>
192 std::function<void(const std::vector<PatchBox>&)>
194 // ADDED AT THE TAIL (ADC-319, MPI ownership diagnostic; additive like the fields above): COARSE-level
195 // (base) box counts. coarse_local_boxes = cpl->coarse().local_size() (level-0 fabs OWNED by this rank);
196 // coarse_total_boxes = cpl->coarse().box_array().size() (total base boxes, all ranks). They reveal
197 // whether distribute_coarse actually distributes the base across ranks (local < total) or replicates
198 // it (local == total on every rank). The pops_native_abi_key guard forces regeneration of older .so
199 // files (purely additive tail addition); the builder always populates them (never empty).
200 std::function<int()> coarse_local_boxes;
201 std::function<int()> coarse_total_boxes;
202 // ADDED AT THE TAIL (np>1 mono-block AMR checkpoint, ADC-509; additive like the fields above): the
203 // GLOBAL (all_reduce_sum gather) counterparts of level_state / level_potential. Under MPI np>1 the
204 // per-level fabs are distributed (round-robin fine patches, optionally distributed coarse), so a
205 // bit-identical checkpoint must GATHER them onto every rank before rank 0 writes -- exactly like
206 // System::state_global / potential_global. The pops_native_abi_key guard forces regeneration of
207 // older .so files (purely additive tail addition); the builder always populates them (never empty).
208 std::function<std::vector<double>(int)> level_state_global;
209 std::function<std::vector<double>(int)> level_potential_global;
210};
211
224 const detail::SharedAmrLayout& layout, const std::string& name,
225 const std::vector<double>& density, bool has_density, double gamma, int substeps,
226 bool recon_prim, bool imex, int stride, const std::vector<std::string>& implicit_vars,
227 const std::vector<std::string>& implicit_roles, double pos_floor)>;
228
246 public:
247 explicit AmrSystem(const AmrSystemConfig& cfg);
249 // RULE OF FIVE (C.21): move-only (PIMPL unique_ptr). The copy was already IMPLICITLY deleted
250 // (move ctor declared); we make it EXPLICIT for intent. No API change (the copy was
251 // already unusable).
252 AmrSystem(const AmrSystem&) = delete;
253 AmrSystem& operator=(const AmrSystem&) = delete;
254 AmrSystem(AmrSystem&&) noexcept;
255 AmrSystem& operator=(AmrSystem&&) noexcept;
256
260 void add_dt_bound(const std::string& label, std::function<double()> fn);
261
264 std::string last_dt_bound() const;
265
314 void add_block(const std::string& name, const ModelSpec& model,
315 const std::string& limiter = "minmod", const std::string& riemann = "rusanov",
316 const std::string& recon = "conservative", const std::string& time = "explicit",
317 int substeps = 1, int stride = 1,
318 const std::vector<std::string>& implicit_vars = {},
319 const std::vector<std::string>& implicit_roles = {},
320 const NewtonOptions& newton = {}, bool newton_diagnostics = false,
321 double positivity_floor = 0.0);
322
328 bool enabled;
332 double
334 double failed_i;
335 double failed_j;
336 double failed_comp;
337 };
340 SourceNewtonReport newton_report(const std::string& name);
341
362 int ncomp, double gamma, int substeps,
363 std::function<AmrCompiledHooks(const AmrBuildParams&)> mono_builder,
364 AmrCompiledBlockBuilder multi_builder = {}, const std::string& name = std::string(),
365 bool recon_prim = false, bool imex = false, int stride = 1,
366 const std::vector<std::string>& implicit_vars = {},
367 const std::vector<std::string>& implicit_roles = {}, double pos_floor = 0.0);
368
402 void add_native_block(const std::string& name, const std::string& so_path,
403 const std::string& limiter = "minmod",
404 const std::string& riemann = "rusanov",
405 const std::string& recon = "conservative",
406 const std::string& time = "explicit", double gamma = 1.4, int substeps = 1,
407 double positivity_floor = 0.0);
408
422 void set_refinement(double threshold, const std::string& variable = std::string(),
423 const std::string& role = std::string());
424
436 void set_phi_refinement(double grad_threshold);
437
445 void set_poisson(const std::string& rhs = "charge_density",
446 const std::string& solver = "geometric_mg", const std::string& bc = "auto",
447 const std::string& wall = "none", double wall_radius = 0.0);
448
451 void set_density(const std::string& name, const std::vector<double>& rho);
452
465 void set_conservative_state(const std::string& name, const std::vector<double>& U);
466
471 void set_magnetic_field(const std::vector<double>& bz);
472
480 void set_aux_field_component(int comp, const std::vector<double>& field);
481
487 void set_aux_field_halo_component(int comp, int bc_type, double value);
488
503 POPS_EXPORT void register_elliptic_field(const std::string& field, int phi_comp, int gx_comp,
504 int gy_comp);
508 POPS_EXPORT void set_block_elliptic_field(const std::string& block_name, const std::string& field,
509 std::function<void(const MultiFab&, MultiFab&)> rhs);
514 std::vector<double> named_field_values(const std::string& field);
516
536 void set_source_stage(const std::string& name, const std::string& kind, double theta,
537 double alpha, const SourceStageOptions& opts = {});
538
542 void set_time_scheme(const std::string& scheme);
543
570 void add_coupled_source(const CoupledSourceProgram& prog, double frequency = 0.0,
571 const std::string& label = "coupled_source");
572
573 void step(double dt);
574 void advance(double dt, int nsteps);
576 double step_cfl(double cfl);
577
578 int nx() const;
579 double time() const;
583 int macro_step() const;
587 void set_clock(double t, int macro_step);
588
601 bool is_profiling() const;
603 std::string profile_report() const;
605 int n_blocks() const;
608 std::vector<std::string> block_names() const;
609 int n_patches();
617 std::vector<PatchBox> patch_boxes();
627
637 int n_levels();
638 int n_vars();
641 std::vector<double> level_state(int k);
642 std::vector<double> level_state_global(int k);
643 void set_level_state(int k,
644 const std::vector<double>& s);
648 std::vector<double> level_potential(int k);
649 std::vector<double> level_potential_global(int k);
650 void set_level_potential(int k, const std::vector<double>& p);
653 void set_hierarchy(const std::vector<PatchBox>& boxes);
654
662 int block_n_vars(const std::string& name);
663 std::vector<double> block_level_state(const std::string& name, int k);
664 std::vector<double> block_level_state_global(const std::string& name,
665 int k);
666 void set_block_level_state(const std::string& name, int k, const std::vector<double>& s);
667
668 double mass();
669 double mass(
670 const std::string& name);
671 std::vector<double> density();
672 std::vector<double> density(const std::string& name);
679 std::vector<double> potential();
680
681 private:
682 struct Impl;
683 std::unique_ptr<Impl> p_;
684};
685
686} // namespace pops
Single block carried on an AMR hierarchy, composed at runtime.
Definition amr_system.hpp:245
void set_level_potential(int k, const std::vector< double > &p)
restores phi of level k
void set_clock(double t, int macro_step)
RESTORES the AMR clock (t, macro_step) – parity with System::set_clock.
std::vector< double > level_potential_global(int k)
np>1 gather (all ranks call)
void add_block(const std::string &name, const ModelSpec &model, const std::string &limiter="minmod", const std::string &riemann="rusanov", const std::string &recon="conservative", const std::string &time="explicit", int substeps=1, int stride=1, const std::vector< std::string > &implicit_vars={}, const std::vector< std::string > &implicit_roles={}, const NewtonOptions &newton={}, bool newton_diagnostics=false, double positivity_floor=0.0)
Adds a block carried on the AMR.
void set_source_stage(const std::string &name, const std::string &kind, double theta, double alpha, const SourceStageOptions &opts={})
Enables the Schur-CONDENSED SOURCE STAGE (amr-schur path) on block name.
AmrSystem(AmrSystem &&) noexcept
void disable_profiling()
void add_dt_bound(const std::string &label, std::function< double()> fn)
GLOBAL time-step bound (AMR counterpart of System::add_dt_bound): fn() evaluated ONCE per step_cfl (h...
bool is_profiling() const
int coarse_total_boxes()
std::vector< std::string > block_names() const
Names of the blocks in add order (parity with System::block_names): the IO facade iterates over them ...
std::vector< double > level_potential(int k)
Potential phi of level k, flat nf*nf row-major.
void set_hierarchy(const std::vector< PatchBox > &boxes)
Imposes the SAVED fine hierarchy (at restart) instead of Berger-Rigoutsos clustering: boxes are the p...
std::vector< double > potential()
Electrostatic potential phi of the COARSE LEVEL (base), n*n row-major.
void enable_profiling()
POPS_EXPORT void set_block_elliptic_field(const std::string &block_name, const std::string &field, std::function< void(const MultiFab &, MultiFab &)> rhs)
Attaches named field's RHS closure (rhs += elliptic_field_rhs(U)) to block block_name.
int n_vars()
number of conserved components (MONO-BLOCK; multi-block: block_n_vars)
std::vector< double > level_state(int k)
FULL conservative state of level k, flat component-major c*nf*nf + j*nf + i (nf = n << k; zeros outsi...
void add_native_block(const std::string &name, const std::string &so_path, 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, double positivity_floor=0.0)
Wires a NATIVE AMR block from a .so loader generated by the DSL (backend "production",...
void set_time_scheme(const std::string &scheme)
Chooses the time-splitting policy of the condensed source stage: "lie" (default, H(dt) S(dt)) or "str...
std::vector< double > named_field_values(const std::string &field)
Solved potential of named field on the COARSE level, n*n row-major (read-back).
double mass()
mass of the 1st block on the coarse (conserved at reflux)
void set_density(const std::string &name, const std::vector< double > &rho)
Sets the initial density on the coarse level (component 0), n*n row-major.
std::vector< double > level_state_global(int k)
MONO-BLOCK, np>1 gather (all ranks call)
int n_blocks() const
number of blocks (1 = mono-block AmrCouplerMP; >= 2 = AmrRuntime)
AmrSystem & operator=(const AmrSystem &)=delete
void set_block_level_state(const std::string &name, int k, const std::vector< double > &s)
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).
std::vector< double > block_level_state(const std::string &name, int k)
void reset_profiling()
std::string profile_report() const
void set_conservative_state(const std::string &name, const std::vector< double > &U)
Sets the FULL INITIAL CONSERVATIVE STATE (all components) on the coarse level, then prolongs it to th...
std::vector< double > density()
coarse density of the 1st block (component 0), n*n row-major
std::vector< double > density(const std::string &name)
coarse density of the named block, n*n
void set_level_state(int k, const std::vector< double > &s)
restores the state of level k (as is)
POPS_EXPORT void register_elliptic_field(const std::string &field, int phi_comp, int gx_comp, int gy_comp)
void set_magnetic_field(const std::vector< double > &bz)
Sets the magnetic field B_z(x, y) of the coarse level (n*n row-major), required by the Schur-condense...
void step(double dt)
one AMR macro-step (periodic regrid included)
SourceNewtonReport newton_report(const std::string &name)
int n_levels()
AMR CHECKPOINT / RESTART (ADC-65 single-block single-rank; ADC-509 multi-block + np>1): per-level STA...
void set_refinement(double threshold, const std::string &variable=std::string(), const std::string &role=std::string())
Refines the cells where the SELECTED conserved variable exceeds threshold.
std::vector< double > block_level_state_global(const std::string &name, int k)
np>1 gather (all ranks call)
std::string last_dt_bound() const
ACTIVE bound of the last step_cfl: "transport:<block>" | "source_frequency:<block>" | "stability_dt:<...
void add_coupled_source(const CoupledSourceProgram &prog, double frequency=0.0, const std::string &label="coupled_source")
Registers an inter-species COUPLED SOURCE (compiled pops.dsl.CoupledSource, flat bytecode ABI P5),...
int coarse_local_boxes()
COARSE-level (base) box counts, MPI ownership diagnostic (ADC-319).
void set_phi_refinement(double grad_threshold)
Adds to the regrid criterion the PHI tag on |grad phi| (D4 of the design docs/AMR_REGRID_UNION_TAGS_D...
AmrSystem(const AmrSystem &)=delete
double step_cfl(double cfl)
Advances at dt = cfl * coarse_dx / max wave speed.
double mass(const std::string &name)
mass of the named block on the coarse (conserved PER BLOCK)
std::vector< PatchBox > patch_boxes()
Index-space signatures of the current fine patches: one PatchBox (level, ilo, jlo,...
double time() const
void advance(double dt, int nsteps)
void set_aux_field_component(int comp, const std::vector< double > &field)
Sets a model-NAMED aux field (ADC-291) at shared-channel component comp (>= kAuxNamedBase) from a coa...
AmrSystem(const AmrSystemConfig &cfg)
int n_patches()
number of current fine patches (of the shared hierarchy)
int macro_step() const
MACRO-STEP counter (0-indexed; incremented by step / advance / step_cfl), parity with System::macro_s...
int block_n_vars(const std::string &name)
MULTI-BLOCK per-BLOCK per-level checkpoint accessors (ADC-509).
void set_poisson(const std::string &rhs="charge_density", const std::string &solver="geometric_mg", const std::string &bc="auto", const std::string &wall="none", double wall_radius=0.0)
Configures the coarse Poisson (cf.
int nx() const
void set_aux_field_halo_component(int comp, int bc_type, double value)
Declares a per-field aux HALO policy (ADC-369) for the NAMED component comp (>= kAuxNamedBase): bc_ty...
Field distributed over a level: decomposition (BoxArray) + distribution (DistributionMapping) + ncomp...
Definition multifab.hpp:33
POPS_EXPORT: force DEFAULT VISIBILITY on an out-of-line symbol, even when the unit is compiled with -...
#define POPS_EXPORT
Definition export.hpp:25
OPTIONS PODs for the public facades (System / AmrSystem), grouping the long families of HOMOGENEOUS p...
Implicit / IMEX block step as a named CONTRACT.
Flat specification of a model: chosen bricks plus their parameters.
Definition amr_hierarchy.hpp:29
std::function< AmrRuntimeBlock(const detail::SharedAmrLayout &layout, 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< std::string > &implicit_vars, const std::vector< std::string > &implicit_roles, double pos_floor)> AmrCompiledBlockBuilder
DEFERRED builder of a COMPILED block on the multi-block hierarchy: receives the SHARED layout (create...
Definition amr_system.hpp:227
double Real
Definition types.hpp:30
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).
Frozen parameters passed to the deferred build of the compiled path (add_compiled_model).
Definition amr_system.hpp:84
double L
Definition amr_system.hpp:86
double schur_theta
theta-scheme of the condensed stage (0.5 = Crank-Nicolson)
Definition amr_system.hpp:110
std::string schur_energy
Definition amr_system.hpp:129
double refine_threshold
1e30 => no refinement
Definition amr_system.hpp:92
bool has_state
Definition amr_system.hpp:103
std::function< bool(Real, Real)> wall
conductive wall predicate (empty = none)
Definition amr_system.hpp:94
int n
Definition amr_system.hpp:85
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
int regrid_every
Definition amr_system.hpp:87
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 pos_floor
Definition amr_system.hpp:148
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::string schur_momentum_x
Definition amr_system.hpp:129
NewtonOptions newton_options
Definition amr_system.hpp:135
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
bool has_density
Definition amr_system.hpp:95
std::string schur_momentum_y
Definition amr_system.hpp:129
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
double gamma
Definition amr_system.hpp:88
bool recon_prim
recon == "primitive" (frozen by add_compiled_model)
Definition amr_system.hpp:90
std::string schur_density
Definition amr_system.hpp:129
int substeps
Definition amr_system.hpp:89
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
int time_method
Definition amr_system.hpp:140
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(const std::vector< PatchBox > &)> set_hierarchy
imposes the saved fine patches
Definition amr_system.hpp:193
std::function< int()> n_vars
conserved components of the block
Definition amr_system.hpp:185
std::function< double()> mass
coarse mass
Definition amr_system.hpp:157
std::function< void(int, const std::vector< double > &)> set_level_state
restores the state of level k
Definition amr_system.hpp:188
std::function< void(double)> step
one macro-step (periodic regrid included)
Definition amr_system.hpp:155
std::function< std::vector< double >(int)> level_potential
phi of level k (nf*nf row-major)
Definition amr_system.hpp:189
std::function< std::vector< PatchBox >()> patch_boxes
index-space signatures of the fine patches
Definition amr_system.hpp:166
std::function< std::vector< double >(int)> level_potential_global
level k phi, gathered
Definition amr_system.hpp:209
std::function< int()> coarse_total_boxes
global coarse box count (identical on all ranks)
Definition amr_system.hpp:201
std::function< int()> n_levels
number of levels (>= 1)
Definition amr_system.hpp:184
std::function< void(int, const std::vector< double > &)> set_level_potential
restores phi of level k
Definition amr_system.hpp:191
std::function< std::vector< double >(int)> level_state
full state of level k (c*nf*nf+j*nf+i)
Definition amr_system.hpp:186
std::function< std::vector< double >()> potential
coarse-level phi, n*n row-major
Definition amr_system.hpp:160
std::function< std::vector< double >()> density
coarse density, n*n row-major
Definition amr_system.hpp:159
std::function< double()> max_speed
max wave speed (CFL step)
Definition amr_system.hpp:156
std::function< std::vector< double >(int)> level_state_global
level k state, gathered
Definition amr_system.hpp:208
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< int()> coarse_local_boxes
per-rank owned coarse (level-0) fab count
Definition amr_system.hpp:200
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
Type-erased closures of ONE AMR block, placed on the shared hierarchy.
Definition amr_runtime.hpp:98
AMR mesh and cadence (per-block physical parameters live in the ModelSpec).
Definition amr_system.hpp:61
int regrid_every
re-refinement every N steps (0 = never after init)
Definition amr_system.hpp:64
int n
coarse-level cells per direction
Definition amr_system.hpp:62
bool distribute_coarse
OWNERSHIP POLICY of the coarse level (cf.
Definition amr_system.hpp:75
double L
size of the square domain [0,L]^2
Definition amr_system.hpp:63
int coarse_max_grid
Coarse tile size when distribute_coarse=true (BoxArray::from_domain).
Definition amr_system.hpp:78
bool periodic
periodic domain
Definition amr_system.hpp:65
Report of the implicit (IMEX) source Newton of a block, AGGREGATED over the levels and substeps of th...
Definition amr_system.hpp:327
double failed_j
j of the same cell (-1 if none)
Definition amr_system.hpp:335
bool converged
no cell failed on the last advance
Definition amr_system.hpp:329
double max_residual
max over cells/levels/substeps of ||F||_inf at the Newton exit
Definition amr_system.hpp:330
double failed_i
i of ONE faulty cell (-1 if none; max index encoded)
Definition amr_system.hpp:334
double n_failed
count (cells x levels x substeps) failed (non-finite / pivot / non-convergence)
Definition amr_system.hpp:333
double max_iters_used
max over cells/levels/substeps of the iterations consumed
Definition amr_system.hpp:331
double failed_comp
conserved component of the worst residual of that cell (-1 unknown)
Definition amr_system.hpp:336
bool enabled
a report was computed (at least one IMEX advance played)
Definition amr_system.hpp:328
Boundary conditions for the FOUR faces of the domain (type + associated Dirichlet value).
Definition physical_bc.hpp:29
BYTECODE description of a generic inter-species COUPLED SOURCE (cf.
Definition facade_options.hpp:77
Brick composition of a block plus parameters.
Definition model_spec.hpp:27
Options of the local Newton of the implicit source (backward-Euler).
Definition implicit_stepper.hpp:114
Settings of the Schur-condensed SOURCE STAGE (cf.
Definition facade_options.hpp:48
SHARED layout of a multi-block AMR hierarchy (PR1 capstone), frozen at construction.
Definition amr_dsl_block.hpp:420