1"""Unit tests for the registration of couplings of solvers and for the
2flag add_global_tasks, with which a coupling leaves the load balancing switch and the
3dynamic mesh refinement to one of its solvers."""
12import toolbox.loadbalancing.api.actionsets
22 solver, patch_size=4, rk_order=2
29 solver.add_pde_term(
exahype2.api.Flux(implementation=
"F[0] = Q[0]; F[1] = Q[1];"))
35 if scheme
is not None:
36 solver.numerical_scheme = SCHEMES[scheme](solver)
41 exahype2_project = types.SimpleNamespace(periodic_BC=[
True,
True,
True], _dimensions=3)
44 solver.numerical_scheme.construct_output(
45 exahype2_project, peano_project, time_step, add_global_tasks
52 isinstance(action_set, toolbox.loadbalancing.api.actionsets.ToggleLoadBalancing)
53 or isinstance(action_set, toolbox.loadbalancing.api.actionsets.LoadBalancing)
54 for action_set
in task.action_sets
60 a, b, c, d, e = (
Task(name=n, entity=Task.GridEntity.CELL)
for n
in "abcde")
63 for task
in (a, b, c):
68 assert first.tasks == [a, b, c, d, e]
70 assert set(e.dependencies) == {b, c}
72 assert d.dependencies == [e]
and b.dependencies == [a]
and a.dependencies == []
73 assert second.tasks == [d, e]
78 a =
Task(name=
"a", entity=Task.GridEntity.CELL)
79 end =
Task(name=
"end", entity=Task.GridEntity.GLOBAL_END_OF_STEP)
80 b =
Task(name=
"b", entity=Task.GridEntity.CELL)
87 assert b.dependencies == [end]
88 assert first.tasks == [a, end, b]
93 a =
Task(name=
"a", entity=Task.GridEntity.CELL)
96 with pytest.raises(ValueError):
102 a =
Task(name=
"a", entity=Task.GridEntity.CELL)
103 b =
Task(name=
"b", entity=Task.GridEntity.CELL)
104 c =
Task(name=
"c", entity=Task.GridEntity.CELL)
112 assert merged.tasks == [a, b, c]
113 assert b.dependencies == [a]
114 assert first.tasks == [a, b]
117@pytest.mark.parametrize("scheme", SCHEMES)
119 name = exahype2.api.Solver.NumericalScheme.DYNAMIC_MESH_REFINEMENT_TASK_NAME
121 assert f
"Probe_{name}" in [task.name
for task
in graph.tasks]
125@pytest.mark.parametrize("scheme", SCHEMES)
128 assert not any(
"Dynamic mesh refinement" in task.name
for task
in graph.tasks)
129 assert not any(
"Disable load balancing" in task.name
for task
in graph.tasks)
132 assert any(
"Reconstruct" in task.name
for task
in graph.tasks)
140 [
"probe"],
"probe",
"probe", directory=str(tmp_path)
142 exahype2_project.set_global_simulation_parameters(
147 periodic_BC=[
True,
True],
150 solver, volume_size=0.1
154 def realise(add_global_tasks):
156 solver.generate_solver_realisation(
157 exahype2_project, peano_project, *graphs, add_global_tasks=add_global_tasks
161 assert len(realise(
True)[3].tasks) > 0
162 assert len(realise(
False)[3].tasks) == 0
166 """! Minimal coupling: it brings its solvers along and realises them itself """
183 project.add_solver(third)
184 project.add_solver(coupling)
185 assert project._solvers == [third, first, second]
186 assert project._realisations == [third, coupling]
191 a, b, c = (
Task(name=n, entity=Task.GridEntity.CELL)
for n
in "abc")
193 for task
in (a, b, c):
195 assert graph.source_tasks() == [a, c]
196 assert graph.sink_tasks() == [b, c]
The conservative flux F(Q) of a hyperbolic PDE.
Point-wise initial condition: given the physical position of a single degree of freedom,...
The maximum absolute eigenvalue of the flux Jacobian in a given direction, i.e.
Point-wise refinement criterion: given the solution Q at a single degree of freedom,...
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,...
Setup phase counterpart to RusanovWithExplicitEuler: sets the initial condition for a Finite Volume s...
Fourth-order central Finite Differences with explicit Runge-Kutta time stepping, realised over a bloc...
Represents a Peano 4 project.
Holds a sequence of Task instances.
One task within a peano4.api.taskgraph.Graph.
Minimal coupling: it brings its solvers along and realises them itself.
generate_solver_realisation(self, *args)
The task graph abstraction allows users to formalise their solver steps over small task graphs which ...
test_graph_merge_unites_graphs_and_keeps_the_dependencies()
_construct(solver, tmp_path, add_global_tasks)
test_project_registers_the_solvers_of_a_coupling_but_realises_the_coupling(tmp_path)
test_graph_append_rejects_shared_tasks()
test_solver_without_global_tasks_does_not_contribute_to_the_mesh_adaptation(tmp_path)
_solver(scheme, name="Probe")
test_schemes_leave_the_global_tasks_to_the_host_on_request(scheme, tmp_path)
test_graph_append_connects_the_end_of_one_graph_to_the_start_of_the_other()
test_graph_source_tasks_are_the_counterpart_of_the_sink_tasks()
_toggles_load_balancing(task)
test_graph_append_makes_the_sources_wait_for_global_sinks_too()
test_schemes_add_the_global_tasks_by_default(scheme, tmp_path)