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"""
107 solver.numerical_scheme = scheme_factory(solver)
108 solver.grid_construction = grid_construction_factory(solver)
109 solver.enforce_ccz4_constraint(enforce)
112 [
"probe"],
"probe",
"probe", directory=str(tmp_path)
114 exahype2_project.set_global_simulation_parameters(
116 offset=[0.0, 0.0, 0.0],
117 size=[1.0, 1.0, 1.0],
119 periodic_BC=[
True,
True,
True],
123 solver.generate_solver_realisation(exahype2_project, peano_project, *graphs)
124 return solver, {task.name: task
for task
in graphs[1].tasks}
128 return sorted(name
for name
in tasks
if "_Enforce CCZ4 constraints after" in name)
133 solver, patch_size=4, rk_order=3
151 exagrype.api.CCZ4Solver.EnforceCCZ4Constraint.No,
163 exagrype.api.CCZ4Solver.EnforceCCZ4Constraint.IntermediateSteps,
167 for anchor, successor, patch
in [
168 (
"Prepare stage 1",
"Project stage 1 onto faces", solver._stage_input),
169 (
"Prepare stage 2",
"Project stage 2 onto faces", solver._stage_input),
170 (
"Complete time step",
"Project solution onto faces", solver._patch),
172 clip = tasks[f
"Probe_Enforce CCZ4 constraints after {anchor}"]
173 assert clip.dependencies == [tasks[f
"Probe_{anchor}"]]
174 assert tasks[f
"Probe_{successor}"].dependencies == [clip]
175 [action_set] = clip.action_sets
177 action_set, toolbox.blockstructured.api.ApplyPointWiselyToPatch
179 body = action_set.get_body_of_operation(
180 peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
182 assert "::exagrype::ccz4::enforceCCZ4constraints(Q);" in body
183 assert f
"fineGridCell{patch.name}.value" in body
192 exagrype.api.CCZ4Solver.EnforceCCZ4Constraint.OnlyFinalSolution,
196 "Probe_Enforce CCZ4 constraints after Complete time step"
208 exagrype.api.CCZ4Solver.EnforceCCZ4Constraint.OnlyFinalSolution,
214 assert set(clip.dependencies) == {
215 tasks[
"Probe_Update cell"],
216 tasks[
"Probe_Insert patch interior"],
218 [action_set] = clip.action_sets
219 assert action_set.guard == solver.grid_selector.createCellGuard()
222 "Compute global CFL condition",
223 "Spawn patch interior update",
224 "Discard patch interior",
226 dependencies = tasks[f
"Probe_{consumer}"].dependencies
227 assert clip
in dependencies
228 assert tasks[
"Probe_Update cell"]
not in dependencies
229 assert tasks[
"Probe_Insert patch interior"]
not in dependencies
238 exagrype.api.CCZ4Solver.EnforceCCZ4Constraint.IntermediateSteps,
241 clip = tasks[
"Probe_Enforce CCZ4 constraints after Update cell"]
243 assert tasks[
"Probe_Project on faces"].dependencies == [clip]
249 class UnknownScheme(exahype2.api.Solver.NumericalScheme):
250 def construct_output(self, exahype2_project, peano_project, time_step):
253 class NoGridConstruction(exahype2.api.Solver.GridConstruction):
254 def construct_output(self, exahype2_project, peano_project, setup_simulation):
257 with pytest.raises(TypeError, match=
"UnknownScheme"):
261 exagrype.api.CCZ4Solver.EnforceCCZ4Constraint.OnlyFinalSolution,
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.
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()