Peano
Loading...
Searching...
No Matches
ApplyReconstructionFunctor.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 peano4.api.solversteps.ActionSet import ActionSet
6
7
9 """!
10
11 Apply a functor to the reconstructed halos of a cell and write the result into the cell's patch
12
13 The action set hooks into touchCellFirstTime(). It does not reconstruct
14 anything: the halos have been filled by earlier tasks (@ref
15 toolbox.blockstructured.api.ReconstructPatchWithHalo). The functor, a
16 C++ snippet, may use
17
18 - oldQWithHalo: a double* to the reconstructed primary variables;
19 - oldDerivativesWithHalo: a double* to the reconstructed derivative
20 variables (the previous values of newQ, with halo);
21 - newQ: a double* to the patch which the functor writes;
22 - marker: the cell marker.
23
24 """
25
27 self,
28 patch,
29 primary_variables_with_halo,
30 derivative_variables_with_halo,
31 functor_implementation: str,
32 guard: str = "true",
33 additional_includes: str = "",
34 ):
35 """!
36
37 @param patch: peano4.api.datamodel.Patch
38 The patch which the functor writes (newQ).
39
40 @param primary_variables_with_halo: peano4.api.datamodel.Patch
41 The reconstructed patch behind oldQWithHalo.
42
43 @param derivative_variables_with_halo: peano4.api.datamodel.Patch
44 The reconstructed patch behind oldDerivativesWithHalo.
45
46 @param functor_implementation: str
47 C++ snippet.
48
49 @param guard: str
50 C++ boolean expression, evaluated per cell in touchCellFirstTime.
51
52 @param additional_includes: str
53 Includes that the snippet needs.
54
55 """
56 super().__init__(descend_invocation_order=1, parallel=False)
57 self._patch = patch
58 self._primary = primary_variables_with_halo
59 self._derivatives = derivative_variables_with_halo
60 self._functor = functor_implementation
61 self._guard = guard
62 self.additional_includes = additional_includes
63
65 return ""
66
68 return ""
69
71 return " return std::vector< peano4::grid::GridControlEvent >();\n"
72
74 return __name__.replace(".py", "").replace(".", "_")
75
77 return False
78
79 def get_body_of_operation(self, operation_name):
80 if operation_name != ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
81 return "\n"
82 return f"""
83 [[maybe_unused]] double* oldQWithHalo = fineGridCell{self._primary.name}.value;
84 [[maybe_unused]] double* oldDerivativesWithHalo = fineGridCell{self._derivatives.name}.value;
85 double* newQ = fineGridCell{self._patch.name}.value;
86 {self._functor}
87"""
88
89 def get_guard_of_operation(self, operation_name):
90 if operation_name == ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
91 return self._guard
92 return "true"
93
94 def get_attributes(self):
95 return ""
96
97 def get_includes(self):
98 return self.additional_includes
Apply a functor to the reconstructed halos of a cell and write the result into the cell's patch.
get_attributes(self)
Return attributes as copied and pasted into the generated class.
get_body_of_createGridControlEventsForNextTraversal(self)
Return the grid control events that this action set wants to trigger.
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.
__init__(self, patch, primary_variables_with_halo, derivative_variables_with_halo, str functor_implementation, str guard="true", str additional_includes="")
Action set (reactions to events).
Definition ActionSet.py:6