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)
39 """! The one task of the time step on which no other task depends"""
40 exahype2_project = types.SimpleNamespace(periodic_BC=[
True,
True,
True])
43 solver.numerical_scheme.construct_output(exahype2_project, peano_project, time_step)
45 id(dependency)
for task
in time_step.tasks
for dependency
in task.dependencies
47 [last] = [task
for task
in time_step.tasks
if id(task)
not in dependencies]
52 return action_set.get_body_of_operation(ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME)
55@pytest.mark.parametrize("scheme", SCHEMES)
58 assert last.name ==
"Probe_Dynamic mesh refinement"
59 assert last.entity == Task.GridEntity.CELL
60 dynamic_mesh_refinement, load_balancing = last.action_sets
65 load_balancing, toolbox.loadbalancing.api.actionsets.LoadBalancing
67 body = load_balancing.get_body_of_unprepareTraversal()
68 assert body.index(
"enable(true)") < body.index(
"finishStep()")
71@pytest.mark.parametrize("scheme", SCHEMES)
74 assert "RefinementControlService" not in (
75 dynamic_mesh_refinement.get_body_of_createGridControlEventsForNextTraversal()
77 assert "refineErasePointwisely" in _criterion_body(dynamic_mesh_refinement)
78 assert "RefinementControlService::getInstance().finishStep()" in (
79 dynamic_mesh_refinement.get_body_of_unprepareTraversal()
83@pytest.mark.parametrize("scheme", SCHEMES)
86 assert last.name ==
"Probe_Dynamic mesh refinement"
87 [load_balancing] = last.action_sets
89 load_balancing, toolbox.loadbalancing.api.actionsets.LoadBalancing
93@pytest.mark.parametrize("scheme", SCHEMES)
95 solver =
_solver(scheme, criterion=
False)
97 [dynamic_mesh_refinement, _] =
_last_task(solver, tmp_path).action_sets
99 dynamic_mesh_refinement,
103 assert "refineErasePointwisely" not in body
104 assert "for (int normal=0; normal<Dimensions; normal++)" in body
105 assert "for (int side=0; side<2; side++)" in body
106 assert "::exahype2::fv::computeOneSidedGradient(" in body
107 assert "refineEraseWithGradient(" in body
108 assert "double gradient[2 + 0];" in body
109 assert "anyVolumeWantsToRefine or command" in body
110 assert "allVolumesWantToErase and command" in body
111 assert "finishStep()" in dynamic_mesh_refinement.get_body_of_unprepareTraversal()
114@pytest.mark.parametrize("scheme", SCHEMES)
117 assert "RefinementCommand::Erase," in _criterion_body(dynamic_mesh_refinement)
123 with pytest.raises(ValueError):
130 assert "tarch::la::max( marker.h() ) >=" not in body
131 assert "3.0 * tarch::la::max( marker.h() ) <" not in body
134@pytest.mark.parametrize("scheme", SCHEMES)
136 solver =
_solver(scheme, min_volume_size=0.25, max_volume_size=1.0)
137 [dynamic_mesh_refinement, _] =
_last_task(solver, tmp_path).action_sets
140 assert "tarch::la::max( marker.h() ) >= 1.0" in body
141 assert "3.0 * tarch::la::max( marker.h() ) < 4.0" in body
144@pytest.mark.parametrize("scheme", SCHEMES)
146 with pytest.raises(AssertionError):
147 _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.
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)