Actual source code: dm.c

      1: #define PETSCDM_DLL
      2:
     3:  #include src/dm/da/daimpl.h

      5: /*
      6:    Provides an interface for functionality needed by the DAMG routines.
      7:    Currently this interface is supported by the DA and VecPack objects
      8:
      9:    Note: this is actually no such thing as a DM object, rather it is
     10:    the common set of functions shared by DA and VecPack.

     12: */

     16: /*@C
     17:     DMDestroy - Destroys a vector packer or DA.

     19:     Collective on DM

     21:     Input Parameter:
     22: .   dm - the DM object to destroy

     24:     Level: developer

     26: .seealso DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix()

     28: @*/
     29: PetscErrorCode PETSCDM_DLLEXPORT DMDestroy(DM dm)
     30: {

     34:   (*dm->bops->destroy)((PetscObject)dm);
     35:   return(0);
     36: }

     40: /*@C
     41:     DMView - Views a vector packer or DA.

     43:     Collective on DM

     45:     Input Parameter:
     46: +   dm - the DM object to view
     47: -   v - the viewer

     49:     Level: developer

     51: .seealso DMDestroy(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix()

     53: @*/
     54: PetscErrorCode PETSCDM_DLLEXPORT DMView(DM dm,PetscViewer v)
     55: {

     59:   if (dm->bops->view) {
     60:     (*dm->bops->view)((PetscObject)dm,v);
     61:   }
     62:   return(0);
     63: }

     67: /*@C
     68:     DMCreateGlobalVector - Creates a global vector from a DA or VecPack object

     70:     Collective on DM

     72:     Input Parameter:
     73: .   dm - the DM object

     75:     Output Parameter:
     76: .   vec - the global vector

     78:     Level: developer

     80: .seealso DMDestroy(), DMView(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix()

     82: @*/
     83: PetscErrorCode PETSCDM_DLLEXPORT DMCreateGlobalVector(DM dm,Vec *vec)
     84: {

     88:   (*dm->ops->createglobalvector)(dm,vec);
     89:   return(0);
     90: }

     94: /*@C
     95:     DMGetInterpolation - Gets interpolation matrix between two DA or VecPack objects

     97:     Collective on DM

     99:     Input Parameter:
    100: +   dm1 - the DM object
    101: -   dm2 - the second, coarser DM object

    103:     Output Parameter:
    104: +  mat - the interpolation
    105: -  vec - the scaling (optional)

    107:     Level: developer

    109: .seealso DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetColoring(), DMGetMatrix()

    111: @*/
    112: PetscErrorCode PETSCDM_DLLEXPORT DMGetInterpolation(DM dm1,DM dm2,Mat *mat,Vec *vec)
    113: {

    117:   (*dm1->ops->getinterpolation)(dm1,dm2,mat,vec);
    118:   return(0);
    119: }

    123: /*@C
    124:     DMGetInjection - Gets injection matrix between two DA or VecPack objects

    126:     Collective on DM

    128:     Input Parameter:
    129: +   dm1 - the DM object
    130: -   dm2 - the second, coarser DM object

    132:     Output Parameter:
    133: .   mat - the injection

    135:     Level: developer

    137: .seealso DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetColoring(), DMGetMatrix(), DMGetInterpolation()

    139: @*/
    140: PetscErrorCode PETSCDM_DLLEXPORT DMGetInjection(DM dm1,DM dm2,VecScatter *ctx)
    141: {

    145:   (*dm1->ops->getinjection)(dm1,dm2,ctx);
    146:   return(0);
    147: }

    151: /*@C
    152:     DMGetColoring - Gets coloring and empty Jacobian for a DA or VecPack

    154:     Collective on DM

    156:     Input Parameter:
    157: +   dm - the DM object
    158: -   ctype - IS_COLORING_GHOSTED or IS_COLORING_LOCAL

    160:     Output Parameter:
    161: .   coloring - the coloring

    163:     Level: developer

    165: .seealso DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetMatrix()

    167: @*/
    168: PetscErrorCode PETSCDM_DLLEXPORT DMGetColoring(DM dm,ISColoringType ctype,ISColoring *coloring)
    169: {

    173:   (*dm->ops->getcoloring)(dm,ctype,coloring);
    174:   return(0);
    175: }

    179: /*@C
    180:     DMGetMatrix - Gets empty Jacobian for a DA or VecPack

    182:     Collective on DM

    184:     Input Parameter:
    185: +   dm - the DM object
    186: -   mtype - Supported types are MATSEQAIJ, MATMPIAIJ, MATSEQBAIJ, MATMPIBAIJ, or
    187:             any type which inherits from one of these (such as MATAIJ, MATLUSOL, etc.).

    189:     Output Parameter:
    190: .   mat - the empty Jacobian

    192:     Level: developer

    194: .seealso DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetMatrix()

    196: @*/
    197: PetscErrorCode PETSCDM_DLLEXPORT DMGetMatrix(DM dm, MatType mtype,Mat *mat)
    198: {

    202:   (*dm->ops->getmatrix)(dm,mtype,mat);
    203:   return(0);
    204: }

    208: /*@C
    209:     DMRefine - Refines a DA or VecPack object

    211:     Collective on DM

    213:     Input Parameter:
    214: +   dm - the DM object
    215: -   comm - the communicator to contain the new DM object (or PETSC_NULL)

    217:     Output Parameter:
    218: .   dmf - the refined DM

    220:     Level: developer

    222: .seealso DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetInterpolation()

    224: @*/
    225: PetscErrorCode PETSCDM_DLLEXPORT DMRefine(DM dm,MPI_Comm comm,DM *dmf)
    226: {

    230:   (*dm->ops->refine)(dm,comm,dmf);
    231:   return(0);
    232: }