12from .PETScMain
import PETScMain
18 Multigrid solver project
20 A project hosts a set of multigrid solvers for different PDEs (which you might
21 eventually want to couple). Other than that, each project generates exactly
22 one main file and a solver repository. The main file is represented by
23 petsc.PETScMain, while the repository is generated directly by the project.
24 Consult generate_Peano4_project() for the latter.
29 Every PETSc project runs through the following steps:
31 - algorithm_step_create_grid
32 - algorithm_step_enumerate_and_init_solution
33 - _algorithm_step_init_petsc
34 - algorithm_step_assemble
35 - _algorithm_step_solve
36 - algorithm_step_map_solution_onto_mesh
39 Each of these steps is mapped onto one observer. It is clear that not all
40 steps actually lead to mesh traversals and, therefore, are not to be modified
41 by users. They are simply there to allow the main function to pick a step and
42 to tell all MPI ranks to run the same step on all local trees. I therefore
43 mark these steps as private via a leading underscore.
48 \param _solvers: [Solver]
49 List of tuples of typename and names of solvers that this project should use simultaneously.
50 \param preconditioner_type: String
51 Preconditioner type to be used. This part of the string should match the final
52 part of the enum class in src/petsc/LinearEquationSystem.h. The namespaceing is
53 taken care of downstream.
54 \param solver_type: String
55 Solver type to be used. This part of the string should match the final
56 part of the enum class in src/petsc/LinearEquationSystem.h. The namespaceing is
57 taken care of downstream.
66 executable="peano4petsc",
67 preconditioner_type="None",
72 namespace, project_name, directory, subdirectory
74 self.
_project.output.makefile.add_cmake_core_library(
"petsc")
83 self.
_build_mode = peano4.api.output.CompileMode.ASSERTS
93 "EnumerateAndInitSolution",
False
101 "MapSolutionOntoMesh",
False
111 load_balancer_name: string
112 Should be full-qualified name of the load balancer.
113 By default, I recommend to pass "toolbox::loadbalancing::RecursiveSubdivision"
115 load_balancer_arguments: string
116 If your load balancing requires parameters, add them
117 here. It is a string that will be copied into the C++ class instantiation.
118 Please add the brackets yourself, i.e. "(3,4,5)" is fine, but "3,4,5" is not.
119 The only exception is the empty parameter list. Here, you can/should simply
120 add the empty string.
127 The standard extensions that I use for both Peano and ExaHyPE.
129 LibraryDebug =
"_debug"
131 LibraryTrace =
"_trace"
132 LibraryAsserts =
"_asserts"
133 LibraryStats =
"_stats"
136 self, src_path, mode=peano4.api.output.CompileMode.RELEASE
141 Path (relative or absolute) to the src directory of Peano. This path
142 should hold both the headers (in subdirectories) and all the static
145 mode: peano4.api.output.CompileMode
154 Configure the makefile of the PETSc project
156 We parse the configure script's/CMAKE outcome first via parse_configure_script_outcome().
157 After that, we set the dimension manually as well as the executable name and
158 the build mode. The values for these parameters step from set_Peano4_installation().
161 self.
_project.output.makefile.parse_configure_script_outcome(
179 offset and size should be lists with dimensions double entries.
186 if plotter_precision <= 0:
187 raise Exception(
"Plotter precision has to be bigger than 0")
199 Construct and return the Peano4 project, i.e. all the action sets et al that
200 you require to run this Peano4 application with PETSc.
202 This routine generates a Peano project, i.e. the domain-specific
203 view is translated into a Peano model. Once you have called this routine,
204 any changes to the PETSc project configuration do not propagate into the Peano
205 setup anymore. If you alter the project setup, you have to call
206 generate_Peano4_project() again to get a new snapshot/version of the
209 The function runs through various steps:
211 1. We create an instance of PETScMain that represents the C++ main file.
213 2. We add the essential algorithmic steps to the result project. At this
214 point, they should all be configured properly
216 3. We configure the makefile via __configure_makefile().
218 4. Add the repository holding the instances of the solver.
220 5. Ensure that the generated readme file holds all relevant literature and
243 self.
_project.output.readme.add_package_description(
246### Peano4 PETSc backend
248This yet has to be written.
258 (x.typename(), x.instance_name())
for x
in self.
_solvers
261 "::petsc::LinearEquationSystem::PreconditionerType::"
265 "::petsc::LinearEquationSystem::KSPSolverType::" + self.
solver_type
271 type_name_of_solvers: [String]
272 Name of the solvers that we should instantiate and use in the main.
278 templatefile_prefix = (
279 os.path.realpath(__file__).replace(
".pyc",
"").replace(
".py",
"")
281 template_name = templatefile_prefix +
".SolverRepository.template"
282 generated_repository_files = (
284 template_name +
".h",
285 template_name +
".cpp",
288 self.
_project.subdirectory +
"repositories",
295 self.
_project.output.add(generated_repository_files)
296 self.
_project.output.makefile.add_h_file(
297 self.
_project.subdirectory +
"repositories/SolverRepository.h",
300 self.
_project.output.makefile.add_cpp_file(
301 self.
_project.subdirectory +
"repositories/SolverRepository.cpp",
308 Takes the solver and runs through the individual steps of the algorithm.
309 Per step, it tells the solver to inject its particular stuff to the
310 underlying observers.
313 print(
"---------------------------------------")
314 print(
"Create data for solver " + solver._name)
315 print(
"---------------------------------------")
318 solver.add_to_Peano4_datamodel(self.
_project.datamodel, verbose=
False)
328 solver.add_to_enumerate_and_init_solution(
336 solver.add_implementation_files_to_project(
346 We export ExaHyPE's constants. Besides the constants from ExaHyPE,
347 I also export some parameters from Peano onto the ExaHyPE constants
348 file. Therefore, it is important that you parse the configure output
349 before we export the constants.
361 self.
_project.constants.add_include(
"""#include <bitset>""")
362 self.
_project.constants.add_include(
"""#include "tarch/la/Vector.h" """)
363 self.
_project.constants.add_include(
"""#include "peano4/utils/Globals.h" """)
364 self.
_project.constants.export_const_with_type(
365 "DomainOffset", offset_string,
"tarch::la::Vector<Dimensions,double>"
367 self.
_project.constants.export_const_with_type(
368 "DomainSize", size_string,
"tarch::la::Vector<Dimensions,double>"
372 build_string =
"python3 "
376 self.
_project.constants.export_string(
"BuildInformation", build_string)
377 self.
_project.constants.export_string(
378 "ConfigureInformation", self.
_project.output.makefile.configure_call
381 self.
_project.output.readme.add_package_description(
384### Peano's multigrid extension
386This is yet to be written, and we need to have a paper on our work.
388 @article{Reinarz:2020:ExaHyPE,
389 title = {ExaHyPE: An engine for parallel dynamically adaptive simulations of wave problems},
390 journal = {Computer Physics Communications},
395 doi = {https://doi.org/10.1016/j.cpc.2020.107251},
396 url = {https://www.sciencedirect.com/science/article/pii/S001046552030076X},
397 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},
398 keywords = {Hyperbolic, PDE, ADER-DG, Finite volumes, AMR, MPI, TBB, MPI+X},
399 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.
401 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.
408 self.
_project.output.readme.add_entry(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.
_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_Peano4_installation(self, src_path, mode=peano4.api.output.CompileMode.RELEASE)
Tell the project where to find Peano.
__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.