Peano
Loading...
Searching...
No Matches
BackupPatchOverlap.py
Go to the documentation of this file.
1# This file is part of the Peano project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3from peano4.api.solversteps.ActionSet import ActionSet
4
5
6
8 """
9
10 This class plugs into the first access to a face and copies the data over
11
12 patch_overlap_in: peano4.api.datamodel.Patch
13 Patch data associated with cell.
14
15 patch_overlap_out: peano4.api.datamodel.Patch
16 Patch data associated with faces.
17
18 invoke_in_touch_first: Boolean
19 If you set this one to True, then I do the copying in touchFaceFirstTime.
20 Otherwise, I do it in touchFaceLastTime
21
22 guard: Boolean
23 Predicate to determine when to invoke this thing. Pass in
24 true if you wanna be it called always
25
26 """
27
28
29 def __init__(self,patch_overlap_in,patch_overlap_out,invoke_in_touch_first,guard="",additional_includes=""):
30 super(BackupPatchOverlap,self).__init__(descend_invocation_order=1,parallel=False)
31 self.d = {}
32 self.d[ "UNKNOWNS" ] = str(patch_overlap_in.no_of_unknowns)
33 self.d[ "DOFS_PER_AXIS" ] = str(patch_overlap_in.dim[1])
34 self.d[ "OVERLAP" ] = str(int(patch_overlap_in.dim[0]/2))
35 self.d[ "FACES_ACCESSOR_IN" ] = "fineGridFace" + patch_overlap_in.name
36 self.d[ "FACES_ACCESSOR_OUT" ] = "fineGridFace" + patch_overlap_out.name
37 self.d[ "GUARD_PREDICATE" ] = guard
38
39 self.invoke_in_touch_first = invoke_in_touch_first
40 self._additional_includes = additional_includes
41
42
43 def set_guard_predicate(self,guard):
44 self.d[ "GUARD_PREDICATE" ] = guard
45
46
48 return ""
49
50
52 return ""
53
54
56 return " return std::vector< peano4::grid::GridControlEvent >();\n"
57
58
60 return __name__.replace(".py", "").replace(".", "_")
61
62
64 return False
65
66
67 __Template = """
68 logTraceInWith3Arguments( "--backup patch overlap from {FACES_ACCESSOR_IN} into {FACES_ACCESSOR_OUT}--(...)", marker.toString(), {FACES_ACCESSOR_OUT}.value, {FACES_ACCESSOR_IN}.value );
69 int counter = 0;
70 dfore(k,{DOFS_PER_AXIS},0,0) {{
71 for (int i=0; i<{OVERLAP}*2; i++) {{
72 for (int j=0; j<{UNKNOWNS}; j++) {{
73 // assertion4( {FACES_ACCESSOR_IN}.value[counter]=={FACES_ACCESSOR_IN}.value[counter], k,i,j, marker.toString() );
74 {FACES_ACCESSOR_OUT}.value[counter] = {FACES_ACCESSOR_IN}.value[counter];
75 counter++;
76 }}
77 }}
78 }}
79 logTraceOutWith1Argument( "--backup patch overlap from {FACES_ACCESSOR_IN} into {FACES_ACCESSOR_OUT}--(...)", {FACES_ACCESSOR_IN}.value[0] );
80"""
81
82
83 def get_body_of_operation(self,operation_name):
84 result = "\n"
85 if self.invoke_in_touch_first and operation_name==ActionSet.OPERATION_TOUCH_FACE_FIRST_TIME:
86 result = self.__Template.format(**self.d)
87 pass
88 if not self.invoke_in_touch_first and operation_name==ActionSet.OPERATION_TOUCH_FACE_LAST_TIME:
89 result = self.__Template.format(**self.d)
90 pass
91 return result
92
93
94 def get_guard_of_operation(self,operation_name):
95 if self.invoke_in_touch_first and operation_name==ActionSet.OPERATION_TOUCH_FACE_FIRST_TIME:
96 return self.d[ "GUARD_PREDICATE" ]
97 if not self.invoke_in_touch_first and operation_name==ActionSet.OPERATION_TOUCH_FACE_LAST_TIME:
98 return self.d[ "GUARD_PREDICATE" ]
99 return "true"
100
101
102 def get_attributes(self):
103 return ""
104
105
106 def get_includes(self):
107 return """
108#include "peano4/utils/Loop.h"
109""" + self._additional_includes
This class plugs into the first access to a face and copies the data over.
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_guard_of_operation(self, operation_name)
Return the guard of an operation.
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.
user_should_modify_template(self)
Is the user allowed to modify the output.
get_attributes(self)
Return attributes as copied and pasted into the generated class.
__init__(self, patch_overlap_in, patch_overlap_out, invoke_in_touch_first, guard="", additional_includes="")
Action set (reactions to events)
Definition ActionSet.py:6