1"""Unit tests for the setup with user-coded refinement criterion
2(@ref exahype2.api.fv.SetupSimulationWithUserCodedRefinementCriterion)."""
23 implementation=
"if (Q[0] > 0.8) *refinementCommand = ::exahype2::RefinementCommand::Refine;"
28 solver, volume_size=0.02, min_volume_size=0.002
35 exahype2_project = types.SimpleNamespace(periodic_BC=[
True,
True,
True])
37 solver.grid_construction.construct_output(exahype2_project, peano_project, graph)
42 matches = [task
for task
in graph.tasks
if task.name.endswith(suffix)]
43 assert len(matches) == 1, [task.name
for task
in graph.tasks]
49 tagged = graph.find_tasks(SetupOverRegularGrid.FinishedInitialRegularMeshSetup)
50 assert [task.name
for task
in tagged] == [
"Probe Initial condition"]
55 assert not any(task.name.endswith(
"Adapt mesh")
for task
in graph.tasks)
56 assert _task(graph,
"Project on faces").dependencies == [
57 _task(graph,
"Initial condition")
63 adapt =
_task(graph,
"Adapt mesh")
64 assert adapt.dependencies == [
_task(graph,
"Initial condition")]
65 assert _task(graph,
"Project on faces").dependencies == [adapt]
66 assert adapt.has_to_repeat == SetupWithCriterion.RepeatCondition
67 assert "isGridStationary" in adapt.has_to_repeat
68 assert "RefinementControlService" in adapt.has_to_repeat
71 _task(graph,
"Project on faces")
in task.dependencies
for task
in graph.tasks
77 action_sets =
_task(graph,
"Adapt mesh").action_sets
78 assert [type(action_set)
for action_set
in action_sets] == [
82 criterion, initialisation = action_sets
84 body = criterion.get_body_of_operation(ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME)
85 assert "refineErasePointwisely(" in body
87 "::exahype2::RefinementCommand command = ::exahype2::RefinementCommand::Keep;"
91 assert ">= 0.018" in body
93 assert "RefinementCommand::Erase," not in body
94 assert "finishStep()" in criterion.get_body_of_unprepareTraversal()
96 "createGridControlEventsForNextTraversal()"
97 in criterion.get_body_of_createGridControlEventsForNextTraversal()
99 create_cell = initialisation.get_body_of_operation(ActionSet.OPERATION_CREATE_CELL)
100 assert "initPointWisely(" in create_cell
102 initialisation.get_body_of_operation(ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME)
108 solver =
_solver(with_criterion=
True)
109 with pytest.raises(AssertionError):
121 solver, volume_size=0.02, min_volume_size=0.002
128 "createGridControlEventsForNextTraversal()"
129 in criterion.get_body_of_createGridControlEventsForNextTraversal()
The conservative flux F(Q) of a hyperbolic PDE.
Gradient-based refinement criterion: given a one-sided difference quotient of the solution along one ...
Point-wise initial condition: given the physical position of a single degree of freedom,...
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-...
Setup phase counterpart to RusanovWithExplicitEuler: sets the initial condition for a Finite Volume s...
Setup over a regular mesh which is then refined adaptively by the user's adaptivity criterion.
Set the initial condition within cells which the mesh refinement creates.
Represents a Peano 4 project.
Action set (reactions to events)
Holds a sequence of Task instances.
The task graph abstraction allows users to formalise their solver steps over small task graphs which ...
test_adapt_mesh_task_evaluates_gradient_criterion(tmp_path)
test_min_volume_size_must_not_exceed_volume_size()
test_adapt_mesh_task_hosts_criterion_and_initialisation(tmp_path)
test_adapt_mesh_task_sits_between_initial_condition_and_projection(tmp_path)
_setup_graph(solver, tmp_path)
test_regular_grid_tags_initial_condition(tmp_path)
test_without_criterion_setup_equals_regular_grid(tmp_path)