Actual source code: networkcreate.c

petsc-3.7.3 2016-08-01
Report Typos and Errors
  1: #define PETSCDM_DLL
  2: #include <petsc/private/dmnetworkimpl.h>    /*I   "petscdmnetwork.h"   I*/
  3: #include <petscdmda.h>

  7: PetscErrorCode  DMSetFromOptions_Network(PetscOptionItems *PetscOptionsObject,DM dm)
  8: {

 13:   PetscOptionsHead(PetscOptionsObject,"DMNetwork Options");
 14:   PetscOptionsTail();
 15:   return(0);
 16: }

 18: /* External function declarations here */
 19: extern PetscErrorCode DMCreateMatrix_Network(DM, Mat*);
 20: extern PetscErrorCode DMDestroy_Network(DM);
 21: extern PetscErrorCode DMView_Network(DM, PetscViewer);
 22: extern PetscErrorCode DMGlobalToLocalBegin_Network(DM, Vec, InsertMode, Vec);
 23: extern PetscErrorCode DMGlobalToLocalEnd_Network(DM, Vec, InsertMode, Vec);
 24: extern PetscErrorCode DMLocalToGlobalBegin_Network(DM, Vec, InsertMode, Vec);
 25: extern PetscErrorCode DMLocalToGlobalEnd_Network(DM, Vec, InsertMode, Vec);
 26: extern PetscErrorCode DMSetUp_Network(DM);
 27: extern PetscErrorCode DMClone_Network(DM, DM*);


 32: static PetscErrorCode DMCreateGlobalVector_Network(DM dm,Vec *vec)
 33: {
 35:   DM_Network     *network = (DM_Network*) dm->data;

 38:   DMCreateGlobalVector(network->plex,vec);
 39:   VecSetDM(*vec,dm);
 40:   return(0);
 41: }

 45: static PetscErrorCode DMCreateLocalVector_Network(DM dm,Vec *vec)
 46: {
 48:   DM_Network     *network = (DM_Network*) dm->data;

 51:   DMCreateLocalVector(network->plex,vec);
 52:   VecSetDM(*vec,dm);
 53:   return(0);
 54: }

 58: PetscErrorCode DMInitialize_Network(DM dm)
 59: {


 63:   dm->ops->view                            = NULL;
 64:   dm->ops->setfromoptions                  = DMSetFromOptions_Network;
 65:   dm->ops->clone                           = DMClone_Network;
 66:   dm->ops->setup                           = DMSetUp_Network;
 67:   dm->ops->createglobalvector              = DMCreateGlobalVector_Network;
 68:   dm->ops->createlocalvector               = DMCreateLocalVector_Network;
 69:   dm->ops->getlocaltoglobalmapping         = NULL;
 70:   dm->ops->createfieldis                   = NULL;
 71:   dm->ops->createcoordinatedm              = NULL;
 72:   dm->ops->getcoloring                     = 0;
 73:   dm->ops->creatematrix                    = DMCreateMatrix_Network;
 74:   dm->ops->createinterpolation             = 0;
 75:   dm->ops->getaggregates                   = 0;
 76:   dm->ops->getinjection                    = 0;
 77:   dm->ops->refine                          = 0;
 78:   dm->ops->coarsen                         = 0;
 79:   dm->ops->refinehierarchy                 = 0;
 80:   dm->ops->coarsenhierarchy                = 0;
 81:   dm->ops->globaltolocalbegin              = DMGlobalToLocalBegin_Network;
 82:   dm->ops->globaltolocalend                = DMGlobalToLocalEnd_Network;
 83:   dm->ops->localtoglobalbegin              = DMLocalToGlobalBegin_Network;
 84:   dm->ops->localtoglobalend                = DMLocalToGlobalEnd_Network;
 85:   dm->ops->destroy                         = DMDestroy_Network;
 86:   dm->ops->createsubdm                     = NULL;
 87:   dm->ops->locatepoints                    = NULL;
 88:   return(0);
 89: }

 93: PetscErrorCode DMClone_Network(DM dm, DM *newdm)
 94: {
 95:   DM_Network     *network = (DM_Network *) dm->data;

 99:   network->refct++;
100:   (*newdm)->data = network;
101:   PetscObjectChangeTypeName((PetscObject) *newdm, DMNETWORK);
102:   DMInitialize_Network(*newdm);
103:   return(0);
104: }

106: /*MC
107:   DMNETWORK = "network" - A DM object that encapsulates an unstructured network. The implementation is based on the DM object
108:                           DMPlex that manages unstructured grids. Distributed networks use a non-overlapping partitioning of
109:                           the edges. In the local representation, Vecs contain all unknowns in the interior and shared boundary.
110:                           This is specified by a PetscSection object. Ownership in the global representation is determined by
111:                           ownership of the underlying DMPlex points. This is specified by another PetscSection object.

113:   Level: intermediate

115: .seealso: DMType, DMNetworkCreate(), DMCreate(), DMSetType()
116: M*/

120: PETSC_EXTERN PetscErrorCode DMCreate_Network(DM dm)
121: {
122:   DM_Network     *network;

127:   PetscNewLog(dm,&network);
128:   dm->data = network;

130:   network->refct          = 1;
131:   network->NNodes         = -1;
132:   network->NEdges         = -1;
133:   network->nNodes         = -1;
134:   network->nEdges         = -1;

136:   DMInitialize_Network(dm);
137:   return(0);
138: }

142: /*@
143:   DMNetworkCreate - Creates a DMNetwork object, which encapsulates an unstructured network.

145:   Collective on MPI_Comm

147:   Input Parameter:
148: . comm - The communicator for the DMNetwork object

150:   Output Parameter:
151: . network  - The DMNetwork object

153:   Level: beginner

155: .keywords: DMNetwork, create
156: @*/
157: PetscErrorCode DMNetworkCreate(MPI_Comm comm, DM *network)
158: {

163:   DMCreate(comm, network);
164:   DMSetType(*network, DMNETWORK);
165:   return(0);
166: }