Actual source code: ex12.c

petsc-master 2017-06-25
Report Typos and Errors
  1: static char help[] = "Poisson Problem in 2d and 3d with simplicial finite elements.\n\
  2: We solve the Poisson problem in a rectangular\n\
  3: domain, using a parallel unstructured mesh (DMPLEX) to discretize it.\n\
  4: This example supports discretized auxiliary fields (conductivity) as well as\n\
  5: multilevel nonlinear solvers.\n\n\n";

  7:  #include <petscdmplex.h>
  8:  #include <petscsnes.h>
  9:  #include <petscds.h>
 10: #include <petscviewerhdf5.h>

 12: typedef enum {NEUMANN, DIRICHLET, NONE} BCType;
 13: typedef enum {RUN_FULL, RUN_EXACT, RUN_TEST, RUN_PERF} RunType;
 14: typedef enum {COEFF_NONE, COEFF_ANALYTIC, COEFF_FIELD, COEFF_NONLINEAR} CoeffType;

 16: typedef struct {
 17:   PetscInt       debug;             /* The debugging level */
 18:   RunType        runType;           /* Whether to run tests, or solve the full problem */
 19:   PetscBool      jacobianMF;        /* Whether to calculate the Jacobian action on the fly */
 20:   PetscLogEvent  createMeshEvent;
 21:   PetscBool      showInitial, showSolution, restart, check, quiet, nonzInit;
 22:   /* Domain and mesh definition */
 23:   PetscInt       dim;               /* The topological mesh dimension */
 24:   DMBoundaryType periodicity[3];    /* The domain periodicity */
 25:   PetscInt       cells[3];          /* The initial domain division */
 26:   char           filename[2048];    /* The optional mesh file */
 27:   PetscBool      interpolate;       /* Generate intermediate mesh elements */
 28:   PetscReal      refinementLimit;   /* The largest allowable cell volume */
 29:   PetscBool      viewHierarchy;     /* Whether to view the hierarchy */
 30:   PetscBool      simplex;           /* Simplicial mesh */
 31:   /* Problem definition */
 32:   BCType         bcType;
 33:   CoeffType      variableCoefficient;
 34:   PetscErrorCode (**exactFuncs)(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx);
 35:   PetscBool      fieldBC;
 36:   void           (**exactFields)(PetscInt, PetscInt, PetscInt,
 37:                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
 38:                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
 39:                                  PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]);
 40:   /* Solver */
 41:   PC            pcmg;              /* This is needed for error monitoring */
 42: } AppCtx;

 44: static PetscErrorCode zero(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
 45: {
 46:   u[0] = 0.0;
 47:   return 0;
 48: }

 50: static PetscErrorCode ecks(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
 51: {
 52:   u[0] = x[0];
 53:   return 0;
 54: }

 56: /*
 57:   In 2D for Dirichlet conditions, we use exact solution:

 59:     u = x^2 + y^2
 60:     f = 4

 62:   so that

 64:     -\Delta u + f = -4 + 4 = 0

 66:   For Neumann conditions, we have

 68:     -\nabla u \cdot -\hat y |_{y=0} =  (2y)|_{y=0} =  0 (bottom)
 69:     -\nabla u \cdot  \hat y |_{y=1} = -(2y)|_{y=1} = -2 (top)
 70:     -\nabla u \cdot -\hat x |_{x=0} =  (2x)|_{x=0} =  0 (left)
 71:     -\nabla u \cdot  \hat x |_{x=1} = -(2x)|_{x=1} = -2 (right)

 73:   Which we can express as

 75:     \nabla u \cdot  \hat n|_\Gamma = {2 x, 2 y} \cdot \hat n = 2 (x + y)
 76: */
 77: static PetscErrorCode quadratic_u_2d(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
 78: {
 79:   *u = x[0]*x[0] + x[1]*x[1];
 80:   return 0;
 81: }

 83: static void quadratic_u_field_2d(PetscInt dim, PetscInt Nf, PetscInt NfAux,
 84:                                  const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
 85:                                  const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
 86:                                  PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uexact[])
 87: {
 88:   uexact[0] = a[0];
 89: }

 91: static void f0_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
 92:                  const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
 93:                  const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
 94:                  PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
 95: {
 96:   f0[0] = 4.0;
 97: }

 99: static void f0_bd_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
100:                     const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
101:                     const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
102:                     PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
103: {
104:   PetscInt d;
105:   for (d = 0, f0[0] = 0.0; d < dim; ++d) f0[0] += -n[d]*2.0*x[d];
106: }

108: static void f1_bd_zero(PetscInt dim, PetscInt Nf, PetscInt NfAux,
109:                        const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
110:                        const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
111:                        PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])
112: {
113:   PetscInt comp;
114:   for (comp = 0; comp < dim; ++comp) f1[comp] = 0.0;
115: }

117: /* gradU[comp*dim+d] = {u_x, u_y} or {u_x, u_y, u_z} */
118: static void f1_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
119:                  const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
120:                  const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
121:                  PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])
122: {
123:   PetscInt d;
124:   for (d = 0; d < dim; ++d) f1[d] = u_x[d];
125: }

127: /* < \nabla v, \nabla u + {\nabla u}^T >
128:    This just gives \nabla u, give the perdiagonal for the transpose */
129: static void g3_uu(PetscInt dim, PetscInt Nf, PetscInt NfAux,
130:                   const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
131:                   const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
132:                   PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])
133: {
134:   PetscInt d;
135:   for (d = 0; d < dim; ++d) g3[d*dim+d] = 1.0;
136: }

138: /*
139:   In 2D for x periodicity and y Dirichlet conditions, we use exact solution:

141:     u = sin(2 pi x)
142:     f = -4 pi^2 sin(2 pi x)

144:   so that

146:     -\Delta u + f = 4 pi^2 sin(2 pi x) - 4 pi^2 sin(2 pi x) = 0
147: */
148: static PetscErrorCode xtrig_u_2d(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
149: {
150:   *u = PetscSinReal(2.0*PETSC_PI*x[0]);
151:   return 0;
152: }

154: static void f0_xtrig_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
155:                        const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
156:                        const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
157:                        PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
158: {
159:   f0[0] = -4.0*PetscSqr(PETSC_PI)*PetscSinReal(2.0*PETSC_PI*x[0]);
160: }

162: /*
163:   In 2D for x-y periodicity, we use exact solution:

165:     u = sin(2 pi x) sin(2 pi y)
166:     f = -8 pi^2 sin(2 pi x)

168:   so that

170:     -\Delta u + f = 4 pi^2 sin(2 pi x) sin(2 pi y) + 4 pi^2 sin(2 pi x) sin(2 pi y) - 8 pi^2 sin(2 pi x) = 0
171: */
172: static PetscErrorCode xytrig_u_2d(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
173: {
174:   *u = PetscSinReal(2.0*PETSC_PI*x[0])*PetscSinReal(2.0*PETSC_PI*x[1]);
175:   return 0;
176: }

178: static void f0_xytrig_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
179:                         const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
180:                         const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
181:                         PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
182: {
183:   f0[0] = -8.0*PetscSqr(PETSC_PI)*PetscSinReal(2.0*PETSC_PI*x[0]);
184: }

186: /*
187:   In 2D for Dirichlet conditions with a variable coefficient, we use exact solution:

189:     u  = x^2 + y^2
190:     f  = 6 (x + y)
191:     nu = (x + y)

193:   so that

195:     -\div \nu \grad u + f = -6 (x + y) + 6 (x + y) = 0
196: */
197: static PetscErrorCode nu_2d(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
198: {
199:   *u = x[0] + x[1];
200:   return 0;
201: }

203: void f0_analytic_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
204:                    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
205:                    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
206:                    PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
207: {
208:   f0[0] = 6.0*(x[0] + x[1]);
209: }

211: /* gradU[comp*dim+d] = {u_x, u_y} or {u_x, u_y, u_z} */
212: void f1_analytic_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
213:                    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
214:                    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
215:                    PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])
216: {
217:   PetscInt d;
218:   for (d = 0; d < dim; ++d) f1[d] = (x[0] + x[1])*u_x[d];
219: }

221: void f1_field_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
222:                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
223:                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
224:                 PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])
225: {
226:   PetscInt d;
227:   for (d = 0; d < dim; ++d) f1[d] = a[0]*u_x[d];
228: }

230: /* < \nabla v, \nabla u + {\nabla u}^T >
231:    This just gives \nabla u, give the perdiagonal for the transpose */
232: void g3_analytic_uu(PetscInt dim, PetscInt Nf, PetscInt NfAux,
233:                     const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
234:                     const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
235:                     PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])
236: {
237:   PetscInt d;
238:   for (d = 0; d < dim; ++d) g3[d*dim+d] = x[0] + x[1];
239: }

241: void g3_field_uu(PetscInt dim, PetscInt Nf, PetscInt NfAux,
242:                  const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
243:                  const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
244:                  PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])
245: {
246:   PetscInt d;
247:   for (d = 0; d < dim; ++d) g3[d*dim+d] = a[0];
248: }

250: /*
251:   In 2D for Dirichlet conditions with a nonlinear coefficient (p-Laplacian with p = 4), we use exact solution:

253:     u  = x^2 + y^2
254:     f  = 16 (x^2 + y^2)
255:     nu = 1/2 |grad u|^2

257:   so that

259:     -\div \nu \grad u + f = -16 (x^2 + y^2) + 16 (x^2 + y^2) = 0
260: */
261: void f0_analytic_nonlinear_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
262:                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
263:                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
264:                              PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
265: {
266:   f0[0] = 16.0*(x[0]*x[0] + x[1]*x[1]);
267: }

269: /* gradU[comp*dim+d] = {u_x, u_y} or {u_x, u_y, u_z} */
270: void f1_analytic_nonlinear_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
271:                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
272:                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
273:                              PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])
274: {
275:   PetscScalar nu = 0.0;
276:   PetscInt    d;
277:   for (d = 0; d < dim; ++d) nu += u_x[d]*u_x[d];
278:   for (d = 0; d < dim; ++d) f1[d] = 0.5*nu*u_x[d];
279: }

281: /*
282:   grad (u + eps w) - grad u = eps grad w

284:   1/2 |grad (u + eps w)|^2 grad (u + eps w) - 1/2 |grad u|^2 grad u
285: = 1/2 (|grad u|^2 + 2 eps <grad u,grad w>) (grad u + eps grad w) - 1/2 |grad u|^2 grad u
286: = 1/2 (eps |grad u|^2 grad w + 2 eps <grad u,grad w> grad u)
287: = eps (1/2 |grad u|^2 grad w + grad u <grad u,grad w>)
288: */
289: void g3_analytic_nonlinear_uu(PetscInt dim, PetscInt Nf, PetscInt NfAux,
290:                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
291:                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
292:                               PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])
293: {
294:   PetscScalar nu = 0.0;
295:   PetscInt    d, e;
296:   for (d = 0; d < dim; ++d) nu += u_x[d]*u_x[d];
297:   for (d = 0; d < dim; ++d) {
298:     g3[d*dim+d] = 0.5*nu;
299:     for (e = 0; e < dim; ++e) {
300:       g3[d*dim+e] += u_x[d]*u_x[e];
301:     }
302:   }
303: }

305: /*
306:   In 3D for Dirichlet conditions we use exact solution:

308:     u = 2/3 (x^2 + y^2 + z^2)
309:     f = 4

311:   so that

313:     -\Delta u + f = -2/3 * 6 + 4 = 0

315:   For Neumann conditions, we have

317:     -\nabla u \cdot -\hat z |_{z=0} =  (2z)|_{z=0} =  0 (bottom)
318:     -\nabla u \cdot  \hat z |_{z=1} = -(2z)|_{z=1} = -2 (top)
319:     -\nabla u \cdot -\hat y |_{y=0} =  (2y)|_{y=0} =  0 (front)
320:     -\nabla u \cdot  \hat y |_{y=1} = -(2y)|_{y=1} = -2 (back)
321:     -\nabla u \cdot -\hat x |_{x=0} =  (2x)|_{x=0} =  0 (left)
322:     -\nabla u \cdot  \hat x |_{x=1} = -(2x)|_{x=1} = -2 (right)

324:   Which we can express as

326:     \nabla u \cdot  \hat n|_\Gamma = {2 x, 2 y, 2z} \cdot \hat n = 2 (x + y + z)
327: */
328: static PetscErrorCode quadratic_u_3d(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
329: {
330:   *u = 2.0*(x[0]*x[0] + x[1]*x[1] + x[2]*x[2])/3.0;
331:   return 0;
332: }

334: static void quadratic_u_field_3d(PetscInt dim, PetscInt Nf, PetscInt NfAux,
335:                                  const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
336:                                  const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
337:                                  PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uexact[])
338: {
339:   uexact[0] = a[0];
340: }

342: static PetscErrorCode ProcessOptions(MPI_Comm comm, AppCtx *options)
343: {
344:   const char    *bcTypes[3]  = {"neumann", "dirichlet", "none"};
345:   const char    *runTypes[4] = {"full", "exact", "test", "perf"};
346:   const char    *coeffTypes[4] = {"none", "analytic", "field", "nonlinear"};
347:   PetscInt       bd, bc, run, coeff, n;
348:   PetscBool      flg;

352:   options->debug               = 0;
353:   options->runType             = RUN_FULL;
354:   options->dim                 = 2;
355:   options->periodicity[0]      = DM_BOUNDARY_NONE;
356:   options->periodicity[1]      = DM_BOUNDARY_NONE;
357:   options->periodicity[2]      = DM_BOUNDARY_NONE;
358:   options->cells[0]            = 1;
359:   options->cells[1]            = 1;
360:   options->cells[2]            = 1;
361:   options->filename[0]         = '\0';
362:   options->interpolate         = PETSC_FALSE;
363:   options->refinementLimit     = 0.0;
364:   options->bcType              = DIRICHLET;
365:   options->variableCoefficient = COEFF_NONE;
366:   options->fieldBC             = PETSC_FALSE;
367:   options->jacobianMF          = PETSC_FALSE;
368:   options->showInitial         = PETSC_FALSE;
369:   options->showSolution        = PETSC_FALSE;
370:   options->restart             = PETSC_FALSE;
371:   options->check               = PETSC_FALSE;
372:   options->viewHierarchy       = PETSC_FALSE;
373:   options->simplex             = PETSC_TRUE;
374:   options->quiet               = PETSC_FALSE;
375:   options->nonzInit            = PETSC_FALSE;

377:   PetscOptionsBegin(comm, "", "Poisson Problem Options", "DMPLEX");
378:   PetscOptionsInt("-debug", "The debugging level", "ex12.c", options->debug, &options->debug, NULL);
379:   run  = options->runType;
380:   PetscOptionsEList("-run_type", "The run type", "ex12.c", runTypes, 3, runTypes[options->runType], &run, NULL);

382:   options->runType = (RunType) run;

384:   PetscOptionsInt("-dim", "The topological mesh dimension", "ex12.c", options->dim, &options->dim, NULL);
385:   bd = options->periodicity[0];
386:   PetscOptionsEList("-x_periodicity", "The x-boundary periodicity", "ex12.c", DMBoundaryTypes, 5, DMBoundaryTypes[options->periodicity[0]], &bd, NULL);
387:   options->periodicity[0] = (DMBoundaryType) bd;
388:   bd = options->periodicity[1];
389:   PetscOptionsEList("-y_periodicity", "The y-boundary periodicity", "ex12.c", DMBoundaryTypes, 5, DMBoundaryTypes[options->periodicity[1]], &bd, NULL);
390:   options->periodicity[1] = (DMBoundaryType) bd;
391:   bd = options->periodicity[2];
392:   PetscOptionsEList("-z_periodicity", "The z-boundary periodicity", "ex12.c", DMBoundaryTypes, 5, DMBoundaryTypes[options->periodicity[2]], &bd, NULL);
393:   options->periodicity[2] = (DMBoundaryType) bd;
394:   n = 3;
395:   PetscOptionsIntArray("-cells", "The initial mesh division", "ex12.c", options->cells, &n, NULL);
396:   PetscOptionsString("-f", "Mesh filename to read", "ex12.c", options->filename, options->filename, sizeof(options->filename), &flg);
397:   PetscOptionsBool("-interpolate", "Generate intermediate mesh elements", "ex12.c", options->interpolate, &options->interpolate, NULL);
398:   PetscOptionsReal("-refinement_limit", "The largest allowable cell volume", "ex12.c", options->refinementLimit, &options->refinementLimit, NULL);
399:   bc   = options->bcType;
400:   PetscOptionsEList("-bc_type","Type of boundary condition","ex12.c",bcTypes,3,bcTypes[options->bcType],&bc,NULL);
401:   options->bcType = (BCType) bc;
402:   coeff = options->variableCoefficient;
403:   PetscOptionsEList("-variable_coefficient","Type of variable coefficent","ex12.c",coeffTypes,4,coeffTypes[options->variableCoefficient],&coeff,NULL);
404:   options->variableCoefficient = (CoeffType) coeff;

406:   PetscOptionsBool("-field_bc", "Use a field representation for the BC", "ex12.c", options->fieldBC, &options->fieldBC, NULL);
407:   PetscOptionsBool("-jacobian_mf", "Calculate the action of the Jacobian on the fly", "ex12.c", options->jacobianMF, &options->jacobianMF, NULL);
408:   PetscOptionsBool("-show_initial", "Output the initial guess for verification", "ex12.c", options->showInitial, &options->showInitial, NULL);
409:   PetscOptionsBool("-show_solution", "Output the solution for verification", "ex12.c", options->showSolution, &options->showSolution, NULL);
410:   PetscOptionsBool("-restart", "Read in the mesh and solution from a file", "ex12.c", options->restart, &options->restart, NULL);
411:   PetscOptionsBool("-check", "Compare with default integration routines", "ex12.c", options->check, &options->check, NULL);
412:   PetscOptionsBool("-dm_view_hierarchy", "View the coarsened hierarchy", "ex12.c", options->viewHierarchy, &options->viewHierarchy, NULL);
413:   PetscOptionsBool("-simplex", "Simplicial (true) or tensor (false) mesh", "ex12.c", options->simplex, &options->simplex, NULL);
414:   PetscOptionsBool("-quiet", "Don't print any vecs", "ex12.c", options->quiet, &options->quiet, NULL);
415:   PetscOptionsBool("-nonzero_initial_guess", "nonzero intial guess", "ex12.c", options->nonzInit, &options->nonzInit, NULL);
416:   PetscOptionsEnd();
417:   PetscLogEventRegister("CreateMesh", DM_CLASSID, &options->createMeshEvent);
418:   return(0);
419: }

421: static PetscErrorCode CreateBCLabel(DM dm, const char name[])
422: {
423:   DMLabel        label;

427:   DMCreateLabel(dm, name);
428:   DMGetLabel(dm, name, &label);
429:   DMPlexMarkBoundaryFaces(dm, label);
430:   DMPlexLabelComplete(dm, label);
431:   return(0);
432: }

434: static PetscErrorCode CreateMesh(MPI_Comm comm, AppCtx *user, DM *dm)
435: {
436:   PetscInt       dim             = user->dim;
437:   const char    *filename        = user->filename;
438:   PetscBool      interpolate     = user->interpolate;
439:   PetscReal      refinementLimit = user->refinementLimit;
440:   size_t         len;

444:   PetscLogEventBegin(user->createMeshEvent,0,0,0,0);
445:   PetscStrlen(filename, &len);
446:   if (!len) {
447:     if (user->simplex) {
448:       DMPlexCreateBoxMesh(comm, dim, dim == 2 ? 2 : 1, interpolate, dm);
449:     } else {
450:       PetscInt d;

452:       if (user->periodicity[0] || user->periodicity[1] || user->periodicity[2]) for (d = 0; d < dim; ++d) user->cells[d] = PetscMax(user->cells[d], 3);
453:       DMPlexCreateHexBoxMesh(comm, dim, user->cells, user->periodicity[0], user->periodicity[1], user->periodicity[2], dm);
454:     }
455:     PetscObjectSetName((PetscObject) *dm, "Mesh");
456:   } else {
457:     DMPlexCreateFromFile(comm, filename, interpolate, dm);
458:     DMPlexSetRefinementUniform(*dm, PETSC_FALSE);
459:   }
460:   {
461:     PetscPartitioner part;
462:     DM               refinedMesh     = NULL;
463:     DM               distributedMesh = NULL;

465:     /* Refine mesh using a volume constraint */
466:     if (refinementLimit > 0.0) {
467:       DMPlexSetRefinementLimit(*dm, refinementLimit);
468:       DMRefine(*dm, comm, &refinedMesh);
469:       if (refinedMesh) {
470:         const char *name;

472:         PetscObjectGetName((PetscObject) *dm,         &name);
473:         PetscObjectSetName((PetscObject) refinedMesh,  name);
474:         DMDestroy(dm);
475:         *dm  = refinedMesh;
476:       }
477:     }
478:     /* Distribute mesh over processes */
479:     DMPlexGetPartitioner(*dm,&part);
480:     PetscPartitionerSetFromOptions(part);
481:     DMPlexDistribute(*dm, 0, NULL, &distributedMesh);
482:     if (distributedMesh) {
483:       DMDestroy(dm);
484:       *dm  = distributedMesh;
485:     }
486:   }
487:   if (user->bcType == NEUMANN) {
488:     DMLabel   label;

490:     DMCreateLabel(*dm, "boundary");
491:     DMGetLabel(*dm, "boundary", &label);
492:     DMPlexMarkBoundaryFaces(*dm, label);
493:   } else if (user->bcType == DIRICHLET) {
494:     PetscBool hasLabel;

496:     DMHasLabel(*dm,"marker",&hasLabel);
497:     if (!hasLabel) {CreateBCLabel(*dm, "marker");}
498:   }
499:   {
500:     char      convType[256];
501:     PetscBool flg;

503:     PetscOptionsBegin(comm, "", "Mesh conversion options", "DMPLEX");
504:     PetscOptionsFList("-dm_plex_convert_type","Convert DMPlex to another format","ex12",DMList,DMPLEX,convType,256,&flg);
505:     PetscOptionsEnd();
506:     if (flg) {
507:       DM dmConv;

509:       DMConvert(*dm,convType,&dmConv);
510:       if (dmConv) {
511:         DMDestroy(dm);
512:         *dm  = dmConv;
513:       }
514:     }
515:   }
516:   DMLocalizeCoordinates(*dm); /* needed for periodic */
517:   DMSetFromOptions(*dm);
518:   DMViewFromOptions(*dm, NULL, "-dm_view");
519:   if (user->viewHierarchy) {
520:     DM       cdm = *dm;
521:     PetscInt i   = 0;
522:     char     buf[256];

524:     while (cdm) {
525:       DMSetUp(cdm);
526:       DMGetCoarseDM(cdm, &cdm);
527:       ++i;
528:     }
529:     cdm = *dm;
530:     while (cdm) {
531:       PetscViewer       viewer;
532:       PetscBool   isHDF5, isVTK;

534:       --i;
535:       PetscViewerCreate(comm,&viewer);
536:       PetscViewerSetType(viewer,PETSCVIEWERHDF5);
537:       PetscViewerSetOptionsPrefix(viewer,"hierarchy_");
538:       PetscViewerSetFromOptions(viewer);
539:       PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERHDF5,&isHDF5);
540:       PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERVTK,&isVTK);
541:       if (isHDF5) {
542:         PetscSNPrintf(buf, 256, "ex12-%d.h5", i);
543:       }
544:       else if (isVTK) {
545:         PetscSNPrintf(buf, 256, "ex12-%d.vtu", i);
546:         PetscViewerPushFormat(viewer,PETSC_VIEWER_VTK_VTU);
547:       }
548:       else {
549:         PetscSNPrintf(buf, 256, "ex12-%d", i);
550:       }
551:       PetscViewerFileSetMode(viewer,FILE_MODE_WRITE);
552:       PetscViewerFileSetName(viewer,buf);
553:       DMView(cdm, viewer);
554:       PetscViewerDestroy(&viewer);
555:       DMGetCoarseDM(cdm, &cdm);
556:     }
557:   }
558:   PetscLogEventEnd(user->createMeshEvent,0,0,0,0);
559:   return(0);
560: }

562: static PetscErrorCode SetupProblem(PetscDS prob, AppCtx *user)
563: {
564:   const PetscInt id = 1;

568:   switch (user->variableCoefficient) {
569:   case COEFF_NONE:
570:     if (user->periodicity[0]) {
571:       if (user->periodicity[1]) {
572:         PetscDSSetResidual(prob, 0, f0_xytrig_u, f1_u);
573:         PetscDSSetJacobian(prob, 0, 0, NULL, NULL, NULL, g3_uu);
574:       } else {
575:         PetscDSSetResidual(prob, 0, f0_xtrig_u,  f1_u);
576:         PetscDSSetJacobian(prob, 0, 0, NULL, NULL, NULL, g3_uu);
577:       }
578:     } else {
579:       PetscDSSetResidual(prob, 0, f0_u, f1_u);
580:       PetscDSSetJacobian(prob, 0, 0, NULL, NULL, NULL, g3_uu);
581:     }
582:     break;
583:   case COEFF_ANALYTIC:
584:     PetscDSSetResidual(prob, 0, f0_analytic_u, f1_analytic_u);
585:     PetscDSSetJacobian(prob, 0, 0, NULL, NULL, NULL, g3_analytic_uu);
586:     break;
587:   case COEFF_FIELD:
588:     PetscDSSetResidual(prob, 0, f0_analytic_u, f1_field_u);
589:     PetscDSSetJacobian(prob, 0, 0, NULL, NULL, NULL, g3_field_uu);
590:     break;
591:   case COEFF_NONLINEAR:
592:     PetscDSSetResidual(prob, 0, f0_analytic_nonlinear_u, f1_analytic_nonlinear_u);
593:     PetscDSSetJacobian(prob, 0, 0, NULL, NULL, NULL, g3_analytic_nonlinear_uu);
594:     break;
595:   default: SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Invalid variable coefficient type %d", user->variableCoefficient);
596:   }
597:   switch (user->dim) {
598:   case 2:
599:     if (user->periodicity[0]) {
600:       if (user->periodicity[1]) {
601:         user->exactFuncs[0] = xytrig_u_2d;
602:       } else {
603:         user->exactFuncs[0] = xtrig_u_2d;
604:       }
605:     } else {
606:       user->exactFuncs[0]  = quadratic_u_2d;
607:       user->exactFields[0] = quadratic_u_field_2d;
608:     }
609:     if (user->bcType == NEUMANN) {PetscDSSetBdResidual(prob, 0, f0_bd_u, f1_bd_zero);}
610:     break;
611:   case 3:
612:     user->exactFuncs[0]  = quadratic_u_3d;
613:     user->exactFields[0] = quadratic_u_field_3d;
614:     if (user->bcType == NEUMANN) {PetscDSSetBdResidual(prob, 0, f0_bd_u, f1_bd_zero);}
615:     break;
616:   default:
617:     SETERRQ1(PETSC_COMM_WORLD, PETSC_ERR_ARG_OUTOFRANGE, "Invalid dimension %d", user->dim);
618:   }
619:   PetscDSAddBoundary(prob, user->bcType == DIRICHLET ? (user->fieldBC ? DM_BC_ESSENTIAL_FIELD : DM_BC_ESSENTIAL) : DM_BC_NATURAL,
620:                             "wall", user->bcType == DIRICHLET ? "marker" : "boundary", 0, 0, NULL,
621:                             user->fieldBC ? (void (*)()) user->exactFields[0] : (void (*)()) user->exactFuncs[0], 1, &id, user);
622:   return(0);
623: }

625: static PetscErrorCode SetupMaterial(DM dm, DM dmAux, AppCtx *user)
626: {
627:   PetscErrorCode (*matFuncs[1])(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) = {nu_2d};
628:   Vec            nu;

632:   DMCreateLocalVector(dmAux, &nu);
633:   DMProjectFunctionLocal(dmAux, 0.0, matFuncs, NULL, INSERT_ALL_VALUES, nu);
634:   PetscObjectCompose((PetscObject) dm, "A", (PetscObject) nu);
635:   VecDestroy(&nu);
636:   return(0);
637: }

639: static PetscErrorCode SetupBC(DM dm, DM dmAux, AppCtx *user)
640: {
641:   PetscErrorCode (*bcFuncs[1])(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx);
642:   Vec            uexact;
643:   PetscInt       dim;

647:   DMGetDimension(dm, &dim);
648:   if (dim == 2) bcFuncs[0] = quadratic_u_2d;
649:   else          bcFuncs[0] = quadratic_u_3d;
650:   DMCreateLocalVector(dmAux, &uexact);
651:   DMProjectFunctionLocal(dmAux, 0.0, bcFuncs, NULL, INSERT_ALL_VALUES, uexact);
652:   PetscObjectCompose((PetscObject) dm, "A", (PetscObject) uexact);
653:   VecDestroy(&uexact);
654:   return(0);
655: }

657: static PetscErrorCode SetupDiscretization(DM dm, AppCtx *user)
658: {
659:   DM             cdm   = dm;
660:   const PetscInt dim   = user->dim;
661:   PetscFE        feAux = NULL;
662:   PetscFE        feCh  = NULL;
663:   PetscFE        fe;
664:   PetscDS        prob, probAux = NULL, probCh = NULL;
665:   PetscBool      simplex = user->simplex;

669:   /* Create finite element */
670:   PetscFECreateDefault(dm, dim, 1, simplex, NULL, -1, &fe);
671:   PetscObjectSetName((PetscObject) fe, "potential");
672:   if (user->variableCoefficient == COEFF_FIELD) {
673:     PetscQuadrature q;

675:     PetscFECreateDefault(dm, dim, 1, simplex, "mat_", -1, &feAux);
676:     PetscFEGetQuadrature(fe, &q);
677:     PetscFESetQuadrature(feAux, q);
678:     PetscDSCreate(PetscObjectComm((PetscObject)dm),&probAux);
679:     PetscDSSetDiscretization(probAux, 0, (PetscObject) feAux);
680:   } else if (user->fieldBC) {
681:     PetscQuadrature q;

683:     PetscFECreateDefault(dm, dim, 1, simplex, "bc_", -1, &feAux);
684:     PetscFEGetQuadrature(fe, &q);
685:     PetscFESetQuadrature(feAux, q);
686:     PetscDSCreate(PetscObjectComm((PetscObject)dm),&probAux);
687:     PetscDSSetDiscretization(probAux, 0, (PetscObject) feAux);
688:   }
689:   if (user->check) {
690:     PetscFECreateDefault(dm, dim, 1, simplex, "ch_", -1, &feCh);
691:     PetscDSCreate(PetscObjectComm((PetscObject)dm),&probCh);
692:     PetscDSSetDiscretization(probCh, 0, (PetscObject) feCh);
693:   }
694:   /* Set discretization and boundary conditions for each mesh */
695:   DMGetDS(dm, &prob);
696:   PetscDSSetDiscretization(prob, 0, (PetscObject) fe);
697:   SetupProblem(prob, user);
698:   while (cdm) {
699:     DM coordDM;

701:     DMSetDS(cdm,prob);
702:     DMGetCoordinateDM(cdm,&coordDM);
703:     if (feAux) {
704:       DM      dmAux;

706:       DMClone(cdm, &dmAux);
707:       DMSetCoordinateDM(dmAux, coordDM);
708:       DMSetDS(dmAux, probAux);
709:       PetscObjectCompose((PetscObject) dm, "dmAux", (PetscObject) dmAux);
710:       if (user->fieldBC) {SetupBC(cdm, dmAux, user);}
711:       else               {SetupMaterial(cdm, dmAux, user);}
712:       DMDestroy(&dmAux);
713:     }
714:     if (feCh) {
715:       DM      dmCh;

717:       DMClone(cdm, &dmCh);
718:       DMSetCoordinateDM(dmCh, coordDM);
719:       DMSetDS(dmCh, probCh);
720:       PetscObjectCompose((PetscObject) dm, "dmCh", (PetscObject) dmCh);
721:       DMDestroy(&dmCh);
722:     }
723:     if (user->bcType == DIRICHLET) {
724:       PetscBool hasLabel;

726:       DMHasLabel(cdm, "marker", &hasLabel);
727:       if (!hasLabel) {CreateBCLabel(cdm, "marker");}
728:     }
729:     DMGetCoarseDM(cdm, &cdm);
730:   }
731:   PetscFEDestroy(&fe);
732:   PetscFEDestroy(&feAux);
733:   PetscFEDestroy(&feCh);
734:   PetscDSDestroy(&probAux);
735:   PetscDSDestroy(&probCh);
736:   return(0);
737: }

739: #include "petsc/private/petscimpl.h"

741: /*@C
742:   KSPMonitorError - Outputs the error at each iteration of an iterative solver.

744:   Collective on KSP

746:   Input Parameters:
747: + ksp   - the KSP
748: . its   - iteration number
749: . rnorm - 2-norm, preconditioned residual value (may be estimated).
750: - ctx   - monitor context

752:   Level: intermediate

754: .keywords: KSP, default, monitor, residual
755: .seealso: KSPMonitorSet(), KSPMonitorTrueResidualNorm(), KSPMonitorDefault()
756: @*/
757: static PetscErrorCode KSPMonitorError(KSP ksp, PetscInt its, PetscReal rnorm, void *ctx)
758: {
759:   AppCtx        *user = (AppCtx *) ctx;
760:   DM             dm;
761:   Vec            du, r;
762:   PetscInt       level = 0;
763:   PetscBool      hasLevel;
764:   PetscViewer    viewer;
765:   char           buf[256];

769:   KSPGetDM(ksp, &dm);
770:   /* Calculate solution */
771:   {
772:     PC        pc = user->pcmg; /* The MG PC */
773:     DM        fdm = NULL,  cdm;
774:     KSP       fksp, cksp;
775:     Vec       fu,   cu;
776:     PetscInt  levels, l;

778:     KSPBuildSolution(ksp, NULL, &du);
779:     PetscObjectComposedDataGetInt((PetscObject) ksp, PetscMGLevelId, level, hasLevel);
780:     PCMGGetLevels(pc, &levels);
781:     PCMGGetSmoother(pc, levels-1, &fksp);
782:     KSPBuildSolution(fksp, NULL, &fu);
783:     for (l = levels-1; l > level; --l) {
784:       Mat R;
785:       Vec s;

787:       PCMGGetSmoother(pc, l-1, &cksp);
788:       KSPGetDM(cksp, &cdm);
789:       DMGetGlobalVector(cdm, &cu);
790:       PCMGGetRestriction(pc, l, &R);
791:       PCMGGetRScale(pc, l, &s);
792:       MatRestrict(R, fu, cu);
793:       VecPointwiseMult(cu, cu, s);
794:       if (l < levels-1) {DMRestoreGlobalVector(fdm, &fu);}
795:       fdm  = cdm;
796:       fu   = cu;
797:     }
798:     if (levels-1 > level) {
799:       VecAXPY(du, 1.0, cu);
800:       DMRestoreGlobalVector(cdm, &cu);
801:     }
802:   }
803:   /* Calculate error */
804:   DMGetGlobalVector(dm, &r);
805:   DMProjectFunction(dm, 0.0, user->exactFuncs, NULL, INSERT_ALL_VALUES, r);
806:   VecAXPY(r,-1.0,du);
807:   PetscObjectSetName((PetscObject) r, "solution error");
808:   /* View error */
809:   PetscSNPrintf(buf, 256, "ex12-%D.h5", level);
810:   PetscViewerHDF5Open(PETSC_COMM_WORLD, buf, FILE_MODE_APPEND, &viewer);
811:   VecView(r, viewer);
812:   /* Cleanup */
813:   PetscViewerDestroy(&viewer);
814:   DMRestoreGlobalVector(dm, &r);
815:   return(0);
816: }

818: /*@C
819:   SNESMonitorError - Outputs the error at each iteration of an iterative solver.

821:   Collective on SNES

823:   Input Parameters:
824: + snes  - the SNES
825: . its   - iteration number
826: . rnorm - 2-norm of residual
827: - ctx   - user context

829:   Level: intermediate

831: .keywords: SNES, nonlinear, default, monitor, norm
832: .seealso: SNESMonitorDefault(), SNESMonitorSet(), SNESMonitorSolution()
833: @*/
834: static PetscErrorCode SNESMonitorError(SNES snes, PetscInt its, PetscReal rnorm, void *ctx)
835: {
836:   AppCtx        *user = (AppCtx *) ctx;
837:   DM             dm;
838:   Vec            u, r;
839:   PetscInt       level = -1;
840:   PetscBool      hasLevel;
841:   PetscViewer    viewer;
842:   char           buf[256];

846:   SNESGetDM(snes, &dm);
847:   /* Calculate error */
848:   SNESGetSolution(snes, &u);
849:   DMGetGlobalVector(dm, &r);
850:   PetscObjectSetName((PetscObject) r, "solution error");
851:   DMProjectFunction(dm, 0.0, user->exactFuncs, NULL, INSERT_ALL_VALUES, r);
852:   VecAXPY(r, -1.0, u);
853:   /* View error */
854:   PetscObjectComposedDataGetInt((PetscObject) snes, PetscMGLevelId, level, hasLevel);
855:   PetscSNPrintf(buf, 256, "ex12-%D.h5", level);
856:   PetscViewerHDF5Open(PETSC_COMM_WORLD, buf, FILE_MODE_APPEND, &viewer);
857:   VecView(r, viewer);
858:   /* Cleanup */
859:   PetscViewerDestroy(&viewer);
860:   DMRestoreGlobalVector(dm, &r);
861:   return(0);
862: }

864: int main(int argc, char **argv)
865: {
866:   DM             dm;          /* Problem specification */
867:   SNES           snes;        /* nonlinear solver */
868:   Vec            u,r;         /* solution, residual vectors */
869:   Mat            A,J;         /* Jacobian matrix */
870:   MatNullSpace   nullSpace;   /* May be necessary for Neumann conditions */
871:   AppCtx         user;        /* user-defined work context */
872:   JacActionCtx   userJ;       /* context for Jacobian MF action */
873:   PetscInt       its;         /* iterations for convergence */
874:   PetscReal      error = 0.0; /* L_2 error in the solution */
875:   PetscBool      isFAS;

878:   PetscInitialize(&argc, &argv, NULL,help);if (ierr) return ierr;
879:   ProcessOptions(PETSC_COMM_WORLD, &user);
880:   SNESCreate(PETSC_COMM_WORLD, &snes);
881:   CreateMesh(PETSC_COMM_WORLD, &user, &dm);
882:   SNESSetDM(snes, dm);
883:   DMSetApplicationContext(dm, &user);

885:   PetscMalloc2(1, &user.exactFuncs, 1, &user.exactFields);
886:   SetupDiscretization(dm, &user);

888:   DMCreateGlobalVector(dm, &u);
889:   PetscObjectSetName((PetscObject) u, "potential");
890:   VecDuplicate(u, &r);

892:   DMCreateMatrix(dm, &J);
893:   if (user.jacobianMF) {
894:     PetscInt M, m, N, n;

896:     MatGetSize(J, &M, &N);
897:     MatGetLocalSize(J, &m, &n);
898:     MatCreate(PETSC_COMM_WORLD, &A);
899:     MatSetSizes(A, m, n, M, N);
900:     MatSetType(A, MATSHELL);
901:     MatSetUp(A);
902: #if 0
903:     MatShellSetOperation(A, MATOP_MULT, (void (*)(void))FormJacobianAction);
904: #endif

906:     userJ.dm   = dm;
907:     userJ.J    = J;
908:     userJ.user = &user;

910:     DMCreateLocalVector(dm, &userJ.u);
911:     if (user.fieldBC) {DMProjectFieldLocal(dm, 0.0, userJ.u, user.exactFields, INSERT_BC_VALUES, userJ.u);}
912:     else              {DMProjectFunctionLocal(dm, 0.0, user.exactFuncs, NULL, INSERT_BC_VALUES, userJ.u);}
913:     MatShellSetContext(A, &userJ);
914:   } else {
915:     A = J;
916:   }
917:   if (user.bcType == NEUMANN) {
918:     MatNullSpaceCreate(PetscObjectComm((PetscObject) dm), PETSC_TRUE, 0, NULL, &nullSpace);
919:     MatSetNullSpace(A, nullSpace);
920:   }

922:   DMPlexSetSNESLocalFEM(dm,&user,&user,&user);
923:   SNESSetJacobian(snes, A, J, NULL, NULL);

925:   SNESSetFromOptions(snes);

927:   if (user.fieldBC) {DMProjectField(dm, 0.0, u, user.exactFields, INSERT_ALL_VALUES, u);}
928:   else              {DMProjectFunction(dm, 0.0, user.exactFuncs, NULL, INSERT_ALL_VALUES, u);}
929:   if (user.restart) {
930: #if defined(PETSC_HAVE_HDF5)
931:     PetscViewer viewer;

933:     PetscViewerCreate(PETSC_COMM_WORLD, &viewer);
934:     PetscViewerSetType(viewer, PETSCVIEWERHDF5);
935:     PetscViewerFileSetMode(viewer, FILE_MODE_READ);
936:     PetscViewerFileSetName(viewer, user.filename);
937:     PetscViewerHDF5PushGroup(viewer, "/fields");
938:     VecLoad(u, viewer);
939:     PetscViewerHDF5PopGroup(viewer);
940:     PetscViewerDestroy(&viewer);
941: #endif
942:   }
943:   if (user.showInitial) {
944:     Vec lv;
945:     DMGetLocalVector(dm, &lv);
946:     DMGlobalToLocalBegin(dm, u, INSERT_VALUES, lv);
947:     DMGlobalToLocalEnd(dm, u, INSERT_VALUES, lv);
948:     DMPrintLocalVec(dm, "Local function", 1.0e-10, lv);
949:     DMRestoreLocalVector(dm, &lv);
950:   }
951:   if (user.viewHierarchy) {
952:     SNES      lsnes;
953:     KSP       ksp;
954:     PC        pc;
955:     PetscInt  numLevels, l;
956:     PetscBool isMG;

958:     PetscObjectTypeCompare((PetscObject) snes, SNESFAS, &isFAS);
959:     if (isFAS) {
960:       SNESFASGetLevels(snes, &numLevels);
961:       for (l = 0; l < numLevels; ++l) {
962:         SNESFASGetCycleSNES(snes, l, &lsnes);
963:         SNESMonitorSet(lsnes, SNESMonitorError, &user, NULL);
964:       }
965:     } else {
966:       SNESGetKSP(snes, &ksp);
967:       KSPGetPC(ksp, &pc);
968:       PetscObjectTypeCompare((PetscObject) pc, PCMG, &isMG);
969:       if (isMG) {
970:         user.pcmg = pc;
971:         PCMGGetLevels(pc, &numLevels);
972:         for (l = 0; l < numLevels; ++l) {
973:           PCMGGetSmootherDown(pc, l, &ksp);
974:           KSPMonitorSet(ksp, KSPMonitorError, &user, NULL);
975:         }
976:       }
977:     }
978:   }
979:   if (user.runType == RUN_FULL || user.runType == RUN_EXACT) {
980:     PetscErrorCode (*initialGuess[1])(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) = {zero};

982:     if (user.nonzInit) initialGuess[0] = ecks;
983:     if (user.runType == RUN_FULL) {
984:       DMProjectFunction(dm, 0.0, initialGuess, NULL, INSERT_VALUES, u);
985:     }
986:     if (user.debug) {
987:       PetscPrintf(PETSC_COMM_WORLD, "Initial guess\n");
988:       VecView(u, PETSC_VIEWER_STDOUT_WORLD);
989:     }
990:     SNESSolve(snes, NULL, u);
991:     SNESGetIterationNumber(snes, &its);
992:     PetscPrintf(PETSC_COMM_WORLD, "Number of SNES iterations = %D\n", its);
993:     DMComputeL2Diff(dm, 0.0, user.exactFuncs, NULL, u, &error);
994:     if (error < 1.0e-11) {PetscPrintf(PETSC_COMM_WORLD, "L_2 Error: < 1.0e-11\n");}
995:     else                 {PetscPrintf(PETSC_COMM_WORLD, "L_2 Error: %g\n", error);}
996:     if (user.showSolution) {
997:       PetscPrintf(PETSC_COMM_WORLD, "Solution\n");
998:       VecChop(u, 3.0e-9);
999:       VecView(u, PETSC_VIEWER_STDOUT_WORLD);
1000:     }
1001:   } else if (user.runType == RUN_PERF) {
1002:     PetscReal res = 0.0;

1004:     SNESComputeFunction(snes, u, r);
1005:     PetscPrintf(PETSC_COMM_WORLD, "Initial Residual\n");
1006:     VecChop(r, 1.0e-10);
1007:     VecNorm(r, NORM_2, &res);
1008:     PetscPrintf(PETSC_COMM_WORLD, "L_2 Residual: %g\n", res);
1009:   } else {
1010:     PetscReal res = 0.0;

1012:     /* Check discretization error */
1013:     PetscPrintf(PETSC_COMM_WORLD, "Initial guess\n");
1014:     if (!user.quiet) {VecView(u, PETSC_VIEWER_STDOUT_WORLD);}
1015:     DMComputeL2Diff(dm, 0.0, user.exactFuncs, NULL, u, &error);
1016:     if (error < 1.0e-11) {PetscPrintf(PETSC_COMM_WORLD, "L_2 Error: < 1.0e-11\n");}
1017:     else                 {PetscPrintf(PETSC_COMM_WORLD, "L_2 Error: %g\n", error);}
1018:     /* Check residual */
1019:     SNESComputeFunction(snes, u, r);
1020:     PetscPrintf(PETSC_COMM_WORLD, "Initial Residual\n");
1021:     VecChop(r, 1.0e-10);
1022:     if (!user.quiet) {VecView(r, PETSC_VIEWER_STDOUT_WORLD);}
1023:     VecNorm(r, NORM_2, &res);
1024:     PetscPrintf(PETSC_COMM_WORLD, "L_2 Residual: %g\n", res);
1025:     /* Check Jacobian */
1026:     {
1027:       Vec          b;

1029:       SNESComputeJacobian(snes, u, A, A);
1030:       VecDuplicate(u, &b);
1031:       VecSet(r, 0.0);
1032:       SNESComputeFunction(snes, r, b);
1033:       MatMult(A, u, r);
1034:       VecAXPY(r, 1.0, b);
1035:       VecDestroy(&b);
1036:       PetscPrintf(PETSC_COMM_WORLD, "Au - b = Au + F(0)\n");
1037:       VecChop(r, 1.0e-10);
1038:       if (!user.quiet) {VecView(r, PETSC_VIEWER_STDOUT_WORLD);}
1039:       VecNorm(r, NORM_2, &res);
1040:       PetscPrintf(PETSC_COMM_WORLD, "Linear L_2 Residual: %g\n", res);
1041:     }
1042:   }
1043:   VecViewFromOptions(u, NULL, "-vec_view");

1045:   if (user.bcType == NEUMANN) {MatNullSpaceDestroy(&nullSpace);}
1046:   if (user.jacobianMF) {VecDestroy(&userJ.u);}
1047:   if (A != J) {MatDestroy(&A);}
1048:   MatDestroy(&J);
1049:   VecDestroy(&u);
1050:   VecDestroy(&r);
1051:   SNESDestroy(&snes);
1052:   DMDestroy(&dm);
1053:   PetscFree2(user.exactFuncs, user.exactFields);
1054:   PetscFinalize();
1055:   return ierr;
1056: }

1058: /*TEST

1060:   # 2D serial P1 test 0-4
1061:   test:
1062:     suffix: 0
1063:     requires: hdf5 triangle
1064:     args: -run_type test -refinement_limit 0.0    -bc_type dirichlet -interpolate 0 -petscspace_order 1 -show_initial -dm_plex_print_fem 1
1065:   test:
1066:     suffix: 1
1067:     requires: hdf5 triangle
1068:     args: -run_type test -refinement_limit 0.0    -bc_type dirichlet -interpolate 1 -petscspace_order 1 -show_initial -dm_plex_print_fem 1
1069:   test:
1070:     suffix: 2
1071:     requires: hdf5 triangle
1072:     args: -run_type test -refinement_limit 0.0625 -bc_type dirichlet -interpolate 1 -petscspace_order 1 -show_initial -dm_plex_print_fem 1
1073:   test:
1074:     suffix: 3
1075:     requires: hdf5 triangle
1076:     args: -run_type test -refinement_limit 0.0    -bc_type neumann   -interpolate 1 -petscspace_order 1 -show_initial -dm_plex_print_fem 1 -dm_view ascii::ascii_info_detail
1077:   test:
1078:     suffix: 4
1079:     requires: hdf5 triangle
1080:     args: -run_type test -refinement_limit 0.0625 -bc_type neumann   -interpolate 1 -petscspace_order 1 -show_initial -dm_plex_print_fem 1
1081:   # 2D serial P2 test 5-8
1082:   test:
1083:     suffix: 5
1084:     requires: hdf5 triangle
1085:     args: -run_type test -refinement_limit 0.0    -bc_type dirichlet -interpolate 1 -petscspace_order 2 -show_initial -dm_plex_print_fem 1
1086:   test:
1087:     suffix: 6
1088:     requires: hdf5 triangle
1089:     args: -run_type test -refinement_limit 0.0625 -bc_type dirichlet -interpolate 1 -petscspace_order 2 -show_initial -dm_plex_print_fem 1
1090:   test:
1091:     suffix: 7
1092:     requires: hdf5 triangle
1093:     args: -run_type test -refinement_limit 0.0    -bc_type neumann   -interpolate 1 -petscspace_order 2 -show_initial -dm_plex_print_fem 1 -dm_view ascii::ascii_info_detail
1094:   test:
1095:     suffix: 8
1096:     requires: hdf5 triangle
1097:     args: -run_type test -refinement_limit 0.0625 -bc_type neumann   -interpolate 1 -petscspace_order 2 -show_initial -dm_plex_print_fem 1 -dm_view ascii::ascii_info_detail
1098:   # 3D serial P1 test 9-12
1099:   test:
1100:     suffix: 9
1101:     requires: hdf5 ctetgen
1102:     args: -run_type test -dim 3 -refinement_limit 0.0    -bc_type dirichlet -interpolate 0 -petscspace_order 1 -show_initial -dm_plex_print_fem 1 -dm_view
1103:   test:
1104:     suffix: 10
1105:     requires: hdf5 ctetgen
1106:     args: -run_type test -dim 3 -refinement_limit 0.0    -bc_type dirichlet -interpolate 1 -petscspace_order 1 -show_initial -dm_plex_print_fem 1 -dm_view
1107:   test:
1108:     suffix: 11
1109:     requires: hdf5 ctetgen
1110:     args: -run_type test -dim 3 -refinement_limit 0.0125 -bc_type dirichlet -interpolate 1 -petscspace_order 1 -show_initial -dm_plex_print_fem 1 -dm_view
1111:   test:
1112:     suffix: 12
1113:     requires: hdf5 ctetgen
1114:     args: -run_type test -dim 3 -refinement_limit 0.0    -bc_type neumann   -interpolate 1 -petscspace_order 1 -snes_fd -show_initial -dm_plex_print_fem 1 -dm_view
1115:   # Analytic variable coefficient 13-20
1116:   test:
1117:     suffix: 13
1118:     requires: hdf5 triangle
1119:     args: -run_type test -refinement_limit 0.0    -variable_coefficient analytic -interpolate 1 -petscspace_order 1 -show_initial -dm_plex_print_fem 1
1120:   test:
1121:     suffix: 14
1122:     requires: hdf5 triangle
1123:     args: -run_type test -refinement_limit 0.0625 -variable_coefficient analytic -interpolate 1 -petscspace_order 1 -show_initial -dm_plex_print_fem 1
1124:   test:
1125:     suffix: 15
1126:     requires: hdf5 triangle
1127:     args: -run_type test -refinement_limit 0.0    -variable_coefficient analytic -interpolate 1 -petscspace_order 2 -show_initial -dm_plex_print_fem 1
1128:   test:
1129:     suffix: 16
1130:     requires: hdf5 triangle
1131:     args: -run_type test -refinement_limit 0.0625 -variable_coefficient analytic -interpolate 1 -petscspace_order 2 -show_initial -dm_plex_print_fem 1
1132:   test:
1133:     suffix: 17
1134:     requires: hdf5 ctetgen
1135:     args: -run_type test -dim 3 -refinement_limit 0.0    -variable_coefficient analytic -interpolate 1 -petscspace_order 1 -show_initial -dm_plex_print_fem 1
1136:   test:
1137:     suffix: 18
1138:     requires: hdf5 ctetgen
1139:     args: -run_type test -dim 3 -refinement_limit 0.0125 -variable_coefficient analytic -interpolate 1 -petscspace_order 1 -show_initial -dm_plex_print_fem 1
1140:   test:
1141:     suffix: 19
1142:     requires: hdf5 ctetgen
1143:     args: -run_type test -dim 3 -refinement_limit 0.0    -variable_coefficient analytic -interpolate 1 -petscspace_order 2 -show_initial -dm_plex_print_fem 1
1144:   test:
1145:     suffix: 20
1146:     requires: hdf5 ctetgen
1147:     args: -run_type test -dim 3 -refinement_limit 0.0125 -variable_coefficient analytic -interpolate 1 -petscspace_order 2 -show_initial -dm_plex_print_fem 1
1148:   # P1 variable coefficient 21-28
1149:   test:
1150:     suffix: 21
1151:     requires: hdf5 triangle
1152:     args: -run_type test -refinement_limit 0.0    -variable_coefficient field    -interpolate 1 -petscspace_order 1 -mat_petscspace_order 1 -show_initial -dm_plex_print_fem 1
1153:   test:
1154:     suffix: 22
1155:     requires: hdf5 triangle
1156:     args: -run_type test -refinement_limit 0.0625 -variable_coefficient field    -interpolate 1 -petscspace_order 1 -mat_petscspace_order 1 -show_initial -dm_plex_print_fem 1
1157:   test:
1158:     suffix: 23
1159:     requires: hdf5 triangle
1160:     args: -run_type test -refinement_limit 0.0    -variable_coefficient field    -interpolate 1 -petscspace_order 2 -mat_petscspace_order 1 -show_initial -dm_plex_print_fem 1
1161:   test:
1162:     suffix: 24
1163:     requires: hdf5 triangle
1164:     args: -run_type test -refinement_limit 0.0625 -variable_coefficient field    -interpolate 1 -petscspace_order 2 -mat_petscspace_order 1 -show_initial -dm_plex_print_fem 1
1165:   test:
1166:     suffix: 25
1167:     requires: hdf5 ctetgen
1168:     args: -run_type test -dim 3 -refinement_limit 0.0    -variable_coefficient field    -interpolate 1 -petscspace_order 1 -mat_petscspace_order 1 -show_initial -dm_plex_print_fem 1
1169:   test:
1170:     suffix: 26
1171:     requires: hdf5 ctetgen
1172:     args: -run_type test -dim 3 -refinement_limit 0.0125 -variable_coefficient field    -interpolate 1 -petscspace_order 1 -mat_petscspace_order 1 -show_initial -dm_plex_print_fem 1
1173:   test:
1174:     suffix: 27
1175:     requires: hdf5 ctetgen
1176:     args: -run_type test -dim 3 -refinement_limit 0.0    -variable_coefficient field    -interpolate 1 -petscspace_order 2 -mat_petscspace_order 1 -show_initial -dm_plex_print_fem 1
1177:   test:
1178:     suffix: 28
1179:     requires: hdf5 ctetgen
1180:     args: -run_type test -dim 3 -refinement_limit 0.0125 -variable_coefficient field    -interpolate 1 -petscspace_order 2 -mat_petscspace_order 1 -show_initial -dm_plex_print_fem 1
1181:   # P0 variable coefficient 29-36
1182:   test:
1183:     suffix: 29
1184:     requires: hdf5 triangle
1185:     args: -run_type test -refinement_limit 0.0    -variable_coefficient field    -interpolate 1 -petscspace_order 1 -show_initial -dm_plex_print_fem 1
1186:   test:
1187:     suffix: 30
1188:     requires: hdf5 triangle
1189:     args: -run_type test -refinement_limit 0.0625 -variable_coefficient field    -interpolate 1 -petscspace_order 1 -show_initial -dm_plex_print_fem 1
1190:   test:
1191:     suffix: 31
1192:     requires: hdf5 triangle
1193:     args: -run_type test -refinement_limit 0.0    -variable_coefficient field    -interpolate 1 -petscspace_order 2 -show_initial -dm_plex_print_fem 1
1194:   test:
1195:     requires: hdf5 triangle
1196:     suffix: 32
1197:     args: -run_type test -refinement_limit 0.0625 -variable_coefficient field    -interpolate 1 -petscspace_order 2 -show_initial -dm_plex_print_fem 1
1198:   test:
1199:     requires: hdf5 ctetgen
1200:     suffix: 33
1201:     args: -run_type test -dim 3 -refinement_limit 0.0    -variable_coefficient field    -interpolate 1 -petscspace_order 1 -show_initial -dm_plex_print_fem 1
1202:   test:
1203:     suffix: 34
1204:     requires: hdf5 ctetgen
1205:     args: -run_type test -dim 3 -refinement_limit 0.0125 -variable_coefficient field    -interpolate 1 -petscspace_order 1 -show_initial -dm_plex_print_fem 1
1206:   test:
1207:     suffix: 35
1208:     requires: hdf5 ctetgen
1209:     args: -run_type test -dim 3 -refinement_limit 0.0    -variable_coefficient field    -interpolate 1 -petscspace_order 2 -show_initial -dm_plex_print_fem 1
1210:   test:
1211:     suffix: 36
1212:     requires: hdf5 ctetgen
1213:     args: -run_type test -dim 3 -refinement_limit 0.0125 -variable_coefficient field    -interpolate 1 -petscspace_order 2 -show_initial -dm_plex_print_fem 1
1214:   # Full solve 39-44
1215:   test:
1216:     suffix: 39
1217:     requires: hdf5 triangle
1218:     args: -run_type full -refinement_limit 0.015625 -interpolate 1 -petscspace_order 2 -pc_type gamg -ksp_rtol 1.0e-10 -ksp_monitor_short -ksp_converged_reason -snes_monitor_short -snes_converged_reason
1219:   test:
1220:     suffix: 40
1221:     requires: hdf5 triangle
1222:     args: -run_type full -refinement_limit 0.015625 -variable_coefficient nonlinear -interpolate 1 -petscspace_order 2 -pc_type svd -ksp_rtol 1.0e-10 -snes_monitor_short -snes_converged_reason
1223:   test:
1224:     suffix: 41
1225:     requires: hdf5 triangle
1226:     args: -run_type full -refinement_limit 0.03125 -variable_coefficient nonlinear -interpolate 1 -petscspace_order 1 -snes_type fas -snes_fas_levels 2 -pc_type svd -ksp_rtol 1.0e-10 -fas_coarse_pc_type svd -fas_coarse_ksp_rtol 1.0e-10 -fas_coarse_snes_monitor_short -snes_monitor_short -snes_linesearch_type basic -fas_coarse_snes_linesearch_type basic -snes_converged_reason -dm_refine_hierarchy 1 -snes_view -fas_levels_1_snes_type newtonls -fas_levels_1_pc_type svd -fas_levels_1_ksp_rtol 1.0e-10 -fas_levels_1_snes_monitor_short
1227:   test:
1228:     suffix: 42
1229:     requires: hdf5 triangle
1230:     args: -run_type full -refinement_limit 0.0625 -variable_coefficient nonlinear -interpolate 1 -petscspace_order 1 -snes_type fas -snes_fas_levels 3 -pc_type svd -ksp_rtol 1.0e-10 -fas_coarse_pc_type svd -fas_coarse_ksp_rtol 1.0e-10 -fas_coarse_snes_monitor_short -snes_monitor_short -snes_linesearch_type basic -fas_coarse_snes_linesearch_type basic -snes_converged_reason -dm_refine_hierarchy 2 -dm_plex_print_fem 0 -snes_view -fas_levels_1_snes_type newtonls -fas_levels_1_pc_type svd -fas_levels_1_ksp_rtol 1.0e-10 -fas_levels_1_snes_monitor_short -fas_levels_2_snes_type newtonls -fas_levels_2_pc_type svd -fas_levels_2_ksp_rtol 1.0e-10 -fas_levels_2_snes_atol 1.0e-11 -fas_levels_2_snes_monitor_short
1231:   test:
1232:     suffix: 43
1233:     requires: hdf5 triangle
1234:     nsize: 2
1235:     args: -run_type full -refinement_limit 0.03125 -variable_coefficient nonlinear -interpolate 1 -petscspace_order 1 -snes_type fas -snes_fas_levels 2 -pc_type svd -ksp_rtol 1.0e-10 -fas_coarse_pc_type svd -fas_coarse_ksp_rtol 1.0e-10 -fas_coarse_snes_monitor_short -snes_monitor_short -snes_linesearch_type basic -fas_coarse_snes_linesearch_type basic -snes_converged_reason -dm_refine_hierarchy 1 -snes_view -fas_levels_1_snes_type newtonls -fas_levels_1_pc_type svd -fas_levels_1_ksp_rtol 1.0e-10 -fas_levels_1_snes_monitor_short
1236:   test:
1237:     suffix: 44
1238:     requires: hdf5 triangle
1239:     nsize: 2
1240:     args: -run_type full -refinement_limit 0.0625 -variable_coefficient nonlinear -interpolate 1 -petscspace_order 1 -snes_type fas -snes_fas_levels 3 -pc_type svd -ksp_rtol 1.0e-10 -fas_coarse_pc_type svd -fas_coarse_ksp_rtol 1.0e-10 -fas_coarse_snes_monitor_short -snes_monitor_short -snes_linesearch_type basic -fas_coarse_snes_linesearch_type basic -snes_converged_reason -dm_refine_hierarchy 2 -dm_plex_print_fem 0 -snes_view -fas_levels_1_snes_type newtonls -fas_levels_1_pc_type svd -fas_levels_1_ksp_rtol 1.0e-10 -fas_levels_1_snes_monitor_short -fas_levels_2_snes_type newtonls -fas_levels_2_pc_type svd -fas_levels_2_ksp_rtol 1.0e-10 -fas_levels_2_snes_atol 1.0e-11 -fas_levels_2_snes_monitor_short
1241:   # Restarting
1242:   test:
1243:     suffix: restart
1244:     requires: hdf5 triangle !complex
1245:     args: -run_type test -refinement_limit 0.0    -bc_type dirichlet -interpolate 1 -petscspace_order 1
1246:     test:
1247:       args: -dm_view hdf5:sol.h5 -vec_view hdf5:sol.h5::append
1248:     test:
1249:       args: -f sol.h5 -restart
1250:   # Periodicity
1251:   test:
1252:     suffix: periodic_0
1253:     requires: hdf5 triangle
1254:     args: -run_type full -refinement_limit 0.0    -bc_type dirichlet -interpolate 1 -petscspace_order 1
1255:   # 2D serial P1 test with field bc
1256:   test:
1257:     suffix: field_bc_p1_0
1258:     requires: hdf5 triangle
1259:     args: -run_type test              -interpolate 1 -bc_type dirichlet -field_bc -petscspace_order 1 -bc_petscspace_order 2 -show_initial -dm_plex_print_fem 1
1260:   test:
1261:     suffix: field_bc_p1_1
1262:     requires: hdf5 triangle
1263:     args: -run_type test -dm_refine 1 -interpolate 1 -bc_type dirichlet -field_bc -petscspace_order 1 -bc_petscspace_order 2 -show_initial -dm_plex_print_fem 1
1264:   test:
1265:     suffix: field_bc_p1_2
1266:     requires: hdf5 triangle
1267:     args: -run_type test              -interpolate 1 -bc_type neumann   -field_bc -petscspace_order 1 -bc_petscspace_order 2 -show_initial -dm_plex_print_fem 1
1268:   test:
1269:     suffix: field_bc_p1_3
1270:     requires: hdf5 triangle
1271:     args: -run_type test -dm_refine 1 -interpolate 1 -bc_type neumann   -field_bc -petscspace_order 1 -bc_petscspace_order 2 -show_initial -dm_plex_print_fem 1
1272:   # 3D serial P1 test with field bc
1273:   test:
1274:     suffix: field_bc_p1_4
1275:     requires: hdf5 ctetgen
1276:     args: -run_type test -dim 3              -interpolate 1 -bc_type dirichlet -field_bc -petscspace_order 1 -bc_petscspace_order 2 -show_initial -dm_plex_print_fem 1
1277:   test:
1278:     suffix: field_bc_p1_5
1279:     requires: hdf5 ctetgen
1280:     args: -run_type test -dim 3 -dm_refine 1 -interpolate 1 -bc_type dirichlet -field_bc -petscspace_order 1 -bc_petscspace_order 2 -show_initial -dm_plex_print_fem 1
1281:   test:
1282:     suffix: field_bc_p1_6
1283:     requires: hdf5 ctetgen
1284:     args: -run_type test -dim 3              -interpolate 1 -bc_type neumann   -field_bc -petscspace_order 1 -bc_petscspace_order 2 -show_initial -dm_plex_print_fem 1
1285:   test:
1286:     suffix: field_bc_p1_7
1287:     requires: hdf5 ctetgen
1288:     args: -run_type test -dim 3 -dm_refine 1 -interpolate 1 -bc_type neumann   -field_bc -petscspace_order 1 -bc_petscspace_order 2 -show_initial -dm_plex_print_fem 1
1289:   # 2D serial P2 test with field bc
1290:   test:
1291:     suffix: field_bc_p2_0
1292:     requires: hdf5 triangle
1293:     args: -run_type test              -interpolate 1 -bc_type dirichlet -field_bc -petscspace_order 2 -bc_petscspace_order 2 -show_initial -dm_plex_print_fem 1
1294:   test:
1295:     suffix: field_bc_p2_1
1296:     requires: hdf5 triangle
1297:     args: -run_type test -dm_refine 1 -interpolate 1 -bc_type dirichlet -field_bc -petscspace_order 2 -bc_petscspace_order 2 -show_initial -dm_plex_print_fem 1
1298:   test:
1299:     suffix: field_bc_p2_2
1300:     requires: hdf5 triangle
1301:     args: -run_type test              -interpolate 1 -bc_type neumann   -field_bc -petscspace_order 2 -bc_petscspace_order 2 -show_initial -dm_plex_print_fem 1
1302:   test:
1303:     suffix: field_bc_p2_3
1304:     requires: hdf5 triangle
1305:     args: -run_type test -dm_refine 1 -interpolate 1 -bc_type neumann   -field_bc -petscspace_order 2 -bc_petscspace_order 2 -show_initial -dm_plex_print_fem 1
1306:   # 3D serial P2 test with field bc
1307:   test:
1308:     suffix: field_bc_p2_4
1309:     requires: hdf5 ctetgen
1310:     args: -run_type test -dim 3              -interpolate 1 -bc_type dirichlet -field_bc -petscspace_order 2 -bc_petscspace_order 2 -show_initial -dm_plex_print_fem 1
1311:   test:
1312:     suffix: field_bc_p2_5
1313:     requires: hdf5 ctetgen
1314:     args: -run_type test -dim 3 -dm_refine 1 -interpolate 1 -bc_type dirichlet -field_bc -petscspace_order 2 -bc_petscspace_order 2 -show_initial -dm_plex_print_fem 1
1315:   test:
1316:     suffix: field_bc_p2_6
1317:     requires: hdf5 ctetgen
1318:     args: -run_type test -dim 3              -interpolate 1 -bc_type neumann   -field_bc -petscspace_order 2 -bc_petscspace_order 2 -show_initial -dm_plex_print_fem 1
1319:   test:
1320:     suffix: field_bc_p2_7
1321:     requires: hdf5 ctetgen
1322:     args: -run_type test -dim 3 -dm_refine 1 -interpolate 1 -bc_type neumann   -field_bc -petscspace_order 2 -bc_petscspace_order 2 -show_initial -dm_plex_print_fem 1
1323:   # Full solve simplex: Convergence
1324:   test:
1325:     suffix: tet_conv_p1_r0
1326:     requires: hdf5 ctetgen
1327:     args: -run_type full -dim 3 -dm_refine 0 -bc_type dirichlet -interpolate 1 -petscspace_order 1 -dm_view -snes_converged_reason -pc_type lu
1328:   test:
1329:     suffix: tet_conv_p1_r2
1330:     requires: hdf5 ctetgen
1331:     args: -run_type full -dim 3 -dm_refine 2 -bc_type dirichlet -interpolate 1 -petscspace_order 1 -dm_view -snes_converged_reason -pc_type lu
1332:   test:
1333:     suffix: tet_conv_p1_r3
1334:     requires: hdf5 ctetgen
1335:     args: -run_type full -dim 3 -dm_refine 3 -bc_type dirichlet -interpolate 1 -petscspace_order 1 -dm_view -snes_converged_reason -pc_type lu
1336:   test:
1337:     suffix: tet_conv_p2_r0
1338:     requires: hdf5 ctetgen
1339:     args: -run_type full -dim 3 -dm_refine 0 -bc_type dirichlet -interpolate 1 -petscspace_order 2 -dm_view -snes_converged_reason -pc_type lu
1340:   test:
1341:     suffix: tet_conv_p2_r2
1342:     requires: hdf5 ctetgen
1343:     args: -run_type full -dim 3 -dm_refine 2 -bc_type dirichlet -interpolate 1 -petscspace_order 2 -dm_view -snes_converged_reason -pc_type lu
1344:   # Full solve simplex: BDDC
1345:   test:
1346:     suffix: tri_bddc
1347:     requires: hdf5 triangle
1348:     nsize: 5
1349:     args: -run_type full -petscpartitioner_type simple -dm_refine 3 -bc_type dirichlet -interpolate 1 -petscspace_order 1 -ksp_type gmres -ksp_gmres_restart 100 -ksp_rtol 1.0e-9 -dm_mat_type is -pc_type bddc -snes_monitor_short -ksp_monitor_short -snes_converged_reason -ksp_converged_reason -snes_view -show_solution 0
1350:   # Full solve simplex: ASM
1351:   test:
1352:     suffix: tri_q2q1_asm_lu
1353:     requires: hdf5 triangle
1354:     args: -run_type full -dm_refine 3 -bc_type dirichlet -interpolate 1 -petscspace_order 1 -ksp_type gmres -ksp_gmres_restart 100 -ksp_rtol 1.0e-9 -pc_type asm -pc_asm_type restrict -pc_asm_blocks 4 -sub_pc_type lu -snes_monitor_short -ksp_monitor_short -snes_converged_reason -ksp_converged_reason -snes_view -show_solution 0
1355:   test:
1356:     suffix: tri_q2q1_msm_lu
1357:     requires: hdf5 triangle
1358:     args: -run_type full -dm_refine 3 -bc_type dirichlet -interpolate 1 -petscspace_order 1 -ksp_type gmres -ksp_gmres_restart 100 -ksp_rtol 1.0e-9 -pc_type asm -pc_asm_type restrict -pc_asm_local_type multiplicative -pc_asm_blocks 4 -sub_pc_type lu -snes_monitor_short -ksp_monitor_short -snes_converged_reason -ksp_converged_reason -snes_view -show_solution 0
1359:   test:
1360:     suffix: tri_q2q1_asm_sor
1361:     requires: hdf5 triangle
1362:     args: -run_type full -dm_refine 3 -bc_type dirichlet -interpolate 1 -petscspace_order 1 -ksp_type gmres -ksp_gmres_restart 100 -ksp_rtol 1.0e-9 -pc_type asm -pc_asm_type restrict -pc_asm_blocks 4 -sub_pc_type sor -snes_monitor_short -ksp_monitor_short -snes_converged_reason -ksp_converged_reason -snes_view -show_solution 0
1363:   test:
1364:     suffix: tri_q2q1_msm_sor
1365:     requires: hdf5 triangle
1366:     args: -run_type full -dm_refine 3 -bc_type dirichlet -interpolate 1 -petscspace_order 1 -ksp_type gmres -ksp_gmres_restart 100 -ksp_rtol 1.0e-9 -pc_type asm -pc_asm_type restrict -pc_asm_local_type multiplicative -pc_asm_blocks 4 -sub_pc_type sor -snes_monitor_short -ksp_monitor_short -snes_converged_reason -ksp_converged_reason -snes_view -show_solution 0
1367:   # Full solve simplex: FAS
1368:   test:
1369:     suffix: fas_newton_0
1370:     requires: hdf5 triangle
1371:     args: -run_type full -variable_coefficient nonlinear -interpolate 1 -petscspace_order 1 -snes_type fas -snes_fas_levels 2 -pc_type svd -ksp_rtol 1.0e-10 -fas_coarse_pc_type svd -fas_coarse_ksp_rtol 1.0e-10 -fas_coarse_snes_monitor_short -snes_monitor_short -snes_linesearch_type basic -fas_coarse_snes_linesearch_type basic -snes_converged_reason -dm_refine_hierarchy 1 -snes_view -fas_levels_1_snes_type newtonls -fas_levels_1_pc_type svd -fas_levels_1_ksp_rtol 1.0e-10 -fas_levels_1_snes_monitor_short
1372:   test:
1373:     suffix: fas_newton_1
1374:     requires: hdf5 triangle
1375:     args: -run_type full -dm_refine_hierarchy 3 -interpolate 1 -petscspace_order 1 -snes_type fas -snes_fas_levels 3 -ksp_rtol 1.0e-10 -fas_coarse_pc_type lu -fas_coarse_snes_monitor_short -snes_monitor_short -snes_linesearch_type basic -fas_coarse_snes_linesearch_type basic -snes_converged_reason -snes_view -fas_levels_snes_type newtonls -fas_levels_snes_linesearch_type basic -fas_levels_ksp_rtol 1.0e-10 -fas_levels_snes_monitor_short
1376:   test:
1377:     suffix: fas_ngs_0
1378:     requires: hdf5 triangle
1379:     args: -run_type full -variable_coefficient nonlinear -interpolate 1 -petscspace_order 1 -snes_type fas -snes_fas_levels 2 -pc_type svd -ksp_rtol 1.0e-10 -fas_coarse_pc_type svd -fas_coarse_ksp_rtol 1.0e-10 -fas_coarse_snes_monitor_short -snes_monitor_short -snes_linesearch_type basic -fas_coarse_snes_linesearch_type basic -snes_converged_reason -dm_refine_hierarchy 1 -snes_view -fas_levels_1_snes_type ngs -fas_levels_1_snes_monitor_short
1380:   test:
1381:     suffix: fas_newton_coarse_0
1382:     requires: hdf5 pragmatic triangle
1383:     TODO: broken
1384:     args: -run_type full -dm_refine 2 -dm_plex_hash_location -variable_coefficient nonlinear -interpolate 1 -petscspace_order 1 -snes_type fas -snes_fas_levels 2 -pc_type svd -ksp_rtol 1.0e-10 -fas_coarse_pc_type svd -fas_coarse_ksp_rtol 1.0e-10 -fas_coarse_snes_monitor_short -snes_monitor_short -snes_linesearch_type basic -fas_coarse_snes_linesearch_type basic -snes_converged_reason -dm_coarsen_hierarchy 1 -snes_view -fas_levels_1_snes_type newtonls -fas_levels_1_pc_type svd -fas_levels_1_ksp_rtol 1.0e-10 -fas_levels_1_snes_monitor_short
1385:   test:
1386:     suffix: mg_newton_coarse_0
1387:     requires: hdf5 triangle pragmatic
1388:     args: -run_type full -dm_refine 3 -interpolate 1 -petscspace_order 1 -snes_monitor_short -ksp_monitor_true_residual -snes_linesearch_type basic -snes_converged_reason -dm_coarsen_hierarchy 3 -dm_plex_hash_location -snes_view -dm_view -ksp_type richardson -pc_type mg  -pc_mg_levels 4 -snes_atol 1.0e-8 -ksp_atol 1.0e-8 -snes_rtol 0.0 -ksp_rtol 0.0 -ksp_norm_type unpreconditioned -mg_levels_ksp_type gmres -mg_levels_pc_type ilu -mg_levels_ksp_max_it 10
1389:   test:
1390:     suffix: mg_newton_coarse_1
1391:     requires: hdf5 triangle pragmatic
1392:     args: -run_type full -dm_refine 5 -interpolate 1 -petscspace_order 1 -dm_coarsen_hierarchy 5 -dm_plex_hash_location -dm_plex_separate_marker -dm_plex_coarsen_bd_label marker -dm_plex_remesh_bd -ksp_type richardson -ksp_rtol 1.0e-12 -pc_type mg -pc_mg_levels 3 -mg_levels_ksp_max_it 2 -snes_monitor -ksp_monitor_true_residual -mg_levels_ksp_monitor_true_residual -dm_view -ksp_view
1393:   test:
1394:     suffix: mg_newton_coarse_2
1395:     requires: hdf5 triangle pragmatic
1396:     args: -run_type full -dm_refine 5 -interpolate 1 -petscspace_order 1 -dm_coarsen_hierarchy 5 -dm_plex_hash_location -dm_plex_separate_marker -dm_plex_remesh_bd -ksp_type richardson -ksp_rtol 1.0e-12 -pc_type mg -pc_mg_levels 3 -mg_levels_ksp_max_it 2 -snes_monitor -ksp_monitor_true_residual -mg_levels_ksp_monitor_true_residual -dm_view -ksp_view
1397:   # Full solve tensor
1398:   test:
1399:     suffix: tensor_plex_2d
1400:     requires: hdf5
1401:     args: -run_type test -refinement_limit 0.0 -simplex 0 -bc_type dirichlet -petscspace_order 1 -petscspace_poly_tensor -dm_refine_hierarchy 2 -cells 2,2
1402:   test:
1403:     suffix: tensor_p4est_2d
1404:     requires: hdf5 p4est
1405:     args: -run_type test -refinement_limit 0.0 -simplex 0 -bc_type dirichlet -petscspace_order 1 -petscspace_poly_tensor -dm_forest_initial_refinement 2 -dm_forest_minimum_refinement 0 -dm_plex_convert_type p4est -cells 2,2
1406:   test:
1407:     suffix: tensor_plex_3d
1408:     requires: hdf5
1409:     args: -run_type test -refinement_limit 0.0 -simplex 0 -bc_type dirichlet -petscspace_order 1 -petscspace_poly_tensor -dim 3 -dm_refine_hierarchy 1 -cells 2,2,2
1410:   test:
1411:     suffix: tensor_p4est_3d
1412:     requires: hdf5 p4est
1413:     args: -run_type test -refinement_limit 0.0 -simplex 0 -bc_type dirichlet -petscspace_order 1 -petscspace_poly_tensor -dm_forest_initial_refinement 1 -dm_forest_minimum_refinement 0 -dim 3 -dm_plex_convert_type p8est -cells 2,2,2
1414:   # Full solve tensor: AMR
1415:   test:
1416:     suffix: amr_0
1417:     requires: hdf5
1418:     nsize: 5
1419:     args: -run_type test -petscpartitioner_type simple -refinement_limit 0.0 -simplex 0 -bc_type dirichlet -petscspace_order 1 -petscspace_poly_tensor -dm_refine 1 -cells 2,2
1420:   test:
1421:     suffix: amr_1
1422:     requires: hdf5 p4est !complex
1423:     args: -run_type test -refinement_limit 0.0 -simplex 0 -bc_type dirichlet -petscspace_order 1 -petscspace_poly_tensor -dm_plex_convert_type p4est -dm_p4est_refine_pattern center -dm_forest_maximum_refinement 5 -dm_view vtk:amr.vtu:vtk_vtu -vec_view vtk:amr.vtu:vtk_vtu:append -cells 2,2
1424:   test:
1425:     suffix: p4est_test_q2_conformal_serial
1426:     requires: hdf5 p4est
1427:     args: -run_type test -interpolate 1 -petscspace_order 2 -simplex 0 -petscspace_poly_tensor -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2 -cells 2,2
1428:   test:
1429:     suffix: p4est_test_q2_conformal_parallel
1430:     requires: hdf5 p4est
1431:     nsize: 7
1432:     args: -run_type test -interpolate 1 -petscspace_order 2 -simplex 0 -petscspace_poly_tensor -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2 -petscpartitioner_type simple -cells 2,2
1433:   test:
1434:     suffix: p4est_test_q2_nonconformal_serial
1435:     requires: hdf5 p4est
1436:     filter: grep -v "CG or CGNE: variant"
1437:     args: -run_type test -interpolate 1 -petscspace_order 2 -simplex 0 -petscspace_poly_tensor -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2 -dm_forest_maximum_refinement 4 -dm_p4est_refine_pattern hash -cells 2,2
1438:   test:
1439:     suffix: p4est_test_q2_nonconformal_parallel
1440:     requires: hdf5 p4est
1441:     filter: grep -v "CG or CGNE: variant"
1442:     nsize: 7
1443:     args: -run_type test -interpolate 1 -petscspace_order 2 -simplex 0 -petscspace_poly_tensor -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2 -dm_forest_maximum_refinement 4 -dm_p4est_refine_pattern hash -petscpartitioner_type simple -cells 2,2
1444:   test:
1445:     suffix: p4est_exact_q2_conformal_serial
1446:     requires: hdf5 p4est
1447:     args: -run_type exact -interpolate 1 -petscspace_order 2 -snes_max_it 1 -snes_type fas -snes_fas_levels 3 -pc_type none -ksp_type preonly -fas_coarse_pc_type none -fas_coarse_ksp_type preonly -fas_coarse_snes_monitor_short -snes_monitor_short -snes_linesearch_type basic -fas_coarse_snes_linesearch_type basic -snes_converged_reason -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type none -fas_levels_ksp_type preonly -fas_levels_snes_monitor_short -simplex 0 -petscspace_poly_tensor -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2 -cells 2,2
1448:   test:
1449:     suffix: p4est_exact_q2_conformal_parallel
1450:     requires: hdf5 p4est
1451:     nsize: 7
1452:     args: -run_type exact -interpolate 1 -petscspace_order 2 -snes_max_it 1 -snes_type fas -snes_fas_levels 3 -pc_type none -ksp_type preonly -fas_coarse_pc_type none -fas_coarse_ksp_type preonly -fas_coarse_snes_monitor_short -snes_monitor_short -snes_linesearch_type basic -fas_coarse_snes_linesearch_type basic -snes_converged_reason -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type none -fas_levels_ksp_type preonly -fas_levels_snes_monitor_short -simplex 0 -petscspace_poly_tensor -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2 -cells 2,2
1453:   test:
1454:     suffix: p4est_exact_q2_nonconformal_serial
1455:     requires: hdf5 p4est
1456:     args: -run_type exact -interpolate 1 -petscspace_order 2 -snes_max_it 1 -snes_type fas -snes_fas_levels 3 -pc_type none -ksp_type preonly -fas_coarse_pc_type none -fas_coarse_ksp_type preonly -fas_coarse_snes_monitor_short -snes_monitor_short -snes_linesearch_type basic -fas_coarse_snes_linesearch_type basic -snes_converged_reason -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type none -fas_levels_ksp_type preonly -fas_levels_snes_monitor_short -simplex 0 -petscspace_poly_tensor -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2 -dm_forest_maximum_refinement 4 -dm_p4est_refine_pattern hash -cells 2,2
1457:   test:
1458:     suffix: p4est_exact_q2_nonconformal_parallel
1459:     requires: hdf5 p4est
1460:     nsize: 7
1461:     args: -run_type exact -interpolate 1 -petscspace_order 2 -snes_max_it 1 -snes_type fas -snes_fas_levels 3 -pc_type none -ksp_type preonly -fas_coarse_pc_type none -fas_coarse_ksp_type preonly -fas_coarse_snes_monitor_short -snes_monitor_short -snes_linesearch_type basic -fas_coarse_snes_linesearch_type basic -snes_converged_reason -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type none -fas_levels_ksp_type preonly -fas_levels_snes_monitor_short -simplex 0 -petscspace_poly_tensor -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2 -dm_forest_maximum_refinement 4 -dm_p4est_refine_pattern hash -petscpartitioner_type simple -cells 2,2
1462:   test:
1463:     suffix: p4est_full_q2_nonconformal_serial
1464:     requires: hdf5 p4est
1465:     filter: grep -v "CG or CGNE: variant"
1466:     args: -run_type full -interpolate 1 -petscspace_order 2 -snes_max_it 20 -snes_type fas -snes_fas_levels 3 -pc_type jacobi -ksp_type cg -fas_coarse_pc_type jacobi -fas_coarse_ksp_type cg -fas_coarse_snes_monitor_short -snes_monitor_short -snes_linesearch_type basic -fas_coarse_snes_linesearch_type basic -snes_converged_reason -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type jacobi -fas_levels_ksp_type cg -fas_levels_snes_monitor_short -simplex 0 -petscspace_poly_tensor -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2 -dm_forest_maximum_refinement 4 -dm_p4est_refine_pattern hash -cells 2,2
1467:   test:
1468:     suffix: p4est_full_q2_nonconformal_parallel
1469:     requires: p4est hdf5
1470:     filter: grep -v "CG or CGNE: variant"
1471:     nsize: 7
1472:     args: -run_type full -interpolate 1 -petscspace_order 2 -snes_max_it 20 -snes_type fas -snes_fas_levels 3 -pc_type jacobi -ksp_type cg -fas_coarse_pc_type jacobi -fas_coarse_ksp_type cg -fas_coarse_snes_monitor_short -snes_monitor_short -snes_linesearch_type basic -fas_coarse_snes_linesearch_type basic -snes_converged_reason -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type jacobi -fas_levels_ksp_type cg -fas_levels_snes_monitor_short -simplex 0 -petscspace_poly_tensor -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2 -dm_forest_maximum_refinement 4 -dm_p4est_refine_pattern hash -petscpartitioner_type simple -cells 2,2
1473:   test:
1474:     suffix: p4est_full_q2_nonconformal_parallel_bddcfas
1475:     requires: hdf5 p4est
1476:     filter: grep -v "CG or CGNE: variant" | sed -e "s/BDDC: Graph max count: 9223372036854775807/BDDC: Graph max count: 2147483647/g"
1477:     nsize: 7
1478:     args: -run_type full -interpolate 1 -petscspace_order 2 -snes_max_it 20 -snes_type fas -snes_fas_levels 3 -dm_mat_type is -pc_type bddc -ksp_type cg -fas_coarse_pc_type bddc -fas_coarse_ksp_type cg -fas_coarse_snes_monitor_short -snes_monitor_short -snes_linesearch_type basic -fas_coarse_snes_linesearch_type basic -snes_converged_reason -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type bddc -fas_levels_ksp_type cg -fas_levels_snes_monitor_short -simplex 0 -petscspace_poly_tensor -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2 -dm_forest_maximum_refinement 4 -dm_p4est_refine_pattern hash -petscpartitioner_type simple -cells 2,2
1479:   test:
1480:     suffix: p4est_full_q2_nonconformal_parallel_bddc
1481:     requires: hdf5 p4est
1482:     filter: grep -v "CG or CGNE: variant" | sed -e "s/BDDC: Graph max count: 9223372036854775807/BDDC: Graph max count: 2147483647/g"
1483:     nsize: 7
1484:     args: -run_type full -interpolate 1 -petscspace_order 2 -snes_max_it 20 -snes_type newtonls -dm_mat_type is -pc_type bddc -ksp_type cg -snes_monitor_short -snes_linesearch_type basic -snes_converged_reason -snes_view -simplex 0 -petscspace_poly_tensor -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2 -dm_forest_maximum_refinement 4 -dm_p4est_refine_pattern hash -petscpartitioner_type simple -cells 2,2
1485:   test:
1486:     suffix: p4est_fas_q2_conformal_serial
1487:     requires: hdf5 p4est broken
1488:     args: -run_type full -variable_coefficient nonlinear -interpolate 1 -petscspace_order 2 -snes_max_it 20 -snes_type fas -snes_fas_levels 3 -pc_type jacobi -ksp_type gmres -fas_coarse_pc_type svd -fas_coarse_ksp_type gmres -fas_coarse_snes_monitor_short -snes_monitor_short -snes_linesearch_type basic -fas_coarse_snes_linesearch_type basic -snes_converged_reason -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type svd -fas_levels_ksp_type gmres -fas_levels_snes_monitor_short -simplex 0 -petscspace_poly_tensor -dm_refine_hierarchy 3 -cells 2,2
1489:   test:
1490:     suffix: p4est_fas_q2_nonconformal_serial
1491:     requires: hdf5 p4est broken
1492:     args: -run_type full -variable_coefficient nonlinear -interpolate 1 -petscspace_order 2 -snes_max_it 20 -snes_type fas -snes_fas_levels 3 -pc_type jacobi -ksp_type gmres -fas_coarse_pc_type jacobi -fas_coarse_ksp_type gmres -fas_coarse_ksp_monitor_true_residual -fas_coarse_snes_monitor_short -snes_monitor_short -snes_linesearch_type basic -fas_coarse_snes_linesearch_type basic -snes_converged_reason -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type jacobi -fas_levels_ksp_type gmres -fas_levels_snes_monitor_short -simplex 0 -petscspace_poly_tensor -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2 -dm_forest_maximum_refinement 4 -dm_p4est_refine_pattern hash -cells 2,2
1493:   test:
1494:     suffix: fas_newton_0_p4est
1495:     requires: hdf5 p4est
1496:     args: -run_type full -variable_coefficient nonlinear -interpolate 1 -petscspace_order 1 -snes_type fas -snes_fas_levels 2 -pc_type svd -ksp_rtol 1.0e-10 -fas_coarse_pc_type svd -fas_coarse_ksp_rtol 1.0e-10 -fas_coarse_snes_monitor_short -snes_monitor_short -snes_linesearch_type basic -fas_coarse_snes_linesearch_type basic -snes_converged_reason -snes_view -fas_levels_1_snes_type newtonls -fas_levels_1_pc_type svd -fas_levels_1_ksp_rtol 1.0e-10 -fas_levels_1_snes_monitor_short -simplex 0 -petscspace_poly_tensor -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2 -dm_forest_maximum_refinement 4 -dm_p4est_refine_pattern hash -cells 2,2

1498: TEST*/