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 8014dd563SJed 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 26014dd563SJed 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 50014dd563SJed Brown PETSC_EXTERN PetscFList DMList; 51014dd563SJed Brown PETSC_EXTERN PetscBool DMRegisterAllCalled; 52014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreate(MPI_Comm,DM*); 53014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetType(DM, const DMType); 54014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetType(DM, const DMType *); 55014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRegister(const char[],const char[],const char[],PetscErrorCode (*)(DM)); 56014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRegisterAll(const char []); 57014dd563SJed 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 108014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMView(DM,PetscViewer); 109014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMLoad(DM,PetscViewer); 110014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMDestroy(DM*); 111014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateGlobalVector(DM,Vec*); 112014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateLocalVector(DM,Vec*); 113014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetLocalVector(DM,Vec *); 114014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRestoreLocalVector(DM,Vec *); 115014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetGlobalVector(DM,Vec *); 116014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRestoreGlobalVector(DM,Vec *); 117014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMClearGlobalVectors(DM); 118014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetNamedGlobalVector(DM,const char*,Vec*); 119014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRestoreNamedGlobalVector(DM,const char*,Vec*); 120014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetLocalToGlobalMapping(DM,ISLocalToGlobalMapping*); 121014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetLocalToGlobalMappingBlock(DM,ISLocalToGlobalMapping*); 122014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateFieldIS(DM,PetscInt*,char***,IS**); 123014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetBlockSize(DM,PetscInt*); 124014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateColoring(DM,ISColoringType,const MatType,ISColoring*); 125014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateMatrix(DM,const MatType,Mat*); 126014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetMatrixPreallocateOnly(DM,PetscBool); 127014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateInterpolation(DM,DM,Mat*,Vec*); 128014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateInjection(DM,DM,VecScatter*); 129014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetWorkArray(DM,PetscInt,PetscScalar**); 130014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRefine(DM,MPI_Comm,DM*); 131014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCoarsen(DM,MPI_Comm,DM*); 132014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRefineHierarchy(DM,PetscInt,DM[]); 133014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCoarsenHierarchy(DM,PetscInt,DM[]); 134014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCoarsenHookAdd(DM,PetscErrorCode (*)(DM,DM,void*),PetscErrorCode (*)(DM,Mat,Vec,Mat,DM,void*),void*); 135014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRefineHookAdd(DM,PetscErrorCode (*)(DM,DM,void*),PetscErrorCode (*)(DM,Mat,DM,void*),void*); 136014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRestrict(DM,Mat,Vec,Mat,DM); 137014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMInterpolate(DM,Mat,DM); 138014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetFromOptions(DM); 139014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetUp(DM); 140014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateInterpolationScale(DM,DM,Mat,Vec*); 141014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateAggregates(DM,DM,Mat*); 142014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGlobalToLocalBegin(DM,Vec,InsertMode,Vec); 143014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGlobalToLocalEnd(DM,Vec,InsertMode,Vec); 144014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMLocalToGlobalBegin(DM,Vec,InsertMode,Vec); 145014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMLocalToGlobalEnd(DM,Vec,InsertMode,Vec); 146014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMConvert(DM,const DMType,DM*); 147e1589f56SBarry Smith 148014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetOptionsPrefix(DM,const char []); 149014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetVecType(DM,const VecType); 150014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetMatType(DM,const MatType); 151014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetApplicationContext(DM,void*); 152014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetApplicationContextDestroy(DM,PetscErrorCode (*)(void**)); 153014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetApplicationContext(DM,void*); 154014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetInitialGuess(DM,PetscErrorCode (*)(DM,Vec)); 155014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetFunction(DM,PetscErrorCode (*)(DM,Vec,Vec)); 156014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetJacobian(DM,PetscErrorCode (*)(DM,Vec,Mat,Mat,MatStructure *)); 157014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetVariableBounds(DM,PetscErrorCode (*)(DM,Vec,Vec)); 158014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMHasInitialGuess(DM,PetscBool *); 159014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMHasFunction(DM,PetscBool *); 160014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMHasJacobian(DM,PetscBool *); 161014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMHasVariableBounds(DM,PetscBool *); 162014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMComputeInitialGuess(DM,Vec); 163014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMComputeFunction(DM,Vec,Vec); 164014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMComputeJacobian(DM,Vec,Mat,Mat,MatStructure *); 165014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMComputeJacobianDefault(DM,Vec,Mat,Mat,MatStructure *); 166014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMComputeVariableBounds(DM,Vec,Vec); 16793d92d96SBarry Smith 16816621825SDmitry Karpeev PETSC_EXTERN PetscErrorCode DMCreateFieldDecompositionDM(DM,const char*,DM*); 16916621825SDmitry Karpeev PETSC_EXTERN PetscErrorCode DMCreateFieldDecomposition(DM,PetscInt*,char***,IS**,DM**); 17016621825SDmitry Karpeev PETSC_EXTERN PetscErrorCode DMCreateDomainDecompositionDM(DM,const char*,DM*); 171*8d4ac253SDmitry Karpeev PETSC_EXTERN PetscErrorCode DMCreateDomainDecomposition(DM,PetscInt*,char***,IS**,IS**,DM**); 172e7c4fc90SDmitry Karpeev 173014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetRefineLevel(DM,PetscInt*); 174014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetCoarsenLevel(DM,PetscInt*); 175014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMFinalizePackage(void); 176e1589f56SBarry Smith 177e1589f56SBarry Smith typedef struct NLF_DAAD* NLF; 178e1589f56SBarry Smith 1793c48a1e8SJed Brown #include "petscbag.h" 180e1589f56SBarry Smith 181014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryMatlabOpen(MPI_Comm, const char [], PetscViewer*); 182014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryMatlabDestroy(PetscViewer*); 183014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryMatlabOutputBag(PetscViewer, const char [], PetscBag); 184014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryMatlabOutputVec(PetscViewer, const char [], Vec); 185014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerBinaryMatlabOutputVecDA(PetscViewer, const char [], Vec, DM); 186e1589f56SBarry Smith 187bc2bf880SBarry Smith #define DM_FILE_CLASSID 1211221 1887da65231SMatthew G Knepley 1897da65231SMatthew G Knepley /* FEM support */ 190014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetLocalFunction(DM, PetscErrorCode (**)(DM, Vec, Vec, void *)); 191014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetLocalFunction(DM, PetscErrorCode (*)(DM, Vec, Vec, void *)); 192014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetLocalJacobian(DM, PetscErrorCode (**)(DM, Vec, Mat, Mat, void *)); 193014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetLocalJacobian(DM, PetscErrorCode (*)(DM, Vec, Mat, Mat, void *)); 194638cfed1SJed Brown PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*DMLocalFunction1)(DM, Vec, Vec, void*); 195638cfed1SJed Brown PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*DMLocalJacobian1)(DM, Vec, Mat, Mat, void*); 196014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMPrintCellVector(PetscInt, const char [], PetscInt, const PetscScalar []); 197014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMPrintCellMatrix(PetscInt, const char [], PetscInt, PetscInt, const PetscScalar []); 1987da65231SMatthew G Knepley 199014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetDefaultSection(DM, PetscSection *); 200014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetDefaultSection(DM, PetscSection); 201014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetDefaultGlobalSection(DM, PetscSection *); 202014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetDefaultSF(DM, PetscSF *); 203014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetDefaultSF(DM, PetscSF); 204014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateDefaultSF(DM, PetscSection, PetscSection); 20588ed4aceSMatthew G Knepley 2067da65231SMatthew G Knepley typedef struct { 2077da65231SMatthew G Knepley PetscInt numQuadPoints; /* The number of quadrature points on an element */ 2087da65231SMatthew G Knepley const PetscReal *quadPoints; /* The quadrature point coordinates */ 2097da65231SMatthew G Knepley const PetscReal *quadWeights; /* The quadrature weights */ 2107da65231SMatthew G Knepley PetscInt numBasisFuncs; /* The number of finite element basis functions on an element */ 2117da65231SMatthew G Knepley PetscInt numComponents; /* The number of components for each basis function */ 2127da65231SMatthew G Knepley const PetscReal *basis; /* The basis functions tabulated at the quadrature points */ 2137da65231SMatthew G Knepley const PetscReal *basisDer; /* The basis function derivatives tabulated at the quadrature points */ 2147da65231SMatthew G Knepley } PetscQuadrature; 215e1589f56SBarry Smith #endif 216