xref: /petsc/include/petscdm.h (revision 08da532b2310464c3bf489aef60f0ccd6d61141d)
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 DMMESH      "mesh"
44 #define DMCOMPLEX   "complex"
45 #define DMCARTESIAN "cartesian"
46 #define DMIGA       "iga"
47 #define DMREDUNDANT "redundant"
48 
49 extern PetscFList DMList;
50 extern PetscBool  DMRegisterAllCalled;
51 extern PetscErrorCode  DMCreate(MPI_Comm,DM*);
52 extern PetscErrorCode  DMSetType(DM, const DMType);
53 extern PetscErrorCode  DMGetType(DM, const DMType *);
54 extern PetscErrorCode  DMRegister(const char[],const char[],const char[],PetscErrorCode (*)(DM));
55 extern PetscErrorCode  DMRegisterAll(const char []);
56 extern PetscErrorCode  DMRegisterDestroy(void);
57 
58 
59 /*MC
60   DMRegisterDynamic - Adds a new DM component implementation
61 
62   Synopsis:
63   PetscErrorCode DMRegisterDynamic(const char *name,const char *path,const char *func_name, PetscErrorCode (*create_func)(DM))
64 
65   Not Collective
66 
67   Input Parameters:
68 + name        - The name of a new user-defined creation routine
69 . path        - The path (either absolute or relative) of the library containing this routine
70 . func_name   - The name of routine to create method context
71 - create_func - The creation routine itself
72 
73   Notes:
74   DMRegisterDynamic() may be called multiple times to add several user-defined DMs
75 
76   If dynamic libraries are used, then the fourth input argument (routine_create) is ignored.
77 
78   Sample usage:
79 .vb
80     DMRegisterDynamic("my_da","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyDMCreate", MyDMCreate);
81 .ve
82 
83   Then, your DM type can be chosen with the procedural interface via
84 .vb
85     DMCreate(MPI_Comm, DM *);
86     DMSetType(DM,"my_da_name");
87 .ve
88    or at runtime via the option
89 .vb
90     -da_type my_da_name
91 .ve
92 
93   Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
94          If your function is not being put into a shared library then use DMRegister() instead
95 
96   Level: advanced
97 
98 .keywords: DM, register
99 .seealso: DMRegisterAll(), DMRegisterDestroy(), DMRegister()
100 M*/
101 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
102 #define DMRegisterDynamic(a,b,c,d) DMRegister(a,b,c,0)
103 #else
104 #define DMRegisterDynamic(a,b,c,d) DMRegister(a,b,c,d)
105 #endif
106 
107 extern PetscErrorCode   DMView(DM,PetscViewer);
108 extern PetscErrorCode   DMLoad(DM,PetscViewer);
109 extern PetscErrorCode   DMDestroy(DM*);
110 extern PetscErrorCode   DMCreateGlobalVector(DM,Vec*);
111 extern PetscErrorCode   DMCreateLocalVector(DM,Vec*);
112 extern PetscErrorCode   DMGetLocalVector(DM,Vec *);
113 extern PetscErrorCode   DMRestoreLocalVector(DM,Vec *);
114 extern PetscErrorCode   DMGetGlobalVector(DM,Vec *);
115 extern PetscErrorCode   DMRestoreGlobalVector(DM,Vec *);
116 extern PetscErrorCode   DMClearGlobalVectors(DM);
117 extern PetscErrorCode   DMGetLocalToGlobalMapping(DM,ISLocalToGlobalMapping*);
118 extern PetscErrorCode   DMGetLocalToGlobalMappingBlock(DM,ISLocalToGlobalMapping*);
119 extern PetscErrorCode   DMGetBlockSize(DM,PetscInt*);
120 extern PetscErrorCode   DMCreateColoring(DM,ISColoringType,const MatType,ISColoring*);
121 extern PetscErrorCode   DMCreateMatrix(DM,const MatType,Mat*);
122 extern PetscErrorCode   DMSetMatrixPreallocateOnly(DM,PetscBool);
123 extern PetscErrorCode   DMCreateInterpolation(DM,DM,Mat*,Vec*);
124 extern PetscErrorCode   DMCreateInjection(DM,DM,VecScatter*);
125 extern PetscErrorCode   DMGetWorkArray(DM,PetscInt,PetscScalar**);
126 extern PetscErrorCode   DMRefine(DM,MPI_Comm,DM*);
127 extern PetscErrorCode   DMCoarsen(DM,MPI_Comm,DM*);
128 extern PetscErrorCode   DMRefineHierarchy(DM,PetscInt,DM[]);
129 extern PetscErrorCode   DMCoarsenHierarchy(DM,PetscInt,DM[]);
130 extern PetscErrorCode   DMCoarsenHookAdd(DM,PetscErrorCode (*)(DM,DM,void*),PetscErrorCode (*)(DM,Mat,Vec,Mat,DM,void*),void*);
131 extern PetscErrorCode   DMRestrict(DM,Mat,Vec,Mat,DM);
132 extern PetscErrorCode   DMSetFromOptions(DM);
133 extern PetscErrorCode   DMSetUp(DM);
134 extern PetscErrorCode   DMCreateInterpolationScale(DM,DM,Mat,Vec*);
135 extern PetscErrorCode   DMCreateAggregates(DM,DM,Mat*);
136 extern PetscErrorCode   DMGlobalToLocalBegin(DM,Vec,InsertMode,Vec);
137 extern PetscErrorCode   DMGlobalToLocalEnd(DM,Vec,InsertMode,Vec);
138 extern PetscErrorCode   DMLocalToGlobalBegin(DM,Vec,InsertMode,Vec);
139 extern PetscErrorCode   DMLocalToGlobalEnd(DM,Vec,InsertMode,Vec);
140 extern PetscErrorCode   DMConvert(DM,const DMType,DM*);
141 
142 extern PetscErrorCode   DMSetOptionsPrefix(DM,const char []);
143 extern PetscErrorCode   DMSetVecType(DM,const VecType);
144 extern PetscErrorCode   DMSetApplicationContext(DM,void*);
145 extern PetscErrorCode   DMSetApplicationContextDestroy(DM,PetscErrorCode (*)(void**));
146 extern PetscErrorCode   DMGetApplicationContext(DM,void*);
147 extern PetscErrorCode   DMSetInitialGuess(DM,PetscErrorCode (*)(DM,Vec));
148 extern PetscErrorCode   DMSetFunction(DM,PetscErrorCode (*)(DM,Vec,Vec));
149 extern PetscErrorCode   DMSetJacobian(DM,PetscErrorCode (*)(DM,Vec,Mat,Mat,MatStructure *));
150 extern PetscErrorCode   DMSetVariableBounds(DM,PetscErrorCode (*)(DM,Vec,Vec));
151 extern PetscErrorCode   DMHasInitialGuess(DM,PetscBool *);
152 extern PetscErrorCode   DMHasFunction(DM,PetscBool *);
153 extern PetscErrorCode   DMHasJacobian(DM,PetscBool *);
154 extern PetscErrorCode   DMHasVariableBounds(DM,PetscBool *);
155 extern PetscErrorCode   DMComputeInitialGuess(DM,Vec);
156 extern PetscErrorCode   DMComputeFunction(DM,Vec,Vec);
157 extern PetscErrorCode   DMComputeJacobian(DM,Vec,Mat,Mat,MatStructure *);
158 extern PetscErrorCode   DMComputeJacobianDefault(DM,Vec,Mat,Mat,MatStructure *);
159 extern PetscErrorCode   DMComputeVariableBounds(DM,Vec,Vec);
160 
161 extern PetscErrorCode   DMGetRefineLevel(DM,PetscInt*);
162 extern PetscErrorCode   DMGetCoarsenLevel(DM,PetscInt*);
163 extern PetscErrorCode   DMFinalizePackage(void);
164 
165 typedef struct NLF_DAAD* NLF;
166 
167 #include "petscbag.h"
168 
169 extern PetscErrorCode  PetscViewerBinaryMatlabOpen(MPI_Comm, const char [], PetscViewer*);
170 extern PetscErrorCode  PetscViewerBinaryMatlabDestroy(PetscViewer*);
171 extern PetscErrorCode  PetscViewerBinaryMatlabOutputBag(PetscViewer, const char [], PetscBag);
172 extern PetscErrorCode  PetscViewerBinaryMatlabOutputVec(PetscViewer, const char [], Vec);
173 extern PetscErrorCode  PetscViewerBinaryMatlabOutputVecDA(PetscViewer, const char [], Vec, DM);
174 
175 #define DM_FILE_CLASSID 1211221
176 
177 /* FEM support */
178 extern PetscErrorCode DMPrintCellVector(PetscInt, const char [], PetscInt, const PetscScalar []);
179 extern PetscErrorCode DMPrintCellMatrix(PetscInt, const char [], PetscInt, PetscInt, const PetscScalar []);
180 
181 typedef struct {
182   PetscInt         numQuadPoints; /* The number of quadrature points on an element */
183   const PetscReal *quadPoints;    /* The quadrature point coordinates */
184   const PetscReal *quadWeights;   /* The quadrature weights */
185   PetscInt         numBasisFuncs; /* The number of finite element basis functions on an element */
186   PetscInt         numComponents; /* The number of components for each basis function */
187   const PetscReal *basis;         /* The basis functions tabulated at the quadrature points */
188   const PetscReal *basisDer;      /* The basis function derivatives tabulated at the quadrature points */
189 } PetscQuadrature;
190 PETSC_EXTERN_CXX_END
191 #endif
192