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