10 This class assumes that you have NxNxN patch within your block. It also
11 assumes that you have an 2MxNxN patch on your faces. M<N. The code interprets
12 these face-associated data as overlap with the patch, hooks into
13 touchCellLastTime, and projects the cell's patch data onto the overlap
16 And then runs over your grid and maps the patch data on the respective entries of the
17 face patch which is an auxiliary data structure.
22 patch: peano4.api.datamodel.Patch
23 This is the input data structure, i.e. the patch from which we extract
26 patch_overlap: peano4.api.datamodel.Patch.
27 Consult remark above about how the dimensions of this overlap patch have
33 def __init__(self,patch,patch_overlap,guard,additional_includes, add_assertions = True):
34 super(ProjectPatchOntoFaces,self).
__init__(descend_invocation_order=1,parallel=
False)
36 if patch_overlap.dim[0] % 2 != 0:
37 print(
"Error: Patch associated to face has to have even number of cells. Otherwise, it is not a symmetric overlap." )
38 assert( patch_overlap.dim[0] % 2 == 0 )
39 if patch.dim[0] != patch.dim[1]:
40 print(
"Error: Can only handle square patches." )
41 assert( patch.dim[0] == patch.dim[1] )
42 if patch_overlap.dim[1] != patch.dim[0]:
43 print(
"Error: Patch of overlap and patch of cell have to match" )
44 assert( patch_overlap.dim[1] == patch.dim[0] )
46 assert isinstance(patch.no_of_unknowns,int)
47 assert isinstance(patch.dim[0],int)
48 assert isinstance(patch_overlap.dim[0],int)
50 self.
d[
"UNKNOWNS" ] = str(patch.no_of_unknowns)
51 self.
d[
"DOFS_PER_AXIS" ] = str(patch.dim[0])
52 self.
d[
"OVERLAP" ] = str(int(patch_overlap.dim[0]/2))
53 self.
d[
"FACES_ACCESSOR" ] =
"fineGridFaces" + patch_overlap.name
54 self.
d[
"CELL_ACCESSOR" ] =
"fineGridCell" + patch.name
55 self.
d[
"GUARD" ] = guard
57 self.
d[
"ASSERTION_PREFIX" ] =
"false"
59 self.
d[
"ASSERTION_PREFIX" ] =
"true"
67 return self.
d[
"GUARD" ]
71 self.
d[
"GUARD" ] = value
82 return " return std::vector< peano4::grid::GridControlEvent >();\n"
86 return __name__.replace(
".py",
"").replace(
".",
"_")
93 __Template_TouchCellLastTime_Preamble =
"""
94 logTraceIn( "touchCellLastTime(...)---ProjectPatchOntoFaces" );
98 __Template_TouchCellLastTime_Core =
"""
99 // @todo Might want to use routine from Projection.h in toolbox.
100 for(int d=0; d<Dimensions; d++) {{
102 * d-loop over all dimensions except d. The vector k's entry d is set
103 * to 0. We start with the left/bottom face, i.e. the one closer to the
104 * coordinate system's origin.
106 dfore(k,{DOFS_PER_AXIS},d,0) {{
107 for (int i=0; i<{OVERLAP}; i++) {{
108 tarch::la::Vector<Dimensions,int> patchCell = k;
109 tarch::la::Vector<Dimensions,int> overlapCell = k;
111 overlapCell(d) = i+{OVERLAP};
113 int patchCellSerialised = peano4::utils::dLinearised(patchCell,{DOFS_PER_AXIS});
114 int overlapCellSerialised = toolbox::blockstructured::serialiseVoxelIndexInOverlap(overlapCell,{DOFS_PER_AXIS},{OVERLAP},d);
115 for (int j=0; j<{UNKNOWNS}; j++) {{
119 {CELL_ACCESSOR}.value[patchCellSerialised*{UNKNOWNS}+j]=={CELL_ACCESSOR}.value[patchCellSerialised*{UNKNOWNS}+j], j,i,k,d, patchCell, overlapCell,
122 {FACES_ACCESSOR}(d).value[overlapCellSerialised*{UNKNOWNS}+j] =
123 {CELL_ACCESSOR}.value[patchCellSerialised*{UNKNOWNS}+j];
126 patchCell(d) = i+{DOFS_PER_AXIS}-{OVERLAP};
129 patchCellSerialised = peano4::utils::dLinearised(patchCell,{DOFS_PER_AXIS});
130 overlapCellSerialised = toolbox::blockstructured::serialiseVoxelIndexInOverlap(overlapCell,{DOFS_PER_AXIS},{OVERLAP},d);
131 for (int j=0; j<{UNKNOWNS}; j++) {{
135 {CELL_ACCESSOR}.value[patchCellSerialised*{UNKNOWNS}+j]=={CELL_ACCESSOR}.value[patchCellSerialised*{UNKNOWNS}+j], j,i,k,d, patchCell, overlapCell,
138 {FACES_ACCESSOR}(d+Dimensions).value[overlapCellSerialised*{UNKNOWNS}+j] =
139 {CELL_ACCESSOR}.value[patchCellSerialised*{UNKNOWNS}+j];
147 __Template_TouchCellLastTime_Epilogue =
"""
148 logTraceOut( "touchCellLastTime(...)---ProjectPatchOntoFaces" );
154 if operation_name==ActionSet.OPERATION_TOUCH_CELL_LAST_TIME:
163 if operation_name==ActionSet.OPERATION_TOUCH_CELL_LAST_TIME:
164 return self.
d[
"GUARD" ]
174#include "peano4/utils/Loop.h"
175#include "toolbox/blockstructured/Enumeration.h"
This class assumes that you have NxNxN patch within your block.
get_attributes(self)
Return attributes as copied and pasted into the generated class.
get_includes(self)
Return include statements that you need.
get_body_of_createGridControlEventsForNextTraversal(self)
Return the grid control events that this action set wants to trigger.
user_should_modify_template(self)
Is the user allowed to modify the output.
get_action_set_name(self)
Return unique action set name.
str __Template_TouchCellLastTime_Epilogue
get_constructor_body(self)
Define a tailored constructor body.
get_destructor_body(self)
__init__(self, patch, patch_overlap, guard, additional_includes, add_assertions=True)
str __Template_TouchCellLastTime_Preamble
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
str __Template_TouchCellLastTime_Core
get_guard_of_operation(self, operation_name)
Return the guard of an operation.
Action set (reactions to events)