Peano
Loading...
Searching...
No Matches
SolveRiemannProblem.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 .AbstractLimiterActionSet import AbstractLimiterActionSet
5
6import peano4.solversteps
7import jinja2
9 TemplateCopyFaceData = """
10 if ( {{PREDICATE}} ) {
11
12 constexpr int RegularSolverPoints = {{REGULAR_SOLVER_ORDER}} + 1;
13 constexpr int LimiterSolverPoints = {{LIMITER_SOLVER_ORDER}} + 1;
14
15 constexpr int NumberOfVariables = repositories::{{REGULAR_SOLVER_INSTANCE}}.NumberOfUnknowns;
16 constexpr int NumberOfParameters = repositories::{{REGULAR_SOLVER_INSTANCE}}.NumberOfAuxiliaryVariables;
17
18 #if DIMENSIONS == 2
19 constexpr int RegularFaceSize = RegularSolverPoints;
20 constexpr int LimiterFaceSize = LimiterSolverPoints;
21 #else
22 constexpr int RegularFaceSize = RegularSolverPoints*RegularSolverPoints;
23 constexpr int LimiterFaceSize = LimiterSolverPoints*LimiterSolverPoints;
24 #endif
25
26 constexpr int FluxElementsPerFace = RegularFaceSize * NumberOfVariables;
27 constexpr int BasisElementsPerFace = RegularFaceSize * (NumberOfVariables + NumberOfParameters);
28
29 constexpr int FluxElementsPerFace2 = LimiterFaceSize * NumberOfVariables;
30 constexpr int BasisElementsPerFace2 = LimiterFaceSize * (NumberOfVariables + NumberOfParameters);
31
32 if(fineGridCell{{SOLVER_NAME}}CellLabel.getTroubled_Marker()==celldata::{{SOLVER_NAME}}CellLabel::Troubled_Marker::REGULAR){
33 for(int d=0; d<DIMENSIONS; d++){
34 if( fineGridFaces{{SOLVER_NAME}}FaceLabel(d).getTroubled_Marker()==facedata::{{SOLVER_NAME}}FaceLabel::Troubled_Marker::TROUBLED ){
35 //Regular face to Limiter
36 // Projected solution estimations
37 kernels::{{SOLVER_NAME}}::regularToLimiterFace(
38 fineGridFaces{{REGULAR_SOLVER_UNKNOWN_IDENTIFIER}}Estimates(d).value+BasisElementsPerFace,
39 fineGridFaces{{LIMITER_SOLVER_UNKNOWN_IDENTIFIER}}Estimates(d).value+BasisElementsPerFace2,
40 NumberOfVariables+NumberOfParameters
41 );
42 // Projected flux estimations
43 kernels::{{SOLVER_NAME}}::regularToLimiterFace(
44 fineGridFaces{{REGULAR_SOLVER_UNKNOWN_IDENTIFIER}}FluxEstimates(d).value+FluxElementsPerFace,
45 fineGridFaces{{LIMITER_SOLVER_UNKNOWN_IDENTIFIER}}FluxEstimates(d).value+FluxElementsPerFace2,
46 NumberOfVariables
47 );
48 }
49
50 if( fineGridFaces{{SOLVER_NAME}}FaceLabel(d+DIMENSIONS).getTroubled_Marker()==facedata::{{SOLVER_NAME}}FaceLabel::Troubled_Marker::TROUBLED ){
51 //Regular face to Limiter
52 // Projected solution estimations
53 kernels::{{SOLVER_NAME}}::regularToLimiterFace(
54 fineGridFaces{{REGULAR_SOLVER_UNKNOWN_IDENTIFIER}}Estimates(d+DIMENSIONS).value,
55 fineGridFaces{{LIMITER_SOLVER_UNKNOWN_IDENTIFIER}}Estimates(d+DIMENSIONS).value,
56 NumberOfVariables+NumberOfParameters
57 );
58 // Projected flux estimations
59 kernels::{{SOLVER_NAME}}::regularToLimiterFace(
60 fineGridFaces{{REGULAR_SOLVER_UNKNOWN_IDENTIFIER}}FluxEstimates(d+DIMENSIONS).value,
61 fineGridFaces{{LIMITER_SOLVER_UNKNOWN_IDENTIFIER}}FluxEstimates(d+DIMENSIONS).value,
62 NumberOfVariables
63 );
64 }
65
66 }
67 }
68 if(fineGridCell{{SOLVER_NAME}}CellLabel.getTroubled_Marker()==celldata::{{SOLVER_NAME}}CellLabel::Troubled_Marker::TROUBLED){
69 for(int d=0; d<DIMENSIONS; d++){
70
71 // Projected solution estimations
72 kernels::{{SOLVER_NAME}}::limiterToRegularFace(
73 fineGridFaces{{LIMITER_SOLVER_UNKNOWN_IDENTIFIER}}Estimates(d).value+BasisElementsPerFace2,
74 fineGridFaces{{REGULAR_SOLVER_UNKNOWN_IDENTIFIER}}Estimates(d).value+BasisElementsPerFace,
75 NumberOfVariables+NumberOfParameters
76 );
77 // Projected flux estimations
78 kernels::{{SOLVER_NAME}}::limiterToRegularFace(
79 fineGridFaces{{LIMITER_SOLVER_UNKNOWN_IDENTIFIER}}FluxEstimates(d).value+FluxElementsPerFace2,
80 fineGridFaces{{REGULAR_SOLVER_UNKNOWN_IDENTIFIER}}FluxEstimates(d).value+FluxElementsPerFace,
81 NumberOfVariables
82 );
83
84 // Projected solution estimations
85 kernels::{{SOLVER_NAME}}::limiterToRegularFace(
86 fineGridFaces{{LIMITER_SOLVER_UNKNOWN_IDENTIFIER}}Estimates(d+DIMENSIONS).value,
87 fineGridFaces{{REGULAR_SOLVER_UNKNOWN_IDENTIFIER}}Estimates(d+DIMENSIONS).value,
88 NumberOfVariables+NumberOfParameters
89 );
90 // Projected flux estimations
91 kernels::{{SOLVER_NAME}}::limiterToRegularFace(
92 fineGridFaces{{LIMITER_SOLVER_UNKNOWN_IDENTIFIER}}FluxEstimates(d+DIMENSIONS).value,
93 fineGridFaces{{REGULAR_SOLVER_UNKNOWN_IDENTIFIER}}FluxEstimates(d+DIMENSIONS).value,
94 NumberOfVariables
95 );
96 }
97 }
98
99 }
100 """
101
102 # TemplateCopyFaceData = """
103
104 # if ( {{PREDICATE}} ) {
105
106 # constexpr int Order = repositories::{{REGULAR_SOLVER_INSTANCE}}.Order;
107 # constexpr int NumberOfVariables = repositories::{{REGULAR_SOLVER_INSTANCE}}.NumberOfUnknowns;
108 # constexpr int NumberOfParameters = repositories::{{REGULAR_SOLVER_INSTANCE}}.NumberOfAuxiliaryVariables;
109
110 # #if DIMENSIONS==2
111 # constexpr int spaceFaceSize = (Order+1);
112 # #else
113 # constexpr int spaceFaceSize = (Order+1)*(Order+1);
114 # #endif
115
116 # constexpr int basisElementsPerFace = spaceFaceSize*(NumberOfVariables+NumberOfParameters);
117 # constexpr int fluxElementsPerFace = spaceFaceSize*NumberOfVariables;
118
119 # if(fineGridCell{{SOLVER_NAME}}CellLabel.getTroubled_Marker()==celldata::{{SOLVER_NAME}}CellLabel::Troubled_Marker::REGULAR){
120 # for(int d=0; d<DIMENSIONS; d++){
121 # if( fineGridFaces{{SOLVER_NAME}}FaceLabel(d).getTroubled_Marker()==facedata::{{SOLVER_NAME}}FaceLabel::Troubled_Marker::TROUBLED ){
122 # //Regular face to Limiter
123 # std::copy_n(fineGridFaces{{REGULAR_SOLVER_UNKNOWN_IDENTIFIER}}Estimates(d).value+basisElementsPerFace, basisElementsPerFace, fineGridFaces{{LIMITER_SOLVER_UNKNOWN_IDENTIFIER}}Estimates(d).value+basisElementsPerFace);
124 # std::copy_n(fineGridFaces{{REGULAR_SOLVER_UNKNOWN_IDENTIFIER}}FluxEstimates(d).value+fluxElementsPerFace, fluxElementsPerFace, fineGridFaces{{LIMITER_SOLVER_UNKNOWN_IDENTIFIER}}FluxEstimates(d).value+fluxElementsPerFace);
125 # }
126
127 # if( fineGridFaces{{SOLVER_NAME}}FaceLabel(d+DIMENSIONS).getTroubled_Marker()==facedata::{{SOLVER_NAME}}FaceLabel::Troubled_Marker::TROUBLED ){
128 # //Regular face to Limiter
129 # std::copy_n(fineGridFaces{{REGULAR_SOLVER_UNKNOWN_IDENTIFIER}}Estimates(d+DIMENSIONS).value, basisElementsPerFace, fineGridFaces{{LIMITER_SOLVER_UNKNOWN_IDENTIFIER}}Estimates(d+DIMENSIONS).value);
130 # std::copy_n(fineGridFaces{{REGULAR_SOLVER_UNKNOWN_IDENTIFIER}}FluxEstimates(d+DIMENSIONS).value, fluxElementsPerFace, fineGridFaces{{LIMITER_SOLVER_UNKNOWN_IDENTIFIER}}FluxEstimates(d+DIMENSIONS).value);
131 # }
132
133 # }
134 # }
135 # if(fineGridCell{{SOLVER_NAME}}CellLabel.getTroubled_Marker()==celldata::{{SOLVER_NAME}}CellLabel::Troubled_Marker::TROUBLED){
136 # for(int d=0; d<DIMENSIONS; d++){
137 # std::copy_n(fineGridFaces{{LIMITER_SOLVER_UNKNOWN_IDENTIFIER}}Estimates(d).value+basisElementsPerFace, basisElementsPerFace, fineGridFaces{{REGULAR_SOLVER_UNKNOWN_IDENTIFIER}}Estimates(d).value+basisElementsPerFace);
138 # std::copy_n(fineGridFaces{{LIMITER_SOLVER_UNKNOWN_IDENTIFIER}}FluxEstimates(d).value+fluxElementsPerFace, fluxElementsPerFace, fineGridFaces{{REGULAR_SOLVER_UNKNOWN_IDENTIFIER}}FluxEstimates(d).value+fluxElementsPerFace);
139
140 # std::copy_n(fineGridFaces{{LIMITER_SOLVER_UNKNOWN_IDENTIFIER}}Estimates(d+DIMENSIONS).value, basisElementsPerFace, fineGridFaces{{REGULAR_SOLVER_UNKNOWN_IDENTIFIER}}Estimates(d+DIMENSIONS).value);
141 # std::copy_n(fineGridFaces{{LIMITER_SOLVER_UNKNOWN_IDENTIFIER}}FluxEstimates(d+DIMENSIONS).value, fluxElementsPerFace, fineGridFaces{{REGULAR_SOLVER_UNKNOWN_IDENTIFIER}}FluxEstimates(d+DIMENSIONS).value);
142 # }
143 # }
144
145 # }"""
146
147 def __init__(self, solver, guard):
148 super(SolveRiemannProblem,self).__init__(solver)
149 self.guard = guard
150
151 def get_body_of_operation(self,operation_name):
152 result = ""
153 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_LAST_TIME:
154 d = {}
155 self._solver._init_dictionary_with_default_parameters(d)
156 self._solver.add_entries_to_text_replacement_dictionary(d)
157 d[ "PREDICATE"] = self.guard
158 result = jinja2.Template(self.TemplateCopyFaceData).render(**d)
159 pass
160 return result
161
163 return __name__.replace(".py", "").replace(".", "_")
164
165 def get_includes(self):
166 return ( super( SolveRiemannProblem, self).get_includes()
167 + """
168#include "kernels/""" + self._solver._name + """/Limiter.h"
169 """)
get_action_set_name(self)
You should replicate this function in each subclass, so you get meaningful action set names (otherwis...