include/pops/physics/composition/composite.hpp Source FileΒΆ

adc_cpp: include/pops/physics/composition/composite.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
composite.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <pops/core/model/physical_model.hpp> // HyperbolicPhysicalModel: contract of the hyperbolic brick
7
14
15namespace pops {
16
29template <class Hyperbolic, class Source, class Elliptic>
32 "CompositeModel : the 1st brick must be a HYPERBOLIC model (Vars + "
33 "cons<->prim conversions + flux + max_wave_speed), see HyperbolicPhysicalModel");
35 using Prim = typename Hyperbolic::Prim;
36 using Aux = pops::Aux;
37 static constexpr int n_vars = Hyperbolic::n_vars;
38 // Aux channel width of the composite model = MAX of the widths of its bricks: if a brick (flux
39 // or source) reads an extra auxiliary field (e.g. a magnetized source declaring n_aux=4 to read
40 // B_z), the composite exposes it to the system (which then sizes the aux channel).
41 // Without any extra-field brick, n_aux = kAuxBaseComps (3) -> strictly identical to the history.
42 static constexpr int n_aux = [] {
43 int w = aux_comps<Hyperbolic>();
44 if (aux_comps<Source>() > w)
45 w = aux_comps<Source>();
46 if (aux_comps<Elliptic>() > w)
47 w = aux_comps<Elliptic>();
48 return w;
49 }();
50
51 Hyperbolic hyp{};
52 Source src{};
53 Elliptic ell{};
54
55 POPS_HD State flux(const State& u, const Aux& a, int dir) const { return hyp.flux(u, a, dir); }
56 POPS_HD Real max_wave_speed(const State& u, const Aux& a, int dir) const {
57 return hyp.max_wave_speed(u, a, dir);
58 }
59 POPS_HD State source(const State& u, const Aux& a) const { return src.apply(u, a); }
60 POPS_HD Real elliptic_rhs(const State& u) const { return ell.rhs(u); }
61 POPS_HD Prim to_primitive(const State& u) const { return hyp.to_primitive(u); }
62 POPS_HD State to_conservative(const Prim& p) const { return hyp.to_conservative(p); }
63 static VariableSet conservative_vars() { return Hyperbolic::conservative_vars(); }
64 static VariableSet primitive_vars() { return Hyperbolic::primitive_vars(); }
65
66 POPS_HD Real pressure(const State& u) const
67 requires requires(const Hyperbolic h, const State s) { h.pressure(s); }
68 {
69 return hyp.pressure(u);
70 }
71 POPS_HD void wave_speeds(const State& u, const Aux& a, int dir, Real& smin, Real& smax) const
72 requires requires(const Hyperbolic h, const State s, const Aux aa, int d, Real& lo, Real& hi) {
73 h.wave_speeds(s, aa, d, lo, hi);
74 }
75 {
76 hyp.wave_speeds(u, a, dir, smin, smax);
77 }
78
84 POPS_HD Real contact_speed(const State& ul, const State& ur, Real pl, Real pr, Real sl, Real sr,
85 int dir) const
86 requires requires(const Hyperbolic h, const State a_, const State b_, Real p, Real q, Real x,
87 Real y, int d) { h.contact_speed(a_, b_, p, q, x, y, d); }
88 {
89 return hyp.contact_speed(ul, ur, pl, pr, sl, sr, dir);
90 }
91 POPS_HD State hllc_star_state(const State& u, Real p, Real s, Real sStar, int dir) const
92 requires requires(const Hyperbolic h, const State a_, Real p_, Real s_, Real ss_, int d) {
93 h.hllc_star_state(a_, p_, s_, ss_, d);
94 }
95 {
96 return hyp.hllc_star_state(u, p, s, sStar, dir);
97 }
98 POPS_HD State roe_dissipation(const State& ul, const Aux& al, const State& ur, const Aux& ar,
99 int dir) const
100 requires requires(const Hyperbolic h, const State a_, const Aux x_, const State b_,
101 const Aux y_, int d) { h.roe_dissipation(a_, x_, b_, y_, d); }
102 {
103 return hyp.roe_dissipation(ul, al, ur, ar, dir);
104 }
105
112 requires requires(const Hyperbolic h, const State s, Real rr) { h.polar_geom_source(s, rr); }
113 {
114 return hyp.polar_geom_source(u, r);
115 }
116
122 POPS_HD Real stability_speed(const State& u, const Aux& a, int dir) const
123 requires requires(const Hyperbolic h, const State s, const Aux aa, int d) {
124 h.stability_speed(s, aa, d);
125 }
126 {
127 return hyp.stability_speed(u, a, dir);
128 }
129 POPS_HD Real stability_dt(const State& u, const Aux& a) const
130 requires requires(const Hyperbolic h, const State s, const Aux aa) { h.stability_dt(s, aa); }
131 {
132 return hyp.stability_dt(u, a);
133 }
134 POPS_HD Real source_frequency(const State& u, const Aux& a) const
135 requires requires(const Source sc, const State s, const Aux aa) { sc.frequency(s, aa); }
136 {
137 return src.frequency(u, a);
138 }
139
144 POPS_HD State project(const State& u, const Aux& a) const
145 requires requires(const Hyperbolic h, const State s, const Aux aa) { h.project(s, aa); }
146 {
147 return hyp.project(u, a);
148 }
149
154 POPS_HD void source_jacobian(const State& u, const Aux& a, Real (&J)[n_vars][n_vars]) const
155 requires requires(const Source sc, const State s, const Aux aa, Real (&JJ)[n_vars][n_vars]) {
156 sc.jacobian(s, aa, JJ);
157 }
158 {
159 src.jacobian(u, a, J);
160 }
161};
162
163} // namespace pops
Hyperbolic brick of a model: flux + wave speed + variables + cons<->prim conversions.
Definition physical_model.hpp:181
Definition amr_hierarchy.hpp:29
double Real
Definition types.hpp:30
C++20 concepts defining the contract of the physics layer.
Pointwise types of the physics layer: StateVec<N> (conserved state) and Aux (auxiliary fields from th...
POINTWISE auxiliary fields shared with the physics: single coupling channel.
Definition state.hpp:123
Composite physical model: one HYPERBOLIC brick + one source + one elliptic right-hand side.
Definition composite.hpp:30
typename Hyperbolic::Prim Prim
Definition composite.hpp:35
POPS_HD Real stability_speed(const State &u, const Aux &a, int dir) const
Optional STEP BOUNDS (audit 2026-06, see core/physical_model.hpp): forwarded conditionally like press...
Definition composite.hpp:122
POPS_HD State source(const State &u, const Aux &a) const
Definition composite.hpp:59
POPS_HD Real stability_dt(const State &u, const Aux &a) const
Definition composite.hpp:129
POPS_HD Real contact_speed(const State &ul, const State &ur, Real pl, Real pr, Real sl, Real sr, int dir) const
Riemann CAPABILITIES (audit wave 3): HLLC hooks (contact_speed + hllc_star_state) and Roe (roe_dissip...
Definition composite.hpp:84
POPS_HD Real pressure(const State &u) const
Definition composite.hpp:66
Source src
Definition composite.hpp:52
Hyperbolic hyp
Definition composite.hpp:51
POPS_HD State roe_dissipation(const State &ul, const Aux &al, const State &ur, const Aux &ar, int dir) const
Definition composite.hpp:98
POPS_HD Real max_wave_speed(const State &u, const Aux &a, int dir) const
Definition composite.hpp:56
POPS_HD Real elliptic_rhs(const State &u) const
Definition composite.hpp:60
POPS_HD State polar_geom_source(const State &u, Real r) const
GEOMETRIC source term of polar curvature, delegated to the hyperbolic brick when it exposes it (polar...
Definition composite.hpp:111
static VariableSet conservative_vars()
Definition composite.hpp:63
POPS_HD State project(const State &u, const Aux &a) const
PROJECTION PONCTUELLE post-pas (ADC-177) : forwardee depuis la brique HYPERBOLIQUE quand elle declare...
Definition composite.hpp:144
Elliptic ell
Definition composite.hpp:53
POPS_HD Real source_frequency(const State &u, const Aux &a) const
Definition composite.hpp:134
static VariableSet primitive_vars()
Definition composite.hpp:64
POPS_HD State flux(const State &u, const Aux &a, int dir) const
Definition composite.hpp:55
POPS_HD Prim to_primitive(const State &u) const
Definition composite.hpp:61
static constexpr int n_aux
Definition composite.hpp:42
POPS_HD void wave_speeds(const State &u, const Aux &a, int dir, Real &smin, Real &smax) const
Definition composite.hpp:71
POPS_HD void source_jacobian(const State &u, const Aux &a, Real(&J)[n_vars][n_vars]) const
ANALYTIC JACOBIAN of the source (audit wave 3): forwarded from the SOURCE brick when it declares jaco...
Definition composite.hpp:154
POPS_HD State hllc_star_state(const State &u, Real p, Real s, Real sStar, int dir) const
Definition composite.hpp:91
static constexpr int n_vars
Definition composite.hpp:37
POPS_HD State to_conservative(const Prim &p) const
Definition composite.hpp:62
Conserved state vector of fixed size, known at compile time.
Definition state.hpp:29
A model's variable set: kind (cons/prim), names, size, canonical roles (optional, parallel to names; ...
Definition variables.hpp:58
Base scalar types and the POPS_HD macro (host+device portability).
#define POPS_HD
Definition types.hpp:25
Descriptor of a model's variables (Vars).