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 #include "petscao.h" 8 PETSC_EXTERN_CXX_BEGIN 9 10 extern PetscErrorCode DMInitializePackage(const char[]); 11 /*S 12 DM - Abstract PETSc object that manages an abstract grid object 13 14 Level: intermediate 15 16 Concepts: grids, grid refinement 17 18 Notes: The DMDACreate() based object and the DMCompositeCreate() based object are examples of DMs 19 20 Though the DM objects require the petscsnes.h include files the DM library is 21 NOT dependent on the SNES or KSP library. In fact, the KSP and SNES libraries depend on 22 DM. (This is not great design, but not trivial to fix). 23 24 .seealso: DMCompositeCreate(), DMDACreate() 25 S*/ 26 typedef struct _p_DM* DM; 27 28 extern PetscClassId DM_CLASSID; 29 30 /*E 31 DMType - String with the name of a PETSc DM or the creation function 32 with an optional dynamic library name, for example 33 http://www.mcs.anl.gov/petsc/lib.a:myveccreate() 34 35 Level: beginner 36 37 .seealso: DMSetType(), DM 38 E*/ 39 40 #define DMType char* 41 #define DMDA "da" 42 #define DMADDA "adda" 43 #define DMCOMPOSITE "composite" 44 #define DMSLICED "sliced" 45 #define DMMESH "mesh" 46 #define DMCARTESIAN "cartesian" 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 /*MC 58 DMRegisterDynamic - Adds a new DM component implementation 59 60 Synopsis: 61 PetscErrorCode DMRegisterDynamic(const char *name,const char *path,const char *func_name, PetscErrorCode (*create_func)(DM)) 62 63 Not Collective 64 65 Input Parameters: 66 + name - The name of a new user-defined creation routine 67 . path - The path (either absolute or relative) of the library containing this routine 68 . func_name - The name of routine to create method context 69 - create_func - The creation routine itself 70 71 Notes: 72 DMRegisterDynamic() may be called multiple times to add several user-defined DMs 73 74 If dynamic libraries are used, then the fourth input argument (routine_create) is ignored. 75 76 Sample usage: 77 .vb 78 DMRegisterDynamic("my_da","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyDMCreate", MyDMCreate); 79 .ve 80 81 Then, your DM type can be chosen with the procedural interface via 82 .vb 83 DMCreate(MPI_Comm, DM *); 84 DMSetType(DM,"my_da_name"); 85 .ve 86 or at runtime via the option 87 .vb 88 -da_type my_da_name 89 .ve 90 91 Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values. 92 If your function is not being put into a shared library then use DMRegister() instead 93 94 Level: advanced 95 96 .keywords: DM, register 97 .seealso: DMRegisterAll(), DMRegisterDestroy(), DMRegister() 98 M*/ 99 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 100 #define DMRegisterDynamic(a,b,c,d) DMRegister(a,b,c,0) 101 #else 102 #define DMRegisterDynamic(a,b,c,d) DMRegister(a,b,c,d) 103 #endif 104 105 extern PetscErrorCode DMView(DM,PetscViewer); 106 extern PetscErrorCode DMDestroy(DM); 107 extern PetscErrorCode DMCreateGlobalVector(DM,Vec*); 108 extern PetscErrorCode DMCreateLocalVector(DM,Vec*); 109 extern PetscErrorCode DMGetLocalVector(DM,Vec *); 110 extern PetscErrorCode DMRestoreLocalVector(DM,Vec *); 111 extern PetscErrorCode DMGetGlobalVector(DM,Vec *); 112 extern PetscErrorCode DMRestoreGlobalVector(DM,Vec *); 113 extern PetscErrorCode DMGetLocalToGlobalMapping(DM,ISLocalToGlobalMapping*); 114 extern PetscErrorCode DMGetLocalToGlobalMappingBlock(DM,ISLocalToGlobalMapping*); 115 extern PetscErrorCode DMGetBlockSize(DM,PetscInt*); 116 extern PetscErrorCode DMGetColoring(DM,ISColoringType,const MatType,ISColoring*); 117 extern PetscErrorCode DMGetMatrix(DM, const MatType,Mat*); 118 extern PetscErrorCode DMGetInterpolation(DM,DM,Mat*,Vec*); 119 extern PetscErrorCode DMGetInjection(DM,DM,VecScatter*); 120 extern PetscErrorCode DMRefine(DM,MPI_Comm,DM*); 121 extern PetscErrorCode DMCoarsen(DM,MPI_Comm,DM*); 122 extern PetscErrorCode DMRefineHierarchy(DM,PetscInt,DM[]); 123 extern PetscErrorCode DMCoarsenHierarchy(DM,PetscInt,DM[]); 124 extern PetscErrorCode DMSetFromOptions(DM); 125 extern PetscErrorCode DMSetUp(DM); 126 extern PetscErrorCode DMGetInterpolationScale(DM,DM,Mat,Vec*); 127 extern PetscErrorCode DMGetAggregates(DM,DM,Mat*); 128 extern PetscErrorCode DMGlobalToLocalBegin(DM,Vec,InsertMode,Vec); 129 extern PetscErrorCode DMGlobalToLocalEnd(DM,Vec,InsertMode,Vec); 130 extern PetscErrorCode DMLocalToGlobalBegin(DM,Vec,InsertMode,Vec); 131 extern PetscErrorCode DMLocalToGlobalEnd(DM,Vec,InsertMode,Vec); 132 extern PetscErrorCode DMGetElements(DM,PetscInt *,PetscInt *,const PetscInt*[]); 133 extern PetscErrorCode DMRestoreElements(DM,PetscInt *,PetscInt *,const PetscInt*[]); 134 135 extern PetscErrorCode DMSetOptionsPrefix(DM,const char []); 136 extern PetscErrorCode DMSetVecType(DM,const VecType); 137 extern PetscErrorCode DMSetContext(DM,void*); 138 extern PetscErrorCode DMGetContext(DM,void**); 139 extern PetscErrorCode DMSetInitialGuess(DM,PetscErrorCode (*)(DM,Vec)); 140 extern PetscErrorCode DMSetFunction(DM,PetscErrorCode (*)(DM,Vec,Vec)); 141 extern PetscErrorCode DMSetJacobian(DM,PetscErrorCode (*)(DM,Vec,Mat,Mat,MatStructure *)); 142 extern PetscErrorCode DMHasInitialGuess(DM,PetscBool *); 143 extern PetscErrorCode DMHasFunction(DM,PetscBool *); 144 extern PetscErrorCode DMHasJacobian(DM,PetscBool *); 145 extern PetscErrorCode DMComputeInitialGuess(DM,Vec); 146 extern PetscErrorCode DMComputeFunction(DM,Vec,Vec); 147 extern PetscErrorCode DMComputeJacobian(DM,Vec,Mat,Mat,MatStructure *); 148 extern PetscErrorCode DMComputeJacobianDefault(DM,Vec,Mat,Mat,MatStructure *); 149 extern PetscErrorCode DMFinalizePackage(void); 150 151 typedef struct NLF_DAAD* NLF; 152 153 #include "petscbag.h" 154 155 extern PetscErrorCode PetscViewerBinaryMatlabOpen(MPI_Comm, const char [], PetscViewer*); 156 extern PetscErrorCode PetscViewerBinaryMatlabDestroy(PetscViewer); 157 extern PetscErrorCode PetscViewerBinaryMatlabOutputBag(PetscViewer, const char [], PetscBag); 158 extern PetscErrorCode PetscViewerBinaryMatlabOutputVec(PetscViewer, const char [], Vec); 159 extern PetscErrorCode PetscViewerBinaryMatlabOutputVecDA(PetscViewer, const char [], Vec, DM); 160 161 PETSC_EXTERN_CXX_END 162 #endif 163