The previous chapters have focused on the core numerical solvers in PETSc. However, numerical solvers without efficient ways
(in both human and machine time) of connecting the solvers to the mathematical models and discretizations that people wish to build their simulations on,
will not get widely used. Thus PETSc provides a set of abstractions represented by the
DM object to provide a powerful, comprehensive
mechanism for translating the problem specification of a model and its discretization to the language and API of solvers.
Some of the model
DM currently supports are PDEs on structured and staggered grids with finite difference methods (
DMSTAG – DMSTAG: Staggered, Structured Grid),
PDEs on unstructured
grids with finite element and finite volume methods (
DMPLEX – DMPlex: Unstructured Grids), PDEs on quad and octree-grids (
DMFOREST), models on
networks (graphs) such
as the power grid or river networks (
DMNETWORK – Networks), and particle-in-cell simulations (
It is possible to create a
but more commonly, a
DM is created with a type-specific constructor; the construction process for each type of
DM is discussed
in the sections on each
DMType. This chapter focuses
on commonalities between all the
DM so we assume the
DM already exists and we wish to work with it.
As discussed earlier, a
DM can construct vectors and matrices appropriate for a model and discretization and provide the mapping between the
global and local vector representations.
The matrices produced may support
MatSetValuesLocal() allowing one to work with the local numbering on each MPI rank. For
DMDA one can also
MatSetValuesStencil() and for
DM can be refined for certain
DMRefine() or coarsened with
DMs may be obtained with routines such as
One attaches a
DM to a solver object with
DM is attached, the solver can utilize it to create and process much of the data that the solver needs to set up and implement its solve.
For example, with
PCMG simply providing a
DM can allow it to create all the data structures needed to run geometric multigrid on your problem.