7 #include "{{CLASSNAME}}.h"
11 #include "Constants.h"
13 #include "tarch/multicore/Lock.h"
15 #include "repositories/SolverRepository.h"
17 tarch::logging::Log {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::{{CLASSNAME}}
::_log(
"{{NAMESPACE | join("::
")}}::{{CLASSNAME}}::{{CLASSNAME}}" );
19 {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::{{CLASSNAME}}():
20 _solverState(SolverState::GridConstruction),
24 {{CONSTRUCTOR_IMPLEMENTATION}}
28 {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::~{{CLASSNAME}}(){
33 double {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::getMinTimeStamp(
bool ofCurrentlyRunningGridSweep)
const {
34 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMinTimeStamp();
38 double {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::getMaxTimeStamp(
bool ofCurrentlyRunningGridSweep)
const {
39 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMaxTimeStamp();
43 double {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::getMinTimeStepSize()
const {
44 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMinTimeStepSize();
48 double {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::getMaxTimeStepSize()
const {
49 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMaxTimeStepSize();
53 double {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::getMaxMeshSize()
const {
54 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMaxMeshSize();
58 double {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::getMinMeshSize()
const {
59 return repositories::{{REGULAR_SOLVER_INSTANCE}}.getMinMeshSize();
63 {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::SolverState {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::getSolverState()
const {
68 void {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::startGridConstructionStep() {
69 assertion( _solverState == SolverState::GridConstruction );
73 void {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::finishGridConstructionStep() {
77 void {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::startGridInitialisationStep() {
78 _solverState = SolverState::GridInitialisation;
82 void {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::finishGridInitialisationStep() {
87 void {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::suspendSolversForOneGridSweep() {
88 _solverState = SolverState::Suspended;
92 void {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::startTimeStep() {
93 switch (_solverState) {
94 case SolverState::GridConstruction:
95 _solverState = SolverState::GridInitialisation;
97 case SolverState::GridInitialisation:
98 case SolverState::PlottingAfterGridInitialisation:
101 case SolverState::LimiterStatusSpreadingToNeighbours:
102 case SolverState::TimeStepping:
103 case SolverState::Plotting:
104 case SolverState::Suspended:
105 _solverState = SolverState::TimeStepping;
109 {{START_TIME_STEP_IMPLEMENTATION}}
111 if(_solverState==SolverState::LimiterStatusSpreadingToNeighbours){
112 repositories::{{REGULAR_SOLVER_INSTANCE}}.suspendSolversForOneGridSweep();
113 repositories::{{LIMITER_SOLVER_INSTANCE}}.suspendSolversForOneGridSweep();
119 void {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::finishTimeStep() {
120 if ( isLastGridSweepOfTimeStep() ) {
126 tarch::mpi::Rank::getInstance().allReduce(
131 [&]() ->
void { tarch::services::ServiceRepository::getInstance().receiveDanglingMessages(); }
134 if(_solverState==SolverState::LimiterStatusSpreadingToNeighbours){
136 tarch::mpi::Rank::getInstance().allReduce(
137 &newNumberOfTroubleCells,
141 [&]() ->
void { tarch::services::ServiceRepository::getInstance().receiveDanglingMessages(); }
147 {{FINISH_TIME_STEP_IMPLEMENTATION}}
153 void {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::printTimeStep(
bool ofCurrentlyRunningGridSweep) {
154 {{PRINT_TIME_STEP_IMPLEMENTATION}}
156 if (getNumberOfTroubledCells() > 0) {
157 logInfo(
"printTimeStep()",
"Solver {{SOLVER_NAME}}:");
158 logInfo(
"printTimeStep()",
"Number of troubled cells: " << getNumberOfTroubledCells());
163 void {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::startPlottingStep(){
164 if ( _solverState==SolverState::GridInitialisation) {
165 _solverState = SolverState::PlottingAfterGridInitialisation;
168 _solverState = SolverState::Plotting;
173 void {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::finishPlottingStep() {
177 std::string {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::toString(SolverState 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:
191 case SolverState::Suspended:
198 bool {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::mayPlot()
const {
199 return _solverState!=SolverState::LimiterStatusSpreadingToNeighbours;
203 bool {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::isFirstGridSweepOfTimeStep()
const {
205 _solverState!=SolverState::LimiterStatusSpreadingToNeighbours
207 repositories::{{REGULAR_SOLVER_INSTANCE}}.isFirstGridSweepOfTimeStep()
209 repositories::{{LIMITER_SOLVER_INSTANCE}}.isFirstGridSweepOfTimeStep()
215 bool {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::isLastGridSweepOfTimeStep()
const {
217 _solverState!=SolverState::LimiterStatusSpreadingToNeighbours
219 repositories::{{REGULAR_SOLVER_INSTANCE}}.isLastGridSweepOfTimeStep()
221 repositories::{{LIMITER_SOLVER_INSTANCE}}.isLastGridSweepOfTimeStep()
226 void {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::startSimulation() {
231 void {{NAMESPACE | join(
"::")}}::{{CLASSNAME}}::finishSimulation() {
236 void {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::addTroubledCell(){
237 tarch::multicore::Lock lock(_semaphore);
240 int {{FULL_QUALIFIED_NAMESPACE}}::{{CLASSNAME}}::getNumberOfTroubledCells()
const {
245 {%
if ADMISSIBILITY_IMPLEMENTATION!=
"<empty>" and ADMISSIBILITY_IMPLEMENTATION!=
"<user-defined>" %}
247 const {{REGULAR_SOLVER_STORAGE_PRECISION}}*
const Q,
248 const tarch::la::Vector<DIMENSIONS,double>&
x,
249 const tarch::la::Vector<DIMENSIONS,double>&
h,
253 {%
if ADMISSIBILITY_IMPLEMENTATION!=
"<none>"%}
254 {{ADMISSIBILITY_IMPLEMENTATION}}
263 {{SOLVER_USER_DEFINITIONS}}
_totalNumberOfTroubledCells(0)
constexpr double timeStamp
string isPhysicallyAdmissible
tarch::logging::Log _log
This is variant 1 of the fused kernels.