16 return Task(name=name, entity=Task.GridEntity.CELL)
21 a, b, c, d = (
_cell_task(name)
for name
in "abcd")
25 for task
in [a, b, c]:
28 graph.insert_after(a, d)
30 assert d
in graph.tasks
31 assert d.dependencies == [a]
32 assert b.dependencies == [d]
33 assert c.dependencies == [d, b]
34 order = graph.ordered_tasks()
35 assert order.index(a) < order.index(d) < order.index(b) < order.index(c)
42 graph.insert_after(a, b)
43 assert graph.ordered_tasks() == [a, b]
48 a, b, c, d, e = (
_cell_task(name)
for name
in "abcde")
53 for task
in [a, b, c, d]:
56 graph.insert_after([b, c], e)
58 assert e.dependencies == [b, c]
59 assert d.dependencies == [e]
60 order = graph.ordered_tasks()
61 assert order.index(b) < order.index(e) < order.index(d)
62 assert order.index(c) < order.index(e)
67 a, b, c, d = (
_cell_task(name)
for name
in "abcd")
70 for task
in [a, b, c]:
72 with pytest.raises(AssertionError):
73 graph.insert_after([a, c], d)
78 a =
Task(name=
"a", entity=Task.GridEntity.CELL, tags={
"x"})
82 for task
in [a, b, c]:
84 assert graph.find_tasks(
"x") == [a, c]
85 assert graph.find_tasks(
"y") == []
90 a =
Task(name=
"a", entity=Task.GridEntity.CELL, tags=[
"x",
"y"])
91 b =
Task(name=
"b", entity=Task.GridEntity.CELL, tags={
"y"})
93 for task
in [a, b, c]:
95 assert graph.find_tasks(
"x") == [a]
96 assert graph.find_tasks(
"y") == [a, b]
97 assert graph.find_tasks(
"x",
"y") == [a, b]
101 scheme_factory, grid_construction_factory, enforce, tmp_path
103 """! Time step graph of a CCZ4 solver with the given constraint enforcement"""
108 solver.numerical_scheme = scheme_factory(solver)
109 solver.grid_construction = grid_construction_factory(solver)
110 solver.enforce_ccz4_constraint(enforce)
113 [
"probe"],
"probe",
"probe", directory=str(tmp_path)
115 exahype2_project.set_global_simulation_parameters(
117 offset=[0.0, 0.0, 0.0],
118 size=[1.0, 1.0, 1.0],
120 periodic_BC=[
True,
True,
True],
124 solver.generate_solver_realisation(exahype2_project, peano_project, *graphs)
125 return solver, {task.name: task
for task
in graphs[1].tasks}
129 return sorted(name
for name
in tasks
if "_Enforce CCZ4 constraints after" in name)
134 solver, patch_size=4, rk_order=3
152 exagrype.api.FOCCZ4Solver.EnforceCCZ4Constraint.No,
164 exagrype.api.FOCCZ4Solver.EnforceCCZ4Constraint.IntermediateSteps,
168 for anchor, successor, patch
in [
169 (
"Prepare stage 1",
"Project stage 1 onto faces", solver._stage_input),
170 (
"Prepare stage 2",
"Project stage 2 onto faces", solver._stage_input),
171 (
"Complete time step",
"Project solution onto faces", solver._patch),
173 clip = tasks[f
"Probe_Enforce CCZ4 constraints after {anchor}"]
174 assert clip.dependencies == [tasks[f
"Probe_{anchor}"]]
175 assert tasks[f
"Probe_{successor}"].dependencies == [clip]
176 [action_set] = clip.action_sets
178 action_set, toolbox.blockstructured.api.ApplyPointWiselyToPatch
180 body = action_set.get_body_of_operation(
181 peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
183 assert "::exagrype::ccz4::enforceCCZ4constraints(Q);" in body
184 assert f
"fineGridCell{patch.name}.value" in body
188 tasks[
"Probe_Project solution onto faces"]
189 in tasks[
"Probe_Compute max eigenvalue"].dependencies
199 exagrype.api.FOCCZ4Solver.EnforceCCZ4Constraint.OnlyFinalSolution,
203 "Probe_Enforce CCZ4 constraints after Complete time step"
215 exagrype.api.FOCCZ4Solver.EnforceCCZ4Constraint.OnlyFinalSolution,
221 assert set(clip.dependencies) == {
222 tasks[
"Probe_Update cell"],
223 tasks[
"Probe_Insert patch interior"],
225 [action_set] = clip.action_sets
226 assert action_set.guard == solver.grid_selector.createCellGuard()
228 "Compute max eigenvalue",
229 "Spawn patch interior update",
230 "Discard patch interior",
232 dependencies = tasks[f
"Probe_{consumer}"].dependencies
233 assert clip
in dependencies
234 assert tasks[
"Probe_Update cell"]
not in dependencies
235 assert tasks[
"Probe_Insert patch interior"]
not in dependencies
244 exagrype.api.FOCCZ4Solver.EnforceCCZ4Constraint.IntermediateSteps,
247 clip = tasks[
"Probe_Enforce CCZ4 constraints after Update cell"]
249 assert tasks[
"Probe_Compute max eigenvalue"].dependencies == [clip]
255 class UnknownScheme(exahype2.api.Solver.NumericalScheme):
260 def construct_output(
261 self, exahype2_project, peano_project, time_step, add_global_tasks=True
265 class NoGridConstruction(exahype2.api.Solver.GridConstruction):
266 def construct_output(self, exahype2_project, peano_project, setup_simulation):
269 with pytest.raises(TypeError, match=
"UnknownScheme"):
273 exagrype.api.FOCCZ4Solver.EnforceCCZ4Constraint.OnlyFinalSolution,
280 a, b, c, d = (
_cell_task(name)
for name
in "abcd")
284 for task
in [a, b, c, d]:
287 assert graph.sink_tasks() == [c, d]
292 assert graph.sink_tasks() == []
297 assert graph.sink_tasks() == [b]
Solver for the Einstein equations in the first-order CCZ4 formulation.
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...
Setup phase of the fourth-order Finite Differences with Runge-Kutta time stepping (exahype2....
Represents a Peano 4 project.
Holds a sequence of Task instances.
One task within a peano4.api.taskgraph.Graph.
exahype2.api.InitPointWisely gauge_wave()
Gauge wave along the x-axis,.
This file is part of the ExaGRyPE project.
The Python-side model of "what happens during one mesh sweep".
The task graph abstraction allows users to formalise their solver steps over small task graphs which ...
test_constraint_enforcement_after_both_writers_of_optimistic_finite_volumes(tmp_path)
test_find_tasks_with_several_tags()
test_constraint_enforcement_rejects_unknown_scheme(tmp_path)
test_constraint_enforcement_after_final_runge_kutta_solution_only(tmp_path)
test_constraint_enforcement_after_each_runge_kutta_stage(tmp_path)
_runge_kutta_grid(solver)
_postprocessed_time_step(scheme_factory, grid_construction_factory, enforce, tmp_path)
Time step graph of a CCZ4 solver with the given constraint enforcement.
test_no_constraint_enforcement_by_default(tmp_path)
test_insert_after_rejects_dependent_anchors()
test_constraint_enforcement_after_plain_finite_volumes(tmp_path)
test_insert_after_last_task()
test_insert_after_redirects_successors()
test_insert_after_several_anchors()
test_sink_tasks_of_chain_and_empty_graph()
test_sink_tasks_of_forking_graph()