Actual source code: petscdmmoab.h

petsc-3.9.4 2018-09-11
Report Typos and Errors

  4:  #include <petscvec.h>
  5:  #include <petscmat.h>
  6:  #include <petscdm.h>
  7:  #include <petscdt.h>

  9: #include <string>
 10: #include <moab/Core.hpp> /*I      "moab/Core.hpp"    I*/
 11: #ifdef MOAB_HAVE_MPI
 12: #include <moab/ParallelComm.hpp> /*I      "moab/ParallelComm.hpp"    I*/
 13: #endif

 15: /* The MBERR macro is used to save typing. It checks a MOAB error code
 16:  * (rval) and calls SETERRQ if not MB_SUCCESS. A message (msg) can
 17:  * also be passed in. */
 18: #define MBERR(msg,rval) do{if(rval != moab::MB_SUCCESS) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_LIB,"MOAB ERROR (%i): %s",(PetscErrorCode)rval,msg);} while(0)
 19: #define MBERRNM(rval) do{if(rval != moab::MB_SUCCESS) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB,"MOAB ERROR (%i)",rval);} while(0)
 20: #define MBERRV(mbif,rval) do{if(rval != moab::MB_SUCCESS) { std::string emsg; mbif->get_last_error(emsg); SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_LIB,"MOAB ERROR (%i): %s",(PetscErrorCode)rval,emsg.c_str());} } while(0)
 21: #define MBERRVM(mbif,msg,rval) do{if(rval != moab::MB_SUCCESS) { std::string emsg; mbif->get_last_error(emsg); SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_LIB,"MOAB ERROR (%i): %s :: %s",(PetscErrorCode)rval,msg,emsg.c_str());} } while(0)


 24: /* define enums for options to read and write MOAB files in parallel */
 25: typedef enum {READ_PART, READ_DELETE, BCAST_DELETE} MoabReadMode;
 26: static const char *const MoabReadModes[] = {"READ_PART", "READ_DELETE", "BCAST_DELETE", "MoabReadMode", "", 0};
 27: typedef enum {WRITE_PART, FORMAT} MoabWriteMode;
 28: static const char *const MoabWriteModes[] = {"WRITE_PART", "FORMAT", "MoabWriteMode", "", 0};

 30: PETSC_EXTERN PetscErrorCode DMMoabCreate(MPI_Comm comm, DM *moab);
 31: PETSC_EXTERN PetscErrorCode DMMoabCreateMoab(MPI_Comm comm, moab::Interface *mbiface, moab::Tag *ltog_tag, moab::Range *range, DM *moab);
 32: PETSC_EXTERN PetscErrorCode DMMoabOutput(DM, const char*, const char*);

 34: PETSC_EXTERN PetscErrorCode DMMoabSetInterface(DM, moab::Interface *);
 35: PETSC_EXTERN PetscErrorCode DMMoabGetInterface(DM, moab::Interface **);
 36: #ifdef MOAB_HAVE_MPI
 37: PETSC_EXTERN PetscErrorCode DMMoabGetParallelComm(DM, moab::ParallelComm**);
 38: #endif

 40: PETSC_EXTERN PetscErrorCode DMMoabSetLocalVertices(DM, moab::Range *);
 41: PETSC_EXTERN PetscErrorCode DMMoabGetAllVertices(DM, moab::Range *local);
 42: PETSC_EXTERN PetscErrorCode DMMoabGetLocalVertices(DM, const moab::Range**, const moab::Range**);
 43: PETSC_EXTERN PetscErrorCode DMMoabSetLocalElements(DM, moab::Range*);
 44: PETSC_EXTERN PetscErrorCode DMMoabGetLocalElements(DM, const moab::Range**);
 45: PETSC_EXTERN PetscErrorCode DMMoabSetLocalToGlobalTag(DM, moab::Tag);
 46: PETSC_EXTERN PetscErrorCode DMMoabGetLocalToGlobalTag(DM, moab::Tag*);
 47: PETSC_EXTERN PetscErrorCode DMMoabSetBlockSize(DM, PetscInt bs);
 48: PETSC_EXTERN PetscErrorCode DMMoabGetBlockSize(DM, PetscInt *bs);
 49: PETSC_EXTERN PetscErrorCode DMMoabSetBlockFills(DM, const PetscInt*, const PetscInt*);
 50: PETSC_EXTERN PetscErrorCode DMMoabGetHierarchyLevel(DM, PetscInt *);

 52: PETSC_EXTERN PetscErrorCode DMMoabGetDimension(DM dm, PetscInt *dim);
 53: PETSC_EXTERN PetscErrorCode DMMoabGetBoundaryEntities(DM dm, moab::Range*, moab::Range*, moab::Range*);
 54: PETSC_EXTERN PetscErrorCode DMMoabGetMaterialBlock(DM dm, const moab::EntityHandle, PetscInt*);

 56: PETSC_EXTERN PetscErrorCode DMMoabGetSize(DM dm, PetscInt*, PetscInt*);
 57: PETSC_EXTERN PetscErrorCode DMMoabGetLocalSize(DM dm, PetscInt*, PetscInt*, PetscInt*, PetscInt*);
 58: PETSC_EXTERN PetscErrorCode DMMoabGetOffset(DM dm, PetscInt*);

 60: PETSC_EXTERN PetscErrorCode DMMoabVecGetArrayRead(DM, Vec, void*);
 61: PETSC_EXTERN PetscErrorCode DMMoabVecRestoreArrayRead(DM, Vec, void*);
 62: PETSC_EXTERN PetscErrorCode DMMoabVecGetArray(DM, Vec, void*);
 63: PETSC_EXTERN PetscErrorCode DMMoabVecRestoreArray(DM, Vec, void*);

 65: PETSC_EXTERN PetscErrorCode DMMoabCreateVector(DM dm, moab::Tag tag, const moab::Range *range, PetscBool serial, PetscBool destroy_tag, Vec *X);
 66: PETSC_EXTERN PetscErrorCode DMMoabGetVecTag(Vec vec, moab::Tag *tag);
 67: PETSC_EXTERN PetscErrorCode DMMoabGetVecRange(Vec vec, moab::Range *range);

 69: PETSC_EXTERN PetscErrorCode DMMoabSetFieldVector(DM, PetscInt, Vec);
 70: PETSC_EXTERN PetscErrorCode DMMoabSetGlobalFieldVector(DM, Vec);

 72: PETSC_EXTERN PetscErrorCode DMMoabCreateVertices(DM, const PetscReal* coords, PetscInt nverts, moab::Range*);
 73: PETSC_EXTERN PetscErrorCode DMMoabCreateElement(DM, const moab::EntityType type, const moab::EntityHandle* conn, PetscInt nverts, moab::EntityHandle* elem);
 74: PETSC_EXTERN PetscErrorCode DMMoabCreateSubmesh(DM dm, DM *newdm);
 75: PETSC_EXTERN PetscErrorCode DMMoabRenumberMeshEntities(DM dm);

 77: PETSC_EXTERN PetscErrorCode DMMoabGetFieldName(DM dm, PetscInt field, const char **fieldName);
 78: PETSC_EXTERN PetscErrorCode DMMoabSetFieldName(DM dm, PetscInt field, const char *fieldName);
 79: PETSC_EXTERN PetscErrorCode DMMoabSetFieldNames(DM dm, PetscInt nfields, const char* fields[]);
 80: PETSC_EXTERN PetscErrorCode DMMoabGetFieldDof(DM dm, moab::EntityHandle point, PetscInt field, PetscInt* dof);
 81: PETSC_EXTERN PetscErrorCode DMMoabGetFieldDofs(DM dm, PetscInt npoints, const moab::EntityHandle* points, PetscInt field, PetscInt* dof);
 82: PETSC_EXTERN PetscErrorCode DMMoabGetFieldDofsLocal(DM dm, PetscInt npoints, const moab::EntityHandle* points, PetscInt field, PetscInt* dof);
 83: PETSC_EXTERN PetscErrorCode DMMoabGetDofs(DM dm, PetscInt npoints, const moab::EntityHandle* points, PetscInt* dof);
 84: PETSC_EXTERN PetscErrorCode DMMoabGetDofsLocal(DM dm, PetscInt npoints, const moab::EntityHandle* points, PetscInt* dof);
 85: PETSC_EXTERN PetscErrorCode DMMoabGetDofsBlocked(DM dm, PetscInt npoints, const moab::EntityHandle* points, PetscInt* dof);
 86: PETSC_EXTERN PetscErrorCode DMMoabGetDofsBlockedLocal(DM dm, PetscInt npoints, const moab::EntityHandle* points, PetscInt* dof);

 88: PETSC_EXTERN PetscErrorCode DMMoabGetVertexDofsBlocked(DM dm, PetscInt** dof);
 89: PETSC_EXTERN PetscErrorCode DMMoabGetVertexDofsBlockedLocal(DM dm, PetscInt** dof);

 91: /* discretization and assembly specific DMMoab interface functions */
 92: PETSC_EXTERN PetscErrorCode DMMoabGetElementConnectivity(DM dm, moab::EntityHandle ehandle, PetscInt* nconn, const moab::EntityHandle **conn);
 93: PETSC_EXTERN PetscErrorCode DMMoabGetVertexConnectivity(DM dm, moab::EntityHandle ehandle, PetscInt* nconn, moab::EntityHandle **conn);
 94: PETSC_EXTERN PetscErrorCode DMMoabRestoreVertexConnectivity(DM dm, moab::EntityHandle ehandle, PetscInt* nconn, moab::EntityHandle **conn);
 95: PETSC_EXTERN PetscErrorCode DMMoabGetVertexCoordinates(DM dm, PetscInt nconn, const moab::EntityHandle *conn, PetscReal *vpos);
 96: PETSC_EXTERN PetscErrorCode DMMoabIsEntityOnBoundary(DM dm, const moab::EntityHandle ent, PetscBool* ent_on_boundary);
 97: PETSC_EXTERN PetscErrorCode DMMoabCheckBoundaryVertices(DM dm, PetscInt nconn, const moab::EntityHandle *cnt, PetscBool* isbdvtx);
 98: PETSC_EXTERN PetscErrorCode DMMoabGetBoundaryMarkers(DM dm, const moab::Range **bdvtx, const moab::Range** bdelems, const moab::Range** bdfaces);

100: /* TODO: Replace nverts/coords with just moab::EntityHandle -- can also eliminate dim */
101: /* TODO: Replace quad/npts with PetscDT */
102: PETSC_EXTERN PetscErrorCode DMMoabFEMCreateQuadratureDefault ( const PetscInt dim, const PetscInt nverts, PetscQuadrature *quadrature );
103: PETSC_EXTERN PetscErrorCode DMMoabFEMComputeBasis ( const PetscInt dim, const PetscInt nverts, const PetscReal *coordinates, const PetscQuadrature quadrature, PetscReal *phypts, PetscReal *jxw, PetscReal *phi, PetscReal **dphi);
104: PETSC_EXTERN PetscErrorCode DMMoabPToRMapping ( const PetscInt dim, const PetscInt nverts, const PetscReal *coordinates, const PetscReal* xphy, PetscReal* natparam, PetscReal* phi);

106: /* DM utility creation interface */
107: PETSC_EXTERN PetscErrorCode DMMoabCreateBoxMesh(MPI_Comm, PetscInt, PetscBool, const PetscReal*, PetscInt, PetscInt, DM*);
108: PETSC_EXTERN PetscErrorCode DMMoabLoadFromFile(MPI_Comm, PetscInt, PetscInt, const char*, const char*, DM*);

110: /* Uniform refinement hierarchy interface */
111: PETSC_EXTERN PetscErrorCode DMMoabGenerateHierarchy(DM dm, PetscInt nlevels, PetscInt *ldegrees);

113: #endif