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 .AbstractRungeKuttaDGActionSet import AbstractRungeKuttaDGActionSet
5
6
7import peano4
8import jinja2
9
10
12 """
13
14 PostprocessSolution differs from other action sets, as I only create it once. See
15 FV.create_action_sets(). Once the instance does exist, you can tailor it. But you
16 can also completely overwrite it.
17
18 """
19
20 def __init__(self, solver):
21 super(EmptyPostprocessSolution, self).__init__(solver)
22 # Is there for compatibility reasons
23 self.guard = "true"
24
25 def get_body_of_operation(self, operation_name):
26 result = ""
27 return result
28
30 return __name__.replace(".py", "").replace(".", "_")
31
32
34 """
35
36 PostprocessSolution differs from other action sets, as I only create it once. See
37 FV.create_action_sets(). Once the instance does exist, you can tailor it. But you
38 can also completely overwrite it.
39
40 The postprocessing plugs into touch cell last time. It is the last action set added
41 by the default implementation. Therefore, it is the first action set of which
42 touchCellLastTime() is called. The reason why I plug into the leaving of the cell
43 is that some solvers may add further action sets to the solve. Enclave tasking for
44 example adds the merger as additional action set. These action sets plug into
45 touchCellFirstTime() - and consequently their first time is called after the
46 postprocessing's first time. By making the postprocessing use touchCellLastTime(),
47 I ensure that any additional action set added by a subclass can still precede the
48 postprocessing.
49
50 """
51
52 def __init__(self, solver):
53 super(DoFWisePostprocessSolution, self).__init__(solver)
54 self.guard = "true"
57
58 def add_postprocessing_kernel(self, operation_per_point):
59 """
60
61 Add a code snippet which is applied to each and every point. You have the following
62 variables which are well-defined:
63
64 - value: Is a pointer to the current finite volume's data
65 - x: A tarch::la::Vector over doubles
66 - marker.h(): A tarch::la::Vector over doubles
67
68
69 operation_per_point: String
70 C/C++ code snippet
71
72 """
73 self._compute_kernel += (
74 """
75{
76 {{COMPUTE_TIME_STEP_SIZE}}
77 const double timeStamp = fineGridCell{{SOLVER_NAME}}CellLabel.getTimeStamp();
78
79 if (
80 not marker.hasBeenRefined()
81 and
82 {{PREDICATE}}
83 ) {
84 logTraceIn( "touchCellFirstTime(...)" );
85
86 ::exahype2::enumerator::AoSLexicographicEnumerator enumerator(
87 1, // only one patch
88 {{DG_ORDER}}+1,
89 0, // int haloSize,
90 {{NUMBER_OF_UNKNOWNS}},
91 {{NUMBER_OF_AUXILIARY_VARIABLES}}
92 );
93 dfor( index, {{DG_ORDER}}+1 ) {
94 double* values = fineGridCell{{UNKNOWN_IDENTIFIER}}.value + enumerator(0,index,0);
95 auto x = ::exahype2::dg::getQuadraturePoint(
96 marker.x(), marker.h(), index, repositories::{{SOLVER_INSTANCE}}.DGOrder, repositories::{{SOLVER_INSTANCE}}.QuadraturePoints1d
97 );
98 """
99 + operation_per_point
100 + """
101 }
102 logTraceOut( "touchCellFirstTime(...)" );
103 }
104}
105"""
106 )
107
108 def get_body_of_operation(self, operation_name):
109 result = ""
110 if (
111 operation_name
112 == peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_LAST_TIME
113 ):
114 d = {}
115 self._solver._init_dictionary_with_default_parameters(d)
116 self._solver.add_entries_to_text_replacement_dictionary(d)
117 d["PREDICATE"] = jinja2.Template(
118 self.guard, undefined=jinja2.DebugUndefined
119 ).render(**d)
120 result = jinja2.Template(
121 self._compute_kernel, undefined=jinja2.DebugUndefined
122 ).render(**d)
123 pass
124 return result
125
127 return __name__.replace(".py", "").replace(".", "_")
128
129 def get_includes(self):
130 return (
131 super(DoFWisePostprocessSolution, self).get_includes()
132 + """
133#include "exahype2/enumerator/AoSLexicographicEnumerator.h"
134"""
135 )
136
137
139 """ """
140
141 def __init__(self, solver):
142 super(CellWisePostprocessSolution, self).__init__(solver)
143 self.guard = "true"
145
146 def add_postprocessing_kernel(self, operation_per_cell):
147 """
148
149 Add a code snippet which is applied to each and every point. You have the following
150 variables which are well-defined:
151
152 - value: Is a pointer to the current finite volume's data
153 - x: A tarch::la::Vector over doubles
154 - marker.h(): A tarch::la::Vector over doubles
155
156
157 operation_per_point: String
158 C/C++ code snippet
159
160 """
161 self._compute_kernel += (
162 """
163{
164 {{COMPUTE_TIME_STEP_SIZE}}
165 const double timeStamp = fineGridCell{{SOLVER_NAME}}CellLabel.getTimeStamp();
166
167 if (
168 not marker.hasBeenRefined()
169 and
170 {{PREDICATE}}
171 ) {
172 logTraceIn( "touchCellFirstTime(...)" );
173
174 """
175 + operation_per_cell
176 + """
177
178 logTraceOut( "touchCellFirstTime(...)" );
179 }
180}
181"""
182 )
183
184 def get_body_of_operation(self, operation_name):
185 result = ""
186 if (
187 operation_name
188 == peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_LAST_TIME
189 ):
190 d = {}
191 self._solver._init_dictionary_with_default_parameters(d)
192 self._solver.add_entries_to_text_replacement_dictionary(d)
193 d["PREDICATE"] = jinja2.Template(
194 self.guard, undefined=jinja2.DebugUndefined
195 ).render(**d)
196 result = jinja2.Template(
197 self._compute_kernel, undefined=jinja2.DebugUndefined
198 ).render(**d)
199 pass
200 return result
201
203 return __name__.replace(".py", "").replace(".", "_")
__init__(self, solver)
solver: RungeKuttaDG 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.
add_postprocessing_kernel(self, operation_per_cell)
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...
__init__(self, solver)
solver: RungeKuttaDG Reference to creating class
add_postprocessing_kernel(self, operation_per_point)
Add a code snippet which is applied to each and every point.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
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...
__init__(self, solver)
solver: RungeKuttaDG Reference to creating class
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.