Peano
Loading...
Searching...
No Matches
test_rkfd4_data_structures.py
Go to the documentation of this file.
1import pytest
2
3import peano4.api
5
6import exahype2.api
7
8
9def _scheme(patch_size=5, rk_order=3, time_step_size=None):
10 solver = exahype2.api.Solver("Probe", 4)
12 solver, patch_size=patch_size, rk_order=rk_order, time_step_size=time_step_size
13 )
14 solver.numerical_scheme = scheme
15 return solver, scheme
16
17
19 solver, scheme = _scheme()
20 assert scheme.overlap == 2
21 assert solver._patch.dim == (5, 5, 5)
22 assert solver._patch.no_of_unknowns == 4
23 assert solver._stage_input.dim == (5, 5, 5)
24 assert solver._stage_input.no_of_unknowns == 4
25 assert solver._patch_with_halo.dim == (9, 9, 9)
26 assert solver._patch_with_halo.no_of_unknowns == 4
27 for overlap in (
28 solver._patch_overlap_current_time_step,
29 solver._patch_overlap_update,
30 ):
31 assert overlap.dim == (4, 5, 5)
32 assert overlap.no_of_unknowns == 4
33
34
36 solver, scheme = _scheme(rk_order=3)
37 assert scheme.rk_order == 3
38 assert solver._rhs_estimates.dim == (15, 5, 5)
39 # Auxiliary variables do not evolve in time, so there is no estimate for them
40 assert solver._rhs_estimates.no_of_unknowns == 4
41
42
44 solver, _ = _scheme()
45 assert [
46 data.name
47 for data in [
48 solver._patch,
49 solver._stage_input,
50 solver._patch_with_halo,
51 solver._rhs_estimates,
52 solver._patch_overlap_current_time_step,
53 solver._patch_overlap_update,
54 solver._max_eigenvalue,
55 ]
56 ] == [
57 "ProbeQ",
58 "ProbeQStageInput",
59 "ProbeQWithHalo",
60 "ProbeQRhsEstimates",
61 "ProbeQCurrentTimeStep",
62 "ProbeQUpdate",
63 "ProbeMaxEigenvalue",
64 ]
65
66
68 return [declaration for declaration, _ in solver._abstract_solver_methods]
69
70
72 """! Per cell, then the reduction is a global datum which the solver hosts """
73 solver, scheme = _scheme()
74 assert scheme.has_adaptive_time_step_size
75 assert solver._max_eigenvalue is not None
76 assert _reduction_methods(solver) == [
77 "void reduceMaxEigenvalue(double eigenvalue);",
78 "double getAndResetMaxEigenvalue();",
79 ]
80
81
83 solver, scheme = _scheme(time_step_size=0.01)
84 assert not scheme.has_adaptive_time_step_size
85 assert solver._max_eigenvalue is None
86 assert _reduction_methods(solver) == []
87
88
90 solver, scheme = _scheme()
91 project = peano4.api.Project(["probe"], "probe", ".")
92 scheme._CentralDifferencesWithRungeKutta__add_data_to_repository(project)
93
94 for patch in scheme._patches():
95 assert isinstance(
97 )
98 face_guard = solver.grid_selector.createFaceGuard()
99 assert (
100 solver._patch_overlap_current_time_step.generator.send_condition == face_guard
101 )
102 assert solver._patch_overlap_update.generator.send_condition == "false"
103 assert solver._patch_overlap_update.generator.receive_and_merge_condition == "false"
104
105
106@pytest.mark.parametrize("patch_size", [1])
108 with pytest.raises(ValueError):
109 _scheme(patch_size=patch_size)
110
111
112@pytest.mark.parametrize("rk_order", [0, 5])
114 with pytest.raises(ValueError):
115 _scheme(rk_order=rk_order)
116
117
118@pytest.mark.parametrize(
119 "arguments",
120 [
121 {"time_step_size": 0.0},
122 {"cfl_constant": 0.0},
123 ],
124)
126 solver = exahype2.api.Solver("Probe", 1)
127 with pytest.raises(ValueError):
129 solver, patch_size=5, rk_order=2, **arguments
130 )
Abstract base class for all ExaHyPE 2 solvers.
Definition Solver.py:17
Fourth-order central Finite Differences with explicit Runge-Kutta time stepping, realised over a bloc...
Represents a Peano 4 project.
Definition Project.py:26
_scheme(patch_size=5, rk_order=3, time_step_size=None)
test_adaptive_time_step_size_stores_the_eigenvalue_per_cell_and_reduces_it_in_the_solver()
Per cell, then the reduction is a global datum which the solver hosts.