12from .PETScMain
import PETScMain
20Multigrid solver project
22A project hosts a set of multigrid solvers for different PDEs (which you might
23eventually want to couple). Other than that, each project generates exactly
24one main file and a solver repository. The main file is represented by
25petsc.PETScMain, while the repository is generated directly by the project.
26Consult generate_Peano4_project() for the latter.
31Every PETSc project runs through the following steps:
33 - algorithm_step_create_grid
34 - algorithm_step_enumerate_and_init_solution
35 - _algorithm_step_init_petsc
36 - algorithm_step_assemble
37 - _algorithm_step_solve
38 - algorithm_step_map_solution_onto_mesh
41Each of these steps is mapped onto one observer. It is clear that not all
42steps actually lead to mesh traversals and, therefore, are not to be modified
43by users. They are simply there to allow the main function to pick a step and
44to tell all MPI ranks to run the same step on all local trees. I therefore
45mark these steps as private via a leading underscore.
50 \param _solvers: [Solver]
51 List of tuples of typename and names of solvers that this project should use simultaneously.
52 \param preconditioner_type: String
53 Preconditioner type to be used. This part of the string should match the final
54 part of the enum class in src/petsc/LinearEquationSystem.h. The namespaceing is
55 taken care of downstream.
56 \param solver_type: String
57 Solver type to be used. This part of the string should match the final
58 part of the enum class in src/petsc/LinearEquationSystem.h. The namespaceing is
59 taken care of downstream.
66 executable = "peano4petsc",
67 preconditioner_type = "None",
68 solver_type = "GMRES",
72 self.
_project.output.makefile.add_cmake_core_library(
"petsc")
81 self.
_build_mode = peano4.output.CompileMode.Asserts
101 load_balancer_name: string
102 Should be full-qualified name of the load balancer.
103 By default, I recommend to pass "toolbox::loadbalancing::RecursiveSubdivision"
105 load_balancer_arguments: string
106 If your load balancing requires parameters, add them
107 here. It is a string that will be copied into the C++ class instantiation.
108 Please add the brackets yourself, i.e. "(3,4,5)" is fine, but "3,4,5" is not.
109 The only exception is the empty parameter list. Here, you can/should simply
110 add the empty string.
118 The standard extensions that I use for both Peano and ExaHyPE.
120 LibraryDebug =
"_debug"
122 LibraryTrace =
"_trace"
123 LibraryAsserts =
"_asserts"
124 LibraryStats =
"_stats"
131 Path (relative or absolute) to the src directory of Peano. This path
132 should hold both the headers (in subdirectories) and all the static
135mode: peano4.output.CompileMode
145Configure the makefile of the PETSc project
147We parse the configure script's/CMAKE outcome first via parse_configure_script_outcome().
148After that, we set the dimension manually as well as the executable name and
149the build mode. The values for these parameters step from set_Peano4_installation().
164 plotter_precision = 5,
168 offset and size should be lists with dimensions double entries.
175 if plotter_precision<=0:
176 raise Exception(
"Plotter precision has to be bigger than 0" )
190Construct and return the Peano4 project, i.e. all the action sets et al that
191you require to run this Peano4 application with PETSc.
193This routine generates a Peano project, i.e. the domain-specific
194view is translated into a Peano model. Once you have called this routine,
195any changes to the PETSc project configuration do not propagate into the Peano
196setup anymore. If you alter the project setup, you have to call
197generate_Peano4_project() again to get a new snapshot/version of the
200The function runs through various steps:
2021. We create an instance of PETScMain that represents the C++ main file.
2042. We add the essential algorithmic steps to the result project. At this
205 point, they should all be configured properly
2073. We configure the makefile via __configure_makefile().
2094. Add the repository holding the instances of the solver.
2115. Ensure that the generated readme file holds all relevant literature and
231 self.
_project.output.readme.add_package_description(
"""
233### Peano4 PETSc backend
235This yet has to be written.
244 self.
dictionary[
"SOLVER_INSTANCES"] = [(x.typename(), x.instance_name())
for x
in self.
_solvers ]
246 self.
dictionary[
"SOLVER_TYPE" ] =
"::petsc::LinearEquationSystem::KSPSolverType::" + self.
solver_type
252 type_name_of_solvers: [String]
253 Name of the solvers that we should instantiate and use in the main.
259 templatefile_prefix = os.path.realpath(__file__).replace(
".pyc",
"" ).replace(
".py",
"" )
260 template_name = templatefile_prefix +
".SolverRepository.template"
262 template_name +
".h",
263 template_name +
".cpp",
266 self.
_project.subdirectory +
"repositories",
271 self.
_project.output.add( generated_repository_files )
272 self.
_project.output.makefile.add_h_file( self.
_project.subdirectory +
"repositories/SolverRepository.h", generated=
True )
273 self.
_project.output.makefile.add_cpp_file( self.
_project.subdirectory +
"repositories/SolverRepository.cpp", generated=
True )
279 Takes the solver and runs through the individual steps of the algorithm.
280 Per step, it tells the solver to inject its particular stuff to the
281 underlying observers.
284 print(
"---------------------------------------")
285 print(
"Create data for solver " +solver._name )
286 print(
"---------------------------------------")
289 solver.add_to_Peano4_datamodel( self.
_project.datamodel, verbose=
False )
314 We export ExaHyPE's constants. Besides the constants from ExaHyPE,
315 I also export some parameters from Peano onto the ExaHyPE constants
316 file. Therefore, it is important that you parse the configure output
317 before we export the constants.
329 self.
_project.constants.add_include(
"""#include <bitset>""")
330 self.
_project.constants.add_include(
"""#include "tarch/la/Vector.h" """)
331 self.
_project.constants.add_include(
"""#include "peano4/utils/Globals.h" """)
332 self.
_project.constants.export_const_with_type(
333 "DomainOffset", offset_string,
"tarch::la::Vector<Dimensions,double>"
335 self.
_project.constants.export_const_with_type(
336 "DomainSize", size_string,
"tarch::la::Vector<Dimensions,double>"
340 build_string =
"python3 "
344 self.
_project.constants.export_string(
"BuildInformation", build_string)
345 self.
_project.constants.export_string(
346 "ConfigureInformation", self.
_project.output.makefile.configure_call
349 self.
_project.output.readme.add_package_description(
352### Peano's multigrid extension
354This is yet to be written, and we need to have a paper on our work.
356 @article{Reinarz:2020:ExaHyPE,
357 title = {ExaHyPE: An engine for parallel dynamically adaptive simulations of wave problems},
358 journal = {Computer Physics Communications},
363 doi = {https://doi.org/10.1016/j.cpc.2020.107251},
364 url = {https://www.sciencedirect.com/science/article/pii/S001046552030076X},
365 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},
366 keywords = {Hyperbolic, PDE, ADER-DG, Finite volumes, AMR, MPI, TBB, MPI+X},
367 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.
369 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.
376 self.
_project.output.readme.add_entry(
377 i.create_readme_descriptor()
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.
_algorithm_step_init_petsc
algorithm_step_create_grid
__generate_solver_repository(self)
algorithm_step_map_solution_onto_mesh
__export_constants(self)
Export all the constrants of the project into a Configure.h file.
__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_load_balancing(self, load_balancer_name, load_balancer_arguments)
Set the load balancing scheme.
__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.
algorithm_step_enumerate_and_init_solution
Represents a Peano 4 project.