Actual source code: petscdmnetwork.h

      1: /*
      2:   DMNetwork, for parallel unstructured network problems.
      3: */
      4: #pragma once

      6: #include <petscdmplex.h>
      7: #include <petscviewer.h>

      9: /* SUBMANSEC = DMNetwork */

     11: #define ALL_COMPONENTS -1

     13: /*
     14:   DMNetworkComponentGenericDataType - This is the data type that PETSc uses for storing the component data.
     15:             For compatibility with PetscSF, which is used for data distribution, its declared as PetscInt.
     16:             To get the user-specific data type, one needs to cast it to the appropriate type.
     17: */
     18: typedef PetscInt DMNetworkComponentGenericDataType;

     20: PETSC_EXTERN PetscErrorCode DMNetworkCreate(MPI_Comm, DM *);
     21: PETSC_EXTERN PetscErrorCode DMNetworkSetNumSubNetworks(DM, PetscInt, PetscInt);
     22: PETSC_EXTERN PetscErrorCode DMNetworkGetNumSubNetworks(DM, PetscInt *, PetscInt *);
     23: PETSC_EXTERN PetscErrorCode DMNetworkLayoutSetUp(DM);
     24: PETSC_EXTERN PetscErrorCode DMNetworkRegisterComponent(DM, const char *, size_t, PetscInt *);
     25: PETSC_EXTERN PetscErrorCode DMNetworkGetVertexRange(DM, PetscInt *, PetscInt *);
     26: PETSC_EXTERN PetscErrorCode DMNetworkGetEdgeRange(DM, PetscInt *, PetscInt *);
     27: PETSC_EXTERN PetscErrorCode DMNetworkGetNumEdges(DM, PetscInt *, PetscInt *);
     28: PETSC_EXTERN PetscErrorCode DMNetworkGetNumVertices(DM, PetscInt *, PetscInt *);

     30: PETSC_EXTERN PetscErrorCode DMNetworkAddComponent(DM, PetscInt, PetscInt, void *, PetscInt);
     31: PETSC_EXTERN PetscErrorCode DMNetworkGetComponent(DM, PetscInt, PetscInt, PetscInt *, void **, PetscInt *);
     32: PETSC_EXTERN PetscErrorCode DMNetworkFinalizeComponents(DM);
     33: PETSC_EXTERN PetscErrorCode DMNetworkGetNumComponents(DM, PetscInt, PetscInt *);
     34: PETSC_EXTERN PetscErrorCode DMNetworkGetLocalVecOffset(DM, PetscInt, PetscInt, PetscInt *);
     35: PETSC_EXTERN PetscErrorCode DMNetworkGetGlobalVecOffset(DM, PetscInt, PetscInt, PetscInt *);

     37: PETSC_EXTERN PetscErrorCode DMNetworkGetEdgeOffset(DM, PetscInt, PetscInt *);
     38: PETSC_EXTERN PetscErrorCode DMNetworkGetVertexOffset(DM, PetscInt, PetscInt *);

     40: PETSC_EXTERN PetscErrorCode DMNetworkAssembleGraphStructures(DM);
     41: PETSC_EXTERN PetscErrorCode DMNetworkSetVertexLocalToGlobalOrdering(DM);
     42: PETSC_EXTERN PetscErrorCode DMNetworkGetVertexLocalToGlobalOrdering(DM, PetscInt, PetscInt *);
     43: PETSC_EXTERN PetscErrorCode PetscSFGetSubSF(PetscSF, ISLocalToGlobalMapping, PetscSF *);
     44: PETSC_EXTERN PetscErrorCode DMNetworkDistribute(DM *, PetscInt);
     45: PETSC_EXTERN PetscErrorCode DMNetworkGetSupportingEdges(DM, PetscInt, PetscInt *, const PetscInt *[]);
     46: PETSC_EXTERN PetscErrorCode DMNetworkGetConnectedVertices(DM, PetscInt, const PetscInt *[]);
     47: PETSC_EXTERN PetscErrorCode DMNetworkIsGhostVertex(DM, PetscInt, PetscBool *);
     48: PETSC_EXTERN PetscErrorCode DMNetworkIsSharedVertex(DM, PetscInt, PetscBool *);
     49: PETSC_EXTERN PetscErrorCode DMNetworkEdgeSetMatrix(DM, PetscInt, Mat[]);
     50: PETSC_EXTERN PetscErrorCode DMNetworkVertexSetMatrix(DM, PetscInt, Mat[]);
     51: PETSC_EXTERN PetscErrorCode DMNetworkHasJacobian(DM, PetscBool, PetscBool);
     52: PETSC_EXTERN PetscErrorCode DMNetworkGetPlex(DM, DM *);
     53: PETSC_EXTERN PetscErrorCode DMNetworkGetGlobalEdgeIndex(DM, PetscInt, PetscInt *);
     54: PETSC_EXTERN PetscErrorCode DMNetworkGetGlobalVertexIndex(DM, PetscInt, PetscInt *);

     56: PETSC_EXTERN PetscErrorCode DMNetworkAddSubnetwork(DM, const char *, PetscInt, PetscInt[], PetscInt *);
     57: PETSC_EXTERN PetscErrorCode DMNetworkGetSubnetwork(DM, PetscInt, PetscInt *, PetscInt *, const PetscInt **, const PetscInt **);
     58: PETSC_EXTERN PetscErrorCode DMNetworkAddSharedVertices(DM, PetscInt, PetscInt, PetscInt, PetscInt[], PetscInt[]);
     59: PETSC_EXTERN PetscErrorCode DMNetworkGetSharedVertices(DM, PetscInt *, const PetscInt **);
     60: PETSC_EXTERN PetscErrorCode DMNetworkSharedVertexGetInfo(DM, PetscInt, PetscInt *, PetscInt *, const PetscInt **);
     61: PETSC_EXTERN PetscErrorCode DMNetworkCreateIS(DM, PetscInt, PetscInt[], PetscInt[], PetscInt[], PetscInt *[], IS *);
     62: PETSC_EXTERN PetscErrorCode DMNetworkCreateLocalIS(DM, PetscInt, PetscInt[], PetscInt[], PetscInt[], PetscInt *[], IS *);

     64: typedef struct _p_DMNetworkMonitorList *DMNetworkMonitorList;
     65: struct _p_DMNetworkMonitorList {
     66:   PetscViewer          viewer;
     67:   Vec                  v;
     68:   PetscInt             element;
     69:   PetscInt             nodes;
     70:   PetscInt             start;
     71:   PetscInt             blocksize;
     72:   DMNetworkMonitorList next;
     73: };

     75: typedef struct _p_DMNetworkMonitor *DMNetworkMonitor;
     76: struct _p_DMNetworkMonitor {
     77:   MPI_Comm             comm;
     78:   DM                   network;
     79:   DMNetworkMonitorList firstnode;
     80: };

     82: PETSC_EXTERN PetscErrorCode DMNetworkMonitorCreate(DM, DMNetworkMonitor *);
     83: PETSC_EXTERN PetscErrorCode DMNetworkMonitorDestroy(DMNetworkMonitor *);
     84: PETSC_EXTERN PetscErrorCode DMNetworkMonitorPop(DMNetworkMonitor);
     85: PETSC_EXTERN PetscErrorCode DMNetworkMonitorAdd(DMNetworkMonitor, const char *, PetscInt, PetscInt, PetscInt, PetscInt, PetscReal, PetscReal, PetscReal, PetscReal, PetscBool);
     86: PETSC_EXTERN PetscErrorCode DMNetworkMonitorView(DMNetworkMonitor, Vec);

     88: PETSC_EXTERN PetscErrorCode DMNetworkViewSetShowRanks(DM, PetscBool);
     89: PETSC_EXTERN PetscErrorCode DMNetworkViewSetViewRanks(DM, IS);
     90: PETSC_EXTERN PetscErrorCode DMNetworkViewSetShowGlobal(DM, PetscBool);
     91: PETSC_EXTERN PetscErrorCode DMNetworkViewSetShowVertices(DM, PetscBool);
     92: PETSC_EXTERN PetscErrorCode DMNetworkViewSetShowNumbering(DM, PetscBool);