Peano
Loading...
Searching...
No Matches
SeparateSweeps.py
Go to the documentation of this file.
1# This file is part of the ExaHyPE2 project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3from .RungeKuttaDG import RungeKuttaDG
4from exahype2.solvers.PDETerms import PDETerms
5
6import peano4
7import exahype2
8
9import jinja2
10
11from peano4.toolbox.blockstructured.ReconstructPatchAndApplyFunctor import ReconstructPatchAndApplyFunctor
12
13
15 """
16 Probably the simplest solver you could think off.
17 We run over the grid twice per Runge-Kutta step. In the first step,
18 we compute the linear reconstruction, project this one onto the faces
19 and also compute the volumetric prediction. In the second step, we
20 solve the Riemann problem and add it to the prediction.
21
22 In the attribute terminology, we call the two runs over the grid sweeps,
23 i.e., we work with two grid sweeps per Runge-Kutta step.
24 """
25
26 def __init__(self,
27 name,
28 rk_order,
29 polynomial_basis,
30 number_of_face_projections,
31 unknowns,
32 auxiliary_variables,
33 min_cell_h,
34 max_cell_h,
35 plot_grid_properties,
36 pde_terms_without_state):
37 """
38 The super call invokes the creation of the data sets, where the guards have
39 to be known already. So we bring those guys forward and then call the superclass
40 constructor.
41 """
42 self._name_name = name
43 self._rk_order_rk_order = rk_order
44
46 "repositories::" + self.get_name_of_global_instance() + ".getSolverState()==" + self._name_name + "::SolverState::GridInitialisation" + \
47 ")"
49 "repositories::" + self.get_name_of_global_instance() + ".getSolverState()==" + self._name_name + "::SolverState::TimeStepAfterGridInitialisation or " + \
50 "repositories::" + self.get_name_of_global_instance() + ".getSolverState()==" + self._name_name + "::SolverState::PlottingAfterGridInitialisation" + \
51 ")"
52
54 "{} and repositories::{}.getSolverState()=={}::SolverState::ProjectOnFacesAndComputeVolumeIntegralOfStep{}".format(self._store_cell_data_default_guard(),self.get_name_of_global_instance(),self._name_name,step) for step in range(0,self.number_of_Runge_Kutta_steps())
55 ]
57 "{} and repositories::{}.getSolverState()=={}::SolverState::SolveRiemannProblemAndAddToVolumeIntegralOfStep{}".format(self._store_cell_data_default_guard(),self.get_name_of_global_instance(),self._name_name,step) for step in range(0,self.number_of_Runge_Kutta_steps())
58 ]
59
61 "{} and repositories::{}.getSolverState()=={}::SolverState::ProjectOnFacesAndComputeVolumeIntegralOfStep{}".format(self._store_face_data_default_guard(),self.get_name_of_global_instance(),self._name_name,step) for step in range(0,self.number_of_Runge_Kutta_steps())
62 ]
64 "{} and repositories::{}.getSolverState()=={}::SolverState::SolveRiemannProblemAndAddToVolumeIntegralOfStep{}".format(self._store_face_data_default_guard(),self.get_name_of_global_instance(),self._name_name,step) for step in range(0,self.number_of_Runge_Kutta_steps())
65 ]
66
69
72
73 super(SeparateSweeps, self).__init__(name,
74 rk_order,
75 polynomial_basis,
76 number_of_face_projections,
77 unknowns,
78 auxiliary_variables,
79 min_cell_h,
80 max_cell_h,
81 plot_grid_properties,
82 pde_terms_without_state)
83
85
88
90 """
91 First, call the superclass' create_data_structures() to ensure that all
92 the data structures are in place.
93
94 The linear combination is to be computed if and only if
95 """
96 super(SeparateSweeps, self).create_data_structures()
97
99 self._estimate_projection.generator.receive_and_merge_condition = self._any_secondary_sweep_of_a_Runge_Kutta_step_on_face
100
101 self._Riemann_solution.generator.send_condition = "false"
102 self._Riemann_solution.generator.receive_and_merge_condition = "false"
103
104 any_primary_sweep_predicate = "(" + " or ".join( self._primary_sweeps_of_Runge_Kutta_step_on_cell ) + ")"
105 self._linear_combination_of_estimates.generator.load_store_compute_flag = "::peano4::grid::constructLoadStoreComputeFlag({},{},{})".format(
106 self._provide_cell_data_to_compute_kernels_default_guard() + " and " + any_primary_sweep_predicate,
107 "false",
108 "false",
109 )
110
111
113 """
114 We invoke the superclass which creates all the action sets, and then we
115 set the appropriate guards.
116
117 - _action_set_update_face_label - can be done always
118 - _action_set_update_cell_label - can be done always
119 - _action_set_linear_combination_of_estimates - primary sweeps only, as
120 these kick off the Runge-Kutta step.
121 - _action_set_couple_resolution_transitions_and_handle_dynamic_mesh_refinement -
122 primary only, as the secondary step is a sole clean-up
123 - _action_set_project_linear_combination_onto_faces - only required in
124 primary sweep. In the secondary, we collect the results together, i.e., we
125 don't immediately need the boundary data anymore.
126 - _action_set_solve_volume_integral - only done in the primary sweep.
127 - _action_set_handle_boundary - only in secondary sweep, as we now have
128 access to the left and right face data and hence can invoke the
129 Riemann solver.
130 - _action_set_solve_Riemann_problem - secondary sweep. See discussion of
131 previous item.
132 - _action_set_add_volume_and_face_solution - secondary sweep. The
133 Riemann solve plugs into the first touch of a face in the secondary
134 sweep, so now we can sum up the solutions.
135 - _action_set_compute_final_linear_combination_and_project_solution_onto_faces -
136 very last secondary sweep.
137 - _action_set_AMR - very last secondary sweep, i.e., after we have
138 the final solution.
139 - _action_set_postprocess_solution - same as for item above.
140
141 :: Guards around linear combination of estimates
142
143 We rely on the action set LinearCombination as it is initialised in the
144 superclass. So the only thing we have to do is to ensure that the
145 linear combination over the estimates is computed if and only if this
146 is required. For the separate sweeps, we compute the linear combinations
147 if the cell holds data, i.e., is on the finest level, and if it is the
148 primary of the two sweeps which realise a RK step, i.e., the one where
149 we later on project onto the faces.
150 """
151 super(SeparateSweeps, self).create_action_sets()
156
160
161 self._action_set_compute_final_linear_combination_and_project_solution_onto_faces.guard = self._store_cell_data_default_guard() + " and repositories::{}.getSolverState()=={}::SolverState::SolveRiemannProblemAndAddToVolumeIntegralOfStep{}".format(self.get_name_of_global_instance(),self._name_name,self.number_of_Runge_Kutta_steps()-1)
An abstract class for any RKDG solver of any order.
_store_cell_data_default_guard(self)
Extend the guard via ands only.
_store_face_data_default_guard(self)
Extend the guard via ands only.
create_data_structures(self)
Recall in subclasses if you wanna change the number of unknowns or auxiliary variables.
create_action_sets(self)
Overwrite in subclasses if you wanna create different action sets.
Probably the simplest solver you could think off.
__init__(self, name, rk_order, polynomial_basis, number_of_face_projections, unknowns, auxiliary_variables, min_cell_h, max_cell_h, plot_grid_properties, pde_terms_without_state)
The super call invokes the creation of the data sets, where the guards have to be known already.
create_data_structures(self)
First, call the superclass' create_data_structures() to ensure that all the data structures are in pl...
create_action_sets(self)
We invoke the superclass which creates all the action sets, and then we set the appropriate guards.