Actual source code: networkcreate.c

petsc-3.5.4 2015-05-23
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(DM dm)
  8: {

 13:   PetscOptionsHead("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);


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

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

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

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

 57: PetscErrorCode DMInitialize_Network(DM dm)
 58: {


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

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

 97:   Level: intermediate

 99: .seealso: DMType, DMNetworkCreate(), DMCreate(), DMSetType()
100: M*/

104: PETSC_EXTERN PetscErrorCode DMCreate_Network(DM dm)
105: {
106:   DM_Network     *network;

111:   PetscNewLog(dm,&network);
112:   dm->data = network;

114:   network->refct          = 1;
115:   network->NNodes         = -1;
116:   network->NEdges         = -1;
117:   network->nNodes         = -1;
118:   network->nEdges         = -1;

120:   DMInitialize_Network(dm);
121:   return(0);
122: }

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

129:   Collective on MPI_Comm

131:   Input Parameter:
132: . comm - The communicator for the DMNetwork object

134:   Output Parameter:
135: . network  - The DMNetwork object

137:   Level: beginner

139: .keywords: DMNetwork, create
140: @*/
141: PetscErrorCode DMNetworkCreate(MPI_Comm comm, DM *network)
142: {

147:   DMCreate(comm, network);
148:   DMSetType(*network, DMNETWORK);
149:   return(0);
150: }