Peano
Loading...
Searching...
No Matches
test_rungekutta_linear_combination.py
Go to the documentation of this file.
1
import
exahype2.api.rungekutta.LinearCombination
as
linear_combination
2
3
4
def
_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
18
def
test_stages_with_zero_weight_are_not_read
():
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
28
def
test_weights_keep_their_stage
():
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
35
def
test_all_weights_zero_copies_solution
():
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
40
def
test_kernel_translates
(tmp_path):
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
exahype2.api.rungekutta.LinearCombination
Definition
LinearCombination.py:1
test_rungekutta_linear_combination._call
_call(weights, solution="Q", output="Y")
Definition
test_rungekutta_linear_combination.py:4
test_rungekutta_linear_combination.test_stages_with_zero_weight_are_not_read
test_stages_with_zero_weight_are_not_read()
Definition
test_rungekutta_linear_combination.py:18
test_rungekutta_linear_combination.test_kernel_translates
test_kernel_translates(tmp_path)
Definition
test_rungekutta_linear_combination.py:40
test_rungekutta_linear_combination.test_all_weights_zero_copies_solution
test_all_weights_zero_copies_solution()
Definition
test_rungekutta_linear_combination.py:35
test_rungekutta_linear_combination.test_weights_keep_their_stage
test_weights_keep_their_stage()
Definition
test_rungekutta_linear_combination.py:28
tests
unit
test_rungekutta_linear_combination.py
Generated on Wed Nov 4 2026 08:20:47 for Peano by
1.9.8