Date: 2016-07-24T17:01:30+00:00

Actual source code: patchcreate.c
petsc-3.7.3 2016-07-24
Report Typos and Errors

      1: #include <petsc/private/dmpatchimpl.h>   /*I      "petscdmpatch.h"   I*/
      2: #include <petscdmda.h>

      6: PetscErrorCode DMSetFromOptions_Patch(PetscOptionItems *PetscOptionsObject,DM dm)
      7: {
      8:   /* DM_Patch      *mesh = (DM_Patch*) dm->data; */

     13:   PetscOptionsHead(PetscOptionsObject,"DMPatch Options");
     14:   /* Handle associated vectors */
     15:   /* Handle viewing */
     16:   PetscOptionsTail();
     17:   return(0);
     18: }

     20: /* External function declarations here */
     21: extern PetscErrorCode DMSetUp_Patch(DM dm);
     22: extern PetscErrorCode DMView_Patch(DM dm, PetscViewer viewer);
     23: extern PetscErrorCode DMCreateGlobalVector_Patch(DM dm, Vec *g);
     24: extern PetscErrorCode DMCreateLocalVector_Patch(DM dm, Vec *l);
     25: extern PetscErrorCode DMDestroy_Patch(DM dm);
     26: extern PetscErrorCode DMCreateSubDM_Patch(DM dm, PetscInt numFields, PetscInt fields[], IS *is, DM *subdm);

     30: PetscErrorCode DMInitialize_Patch(DM dm)
     31: {
     33:   dm->ops->view                            = DMView_Patch;
     34:   dm->ops->setfromoptions                  = DMSetFromOptions_Patch;
     35:   dm->ops->setup                           = DMSetUp_Patch;
     36:   dm->ops->createglobalvector              = DMCreateGlobalVector_Patch;
     37:   dm->ops->createlocalvector               = DMCreateLocalVector_Patch;
     38:   dm->ops->getlocaltoglobalmapping         = NULL;
     39:   dm->ops->createfieldis                   = NULL;
     40:   dm->ops->getcoloring                     = 0;
     41:   dm->ops->creatematrix                    = 0;
     42:   dm->ops->createinterpolation             = 0;
     43:   dm->ops->getaggregates                   = 0;
     44:   dm->ops->getinjection                    = 0;
     45:   dm->ops->refine                          = 0;
     46:   dm->ops->coarsen                         = 0;
     47:   dm->ops->refinehierarchy                 = 0;
     48:   dm->ops->coarsenhierarchy                = 0;
     49:   dm->ops->globaltolocalbegin              = NULL;
     50:   dm->ops->globaltolocalend                = NULL;
     51:   dm->ops->localtoglobalbegin              = NULL;
     52:   dm->ops->localtoglobalend                = NULL;
     53:   dm->ops->destroy                         = DMDestroy_Patch;
     54:   dm->ops->createsubdm                     = DMCreateSubDM_Patch;
     55:   return(0);
     56: }

     60: PETSC_EXTERN PetscErrorCode DMCreate_Patch(DM dm)
     61: {
     62:   DM_Patch       *mesh;

     67:   PetscNewLog(dm,&mesh);
     68:   dm->data = mesh;

     70:   mesh->refct       = 1;
     71:   mesh->dmCoarse    = NULL;
     72:   mesh->patchSize.i = 0;
     73:   mesh->patchSize.j = 0;
     74:   mesh->patchSize.k = 0;
     75:   mesh->patchSize.c = 0;

     77:   DMInitialize_Patch(dm);
     78:   return(0);
     79: }

     83: /*@
     84:   DMPatchCreate - Creates a DMPatch object, which is a collections of DMs called patches.

     86:   Collective on MPI_Comm

     88:   Input Parameter:
     89: . comm - The communicator for the DMPatch object

     91:   Output Parameter:
     92: . mesh  - The DMPatch object

     94:   Level: beginner

     96: .keywords: DMPatch, create
     97: @*/
     98: PetscErrorCode DMPatchCreate(MPI_Comm comm, DM *mesh)
     99: {

    104:   DMCreate(comm, mesh);
    105:   DMSetType(*mesh, DMPATCH);
    106:   return(0);
    107: }

    111: PetscErrorCode DMPatchCreateGrid(MPI_Comm comm, PetscInt dim, MatStencil patchSize, MatStencil commSize, MatStencil gridSize, DM *dm)
    112: {
    113:   DM_Patch       *mesh;
    114:   DM             da;
    115:   PetscInt       dof = 1, width = 1;

    119:   DMPatchCreate(comm, dm);
    120:   mesh = (DM_Patch*) (*dm)->data;
    121:   if (dim < 2) {
    122:     gridSize.j  = 1;
    123:     patchSize.j = 1;
    124:   }
    125:   if (dim < 3) {
    126:     gridSize.k  = 1;
    127:     patchSize.k = 1;
    128:   }
    129:   DMCreate(comm, &da);
    130:   DMSetType(da, DMDA);
    131:   DMSetDimension(da, dim);
    132:   DMDASetSizes(da, gridSize.i, gridSize.j, gridSize.k);
    133:   DMDASetBoundaryType(da, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE);
    134:   DMDASetDof(da, dof);
    135:   DMDASetStencilType(da, DMDA_STENCIL_BOX);
    136:   DMDASetStencilWidth(da, width);

    138:   mesh->dmCoarse = da;

    140:   DMPatchSetPatchSize(*dm, patchSize);
    141:   DMPatchSetCommSize(*dm, commSize);
    142:   return(0);
    143: }