--- /dev/null
+# Example Testing
+
+This folder, that is part of the deal.II testsuite, contains the logic
+to run the deal.II examples (located under ./examples/ in the
+repository) as automated tests using CTest. Instead of storing copies
+of the source code of these example, we only store a fairly small
+textual diff for each example. This is motivated by the lesson, that
+copies of examples very quickly become out of date and we repeatedly
+fail to detect if an example program breaks due to a change in the
+library.
+
+## Usage
+
+When running the ``setup_tests`` or ``setup_tests_examples`` target in
+a deal.II build directory, the diff files will be used to create
+temporary .cc files located at
+``build/tests/examples/source/step-*.cc``.
+
+For development of new examples, we suggest first creating an empty
+.diff and .output file in the tests/examples/ folders and then running
+``setup_tests`` to pick up the new test.
+
+To modify the source code, go into ``build/tests/examples/source/``
+and edit the .cc file there. Afterwards, you can update the .diff
+files by running the ``update_diffs`` target in that folder.
--- /dev/null
+272,273c272,273
+< table.evaluate_all_convergence_rates(
+< ConvergenceTable::reduction_rate_log2);
+---
+> //table.evaluate_all_convergence_rates(
+> // ConvergenceTable::reduction_rate_log2);
+357,358c357,358
+< table.evaluate_all_convergence_rates(
+< ConvergenceTable::reduction_rate_log2);
+---
+> //table.evaluate_all_convergence_rates(
+> // ConvergenceTable::reduction_rate_log2);
+360c360
+< table.set_precision("eval.pi", 16);
+---
+> table.set_precision("eval.pi", 14);
--- /dev/null
+Output of grids into gnuplot files:
+===================================
+Refinement level: 0
+Degree = 1
+Degree = 2
+Degree = 3
+
+Refinement level: 1
+Degree = 1
+Degree = 2
+Degree = 3
+
+Computation of Pi by the area:
+==============================
+Degree = 1
+cells eval.pi error
+ 5 1.9999999999999987 1.1416e+00
+ 20 2.8284271247461947 3.1317e-01
+ 80 3.0614674589207289 8.0125e-02
+ 320 3.1214451522579965 2.0148e-02
+ 1280 3.1365484905461289 5.0442e-03
+ 5120 3.1403311569547396 1.2615e-03
+
+Degree = 2
+cells eval.pi error
+ 5 3.1045694996615842 3.7023e-02
+ 20 3.1391475703122338 2.4451e-03
+ 80 3.1414377167038370 1.5494e-04
+ 320 3.1415829366418526 9.7169e-06
+ 1280 3.1415920457578816 6.0783e-07
+ 5120 3.1415926155921077 3.7998e-08
+
+Degree = 3
+cells eval.pi error
+ 5 3.1410033851499315 5.8927e-04
+ 20 3.1415830393583932 9.6142e-06
+ 80 3.1415925017363935 1.5185e-07
+ 320 3.1415926512106194 2.3792e-09
+ 1280 3.1415926535527809 3.7012e-11
+ 5120 3.1415926535891971 5.9597e-13
+
+Degree = 4
+cells eval.pi error
+ 5 3.1415871927401127 5.4608e-06
+ 20 3.1415926314742517 2.2116e-08
+ 80 3.1415926535026317 8.7161e-11
+ 320 3.1415926535893943 3.9879e-13
+ 1280 3.1415926535899694 1.7630e-13
+ 5120 3.1415926535897674 2.5757e-14
+
+Computation of Pi by the perimeter:
+===================================
+Degree = 1
+cells eval.pi error
+ 5 2.82842712474619 3.1317e-01
+ 20 3.06146745892072 8.0125e-02
+ 80 3.12144515225805 2.0148e-02
+ 320 3.13654849054594 5.0442e-03
+ 1280 3.14033115695475 1.2615e-03
+ 5120 3.14127725093278 3.1540e-04
+
+Degree = 2
+cells eval.pi error
+ 5 3.12489306685506 1.6700e-02
+ 20 3.14040506056054 1.1876e-03
+ 80 3.14151576318070 7.6890e-05
+ 320 3.14158780427986 4.8493e-06
+ 1280 3.14159234981746 3.0377e-07
+ 5120 3.14159263459320 1.8997e-08
+
+Degree = 3
+cells eval.pi error
+ 5 3.14149404014561 9.8613e-05
+ 20 3.14159134325492 1.3103e-06
+ 80 3.14159263417269 1.9417e-08
+ 320 3.14159265329069 2.9910e-10
+ 1280 3.14159265358513 4.6585e-12
+ 5120 3.14159265358971 7.9048e-14
+
+Degree = 4
+cells eval.pi error
+ 5 3.14159210294326 5.5065e-07
+ 20 3.14159265137376 2.2160e-09
+ 80 3.14159265358107 8.7228e-12
+ 320 3.14159265358976 3.4639e-14
+ 1280 3.14159265358979 4.4409e-15
+ 5120 3.14159265358979 1.3323e-15
+
--- /dev/null
+Using mapping with degree 1:
+============================
+cells |u|_1 error
+ 5 0.680402 0.572912
+ 20 1.088141 0.165173
+ 80 1.210142 0.043172
+ 320 1.242375 0.010939
+ 1280 1.250569 0.002745
+ 5120 1.252627 0.000687
+
+Using mapping with degree 2:
+============================
+cells |u|_1 error
+ 5 1.177062 0.076252
+ 20 1.228978 0.024336
+ 80 1.245175 0.008139
+ 320 1.250881 0.002433
+ 1280 1.252646 0.000668
+ 5120 1.253139 0.000175
+
+Using mapping with degree 3:
+============================
+cells |u|_1 error
+ 5 1.193493 0.059821
+ 20 1.229825 0.023489
+ 80 1.245221 0.008094
+ 320 1.250884 0.002430
+ 1280 1.252646 0.000668
+ 5120 1.253139 0.000175
+
--- /dev/null
+20a21
+> #include "../example_test.h"
+495c496,500
+< solver.solve(system_matrix, solution, right_hand_side, preconditioner);
+---
+> check_solver_within_range(std::cout,
+> solver.solve(system_matrix, solution, right_hand_side, preconditioner),
+> solver_control.last_step(),
+> 3,
+> 100);
+497,498c502,503
+< std::cout << " Solver converged in " << solver_control.last_step()
+< << " iterations." << std::endl;
+---
+> //std::cout << " Solver converged in " << solver_control.last_step()
+> // << " iterations." << std::endl;
--- /dev/null
+Cycle 0
+ Number of active cells: 64
+ Number of degrees of freedom: 256
+Solver stopped within 3 - 100 iterations
+ Writing solution to <solution-0.vtk>
+ L-infinity norm: 1.09057
+Cycle 1
+ Number of active cells: 109
+ Number of degrees of freedom: 436
+Solver stopped within 3 - 100 iterations
+ Writing solution to <solution-1.vtk>
+ L-infinity norm: 1.10402
+Cycle 2
+ Number of active cells: 205
+ Number of degrees of freedom: 820
+Solver stopped within 3 - 100 iterations
+ Writing solution to <solution-2.vtk>
+ L-infinity norm: 1.09813
+Cycle 3
+ Number of active cells: 394
+ Number of degrees of freedom: 1576
+Solver stopped within 3 - 100 iterations
+ Writing solution to <solution-3.vtk>
+ L-infinity norm: 1.09579
+Cycle 4
+ Number of active cells: 766
+ Number of degrees of freedom: 3064
+Solver stopped within 3 - 100 iterations
+ Writing solution to <solution-4.vtk>
+ L-infinity norm: 1.09612
+Cycle 5
+ Number of active cells: 1504
+ Number of degrees of freedom: 6016
+Solver stopped within 3 - 100 iterations
+ Writing solution to <solution-5.vtk>
+ L-infinity norm: 1.09532
--- /dev/null
+1317c1317
+< if (solver.n_dofs() < 20000)
+---
+> if (solver.n_dofs() < 5000)
--- /dev/null
+Running tests with "global" refinement criterion:
+-------------------------------------------------
+Refinement cycle: 0 1 2 3 4 5
+DoFs u(x_0)
+ 25 1.2868
+ 81 1.6945
+ 289 1.4658
+ 1089 1.5679
+ 4225 1.5882
+16641 1.5932
+
+Running tests with "kelly" refinement criterion:
+------------------------------------------------
+Refinement cycle: 0 1 2 3 4 5 6 7 8 9
+DoFs u(x_0)
+ 25 1.2868
+ 43 0.9789
+ 86 1.1580
+ 155 1.3960
+ 292 1.6537
+ 540 1.5091
+ 982 1.5713
+1855 1.5643
+3403 1.5923
+6425 1.5893
+
--- /dev/null
+Refinement cycle: 0
+ Number of degrees of freedom: 72
+ Point value: 0.03243
+ Estimated error: 0.000702385
+Refinement cycle: 1
+ Number of degrees of freedom: 67
+ Point value: 0.0324827
+ Estimated error: 0.000888953
+Refinement cycle: 2
+ Number of degrees of freedom: 130
+ Point value: 0.0329619
+ Estimated error: 0.000454606
+Refinement cycle: 3
+ Number of degrees of freedom: 307
+ Point value: 0.0331934
+ Estimated error: 0.000241254
+Refinement cycle: 4
+ Number of degrees of freedom: 718
+ Point value: 0.0333675
+ Estimated error: 7.4912e-05
+Refinement cycle: 5
+ Number of degrees of freedom: 1665
+ Point value: 0.0334083
+ Estimated error: 3.69111e-05
+Refinement cycle: 6
+ Number of degrees of freedom: 3975
+ Point value: 0.033431
+ Estimated error: 1.54218e-05
+Refinement cycle: 7
+ Number of degrees of freedom: 8934
+ Point value: 0.0334406
+ Estimated error: 6.28359e-06
+Refinement cycle: 8
+ Number of degrees of freedom: 21799
+ Point value: 0.0334444
+
--- /dev/null
+21a22
+> #include "../example_test.h"
+589c590,595
+< solver.solve(system_matrix, solution, system_rhs, preconditioner);
+---
+> check_solver_within_range(std::cout,
+> solver.solve(system_matrix, solution, system_rhs, preconditioner),
+> solver_control.last_step(),
+> 7,
+> 16);
+>
--- /dev/null
+Cycle 0
+ Number of active cells: 80
+ Number of degrees of freedom: 89 (by level: 8, 25, 89)
+Solver stopped within 7 - 16 iterations
+ Number of CG iterations: 8
+
+Cycle 1
+ Number of active cells: 152
+ Number of degrees of freedom: 174 (by level: 8, 25, 89, 123)
+Solver stopped within 7 - 16 iterations
+ Number of CG iterations: 9
+
+Cycle 2
+ Number of active cells: 287
+ Number of degrees of freedom: 331 (by level: 8, 25, 89, 223, 127)
+Solver stopped within 7 - 16 iterations
+ Number of CG iterations: 10
+
+Cycle 3
+ Number of active cells: 545
+ Number of degrees of freedom: 608 (by level: 8, 25, 89, 231, 476, 24)
+Solver stopped within 7 - 16 iterations
+ Number of CG iterations: 10
+
+Cycle 4
+ Number of active cells: 1034
+ Number of degrees of freedom: 1137 (by level: 8, 25, 89, 274, 756, 417, 15)
+Solver stopped within 7 - 16 iterations
+ Number of CG iterations: 10
+
+Cycle 5
+ Number of active cells: 1964
+ Number of degrees of freedom: 2181 (by level: 8, 25, 89, 304, 779, 1030, 817)
+Solver stopped within 7 - 16 iterations
+ Number of CG iterations: 10
+
+Cycle 6
+ Number of active cells: 3734
+ Number of degrees of freedom: 4101 (by level: 8, 25, 89, 337, 779, 2046, 885, 1545)
+Solver stopped within 7 - 16 iterations
+ Number of CG iterations: 10
+
+Cycle 7
+ Number of active cells: 7094
+ Number of degrees of freedom: 7833 (by level: 8, 25, 89, 337, 1056, 2835, 1740, 1765, 3085)
+Solver stopped within 7 - 16 iterations
+ Number of CG iterations: 11
+
--- /dev/null
+958c958
+< for (unsigned int cycle = 0; cycle < 10; ++cycle)
+---
+> for (unsigned int cycle = 0; cycle < 8; ++cycle)
--- /dev/null
+Cycle 0:
+ Number of active cells: 64
+ Number of degrees of freedom: 162 (by partition: 162)
+ Solver converged in 9 iterations.
+Cycle 1:
+ Number of active cells: 121
+ Number of degrees of freedom: 298 (by partition: 298)
+ Solver converged in 17 iterations.
+Cycle 2:
+ Number of active cells: 229
+ Number of degrees of freedom: 550 (by partition: 550)
+ Solver converged in 26 iterations.
+Cycle 3:
+ Number of active cells: 433
+ Number of degrees of freedom: 1004 (by partition: 1004)
+ Solver converged in 36 iterations.
+Cycle 4:
+ Number of active cells: 820
+ Number of degrees of freedom: 1826 (by partition: 1826)
+ Solver converged in 51 iterations.
+Cycle 5:
+ Number of active cells: 1558
+ Number of degrees of freedom: 3348 (by partition: 3348)
+ Solver converged in 67 iterations.
+Cycle 6:
+ Number of active cells: 2953
+ Number of degrees of freedom: 6318 (by partition: 6318)
+ Solver converged in 93 iterations.
+Cycle 7:
+ Number of active cells: 5596
+ Number of degrees of freedom: 11706 (by partition: 11706)
+ Solver converged in 122 iterations.
--- /dev/null
+675c675
+< deallog.depth_console(2);
+---
+> //deallog.depth_console(2);
--- /dev/null
+Number of active cells: 1024
+Number of degrees of freedom: 1089
+Output written to solution.vtk
--- /dev/null
+Solving problem in 2 space dimensions.
+ Number of active cells: 256
+ Total number of cells: 341
+ Number of degrees of freedom: 289
+ 26 CG iterations needed to obtain convergence.
+Solving problem in 3 space dimensions.
+ Number of active cells: 4096
+ Total number of cells: 4681
+ Number of degrees of freedom: 4913
+ 30 CG iterations needed to obtain convergence.
20a21
> #include "../example_test.h"
-496,502c497,504
+503,509c504,511
< solver.solve(system_matrix,
< completely_distributed_solution,
< system_rhs,
> solver_control.last_step(),
> 8,
> 15);
-627c629
+634c636
< const unsigned int n_cycles = 8;
---
> const unsigned int n_cycles = 3;
-655c657
+662c664
< computing_timer.print_summary();
---
> // computing_timer.print_summary();
-1058c1058
+1064c1064
< triangulation.refine_global(6 - dim);
---
> triangulation.refine_global(2);
-1098c1098
+1104c1104
< std::cout << " VM Peak: " << mem.VmPeak << std::endl;
---
> // std::cout << " VM Peak: " << mem.VmPeak << std::endl;
-1100c1100
+1106c1106
< computing_timer.print_summary();
---
> // computing_timer.print_summary();
-1114c1114
+1120c1120
< const int dim = 3;
---
> const int dim = 2;
-1116,1118c1116,1123
+1122,1124c1122,1129
< StokesProblem<dim> flow_problem(degree, SolverType::FGMRES_GMG);
<
< flow_problem.run();
--- /dev/null
+524c524
+< for (unsigned int cycle = 0; cycle < 8; ++cycle)
+---
+> for (unsigned int cycle = 0; cycle < 6; ++cycle)
--- /dev/null
+Cycle 0:
+ Number of active cells: 20
+ Number of degrees of freedom: 89
+Cycle 1:
+ Number of active cells: 44
+ Number of degrees of freedom: 209
+Cycle 2:
+ Number of active cells: 92
+ Number of degrees of freedom: 449
+Cycle 3:
+ Number of active cells: 200
+ Number of degrees of freedom: 921
+Cycle 4:
+ Number of active cells: 440
+ Number of degrees of freedom: 2017
+Cycle 5:
+ Number of active cells: 956
+ Number of degrees of freedom: 4425
--- /dev/null
+958c958
+< (refinement_mode == global_refinement) ? 5 : 9;
+---
+> (refinement_mode == global_refinement) ? 3 : 6;
--- /dev/null
+Solving with Q1 elements, adaptive refinement
+=============================================
+
+Cycle 0:
+ Number of active cells: 64
+ Number of degrees of freedom: 81
+Cycle 1:
+ Number of active cells: 121
+ Number of degrees of freedom: 154
+Cycle 2:
+ Number of active cells: 280
+ Number of degrees of freedom: 341
+Cycle 3:
+ Number of active cells: 565
+ Number of degrees of freedom: 678
+Cycle 4:
+ Number of active cells: 1075
+ Number of degrees of freedom: 1240
+Cycle 5:
+ Number of active cells: 2041
+ Number of degrees of freedom: 2306
+
+cycle cells dofs L2 H1 Linfty
+ 0 64 81 1.840e+00 2.858e+00 1.835e+00
+ 1 121 154 5.336e-02 1.200e+00 1.354e-01
+ 2 280 341 1.439e-02 7.892e-01 7.554e-02
+ 3 565 678 8.696e-03 5.086e-01 2.843e-02
+ 4 1075 1240 3.245e-03 3.059e-01 1.072e-02
+ 5 2041 2306 2.407e-03 2.147e-01 5.156e-03
+
+Solving with Q1 elements, global refinement
+===========================================
+
+Cycle 0:
+ Number of active cells: 64
+ Number of degrees of freedom: 81
+Cycle 1:
+ Number of active cells: 256
+ Number of degrees of freedom: 289
+Cycle 2:
+ Number of active cells: 1024
+ Number of degrees of freedom: 1089
+
+cycle cells dofs L2 H1 Linfty
+ 0 64 81 1.840e+00 2.858e+00 1.835e+00
+ 1 256 289 3.570e-02 1.199e+00 1.307e-01
+ 2 1024 1089 1.192e-02 7.565e-01 7.168e-02
+
+n cells H1 L2
+0 64 2.858e+00 - - 1.840e+00 - -
+1 256 1.199e+00 2.38 1.25 3.570e-02 51.54 5.69
+2 1024 7.565e-01 1.58 0.66 1.192e-02 2.99 1.58
+
+Solving with Q2 elements, global refinement
+===========================================
+
+Cycle 0:
+ Number of active cells: 64
+ Number of degrees of freedom: 289
+Cycle 1:
+ Number of active cells: 256
+ Number of degrees of freedom: 1089
+Cycle 2:
+ Number of active cells: 1024
+ Number of degrees of freedom: 4225
+
+cycle cells dofs L2 H1 Linfty
+ 0 64 289 1.606e-01 1.278e+00 3.029e-01
+ 1 256 1089 7.638e-03 5.248e-01 4.816e-02
+ 2 1024 4225 8.601e-04 1.086e-01 4.827e-03
+
+n cells H1 L2
+0 64 1.278e+00 - - 1.606e-01 - -
+1 256 5.248e-01 2.43 1.28 7.638e-03 21.03 4.39
+2 1024 1.086e-01 4.83 2.27 8.601e-04 8.88 3.15
+
+Solving with Q2 elements, adaptive refinement
+===========================================
+
+Cycle 0:
+ Number of active cells: 64
+ Number of degrees of freedom: 289
+Cycle 1:
+ Number of active cells: 121
+ Number of degrees of freedom: 569
+Cycle 2:
+ Number of active cells: 280
+ Number of degrees of freedom: 1317
+Cycle 3:
+ Number of active cells: 529
+ Number of degrees of freedom: 2459
+Cycle 4:
+ Number of active cells: 1015
+ Number of degrees of freedom: 4719
+Cycle 5:
+ Number of active cells: 1963
+ Number of degrees of freedom: 9039
+
+cycle cells dofs L2 H1 Linfty
+ 0 64 289 1.606e-01 1.278e+00 3.029e-01
+ 1 121 569 7.916e-03 5.257e-01 4.857e-02
+ 2 280 1317 1.092e-03 1.165e-01 4.832e-03
+ 3 529 2459 5.999e-04 5.177e-02 1.873e-03
+ 4 1015 4719 2.100e-04 3.245e-02 7.938e-04
+ 5 1963 9039 7.821e-05 1.990e-02 7.260e-04
+
--- /dev/null
+589c589
+< for (unsigned int cycle = 0; cycle < 8; ++cycle)
+---
+> for (unsigned int cycle = 0; cycle < 5; ++cycle)
--- /dev/null
+Cycle 0:
+ Number of active cells: 256
+ Number of degrees of freedom: 578
+Cycle 1:
+ Number of active cells: 484
+ Number of degrees of freedom: 1082
+Cycle 2:
+ Number of active cells: 922
+ Number of degrees of freedom: 2030
+Cycle 3:
+ Number of active cells: 1750
+ Number of degrees of freedom: 3774
+Cycle 4:
+ Number of active cells: 3319
+ Number of degrees of freedom: 7064