Peano
Loading...
Searching...
No Matches
StaticCouplingAbstract.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
13#include "tarch/multicore/Lock.h"
14#include "tarch/services/ServiceRepository.h"
15
16#include "repositories/SolverRepository.h"
17
18
19tarch::logging::Log {{NAMESPACE | join("::")}}::{{CLASSNAME}}::_log( "{{NAMESPACE | join("::")}}::{{CLASSNAME}}" );
20
21{{NAMESPACE | join("::")}}::{{CLASSNAME}}::{{CLASSNAME}}():
22 _solverState(SolverState::GridConstruction),
25
26 {{CONSTRUCTOR_IMPLEMENTATION}}
27
28}
29
30{{NAMESPACE | join("::")}}::{{CLASSNAME}}::~{{CLASSNAME}}(){
31
32}
33
34
35double {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getMinTimeStamp() const {
36 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMinTimeStamp();
37}
38
39
40double {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getMaxTimeStamp() const {
41 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMaxTimeStamp();
42}
43
44
45double {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getMinTimeStepSize() const {
46 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMinTimeStepSize();
47}
48
49
50double {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getMaxTimeStepSize() const {
51 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMaxTimeStepSize();
52}
53
54
55double {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getMaxMeshSize() const {
56 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMaxMeshSize();
57}
58
59
60double {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getMinMeshSize() const {
61 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMinMeshSize();
62}
63
64int {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getNumberOfDoFs() const {
65 return 0;
66}
67
68{{NAMESPACE | join("::")}}::{{CLASSNAME}}::SolverState {{NAMESPACE | join("::")}}::{{CLASSNAME}}::getSolverState() const {
69 return _solverState;
70}
71
72
73void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::startGridConstructionStep() {
74 assertion( _solverState == SolverState::GridConstruction );
75}
76
77
78void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::finishGridConstructionStep() {
79}
80
81
82void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::startGridInitialisationStep() {
83 _solverState = SolverState::GridInitialisation;
84}
85
86
87void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::finishGridInitialisationStep() {
88
89}
90
91
92void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::suspendSolversForOneGridSweep() {
93 _solverState = SolverState::Suspended;
94}
95
96
97void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::startTimeStep() {
98 switch (_solverState) {
99 case SolverState::GridConstruction:
100 _solverState = SolverState::GridInitialisation;
101 break;
102 case SolverState::GridInitialisation:
103 case SolverState::PlottingAfterGridInitialisation:
104 // _solverState = SolverState::LimiterStatusSpreadingToNeighbours;
105 // break;
106 case SolverState::LimiterStatusSpreadingToNeighbours:
107 case SolverState::TimeStepping:
108 case SolverState::Plotting:
109 case SolverState::Suspended:
110 _solverState = SolverState::TimeStepping;
111 break;
112 }
113
114 {{START_TIME_STEP_IMPLEMENTATION}}
115
116 if(_solverState==SolverState::LimiterStatusSpreadingToNeighbours){
117 repositories::{{REGULAR_SOLVER_INSTANCE}}.suspendSolversForOneGridSweep();
118 repositories::{{LIMITER_SOLVER_INSTANCE}}.suspendSolversForOneGridSweep();
119 }
120
121}
122
123
124void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::finishTimeStep() {
125 if ( isLastGridSweepOfTimeStep() ) {
126
127 #ifdef WITH_MPI
128
129 int newCellUpdates = _cellUpdates;
130
131 tarch::mpi::Rank::getInstance().allReduce(
132 &newCellUpdates,
134 1, MPI_INT,
135 MPI_SUM,
136 [&]() -> void { tarch::services::ServiceRepository::getInstance().receiveDanglingMessages(); }
137 );
138
139 if(_solverState==SolverState::LimiterStatusSpreadingToNeighbours){
140 int newNumberOfTroubleCells = _totalNumberOfTroubledCells;
141 tarch::mpi::Rank::getInstance().allReduce(
142 &newNumberOfTroubleCells,
144 1, MPI_INT,
145 MPI_SUM,
146 [&]() -> void { tarch::services::ServiceRepository::getInstance().receiveDanglingMessages(); }
147 );
148 }
149
150 #endif
151
152 {{FINISH_TIME_STEP_IMPLEMENTATION}}
153
154 }
155}
156
157
158void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::printTimeStep() {
159 {{PRINT_TIME_STEP_IMPLEMENTATION}}
160
161 if (getNumberOfTroubledCells() > 0) {
162 logInfo("printTimeStep()", "Solver {{SOLVER_NAME}}:");
163 logInfo("printTimeStep()", "Number of troubled cells: " << getNumberOfTroubledCells());
164 }
165}
166
167
168void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::startPlottingStep(){
169 if ( _solverState==SolverState::GridInitialisation) {
170 _solverState = SolverState::PlottingAfterGridInitialisation;
171 }
172 else {
173 _solverState = SolverState::Plotting;
174 }
175}
176
177
178void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::finishPlottingStep() {
179}
180
181
182std::string {{NAMESPACE | join("::")}}::{{CLASSNAME}}::toString(SolverState state) {
183 switch (state) {
184 case SolverState::GridConstruction:
185 return "grid-construction";
186 case SolverState::GridInitialisation:
187 return "grid-initialisation";
188 case SolverState::PlottingAfterGridInitialisation:
189 return "plotting-after-grid-initialisation";
190 case SolverState::LimiterStatusSpreadingToNeighbours:
191 return "limiter status spreading to neighbours";
192 case SolverState::TimeStepping:
193 return "timestepping";
194 case SolverState::Plotting:
195 return "plotting";
196 case SolverState::Suspended:
197 return "suspended";
198 }
199 return "<undef>";
200}
201
202
203bool {{NAMESPACE | join("::")}}::{{CLASSNAME}}::mayPlot() const {
204 return _solverState!=SolverState::LimiterStatusSpreadingToNeighbours;
205}
206
207
208bool {{NAMESPACE | join("::")}}::{{CLASSNAME}}::isFirstGridSweepOfTimeStep() const {
209 return (
210 _solverState!=SolverState::LimiterStatusSpreadingToNeighbours
211 and
212 repositories::{{REGULAR_SOLVER_INSTANCE}}.isFirstGridSweepOfTimeStep()
213 and
214 repositories::{{LIMITER_SOLVER_INSTANCE}}.isFirstGridSweepOfTimeStep()
215 );
216
217}
218
219
220bool {{NAMESPACE | join("::")}}::{{CLASSNAME}}::isLastGridSweepOfTimeStep() const {
221 return (
222 _solverState!=SolverState::LimiterStatusSpreadingToNeighbours
223 and
224 repositories::{{REGULAR_SOLVER_INSTANCE}}.isLastGridSweepOfTimeStep()
225 and
226 repositories::{{LIMITER_SOLVER_INSTANCE}}.isLastGridSweepOfTimeStep()
227 );
228}
229
230
231void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::startSimulation() {
232
233}
234
235
236void {{NAMESPACE | join("::")}}::{{CLASSNAME}}::finishSimulation() {
237
238}
239
240
241void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::addTroubledCell(){
242 tarch::multicore::Lock lock(_semaphore);
244}
245int {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::getNumberOfTroubledCells() const {
247}
248
249
250{% if ADMISSIBILITY_IMPLEMENTATION!="<empty>" and ADMISSIBILITY_IMPLEMENTATION!="<user-defined>" %}
251bool {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::isPhysicallyAdmissible(
252 const {{REGULAR_SOLVER_STORAGE_PRECISION}}* const Q,
253 const tarch::la::Vector<DIMENSIONS,double>& x,
254 const tarch::la::Vector<DIMENSIONS,double>& h,
255 const double timeStamp
256){
257
258 {% if ADMISSIBILITY_IMPLEMENTATION!="<none>"%}
259 {{ADMISSIBILITY_IMPLEMENTATION}}
260 {% else %}
261 return true;
262 {% endif %}
263
264}
265{% endif %}
266
267
268{{SOLVER_USER_DEFINITIONS}}
_cellUpdates(0)
constexpr double timeStamp
tarch::logging::Log _log("::")