include/pops/runtime/builders/compiled/compiled_block_abi.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
|
compiled_block_abi.hpp
Go to the documentation of this file.
8#include <pops/mesh/execution/for_each.hpp> // device_fence: barrier before host read (unified memory)
13#include <pops/core/model/physical_model.hpp> // aux_comps<Model>: aux channel width of the generated model
14#include <pops/core/state/variables.hpp> // roles_meta<Model>: conservative/primitive role CSV (manifest)
15#include <pops/runtime/config/runtime_params.hpp> // RuntimeParams: RUNTIME params (P7-b) carried by the ABI
16#include <pops/runtime/module_capabilities.hpp> // kAbiVersion: per-artifact ABI revision (manifest)
78 // 2*naux doubles AFTER the naux*nn valid cells: (type, value) per component (type 0 = none/inherit,
79 // 1 = Foextrap, 2 = Dirichlet -- pops::BCType). For each declared component, re-fill ITS physical-face
80 // ghosts with the field's own policy (aux_halo_override keeps periodic faces periodic, so a periodic
245 BlockClosures clo = make_block(model, lim, riem, ctx, imex, recon_prim, "ssprk2", {}, {}, nullptr,
294void to_primitive(const double* U, double* P, int n, const double* pvals = nullptr, int npar = 0) {
465 // Python overlay. Artifact-honest for the AOT compiled-block route: it runs a single uniform grid
466 // (supports_uniform) on ONE rank (the make_grid DistributionMapping is single-rank -> supports_mpi
467 // false; an AMR hierarchy uses a different loader -> supports_amr false). supports_gpu is the .so's
520 extern "C" void pops_compiled_residual_p(const double* U, double* R, const double* aux, int n, \
527 extern "C" void pops_compiled_advance(double* U, const double* aux, int n, double dx, double dy, \
541 extern "C" double pops_compiled_max_speed(const double* U, const double* aux, int n, double dx, \
545 extern "C" double pops_compiled_max_speed_p(const double* U, const double* aux, int n, double dx, \
574 extern "C" void pops_compiled_project_p(double* U, const double* aux, int n, const double* pvals, \
Builds the closures of a block (time advance + residual + Poisson contribution) from a COMPILED model...
BoxArray: the set of boxes tiling a level (disjoint, covering).
static BoxArray from_domain(const Box2D &domain, int max_grid_size)
Tile the domain into tiles of at most max_grid_size per direction, distributed evenly.
Definition box_array.hpp:30
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
void set_val(Real v)
Fills all cells (valid + ghosts) of every local fab with v.
Definition multifab.hpp:85
#define POPS_AUX_MARSHAL(name, idx)
Trait OPTIONNEL : PROJECTION PONCTUELLE post-pas U -> project(U, aux) (ADC-177).
Definition physical_model.hpp:154
OPTIONAL extension of a PhysicalModel: primitive variables + cons<->prim conversions.
Definition physical_model.hpp:167
DistributionMapping: maps each box (by global index) to its owning MPI rank.
fill_boundary: INTRA-level halo exchange (fills ghosts from neighbors).
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...
Authoritative STATIC capability facts of the built _pops module (Spec 5 sec.13.12 / sec....
MultiFab: a field DISTRIBUTED over a level (equivalent of AMReX's MultiFab).
Definition compiled_block_abi.hpp:37
void pointwise_project(double *U, const double *aux_in, int n, const double *pvals=nullptr, int npar=0)
PROJECTION PONCTUELLE post-pas (ADC-177) : U(k) <- model.project(U(k), aux(k)) sur les n*n cellules,...
Definition compiled_block_abi.hpp:321
void residual(const double *U, double *R, const double *aux_in, int n, double dx, double dy, bool periodic, const std::string &lim, const std::string &riem, bool recon_prim, const double *pvals=nullptr, int npar=0, double pos_floor=0)
Residual -div F + S of the production path (assemble_rhs<Limiter, Flux>) on the generated model.
Definition compiled_block_abi.hpp:217
LocalGrid make_grid(int n, double dx, double dy, bool periodic, const double *aux_in, int naux)
naux = width of the aux channel the model READS (aux_comps<Model>(), >= 3).
Definition compiled_block_abi.hpp:54
void apply_runtime_params(B &b, const RuntimeParams &rp)
Writes rp into the params member of brick b if it has one (P7-b); otherwise no-op.
Definition compiled_block_abi.hpp:135
void extract(const MultiFab &mf, double *out, int n, int nv)
Copies the INTERIOR of fab(0) (nv components) into the component-major flat array out.
Definition compiled_block_abi.hpp:112
double max_speed(const double *U, const double *aux_in, int n, double dx, double dy, bool periodic, const double *pvals=nullptr, int npar=0)
Max wave speed of the block (for the CFL step on the System side) via make_max_speed on the generated...
Definition compiled_block_abi.hpp:253
std::string model_cons_roles_csv()
The conservative-role CSV of Model, or an empty string if the model declares no roles.
Definition compiled_block_abi.hpp:418
int brick_nparams(const B &b)
Number of runtime parameters the params member of a brick b carries (0 if the brick has none).
Definition compiled_block_abi.hpp:163
RuntimeParams model_params(const Model &model)
params block (full RuntimeParams) of the model: the FIRST brick that carries one (all carry the same ...
Definition compiled_block_abi.hpp:176
int model_nparams()
Number of runtime parameters declared by Model (P7-b): max of the params.count of its 3 bricks (each ...
Definition compiled_block_abi.hpp:193
Model make_model_with_params(const double *pvals, int npar)
Builds a Model (CompositeModel<Hyp, Src, Ell>) and injects the npar runtime parameter values pvals in...
Definition compiled_block_abi.hpp:146
void fill_interior(MultiFab &mf, const double *in, int n, int nv)
Copies nv components of the component-major flat array in into the INTERIOR of fab(0) (without touchi...
Definition compiled_block_abi.hpp:100
void poisson_rhs(const double *U, double *rhs_out, int n, const double *pvals=nullptr, int npar=0)
Elliptic right-hand side f(U) of the block (the System adds it to its Poisson sum).
Definition compiled_block_abi.hpp:371
std::string csv_to_json_array(const std::string &csv)
A JSON array literal ["a","b",...] from a comma-separated CSV (empty CSV -> []).
Definition compiled_block_abi.hpp:393
void to_conservative(const double *P, double *U, int n, const double *pvals=nullptr, int npar=0)
PRIMITIVE -> CONSERVATIVE conversion cell by cell (M.to_conservative) on component-major flat arrays ...
Definition compiled_block_abi.hpp:269
void model_param_defaults(double *out)
Writes the DECLARATION values of Model's runtime parameters into out (at least model_nparams<Model>()...
Definition compiled_block_abi.hpp:204
std::string compiled_manifest_json()
The per-artifact NativeManifest of Model as a JSON string (Spec 5 sec.13.12, criterion #36).
Definition compiled_block_abi.hpp:455
void to_primitive(const double *U, double *P, int n, const double *pvals=nullptr, int npar=0)
CONSERVATIVE -> PRIMITIVE conversion cell by cell (M.to_primitive).
Definition compiled_block_abi.hpp:294
std::string compiled_native_entrypoints_csv()
The native entrypoint symbols a POPS_DEFINE_COMPILED_BLOCK .so exports, as a CSV.
Definition compiled_block_abi.hpp:429
void advance(double *U, const double *aux_in, int n, double dx, double dy, bool periodic, const std::string &lim, const std::string &riem, bool recon_prim, bool imex, double dt, int nsub, const double *pvals=nullptr, int npar=0, double pos_floor=0)
Advances by nsub substeps (explicit SSPRK2, or ForwardEuler + implicit source if imex).
Definition compiled_block_abi.hpp:235
constexpr bool kHasGpuBackend
True iff this translation unit is compiled for a real GPU device backend.
Definition module_capabilities.hpp:60
int block_n_ghost(const std::string &lim)
Number of ghosts required by the spatial scheme lim (single source: Limiter::n_ghost).
Definition block_builder.hpp:759
BCRec aux_halo_override(const BCRec &shared, const AuxHaloPolicy &p)
Builds the effective override BCRec for a per-field aux halo: starts from the SHARED aux BC shared (s...
Definition physical_bc.hpp:204
constexpr int kAbiVersion
Discrete, monotonic ABI revision of the module capability contract.
Definition module_capabilities.hpp:32
POPS_COLD_FN BlockClosures make_block(const Model &m, const std::string &lim, const std::string &riem, const GridContext &ctx, bool imex, bool recon_prim, const std::string &method="ssprk2", const std::vector< int > &implicit_components={}, const NewtonOptions &newton_opts={}, NewtonReport *newton_report=nullptr, Real pos_floor=Real(0), bool wave_speed_cache=false)
Definition block_builder.hpp:726
void device_fence()
Device barrier: waits for in-flight kernels to finish before a HOST access to unified memory.
Definition kokkos_env.hpp:43
void fill_boundary(MultiFab &mf, const Box2D &domain, Periodicity per={})
BLOCKING halo exchange: begin then end immediately (no overlap).
Definition fill_boundary.hpp:333
void fill_physical_bc(MultiFab &mf, const Box2D &domain, const BCRec &bc)
Fills the physical-face ghosts of ALL components per bc (historical entry point, bit-identical).
Definition physical_bc.hpp:176
std::string roles_csv(const VariableSet &vs)
CSV of a VariableSet's roles (role_name, separator ',').
Definition variables.hpp:172
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
constexpr int kMaxRuntimeParams
Maximum number of runtime parameters per DSL block.
Definition runtime_params.hpp:32
std::function< Real(const MultiFab &)> make_max_speed(const Model &m, const GridContext &ctx)
Closure of the speed used by the block CFL step.
Definition block_builder.hpp:831
BCType
Boundary condition type for a face: Periodic (handled by fill_boundary), Foextrap (zero gradient,...
Definition physical_bc.hpp:25
@ Foextrap
@ Dirichlet
void fill_ghosts(MultiFab &mf, const Box2D &domain, const BCRec &bc)
COMPLETE ghost filling: fill_boundary (interior + periodic, periodicity deduced from bc) THEN fill_ph...
Definition physical_bc.hpp:227
PHYSICAL boundary conditions at the domain edge (BCType, BCRec, fill_physical_bc, fill_ghosts).
C++20 concepts defining the contract of the physics layer.
RuntimeParams: carrier for the RUNTIME PARAMETERS of a DSL model (P7-b).
#define POPS_AUX_FIELDS(X)
SINGLE SOURCE of the layout of the EXTRA aux fields (X-macro).
Definition state.hpp:92
WRITE POD handle (raw pointer + strides) over a Fab2D buffer, indexed by (i, j, c) IN GLOBAL INDICES ...
Definition fab2d.hpp:29
Per-field aux halo policy (ADC-369): a UNIFORM boundary policy for ONE model-named aux component,...
Definition physical_bc.hpp:195
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
std::function< void(MultiFab &, Real, int)> advance
(U, dt, n): n substeps of dt/n
Definition grid_context.hpp:62
std::function< void(MultiFab &, MultiFab &)> rhs_into
R <- -div F + S (Poisson frozen)
Definition grid_context.hpp:66
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
Mesh + transport BC + aux shared by a block closures.
Definition grid_context.hpp:41
Per-direction periodicity: halo wrapping in x and/or y during the exchange (false = open edge,...
Definition fill_boundary.hpp:37
FLAT carrier (fixed size, by value) of the runtime parameter values of a block.
Definition runtime_params.hpp:38
Detects (SFINAE) whether a brick B exposes a params member of type pops::RuntimeParams (DSL bricks ca...
Definition compiled_block_abi.hpp:127
Local single-grid mesh rebuilt inside the .so + aux filled from the System array.
Definition compiled_block_abi.hpp:40
Descriptor of a model's variables (Vars).
Generated by