Luca Heltai [email protected]
For each of the point below, extend the Poisson class with functions that
perform the indicated tasks, trying to minimize the amount of code you copy and
paste, possibly restructuring existing code by adding arguments to existing
functions, and generating wrappers similar to the run method (e.g.,
run_exercise_3).
Once you created a function that performs the given task, add it to the
poisson-tester.cc file, and make sure all the exercises are run through the
gtest executable, e.g., adding a test for each exercise, as in the following
snippet:
TEST_F(PoissonTester, Exercise3) {
run_exercise_3();
}By the end of this laboratory, you will have a code that solves a Poisson problem in arbitrary dimensions, with Lagrangian finite elements of arbitrary degree, on different domain types, with different boundary conditions, and different functions for the definition of the right hand side, the stiffness coefficient, and the forcing term.
The problem will run on successively refined grids, and we will verify Bramble-Hilbert lemma for Lagrangian finite element spaces of different order, building manufactured solutions using python, and plotting error convergence tables using latex, tikz, and pgfplots.
The program will build on top of your implementation of Step3, drawing from
step-4, step-5, and step-7.
-
See documentation of step-4 at https://www.dealii.org/current/doxygen/deal.II/step_4.html
-
Compile and run step-4. Examine the source and header files.
-
Copy your implementation of
step-3fromlab-03to the filessource/poisson.cc,include/poisson.h, andtests/poisson-tester.cc, make sure you rename correctly all your files and classes toPoisson. -
Add the template parameter
<int dim>to yourPoissonclass, followingstep-4as an example, and make sure that your program runs correctly both in 2D and in 3D. -
Add the parameters
Number of refinement cyclesExact solution expression
and the corresponding member variables (i.e.,
n_cycles,exact_solution_expression, andexact_solution) and run the Poisson problem again for each refinement cycle with one global refinement, making sure you output the result for each refinement cycle separately invtuformat, i.e., ifOutput filenameispoisson_2d, andNumber of refinement cyclesis 3, you should outputpoisson_2d_0.vtupoisson_2d_1.vtupoisson_2d_2.vtu
where the solution in
poisson_2d_0.vtushould haveNumber of global refinementsrefinements,poisson_2d_1.vtushould haveNumber of global refinements+1 refinements, andpoisson_2d_2.vtushould haveNumber of global refinements+2 refinements. -
Add a
ParsedConvergenceTableobject to yourPoissonclass (see https://www.dealii.org/current/doxygen/deal.II/classParsedConvergenceTable.html) and add its parameters in the subsectionError tableof the parameter file, i.e., in thePoissonconstructor add the following lines of code:
this->prm.enter_subsection("Error table");
error_table.add_parameters(this->prm);
this->prm.leave_subsection();
-
Set the boundary conditions, forcing function, and exact expression to get the manufactured solution
u(x,y)=sin(pi*x)*cos(pi*y). Add a methodcompute_error()to thePoissonclass, that calls theParsedConvergenceTable::error_from_exactmethod with theexact_solutionfunction you created above. Make sure you output both the L2 and H1 error in text format to a file. Play with thejupyternotebookmanufactured_solutions.ipynbto construct non-trivial exact solutions. -
Add a parameter
Stiffness coefficient expressionand the corresponding members to thePoissonclass, so that the problem you will be solving is$-div(coefficient(x)\nabla u) = f(x)$ . -
Construct a (non-singular!) manufactured solution where
coefficientis a discontinuous function. Notice that the manufactured solution may need a discontinuous forcing term on the right hand side, but should not have other types of singularities, that is, you need to make sure that$coefficient(x)\nabla u$ is continuous, i.e., that$\nabla u$ has a jump depending on the jump of thecoefficient. Output the error tables, and comment on the error rates you observe. Do things improve when increasing the polynomial order? Why? -
(optional) Use the latex file provided in the latex subdirectory to generate professional convergence plots for your solutions.