From 2aad6bc016340cc91a50bb50a4b297ab7d0a59aa Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Sat, 13 Jan 2024 23:45:34 -0500 Subject: [PATCH] test examples: support loading files - add symlink (thank you @tamiko) to support loading input files - add step-5 --- tests/examples/README.md | 10 +++++++++- tests/examples/step-5.diff | 17 +++++++++++++++++ tests/examples/step-5.output | 30 ++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 tests/examples/step-5.diff create mode 100644 tests/examples/step-5.output diff --git a/tests/examples/README.md b/tests/examples/README.md index fe6d2080a478..69269f9c4a7f 100644 --- a/tests/examples/README.md +++ b/tests/examples/README.md @@ -22,4 +22,12 @@ For development of new examples, we suggest first creating an empty 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. +files by running the ``update_diffs`` target in the folder +``build/tests/examples``, i.e., by running ``make update_diffs``. + +To support loading files from the ./examples/step-XY/ directory, we +automatically create a symlink such that +``` + SOURCE_DIR "/step-5/" +``` +compiles to an absolute path pointing at ``./examples/step-5/``. diff --git a/tests/examples/step-5.diff b/tests/examples/step-5.diff new file mode 100644 index 000000000000..4d60e3e2b820 --- /dev/null +++ b/tests/examples/step-5.diff @@ -0,0 +1,17 @@ +40a41 +> #include "../example_test.h" +268,271c269,273 +< solver.solve(system_matrix, solution, system_rhs, preconditioner); +< +< std::cout << " " << solver_control.last_step() +< << " CG iterations needed to obtain convergence." << std::endl; +--- +> check_solver_within_range(std::cout, +> solver.solve(system_matrix, solution, system_rhs, preconditioner), +> solver_control.last_step(), +> 10, +> 200); +327c329 +< std::ifstream input_file("circle-grid.inp"); +--- +> std::ifstream input_file(SOURCE_DIR "/step-5/circle-grid.inp"); diff --git a/tests/examples/step-5.output b/tests/examples/step-5.output new file mode 100644 index 000000000000..53dd3cbca838 --- /dev/null +++ b/tests/examples/step-5.output @@ -0,0 +1,30 @@ +Cycle 0: + Number of active cells: 20 + Total number of cells: 20 + Number of degrees of freedom: 25 +Solver stopped within 10 - 200 iterations +Cycle 1: + Number of active cells: 80 + Total number of cells: 100 + Number of degrees of freedom: 89 +Solver stopped within 10 - 200 iterations +Cycle 2: + Number of active cells: 320 + Total number of cells: 420 + Number of degrees of freedom: 337 +Solver stopped within 10 - 200 iterations +Cycle 3: + Number of active cells: 1280 + Total number of cells: 1700 + Number of degrees of freedom: 1313 +Solver stopped within 10 - 200 iterations +Cycle 4: + Number of active cells: 5120 + Total number of cells: 6820 + Number of degrees of freedom: 5185 +Solver stopped within 10 - 200 iterations +Cycle 5: + Number of active cells: 20480 + Total number of cells: 27300 + Number of degrees of freedom: 20609 +Solver stopped within 10 - 200 iterations