Peano
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
3from peano4.api.solversteps.ActionSet import ActionSet
4
5import peano4.api
6import jinja2
7
8
10 """!
11
12 Copy patch_overlap_update - the face overlap
13 exahype2.api.fv.actionsets.ProjectPatchOntoFaces has just written the
14 latest projection into - onto patch_overlap_current_time_step, the
15 persistent face data toolbox.blockstructured.api.ReconstructPatchWithHalo
16 reads from to rebuild a patch's halo. Both halves of the face overlap
17 (left and right, relative to the face's normal) are copied in full,
18 unconditionally subject only to guard.
19
20 Ported and substantially slimmed down from the legacy
21 exahype2.solvers.fv.actionsets.RollOverUpdatedFace: that version
22 additionally rolled a third ("old") buffer over and gated each half
23 of the copy on a per-half "updated" flag read from a face label -
24 neither the third buffer nor the face label exist yet in the new
25 exahype2.api's data structures (@see
26 exahype2.api.fv.RusanovWithExplicitEuler.__create_data_structures(),
27 which creates exactly solver._patch_overlap_current_time_step and
28 solver._patch_overlap_update, and nothing else on the face side).
29
30 """
31
32 TemplateHandleFace = jinja2.Template("""
33 const int normal = marker.getSelectedFaceNumber() % Dimensions;
34
35 logTraceInWith2Arguments( "touchFaceLastTime(...)---RollOverUpdatedFace", marker.toString(), normal );
36
37 ::exahype2::fv::copyHalfOfHalo(
38 {{UNKNOWNS}},
39 {{DOFS_PER_AXIS}},
40 {{OVERLAP}},
41 normal,
42 false, // left half
43 {{UPDATE_ACCESSOR}}.value,
44 {{CURRENT_TIME_STEP_ACCESSOR}}.value
45 );
46 ::exahype2::fv::copyHalfOfHalo(
47 {{UNKNOWNS}},
48 {{DOFS_PER_AXIS}},
49 {{OVERLAP}},
50 normal,
51 true, // right half
52 {{UPDATE_ACCESSOR}}.value,
53 {{CURRENT_TIME_STEP_ACCESSOR}}.value
54 );
55
56 logTraceOut( "touchFaceLastTime(...)---RollOverUpdatedFace" );
57""")
58
59 def __init__(self, patch_overlap_current_time_step, patch_overlap_update, guard, includes):
60 """!
61
62 patch_overlap_current_time_step: peano4.api.datamodel.Patch
63 The persistent face overlap to roll patch_overlap_update into -
64 @see exahype2.api.fv.RusanovWithExplicitEuler.
65
66 patch_overlap_update: peano4.api.datamodel.Patch
67 The face overlap exahype2.api.fv.actionsets.ProjectPatchOntoFaces
68 has just written the latest projection into - @see
69 exahype2.api.fv.RusanovWithExplicitEuler. Its dim[1] is assumed to
70 equal the cell patch's dofs-per-axis, i.e. patch_overlap_update
71 and patch_overlap_current_time_step have to be face-associated
72 overlaps of a cell patch in the sense of
73 exahype2.api.fv.actionsets.ProjectPatchOntoFaces.
74
75 guard: str
76 C++ boolean expression, evaluated per face in touchFaceLastTime,
77 guarding whether that face's overlap is rolled over.
78
79 includes: str
80 Additional includes this action set's generated code needs -
81 callers typically pass solver._get_default_includes() +
82 solver.user_solver_includes.
83
84 """
85 super().__init__(descend_invocation_order=1, parallel=False)
86 self.additional_includes = includes
87 self.d = {}
88 self.d["GUARD"] = guard
89 self.d["UNKNOWNS"] = str(patch_overlap_update.no_of_unknowns)
90 self.d["DOFS_PER_AXIS"] = str(patch_overlap_update.dim[1])
91 self.d["OVERLAP"] = str(int(patch_overlap_update.dim[0] / 2))
92 self.d["UPDATE_ACCESSOR"] = "fineGridFace" + patch_overlap_update.name
93 self.d["CURRENT_TIME_STEP_ACCESSOR"] = "fineGridFace" + patch_overlap_current_time_step.name
94
95 def get_body_of_operation(self, operation_name):
96 result = ""
97 if operation_name == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_FACE_LAST_TIME:
98 result = self.TemplateHandleFace.render(**self.d)
99 return result
100
101 def get_guard_of_operation(self, operation_name):
102 if operation_name == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_FACE_LAST_TIME:
103 return self.d["GUARD"]
104 return "true"
105
107 return __name__.replace(".py", "").replace(".", "_")
108
110 return False
111
112 def get_includes(self):
113 return (
114 """
115#include <functional>
116#include "exahype2/fv/PatchUtils.h"
117"""
119 )
Copy patch_overlap_update - the face overlap exahype2.api.fv.actionsets.ProjectPatchOntoFaces has jus...
__init__(self, patch_overlap_current_time_step, patch_overlap_update, guard, includes)
patch_overlap_current_time_step: peano4.api.datamodel.Patch The persistent face overlap to roll patch...
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_guard_of_operation(self, operation_name)
Return the guard of an operation.
Action set (reactions to events)
Definition ActionSet.py:6