6from .MatrixFreeMain
import MatrixFreeMain
13 Here we recreate a multigrid project, without using PETSc.
15 We keep some of the basic steps:
16 - _algorithm_step_create_grid
17 - _algorithm_step_enumerate_and_init_solution
18 - _algorithm_step_solve
19 - _algorithm_step_plot
21 The rest is yet to be fleshed out.
23 Now that we have multiple solvers in a project, we may not
24 want to use all of them for stopping criteria. Hence, we
25 have a second array for solvers which participate, but are
26 not asked if their stopping criteria have been reached.
28 @todo I think all projects should share certain commonalities
29 @todo I want to have some feature to set the MPI timeout
34 The standard extensions that are used for Peano and ExaHyPE.
36 LibraryDebug =
"_debug"
38 LibraryTrace =
"_trace"
39 LibraryAsserts =
"_asserts"
40 LibraryStats =
"_stats"
46 executable = "peano4matrixfree",
48 abstract_overwrite=True,
52 Create a matrix project
88 domain_size = [1.0, 1.0],
89 plot_after_each_mesh_sweep =
False,
97 Set the load balancing scheme
99 @param load_balancer_name: string
100 Should be full-qualified name of the load balancer.
101 By default, I recommend to pass "toolbox::loadbalancing::RecursiveSubdivision"
103 @param load_balancer_arguments: string
104 If your load balancing requires parameters, add them
105 here. It is a string that will be copied into the C++ class instantiation.
106 Please add the brackets yourself, i.e. "(3,4,5)" is fine, but "3,4,5" is not.
107 The only exception is the empty parameter list. Here, you can/should simply
108 add the empty string.
117 Tell the project where to find Peano
119 Once we know where to find Peano, we can parse the configuration/makefile
120 there and know which compile parameters to use. We also know then where to
121 search for the static libraries.
123 @param src_path: string
124 Path (relative or absolute) to the src directory of Peano. This path
125 should hold both the headers (in subdirectories) and all the static
128 @param mode: peano4.output.CompileMode
138 Parse makefile of Peano to extract the configuration settings
140 We parse the configure script's/CMAKE outcome first via parse_configure_script_outcome().
141 After that, we set the dimension manually as well as the executable name and
142 the build mode. The values for these parameters step from set_Peano4_installation().
156 plot_after_each_mesh_sweep,
158 plotter_precision = 5,
162 Configure global simulation settings
164 @param offset: [Float]
167 should be lists with dimensions double entries.
176 if plotter_precision<=0:
177 raise Exception(
"Plotter precision has to be bigger than 0" )
190 Construct and return the Peano4 project, i.e. all the action sets et al that
191 you require to run this Peano4 application with PETSc.
209 self.
_project.output.readme.add_package_description(
"""
219 "SOLVER_INSTANCES": [(x.typename(), x.instance_name())
for x
in self.
_solvers ],
220 "AUX_SOLVER_INSTANCES": [(x.typename(), x.instance_name())
for x
in self.
_aux_solvers ],
230 templatefile_prefix = os.path.realpath(__file__).replace(
".pyc",
"" ).replace(
".py",
"" )
231 template_name = templatefile_prefix +
".SolverRepository.template"
233 template_name +
".h",
234 template_name +
".cpp",
237 self.
_project.subdirectory +
"repositories",
242 self.
_project.output.add( generated_repository_files )
243 self.
_project.output.makefile.add_h_file( self.
_project.subdirectory +
"repositories/SolverRepository.h", generated=
True )
244 self.
_project.output.makefile.add_cpp_file( self.
_project.subdirectory +
"repositories/SolverRepository.cpp", generated=
True )
251 Takes the solver and runs through the individual steps of the algorithm.
252 Per step, it tells the solver to inject its particular stuff to the
253 underlying observers.
255 The auxiliary flag allows us to distinguish the "main" solver from the
256 helpers. The rationale for this is that we only want to measure the
257 termination conditions for a subset of the solvers.
260 print(
"---------------------------------------")
261 print(
"Create data for solver " +solver._name )
262 print(
"---------------------------------------")
265 solver.add_to_Peano4_datamodel( self.
_project.datamodel, verbose=
False )
285 This is for two-grid setup - we mark the correction solver as "auxiliary", so that we
286 don't exit early before the main solver has reached tolerance.
298 Export all the constrants of the project into a Configure.h file
300 We export ExaHyPE's constants. Besides the constants from ExaHyPE,
301 I also export some parameters from Peano onto the ExaHyPE constants
302 file. Therefore, it is important that you parse the configure output
303 before we export the constants.
316 self.
_project.constants.add_include(
"""#include <bitset>""")
317 self.
_project.constants.add_include(
"""#include "tarch/la/Vector.h" """)
318 self.
_project.constants.add_include(
"""#include "peano4/utils/Globals.h" """)
319 self.
_project.constants.export_const_with_type(
320 "DomainOffset", offset_string,
"tarch::la::Vector<Dimensions,double>"
322 self.
_project.constants.export_const_with_type(
323 "DomainSize", size_string,
"tarch::la::Vector<Dimensions,double>"
327 build_string =
"python3 "
331 self.
_project.constants.export_string(
"BuildInformation", build_string)
332 self.
_project.constants.export_string(
333 "ConfigureInformation", self.
_project.output.makefile.configure_call
336 self.
_project.output.readme.add_package_description(
339### Peano's multigrid extension
341This is yet to be written, and we need to have a paper on our work.
343 @article{Reinarz:2020:ExaHyPE,
344 title = {ExaHyPE: An engine for parallel dynamically adaptive simulations of wave problems},
345 journal = {Computer Physics Communications},
350 doi = {https://doi.org/10.1016/j.cpc.2020.107251},
351 url = {https://www.sciencedirect.com/science/article/pii/S001046552030076X},
352 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},
353 keywords = {Hyperbolic, PDE, ADER-DG, Finite volumes, AMR, MPI, TBB, MPI+X},
354 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.
356 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.
363 self.
_project.output.readme.add_entry(
364 i.create_readme_descriptor()
378 """! Set orchestration
380 value has to be a string which creates an orchestration object,
381 i.e., an object of the type tarch::multicore::orchestration::Orchestration.
382 You can either create it directly (in this case you need to add a new),
383 or you can use a factory method such as
384 "tarch::multicore::orchestration::StrategyFactory::createDefaultStrategy()".
386 A typical usage looks similar to
388 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
389project.set_multicore_orchestration( "new ::tarch::multicore::orchestration::Hardcoded(8,256,tarch::multicore::Task::Host,::tarch::multicore::orchestration::Hardcoded::NoNestedParallelism,::tarch::multicore::orchestration::FusionImplementation::LazyEvaluation)" )
390 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
392 self._multicore_orchestration = value
Here we recreate a multigrid project, without using PETSc.
set_global_simulation_parameters(self, dimensions, offset, domain_size, plot_after_each_mesh_sweep, max_iterations=100, plotter_precision=5)
Configure global simulation settings.
set_Peano4_installation(self, src_path, mode=peano4.output.CompileMode.Release)
Tell the project where to find Peano.
set_global_simulation_parameters(self, dimensions, offset, domain_size, plotter_precision=5)
offset and size should be lists with dimensions double entries.
algorithm_step_create_grid
__generate_solver_repository(self)
__export_constants(self)
Export all the constrants of the project into a Configure.h file.
set_mpi_timeout(self, value)
__set_solver_repository_dict(self)
set_output_path(self, path)
generate_Peano4_project(self, verbose=False)
Build project.
__configure_makefile(self)
Parse makefile of Peano to extract the configuration settings.
set_multicore_orchestration(self, value)
Set orchestration.
set_load_balancing(self, load_balancer_name, load_balancer_arguments)
Set the load balancing scheme.
algorithm_step_init_solution
__init__(self, namespace, project_name, directory=".", executable="peano4matrixfree", subdirectory="", abstract_overwrite=True)
Create a matrix project.
add_solver(self, solver, auxiliary=False)
Add a new solver.
_plot_after_each_mesh_sweep
Represents a Peano 4 project.