Date: 2022-08-02T03:14:13+00:00

Actual source code: petscdmmoab.h

      1: #if !defined(PETSCMOAB_H)
      2: #define PETSCMOAB_H

      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. */
     20: #define MBERRV(mbif,rval) do{if (rval != moab::MB_SUCCESS) { std::string emsg; mbif->get_last_error(emsg); SETERRQ(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); SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"MOAB ERROR (%i): %s :: %s",(PetscErrorCode)rval,msg,emsg.c_str());} } while (0)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    112: #endif