Peano
Loading...
Searching...
No Matches
test_fv_rusanov_eigenvalues.py
Go to the documentation of this file.
1import importlib
2import inspect
3import re
4
5# exahype2.api.fv re-exports the classes under their module names, so we
6# fetch the modules (which host the DSL kernels) explicitly
7explicit = importlib.import_module("exahype2.api.fv.RusanovWithExplicitEuler")
8optimistic = importlib.import_module(
9 "exahype2.api.fv.RusanovWithOptimisticExplicitEuler"
10)
11
12
13KERNELS = [
14 explicit.timeStepWithRusanov2D,
15 explicit.timeStepWithRusanov3D,
16 optimistic.timeStepWithRusanov2DOnPatchInterior,
17 optimistic.timeStepWithRusanov2DOnShell,
18 optimistic.timeStepWithRusanov3DOnPatchInterior,
19 optimistic.timeStepWithRusanov3DOnShell,
20]
21
22
24 """The argument eval("maxEigenvalue", ...) is applied to, per call"""
25 return re.findall(
26 r'eval\‍("maxEigenvalue", (\w+(?:\[[^\]]*\])?)', inspect.getsource(kernel)
27 )
28
29
31 for kernel in KERNELS:
32 for region in _evaluated_regions(kernel):
33 # input without a slice is the patch including all of its halo,
34 # whereas output without a slice is the patch without halo
35 assert region != "input", kernel.__name__
36 if "[" not in region:
37 continue
38 # Along each axis, we may step at most one volume into the halo,
39 # i.e. a slice starts at -1 at the lowest and ends at NV+1 at the
40 # highest
41 for axis in region[region.index("[") + 1 : -1].split(","):
42 axis = axis.strip().replace(" ", "")
43 if axis == ":":
44 continue
45 start, end = axis.split(":")
46 assert start not in ("-H", "0-H"), (kernel.__name__, region)
47 assert end not in ("NV+H",), (kernel.__name__, region)
48
49
51 def guards(kernel):
52 return set(re.findall(r"^\s*if (\w+):", inspect.getsource(kernel), re.M))
53
54 expected = {"volumetricSource", "flux", "nonconservativeProduct", "maxEigenvalue"}
55 assert guards(explicit.timeStepWithRusanov2D) == expected
56 assert guards(explicit.timeStepWithRusanov3D) == expected
_evaluated_regions(kernel)
The argument eval("maxEigenvalue", ...) is applied to, per call.