13 Initialise the patches of new cells from their parent, and hand the
14 patches of erased cells over to their parent
16 The action set realises the data transfer of a dynamically adaptive
17 mesh for patches which live on the finest mesh level only:
19 - If a mesh sweep refines a cell, Peano creates its 3^d children.
20 createCell() interpolates the parent's patch into each child's patch
21 (::toolbox::blockstructured::interpolateCell_AoS_...). The parent's
22 patch is still available in this sweep, as the parent has not been
23 refined when the sweep has started.
24 - If a mesh sweep erases the children of a cell, the parent becomes a
25 leaf again. touchCellFirstTime() clears the parent's patch, and
26 destroyCell() then restricts each child's patch into the parent's patch
27 (::toolbox::blockstructured::restrictCell_AoS_...). The averaging
28 accumulates the children's contributions, so the parent has to be
31 The patch is a NxNxN patch, i.e. N volumes per axis.
40 The value of each entry is the suffix of the C++ routine
41 ::toolbox::blockstructured::interpolateCell_AoS_<suffix>().
43 - PiecewiseConstant copies the coarse value into all fine volumes
45 - Linear interpolates d-linearly. Along the boundary of the coarse
46 patch, it extrapolates constantly, as linear extrapolation can
47 produce unphysical values such as negative densities next to steep
52 PiecewiseConstant =
"piecewise_constant"
53 Linear =
"linear_with_constant_extrapolation"
60 The value of each entry is the suffix of the C++ routine
61 ::toolbox::blockstructured::restrictCell_AoS_<suffix>().
63 - Averaging sets each coarse volume to the average of the 3^d fine
68 Averaging =
"averaging"
70 TemplateCreateCell = jinja2.Template(
72 logTraceInWith1Argument( "createCell(...)---InterpolateAndRestrictCells", marker.toString() );
73 ::toolbox::blockstructured::interpolateCell_AoS_{{INTERPOLATION}}(
77 coarseGridCell{{CELL_NAME}}.value,
78 fineGridCell{{CELL_NAME}}.value
80 logTraceOut( "createCell(...)---InterpolateAndRestrictCells" );
84 TemplateTouchCellFirstTime = jinja2.Template(
86 if ( marker.hasBeenRefined() and not marker.willBeRefined() ) {
87 logTraceInWith1Argument( "touchCellFirstTime(...)---InterpolateAndRestrictCells", marker.toString() );
88 ::toolbox::blockstructured::clearCell(
92 fineGridCell{{CELL_NAME}}.value
94 logTraceOut( "touchCellFirstTime(...)---InterpolateAndRestrictCells" );
99 TemplateDestroyCell = jinja2.Template(
101 logTraceInWith1Argument( "destroyCell(...)---InterpolateAndRestrictCells", marker.toString() );
102 ::toolbox::blockstructured::restrictCell_AoS_{{RESTRICTION}}(
106 fineGridCell{{CELL_NAME}}.value,
107 coarseGridCell{{CELL_NAME}}.value
109 logTraceOut( "destroyCell(...)---InterpolateAndRestrictCells" );
116 interpolation:
"InterpolateAndRestrictCells.Interpolation" =
None,
117 restriction:
"InterpolateAndRestrictCells.Restriction" =
None,
118 additional_includes: str =
"",
122 @param patch: peano4.api.datamodel.Patch
123 The cell data which the action set interpolates and restricts.
125 @param interpolation: InterpolateAndRestrictCells.Interpolation
126 Interpolation scheme. Defaults to Interpolation.Linear.
128 @param restriction: InterpolateAndRestrictCells.Restriction
129 Restriction scheme. Defaults to Restriction.Averaging.
131 @param additional_includes: str
132 Further include statements.
135 super().
__init__(descend_invocation_order=1, parallel=
False)
137 InterpolateAndRestrictCells.Interpolation.Linear
138 if interpolation
is None
142 InterpolateAndRestrictCells.Restriction.Averaging
143 if restriction
is None
153 "UNKNOWNS": patch.no_of_unknowns,
154 "DOFS_PER_AXIS": patch.dim[0],
155 "CELL_NAME": patch.name,
168 return " return std::vector< peano4::grid::GridControlEvent >();\n"
177 if operation_name == ActionSet.OPERATION_CREATE_CELL:
179 if operation_name == ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
181 if operation_name == ActionSet.OPERATION_DESTROY_CELL:
186 return __name__.replace(
".py",
"").replace(
".",
"_")
197#include "toolbox/blockstructured/Interpolation.h"
198#include "toolbox/blockstructured/Restriction.h"
Initialise the patches of new cells from their parent, and hand the patches of erased cells over to t...
get_body_of_unprepareTraversal(self)
__init__(self, patch, "InterpolateAndRestrictCells.Interpolation" interpolation=None, "InterpolateAndRestrictCells.Restriction" restriction=None, str additional_includes="")
get_attributes(self)
Return attributes as copied and pasted into the generated class.
TemplateTouchCellFirstTime
get_destructor_body(self)
get_constructor_body(self)
Define a tailored constructor body.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
get_body_of_createGridControlEventsForNextTraversal(self)
Return the grid control events that this action set wants to trigger.
get_action_set_name(self)
Return unique action set name.
user_should_modify_template(self)
Is the user allowed to modify the output.
get_includes(self)
Return include statements that you need.
get_body_of_prepareTraversal(self)
Action set (reactions to events)