xref: /petsc/include/petscdm.h (revision 3a19ef87c57d96a00c8e8b5d38d585840d49a0e4)
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
62c8e378dSBarry Smith #include <petscmat.h>
7e1589f56SBarry Smith 
8014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMInitializePackage(const char[]);
9e1589f56SBarry Smith /*S
10e1589f56SBarry Smith      DM - Abstract PETSc object that manages an abstract grid object
11e1589f56SBarry Smith 
12e1589f56SBarry Smith    Level: intermediate
13e1589f56SBarry Smith 
14e1589f56SBarry Smith   Concepts: grids, grid refinement
15e1589f56SBarry Smith 
16325fc9f4SBarry Smith    Notes: The DMDACreate() based object and the DMCompositeCreate() based object are examples of DMs
17e1589f56SBarry Smith 
18325fc9f4SBarry Smith           Though the DM objects require the petscsnes.h include files the DM library is
19e1589f56SBarry Smith     NOT dependent on the SNES or KSP library. In fact, the KSP and SNES libraries depend on
20e1589f56SBarry Smith     DM. (This is not great design, but not trivial to fix).
21e1589f56SBarry Smith 
22e1589f56SBarry Smith .seealso:  DMCompositeCreate(), DMDACreate()
23e1589f56SBarry Smith S*/
24e1589f56SBarry Smith typedef struct _p_DM* DM;
25e1589f56SBarry Smith 
26014dd563SJed Brown PETSC_EXTERN PetscClassId DM_CLASSID;
27e1589f56SBarry Smith 
2876bdecfbSBarry Smith /*J
29e1589f56SBarry Smith     DMType - String with the name of a PETSc DM or the creation function
30e1589f56SBarry Smith        with an optional dynamic library name, for example
31e1589f56SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:myveccreate()
32e1589f56SBarry Smith 
33e1589f56SBarry Smith    Level: beginner
34e1589f56SBarry Smith 
35e1589f56SBarry Smith .seealso: DMSetType(), DM
3676bdecfbSBarry Smith J*/
37e1589f56SBarry Smith #define DMType char*
38e1589f56SBarry Smith #define DMDA        "da"
39e1589f56SBarry Smith #define DMADDA      "adda"
40e1589f56SBarry Smith #define DMCOMPOSITE "composite"
41e1589f56SBarry Smith #define DMSLICED    "sliced"
42fe1899a2SJed Brown #define DMSHELL     "shell"
43b30b9b2eSMatthew G Knepley #define DMMESH      "mesh"
44c4721b0eSMatthew G Knepley #define DMCOMPLEX   "complex"
45b30b9b2eSMatthew G Knepley #define DMCARTESIAN "cartesian"
46f11a0a46SMatthew G Knepley #define DMIGA       "iga"
478ac4e037SJed Brown #define DMREDUNDANT "redundant"
4801bc414fSDmitry Karpeev #define DMAKKT      "akkt"
49*3a19ef87SMatthew G Knepley #define DMPATCH     "patch"
50e1589f56SBarry Smith 
51014dd563SJed Brown PETSC_EXTERN PetscFList DMList;
52014dd563SJed Brown PETSC_EXTERN PetscBool DMRegisterAllCalled;
53014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreate(MPI_Comm,DM*);
54014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetType(DM, const DMType);
55014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetType(DM, const DMType *);
56014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRegister(const char[],const char[],const char[],PetscErrorCode (*)(DM));
57014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRegisterAll(const char []);
58014dd563SJed Brown PETSC_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 
109014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMView(DM,PetscViewer);
110014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMLoad(DM,PetscViewer);
111014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMDestroy(DM*);
112014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateGlobalVector(DM,Vec*);
113014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateLocalVector(DM,Vec*);
114014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetLocalVector(DM,Vec *);
115014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRestoreLocalVector(DM,Vec *);
116014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetGlobalVector(DM,Vec *);
117014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRestoreGlobalVector(DM,Vec *);
118014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMClearGlobalVectors(DM);
119014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetNamedGlobalVector(DM,const char*,Vec*);
120014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRestoreNamedGlobalVector(DM,const char*,Vec*);
121014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetLocalToGlobalMapping(DM,ISLocalToGlobalMapping*);
122014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetLocalToGlobalMappingBlock(DM,ISLocalToGlobalMapping*);
123014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateFieldIS(DM,PetscInt*,char***,IS**);
124014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetBlockSize(DM,PetscInt*);
125014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateColoring(DM,ISColoringType,const MatType,ISColoring*);
126014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateMatrix(DM,const MatType,Mat*);
127014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetMatrixPreallocateOnly(DM,PetscBool);
128014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateInterpolation(DM,DM,Mat*,Vec*);
129014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateInjection(DM,DM,VecScatter*);
130aa1993deSMatthew G Knepley PETSC_EXTERN PetscErrorCode DMGetWorkArray(DM,PetscInt,PetscDataType,void*);
131aa1993deSMatthew G Knepley PETSC_EXTERN PetscErrorCode DMRestoreWorkArray(DM,PetscInt,PetscDataType,void*);
132014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRefine(DM,MPI_Comm,DM*);
133014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCoarsen(DM,MPI_Comm,DM*);
134014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRefineHierarchy(DM,PetscInt,DM[]);
135014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCoarsenHierarchy(DM,PetscInt,DM[]);
136014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCoarsenHookAdd(DM,PetscErrorCode (*)(DM,DM,void*),PetscErrorCode (*)(DM,Mat,Vec,Mat,DM,void*),void*);
137014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRefineHookAdd(DM,PetscErrorCode (*)(DM,DM,void*),PetscErrorCode (*)(DM,Mat,DM,void*),void*);
138014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRestrict(DM,Mat,Vec,Mat,DM);
139014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMInterpolate(DM,Mat,DM);
140014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetFromOptions(DM);
141014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetUp(DM);
142014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateInterpolationScale(DM,DM,Mat,Vec*);
143014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateAggregates(DM,DM,Mat*);
144014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGlobalToLocalBegin(DM,Vec,InsertMode,Vec);
145014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGlobalToLocalEnd(DM,Vec,InsertMode,Vec);
146014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMLocalToGlobalBegin(DM,Vec,InsertMode,Vec);
147014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMLocalToGlobalEnd(DM,Vec,InsertMode,Vec);
148014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMConvert(DM,const DMType,DM*);
149e1589f56SBarry Smith 
150014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetOptionsPrefix(DM,const char []);
151014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetVecType(DM,const VecType);
152014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetMatType(DM,const MatType);
153014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetApplicationContext(DM,void*);
154014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetApplicationContextDestroy(DM,PetscErrorCode (*)(void**));
155014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetApplicationContext(DM,void*);
156014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetInitialGuess(DM,PetscErrorCode (*)(DM,Vec));
157014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetFunction(DM,PetscErrorCode (*)(DM,Vec,Vec));
158014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetJacobian(DM,PetscErrorCode (*)(DM,Vec,Mat,Mat,MatStructure *));
159014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetVariableBounds(DM,PetscErrorCode (*)(DM,Vec,Vec));
160014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMHasInitialGuess(DM,PetscBool *);
161014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMHasFunction(DM,PetscBool *);
162014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMHasJacobian(DM,PetscBool *);
163014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMHasVariableBounds(DM,PetscBool *);
164b0ae01b7SPeter Brune PETSC_EXTERN PetscErrorCode DMHasColoring(DM,PetscBool *);
165014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMComputeInitialGuess(DM,Vec);
166014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMComputeFunction(DM,Vec,Vec);
167014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMComputeJacobian(DM,Vec,Mat,Mat,MatStructure *);
168014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMComputeJacobianDefault(DM,Vec,Mat,Mat,MatStructure *);
169014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMComputeVariableBounds(DM,Vec,Vec);
17093d92d96SBarry Smith 
17181d26defSMatthew G Knepley PETSC_EXTERN PetscErrorCode DMCreateSubDM(DM, PetscInt, PetscInt[], IS *, DM *);
17216621825SDmitry Karpeev PETSC_EXTERN PetscErrorCode DMCreateFieldDecompositionDM(DM,const char*,DM*);
17316621825SDmitry Karpeev PETSC_EXTERN PetscErrorCode DMCreateFieldDecomposition(DM,PetscInt*,char***,IS**,DM**);
17416621825SDmitry Karpeev PETSC_EXTERN PetscErrorCode DMCreateDomainDecompositionDM(DM,const char*,DM*);
1758d4ac253SDmitry Karpeev PETSC_EXTERN PetscErrorCode DMCreateDomainDecomposition(DM,PetscInt*,char***,IS**,IS**,DM**);
176e7c4fc90SDmitry Karpeev 
177014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetRefineLevel(DM,PetscInt*);
178014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetCoarsenLevel(DM,PetscInt*);
179014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMFinalizePackage(void);
180e1589f56SBarry Smith 
181e1589f56SBarry Smith typedef struct NLF_DAAD* NLF;
182e1589f56SBarry Smith 
1832c8e378dSBarry Smith #include <petscbag.h>
184e1589f56SBarry Smith 
185014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryMatlabOpen(MPI_Comm, const char [], PetscViewer*);
186014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryMatlabDestroy(PetscViewer*);
187014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryMatlabOutputBag(PetscViewer, const char [], PetscBag);
188014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryMatlabOutputVec(PetscViewer, const char [], Vec);
189014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryMatlabOutputVecDA(PetscViewer, const char [], Vec, DM);
190e1589f56SBarry Smith 
191bc2bf880SBarry Smith #define DM_FILE_CLASSID 1211221
1927da65231SMatthew G Knepley 
1937da65231SMatthew G Knepley /* FEM support */
194014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetLocalFunction(DM, PetscErrorCode (**)(DM, Vec, Vec, void *));
195014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetLocalFunction(DM, PetscErrorCode (*)(DM, Vec, Vec, void *));
196014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetLocalJacobian(DM, PetscErrorCode (**)(DM, Vec, Mat, Mat, void *));
197014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetLocalJacobian(DM, PetscErrorCode (*)(DM, Vec, Mat, Mat, void *));
198638cfed1SJed Brown PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*DMLocalFunction1)(DM, Vec, Vec, void*);
199638cfed1SJed Brown PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*DMLocalJacobian1)(DM, Vec, Mat, Mat, void*);
200014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMPrintCellVector(PetscInt, const char [], PetscInt, const PetscScalar []);
201014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMPrintCellMatrix(PetscInt, const char [], PetscInt, PetscInt, const PetscScalar []);
2027da65231SMatthew G Knepley 
203014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetDefaultSection(DM, PetscSection *);
204014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetDefaultSection(DM, PetscSection);
205014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetDefaultGlobalSection(DM, PetscSection *);
206014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetDefaultSF(DM, PetscSF *);
207014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetDefaultSF(DM, PetscSF);
208014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateDefaultSF(DM, PetscSection, PetscSection);
20988ed4aceSMatthew G Knepley 
2107da65231SMatthew G Knepley typedef struct {
2117da65231SMatthew G Knepley   PetscInt         numQuadPoints; /* The number of quadrature points on an element */
2127da65231SMatthew G Knepley   const PetscReal *quadPoints;    /* The quadrature point coordinates */
2137da65231SMatthew G Knepley   const PetscReal *quadWeights;   /* The quadrature weights */
2147da65231SMatthew G Knepley   PetscInt         numBasisFuncs; /* The number of finite element basis functions on an element */
2157da65231SMatthew G Knepley   PetscInt         numComponents; /* The number of components for each basis function */
2167da65231SMatthew G Knepley   const PetscReal *basis;         /* The basis functions tabulated at the quadrature points */
2177da65231SMatthew G Knepley   const PetscReal *basisDer;      /* The basis function derivatives tabulated at the quadrature points */
2187da65231SMatthew G Knepley } PetscQuadrature;
219e1589f56SBarry Smith #endif
220