From 5b7a6a8012659d77103016f42071812b32177ed1 Mon Sep 17 00:00:00 2001 From: Guido Kanschat Date: Thu, 8 Jul 2010 19:44:18 +0000 Subject: [PATCH] work example for ThetaTimestepping into documentation git-svn-id: https://svn.dealii.org/trunk@21464 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/numerics/theta_timestepping.h | 70 +++++++++++++++++-- .../examples/doxygen/theta_timestepping.cc | 8 +-- 2 files changed, 67 insertions(+), 11 deletions(-) diff --git a/deal.II/deal.II/include/numerics/theta_timestepping.h b/deal.II/deal.II/include/numerics/theta_timestepping.h index 0988553774..339a289c9a 100644 --- a/deal.II/deal.II/include/numerics/theta_timestepping.h +++ b/deal.II/deal.II/include/numerics/theta_timestepping.h @@ -60,11 +60,11 @@ namespace Algorithms * 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 with a + * 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 * * @f[ - * (M - \theta k A) u_{n+1} = (M + (1-\theta)k A) u_n. + * (M + \theta k A) u_{n+1} = (M - (1-\theta)k A) u_n. * @f] * * Here, M is the mass matrix. We see, that the right hand side @@ -98,15 +98,71 @@ namespace Algorithms * #op_implicit is directly written into the output argument given to * ThetaTimestepping. * - *

Setup

+ *

Usage of 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. First, we define - * the two operators - * + * and we include the following example for its use. It can be found + * in examples/doxygen/theta_timestepping.cc * - * @author Guido Kanschat, 2010 + * @dontinclude 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. + * + * @skip class Explicit + * @until End of declarations + * + * 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. + * + * @skipline main + * @until out.initialize + * + * 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. + * + * @until set_output + * + * 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. + * + * @until add + * + * Finally, we are ready to tell the solver, that we are looknig at + * the initial timestep and run it. + * + * @until outdata + * @skip Explicit::initialize + * + * 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. + * + * @skipline void + * @until vmult + * @until } + * + * @author Guido Kanschat + * @date 2010 */ template class ThetaTimestepping : public Operator diff --git a/deal.II/examples/doxygen/theta_timestepping.cc b/deal.II/examples/doxygen/theta_timestepping.cc index f4daa804ae..bf5b4dc067 100644 --- a/deal.II/examples/doxygen/theta_timestepping.cc +++ b/deal.II/examples/doxygen/theta_timestepping.cc @@ -57,7 +57,8 @@ class Implicit FullMatrix m; }; - +// End of declarations + int main() { FullMatrix matrix(2); @@ -74,17 +75,16 @@ int main() ThetaTimestepping > solver(op_explicit, op_implicit); op_explicit.initialize_timestep_data(solver.explicit_data()); op_implicit.initialize_timestep_data(solver.implicit_data()); - solver.notify(Events::initial); + solver.set_output(out); Vector value(2); value(0) = 1.; - NamedData*> indata; NamedData*> outdata; Vector* p = &value; outdata.add(p, "value"); - solver.set_output(out); + solver.notify(Events::initial); solver(outdata, indata); } -- 2.39.5