Peano
Loading...
Searching...
No Matches
ScalarField.py
Go to the documentation of this file.
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
3"""
4
5import exahype2.api
6
7from ..FOCCZ4Solver import FOCCZ4Solver
8
9
11 """!
12
13 Four scalar fields which a spacetime advects
14
15 The solver has four unknowns phi_0, ..., phi_3. They obey the advection equation
16
17 @f$ \\partial_t \\phi + v \\partial_x \\phi = 0, \\qquad v = \\alpha^2, @f$
18
19 along the x-axis, where @f$ \\alpha @f$ is the lapse of first-order CCZ4. The
20 lapse enters through a set of auxiliary variables, which holds the 58
21 entries of CCZ4 (@ref exagrype.api.FOCCZ4Solver). A coupling creates the
22 set, fills it, and hands it over to the constructor. The coupling is a
23 fake coupling: the spacetime advects the field, but the field does not
24 feed back into the spacetime. The velocity is the metric component g_xx
25 of the gauge wave, i.e. the equation has a closed-form solution on the
26 gauge wave (@ref benchmarks/exagrype/gauge-wave-with-scalar-field).
27
28 The PDE terms are a non-conservative product, a maximum eigenvalue and an
29 initial condition (four sine waves along the x-axis with phase shifts). All of them
30 are stateless and call @ref exagrype::scalarfield::nonconservativeProduct()
31 and friends. The solver has no flux: the advective form is what the exact
32 solution refers to.
33
34 The solver is deliberately plain. Its numerical scheme is assigned like for any
35 other solver (outer coupling), or by the coupling (inner coupling).
36
37 """
38
39 Unknowns = {"phi": 4}
40 """! The four advected fields """
41
42 def __init__(self, name: str, ccz4_fields: exahype2.api.AuxiliaryVariables):
43 """!
44
45 @param name: str
46 Name of the solver, @ref exahype2.api.Solver.
47
48 @param ccz4_fields: exahype2.api.AuxiliaryVariables
49 The set which holds the 58 entries of first-order CCZ4. The solver
50 attaches it. The coupling fills it.
51
52 """
53 if ccz4_fields.size != sum(FOCCZ4Solver.Unknowns.values()):
54 raise ValueError(
55 f"Solver {name}: the auxiliary set has to hold the "
56 f"{sum(FOCCZ4Solver.Unknowns.values())} entries of first-order CCZ4, "
57 f"but holds {ccz4_fields.size}"
58 )
59 super().__init__(name, unknowns=self.Unknowns)
60 self.add_user_solver_includes('#include "exagrype/scalarfield/ScalarFieldKernels.h"\n')
61 self.add_auxiliary_variables(ccz4_fields)
62 fields = ccz4_fields.argument_name
63 self.add_pde_term(
65 implementation=f"::exagrype::scalarfield::nonconservativeProduct({fields}, deltaQ, normal, BTimesDeltaQ);",
66 stateless=True,
67 )
68 )
69 self.add_pde_term(
71 implementation=f"*lambdaMax = ::exagrype::scalarfield::maxEigenvalue({fields}, normal);",
72 stateless=True,
73 )
74 )
75 self.add_pde_term(
77 implementation=f"::exagrype::scalarfield::initialValues(Q, {fields}, x);"
78 )
79 )
Four scalar fields which a spacetime advects.
__init__(self, str name, exahype2.api.AuxiliaryVariables ccz4_fields)
A set of auxiliary variables of a solver.
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.
The non-conservative product B(Q) applied to a jump deltaQ in a given direction, i....
Abstract base class for all ExaHyPE 2 solvers.
Definition Solver.py:17
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...
Definition Solver.py:916
add_user_solver_includes(self, str value)
Add further includes to this property, if your solver requires some additional routines from other he...
Definition Solver.py:825
add_auxiliary_variables(self, "AuxiliaryVariables" auxiliary)
Attach a set of auxiliary variables to the solver.
Definition Solver.py:776