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 kernel does not return any eigenvalue, as exahype2.api.fv.actionsets.ComputeMaxEigenvalue
22 determines it for the whole patch afterwards.
23
24 """
25
26 def __init__(self, solver, guard, time_step_size=None, time_stamp=None, input=None):
27 """!
28
29 @param solver: exahype2.api.Solver
30 Has to have solver._patch, solver._patch_interior,
31 and solver.compute_kernel_call_on_patch_interior set - @see
32 exahype2.api.fv.RusanovWithOptimisticExplicitEuler.
33
34 @param guard: str
35 C++ boolean expression, evaluated per cell in touchCellFirstTime,
36 guarding whether that cell's patch interior is updated.
37
38 @param time_step_size: str
39 C++ expression for the time step size the patch interior is
40 advanced by. Defaults to the solver's getMinTimeStepSize().
41
42 @param time_stamp: str
43 C++ expression for the time stamp the patch interior update
44 starts from. Defaults to the solver's getMinTimeStamp().
45
46 @param input: str
47 C++ expression for the patch the update reads. Defaults to the
48 cell's patch.
49
50 """
51 AbstractFVActionSet.__init__(self, solver)
52 self.guard = guard
53 self.time_step_size = time_step_size
54 self.time_stamp = time_stamp
55 self.input = input
56
57 def get_body_of_operation(self, operation_name):
58 result = ""
59 if operation_name == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
60 time_step_size = self.time_step_size
61 if time_step_size is None:
62 time_step_size = f"repositories::{self._solver.get_name_of_global_instance()}.getMinTimeStepSize()"
63 time_stamp = self.time_stamp
64 if time_stamp is None:
65 time_stamp = f"repositories::{self._solver.get_name_of_global_instance()}.getMinTimeStamp()"
66 input = self.input
67 if input is None:
68 input = f"fineGridCell{self._solver._patch.name}.value"
69 result = f"""
70 {{
71 double timeStamp = {time_stamp};
72 double timeStepSize = {time_step_size};
73 ::exahype2::CellData patchData({input}, marker.x(), marker.h(), timeStamp, timeStepSize, fineGridCell{self._solver._patch_interior.name}.value);
74 {self._solver.compute_kernel_call_on_patch_interior}
75 }}
76"""
77 return result
78
79 def get_guard_of_operation(self, operation_name):
80 if operation_name == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
81 return self.guard
82 return "true"
83
85 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...