19 Represents an ExaHyPE 2 project. An ExaHyPE2 project is a Peano 4
20 project with a particular set of actions (algorithmic phases)
21 that you can choose from and with particular solver types. It
22 realises a builder mechanism, i.e. you build up your ExaHyPE 2
23 project and then you finally tell the project "give me the Peano 4
24 project". From hereon, you can use this Peano 4 project to actually
25 set up the Peano 4 application.
27 The project will have a marker per cell that encodes stuff alike
28 a boundary marker. But it is also used to coordinate different
31 @see generate_Peano4_project()
34 def __init__(self, namespace, project_name, executable, directory=".", subdirectory="", abstract_overwrite=True):
57 "tarch/accelerator/Device.h"
86 load_balancer_name: string
87 Should be full-qualified name of the load balancer.
88 By default, I recommend to pass "toolbox::loadbalancing::strategies::RecursiveSubdivision".
90 load_balancer_arguments: string
91 If your load balancing requires parameters, add them
92 here. It is a string that will be copied into the C++ class instantiation.
93 Please add the brackets yourself, i.e. "(3,4,5)" is fine, but "3,4,5" is not.
94 The only exception is the empty parameter list. Here, you can/should simply
102 """! Set a log filter file name
103 Pass in the empty string, if you want the code to use the hard-coded
110 """! Set number of threads to use
111 Pass in number of threads (positive integer) or a string such as
112 "tarch::multicore::Core::UseDefaultNumberOfThreads".
118 """! Set orchestration
119 value has to be a string which creates an orchestration object,
120 i.e., an object of the type tarch::multicore::orchestration::Orchestration.
121 You can either create it directly (in this case you need to add a new),
122 or you can use a factory method such as
123 "tarch::multicore::orchestration::StrategyFactory::createDefaultStrategy()".
130 value has to be a number greater or equal to zero, this then sets the
131 timeout in seconds after which a node waiting for an MPI message shall
132 quit an shutdown the whole application with an error report.
133 If zero is passed, this feature is switched off and nodes will wait
137 raise Exception(
"Timeout has to be greater or equal to 0")
142 """! Set GPUs to be used
143 value is a list of integers or the empty list if you want the code to
144 use all GPUs that are visible to a rank.
150 The standard extensions that I use for both Peano and ExaHyPE.
152 LibraryDebug =
"_debug"
154 LibraryTrace =
"_trace"
155 LibraryAsserts =
"_asserts"
156 LibraryStats =
"_stats"
161 Path (relative or absolute) to the src directory of Peano. This path
162 should hold both the headers (in subdirectories) and all the static
165 mode: peano4.output.CompileMode
175 Add a new filter to Peano/ExaHyPE
177 offset: (float,float,float)
179 size: (float,float,float)
182 A positive value. Peano makes snapshots every dt simulation
183 units. This is something you specify once per simulation. But
184 you might decide only to splot every k of these snapshots.
187 new_entry += str(offset[0])
192 new_entry += str(size[0])
197 new_entry += str(frequency)
208 We export ExaHyPE's constants. Besides the constants from ExaHyPE,
209 we also export some parameters from Peano onto the ExaHyPE constants
210 file. Therefore, it is important that you parse the configure output
211 before we export the constants.
223 self.
_project.constants.add_include(
"""#include <bitset>""")
224 self.
_project.constants.add_include(
"""#include "tarch/la/Vector.h" """)
225 self.
_project.constants.add_include(
"""#include "peano4/utils/Globals.h" """)
226 self.
_project.constants.export_const_with_type(
227 "DomainOffset", offset_string,
"tarch::la::Vector<Dimensions,double>"
229 self.
_project.constants.export_const_with_type(
230 "DomainSize", size_string,
"tarch::la::Vector<Dimensions,double>"
239 "MaxTerminalTime",
"std::numeric_limits<double>::max()"
244 "FirstPlotTimeStamp", f
"{self._restart_timestamp:.{5}g}"
247 "FirstCheckpointTimeStamp", f
"{self._restart_timestamp:.{5}g}"
267 error_message =
"No checkpoint found for all/part of solvers, please check your path and checkpoint files."
268 sys.stderr.write(error_message +
"\n")
277 self.
_project.constants.export_const_with_type(
278 "CheckpointFilesOf"+self.
_solvers[i]._name, file_string,
"std::vector<std::string>"
287 build_string =
"python3 "
291 self.
_project.constants.export_string(
"BuildInformation", build_string)
292 self.
_project.constants.export_string(
293 "ConfigureInformation", self.
_project.output.makefile.configure_call
296 self.
_project.output.readme.add_package_description(
301This code uses ExaHyPE in its second generation. The first generation of the
302code was developed through an EU FET HPC project called ExaHyPE. This first
303generation was built on top of Peano in its third generation. The present
304code uses ExaHyPE 2 which is a complete rewrite built on top of Peano 4. We
305do not yet have a release paper for this second generation of ExaHyPE, and
306thus appreciate any citation of the original release paper
308 @article{Reinarz:2020:ExaHyPE,
309 title = {ExaHyPE: An engine for parallel dynamically adaptive simulations of wave problems},
310 journal = {Computer Physics Communications},
315 doi = {https://doi.org/10.1016/j.cpc.2020.107251},
316 url = {https://www.sciencedirect.com/science/article/pii/S001046552030076X},
317 author = {Anne Reinarz and Dominic E. Charrier and Michael Bader and Luke Bovard and Michael Dumbser and Kenneth Duru and Francesco Fambri and Alice-Agnes Gabriel and Jean-Matthieu Gallard and Sven K\"oppel and Lukas Krenz and Leonhard Rannabauer and Luciano Rezzolla and Philipp Samfass and Maurizio Tavelli and Tobias Weinzierl},
318 keywords = {Hyperbolic, PDE, ADER-DG, Finite volumes, AMR, MPI, TBB, MPI+X},
319 abstract = {ExaHyPE (An Exascale Hyperbolic PDE Engine) is a software engine for solving systems of first-order hyperbolic partial differential equations (PDEs). Hyperbolic PDEs are typically derived from the conservation laws of physics and are useful in a wide range of application areas. Applications powered by ExaHyPE can be run on a student's laptop, but are also able to exploit thousands of processor cores on state-of-the-art supercomputers. The engine is able to dynamically increase the accuracy of the simulation using adaptive mesh refinement where required. Due to the robustness and shock capturing abilities of ExaHyPE's numerical methods, users of the engine can simulate linear and non-linear hyperbolic PDEs with very high accuracy. Users can tailor the engine to their particular PDE by specifying evolved quantities, fluxes, and source terms. A complete simulation code for a new hyperbolic PDE can often be realised within a few hours - a task that, traditionally, can take weeks, months, often years for researchers starting from scratch. In this paper, we showcase ExaHyPE's workflow and capabilities through real-world scenarios from our two main application areas: seismology and astrophysics.
321 Program title: ExaHyPE-Engine Program Files doi: http://dx.doi.org/10.17632/6sz8h6hnpz.1 Licensing provisions: BSD 3-clause Programming languages: C++, Python, Fortran Nature of Problem: The ExaHyPE PDE engine offers robust algorithms to solve linear and non-linear hyperbolic systems of PDEs written in first order form. The systems may contain both conservative and non-conservative terms. Solution method: ExaHyPE employs the discontinuous Galerkin (DG) method combined with explicit one-step ADER (arbitrary high-order derivative) time-stepping. An a-posteriori limiting approach is applied to the ADER-DG solution, whereby spurious solutions are discarded and recomputed with a robust, patch-based finite volume scheme. ExaHyPE uses dynamical adaptive mesh refinement to enhance the accuracy of the solution around shock waves, complex geometries, and interesting features.
328 self.
_project.output.readme.add_entry(
344 first_plot_time_stamp,
345 time_in_between_plots,
346 periodic_BC=[False, False, False],
349 first_checkpoint_time_stamp=0.0,
350 time_in_between_checkpoints=0.0
353 ! Set the global simulation parameters
355 @param dimensions: 2 or 3
357 @param offset: [Float]
358 Has to have dimension number of entries.
361 Has to have dimension number of entries and all of them have to be
362 positive. At this point, we strongly suggest that all size entries
363 are exactly the same. While Peano and ExaHyPE do support anisotropic
364 meshes, most compute kernels do not, so working with something else
365 than a square or cube will likely break all numerics.
367 @param first_plot_time_stamp: Float
368 Is irrelevant if time_in_between_plots equals zero
370 @param time_in_between_plots: Float
371 Set to zero if you don't want to have any plots
373 @param max_end_time: Float
374 If you set it zero (or actually any value smaller than min_end_time), then
375 the code will run until the cell that lags behind the most hits the min time.
376 If you specify a valid max time however, you can stop the sim as soon as the
377 most advanced cell exceeds this threshold.
385 ),
"domain offset vector and dimensions don't match"
388 ),
"domain offset vector and dimensions don't match"
405 for d
in range(0, dimensions):
407 if plotter_precision <= 0:
408 raise Exception(
"Plotter precision has to be bigger than 0")
412 set checkpointing. The function accept the corresponding peano
413 patch file and create corresponding arrays recording the checkpoint
416 @param restart_timestamp float
417 targeting restart timestamp, the function will find the first
418 checkpointed timestamp right after this input time. Thus the final
419 restarting timestamp may not be equal to this specified time.
421 @param checkpoint_file string
422 the location of the checkpoint meta-file
430 checkpoint_meta_file=checkpoint_path+
"checkpoint-"+solver._name+
".peano-patch-file"
431 recording_current_snapshot=
False
432 solver_file_collection=[]
433 with open(checkpoint_meta_file,
'r')
as file:
435 if line.strip().split()==[]:
continue
436 if line.strip().split()[0] ==
"timestamp" and float(line.strip().split()[1])>=self.
_restart_timestamp:
438 recording_current_snapshot=
True
439 if line.strip().split()[0] ==
"include" and recording_current_snapshot==
True:
440 solver_file_collection.append( line.strip().split()[1] )
441 if line.strip().split()[0] ==
"end" and recording_current_snapshot==
True:
443 if recording_current_snapshot:
453 print(
"Couldn't create the defined output path, please ensure that this path exists")
477 I have to call finishedTraversal() for each tracer set. As tracers
478 are a subclass of DoF, they have a name property.
485 (solver._name, solver.get_name_of_global_instance())
488 templatefile_prefix = (
489 os.path.realpath(__file__).replace(
".pyc",
"").replace(
".py",
"")
491 generated_solver_files = (
493 templatefile_prefix +
"SolverRepository.template.h",
494 templatefile_prefix +
"SolverRepository.template.cpp",
496 self.
_project.namespace + [
"repositories"],
497 self.
_project.subdirectory +
"repositories",
503 self.
_project.output.add(generated_solver_files)
504 self.
_project.output.makefile.add_cpp_file(
505 self.
_project.subdirectory +
"repositories/SolverRepository.cpp", generated=
True
513 sort_descend_invocation_order_within_action_sets=-1,
514 plot_descend_invocation_order_within_action_sets=65536,
518 Add a tracer to the project
520 Tracers have to be the very last thing you add to your project.
521 At this point, all solvers have to be added to the project.
522 However, you have to add the tracers prior to any user-defined
523 routines. See docu of init_new_user_defined_algorithmic_step().
525 We rely on the particle toolbox. Therefore, our particles have
526 already a position x, a search radius (which we don't usually
527 use here), and a (parallel) state. The search radius determines
528 how Peano sorts particles within the tree, and we can set it to
529 zero here. This ensures that the particle has no real volume and
530 thus is always sieved through to the finest grid level.
532 @see peano4.toolbox.particles.Particle
535 ## Projection of data onto particles and database dumping
537 The projection onto the particle has to be realised separately, as
538 it depends on the solver variant chosen. The same holds for the
539 dump of particle data into a database if this shall happen
542 Most bigger applications add their solvers an add_tracer() operation,
543 which takes all of this domain knowledge into account. This
544 add_tracer() then forwards to this routine, adding further
547 See the class application.exahype2.ccz.CCZ4Solver and its derived
548 variants for examples.
553 Tracers in ExaHyPE can move, though they do not have to move. Even if
554 they move, they never have a native velocity, i.e. their velocity will
555 always be a projection of an ExaHyPE solution. We are talking about
556 tracers after all and not about a proper PIC approach. Due to this
557 constraint, we do not need a velocity vector. However, we need an
558 additional enumeration which clarifies if a
559 particle has moved already or not. This enumeration is needed by the
560 particle update routines. Obviously, nothing stops you from adding
561 a separate velocity field to the tracer object and thus to redefine
565 ## ExaHyPE-specific particle attributes
568 particle a number which is a tuple consisting of the tree number
569 (on which tree has a particle been generated plus what was the
570 tree-local number of this particle at the time). Through this
571 tuple, we can track tracers later on even if they move across
574 We can plot the data - if there is data to be tracked - directly,
575 as it is a large double array. For the index, we have to type cast
576 the data, as this is a tuple of integers, and Peano's VTK plotter
577 supports only double vectors.
579 @see peano4.toolbox.particles.PlotParticlesInVTKFormat.add_attribute_to_plot()
584 We add the particle ordering with descend order -1. This should do the job
585 for most setups, but we might be wrong. The following action sets are
588 - UpdateParallelState is added to each and every time step and plotting
589 sweep. As we also add
590 - peano4.toolbox.particles.api.UpdateParticleGridAssociation_LiftDrop to each and every time step,
591 particles can move at any point. We always resort them immediately.
593 Both action sets are assigned the standard priority of sort_descend_invocation_order_within_action_sets.
599 Has to be a unique name for this tracer
601 attribute_count: integer
602 Number of attributes that we track per particle (scalar values added
603 pre particle). Can be 0 if you don't want any attributes.
606 See tracer.InsertParticles
609 If this flag is set, ExaHyPE dumps the particles as vtu files whenever
610 it writes patch files. You can switch this behaviour off. A lot of codes
611 do so if they dump the tracer data independently into another database
614 sort_descend_invocation_order_within_action_sets: Integer
615 You have to clarify what the priority of the tracer is within the
616 action sets. By default, all ExaHyPE solvers start with priority
617 0 and then up to n. So you are fine with using the default of -1
618 which means that the tracer precedes any solver. However, there
619 might be cases where you wanna move the priorities manually.
621 Returns the particle set that you can use to modify further
625 if attribute_count > 0:
627 "data", str(attribute_count)
629 particle.data.add_attribute(particle_attr)
631 particle.data.add_attribute(
636 particle.data.add_attribute(particle_number)
640 self.
_project.datamodel.add_global_object(particle)
641 self.
_project.datamodel.add_vertex(particles)
658 update_particle_association_action_set = (
661 update_particle_association_action_set.descend_invocation_order = sort_descend_invocation_order_within_action_sets
662 update_particle_association_action_set.parallel =
True
664 update_particle_parallel_state_action_set = (
667 update_particle_parallel_state_action_set.descend_invocation_order = (
668 sort_descend_invocation_order_within_action_sets
670 update_particle_parallel_state_action_set.parallel =
True
688 particle_set=particles,
689 time_stamp_evaluation=
"repositories::getMinTimeStamp()",
690 additional_includes=
"""
691#include "repositories/SolverRepository.h"
694 if attribute_count > 0:
695 particle_plotter.add_attribute_to_plot(particle_attr, attribute_count)
696 particle_plotter.add_attribute_to_plot(
697 particle_number, 2,
"tarch::la::convertScalar<double>(p->getNumber())"
699 particle_plotter.descend_invocation_order = plot_descend_invocation_order_within_action_sets
703 self.
plot_solution.add_action_set(update_particle_association_action_set)
704 self.
plot_solution.add_action_set(update_particle_parallel_state_action_set)
717 Add a new action set to the time stepping
719 You have to be careful with the priorities, i.e. you might want to
720 use myproject.perform_time_step.max_priority() or myproject.perform_time_step.min_priority()
722 priority you should assign to action_set.
730 Add a new action set to the plotting
738 Add a new action set to the checkpointing
744 self.
init_grid.add_action_set(action_set)
749 Add an action set to create grid
751 This routine actually adds an action set to each and every grid
752 creation routine. After all, we distinguish three flavours of it
755 - without refinement as we've just refined or split up domain;
756 - without refinement to let load balancing converge.
766 Construct a Peano 4 project and return it
768 Build the Peano 4 project, i.e., all the action sets et al that you require
769 to run this ExaHyPE 2 application. The project is built within self._project
770 and eventually returned.
772 This routine generates a Peano project, i.e. the domain-specific ExaHyPE
773 view is translated into a Peano model. Once you have called this routine,
774 any changes to the ExaHyPE 2 configuration do not propagate into the Peano
775 setup anymore. If you alter the ExaHyPE setup, you have to call
776 generate_Peano4_project() again to get a new snapshot/version of the
790 print(
"---------------------------------------")
791 print(
"Create data for solver " + solver._name)
792 print(
"---------------------------------------")
795 solver.add_to_Peano4_datamodel(self.
_project.datamodel, verbose)
797 solver.add_use_data_statements_to_Peano4_solver_step(self.
create_grid)
798 solver.add_use_data_statements_to_Peano4_solver_step(self.
plot_solution)
801 solver.add_use_data_statements_to_Peano4_solver_step(self.
init_grid)
802 solver.add_use_data_statements_to_Peano4_solver_step(
805 solver.add_use_data_statements_to_Peano4_solver_step(
809 solver.add_actions_to_create_grid(
810 self.
create_grid, evaluate_refinement_criterion=
True
818 solver.add_actions_to_init_grid(self.
init_grid)
823 solver.add_actions_to_create_grid(
825 evaluate_refinement_criterion=
False,
827 solver.add_actions_to_create_grid(
834 solver.add_implementation_files_to_project(
845 self.
_project.output.makefile.parse_configure_script_outcome(
858 """! Inform ExaHyPE 2 that there is an additional solver step not resulting from vanilla solver versions
860 Use this routine whenever you have created your own
861 @ref page_architecture "algorithmic step". Please note that the routine
862 should be called after you have created all of your solvers. Otherwise,
863 we'll miss out a few of your solvers and the data access patterns
864 will/might be corrupted. Also all tracers have to be added at this
867 The routine has no side-effects, i.e. does not alter the underlying
868 project. It only manipulates the step. Therefore, you can even call it
869 after you have distilled the Peano project from the ExaHyPE project,
870 i.e. after you have called exahype2.Project.generate_Peano4_project().
871 In return, you however still have to add the new step manually to the
872 Peano project. That is, this routine merely initialises the new step,
873 but it does not yet add it to the sweeps known by Peano.
875 @param step: peano4.solversteps.Step
879 solver.add_use_data_statements_to_Peano4_solver_step(step)
882 step.use_vertex(tracer_set)
Wrapper around C++ enumerations which is not a datatype supported natively by MPI.
_time_in_between_checkpoints
set_restart_from_checkpoint(self, expected_restart_timestamp=0, checkpoint_path="./")
set checkpointing.
__generate_solver_repository(self)
I have to call finishedTraversal() for each tracer set.
init_new_user_defined_algorithmic_step(self, step)
Inform ExaHyPE 2 that there is an additional solver step not resulting from vanilla solver versions.
_first_checkpoint_time_stamp
add_action_set_to_timestepping(self, action_set)
Add a new action set to the time stepping.
set_load_balancing(self, load_balancer_name, load_balancer_arguments="")
load_balancer_name: string Should be full-qualified name of the load balancer.
set_number_of_threads(self, value)
Set number of threads to use Pass in number of threads (positive integer) or a string such as "tarch:...
set_Peano4_installation(self, src_path, mode=peano4.output.CompileMode.Release)
src_path: string Path (relative or absolute) to the src directory of Peano.
solverRepositoryDictionary
set_output_path(self, path)
add_plot_filter(self, offset, size, frequency=1)
Add a new filter to Peano/ExaHyPE.
__configure_makefile(self)
generate_Peano4_project(self, verbose=False)
Construct a Peano 4 project and return it.
add_tracer(self, name, attribute_count=0, plot=True, sort_descend_invocation_order_within_action_sets=-1, plot_descend_invocation_order_within_action_sets=65536)
Add a tracer to the project.
__init__(self, namespace, project_name, executable, directory=".", subdirectory="", abstract_overwrite=True)
set_timeout(self, value)
Set timeout value has to be a number greater or equal to zero, this then sets the timeout in seconds ...
add_action_set_to_plot_solution(self, action_set)
Add a new action set to the plotting.
additional_includes(self)
__set_solver_repository_dict(self)
set_multicore_orchestration(self, value)
Set orchestration value has to be a string which creates an orchestration object, i....
add_action_set_to_create_grid(self, action_set)
Add an action set to create grid.
add_mainfile_include(self, value)
set_global_simulation_parameters(self, dimensions, offset, size, min_end_time, first_plot_time_stamp, time_in_between_plots, periodic_BC=[False, False, False], plotter_precision=5, max_end_time=0.0, first_checkpoint_time_stamp=0.0, time_in_between_checkpoints=0.0)
! Set the global simulation parameters
set_log_filter_file(self, file_name)
Set a log filter file name Pass in the empty string, if you want the code to use the hard-coded defau...
create_grid_and_converge_lb
__export_constants(self)
We export ExaHyPE's constants.
set_gpus(self, value)
Set GPUs to be used value is a list of integers or the empty list if you want the code to use all GPU...
add_action_set_to_checkpoint_solution(self, action_set)
Add a new action set to the checkpointing.
create_grid_but_postpone_refinement
add_action_set_to_initialisation(self, action_set)
Represents a Peano 4 project.
Specialisation of dastgen2.attributes.DoubleArray which relies on Peano's tarch.
Represents a particle set.
For constructor's time_stamp_evaluation argument.
Update the parallel state of particles and keep stats of them.
Associate particles to spacetree vertices.