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 62c8e378dSBarry Smith #include <petscmat.h> 71e25c274SJed Brown #include <petscdmtypes.h> 8e1589f56SBarry Smith 9607a6623SBarry Smith PETSC_EXTERN PetscErrorCode DMInitializePackage(void); 10e1589f56SBarry Smith 11014dd563SJed Brown PETSC_EXTERN PetscClassId DM_CLASSID; 12e1589f56SBarry Smith 1376bdecfbSBarry Smith /*J 148f6c3df8SBarry Smith DMType - String with the name of a PETSc DM 15e1589f56SBarry Smith 16e1589f56SBarry Smith Level: beginner 17e1589f56SBarry Smith 18e1589f56SBarry Smith .seealso: DMSetType(), DM 1976bdecfbSBarry Smith J*/ 2019fd82e9SBarry Smith typedef const char* DMType; 21e1589f56SBarry Smith #define DMDA "da" 22e1589f56SBarry Smith #define DMADDA "adda" 23e1589f56SBarry Smith #define DMCOMPOSITE "composite" 24e1589f56SBarry Smith #define DMSLICED "sliced" 25fe1899a2SJed Brown #define DMSHELL "shell" 26ab7f58a0SBarry Smith #define DMPLEX "plex" 27b30b9b2eSMatthew G Knepley #define DMCARTESIAN "cartesian" 288ac4e037SJed Brown #define DMREDUNDANT "redundant" 293a19ef87SMatthew G Knepley #define DMPATCH "patch" 301d72bce8STim Tautges #define DMMOAB "moab" 31e1589f56SBarry Smith 32140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList DMList; 33014dd563SJed Brown PETSC_EXTERN PetscBool DMRegisterAllCalled; 34014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreate(MPI_Comm,DM*); 3538221697SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMClone(DM,DM*); 3619fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode DMSetType(DM, DMType); 3719fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode DMGetType(DM, DMType *); 38bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode DMRegister(const char[],PetscErrorCode (*)(DM)); 39607a6623SBarry Smith PETSC_EXTERN PetscErrorCode DMRegisterAll(void); 40014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRegisterDestroy(void); 41e1589f56SBarry Smith 42014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMView(DM,PetscViewer); 43014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMLoad(DM,PetscViewer); 44014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMDestroy(DM*); 45014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateGlobalVector(DM,Vec*); 46014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateLocalVector(DM,Vec*); 47014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetLocalVector(DM,Vec *); 48014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRestoreLocalVector(DM,Vec *); 49014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetGlobalVector(DM,Vec *); 50014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRestoreGlobalVector(DM,Vec *); 51014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMClearGlobalVectors(DM); 52014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetNamedGlobalVector(DM,const char*,Vec*); 53014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRestoreNamedGlobalVector(DM,const char*,Vec*); 542348bcf4SPeter Brune PETSC_EXTERN PetscErrorCode DMGetNamedLocalVector(DM,const char*,Vec*); 552348bcf4SPeter Brune PETSC_EXTERN PetscErrorCode DMRestoreNamedLocalVector(DM,const char*,Vec*); 56014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetLocalToGlobalMapping(DM,ISLocalToGlobalMapping*); 57014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetLocalToGlobalMappingBlock(DM,ISLocalToGlobalMapping*); 58014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateFieldIS(DM,PetscInt*,char***,IS**); 59014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetBlockSize(DM,PetscInt*); 6019fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode DMCreateColoring(DM,ISColoringType,MatType,ISColoring*); 6119fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode DMCreateMatrix(DM,MatType,Mat*); 62014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetMatrixPreallocateOnly(DM,PetscBool); 63014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateInterpolation(DM,DM,Mat*,Vec*); 64014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateInjection(DM,DM,VecScatter*); 65aa1993deSMatthew G Knepley PETSC_EXTERN PetscErrorCode DMGetWorkArray(DM,PetscInt,PetscDataType,void*); 66aa1993deSMatthew G Knepley PETSC_EXTERN PetscErrorCode DMRestoreWorkArray(DM,PetscInt,PetscDataType,void*); 67014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRefine(DM,MPI_Comm,DM*); 68014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCoarsen(DM,MPI_Comm,DM*); 69014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRefineHierarchy(DM,PetscInt,DM[]); 70014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCoarsenHierarchy(DM,PetscInt,DM[]); 71014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCoarsenHookAdd(DM,PetscErrorCode (*)(DM,DM,void*),PetscErrorCode (*)(DM,Mat,Vec,Mat,DM,void*),void*); 72014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRefineHookAdd(DM,PetscErrorCode (*)(DM,DM,void*),PetscErrorCode (*)(DM,Mat,DM,void*),void*); 73014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMRestrict(DM,Mat,Vec,Mat,DM); 74014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMInterpolate(DM,Mat,DM); 75014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetFromOptions(DM); 76146574abSBarry Smith PETSC_EXTERN PetscErrorCode DMViewFromOptions(DM,const char[], const char[]); 77ca266f36SBarry Smith 78014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetUp(DM); 79014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateInterpolationScale(DM,DM,Mat,Vec*); 80014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateAggregates(DM,DM,Mat*); 81baf369e7SPeter Brune PETSC_EXTERN PetscErrorCode DMGlobalToLocalHookAdd(DM,PetscErrorCode (*)(DM,Vec,InsertMode,Vec,void*),PetscErrorCode (*)(DM,Vec,InsertMode,Vec,void*),void*); 82014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGlobalToLocalBegin(DM,Vec,InsertMode,Vec); 83014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGlobalToLocalEnd(DM,Vec,InsertMode,Vec); 84014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMLocalToGlobalBegin(DM,Vec,InsertMode,Vec); 85014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMLocalToGlobalEnd(DM,Vec,InsertMode,Vec); 86d78e899eSRichard Tran Mills PETSC_EXTERN PetscErrorCode DMLocalToLocalBegin(DM,Vec,InsertMode,Vec); 87d78e899eSRichard Tran Mills PETSC_EXTERN PetscErrorCode DMLocalToLocalEnd(DM,Vec,InsertMode,Vec); 8819fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode DMConvert(DM,DMType,DM*); 89e1589f56SBarry Smith 906636e97aSMatthew G Knepley PETSC_EXTERN PetscErrorCode DMGetCoordinateDM(DM,DM*); 91*1cfe2091SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMSetCoordinateDM(DM,DM); 926636e97aSMatthew G Knepley PETSC_EXTERN PetscErrorCode DMGetCoordinates(DM,Vec*); 936636e97aSMatthew G Knepley PETSC_EXTERN PetscErrorCode DMSetCoordinates(DM,Vec); 946636e97aSMatthew G Knepley PETSC_EXTERN PetscErrorCode DMGetCoordinatesLocal(DM,Vec*); 956636e97aSMatthew G Knepley PETSC_EXTERN PetscErrorCode DMSetCoordinatesLocal(DM,Vec); 96e87bb0d3SMatthew G Knepley PETSC_EXTERN PetscErrorCode DMLocatePoints(DM,Vec,IS*); 976636e97aSMatthew G Knepley 985dbd56e3SPeter Brune /* block hook interface */ 99be081cd6SPeter Brune PETSC_EXTERN PetscErrorCode DMSubDomainHookAdd(DM,PetscErrorCode (*)(DM,DM,void*),PetscErrorCode (*)(DM,VecScatter,VecScatter,DM,void*),void*); 100be081cd6SPeter Brune PETSC_EXTERN PetscErrorCode DMSubDomainRestrict(DM,VecScatter,VecScatter,DM); 1015dbd56e3SPeter Brune 102014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetOptionsPrefix(DM,const char []); 10319fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode DMSetVecType(DM,VecType); 10419fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode DMSetMatType(DM,MatType); 105014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetApplicationContext(DM,void*); 106014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetApplicationContextDestroy(DM,PetscErrorCode (*)(void**)); 107014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetApplicationContext(DM,void*); 108014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetVariableBounds(DM,PetscErrorCode (*)(DM,Vec,Vec)); 109014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMHasVariableBounds(DM,PetscBool *); 110b0ae01b7SPeter Brune PETSC_EXTERN PetscErrorCode DMHasColoring(DM,PetscBool *); 111014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMComputeVariableBounds(DM,Vec,Vec); 11293d92d96SBarry Smith 11381d26defSMatthew G Knepley PETSC_EXTERN PetscErrorCode DMCreateSubDM(DM, PetscInt, PetscInt[], IS *, DM *); 11416621825SDmitry Karpeev PETSC_EXTERN PetscErrorCode DMCreateFieldDecomposition(DM,PetscInt*,char***,IS**,DM**); 1158d4ac253SDmitry Karpeev PETSC_EXTERN PetscErrorCode DMCreateDomainDecomposition(DM,PetscInt*,char***,IS**,IS**,DM**); 116e30e807fSPeter Brune PETSC_EXTERN PetscErrorCode DMCreateDomainDecompositionScatters(DM,PetscInt,DM*,VecScatter**,VecScatter**,VecScatter**); 117e7c4fc90SDmitry Karpeev 118014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetRefineLevel(DM,PetscInt*); 119014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetCoarsenLevel(DM,PetscInt*); 120014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMFinalizePackage(void); 121e1589f56SBarry Smith 1225f1ad066SMatthew G Knepley PETSC_EXTERN PetscErrorCode VecGetDM(Vec, DM*); 1235f1ad066SMatthew G Knepley PETSC_EXTERN PetscErrorCode VecSetDM(Vec, DM); 124c688c046SMatthew G Knepley PETSC_EXTERN PetscErrorCode MatGetDM(Mat, DM*); 125c688c046SMatthew G Knepley PETSC_EXTERN PetscErrorCode MatSetDM(Mat, DM); 1265f1ad066SMatthew G Knepley 127e1589f56SBarry Smith typedef struct NLF_DAAD* NLF; 128e1589f56SBarry Smith 129bc2bf880SBarry Smith #define DM_FILE_CLASSID 1211221 1307da65231SMatthew G Knepley 1317da65231SMatthew G Knepley /* FEM support */ 132014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMPrintCellVector(PetscInt, const char [], PetscInt, const PetscScalar []); 133014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMPrintCellMatrix(PetscInt, const char [], PetscInt, PetscInt, const PetscScalar []); 1346113b454SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMPrintLocalVec(DM, const char [], PetscReal, Vec); 1357da65231SMatthew G Knepley 136014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetDefaultSection(DM, PetscSection *); 137014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetDefaultSection(DM, PetscSection); 138014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetDefaultGlobalSection(DM, PetscSection *); 139eaf8d80aSMatthew G Knepley PETSC_EXTERN PetscErrorCode DMSetDefaultGlobalSection(DM, PetscSection); 140014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMGetDefaultSF(DM, PetscSF *); 141014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMSetDefaultSF(DM, PetscSF); 142014dd563SJed Brown PETSC_EXTERN PetscErrorCode DMCreateDefaultSF(DM, PetscSection, PetscSection); 143b21d0597SMatthew G Knepley PETSC_EXTERN PetscErrorCode DMGetPointSF(DM, PetscSF *); 144057b4bcdSMatthew G Knepley PETSC_EXTERN PetscErrorCode DMSetPointSF(DM, PetscSF); 14588ed4aceSMatthew G Knepley 146af122d2aSMatthew G Knepley PETSC_EXTERN PetscErrorCode DMGetNumFields(DM, PetscInt *); 147af122d2aSMatthew G Knepley PETSC_EXTERN PetscErrorCode DMSetNumFields(DM, PetscInt); 148af122d2aSMatthew G Knepley PETSC_EXTERN PetscErrorCode DMGetField(DM, PetscInt, PetscObject *); 149af122d2aSMatthew G Knepley 15083e5549fSMatthew G Knepley typedef enum {PETSC_UNIT_LENGTH, PETSC_UNIT_MASS, PETSC_UNIT_TIME, PETSC_UNIT_CURRENT, PETSC_UNIT_TEMPERATURE, PETSC_UNIT_AMOUNT, PETSC_UNIT_LUMINOSITY, NUM_PETSC_UNITS} PetscUnit; 151e87bb0d3SMatthew G Knepley 152e87bb0d3SMatthew G Knepley struct _DMInterpolationInfo { 153e87bb0d3SMatthew G Knepley MPI_Comm comm; 154e87bb0d3SMatthew G Knepley PetscInt dim; /*1 The spatial dimension of points */ 155e87bb0d3SMatthew G Knepley PetscInt nInput; /* The number of input points */ 156e87bb0d3SMatthew G Knepley PetscReal *points; /* The input point coordinates */ 157e87bb0d3SMatthew G Knepley PetscInt *cells; /* The cell containing each point */ 158e87bb0d3SMatthew G Knepley PetscInt n; /* The number of local points */ 159e87bb0d3SMatthew G Knepley Vec coords; /* The point coordinates */ 160e87bb0d3SMatthew G Knepley PetscInt dof; /* The number of components to interpolate */ 161e87bb0d3SMatthew G Knepley }; 162e87bb0d3SMatthew G Knepley typedef struct _DMInterpolationInfo *DMInterpolationInfo; 163e87bb0d3SMatthew G Knepley 16494b4b8a8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMInterpolationCreate(MPI_Comm, DMInterpolationInfo *); 16594b4b8a8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMInterpolationSetDim(DMInterpolationInfo, PetscInt); 16694b4b8a8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMInterpolationGetDim(DMInterpolationInfo, PetscInt *); 16794b4b8a8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMInterpolationSetDof(DMInterpolationInfo, PetscInt); 16894b4b8a8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMInterpolationGetDof(DMInterpolationInfo, PetscInt *); 16994b4b8a8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMInterpolationAddPoints(DMInterpolationInfo, PetscInt, PetscReal[]); 17094b4b8a8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMInterpolationSetUp(DMInterpolationInfo, DM, PetscBool); 17194b4b8a8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMInterpolationGetCoordinates(DMInterpolationInfo, Vec *); 17294b4b8a8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMInterpolationGetVector(DMInterpolationInfo, Vec *); 17394b4b8a8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMInterpolationRestoreVector(DMInterpolationInfo, Vec *); 17494b4b8a8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMInterpolationEvaluate(DMInterpolationInfo, DM, Vec, Vec); 17594b4b8a8SMatthew G. Knepley PETSC_EXTERN PetscErrorCode DMInterpolationDestroy(DMInterpolationInfo *); 176e1589f56SBarry Smith #endif 177