Actual source code: dm.c
1:
2: #include src/dm/da/daimpl.h
4: /*
5: Provides an interface for functionality needed by the DAMG routines.
6: Currently this interface is supported by the DA and VecPack objects
7:
8: Note: this is actually no such thing as a DM object, rather it is
9: the common set of functions shared by DA and VecPack.
11: */
15: /*@C
16: DMDestroy - Destroys a vector packer or DA.
18: Collective on DM
20: Input Parameter:
21: . dm - the DM object to destroy
23: Level: developer
25: .seealso DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix()
27: @*/
28: PetscErrorCode DMDestroy(DM dm)
29: {
33: (*dm->bops->destroy)((PetscObject)dm);
34: return(0);
35: }
39: /*@C
40: DMView - Views a vector packer or DA.
42: Collective on DM
44: Input Parameter:
45: + dm - the DM object to view
46: - v - the viewer
48: Level: developer
50: .seealso DMDestroy(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix()
52: @*/
53: PetscErrorCode DMView(DM dm,PetscViewer v)
54: {
58: if (dm->bops->view) {
59: (*dm->bops->view)((PetscObject)dm,v);
60: }
61: return(0);
62: }
66: /*@C
67: DMCreateGlobalVector - Creates a global vector from a DA or VecPack object
69: Collective on DM
71: Input Parameter:
72: . dm - the DM object
74: Output Parameter:
75: . vec - the global vector
77: Level: developer
79: .seealso DMDestroy(), DMView(), DMGetInterpolation(), DMGetColoring(), DMGetMatrix()
81: @*/
82: PetscErrorCode DMCreateGlobalVector(DM dm,Vec *vec)
83: {
87: (*dm->ops->createglobalvector)(dm,vec);
88: return(0);
89: }
93: /*@C
94: DMGetInterpolation - Gets interpolation matrix between two DA or VecPack objects
96: Collective on DM
98: Input Parameter:
99: + dm1 - the DM object
100: - dm2 - the second, coarser DM object
102: Output Parameter:
103: + mat - the interpolation
104: - vec - the scaling (optional)
106: Level: developer
108: .seealso DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetColoring(), DMGetMatrix()
110: @*/
111: PetscErrorCode DMGetInterpolation(DM dm1,DM dm2,Mat *mat,Vec *vec)
112: {
116: (*dm1->ops->getinterpolation)(dm1,dm2,mat,vec);
117: return(0);
118: }
122: /*@C
123: DMGetInjection - Gets injection matrix between two DA or VecPack objects
125: Collective on DM
127: Input Parameter:
128: + dm1 - the DM object
129: - dm2 - the second, coarser DM object
131: Output Parameter:
132: . mat - the injection
134: Level: developer
136: .seealso DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetColoring(), DMGetMatrix(), DMGetInterpolation()
138: @*/
139: PetscErrorCode DMGetInjection(DM dm1,DM dm2,VecScatter *ctx)
140: {
144: (*dm1->ops->getinjection)(dm1,dm2,ctx);
145: return(0);
146: }
150: /*@C
151: DMGetColoring - Gets coloring and empty Jacobian for a DA or VecPack
153: Collective on DM
155: Input Parameter:
156: + dm - the DM object
157: - ctype - IS_COLORING_GHOSTED or IS_COLORING_LOCAL
159: Output Parameter:
160: . coloring - the coloring
162: Level: developer
164: .seealso DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetMatrix()
166: @*/
167: PetscErrorCode DMGetColoring(DM dm,ISColoringType ctype,ISColoring *coloring)
168: {
172: (*dm->ops->getcoloring)(dm,ctype,coloring);
173: return(0);
174: }
178: /*@C
179: DMGetMatrix - Gets empty Jacobian for a DA or VecPack
181: Collective on DM
183: Input Parameter:
184: + dm - the DM object
185: - mtype - Supported types are MATSEQAIJ, MATMPIAIJ, MATSEQBAIJ, MATMPIBAIJ, or
186: any type which inherits from one of these (such as MATAIJ, MATLUSOL, etc.).
188: Output Parameter:
189: . mat - the empty Jacobian
191: Level: developer
193: .seealso DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetInterpolation(), DMGetMatrix()
195: @*/
196: PetscErrorCode DMGetMatrix(DM dm,const MatType mtype,Mat *mat)
197: {
201: (*dm->ops->getmatrix)(dm,mtype,mat);
202: return(0);
203: }
207: /*@C
208: DMRefine - Refines a DA or VecPack object
210: Collective on DM
212: Input Parameter:
213: + dm - the DM object
214: - comm - the communicator to contain the new DM object (or PETSC_NULL)
216: Output Parameter:
217: . dmf - the refined DM
219: Level: developer
221: .seealso DMDestroy(), DMView(), DMCreateGlobalVector(), DMGetInterpolation()
223: @*/
224: PetscErrorCode DMRefine(DM dm,MPI_Comm comm,DM *dmf)
225: {
229: (*dm->ops->refine)(dm,comm,dmf);
230: return(0);
231: }