3from .AbstractADERDGActionSet
import AbstractADERDGActionSet
7import peano4.solversteps
12 The linear combination of the Runge-Kutta trials has to be projected onto
13 the faces, so we can then solve the Riemann problems. So the projection
14 happens in one grid sweep, the corresponding Riemann solve in the next one.
17 _Template_TouchFaceFirstTime =
"""
19 const double timeStamp = std::max(
20 fineGridFace{{SOLVER_NAME}}FaceLabel.getNewTimeStamp(0),
21 fineGridFace{{SOLVER_NAME}}FaceLabel.getNewTimeStamp(1)
24 // Needs to declare and define timeStepSize
25 {{COMPUTE_TIME_STEP_SIZE}}
28 constexpr int SpaceFaceSize = {{ORDER}} + 1;
30 constexpr int SpaceFaceSize = ({{ORDER}} + 1) * ({{ORDER}} + 1);
33 constexpr int FluxElementsPerFace = SpaceFaceSize * {{NUMBER_OF_UNKNOWNS}};
34 constexpr int BasisElementsPerFace = SpaceFaceSize * ({{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}});
37 * 2d: 0,1,2,3 -> 0,2,1,3
38 * 3d: 0,1,2,3,4,5 -> 0,3,1,4,2,5
40 {{CORRECTOR_COMPUTATION_PRECISION}}* FL = fineGridFace{{SOLVER_NAME}}QFluxEstimates.value;
41 {{CORRECTOR_COMPUTATION_PRECISION}}* FR = fineGridFace{{SOLVER_NAME}}QFluxEstimates.value + FluxElementsPerFace;
42 {{CORRECTOR_COMPUTATION_PRECISION}}* QL = fineGridFace{{SOLVER_NAME}}QEstimates.value;
43 {{CORRECTOR_COMPUTATION_PRECISION}}* QR = fineGridFace{{SOLVER_NAME}}QEstimates.value + BasisElementsPerFace;
44 const int direction = marker.getSelectedFaceNumber() % Dimensions;
45 const int faceNumber = marker.getSelectedFaceNumber();
46 const bool isBoundary = fineGridFace{{SOLVER_NAME}}FaceLabel.getBoundary();
47 tarch::la::Vector<Dimensions,double> faceCentre = marker.x();
53 _Template_TouchCellFirstTime =
"""
55 const double timeStamp = fineGridCell{{SOLVER_NAME}}CellLabel.getTimeStamp();
57 // Reuse the same timeStepSize from the predictor
58 const double timeStepSize = fineGridCell{{SOLVER_NAME}}CellLabel.getTimeStepSize();
60 {{SOLUTION_STORAGE_PRECISION}}* luh = fineGridCell{{UNKNOWN_IDENTIFIER}}.value;
62 {{CORRECTOR_ALLOCATIONS}}
64 ::exahype2::CellData<{{SOLUTION_STORAGE_PRECISION}}, {{CORRECTOR_COMPUTATION_PRECISION}}> cellData(
65 fineGridCell{{UNKNOWN_IDENTIFIER}}.value,
73 for (int d = 0; d < Dimensions; d++) {
74 const int direction = d;
77 if (!fineGridFaces{{SOLVER_NAME}}FaceLabel(d).getIsHanging()) {
78 // If above hanging face, the Riemann fluxes have been received from the other side and are therefore on that side.
79 {{CORRECTOR_COMPUTATION_PRECISION}}* FIn = fineGridFaces{{UNKNOWN_IDENTIFIER}}FluxEstimates(d).value +
80 (fineGridFaces{{SOLVER_NAME}}FaceLabel(d).getAboveHanging() ? 0 : fluxElementsPerFace);
82 const int orientation = 0;
88 if (!fineGridFaces{{SOLVER_NAME}}FaceLabel(d + Dimensions).getIsHanging()) {
89 // If above hanging face, the Riemann fluxes have been received from the other side and are therefore on that side.
90 {{CORRECTOR_COMPUTATION_PRECISION}}* FIn = fineGridFaces{{UNKNOWN_IDENTIFIER}}FluxEstimates(d + Dimensions).value +
91 (fineGridFaces{{SOLVER_NAME}}FaceLabel(d+Dimensions).getAboveHanging() ? fluxElementsPerFace : 0);
93 const int orientation = 1;
99 {{POSTPROCESS_UPDATED_PATCH}}
101 {{COMPUTE_NEW_TIME_STEP_SIZE}}
103 fineGridCell{{SOLVER_NAME}}CellLabel.setTimeStamp(timeStamp + timeStepSize);
104 fineGridCell{{SOLVER_NAME}}CellLabel.setHasUpdated(true);
106 repositories::{{SOLVER_INSTANCE}}.update(newTimeStepSize, timeStamp+timeStepSize, marker.h()(0));
110 _Template_RiemannSolver =
"""
111 kernels::{{SOLVER_NAME}}::riemannSolver<{{CORRECTOR_COMPUTATION_PRECISION}}>(
112 repositories::{{SOLVER_INSTANCE}},
125 _Template_CustomRiemannSolver =
"""
126 repositories::{{SOLVER_INSTANCE}}.riemannSolver(
141 _Template_FaceIntegral =
"""
142 const double inverseDxDirection = 1.0 / marker.h()[d];
143 kernels::{{SOLVER_NAME}}::faceIntegral(
153 _Template_CorrectorAllocations =
"""
154 const int fluxElementsPerFace = kernels::{{SOLVER_NAME}}::getBndFluxSize();
159 guard_project: String (C++ code)
160 Predicate which controls if the solution is actually projected
162 guard_safe_old_time_step: String (C++ code)
163 Predicate which controls if the projection should be copied into
164 the old solution and the time step should also be moved over
166 super(Correction, self).
__init__(solver)
172 solver._riemann_solver_implementation != PDETerms.None_Implementation
179 self.
_solver._init_dictionary_with_default_parameters(d)
180 self.
_solver.add_entries_to_text_replacement_dictionary(d)
183 == peano4.solversteps.ActionSet.OPERATION_TOUCH_FACE_FIRST_TIME
185 d[
"PREDICATE"] = self.riemann_guard
187 d[
"RIEMANN_SOLVER"] = jinja2.Template(
191 d[
"RIEMANN_SOLVER"] = jinja2.Template(
197 == peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
199 d[
"PREDICATE"] = self.guard
200 d[
"CORRECTOR_ALLOCATIONS"] = jinja2.Template(
211 return __name__.replace(
".py",
"").replace(
".",
"_")
217#include "exahype2/CellData.h"
223 +
"""/FaceIntegral.h"
226 +
"""/RiemannSolver.h"
229 +
"""/MaxScaledEigenvalue.h"
The linear combination of the Runge-Kutta trials has to be projected onto the faces,...
_use_custom_riemann_solver
str _Template_RiemannSolver
get_includes(self)
Return include statements that you need.
str _Template_CorrectorAllocations
str _Template_TouchFaceFirstTime
str _Template_FaceIntegral
__init__(self, solver, guard)
guard_project: String (C++ code) Predicate which controls if the solution is actually projected
str _Template_CustomRiemannSolver
str _Template_TouchCellFirstTime
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
get_action_set_name(self)
You should replicate this function in each subclass, so you get meaningful action set names (otherwis...