Peano
Loading...
Searching...
No Matches
EvaluateRungeKuttaRightHandSide.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
3from ...AuxiliaryVariables import code_to_assemble_kernel_input
4import peano4.api
5
6from .AbstractRKFD4ActionSet import AbstractRKFD4ActionSet
7
8
10 """!
11
12 Evaluate the right-hand side of one Runge-Kutta stage over a patch
13
14 The action set hands the input of the stage with its halo
15 (solver._patch_with_halo) to the fourth-order Finite Differences kernel
16 (@ref exahype2.api.rkfd4.FD4Kernels) and lets it write the right-hand
17 side into the stage's slot of solver._rhs_estimates. The kernel sees
18 the time stamp of the stage, i.e. @f$ t^n + c_k \\Delta t @f$, and the
19 time step size of the whole Runge-Kutta step.
20
21 Global time stepping: the time stamp and the time step size are those
22 of the solver (getMinTimeStamp() and getMinTimeStepSize()).
23
24 """
25
26 def __init__(self, solver, stage, guard):
27 """!
28
29 @param solver: exahype2.api.Solver
30 Has to have an exahype2.api.rkfd4.CentralDifferencesWithRungeKutta
31 as numerical scheme which has already constructed its kernel call,
32 i.e. solver.compute_kernel_call.
33
34 @param stage: int
35 Number of the Runge-Kutta stage, starting with zero.
36
37 @param guard: str
38 C++ boolean expression, evaluated per cell in touchCellFirstTime.
39
40 """
41 AbstractRKFD4ActionSet.__init__(self, solver)
42 self.stage = stage
43 self.guard = guard
44
45 def get_body_of_operation(self, operation_name):
46 if (
47 operation_name
48 != peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
49 ):
50 return ""
51 scheme = self._solver.numerical_scheme
52 n = scheme.patch_size
53 unknowns = self._solver.unknowns
54 relative_time_step_size = scheme.butcher_tableau.relative_time_step_sizes()[
55 self.stage
56 ]
57 instance = self._solver.get_name_of_global_instance()
58 return f"""
59 const double timeStepSize = repositories::{instance}.getMinTimeStepSize();
60 const double timeStamp = repositories::{instance}.getMinTimeStamp() + {relative_time_step_size!r} * timeStepSize;
61 #if Dimensions==2
62 double* estimate = fineGridCell{self._solver._rhs_estimates.name}.value + {self.stage * unknowns * n * n};
63 #else
64 double* estimate = fineGridCell{self._solver._rhs_estimates.name}.value + {self.stage * unknowns * n * n * n};
65 #endif
66 {code_to_assemble_kernel_input(self._solver, "kernelIn", f"fineGridCell{self._solver._patch_with_halo.name}.value", scheme.HALO_SIZE)}
67 ::exahype2::CellData patchData({"kernelIn.data()" if self._solver.auxiliary_variables else f"fineGridCell{self._solver._patch_with_halo.name}.value"}, marker.x(), marker.h(), timeStamp, timeStepSize, estimate);
68 {self._solver.compute_kernel_call}
69"""
70
71 def get_guard_of_operation(self, operation_name):
72 if (
73 operation_name
74 == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
75 ):
76 return self.guard
77 return "true"
78
80 return __name__.replace(".py", "").replace(".", "_")
Base class of the action sets of exahype2.api.rkfd4 which work against the solver.
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...