Peano
Loading...
Searching...
No Matches
test_hanging_faces.py
Go to the documentation of this file.
1"""Hanging faces on adaptive meshes: the toolbox action sets
2(toolbox.blockstructured.api.InterpolateHangingFaces,
3toolbox.blockstructured.api.RestrictHangingFaces) and how the Finite
4Volume scheme uses them."""
5
6import peano4.api
10import exahype2.api
12
14Interpolate = toolbox.blockstructured.api.InterpolateHangingFaces
15Restrict = toolbox.blockstructured.api.RestrictHangingFaces
16
17
19 return peano4.api.datamodel.Patch((2, 9, 9), 4, "QFace")
20
21
23 action_set = Interpolate(_face_patch())
24 body = action_set.get_body_of_operation(ActionSet.OPERATION_CREATE_HANGING_FACE)
25 assert "interpolateHaloLayer_AoS_linear_with_constant_extrapolation(" in body
26 assert "coarseGridFacesQFace(marker.getSelectedFaceNumber()).value" in body
27 assert "fineGridFaceQFace.value" in body
28 for operation in [
29 ActionSet.OPERATION_DESTROY_HANGING_FACE,
30 ActionSet.OPERATION_TOUCH_FACE_FIRST_TIME,
31 ActionSet.OPERATION_CREATE_CELL,
32 ]:
33 assert action_set.get_body_of_operation(operation) == ""
34
35
37 action_set = Interpolate(_face_patch(), Interpolate.Scheme.PiecewiseConstant)
38 body = action_set.get_body_of_operation(ActionSet.OPERATION_CREATE_HANGING_FACE)
39 assert "interpolateHaloLayer_AoS_piecewise_constant(" in body
40
41
43 action_set = Restrict(_face_patch(), clear_guard="myClearGuard")
44 body = action_set.get_body_of_operation(ActionSet.OPERATION_DESTROY_HANGING_FACE)
45 assert "restrictInnerHalfOfHaloLayer_AoS_averaging(" in body
46 assert "coarseGridFacesQFace(marker.getSelectedFaceNumber()).value" in body
47 clear = action_set.get_body_of_operation(ActionSet.OPERATION_TOUCH_FACE_FIRST_TIME)
48 assert "clearHaloLayerAoS(" in clear
49 assert (
50 action_set.get_guard_of_operation(ActionSet.OPERATION_TOUCH_FACE_FIRST_TIME)
51 == "myClearGuard"
52 )
53
54
56 action_set = Restrict(_face_patch(), Restrict.Scheme.Inject)
57 body = action_set.get_body_of_operation(ActionSet.OPERATION_DESTROY_HANGING_FACE)
58 assert "restrictInnerHalfOfHaloLayer_AoS_inject(" in body
59 assert (
60 action_set.get_body_of_operation(ActionSet.OPERATION_TOUCH_FACE_FIRST_TIME)
61 == ""
62 )
63
64
65def _graphs(tmp_path, **scheme_arguments):
66 solver = exahype2.api.Solver("Probe", 4, 0)
67 solver.add_pde_term(exahype2.api.Flux(implementation=""))
68 solver.add_pde_term(exahype2.api.MaxEigenvalue(implementation=""))
69 solver.add_pde_term(exahype2.api.InitPointWisely(implementation=""))
70 solver.numerical_scheme = exahype2.api.fv.RusanovWithExplicitEuler(
71 solver, 9, **scheme_arguments
72 )
73 solver.grid_construction = exahype2.api.fv.SetupSimulationOverRegularGrid(
74 solver, volume_size=0.1
75 )
76 exahype2_project = exahype2.api.Project(
77 ["probe"], "probe", "probe", directory=str(tmp_path)
78 )
79 exahype2_project.set_global_simulation_parameters(
80 dimensions=2,
81 offset=[0.0, 0.0],
82 size=[1.0, 1.0],
83 min_end_time=1.0,
84 periodic_BC=[True, True, True],
85 )
86 peano_project = peano4.api.Project(["probe"], "probe", str(tmp_path))
87 graphs = [peano4.api.taskgraph.Graph() for _ in range(4)]
88 solver.generate_solver_realisation(exahype2_project, peano_project, *graphs)
89 return solver, [{task.name: task for task in graph.tasks} for graph in graphs[:2]]
90
91
92def _action_sets_of_type(task, action_set_type):
93 return [a for a in task.action_sets if isinstance(a, action_set_type)]
94
95
97 tmp_path,
98):
99 solver, (setup, time_step) = _graphs(tmp_path)
100 (interpolation,) = _action_sets_of_type(time_step["Probe_Reconstruct"], Interpolate)
101 assert interpolation.scheme == Interpolate.Scheme.Linear
102 assert interpolation.d["FACE_NAME"] == solver._patch_overlap_current_time_step.name
103 (restriction,) = _action_sets_of_type(time_step["Probe_Project on faces"], Restrict)
104 assert restriction.scheme == Restrict.Scheme.Averaging
105 assert restriction.d["FACE_NAME"] == solver._patch_overlap_update.name
106 (setup_restriction,) = _action_sets_of_type(
107 setup["Probe Project on faces"], Restrict
108 )
109 assert setup_restriction.d["FACE_NAME"] == solver._patch_overlap_update.name
110
111
113 _, (setup, time_step) = _graphs(
114 tmp_path,
115 interpolation=Interpolate.Scheme.PiecewiseConstant,
116 restriction=Restrict.Scheme.Inject,
117 )
118 (interpolation,) = _action_sets_of_type(time_step["Probe_Reconstruct"], Interpolate)
119 assert interpolation.scheme == Interpolate.Scheme.PiecewiseConstant
120 for task in [time_step["Probe_Project on faces"], setup["Probe Project on faces"]]:
121 (restriction,) = _action_sets_of_type(task, Restrict)
122 assert restriction.scheme == Restrict.Scheme.Inject
The conservative flux F(Q) of a hyperbolic PDE.
Definition Flux.py:8
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.
ExaHyPE 2 project.
Definition Project.py:15
Abstract base class for all ExaHyPE 2 solvers.
Definition Solver.py:17
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...
Represents a Peano 4 project.
Definition Project.py:23
Patch implementation of a degree of freedom.
Definition Patch.py:7
Action set (reactions to events)
Definition ActionSet.py:6
Holds a sequence of Task instances.
Definition Graph.py:9
The Python-side model of "what happens during one mesh sweep".
Definition __init__.py:1
The task graph abstraction allows users to formalise their solver steps over small task graphs which ...
Definition __init__.py:1
test_interpolation_defaults_to_linear_in_create_hanging_face()
test_time_step_interpolates_before_reconstruction_and_restricts_projection(tmp_path)
_action_sets_of_type(task, action_set_type)
test_averaging_restricts_in_destroy_hanging_face_and_clears_faces()
_graphs(tmp_path, **scheme_arguments)
test_schemes_are_configurable(tmp_path)