Peano
Loading...
Searching...
No Matches
PostprocessSolution.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 PostprocessSolution differs from other action sets, as I only create it once. See
13 FV.create_action_sets(). Once the instance does exist, you can tailor it. But you
14 can also completely overwrite it.
15
16 """
17 def __init__(self,solver):
18 AbstractRKFDActionSet.__init__(self,solver)
19 # Is there for compatibility reasons
20 self.guard = "true"
22
23
24 def get_body_of_operation(self,operation_name):
25 result = ""
26 return result
27
28
30 return __name__.replace(".py", "").replace(".", "_")
31
32
33
34
35
37 def __init__(self,solver,compute_kernel):
38 super(PatchWisePostprocessSolution,self).__init__(solver)
39 self.compute_kernel = compute_kernel
40
41
42 def get_body_of_operation(self,operation_name):
43 result = ""
44 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_LAST_TIME:
45 d = {}
46 self._solver._init_dictionary_with_default_parameters(d)
47 self._solver.add_entries_to_text_replacement_dictionary(d)
48 result = jinja2.Template(self.compute_kernel, undefined=jinja2.DebugUndefined).render(**d)
49 pass
50 return result
51
52
54 return __name__.replace(".py", "").replace(".", "_")
55
56
57
59 """!
60
61 Postprocess solution mesh cell by mesh cell without mesh cell interactions
62
63 PostprocessSolution differs from other action sets, as I only create it once. See
64 FV.create_action_sets(). Once the instance does exist, you can tailor it. But you
65 can also completely overwrite it.
66
67 The postprocessing plugs into touch cell last time. It is the last action set added
68 by the default implementation. Therefore, it is the first action set of which
69 touchCellLastTime() is called. The reason why I plug into the leaving of the cell
70 is that some solvers may add further action sets to the solve. Enclave tasking for
71 example adds the merger as additional action set. These action sets plug into
72 touchCellFirstTime() - and consequently their first time is called after the
73 postprocessing's first time. By making the postprocessing use touchCellLastTime(),
74 I ensure that any additional action set added by a subclass can still precede the
75 postprocessing.
76
77
78 """
79 def __init__(self,solver):
80 AbstractRKFDActionSet.__init__(self,solver)
81 self.guard = "true"
84
85
86 def add_postprocessing_kernel(self, operation_per_point):
87 """
88
89 Add a code snippet which is applied to each and every point. You have the following
90 variables which are well-defined:
91
92 - value: Is a pointer to the current finite volume's data
93 - volumeX: A tarch::la::Vector over doubles
94 - volumeH: A tarch::la::Vector over doubles
95
96
97 operation_per_point: String
98 C/C++ code snippet
99
100 """
101 self._compute_kernel += """
102 if (
103 not marker.hasBeenRefined()
104 and
105 {{PREDICATE}}
106 ) {
107 logTraceIn( "touchCellFirstTime(...)" );
108 int index = 0;
109 dfor( volume, {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}} ) {
110 double* value = fineGridCell{{UNKNOWN_IDENTIFIER}}.value + index;
111 auto volumeX = ::exahype2::fv::getVolumeCentre( marker.x(), marker.h(), {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}}, volume);
112 auto volumeH = ::exahype2::fv::getVolumeSize( marker.h(), {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}});
113
114 """ + operation_per_point + """
115
116 index += {{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}};
117 }
118 logTraceOut( "touchCellFirstTime(...)" );
119 }
120"""
121
122
123
124 def get_body_of_operation(self,operation_name):
125 result = ""
126 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_LAST_TIME:
127 d = {}
128 self._solver._init_dictionary_with_default_parameters(d)
129 self._solver.add_entries_to_text_replacement_dictionary(d)
130 d[ "PREDICATE" ] = jinja2.Template(self.guard, undefined=jinja2.DebugUndefined).render(**d)
131 result = jinja2.Template(self._compute_kernel, undefined=jinja2.DebugUndefined).render(**d)
132 pass
133 return result
134
135
137 return __name__.replace(".py", "").replace(".", "_")
Postprocess solution mesh cell by mesh cell without mesh cell interactions.
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.
add_postprocessing_kernel(self, operation_per_point)
Add a code snippet which is applied to each and every point.
PostprocessSolution differs from other action sets, as I only create it once.
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.
__init__(self, solver)
solver: ADERDG Reference to creating class
__init__(self, solver, compute_kernel)
solver: ADERDG Reference to creating class
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.