Peano
Loading...
Searching...
No Matches
SolverDefinitions.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
3import jinja2
4
5
8 self,
9 flux_implementation,
10 ncp_implementation,
11 eigenvalues_implementation,
12 source_term_implementation,
13 material_parameters_implementation,
14 point_source_implementation,
15 is_linear,
16 computation_precisions,
17 pde_terms_without_state,
18 ):
19 self._flux_implementation = flux_implementation
20 self._ncp_implementation = ncp_implementation
21 self._eigenvalues_implementation = eigenvalues_implementation
22 self._source_term_implementation = source_term_implementation
23 self._material_parameters_implementation = material_parameters_implementation
24 self._point_source_implementation = point_source_implementation
25 self._is_linear = is_linear
26 self._computation_precisions = computation_precisions
27 self._pde_terms_without_state = pde_terms_without_state
28
30 Template_SinglePrecisions = jinja2.Template(
31 """
32{% if EIGENVALUES_IMPLEMENTATION=="<user-defined>" %}
33double {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::maxEigenvalue(
34 [[maybe_unused]] const {{COMPUTATION_PRECISIONS[0]}}* __restrict__ Q, // Q[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
35 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& x,
36 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& h,
37 [[maybe_unused]] double t,
38 [[maybe_unused]] double dt,
39 [[maybe_unused]] int normal
40) {
41 logTraceInWith3Arguments("maxEigenvalue(...)", x, t, normal);
42 // @todo implement
43 double maxEigenvalue = 1.0;
44 return maxEigenvalue;
45 logTraceOut("maxEigenvalue(...)");
46}
47{% endif %}
48
49{% if FLUX_IMPLEMENTATION=="<user-defined>" %}
50void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::flux(
51 [[maybe_unused]] const {{COMPUTATION_PRECISIONS[0]}}* __restrict__ Q, // Q[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
52 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& x,
53 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& h,
54 [[maybe_unused]] double t,
55 [[maybe_unused]] double dt,
56 [[maybe_unused]] int normal,
57 [[maybe_unused]] {{COMPUTATION_PRECISIONS[0]}}* __restrict__ F // F[{{NUMBER_OF_UNKNOWNS}}]
58) {
59 logTraceIn("flux(...)");
60 // @todo implement
61 logTraceOut("flux(...)");
62}
63{% endif %}
64
65{% if NCP_IMPLEMENTATION=="<user-defined>" %}
66void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::nonconservativeProduct(
67 [[maybe_unused]] const {{COMPUTATION_PRECISIONS[0]}}* __restrict__ Q, // Q[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
68 [[maybe_unused]] const {{COMPUTATION_PRECISIONS[0]}}* __restrict__ deltaQ, // deltaQ[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
69 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& x,
70 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& h,
71 [[maybe_unused]] double t,
72 [[maybe_unused]] double dt,
73 [[maybe_unused]] int normal,
74 [[maybe_unused]] {{COMPUTATION_PRECISIONS[0]}}* __restrict__ BTimesDeltaQ // BTimesDeltaQ[{{NUMBER_OF_UNKNOWNS}}]
75) {
76 logTraceInWith3Arguments("nonconservativeProduct(...)", x, t, normal);
77 // @todo implement
78 logTraceOut("nonconservativeProduct(...)");
79}
80{% endif %}
81
82{% if SOURCE_TERM_IMPLEMENTATION=="<user-defined>" %}
83void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::algebraicSource(
84 [[maybe_unused]] const {{COMPUTATION_PRECISIONS[0]}}* const Q, // Q[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
85 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& x,
86 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& h,
87 [[maybe_unused]] double t,
88 [[maybe_unused]] double dt,
89 [[maybe_unused]] {{COMPUTATION_PRECISIONS[0]}}* S
90) {
91 logTraceInWith6Arguments("algebraicSource(...)", Q, x, h, t, dt, S);
92 // @todo implement
93 logTraceOut("algebraicSource(...)");
94}
95{% endif %}
96
97{% if MATERIAL_PARAM_IMPLEMENTATION=="<user-defined>" %}
98void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::multiplyMaterialParameterMatrix(
99 [[maybe_unused]] const {{COMPUTATION_PRECISIONS[0]}}* const Q,
100 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& x,
101 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& h,
102 [[maybe_unused]] double t,
103 [[maybe_unused]] double dt,
104 [[maybe_unused]] int normal,
105 [[maybe_unused]] {{COMPUTATION_PRECISIONS[0]}}* const rhs
106) {
107 // @todo implement
108}
109{% endif %}
110
111{% if POINT_SOURCE_IMPLEMENTATION!="<none>" %}
112void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::initPointSourceLocations(
113 [[maybe_unused]] double sourceLocation[NumberOfPointSources][Dimensions]
114) {
115 // @todo implement
116}
117{% endif %}
118
119{% if POINT_SOURCE_IMPLEMENTATION=="<user-defined>" %}
120void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::pointSource(
121 [[maybe_unused]] const {{COMPUTATION_PRECISIONS[0]}}* const Q, // Q[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
122 [[maybe_unused]] const double* const x,
123 [[maybe_unused]] const double t,
124 [[maybe_unused]] const double dt,
125 [[maybe_unused]] {{COMPUTATION_PRECISIONS[0]}}* const forceVector, // forceVector[{{NUMBER_OF_UNKNOWNS}}
126 [[maybe_unused]] int n
127) {
128 // @todo implement
129}
130{% endif %}
131""",
132 undefined=jinja2.DebugUndefined,
133 )
134
135 Template_MultiplePrecisions = jinja2.Template(
136 """
137{% if EIGENVALUES_IMPLEMENTATION=="<user-defined>" %}
138template <typename T>
139double {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::maxEigenvalue(
140 [[maybe_unused]] const T* __restrict__ Q, // Q[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
141 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& x,
142 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& h,
143 [[maybe_unused]] double t,
144 [[maybe_unused]] double dt,
145 [[maybe_unused]] int normal
146) {
147 logTraceInWith3Arguments("maxEigenvalue(...)", x, t, normal);
148 // @todo implement
149 logTraceOut("maxEigenvalue(...)");
150}
151
152{% for PRECISION_NUM in range(0,COMPUTATION_PRECISIONS|length) %}
153template double {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::maxEigenvalue(
154 [[maybe_unused]] const {{COMPUTATION_PRECISIONS[PRECISION_NUM]}}* __restrict__ Q, // Q[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
155 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& x,
156 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& h,
157 [[maybe_unused]] double t,
158 [[maybe_unused]] double dt,
159 [[maybe_unused]] int normal
160);
161{% endfor%}
162{% endif %}
163
164{% if FLUX_IMPLEMENTATION=="<user-defined>" %}
165template <typename T>
166void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::flux(
167 [[maybe_unused]] const T* __restrict__ Q, // Q[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
168 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& x,
169 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& h,
170 [[maybe_unused]] double t,
171 [[maybe_unused]] double dt,
172 [[maybe_unused]] int normal,
173 [[maybe_unused]] T* __restrict__ F // F[{{NUMBER_OF_UNKNOWNS}}]
174) {
175 logTraceIn( "flux(...)");
176 // @todo implement
177 logTraceOut( "flux(...)" );
178}
179
180{% for PRECISION_NUM in range(0,COMPUTATION_PRECISIONS|length) %}
181template void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::flux(
182 [[maybe_unused]] const {{COMPUTATION_PRECISIONS[PRECISION_NUM]}}* __restrict__ Q,
183 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& x,
184 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& h,
185 [[maybe_unused]] double t,
186 [[maybe_unused]] double dt,
187 [[maybe_unused]] int normal,
188 [[maybe_unused]] {{COMPUTATION_PRECISIONS[PRECISION_NUM]}}* __restrict__ F
189);
190{% endfor%}
191{% endif %}
192
193{% if NCP_IMPLEMENTATION=="<user-defined>" %}
194template <typename T>
195void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::nonconservativeProduct(
196 [[maybe_unused]] const T* __restrict__ Q, // Q[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
197 [[maybe_unused]] const T* __restrict__ deltaQ, // deltaQ[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
198 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& x,
199 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& h,
200 [[maybe_unused]] double t,
201 [[maybe_unused]] double dt,
202 [[maybe_unused]] int normal,
203 [[maybe_unused]] T* __restrict__ BTimesDeltaQ // BTimesDeltaQ[{{NUMBER_OF_UNKNOWNS}}]
204) {
205 logTraceInWith3Arguments("nonconservativeProduct(...)", x, t, normal);
206 // @todo implement
207 logTraceOut("nonconservativeProduct(...)");
208}
209
210{% for PRECISION_NUM in range(0,COMPUTATION_PRECISIONS|length) %}
211template void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::nonconservativeProduct(
212 [[maybe_unused]] const {{COMPUTATION_PRECISIONS[PRECISION_NUM]}}* __restrict__ Q,
213 [[maybe_unused]] const {{COMPUTATION_PRECISIONS[PRECISION_NUM]}}* __restrict__ deltaQ,
214 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& x,
215 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& h,
216 [[maybe_unused]] double t,
217 [[maybe_unused]] double dt,
218 [[maybe_unused]] int normal,
219 [[maybe_unused]] {{COMPUTATION_PRECISIONS[PRECISION_NUM]}}* __restrict__ BTimesDeltaQ
220);
221{% endfor%}
222{% endif %}
223
224{% if SOURCE_TERM_IMPLEMENTATION=="<user-defined>" %}
225template <typename T>
226void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::algebraicSource(
227 [[maybe_unused]] const T* const Q, // Q[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
228 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& x,
229 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& h,
230 [[maybe_unused]] double t,
231 [[maybe_unused]] double dt,
232 [[maybe_unused]] T* S
233) {
234 logTraceInWith6Arguments("algebraicSource(...)", Q, x, h, t, dt, S);
235 // @todo implement
236 logTraceOut("algebraicSource(...)");
237}
238
239{% for PRECISION_NUM in range(0,COMPUTATION_PRECISIONS|length) %}
240template void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::algebraicSource(
241 [[maybe_unused]] const {{COMPUTATION_PRECISIONS[PRECISION_NUM]}}* const Q,
242 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& x,
243 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& h,
244 [[maybe_unused]] double t,
245 [[maybe_unused]] double dt,
246 [[maybe_unused]] {{COMPUTATION_PRECISIONS[PRECISION_NUM]}}* S
247);
248{% endfor%}
249{% endif %}
250
251{% if MATERIAL_PARAM_IMPLEMENTATION=="<user-defined>" %}
252template <typename T>
253void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::multiplyMaterialParameterMatrix(
254 [[maybe_unused]] const T* const Q,
255 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& x,
256 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& h,
257 [[maybe_unused]] double t,
258 [[maybe_unused]] double dt,
259 [[maybe_unused]] int normal,
260 [[maybe_unused]] T* const rhs
261) {
262 // @todo implement
263}
264
265{% for PRECISION_NUM in range(0,COMPUTATION_PRECISIONS|length) %}
266template void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::multiplyMaterialParameterMatrix(
267 [[maybe_unused]] const {{COMPUTATION_PRECISIONS[PRECISION_NUM]}}* const Q,
268 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& x,
269 [[maybe_unused]] const tarch::la::Vector<Dimensions, double>& h,
270 [[maybe_unused]] double t,
271 [[maybe_unused]] double dt,
272 [[maybe_unused]] int normal,
273 [[maybe_unused]] {{COMPUTATION_PRECISIONS[PRECISION_NUM]}}* const rhs
274);
275{% endfor%}
276{% endif %}
277
278{% if POINT_SOURCE_IMPLEMENTATION!="<none>" %}
279void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::initPointSourceLocations(
280 [[maybe_unused]] double sourceLocation[NumberOfPointSources][Dimensions]
281) {
282 // @todo implement
283}
284{% endif %}
285
286{% if POINT_SOURCE_IMPLEMENTATION=="<user-defined>" %}
287template <typename T>
288void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::pointSource(
289 [[maybe_unused]] const T* const Q, // Q[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
290 [[maybe_unused]] const double* const x,
291 [[maybe_unused]] const double t,
292 [[maybe_unused]] const double dt,
293 [[maybe_unused]] T* const forceVector, // forceVector[{{NUMBER_OF_UNKNOWNS}}
294 [[maybe_unused]] int n
295) {
296 // @todo implement
297}
298
299{% for PRECISION_NUM in range(0,COMPUTATION_PRECISIONS|length) %}
300template void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::pointSource(
301 [[maybe_unused]] const {{COMPUTATION_PRECISIONS[PRECISION_NUM]}}* const Q,
302 [[maybe_unused]] const double* const x,
303 [[maybe_unused]] const double t,
304 [[maybe_unused]] const double dt,
305 [[maybe_unused]] {{COMPUTATION_PRECISIONS[PRECISION_NUM]}}* const forceVector,
306 [[maybe_unused]] int n
307);
308{% endfor%}
309{% endif %}
310""",
311 undefined=jinja2.DebugUndefined,
312 )
313
314 d = {}
315 d["FLUX_IMPLEMENTATION"] = self._flux_implementation
316 d["NCP_IMPLEMENTATION"] = self._ncp_implementation
317 d["EIGENVALUES_IMPLEMENTATION"] = self._eigenvalues_implementation
318 d["SOURCE_TERM_IMPLEMENTATION"] = self._source_term_implementation
319 d["MATERIAL_PARAM_IMPLEMENTATION"] = self._material_parameters_implementation
320 d["POINT_SOURCE_IMPLEMENTATION"] = self._point_source_implementation
321 d["IS_LINEAR"] = self._is_linear
322 d["COMPUTATION_PRECISIONS"] = self._computation_precisions
323 d["STATELESS_PDE_TERMS"] = self._pde_terms_without_state
324
325 if len(self._computation_precisions) > 1:
326 return Template_MultiplePrecisions.render(**d)
327 else:
328 return Template_SinglePrecisions.render(**d)
__init__(self, flux_implementation, ncp_implementation, eigenvalues_implementation, source_term_implementation, material_parameters_implementation, point_source_implementation, is_linear, computation_precisions, pde_terms_without_state)