7from numpy.polynomial.legendre
import leggauss
8from scipy.interpolate
import lagrange
10from abc
import abstractmethod
15Abstract base class for all PETSc solvers
17A PETSc solver in Peano is Python class which represents one solver aka one
18PDE problem. Various of these solvers might have to be combined in one
21It is the project's job to define which mesh traversals (grid
22construction, visualisation, ...) are required, how to run through these,
23how to load balance. Each solver in return will know what unknows we require
24per mesh entity (vertex, face, ...). Most solvers will create a Python
25representation of these unknowns in their constructor. Once the user has
26constructed a solver and added it to the underlying
27project, is it the project's job to ask each solver
29- can you add your data model to the underlying Peano project;
30- can you tell me which data entities all of the mesh traversals have to
32- add your particular action sets to the grid construction, initialisation,
35For further information how the solvers add their solver-specific data to the
36project's generic mesh traversals, consult also generic documentation in peano4.actionsets.ActionSet.
41Most solvers will split the realisation of the solver into different parts.
43First and foremost, it will have to manage data associated with the grid vertices,
44faces, cells. This is the static data model. As I don't want to write classes
45for these unknowns, the solvers typically use DaStGen 2, which simply is a
46code generator to create a class per data model. This part is all handled
47within Python, and you should not see them in the output. If you want to study
48these models however, you can peek into the generated vertexdata or facedata
51For the actual code semantics, most solvers introduce a type which represents
52the solver. This one defines, for example, what the initial value looks
53like. It is actually realised as two classes: An abstract base class and its
54implementation. The abstract base class contains all the variables that can
55be modified via Python. The realisation itself is then the actual C++ code
56which users might want to modify after the Python call has succeeded and set
57everything up. That is: the Python PETSc API will give you both an abstract
58solver class and its subclass in the working directory. The abstract base
59class will be overwritten every time you run the Python script. The subclass
60is only a template that you should befill with your problem-specific knowledge.
61It will not be overwritten by any subsequent Python calls.
63The actual solver class that you have to implement yourself is instantiated
64within a file called repositories/SolverRepository. This one is generated, too,
65but you can peek into it. It instantiates each solver exactly one and this is
66the object instance against which the actual solver algorithm operates from
69The glue between Peano and the solver is the action sets, i.e. the classes that encode how the grid
70traversal and observations made throughout the traversal are mapped onto
71either Peano's routines, routines from the toolbox, or functions from the
72solver objects. These action sets define what happens if the code reads a
73vertex for the first time of a mesh traversal, e.g.
76## Links to high level concepts
78- For the types of mesh entities, please consult @ref documentation_multigrid_boundary_conditions.
92 Every solver has a unique name.
117 Add whatever action set you want to use to observer.
120 assert False,
"should not be called"
127 Add whatever action set you want to use to observer.
130 assert False,
"should not be called"
136 Add whatever action set you want to use to observer.
139 assert False,
"should not be called"
145 Add whatever action set you want to use here. I am not sure if there is a
146 real grid traversal tied to this step. So maybe nothing is called. Has to
147 be checked. Anyway, most solvers leave this one blank.
150 assert False,
"should not be called"
157 Add whatever action set you want to use to observer.
160 assert False,
"should not be called"
167 Add whatever action set you want to use to observer.
170 assert False,
"should not be called"
177 Add whatever action set you want to use to observer.
180 assert False,
"should not be called"
185 Initialise index model
187 We build up a data model, which is really an index model in this case.
188 Every vertex, face and cell can hold a data model which is only one integer.
189 This integer encodes the first index of a matrix unknown held by the
190 grid entity. For the plain DG code, there are no vertex unknowns. However,
191 we have two types of face indices: Those for the projection and those for
192 the solution of the Riemann problem.
194 You might want to overwrite this routine, but please ensure that you still
195 call this superclass implementation, too.
206 Register the index numbers to be used in each and every mesh traversal. You
207 can overwrite the routine and add your own stuff. However, please ensure
208 this routine still is invoked, too.
221This routine is typically not invoked by a user.
223output: peano4.output.Output
224 Add artefacts this output in any implementation.
227 assert False,
"should not be called"
237Return the name of the object that will be created for this solver.
240 return "instanceOf" + self.
typename()
244 raise NotImplementedError
248 raise NotImplementedError
252 raise NotImplementedError
258 Should really be abstract and properly be initialised
260 @todo Has to be implemented properly, i.e. should at least report on the
261 type and the name of the solver
264 return "Yet to be written"
Abstract base class for all PETSc solvers.
add_use_statements(self, observer)
Register the index numbers to be used in each and every mesh traversal.
number_of_matrix_entries_per_cell(self)
add_to_plot(self, observer)
Add whatever action set you want to use to observer.
instance_name(self)
Return the name of the object that will be created for this solver.
__init__(self, name, min_h, max_h)
name: String Every solver has a unique name.
add_to_init_petsc(self, observer)
Add whatever action set you want to use here.
add_to_enumerate_and_init_solution(self, observer)
Add whatever action set you want to use to observer.
number_of_matrix_entries_per_face(self)
add_to_assemble(self, observer)
Add whatever action set you want to use to observer.
create_readme_descriptor(self)
Should really be abstract and properly be initialised.
add_to_Peano4_datamodel(self, datamodel, verbose)
Initialise index model.
add_implementation_files_to_project(self, namespace, output)
This routine is typically not invoked by a user.
add_to_create_grid(self, observer)
Add whatever action set you want to use to observer.
add_to_map_solution_onto_mesh(self, observer)
Add whatever action set you want to use to observer.
number_of_matrix_entries_per_vertex(self)
Wrapper around C++ enumerations which is not a datatype supported natively by MPI.
Default superclass for any data model in Peano which is stored within the grid.