Opm::Simulator< TypeTag > Class Template Reference

Manages the initializing and running of time dependent problems. More...

#include <simulator.hh>

Public Member Functions

 Simulator (const Simulator &)=delete
 
 Simulator (bool verbose=true)
 
 Simulator (Communication comm, bool verbose=true)
 
Vanguard & vanguard ()
 Return a reference to the grid manager of simulation. More...
 
const Vanguard & vanguard () const
 Return a reference to the grid manager of simulation. More...
 
const GridView & gridView () const
 Return the grid view for which the simulation is done. More...
 
Model & model ()
 Return the physical model used in the simulation. More...
 
const Model & model () const
 Return the physical model used in the simulation. More...
 
Problem & problem ()
 Return the object which specifies the pysical setup of the simulation. More...
 
const Problem & problem () const
 Return the object which specifies the pysical setup of the simulation. More...
 
void setStartTime (Scalar t)
 Set the time of the start of the simulation. More...
 
Scalar startTime () const
 Return the time of the start of the simulation. More...
 
void setTime (Scalar t)
 Set the current simulated time, don't change the current time step index. More...
 
void setTime (Scalar t, unsigned stepIdx)
 Set the current simulated time and the time step index. More...
 
Scalar time () const
 Return the number of seconds of simulated time which have elapsed since the start time. More...
 
void setEndTime (Scalar t)
 Set the time of simulated seconds at which the simulation runs. More...
 
Scalar endTime () const
 Returns the number of (simulated) seconds which the simulation runs. More...
 
const TimersetupTimer () const
 Returns a reference to the timer object which measures the time needed to set up and initialize the simulation. More...
 
const TimerexecutionTimer () const
 Returns a reference to the timer object which measures the time needed to run the simulation. More...
 
TimerexecutionTimer ()
 
const TimerprePostProcessTimer () const
 Returns a reference to the timer object which measures the time needed for pre- and postprocessing of the solutions. More...
 
const TimerlinearizeTimer () const
 Returns a reference to the timer object which measures the time needed for linarizing the solutions. More...
 
const TimersolveTimer () const
 Returns a reference to the timer object which measures the time needed by the solver. More...
 
const TimerupdateTimer () const
 Returns a reference to the timer object which measures the time needed to the solutions of the non-linear system of equations. More...
 
const TimerwriteTimer () const
 Returns a reference to the timer object which measures the time needed to write the visualization output. More...
 
void setTimeStepSize (Scalar value)
 Set the current time step size to a given value. More...
 
void setTimeStepIndex (unsigned value)
 Set the current time step index to a given value. More...
 
Scalar timeStepSize () const
 Returns the time step length $\mathrm{[s]}$ so that we don't miss the beginning of the next episode or cross the end of the simlation. More...
 
int timeStepIndex () const
 Returns number of time steps which have been executed since the beginning of the simulation. More...
 
void setFinished (bool yesno=true)
 Specify whether the simulation is finished. More...
 
bool finished () const
 Returns true if the simulation is finished. More...
 
bool willBeFinished () const
 Returns true if the simulation is finished after the time level is incremented by the current time step size. More...
 
Scalar maxTimeStepSize () const
 Aligns the time step size to the episode boundary and to the end time of the simulation. More...
 
void startNextEpisode (Scalar episodeStartTime, Scalar episodeLength)
 Change the current episode of the simulation. More...
 
void startNextEpisode (Scalar len=std::numeric_limits< Scalar >::max())
 Start the next episode, but don't change the episode identifier. More...
 
void setEpisodeIndex (int episodeIdx)
 Sets the index of the current episode. More...
 
int episodeIndex () const
 Returns the index of the current episode. More...
 
Scalar episodeStartTime () const
 Returns the absolute time when the current episode started $\mathrm{[s]}$. More...
 
void setEpisodeLength (Scalar dt)
 Sets the length in seconds of the current episode. More...
 
Scalar episodeLength () const
 Returns the length of the current episode in simulated time $\mathrm{[s]}$. More...
 
bool episodeStarts () const
 Returns true if the current episode has just been started at the current time. More...
 
bool episodeIsOver () const
 Returns true if the current episode is finished at the current time. More...
 
bool episodeWillBeOver () const
 Returns true if the current episode will be finished after the current time step. More...
 
Scalar episodeMaxTimeStepSize () const
 Aligns the time step size to the episode boundary if the current time step crosses the boundary of the current episode. More...
 
void run ()
 Runs the simulation using a given problem class. More...
 

Static Public Member Functions

static void registerParameters ()
 Registers all runtime parameters used by the simulation. More...
 
static std::string humanReadableTime (Scalar timeInSeconds, bool isAmendment=true)
 Given a time step size in seconds, return it in a format which is more easily parsable by humans. More...
 

Saving/restoring the simulation state

void serialize ()
 This method writes the complete state of the simulation to the harddisk. More...
 
template<class Restarter >
void serialize (Restarter &restarter)
 Write the time manager's state to a restart file. More...
 
template<class Restarter >
void deserialize (Restarter &restarter)
 Read the time manager's state from a restart file. More...
 
template<class Serializer >
void serializeOp (Serializer &serializer)
 

Detailed Description

template<class TypeTag>
class Opm::Simulator< TypeTag >

Manages the initializing and running of time dependent problems.

This class instantiates the grid, the model and the problem to be simlated and runs the simulation loop. The time axis is treated as a sequence of "episodes" which are defined as time intervals for which the problem exhibits boundary conditions and source terms that do not depend on time.

Constructor & Destructor Documentation

◆ Simulator() [1/3]

template<class TypeTag >
Opm::Simulator< TypeTag >::Simulator ( const Simulator< TypeTag > &  )
delete

◆ Simulator() [2/3]

template<class TypeTag >
Opm::Simulator< TypeTag >::Simulator ( bool  verbose = true)
inline

◆ Simulator() [3/3]

template<class TypeTag >
Opm::Simulator< TypeTag >::Simulator ( Communication  comm,
bool  verbose = true 
)
inline

Member Function Documentation

◆ deserialize()

template<class TypeTag >
template<class Restarter >
void Opm::Simulator< TypeTag >::deserialize ( Restarter &  restarter)
inline

Read the time manager's state from a restart file.

Template Parameters
RestarterThe type of the object which takes care to deserialize data
Parameters
restarterThe deserializer object

Referenced by Opm::Simulator< TypeTag >::run().

◆ endTime()

template<class TypeTag >
Scalar Opm::Simulator< TypeTag >::endTime ( ) const
inline

Returns the number of (simulated) seconds which the simulation runs.

Referenced by Opm::Simulator< TypeTag >::finished(), Opm::Simulator< TypeTag >::maxTimeStepSize(), and Opm::Simulator< TypeTag >::willBeFinished().

◆ episodeIndex()

template<class TypeTag >
int Opm::Simulator< TypeTag >::episodeIndex ( ) const
inline

Returns the index of the current episode.

The first episode has the index 0.

Referenced by Opm::Simulator< TypeTag >::run().

◆ episodeIsOver()

template<class TypeTag >
bool Opm::Simulator< TypeTag >::episodeIsOver ( ) const
inline

◆ episodeLength()

template<class TypeTag >
Scalar Opm::Simulator< TypeTag >::episodeLength ( ) const
inline

◆ episodeMaxTimeStepSize()

template<class TypeTag >
Scalar Opm::Simulator< TypeTag >::episodeMaxTimeStepSize ( ) const
inline

◆ episodeStarts()

template<class TypeTag >
bool Opm::Simulator< TypeTag >::episodeStarts ( ) const
inline

Returns true if the current episode has just been started at the current time.

References Opm::Simulator< TypeTag >::startTime(), and Opm::Simulator< TypeTag >::time().

◆ episodeStartTime()

template<class TypeTag >
Scalar Opm::Simulator< TypeTag >::episodeStartTime ( ) const
inline

Returns the absolute time when the current episode started $\mathrm{[s]}$.

Referenced by Opm::Simulator< TypeTag >::episodeMaxTimeStepSize(), and Opm::Simulator< TypeTag >::startNextEpisode().

◆ episodeWillBeOver()

template<class TypeTag >
bool Opm::Simulator< TypeTag >::episodeWillBeOver ( ) const
inline

Returns true if the current episode will be finished after the current time step.

References Opm::Simulator< TypeTag >::episodeLength(), Opm::Simulator< TypeTag >::startTime(), Opm::Simulator< TypeTag >::time(), and Opm::Simulator< TypeTag >::timeStepSize().

◆ executionTimer() [1/2]

template<class TypeTag >
Timer & Opm::Simulator< TypeTag >::executionTimer ( )
inline

◆ executionTimer() [2/2]

template<class TypeTag >
const Timer & Opm::Simulator< TypeTag >::executionTimer ( ) const
inline

Returns a reference to the timer object which measures the time needed to run the simulation.

◆ finished()

template<class TypeTag >
bool Opm::Simulator< TypeTag >::finished ( ) const
inline

Returns true if the simulation is finished.

This is the case if either setFinished(true) has been called or if the end time is reached.

References Opm::Simulator< TypeTag >::endTime(), Opm::Simulator< TypeTag >::time(), and Opm::Simulator< TypeTag >::timeStepSize().

Referenced by Opm::Simulator< TypeTag >::maxTimeStepSize(), and Opm::Simulator< TypeTag >::run().

◆ gridView()

◆ humanReadableTime()

template<class TypeTag >
static std::string Opm::Simulator< TypeTag >::humanReadableTime ( Scalar  timeInSeconds,
bool  isAmendment = true 
)
inlinestatic

Given a time step size in seconds, return it in a format which is more easily parsable by humans.

e.g. 874000.0 will become "10.12 days"

Referenced by Opm::FvBaseProblem< TypeTag >::finalize(), and Opm::Simulator< TypeTag >::run().

◆ linearizeTimer()

template<class TypeTag >
const Timer & Opm::Simulator< TypeTag >::linearizeTimer ( ) const
inline

Returns a reference to the timer object which measures the time needed for linarizing the solutions.

◆ maxTimeStepSize()

template<class TypeTag >
Scalar Opm::Simulator< TypeTag >::maxTimeStepSize ( ) const
inline

Aligns the time step size to the episode boundary and to the end time of the simulation.

References Opm::Simulator< TypeTag >::endTime(), Opm::Simulator< TypeTag >::episodeMaxTimeStepSize(), Opm::Simulator< TypeTag >::finished(), and Opm::Simulator< TypeTag >::time().

Referenced by Opm::Simulator< TypeTag >::run().

◆ model() [1/2]

template<class TypeTag >
Model & Opm::Simulator< TypeTag >::model ( )
inline

Return the physical model used in the simulation.

Referenced by Opm::Simulator< TypeTag >::run().

◆ model() [2/2]

template<class TypeTag >
const Model & Opm::Simulator< TypeTag >::model ( ) const
inline

Return the physical model used in the simulation.

◆ prePostProcessTimer()

template<class TypeTag >
const Timer & Opm::Simulator< TypeTag >::prePostProcessTimer ( ) const
inline

Returns a reference to the timer object which measures the time needed for pre- and postprocessing of the solutions.

◆ problem() [1/2]

template<class TypeTag >
Problem & Opm::Simulator< TypeTag >::problem ( )
inline

Return the object which specifies the pysical setup of the simulation.

Referenced by Opm::Restart::deserializeBegin(), Opm::Restart::serializeBegin(), and Opm::TpfaLinearizer< TypeTag >::updateFlowsInfo().

◆ problem() [2/2]

template<class TypeTag >
const Problem & Opm::Simulator< TypeTag >::problem ( ) const
inline

Return the object which specifies the pysical setup of the simulation.

◆ registerParameters()

template<class TypeTag >
static void Opm::Simulator< TypeTag >::registerParameters ( )
inlinestatic

Registers all runtime parameters used by the simulation.

◆ run()

◆ serialize() [1/2]

template<class TypeTag >
void Opm::Simulator< TypeTag >::serialize ( )
inline

This method writes the complete state of the simulation to the harddisk.

The file will start with the prefix returned by the name() method, has the current time of the simulation clock in it's name and uses the extension .ers. (Ewoms ReStart file.) See Opm::Restart for details.

References Opm::Simulator< TypeTag >::gridView(), Opm::Simulator< TypeTag >::serialize(), Opm::Restart::serializeBegin(), and Opm::Simulator< TypeTag >::timeStepSize().

Referenced by Opm::Simulator< TypeTag >::run(), and Opm::Simulator< TypeTag >::serialize().

◆ serialize() [2/2]

template<class TypeTag >
template<class Restarter >
void Opm::Simulator< TypeTag >::serialize ( Restarter &  restarter)
inline

Write the time manager's state to a restart file.

Template Parameters
RestarterThe type of the object which takes care to serialize data
Parameters
restarterThe serializer object

◆ serializeOp()

template<class TypeTag >
template<class Serializer >
void Opm::Simulator< TypeTag >::serializeOp ( Serializer &  serializer)
inline

◆ setEndTime()

template<class TypeTag >
void Opm::Simulator< TypeTag >::setEndTime ( Scalar  t)
inline

Set the time of simulated seconds at which the simulation runs.

Parameters
tThe time $\mathrm{[s]}$ at which the simulation is finished

◆ setEpisodeIndex()

template<class TypeTag >
void Opm::Simulator< TypeTag >::setEpisodeIndex ( int  episodeIdx)
inline

Sets the index of the current episode.

Use this method with care!

◆ setEpisodeLength()

template<class TypeTag >
void Opm::Simulator< TypeTag >::setEpisodeLength ( Scalar  dt)
inline

Sets the length in seconds of the current episode.

Use this method with care!

◆ setFinished()

template<class TypeTag >
void Opm::Simulator< TypeTag >::setFinished ( bool  yesno = true)
inline

Specify whether the simulation is finished.

Parameters
yesnoIf true the simulation is considered finished before the end time is reached, else it is only considered finished if the end time is reached.

◆ setStartTime()

template<class TypeTag >
void Opm::Simulator< TypeTag >::setStartTime ( Scalar  t)
inline

Set the time of the start of the simulation.

Parameters
tThe time $\mathrm{[s]}$ which should be jumped to

◆ setTime() [1/2]

template<class TypeTag >
void Opm::Simulator< TypeTag >::setTime ( Scalar  t)
inline

Set the current simulated time, don't change the current time step index.

Parameters
tThe time $\mathrm{[s]}$ which should be jumped to

◆ setTime() [2/2]

template<class TypeTag >
void Opm::Simulator< TypeTag >::setTime ( Scalar  t,
unsigned  stepIdx 
)
inline

Set the current simulated time and the time step index.

Parameters
tThe time $\mathrm{[s]}$ which should be jumped to
stepIdxThe new time step index

◆ setTimeStepIndex()

template<class TypeTag >
void Opm::Simulator< TypeTag >::setTimeStepIndex ( unsigned  value)
inline

Set the current time step index to a given value.

Parameters
timeStepIndexThe new value for the time step index

◆ setTimeStepSize()

template<class TypeTag >
void Opm::Simulator< TypeTag >::setTimeStepSize ( Scalar  value)
inline

Set the current time step size to a given value.

If the step size would exceed the length of the current episode, the timeStep() method will take care that the step size won't exceed the episode or the end of the simulation, though.

Parameters
timeStepSizeThe new value for the time step size $\mathrm{[s]}$

Referenced by Opm::Simulator< TypeTag >::run().

◆ setupTimer()

template<class TypeTag >
const Timer & Opm::Simulator< TypeTag >::setupTimer ( ) const
inline

Returns a reference to the timer object which measures the time needed to set up and initialize the simulation.

◆ solveTimer()

template<class TypeTag >
const Timer & Opm::Simulator< TypeTag >::solveTimer ( ) const
inline

Returns a reference to the timer object which measures the time needed by the solver.

◆ startNextEpisode() [1/2]

template<class TypeTag >
void Opm::Simulator< TypeTag >::startNextEpisode ( Scalar  episodeStartTime,
Scalar  episodeLength 
)
inline

Change the current episode of the simulation.

Parameters
episodeStartTimeTime when the episode began $\mathrm{[s]}$
episodeLengthLength of the episode $\mathrm{[s]}$

References Opm::Simulator< TypeTag >::episodeLength(), and Opm::Simulator< TypeTag >::episodeStartTime().

◆ startNextEpisode() [2/2]

template<class TypeTag >
void Opm::Simulator< TypeTag >::startNextEpisode ( Scalar  len = std::numeric_limits<Scalar>::max())
inline

Start the next episode, but don't change the episode identifier.

Parameters
lenLength of the episode $\mathrm{[s]}$, infinite if not specified.

◆ startTime()

template<class TypeTag >
Scalar Opm::Simulator< TypeTag >::startTime ( ) const
inline

◆ time()

◆ timeStepIndex()

template<class TypeTag >
int Opm::Simulator< TypeTag >::timeStepIndex ( ) const
inline

Returns number of time steps which have been executed since the beginning of the simulation.

Referenced by Opm::Simulator< TypeTag >::run().

◆ timeStepSize()

template<class TypeTag >
Scalar Opm::Simulator< TypeTag >::timeStepSize ( ) const
inline

Returns the time step length $\mathrm{[s]}$ so that we don't miss the beginning of the next episode or cross the end of the simlation.

Referenced by Opm::Simulator< TypeTag >::episodeWillBeOver(), Opm::Simulator< TypeTag >::finished(), Opm::Simulator< TypeTag >::run(), and Opm::Simulator< TypeTag >::serialize().

◆ updateTimer()

template<class TypeTag >
const Timer & Opm::Simulator< TypeTag >::updateTimer ( ) const
inline

Returns a reference to the timer object which measures the time needed to the solutions of the non-linear system of equations.

◆ vanguard() [1/2]

template<class TypeTag >
Vanguard & Opm::Simulator< TypeTag >::vanguard ( )
inline

Return a reference to the grid manager of simulation.

◆ vanguard() [2/2]

template<class TypeTag >
const Vanguard & Opm::Simulator< TypeTag >::vanguard ( ) const
inline

Return a reference to the grid manager of simulation.

◆ willBeFinished()

template<class TypeTag >
bool Opm::Simulator< TypeTag >::willBeFinished ( ) const
inline

Returns true if the simulation is finished after the time level is incremented by the current time step size.

References Opm::Simulator< TypeTag >::endTime(), and Opm::Simulator< TypeTag >::time().

◆ writeTimer()

template<class TypeTag >
const Timer & Opm::Simulator< TypeTag >::writeTimer ( ) const
inline

Returns a reference to the timer object which measures the time needed to write the visualization output.


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