Peano
Loading...
Searching...
No Matches
FOCCZ4Solver.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
5from typing import Dict, Union
6
7import exahype2.api
8
9from .CCZ4SolverBase import CCZ4SolverBase
10
11
13 """!
14
15 Solver for the Einstein equations in the first-order CCZ4 formulation
16
17 The solver is a plain exahype2.api.Solver with the 58 CCZ4 unknowns and
18 the PDE terms of CCZ4 pre-registered. All terms delegate to the
19 ExaGRyPE library (configure Peano with --enable-exagrype):
20
21 - the non-conservative product to exagrype::ccz4::ncpFirstOrder(),
22 plus the advection terms if the numerical scheme does not add them
23 (@ref exagrype.api.CCZ4SolverBase.CCZ4SolverBase.ncp_adds_advection());
24 it is registered only when the solver is realised,
25 - the volumetric source to exagrype::ccz4::sourceFirstOrder(),
26 - the maximum eigenvalue to exagrype::ccz4::maxEigenvalue().
27
28 The solver has no initial condition. Add one as for any other solver,
29 e.g. a routine of exagrype.api.initialvalues via add_pde_term().
30
31 CCZ4 has no conservative flux. You still have to assign a numerical
32 scheme, a grid construction and (optionally) a plotter, exactly as for
33 any other exahype2.api.Solver, and to add the solver to an
34 exahype2.api.Project. The project has to be three-dimensional: the
35 generated solver class refuses to compile otherwise.
36
37 ## Shortcomings
38
39 - The fourth-order Finite Differences of the production runs are
40 available through exahype2.api.rkfd4, i.e. pass a
41 CentralDifferencesWithRungeKutta as numerical scheme. They have no
42 artificial dissipation. exagrype.api.FD4WithKODissipation is the same
43 scheme with a Kreiss-Oliger dissipation on top. Unlike the legacy
44 ExaGRyPE, neither supports adaptive mesh refinement yet.
45 - The solution is pushed back onto the CCZ4 constraints
46 (exagrype::ccz4::enforceCCZ4constraints()) only if you switch it on
47 via enforce_ccz4_constraint(). Without it, long runs drift away from
48 the constraint surface.
49 - The advection terms @f$ \\beta^k \\partial _k Q @f$ of all
50 unknowns besides the metric, the lapse, the shift and phi (whose
51 advection is part of the algebraic source) are added either by the
52 fourth-order Finite Differences, if you select their kernel
53 CentralDifferencesWithLopsidedAdvection with ADVECTION_VELOCITY and
54 advected_quantities(), or by the non-conservative product
55 with central differences otherwise. The Finite Volumes of
56 exahype2.api.fv add none of them, i.e. they evolve CCZ4 without
57 these advection terms
58 (@ref exagrype.api.CCZ4SolverBase.CCZ4SolverBase.ncp_adds_advection()).
59 - Black holes are limited to a single one
60 (exagrype.api.initialvalues.single_black_hole()). Tracers and the
61 ADM/Psi4 postprocessing are not available yet. The second-order
62 formulation is exagrype.api.FOSOCCZ4Solver.
63
64 """
65
66 Unknowns = {
67 "G": 6,
68 "K": 6,
69 "theta": 1,
70 "Z": 3,
71 "lapse": 1,
72 "shift": 3,
73 "b": 3,
74 "Kex": 1,
75 "phi": 1,
76 "dLapse": 3,
77 "dxShift": 3,
78 "dyShift": 3,
79 "dzShift": 3,
80 "dxG": 6,
81 "dyG": 6,
82 "dzG": 6,
83 "P": 3,
84 }
85 """!
86
87 The 58 unknowns of the first-order CCZ4 formulation in the order the
88 kernels in exagrype::ccz4 expect them: 25 primary entries (up to phi)
89 followed by the 33 first derivatives. Kex is the trace of the extrinsic
90 curvature, whereas K holds the six entries of the trace-free conformal
91 extrinsic curvature.
92
93 """
94
96 self,
97 name: str,
98 parameters: Dict[str, Union[int, float]] = None,
99 ):
100 """!
101
102 Create a first-order CCZ4 solver
103
104 @param name: str
105 Name of the solver (@ref exahype2.api.Solver).
106
107 @param parameters: Dict[str, Union[int, float]]
108 CCZ4 parameters that differ from DefaultParameters, e.g.
109 {"CCZ4k1": 0.0}. Keys which are not in DefaultParameters are
110 rejected, as they most likely are typos.
111
112 """
113 super().__init__(name, self.Unknowns, parameters)
114
115 def _ncp_implementation(self) -> str:
116 """! The secondary entries follow the 25 primary ones"""
117 return """
118 ::exagrype::ccz4::ncpFirstOrder(
119 BTimesDeltaQ, BTimesDeltaQ + 25,
120 Q, Q + 25,
121 deltaQ, deltaQ + 25,
122 normal, CCZ4LapseType, CCZ4c, CCZ4e, CCZ4f, CCZ4b, CCZ4s, CCZ4mu
123 );
124"""
125
126 def _source_implementation(self) -> str:
127 return f"""
128 tarch::memset(S, 0, {sum(self.Unknowns.values())} * sizeof(double));
129 ::exagrype::ccz4::sourceFirstOrder(
130 S, S + 25,
131 Q, Q + 25,
132 CCZ4LapseType, CCZ4c, CCZ4e, CCZ4f, CCZ4b, CCZ4s, CCZ4itau, CCZ4eta, CCZ4k1, CCZ4k2, CCZ4k3
133 );
134"""
Everything the first-order and the second-order CCZ4 solvers share.
Solver for the Einstein equations in the first-order CCZ4 formulation.
__init__(self, str name, Dict[str, Union[int, float]] parameters=None)
Create a first-order CCZ4 solver.
str _source_implementation(self)
C++ which calls the source term kernel.
str _ncp_implementation(self)
The secondary entries follow the 25 primary ones.