11 [
"probe"],
"probe",
"probe", directory=str(tmp_path)
13 exahype2_project.set_global_simulation_parameters(
15 offset=[0.0, 0.0, 0.0],
18 periodic_BC=[
True,
True,
True],
24 """! Let the host realise the pair and return the time step graph of the project"""
25 exahype2_project, peano_project =
_project(tmp_path)
27 pair.generate_solver_realisation(exahype2_project, peano_project, *graphs)
32 """! Configure the CCZ4 solver of the pair with FD4 and lopsided advection"""
34 Kernel = exahype2.api.rkfd4.CentralDifferencesWithRungeKutta.RightHandSideKernel
40 right_hand_side_kernel=Kernel.CentralDifferencesWithLopsidedAdvection,
41 advection_velocity=exagrype.api.FOSOCCZ4Solver.ADVECTION_VELOCITY,
42 advected_quantities=solver.advected_quantities(),
45 solver, volume_size=1.0 / 27.0
47 if enforce
is not None:
48 solver.enforce_ccz4_constraint(enforce)
52 """! Configure the pair with FD4, realise both solvers and return the time step graph"""
60 assert first_order.unknowns == 58
61 assert second_order.unknowns == 25
62 assert second_order.number_of_auxiliary_variables == 33
63 assert second_order.derivatives.size == 33
64 assert second_order.auxiliary_variables == [second_order.derivatives]
65 assert second_order.derivatives.owner
is second_order
68 second_order.variable_names_per_entry()
69 + second_order.derivatives.variable_names_per_entry()
72 assert list(exagrype.api.FOSOCCZ4Solver.Unknowns) + list(
73 exagrype.api.FOSOCCZ4Solver.DerivativeUnknowns
74 ) == list(exagrype.api.FOCCZ4Solver.Unknowns)
76 exagrype.api.FOSOCCZ4Solver.Unknowns
77 | exagrype.api.FOSOCCZ4Solver.DerivativeUnknowns
78 == exagrype.api.FOCCZ4Solver.Unknowns
85 with pytest.raises(KeyError):
91 C++ which calls the kernel of the non-conservative product. The solver
92 registers its non-conservative product only when it is realised, so it
93 is taken from the hook which writes it.
95 return solver._ncp_implementation()
101 assert "::exagrype::ccz4::ncpFirstOrder(" in _ncp_call(first_order)
102 assert "::exagrype::ccz4::ncpSecondOrder(" in _ncp_call(second_order)
103 for solver, order
in [(first_order,
"FirstOrder"), (second_order,
"SecondOrder")]:
105 f
"::exagrype::ccz4::source{order}("
106 in solver.get_pde_term(
"volumetricSource", stateless=
True).implementation
108 for solver
in (first_order, second_order):
110 "::exagrype::ccz4::maxEigenvalue("
111 in solver.get_pde_term(
"maxEigenvalue", stateless=
True).implementation
116 assert "Q, derivatives," in ncp
117 assert "deltaQ, deltaDerivatives," in ncp
118 source = second_order.get_pde_term(
119 "volumetricSource", stateless=
True
121 assert "Q, derivatives," in source
125 in first_order.get_pde_term(
"volumetricSource", stateless=
True).implementation
127 assert "deltaQ, deltaQ + 25," in _ncp_call(first_order)
129 assert "S,\n Q, derivatives," in source
130 assert "[58]" not in ncp + source
137 assert "gaugeWave" in implementation
138 assert "initialValues[58]" in implementation
139 assert "Q[i] = initialValues[i]" in implementation
140 assert "derivatives[i] = initialValues[25 + i]" in implementation
146 "SO", parameters={
"CCZ4b": 1,
"CCZ4s": 1}
148 assert moving_puncture.advected_quantities() == list(
149 exagrype.api.FOSOCCZ4Solver.Unknowns
153 assert "shift" not in default.advected_quantities()
154 assert "b" not in default.advected_quantities()
155 assert "G" in default.advected_quantities()
156 assert "lapse" in default.advected_quantities()
159 "SO", parameters={
"CCZ4b": 0,
"CCZ4s": 1}
160 ).advected_quantities()
161 assert set(moving_puncture.advected_quantities()) - set(non_shifting) == {
169 "enforceCCZ4constraintsOfEvolvedVariables"
173 "enforceCCZ4constraintsOfEvolvedVariables"
182 exagrype.api.FOSOCCZ4Solver.EnforceCCZ4Constraint
183 is exagrype.api.FOCCZ4Solver.EnforceCCZ4Constraint
191 assert pair.ccz4.name ==
"SO"
192 assert pair.reconstruction.name ==
"SOReconstruction"
193 assert pair.reconstruction.ccz4
is pair.ccz4
195 assert pair.ccz4.unknowns == 25
196 assert pair.ccz4.number_of_auxiliary_variables == 33
197 assert pair.reconstruction.unknowns == 33
199 assert pair.reconstruction.variable_names_per_entry() == [
200 name.removeprefix(
"Derivatives.")
201 for name
in pair.ccz4.derivatives.variable_names_per_entry()
203 assert pair.reconstruction.pde_terms == []
204 assert pair.reconstruction.plotters == []
212 project.add_solver(pair)
213 assert project._solvers == [pair.ccz4, pair.reconstruction]
214 assert project._realisations == [pair]
215 assert pair.reconstruction.name ==
"Recon"
219 """! Neither solver sees the tasks of the other one, only the host's graph holds both"""
222 exahype2_project, peano_project =
_project(tmp_path)
224 for solver
in (pair.ccz4, pair.reconstruction):
225 original = solver.generate_solver_realisation
227 def record(*args, _solver=solver, _original=original, **kwargs):
228 result = _original(*args, **kwargs)
230 recorded[_solver.name] = (
232 [(t.name, len(t.dependencies))
for t
in args[3].tasks],
237 solver.generate_solver_realisation = record
239 pair.generate_solver_realisation(exahype2_project, peano_project, *project_graphs)
241 ccz4_graph, ccz4_tasks, ccz4_kwargs = recorded[
"SO"]
242 recon_graph, recon_tasks, recon_kwargs = recorded[
"SOReconstruction"]
243 assert ccz4_graph
is not recon_graph
244 assert ccz4_graph
is not project_graphs[1]
245 assert not any(
"Reconstruct derivatives" in name
for name, _
in ccz4_tasks)
247 (
"Reconstruct primary variables", 1),
248 (
"Interpolate primary variables on hanging faces", 0),
249 (
"Interpolate derivative variables on hanging faces", 0),
250 (
"Reconstruct derivative variables", 1),
251 (
"Reconstruct derivatives", 2),
252 (
"Project derivative variables onto faces", 1),
253 (
"Restrict derivative variables on hanging faces", 1),
254 (
"Roll over derivative variable faces", 1),
256 assert recon_tasks == [
257 (f
"SOReconstruction_{task_name} stage {stage}", dependencies)
258 for stage
in range(4)
259 for task_name, dependencies
in chain
262 assert len(project_graphs[1].tasks) == len(ccz4_tasks) + len(recon_tasks) + 2
264 assert ccz4_kwargs == {
"add_global_tasks":
False}
265 assert recon_kwargs == {
"add_global_tasks":
False}
271 def report(self, title="Task graph"):
272 titles[title] = [t.name
for t
in self.tasks]
284 own_ccz4 = titles[
"Time stepping task graph for SO (CCZ4 part)"]
285 own_reconstruction = titles[
286 "Time stepping task graph for SOReconstruction (reconstruction part of SO)"
289 "Time stepping task graph for host SO (concatenation of the graphs of SO, SOReconstruction)"
291 assert not any(
"Reconstruct derivatives" in name
for name
in own_ccz4)
292 assert len(own_reconstruction) == 4 * 8
294 assert sorted(host) == sorted(
298 "SO_Disable load balancing",
299 "SO_Dynamic mesh refinement and load balancing",
302 assert not any(
"Disable load balancing" in name
for name
in own_ccz4)
308 methods = dict(pair.reconstruction._abstract_solver_methods)
312 "getMinTimeStepSize",
313 "getMaxTimeStepSize",
315 definition = methods[f
"double {getter}() const override;"](
"A")
316 assert f
"repositories::instanceOfSO.{getter}()" in definition
317 assert "SolverRepository.h" in pair.reconstruction.user_solver_includes
322 order = time_step.ordered_tasks()
323 for stage
in range(4):
327 if task.name == f
"SO_Interpolate Derivatives on hanging faces stage {stage}"
332 if task.name.startswith(
"SOReconstruction_")
333 and task.name.endswith(f
" stage {stage}")
337 f
"SOReconstruction_Interpolate primary variables on hanging faces stage {stage}"
340 f
"SOReconstruction_Interpolate derivative variables on hanging faces stage {stage}"
344 f
"SOReconstruction_Roll over derivative variable faces stage {stage}"
346 assert last
in reconstruct.dependencies
347 assert order.index(last) < order.index(reconstruct)
350 for first
in first_tasks:
352 dependency.name.startswith(
"SO_Roll over stage")
353 or dependency.name.startswith(
"SO_Roll over solution")
354 for dependency
in first.dependencies
356 assert f
"SO_Prepare stage {stage}" in {
357 task.name
for task
in order[: order.index(first)]
364 time_step =
_realise(pair, tmp_path)
365 Access = peano4.api.taskgraph.Task.DataAccess
366 tasks = {task.name: task
for task
in time_step.tasks}
367 primary = tasks[
"SOReconstruction_Reconstruct primary variables stage 1"]
368 assert primary.cell_data_access[solver._stage_input] == Access.READ_AND_WRITE
370 primary.face_data_access[solver._patch_overlap_current_time_step]
371 == Access.READ_AND_WRITE
373 derivatives = tasks[
"SOReconstruction_Reconstruct derivative variables stage 1"]
375 derivatives.cell_data_access[solver.derivatives.patch] == Access.READ_AND_WRITE
378 derivatives.face_data_access[solver.derivatives.patch_overlap_current_time_step]
379 == Access.READ_AND_WRITE
387 enforce=exagrype.api.FOSOCCZ4Solver.EnforceCCZ4Constraint.IntermediateSteps,
389 names = [task.name
for task
in time_step.ordered_tasks()]
390 assert any(
"Enforce CCZ4 constraints" in name
for name
in names)
391 assert sum(
"Reconstruct derivatives" in name
for name
in names) == 4
399 solver, volume_size=1.0 / 27.0
405 if task.name ==
"SO_Interpolate Derivatives on hanging faces"
410 if task.name ==
"SOReconstruction_Roll over derivative variable faces"
412 assert last
in reconstruct.dependencies
413 assert order.index(last) < order.index(reconstruct)
414 assert sum(
"Reconstruct derivatives" in task.name
for task
in order) == 1
422 with pytest.raises(Exception):
423 pair.reconstruction.create_task_graph(
None,
None, 0, 1)
429 pair.ccz4, 9, rk_order=4
431 assert pair.ccz4.numerical_scheme.HALO_SIZE == 2
432 with pytest.raises(ValueError, match=
"at least three"):
433 pair.reconstruction.create_task_graph(
None,
None, 0, 1)
440 solver, 9, rk_order=4, kreiss_oliger_sigma=1.0
443 solver, volume_size=1.0 / 27.0
446 assert sum(
"Reconstruct derivatives" in task.name
for task
in time_step.tasks) == 4
447 assert pair.reconstruction.numerical_scheme.halo_size == 3
450@pytest.mark.parametrize(
455 Finite Volumes and Finite Differences both call the static terms. The
456 non-conservative product is registered when the solver is realised
457 (test_realisation_registers_the_ncp_which_fits_the_numerical_scheme in
458 test_exagrype_ccz4_solver.py checks that it is stateless).
460 solver = solver_class(
"S")
461 for name
in [
"volumetricSource",
"maxEigenvalue"]:
462 assert solver.get_pde_term(name, stateless=
True).stateless
463 with pytest.raises(KeyError):
464 solver.get_pde_term(name)
471 tasks = {task.name: task
for task
in time_step.tasks}
472 for stage
in range(4):
473 unknowns = tasks[f
"SO_Interpolate hanging faces stage {stage}"]
475 f
"SO_Interpolate Derivatives on hanging faces stage {stage}"
477 reconstruct = tasks[f
"SO_Reconstruct stage {stage}"]
478 reconstruct_derivatives = tasks[
479 f
"SO_Reconstruct auxiliary variables Derivatives stage {stage}"
482 f
"SOReconstruction_Roll over derivative variable faces stage {stage}"
485 assert unknowns
not in derivatives.dependencies
486 assert derivatives
not in unknowns.dependencies
487 assert unknowns
in reconstruct.dependencies
488 assert derivatives
in reconstruct_derivatives.dependencies
489 assert reconstruct_derivatives
not in reconstruct.dependencies
490 assert reconstruct
not in reconstruct_derivatives.dependencies
492 assert chain_end
in reconstruct.dependencies
494 assert chain_end
in derivatives.dependencies
496 rhs = tasks[f
"SO_Evaluate Runge-Kutta right hand side stage {stage}"]
497 assert reconstruct
in rhs.dependencies
498 assert reconstruct_derivatives
in rhs.dependencies
Everything the first-order and the second-order CCZ4 solvers share.
Fourth-order Finite Differences with Kreiss-Oliger dissipation.
Solver for the Einstein equations in the first-order CCZ4 formulation.
Solver for the Einstein equations in the first-/second-order reconstructed CCZ4 formulation.
Reconstructs the first derivatives which exagrype.api.FOSOCCZ4Solver needs.
CCZ4 in the first-/second-order reconstructed formulation as a coupled pair.
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....
Singleton logger for the Peano 4 Python API.
Represents a Peano 4 project.
Holds a sequence of Task instances.
This file is part of the ExaGRyPE project.
The task graph abstraction allows users to formalise their solver steps over small task graphs which ...
test_so_solver_has_no_formulation_switch_parameter()
test_so_solver_calls_the_second_order_kernels()
test_so_solver_enforces_only_the_constraints_of_the_evolved_unknowns()
test_host_reports_the_concatenated_graph(tmp_path, monkeypatch)
test_so_solver_advects_all_evolved_unknowns_with_lopsided_stencils()
test_interpolations_and_reconstructions_of_the_ccz4_solver_run_in_parallel(tmp_path)
_realise_pair(pair, tmp_path)
Let the host realise the pair and return the time step graph of the project.
test_so_solver_splits_the_initial_condition()
_realise(pair, tmp_path, enforce=None)
Configure the pair with FD4, realise both solvers and return the time step graph.
test_reconstruction_rejects_unsupported_schemes(tmp_path)
test_fososolver_hosts_the_ccz4_solver_and_the_reconstruction_solver()
test_pde_terms_are_stateless(solver_class)
Finite Volumes and Finite Differences both call the static terms.
test_reconstruction_solver_takes_turns_with_each_stage_of_the_solver(tmp_path)
test_reconstruction_keeps_the_data_it_shares_with_the_solver_alive(tmp_path)
test_project_registers_the_solvers_of_the_host_but_lets_the_host_realise_them(tmp_path)
test_reconstruction_works_together_with_the_constraint_enforcement(tmp_path)
_ncp_call(solver)
C++ which calls the kernel of the non-conservative product.
test_solvers_share_the_base_class()
test_reconstruction_rejects_a_halo_of_two(tmp_path)
test_reconstruction_adapts_to_the_larger_halo_of_the_dissipation_scheme(tmp_path)
test_reconstruction_runs_in_front_of_the_finite_volume_update(tmp_path)
_configure(pair, enforce=None)
Configure the CCZ4 solver of the pair with FD4 and lopsided advection.
test_reconstruction_solver_forwards_the_time_step_data_of_the_ccz4_solver(tmp_path)
test_so_solver_splits_the_58_entries_into_25_unknowns_and_33_derivatives()
test_solvers_build_separate_graphs_which_the_host_concatenates(tmp_path)
Neither solver sees the tasks of the other one, only the host's graph holds both.