/* Regular array object, for easy parallelism of simple grid problems on regular distributed arrays. */ #if !defined(__PETSCDA_H) #define __PETSCDA_H #include "petscvec.h" #include "petscao.h" PETSC_EXTERN_CXX_BEGIN /*S DA - Abstract PETSc object that manages distributed field data for a single structured grid Level: beginner Concepts: distributed array .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DADestroy(), VecScatter, DACreate(), DM, DMComposite S*/ typedef struct _p_DA* DA; /*E DAStencilType - Determines if the stencil extends only along the coordinate directions, or also to the northeast, northwest etc Level: beginner .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DA, DACreate() E*/ typedef enum { DA_STENCIL_STAR,DA_STENCIL_BOX } DAStencilType; /*MC DA_STENCIL_STAR - "Star"-type stencil. In logical grid coordinates, only (i,j,k), (i+s,j,k), (i,j+s,k), (i,j,k+s) are in the stencil NOT, for example, (i+s,j+s,k) Level: beginner .seealso: DA_STENCIL_BOX, DAStencilType M*/ /*MC DA_STENCIL_Box - "Box"-type stencil. In logical grid coordinates, any of (i,j,k), (i+s,j+r,k+t) may be in the stencil. Level: beginner .seealso: DA_STENCIL_STAR, DAStencilType M*/ /*E DAPeriodicType - Is the domain periodic in one or more directions Level: beginner .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DA, DACreate() E*/ typedef enum { DA_NONPERIODIC,DA_XPERIODIC,DA_YPERIODIC,DA_XYPERIODIC, DA_XYZPERIODIC,DA_XZPERIODIC,DA_YZPERIODIC,DA_ZPERIODIC} DAPeriodicType; /*E DAInterpolationType - Defines the type of interpolation that will be returned by DAGetInterpolation. Level: beginner .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DA, DAGetInterpolation(), DASetInterpolationType(), DACreate() E*/ typedef enum { DA_Q0, DA_Q1 } DAInterpolationType; EXTERN PetscErrorCode PETSCDM_DLLEXPORT DASetInterpolationType(DA,DAInterpolationType); /*E DAElementType - Defines the type of elements that will be returned by DAGetElements. Level: beginner .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DA, DAGetInterpolation(), DASetInterpolationType(), DASetElementType(), DAGetElements(), DARestoreElements(), DACreate() E*/ typedef enum { DA_ELEMENT_P1, DA_ELEMENT_Q1 } DAElementType; EXTERN PetscErrorCode PETSCDM_DLLEXPORT DASetElementType(DA,DAElementType); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGetElements(DA,PetscInt *,const PetscInt*[]); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DARestoreElements(DA,PetscInt *,const PetscInt*[]); #define DAXPeriodic(pt) ((pt)==DA_XPERIODIC||(pt)==DA_XYPERIODIC||(pt)==DA_XZPERIODIC||(pt)==DA_XYZPERIODIC) #define DAYPeriodic(pt) ((pt)==DA_YPERIODIC||(pt)==DA_XYPERIODIC||(pt)==DA_YZPERIODIC||(pt)==DA_XYZPERIODIC) #define DAZPeriodic(pt) ((pt)==DA_ZPERIODIC||(pt)==DA_XZPERIODIC||(pt)==DA_YZPERIODIC||(pt)==DA_XYZPERIODIC) typedef enum { DA_X,DA_Y,DA_Z } DADirection; extern PetscCookie PETSCDM_DLLEXPORT DA_COOKIE; EXTERN PetscErrorCode PETSCDM_DLLEXPORT DACreate1d(MPI_Comm,DAPeriodicType,PetscInt,PetscInt,PetscInt,PetscInt*,DA *); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DACreate2d(MPI_Comm,DAPeriodicType,DAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt*,PetscInt*,DA *); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DACreate3d(MPI_Comm,DAPeriodicType,DAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt*,PetscInt*,PetscInt*,DA*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DACreate(MPI_Comm,PetscInt,DAPeriodicType,DAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt*,PetscInt*,PetscInt*,DA*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DADestroy(DA); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAView(DA,PetscViewer); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGlobalToLocalBegin(DA,Vec,InsertMode,Vec); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGlobalToLocalEnd(DA,Vec,InsertMode,Vec); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGlobalToNaturalBegin(DA,Vec,InsertMode,Vec); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGlobalToNaturalEnd(DA,Vec,InsertMode,Vec); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DANaturalToGlobalBegin(DA,Vec,InsertMode,Vec); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DANaturalToGlobalEnd(DA,Vec,InsertMode,Vec); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DALocalToLocalBegin(DA,Vec,InsertMode,Vec); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DALocalToLocalEnd(DA,Vec,InsertMode,Vec); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DALocalToGlobal(DA,Vec,InsertMode,Vec); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DALocalToGlobalBegin(DA,Vec,Vec); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DALocalToGlobalEnd(DA,Vec,Vec); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGetOwnershipRange(DA,PetscInt **,PetscInt **,PetscInt **); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DACreateGlobalVector(DA,Vec *); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DACreateNaturalVector(DA,Vec *); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DACreateLocalVector(DA,Vec *); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGetLocalVector(DA,Vec *); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DARestoreLocalVector(DA,Vec *); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGetGlobalVector(DA,Vec *); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DARestoreGlobalVector(DA,Vec *); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DALoad(PetscViewer,PetscInt,PetscInt,PetscInt,DA *); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGetCorners(DA,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGetGhostCorners(DA,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGetInfo(DA,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,DAPeriodicType*,DAStencilType*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGetProcessorSubset(DA,DADirection,PetscInt,MPI_Comm*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DARefine(DA,MPI_Comm,DA*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGlobalToNaturalAllCreate(DA,VecScatter*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DANaturalAllToGlobalCreate(DA,VecScatter*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGetGlobalIndices(DA,PetscInt*,PetscInt**); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGetISLocalToGlobalMapping(DA,ISLocalToGlobalMapping*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGetISLocalToGlobalMappingBlck(DA,ISLocalToGlobalMapping*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGetScatter(DA,VecScatter*,VecScatter*,VecScatter*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGetAO(DA,AO*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DASetCoordinates(DA,Vec); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGetCoordinates(DA,Vec *); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGetGhostedCoordinates(DA,Vec *); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGetCoordinateDA(DA,DA *); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DASetUniformCoordinates(DA,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DASetFieldName(DA,PetscInt,const char[]); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAGetFieldName(DA,PetscInt,char **); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAVecGetArray(DA,Vec,void *); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAVecRestoreArray(DA,Vec,void *); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAVecGetArrayDOF(DA,Vec,void *); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DAVecRestoreArrayDOF(DA,Vec,void *); EXTERN PetscErrorCode PETSCDM_DLLEXPORT DASplitComm2d(MPI_Comm,PetscInt,PetscInt,PetscInt,MPI_Comm*); /*S SDA - This provides a simplified interface to the DA distributed array object in PETSc. This is intended for people who are NOT using PETSc vectors or objects but just want to distribute simple rectangular arrays amoung a number of procesors and have PETSc handle moving the ghost-values when needed. In certain applications this can serve as a replacement for BlockComm (which is apparently being phased out?). Level: beginner Concepts: simplified distributed array .seealso: SDACreate1d(), SDACreate2d(), SDACreate3d(), SDADestroy(), DA, SDALocalToLocalBegin(), SDALocalToLocalEnd(), SDAGetCorners(), SDAGetGhostCorners() S*/ typedef struct _n_SDA* SDA; EXTERN PetscErrorCode PETSCDM_DLLEXPORT SDACreate3d(MPI_Comm,DAPeriodicType,DAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt*,PetscInt*,PetscInt*,SDA*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT SDACreate2d(MPI_Comm,DAPeriodicType,DAStencilType,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt*,PetscInt*,SDA*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT SDACreate1d(MPI_Comm,DAPeriodicType,PetscInt,PetscInt,PetscInt,PetscInt*,SDA*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT SDADestroy(SDA); EXTERN PetscErrorCode PETSCDM_DLLEXPORT SDALocalToLocalBegin(SDA,PetscScalar*,InsertMode,PetscScalar*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT SDALocalToLocalEnd(SDA,PetscScalar*,InsertMode,PetscScalar*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT SDAGetCorners(SDA,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT SDAGetGhostCorners(SDA,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*); EXTERN PetscErrorCode PETSCDM_DLLEXPORT SDAArrayView(SDA,PetscScalar*,PetscViewer); EXTERN PetscErrorCode PETSCDM_DLLEXPORT MatRegisterDAAD(void); EXTERN PetscErrorCode PETSCDM_DLLEXPORT MatCreateDAAD(DA,Mat*); /*S DALocalInfo - C struct that contains information about a structured grid and a processors logical location in it. Level: beginner Concepts: distributed array Developer note: Then entries in this struct are int instead of PetscInt so that the elements may be extracted in Fortran as if from an integer array .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DADestroy(), DA, DAGetLocalInfo(), DAGetInfo() S*/ typedef struct { PetscInt dim,dof,sw; PetscInt mx,my,mz; /* global number of grid points in each direction */ PetscInt xs,ys,zs; /* starting pointd of this processor, excluding ghosts */ PetscInt xm,ym,zm; /* number of grid points on this processor, excluding ghosts */ PetscInt gxs,gys,gzs; /* starting point of this processor including ghosts */ PetscInt gxm,gym,gzm; /* number of grid points on this processor including ghosts */ DAPeriodicType pt; DAStencilType st; DA da; } DALocalInfo; /*MC DAForEachPointBegin2d - Starts a loop over the local part of a two dimensional DA Synopsis: void DAForEachPointBegin2d(DALocalInfo *info,PetscInt i,PetscInt j); Level: intermediate .seealso: DAForEachPointEnd2d(), DAVecGetArray() M*/ #define DAForEachPointBegin2d(info,i,j) {\ PetscInt _xints = info->xs,_xinte = info->xs+info->xm,_yints = info->ys,_yinte = info->ys+info->ym;\ for (j=_yints; j<_yinte; j++) {\ for (i=_xints; i<_xinte; i++) {\ /*MC DAForEachPointEnd2d - Ends a loop over the local part of a two dimensional DA Synopsis: void DAForEachPointEnd2d; Level: intermediate .seealso: DAForEachPointBegin2d(), DAVecGetArray() M*/ #define DAForEachPointEnd2d }}} /*MC DACoor2d - Structure for holding 2d (x and y) coordinates. Level: intermediate Sample Usage: DACoor2d **coors; Vec vcoors; DA cda; DAGetCoordinates(da,&vcoors); DAGetCoordinateDA(da,&cda); DAVecGetArray(cda,vcoors,&coors); DAGetCorners(cda,&mstart,&nstart,0,&m,&n,0) for (i=mstart; i EXTERN PetscErrorCode PETSC_DLLEXPORT PetscViewerBinaryMatlabOpen(MPI_Comm, const char [], PetscViewer*); EXTERN PetscErrorCode PETSC_DLLEXPORT PetscViewerBinaryMatlabDestroy(PetscViewer); EXTERN PetscErrorCode PETSC_DLLEXPORT PetscViewerBinaryMatlabOutputBag(PetscViewer, const char [], PetscBag); EXTERN PetscErrorCode PETSC_DLLEXPORT PetscViewerBinaryMatlabOutputVec(PetscViewer, const char [], Vec); EXTERN PetscErrorCode PETSC_DLLEXPORT PetscViewerBinaryMatlabOutputVecDA(PetscViewer, const char [], Vec, DA); PETSC_EXTERN_CXX_END #endif