Peano
Loading...
Searching...
No Matches
UpdateCellInterior.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 .AbstractFVActionSet import AbstractFVActionSet
4
5import peano4.api
6
7
9 """!
10
11 Update the patch interior of a Finite Volume patch
12
13 Counterpart of exahype2.api.fv.actionsets.UpdateCell which updates only
14 the patch interior, i.e. the patch without its shell (@see
15 exahype2.api.fv.RusanovWithOptimisticExplicitEuler). The update of the
16 patch interior does not need any halo data. The action set hence reads
17 the patch solver._patch rather than its halo-augmented reconstruction,
18 invokes the patch interior compute kernel, and writes the result into
19 solver._patch_interior.
20
21 The maximum eigenvalue of the patch interior goes into the third entry
22 of solver._max_eigenvalue_and_time_step_sizes. The second entry holds the estimated time
23 step size (@see exahype2.api.fv.actionsets.SpawnTaskToUpdateCellInterior).
24
25 """
26
27 def __init__(self, solver, guard, time_step_size=None, time_stamp=None, input=None):
28 """!
29
30 @param solver: exahype2.api.Solver
31 Has to have solver._patch, solver._patch_interior,
32 solver._max_eigenvalue_and_time_step_sizes and
33 solver.compute_kernel_call_on_patch_interior set - @see
34 exahype2.api.fv.RusanovWithOptimisticExplicitEuler.
35
36 @param guard: str
37 C++ boolean expression, evaluated per cell in touchCellFirstTime,
38 guarding whether that cell's patch interior is updated.
39
40 @param time_step_size: str
41 C++ expression for the time step size the patch interior is
42 advanced by. Defaults to the solver's getMinTimeStepSize().
43
44 @param time_stamp: str
45 C++ expression for the time stamp the patch interior update
46 starts from. Defaults to the solver's getMinTimeStamp().
47
48 @param input: str
49 C++ expression for the patch the update reads. Defaults to the
50 cell's patch.
51
52 """
53 AbstractFVActionSet.__init__(self, solver)
54 self.guard = guard
55 self.time_step_size = time_step_size
56 self.time_stamp = time_stamp
57 self.input = input
58
59 def get_body_of_operation(self, operation_name):
60 result = ""
61 if operation_name == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
62 time_step_size = self.time_step_size
63 if time_step_size is None:
64 time_step_size = f"repositories::{self._solver.get_name_of_global_instance()}.getMinTimeStepSize()"
65 time_stamp = self.time_stamp
66 if time_stamp is None:
67 time_stamp = f"repositories::{self._solver.get_name_of_global_instance()}.getMinTimeStamp()"
68 input = self.input
69 if input is None:
70 input = f"fineGridCell{self._solver._patch.name}.value"
71 result = f"""
72 {{
73 double timeStamp = {time_stamp};
74 double timeStepSize = {time_step_size};
75 ::exahype2::CellData patchData({input}, marker.x(), marker.h(), timeStamp, timeStepSize, fineGridCell{self._solver._patch_interior.name}.value);
76 {self._solver.compute_kernel_call_on_patch_interior}
77 fineGridCell{self._solver._max_eigenvalue_and_time_step_sizes.name}.setMaxEigenvalue( 2, patchData.maxEigenvalue[0] );
78 }}
79"""
80 return result
81
82 def get_guard_of_operation(self, operation_name):
83 if operation_name == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
84 return self.guard
85 return "true"
86
88 return __name__.replace(".py", "").replace(".", "_")
Update the patch interior of a Finite Volume patch.
__init__(self, solver, guard, time_step_size=None, time_stamp=None, input=None)
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
get_guard_of_operation(self, operation_name)
Return the guard of an operation.
get_action_set_name(self)
You should replicate this function in each subclass, so you get meaningful action set names (otherwis...