Peano
Loading...
Searching...
No Matches
EvaluateRightHandSide.py
Go to the documentation of this file.
1# This file is part of the ExaHyPE2 project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3import peano4.api
4
5from .AbstractRKFD4ActionSet import AbstractRKFD4ActionSet
6
7
9 """!
10
11 Evaluate the right-hand side of one Runge-Kutta stage over a patch
12
13 The action set hands the input of the stage with its halo
14 (solver._patch_with_halo) to the fourth-order Finite Differences kernel
15 (@ref exahype2.api.rkfd4.FD4Kernels) and lets it write the right-hand
16 side into the stage's slot of solver._rhs_estimates. The kernel sees
17 the time stamp of the stage, i.e. @f$ t^n + c_k \\Delta t @f$, and the
18 time step size of the whole Runge-Kutta step.
19
20 Global time stepping: the time stamp and the time step size are those
21 of the solver (getMinTimeStamp() and getMinTimeStepSize()).
22
23 """
24
25 def __init__(self, solver, stage, guard):
26 """!
27
28 @param solver: exahype2.api.Solver
29 Has to have an exahype2.api.rkfd4.CentralDifferencesWithRungeKutta
30 as numerical scheme which has already constructed its kernel call,
31 i.e. solver.compute_kernel_call.
32
33 @param stage: int
34 Number of the Runge-Kutta stage, starting with zero.
35
36 @param guard: str
37 C++ boolean expression, evaluated per cell in touchCellFirstTime.
38
39 """
40 AbstractRKFD4ActionSet.__init__(self, solver)
41 self.stage = stage
42 self.guard = guard
43
44 def get_body_of_operation(self, operation_name):
45 if (
46 operation_name
47 != peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
48 ):
49 return ""
50 scheme = self._solver.numerical_scheme
51 n = scheme.patch_size
52 unknowns = self._solver.unknowns
53 relative_time_step_size = scheme.butcher_tableau.relative_time_step_sizes()[
54 self.stage
55 ]
56 instance = self._solver.get_name_of_global_instance()
57 return f"""
58 const double timeStepSize = repositories::{instance}.getMinTimeStepSize();
59 const double timeStamp = repositories::{instance}.getMinTimeStamp() + {relative_time_step_size!r} * timeStepSize;
60 #if Dimensions==2
61 double* estimate = fineGridCell{self._solver._rhs_estimates.name}.value + {self.stage * unknowns * n * n};
62 #else
63 double* estimate = fineGridCell{self._solver._rhs_estimates.name}.value + {self.stage * unknowns * n * n * n};
64 #endif
65 ::exahype2::CellData patchData(fineGridCell{self._solver._patch_with_halo.name}.value, marker.x(), marker.h(), timeStamp, timeStepSize, estimate);
66 {self._solver.compute_kernel_call}
67"""
68
69 def get_guard_of_operation(self, operation_name):
70 if (
71 operation_name
72 == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
73 ):
74 return self.guard
75 return "true"
76
78 return __name__.replace(".py", "").replace(".", "_")
Base class of the action sets of exahype2.api.rkfd4 which work against the solver.
Evaluate the right-hand side of one Runge-Kutta stage over a patch.
get_action_set_name(self)
You should replicate this function in each subclass, so you get meaningful action set names (otherwis...
get_guard_of_operation(self, operation_name)
Return the guard of an operation.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.