![]() |
Reference documentation for deal.II version 8.1.0
|
#include <theta_timestepping.h>
Public Member Functions | |
ThetaTimestepping (Operator< VECTOR > &op_explicit, Operator< VECTOR > &op_implicit) | |
virtual void | operator() (NamedData< VECTOR * > &out, const NamedData< VECTOR * > &in) |
virtual void | notify (const Event &) |
void | set_output (OutputOperator< VECTOR > &output) |
void | declare_parameters (ParameterHandler ¶m) |
void | initialize (ParameterHandler ¶m) |
const double & | current_time () const |
const double & | step_size () const |
const double & | theta () const |
const TimestepData & | explicit_data () const |
const TimestepData & | implicit_data () const |
TimestepControl & | timestep_control () |
![]() | |
~Operator () | |
void | clear_events () |
![]() | |
Subscriptor () | |
Subscriptor (const Subscriptor &) | |
virtual | ~Subscriptor () |
Subscriptor & | operator= (const Subscriptor &) |
void | subscribe (const char *identifier=0) const |
void | unsubscribe (const char *identifier=0) const |
unsigned int | n_subscriptions () const |
void | list_subscribers () const |
DeclException3 (ExcInUse, int, char *, std::string &,<< "Object of class "<< arg2<< " is still used by "<< arg1<< " other objects.\n"<< "(Additional information: "<< arg3<< ")\n"<< "Note the entry in the Frequently Asked Questions of "<< "deal.II (linked to from http://www.dealii.org/) for "<< "more information on what this error means.") | |
DeclException2 (ExcNoSubscriber, char *, char *,<< "No subscriber with identifier \""<< arg2<< "\" did subscribe to this object of class "<< arg1) | |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
Private Attributes | |
TimestepControl | control |
double | vtheta |
bool | adaptive |
TimestepData | d_explicit |
TimestepData | d_implicit |
SmartPointer< Operator< VECTOR >, ThetaTimestepping< VECTOR > > | op_explicit |
SmartPointer< Operator< VECTOR >, ThetaTimestepping< VECTOR > > | op_implicit |
SmartPointer< OutputOperator< VECTOR >, ThetaTimestepping< VECTOR > > | output |
Additional Inherited Members | |
![]() | |
Event | notifications |
Application class performing the theta timestepping scheme.
The theta scheme is an abstraction of implicit and explicit Euler schemes, the Crank-Nicholson scheme and linear combinations of those. The choice of the actual scheme is controlled by the parameter theta as follows.
For fixed theta, the Crank-Nicholson scheme is the only second order scheme. Nevertheless, further stability may be achieved by choosing theta larger than ½, thereby introducing a first order error term. In order to avoid a loss of convergence order, the adaptive theta scheme can be used, where theta=½+c dt.
Assume that we want to solve the equation u' + Au = 0 with a step size k. A step of the theta scheme can be written as
Here, M is the mass matrix. We see, that the right hand side amounts to an explicit Euler step with modified step size in weak form (up to inversion of M). The left hand side corresponds to an implicit Euler step with modified step size (right hand side given). Thus, the implementation of the theta scheme will use two Operator objects, one for the explicit, one for the implicit part. Each of these will use its own TimestepData to account for the modified step sizes (and different times if the problem is not autonomous).
ThetaTimestepping uses NamedData for communicating vectors. With outer or inner Operator objects. It does not use itself the input vectors provided, but forwards them to the explicit and implicit operators.
The explicit Operator op_explicit receives in its input in first place the vector "Previous iterate"
, which is the solution value after the previous timestep. It is followed by all vectors provided to ThetaTimestepping::operator() as input argument. op_explicit is supposed to write its result into the first position of its output argument, labeled "Result"
.
The implicit Operator op_implicit receives the result of op_explicit in its first input vector labeled "Previous
time"
. It is followed by all vectors provided to ThetaTimestepping::operator() as input argument. The output of op_implicit is directly written into the output argument given to ThetaTimestepping.
The use ThetaTimestepping is more complicated than for instance Newton, since the inner operators will usually need to access the TimeStepData. Thus, we have a circular dependency of information, and we include the following example for its use. It can be found in examples/doxygen/theta_timestepping.cc
First, we define the two operators used by ThetaTimestepping and call them Implicit
and Explicit
. They both share the public interface of Operator, and additionally provide storage for the matrices to be used and a pointer to TimestepData. Note that we do not use a SmartPointer here, since the TimestepData will be destroyed before the operator.
These operators will be implemented after the main program. But let us look at how they get used. First, let us define a matrix to be used for our system and also an OutputOperator in order to write the data of each timestep to a file.
Now we create objects for the implicit and explicit parts of the steps as well as the ThetaTimestepping itself. Notice how the TimestepData of ThetaTimestepping gets forwarded to the inner operators. There are two different data objects, because the timestep size is modified by theta.
The next step is providing the vectors to be used. value
is filled with the initial value and is also the vector where the solution at each timestep will be. Because the interface of Operator has to be able to handle several vectors, we need to store it in a NamedData object. Notice, that we need to create the intermediate pointer p
. If we would use &value
directly in the add
function, the resulting object would be constant.
Finally, we are ready to tell the solver, that we are looknig at the initial timestep and run it.
Now we need to study the application of the implicit and explicit operator. We assume that the pointer matrix
points to the matrix created in the main program, and that timestep_data
points to the correct data object of ThetaTimestepping.
Definition at line 173 of file theta_timestepping.h.
Algorithms::ThetaTimestepping< VECTOR >::ThetaTimestepping | ( | Operator< VECTOR > & | op_explicit, |
Operator< VECTOR > & | op_implicit | ||
) |
Constructor, receiving the two operators stored in op_explicit and op_implicit. For their meening, see the description of those variables.
Definition at line 28 of file theta_timestepping.templates.h.
|
virtual |
The timestepping scheme. in
should contain the initial value in first position. out
Implements Algorithms::Operator< VECTOR >.
Definition at line 66 of file theta_timestepping.templates.h.
|
virtual |
Register an event triggered by an outer iteration.
Reimplemented from Algorithms::Operator< VECTOR >.
Definition at line 35 of file theta_timestepping.templates.h.
|
inline |
Define an operator which will output the result in each step. Note that no output will be generated without this.
Definition at line 360 of file theta_timestepping.h.
const double& Algorithms::ThetaTimestepping< VECTOR >::current_time | ( | ) | const |
The current time in the timestepping scheme.
const double& Algorithms::ThetaTimestepping< VECTOR >::step_size | ( | ) | const |
The current step size.
const double& Algorithms::ThetaTimestepping< VECTOR >::theta | ( | ) | const |
The weight between implicit and explicit part.
|
inline |
The data handed to the op_explicit time stepping operator.
The time in here is the time at the beginning of the current step, the time step is (1-theta) times the actual time step.
Definition at line 344 of file theta_timestepping.h.
|
inline |
The data handed to the op_implicit time stepping operator.
The time in here is the time at the beginning of the current step, the time step is theta times the actual time step.
Definition at line 353 of file theta_timestepping.h.
TimestepControl& Algorithms::ThetaTimestepping< VECTOR >::timestep_control | ( | ) |
Allow access to the control object.
|
private |
The object controlling the time step size and computing the new time in each step.
Definition at line 262 of file theta_timestepping.h.
|
private |
The control parameter theta in the range [0,1]
.
Definition at line 268 of file theta_timestepping.h.
|
private |
Use adaptive theta if true
.
Definition at line 273 of file theta_timestepping.h.
|
private |
The data for the explicit part of the scheme.
Definition at line 279 of file theta_timestepping.h.
|
private |
The data for the implicit part of the scheme.
Definition at line 285 of file theta_timestepping.h.
|
private |
The operator computing the explicit part of the scheme. This will receive in its input data the value at the current time with name "Current time solution". It should obtain the current time and time step size from explicit_data().
Its return value is Mu+cAu, where u is the current state vector, M the mass matrix, A the operator in space and c is the time step size in explicit_data().
Definition at line 308 of file theta_timestepping.h.
|
private |
The operator solving the implicit part of the scheme. It will receive in its input data the vector "Previous time". Information on the timestep should be obtained from implicit_data().
Its return value is the solution u of Mu-cAu=f, where f is the dual space vector found in the "Previous time" entry of the input data, M the mass matrix, A the operator in space and c is the time step size in explicit_data().
Definition at line 331 of file theta_timestepping.h.
|
private |
The operator writing the output in each time step
Definition at line 337 of file theta_timestepping.h.