Actual source code: dmnetworkimpl.h

petsc-master 2020-05-26
Report Typos and Errors
  1: #if !defined(_NETWORKIMPL_H)
  2: #define _NETWORKIMPL_H

  4:  #include <petscmat.h>
  5:  #include <petscdmnetwork.h>
  6:  #include <petsc/private/dmpleximpl.h>

  8: #define MAX_DATA_AT_POINT 36

 10: #define MAX_COMPONENTS 16

 12: typedef struct _p_DMNetworkComponentHeader *DMNetworkComponentHeader;
 13: struct _p_DMNetworkComponentHeader {
 14:   PetscInt index;    /* index for user input global edge and vertex */
 15:   PetscInt subnetid; /* Id for subnetwork */
 16:   PetscInt ndata;
 17:   PetscInt size[MAX_DATA_AT_POINT];
 18:   PetscInt key[MAX_DATA_AT_POINT];
 19:   PetscInt offset[MAX_DATA_AT_POINT];
 20:   PetscInt nvar[MAX_DATA_AT_POINT]; /* Number of variables */
 21:   PetscInt offsetvarrel[MAX_DATA_AT_POINT]; /* offset from the first variable of the network point */
 22: } PETSC_ATTRIBUTEALIGNED(sizeof(PetscScalar));

 24: typedef struct _p_DMNetworkComponentValue *DMNetworkComponentValue;
 25: struct _p_DMNetworkComponentValue {
 26:   void* data[MAX_DATA_AT_POINT];
 27: } PETSC_ATTRIBUTEALIGNED(sizeof(PetscScalar));

 29: typedef struct {
 30:   char     name[32-sizeof(PetscInt)];
 31:   PetscInt size;
 32: } DMNetworkComponent PETSC_ATTRIBUTEALIGNED(sizeof(PetscScalar));


 35: /* Indexing data structures for vertex and edges */
 36: typedef struct {
 37:   PetscSection                      DofSection;
 38:   PetscSection                      GlobalDofSection;
 39:   ISLocalToGlobalMapping            mapping;
 40:   PetscSF                           sf;
 41: } DMNetworkVertexInfo;

 43: typedef struct {
 44:   PetscSection                      DofSection;
 45:   PetscSection                      GlobalDofSection;
 46:   ISLocalToGlobalMapping            mapping;
 47:   PetscSF                           sf;
 48: } DMNetworkEdgeInfo;

 50: typedef struct {
 51:   PetscInt  Nvtx, nvtx;     /* Number of global/local vertices */
 52:   PetscInt  Nedge,nedge;    /* Number of global/local edges */
 53:   PetscInt  eStart, eEnd;   /* Range of edge numbers (start, end+1) */
 54:   PetscInt  vStart, vEnd;   /* Range of vertex numbers (start, end+1) */
 55:   PetscInt  *edgelist;      /* User provided list of edges. Each edge has the format [from to] where from and to are the vertices covering the edge */
 56:   PetscInt  *vertices;      /* Vertices for this subnetwork. These are mapped to the vertex numbers for the whole network */
 57:   PetscInt  *edges;         /* Edges for this subnetwork. These are mapped to the edge numbers for the whole network */
 58: } DMSubnetwork;

 60: typedef struct {
 61:   PetscInt                          refct;       /* reference count */
 62:   PetscInt                          NEdges,nEdges;        /* Number of global/local edges */
 63:   PetscInt                          NVertices,nVertices; /* Number of global/local vertices */
 64:   PetscInt                          pStart,pEnd; /* Start and end indices for topological points */
 65:   PetscInt                          vStart,vEnd; /* Start and end indices for vertices */
 66:   PetscInt                          eStart,eEnd; /* Start and end indices for edges */
 67:   DM                                plex;        /* DM created from Plex */
 68:   PetscSection                      DataSection; /* Section for managing parameter distribution */
 69:   PetscSection                      DofSection;  /* Section for managing data distribution */
 70:   PetscSection                      GlobalDofSection; /* Global Dof section */
 71:   PetscBool                         distributecalled; /* Flag if DMNetworkDistribute() is called */
 72:   PetscInt                          *vltog;           /* Maps vertex local ordering to global ordering, include ghost vertices */

 74:   DMNetworkVertexInfo               vertex;
 75:   DMNetworkEdgeInfo                 edge;

 77:   PetscInt                          ncomponent; /* Number of components */
 78:   DMNetworkComponent                component[MAX_COMPONENTS]; /* List of components */
 79:   DMNetworkComponentHeader          header;
 80:   DMNetworkComponentValue           cvalue;
 81:   PetscInt                          dataheadersize;
 82:   DMNetworkComponentGenericDataType *componentdataarray; /* Array to hold the data */

 84:   PetscInt                          nsubnet;  /* Global number of subnetworks, including coupling subnetworks */
 85:   PetscInt                          ncsubnet; /* Global number of coupling subnetworks */
 86:   DMSubnetwork                      *subnet;  /* Subnetworks */
 87:   PetscInt                          *subnetvtx; /* Maps local vertex to local subnetwork's vertex */

 89:   PetscBool                         userEdgeJacobian,userVertexJacobian;  /* Global flag for using user's sub Jacobians */
 90:   Mat                               *Je;  /* Pointer array to hold local sub Jacobians for edges, 3 elements for an edge */
 91:   Mat                               *Jv;  /* Pointer array to hold local sub Jacobians for vertices, 1+2*nsupportedges for a vertex */
 92:   PetscInt                          *Jvptr;   /* index of Jv for v-th vertex
 93:                                               Jvpt[v-vStart]:    Jacobian(v,v)
 94:                                               Jvpt[v-vStart]+2i+1: Jacobian(v,e[i]),   e[i]: i-th supporting edge
 95:                                               Jvpt[v-vStart]+2i+2: Jacobian(v,vc[i]), vc[i]: i-th connected vertex
 96:                                               */
 97: } DM_Network;

 99: #endif /* _NETWORKIMPL_H */