Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test examples: support loading files
Browse files Browse the repository at this point in the history
- add symlink (thank you @tamiko) to support loading input files
- add step-5
tjhei committed Jan 14, 2024
1 parent cf40acf commit 2aad6bc
Showing 3 changed files with 56 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/examples/README.md
Original file line number Diff line number Diff line change
@@ -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/``.
17 changes: 17 additions & 0 deletions tests/examples/step-5.diff
Original file line number Diff line number Diff line change
@@ -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");
30 changes: 30 additions & 0 deletions tests/examples/step-5.output
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2aad6bc

Please sign in to comment.