9 Apply a C++ snippet to each entry of a cell's patch
11 The action set hooks into touchCellFirstTime() and runs over all
12 NxNxN entries (volumes or grid points) of the patch. For each entry, it
13 runs implementation, i.e. a C++ snippet which may use
15 - Q: a pointer (double*) to the patch.no_of_unknowns doubles of the
16 entry, which the snippet may read and write;
17 - x: the position (tarch::la::Vector<Dimensions,double>) of the entry,
18 i.e. the centre of the volume if we interpret the patch as N^d
19 volumes which tessellate the cell.
21 A typical use case is the postprocessing of a solution, e.g. the
22 enforcement of algebraic constraints or the clipping of unphysical
25 As the action set plugs into touchCellFirstTime(), it runs after all
26 action sets of tasks it depends on which plug into touchCellFirstTime()
27 as well, and before all action sets plugging into touchCellLastTime()
28 such as toolbox.blockstructured.api.ProjectPatchOntoFaces, if the task
29 graph compiler fuses the tasks into one mesh traversal.
38 additional_includes: str =
"",
42 @param patch: peano4.api.datamodel.Patch
43 The cell's patch. It has to be a cube, i.e. have the same number of
44 entries along each axis.
46 @param implementation: str
47 C++ snippet that is applied to each entry, @see class
48 documentation for the variables it may use.
51 C++ boolean expression. The action set only processes cells for
52 which the guard holds.
54 @param additional_includes: str
55 Includes that the snippet needs.
58 super(ApplyPointWiselyToPatch, self).
__init__(
59 descend_invocation_order=1, parallel=
False
61 assert patch.dim[0] == patch.dim[1],
"Can only handle square patches"
82 return " return std::vector< peano4::grid::GridControlEvent >();\n"
85 return __name__.replace(
".py",
"").replace(
".",
"_")
91 if operation_name != ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
93 entries_per_axis = self.
_patch.dim[0]
94 unknowns = self.
_patch.no_of_unknowns
96 const tarch::la::Vector<Dimensions, double> entryH = marker.h() / {entries_per_axis}.0;
97 dfor(entry, {entries_per_axis}) {{
98 tarch::la::Vector<Dimensions, double> x;
99 for (int d = 0; d < Dimensions; d++) {{
100 x(d) = marker.x()(d) - 0.5 * marker.h()(d) + (entry(d) + 0.5) * entryH(d);
102 double* __restrict__ Q = fineGridCell{self._patch.name}.value + peano4::utils::dLinearised(entry, {entries_per_axis}) * {unknowns};
104 {self._implementation}
110 if operation_name == ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
120#include "peano4/utils/Loop.h"
Apply a C++ snippet to each entry of a cell's patch.
get_guard_of_operation(self, operation_name)
Return the guard of an operation.
get_constructor_body(self)
Define a tailored constructor body.
user_should_modify_template(self)
Is the user allowed to modify the output.
get_body_of_createGridControlEventsForNextTraversal(self)
Return the grid control events that this action set wants to trigger.
get_includes(self)
Return include statements that you need.
get_action_set_name(self)
Return unique action set name.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
get_attributes(self)
Return attributes as copied and pasted into the generated class.
__init__(self, patch, str implementation, str guard="true", str additional_includes="")
get_destructor_body(self)
Action set (reactions to events)