Peano 4
Loading...
Searching...
No Matches
RollOverUpdatedFace.py
Go to the documentation of this file.
1# This file is part of the ExaHyPE2 project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3
4from .AbstractRKFDActionSet import AbstractRKFDActionSet
5
6import peano4
7import jinja2
8
10 """!
11
12 Roll over QUpdate data on face into QNew
13
14 This action set takes the updated data per face and writes it into
15 new. So it takes the outcome from ProjectPatchOntoFaces and writes
16 it onto the (persistent) face data. Before it does so, the action
17 set also rolls over the new data to the old one.
18
19 We may not roll over data if no data has been written onto the
20 face. So we check the updated flag. It is reset by the UpdateFaceLabel
21 action set in the grid subpackage and set again by either the face
22 projection or the dynamic amr handling.
23
24 """
25 TemplateHandleFace = jinja2.Template( """
26 if ( {{GUARD}} ) {
27 const int normal = marker.getSelectedFaceNumber() % Dimensions;
28
29 logTraceInWith3Arguments( "touchFaceLastTime(...)", fineGridFace{{SOLVER_NAME}}FaceLabel.toString(), marker.toString(), normal );
30
31 // Left half
32 if ({{FACE_METADATA_ACCESSOR}}.getUpdated(0)) {
33 logTraceInWith1Argument( "touchFaceLastTime(...)", "left half of face" );
34 dfore(k,{{DOFS_PER_AXIS}},normal,0) {
35 for (int i=0; i<{{OVERLAP}}; i++) {
36 tarch::la::Vector<Dimensions,int> overlapCell = k;
37 overlapCell(normal) = i;
38 const int index = toolbox::blockstructured::serialiseVoxelIndexInOverlap(overlapCell,{{DOFS_PER_AXIS}},{{OVERLAP}},normal);
39 logDebug( "touchFaceLastTime(...)", "normal=" << normal << ",{{NEW_ACCESSOR}}[" << index << "]->{{OLD_ACCESSOR}}[" << index << "]" );
40 logDebug( "touchFaceLastTime(...)", "normal=" << normal << ",{{UPDATE_ACCESSOR}}[" << index << "]->{{NEW_ACCESSOR}}[" << index << "]" );
41 for (int j=0; j<{{UNKNOWNS}}; j++) {
42 // The initialisation mapping has an epilogue which then copies this
43 // updated new solution over into the old one
44 {{OLD_ACCESSOR}}.value[index*{{UNKNOWNS}}+j] = {{NEW_ACCESSOR}}.value[index*{{UNKNOWNS}}+j];
45 {{NEW_ACCESSOR}}.value[index*{{UNKNOWNS}}+j] = {{UPDATE_ACCESSOR}}.value[index*{{UNKNOWNS}}+j];
46 }
47 }
48 }
49
50 {{FACE_METADATA_ACCESSOR}}.setOldTimeStamp(0, {{FACE_METADATA_ACCESSOR}}.getNewTimeStamp(0) );
51 {{FACE_METADATA_ACCESSOR}}.setNewTimeStamp(0, {{FACE_METADATA_ACCESSOR}}.getUpdatedTimeStamp(0) );
52
53 logTraceOut( "touchFaceLastTime(...)" );
54 }
55 else {
56 logTraceIn( "touchFaceLastTime(...) (skip left part of face)" );
57 logTraceOut( "touchFaceLastTime(...) (skip left part of face)" );
58 }
59
60 // Right half
61 if ({{FACE_METADATA_ACCESSOR}}.getUpdated(1)) {
62 logTraceInWith1Argument( "touchFaceLastTime(...)", "right half of face" );
63 dfore(k,{{DOFS_PER_AXIS}},normal,0) {
64 for (int i={{OVERLAP}}; i<2*{{OVERLAP}}; i++) {
65 tarch::la::Vector<Dimensions,int> overlapCell = k;
66 overlapCell(normal) = i;
67 const int index = toolbox::blockstructured::serialiseVoxelIndexInOverlap(overlapCell,{{DOFS_PER_AXIS}},{{OVERLAP}},normal);
68 logDebug( "touchFaceLastTime(...)", "normal=" << normal << ",{{NEW_ACCESSOR}}[" << index << "]->{{OLD_ACCESSOR}}[" << index << "]" );
69 logDebug( "touchFaceLastTime(...)", "normal=" << normal << ",{{UPDATE_ACCESSOR}}[" << index << "]->{{NEW_ACCESSOR}}[" << index << "]" );
70 for (int j=0; j<{{UNKNOWNS}}; j++) {
71 // The initialisation mapping has an epilogue which then copies this
72 // updated new solution over into the old one
73 {{OLD_ACCESSOR}}.value[index*{{UNKNOWNS}}+j] = {{NEW_ACCESSOR}}.value[index*{{UNKNOWNS}}+j];
74 {{NEW_ACCESSOR}}.value[index*{{UNKNOWNS}}+j] = {{UPDATE_ACCESSOR}}.value[index*{{UNKNOWNS}}+j];
75 }
76 }
77 }
78
79 {{FACE_METADATA_ACCESSOR}}.setOldTimeStamp(1, {{FACE_METADATA_ACCESSOR}}.getNewTimeStamp(1) );
80 {{FACE_METADATA_ACCESSOR}}.setNewTimeStamp(1, {{FACE_METADATA_ACCESSOR}}.getUpdatedTimeStamp(1) );
81
82 logTraceOut( "touchFaceLastTime(...)" );
83 }
84 else {
85 logTraceIn( "touchFaceLastTime(...) (skip right part of face)" );
86 logTraceOut( "touchFaceLastTime(...) (skip right part of face)" );
87 }
88
89 int index = 0;
90 logTraceOut( "touchFaceLastTime(...)" );
91 }
92""" )
93
94
95 def __init__(self,solver,guard):
96 """
97
98 ## Attributes
99
100 overwrite_old_and_new_solution_with_update: Boolean
101 This flag should be set if you use the action set throughout the
102 initialisation, where you determine an update on the face and
103 this update should then be used for old and new face data (as
104 they are the same). If it is set to false, then the new solution
105 is backuped in old, and the update overwrites the new data field.
106
107 """
108 AbstractRKFDActionSet.__init__(self,solver)
109 self.guard = guard
110
111
112 def get_body_of_operation(self,operation_name):
113 result = ""
114 self.d = {}
115 self.d[ "GUARD" ] = self.guard
116 self.d[ "UNKNOWNS" ] = str(self._solver._patch_overlap_update.no_of_unknowns)
117 self.d[ "DOFS_PER_AXIS" ] = str(self._solver._patch.dim[0])
118 self.d[ "OVERLAP" ] = str(int(self._solver._patch_overlap_update.dim[0]/2))
119 self.d[ "UPDATE_ACCESSOR" ] = "fineGridFace" + self._solver._patch_overlap_update.name
120 self.d[ "OLD_ACCESSOR" ] = "fineGridFace" + self._solver._patch_overlap_old.name
121 self.d[ "NEW_ACCESSOR" ] = "fineGridFace" + self._solver._patch_overlap_new.name
122 self.d[ "FACE_METADATA_ACCESSOR" ] = "fineGridFace" + self._solver._face_label.name
123 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_FACE_LAST_TIME:
124 self._solver._init_dictionary_with_default_parameters(self.d)
125 self._solver.add_entries_to_text_replacement_dictionary(self.d)
126 result = self.TemplateHandleFace.render(**self.d)
127 pass
128 return result
129
130
131 def get_includes(self):
132 return """
133#include "peano4/utils/Loop.h"
134#include "toolbox/blockstructured/Enumeration.h"
135""" + AbstractRKFDActionSet.get_includes(self)
136
137
139 return __name__.replace(".py", "").replace(".", "_")
get_action_set_name(self)
You should replicate this function in each subclass, so you get meaningful action set names (otherwis...
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.