From 934f5ba5a536180331f6a30cb50f6e9877bb7a7d Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Sun, 19 Apr 2020 15:51:26 -0400 Subject: [PATCH] Inline code examples --- examples/CMakeLists.txt | 1 - .../deal.II/algorithms/theta_timestepping.h | 120 +++++++++++++++--- include/deal.II/lac/block_sparsity_pattern.h | 26 +++- 3 files changed, 121 insertions(+), 26 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index ed164e20e7..f5db9c5c7a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -34,7 +34,6 @@ IF(DEAL_II_COMPONENT_EXAMPLES) PATTERN "*.inp" PATTERN "*.ipynb" PATTERN "step*/CMakeLists.txt" - PATTERN "doxygen/CMakeLists.txt" # # Special files: # diff --git a/include/deal.II/algorithms/theta_timestepping.h b/include/deal.II/algorithms/theta_timestepping.h index 2f4ee26a20..0ba8f45146 100644 --- a/include/deal.II/algorithms/theta_timestepping.h +++ b/include/deal.II/algorithms/theta_timestepping.h @@ -124,10 +124,7 @@ namespace Algorithms * 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 - * - * @dontinclude theta_timestepping.cc + * following example for its use. * * First, we define the two operators used by ThetaTimestepping and call * them Implicit and Explicit. They both share the @@ -136,22 +133,58 @@ namespace Algorithms * use a SmartPointer here, since the TimestepData will be destroyed before * the operator. * - * @skip class Explicit - * @until End of declarations + * @code + * class Explicit : public OperatorBase + * { + * public: + * Explicit(const FullMatrix &matrix); + * void operator()(AnyData &out, const AnyData &in); + * + * private: + * SmartPointer, Explicit> matrix; + * FullMatrix m; + * }; + * + * class Implicit : public OperatorBase + * { + * public: + * Implicit(const FullMatrix &matrix); + * void operator()(AnyData &out, const AnyData &in); + * + * private: + * SmartPointer, Implicit> matrix; + * FullMatrix m; + * }; + * @endcode * * These operators will be implemented after the main program. But let us * look first 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 + * @code + * int main() + * { + * FullMatrix matrix(2); + * matrix(0, 0) = 0.; + * matrix(1, 1) = 0.; + * matrix(0, 1) = 3.14; + * matrix(1, 0) = -3.14; + * + * OutputOperator> out; + * out.initialize_stream(std::cout); + * @endcode * * Now we create objects for the implicit and explicit parts of the steps as * well as the ThetaTimestepping itself. We initialize the timestepping with * the output operator in order to be able to see the output in every step. * - * @until set_output + * @code + * Explicit op_explicit(matrix); + * Implicit op_implicit(matrix); + * ThetaTimestepping> solver(op_explicit, op_implicit); + * solver.set_output(out); + * @endcode * * 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 @@ -160,20 +193,35 @@ namespace Algorithms * Since our problem has no additional parameters, the input AnyData object * remains empty. * - * @until add + * @code + * Vector value(2); + * value(0) = 1.; + * AnyData indata; + * AnyData outdata; + * outdata.add(&value, "value"); + * @endcode * * Finally, we are ready to tell the solver, that we are starting at the * initial timestep and run it. * - * @until } + * @code + * solver.notify(Events::initial); + * solver(outdata, indata); + * } + * @endcode * * Besides the main function, we need to define the members functions * of the implicit and explicit operators. * First the constructor, which simply copies the system matrix into the * member pointer for later use. * - * @skip Explicit:: - * @until } + * @code + * Explicit::Explicit(const FullMatrix &M) + * : matrix(&M) + * { + * m.reinit(M.m(), M.n()); + * } + * @endcode * * Now we need to study the application of the implicit and explicit * operator. We assume that the pointer matrix points to the @@ -185,19 +233,55 @@ namespace Algorithms * off the notifications, we clear them, such that the matrix is only * generated when necessary. * - * @skipline void - * @until clear + * @code + * void Explicit::operator()(AnyData &out, const AnyData &in) + * { + * const double timestep = *in.read_ptr("Timestep"); + * if (this->notifications.test(Events::initial) || + * this->notifications.test(Events::new_timestep_size)) + * { + * m.equ(-timestep, *matrix); + * for (unsigned int i = 0; i < m.m(); ++i) + * m(i, i) += 1.; + * } + * this->notifications.clear(); + * @endcode * * Now we multiply the input vector with the new matrix and store on output. * - * @until } + * @code + * m.vmult(*out.entry *>(0), + * *in.read_ptr>("Previous iterate")); + * } + * @endcode * * The code for the implicit operator is almost the same, except * that we change the sign in front of the timestep and use the inverse of * the matrix. * - * @until vmult - * @until } + * @code + * Implicit::Implicit(const FullMatrix &M) + * : matrix(&M) + * { + * m.reinit(M.m(), M.n()); + * } + * + * void Implicit::operator()(AnyData &out, const AnyData &in) + * { + * const double timestep = *in.read_ptr("Timestep"); + * if (this->notifications.test(Events::initial) || + * this->notifications.test(Events::new_timestep_size)) + * { + * m.equ(timestep, *matrix); + * for (unsigned int i = 0; i < m.m(); ++i) + * m(i, i) += 1.; + * m.gauss_jordan(); + * } + * this->notifications.clear(); + * m.vmult(*out.entry *>(0), + * *in.read_ptr>("Previous time")); + * } + * @endcode * @author Guido Kanschat * @date 2010 */ diff --git a/include/deal.II/lac/block_sparsity_pattern.h b/include/deal.II/lac/block_sparsity_pattern.h index 71484356a4..577e9a5f77 100644 --- a/include/deal.II/lac/block_sparsity_pattern.h +++ b/include/deal.II/lac/block_sparsity_pattern.h @@ -482,26 +482,38 @@ public: * the use of block indices causes some additional complications, we give a * short example. * - * @dontinclude block_dynamic_sparsity_pattern.cc - * * After the DoFHandler dof and the AffineConstraints * constraints have been set up with a system element, we must count * the degrees of freedom in each matrix block: * - * @skipline dofs_per_block - * @until count + * @code + * const std::vector dofs_per_block = + * DoFTools::count_dofs_per_fe_block(dof); + * @endcode * * Now, we are ready to set up the BlockDynamicSparsityPattern. * - * @until collect + * @code + * BlockDynamicSparsityPattern dsp(fe.n_blocks(), fe.n_blocks()); + * for (unsigned int i = 0; i < fe.n_blocks(); ++i) + * for (unsigned int j = 0; j < fe.n_blocks(); ++j) + * dsp.block(i, j).reinit(dofs_per_block[i], dofs_per_block[j]); + * dsp.collect_sizes(); + * @endcode * * It is filled as if it were a normal pattern * - * @until condense + * @code + * DoFTools::make_sparsity_pattern(dof, dsp); + * constraints.condense(dsp); + * @endcode * * In the end, it is copied to a normal BlockSparsityPattern for later use. * - * @until copy + * @code + * BlockSparsityPattern sparsity; + * sparsity.copy_from(dsp); + * @endcode * * @author Wolfgang Bangerth, 2000, 2001, Guido Kanschat, 2006, 2007 */ -- 2.39.5