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