Peano
Loading...
Searching...
No Matches
test_rungekutta_linear_combination.py
Go to the documentation of this file.
1import exahype2.api.rungekutta.LinearCombination as linear_combination
2
3
4def _call(weights, solution="Q", output="Y"):
5 return linear_combination.create_linear_combination_call(
6 namespace=["probe"],
7 number_of_dofs=25,
8 unknowns=4,
9 auxiliary_variables=1,
10 weights=weights,
11 solution=solution,
12 estimates="K",
13 output=output,
14 time_step_size="dt",
15 )
16
17
19 # Row three of Kutta's 3/8 rule: the estimate of stage three does not
20 # exist yet and may hold NaN
21 call = _call([1.0, -1.0, 1.0, 0.0])
22 assert "static constexpr double weights[3] = { 1.0, -1.0, 1.0 };" in call
23 assert "double* estimatePointers[3] = { K + 0, K + 100, K + 200 };" in call
24 assert "K + 300" not in call
25 assert " 3\n >(solutionPointers" in call
26
27
29 # Midpoint rule: the final combination uses stage one only
30 call = _call([0.0, 1.0])
31 assert "static constexpr double weights[1] = { 1.0 };" in call
32 assert "double* estimatePointers[1] = { K + 100 };" in call
33
34
36 assert "std::copy_n( Q, 125, Y );" in _call([0.0, 0.0])
37 assert _call([0.0], solution="Q", output="Q") == "{}"
38
39
41 linear_combination.generate_linear_combination_kernel(["probe"], str(tmp_path))
42 code = (tmp_path / "kernels" / "rungekutta_linear_combination.cpph").read_text()
43 assert "void linearCombinationOfRungeKuttaEstimates(" in code
44 assert "weights[" in code