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: #if defined(__clang__)
     13:   #pragma clang diagnostic push
     14:   #pragma clang diagnostic ignored "-Wunknown-warning-option"
     15:   #pragma clang diagnostic ignored "-Wnontrivial-memcall"
     16: #endif
     17: #include <moab/Core.hpp> /*I      "moab/Core.hpp"    I*/
     18: #if defined(__clang__)
     19:   #pragma clang diagnostic pop
     20: #endif
     21: #ifdef MOAB_HAVE_MPI
     22:   #include <moab/ParallelComm.hpp> /*I      "moab/ParallelComm.hpp"    I*/
     23: #endif

     25: /* The MBERR macro is used to save typing. It checks a MOAB error code
     26:  * (rval) and calls SETERRQ if not MB_SUCCESS. A message (msg) can
     27:  * also be passed in. */
     28: #define MBERR(msg, rval) PetscCheck(rval == moab::MB_SUCCESS, PETSC_COMM_SELF, PETSC_ERR_LIB, "MOAB ERROR (%i): %s", (PetscErrorCode)rval, msg)
     29: #define MBERRNM(rval)    PetscCheck(rval == moab::MB_SUCCESS, PETSC_COMM_SELF, PETSC_ERR_LIB, "MOAB ERROR (%i)", rval)
     30: #define MBERRV(mbif, 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", (PetscErrorCode)rval, emsg.c_str()); \
     36:     } \
     37:   } while (0)
     38: #define MBERRVM(mbif, msg, rval) \
     39:   do { \
     40:     if (rval != moab::MB_SUCCESS) { \
     41:       std::string emsg; \
     42:       mbif->get_last_error(emsg); \
     43:       SETERRQ(PETSC_COMM_SELF, PETSC_ERR_LIB, "MOAB ERROR (%i): %s :: %s", (PetscErrorCode)rval, msg, emsg.c_str()); \
     44:     } \
     45:   } while (0)

     47: /* define enums for options to read and write MOAB files in parallel */
     48: typedef enum {
     49:   READ_PART,
     50:   READ_DELETE,
     51:   BCAST_DELETE
     52: } MoabReadMode;
     53: static const char *const MoabReadModes[] = {"READ_PART", "READ_DELETE", "BCAST_DELETE", "MoabReadMode", "", 0};
     54: typedef enum {
     55:   WRITE_PART,
     56:   FORMAT
     57: } MoabWriteMode;
     58: static const char *const MoabWriteModes[] = {"WRITE_PART", "FORMAT", "MoabWriteMode", "", 0};

     60: PETSC_EXTERN PetscErrorCode DMMoabCreate(MPI_Comm, DM *);
     61: PETSC_EXTERN PetscErrorCode DMMoabCreateMoab(MPI_Comm, moab::Interface *, moab::Tag *, moab::Range *, DM *);
     62: PETSC_EXTERN PetscErrorCode DMMoabOutput(DM, const char *, const char *);

     64: PETSC_EXTERN PetscErrorCode DMMoabSetInterface(DM, moab::Interface *);
     65: PETSC_EXTERN PetscErrorCode DMMoabGetInterface(DM, moab::Interface **);
     66: #ifdef MOAB_HAVE_MPI
     67: PETSC_EXTERN PetscErrorCode DMMoabGetParallelComm(DM, moab::ParallelComm **);
     68: #endif

     70: PETSC_EXTERN PetscErrorCode DMMoabSetLocalVertices(DM, moab::Range *);
     71: PETSC_EXTERN PetscErrorCode DMMoabGetAllVertices(DM, moab::Range *);
     72: PETSC_EXTERN PetscErrorCode DMMoabGetLocalVertices(DM, const moab::Range **, const moab::Range **);
     73: PETSC_EXTERN PetscErrorCode DMMoabSetLocalElements(DM, moab::Range *);
     74: PETSC_EXTERN PetscErrorCode DMMoabGetLocalElements(DM, const moab::Range **);
     75: PETSC_EXTERN PetscErrorCode DMMoabSetLocalToGlobalTag(DM, moab::Tag);
     76: PETSC_EXTERN PetscErrorCode DMMoabGetLocalToGlobalTag(DM, moab::Tag *);
     77: PETSC_EXTERN PetscErrorCode DMMoabSetBlockSize(DM, PetscInt);
     78: PETSC_EXTERN PetscErrorCode DMMoabGetBlockSize(DM, PetscInt *);
     79: PETSC_EXTERN PetscErrorCode DMMoabSetBlockFills(DM, const PetscInt *, const PetscInt *);
     80: PETSC_EXTERN PetscErrorCode DMMoabGetHierarchyLevel(DM, PetscInt *);

     82: PETSC_EXTERN PetscErrorCode DMMoabGetDimension(DM, PetscInt *);
     83: PETSC_EXTERN PetscErrorCode DMMoabGetBoundaryEntities(DM, moab::Range *, moab::Range *, moab::Range *);
     84: PETSC_EXTERN PetscErrorCode DMMoabGetMaterialBlock(DM, const moab::EntityHandle, PetscInt *);

     86: PETSC_EXTERN PetscErrorCode DMMoabGetSize(DM, PetscInt *, PetscInt *);
     87: PETSC_EXTERN PetscErrorCode DMMoabGetLocalSize(DM, PetscInt *, PetscInt *, PetscInt *, PetscInt *);
     88: PETSC_EXTERN PetscErrorCode DMMoabGetOffset(DM, PetscInt *);

     90: PETSC_EXTERN PetscErrorCode DMMoabVecGetArrayRead(DM, Vec, void *);
     91: PETSC_EXTERN PetscErrorCode DMMoabVecRestoreArrayRead(DM, Vec, void *);
     92: PETSC_EXTERN PetscErrorCode DMMoabVecGetArray(DM, Vec, void *);
     93: PETSC_EXTERN PetscErrorCode DMMoabVecRestoreArray(DM, Vec, void *);

     95: PETSC_EXTERN PetscErrorCode DMMoabCreateVector(DM, moab::Tag, const moab::Range *, PetscBool, PetscBool, Vec *);
     96: PETSC_EXTERN PetscErrorCode DMMoabGetVecTag(Vec, moab::Tag *);
     97: PETSC_EXTERN PetscErrorCode DMMoabGetVecRange(Vec, moab::Range *);

     99: PETSC_EXTERN PetscErrorCode DMMoabSetFieldVector(DM, PetscInt, Vec);
    100: PETSC_EXTERN PetscErrorCode DMMoabSetGlobalFieldVector(DM, Vec);

    102: PETSC_EXTERN PetscErrorCode DMMoabCreateVertices(DM, const PetscReal *, PetscInt, moab::Range *);
    103: PETSC_EXTERN PetscErrorCode DMMoabCreateElement(DM, const moab::EntityType, const moab::EntityHandle *, PetscInt, moab::EntityHandle *);
    104: PETSC_EXTERN PetscErrorCode DMMoabCreateSubmesh(DM, DM *);
    105: PETSC_EXTERN PetscErrorCode DMMoabRenumberMeshEntities(DM);

    107: PETSC_EXTERN PetscErrorCode DMMoabGetFieldName(DM, PetscInt, const char **);
    108: PETSC_EXTERN PetscErrorCode DMMoabSetFieldName(DM, PetscInt, const char *);
    109: PETSC_EXTERN PetscErrorCode DMMoabSetFieldNames(DM, PetscInt, const char *[]);
    110: PETSC_EXTERN PetscErrorCode DMMoabGetFieldDof(DM, moab::EntityHandle, PetscInt, PetscInt *);
    111: PETSC_EXTERN PetscErrorCode DMMoabGetFieldDofs(DM, PetscInt, const moab::EntityHandle *, PetscInt, PetscInt *);
    112: PETSC_EXTERN PetscErrorCode DMMoabGetFieldDofsLocal(DM, PetscInt, const moab::EntityHandle *, PetscInt, PetscInt *);
    113: PETSC_EXTERN PetscErrorCode DMMoabGetDofs(DM, PetscInt, const moab::EntityHandle *, PetscInt *);
    114: PETSC_EXTERN PetscErrorCode DMMoabGetDofsLocal(DM, PetscInt, const moab::EntityHandle *, PetscInt *);
    115: PETSC_EXTERN PetscErrorCode DMMoabGetDofsBlocked(DM, PetscInt, const moab::EntityHandle *, PetscInt *);
    116: PETSC_EXTERN PetscErrorCode DMMoabGetDofsBlockedLocal(DM, PetscInt, const moab::EntityHandle *, PetscInt *);

    118: PETSC_EXTERN PetscErrorCode DMMoabGetVertexDofsBlocked(DM, PetscInt **);
    119: PETSC_EXTERN PetscErrorCode DMMoabGetVertexDofsBlockedLocal(DM, PetscInt **);

    121: /* discretization and assembly specific DMMoab interface functions */
    122: PETSC_EXTERN PetscErrorCode DMMoabGetElementConnectivity(DM, moab::EntityHandle, PetscInt *, const moab::EntityHandle **);
    123: PETSC_EXTERN PetscErrorCode DMMoabGetVertexConnectivity(DM, moab::EntityHandle, PetscInt *, moab::EntityHandle **);
    124: PETSC_EXTERN PetscErrorCode DMMoabRestoreVertexConnectivity(DM, moab::EntityHandle, PetscInt *, moab::EntityHandle **);
    125: PETSC_EXTERN PetscErrorCode DMMoabGetVertexCoordinates(DM, PetscInt, const moab::EntityHandle *, PetscReal *);
    126: PETSC_EXTERN PetscErrorCode DMMoabIsEntityOnBoundary(DM, const moab::EntityHandle, PetscBool *);
    127: PETSC_EXTERN PetscErrorCode DMMoabCheckBoundaryVertices(DM, PetscInt, const moab::EntityHandle *, PetscBool *);
    128: PETSC_EXTERN PetscErrorCode DMMoabGetBoundaryMarkers(DM, const moab::Range **, const moab::Range **, const moab::Range **);

    130: /* TODO: Replace nverts/coords with just moab::EntityHandle -- can also eliminate dim */
    131: /* TODO: Replace quad/npts with PetscDT */
    132: PETSC_EXTERN PetscErrorCode DMMoabFEMCreateQuadratureDefault(const PetscInt, const PetscInt, PetscQuadrature *);
    133: PETSC_EXTERN PetscErrorCode DMMoabFEMComputeBasis(const PetscInt, const PetscInt, const PetscReal *, const PetscQuadrature, PetscReal *, PetscReal *, PetscReal *, PetscReal **);
    134: PETSC_EXTERN PetscErrorCode DMMoabPToRMapping(const PetscInt, const PetscInt, const PetscReal *, const PetscReal *, PetscReal *, PetscReal *);

    136: /* DM utility creation interface */
    137: PETSC_EXTERN PetscErrorCode DMMoabCreateBoxMesh(MPI_Comm, PetscInt, PetscBool, const PetscReal *, PetscInt, PetscInt, DM *);
    138: PETSC_EXTERN PetscErrorCode DMMoabLoadFromFile(MPI_Comm, PetscInt, PetscInt, const char *, const char *, DM *);

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