10import toolbox.loadbalancing.api.actionsets
23 solver, patch_size=4, rk_order=2, **bounds
28def _solver(scheme, criterion=True, **bounds):
30 solver.add_pde_term(
exahype2.api.Flux(implementation=
"F[0] = Q[0]; F[1] = Q[1];"))
34 solver.numerical_scheme = SCHEMES[scheme](solver, **bounds)
40 The one task of the time step on which no other task depends, apart from
41 the tasks that act at the end of the time step (such as the one that
42 computes the time step size)
44 exahype2_project = types.SimpleNamespace(periodic_BC=[
True,
True,
True], _dimensions=3)
47 solver.numerical_scheme.construct_output(exahype2_project, peano_project, time_step)
49 id(dependency)
for task
in time_step.tasks
for dependency
in task.dependencies
53 for task
in time_step.tasks
54 if id(task)
not in dependencies
55 and task.entity != Task.GridEntity.GLOBAL_END_OF_STEP
61 return action_set.get_body_of_operation(ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME)
64@pytest.mark.parametrize("scheme", SCHEMES)
67 assert last.name == f
"Probe_{exahype2.api.Solver.NumericalScheme.DYNAMIC_MESH_REFINEMENT_TASK_NAME}"
68 assert last.entity == Task.GridEntity.CELL
69 dynamic_mesh_refinement, load_balancing = last.action_sets
74 load_balancing, toolbox.loadbalancing.api.actionsets.LoadBalancing
76 body = load_balancing.get_body_of_unprepareTraversal()
77 assert body.index(
"enable(true)") < body.index(
"finishStep()")
80@pytest.mark.parametrize("scheme", SCHEMES)
83 assert "RefinementControlService" not in (
84 dynamic_mesh_refinement.get_body_of_createGridControlEventsForNextTraversal()
86 assert "refineErasePointwisely" in _criterion_body(dynamic_mesh_refinement)
87 assert "RefinementControlService::getInstance().finishStep()" in (
88 dynamic_mesh_refinement.get_body_of_unprepareTraversal()
92@pytest.mark.parametrize("scheme", SCHEMES)
95 assert last.name == f
"Probe_{exahype2.api.Solver.NumericalScheme.DYNAMIC_MESH_REFINEMENT_TASK_NAME}"
96 [load_balancing] = last.action_sets
98 load_balancing, toolbox.loadbalancing.api.actionsets.LoadBalancing
102@pytest.mark.parametrize("scheme", SCHEMES)
104 solver =
_solver(scheme, criterion=
False)
106 [dynamic_mesh_refinement, _] =
_last_task(solver, tmp_path).action_sets
108 dynamic_mesh_refinement,
112 assert "refineErasePointwisely" not in body
113 assert "for (int normal=0; normal<Dimensions; normal++)" in body
114 assert "for (int side=0; side<2; side++)" in body
115 assert "::exahype2::fv::computeOneSidedGradient(" in body
116 assert "refineEraseWithGradient(" in body
117 assert "double gradient[2 + 0];" in body
118 assert "anyVolumeWantsToRefine or command" in body
119 assert "allVolumesWantToErase and command" in body
120 assert "finishStep()" in dynamic_mesh_refinement.get_body_of_unprepareTraversal()
123@pytest.mark.parametrize("scheme", SCHEMES)
126 assert "RefinementCommand::Erase," in _criterion_body(dynamic_mesh_refinement)
132 with pytest.raises(ValueError):
139 assert "tarch::la::max( marker.h() ) >=" not in body
140 assert "3.0 * tarch::la::max( marker.h() ) <" not in body
143@pytest.mark.parametrize("scheme", SCHEMES)
145 solver =
_solver(scheme, min_volume_size=0.25, max_volume_size=1.0)
146 [dynamic_mesh_refinement, _] =
_last_task(solver, tmp_path).action_sets
149 assert "tarch::la::max( marker.h() ) >= 1.0" in body
150 assert "3.0 * tarch::la::max( marker.h() ) < 4.0" in body
153@pytest.mark.parametrize("scheme", SCHEMES)
155 with pytest.raises(AssertionError):
156 _solver(scheme, min_volume_size=1.0, max_volume_size=0.5)
The conservative flux F(Q) of a hyperbolic PDE.
Gradient-based refinement criterion: given a one-sided difference quotient of the solution along one ...
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.
Evaluate the gradient-based refinement criterion and collect the outcome as refine and erase requests...
Evaluate the point-wise refinement criterion and collect the outcome as refine and erase requests.
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,...
Fourth-order central Finite Differences with explicit Runge-Kutta time stepping, realised over a bloc...
Represents a Peano 4 project.
Action set (reactions to events).
Holds a sequence of Task instances.
One task within a peano4.api.taskgraph.Graph.
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_gradient_criterion_yields_gradient_action_set(scheme, tmp_path)
_criterion_body(action_set)
_last_task(solver, tmp_path)
The one task of the time step on which no other task depends, apart from the tasks that act at the en...
test_last_task_evaluates_criterion_and_switches_on_load_balancing(scheme, tmp_path)
_solver(scheme, criterion=True, **bounds)
test_mesh_size_is_unconstrained_by_default(tmp_path)
test_numerical_scheme_rejects_inverted_bounds(scheme)
test_no_criterion_means_no_evaluation(scheme, tmp_path)
test_two_criteria_are_rejected(tmp_path)
test_time_step_never_hands_events_to_peano(scheme, tmp_path)
test_time_step_does_not_veto_erase(scheme, tmp_path)
test_numerical_scheme_bounds_mesh_size(scheme, tmp_path)