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.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.datamodel.Patch
13 Patch data associated with cell.
14
15 patch_overlap_out: peano4.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 if ({GUARD_PREDICATE}) {{
69 logTraceInWith3Arguments( "--backup patch overlap from {FACES_ACCESSOR_IN} into {FACES_ACCESSOR_OUT}--(...)", marker.toString(), {FACES_ACCESSOR_OUT}.value, {FACES_ACCESSOR_IN}.value );
70 int counter = 0;
71 dfore(k,{DOFS_PER_AXIS},0,0) {{
72 for (int i=0; i<{OVERLAP}*2; i++) {{
73 for (int j=0; j<{UNKNOWNS}; j++) {{
74 // assertion4( {FACES_ACCESSOR_IN}.value[counter]=={FACES_ACCESSOR_IN}.value[counter], k,i,j, marker.toString() );
75 {FACES_ACCESSOR_OUT}.value[counter] = {FACES_ACCESSOR_IN}.value[counter];
76 counter++;
77 }}
78 }}
79 }}
80 logTraceOutWith1Argument( "--backup patch overlap from {FACES_ACCESSOR_IN} into {FACES_ACCESSOR_OUT}--(...)", {FACES_ACCESSOR_IN}.value[0] );
81 }}
82"""
83
84
85 def get_body_of_operation(self,operation_name):
86 result = "\n"
87 if self.invoke_in_touch_first and operation_name==ActionSet.OPERATION_TOUCH_FACE_FIRST_TIME:
88 result = self.__Template.format(**self.d)
89 pass
90 if not self.invoke_in_touch_first and operation_name==ActionSet.OPERATION_TOUCH_FACE_LAST_TIME:
91 result = self.__Template.format(**self.d)
92 pass
93 return result
94
95
96 def get_attributes(self):
97 return ""
98
99
100 def get_includes(self):
101 return """
102#include "peano4/utils/Loop.h"
103""" + self._additional_includes
Action set (reactions to events)
Definition ActionSet.py:6
This class plugs into the first access to a face and copies the data over.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
__init__(self, patch_overlap_in, patch_overlap_out, invoke_in_touch_first, guard="", additional_includes="")
get_attributes(self)
Return attributes as copied and pasted into the generated class.
user_should_modify_template(self)
Is the user allowed to modify the output.