xref: /petsc/src/dm/interface/dm.c (revision 9a42bb27a39f0cdf3306a1e22d33cd9809484eaa)
147c6ae99SBarry Smith #define PETSCDM_DLL
247c6ae99SBarry Smith 
347c6ae99SBarry Smith #include "private/dmimpl.h"     /*I      "petscda.h"     I*/
447c6ae99SBarry Smith 
547c6ae99SBarry Smith #undef __FUNCT__
6*9a42bb27SBarry Smith #define __FUNCT__ "DMSetVecType"
7*9a42bb27SBarry Smith /*@C
8*9a42bb27SBarry Smith        DMSetVecType - Sets the type of vector created with DACreateLocalVector() and DACreateGlobalVector()
9*9a42bb27SBarry Smith 
10*9a42bb27SBarry Smith    Logically Collective on DA
11*9a42bb27SBarry Smith 
12*9a42bb27SBarry Smith    Input Parameter:
13*9a42bb27SBarry Smith +  da - initial distributed array
14*9a42bb27SBarry Smith .  ctype - the vector type, currently either VECSTANDARD or VECCUDA
15*9a42bb27SBarry Smith 
16*9a42bb27SBarry Smith    Options Database:
17*9a42bb27SBarry Smith .   -da_vec_type ctype
18*9a42bb27SBarry Smith 
19*9a42bb27SBarry Smith    Level: intermediate
20*9a42bb27SBarry Smith 
21*9a42bb27SBarry Smith .seealso: DACreate1d(), DACreate2d(), DACreate3d(), DMDestroy(), DA, DAInterpolationType, VecType
22*9a42bb27SBarry Smith @*/
23*9a42bb27SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMSetVecType(DM da,const VecType ctype)
24*9a42bb27SBarry Smith {
25*9a42bb27SBarry Smith   PetscErrorCode ierr;
26*9a42bb27SBarry Smith 
27*9a42bb27SBarry Smith   PetscFunctionBegin;
28*9a42bb27SBarry Smith   PetscValidHeaderSpecific(da,DM_CLASSID,1);
29*9a42bb27SBarry Smith   ierr = PetscFree(da->vectype);CHKERRQ(ierr);
30*9a42bb27SBarry Smith   ierr = PetscStrallocpy(ctype,&da->vectype);CHKERRQ(ierr);
31*9a42bb27SBarry Smith   PetscFunctionReturn(0);
32*9a42bb27SBarry Smith }
33*9a42bb27SBarry Smith 
34*9a42bb27SBarry Smith #undef __FUNCT__
35*9a42bb27SBarry Smith #define __FUNCT__ "DMSetOptionsPrefix"
36*9a42bb27SBarry Smith /*@C
37*9a42bb27SBarry Smith    DMSetOptionsPrefix - Sets the prefix used for searching for all
38*9a42bb27SBarry Smith    DA options in the database.
39*9a42bb27SBarry Smith 
40*9a42bb27SBarry Smith    Logically Collective on DA
41*9a42bb27SBarry Smith 
42*9a42bb27SBarry Smith    Input Parameter:
43*9a42bb27SBarry Smith +  da - the DA context
44*9a42bb27SBarry Smith -  prefix - the prefix to prepend to all option names
45*9a42bb27SBarry Smith 
46*9a42bb27SBarry Smith    Notes:
47*9a42bb27SBarry Smith    A hyphen (-) must NOT be given at the beginning of the prefix name.
48*9a42bb27SBarry Smith    The first character of all runtime options is AUTOMATICALLY the hyphen.
49*9a42bb27SBarry Smith 
50*9a42bb27SBarry Smith    Level: advanced
51*9a42bb27SBarry Smith 
52*9a42bb27SBarry Smith .keywords: DA, set, options, prefix, database
53*9a42bb27SBarry Smith 
54*9a42bb27SBarry Smith .seealso: DMSetFromOptions()
55*9a42bb27SBarry Smith @*/
56*9a42bb27SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMSetOptionsPrefix(DM dm,const char prefix[])
57*9a42bb27SBarry Smith {
58*9a42bb27SBarry Smith   PetscErrorCode ierr;
59*9a42bb27SBarry Smith 
60*9a42bb27SBarry Smith   PetscFunctionBegin;
61*9a42bb27SBarry Smith   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
62*9a42bb27SBarry Smith   ierr = PetscObjectSetOptionsPrefix((PetscObject)dm,prefix);CHKERRQ(ierr);
63*9a42bb27SBarry Smith   PetscFunctionReturn(0);
64*9a42bb27SBarry Smith }
65*9a42bb27SBarry Smith 
66*9a42bb27SBarry Smith #undef __FUNCT__
6747c6ae99SBarry Smith #define __FUNCT__ "DMDestroy"
6847c6ae99SBarry Smith /*@
6947c6ae99SBarry Smith     DMDestroy - Destroys a vector packer or DA.
7047c6ae99SBarry Smith 
7147c6ae99SBarry Smith     Collective on DM
7247c6ae99SBarry Smith 
7347c6ae99SBarry Smith     Input Parameter:
7447c6ae99SBarry Smith .   dm - the DM object to destroy
7547c6ae99SBarry Smith 
7647c6ae99SBarry Smith     Level: developer
7747c6ae99SBarry Smith 
7847c6ae99SBarry Smith .seealso DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix()
7947c6ae99SBarry Smith 
8047c6ae99SBarry Smith @*/
8147c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMDestroy(DM dm)
8247c6ae99SBarry Smith {
8347c6ae99SBarry Smith   PetscErrorCode ierr;
8447c6ae99SBarry Smith 
8547c6ae99SBarry Smith   PetscFunctionBegin;
860c010503SBarry Smith   ierr = (*dm->ops->destroy)(dm);CHKERRQ(ierr);
8747c6ae99SBarry Smith   PetscFunctionReturn(0);
8847c6ae99SBarry Smith }
8947c6ae99SBarry Smith 
9047c6ae99SBarry Smith #undef __FUNCT__
91d7bf68aeSBarry Smith #define __FUNCT__ "DMSetUp"
92d7bf68aeSBarry Smith /*@
93d7bf68aeSBarry Smith     DMSetUp - sets up the data structures inside a DM object
94d7bf68aeSBarry Smith 
95d7bf68aeSBarry Smith     Collective on DM
96d7bf68aeSBarry Smith 
97d7bf68aeSBarry Smith     Input Parameter:
98d7bf68aeSBarry Smith .   dm - the DM object to setup
99d7bf68aeSBarry Smith 
100d7bf68aeSBarry Smith     Level: developer
101d7bf68aeSBarry Smith 
102d7bf68aeSBarry Smith .seealso DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix()
103d7bf68aeSBarry Smith 
104d7bf68aeSBarry Smith @*/
105d7bf68aeSBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMSetUp(DM dm)
106d7bf68aeSBarry Smith {
107d7bf68aeSBarry Smith   PetscErrorCode ierr;
108d7bf68aeSBarry Smith 
109d7bf68aeSBarry Smith   PetscFunctionBegin;
110d7bf68aeSBarry Smith   if (dm->ops->setup) {
111d7bf68aeSBarry Smith     ierr = (*dm->ops->setup)(dm);CHKERRQ(ierr);
112d7bf68aeSBarry Smith   }
113d7bf68aeSBarry Smith   PetscFunctionReturn(0);
114d7bf68aeSBarry Smith }
115d7bf68aeSBarry Smith 
116d7bf68aeSBarry Smith #undef __FUNCT__
117d7bf68aeSBarry Smith #define __FUNCT__ "DMSetFromOptions"
118d7bf68aeSBarry Smith /*@
119d7bf68aeSBarry Smith     DMSetFromOptions - sets parameters in a DM from the options database
120d7bf68aeSBarry Smith 
121d7bf68aeSBarry Smith     Collective on DM
122d7bf68aeSBarry Smith 
123d7bf68aeSBarry Smith     Input Parameter:
124d7bf68aeSBarry Smith .   dm - the DM object to set options for
125d7bf68aeSBarry Smith 
126d7bf68aeSBarry Smith     Level: developer
127d7bf68aeSBarry Smith 
128d7bf68aeSBarry Smith .seealso DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix()
129d7bf68aeSBarry Smith 
130d7bf68aeSBarry Smith @*/
131d7bf68aeSBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMSetFromOptions(DM dm)
132d7bf68aeSBarry Smith {
133d7bf68aeSBarry Smith   PetscErrorCode ierr;
134d7bf68aeSBarry Smith 
135d7bf68aeSBarry Smith   PetscFunctionBegin;
136d7bf68aeSBarry Smith   if (dm->ops->setfromoptions) {
137d7bf68aeSBarry Smith     ierr = (*dm->ops->setfromoptions)(dm);CHKERRQ(ierr);
138d7bf68aeSBarry Smith   }
139d7bf68aeSBarry Smith   PetscFunctionReturn(0);
140d7bf68aeSBarry Smith }
141d7bf68aeSBarry Smith 
142d7bf68aeSBarry Smith #undef __FUNCT__
14347c6ae99SBarry Smith #define __FUNCT__ "DMView"
14447c6ae99SBarry Smith /*@
14547c6ae99SBarry Smith     DMView - Views a vector packer or DA.
14647c6ae99SBarry Smith 
14747c6ae99SBarry Smith     Collective on DM
14847c6ae99SBarry Smith 
14947c6ae99SBarry Smith     Input Parameter:
15047c6ae99SBarry Smith +   dm - the DM object to view
15147c6ae99SBarry Smith -   v - the viewer
15247c6ae99SBarry Smith 
15347c6ae99SBarry Smith     Level: developer
15447c6ae99SBarry Smith 
15547c6ae99SBarry Smith .seealso DMDestroy(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix()
15647c6ae99SBarry Smith 
15747c6ae99SBarry Smith @*/
15847c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMView(DM dm,PetscViewer v)
15947c6ae99SBarry Smith {
16047c6ae99SBarry Smith   PetscErrorCode ierr;
16147c6ae99SBarry Smith 
16247c6ae99SBarry Smith   PetscFunctionBegin;
1630c010503SBarry Smith   if (dm->ops->view) {
1640c010503SBarry Smith     ierr = (*dm->ops->view)(dm,v);CHKERRQ(ierr);
16547c6ae99SBarry Smith   }
16647c6ae99SBarry Smith   PetscFunctionReturn(0);
16747c6ae99SBarry Smith }
16847c6ae99SBarry Smith 
16947c6ae99SBarry Smith #undef __FUNCT__
17047c6ae99SBarry Smith #define __FUNCT__ "DMCreateGlobalVector"
17147c6ae99SBarry Smith /*@
17247c6ae99SBarry Smith     DMCreateGlobalVector - Creates a global vector from a DA or DMComposite object
17347c6ae99SBarry Smith 
17447c6ae99SBarry Smith     Collective on DM
17547c6ae99SBarry Smith 
17647c6ae99SBarry Smith     Input Parameter:
17747c6ae99SBarry Smith .   dm - the DM object
17847c6ae99SBarry Smith 
17947c6ae99SBarry Smith     Output Parameter:
18047c6ae99SBarry Smith .   vec - the global vector
18147c6ae99SBarry Smith 
18247c6ae99SBarry Smith     Level: developer
18347c6ae99SBarry Smith 
18447c6ae99SBarry Smith .seealso DMDestroy(), DMView(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix()
18547c6ae99SBarry Smith 
18647c6ae99SBarry Smith @*/
18747c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMCreateGlobalVector(DM dm,Vec *vec)
18847c6ae99SBarry Smith {
18947c6ae99SBarry Smith   PetscErrorCode ierr;
19047c6ae99SBarry Smith 
19147c6ae99SBarry Smith   PetscFunctionBegin;
19247c6ae99SBarry Smith   ierr = (*dm->ops->createglobalvector)(dm,vec);CHKERRQ(ierr);
19347c6ae99SBarry Smith   PetscFunctionReturn(0);
19447c6ae99SBarry Smith }
19547c6ae99SBarry Smith 
19647c6ae99SBarry Smith #undef __FUNCT__
19747c6ae99SBarry Smith #define __FUNCT__ "DMCreateLocalVector"
19847c6ae99SBarry Smith /*@
19947c6ae99SBarry Smith     DMCreateLocalVector - Creates a local vector from a DA or DMComposite object
20047c6ae99SBarry Smith 
20147c6ae99SBarry Smith     Not Collective
20247c6ae99SBarry Smith 
20347c6ae99SBarry Smith     Input Parameter:
20447c6ae99SBarry Smith .   dm - the DM object
20547c6ae99SBarry Smith 
20647c6ae99SBarry Smith     Output Parameter:
20747c6ae99SBarry Smith .   vec - the local vector
20847c6ae99SBarry Smith 
20947c6ae99SBarry Smith     Level: developer
21047c6ae99SBarry Smith 
21147c6ae99SBarry Smith .seealso DMDestroy(), DMView(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix()
21247c6ae99SBarry Smith 
21347c6ae99SBarry Smith @*/
21447c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMCreateLocalVector(DM dm,Vec *vec)
21547c6ae99SBarry Smith {
21647c6ae99SBarry Smith   PetscErrorCode ierr;
21747c6ae99SBarry Smith 
21847c6ae99SBarry Smith   PetscFunctionBegin;
21947c6ae99SBarry Smith   ierr = (*dm->ops->createlocalvector)(dm,vec);CHKERRQ(ierr);
22047c6ae99SBarry Smith   PetscFunctionReturn(0);
22147c6ae99SBarry Smith }
22247c6ae99SBarry Smith 
22347c6ae99SBarry Smith #undef __FUNCT__
22447c6ae99SBarry Smith #define __FUNCT__ "DMGetInterpolation"
22547c6ae99SBarry Smith /*@
22647c6ae99SBarry Smith     DMGetInterpolation - Gets interpolation matrix between two DA or DMComposite objects
22747c6ae99SBarry Smith 
22847c6ae99SBarry Smith     Collective on DM
22947c6ae99SBarry Smith 
23047c6ae99SBarry Smith     Input Parameter:
23147c6ae99SBarry Smith +   dm1 - the DM object
23247c6ae99SBarry Smith -   dm2 - the second, finer DM object
23347c6ae99SBarry Smith 
23447c6ae99SBarry Smith     Output Parameter:
23547c6ae99SBarry Smith +  mat - the interpolation
23647c6ae99SBarry Smith -  vec - the scaling (optional)
23747c6ae99SBarry Smith 
23847c6ae99SBarry Smith     Level: developer
23947c6ae99SBarry Smith 
24047c6ae99SBarry Smith .seealso DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetColoring(), DMGetMatrix()
24147c6ae99SBarry Smith 
24247c6ae99SBarry Smith @*/
24347c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMGetInterpolation(DM dm1,DM dm2,Mat *mat,Vec *vec)
24447c6ae99SBarry Smith {
24547c6ae99SBarry Smith   PetscErrorCode ierr;
24647c6ae99SBarry Smith 
24747c6ae99SBarry Smith   PetscFunctionBegin;
24847c6ae99SBarry Smith   ierr = (*dm1->ops->getinterpolation)(dm1,dm2,mat,vec);CHKERRQ(ierr);
24947c6ae99SBarry Smith   PetscFunctionReturn(0);
25047c6ae99SBarry Smith }
25147c6ae99SBarry Smith 
25247c6ae99SBarry Smith #undef __FUNCT__
25347c6ae99SBarry Smith #define __FUNCT__ "DMGetInjection"
25447c6ae99SBarry Smith /*@
25547c6ae99SBarry Smith     DMGetInjection - Gets injection matrix between two DA or DMComposite objects
25647c6ae99SBarry Smith 
25747c6ae99SBarry Smith     Collective on DM
25847c6ae99SBarry Smith 
25947c6ae99SBarry Smith     Input Parameter:
26047c6ae99SBarry Smith +   dm1 - the DM object
26147c6ae99SBarry Smith -   dm2 - the second, finer DM object
26247c6ae99SBarry Smith 
26347c6ae99SBarry Smith     Output Parameter:
26447c6ae99SBarry Smith .   ctx - the injection
26547c6ae99SBarry Smith 
26647c6ae99SBarry Smith     Level: developer
26747c6ae99SBarry Smith 
26847c6ae99SBarry Smith .seealso DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetColoring(), DMGetMatrix(), DMGetInterpolation()
26947c6ae99SBarry Smith 
27047c6ae99SBarry Smith @*/
27147c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMGetInjection(DM dm1,DM dm2,VecScatter *ctx)
27247c6ae99SBarry Smith {
27347c6ae99SBarry Smith   PetscErrorCode ierr;
27447c6ae99SBarry Smith 
27547c6ae99SBarry Smith   PetscFunctionBegin;
27647c6ae99SBarry Smith   ierr = (*dm1->ops->getinjection)(dm1,dm2,ctx);CHKERRQ(ierr);
27747c6ae99SBarry Smith   PetscFunctionReturn(0);
27847c6ae99SBarry Smith }
27947c6ae99SBarry Smith 
28047c6ae99SBarry Smith #undef __FUNCT__
28147c6ae99SBarry Smith #define __FUNCT__ "DMGetColoring"
28247c6ae99SBarry Smith /*@
28347c6ae99SBarry Smith     DMGetColoring - Gets coloring for a DA or DMComposite
28447c6ae99SBarry Smith 
28547c6ae99SBarry Smith     Collective on DM
28647c6ae99SBarry Smith 
28747c6ae99SBarry Smith     Input Parameter:
28847c6ae99SBarry Smith +   dm - the DM object
28947c6ae99SBarry Smith .   ctype - IS_COLORING_GHOSTED or IS_COLORING_GLOBAL
29047c6ae99SBarry Smith -   matype - either MATAIJ or MATBAIJ
29147c6ae99SBarry Smith 
29247c6ae99SBarry Smith     Output Parameter:
29347c6ae99SBarry Smith .   coloring - the coloring
29447c6ae99SBarry Smith 
29547c6ae99SBarry Smith     Level: developer
29647c6ae99SBarry Smith 
29747c6ae99SBarry Smith .seealso DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetMatrix()
29847c6ae99SBarry Smith 
29947c6ae99SBarry Smith @*/
30047c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMGetColoring(DM dm,ISColoringType ctype,const MatType mtype,ISColoring *coloring)
30147c6ae99SBarry Smith {
30247c6ae99SBarry Smith   PetscErrorCode ierr;
30347c6ae99SBarry Smith 
30447c6ae99SBarry Smith   PetscFunctionBegin;
30547c6ae99SBarry Smith   if (!dm->ops->getcoloring) SETERRQ(((PetscObject)dm)->comm,PETSC_ERR_SUP,"No coloring for this type of DM yet");
30647c6ae99SBarry Smith   ierr = (*dm->ops->getcoloring)(dm,ctype,mtype,coloring);CHKERRQ(ierr);
30747c6ae99SBarry Smith   PetscFunctionReturn(0);
30847c6ae99SBarry Smith }
30947c6ae99SBarry Smith 
31047c6ae99SBarry Smith #undef __FUNCT__
31147c6ae99SBarry Smith #define __FUNCT__ "DMGetMatrix"
31247c6ae99SBarry Smith /*@C
31347c6ae99SBarry Smith     DMGetMatrix - Gets empty Jacobian for a DA or DMComposite
31447c6ae99SBarry Smith 
31547c6ae99SBarry Smith     Collective on DM
31647c6ae99SBarry Smith 
31747c6ae99SBarry Smith     Input Parameter:
31847c6ae99SBarry Smith +   dm - the DM object
31947c6ae99SBarry Smith -   mtype - Supported types are MATSEQAIJ, MATMPIAIJ, MATSEQBAIJ, MATMPIBAIJ, or
32047c6ae99SBarry Smith             any type which inherits from one of these (such as MATAIJ, MATLUSOL, etc.).
32147c6ae99SBarry Smith 
32247c6ae99SBarry Smith     Output Parameter:
32347c6ae99SBarry Smith .   mat - the empty Jacobian
32447c6ae99SBarry Smith 
32547c6ae99SBarry Smith     Level: developer
32647c6ae99SBarry Smith 
32747c6ae99SBarry Smith .seealso DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetMatrix()
32847c6ae99SBarry Smith 
32947c6ae99SBarry Smith @*/
33047c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMGetMatrix(DM dm, const MatType mtype,Mat *mat)
33147c6ae99SBarry Smith {
33247c6ae99SBarry Smith   PetscErrorCode ierr;
33347c6ae99SBarry Smith 
33447c6ae99SBarry Smith   PetscFunctionBegin;
33547c6ae99SBarry Smith   ierr = (*dm->ops->getmatrix)(dm,mtype,mat);CHKERRQ(ierr);
33647c6ae99SBarry Smith   PetscFunctionReturn(0);
33747c6ae99SBarry Smith }
33847c6ae99SBarry Smith 
33947c6ae99SBarry Smith #undef __FUNCT__
34047c6ae99SBarry Smith #define __FUNCT__ "DMRefine"
34147c6ae99SBarry Smith /*@
34247c6ae99SBarry Smith     DMRefine - Refines a DM object
34347c6ae99SBarry Smith 
34447c6ae99SBarry Smith     Collective on DM
34547c6ae99SBarry Smith 
34647c6ae99SBarry Smith     Input Parameter:
34747c6ae99SBarry Smith +   dm - the DM object
34847c6ae99SBarry Smith -   comm - the communicator to contain the new DM object (or PETSC_NULL)
34947c6ae99SBarry Smith 
35047c6ae99SBarry Smith     Output Parameter:
35147c6ae99SBarry Smith .   dmf - the refined DM
35247c6ae99SBarry Smith 
35347c6ae99SBarry Smith     Level: developer
35447c6ae99SBarry Smith 
35547c6ae99SBarry Smith .seealso DMCoarsen(), DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetInterpolation()
35647c6ae99SBarry Smith 
35747c6ae99SBarry Smith @*/
35847c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMRefine(DM dm,MPI_Comm comm,DM *dmf)
35947c6ae99SBarry Smith {
36047c6ae99SBarry Smith   PetscErrorCode ierr;
36147c6ae99SBarry Smith 
36247c6ae99SBarry Smith   PetscFunctionBegin;
36347c6ae99SBarry Smith   ierr = (*dm->ops->refine)(dm,comm,dmf);CHKERRQ(ierr);
36447c6ae99SBarry Smith   PetscFunctionReturn(0);
36547c6ae99SBarry Smith }
36647c6ae99SBarry Smith 
36747c6ae99SBarry Smith #undef __FUNCT__
36847c6ae99SBarry Smith #define __FUNCT__ "DMGlobalToLocalBegin"
36947c6ae99SBarry Smith /*@
37047c6ae99SBarry Smith     DMGlobalToLocalBegin - Begins updating local vectors from global vector
37147c6ae99SBarry Smith 
37247c6ae99SBarry Smith     Neighbor-wise Collective on DM
37347c6ae99SBarry Smith 
37447c6ae99SBarry Smith     Input Parameters:
37547c6ae99SBarry Smith +   dm - the DM object
37647c6ae99SBarry Smith .   g - the global vector
37747c6ae99SBarry Smith .   mode - INSERT_VALUES or ADD_VALUES
37847c6ae99SBarry Smith -   l - the local vector
37947c6ae99SBarry Smith 
38047c6ae99SBarry Smith 
38147c6ae99SBarry Smith     Level: beginner
38247c6ae99SBarry Smith 
383*9a42bb27SBarry Smith .seealso DMCoarsen(), DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGlobalToLocalEnd(), DMLocalToGlobalBegin()
38447c6ae99SBarry Smith 
38547c6ae99SBarry Smith @*/
38647c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMGlobalToLocalBegin(DM dm,Vec g,InsertMode mode,Vec l)
38747c6ae99SBarry Smith {
38847c6ae99SBarry Smith   PetscErrorCode ierr;
38947c6ae99SBarry Smith 
39047c6ae99SBarry Smith   PetscFunctionBegin;
39147c6ae99SBarry Smith   ierr = (*dm->ops->globaltolocalbegin)(dm,g,mode,l);CHKERRQ(ierr);
39247c6ae99SBarry Smith   PetscFunctionReturn(0);
39347c6ae99SBarry Smith }
39447c6ae99SBarry Smith 
39547c6ae99SBarry Smith #undef __FUNCT__
39647c6ae99SBarry Smith #define __FUNCT__ "DMGlobalToLocalEnd"
39747c6ae99SBarry Smith /*@
39847c6ae99SBarry Smith     DMGlobalToLocalEnd - Ends updating local vectors from global vector
39947c6ae99SBarry Smith 
40047c6ae99SBarry Smith     Neighbor-wise Collective on DM
40147c6ae99SBarry Smith 
40247c6ae99SBarry Smith     Input Parameters:
40347c6ae99SBarry Smith +   dm - the DM object
40447c6ae99SBarry Smith .   g - the global vector
40547c6ae99SBarry Smith .   mode - INSERT_VALUES or ADD_VALUES
40647c6ae99SBarry Smith -   l - the local vector
40747c6ae99SBarry Smith 
40847c6ae99SBarry Smith 
40947c6ae99SBarry Smith     Level: beginner
41047c6ae99SBarry Smith 
411*9a42bb27SBarry Smith .seealso DMCoarsen(), DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGlobalToLocalEnd(), DMLocalToGlobalBegin()
41247c6ae99SBarry Smith 
41347c6ae99SBarry Smith @*/
41447c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMGlobalToLocalEnd(DM dm,Vec g,InsertMode mode,Vec l)
41547c6ae99SBarry Smith {
41647c6ae99SBarry Smith   PetscErrorCode ierr;
41747c6ae99SBarry Smith 
41847c6ae99SBarry Smith   PetscFunctionBegin;
41947c6ae99SBarry Smith   ierr = (*dm->ops->globaltolocalend)(dm,g,mode,l);CHKERRQ(ierr);
42047c6ae99SBarry Smith   PetscFunctionReturn(0);
42147c6ae99SBarry Smith }
42247c6ae99SBarry Smith 
42347c6ae99SBarry Smith #undef __FUNCT__
424*9a42bb27SBarry Smith #define __FUNCT__ "DMLocalToGlobalBegin"
42547c6ae99SBarry Smith /*@
426*9a42bb27SBarry Smith     DMLocalToGlobalBegin - updates global vectors from local vectors
427*9a42bb27SBarry Smith 
428*9a42bb27SBarry Smith     Neighbor-wise Collective on DM
429*9a42bb27SBarry Smith 
430*9a42bb27SBarry Smith     Input Parameters:
431*9a42bb27SBarry Smith +   dm - the DM object
432*9a42bb27SBarry Smith .   g - the global vector
433*9a42bb27SBarry Smith .   mode - if INSERT_VALUES then no parallel communication is used, if ADD_VALUES then all ghost points from the same base point accumulate into that
434*9a42bb27SBarry Smith            base point.
435*9a42bb27SBarry Smith -   l - the local vector
436*9a42bb27SBarry Smith 
437*9a42bb27SBarry Smith     Notes: In the ADD_VALUES case you normally would zero the receiving vector before beginning this operation. If you would like to simply add the non-ghosted values in the local
438*9a42bb27SBarry Smith            array into the global array you need to either (1) zero the ghosted locations and use ADD_VALUES or (2) use INSERT_VALUES into a work global array and then add the work
439*9a42bb27SBarry Smith            global array to the final global array with VecAXPY().
440*9a42bb27SBarry Smith 
441*9a42bb27SBarry Smith     Level: beginner
442*9a42bb27SBarry Smith 
443*9a42bb27SBarry Smith .seealso DMCoarsen(), DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGlobalToLocalEnd(), DMGlobalToLocalBegin()
444*9a42bb27SBarry Smith 
445*9a42bb27SBarry Smith @*/
446*9a42bb27SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMLocalToGlobalBegin(DM dm,Vec g,InsertMode mode,Vec l)
447*9a42bb27SBarry Smith {
448*9a42bb27SBarry Smith   PetscErrorCode ierr;
449*9a42bb27SBarry Smith 
450*9a42bb27SBarry Smith   PetscFunctionBegin;
451*9a42bb27SBarry Smith   ierr = (*dm->ops->localtoglobalbegin)(dm,g,mode,l);CHKERRQ(ierr);
452*9a42bb27SBarry Smith   PetscFunctionReturn(0);
453*9a42bb27SBarry Smith }
454*9a42bb27SBarry Smith 
455*9a42bb27SBarry Smith #undef __FUNCT__
456*9a42bb27SBarry Smith #define __FUNCT__ "DMLocalToGlobalEnd"
457*9a42bb27SBarry Smith /*@
458*9a42bb27SBarry Smith     DMLocalToGlobalEnd - updates global vectors from local vectors
45947c6ae99SBarry Smith 
46047c6ae99SBarry Smith     Neighbor-wise Collective on DM
46147c6ae99SBarry Smith 
46247c6ae99SBarry Smith     Input Parameters:
46347c6ae99SBarry Smith +   dm - the DM object
46447c6ae99SBarry Smith .   g - the global vector
46547c6ae99SBarry Smith .   mode - INSERT_VALUES or ADD_VALUES
46647c6ae99SBarry Smith -   l - the local vector
46747c6ae99SBarry Smith 
46847c6ae99SBarry Smith 
46947c6ae99SBarry Smith     Level: beginner
47047c6ae99SBarry Smith 
471*9a42bb27SBarry Smith .seealso DMCoarsen(), DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGlobalToLocalEnd(), DMGlobalToLocalEnd()
47247c6ae99SBarry Smith 
47347c6ae99SBarry Smith @*/
474*9a42bb27SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMLocalToGlobalEnd(DM dm,Vec g,InsertMode mode,Vec l)
47547c6ae99SBarry Smith {
47647c6ae99SBarry Smith   PetscErrorCode ierr;
47747c6ae99SBarry Smith 
47847c6ae99SBarry Smith   PetscFunctionBegin;
479*9a42bb27SBarry Smith   ierr = (*dm->ops->localtoglobalend)(dm,g,mode,l);CHKERRQ(ierr);
48047c6ae99SBarry Smith   PetscFunctionReturn(0);
48147c6ae99SBarry Smith }
48247c6ae99SBarry Smith 
48347c6ae99SBarry Smith #undef __FUNCT__
48447c6ae99SBarry Smith #define __FUNCT__ "DMComputeJacobianDefault"
48547c6ae99SBarry Smith /*@
48647c6ae99SBarry Smith     DMComputeJacobianDefault - computes the Jacobian using the DMComputeFunction() if Jacobian computer is not provided
48747c6ae99SBarry Smith 
48847c6ae99SBarry Smith     Collective on DM
48947c6ae99SBarry Smith 
49047c6ae99SBarry Smith     Input Parameter:
49147c6ae99SBarry Smith +   dm - the DM object
49247c6ae99SBarry Smith .   x - location to compute Jacobian at; may be ignored for linear problems
49347c6ae99SBarry Smith .   A - matrix that defines the operator for the linear solve
49447c6ae99SBarry Smith -   B - the matrix used to construct the preconditioner
49547c6ae99SBarry Smith 
49647c6ae99SBarry Smith     Level: developer
49747c6ae99SBarry Smith 
49847c6ae99SBarry Smith .seealso DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix(), DMGetContext(), DMSetInitialGuess(),
49947c6ae99SBarry Smith          DMSetFunction()
50047c6ae99SBarry Smith 
50147c6ae99SBarry Smith @*/
50247c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMComputeJacobianDefault(DM dm,Vec x,Mat A,Mat B,MatStructure *stflag)
50347c6ae99SBarry Smith {
50447c6ae99SBarry Smith   PetscErrorCode ierr;
50547c6ae99SBarry Smith   PetscFunctionBegin;
50647c6ae99SBarry Smith   *stflag = SAME_NONZERO_PATTERN;
50747c6ae99SBarry Smith   ierr  = MatFDColoringApply(B,dm->fd,x,stflag,dm);CHKERRQ(ierr);
50847c6ae99SBarry Smith   if (A != B) {
50947c6ae99SBarry Smith     ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
51047c6ae99SBarry Smith     ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
51147c6ae99SBarry Smith   }
51247c6ae99SBarry Smith   PetscFunctionReturn(0);
51347c6ae99SBarry Smith }
51447c6ae99SBarry Smith 
51547c6ae99SBarry Smith #undef __FUNCT__
51647c6ae99SBarry Smith #define __FUNCT__ "DMCoarsen"
51747c6ae99SBarry Smith /*@
51847c6ae99SBarry Smith     DMCoarsen - Coarsens a DM object
51947c6ae99SBarry Smith 
52047c6ae99SBarry Smith     Collective on DM
52147c6ae99SBarry Smith 
52247c6ae99SBarry Smith     Input Parameter:
52347c6ae99SBarry Smith +   dm - the DM object
52447c6ae99SBarry Smith -   comm - the communicator to contain the new DM object (or PETSC_NULL)
52547c6ae99SBarry Smith 
52647c6ae99SBarry Smith     Output Parameter:
52747c6ae99SBarry Smith .   dmc - the coarsened DM
52847c6ae99SBarry Smith 
52947c6ae99SBarry Smith     Level: developer
53047c6ae99SBarry Smith 
53147c6ae99SBarry Smith .seealso DMRefine(), DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetInterpolation()
53247c6ae99SBarry Smith 
53347c6ae99SBarry Smith @*/
53447c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMCoarsen(DM dm, MPI_Comm comm, DM *dmc)
53547c6ae99SBarry Smith {
53647c6ae99SBarry Smith   PetscErrorCode ierr;
53747c6ae99SBarry Smith 
53847c6ae99SBarry Smith   PetscFunctionBegin;
53947c6ae99SBarry Smith   ierr = (*dm->ops->coarsen)(dm, comm, dmc);CHKERRQ(ierr);
54047c6ae99SBarry Smith   (*dmc)->ops->initialguess = dm->ops->initialguess;
54147c6ae99SBarry Smith   (*dmc)->ops->function     = dm->ops->function;
54247c6ae99SBarry Smith   (*dmc)->ops->functionj    = dm->ops->functionj;
54347c6ae99SBarry Smith   if (dm->ops->jacobian != DMComputeJacobianDefault) {
54447c6ae99SBarry Smith     (*dmc)->ops->jacobian     = dm->ops->jacobian;
54547c6ae99SBarry Smith   }
54647c6ae99SBarry Smith   PetscFunctionReturn(0);
54747c6ae99SBarry Smith }
54847c6ae99SBarry Smith 
54947c6ae99SBarry Smith #undef __FUNCT__
55047c6ae99SBarry Smith #define __FUNCT__ "DMRefineHierarchy"
55147c6ae99SBarry Smith /*@C
55247c6ae99SBarry Smith     DMRefineHierarchy - Refines a DM object, all levels at once
55347c6ae99SBarry Smith 
55447c6ae99SBarry Smith     Collective on DM
55547c6ae99SBarry Smith 
55647c6ae99SBarry Smith     Input Parameter:
55747c6ae99SBarry Smith +   dm - the DM object
55847c6ae99SBarry Smith -   nlevels - the number of levels of refinement
55947c6ae99SBarry Smith 
56047c6ae99SBarry Smith     Output Parameter:
56147c6ae99SBarry Smith .   dmf - the refined DM hierarchy
56247c6ae99SBarry Smith 
56347c6ae99SBarry Smith     Level: developer
56447c6ae99SBarry Smith 
56547c6ae99SBarry Smith .seealso DMCoarsenHierarchy(), DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetInterpolation()
56647c6ae99SBarry Smith 
56747c6ae99SBarry Smith @*/
56847c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMRefineHierarchy(DM dm,PetscInt nlevels,DM dmf[])
56947c6ae99SBarry Smith {
57047c6ae99SBarry Smith   PetscErrorCode ierr;
57147c6ae99SBarry Smith 
57247c6ae99SBarry Smith   PetscFunctionBegin;
57347c6ae99SBarry Smith   if (nlevels < 0) SETERRQ(((PetscObject)dm)->comm,PETSC_ERR_ARG_OUTOFRANGE,"nlevels cannot be negative");
57447c6ae99SBarry Smith   if (nlevels == 0) PetscFunctionReturn(0);
57547c6ae99SBarry Smith   if (dm->ops->refinehierarchy) {
57647c6ae99SBarry Smith     ierr = (*dm->ops->refinehierarchy)(dm,nlevels,dmf);CHKERRQ(ierr);
57747c6ae99SBarry Smith   } else if (dm->ops->refine) {
57847c6ae99SBarry Smith     PetscInt i;
57947c6ae99SBarry Smith 
58047c6ae99SBarry Smith     ierr = DMRefine(dm,((PetscObject)dm)->comm,&dmf[0]);CHKERRQ(ierr);
58147c6ae99SBarry Smith     for (i=1; i<nlevels; i++) {
58247c6ae99SBarry Smith       ierr = DMRefine(dmf[i-1],((PetscObject)dm)->comm,&dmf[i]);CHKERRQ(ierr);
58347c6ae99SBarry Smith     }
58447c6ae99SBarry Smith   } else {
58547c6ae99SBarry Smith     SETERRQ(((PetscObject)dm)->comm,PETSC_ERR_SUP,"No RefineHierarchy for this DM yet");
58647c6ae99SBarry Smith   }
58747c6ae99SBarry Smith   PetscFunctionReturn(0);
58847c6ae99SBarry Smith }
58947c6ae99SBarry Smith 
59047c6ae99SBarry Smith #undef __FUNCT__
59147c6ae99SBarry Smith #define __FUNCT__ "DMCoarsenHierarchy"
59247c6ae99SBarry Smith /*@C
59347c6ae99SBarry Smith     DMCoarsenHierarchy - Coarsens a DM object, all levels at once
59447c6ae99SBarry Smith 
59547c6ae99SBarry Smith     Collective on DM
59647c6ae99SBarry Smith 
59747c6ae99SBarry Smith     Input Parameter:
59847c6ae99SBarry Smith +   dm - the DM object
59947c6ae99SBarry Smith -   nlevels - the number of levels of coarsening
60047c6ae99SBarry Smith 
60147c6ae99SBarry Smith     Output Parameter:
60247c6ae99SBarry Smith .   dmc - the coarsened DM hierarchy
60347c6ae99SBarry Smith 
60447c6ae99SBarry Smith     Level: developer
60547c6ae99SBarry Smith 
60647c6ae99SBarry Smith .seealso DMRefineHierarchy(), DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetInterpolation()
60747c6ae99SBarry Smith 
60847c6ae99SBarry Smith @*/
60947c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMCoarsenHierarchy(DM dm, PetscInt nlevels, DM dmc[])
61047c6ae99SBarry Smith {
61147c6ae99SBarry Smith   PetscErrorCode ierr;
61247c6ae99SBarry Smith 
61347c6ae99SBarry Smith   PetscFunctionBegin;
61447c6ae99SBarry Smith   if (nlevels < 0) SETERRQ(((PetscObject)dm)->comm,PETSC_ERR_ARG_OUTOFRANGE,"nlevels cannot be negative");
61547c6ae99SBarry Smith   if (nlevels == 0) PetscFunctionReturn(0);
61647c6ae99SBarry Smith   PetscValidPointer(dmc,3);
61747c6ae99SBarry Smith   if (dm->ops->coarsenhierarchy) {
61847c6ae99SBarry Smith     ierr = (*dm->ops->coarsenhierarchy)(dm, nlevels, dmc);CHKERRQ(ierr);
61947c6ae99SBarry Smith   } else if (dm->ops->coarsen) {
62047c6ae99SBarry Smith     PetscInt i;
62147c6ae99SBarry Smith 
62247c6ae99SBarry Smith     ierr = DMCoarsen(dm,((PetscObject)dm)->comm,&dmc[0]);CHKERRQ(ierr);
62347c6ae99SBarry Smith     for (i=1; i<nlevels; i++) {
62447c6ae99SBarry Smith       ierr = DMCoarsen(dmc[i-1],((PetscObject)dm)->comm,&dmc[i]);CHKERRQ(ierr);
62547c6ae99SBarry Smith     }
62647c6ae99SBarry Smith   } else {
62747c6ae99SBarry Smith     SETERRQ(((PetscObject)dm)->comm,PETSC_ERR_SUP,"No CoarsenHierarchy for this DM yet");
62847c6ae99SBarry Smith   }
62947c6ae99SBarry Smith   PetscFunctionReturn(0);
63047c6ae99SBarry Smith }
63147c6ae99SBarry Smith 
63247c6ae99SBarry Smith #undef __FUNCT__
63347c6ae99SBarry Smith #define __FUNCT__ "DMGetAggregates"
63447c6ae99SBarry Smith /*@
63547c6ae99SBarry Smith    DMGetAggregates - Gets the aggregates that map between
63647c6ae99SBarry Smith    grids associated with two DMs.
63747c6ae99SBarry Smith 
63847c6ae99SBarry Smith    Collective on DM
63947c6ae99SBarry Smith 
64047c6ae99SBarry Smith    Input Parameters:
64147c6ae99SBarry Smith +  dmc - the coarse grid DM
64247c6ae99SBarry Smith -  dmf - the fine grid DM
64347c6ae99SBarry Smith 
64447c6ae99SBarry Smith    Output Parameters:
64547c6ae99SBarry Smith .  rest - the restriction matrix (transpose of the projection matrix)
64647c6ae99SBarry Smith 
64747c6ae99SBarry Smith    Level: intermediate
64847c6ae99SBarry Smith 
64947c6ae99SBarry Smith .keywords: interpolation, restriction, multigrid
65047c6ae99SBarry Smith 
65147c6ae99SBarry Smith .seealso: DMRefine(), DMGetInjection(), DMGetInterpolation()
65247c6ae99SBarry Smith @*/
65347c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMGetAggregates(DM dmc, DM dmf, Mat *rest)
65447c6ae99SBarry Smith {
65547c6ae99SBarry Smith   PetscErrorCode ierr;
65647c6ae99SBarry Smith 
65747c6ae99SBarry Smith   PetscFunctionBegin;
65847c6ae99SBarry Smith   ierr = (*dmc->ops->getaggregates)(dmc, dmf, rest);CHKERRQ(ierr);
65947c6ae99SBarry Smith   PetscFunctionReturn(0);
66047c6ae99SBarry Smith }
66147c6ae99SBarry Smith 
66247c6ae99SBarry Smith #undef __FUNCT__
66347c6ae99SBarry Smith #define __FUNCT__ "DMSetContext"
66447c6ae99SBarry Smith /*@
66547c6ae99SBarry Smith     DMSetContext - Set a user context into a DM object
66647c6ae99SBarry Smith 
66747c6ae99SBarry Smith     Not Collective
66847c6ae99SBarry Smith 
66947c6ae99SBarry Smith     Input Parameters:
67047c6ae99SBarry Smith +   dm - the DM object
67147c6ae99SBarry Smith -   ctx - the user context
67247c6ae99SBarry Smith 
67347c6ae99SBarry Smith     Level: intermediate
67447c6ae99SBarry Smith 
67547c6ae99SBarry Smith .seealso DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix(), DMGetContext()
67647c6ae99SBarry Smith 
67747c6ae99SBarry Smith @*/
67847c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMSetContext(DM dm,void *ctx)
67947c6ae99SBarry Smith {
68047c6ae99SBarry Smith   PetscFunctionBegin;
68147c6ae99SBarry Smith   dm->ctx = ctx;
68247c6ae99SBarry Smith   PetscFunctionReturn(0);
68347c6ae99SBarry Smith }
68447c6ae99SBarry Smith 
68547c6ae99SBarry Smith #undef __FUNCT__
68647c6ae99SBarry Smith #define __FUNCT__ "DMGetContext"
68747c6ae99SBarry Smith /*@
68847c6ae99SBarry Smith     DMGetContext - Gets a user context from a DM object
68947c6ae99SBarry Smith 
69047c6ae99SBarry Smith     Not Collective
69147c6ae99SBarry Smith 
69247c6ae99SBarry Smith     Input Parameter:
69347c6ae99SBarry Smith .   dm - the DM object
69447c6ae99SBarry Smith 
69547c6ae99SBarry Smith     Output Parameter:
69647c6ae99SBarry Smith .   ctx - the user context
69747c6ae99SBarry Smith 
69847c6ae99SBarry Smith     Level: intermediate
69947c6ae99SBarry Smith 
70047c6ae99SBarry Smith .seealso DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix(), DMGetContext()
70147c6ae99SBarry Smith 
70247c6ae99SBarry Smith @*/
70347c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMGetContext(DM dm,void **ctx)
70447c6ae99SBarry Smith {
70547c6ae99SBarry Smith   PetscFunctionBegin;
70647c6ae99SBarry Smith   *ctx = dm->ctx;
70747c6ae99SBarry Smith   PetscFunctionReturn(0);
70847c6ae99SBarry Smith }
70947c6ae99SBarry Smith 
71047c6ae99SBarry Smith #undef __FUNCT__
71147c6ae99SBarry Smith #define __FUNCT__ "DMSetInitialGuess"
71247c6ae99SBarry Smith /*@
71347c6ae99SBarry Smith     DMSetInitialGuess - sets a function to compute an initial guess vector entries for the solvers
71447c6ae99SBarry Smith 
71547c6ae99SBarry Smith     Logically Collective on DM
71647c6ae99SBarry Smith 
71747c6ae99SBarry Smith     Input Parameter:
71847c6ae99SBarry Smith +   dm - the DM object to destroy
71947c6ae99SBarry Smith -   f - the function to compute the initial guess
72047c6ae99SBarry Smith 
72147c6ae99SBarry Smith     Level: intermediate
72247c6ae99SBarry Smith 
72347c6ae99SBarry Smith .seealso DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix(), DMGetContext(), DMSetFunction(), DMSetJacobian()
72447c6ae99SBarry Smith 
72547c6ae99SBarry Smith @*/
72647c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMSetInitialGuess(DM dm,PetscErrorCode (*f)(DM,Vec))
72747c6ae99SBarry Smith {
72847c6ae99SBarry Smith   PetscFunctionBegin;
72947c6ae99SBarry Smith   dm->ops->initialguess = f;
73047c6ae99SBarry Smith   PetscFunctionReturn(0);
73147c6ae99SBarry Smith }
73247c6ae99SBarry Smith 
73347c6ae99SBarry Smith #undef __FUNCT__
73447c6ae99SBarry Smith #define __FUNCT__ "DMSetFunction"
73547c6ae99SBarry Smith /*@
73647c6ae99SBarry Smith     DMSetFunction - sets a function to compute the right hand side vector entries for the KSP solver or nonlinear function for SNES
73747c6ae99SBarry Smith 
73847c6ae99SBarry Smith     Logically Collective on DM
73947c6ae99SBarry Smith 
74047c6ae99SBarry Smith     Input Parameter:
74147c6ae99SBarry Smith +   dm - the DM object
74247c6ae99SBarry Smith -   f - the function to compute (use PETSC_NULL to cancel a previous function that was set)
74347c6ae99SBarry Smith 
74447c6ae99SBarry Smith     Level: intermediate
74547c6ae99SBarry Smith 
74647c6ae99SBarry Smith     Notes: This sets both the function for function evaluations and the function used to compute Jacobians via finite differences if no Jacobian
74747c6ae99SBarry Smith            computer is provided with DMSetJacobian(). Canceling cancels the function, but not the function used to compute the Jacobian.
74847c6ae99SBarry Smith 
74947c6ae99SBarry Smith .seealso DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix(), DMGetContext(), DMSetInitialGuess(),
75047c6ae99SBarry Smith          DMSetJacobian()
75147c6ae99SBarry Smith 
75247c6ae99SBarry Smith @*/
75347c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMSetFunction(DM dm,PetscErrorCode (*f)(DM,Vec,Vec))
75447c6ae99SBarry Smith {
75547c6ae99SBarry Smith   PetscFunctionBegin;
75647c6ae99SBarry Smith   dm->ops->function = f;
75747c6ae99SBarry Smith   if (f) {
75847c6ae99SBarry Smith     dm->ops->functionj = f;
75947c6ae99SBarry Smith   }
76047c6ae99SBarry Smith   PetscFunctionReturn(0);
76147c6ae99SBarry Smith }
76247c6ae99SBarry Smith 
76347c6ae99SBarry Smith #undef __FUNCT__
76447c6ae99SBarry Smith #define __FUNCT__ "DMSetJacobian"
76547c6ae99SBarry Smith /*@
76647c6ae99SBarry Smith     DMSetJacobian - sets a function to compute the matrix entries for the KSP solver or Jacobian for SNES
76747c6ae99SBarry Smith 
76847c6ae99SBarry Smith     Logically Collective on DM
76947c6ae99SBarry Smith 
77047c6ae99SBarry Smith     Input Parameter:
77147c6ae99SBarry Smith +   dm - the DM object to destroy
77247c6ae99SBarry Smith -   f - the function to compute the matrix entries
77347c6ae99SBarry Smith 
77447c6ae99SBarry Smith     Level: intermediate
77547c6ae99SBarry Smith 
77647c6ae99SBarry Smith .seealso DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix(), DMGetContext(), DMSetInitialGuess(),
77747c6ae99SBarry Smith          DMSetFunction()
77847c6ae99SBarry Smith 
77947c6ae99SBarry Smith @*/
78047c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMSetJacobian(DM dm,PetscErrorCode (*f)(DM,Vec,Mat,Mat,MatStructure*))
78147c6ae99SBarry Smith {
78247c6ae99SBarry Smith   PetscFunctionBegin;
78347c6ae99SBarry Smith   dm->ops->jacobian = f;
78447c6ae99SBarry Smith   PetscFunctionReturn(0);
78547c6ae99SBarry Smith }
78647c6ae99SBarry Smith 
78747c6ae99SBarry Smith #undef __FUNCT__
78847c6ae99SBarry Smith #define __FUNCT__ "DMComputeInitialGuess"
78947c6ae99SBarry Smith /*@
79047c6ae99SBarry Smith     DMComputeInitialGuess - computes an initial guess vector entries for the KSP solvers
79147c6ae99SBarry Smith 
79247c6ae99SBarry Smith     Collective on DM
79347c6ae99SBarry Smith 
79447c6ae99SBarry Smith     Input Parameter:
79547c6ae99SBarry Smith +   dm - the DM object to destroy
79647c6ae99SBarry Smith -   x - the vector to hold the initial guess values
79747c6ae99SBarry Smith 
79847c6ae99SBarry Smith     Level: developer
79947c6ae99SBarry Smith 
80047c6ae99SBarry Smith .seealso DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix(), DMGetContext(), DMSetRhs(), DMSetMat()
80147c6ae99SBarry Smith 
80247c6ae99SBarry Smith @*/
80347c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMComputeInitialGuess(DM dm,Vec x)
80447c6ae99SBarry Smith {
80547c6ae99SBarry Smith   PetscErrorCode ierr;
80647c6ae99SBarry Smith   PetscFunctionBegin;
80747c6ae99SBarry Smith   if (!dm->ops->initialguess) SETERRQ(((PetscObject)dm)->comm,PETSC_ERR_ARG_WRONGSTATE,"Need to provide function with DMSetInitialGuess()");
80847c6ae99SBarry Smith   ierr = (*dm->ops->initialguess)(dm,x);CHKERRQ(ierr);
80947c6ae99SBarry Smith   PetscFunctionReturn(0);
81047c6ae99SBarry Smith }
81147c6ae99SBarry Smith 
81247c6ae99SBarry Smith #undef __FUNCT__
81347c6ae99SBarry Smith #define __FUNCT__ "DMHasInitialGuess"
81447c6ae99SBarry Smith /*@
81547c6ae99SBarry Smith     DMHasInitialGuess - does the DM object have an initial guess function
81647c6ae99SBarry Smith 
81747c6ae99SBarry Smith     Not Collective
81847c6ae99SBarry Smith 
81947c6ae99SBarry Smith     Input Parameter:
82047c6ae99SBarry Smith .   dm - the DM object to destroy
82147c6ae99SBarry Smith 
82247c6ae99SBarry Smith     Output Parameter:
82347c6ae99SBarry Smith .   flg - PETSC_TRUE if function exists
82447c6ae99SBarry Smith 
82547c6ae99SBarry Smith     Level: developer
82647c6ae99SBarry Smith 
82747c6ae99SBarry Smith .seealso DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix(), DMGetContext(), DMSetFunction(), DMSetJacobian()
82847c6ae99SBarry Smith 
82947c6ae99SBarry Smith @*/
83047c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMHasInitialGuess(DM dm,PetscBool  *flg)
83147c6ae99SBarry Smith {
83247c6ae99SBarry Smith   PetscFunctionBegin;
83347c6ae99SBarry Smith   *flg =  (dm->ops->initialguess) ? PETSC_TRUE : PETSC_FALSE;
83447c6ae99SBarry Smith   PetscFunctionReturn(0);
83547c6ae99SBarry Smith }
83647c6ae99SBarry Smith 
83747c6ae99SBarry Smith #undef __FUNCT__
83847c6ae99SBarry Smith #define __FUNCT__ "DMHasFunction"
83947c6ae99SBarry Smith /*@
84047c6ae99SBarry Smith     DMHasFunction - does the DM object have a function
84147c6ae99SBarry Smith 
84247c6ae99SBarry Smith     Not Collective
84347c6ae99SBarry Smith 
84447c6ae99SBarry Smith     Input Parameter:
84547c6ae99SBarry Smith .   dm - the DM object to destroy
84647c6ae99SBarry Smith 
84747c6ae99SBarry Smith     Output Parameter:
84847c6ae99SBarry Smith .   flg - PETSC_TRUE if function exists
84947c6ae99SBarry Smith 
85047c6ae99SBarry Smith     Level: developer
85147c6ae99SBarry Smith 
85247c6ae99SBarry Smith .seealso DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix(), DMGetContext(), DMSetFunction(), DMSetJacobian()
85347c6ae99SBarry Smith 
85447c6ae99SBarry Smith @*/
85547c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMHasFunction(DM dm,PetscBool  *flg)
85647c6ae99SBarry Smith {
85747c6ae99SBarry Smith   PetscFunctionBegin;
85847c6ae99SBarry Smith   *flg =  (dm->ops->function) ? PETSC_TRUE : PETSC_FALSE;
85947c6ae99SBarry Smith   PetscFunctionReturn(0);
86047c6ae99SBarry Smith }
86147c6ae99SBarry Smith 
86247c6ae99SBarry Smith #undef __FUNCT__
86347c6ae99SBarry Smith #define __FUNCT__ "DMHasJacobian"
86447c6ae99SBarry Smith /*@
86547c6ae99SBarry Smith     DMHasJacobian - does the DM object have a matrix function
86647c6ae99SBarry Smith 
86747c6ae99SBarry Smith     Not Collective
86847c6ae99SBarry Smith 
86947c6ae99SBarry Smith     Input Parameter:
87047c6ae99SBarry Smith .   dm - the DM object to destroy
87147c6ae99SBarry Smith 
87247c6ae99SBarry Smith     Output Parameter:
87347c6ae99SBarry Smith .   flg - PETSC_TRUE if function exists
87447c6ae99SBarry Smith 
87547c6ae99SBarry Smith     Level: developer
87647c6ae99SBarry Smith 
87747c6ae99SBarry Smith .seealso DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix(), DMGetContext(), DMSetFunction(), DMSetJacobian()
87847c6ae99SBarry Smith 
87947c6ae99SBarry Smith @*/
88047c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMHasJacobian(DM dm,PetscBool  *flg)
88147c6ae99SBarry Smith {
88247c6ae99SBarry Smith   PetscFunctionBegin;
88347c6ae99SBarry Smith   *flg =  (dm->ops->jacobian) ? PETSC_TRUE : PETSC_FALSE;
88447c6ae99SBarry Smith   PetscFunctionReturn(0);
88547c6ae99SBarry Smith }
88647c6ae99SBarry Smith 
88747c6ae99SBarry Smith #undef __FUNCT__
88847c6ae99SBarry Smith #define __FUNCT__ "DMComputeFunction"
88947c6ae99SBarry Smith /*@
89047c6ae99SBarry Smith     DMComputeFunction - computes the right hand side vector entries for the KSP solver or nonlinear function for SNES
89147c6ae99SBarry Smith 
89247c6ae99SBarry Smith     Collective on DM
89347c6ae99SBarry Smith 
89447c6ae99SBarry Smith     Input Parameter:
89547c6ae99SBarry Smith +   dm - the DM object to destroy
89647c6ae99SBarry Smith .   x - the location where the function is evaluationed, may be ignored for linear problems
89747c6ae99SBarry Smith -   b - the vector to hold the right hand side entries
89847c6ae99SBarry Smith 
89947c6ae99SBarry Smith     Level: developer
90047c6ae99SBarry Smith 
90147c6ae99SBarry Smith .seealso DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix(), DMGetContext(), DMSetInitialGuess(),
90247c6ae99SBarry Smith          DMSetJacobian()
90347c6ae99SBarry Smith 
90447c6ae99SBarry Smith @*/
90547c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMComputeFunction(DM dm,Vec x,Vec b)
90647c6ae99SBarry Smith {
90747c6ae99SBarry Smith   PetscErrorCode ierr;
90847c6ae99SBarry Smith   PetscFunctionBegin;
90947c6ae99SBarry Smith   if (!dm->ops->function) SETERRQ(((PetscObject)dm)->comm,PETSC_ERR_ARG_WRONGSTATE,"Need to provide function with DMSetFunction()");
91047c6ae99SBarry Smith   if (!x) x = dm->x;
91147c6ae99SBarry Smith   ierr = (*dm->ops->function)(dm,x,b);CHKERRQ(ierr);
91247c6ae99SBarry Smith   PetscFunctionReturn(0);
91347c6ae99SBarry Smith }
91447c6ae99SBarry Smith 
91547c6ae99SBarry Smith 
91647c6ae99SBarry Smith #undef __FUNCT__
91747c6ae99SBarry Smith #define __FUNCT__ "DMComputeJacobian"
91847c6ae99SBarry Smith /*@
91947c6ae99SBarry Smith     DMComputeJacobian - compute the matrix entries for the solver
92047c6ae99SBarry Smith 
92147c6ae99SBarry Smith     Collective on DM
92247c6ae99SBarry Smith 
92347c6ae99SBarry Smith     Input Parameter:
92447c6ae99SBarry Smith +   dm - the DM object
92547c6ae99SBarry Smith .   x - location to compute Jacobian at; may be ignored for linear problems
92647c6ae99SBarry Smith .   A - matrix that defines the operator for the linear solve
92747c6ae99SBarry Smith -   B - the matrix used to construct the preconditioner
92847c6ae99SBarry Smith 
92947c6ae99SBarry Smith     Level: developer
93047c6ae99SBarry Smith 
93147c6ae99SBarry Smith .seealso DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix(), DMGetContext(), DMSetInitialGuess(),
93247c6ae99SBarry Smith          DMSetFunction()
93347c6ae99SBarry Smith 
93447c6ae99SBarry Smith @*/
93547c6ae99SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMComputeJacobian(DM dm,Vec x,Mat A,Mat B,MatStructure *stflag)
93647c6ae99SBarry Smith {
93747c6ae99SBarry Smith   PetscErrorCode ierr;
93847c6ae99SBarry Smith 
93947c6ae99SBarry Smith   PetscFunctionBegin;
94047c6ae99SBarry Smith   if (!dm->ops->jacobian) {
94147c6ae99SBarry Smith     ISColoring    coloring;
94247c6ae99SBarry Smith     MatFDColoring fd;
94347c6ae99SBarry Smith 
94447c6ae99SBarry Smith     ierr = DMGetColoring(dm,IS_COLORING_GHOSTED,MATAIJ,&coloring);CHKERRQ(ierr);
94547c6ae99SBarry Smith     ierr = MatFDColoringCreate(B,coloring,&fd);CHKERRQ(ierr);
94647c6ae99SBarry Smith     ierr = ISColoringDestroy(coloring);CHKERRQ(ierr);
94747c6ae99SBarry Smith     ierr = MatFDColoringSetFunction(fd,(PetscErrorCode (*)(void))dm->ops->functionj,dm);CHKERRQ(ierr);
94847c6ae99SBarry Smith     dm->fd = fd;
94947c6ae99SBarry Smith     dm->ops->jacobian = DMComputeJacobianDefault;
95047c6ae99SBarry Smith 
95147c6ae99SBarry Smith     if (!dm->x) {
95247c6ae99SBarry Smith       ierr = MatGetVecs(B,&dm->x,PETSC_NULL);CHKERRQ(ierr);
95347c6ae99SBarry Smith     }
95447c6ae99SBarry Smith   }
95547c6ae99SBarry Smith   if (!x) x = dm->x;
95647c6ae99SBarry Smith   ierr = (*dm->ops->jacobian)(dm,x,A,B,stflag);CHKERRQ(ierr);
95747c6ae99SBarry Smith   PetscFunctionReturn(0);
95847c6ae99SBarry Smith }
959264ace61SBarry Smith 
960264ace61SBarry Smith PetscFList DMList                       = PETSC_NULL;
961264ace61SBarry Smith PetscBool  DMRegisterAllCalled          = PETSC_FALSE;
962264ace61SBarry Smith 
963264ace61SBarry Smith #undef __FUNCT__
964264ace61SBarry Smith #define __FUNCT__ "DMSetType"
965264ace61SBarry Smith /*@C
966264ace61SBarry Smith   DMSetType - Builds a DM, for a particular DM implementation.
967264ace61SBarry Smith 
968264ace61SBarry Smith   Collective on DM
969264ace61SBarry Smith 
970264ace61SBarry Smith   Input Parameters:
971264ace61SBarry Smith + dm     - The DM object
972264ace61SBarry Smith - method - The name of the DM type
973264ace61SBarry Smith 
974264ace61SBarry Smith   Options Database Key:
975264ace61SBarry Smith . -dm_type <type> - Sets the DM type; use -help for a list of available types
976264ace61SBarry Smith 
977264ace61SBarry Smith   Notes:
978264ace61SBarry Smith   See "petsc/include/petscda.h" for available DM types (for instance, DM1D, DM2D, or DM3D).
979264ace61SBarry Smith 
980264ace61SBarry Smith   Level: intermediate
981264ace61SBarry Smith 
982264ace61SBarry Smith .keywords: DM, set, type
983264ace61SBarry Smith .seealso: DMGetType(), DMCreate()
984264ace61SBarry Smith @*/
985264ace61SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMSetType(DM dm, const DMType method)
986264ace61SBarry Smith {
987264ace61SBarry Smith   PetscErrorCode (*r)(DM);
988264ace61SBarry Smith   PetscBool      match;
989264ace61SBarry Smith   PetscErrorCode ierr;
990264ace61SBarry Smith 
991264ace61SBarry Smith   PetscFunctionBegin;
992264ace61SBarry Smith   PetscValidHeaderSpecific(dm, DM_CLASSID,1);
993264ace61SBarry Smith   ierr = PetscTypeCompare((PetscObject) dm, method, &match);CHKERRQ(ierr);
994264ace61SBarry Smith   if (match) PetscFunctionReturn(0);
995264ace61SBarry Smith 
996264ace61SBarry Smith   if (!DMRegisterAllCalled) {ierr = DMRegisterAll(PETSC_NULL);CHKERRQ(ierr);}
997264ace61SBarry Smith   ierr = PetscFListFind(DMList, ((PetscObject)dm)->comm, method,(void (**)(void)) &r);CHKERRQ(ierr);
998264ace61SBarry Smith   if (!r) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown DM type: %s", method);
999264ace61SBarry Smith 
1000264ace61SBarry Smith   if (dm->ops->destroy) {
1001264ace61SBarry Smith     ierr = (*dm->ops->destroy)(dm);CHKERRQ(ierr);
1002264ace61SBarry Smith   }
1003264ace61SBarry Smith   ierr = (*r)(dm);CHKERRQ(ierr);
1004264ace61SBarry Smith   ierr = PetscObjectChangeTypeName((PetscObject)dm,method);CHKERRQ(ierr);
1005264ace61SBarry Smith   PetscFunctionReturn(0);
1006264ace61SBarry Smith }
1007264ace61SBarry Smith 
1008264ace61SBarry Smith #undef __FUNCT__
1009264ace61SBarry Smith #define __FUNCT__ "DMGetType"
1010264ace61SBarry Smith /*@C
1011264ace61SBarry Smith   DMGetType - Gets the DM type name (as a string) from the DM.
1012264ace61SBarry Smith 
1013264ace61SBarry Smith   Not Collective
1014264ace61SBarry Smith 
1015264ace61SBarry Smith   Input Parameter:
1016264ace61SBarry Smith . dm  - The DM
1017264ace61SBarry Smith 
1018264ace61SBarry Smith   Output Parameter:
1019264ace61SBarry Smith . type - The DM type name
1020264ace61SBarry Smith 
1021264ace61SBarry Smith   Level: intermediate
1022264ace61SBarry Smith 
1023264ace61SBarry Smith .keywords: DM, get, type, name
1024264ace61SBarry Smith .seealso: DMSetType(), DMCreate()
1025264ace61SBarry Smith @*/
1026264ace61SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMGetType(DM dm, const DMType *type)
1027264ace61SBarry Smith {
1028264ace61SBarry Smith   PetscErrorCode ierr;
1029264ace61SBarry Smith 
1030264ace61SBarry Smith   PetscFunctionBegin;
1031264ace61SBarry Smith   PetscValidHeaderSpecific(dm, DM_CLASSID,1);
1032264ace61SBarry Smith   PetscValidCharPointer(type,2);
1033264ace61SBarry Smith   if (!DMRegisterAllCalled) {
1034264ace61SBarry Smith     ierr = DMRegisterAll(PETSC_NULL);CHKERRQ(ierr);
1035264ace61SBarry Smith   }
1036264ace61SBarry Smith   *type = ((PetscObject)dm)->type_name;
1037264ace61SBarry Smith   PetscFunctionReturn(0);
1038264ace61SBarry Smith }
1039264ace61SBarry Smith 
1040264ace61SBarry Smith 
1041264ace61SBarry Smith /*--------------------------------------------------------------------------------------------------------------------*/
1042264ace61SBarry Smith 
1043264ace61SBarry Smith #undef __FUNCT__
1044264ace61SBarry Smith #define __FUNCT__ "DMRegister"
1045264ace61SBarry Smith /*@C
1046264ace61SBarry Smith   DMRegister - See DMRegisterDynamic()
1047264ace61SBarry Smith 
1048264ace61SBarry Smith   Level: advanced
1049264ace61SBarry Smith @*/
1050264ace61SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMRegister(const char sname[], const char path[], const char name[], PetscErrorCode (*function)(DM))
1051264ace61SBarry Smith {
1052264ace61SBarry Smith   char fullname[PETSC_MAX_PATH_LEN];
1053264ace61SBarry Smith   PetscErrorCode ierr;
1054264ace61SBarry Smith 
1055264ace61SBarry Smith   PetscFunctionBegin;
1056264ace61SBarry Smith   ierr = PetscStrcpy(fullname, path);CHKERRQ(ierr);
1057264ace61SBarry Smith   ierr = PetscStrcat(fullname, ":");CHKERRQ(ierr);
1058264ace61SBarry Smith   ierr = PetscStrcat(fullname, name);CHKERRQ(ierr);
1059264ace61SBarry Smith   ierr = PetscFListAdd(&DMList, sname, fullname, (void (*)(void)) function);CHKERRQ(ierr);
1060264ace61SBarry Smith   PetscFunctionReturn(0);
1061264ace61SBarry Smith }
1062264ace61SBarry Smith 
1063264ace61SBarry Smith 
1064264ace61SBarry Smith /*--------------------------------------------------------------------------------------------------------------------*/
1065264ace61SBarry Smith #undef __FUNCT__
1066264ace61SBarry Smith #define __FUNCT__ "DMRegisterDestroy"
1067264ace61SBarry Smith /*@C
1068264ace61SBarry Smith    DMRegisterDestroy - Frees the list of DM methods that were registered by DMRegister()/DMRegisterDynamic().
1069264ace61SBarry Smith 
1070264ace61SBarry Smith    Not Collective
1071264ace61SBarry Smith 
1072264ace61SBarry Smith    Level: advanced
1073264ace61SBarry Smith 
1074264ace61SBarry Smith .keywords: DM, register, destroy
1075264ace61SBarry Smith .seealso: DMRegister(), DMRegisterAll(), DMRegisterDynamic()
1076264ace61SBarry Smith @*/
1077264ace61SBarry Smith PetscErrorCode PETSCDM_DLLEXPORT DMRegisterDestroy(void)
1078264ace61SBarry Smith {
1079264ace61SBarry Smith   PetscErrorCode ierr;
1080264ace61SBarry Smith 
1081264ace61SBarry Smith   PetscFunctionBegin;
1082264ace61SBarry Smith   ierr = PetscFListDestroy(&DMList);CHKERRQ(ierr);
1083264ace61SBarry Smith   DMRegisterAllCalled = PETSC_FALSE;
1084264ace61SBarry Smith   PetscFunctionReturn(0);
1085264ace61SBarry Smith }
1086