Reference documentation for deal.II version Git d435e92be9 2020-09-23 09:04:26 -0400
TimeStepBase_Tria< dim > Class Template Referenceabstract

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

Inheritance diagram for TimeStepBase_Tria< dim >:
[legend]

## Public Types

enum  SolutionState { grid_refinement = 0x1000 }

using Flags = typename TimeStepBase_Tria_Flags::Flags< dim >

using RefinementFlags = typename TimeStepBase_Tria_Flags::RefinementFlags< dim >

using RefinementData = typename TimeStepBase_Tria_Flags::RefinementData< dim >

## Public Member Functions

TimeStepBase_Tria ()

TimeStepBase_Tria (const double time, const Triangulation< dim, dim > &coarse_grid, const Flags &flags, const RefinementFlags &refinement_flags=RefinementFlags())

virtual ~TimeStepBase_Tria () override

virtual void wake_up (const unsigned int wakeup_level) override

virtual void sleep (const unsigned int) override

void refine_grid (const RefinementData data)

virtual void init_for_refinement ()

virtual void get_tria_refinement_criteria (Vector< float > &criteria) const =0

void save_refine_flags ()

virtual std::size_t memory_consumption () const override

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

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)

## Static Public Member Functions

static ::ExceptionBaseExcGridNotDeleted ()

static ::ExceptionBaseExcInUse (int arg1, std::string arg2, std::string arg3)

static ::ExceptionBaseExcNoSubscriber (std::string arg1, std::string arg2)

## Protected Attributes

SmartPointer< Triangulation< dim, dim >, TimeStepBase_Tria< dim > > tria

SmartPointer< const Triangulation< dim, dim >, TimeStepBase_Tria< dim > > coarse_grid

const Flags flags

const RefinementFlags refinement_flags

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 restore_grid ()

## Private Attributes

std::vector< std::vector< bool > > refine_flags

std::vector< std::vector< bool > > coarsen_flags

## Detailed Description

### template<int dim> class TimeStepBase_Tria< dim >

Specialization of TimeStepBase which addresses some aspects of grid handling. In particular, this class is thought to make handling of grids available that are adaptively refined on each time step separately or with a loose coupling between time steps. It also takes care of deleting and rebuilding grids when memory resources are a point, through the sleep and wake_up functions declared in the base class.

In addition to that, it offers functions which do some rather hairy refinement rules for time dependent problems, trying to avoid too much change in the grids between subsequent time levels, while also trying to retain the freedom of refining each grid separately. There are lots of flags and numbers controlling this function, which might drastically change the behaviour of the function – see the description of the flags for further information.

Definition at line 1304 of file time_dependent.h.

## ◆ Flags

template<int dim>
 using TimeStepBase_Tria< dim >::Flags = typename TimeStepBase_Tria_Flags::Flags

Typedef the data types of the TimeStepBase_Tria_Flags() namespace into local scope.

Definition at line 1311 of file time_dependent.h.

## ◆ RefinementFlags

template<int dim>
 using TimeStepBase_Tria< dim >::RefinementFlags = typename TimeStepBase_Tria_Flags::RefinementFlags

Definition at line 1313 of file time_dependent.h.

## ◆ RefinementData

template<int dim>
 using TimeStepBase_Tria< dim >::RefinementData = typename TimeStepBase_Tria_Flags::RefinementData

Definition at line 1314 of file time_dependent.h.

## ◆ SolutionState

template<int dim>

Extension of the enum in the base class denoting the next action to be done.

Enumerator
grid_refinement

Perform grid refinement next.

Definition at line 1321 of file time_dependent.h.

## ◆ TimeStepBase_Tria() [1/2]

template<int dim>
 TimeStepBase_Tria< dim >::TimeStepBase_Tria ( )

Default constructor. Does nothing but throws an exception. We need to have such a constructor in order to satisfy the needs of derived classes, which take this class as a virtual base class and don't need to call this constructor of they are not terminal classes. The compiler would like to know a constructor to call anyway since it can't know that the class is not terminal.

Definition at line 423 of file time_dependent.cc.

## ◆ TimeStepBase_Tria() [2/2]

template<int dim>
 TimeStepBase_Tria< dim >::TimeStepBase_Tria ( const double time, const Triangulation< dim, dim > & coarse_grid, const Flags & flags, const RefinementFlags & refinement_flags = RefinementFlags() )

Constructor. Takes a coarse grid from which the grids on this time level will be derived and some flags steering the behaviour of this object.

The ownership of the coarse grid stays with the creator of this object. However, it is locked from destruction to guarantee the lifetime of the coarse grid is longer than it is needed by this object.

You need to give the general flags structure to this function since it is needed anyway; the refinement flags can be omitted if you do not intend to call the refinement function of this class.

## ◆ ~TimeStepBase_Tria()

template<int dim>
 TimeStepBase_Tria< dim >::~TimeStepBase_Tria ( )
overridevirtual

Destructor. At present, this does not more than releasing the lock on the coarse grid triangulation given to the constructor.

Definition at line 453 of file time_dependent.cc.

## ◆ wake_up()

template<int dim>
 void TimeStepBase_Tria< dim >::wake_up ( const unsigned int wakeup_level )
overridevirtual

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. By default, this function rebuilds the triangulation if the respective flag has been set to destroy it in the sleep function. It does so also the first time we hit this function and wakeup_level equals flags.wakeup_level_to_build_grid, independently of the value of the mentioned flag. (Actually, it does so whenever the triangulation pointer equals the Null pointer and the value of wakeup_level is right.)

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 from TimeStepBase.

Definition at line 471 of file time_dependent.cc.

## ◆ sleep()

template<int dim>
 void TimeStepBase_Tria< dim >::sleep ( const unsigned int sleep_level )
overridevirtual

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, if the user specified so in the flags for this object, the triangulation is deleted and the refinement history is saved such that the respective wake_up function can rebuild it. You should therefore call this function from your overloaded version, preferably at the end so that your function can use the triangulation as long as you need it.

Reimplemented from TimeStepBase.

Definition at line 484 of file time_dependent.cc.

## ◆ refine_grid()

template<int dim>
 void TimeStepBase_Tria< dim >::refine_grid ( const RefinementData data )

Do the refinement according to the flags passed to the constructor of this object and the data passed to this function. For a description of the working of this function refer to the general documentation of this class.

In fact, this function does not actually refine or coarsen the triangulation, but only sets the respective flags. This is done because usually you will not need the grid immediately afterwards but only in the next sweep, so it suffices to store the flags and rebuild it the next time we need it. Also, it may be that the next time step would like to add or delete some flags, so we have to wait anyway with the use of this grid.

Definition at line 737 of file time_dependent.cc.

## ◆ init_for_refinement()

template<int dim>
 void TimeStepBase_Tria< dim >::init_for_refinement ( )
virtual

Respective init function for the refinement loop; does nothing in the default implementation, apart from setting next_action to grid_refinement but can be overloaded.

Definition at line 1141 of file time_dependent.cc.

## ◆ get_tria_refinement_criteria()

template<int dim>
 virtual void TimeStepBase_Tria< dim >::get_tria_refinement_criteria ( Vector< float > & criteria ) const
pure virtual

Virtual function that should fill the vector with the refinement criteria for the present triangulation. It is used within the refine_grid function to get the criteria for the present time step, since they can't be passed through its argument when using the loop of the time step management object.

## ◆ save_refine_flags()

template<int dim>
 void TimeStepBase_Tria< dim >::save_refine_flags ( )

The refinement flags of the triangulation are stored in a local variable thus allowing a restoration. The coarsening flags are also stored.

Definition at line 505 of file time_dependent.cc.

## ◆ memory_consumption()

template<int dim>
 std::size_t TimeStepBase_Tria< dim >::memory_consumption ( ) const
overridevirtual

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 from TimeStepBase.

Definition at line 1150 of file time_dependent.cc.

## ◆ restore_grid()

template<int dim>
 void TimeStepBase_Tria< dim >::restore_grid ( )
private

Restore the grid according to the saved data. For this, the coarse grid is copied and the grid is stepwise rebuilt using the saved flags.

Definition at line 519 of file time_dependent.cc.

## ◆ start_sweep()

 void TimeStepBase::start_sweep ( )
virtualinherited

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 ( )
virtualinherited

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 ( )
virtualinherited

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 ( )
virtualinherited

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 ( )
virtualinherited

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 virtualinherited

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 ( )
virtualinherited

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 ( )
virtualinherited

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
inherited

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
inherited

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
inherited

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

## ◆ get_forward_timestep()

 double TimeStepBase::get_forward_timestep ( ) const
inherited

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.

## ◆ subscribe()

 void Subscriptor::subscribe ( std::atomic< bool > *const validity, const std::string & identifier = "" ) const
inherited

Subscribes a user of the object by storing the pointer validity. The subscriber may be identified by text supplied as identifier.

Definition at line 136 of file subscriptor.cc.

## ◆ unsubscribe()

 void Subscriptor::unsubscribe ( std::atomic< bool > *const validity, const std::string & identifier = "" ) const
inherited

Unsubscribes a user from the object.

Note
The identifier and the validity pointer must be the same as the one supplied to subscribe().

Definition at line 156 of file subscriptor.cc.

## ◆ n_subscriptions()

 unsigned int Subscriptor::n_subscriptions ( ) const
inlineinherited

Return the present number of subscriptions to this object. This allows to use this class for reference counted lifetime determination where the last one to unsubscribe also deletes the object.

Definition at line 290 of file subscriptor.h.

## ◆ list_subscribers() [1/2]

template<typename StreamType >
 void Subscriptor::list_subscribers ( StreamType & stream ) const
inlineinherited

List the subscribers to the input stream.

Definition at line 307 of file subscriptor.h.

## ◆ list_subscribers() [2/2]

 void Subscriptor::list_subscribers ( ) const
inherited

List the subscribers to deallog.

Definition at line 204 of file subscriptor.cc.

## ◆ serialize()

template<class Archive >
 void Subscriptor::serialize ( Archive & ar, const unsigned int version )
inlineinherited

Read or write the data of this object to or from a stream for the purpose of serialization.

This function does not actually serialize any of the member variables of this class. The reason is that what this class stores is only who subscribes to this object, but who does so at the time of storing the contents of this object does not necessarily have anything to do with who subscribes to the object when it is restored. Consequently, we do not want to overwrite the subscribers at the time of restoring, and then there is no reason to write the subscribers out in the first place.

Definition at line 299 of file subscriptor.h.

## ◆ tria

template<int dim>
 SmartPointer, TimeStepBase_Tria > TimeStepBase_Tria< dim >::tria
protected

Triangulation used at this time level. Since this is something that every time stepping scheme needs to have, we can safely put it into the base class. Note that the triangulation is frequently deleted and rebuilt by the functions sleep and wake_up to save memory, if such a behaviour is specified in the flags structure.

Definition at line 1471 of file time_dependent.h.

## ◆ coarse_grid

template<int dim>
 SmartPointer, TimeStepBase_Tria > TimeStepBase_Tria< dim >::coarse_grid
protected

Pointer to a grid which is to be used as the coarse grid for this time level. This pointer is set through the constructor; ownership remains with the owner of this management object.

Definition at line 1479 of file time_dependent.h.

## ◆ flags

template<int dim>
 const Flags TimeStepBase_Tria< dim >::flags
protected

Some flags about how this time level shall behave. See the documentation of this struct to find out more about that.

Definition at line 1485 of file time_dependent.h.

## ◆ refinement_flags

template<int dim>
 const RefinementFlags TimeStepBase_Tria< dim >::refinement_flags
protected

Flags controlling the refinement process; see the documentation of the respective structure for more information.

Definition at line 1491 of file time_dependent.h.

## ◆ refine_flags

template<int dim>
 std::vector > TimeStepBase_Tria< dim >::refine_flags
private

Vectors holding the refinement and coarsening flags of the different sweeps on this time level. The vectors therefore hold the history of the grid.

Definition at line 1499 of file time_dependent.h.

## ◆ coarsen_flags

template<int dim>
 std::vector > TimeStepBase_Tria< dim >::coarsen_flags
private

Definition at line 1504 of file time_dependent.h.

## ◆ previous_timestep

 const TimeStepBase* TimeStepBase::previous_timestep
protectedinherited

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
protectedinherited

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
protectedinherited

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
protectedinherited

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
protectedinherited

Discrete time this level operates on.

Definition at line 897 of file time_dependent.h.

## ◆ next_action

 unsigned int TimeStepBase::next_action
protectedinherited

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: