Peano
Loading...
Searching...
No Matches
test_exagrype_fd4_with_ko_dissipation.py
Go to the documentation of this file.
1import types
2
3import pytest
4
5import peano4.api
8
9import exahype2.api
10import exagrype.api
11
12
13def _solver(quantities=None, sigma=8.0, rk_order=2):
14 solver = exagrype.api.FOCCZ4Solver("CCZ4")
15 solver.numerical_scheme = exagrype.api.FD4WithKODissipation(
16 solver,
17 patch_size=5,
18 rk_order=rk_order,
19 kreiss_oliger_sigma=sigma,
20 quantities=quantities,
21 )
22 return solver
23
24
25def _construct_time_step(solver, directory):
26 exahype2_project = types.SimpleNamespace(periodic_BC=[True, True, True])
27 peano_project = peano4.api.Project(["probe"], "probe", str(directory))
28 time_step = peano4.api.taskgraph.Graph()
29 solver.numerical_scheme.construct_output(exahype2_project, peano_project, time_step)
30 return {task.name: task for task in time_step.tasks}
31
32
33def _body(action_set):
34 return action_set.get_body_of_operation(
35 peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
36 )
37
38
40 solver = _solver()
41 assert solver.numerical_scheme.overlap == 3
42 assert solver._patch_with_halo.dim == (11, 11, 11)
43 assert solver._patch_overlap_current_time_step.dim == (6, 5, 5)
44
45
47 solver = exagrype.api.FOCCZ4Solver("CCZ4")
49 solver, patch_size=5, rk_order=2
50 )
51 assert scheme.overlap == 2
52 assert not hasattr(scheme, "kreiss_oliger_sigma")
53
54
56 solver = _solver()
57 assert solver.numerical_scheme.dissipative_quantities == list(range(58))
58
59
61 solver = _solver(quantities=["lapse", "G", 57, 0])
62 assert solver.numerical_scheme.dissipative_quantities == [0, 1, 2, 3, 4, 5, 16, 57]
63
64
65@pytest.mark.parametrize("quantities", [["lapsee"], ["K0"], [58], [-1], [1.5], []])
67 with pytest.raises((ValueError, TypeError)):
68 _solver(quantities=quantities)
69
70
72 with pytest.raises(ValueError):
73 _solver(sigma=-1.0)
74
75
77 solver = _solver(quantities=["lapse", "phi"], rk_order=2)
78 tasks = _construct_time_step(solver, tmp_path)
79 for stage in range(2):
80 evaluation = tasks[f"CCZ4_Evaluate Runge-Kutta right hand side stage {stage}"]
81 dissipation = tasks[f"CCZ4_Add Kreiss-Oliger dissipation stage {stage}"]
82 assert [type(a) for a in evaluation.action_sets] == [
84 ]
85 assert [type(a) for a in dissipation.action_sets] == [
87 ]
88 assert dissipation.dependencies == [evaluation]
89 body = _body(dissipation.action_sets[0])
90 assert "::exagrype::ccz4::addKreissOligerDissipation(" in body
91 assert "constexpr int dissipativeQuantities[] = { 16, 24 };" in body
92 # Estimate slot of the stage: stage * 58 unknowns * 5^3 grid cells
93 assert f"fineGridCellCCZ4QRhsEstimates.value + {stage * 58 * 125}," in body
94 assert " 3,\n" in body
95 assert " 8.0,\n" in body
96
97
99 solver = _solver()
100 _construct_time_step(solver, tmp_path)
101 # The kernel gets the halo of three, and the functors follow patchData directly
102 assert "<\n 5,\n 3,\n 58,\n 0\n>" in solver.compute_kernel_call
103 assert "(\n patchData,\n [&](" in solver.compute_kernel_call
Fourth-order Finite Differences with Kreiss-Oliger dissipation.
Solver for the Einstein equations in the first-order CCZ4 formulation.
Add the Kreiss-Oliger dissipation to the right-hand side of one Runge-Kutta stage.
Fourth-order central Finite Differences with explicit Runge-Kutta time stepping, realised over a bloc...
Represents a Peano 4 project.
Definition Project.py:26
Holds a sequence of Task instances.
Definition Graph.py:9
This file is part of the ExaGRyPE project.
Definition __init__.py:1
The Python-side model of "what happens during one mesh sweep".
Definition __init__.py:1
The task graph abstraction allows users to formalise their solver steps over small task graphs which ...
Definition __init__.py:1