Reference documentation for deal.II version 9.3.3
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Public Types | Public Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
TimeStepBase Class Referenceabstract

#include <deal.II/numerics/time_dependent.h>

Inheritance diagram for TimeStepBase:
[legend]

Public Types

enum  SolutionState { primal_problem = 0x0 , dual_problem = 0x1 , postprocess = 0x2 }
 

Public Member Functions

 TimeStepBase (const double time)
 
virtual ~TimeStepBase () override=default
 
 TimeStepBase (const TimeStepBase &)=delete
 
TimeStepBaseoperator= (const TimeStepBase &)=delete
 
virtual void wake_up (const unsigned int)
 
virtual void sleep (const unsigned int)
 
virtual void start_sweep ()
 
virtual void end_sweep ()
 
virtual void init_for_primal_problem ()
 
virtual void init_for_dual_problem ()
 
virtual void init_for_postprocessing ()
 
virtual void solve_primal_problem ()=0
 
virtual void solve_dual_problem ()
 
virtual void postprocess_timestep ()
 
double get_time () const
 
unsigned int get_timestep_no () const
 
double get_backward_timestep () const
 
double get_forward_timestep () const
 
virtual std::size_t memory_consumption () const
 

Protected Attributes

const TimeStepBaseprevious_timestep
 
const TimeStepBasenext_timestep
 
unsigned int sweep_no
 
unsigned int timestep_no
 
const double time
 
unsigned int next_action
 

Private Member Functions

void set_previous_timestep (const TimeStepBase *previous)
 
void set_next_timestep (const TimeStepBase *next)
 
void set_timestep_no (const unsigned int step_no)
 
void set_sweep_no (const unsigned int sweep_no)
 

Friends

class TimeDependent
 

Subscriptor functionality

Classes derived from Subscriptor provide a facility to subscribe to this object. This is mostly used by the SmartPointer class.

void subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const
 
void unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const
 
unsigned int n_subscriptions () const
 
template<typename StreamType >
void list_subscribers (StreamType &stream) const
 
void list_subscribers () const
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 
void check_no_subscribers () const noexcept
 
using map_value_type = decltype(counter_map)::value_type
 
using map_iterator = decltype(counter_map)::iterator
 
std::atomic< unsigned intcounter
 
std::map< std::string, unsigned intcounter_map
 
std::vector< std::atomic< bool > * > validity_pointers
 
const std::type_info * object_info
 
static std::mutex mutex
 
static ::ExceptionBaseExcInUse (int arg1, std::string arg2, std::string arg3)
 
static ::ExceptionBaseExcNoSubscriber (std::string arg1, std::string arg2)
 

Detailed Description

Base class for a time step in time dependent problems. This class provides barely more than the basic framework, defining the necessary virtual functions (namely sleep and wake_up), the interface to previous and following grids, and some functions to be called before a new loop over all time steps is started.

Definition at line 665 of file time_dependent.h.

Member Enumeration Documentation

◆ SolutionState

Enum denoting the type of problem which will have to be solved next.

Enumerator
primal_problem 

Solve the primal problem next.

dual_problem 

Solve the dual problem next.

postprocess 

Perform postprocessing next.

Definition at line 671 of file time_dependent.h.

Constructor & Destructor Documentation

◆ TimeStepBase() [1/2]

TimeStepBase::TimeStepBase ( const double  time)

Constructor. Does nothing here apart from setting the time.

Definition at line 268 of file time_dependent.cc.

◆ ~TimeStepBase()

virtual TimeStepBase::~TimeStepBase ( )
overridevirtualdefault

Destructor. At present, this does nothing.

◆ TimeStepBase() [2/2]

TimeStepBase::TimeStepBase ( const TimeStepBase )
delete

The copy constructor is deleted to avoid shallow copies with unexpected behavior.

Member Function Documentation

◆ operator=()

TimeStepBase & TimeStepBase::operator= ( const TimeStepBase )
delete

The copy assignment operator is deleted to avoid shallow copies with unexpected behavior.

◆ wake_up()

void TimeStepBase::wake_up ( const unsigned int  )
virtual

Reconstruct all the data that is needed for this time level to work. This function serves to reget all the variables and data structures to work again after they have been send to sleep some time before, or at the first time we visit this time level. In particular, it is used to reconstruct the triangulation, degree of freedom handlers, to reload data vectors in case they have been stored to disk, etc.

The actual implementation of this function does nothing.

Since this is an important task, you should call this function from your own function, should you choose to overload it in your own class (which likely is the case), preferably at the beginning so that your function can take effect of the triangulation already existing.

Reimplemented in TimeStepBase_Tria< dim >.

Definition at line 280 of file time_dependent.cc.

◆ sleep()

void TimeStepBase::sleep ( const unsigned int  )
virtual

This is the opposite function to wake_up. It is used to delete data or save it to disk after they are no more needed for the present sweep. Typical kinds of data for this are data vectors, degree of freedom handlers, triangulation objects, etc. which occupy large amounts of memory and may therefore be externalized.

By default, this function does nothing.

Reimplemented in TimeStepBase_Tria< dim >.

Definition at line 286 of file time_dependent.cc.

◆ start_sweep()

void TimeStepBase::start_sweep ( )
virtual

This function is called each time before a new sweep is started. You may want to set up some fields needed in the course of the computations, and so on. You should take good care, however, not to install large objects, which should be deferred until the wake_up function is called.

A typical action of this function would be sorting out names of temporary files needed in the process of solving, etc.

At the time this function is called, the values of timestep_no, sweep_no and the pointer to the previous and next time step object already have their correct value.

The default implementation of this function does nothing.

Definition at line 292 of file time_dependent.cc.

◆ end_sweep()

void TimeStepBase::end_sweep ( )
virtual

This is the analogous to the above function, but it is called at the end of a sweep. You will usually want to do clean-ups in this function, such as deleting temporary files and the like.

Definition at line 298 of file time_dependent.cc.

◆ init_for_primal_problem()

void TimeStepBase::init_for_primal_problem ( )
virtual

Before the primal problem is solved on each time level, this function is called (i.e. before the solution takes place on the first time level). By default, this function sets the next_action variable of this class. You may overload this function, but you should call this function within your own one.

Definition at line 304 of file time_dependent.cc.

◆ init_for_dual_problem()

void TimeStepBase::init_for_dual_problem ( )
virtual

Same as above, but called before a round of dual problem solves.

Definition at line 312 of file time_dependent.cc.

◆ init_for_postprocessing()

void TimeStepBase::init_for_postprocessing ( )
virtual

Same as above, but called before a round of postprocessing steps.

Definition at line 320 of file time_dependent.cc.

◆ solve_primal_problem()

virtual void TimeStepBase::solve_primal_problem ( )
pure virtual

This function is called by the manager object when solving the primal problem on this time level is needed. It is called after the wake_up function was called and before the sleep function will be called. There is no default implementation for obvious reasons, so you have to overload this function.

◆ solve_dual_problem()

void TimeStepBase::solve_dual_problem ( )
virtual

This function is called by the manager object when solving the dual problem on this time level is needed. It is called after the wake_up function was called and before the sleep function will be called. There is a default implementation doing plain nothing since some problems may not need solving a dual problem. However, it will abort the program when being called anyway, since then you should really overload the function.

Definition at line 328 of file time_dependent.cc.

◆ postprocess_timestep()

void TimeStepBase::postprocess_timestep ( )
virtual

This function is called by the manager object when postprocessing this time level is needed. It is called after the wake_up function was called and before the sleep function will be called. There is a default implementation doing plain nothing since some problems may not need doing a postprocess step, e.g. if everything was already done when solving the primal problem. However, it will abort the program when being called anyway, since then you should really overload the function.

Definition at line 336 of file time_dependent.cc.

◆ get_time()

double TimeStepBase::get_time ( ) const

Return the time value of this time step.

Definition at line 344 of file time_dependent.cc.

◆ get_timestep_no()

unsigned int TimeStepBase::get_timestep_no ( ) const

Return the number of this time step. Note that this number may vary between different sweeps, if timesteps are added or deleted.

Definition at line 352 of file time_dependent.cc.

◆ get_backward_timestep()

double TimeStepBase::get_backward_timestep ( ) const

Compute the time difference to the last time step. If this timestep is the first one, this function will result in an exception. Though this behavior seems a bit drastic, it is appropriate in most cases since if there is no previous time step you will need special treatment anyway and this way no invalid value is returned which could lead to wrong but unnoticed results of your computation. (The only sensible value to return in that case would not be zero, since valid computation can be done with that, but would be a denormalized value such as NaN. However, there is not much difference in finding that the results of a computation are all denormalized values or in getting an exception; in the latter case you at least get the exact place where your problem lies.)

Definition at line 360 of file time_dependent.cc.

◆ get_forward_timestep()

double TimeStepBase::get_forward_timestep ( ) const

Return the time difference to the next time step. With regard to the case that there is no next time step, the same applies as for the function above.

Definition at line 371 of file time_dependent.cc.

◆ memory_consumption()

std::size_t TimeStepBase::memory_consumption ( ) const
virtual

Determine an estimate for the memory consumption (in bytes) of this object.

You will want to overload this function in derived classes to compute the amount memory used by the derived class, and add the result of this function to your result.

Reimplemented in TimeStepBase_Tria< dim >.

Definition at line 414 of file time_dependent.cc.

◆ set_previous_timestep()

void TimeStepBase::set_previous_timestep ( const TimeStepBase previous)
private

Reset the pointer to the previous time step; shall only be called by the time level manager object.

This function is called at the set-up of the manager object and whenever a timestep is inserted or deleted.

Definition at line 382 of file time_dependent.cc.

◆ set_next_timestep()

void TimeStepBase::set_next_timestep ( const TimeStepBase next)
private

Reset the pointer to the next time step; shall only be called by the time level manager object.

This function is called at the set-up of the manager object and whenever a timestep is inserted or deleted.

Definition at line 390 of file time_dependent.cc.

◆ set_timestep_no()

void TimeStepBase::set_timestep_no ( const unsigned int  step_no)
private

Set the number this time step has in the list of timesteps. This function is called by the time step management object at the beginning of each sweep, to update information which may have changed due to addition or deletion of time levels.

Definition at line 398 of file time_dependent.cc.

◆ set_sweep_no()

void TimeStepBase::set_sweep_no ( const unsigned int  sweep_no)
private

Set the number of the sweep we are presently in. This function is called by the time level management object at start-up time of each sweep.

Definition at line 406 of file time_dependent.cc.

Friends And Related Function Documentation

◆ TimeDependent

friend class TimeDependent
friend

Definition at line 944 of file time_dependent.h.

Member Data Documentation

◆ previous_timestep

const TimeStepBase* TimeStepBase::previous_timestep
protected

Pointer to the previous time step object in the list.

Definition at line 874 of file time_dependent.h.

◆ next_timestep

const TimeStepBase* TimeStepBase::next_timestep
protected

Pointer to the next time step object in the list.

Definition at line 879 of file time_dependent.h.

◆ sweep_no

unsigned int TimeStepBase::sweep_no
protected

Number of the sweep we are presently in. This number is reset by the time level manager before a sweep is started.

Definition at line 885 of file time_dependent.h.

◆ timestep_no

unsigned int TimeStepBase::timestep_no
protected

Number of the time step, counted from zero onwards. This number is reset at the start of each sweep by the time level manager, since some time steps may have been inserted or deleted after the previous sweep.

Definition at line 892 of file time_dependent.h.

◆ time

const double TimeStepBase::time
protected

Discrete time this level operates on.

Definition at line 897 of file time_dependent.h.

◆ next_action

unsigned int TimeStepBase::next_action
protected

Variable storing whether the solution of a primal or a dual problem is actual, or any of the other actions specified. This variable is set by the init_for_* functions.

Definition at line 904 of file time_dependent.h.


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