1"""Unit tests for the separate eigenvalue tasks of the Finite Volume schemes:
2update cell -> compute max eigenvalue -> reduce max eigenvalue -> time step size
3(@ref exahype2.api.fv.actionsets.ComputeMaxEigenvalue)."""
23 solver.add_pde_term(
exahype2.api.Flux(implementation=
"F[0] = Q[0]; F[1] = Q[1];"))
25 solver.numerical_scheme = SCHEMES[scheme](solver, 9)
26 exahype2_project = types.SimpleNamespace(periodic_BC=[
True,
True,
True], _dimensions=3)
29 solver.numerical_scheme.construct_output(exahype2_project, peano_project, graph)
30 return solver, {task.name: task
for task
in graph.tasks}, graph
33@pytest.mark.parametrize("scheme", SCHEMES)
38 compute = tasks[
"Probe_Compute max eigenvalue"]
39 reduce = tasks[
"Probe_Reduce max eigenvalue"]
40 cfl = tasks[
"Probe_Compute global CFL condition"]
41 assert compute.entity == Task.GridEntity.CELL
42 assert reduce.entity == Task.GridEntity.CELL
43 assert cfl.entity == Task.GridEntity.GLOBAL_END_OF_STEP
44 assert reduce.dependencies == [compute]
45 assert reduce
in cfl.dependencies
46 assert tasks[f
"Probe_{exahype2.api.Solver.NumericalScheme.DYNAMIC_MESH_REFINEMENT_TASK_NAME}"].dependencies.count(reduce) == 1
52 cfl = tasks[
"Probe_Compute global CFL condition"]
53 assert "Probe_Roll over faces" not in tasks
54 assert tasks[
"Probe_Project on faces"]
in cfl.dependencies
55 _, tasks, _ =
_time_step(
"optimistic", tmp_path)
56 cfl = tasks[
"Probe_Compute global CFL condition"]
57 assert tasks[
"Probe_Project on faces"]
in cfl.dependencies
64 assert tasks[
"Probe_Compute max eigenvalue"].dependencies == [
65 tasks[
"Probe_Update cell"]
67 assert tasks[
"Probe_Project on faces"].dependencies == [tasks[
"Probe_Update cell"]]
73 _, tasks, _ =
_time_step(
"optimistic", tmp_path)
74 assert set(tasks[
"Probe_Compute max eigenvalue"].dependencies) == {
75 tasks[
"Probe_Update cell"],
76 tasks[
"Probe_Insert patch interior"],
78 spawn = tasks[
"Probe_Spawn patch interior update"]
79 assert tasks[
"Probe_Compute max eigenvalue"]
not in spawn.dependencies
80 assert spawn
in tasks[
"Probe_Compute global CFL condition"].dependencies
83@pytest.mark.parametrize("scheme", SCHEMES)
86 for name, task
in tasks.items():
87 if "Update cell" in name
or "Insert patch interior" in name:
89 for action_set
in task.action_sets:
90 body = action_set.get_body_of_operation(
91 peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
93 if type(action_set).__name__ ==
"ComputeMaxEigenvalue":
94 assert "max_eigenvalue_kernel" not in body
95 assert "setMaxEigenvalue( 0" in body
96 for name
in [
"Probe_Update cell",
"Probe_Update cell shell"]:
99 for action_set
in tasks[name].action_sets:
100 body = action_set.get_body_of_operation(
101 peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
103 assert "setMaxEigenvalue" not in body
106@pytest.mark.parametrize("scheme", SCHEMES)
108 _, tasks, graph =
_time_step(scheme, tmp_path)
109 steps = FuseSteps.translate(graph,
"S",
None,
None)
111 [type(action_set).__name__
for action_set
in step.action_sets]
for step
in steps
115 for step_names
in names
116 if "UpdateCell" in step_names
and "ComputeMaxEigenvalue" in step_names
118 assert len(holders) == 1, names
122 assert "ProjectPatchOntoFaces" not in holders[0]
123 assert "ReduceMaxEigenvalue" not in holders[0]
126 assert len(names) == 2, names
127 assert "ProjectPatchOntoFaces" in names[-1]
128 assert "ReduceMaxEigenvalue" in names[-1]
129 assert "ComputeGlobalCFLCondition" in names[-1]
134 The eigenvalue task must call the eigenvalue kernel (not the time step
137 solver, _, _ =
_time_step(
"explicit", tmp_path)
138 call = solver.numerical_scheme.max_eigenvalue_kernel_call
139 assert "maxEigenvalueOverPatch" in call
140 assert "timeStepWithRusanov" not in call
The conservative flux F(Q) of a hyperbolic PDE.
The maximum absolute eigenvalue of the flux Jacobian in a given direction, i.e.
Abstract base class for all ExaHyPE 2 solvers.
Finite Volumes with a Rusanov Riemann solver and explicit Euler time stepping, realised over a block-...
Finite Volumes with a Rusanov Riemann solver and optimistic explicit Euler time stepping,...
Represents a Peano 4 project.
Holds a sequence of Task instances.
Compilers are simple functions.
The task graph abstraction allows users to formalise their solver steps over small task graphs which ...
test_update_eigenvalue_and_reduction_fold_into_one_traversal(scheme, tmp_path)
test_eigenvalue_task_calls_the_eigenvalue_kernel(tmp_path)
The eigenvalue task must call the eigenvalue kernel (not the time step kernel).
test_update_does_not_store_an_eigenvalue(scheme, tmp_path)
_time_step(scheme, tmp_path)
test_time_step_size_is_computed_after_the_roll_over(tmp_path)
test_optimistic_eigenvalue_follows_both_branches_and_runs_beside_the_spawn(tmp_path)
test_explicit_eigenvalue_follows_the_update_and_runs_beside_the_projection(tmp_path)
test_eigenvalue_is_computed_stored_and_reduced_before_the_time_step_size(scheme, tmp_path)