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