Actual source code: dmnetworkimpl.h

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

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

  9: typedef struct _p_DMNetworkComponentHeader *DMNetworkComponentHeader;
 10: struct _p_DMNetworkComponentHeader {
 11:   PetscInt index;    /* index for user input global edge and vertex */
 12:   PetscInt subnetid; /* Id for subnetwork */
 13:   PetscInt ndata;    /* number of components */
 14:   PetscInt hsize;    /* Size of the header */
 15:   PetscInt maxcomps; /* Maximum components at this point (ndata <= maxcomps). maxcomps
 16:                         is set initially to a default value and is incremented every time
 17:                         ndata exceeds maxcomps */
 18:   /* The following arrays store the different attributes for each component at the given point.
 19:      The length of these arrays equals maxcomps. The arrays are resized every time
 20:      ndata exceeds maxcomps
 21:   */
 22:   PetscInt *size;    /* component data struct sizes */
 23:   PetscInt *key;     /* component keys */
 24:   PetscInt *offset;  /* component offset in the vector */
 25:   PetscInt *nvar;    /* number of variabes for the component */
 26:   PetscInt *offsetvarrel; /* relative offset from the first component at this point */
 27: } PETSC_ATTRIBUTEALIGNED(PetscMax(sizeof(double),sizeof(PetscScalar)));

 29: typedef struct _p_DMNetworkComponentValue *DMNetworkComponentValue;
 30: struct _p_DMNetworkComponentValue {
 31:   void* *data;
 32: } PETSC_ATTRIBUTEALIGNED(PetscMax(sizeof(double),sizeof(PetscScalar)));

 34: typedef struct {
 35:   char     name[32-sizeof(PetscInt)];
 36:   PetscInt size;
 37: } DMNetworkComponent PETSC_ATTRIBUTEALIGNED(PetscMax(sizeof(double),sizeof(PetscScalar)));

 39: /* Indexing data structures for vertex and edges */
 40: typedef struct {
 41:   PetscSection                      DofSection;
 42:   PetscSection                      GlobalDofSection;
 43:   ISLocalToGlobalMapping            mapping;
 44:   PetscSF                           sf;
 45: } DMNetworkVertexInfo;

 47: typedef struct {
 48:   PetscSection                      DofSection;
 49:   PetscSection                      GlobalDofSection;
 50:   ISLocalToGlobalMapping            mapping;
 51:   PetscSF                           sf;
 52: } DMNetworkEdgeInfo;

 54: /*
 55:   Shared vertex - a vertex in DMNetwork that is shared by 2 or more subnetworks. sv provides the mapping from the subnetwork vertices to the global DMNetwork vertex (merged network).
 56:   sv is organized as (see SVtxCreate())
 57:         sv(net[0],idx[0]) --> sv(net[1],idx[1])
 58:                           --> sv(net[1],idx[1])
 59:                           ...
 60:                           --> sv(net[n-1],idx[n-1])
 61:         and net[0] < net[1] < ... < net[n-1]
 62:         where sv[0] has SVFROM type, sv[i], i>0, has SVTO type.
 63: */
 64: typedef struct {
 65:   PetscInt gidx;                /* global index of the shared vertices in dmplex */
 66:   PetscInt n;                   /* number of subnetworks that share the common DMNetwork vertex */
 67:   PetscInt *sv;                 /* array of size n: sv[2*i,2*i+1]=(net[i], idx[i]), i=0,...,n-1 */
 68: } SVtx;
 69: typedef enum {SVNONE=-1, SVFROM=0, SVTO=1} SVtxType;

 71: typedef struct {
 72:   PetscInt  Nvtx, nvtx;     /* Number of global/local vertices */
 73:   PetscInt  Nedge,nedge;    /* Number of global/local edges */
 74:   PetscInt  eStart, eEnd;   /* Range of edge numbers (start, end+1) */
 75:   PetscInt  vStart, vEnd;   /* Range of vertex numbers (start, end+1) */
 76:   PetscInt  *edgelist;      /* User provided list of edges. Each edge has the format [from to] where from and to are the vertices covering the edge in the subnet numbering */
 77:   PetscInt  *vertices;      /* Vertices for this subnetwork. These are mapped to the vertex numbers for the whole network */
 78:   PetscInt  *edges;         /* Edges for this subnetwork. These are mapped to the edge numbers for the whole network */
 79:   char      name[32-sizeof(PetscInt)];
 80: } DMSubnetwork;

 82: typedef struct {
 83:   PetscInt                          refct;               /* reference count */
 84:   PetscInt                          NEdges,nEdges;       /* Number of global/local edges */
 85:   PetscInt                          NVertices,nVertices; /* Number of global/local vertices */
 86:   PetscInt                          pStart,pEnd;         /* Start and end indices for topological points */
 87:   PetscInt                          vStart,vEnd;         /* Start and end indices for vertices */
 88:   PetscInt                          eStart,eEnd;         /* Start and end indices for edges */
 89:   DM                                plex;                /* DM created from Plex */
 90:   PetscSection                      DataSection;         /* Section for managing parameter distribution */
 91:   PetscSection                      DofSection;          /* Section for managing data distribution */
 92:   PetscSection                      GlobalDofSection;    /* Global Dof section */
 93:   PetscBool                         distributecalled;    /* Flag if DMNetworkDistribute() is called */
 94:   PetscInt                          *vltog;              /* Maps vertex local ordering to global ordering, include ghost vertices */

 96:   DMNetworkVertexInfo               vertex;
 97:   DMNetworkEdgeInfo                 edge;

 99:   PetscInt                          ncomponent;  /* Number of components that have been registered */
100:   DMNetworkComponent                *component; /* List of components that have been registered */
101:   DMNetworkComponentHeader          header;
102:   DMNetworkComponentValue           cvalue;
103:   DMNetworkComponentGenericDataType *componentdataarray; /* Array to hold the data */

105:   PetscInt                          nsubnet,Nsubnet; /* Local and global number of subnetworks */
106:   DMSubnetwork                      *subnet;         /* Subnetworks */
107:   PetscInt                          *subnetvtx,*subnetedge; /* Maps local vertex/edge to local subnetwork's vertex/edge */
108:   SVtx                              *svtx;           /* Array of vertices shared by subnetworks */
109:   PetscInt                          nsvtx,Nsvtx;     /* Local and global num of entries in svtx */
110:   PetscInt                          *svertices;      /* Array of local subnetwork vertices that are merged/shared */
111:   PetscInt                          *sedgelist;      /* Edge list of shared vertices */
112:   PetscTable                        svtable;         /* hash table for finding shared vertex info */

114:   PetscBool                         userEdgeJacobian,userVertexJacobian;  /* Global flag for using user's sub Jacobians */
115:   Mat                               *Je;  /* Pointer array to hold local sub Jacobians for edges, 3 elements for an edge */
116:   Mat                               *Jv;  /* Pointer array to hold local sub Jacobians for vertices, 1+2*nsupportedges for a vertex */
117:   PetscInt                          *Jvptr;   /* index of Jv for v-th vertex
118:                                               Jvpt[v-vStart]:    Jacobian(v,v)
119:                                               Jvpt[v-vStart]+2i+1: Jacobian(v,e[i]),   e[i]: i-th supporting edge
120:                                               Jvpt[v-vStart]+2i+2: Jacobian(v,vc[i]), vc[i]: i-th connected vertex
121:                                               */
122:   PetscInt                          max_comps_registered; /* Max. number of components that can be registered */
123: } DM_Network;

125: #endif /* _NETWORKIMPL_H */