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.EvaluateRungeKuttaRightHandSide,
20 which overwrites the slot. As every action set of the scheme has a task of
21 its own, the dissipation task depends on the evaluation task. @ref
22 exagrype.api.FD4WithKODissipation arranges this.
23
24 """
25
26 TASK_NAME = "Add Kreiss-Oliger dissipation"
27 """! Name of the task which hosts the action set (@ref exahype2.api.rkfd4.CentralDifferencesWithRungeKutta) """
28
30 self, solver, stage: int, sigma: float, quantities: List[int], guard: str
31 ):
32 """!
33
34 @param solver: exahype2.api.Solver
35 Has to have an exagrype.api.FD4WithKODissipation as numerical
36 scheme.
37
38 @param stage: int
39 Number of the Runge-Kutta stage, starting with zero.
40
41 @param sigma: float
42 Scaling of the dissipation.
43
44 @param quantities: List[int]
45 Indices of the unknowns which are subject to the dissipation.
46
47 @param guard: str
48 C++ boolean expression, evaluated per cell in touchCellFirstTime.
49
50 """
51 super().__init__(solver)
52 self.stage = stage
53 self.sigma = sigma
54 self.quantities = quantities
55 self.guard = guard
56
57 def get_body_of_operation(self, operation_name):
58 if (
59 operation_name
60 != peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
61 ):
62 return ""
63 scheme = self._solver.numerical_scheme
64 n = scheme.patch_size
65 unknowns = self._solver.unknowns
66 quantities = ", ".join(str(quantity) for quantity in self.quantities)
67 return f"""
68 static_assert(Dimensions == 3, "The Kreiss-Oliger dissipation of ExaGRyPE is three-dimensional only");
69 constexpr int dissipativeQuantities[] = {{ {quantities} }};
70 ::exagrype::ccz4::addKreissOligerDissipation(
71 fineGridCell{self._solver._patch_with_halo.name}.value,
72 fineGridCell{self._solver._rhs_estimates.name}.value + {self.stage * unknowns * n * n * n},
73 marker.h(),
74 {n},
75 {scheme.overlap},
76 {unknowns},
77 {0},
78 {self.sigma!r},
79 dissipativeQuantities,
80 {len(self.quantities)}
81 );
82"""
83
84 def get_guard_of_operation(self, operation_name):
85 if (
86 operation_name
87 == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
88 ):
89 return self.guard
90 return "true"
91
92 def get_includes(self):
93 return super().get_includes() + '\n#include "exagrype/ccz4/Kernels.h"\n'
94
96 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.