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