This repository contains the source code for the deal.II crash course of the 10th deal.II Users and Developers Workshop. In addition, the accompanying presentation can be found here.
The course is structured in two sessions. In the first session, the basic layout of a deal.II program will be covered by solving a stationary Poisson's problem. The second session will be dedicated to the solution of a time-dependent problem. More concrete, a linear Heat equation.
In both case, a code skeleton is provided which should be filled in a gap text manner. The sessions' folders can be found by their names. In addition, each session folder contains a solution folder which includes a working code solution.
cmake -DDEAL_II_DIR=PATH2DEALII .
: buildmake release
: switch from debug to release modemake
: compile codemake run
: run code
Session 1 aims to solve Poisson's problem and is oriented on step-3 of the deal.II tutorial program.
Let
In this exercise, let:
$\Omega = (-1,1)^2$ -
$f = 1$ , -
$g = 0$ .
Exemplary solutions for
The missing gaps are marked by /* MISSING CODE /*
comments. The following steps must be done to complete the code:
- Complete
Poisson::run()
.- This method is used as a central place to call the other methods of the class to solve the problem.
- Complete
Poisson::make_grid()
by generating the mesh, c.f. deal.II GridGenerator. - Complete
Poisson::assemble_system()
.- Get the
FEValues<2> fe_values
, c.f. FEValues Constructor and FEValues update flags. - Reset the local cell's contributions.
- Assemble system matrix contributions.
- Assemble the rhs contribution.
- Transfer the local elements to the global matrix.
- Transfer the local elements to the global rhs.
- Set Dirichlet boundary conditions.
- Get the
For further Interaction with the code, there are two bonus exercises that could be done to extend the code. These are marked in the code by /* BONUS */
.
- Try out and replace the homogeneous Dirichlet BC by non-zero BC.
- Investigate the solution on successively refined meshes.
Let
where
In this exercise, let
-
$u_D = 0$ , -
$u_0 = \sin(x_1)\sin(x_2)$ , -
$f = 0$ , -
$\alpha(x) = 1$ .
The solution for
The missing gaps are marked by /* MISSING CODE /*
comments. The following steps must be done to complete the code:
- In
main()
: Initialize a 2D instance of theStep_Heat
class and start the solution process. - In
Step_Heat<dim>::run()
: Call the grid generation and the system setup. - In
Step_Heat<dim>::setup_system()
:- Create the sparsity pattern.
- Initialize the rhs and solutions vectors.
- Note, that a vector to store the old solution is required.
- In
InitialValues<dim>::value
: Add the initial condition for the solution. - In
Step_Heat<dim>::run()
:- Call the assemble of the system for each new time step solve.
- Solve the LES.
- Add the stopping criterion for the time step loop.
- In
Step_Heat<dim>::assemble_system()
:- Add the
fe_values
. - Add mass matrix contribution to
cell_matrix
. - Add stiffness matrix contribution to
cell_matrix
. - Add rhs values contributions to
cell_vector
. - Add old time step solution contributions to
cell_vector
.
- Add the
For further Interaction with the code, there are two bonus exercises that could be done to extend the code. These are marked in the code by /* BONUS 1 */
and /* BONUS 2 */
, respectively.
- The code contains the possibility to choose a space-dependent
$\alpha(x) \leq 0$ . Try to simulate the heat equation with two different heat coefficients.- In
Coefficient<dim>::value
: Return a space dependent heat coefficient. - In
assemble_system
: Add theconst Coefficient<dim> coefficient
and its contributions in the assembly ofcell_matrix
.
- In
- Previously, we choose a homogenous RHS. Try to extend this top a non-zero RHS.
Should you have any questions do not hesitate to send us an email at
fischer@ifam.uni-hannover.de
wick@ifam.uni-hannover.de