Actual source code: petscdmmoab.h

      1: #pragma once

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

      8: /* MANSEC = DM */
      9: /* SUBMANSEC = DMMOAB */

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

     17: /* The MBERR macro is used to save typing. It checks a MOAB error code
     18:  * (rval) and calls SETERRQ if not MB_SUCCESS. A message (msg) can
     19:  * also be passed in. */
     20: #define MBERR(msg, rval) PetscCheck(rval == moab::MB_SUCCESS, PETSC_COMM_SELF, PETSC_ERR_LIB, "MOAB ERROR (%i): %s", (PetscErrorCode)rval, msg)
     21: #define MBERRNM(rval)    PetscCheck(rval == moab::MB_SUCCESS, PETSC_COMM_SELF, PETSC_ERR_LIB, "MOAB ERROR (%i)", rval)
     22: #define MBERRV(mbif, rval) \
     23:   do { \
     24:     if (rval != moab::MB_SUCCESS) { \
     25:       std::string emsg; \
     26:       mbif->get_last_error(emsg); \
     27:       SETERRQ(PETSC_COMM_SELF, PETSC_ERR_LIB, "MOAB ERROR (%i): %s", (PetscErrorCode)rval, emsg.c_str()); \
     28:     } \
     29:   } while (0)
     30: #define MBERRVM(mbif, msg, rval) \
     31:   do { \
     32:     if (rval != moab::MB_SUCCESS) { \
     33:       std::string emsg; \
     34:       mbif->get_last_error(emsg); \
     35:       SETERRQ(PETSC_COMM_SELF, PETSC_ERR_LIB, "MOAB ERROR (%i): %s :: %s", (PetscErrorCode)rval, msg, emsg.c_str()); \
     36:     } \
     37:   } while (0)

     39: /* define enums for options to read and write MOAB files in parallel */
     40: typedef enum {
     41:   READ_PART,
     42:   READ_DELETE,
     43:   BCAST_DELETE
     44: } MoabReadMode;
     45: static const char *const MoabReadModes[] = {"READ_PART", "READ_DELETE", "BCAST_DELETE", "MoabReadMode", "", 0};
     46: typedef enum {
     47:   WRITE_PART,
     48:   FORMAT
     49: } MoabWriteMode;
     50: static const char *const MoabWriteModes[] = {"WRITE_PART", "FORMAT", "MoabWriteMode", "", 0};

     52: PETSC_EXTERN PetscErrorCode DMMoabCreate(MPI_Comm, DM *);
     53: PETSC_EXTERN PetscErrorCode DMMoabCreateMoab(MPI_Comm, moab::Interface *, moab::Tag *, moab::Range *, DM *);
     54: PETSC_EXTERN PetscErrorCode DMMoabOutput(DM, const char *, const char *);

     56: PETSC_EXTERN PetscErrorCode DMMoabSetInterface(DM, moab::Interface *);
     57: PETSC_EXTERN PetscErrorCode DMMoabGetInterface(DM, moab::Interface **);
     58: #ifdef MOAB_HAVE_MPI
     59: PETSC_EXTERN PetscErrorCode DMMoabGetParallelComm(DM, moab::ParallelComm **);
     60: #endif

     62: PETSC_EXTERN PetscErrorCode DMMoabSetLocalVertices(DM, moab::Range *);
     63: PETSC_EXTERN PetscErrorCode DMMoabGetAllVertices(DM, moab::Range *);
     64: PETSC_EXTERN PetscErrorCode DMMoabGetLocalVertices(DM, const moab::Range **, const moab::Range **);
     65: PETSC_EXTERN PetscErrorCode DMMoabSetLocalElements(DM, moab::Range *);
     66: PETSC_EXTERN PetscErrorCode DMMoabGetLocalElements(DM, const moab::Range **);
     67: PETSC_EXTERN PetscErrorCode DMMoabSetLocalToGlobalTag(DM, moab::Tag);
     68: PETSC_EXTERN PetscErrorCode DMMoabGetLocalToGlobalTag(DM, moab::Tag *);
     69: PETSC_EXTERN PetscErrorCode DMMoabSetBlockSize(DM, PetscInt);
     70: PETSC_EXTERN PetscErrorCode DMMoabGetBlockSize(DM, PetscInt *);
     71: PETSC_EXTERN PetscErrorCode DMMoabSetBlockFills(DM, const PetscInt *, const PetscInt *);
     72: PETSC_EXTERN PetscErrorCode DMMoabGetHierarchyLevel(DM, PetscInt *);

     74: PETSC_EXTERN PetscErrorCode DMMoabGetDimension(DM, PetscInt *);
     75: PETSC_EXTERN PetscErrorCode DMMoabGetBoundaryEntities(DM, moab::Range *, moab::Range *, moab::Range *);
     76: PETSC_EXTERN PetscErrorCode DMMoabGetMaterialBlock(DM, const moab::EntityHandle, PetscInt *);

     78: PETSC_EXTERN PetscErrorCode DMMoabGetSize(DM, PetscInt *, PetscInt *);
     79: PETSC_EXTERN PetscErrorCode DMMoabGetLocalSize(DM, PetscInt *, PetscInt *, PetscInt *, PetscInt *);
     80: PETSC_EXTERN PetscErrorCode DMMoabGetOffset(DM, PetscInt *);

     82: PETSC_EXTERN PetscErrorCode DMMoabVecGetArrayRead(DM, Vec, void *);
     83: PETSC_EXTERN PetscErrorCode DMMoabVecRestoreArrayRead(DM, Vec, void *);
     84: PETSC_EXTERN PetscErrorCode DMMoabVecGetArray(DM, Vec, void *);
     85: PETSC_EXTERN PetscErrorCode DMMoabVecRestoreArray(DM, Vec, void *);

     87: PETSC_EXTERN PetscErrorCode DMMoabCreateVector(DM, moab::Tag, const moab::Range *, PetscBool, PetscBool, Vec *);
     88: PETSC_EXTERN PetscErrorCode DMMoabGetVecTag(Vec, moab::Tag *);
     89: PETSC_EXTERN PetscErrorCode DMMoabGetVecRange(Vec, moab::Range *);

     91: PETSC_EXTERN PetscErrorCode DMMoabSetFieldVector(DM, PetscInt, Vec);
     92: PETSC_EXTERN PetscErrorCode DMMoabSetGlobalFieldVector(DM, Vec);

     94: PETSC_EXTERN PetscErrorCode DMMoabCreateVertices(DM, const PetscReal *, PetscInt, moab::Range *);
     95: PETSC_EXTERN PetscErrorCode DMMoabCreateElement(DM, const moab::EntityType, const moab::EntityHandle *, PetscInt, moab::EntityHandle *);
     96: PETSC_EXTERN PetscErrorCode DMMoabCreateSubmesh(DM, DM *);
     97: PETSC_EXTERN PetscErrorCode DMMoabRenumberMeshEntities(DM);

     99: PETSC_EXTERN PetscErrorCode DMMoabGetFieldName(DM, PetscInt, const char **);
    100: PETSC_EXTERN PetscErrorCode DMMoabSetFieldName(DM, PetscInt, const char *);
    101: PETSC_EXTERN PetscErrorCode DMMoabSetFieldNames(DM, PetscInt, const char *[]);
    102: PETSC_EXTERN PetscErrorCode DMMoabGetFieldDof(DM, moab::EntityHandle, PetscInt, PetscInt *);
    103: PETSC_EXTERN PetscErrorCode DMMoabGetFieldDofs(DM, PetscInt, const moab::EntityHandle *, PetscInt, PetscInt *);
    104: PETSC_EXTERN PetscErrorCode DMMoabGetFieldDofsLocal(DM, PetscInt, const moab::EntityHandle *, PetscInt, PetscInt *);
    105: PETSC_EXTERN PetscErrorCode DMMoabGetDofs(DM, PetscInt, const moab::EntityHandle *, PetscInt *);
    106: PETSC_EXTERN PetscErrorCode DMMoabGetDofsLocal(DM, PetscInt, const moab::EntityHandle *, PetscInt *);
    107: PETSC_EXTERN PetscErrorCode DMMoabGetDofsBlocked(DM, PetscInt, const moab::EntityHandle *, PetscInt *);
    108: PETSC_EXTERN PetscErrorCode DMMoabGetDofsBlockedLocal(DM, PetscInt, const moab::EntityHandle *, PetscInt *);

    110: PETSC_EXTERN PetscErrorCode DMMoabGetVertexDofsBlocked(DM, PetscInt **);
    111: PETSC_EXTERN PetscErrorCode DMMoabGetVertexDofsBlockedLocal(DM, PetscInt **);

    113: /* discretization and assembly specific DMMoab interface functions */
    114: PETSC_EXTERN PetscErrorCode DMMoabGetElementConnectivity(DM, moab::EntityHandle, PetscInt *, const moab::EntityHandle **);
    115: PETSC_EXTERN PetscErrorCode DMMoabGetVertexConnectivity(DM, moab::EntityHandle, PetscInt *, moab::EntityHandle **);
    116: PETSC_EXTERN PetscErrorCode DMMoabRestoreVertexConnectivity(DM, moab::EntityHandle, PetscInt *, moab::EntityHandle **);
    117: PETSC_EXTERN PetscErrorCode DMMoabGetVertexCoordinates(DM, PetscInt, const moab::EntityHandle *, PetscReal *);
    118: PETSC_EXTERN PetscErrorCode DMMoabIsEntityOnBoundary(DM, const moab::EntityHandle, PetscBool *);
    119: PETSC_EXTERN PetscErrorCode DMMoabCheckBoundaryVertices(DM, PetscInt, const moab::EntityHandle *, PetscBool *);
    120: PETSC_EXTERN PetscErrorCode DMMoabGetBoundaryMarkers(DM, const moab::Range **, const moab::Range **, const moab::Range **);

    122: /* TODO: Replace nverts/coords with just moab::EntityHandle -- can also eliminate dim */
    123: /* TODO: Replace quad/npts with PetscDT */
    124: PETSC_EXTERN PetscErrorCode DMMoabFEMCreateQuadratureDefault(const PetscInt, const PetscInt, PetscQuadrature *);
    125: PETSC_EXTERN PetscErrorCode DMMoabFEMComputeBasis(const PetscInt, const PetscInt, const PetscReal *, const PetscQuadrature, PetscReal *, PetscReal *, PetscReal *, PetscReal **);
    126: PETSC_EXTERN PetscErrorCode DMMoabPToRMapping(const PetscInt, const PetscInt, const PetscReal *, const PetscReal *, PetscReal *, PetscReal *);

    128: /* DM utility creation interface */
    129: PETSC_EXTERN PetscErrorCode DMMoabCreateBoxMesh(MPI_Comm, PetscInt, PetscBool, const PetscReal *, PetscInt, PetscInt, DM *);
    130: PETSC_EXTERN PetscErrorCode DMMoabLoadFromFile(MPI_Comm, PetscInt, PetscInt, const char *, const char *, DM *);

    132: /* Uniform refinement hierarchy interface */
    133: PETSC_EXTERN PetscErrorCode DMMoabGenerateHierarchy(DM, PetscInt, PetscInt *);