xref: /petsc/src/ts/utils/dmplexts.c (revision c5d70e09b8314f26940d903f61426f33ee71ada9)
1af0996ceSBarry Smith #include <petsc/private/dmpleximpl.h> /*I "petscdmplex.h" I*/
2af0996ceSBarry Smith #include <petsc/private/tsimpl.h>     /*I "petscts.h" I*/
337c2070cSMatthew G. Knepley #include <petsc/private/snesimpl.h>
4924a1b8fSMatthew G. Knepley #include <petscds.h>
56dbbd306SMatthew G. Knepley #include <petscfv.h>
66dbbd306SMatthew G. Knepley 
7254c1ad2SMatthew G. Knepley #undef __FUNCT__
86da023fcSToby Isaac #define __FUNCT__ "DMTSConvertPlex"
96da023fcSToby Isaac static PetscErrorCode DMTSConvertPlex(DM dm, DM *plex, PetscBool copy)
106da023fcSToby Isaac {
116da023fcSToby Isaac   PetscBool      isPlex;
126da023fcSToby Isaac   PetscErrorCode ierr;
136da023fcSToby Isaac 
146da023fcSToby Isaac   PetscFunctionBegin;
156da023fcSToby Isaac   ierr = PetscObjectTypeCompare((PetscObject)dm,DMPLEX,&isPlex);CHKERRQ(ierr);
166da023fcSToby Isaac   if (isPlex) {
176da023fcSToby Isaac     *plex = dm;
186da023fcSToby Isaac     ierr = PetscObjectReference((PetscObject)dm);CHKERRQ(ierr);
196da023fcSToby Isaac   }
206da023fcSToby Isaac   else {
216da023fcSToby Isaac     ierr = DMConvert(dm,DMPLEX,plex);CHKERRQ(ierr);
226da023fcSToby Isaac     if (copy) {
236da023fcSToby Isaac       PetscInt    i;
246da023fcSToby Isaac       PetscObject obj;
256da023fcSToby Isaac       const char *comps[3] = {"A","dmAux","dmCh"};
266da023fcSToby Isaac 
276da023fcSToby Isaac       ierr = DMCopyDMTS(dm,*plex);CHKERRQ(ierr);
286da023fcSToby Isaac       ierr = DMCopyDMSNES(dm,*plex);CHKERRQ(ierr);
296da023fcSToby Isaac       for (i = 0; i < 3; i++) {
306da023fcSToby Isaac         ierr = PetscObjectQuery((PetscObject)dm,comps[i],&obj);CHKERRQ(ierr);
316da023fcSToby Isaac         ierr = PetscObjectCompose((PetscObject)*plex,comps[i],obj);CHKERRQ(ierr);
326da023fcSToby Isaac       }
336da023fcSToby Isaac     }
346da023fcSToby Isaac   }
356da023fcSToby Isaac   PetscFunctionReturn(0);
366da023fcSToby Isaac }
376da023fcSToby Isaac 
386da023fcSToby Isaac 
396da023fcSToby Isaac #undef __FUNCT__
40b6aca0f9SMatthew G. Knepley #define __FUNCT__ "DMPlexTSGetGeometryFVM"
41c510411aSMatthew G. Knepley /*@
42b6aca0f9SMatthew G. Knepley   DMPlexTSGetGeometryFVM - Return precomputed geometric data
43c510411aSMatthew G. Knepley 
44c510411aSMatthew G. Knepley   Input Parameter:
45c510411aSMatthew G. Knepley . dm - The DM
46c510411aSMatthew G. Knepley 
47c510411aSMatthew G. Knepley   Output Parameters:
48c510411aSMatthew G. Knepley + facegeom - The values precomputed from face geometry
49c510411aSMatthew G. Knepley . cellgeom - The values precomputed from cell geometry
50c510411aSMatthew G. Knepley - minRadius - The minimum radius over the mesh of an inscribed sphere in a cell
51c510411aSMatthew G. Knepley 
52c510411aSMatthew G. Knepley   Level: developer
53c510411aSMatthew G. Knepley 
54c510411aSMatthew G. Knepley .seealso: DMPlexTSSetRHSFunctionLocal()
55c510411aSMatthew G. Knepley @*/
56b6aca0f9SMatthew G. Knepley PetscErrorCode DMPlexTSGetGeometryFVM(DM dm, Vec *facegeom, Vec *cellgeom, PetscReal *minRadius)
57a0ac79e7SMatthew G. Knepley {
58a0ac79e7SMatthew G. Knepley   DMTS           dmts;
591faf85eaSMatthew G. Knepley   PetscObject    obj;
606da023fcSToby Isaac   DM             plex;
61a0ac79e7SMatthew G. Knepley   PetscErrorCode ierr;
62a0ac79e7SMatthew G. Knepley 
63a0ac79e7SMatthew G. Knepley   PetscFunctionBegin;
64924a1b8fSMatthew G. Knepley   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
656da023fcSToby Isaac   ierr = DMTSConvertPlex(dm,&plex,PETSC_TRUE);CHKERRQ(ierr);
666da023fcSToby Isaac   ierr = DMGetDMTS(plex, &dmts);CHKERRQ(ierr);
67b6aca0f9SMatthew G. Knepley   ierr = PetscObjectQuery((PetscObject) dmts, "DMPlexTS_facegeom_fvm", &obj);CHKERRQ(ierr);
681faf85eaSMatthew G. Knepley   if (!obj) {
691faf85eaSMatthew G. Knepley     Vec cellgeom, facegeom;
701faf85eaSMatthew G. Knepley 
716da023fcSToby Isaac     ierr = DMPlexComputeGeometryFVM(plex, &cellgeom, &facegeom);CHKERRQ(ierr);
72b6aca0f9SMatthew G. Knepley     ierr = PetscObjectCompose((PetscObject) dmts, "DMPlexTS_facegeom_fvm", (PetscObject) facegeom);CHKERRQ(ierr);
73b6aca0f9SMatthew G. Knepley     ierr = PetscObjectCompose((PetscObject) dmts, "DMPlexTS_cellgeom_fvm", (PetscObject) cellgeom);CHKERRQ(ierr);
741faf85eaSMatthew G. Knepley     ierr = VecDestroy(&facegeom);CHKERRQ(ierr);
751faf85eaSMatthew G. Knepley     ierr = VecDestroy(&cellgeom);CHKERRQ(ierr);
761faf85eaSMatthew G. Knepley   }
77b6aca0f9SMatthew G. Knepley   if (facegeom) {PetscValidPointer(facegeom, 2); ierr = PetscObjectQuery((PetscObject) dmts, "DMPlexTS_facegeom_fvm", (PetscObject *) facegeom);CHKERRQ(ierr);}
78b6aca0f9SMatthew G. Knepley   if (cellgeom) {PetscValidPointer(cellgeom, 3); ierr = PetscObjectQuery((PetscObject) dmts, "DMPlexTS_cellgeom_fvm", (PetscObject *) cellgeom);CHKERRQ(ierr);}
796da023fcSToby Isaac   if (minRadius) {ierr = DMPlexGetMinRadius(plex, minRadius);CHKERRQ(ierr);}
80b2338dbcSToby Isaac   ierr = DMDestroy(&plex);CHKERRQ(ierr);
81924a1b8fSMatthew G. Knepley   PetscFunctionReturn(0);
82924a1b8fSMatthew G. Knepley }
83924a1b8fSMatthew G. Knepley 
84924a1b8fSMatthew G. Knepley #undef __FUNCT__
85c49ccbb3SMatthew G. Knepley #define __FUNCT__ "DMPlexTSGetGradientDM"
86c49ccbb3SMatthew G. Knepley /*@C
87c49ccbb3SMatthew G. Knepley   DMPlexTSGetGradientDM - Return gradient data layout
88c49ccbb3SMatthew G. Knepley 
89c49ccbb3SMatthew G. Knepley   Input Parameters:
90c49ccbb3SMatthew G. Knepley + dm - The DM
91c49ccbb3SMatthew G. Knepley - fv - The PetscFV
92c49ccbb3SMatthew G. Knepley 
93c49ccbb3SMatthew G. Knepley   Output Parameter:
94c49ccbb3SMatthew G. Knepley . dmGrad - The layout for gradient values
95c49ccbb3SMatthew G. Knepley 
96c49ccbb3SMatthew G. Knepley   Level: developer
97c49ccbb3SMatthew G. Knepley 
98c49ccbb3SMatthew G. Knepley .seealso: DMPlexTSGetGeometryFVM(), DMPlexTSSetRHSFunctionLocal()
99c49ccbb3SMatthew G. Knepley @*/
100c49ccbb3SMatthew G. Knepley PetscErrorCode DMPlexTSGetGradientDM(DM dm, PetscFV fv, DM *dmGrad)
101c49ccbb3SMatthew G. Knepley {
102c49ccbb3SMatthew G. Knepley   DMTS           dmts;
103c49ccbb3SMatthew G. Knepley   PetscObject    obj;
104c49ccbb3SMatthew G. Knepley   PetscBool      computeGradients;
1056da023fcSToby Isaac   DM             plex;
106c49ccbb3SMatthew G. Knepley   PetscErrorCode ierr;
107c49ccbb3SMatthew G. Knepley 
108c49ccbb3SMatthew G. Knepley   PetscFunctionBegin;
109c49ccbb3SMatthew G. Knepley   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
110c49ccbb3SMatthew G. Knepley   PetscValidHeaderSpecific(fv,PETSCFV_CLASSID,2);
111c49ccbb3SMatthew G. Knepley   PetscValidPointer(dmGrad,3);
112c49ccbb3SMatthew G. Knepley   ierr = PetscFVGetComputeGradients(fv, &computeGradients);CHKERRQ(ierr);
113c49ccbb3SMatthew G. Knepley   if (!computeGradients) {*dmGrad = NULL; PetscFunctionReturn(0);}
1146da023fcSToby Isaac   ierr = DMTSConvertPlex(dm,&plex,PETSC_TRUE);CHKERRQ(ierr);
1156da023fcSToby Isaac   ierr = DMGetDMTS(plex, &dmts);CHKERRQ(ierr);
116c49ccbb3SMatthew G. Knepley   ierr = PetscObjectQuery((PetscObject) dmts, "DMPlexTS_dmgrad_fvm", &obj);CHKERRQ(ierr);
117c49ccbb3SMatthew G. Knepley   if (!obj) {
118c49ccbb3SMatthew G. Knepley     DM  dmGrad;
11908449791SMatthew G. Knepley     Vec faceGeometry, cellGeometry;
120c49ccbb3SMatthew G. Knepley 
1216da023fcSToby Isaac     ierr = DMPlexTSGetGeometryFVM(plex, &faceGeometry, &cellGeometry, NULL);CHKERRQ(ierr);
1226da023fcSToby Isaac     ierr = DMPlexComputeGradientFVM(plex, fv, faceGeometry, cellGeometry, &dmGrad);CHKERRQ(ierr);
123c49ccbb3SMatthew G. Knepley     ierr = PetscObjectCompose((PetscObject) dmts, "DMPlexTS_dmgrad_fvm", (PetscObject) dmGrad);CHKERRQ(ierr);
124924a1b8fSMatthew G. Knepley     ierr = DMDestroy(&dmGrad);CHKERRQ(ierr);
125c49ccbb3SMatthew G. Knepley   }
126c49ccbb3SMatthew G. Knepley   ierr = PetscObjectQuery((PetscObject) dmts, "DMPlexTS_dmgrad_fvm", (PetscObject *) dmGrad);CHKERRQ(ierr);
127b2338dbcSToby Isaac   ierr = DMDestroy(&plex);CHKERRQ(ierr);
128254c1ad2SMatthew G. Knepley   PetscFunctionReturn(0);
129254c1ad2SMatthew G. Knepley }
130254c1ad2SMatthew G. Knepley 
131254c1ad2SMatthew G. Knepley #undef __FUNCT__
132924a1b8fSMatthew G. Knepley #define __FUNCT__ "DMPlexTSComputeRHSFunctionFVM"
13308449791SMatthew G. Knepley /*@
13408449791SMatthew G. Knepley   DMPlexTSComputeRHSFunctionFVM - Form the local forcing F from the local input X using pointwise functions specified by the user
13508449791SMatthew G. Knepley 
13608449791SMatthew G. Knepley   Input Parameters:
13708449791SMatthew G. Knepley + dm - The mesh
13808449791SMatthew G. Knepley . t - The time
13908449791SMatthew G. Knepley . locX  - Local solution
14008449791SMatthew G. Knepley - user - The user context
14108449791SMatthew G. Knepley 
14208449791SMatthew G. Knepley   Output Parameter:
1433b16df42SMatthew G. Knepley . F  - Global output vector
14408449791SMatthew G. Knepley 
14508449791SMatthew G. Knepley   Level: developer
14608449791SMatthew G. Knepley 
14708449791SMatthew G. Knepley .seealso: DMPlexComputeJacobianActionFEM()
14808449791SMatthew G. Knepley @*/
1493b16df42SMatthew G. Knepley PetscErrorCode DMPlexTSComputeRHSFunctionFVM(DM dm, PetscReal time, Vec locX, Vec F, void *user)
150254c1ad2SMatthew G. Knepley {
1513b16df42SMatthew G. Knepley   Vec            locF;
152c4d4a4f8SMatthew G. Knepley   PetscInt       cStart, cEnd, cEndInterior;
1536da023fcSToby Isaac   DM             plex;
154254c1ad2SMatthew G. Knepley   PetscErrorCode ierr;
155254c1ad2SMatthew G. Knepley 
156254c1ad2SMatthew G. Knepley   PetscFunctionBegin;
1576da023fcSToby Isaac   ierr = DMTSConvertPlex(dm,&plex,PETSC_TRUE);CHKERRQ(ierr);
1586da023fcSToby Isaac   ierr = DMPlexGetHeightStratum(plex, 0, &cStart, &cEnd);CHKERRQ(ierr);
1596da023fcSToby Isaac   ierr = DMPlexGetHybridBounds(plex, &cEndInterior, NULL, NULL, NULL);CHKERRQ(ierr);
160c4d4a4f8SMatthew G. Knepley   cEnd = cEndInterior < 0 ? cEnd : cEndInterior;
1616da023fcSToby Isaac   ierr = DMGetLocalVector(plex, &locF);CHKERRQ(ierr);
1623b16df42SMatthew G. Knepley   ierr = VecZeroEntries(locF);CHKERRQ(ierr);
1636da023fcSToby Isaac   ierr = DMPlexComputeResidual_Internal(plex, cStart, cEnd, time, locX, NULL, locF, user);CHKERRQ(ierr);
1646da023fcSToby Isaac   ierr = DMLocalToGlobalBegin(plex, locF, INSERT_VALUES, F);CHKERRQ(ierr);
1656da023fcSToby Isaac   ierr = DMLocalToGlobalEnd(plex, locF, INSERT_VALUES, F);CHKERRQ(ierr);
1666da023fcSToby Isaac   ierr = DMRestoreLocalVector(plex, &locF);CHKERRQ(ierr);
167b2338dbcSToby Isaac   ierr = DMDestroy(&plex);CHKERRQ(ierr);
168254c1ad2SMatthew G. Knepley   PetscFunctionReturn(0);
169254c1ad2SMatthew G. Knepley }
170254c1ad2SMatthew G. Knepley 
171254c1ad2SMatthew G. Knepley #undef __FUNCT__
172*c5d70e09SMatthew G. Knepley #define __FUNCT__ "DMPlexTSComputeBoundaryFEM"
173*c5d70e09SMatthew G. Knepley /*@
174*c5d70e09SMatthew G. Knepley   DMPlexTSComputeBoundaryFEM - Form the boundary values for the local input X
175*c5d70e09SMatthew G. Knepley 
176*c5d70e09SMatthew G. Knepley   Input Parameters:
177*c5d70e09SMatthew G. Knepley + dm - The mesh
178*c5d70e09SMatthew G. Knepley - user - The user context
179*c5d70e09SMatthew G. Knepley 
180*c5d70e09SMatthew G. Knepley   Output Parameter:
181*c5d70e09SMatthew G. Knepley . X  - Local solution
182*c5d70e09SMatthew G. Knepley 
183*c5d70e09SMatthew G. Knepley   Level: developer
184*c5d70e09SMatthew G. Knepley 
185*c5d70e09SMatthew G. Knepley .seealso: DMPlexSNESComputeBoundaryFEM()
186*c5d70e09SMatthew G. Knepley @*/
187*c5d70e09SMatthew G. Knepley PetscErrorCode DMPlexTSComputeBoundaryFEM(DM dm, Vec X, void *user)
188*c5d70e09SMatthew G. Knepley {
189*c5d70e09SMatthew G. Knepley   DM             plex;
190*c5d70e09SMatthew G. Knepley   PetscErrorCode ierr;
191*c5d70e09SMatthew G. Knepley 
192*c5d70e09SMatthew G. Knepley   PetscFunctionBegin;
193*c5d70e09SMatthew G. Knepley   ierr = DMTSConvertPlex(dm, &plex, PETSC_TRUE);CHKERRQ(ierr);
194*c5d70e09SMatthew G. Knepley   ierr = DMPlexInsertBoundaryValues(plex, PETSC_TRUE, X, PETSC_MIN_REAL, NULL, NULL, NULL);CHKERRQ(ierr);
195*c5d70e09SMatthew G. Knepley   ierr = DMDestroy(&plex);CHKERRQ(ierr);
196*c5d70e09SMatthew G. Knepley   PetscFunctionReturn(0);
197*c5d70e09SMatthew G. Knepley }
198*c5d70e09SMatthew G. Knepley 
199*c5d70e09SMatthew G. Knepley #undef __FUNCT__
20024cdb843SMatthew G. Knepley #define __FUNCT__ "DMPlexTSComputeIFunctionFEM"
20124cdb843SMatthew G. Knepley /*@
20224cdb843SMatthew G. Knepley   DMPlexTSComputeIFunctionFEM - Form the local residual F from the local input X using pointwise functions specified by the user
20324cdb843SMatthew G. Knepley 
20424cdb843SMatthew G. Knepley   Input Parameters:
20524cdb843SMatthew G. Knepley + dm - The mesh
20624cdb843SMatthew G. Knepley . t - The time
20708449791SMatthew G. Knepley . locX  - Local solution
20808449791SMatthew G. Knepley . locX_t - Local solution time derivative, or NULL
20924cdb843SMatthew G. Knepley - user - The user context
21024cdb843SMatthew G. Knepley 
21124cdb843SMatthew G. Knepley   Output Parameter:
21208449791SMatthew G. Knepley . locF  - Local output vector
21324cdb843SMatthew G. Knepley 
21424cdb843SMatthew G. Knepley   Level: developer
21524cdb843SMatthew G. Knepley 
21624cdb843SMatthew G. Knepley .seealso: DMPlexComputeJacobianActionFEM()
21724cdb843SMatthew G. Knepley @*/
21808449791SMatthew G. Knepley PetscErrorCode DMPlexTSComputeIFunctionFEM(DM dm, PetscReal time, Vec locX, Vec locX_t, Vec locF, void *user)
21924cdb843SMatthew G. Knepley {
220c4d4a4f8SMatthew G. Knepley   PetscInt       cStart, cEnd, cEndInterior;
2216da023fcSToby Isaac   DM             plex;
22224cdb843SMatthew G. Knepley   PetscErrorCode ierr;
22324cdb843SMatthew G. Knepley 
22424cdb843SMatthew G. Knepley   PetscFunctionBegin;
2256da023fcSToby Isaac   ierr = DMTSConvertPlex(dm,&plex,PETSC_TRUE);CHKERRQ(ierr);
2266da023fcSToby Isaac   ierr = DMPlexGetHeightStratum(plex, 0, &cStart, &cEnd);CHKERRQ(ierr);
2276da023fcSToby Isaac   ierr = DMPlexGetHybridBounds(plex, &cEndInterior, NULL, NULL, NULL);CHKERRQ(ierr);
228c4d4a4f8SMatthew G. Knepley   cEnd = cEndInterior < 0 ? cEnd : cEndInterior;
2296da023fcSToby Isaac   ierr = DMPlexComputeResidual_Internal(plex, cStart, cEnd, time, locX, locX_t, locF, user);CHKERRQ(ierr);
230b2338dbcSToby Isaac   ierr = DMDestroy(&plex);CHKERRQ(ierr);
23124cdb843SMatthew G. Knepley   PetscFunctionReturn(0);
23224cdb843SMatthew G. Knepley }
2337cdb2a12SMatthew G. Knepley 
2347cdb2a12SMatthew G. Knepley #undef __FUNCT__
235756a1f44SMatthew G. Knepley #define __FUNCT__ "DMPlexTSComputeIJacobianFEM"
236756a1f44SMatthew G. Knepley /*@
237756a1f44SMatthew G. Knepley   DMPlexTSComputeIJacobianFEM - Form the local Jacobian J from the local input X using pointwise functions specified by the user
238756a1f44SMatthew G. Knepley 
239756a1f44SMatthew G. Knepley   Input Parameters:
240756a1f44SMatthew G. Knepley + dm - The mesh
241756a1f44SMatthew G. Knepley . t - The time
242756a1f44SMatthew G. Knepley . locX  - Local solution
243756a1f44SMatthew G. Knepley . locX_t - Local solution time derivative, or NULL
244756a1f44SMatthew G. Knepley . X_tshift - The multiplicative parameter for dF/du_t
245756a1f44SMatthew G. Knepley - user - The user context
246756a1f44SMatthew G. Knepley 
247756a1f44SMatthew G. Knepley   Output Parameter:
248756a1f44SMatthew G. Knepley . locF  - Local output vector
249756a1f44SMatthew G. Knepley 
250756a1f44SMatthew G. Knepley   Level: developer
251756a1f44SMatthew G. Knepley 
252756a1f44SMatthew G. Knepley .seealso: DMPlexComputeJacobianActionFEM()
253756a1f44SMatthew G. Knepley @*/
254756a1f44SMatthew G. Knepley PetscErrorCode DMPlexTSComputeIJacobianFEM(DM dm, PetscReal time, Vec locX, Vec locX_t, PetscReal X_tShift, Mat Jac, Mat JacP, void *user)
255756a1f44SMatthew G. Knepley {
256756a1f44SMatthew G. Knepley   PetscInt       cStart, cEnd, cEndInterior;
257756a1f44SMatthew G. Knepley   DM             plex;
258756a1f44SMatthew G. Knepley   PetscErrorCode ierr;
259756a1f44SMatthew G. Knepley 
260756a1f44SMatthew G. Knepley   PetscFunctionBegin;
261756a1f44SMatthew G. Knepley   ierr = DMTSConvertPlex(dm,&plex,PETSC_TRUE);CHKERRQ(ierr);
262756a1f44SMatthew G. Knepley   ierr = DMPlexGetHeightStratum(plex, 0, &cStart, &cEnd);CHKERRQ(ierr);
263756a1f44SMatthew G. Knepley   ierr = DMPlexGetHybridBounds(plex, &cEndInterior, NULL, NULL, NULL);CHKERRQ(ierr);
264756a1f44SMatthew G. Knepley   cEnd = cEndInterior < 0 ? cEnd : cEndInterior;
265756a1f44SMatthew G. Knepley   ierr = DMPlexComputeJacobian_Internal(plex, cStart, cEnd, time, X_tShift, locX, locX_t, Jac, JacP, user);CHKERRQ(ierr);
266756a1f44SMatthew G. Knepley   ierr = DMDestroy(&plex);CHKERRQ(ierr);
267756a1f44SMatthew G. Knepley   PetscFunctionReturn(0);
268756a1f44SMatthew G. Knepley }
269756a1f44SMatthew G. Knepley 
270756a1f44SMatthew G. Knepley #undef __FUNCT__
2717cdb2a12SMatthew G. Knepley #define __FUNCT__ "DMTSCheckFromOptions"
2720163fd50SMatthew G. Knepley PetscErrorCode DMTSCheckFromOptions(TS ts, Vec u, PetscErrorCode (**exactFuncs)(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nf, PetscScalar *u, void *ctx), void **ctxs)
2737cdb2a12SMatthew G. Knepley {
2747cdb2a12SMatthew G. Knepley   DM             dm;
2757cdb2a12SMatthew G. Knepley   SNES           snes;
2761878804aSMatthew G. Knepley   Vec            sol;
2777cdb2a12SMatthew G. Knepley   PetscBool      check;
2787cdb2a12SMatthew G. Knepley   PetscErrorCode ierr;
2797cdb2a12SMatthew G. Knepley 
2807cdb2a12SMatthew G. Knepley   PetscFunctionBegin;
281c5929fdfSBarry Smith   ierr = PetscOptionsHasName(((PetscObject)ts)->options,((PetscObject)ts)->prefix, "-dmts_check", &check);CHKERRQ(ierr);
2827cdb2a12SMatthew G. Knepley   if (!check) PetscFunctionReturn(0);
28372fd7fc8SMatthew G. Knepley   ierr = VecDuplicate(u, &sol);CHKERRQ(ierr);
28472fd7fc8SMatthew G. Knepley   ierr = TSSetSolution(ts, sol);CHKERRQ(ierr);
2857cdb2a12SMatthew G. Knepley   ierr = TSGetDM(ts, &dm);CHKERRQ(ierr);
2867cdb2a12SMatthew G. Knepley   ierr = TSSetUp(ts);CHKERRQ(ierr);
2877cdb2a12SMatthew G. Knepley   ierr = TSGetSNES(ts, &snes);CHKERRQ(ierr);
2887cdb2a12SMatthew G. Knepley   ierr = SNESSetSolution(snes, sol);CHKERRQ(ierr);
2891878804aSMatthew G. Knepley   ierr = DMSNESCheckFromOptions_Internal(snes, dm, u, sol, exactFuncs, ctxs);CHKERRQ(ierr);
29072fd7fc8SMatthew G. Knepley   ierr = VecDestroy(&sol);CHKERRQ(ierr);
2917cdb2a12SMatthew G. Knepley   PetscFunctionReturn(0);
2927cdb2a12SMatthew G. Knepley }
293