xref: /petsc/include/petscdm.h (revision 9ae82921df069a58776bfe4da82b38e8ff7dd41c)
1 /*
2       Objects to manage the interactions between the mesh data structures and the algebraic objects
3 */
4 #if !defined(__PETSCDM_H)
5 #define __PETSCDM_H
6 #include "petscmat.h"
7 PETSC_EXTERN_CXX_BEGIN
8 
9 extern PetscErrorCode  DMInitializePackage(const char[]);
10 /*S
11      DM - Abstract PETSc object that manages an abstract grid object
12 
13    Level: intermediate
14 
15   Concepts: grids, grid refinement
16 
17    Notes: The DMDACreate() based object and the DMCompositeCreate() based object are examples of DMs
18 
19           Though the DM objects require the petscsnes.h include files the DM library is
20     NOT dependent on the SNES or KSP library. In fact, the KSP and SNES libraries depend on
21     DM. (This is not great design, but not trivial to fix).
22 
23 .seealso:  DMCompositeCreate(), DMDACreate()
24 S*/
25 typedef struct _p_DM* DM;
26 
27 extern PetscClassId  DM_CLASSID;
28 
29 /*J
30     DMType - String with the name of a PETSc DM or the creation function
31        with an optional dynamic library name, for example
32        http://www.mcs.anl.gov/petsc/lib.a:myveccreate()
33 
34    Level: beginner
35 
36 .seealso: DMSetType(), DM
37 J*/
38 #define DMType char*
39 #define DMDA        "da"
40 #define DMADDA      "adda"
41 #define DMCOMPOSITE "composite"
42 #define DMSLICED    "sliced"
43 #define DMSHELL     "shell"
44 #define DMMESH      "mesh"
45 #define DMCOMPLEX   "complex"
46 #define DMCARTESIAN "cartesian"
47 #define DMIGA       "iga"
48 #define DMREDUNDANT "redundant"
49 #define DMAKKT      "akkt"
50 
51 extern PetscFList DMList;
52 extern PetscBool  DMRegisterAllCalled;
53 extern PetscErrorCode  DMCreate(MPI_Comm,DM*);
54 extern PetscErrorCode  DMSetType(DM, const DMType);
55 extern PetscErrorCode  DMGetType(DM, const DMType *);
56 extern PetscErrorCode  DMRegister(const char[],const char[],const char[],PetscErrorCode (*)(DM));
57 extern PetscErrorCode  DMRegisterAll(const char []);
58 extern PetscErrorCode  DMRegisterDestroy(void);
59 
60 
61 /*MC
62   DMRegisterDynamic - Adds a new DM component implementation
63 
64   Synopsis:
65   PetscErrorCode DMRegisterDynamic(const char *name,const char *path,const char *func_name, PetscErrorCode (*create_func)(DM))
66 
67   Not Collective
68 
69   Input Parameters:
70 + name        - The name of a new user-defined creation routine
71 . path        - The path (either absolute or relative) of the library containing this routine
72 . func_name   - The name of routine to create method context
73 - create_func - The creation routine itself
74 
75   Notes:
76   DMRegisterDynamic() may be called multiple times to add several user-defined DMs
77 
78   If dynamic libraries are used, then the fourth input argument (routine_create) is ignored.
79 
80   Sample usage:
81 .vb
82     DMRegisterDynamic("my_da","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyDMCreate", MyDMCreate);
83 .ve
84 
85   Then, your DM type can be chosen with the procedural interface via
86 .vb
87     DMCreate(MPI_Comm, DM *);
88     DMSetType(DM,"my_da_name");
89 .ve
90    or at runtime via the option
91 .vb
92     -da_type my_da_name
93 .ve
94 
95   Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
96          If your function is not being put into a shared library then use DMRegister() instead
97 
98   Level: advanced
99 
100 .keywords: DM, register
101 .seealso: DMRegisterAll(), DMRegisterDestroy(), DMRegister()
102 M*/
103 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
104 #define DMRegisterDynamic(a,b,c,d) DMRegister(a,b,c,0)
105 #else
106 #define DMRegisterDynamic(a,b,c,d) DMRegister(a,b,c,d)
107 #endif
108 
109 extern PetscErrorCode   DMView(DM,PetscViewer);
110 extern PetscErrorCode   DMLoad(DM,PetscViewer);
111 extern PetscErrorCode   DMDestroy(DM*);
112 extern PetscErrorCode   DMCreateGlobalVector(DM,Vec*);
113 extern PetscErrorCode   DMCreateLocalVector(DM,Vec*);
114 extern PetscErrorCode   DMGetLocalVector(DM,Vec *);
115 extern PetscErrorCode   DMRestoreLocalVector(DM,Vec *);
116 extern PetscErrorCode   DMGetGlobalVector(DM,Vec *);
117 extern PetscErrorCode   DMRestoreGlobalVector(DM,Vec *);
118 extern PetscErrorCode   DMClearGlobalVectors(DM);
119 extern PetscErrorCode DMGetNamedGlobalVector(DM,const char*,Vec*);
120 extern PetscErrorCode DMRestoreNamedGlobalVector(DM,const char*,Vec*);
121 extern PetscErrorCode   DMGetLocalToGlobalMapping(DM,ISLocalToGlobalMapping*);
122 extern PetscErrorCode   DMGetLocalToGlobalMappingBlock(DM,ISLocalToGlobalMapping*);
123 extern PetscErrorCode   DMCreateFieldIS(DM,PetscInt*,char***,IS**);
124 extern PetscErrorCode   DMGetBlockSize(DM,PetscInt*);
125 extern PetscErrorCode   DMCreateColoring(DM,ISColoringType,const MatType,ISColoring*);
126 extern PetscErrorCode   DMCreateMatrix(DM,const MatType,Mat*);
127 extern PetscErrorCode   DMSetMatrixPreallocateOnly(DM,PetscBool);
128 extern PetscErrorCode   DMCreateInterpolation(DM,DM,Mat*,Vec*);
129 extern PetscErrorCode   DMCreateInjection(DM,DM,VecScatter*);
130 extern PetscErrorCode   DMGetWorkArray(DM,PetscInt,PetscScalar**);
131 extern PetscErrorCode   DMRefine(DM,MPI_Comm,DM*);
132 extern PetscErrorCode   DMCoarsen(DM,MPI_Comm,DM*);
133 extern PetscErrorCode   DMRefineHierarchy(DM,PetscInt,DM[]);
134 extern PetscErrorCode   DMCoarsenHierarchy(DM,PetscInt,DM[]);
135 extern PetscErrorCode   DMCoarsenHookAdd(DM,PetscErrorCode (*)(DM,DM,void*),PetscErrorCode (*)(DM,Mat,Vec,Mat,DM,void*),void*);
136 extern PetscErrorCode   DMRestrict(DM,Mat,Vec,Mat,DM);
137 extern PetscErrorCode   DMSetFromOptions(DM);
138 extern PetscErrorCode   DMSetUp(DM);
139 extern PetscErrorCode   DMCreateInterpolationScale(DM,DM,Mat,Vec*);
140 extern PetscErrorCode   DMCreateAggregates(DM,DM,Mat*);
141 extern PetscErrorCode   DMGlobalToLocalBegin(DM,Vec,InsertMode,Vec);
142 extern PetscErrorCode   DMGlobalToLocalEnd(DM,Vec,InsertMode,Vec);
143 extern PetscErrorCode   DMLocalToGlobalBegin(DM,Vec,InsertMode,Vec);
144 extern PetscErrorCode   DMLocalToGlobalEnd(DM,Vec,InsertMode,Vec);
145 extern PetscErrorCode   DMConvert(DM,const DMType,DM*);
146 
147 extern PetscErrorCode   DMSetOptionsPrefix(DM,const char []);
148 extern PetscErrorCode   DMSetVecType(DM,const VecType);
149 extern PetscErrorCode   DMSetMatType(DM,const MatType);
150 extern PetscErrorCode   DMSetApplicationContext(DM,void*);
151 extern PetscErrorCode   DMSetApplicationContextDestroy(DM,PetscErrorCode (*)(void**));
152 extern PetscErrorCode   DMGetApplicationContext(DM,void*);
153 extern PetscErrorCode   DMSetInitialGuess(DM,PetscErrorCode (*)(DM,Vec));
154 extern PetscErrorCode   DMSetFunction(DM,PetscErrorCode (*)(DM,Vec,Vec));
155 extern PetscErrorCode   DMSetJacobian(DM,PetscErrorCode (*)(DM,Vec,Mat,Mat,MatStructure *));
156 extern PetscErrorCode   DMSetVariableBounds(DM,PetscErrorCode (*)(DM,Vec,Vec));
157 extern PetscErrorCode   DMHasInitialGuess(DM,PetscBool *);
158 extern PetscErrorCode   DMHasFunction(DM,PetscBool *);
159 extern PetscErrorCode   DMHasJacobian(DM,PetscBool *);
160 extern PetscErrorCode   DMHasVariableBounds(DM,PetscBool *);
161 extern PetscErrorCode   DMComputeInitialGuess(DM,Vec);
162 extern PetscErrorCode   DMComputeFunction(DM,Vec,Vec);
163 extern PetscErrorCode   DMComputeJacobian(DM,Vec,Mat,Mat,MatStructure *);
164 extern PetscErrorCode   DMComputeJacobianDefault(DM,Vec,Mat,Mat,MatStructure *);
165 extern PetscErrorCode   DMComputeVariableBounds(DM,Vec,Vec);
166 
167 extern PetscErrorCode   DMCreateDecompositionDM(DM,const char*,DM*);
168 extern PetscErrorCode   DMCreateDecomposition(DM,PetscInt*,char***,IS**,DM**);
169 
170 extern PetscErrorCode   DMGetRefineLevel(DM,PetscInt*);
171 extern PetscErrorCode   DMGetCoarsenLevel(DM,PetscInt*);
172 extern PetscErrorCode   DMFinalizePackage(void);
173 
174 typedef struct NLF_DAAD* NLF;
175 
176 #include "petscbag.h"
177 
178 extern PetscErrorCode  PetscViewerBinaryMatlabOpen(MPI_Comm, const char [], PetscViewer*);
179 extern PetscErrorCode  PetscViewerBinaryMatlabDestroy(PetscViewer*);
180 extern PetscErrorCode  PetscViewerBinaryMatlabOutputBag(PetscViewer, const char [], PetscBag);
181 extern PetscErrorCode  PetscViewerBinaryMatlabOutputVec(PetscViewer, const char [], Vec);
182 extern PetscErrorCode  PetscViewerBinaryMatlabOutputVecDA(PetscViewer, const char [], Vec, DM);
183 
184 #define DM_FILE_CLASSID 1211221
185 
186 /* FEM support */
187 extern PetscErrorCode DMGetLocalFunction(DM, PetscErrorCode (**)(DM, Vec, Vec, void *));
188 extern PetscErrorCode DMSetLocalFunction(DM, PetscErrorCode (*)(DM, Vec, Vec, void *));
189 extern PetscErrorCode DMGetLocalJacobian(DM, PetscErrorCode (**)(DM, Vec, Mat, Mat, void *));
190 extern PetscErrorCode DMSetLocalJacobian(DM, PetscErrorCode (*)(DM, Vec, Mat, Mat, void *));
191 typedef PetscErrorCode (*DMLocalFunction1)(DM, Vec, Vec, void*);
192 typedef PetscErrorCode (*DMLocalJacobian1)(DM, Vec, Mat, Mat, void*);
193 extern PetscErrorCode DMPrintCellVector(PetscInt, const char [], PetscInt, const PetscScalar []);
194 extern PetscErrorCode DMPrintCellMatrix(PetscInt, const char [], PetscInt, PetscInt, const PetscScalar []);
195 
196 extern PetscErrorCode DMGetDefaultSection(DM, PetscSection *);
197 extern PetscErrorCode DMSetDefaultSection(DM, PetscSection);
198 extern PetscErrorCode DMGetDefaultGlobalSection(DM, PetscSection *);
199 extern PetscErrorCode DMGetDefaultSF(DM, PetscSF *);
200 extern PetscErrorCode DMSetDefaultSF(DM, PetscSF);
201 extern PetscErrorCode DMCreateDefaultSF(DM, PetscSection, PetscSection);
202 
203 typedef struct {
204   PetscInt         numQuadPoints; /* The number of quadrature points on an element */
205   const PetscReal *quadPoints;    /* The quadrature point coordinates */
206   const PetscReal *quadWeights;   /* The quadrature weights */
207   PetscInt         numBasisFuncs; /* The number of finite element basis functions on an element */
208   PetscInt         numComponents; /* The number of components for each basis function */
209   const PetscReal *basis;         /* The basis functions tabulated at the quadrature points */
210   const PetscReal *basisDer;      /* The basis function derivatives tabulated at the quadrature points */
211 } PetscQuadrature;
212 PETSC_EXTERN_CXX_END
213 #endif
214