xref: /petsc/include/petscdm.h (revision 01bc414f5c6c7f1a7f24d8d77db9ee6ab967525e)
1e1589f56SBarry Smith /*
2e1589f56SBarry Smith       Objects to manage the interactions between the mesh data structures and the algebraic objects
3e1589f56SBarry Smith */
43c48a1e8SJed Brown #if !defined(__PETSCDM_H)
53c48a1e8SJed Brown #define __PETSCDM_H
662cbcd01SMatthew G Knepley #include "petscmat.h"
7e1589f56SBarry Smith PETSC_EXTERN_CXX_BEGIN
8e1589f56SBarry Smith 
97087cfbeSBarry Smith extern PetscErrorCode  DMInitializePackage(const char[]);
10e1589f56SBarry Smith /*S
11e1589f56SBarry Smith      DM - Abstract PETSc object that manages an abstract grid object
12e1589f56SBarry Smith 
13e1589f56SBarry Smith    Level: intermediate
14e1589f56SBarry Smith 
15e1589f56SBarry Smith   Concepts: grids, grid refinement
16e1589f56SBarry Smith 
17325fc9f4SBarry Smith    Notes: The DMDACreate() based object and the DMCompositeCreate() based object are examples of DMs
18e1589f56SBarry Smith 
19325fc9f4SBarry Smith           Though the DM objects require the petscsnes.h include files the DM library is
20e1589f56SBarry Smith     NOT dependent on the SNES or KSP library. In fact, the KSP and SNES libraries depend on
21e1589f56SBarry Smith     DM. (This is not great design, but not trivial to fix).
22e1589f56SBarry Smith 
23e1589f56SBarry Smith .seealso:  DMCompositeCreate(), DMDACreate()
24e1589f56SBarry Smith S*/
25e1589f56SBarry Smith typedef struct _p_DM* DM;
26e1589f56SBarry Smith 
277087cfbeSBarry Smith extern PetscClassId  DM_CLASSID;
28e1589f56SBarry Smith 
2976bdecfbSBarry Smith /*J
30e1589f56SBarry Smith     DMType - String with the name of a PETSc DM or the creation function
31e1589f56SBarry Smith        with an optional dynamic library name, for example
32e1589f56SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:myveccreate()
33e1589f56SBarry Smith 
34e1589f56SBarry Smith    Level: beginner
35e1589f56SBarry Smith 
36e1589f56SBarry Smith .seealso: DMSetType(), DM
3776bdecfbSBarry Smith J*/
38e1589f56SBarry Smith #define DMType char*
39e1589f56SBarry Smith #define DMDA        "da"
40e1589f56SBarry Smith #define DMADDA      "adda"
41e1589f56SBarry Smith #define DMCOMPOSITE "composite"
42e1589f56SBarry Smith #define DMSLICED    "sliced"
43fe1899a2SJed Brown #define DMSHELL     "shell"
44b30b9b2eSMatthew G Knepley #define DMMESH      "mesh"
45c4721b0eSMatthew G Knepley #define DMCOMPLEX   "complex"
46b30b9b2eSMatthew G Knepley #define DMCARTESIAN "cartesian"
47f11a0a46SMatthew G Knepley #define DMIGA       "iga"
488ac4e037SJed Brown #define DMREDUNDANT "redundant"
49*01bc414fSDmitry Karpeev #define DMAKKT      "akkt"
50e1589f56SBarry Smith 
51e1589f56SBarry Smith extern PetscFList DMList;
52e1589f56SBarry Smith extern PetscBool  DMRegisterAllCalled;
537087cfbeSBarry Smith extern PetscErrorCode  DMCreate(MPI_Comm,DM*);
547087cfbeSBarry Smith extern PetscErrorCode  DMSetType(DM, const DMType);
557087cfbeSBarry Smith extern PetscErrorCode  DMGetType(DM, const DMType *);
567087cfbeSBarry Smith extern PetscErrorCode  DMRegister(const char[],const char[],const char[],PetscErrorCode (*)(DM));
577087cfbeSBarry Smith extern PetscErrorCode  DMRegisterAll(const char []);
587087cfbeSBarry Smith extern PetscErrorCode  DMRegisterDestroy(void);
59e1589f56SBarry Smith 
60e1589f56SBarry Smith 
61e1589f56SBarry Smith /*MC
62e1589f56SBarry Smith   DMRegisterDynamic - Adds a new DM component implementation
63e1589f56SBarry Smith 
64e1589f56SBarry Smith   Synopsis:
65e1589f56SBarry Smith   PetscErrorCode DMRegisterDynamic(const char *name,const char *path,const char *func_name, PetscErrorCode (*create_func)(DM))
66e1589f56SBarry Smith 
67e1589f56SBarry Smith   Not Collective
68e1589f56SBarry Smith 
69e1589f56SBarry Smith   Input Parameters:
70e1589f56SBarry Smith + name        - The name of a new user-defined creation routine
71e1589f56SBarry Smith . path        - The path (either absolute or relative) of the library containing this routine
72e1589f56SBarry Smith . func_name   - The name of routine to create method context
73e1589f56SBarry Smith - create_func - The creation routine itself
74e1589f56SBarry Smith 
75e1589f56SBarry Smith   Notes:
76e1589f56SBarry Smith   DMRegisterDynamic() may be called multiple times to add several user-defined DMs
77e1589f56SBarry Smith 
78e1589f56SBarry Smith   If dynamic libraries are used, then the fourth input argument (routine_create) is ignored.
79e1589f56SBarry Smith 
80e1589f56SBarry Smith   Sample usage:
81e1589f56SBarry Smith .vb
82e1589f56SBarry Smith     DMRegisterDynamic("my_da","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyDMCreate", MyDMCreate);
83e1589f56SBarry Smith .ve
84e1589f56SBarry Smith 
85e1589f56SBarry Smith   Then, your DM type can be chosen with the procedural interface via
86e1589f56SBarry Smith .vb
87e1589f56SBarry Smith     DMCreate(MPI_Comm, DM *);
88e1589f56SBarry Smith     DMSetType(DM,"my_da_name");
89e1589f56SBarry Smith .ve
90e1589f56SBarry Smith    or at runtime via the option
91e1589f56SBarry Smith .vb
92e1589f56SBarry Smith     -da_type my_da_name
93e1589f56SBarry Smith .ve
94e1589f56SBarry Smith 
95e1589f56SBarry Smith   Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
96e1589f56SBarry Smith          If your function is not being put into a shared library then use DMRegister() instead
97e1589f56SBarry Smith 
98e1589f56SBarry Smith   Level: advanced
99e1589f56SBarry Smith 
100e1589f56SBarry Smith .keywords: DM, register
101e1589f56SBarry Smith .seealso: DMRegisterAll(), DMRegisterDestroy(), DMRegister()
102e1589f56SBarry Smith M*/
103e1589f56SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
104e1589f56SBarry Smith #define DMRegisterDynamic(a,b,c,d) DMRegister(a,b,c,0)
105e1589f56SBarry Smith #else
106e1589f56SBarry Smith #define DMRegisterDynamic(a,b,c,d) DMRegister(a,b,c,d)
107e1589f56SBarry Smith #endif
108e1589f56SBarry Smith 
1097087cfbeSBarry Smith extern PetscErrorCode   DMView(DM,PetscViewer);
110bc2bf880SBarry Smith extern PetscErrorCode   DMLoad(DM,PetscViewer);
111fcfd50ebSBarry Smith extern PetscErrorCode   DMDestroy(DM*);
1127087cfbeSBarry Smith extern PetscErrorCode   DMCreateGlobalVector(DM,Vec*);
1137087cfbeSBarry Smith extern PetscErrorCode   DMCreateLocalVector(DM,Vec*);
1147087cfbeSBarry Smith extern PetscErrorCode   DMGetLocalVector(DM,Vec *);
1157087cfbeSBarry Smith extern PetscErrorCode   DMRestoreLocalVector(DM,Vec *);
1167087cfbeSBarry Smith extern PetscErrorCode   DMGetGlobalVector(DM,Vec *);
1177087cfbeSBarry Smith extern PetscErrorCode   DMRestoreGlobalVector(DM,Vec *);
1184dcab191SBarry Smith extern PetscErrorCode   DMClearGlobalVectors(DM);
119dfe15315SJed Brown extern PetscErrorCode DMGetNamedGlobalVector(DM,const char*,Vec*);
120dfe15315SJed Brown extern PetscErrorCode DMRestoreNamedGlobalVector(DM,const char*,Vec*);
1217087cfbeSBarry Smith extern PetscErrorCode   DMGetLocalToGlobalMapping(DM,ISLocalToGlobalMapping*);
1227087cfbeSBarry Smith extern PetscErrorCode   DMGetLocalToGlobalMappingBlock(DM,ISLocalToGlobalMapping*);
12321c9b008SJed Brown extern PetscErrorCode   DMCreateFieldIS(DM,PetscInt*,char***,IS**);
1247087cfbeSBarry Smith extern PetscErrorCode   DMGetBlockSize(DM,PetscInt*);
125e727c939SJed Brown extern PetscErrorCode   DMCreateColoring(DM,ISColoringType,const MatType,ISColoring*);
126950540a4SJed Brown extern PetscErrorCode   DMCreateMatrix(DM,const MatType,Mat*);
127fcfd50ebSBarry Smith extern PetscErrorCode   DMSetMatrixPreallocateOnly(DM,PetscBool);
128e727c939SJed Brown extern PetscErrorCode   DMCreateInterpolation(DM,DM,Mat*,Vec*);
129e727c939SJed Brown extern PetscErrorCode   DMCreateInjection(DM,DM,VecScatter*);
130a89ea682SMatthew G Knepley extern PetscErrorCode   DMGetWorkArray(DM,PetscInt,PetscScalar**);
1317087cfbeSBarry Smith extern PetscErrorCode   DMRefine(DM,MPI_Comm,DM*);
1327087cfbeSBarry Smith extern PetscErrorCode   DMCoarsen(DM,MPI_Comm,DM*);
1337087cfbeSBarry Smith extern PetscErrorCode   DMRefineHierarchy(DM,PetscInt,DM[]);
1347087cfbeSBarry Smith extern PetscErrorCode   DMCoarsenHierarchy(DM,PetscInt,DM[]);
135b17ce1afSJed Brown extern PetscErrorCode   DMCoarsenHookAdd(DM,PetscErrorCode (*)(DM,DM,void*),PetscErrorCode (*)(DM,Mat,Vec,Mat,DM,void*),void*);
136b17ce1afSJed Brown extern PetscErrorCode   DMRestrict(DM,Mat,Vec,Mat,DM);
1377087cfbeSBarry Smith extern PetscErrorCode   DMSetFromOptions(DM);
1387087cfbeSBarry Smith extern PetscErrorCode   DMSetUp(DM);
139e727c939SJed Brown extern PetscErrorCode   DMCreateInterpolationScale(DM,DM,Mat,Vec*);
140e727c939SJed Brown extern PetscErrorCode   DMCreateAggregates(DM,DM,Mat*);
1417087cfbeSBarry Smith extern PetscErrorCode   DMGlobalToLocalBegin(DM,Vec,InsertMode,Vec);
1427087cfbeSBarry Smith extern PetscErrorCode   DMGlobalToLocalEnd(DM,Vec,InsertMode,Vec);
1437087cfbeSBarry Smith extern PetscErrorCode   DMLocalToGlobalBegin(DM,Vec,InsertMode,Vec);
1447087cfbeSBarry Smith extern PetscErrorCode   DMLocalToGlobalEnd(DM,Vec,InsertMode,Vec);
145fee00e32SMatthew G Knepley extern PetscErrorCode   DMConvert(DM,const DMType,DM*);
146e1589f56SBarry Smith 
147ab6fcfeaSJed Brown extern PetscErrorCode   DMSetOptionsPrefix(DM,const char []);
148ab6fcfeaSJed Brown extern PetscErrorCode   DMSetVecType(DM,const VecType);
149521d9a4cSLisandro Dalcin extern PetscErrorCode   DMSetMatType(DM,const MatType);
1501b2093e4SBarry Smith extern PetscErrorCode   DMSetApplicationContext(DM,void*);
1511a266240SBarry Smith extern PetscErrorCode   DMSetApplicationContextDestroy(DM,PetscErrorCode (*)(void**));
1521b2093e4SBarry Smith extern PetscErrorCode   DMGetApplicationContext(DM,void*);
1537087cfbeSBarry Smith extern PetscErrorCode   DMSetInitialGuess(DM,PetscErrorCode (*)(DM,Vec));
1547087cfbeSBarry Smith extern PetscErrorCode   DMSetFunction(DM,PetscErrorCode (*)(DM,Vec,Vec));
1557087cfbeSBarry Smith extern PetscErrorCode   DMSetJacobian(DM,PetscErrorCode (*)(DM,Vec,Mat,Mat,MatStructure *));
15608da532bSDmitry Karpeev extern PetscErrorCode   DMSetVariableBounds(DM,PetscErrorCode (*)(DM,Vec,Vec));
1577087cfbeSBarry Smith extern PetscErrorCode   DMHasInitialGuess(DM,PetscBool *);
1587087cfbeSBarry Smith extern PetscErrorCode   DMHasFunction(DM,PetscBool *);
1597087cfbeSBarry Smith extern PetscErrorCode   DMHasJacobian(DM,PetscBool *);
16008da532bSDmitry Karpeev extern PetscErrorCode   DMHasVariableBounds(DM,PetscBool *);
1617087cfbeSBarry Smith extern PetscErrorCode   DMComputeInitialGuess(DM,Vec);
1627087cfbeSBarry Smith extern PetscErrorCode   DMComputeFunction(DM,Vec,Vec);
1637087cfbeSBarry Smith extern PetscErrorCode   DMComputeJacobian(DM,Vec,Mat,Mat,MatStructure *);
1647087cfbeSBarry Smith extern PetscErrorCode   DMComputeJacobianDefault(DM,Vec,Mat,Mat,MatStructure *);
16508da532bSDmitry Karpeev extern PetscErrorCode   DMComputeVariableBounds(DM,Vec,Vec);
16693d92d96SBarry Smith 
167e7c4fc90SDmitry Karpeev extern PetscErrorCode   DMCreateDecompositionDM(DM,const char*,DM*);
168e7c4fc90SDmitry Karpeev extern PetscErrorCode   DMCreateDecomposition(DM,PetscInt*,char***,IS**,DM**);
169e7c4fc90SDmitry Karpeev 
170eb3f98d2SBarry Smith extern PetscErrorCode   DMGetRefineLevel(DM,PetscInt*);
1715fe1f584SPeter Brune extern PetscErrorCode   DMGetCoarsenLevel(DM,PetscInt*);
1727087cfbeSBarry Smith extern PetscErrorCode   DMFinalizePackage(void);
173e1589f56SBarry Smith 
174e1589f56SBarry Smith typedef struct NLF_DAAD* NLF;
175e1589f56SBarry Smith 
1763c48a1e8SJed Brown #include "petscbag.h"
177e1589f56SBarry Smith 
1787087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryMatlabOpen(MPI_Comm, const char [], PetscViewer*);
1796bf464f9SBarry Smith extern PetscErrorCode  PetscViewerBinaryMatlabDestroy(PetscViewer*);
1807087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryMatlabOutputBag(PetscViewer, const char [], PetscBag);
1817087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryMatlabOutputVec(PetscViewer, const char [], Vec);
1827087cfbeSBarry Smith extern PetscErrorCode  PetscViewerBinaryMatlabOutputVecDA(PetscViewer, const char [], Vec, DM);
183e1589f56SBarry Smith 
184bc2bf880SBarry Smith #define DM_FILE_CLASSID 1211221
1857da65231SMatthew G Knepley 
1867da65231SMatthew G Knepley /* FEM support */
1877da65231SMatthew G Knepley extern PetscErrorCode DMPrintCellVector(PetscInt, const char [], PetscInt, const PetscScalar []);
1887da65231SMatthew G Knepley extern PetscErrorCode DMPrintCellMatrix(PetscInt, const char [], PetscInt, PetscInt, const PetscScalar []);
1897da65231SMatthew G Knepley 
1907da65231SMatthew G Knepley typedef struct {
1917da65231SMatthew G Knepley   PetscInt         numQuadPoints; /* The number of quadrature points on an element */
1927da65231SMatthew G Knepley   const PetscReal *quadPoints;    /* The quadrature point coordinates */
1937da65231SMatthew G Knepley   const PetscReal *quadWeights;   /* The quadrature weights */
1947da65231SMatthew G Knepley   PetscInt         numBasisFuncs; /* The number of finite element basis functions on an element */
1957da65231SMatthew G Knepley   PetscInt         numComponents; /* The number of components for each basis function */
1967da65231SMatthew G Knepley   const PetscReal *basis;         /* The basis functions tabulated at the quadrature points */
1977da65231SMatthew G Knepley   const PetscReal *basisDer;      /* The basis function derivatives tabulated at the quadrature points */
1987da65231SMatthew G Knepley } PetscQuadrature;
199e1589f56SBarry Smith PETSC_EXTERN_CXX_END
200e1589f56SBarry Smith #endif
201