Peano 4
Loading...
Searching...
No Matches
PosterioriLimitingAbstract.template.cpp
Go to the documentation of this file.
1// **********************************************************************************************
2// *** !!!WARNING!!! ***
3// *** WARNING: AUTO GENERATED FILE! DO NOT MODIFY BY HAND! YOUR CHANGES WILL BE OVERWRITTEN! ***
4// *** !!!WARNING!!! ***
5// *** Generated by Peano's Python API: www.peano-framework.org ***
6// **********************************************************************************************
7#include "{{CLASSNAME}}.h"
8
9#include <algorithm>
10
11#include "Constants.h"
12
14
15#include "repositories/SolverRepository.h"
16
17tarch::logging::Log {{NAMESPACE | join("::")}}::{{CLASSNAME}}::{{CLASSNAME}}::_log( "{{NAMESPACE | join("::")}}::{{CLASSNAME}}::{{CLASSNAME}}" );
18
19{{NAMESPACE | join("::")}}::{{CLASSNAME}}::{{CLASSNAME}}():
20 _solverState(SolverState::GridConstruction),
23
24 generated::kernels::limiter::Quadrature<double>::initQuadratureNodesAndWeights();
25
26 {{CONSTRUCTOR_IMPLEMENTATION}}
27
28}
29
30{{NAMESPACE | join("::")}}::{{CLASSNAME}}::~{{CLASSNAME}}(){
31
32 generated::kernels::limiter::Quadrature<double>::freeQuadratureNodesAndWeights();
33
34}
35
36
37double {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getMinTimeStamp(bool ofCurrentlyRunningGridSweep) const {
38 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMinTimeStamp();
39}
40
41
42double {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getMaxTimeStamp(bool ofCurrentlyRunningGridSweep) const {
43 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMaxTimeStamp();
44}
45
46
47double {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getMinTimeStepSize() const {
48 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMinTimeStepSize();
49}
50
51
52double {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getMaxTimeStepSize() const {
53 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMaxTimeStepSize();
54}
55
56
57double {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getMaxMeshSize() const {
58 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMaxMeshSize();
59}
60
61
62double {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getMinMeshSize() const {
63 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMinMeshSize();
64}
65
66
67{{NAMESPACE | join("::")}}::{{CLASSNAME}}::SolverState {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getSolverState() const {
68 return _solverState;
69}
70
71
72void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::startGridConstructionStep() {
73 assertion( _solverState == SolverState::GridConstruction );
74}
75
76
77void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::finishGridConstructionStep() {
78}
79
80
81void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::startGridInitialisationStep() {
82 _solverState = SolverState::GridInitialisation;
83}
84
85
86void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::finishGridInitialisationStep() {
87
88}
89
90
91void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::suspendSolversForOneGridSweep() {
92 _solverState = SolverState::Suspended;
93}
94
95
96void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::startTimeStep(
97 double globalMinTimeStamp,
98 double globalMaxTimeStamp,
99 double globalMinTimeStepSize,
100 double globalMaxTimeStepSize
101) {
102 switch (_solverState) {
103 case SolverState::GridConstruction:
104 _solverState = SolverState::GridInitialisation;
105 break;
106 case SolverState::GridInitialisation:
107 case SolverState::Suspended:
108 case SolverState::Plotting:
109 case SolverState::RegularSolver:
111 SolverState::RegularSolver : SolverState::LimiterStatusSpreadingToNeighbours);
112 break;
113 case SolverState::LimiterStatusSpreadingToNeighbours:
114 _solverState = SolverState::LimiterStatusSpreadingToSecondNeighbours;
115 break;
116 case SolverState::LimiterStatusSpreadingToSecondNeighbours:
117 _solverState = SolverState::LimiterSolver;
118 break;
119 case SolverState::LimiterSolver:
120 _solverState = SolverState::RegularSolver;
121 break;
122 }
123
124 if (_solverState==SolverState::RegularSolver) {
125
126 _cellUpdates = 0;
128
129 }
130
131 {{START_TIME_STEP_IMPLEMENTATION}}
132
133
134 if (_solverState==SolverState::RegularSolver) {
135 repositories::{{LIMITER_SOLVER_INSTANCE}}.suspendSolversForOneGridSweep();
136
137 _cellUpdates = 0;
139 }
140
141 if (_solverState==SolverState::LimiterSolver) {
142 repositories::{{REGULAR_SOLVER_INSTANCE}}.suspendSolversForOneGridSweep();
143 }
144
145 if(_solverState==SolverState::LimiterStatusSpreadingToNeighbours
146 or _solverState==SolverState::LimiterStatusSpreadingToSecondNeighbours
147 ){
148 repositories::{{LIMITER_SOLVER_INSTANCE}}.suspendSolversForOneGridSweep();
149 repositories::{{REGULAR_SOLVER_INSTANCE}}.suspendSolversForOneGridSweep();
150 }
151
152 if (
154// and ( _solverState==SolverState::RegularSolver or _solverState==SolverState::LimiterSolver )
155 ) {
156
157 logInfo( "startTimeStep(...)", "LIMITING SOLVER" );
158 logInfo( "startTimeStep(...)", "phase " + toString(_solverState) );
159 logInfo( "startTimeStep()", "total number of troubled cells: = " << _numberOfTroubledCellsThisTimeStep );
160 logInfo( "startTimeStep(...)", "LIMITING SOLVER\n" );
161
162 // if(_numberOfTroubledCellsThisTimeStep>0){
163 // ::exahype2::triggerNonCriticalAssertion( __FILE__, __LINE__, "_numberOfTroubledCellsThisTimeStep>0", "_numberOfTroubledCellsThisTimeStep: " + std::to_string(_numberOfTroubledCellsThisTimeStep) );
164 // }
165 }
166
167
168}
169
170
171void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::finishTimeStep() {
172 if ( isLastGridSweepOfTimeStep() ) {
173
174 #ifdef Parallel
175
176 int newCellUpdates = _cellUpdates;
177 int newNumberOfTroubleCells = _numberOfTroubledCellsThisTimeStep;
178
180 &newCellUpdates,
182 1, MPI_INT,
183 MPI_SUM,
185 );
186
188 &newNumberOfTroubleCells,
190 1, MPI_INT,
191 MPI_SUM,
193 );
194 #endif
195
196 {{FINISH_TIME_STEP_IMPLEMENTATION}}
197
198 }
199}
200
201
202void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::startPlottingStep(
203 double globalMinTimeStamp,
204 double globalMaxTimeStamp,
205 double globalMinTimeStepSize,
206 double globalMaxTimeStepSize
207) {
208 assertion( mayPlot() );
209 _solverState = SolverState::Plotting;
210}
211
212
213void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::finishPlottingStep() {
214}
215
216
217std::string {{NAMESPACE | join("::")}}::{{CLASSNAME}}::toString(SolverState state) {
218 switch (state) {
219 case SolverState::GridConstruction:
220 return "grid-construction";
221 case SolverState::GridInitialisation:
222 return "grid-initialisation";
223 case SolverState::RegularSolver:
224 return "regular (non-limiting) solver";
225 case SolverState::LimiterStatusSpreadingToNeighbours:
226 return "limiter status spreading to neighbours";
227 case SolverState::LimiterStatusSpreadingToSecondNeighbours:
228 return "limiter status spreading to second neighbours";
229 case SolverState::LimiterSolver:
230 return "limiting solver";
231 case SolverState::Plotting:
232 return "plotting";
233 case SolverState::Suspended:
234 return "suspended";
235 }
236 return "<undef>";
237}
238
239
240bool {{NAMESPACE | join("::")}}::{{CLASSNAME}}::mayPlot() const {
241 return
242 (
243 (
244 _solverState==SolverState::GridInitialisation
245 or
246 _solverState==SolverState::RegularSolver
247 and repositories::{{REGULAR_SOLVER_INSTANCE}}.mayPlot()
249 )
250 or
251 (
252 _solverState==SolverState::LimiterSolver and
253 repositories::{{LIMITER_SOLVER_INSTANCE}}.mayPlot()
254 )
255 );
256}
257
258
259bool {{NAMESPACE | join("::")}}::{{CLASSNAME}}::isFirstGridSweepOfTimeStep() const {
260 return (
261 ( _solverState==SolverState::RegularSolver and repositories::{{REGULAR_SOLVER_INSTANCE}}.isFirstGridSweepOfTimeStep() )
262 or
263 ( _solverState==SolverState::LimiterSolver and repositories::{{LIMITER_SOLVER_INSTANCE}}.isFirstGridSweepOfTimeStep() )
264 );
265
266}
267
268
269bool {{NAMESPACE | join("::")}}::{{CLASSNAME}}::isLastGridSweepOfTimeStep() const {
270 return (
271 ( _solverState==SolverState::RegularSolver and repositories::{{REGULAR_SOLVER_INSTANCE}}.isLastGridSweepOfTimeStep() )
272 or
273 ( _solverState==SolverState::LimiterSolver and repositories::{{LIMITER_SOLVER_INSTANCE}}.isLastGridSweepOfTimeStep() )
274 );
275}
276
277
278void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::startSimulation() {
279
280}
281
282
283void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::finishSimulation() {
284
285}
286
287
288void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::addTroubledCell(){
290}
291int {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::getNumberOfTroubledCells() const {
293}
294
295
296{% if ADMISSIBILITY_IMPLEMENTATION!="<empty>" and ADMISSIBILITY_IMPLEMENTATION!="<user-defined>" %}
297bool {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::isPhysicallyAdmissible(
298 const double* const Q,
301 const double timeStamp
302){
303
304 {% if ADMISSIBILITY_IMPLEMENTATION!="<none>"%}
305 {{ADMISSIBILITY_IMPLEMENTATION}}
306 {% else %}
307 return true;
308 {% endif %}
309
310}
311{% endif %}
312
313
314{{SOLVER_USER_DEFINITIONS}}
#define assertion(expr)
AutomatonState state
#define logInfo(methodName, logMacroMessageStream)
Wrapper macro around tarch::tarch::logging::Log to improve logging.
Definition Log.h:411
_solverState(SolverState::GridConstruction)
_cellUpdates(0)
Log Device.
Definition Log.h:516
bool isGlobalMaster() const
Is this node the global master process, i.e.
Definition Rank.cpp:419
static Rank & getInstance()
This operation returns the singleton instance.
Definition Rank.cpp:538
void allReduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, std::function< void()> waitor=[]() -> void {})
Definition Rank.cpp:279
virtual void receiveDanglingMessages() override
Answer to MPI Messages.
static ServiceRepository & getInstance()
std::string toString(Filter filter)
Definition convert.cpp:170
tarch::logging::Log _log("examples::unittests")
Simple vector class.
Definition Vector.h:134