1""" This file is part of the ExaGRyPE project. For conditions of distribution and
2 use, please see the copyright notice at www.peano-framework.org
7from ..FOCCZ4Solver
import FOCCZ4Solver
8from .
import initialvalues
14 Compressible Euler equations of an ideal gas
16 The solver evolves the five conserved quantities density, momentum and
20 \\partial_t \\begin{pmatrix} \\rho \\\\ j \\\\ E \\end{pmatrix}
21 + \\nabla \\cdot \\begin{pmatrix} j \\\\ j \\otimes j / \\rho + p I \\\\ (E+p) j / \\rho \\end{pmatrix} = 0,
22 \\qquad p = (\\gamma-1) \\left(E - \\frac{|j|^2}{2\\rho}\\right),
25 in three dimensions. It has a flux, a maximum eigenvalue, a source term and an initial
26 condition, all of them stateless. The source term is zero.
27 Flux, source and eigenvalue see the CCZ4 fields, even though they ignore
28 them at the moment. The solver always holds a
29 set of auxiliary variables with the 58 entries of first-order CCZ4,
30 which the user attaches (add_auxiliary_variables()); generating the
31 solver without it fails. By default, the
32 initial condition is a density wave which the fluid advects with
33 constant velocity (initialvalues.smooth_wave()).
35 The solver is deliberately plain. Its purpose within ExaGRyPE is to be
36 the matter ingredient which one couples to exagrype.api.FOCCZ4Solver. The
37 assembly of such a coupled system is not part of this class, but done by
38 the user (see benchmarks/exagrype/gauge-wave-with-Euler), who typically
39 attaches auxiliary variables (@ref exahype2.api.AuxiliaryVariables) with
40 the spacetime to the solver, and replaces the flux and the source term
41 through the hooks _flux_implementation() and _source_implementation().
45 - The equations are those of flat-space hydrodynamics, i.e. the solver
46 knows nothing about general relativity on its own.
47 - Only ideal gases are supported, and there is no positivity limiter.
56 """! The five conserved quantities in the order the flux expects them """
66 Create an Euler solver
69 Name of the solver, @ref exahype2.api.Solver.
72 Adiabatic index of the ideal gas. Has to be greater than one.
74 @param initial_condition: exahype2.api.InitPointWisely
75 Initial condition. Defaults to exagrype.api.euler.initialvalues.smooth_wave().
79 raise ValueError(f
"Solver {name}: gamma has to be greater than one")
84 '#include "exagrype/euler/EulerKernels.h"\n'
85 '#include "exagrype/euler/initialvalues/InitialValues.h"\n'
88 'static_assert(Dimensions == 3, "The Euler solver of ExaGRyPE is three-dimensional only");'
91 f
"static constexpr double Gamma = {gamma!r};"
97 implementation=
"", stateless=
True
103 initial_condition
if initial_condition
is not None else initialvalues.smooth_wave()
109 Attach a set of auxiliary variables and hand it to flux, source and eigenvalue
111 The sets are not known when the constructor creates the PDE terms, so
112 the terms are (re)built from the hooks whenever a set arrives. They
113 stay empty until the first set has been attached.
115 @param auxiliary: exahype2.api.AuxiliaryVariables
116 The set, @ref exahype2.api.Solver.add_auxiliary_variables().
125 Reject solvers that do not see the CCZ4 fields
127 The Euler solver is the matter part of a coupled system with
128 first-order CCZ4. Hence, it always holds a set of auxiliary variables
129 with as many entries as FOCCZ4Solver has unknowns. Flux, source and
130 eigenvalue rely on this and do not handle solvers without
131 auxiliary variables. The check runs at generation time, as the sets
132 are attached after the constructor.
135 size = sum(FOCCZ4Solver.Unknowns.values())
138 f
"Solver {self.name}: the Euler solver needs a set of auxiliary variables "
139 f
"with the {size} entries of first-order CCZ4, but has "
140 f
"{[(a.name, a.size) for a in self.auxiliary_variables]}"
147 Rebuild the implementations of flux, source and eigenvalue from the hooks
149 Nothing happens before the set with the CCZ4 fields has been attached,
150 as the kernels need it.
162 The set of auxiliary variables which holds the CCZ4 fields
164 It is the set with as many entries as FOCCZ4Solver has unknowns. Other
165 sets (such as the lapse of a toy coupling) are not handed to the kernels.
167 @return exahype2.api.AuxiliaryVariables
168 The set, or None if it has not been attached yet.
171 size = sum(FOCCZ4Solver.Unknowns.values())
173 if len(candidates) > 1:
175 f
"Solver {self.name}: more than one set of auxiliary variables has the {size} entries of CCZ4: "
176 f
"{[a.name for a in candidates]}"
178 return candidates[0]
if candidates
else None
183 C++ expression of the pointer to the CCZ4 fields in a PDE term
185 The kernels of exagrype::euler take it as ccz4Fields.
192 """! Adiabatic index of the gas"""
198 C++ of the flux along normal
200 Hook for subclasses, which can scale or modify the flux, e.g. by the
201 lapse of a spacetime they hold as auxiliary variables. The code has
202 the variables Q, x, normal and F at hand, plus one pointer per set of
203 auxiliary variables (the CCZ4 fields: _ccz4_fields()). The default
204 calls exagrype::euler::flux().
208 ::exagrype::euler::flux( Q, {self._ccz4_fields()}, normal, Gamma, F );
214 C++ of the volumetric source
216 Hook for subclasses. The code has Q, x, t and S at hand, plus the
217 arguments of _flux_implementation(). The default calls
218 exagrype::euler::source(), which yields zero.
222 ::exagrype::euler::source( Q, {self._ccz4_fields()}, Gamma, S );
227 *lambdaMax = ::exagrype::euler::maxEigenvalue( Q, {self._ccz4_fields()}, normal, Gamma );
Compressible Euler equations of an ideal gas.
_refresh_pde_terms(self)
Rebuild the implementations of flux, source and eigenvalue from the hooks.
__init__(self, str name, float gamma=1.4, exahype2.api.InitPointWisely initial_condition=None)
Create an Euler solver.
float gamma(self)
Adiabatic index of the gas.
str _max_eigenvalue_implementation(self)
_ccz4_fields_set(self)
The set of auxiliary variables which holds the CCZ4 fields.
str _source_implementation(self)
C++ of the volumetric source.
add_auxiliary_variables(self, exahype2.api.AuxiliaryVariables auxiliary)
Attach a set of auxiliary variables and hand it to flux, source and eigenvalue.
generate_solver_realisation(self, *args, **kwargs)
Reject solvers that do not see the CCZ4 fields.
str _flux_implementation(self)
C++ of the flux along normal.
str _ccz4_fields(self)
C++ expression of the pointer to the CCZ4 fields in a PDE term.
A set of auxiliary variables of a solver.
The conservative flux F(Q) of a hyperbolic PDE.
Point-wise initial condition: given the physical position of a single degree of freedom,...
The maximum absolute eigenvalue of the flux Jacobian in a given direction, i.e.
Abstract base class for all ExaHyPE 2 solvers.
add_abstract_solver_attribute(self, str declaration)
Add a raw C++ member attribute declaration to the generated Abstract<SolverName> class (.
add_pde_term(self, PDETerm term)
Register a PDE term with this solver, or replace the one already registered under the same name and s...
add_user_solver_includes(self, str value)
Add further includes to this property, if your solver requires some additional routines from other he...
List["AuxiliaryVariables"] auxiliary_variables(self)
All sets of auxiliary variables in the order they have been attached.
The algebraic, volume-distributed source term S(Q) of a hyperbolic PDE - as opposed to PointSource,...