13 from abc
import abstractmethod
15 from exahype2.solvers.PDETerms
import PDETerms
17 from .actionsets
import ( SpreadLimiterStatus, SolveRiemannProblem, VerifyTroubledness)
26 limiting_criterion_implementation = PDETerms.User_Defined_Implementation
38 These will be used by children of this class to fill them with the declaration and definition of the
39 above mandatory and optional functions.
48 Used by child classes, will contain code to be executed at the start and end respectively of the
49 time step. Typically specifies some timestep variable and advances the overall timestamp of the
61 raise Exception(
"Limiting criterion cannot be none")
69 Creates all the structures which are attached on the peano grid either in a cell or on the faces.
70 These are defined as peano patches which have given sizes to contain persistent data as well as
71 conditions for when they should be merged, sent, received, stored, loaded, etc.
78 This will serve as a face marker to communicate with neighbouring cells whether
79 a given cell is troubled, is neighbouring a troubled cell, or is fine.
80 Cells that are troubled or neighbouring a troubled cell must rollback their solution
81 to the previous one and perform one timestep using a more robust FV scheme.
82 Therefore these and their neighbours must convert the DG representation of their
83 previous solution to an FV representation and project it to their faces so that these
84 can be exchanged with their neighbours.
86 Variants = [
"REGULAR",
"REGULAR_TO_LIMITER",
"LIMITER_TO_REGULAR",
"TROUBLED"]
89 self.
_cell_label_cell_label.data.add_attribute(dastgen2.attributes.Enumeration( name=
"Troubled_Marker", variants=Variants, initval=
"Troubled_Marker::REGULAR" ) )
90 self.
_face_label_face_label.data.add_attribute(dastgen2.attributes.Enumeration( name=
"Troubled_Marker", variants=Variants, initval=
"Troubled_Marker::REGULAR" ) )
92 self.
_face_label_face_label.peano4_mpi_and_storage_aspect.merge_implementation +=
"\n _Troubled_Marker = std::max(_Troubled_Marker, neighbour.getTroubled_Marker());"
94 compute_time_step_size =
"""
99 self.
_limiter_solver_limiter_solver._compute_time_step_size = compute_time_step_size
100 self.
_regular_solver_regular_solver._compute_time_step_size = compute_time_step_size
103 Creates the action sets, these are actions tied to the grid that are executed at given points of
104 grid generation, construction or steps of the ader-dg solver. Peano handles grid structures that
105 contain data as well as operations that are executed on that data. These are the latter.
106 The guard here are the conditions for the execution of the operation, as in they are only executed
107 if the guard evaluates to true.
114 guard = (
"not marker.willBeRefined() and not marker.hasBeenRefined() and" +
115 " repositories::" + self.
get_name_of_global_instanceget_name_of_global_instance() +
".getSolverState()==" + self.
_name_name +
"::SolverState::GridInitialisation"
124 guard = (
"not marker.willBeRefined() and not marker.hasBeenRefined()"
125 +
" and repositories::" + self.
get_name_of_global_instanceget_name_of_global_instance() +
".getSolverState()==" + self.
_name_name +
"::SolverState::TimeStepping"
131 checking troubledness needs to happen in the initialization after the regular solver
132 has computed its initial condition.
133 spreading limiter status happens once in its own dedicated step after initialization
134 but before either solvers are allowed to start computing, and once in the first
135 timestep before any other operations are performed
136 copying and converting the data from regular to limiter and from limiter to regular
137 happens before they are used in the first grid traversal, so either at the very
138 beginning of the first grid traversal or at the end of the second, so that
139 regular-to-limiter and limiter-to-regular cells both have access to either version
140 and can therefore project both variants of their faces
147 " and fineGridCell" + self.
_name_name +
"CellLabel.getTroubled_Marker()==celldata::" + self.
_name_name +
"CellLabel::Troubled_Marker::REGULAR"
151 " and fineGridCell" + self.
_name_name +
"CellLabel.getTroubled_Marker()==celldata::" + self.
_name_name +
"CellLabel::Troubled_Marker::REGULAR"
159 " and fineGridCell" + self.
_name_name +
"CellLabel.getTroubled_Marker()==celldata::" + self.
_name_name +
"CellLabel::Troubled_Marker::TROUBLED"
163 " and fineGridCell" + self.
_name_name +
"CellLabel.getTroubled_Marker()==celldata::" + self.
_name_name +
"CellLabel::Troubled_Marker::TROUBLED"
166 self.
_limiter_solver_limiter_solver._action_set_correction.face_guard += (
167 " and fineGridFace" + self.
_name_name +
"FaceLabel.getTroubled_Marker()>=facedata::" + self.
_name_name +
"FaceLabel::Troubled_Marker::LIMITER_TO_REGULAR"
174 """ ExaHyPE 2 Limiting solver"""
185 Add further includes to this property, if your action sets require some additional
186 routines from other header files.
193 "not marker.willBeRefined() "
194 +
"and repositories::"
196 +
".getSolverState()!="
198 +
"::SolverState::GridConstruction"
203 "not marker.willBeRefined() "
204 +
"and repositories::"
206 +
".getSolverState()!="
208 +
"::SolverState::GridConstruction"
213 "not marker.willBeRefined() "
214 +
"and repositories::"
216 +
".getSolverState()!="
218 +
"::SolverState::GridConstruction"
223 "not marker.hasBeenRefined() "
224 +
"and repositories::"
226 +
".getSolverState()!="
228 +
"::SolverState::GridConstruction "
229 +
"and repositories::"
231 +
".getSolverState()!="
233 +
"::SolverState::GridInitialisation"
238 "not marker.willBeRefined() "
239 +
"and repositories::"
241 +
".getSolverState()!="
243 +
"::SolverState::GridConstruction"
248 "not marker.hasBeenRefined() "
249 +
"and repositories::"
251 +
".getSolverState()!="
253 +
"::SolverState::GridConstruction "
254 +
"and repositories::"
256 +
".getSolverState()!="
258 +
"::SolverState::GridInitialisation"
264 +
" and not repositories::"
266 +
".PeriodicBC[marker.getSelectedFaceNumber()%DIMENSIONS]"
267 +
" and not marker.hasBeenRefined() and fineGridFace"
269 +
"FaceLabel.getBoundary()"
274 "not marker.willBeRefined()"
275 +
"and repositories::"
277 +
".getSolverState()!="
279 +
"::SolverState::GridConstruction "
286 +
".getSolverState()!="
288 +
"::SolverState::GridInitialisation"
295 return self.
_name_name +
"Q"
298 return "InstanceOf" + self.
_name_name
302 #include "tarch/la/Vector.h"
304 #include "peano4/utils/Globals.h"
305 #include "peano4/utils/Loop.h"
307 #include "repositories/SolverRepository.h"
312 The following functions will be called by the peano4 project,
313 they tell peano which of our generated data it should attach
314 to each grid element and use.
320 Name: """ + self.
_name_name +
"""
321 Type: """ + self.__class__.__name__
361 kernels_namespace = namespace + [
"kernels", self.
_name_name]
362 kernels_output_path = subdirectory +
"kernels/" + self.
_name_name
363 kernels_templates_prefix = os.path.dirname(os.path.realpath(__file__)) +
"/kernels/"
365 if not os.path.exists(kernels_output_path):
366 os.makedirs(kernels_output_path)
368 kernels.Limiter(d).generate_kernels(
369 kernels_namespace, output, subdirectory,
370 kernels_templates_prefix, kernels_output_path,
371 regular_solver_quadpoints = self.
_regular_solver_regular_solver._basis.quadrature_points(render=
False),
372 limiter_solver_quadpoints = self.
_limiter_solver_limiter_solver._basis.quadrature_points(render=
False)
376 This tells peano to add the solver files to the project. It generates any files that are not
377 specifically cell or face data or grid actions such as the actionsets.
378 Currently it generates solver implementation and header files.
382 The ExaHyPE2 project will call this operation when it sets
383 up the overall environment.
385 This routine is typically not invoked by a user.
387 output: peano4.output.Output
390 HeaderDictionary = {}
393 generated_abstract_files = (
394 peano4.output.Jinja2TemplatedHeaderImplementationFilePair(
395 os.path.dirname(os.path.realpath(__file__)) +
"/StaticCouplingAbstract.template.h",
396 os.path.dirname(os.path.realpath(__file__)) +
"/StaticCouplingAbstract.template.cpp",
397 "Abstract" + self.
_name_name,
406 generated_solver_files = (
407 peano4.output.Jinja2TemplatedHeaderImplementationFilePair(
408 os.path.dirname(os.path.realpath(__file__)) +
"/StaticCoupling.template.h",
409 os.path.dirname(os.path.realpath(__file__)) +
"/StaticCoupling.template.cpp",
419 output.add(generated_abstract_files)
420 output.makefile.add_cpp_file(subdirectory +
"Abstract" + self.
_name_name +
".cpp", generated=
True)
421 output.makefile.add_h_file(subdirectory +
"Abstract" + self.
_name_name +
".h", generated=
True)
423 output.add(generated_solver_files)
424 output.makefile.add_cpp_file(subdirectory + self.
_name_name +
".cpp", generated=
True)
425 output.makefile.add_h_file(subdirectory + self.
_name_name +
".h", generated=
True)
427 self.
_generate_kernels_generate_kernels(namespace, output, subdirectory, dimensions)
434 Generates a dictionary of "words" that will later be used in various templates to fill these out by adding
435 information from the solver or which was specified by the user.
443 d[
"SOLVER_NAME"] = self.
_name_name
456 d[
"REGULAR_SOLVER_STORAGE_PRECISION"] = self.
_regular_solver_regular_solver._solution_persistent_storage_precision
458 d[
"REGULAR_SOLVER_CORRECTION_PRECISION"] = self.
_regular_solver_regular_solver._corrector_computation_precision
459 d[
"LIMITER_SOLVER_CORRECTION_PRECISION"] = self.
_limiter_solver_limiter_solver._corrector_computation_precision
461 d[
"NUMBER_OF_DOFS_PER_CELL_2D"] = (
464 d[
"NUMBER_OF_DOFS_PER_CELL_3D"] = (
468 d[
"SOLVER_USER_DECLARATIONS"] = jinja2.Template(
471 d[
"SOLVER_USER_DEFINITIONS"] = jinja2.Template(
475 d[
"START_TIME_STEP_IMPLEMENTATION"] = jinja2.Template(
478 d[
"FINISH_TIME_STEP_IMPLEMENTATION"] = jinja2.Template(
481 d[
"PRINT_TIME_STEP_IMPLEMENTATION"] = jinja2.Template(
485 d[
"CONSTRUCTOR_IMPLEMENTATION"] = jinja2.Template(
def __init__(self, name, regularSolver, limitingSolver, limiting_criterion_implementation=PDETerms.User_Defined_Implementation)
def add_actions_to_plot_solution(self, step, output_path)
def create_data_structures(self)
This will serve as a face marker to communicate with neighbouring cells whether a given cell is troub...
def add_actions_to_init_grid(self, step)
def _get_default_includes(self)
def _load_cell_data_default_guard(self)
_solver_user_declarations
def _load_face_data_default_guard(self)
def _store_cell_data_default_guard(self)
def _restrict_face_data_default_guard(self)
def get_user_solver_includes(self)
def _interpolate_face_data_default_guard(self)
def add_entries_to_text_replacement_dictionary(self, d)
def add_user_action_set_includes(self, value)
Add further includes to this property, if your action sets require some additional routines from othe...
def create_action_sets(self)
def add_to_Peano4_datamodel(self, datamodel)
_start_time_step_implementation
def _init_dictionary_with_default_parameters(self, d)
def _clear_face_data_default_guard(self)
def add_implementation_files_to_project(self, namespace, output, dimensions, subdirectory="")
The ExaHyPE2 project will call this operation when it sets up the overall environment.
def _generate_kernels(self, namespace, output, subdirectory, dimensions)
def add_use_data_statements_to_Peano4_solver_step(self, step)
def _store_boundary_data_default_guard(self)
def create_readme_descriptor(self, domain_offset, domain_size)
_print_time_step_implementation
_constructor_implementation
def _store_face_data_default_guard(self)
_action_set_copy_face_data
def set_plot_description(self, description)
def get_name_of_global_instance(self)
def add_actions_to_perform_time_step(self, step)
def add_actions_to_create_grid(self, step, evaluate_refinement_criterion)
def _provide_cell_data_to_compute_kernels_default_guard(self)
_physical_admissibility_criterion
_action_set_check_troubledness
def _provide_face_data_to_compute_kernels_default_guard(self)
_finish_time_step_implementation
def get_user_action_set_includes(self)
def _unknown_identifier(self)