5from ..AdaptivityCriterion
import get_adaptivity_criterion
6from ..blockstructured.create_dynamic_mesh_refinement_action_set
import (
7 create_dynamic_mesh_refinement_action_set,
9from ..Solver
import Solver
10from .SetupSimulationOverRegularGrid
import SetupSimulationOverRegularGrid
11from .actionsets
import InitialiseNewCells
17 Setup over a regular mesh which is then refined adaptively by the user's
20 The setup does everything SetupSimulationOverRegularGrid does: It
21 constructs a regular mesh and sets the initial condition. If the solver
22 has an exahype2.api.AdaptivityCriterion PDE term, the setup then
23 adapts this mesh. It inserts one further task after the task tagged with
24 SetupSimulationOverRegularGrid.FinishedInitialRegularMeshSetup, i.e.
25 after the initial condition. The projection onto the faces, which has
26 followed the initial condition so far, follows this new task instead and
27 hence remains the very last task of the setup.
29 The new task repeats until the mesh is stationary. It hosts two action
32 - The action set which also evaluates the criterion within the time
33 step (@ref exahype2.api.blockstructured.create_dynamic_mesh_refinement_action_set.create_dynamic_mesh_refinement_action_set())
34 turns the criterion's outcome into refine or erase events for
35 ExaHyPE's refinement service. Different to the time step, it also
36 hands the service's events over to Peano.
37 The mesh is never refined below min_volume_size.
38 The setup vetoes all erase commands, i.e. it only ever refines the
39 regular mesh: It has no restriction which would hand the patches of
40 erased cells over to their parent. Erase commands of the criterion
41 hence only take effect once the time stepping runs.
42 - exahype2.api.fv.actionsets.InitialiseNewCells sets the initial
43 condition within each cell which the refinement creates.
45 Without an adaptivity criterion, the setup is the same as
46 SetupSimulationOverRegularGrid.
48 Peano realises a refinement event one to two mesh sweeps after the
49 criterion has asked for it (@ref exahype2::RefinementControl). The mesh
50 hence might still be stationary in the sweeps right after the criterion
51 has issued an event. The task therefore repeats as long as the mesh
52 changes or the refinement service still holds events.
56 def __init__(self, solver: Solver, volume_size: float, min_volume_size: float):
59 @param volume_size: float
60 Maximum edge length of one Finite Volume. The setup first
61 constructs a regular mesh with this volume size
62 (@ref exahype2.api.fv.SetupSimulationOverRegularGrid). The mesh
63 refinement never erases cells of this regular mesh.
65 @param min_volume_size: float
66 Minimum edge length of one Finite Volume. The setup refines a cell
67 only if its volumes are at least of this size, i.e. the resulting
68 volumes are strictly smaller than min_volume_size. The
69 semantics are the same as for volume_size.
72 super().
__init__(solver, volume_size)
73 assert min_volume_size <= volume_size, (
74 f
"min_volume_size={min_volume_size} has to be smaller than or equal to "
75 f
"volume_size={volume_size}"
81 "not peano4::grid::isGridStationary( peano4::parallel::SpacetreeSet::getInstance().getGridStatistics() )"
82 " or not ::exahype2::RefinementControlService::getInstance().createGridControlEventsForNextTraversal().empty()"
88 Construct the setup over the regular mesh and insert the mesh
89 adaptation after it, if the solver has an adaptivity criterion
93 "Create setup task graph for Finite Volume scheme with user-coded refinement criterion"
98 anchors = setup_simulation.find_tasks(
99 SetupSimulationOverRegularGrid.FinishedInitialRegularMeshSetup
101 assert len(anchors) == 1, (
102 f
"Expected exactly one task tagged with "
103 f
"{SetupSimulationOverRegularGrid.FinishedInitialRegularMeshSetup}, "
104 f
"got {len(anchors)}"
113 Create the repeating task which adapts the mesh
118 name=f
"{self._solver.name} Adapt mesh",
119 entity=peano4.api.taskgraph.Task.GridEntity.CELL,
122 adapt_mesh_task.add_action_set(
123 create_dynamic_mesh_refinement_action_set(
129 hand_events_to_peano=
True,
133 adapt_mesh_task.add_action_set(
138 adapt_mesh_task.use_cell(
141 return adapt_mesh_task
Setup phase counterpart to RusanovWithExplicitEuler: sets the initial condition for a Finite Volume s...
_construct_task_graph(self, exahype2_project, peano_project, setup_simulation)
Add the tasks of the setup over a regular mesh to setup_simulation.
_solver
On adaptive meshes, restrict the fine data from the hanging faces onto the coarse faces.
_report_task_graph(self, setup_simulation)
Visualise or log the setup task graph, depending on the logger's verbosity.
Setup over a regular mesh which is then refined adaptively by the user's adaptivity criterion.
_create_adapt_mesh_task(self)
Create the repeating task which adapts the mesh.
construct_output(self, exahype2_project, peano_project, setup_simulation)
Construct the setup over the regular mesh and insert the mesh adaptation after it,...
tuple RepeatCondition
Repeat condition of the mesh adaptation task.
__init__(self, Solver solver, float volume_size, float min_volume_size)
Set the initial condition within cells which the mesh refinement creates.
Singleton logger for the Peano 4 Python API.
One task within a peano4.api.taskgraph.Graph.