Peano
Loading...
Searching...
No Matches
AddKreissOligerDissipation.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 List
6
8import peano4.api
9
10
12 """!
13
14 Add the Kreiss-Oliger dissipation to the right-hand side of one Runge-Kutta stage
15
16 The action set reads the input of the stage with its halo
17 (solver._patch_with_halo) and adds the dissipation to the stage's slot
18 of solver._rhs_estimates via exagrype::ccz4::addKreissOligerDissipation().
19 It has to run after exahype2.api.rkfd4.actionsets.EvaluateRightHandSide,
20 which overwrites the slot, within the same task. @ref
21 exagrype.api.FD4WithKODissipation arranges this.
22
23 """
24
26 self, solver, stage: int, sigma: float, quantities: List[int], guard: str
27 ):
28 """!
29
30 @param solver: exahype2.api.Solver
31 Has to have an exagrype.api.FD4WithKODissipation as numerical
32 scheme.
33
34 @param stage: int
35 Number of the Runge-Kutta stage, starting with zero.
36
37 @param sigma: float
38 Scaling of the dissipation.
39
40 @param quantities: List[int]
41 Indices of the unknowns which are subject to the dissipation.
42
43 @param guard: str
44 C++ boolean expression, evaluated per cell in touchCellFirstTime.
45
46 """
47 super().__init__(solver)
48 self.stage = stage
49 self.sigma = sigma
50 self.quantities = quantities
51 self.guard = guard
52
53 def get_body_of_operation(self, operation_name):
54 if (
55 operation_name
56 != peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
57 ):
58 return ""
59 scheme = self._solver.numerical_scheme
60 n = scheme.patch_size
61 unknowns = self._solver.unknowns
62 quantities = ", ".join(str(quantity) for quantity in self.quantities)
63 return f"""
64 static_assert(Dimensions == 3, "The Kreiss-Oliger dissipation of ExaGRyPE is three-dimensional only");
65 constexpr int dissipativeQuantities[] = {{ {quantities} }};
66 ::exagrype::ccz4::addKreissOligerDissipation(
67 fineGridCell{self._solver._patch_with_halo.name}.value,
68 fineGridCell{self._solver._rhs_estimates.name}.value + {self.stage * unknowns * n * n * n},
69 marker.h(),
70 {n},
71 {scheme.overlap},
72 {unknowns},
73 {self._solver.auxiliary_variables},
74 {self.sigma!r},
75 dissipativeQuantities,
76 {len(self.quantities)}
77 );
78"""
79
80 def get_guard_of_operation(self, operation_name):
81 if (
82 operation_name
83 == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
84 ):
85 return self.guard
86 return "true"
87
88 def get_includes(self):
89 return super().get_includes() + '\n#include "exagrype/ccz4/Kernels.h"\n'
90
92 return __name__.replace(".py", "").replace(".", "_")
Add the Kreiss-Oliger dissipation to the right-hand side of one Runge-Kutta stage.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
__init__(self, solver, int stage, float sigma, List[int] quantities, str guard)
get_guard_of_operation(self, operation_name)
Return the guard of an operation.
get_includes(self)
The includes cover the kernels the numerical scheme generates (exahype2.api.rkfd4....
get_action_set_name(self)
You should replicate this function in each subclass, so you get meaningful action set names (otherwis...
Base class of the action sets of exahype2.api.rkfd4 which work against the solver.