Reference documentation for deal.II version 9.1.0-pre
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

Public Member Functions

 TimeStepBase (const double time)
 
virtual ~TimeStepBase () override=default
 
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
 
- Public Member Functions inherited from Subscriptor
 Subscriptor ()
 
 Subscriptor (const Subscriptor &)
 
 Subscriptor (Subscriptor &&) noexcept
 
virtual ~Subscriptor ()
 
Subscriptoroperator= (const Subscriptor &)
 
Subscriptoroperator= (Subscriptor &&) noexcept
 
void subscribe (const char *identifier=nullptr) const
 
void unsubscribe (const char *identifier=nullptr) 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)
 

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)
 
 TimeStepBase (const TimeStepBase &)=delete
 
TimeStepBaseoperator= (const TimeStepBase &)=delete
 

Friends

class TimeDependent
 

Additional Inherited Members

- Static Public Member Functions inherited from Subscriptor
static::ExceptionBase & ExcInUse (int arg1, std::string arg2, std::string arg3)
 
static::ExceptionBase & ExcNoSubscriber (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.

Author
Wolfgang Bangerth, 1999

Definition at line 664 of file time_dependent.h.

Member Enumeration Documentation

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 670 of file time_dependent.h.

Constructor & Destructor Documentation

TimeStepBase::TimeStepBase ( const double  time)

Constructor. Does nothing here apart from setting the time.

Definition at line 269 of file time_dependent.cc.

virtual TimeStepBase::~TimeStepBase ( )
overridevirtualdefault

Destructor. At present, this does nothing.

TimeStepBase::TimeStepBase ( const TimeStepBase )
privatedelete

Copy constructor. I can see no reason why someone might want to use it, so I don't provide it. Since this class has pointer members, making it private prevents the compiler to provide it's own, incorrect one if anyone chose to copy such an object.

Member Function Documentation

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 281 of file time_dependent.cc.

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 287 of file time_dependent.cc.

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 293 of file time_dependent.cc.

void TimeStepBase::end_sweep ( )
virtual

This is the analogon 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 299 of file time_dependent.cc.

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 305 of file time_dependent.cc.

void TimeStepBase::init_for_dual_problem ( )
virtual

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

Definition at line 313 of file time_dependent.cc.

void TimeStepBase::init_for_postprocessing ( )
virtual

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

Definition at line 321 of file time_dependent.cc.

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.

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 329 of file time_dependent.cc.

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 337 of file time_dependent.cc.

double TimeStepBase::get_time ( ) const

Return the time value of this time step.

Definition at line 345 of file time_dependent.cc.

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 353 of file time_dependent.cc.

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 behaviour 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 361 of file time_dependent.cc.

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 372 of file time_dependent.cc.

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 415 of file time_dependent.cc.

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 383 of file time_dependent.cc.

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 391 of file time_dependent.cc.

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 deleltion of time levels.

Definition at line 399 of file time_dependent.cc.

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 407 of file time_dependent.cc.

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

Copy operator. I can see no reason why someone might want to use it, so I don't provide it. Since this class has pointer members, making it private prevents the compiler to provide it's own, incorrect one if anyone chose to copy such an object.

Member Data Documentation

const TimeStepBase* TimeStepBase::previous_timestep
protected

Pointer to the previous time step object in the list.

Definition at line 860 of file time_dependent.h.

const TimeStepBase* TimeStepBase::next_timestep
protected

Pointer to the next time step object in the list.

Definition at line 865 of file time_dependent.h.

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 871 of file time_dependent.h.

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 878 of file time_dependent.h.

const double TimeStepBase::time
protected

Discrete time this level operates on.

Definition at line 883 of file time_dependent.h.

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 890 of file time_dependent.h.


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