include/pops/runtime/system.hpp Source File

adc_cpp: include/pops/runtime/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
system.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <pops/core/state/variables.hpp> // VariableSet (role-bearing descriptor carried by each block)
4#include <pops/numerics/time/integrators/implicit_stepper.hpp> // NewtonOptions (options of the IMEX source Newton)
5#include <pops/runtime/export.hpp> // POPS_EXPORT (methods resolved by the native loader through dlopen)
6#include <pops/runtime/facade_options.hpp> // SourceStageOptions / CoupledSourceProgram (facade PODs, ADC-214)
7#include <pops/runtime/context/grid_context.hpp> // GridContext + BlockClosures (AOT-compiled block seam)
9#include <pops/runtime/config/runtime_params.hpp> // RuntimeParams (compiled-Program runtime params, ADC-510)
10
11#include <array>
12#include <functional>
13#include <map>
14#include <memory>
15#include <string>
16#include <vector>
17
32
33namespace pops {
34
35namespace runtime::program {
36class Profiler; // per-node wall-clock profiler (ADC-459); full type in program/profiler.hpp
37class CacheManager; // scheduler value cache (ADC-458); full type in program/cache_manager.hpp
38} // namespace runtime::program
39
51 int n = 64;
52 double L = 1.0;
53 bool periodic = true;
54 // --- opt-in geometry (Phase 1): "cartesian" (default, bit-identical) | "polar" (global ring) ---
55 std::string geometry =
56 "cartesian";
57 int nr = 0;
58 int ntheta = 0;
59 double r_min = 0.0;
60 double r_max = 1.0;
61 // --- multi-box split of the polar TRANSPORT (split into theta BANDS, ADC-67) -----------------
62 // Number of boxes of the ring, split in theta (each box covers the whole radius [0, nr-1] and one
63 // azimuthal band). 1 (default) = mono-box STRICTLY bit-identical to history. theta_boxes > 1:
64 // polar transport (assemble_rhs_polar + collective fill_ghosts) runs multi-box. CONSTRAINTS (cf.
65 // PolarMesh / check_geometry): 1 <= theta_boxes <= ntheta AND theta_boxes divides ntheta. INERT in
66 // cartesian (the cartesian split goes through AmrSystem / the historical mono-box MPI multi-box).
67 // SCOPE: multi-box transport OK; DIRECT polar Poisson mono-box only (clear UPSTREAM rejection if
68 // theta_boxes > 1, cf. ensure_elliptic_polar); polar tensor Schur stage multi-box.
69 int theta_boxes = 1;
70};
71
89class System {
90 public:
91 explicit System(const SystemConfig& cfg);
93 System(System&&) noexcept;
94 System& operator=(System&&) noexcept;
95
153 void add_block(const std::string& name, const ModelSpec& model,
154 const std::string& limiter = "minmod", const std::string& riemann = "rusanov",
155 const std::string& recon = "conservative", const std::string& time = "explicit",
156 int substeps = 1, bool evolve = true, int stride = 1,
157 const std::vector<std::string>& implicit_vars = {},
158 const std::vector<std::string>& implicit_roles = {},
159 const NewtonOptions& newton = {}, bool newton_diagnostics = false,
160 double positivity_floor = 0.0, bool wave_speed_cache = false);
161
166 bool enabled;
170 double
172 double failed_i;
173 double failed_j;
174 double failed_comp;
175 };
176 SourceNewtonReport newton_report(const std::string& name) const;
177
187 void add_dynamic_block(const std::string& name, const std::string& so_path, int substeps = 1,
188 const std::vector<std::string>& names = {},
189 const std::string& recon = "none");
190
202 void add_compiled_block(const std::string& name, const std::string& so_path,
203 const std::string& limiter = "minmod",
204 const std::string& riemann = "rusanov",
205 const std::string& recon = "conservative",
206 const std::string& time = "explicit", int substeps = 1,
207 const std::vector<std::string>& names = {},
208 double positivity_floor = 0.0);
209
217 void set_block_params(const std::string& name, const std::vector<double>& values);
218
237 void add_native_block(const std::string& name, const std::string& so_path,
238 const std::string& limiter = "minmod",
239 const std::string& riemann = "rusanov",
240 const std::string& recon = "conservative",
241 const std::string& time = "explicit", double gamma = 1.4, int substeps = 1,
242 bool evolve = true, int stride = 1, double positivity_floor = 0.0);
243
247 static std::string abi_key();
248
266 POPS_EXPORT void install_block(const std::string& name, int ncomp, const VariableSet& cons_vars,
267 const VariableSet& prim_vars, double gamma, BlockClosures closures,
268 std::function<Real(const MultiFab&)> max_speed,
269 std::function<void(const MultiFab&, MultiFab&)> poisson_rhs,
270 int substeps, bool evolve, int stride = 1);
277 POPS_EXPORT void set_block_ghosts(const std::string& name, int n_ghost);
279
292 void set_poisson(const std::string& rhs = "charge_density",
293 const std::string& solver = "geometric_mg", const std::string& bc = "auto",
294 const std::string& wall = "none", double wall_radius = 0.0, double epsilon = 1.0,
295 double abs_tol = 0.0);
296
301 std::string poisson_solver() const;
302
321 void set_disc_domain(double cx, double cy, double R, const std::string& mode = "none");
322
327 void set_geometry_mode(const std::string& mode);
328
332 std::vector<double> disc_mask() const;
333
339 void set_epsilon_field(const std::vector<double>& eps);
340
347 void set_epsilon_anisotropic_field(const std::vector<double>& eps_x,
348 const std::vector<double>& eps_y);
349
355 void set_reaction_field(const std::vector<double>& kappa);
356
362 void set_magnetic_field(const std::vector<double>& bz);
363
369 void set_electron_temperature_from(const std::string& name);
370
377
385 void set_aux_field_component(int comp, const std::vector<double>& field);
386
394 void set_aux_field_halo_component(int comp, int bc_type, double value);
395
400 std::vector<double> aux_field_component(int comp) const;
401
404 void set_density(const std::string& name, const std::vector<double>& rho);
405
411 void set_primitive_state(const std::string& name, const std::vector<double>& prim);
412
416 std::vector<double> get_primitive_state(const std::string& name);
417
421 using CellConvert = std::function<void(const double* in, double* out)>;
425 POPS_EXPORT void set_block_conversion(const std::string& name, CellConvert prim_to_cons,
426 CellConvert cons_to_prim);
427
435 POPS_EXPORT void set_block_dt_bounds(const std::string& name,
436 std::function<Real(const MultiFab&)> source_frequency,
437 std::function<Real(const MultiFab&)> stability_dt);
438
445 void add_dt_bound(const std::string& label, std::function<double()> fn);
446
450 std::string last_dt_bound() const;
451
455 void add_ionization(const std::string& electron, const std::string& ion,
456 const std::string& neutral, double rate);
457
461 void add_collision(const std::string& a, const std::string& b, double rate);
462
466 void add_thermal_exchange(const std::string& a, const std::string& b, double rate);
467
493 void set_source_stage(const std::string& name, const std::string& kind, double theta,
494 double alpha, const SourceStageOptions& opts = {});
495
504 void set_time_scheme(const std::string& scheme);
505
511 void set_gauss_policy(const std::string& policy);
512
544 void add_coupled_source(const CoupledSourceProgram& prog, double frequency = 0.0,
545 const std::string& label = "coupled_source");
546
558 POPS_EXPORT void solve_fields_from_state(int block_idx, const MultiFab& U_stage);
569 POPS_EXPORT void solve_fields_from_blocks(const std::vector<const MultiFab*>& U_stages);
582 POPS_EXPORT void solve_fields_from_state(const std::string& field, int block_idx,
583 const MultiFab& U_stage);
587 POPS_EXPORT void register_elliptic_field(const std::string& field, int phi_comp, int gx_comp,
588 int gy_comp);
591 POPS_EXPORT void set_block_elliptic_field(const std::string& block_name, const std::string& field,
592 std::function<void(const MultiFab&, MultiFab&)> rhs);
594 void step(double dt);
595 void advance(double dt, int nsteps);
596
598 double step_cfl(double cfl);
602 std::array<double, 3> dt_hotspot(const std::string& name);
603
606 double step_adaptive(double cfl);
607
616 bool is_profiling() const;
618 std::string profile_report() const;
626
630 std::vector<double> eval_rhs(const std::string& name);
631 std::vector<double> get_state(const std::string& name);
632 void set_state(const std::string& name, const std::vector<double>& u);
633 int n_vars(const std::string& name) const;
635 std::vector<std::string> variable_names(const std::string& name,
636 const std::string& kind = "conservative") const;
640 std::vector<std::string> variable_roles(const std::string& name,
641 const std::string& kind = "conservative") const;
645 double block_gamma(const std::string& name) const;
647
658 POPS_EXPORT void install_program_step(std::function<void(double)> step);
669 POPS_EXPORT void set_program_cadence(int substeps, int stride);
687 POPS_EXPORT void set_program_block_map(const std::vector<int>& prog_to_sys);
689 POPS_EXPORT const std::vector<int>& program_block_map() const;
725 POPS_EXPORT Real block_max_speed(int b, const MultiFab& U) const;
736 POPS_EXPORT MultiFab alloc_scalar_field(int n_comp, int n_ghost);
750 POPS_EXPORT MultiFab& register_history(const std::string& name, int lag);
755 POPS_EXPORT MultiFab& read_history(const std::string& name, int lag);
762 POPS_EXPORT void store_history(const std::string& name, const MultiFab& value);
776 POPS_EXPORT std::vector<std::string> history_names() const;
778 POPS_EXPORT int history_depth(const std::string& name) const;
780 POPS_EXPORT int history_ncomp(const std::string& name) const;
786 POPS_EXPORT std::vector<double> history_global(const std::string& name, int slot) const;
790 POPS_EXPORT bool history_initialized(const std::string& name) const;
795 POPS_EXPORT void restore_history(const std::string& name, int slot,
796 const std::vector<double>& values);
800 POPS_EXPORT void set_history_initialized(const std::string& name, bool initialized);
807 POPS_EXPORT void install_program(const std::string& so_path);
830 POPS_EXPORT std::vector<int> program_cache_nodes() const;
833 POPS_EXPORT std::string program_cache_name(int node_id) const;
837 POPS_EXPORT double program_cache_accumulated_dt(int node_id) const;
839 POPS_EXPORT int program_cache_ncomp(int node_id) const;
842 POPS_EXPORT int program_cache_ngrow(int node_id) const;
846 POPS_EXPORT std::vector<double> program_cache_global(int node_id) const;
852 POPS_EXPORT void restore_program_cache(int node_id, int ncomp, int ngrow, int last_update_step,
853 double accumulated_dt, const std::string& name,
854 const std::vector<double>& values);
870 POPS_EXPORT void record_program_diagnostic(const std::string& name, Real value);
873 POPS_EXPORT Real program_diagnostic(const std::string& name) const;
876 POPS_EXPORT std::map<std::string, Real> program_diagnostics() const;
894 POPS_EXPORT void set_program_params(int prog_block, const std::vector<double>& values);
904 POPS_EXPORT void seed_program_params(int prog_block, const std::vector<double>& defaults);
907
910 int nx() const;
921 void set_clock(double t, int macro_step);
927 int ny() const;
928 double time() const;
929 int n_species() const;
934 std::vector<std::string> block_names() const;
935 double mass(const std::string& name) const;
936 std::vector<double> density(const std::string& name) const;
937 std::vector<double> potential();
942 void set_potential(const std::vector<double>& phi);
943
955 std::vector<double> density_global(const std::string& name) const;
956 std::vector<double> state_global(const std::string& name) const;
957 std::vector<double> potential_global();
959
972 std::vector<std::array<int, 4>> local_boxes(
973 const std::string& name) const;
974 std::vector<double> local_state(const std::string& name,
975 int li) const;
978
979 private:
980 struct Impl;
981 std::unique_ptr<Impl> p_;
982};
983
984} // namespace pops
Field distributed over a level: decomposition (BoxArray) + distribution (DistributionMapping) + ncomp...
Definition multifab.hpp:33
Coupled multi-species system, composed at runtime from generic bricks.
Definition system.hpp:89
POPS_EXPORT std::vector< double > program_cache_global(int node_id) const
GLOBAL (collective, MPI-safe) gather of slot node_id's cached MultiFab into a component-major buffer ...
std::vector< double > density_global(const std::string &name) const
comp0, ny*nx global
POPS_EXPORT std::vector< double > history_global(const std::string &name, int slot) const
GLOBAL (collective, MPI-safe) gather of slot slot (0 = current, k = k macro-steps back) of history na...
POPS_EXPORT void restore_program_cache(int node_id, int ncomp, int ngrow, int last_update_step, double accumulated_dt, const std::string &name, const std::vector< double > &values)
RESTORE (restart) slot node_id from a GLOBAL component-major buffer (same layout as program_cache_glo...
SourceNewtonReport newton_report(const std::string &name) const
double step_adaptive(double cfl)
Advances one MULTIRATE macro-step: the slowest block sets the macro-step, each block that is faster i...
POPS_EXPORT Real cfl_min_dx() const
The MIN physical cell size of the grid (Cartesian min(dx, dy); polar min(dr, r_min*dtheta)) – the SAM...
void set_electron_temperature_from(const std::string &name)
Designates a COMPRESSIBLE fluid block (4 var) as the source of the electron temperature T_e: the T_e ...
POPS_EXPORT MultiFab & read_history(const std::string &name, int lag)
The history slot lag macro-steps back (lag 0 = the current slot, lag 1 = the previous step's stored v...
double block_gamma(const std::string &name) const
Adiabatic index (gamma) of the block, read by the inter-species couplings (collision,...
POPS_EXPORT void set_history_initialized(const std::string &name, bool initialized)
Mark history name initialized (or not) after a restart: a restored, already-stored ring must read at ...
POPS_EXPORT void block_neg_div_flux_into(int b, MultiFab &U, MultiFab &R)
R <- -div F(U) for block b – the SAME flux divergence as block_rhs_into but WITHOUT the model's defau...
POPS_EXPORT void set_program_block_map(const std::vector< int > &prog_to_sys)
void set_source_stage(const std::string &name, const std::string &kind, double theta, double alpha, const SourceStageOptions &opts={})
Enables a Schur-condensed SOURCE STAGE on block name (EXPLICIT / IMPLICIT splitting,...
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, bool evolve=true, 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, bool wave_speed_cache=false)
Adds an equation block (one species).
System(const SystemConfig &cfg)
std::vector< double > state_global(const std::string &name) const
U, ncomp*ny*nx global.
std::vector< std::string > variable_names(const std::string &name, const std::string &kind="conservative") const
Variable names of a block (introspection): kind = "conservative" | "primitive".
POPS_EXPORT RuntimeParams program_params(int prog_block) const
Block prog_block's CURRENT RuntimeParams (a device-clean by-value copy: trivially copyable,...
void set_clock(double t, int macro_step)
RESTORES the clock (t, macro_step) – reserved for the RESTART (sim.restart).
POPS_EXPORT void set_block_elliptic_field(const std::string &block_name, const std::string &field, std::function< void(const MultiFab &, MultiFab &)> rhs)
Attach named field's RHS closure (+= elliptic_field_rhs(U)) to block block_name.
POPS_EXPORT std::map< std::string, Real > program_diagnostics() const
All recorded diagnostics (name -> last recorded value).
POPS_EXPORT int macro_step() const
MACRO-STEP counter (0-indexed; incremented by step / step_cfl / step_adaptive).
std::vector< double > eval_rhs(const std::string &name)
-div F + S, size ncomp*n*n
POPS_EXPORT void register_elliptic_field(const std::string &field, int phi_comp, int gx_comp, int gy_comp)
Register named field's aux output components (where its solved phi / centered grad land).
POPS_EXPORT void seed_program_params(int prog_block, const std::vector< double > &defaults)
Seed block prog_block's RuntimeParams to its DECLARATION defaults (count values, the ....
std::vector< double > disc_mask() const
void add_coupled_source(const CoupledSourceProgram &prog, double frequency=0.0, const std::string &label="coupled_source")
Adds a GENERIC inter-species COUPLED SOURCE described by a BYTECODE (pops.dsl.CoupledSource,...
POPS_EXPORT int n_blocks() const
Number of blocks (species) installed.
void add_dynamic_block(const std::string &name, const std::string &so_path, int substeps=1, const std::vector< std::string > &names={}, const std::string &recon="none")
Adds a block whose model is LOADED AT RUNTIME from a shared library (.so) generated by the DSL (emit_...
std::string last_dt_bound() const
Name of the ACTIVE bound (the one that set dt) of the last step_cfl: "transport:<block>",...
void reset_profiling()
POPS_EXPORT std::string program_cache_name(int node_id) const
The scheduled node name of slot node_id ("fields_from_state"), or "node_<id>" if it was stored withou...
POPS_EXPORT int program_cache_ncomp(int node_id) const
The component count of slot node_id's cached value.
POPS_EXPORT std::vector< std::string > history_names() const
void set_disc_domain(double cx, double cy, double R, const std::string &mode="none")
Sets the TRANSPORT DOMAIN as a DISC centered at (cx, cy) with radius R (T2 work, CONTRACT inert by de...
POPS_EXPORT void set_program_cadence(int substeps, int stride)
Set the compiled-Program macro-step cadence (ADC-411): SYSTEM-level substeps and stride around the in...
void add_collision(const std::string &a, const std::string &b, double rate)
Adds an inter-species COLLISION / friction (operator-split): force k (u_a - u_b) on the momentum,...
void add_compiled_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", int substeps=1, const std::vector< std::string > &names={}, double positivity_floor=0.0)
Adds a block whose model is COMPILED AOT from a .so generated by the DSL (dsl.compile_aot / compile_o...
POPS_EXPORT GridContext grid_context()
REAL mesh + BC + aux of the System (aux not owned)
void advance(double dt, int nsteps)
std::array< double, 3 > dt_hotspot(const std::string &name)
Diagnostic (ADC-182): {w, i, j} of the GLOBAL cell that dominates the transport CFL bound of the bloc...
POPS_EXPORT void set_block_dt_bounds(const std::string &name, std::function< Real(const MultiFab &)> source_frequency, std::function< Real(const MultiFab &)> stability_dt)
Installs the optional STEP BOUNDS of a block (after install_block): reduction of the max source frequ...
void enable_profiling()
POPS_EXPORT void block_source_into(int b, MultiFab &U, MultiFab &R)
R <- S(U, aux) for block b – the model's default/composite SOURCE only, WITHOUT the flux divergence (...
POPS_EXPORT void ensure_aux_width(int ncomp)
Guarantees that the SHARED aux channel has at least ncomp components.
POPS_EXPORT void install_block(const std::string &name, int ncomp, const VariableSet &cons_vars, const VariableSet &prim_vars, double gamma, BlockClosures closures, std::function< Real(const MultiFab &)> max_speed, std::function< void(const MultiFab &, MultiFab &)> poisson_rhs, int substeps, bool evolve, int stride=1)
Installs a block from already-built closures (cf.
void set_epsilon_anisotropic_field(const std::vector< double > &eps_x, const std::vector< double > &eps_y)
Sets an ANISOTROPIC permittivity eps_x(x), eps_y(x), two n*n row-major fields (> 0),...
std::vector< double > density(const std::string &name) const
ny*nx row-major (j slow, i fast)
POPS_EXPORT void solve_fields_from_state(const std::string &field, int block_idx, const MultiFab &U_stage)
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, double epsilon=1.0, double abs_tol=0.0)
Configures the shared Poisson.
std::vector< double > potential_global()
phi, ny*nx global
POPS_EXPORT MultiFab & block_state(int b)
The conservative state MultiFab of block b (zero-copy, non-owning reference).
void set_gauss_policy(const std::string &policy)
Gauss-law policy.
POPS_EXPORT void solve_fields_from_state(int block_idx, const MultiFab &U_stage)
Per-stage field solve (ADC-409): SAME elliptic solve + aux derivation as solve_fields(),...
void set_state(const std::string &name, const std::vector< double > &u)
POPS_EXPORT int history_depth(const std::string &name) const
Ring depth (max lag + 1) of history name.
std::vector< std::string > block_names() const
Block names, in the order of addition.
std::vector< double > get_primitive_state(const std::string &name)
Reads the CONSERVATIVE state of the block and converts it to PRIMITIVE variables via the model conver...
void disable_profiling()
std::vector< double > potential()
phi, ny*nx row-major (j slow, i fast)
std::vector< std::array< int, 4 > > local_boxes(const std::string &name) const
(ilo,jlo,ihi,jhi) per local fab
POPS_EXPORT runtime::program::CacheManager & program_cache()
POPS_EXPORT int history_ncomp(const std::string &name) const
Component count of the slots of history name (the block's ncomp).
POPS_EXPORT double program_cache_accumulated_dt(int node_id) const
The accumulated skipped dt of slot node_id (accumulate_dt policy). 0 if none.
int ny() const
Extent of the SLOW axis of the field (rows of the (ny, nx) row-major array returned by density / pote...
POPS_EXPORT Real block_max_speed(int b, const MultiFab &U) const
The maximum |wave speed| of block b evaluated on U – the SAME per-block reduction step_cfl reads (Blo...
std::string profile_report() const
void set_aux_field_component(int comp, const std::vector< double > &field)
Sets a NAMED aux field (ADC-70 phase 1) on the canonical component comp (>= kAuxNamedBase = 5),...
POPS_EXPORT void rotate_histories()
Shift every history ring buffer one step (slot k <- slot k-1, for k = depth-1 .
void set_reaction_field(const std::vector< double > &kappa)
Enables a REACTION term kappa(x) >= 0: the system Poisson operator goes from div(eps grad phi) = f to...
POPS_EXPORT void record_program_diagnostic(const std::string &name, Real value)
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, bool evolve=true, int stride=1, double positivity_floor=0.0)
Adds a block whose model is compiled into a NATIVE LOADER .so generated by the DSL (dsl....
POPS_EXPORT int program_cache_last_update_step(int node_id) const
The macro step at slot node_id's last recompute.
POPS_EXPORT void solve_fields()
solves Poisson then derives aux = (phi, grad phi); exported
std::vector< double > local_state(const std::string &name, int li) const
U of fab li, flat (ncomp*bny*bnx)
POPS_EXPORT void set_block_conversion(const std::string &name, CellConvert prim_to_cons, CellConvert cons_to_prim)
Installs the pointwise cons <-> prim conversions of a block (after install_block).
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...
void set_time_scheme(const std::string &scheme)
Time SPLITTING POLICY of the macro-step (hyperbolic transport H + source stage S):
std::vector< std::string > variable_roles(const std::string &name, const std::string &kind="conservative") const
PHYSICAL roles of the variables of a block (parallel to variable_names): "density",...
POPS_EXPORT const std::vector< int > & program_block_map() const
The installed program-index -> system-index map (empty = identity). Read by ProgramContext.
std::function< void(const double *in, double *out)> CellConvert
Type-erasure of the POINTWISE (one cell) cons <-> prim conversion of a block: in/out are arrays of nc...
Definition system.hpp:421
std::vector< double > get_state(const std::string &name)
U, ncomp*n*n (component-major)
void add_ionization(const std::string &electron, const std::string &ion, const std::string &neutral, double rate)
Adds an IONIZATION coupling (operator-split): rate k n_e n_g; a neutral becomes an ion and an electro...
POPS_EXPORT void set_block_ghosts(const std::string &name, int n_ghost)
Guarantees that the state U of block name carries at least n_ghost ghosts (width of the spatial stenc...
POPS_EXPORT runtime::program::Profiler & profiler()
The System-owned Profiler (a non-owning reference; lives as long as the System).
POPS_EXPORT void set_program_params(int prog_block, const std::vector< double > &values)
void add_thermal_exchange(const std::string &a, const std::string &b, double rate)
Adds an inter-species THERMAL EXCHANGE (operator-split): heat flux k (T_a - T_b) on the energy,...
POPS_EXPORT void block_rhs_into(int b, MultiFab &U, MultiFab &R)
R <- -div F(U) + S(U, aux) for block b (the block's frozen-Poisson residual closure).
POPS_EXPORT Real program_diagnostic(const std::string &name) const
The recorded value of diagnostic name.
bool is_profiling() const
void set_block_params(const std::string &name, const std::vector< double > &values)
Changes the values of the RUNTIME parameters of an AOT block (add_compiled_block) WITHOUT recompiling...
void set_epsilon_field(const std::vector< double > &eps)
Sets a VARIABLE permittivity eps(x), n*n row-major field (> 0), at the cell CENTER.
void set_primitive_state(const std::string &name, const std::vector< double > &prim)
Initializes the state of a block from its PRIMITIVE variables (rho, u, v, p ...): prim is a flat ncom...
System(System &&) noexcept
double mass(const std::string &name) const
POPS_EXPORT MultiFab & register_history(const std::string &name, int lag)
void set_potential(const std::vector< double > &phi)
RESTORES the potential phi (IO v1, reserved for restart): without it the multigrid would restart from...
POPS_EXPORT MultiFab alloc_scalar_field(int n_comp, int n_ghost)
A fresh scalar field co-distributed with the System mesh: block 0's BoxArray and DistributionMapping,...
int n_vars(const std::string &name) const
POPS_EXPORT void install_program_step(std::function< void(double)> step)
static std::string abi_key()
ABI key of the module (compiler + C++ standard + signature of the pops headers, frozen at compilation...
double step_cfl(double cfl)
Advances one step at dt = cfl * h / max wave speed of the system.
POPS_EXPORT void block_project(int b, MultiFab &u)
Apply block b's post-step positivity projection to u in place (ADC-177): U <- project(U,...
POPS_EXPORT void store_history(const std::string &name, const MultiFab &value)
Copy value (valid cells) into the CURRENT slot [0] of history name and mark it initialized.
int n_species() const
POPS_EXPORT int program_cache_ngrow(int node_id) const
The ghost-cell width of slot node_id's cached value (1 for the aux, the block-state width for a held ...
int nx() const
POPS_EXPORT std::string installed_program_hash() const
IR hash of the installed compiled Program (the string returned by the .so's pops_program_hash),...
void step(double dt)
solve_fields, then advances each block according to its scheme
POPS_EXPORT std::vector< int > program_cache_nodes() const
double time() const
POPS_EXPORT void solve_fields_from_blocks(const std::vector< const MultiFab * > &U_stages)
Coupled multi-block field solve (Spec 3 criterion 24, ADC-457): SAME elliptic solve + aux derivation ...
std::string poisson_solver() const
Configured field (Poisson) solver token, e.g.
void set_geometry_mode(const std::string &mode)
Sets ONLY the disc transport mode (without (re)defining the disc): "none" | "staircase" | "cutcell".
void add_dt_bound(const std::string &label, std::function< double()> fn)
Adds a GLOBAL time-step bound, evaluated ONCE per step (host) by step_cfl / step_adaptive: dt <= fn()...
void set_density(const std::string &name, const std::vector< double > &rho)
Sets the density of a species (component 0), n*n row-major array.
POPS_EXPORT bool history_initialized(const std::string &name) const
Whether history name has been stored at least once (the cold-start fill already happened).
void set_magnetic_field(const std::vector< double > &bz)
Sets an out-of-plane magnetic field B_z(x, y) SHARED by the blocks, n*n row-major.
POPS_EXPORT void restore_history(const std::string &name, int slot, const std::vector< double > &values)
RESTORE (restart) slot slot of history name from a GLOBAL component-major buffer (same layout as hist...
POPS_EXPORT void install_program(const std::string &so_path)
Load a generated problem.so and install its compiled time Program.
std::vector< double > aux_field_component(int comp) const
Reads a NAMED aux field (component comp >= kAuxNamedBase): valid cells of the aux channel,...
Definition cache_manager.hpp:48
Definition profiler.hpp:27
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...
Block grid context plus closures, shared between System (which installs them) and block_builder....
Implicit / IMEX block step as a named CONTRACT.
Flat specification of a model: chosen bricks plus their parameters.
Definition amr_hierarchy.hpp:29
double Real
Definition types.hpp:30
RuntimeParams: carrier for the RUNTIME PARAMETERS of a DSL model (P7-b).
Compiled block closures, frozen at add time.
Definition grid_context.hpp:61
BYTECODE description of a generic inter-species COUPLED SOURCE (cf.
Definition facade_options.hpp:77
Mesh + transport BC + aux shared by a block closures.
Definition grid_context.hpp:41
Brick composition of a block plus parameters.
Definition model_spec.hpp:27
FLAT carrier (fixed size, by value) of the runtime parameter values of a block.
Definition runtime_params.hpp:38
Settings of the Schur-condensed SOURCE STAGE (cf.
Definition facade_options.hpp:48
Mesh and domain shared by all blocks (physical parameters are per block, in the ModelSpec).
Definition system.hpp:50
std::string geometry
geometry choice (carried by pops.CartesianMesh / pops.PolarMesh)
Definition system.hpp:55
int ntheta
azimuthal cells (polar; 0 => takes n)
Definition system.hpp:58
bool periodic
periodic domain, otherwise free outflow in transport (cartesian)
Definition system.hpp:53
double r_min
inner radius of the ring (polar)
Definition system.hpp:59
int n
cells per direction (n x n domain) – for polar: n_r = n_theta = n
Definition system.hpp:51
int theta_boxes
boxes of the theta split of polar transport (1 = mono-box)
Definition system.hpp:69
int nr
radial cells (polar; 0 => takes n)
Definition system.hpp:57
double r_max
outer radius of the ring (polar)
Definition system.hpp:60
double L
size of the square domain [0,L]^2 (cartesian)
Definition system.hpp:52
Report of the implicit source Newton (IMEX) of a block, AGGREGATED over the substeps of the LAST adva...
Definition system.hpp:165
bool converged
no failed cell on the last advance
Definition system.hpp:167
double failed_comp
conservative component of the worst residual of that cell (-1 unknown)
Definition system.hpp:174
double failed_i
i of ONE faulty cell (-1 if none; max index encoded)
Definition system.hpp:172
double max_residual
max over cells/substeps of ||F||_inf at the Newton exit
Definition system.hpp:168
bool enabled
a report was computed (at least one IMEX advance played)
Definition system.hpp:166
double failed_j
j of the same cell (-1 if none)
Definition system.hpp:173
double n_failed
number of (cells x substeps) failed (non-finite / pivot / non-convergence)
Definition system.hpp:171
double max_iters_used
max over cells/substeps of the iterations consumed
Definition system.hpp:169
A model's variable set: kind (cons/prim), names, size, canonical roles (optional, parallel to names; ...
Definition variables.hpp:58
Descriptor of a model's variables (Vars).