13 Restrict the overlap data of hanging faces onto the coarser mesh
15 A hanging face is a face of a fine cell which sits on the face of a
16 coarser, unrefined cell (toolbox.blockstructured.api.InterpolateHangingFaces).
17 The action set plugs into destroyHangingFace(): It takes the half of the
18 hanging face which belongs to the fine cell and restricts it onto the
19 corresponding half of the coarse face
20 (::toolbox::blockstructured::restrictInnerHalfOfHaloLayer_AoS_...).
21 Peano destroys a hanging face after touchCellLastTime() of its fine
22 cell, i.e. after the fine cell has projected its data onto its faces.
23 Peano touches the coarse face for the last time after all of these
24 hanging faces have been destroyed. Afterwards, the coarse face holds the
25 data of the coarse cell on one side and the restricted fine data on the
28 The face overlap has to be a 2MxNxN patch: M is the overlap, N the
29 number of volumes per patch axis.
32 ## Averaging and clearing
34 Averaging accumulates the fine grid values within the coarse face.
35 The action set therefore clears the face data in touchFaceFirstTime()
36 for each face which passes the clear guard. This clears both halves of
37 the face. Use the action set only in a mesh sweep where all face data
38 which are cleared are written again afterwards, e.g. by a projection
39 onto the faces. Injection overwrites the coarse values and hence does
49 The value of each entry is the suffix of the C++ routine
50 ::toolbox::blockstructured::restrictInnerHalfOfHaloLayer_AoS_<suffix>().
52 - Averaging sets each coarse volume to the average of the fine
53 volumes along the face which it covers.
54 - Inject copies the value of the fine volume in the centre of each
59 Averaging =
"averaging"
62 TemplateTouchFaceFirstTime = jinja2.Template(
64 logTraceInWith1Argument( "touchFaceFirstTime(...)---RestrictHangingFaces", marker.toString() );
65 ::toolbox::blockstructured::clearHaloLayerAoS(
70 fineGridFace{{FACE_NAME}}.value
72 logTraceOut( "touchFaceFirstTime(...)---RestrictHangingFaces" );
76 TemplateDestroyHangingFace = jinja2.Template(
78 logTraceInWith1Argument( "destroyHangingFace(...)---RestrictHangingFaces", marker.toString() );
79 ::toolbox::blockstructured::restrictInnerHalfOfHaloLayer_AoS_{{SCHEME}}(
84 fineGridFace{{FACE_NAME}}.value,
85 coarseGridFaces{{FACE_NAME}}(marker.getSelectedFaceNumber()).value
87 logTraceOut( "destroyHangingFace(...)---RestrictHangingFaces" );
94 scheme:
"RestrictHangingFaces.Scheme" =
None,
96 clear_guard: str =
"true",
97 additional_includes: str =
"",
101 @param patch_overlap: peano4.api.datamodel.Patch
102 The face data which the action set restricts. The data of the
103 hanging face are read, the data of the coarse face are written.
105 @param scheme: RestrictHangingFaces.Scheme
106 Restriction scheme. Defaults to Scheme.Averaging. Injection
107 supports an overlap of one only.
110 C++ boolean expression over the hanging face's
111 peano4::datamanagement::FaceMarker marker.
113 @param clear_guard: str
114 C++ boolean expression over a persistent face's
115 peano4::datamanagement::FaceMarker marker. Only used for averaging:
116 The action set clears the face's data in touchFaceFirstTime() if
117 the expression holds.
119 @param additional_includes: str
120 Further include statements, e.g. required by the guards.
123 super().
__init__(descend_invocation_order=1, parallel=
False)
124 assert patch_overlap.dim[0] % 2 == 0, (
125 "Patch associated to face has to have even number of volumes along "
126 "the normal. Otherwise, it is not a symmetric overlap."
129 RestrictHangingFaces.Scheme.Averaging
if scheme
is None else scheme
133 self.
scheme != RestrictHangingFaces.Scheme.Inject
134 or patch_overlap.dim[0] == 2
136 "Injection supports an overlap of one only, but the face data "
137 f
"{patch_overlap.name} have an overlap of {patch_overlap.dim[0] // 2}. "
138 "Use averaging instead."
141 "UNKNOWNS": patch_overlap.no_of_unknowns,
142 "DOFS_PER_AXIS": patch_overlap.dim[1],
143 "OVERLAP": patch_overlap.dim[0] // 2,
144 "FACE_NAME": patch_overlap.name,
145 "SCHEME": self.
scheme.value,
153 """! Does the scheme accumulate, i.e. does it have to clear the faces first?"""
154 return self.
scheme == RestrictHangingFaces.Scheme.Averaging
163 return " return std::vector< peano4::grid::GridControlEvent >();\n"
172 if operation_name == ActionSet.OPERATION_DESTROY_HANGING_FACE:
175 operation_name == ActionSet.OPERATION_TOUCH_FACE_FIRST_TIME
182 if operation_name == ActionSet.OPERATION_DESTROY_HANGING_FACE:
184 if operation_name == ActionSet.OPERATION_TOUCH_FACE_FIRST_TIME:
189 return __name__.replace(
".py",
"").replace(
".",
"_")
200#include "toolbox/blockstructured/Restriction.h"
Restrict the overlap data of hanging faces onto the coarser mesh.
get_action_set_name(self)
Return unique action set name.
get_constructor_body(self)
Define a tailored constructor body.
TemplateDestroyHangingFace
user_should_modify_template(self)
Is the user allowed to modify the output.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
get_includes(self)
Return include statements that you need.
bool clears_faces(self)
Does the scheme accumulate, i.e.
TemplateTouchFaceFirstTime
get_destructor_body(self)
get_guard_of_operation(self, operation_name)
Return the guard of an operation.
get_body_of_unprepareTraversal(self)
__init__(self, patch_overlap, "RestrictHangingFaces.Scheme" scheme=None, str guard="true", str clear_guard="true", str additional_includes="")
get_body_of_prepareTraversal(self)
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.
Action set (reactions to events)