include/pops/core/state/state.hpp File ReferenceΒΆ

adc_cpp: include/pops/core/state/state.hpp File Reference
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
state.hpp File Reference

Pointwise types of the physics layer: StateVec<N> (conserved state) and Aux (auxiliary fields from the elliptic solver). More...

+ Include dependency graph for state.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pops::StateVec< N >
 Conserved state vector of fixed size, known at compile time. More...
 
struct  pops::Aux
 POINTWISE auxiliary fields shared with the physics: single coupling channel. More...
 

Namespaces

namespace  pops
 

Macros

#define POPS_AUX_FIELDS(X)
 SINGLE SOURCE of the layout of the EXTRA aux fields (X-macro).
 
#define POPS_AUX_DECL(name, idx)   Real name{};
 
#define POPS_AUX_NAMED_BASE_CHECK(name, idx)
 
#define POPS_AUX_IDX_CHECK(name, idx)
 

Functions

Arithmetic operators for StateVec (POPS_HD, device-clean).
template<int N>
POPS_HD StateVec< N > pops::operator+ (StateVec< N > a, const StateVec< N > &b)
 
template<int N>
POPS_HD StateVec< N > pops::operator- (StateVec< N > a, const StateVec< N > &b)
 
template<int N>
POPS_HD StateVec< N > pops::operator* (Real s, StateVec< N > a)
 

Variables

constexpr int pops::kAuxMaxExtra = 4
 
constexpr int pops::kAuxBaseComps = 3
 
constexpr int pops::kAuxNamedBase = kAuxBaseComps + 2
 
constexpr int pops::kAuxMaxComps = kAuxNamedBase + kAuxMaxExtra
 

Detailed Description

Pointwise types of the physics layer: StateVec<N> (conserved state) and Aux (auxiliary fields from the elliptic solver).

The canonical indices of Aux are defined here and must stay in sync with AUX_CANONICAL in python/pops/dsl.py (inherent duplication: Python does not read C++ headers).

Macro Definition Documentation

◆ POPS_AUX_DECL

#define POPS_AUX_DECL (   name,
  idx 
)    Real name{};

◆ POPS_AUX_FIELDS

#define POPS_AUX_FIELDS (   X)
Value:
X(B_z, 3) \
X(T_e, 4)

SINGLE SOURCE of the layout of the EXTRA aux fields (X-macro).

This is the ONLY place listing {member, index} for the fields beyond the base contract. Python-C++ INVARIANT: the indices here must stay identical to AUX_CANONICAL in python/pops/dsl.py ({"phi":0,"grad_x":1,"grad_y":2,"B_z":3,"T_e":4}). Modifying one requires modifying the other at the same time. The duplication is inherent: Python does not read C++ headers. load_aux (device read, spatial_operator.hpp) AND the host marshaling (python/system.cpp) are GENERATED from it, so adding an extra aux field is done HERE and NOWHERE ELSE. This closes the historical gap (#51: T_e added to the struct + load_aux but forgotten in the JIT marshaling -> read as 0 silently). Each entry: X(member, index). The index MUST be >= 3 (components 0..2 are phi/grad_x/grad_y, wired in the base constructor) and follow the canonical layout shared with AUX_CANONICAL on the DSL side (python/pops/dsl.py), inherent duplication: Python does not read C++ headers. To add a field: 1 line here (and the mirror line in AUX_CANONICAL). Pure preprocessor -> device-clean (nvcc/Kokkos), no C++26 reflection.

◆ POPS_AUX_IDX_CHECK

#define POPS_AUX_IDX_CHECK (   name,
  idx 
)
Value:
static_assert((idx) >= kAuxBaseComps, \
"extra aux field '" #name "': index must be >= kAuxBaseComps (3)");

◆ POPS_AUX_NAMED_BASE_CHECK

#define POPS_AUX_NAMED_BASE_CHECK (   name,
  idx 
)
Value:
static_assert(kAuxNamedBase > (idx), \
"kAuxNamedBase must be beyond the canonical aux field '" #name "'");