Peano
Loading...
Searching...
No Matches
exahype2::Solver Class Reference

#include <Solver.h>

Inheritance diagram for exahype2::Solver:
Collaboration diagram for exahype2::Solver:

Public Types

enum class  Offloadable { Yes }
 This is a "fake" enum, i.e. More...
 

Public Member Functions

 Solver ()
 The min and max time stamp and the time step size all start at 0, so the very first time step does not advance the solution.
 
virtual double getMinTimeStamp () const
 
virtual double getMaxTimeStamp () const
 
virtual double getMinTimeStepSize () const
 
virtual double getMaxTimeStepSize () const
 
virtual double getAdmissibleTimeStepSize () const
 The time step size the solver would use if enforceTimeStepSize() had not been called, i.e.
 
virtual void startTimeStep (double globalMinTimeStamp, double globalMaxTimeStamp, double globalMinTimeStepSize, double globalMaxTimeStepSize)
 Default implementation: rolls the previous sweep's accumulated _minTimeStampUpdatedThisTimeStep/_maxTimeStampUpdatedThisTimeStep, _minTimeStepSizeUpdatedThisTimeStep/_maxTimeStepSizeUpdatedThisTimeStep and _minVolumeHUpdatedThisTimeStep/_maxVolumeHUpdatedThisTimeStep over into the corresponding global attributes, and resets the UpdatedThisTimeStep accumulators (and _cellUpdates) so the new sweep about to start can accumulate its own contributions via updateCell().
 
virtual void finishTimeStep ()
 Default implementation: MPI-all-reduces the UpdatedThisTimeStep accumulators (min via MPI_MIN, max via MPI_MAX, _cellUpdates via MPI_SUM) across ranks, so every rank's startTimeStep() rolls over the same, globally synchronised values.
 
virtual void startPlottingStep (double globalMinTimeStamp, double globalMaxTimeStamp, double globalMinTimeStepSize, double globalMaxTimeStepSize)
 Not pure virtual, unlike the other lifecycle hooks above: overriding it is optional.
 
virtual void finishPlottingStep ()
 Not pure virtual -.
 
virtual double getMaxMeshSize () const
 
virtual double getMinMeshSize () const
 
virtual std::string toCheckpointMetaData () const
 Solver state for the header of a checkpoint.
 
virtual void fromCheckpointMetaData (const std::string &metaData)
 Restore the solver state from the header of a checkpoint.
 
virtual bool cellCanUseStatelessPDETerms (const tarch::la::Vector< Dimensions, double > &cellCentre, const tarch::la::Vector< Dimensions, double > &cellH, double t, double dt) const
 Default implementation: always returns true, i.e.
 
void updateCell (double timeStepSize, double timeStamp)
 Thread-safely fold one cell's contribution into this time step's running time stamp and time step size bounds (protected by _semaphore).
 
void enforceTimeStepSize (double timeStepSize)
 Thread-safely overwrite the current minimum and maximum time step size (protected by _semaphore), i.e.
 
void resetTimeStepSize ()
 Restart the time stepping with a time step size of zero.
 

Static Public Member Functions

static std::string toCheckpointMetaDataEntry (const std::string &key, double value)
 One line of toCheckpointMetaData()
 
static bool getCheckpointMetaDataEntry (const std::string &metaData, const std::string &key, double &value)
 Find one entry of a checkpoint's meta data.
 

Protected Attributes

double _minTimeStamp
 
double _maxTimeStamp
 
double _minTimeStampUpdatedThisTimeStep
 
double _maxTimeStampUpdatedThisTimeStep
 
double _minVolumeH
 
double _maxVolumeH
 
double _minVolumeHUpdatedThisTimeStep
 
double _maxVolumeHUpdatedThisTimeStep
 
double _minTimeStepSize
 
double _maxTimeStepSize
 
double _admissibleTimeStepSize
 
double _minTimeStepSizeUpdatedThisTimeStep
 
double _maxTimeStepSizeUpdatedThisTimeStep
 
int _cellUpdates
 
tarch::multicore::BooleanSemaphore _semaphore
 

Detailed Description

Definition at line 18 of file Solver.h.

Member Enumeration Documentation

◆ Offloadable

enum class exahype2::Solver::Offloadable
strong

This is a "fake" enum, i.e.

we do not use it to distinguish different variants. Instead, we use it as a fix that allows us to "overload" operations:

In C++ you cannot overload w.r.t. static. We however need functions which exist twice in ExaHyPE: Once as standard (virtual) member functions and once at static version which an be offloaded to a GPU as it does not have a state. Both function variants, in theory, have the same signature but if they had, a compiler could not distinguish them. So I use this enum for the GPU version.

If you create a solver without GPU support, this enum will not be used. It is however always created. Once you write a GPU version and then compile without GPU support, you will thus still be able to have all your GPU function variants, and you don't have to work with ifdefs.

Enumerator
Yes 

Definition at line 37 of file Solver.h.

Constructor & Destructor Documentation

◆ Solver()

exahype2::Solver::Solver ( )

The min and max time stamp and the time step size all start at 0, so the very first time step does not advance the solution.

It only yields the first admissible time step size.

Member Function Documentation

◆ cellCanUseStatelessPDETerms()

virtual bool exahype2::Solver::cellCanUseStatelessPDETerms ( const tarch::la::Vector< Dimensions, double > &  cellCentre,
const tarch::la::Vector< Dimensions, double > &  cellH,
double  t,
double  dt 
) const
virtual

Default implementation: always returns true, i.e.

every cell uses the stateless (GPU-offloadable) variants of the PDE terms wherever a solver offers both a stateless and a stateful variant. A solver overrides this to opt individual cells out of the stateless variants and into the ones with state.

◆ enforceTimeStepSize()

void exahype2::Solver::enforceTimeStepSize ( double  timeStepSize)

Thread-safely overwrite the current minimum and maximum time step size (protected by _semaphore), i.e.

what getMinTimeStepSize() and getMaxTimeStepSize() return from now on. Optimistic time stepping uses this setter to switch to the time step size it has estimated beforehand (

See also
exahype2.api.fv.actionsets.ReadjustTimeStepSizeForOptimisticGlobalTimestepping). The accumulators of the time step that is currently running remain unchanged, and so does getAdmissibleTimeStepSize().

◆ finishPlottingStep()

virtual void exahype2::Solver::finishPlottingStep ( )
virtual

Not pure virtual -.

See also
startPlottingStep().

Definition at line 105 of file Solver.h.

◆ finishTimeStep()

virtual void exahype2::Solver::finishTimeStep ( )
virtual

Default implementation: MPI-all-reduces the UpdatedThisTimeStep accumulators (min via MPI_MIN, max via MPI_MAX, _cellUpdates via MPI_SUM) across ranks, so every rank's startTimeStep() rolls over the same, globally synchronised values.

A no-op in a build without MPI support.

◆ fromCheckpointMetaData()

virtual void exahype2::Solver::fromCheckpointMetaData ( const std::string &  metaData)
virtual

Restore the solver state from the header of a checkpoint.

Counterpart of toCheckpointMetaData(): The routine sets the time stamps, the time step sizes, the admissible time step size and the mesh sizes to the values in metaData. Attributes which metaData does not hold keep their values. Afterwards, it resets the bookkeeping of the time step as startTimeStep() does, so the next time step continues from the restored state. Generated solvers override it to restore their own attributes via getCheckpointMetaDataEntry().

exahype2.api.blockstructured.LoadCheckpoint calls the routine once the solution has been read from the checkpoint.

◆ getAdmissibleTimeStepSize()

virtual double exahype2::Solver::getAdmissibleTimeStepSize ( ) const
virtual

The time step size the solver would use if enforceTimeStepSize() had not been called, i.e.

the maximum time step size as startTimeStep() has rolled it over. enforceTimeStepSize() does not alter it.

◆ getCheckpointMetaDataEntry()

static bool exahype2::Solver::getCheckpointMetaDataEntry ( const std::string &  metaData,
const std::string &  key,
double &  value 
)
static

Find one entry of a checkpoint's meta data.

Parameters
metaDataKey-value pairs as written by toCheckpointMetaData(), one per line. Leading white spaces per line are ignored.
keyKey of the entry, i.e. the attribute's name without leading underscore.
valueSet to the entry's value if metaData holds the key. Otherwise, it is left unchanged.
Returns
Whether metaData holds the key.

◆ getMaxMeshSize()

virtual double exahype2::Solver::getMaxMeshSize ( ) const
virtual

◆ getMaxTimeStamp()

virtual double exahype2::Solver::getMaxTimeStamp ( ) const
virtual

◆ getMaxTimeStepSize()

virtual double exahype2::Solver::getMaxTimeStepSize ( ) const
virtual

◆ getMinMeshSize()

virtual double exahype2::Solver::getMinMeshSize ( ) const
virtual

◆ getMinTimeStamp()

virtual double exahype2::Solver::getMinTimeStamp ( ) const
virtual

◆ getMinTimeStepSize()

virtual double exahype2::Solver::getMinTimeStepSize ( ) const
virtual

◆ resetTimeStepSize()

void exahype2::Solver::resetTimeStepSize ( )

Restart the time stepping with a time step size of zero.

Thread-safely sets the current minimum and maximum time step size and the admissible time step size to zero (protected by _semaphore). The next time step hence behaves like the very first one: It does not advance the time stamp, but it derives an admissible time step size from the current solution and mesh. The mesh adaptation uses this routine whenever it has changed the mesh, as the time step size of the old mesh might violate the CFL condition on the new one (

See also
exahype2.api.blockstructured.ConsumeRefinementRequests). Optimistic time stepping does not apply any estimate in this time step, as the admissible time step size is zero.

◆ startPlottingStep()

virtual void exahype2::Solver::startPlottingStep ( double  globalMinTimeStamp,
double  globalMaxTimeStamp,
double  globalMinTimeStepSize,
double  globalMaxTimeStepSize 
)
virtual

Not pure virtual, unlike the other lifecycle hooks above: overriding it is optional.

The legacy python/exahype2 solvers override it to drive their own _solverState transitions into SolverState::Plotting/PlottingAfterGridInitialisation; newer solvers that have no use for it can simply not override it.

Definition at line 95 of file Solver.h.

◆ startTimeStep()

virtual void exahype2::Solver::startTimeStep ( double  globalMinTimeStamp,
double  globalMaxTimeStamp,
double  globalMinTimeStepSize,
double  globalMaxTimeStepSize 
)
virtual

Default implementation: rolls the previous sweep's accumulated _minTimeStampUpdatedThisTimeStep/_maxTimeStampUpdatedThisTimeStep, _minTimeStepSizeUpdatedThisTimeStep/_maxTimeStepSizeUpdatedThisTimeStep and _minVolumeHUpdatedThisTimeStep/_maxVolumeHUpdatedThisTimeStep over into the corresponding global attributes, and resets the UpdatedThisTimeStep accumulators (and _cellUpdates) so the new sweep about to start can accumulate its own contributions via updateCell().

globalMin/Max... are not used by the default implementation - they are there for solvers that need to react to the other solvers' bounds in a multi-solver project.

◆ toCheckpointMetaData()

virtual std::string exahype2::Solver::toCheckpointMetaData ( ) const
virtual

Solver state for the header of a checkpoint.

The checkpoint plotters (exahype2.api.fv.WriteCheckpoint and exahype2.api.rkfd4.WriteCheckpoint) write the result into the meta-data block of each Peano patch file. Every line holds one attribute as key-value pair, with the attribute's name without its leading underscore as key:

minTimeStamp 1.00000000000000006e-01
maxTimeStamp 1.00000000000000006e-01

The lines are separated by line breaks. The values carry 17 significant digits, so a double survives the round trip through the file unchanged.

The routine writes the time stamps, the time step sizes, the admissible time step size and the mesh sizes. It leaves out the bookkeeping of the time step which is currently running (the *UpdatedThisTimeStep attributes) and the cell update counter. Generated solvers override it to append their own attributes via toCheckpointMetaDataEntry().

◆ toCheckpointMetaDataEntry()

static std::string exahype2::Solver::toCheckpointMetaDataEntry ( const std::string &  key,
double  value 
)
static

One line of toCheckpointMetaData()

Returns
key and value separated by a blank, with the value in scientific notation with 17 significant digits. No line break.

◆ updateCell()

void exahype2::Solver::updateCell ( double  timeStepSize,
double  timeStamp 
)

Thread-safely fold one cell's contribution into this time step's running time stamp and time step size bounds (protected by _semaphore).

Does not touch _minVolumeH/_maxVolumeH - those describe the mesh, not the time stepping, and are set elsewhere.

Field Documentation

◆ _admissibleTimeStepSize

double exahype2::Solver::_admissibleTimeStepSize
protected
See also
getAdmissibleTimeStepSize()

Definition at line 243 of file Solver.h.

◆ _cellUpdates

int exahype2::Solver::_cellUpdates
protected

Definition at line 248 of file Solver.h.

◆ _maxTimeStamp

double exahype2::Solver::_maxTimeStamp
protected

Definition at line 226 of file Solver.h.

◆ _maxTimeStampUpdatedThisTimeStep

double exahype2::Solver::_maxTimeStampUpdatedThisTimeStep
protected

Definition at line 229 of file Solver.h.

◆ _maxTimeStepSize

double exahype2::Solver::_maxTimeStepSize
protected

Definition at line 238 of file Solver.h.

◆ _maxTimeStepSizeUpdatedThisTimeStep

double exahype2::Solver::_maxTimeStepSizeUpdatedThisTimeStep
protected

Definition at line 246 of file Solver.h.

◆ _maxVolumeH

double exahype2::Solver::_maxVolumeH
protected

Definition at line 232 of file Solver.h.

◆ _maxVolumeHUpdatedThisTimeStep

double exahype2::Solver::_maxVolumeHUpdatedThisTimeStep
protected

Definition at line 235 of file Solver.h.

◆ _minTimeStamp

double exahype2::Solver::_minTimeStamp
protected

Definition at line 225 of file Solver.h.

◆ _minTimeStampUpdatedThisTimeStep

double exahype2::Solver::_minTimeStampUpdatedThisTimeStep
protected

Definition at line 228 of file Solver.h.

◆ _minTimeStepSize

double exahype2::Solver::_minTimeStepSize
protected

Definition at line 237 of file Solver.h.

◆ _minTimeStepSizeUpdatedThisTimeStep

double exahype2::Solver::_minTimeStepSizeUpdatedThisTimeStep
protected

Definition at line 245 of file Solver.h.

◆ _minVolumeH

double exahype2::Solver::_minVolumeH
protected

Definition at line 231 of file Solver.h.

◆ _minVolumeHUpdatedThisTimeStep

double exahype2::Solver::_minVolumeHUpdatedThisTimeStep
protected

Definition at line 234 of file Solver.h.

◆ _semaphore

tarch::multicore::BooleanSemaphore exahype2::Solver::_semaphore
protected

Definition at line 250 of file Solver.h.


The documentation for this class was generated from the following file: