Peano
Loading...
Searching...
No Matches
StaticLimitingAbstract.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 kernels::{{SOLVER_NAME}}::Quadrature<double>::initQuadratureNodesAndWeights();
25
26 {{CONSTRUCTOR_IMPLEMENTATION}}
27}
28
29{{NAMESPACE | join("::")}}::{{CLASSNAME}}::~{{CLASSNAME}}(){
30 kernels::{{SOLVER_NAME}}::Quadrature<double>::freeQuadratureNodesAndWeights();
31}
32
33double {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getMinTimeStamp(bool ofCurrentlyRunningGridSweep) const {
34 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMinTimeStamp();
35}
36
37double {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getMaxTimeStamp(bool ofCurrentlyRunningGridSweep) const {
38 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMaxTimeStamp();
39}
40
41double {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getMinTimeStepSize() const {
42 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMinTimeStepSize();
43}
44
45double {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getMaxTimeStepSize() const {
46 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMaxTimeStepSize();
47}
48
49double {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getMaxMeshSize() const {
50 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMaxMeshSize();
51}
52
53double {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getMinMeshSize() const {
54 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMinMeshSize();
55}
56
57{{NAMESPACE | join("::")}}::{{CLASSNAME}}::SolverState {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getSolverState() const {
58 return _solverState;
59}
60
61void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::startGridConstructionStep() {
62 assertion( _solverState == SolverState::GridConstruction );
63}
64
65void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::finishGridConstructionStep() {}
66
67void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::startGridInitialisationStep() {
68 _solverState = SolverState::GridInitialisation;
69}
70
71void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::finishGridInitialisationStep() {}
72
73void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::suspendSolversForOneGridSweep() {
74 _solverState = SolverState::Suspended;
75}
76
77void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::startTimeStep(
78 double globalMinTimeStamp,
79 double globalMaxTimeStamp,
80 double globalMinTimeStepSize,
81 double globalMaxTimeStepSize
82) {
83 switch (_solverState) {
84 case SolverState::GridConstruction:
85 _solverState = SolverState::GridInitialisation;
86 break;
87 case SolverState::GridInitialisation:
88 case SolverState::PlottingAfterGridInitialisation:
89 _solverState = SolverState::LimiterStatusSpreadingToNeighbours;
90 repositories::{{LIMITER_SOLVER_INSTANCE}}.suspendSolversForOneGridSweep();
91 repositories::{{REGULAR_SOLVER_INSTANCE}}.suspendSolversForOneGridSweep();
92 break;
93 case SolverState::LimiterStatusSpreadingToNeighbours:
94 repositories::{{LIMITER_SOLVER_INSTANCE}}.suspendSolversForOneGridSweep();
95 case SolverState::TimeStep:
96 case SolverState::Plotting:
97 case SolverState::Suspended:
98 _solverState = SolverState::TimeStep;
99 break;
100 }
101
102 {{START_TIME_STEP_IMPLEMENTATION}}
103
104 if (::tarch::mpi::Rank::getInstance().isGlobalMaster()) {
105 logInfo("startTimeStep(...)", "Solver {{SOLVER_NAME}}:");
106 logInfo("startTimeStep(...)", "total number of troubled cells: " << _totalNumberOfTroubledCells);
107 logInfo("startTimeStep(...)", "phase " + toString(_solverState) );
108 }
109}
110
111void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::finishTimeStep() {
112 if (isLastGridSweepOfTimeStep()) {
113 #ifdef Parallel
114 int newCellUpdates = _cellUpdates;
115
117 &newCellUpdates,
119 1, MPI_INT,
120 MPI_SUM,
122 );
123
124 if (_solverState == SolverState::LimiterStatusSpreadingToNeighbours) {
125 int newNumberOfTroubleCells = _totalNumberOfTroubledCells;
127 &newNumberOfTroubleCells,
129 1, MPI_INT,
130 MPI_SUM,
132 );
133 }
134 #endif
135
136 {{FINISH_TIME_STEP_IMPLEMENTATION}}
137 }
138}
139
140void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::startPlottingStep(
141 double globalMinTimeStamp,
142 double globalMaxTimeStamp,
143 double globalMinTimeStepSize,
144 double globalMaxTimeStepSize
145) {
146 if ( _solverState==SolverState::GridInitialisation) {
147 _solverState = SolverState::PlottingAfterGridInitialisation;
148 }
149 else {
150 _solverState = SolverState::Plotting;
151 }
152}
153
154
155void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::finishPlottingStep() {
156}
157
158
159std::string {{NAMESPACE | join("::")}}::{{CLASSNAME}}::toString(SolverState state) {
160 switch (state) {
161 case SolverState::GridConstruction:
162 return "grid-construction";
163 case SolverState::GridInitialisation:
164 return "grid-initialisation";
165 case SolverState::PlottingAfterGridInitialisation:
166 return "plotting-after-grid-initialisation";
167 case SolverState::LimiterStatusSpreadingToNeighbours:
168 return "limiter-status-spreading-to-neighbours";
169 case SolverState::TimeStep:
170 return "time-step";
171 case SolverState::Plotting:
172 return "plotting";
173 case SolverState::Suspended:
174 return "suspended";
175 }
176 return "<undef>";
177}
178
179
180bool {{NAMESPACE | join("::")}}::{{CLASSNAME}}::mayPlot() const {
181 return _solverState!=SolverState::LimiterStatusSpreadingToNeighbours;
182}
183
184
185bool {{NAMESPACE | join("::")}}::{{CLASSNAME}}::isFirstGridSweepOfTimeStep() const {
186 return (
187 _solverState!=SolverState::LimiterStatusSpreadingToNeighbours
188 and
189 repositories::{{REGULAR_SOLVER_INSTANCE}}.isFirstGridSweepOfTimeStep()
190 and
191 repositories::{{LIMITER_SOLVER_INSTANCE}}.isFirstGridSweepOfTimeStep()
192 );
193
194}
195
196
197bool {{NAMESPACE | join("::")}}::{{CLASSNAME}}::isLastGridSweepOfTimeStep() const {
198 return (
199 _solverState!=SolverState::LimiterStatusSpreadingToNeighbours
200 and
201 repositories::{{REGULAR_SOLVER_INSTANCE}}.isLastGridSweepOfTimeStep()
202 and
203 repositories::{{LIMITER_SOLVER_INSTANCE}}.isLastGridSweepOfTimeStep()
204 );
205}
206
207
208void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::startSimulation() {
209
210}
211
212
213void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::finishSimulation() {
214
215}
216
217
218void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::addTroubledCell(){
219 tarch::multicore::Lock lock(_semaphore);
221}
222int {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::getNumberOfTroubledCells() const {
224}
225
226
227{% if ADMISSIBILITY_IMPLEMENTATION!="<empty>" and ADMISSIBILITY_IMPLEMENTATION!="<user-defined>" %}
228bool {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::isPhysicallyAdmissible(
229 const double* const Q,
232 const double timeStamp
233){
234
235 {% if ADMISSIBILITY_IMPLEMENTATION!="<none>"%}
236 {{ADMISSIBILITY_IMPLEMENTATION}}
237 {% else %}
238 return true;
239 {% endif %}
240
241}
242{% endif %}
243
244{{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
_cellUpdates(0)
Log Device.
Definition Log.h:516
static Rank & getInstance()
This operation returns the singleton instance.
Definition Rank.cpp:539
void allReduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, std::function< void()> waitor=[]() -> void {})
Definition Rank.cpp:284
Create a lock around a boolean semaphore region.
Definition Lock.h:19
virtual void receiveDanglingMessages() override
Answer to MPI Messages.
static ServiceRepository & getInstance()
std::string toString(Filter filter)
Definition convert.cpp:170
tarch::logging::Log _log("exahype2::fv")
Definition idx.h:5
Simple vector class.
Definition Vector.h:150