xref: /petsc/src/snes/tutorials/ex12.c (revision 8fb5bd83c3955fefcf33a54e3bb66920a9fa884b)
1c4762a1bSJed Brown static char help[] = "Poisson Problem in 2d and 3d with simplicial finite elements.\n\
2c4762a1bSJed Brown We solve the Poisson problem in a rectangular\n\
3c4762a1bSJed Brown domain, using a parallel unstructured mesh (DMPLEX) to discretize it.\n\
4c4762a1bSJed Brown This example supports discretized auxiliary fields (conductivity) as well as\n\
5c4762a1bSJed Brown multilevel nonlinear solvers.\n\n\n";
6c4762a1bSJed Brown 
7c4762a1bSJed Brown /*
8c4762a1bSJed Brown A visualization of the adaptation can be accomplished using:
9c4762a1bSJed Brown 
10c4762a1bSJed Brown   -dm_adapt_view hdf5:$PWD/adapt.h5 -sol_adapt_view hdf5:$PWD/adapt.h5::append -dm_adapt_pre_view hdf5:$PWD/orig.h5 -sol_adapt_pre_view hdf5:$PWD/orig.h5::append
11c4762a1bSJed Brown 
12c4762a1bSJed Brown Information on refinement:
13c4762a1bSJed Brown 
14c20d7725SJed Brown    -info :~sys,vec,is,mat,ksp,snes,ts
15c4762a1bSJed Brown */
16c4762a1bSJed Brown 
17c4762a1bSJed Brown #include <petscdmplex.h>
18c4762a1bSJed Brown #include <petscdmadaptor.h>
19c4762a1bSJed Brown #include <petscsnes.h>
20c4762a1bSJed Brown #include <petscds.h>
21c4762a1bSJed Brown #include <petscviewerhdf5.h>
22c4762a1bSJed Brown 
23c4762a1bSJed Brown typedef enum {NEUMANN, DIRICHLET, NONE} BCType;
24c4762a1bSJed Brown typedef enum {RUN_FULL, RUN_EXACT, RUN_TEST, RUN_PERF} RunType;
258d1b37daSJoe Wallwork typedef enum {COEFF_NONE, COEFF_ANALYTIC, COEFF_FIELD, COEFF_NONLINEAR, COEFF_BALL, COEFF_CROSS, COEFF_CHECKERBOARD_0, COEFF_CHECKERBOARD_1} CoeffType;
26c4762a1bSJed Brown 
27c4762a1bSJed Brown typedef struct {
28c4762a1bSJed Brown   RunType        runType;           /* Whether to run tests, or solve the full problem */
29c4762a1bSJed Brown   PetscBool      jacobianMF;        /* Whether to calculate the Jacobian action on the fly */
30c4762a1bSJed Brown   PetscBool      showInitial, showSolution, restart, quiet, nonzInit;
31c4762a1bSJed Brown   /* Problem definition */
32c4762a1bSJed Brown   BCType         bcType;
33c4762a1bSJed Brown   CoeffType      variableCoefficient;
34c4762a1bSJed Brown   PetscErrorCode (**exactFuncs)(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx);
35c4762a1bSJed Brown   PetscBool      fieldBC;
36c4762a1bSJed Brown   void           (**exactFields)(PetscInt, PetscInt, PetscInt,
37c4762a1bSJed Brown                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
38c4762a1bSJed Brown                                  const PetscInt[], const PetscInt[], const PetscScalar[], const PetscScalar[], const PetscScalar[],
39c4762a1bSJed Brown                                  PetscReal, const PetscReal[], PetscInt, const PetscScalar[], PetscScalar[]);
40c4762a1bSJed Brown   PetscBool      bdIntegral;        /* Compute the integral of the solution on the boundary */
41d6837840SMatthew G. Knepley   /* Reproducing tests from SISC 40(3), pp. A1473-A1493, 2018 */
42d6837840SMatthew G. Knepley   PetscInt       div;               /* Number of divisions */
43d6837840SMatthew G. Knepley   PetscInt       k;                 /* Parameter for checkerboard coefficient */
44d6837840SMatthew G. Knepley   PetscInt      *kgrid;             /* Random parameter grid */
4530602db0SMatthew G. Knepley   PetscBool      rand;              /* Make random assignments */
46c4762a1bSJed Brown   /* Solver */
47c4762a1bSJed Brown   PC             pcmg;              /* This is needed for error monitoring */
48c4762a1bSJed Brown   PetscBool      checkksp;          /* Whether to check the KSPSolve for runType == RUN_TEST */
49c4762a1bSJed Brown } AppCtx;
50c4762a1bSJed Brown 
51c4762a1bSJed Brown static PetscErrorCode zero(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
52c4762a1bSJed Brown {
53c4762a1bSJed Brown   u[0] = 0.0;
54c4762a1bSJed Brown   return 0;
55c4762a1bSJed Brown }
56c4762a1bSJed Brown 
57c4762a1bSJed Brown static PetscErrorCode ecks(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
58c4762a1bSJed Brown {
59c4762a1bSJed Brown   u[0] = x[0];
60c4762a1bSJed Brown   return 0;
61c4762a1bSJed Brown }
62c4762a1bSJed Brown 
63c4762a1bSJed Brown /*
64c4762a1bSJed Brown   In 2D for Dirichlet conditions, we use exact solution:
65c4762a1bSJed Brown 
66c4762a1bSJed Brown     u = x^2 + y^2
67c4762a1bSJed Brown     f = 4
68c4762a1bSJed Brown 
69c4762a1bSJed Brown   so that
70c4762a1bSJed Brown 
71c4762a1bSJed Brown     -\Delta u + f = -4 + 4 = 0
72c4762a1bSJed Brown 
73c4762a1bSJed Brown   For Neumann conditions, we have
74c4762a1bSJed Brown 
75c4762a1bSJed Brown     -\nabla u \cdot -\hat y |_{y=0} =  (2y)|_{y=0} =  0 (bottom)
76c4762a1bSJed Brown     -\nabla u \cdot  \hat y |_{y=1} = -(2y)|_{y=1} = -2 (top)
77c4762a1bSJed Brown     -\nabla u \cdot -\hat x |_{x=0} =  (2x)|_{x=0} =  0 (left)
78c4762a1bSJed Brown     -\nabla u \cdot  \hat x |_{x=1} = -(2x)|_{x=1} = -2 (right)
79c4762a1bSJed Brown 
80c4762a1bSJed Brown   Which we can express as
81c4762a1bSJed Brown 
82c4762a1bSJed Brown     \nabla u \cdot  \hat n|_\Gamma = {2 x, 2 y} \cdot \hat n = 2 (x + y)
83c4762a1bSJed Brown 
84c4762a1bSJed Brown   The boundary integral of this solution is (assuming we are not orienting the edges)
85c4762a1bSJed Brown 
86c4762a1bSJed Brown     \int^1_0 x^2 dx + \int^1_0 (1 + y^2) dy + \int^1_0 (x^2 + 1) dx + \int^1_0 y^2 dy = 1/3 + 4/3 + 4/3 + 1/3 = 3 1/3
87c4762a1bSJed Brown */
88c4762a1bSJed Brown static PetscErrorCode quadratic_u_2d(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
89c4762a1bSJed Brown {
90c4762a1bSJed Brown   *u = x[0]*x[0] + x[1]*x[1];
91c4762a1bSJed Brown   return 0;
92c4762a1bSJed Brown }
93c4762a1bSJed Brown 
94c4762a1bSJed Brown static void quadratic_u_field_2d(PetscInt dim, PetscInt Nf, PetscInt NfAux,
95c4762a1bSJed Brown                                  const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
96c4762a1bSJed Brown                                  const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
97c4762a1bSJed Brown                                  PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uexact[])
98c4762a1bSJed Brown {
99c4762a1bSJed Brown   uexact[0] = a[0];
100c4762a1bSJed Brown }
101c4762a1bSJed Brown 
1028d1b37daSJoe Wallwork static PetscErrorCode ball_u_2d(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
103c4762a1bSJed Brown {
104c4762a1bSJed Brown   const PetscReal alpha   = 500.;
105c4762a1bSJed Brown   const PetscReal radius2 = PetscSqr(0.15);
106c4762a1bSJed Brown   const PetscReal r2      = PetscSqr(x[0] - 0.5) + PetscSqr(x[1] - 0.5);
107c4762a1bSJed Brown   const PetscReal xi      = alpha*(radius2 - r2);
108c4762a1bSJed Brown 
109c4762a1bSJed Brown   *u = PetscTanhScalar(xi) + 1.0;
110c4762a1bSJed Brown   return 0;
111c4762a1bSJed Brown }
112c4762a1bSJed Brown 
113c4762a1bSJed Brown static PetscErrorCode cross_u_2d(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
114c4762a1bSJed Brown {
115c4762a1bSJed Brown   const PetscReal alpha = 50*4;
116c4762a1bSJed Brown   const PetscReal xy    = (x[0]-0.5)*(x[1]-0.5);
117c4762a1bSJed Brown 
118c4762a1bSJed Brown   *u = PetscSinReal(alpha*xy) * (alpha*PetscAbsReal(xy) < 2*PETSC_PI ? 1 : 0.01);
119c4762a1bSJed Brown   return 0;
120c4762a1bSJed Brown }
121c4762a1bSJed Brown 
122c4762a1bSJed Brown static void f0_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
123c4762a1bSJed Brown                  const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
124c4762a1bSJed Brown                  const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
125c4762a1bSJed Brown                  PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
126c4762a1bSJed Brown {
127c4762a1bSJed Brown   f0[0] = 4.0;
128c4762a1bSJed Brown }
129c4762a1bSJed Brown 
1308d1b37daSJoe Wallwork static void f0_ball_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
131c4762a1bSJed Brown                       const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
132c4762a1bSJed Brown                       const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
133c4762a1bSJed Brown                       PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
134c4762a1bSJed Brown {
1358d1b37daSJoe Wallwork   PetscInt        d;
1368d1b37daSJoe Wallwork   const PetscReal alpha = 500., radius2 = PetscSqr(0.15);
1378d1b37daSJoe Wallwork   PetscReal       r2, xi;
138c4762a1bSJed Brown 
1398d1b37daSJoe Wallwork   for (d = 0, r2 = 0.0; d < dim; ++d) r2 += PetscSqr(x[d] - 0.5);
1408d1b37daSJoe Wallwork   xi = alpha*(radius2 - r2);
1418d1b37daSJoe Wallwork   f0[0] = (-2.0*dim*alpha - 8.0*PetscSqr(alpha)*r2*PetscTanhReal(xi)) * PetscSqr(1.0/PetscCoshReal(xi));
142c4762a1bSJed Brown }
143c4762a1bSJed Brown 
1448d1b37daSJoe Wallwork static void f0_cross_u_2d(PetscInt dim, PetscInt Nf, PetscInt NfAux,
145c4762a1bSJed Brown                           const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
146c4762a1bSJed Brown                           const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
147c4762a1bSJed Brown                           PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
148c4762a1bSJed Brown {
149c4762a1bSJed Brown   const PetscReal alpha = 50*4;
150c4762a1bSJed Brown   const PetscReal xy    = (x[0]-0.5)*(x[1]-0.5);
151c4762a1bSJed Brown 
152c4762a1bSJed Brown   f0[0] = PetscSinReal(alpha*xy) * (alpha*PetscAbsReal(xy) < 2*PETSC_PI ? 1 : 0.01);
153c4762a1bSJed Brown }
154c4762a1bSJed Brown 
155d6837840SMatthew G. Knepley static void f0_checkerboard_0_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
156d6837840SMatthew G. Knepley                                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
157d6837840SMatthew G. Knepley                                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
158d6837840SMatthew G. Knepley                                 PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
159d6837840SMatthew G. Knepley {
160d6837840SMatthew G. Knepley   f0[0] = -20.0*PetscExpReal(-(PetscSqr(x[0] - 0.5) + PetscSqr(x[1] - 0.5)));
161d6837840SMatthew G. Knepley }
162d6837840SMatthew G. Knepley 
163c4762a1bSJed Brown static void f0_bd_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
164c4762a1bSJed Brown                     const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
165c4762a1bSJed Brown                     const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
166c4762a1bSJed Brown                     PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
167c4762a1bSJed Brown {
168c4762a1bSJed Brown   PetscInt d;
169c4762a1bSJed Brown   for (d = 0, f0[0] = 0.0; d < dim; ++d) f0[0] += -n[d]*2.0*x[d];
170c4762a1bSJed Brown }
171c4762a1bSJed Brown 
172c4762a1bSJed Brown /* gradU[comp*dim+d] = {u_x, u_y} or {u_x, u_y, u_z} */
173c4762a1bSJed Brown static void f1_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
174c4762a1bSJed Brown                  const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
175c4762a1bSJed Brown                  const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
176c4762a1bSJed Brown                  PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])
177c4762a1bSJed Brown {
178c4762a1bSJed Brown   PetscInt d;
179c4762a1bSJed Brown   for (d = 0; d < dim; ++d) f1[d] = u_x[d];
180c4762a1bSJed Brown }
181c4762a1bSJed Brown 
182c4762a1bSJed Brown /* < \nabla v, \nabla u + {\nabla u}^T >
183c4762a1bSJed Brown    This just gives \nabla u, give the perdiagonal for the transpose */
184c4762a1bSJed Brown static void g3_uu(PetscInt dim, PetscInt Nf, PetscInt NfAux,
185c4762a1bSJed Brown                   const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
186c4762a1bSJed Brown                   const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
187c4762a1bSJed Brown                   PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])
188c4762a1bSJed Brown {
189c4762a1bSJed Brown   PetscInt d;
190c4762a1bSJed Brown   for (d = 0; d < dim; ++d) g3[d*dim+d] = 1.0;
191c4762a1bSJed Brown }
192c4762a1bSJed Brown 
193c4762a1bSJed Brown /*
194c4762a1bSJed Brown   In 2D for x periodicity and y Dirichlet conditions, we use exact solution:
195c4762a1bSJed Brown 
196c4762a1bSJed Brown     u = sin(2 pi x)
197c4762a1bSJed Brown     f = -4 pi^2 sin(2 pi x)
198c4762a1bSJed Brown 
199c4762a1bSJed Brown   so that
200c4762a1bSJed Brown 
201c4762a1bSJed Brown     -\Delta u + f = 4 pi^2 sin(2 pi x) - 4 pi^2 sin(2 pi x) = 0
202c4762a1bSJed Brown */
203c4762a1bSJed Brown static PetscErrorCode xtrig_u_2d(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
204c4762a1bSJed Brown {
205c4762a1bSJed Brown   *u = PetscSinReal(2.0*PETSC_PI*x[0]);
206c4762a1bSJed Brown   return 0;
207c4762a1bSJed Brown }
208c4762a1bSJed Brown 
209c4762a1bSJed Brown static void f0_xtrig_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
210c4762a1bSJed Brown                        const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
211c4762a1bSJed Brown                        const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
212c4762a1bSJed Brown                        PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
213c4762a1bSJed Brown {
214c4762a1bSJed Brown   f0[0] = -4.0*PetscSqr(PETSC_PI)*PetscSinReal(2.0*PETSC_PI*x[0]);
215c4762a1bSJed Brown }
216c4762a1bSJed Brown 
217c4762a1bSJed Brown /*
218c4762a1bSJed Brown   In 2D for x-y periodicity, we use exact solution:
219c4762a1bSJed Brown 
220c4762a1bSJed Brown     u = sin(2 pi x) sin(2 pi y)
221c4762a1bSJed Brown     f = -8 pi^2 sin(2 pi x)
222c4762a1bSJed Brown 
223c4762a1bSJed Brown   so that
224c4762a1bSJed Brown 
225c4762a1bSJed Brown     -\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
226c4762a1bSJed Brown */
227c4762a1bSJed Brown static PetscErrorCode xytrig_u_2d(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
228c4762a1bSJed Brown {
229c4762a1bSJed Brown   *u = PetscSinReal(2.0*PETSC_PI*x[0])*PetscSinReal(2.0*PETSC_PI*x[1]);
230c4762a1bSJed Brown   return 0;
231c4762a1bSJed Brown }
232c4762a1bSJed Brown 
233c4762a1bSJed Brown static void f0_xytrig_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
234c4762a1bSJed Brown                         const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
235c4762a1bSJed Brown                         const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
236c4762a1bSJed Brown                         PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
237c4762a1bSJed Brown {
238c4762a1bSJed Brown   f0[0] = -8.0*PetscSqr(PETSC_PI)*PetscSinReal(2.0*PETSC_PI*x[0]);
239c4762a1bSJed Brown }
240c4762a1bSJed Brown 
241c4762a1bSJed Brown /*
242c4762a1bSJed Brown   In 2D for Dirichlet conditions with a variable coefficient, we use exact solution:
243c4762a1bSJed Brown 
244c4762a1bSJed Brown     u  = x^2 + y^2
245c4762a1bSJed Brown     f  = 6 (x + y)
246c4762a1bSJed Brown     nu = (x + y)
247c4762a1bSJed Brown 
248c4762a1bSJed Brown   so that
249c4762a1bSJed Brown 
250c4762a1bSJed Brown     -\div \nu \grad u + f = -6 (x + y) + 6 (x + y) = 0
251c4762a1bSJed Brown */
252c4762a1bSJed Brown static PetscErrorCode nu_2d(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
253c4762a1bSJed Brown {
254c4762a1bSJed Brown   *u = x[0] + x[1];
255c4762a1bSJed Brown   return 0;
256c4762a1bSJed Brown }
257c4762a1bSJed Brown 
258d6837840SMatthew G. Knepley static PetscErrorCode checkerboardCoeff(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
259d6837840SMatthew G. Knepley {
260d6837840SMatthew G. Knepley   AppCtx  *user = (AppCtx *) ctx;
261d6837840SMatthew G. Knepley   PetscInt div  = user->div;
262d6837840SMatthew G. Knepley   PetscInt k    = user->k;
263d6837840SMatthew G. Knepley   PetscInt mask = 0, ind = 0, d;
264d6837840SMatthew G. Knepley 
265d6837840SMatthew G. Knepley   PetscFunctionBeginUser;
266d6837840SMatthew G. Knepley   for (d = 0; d < dim; ++d) mask = (mask + (PetscInt) (x[d]*div)) % 2;
267d6837840SMatthew G. Knepley   if (user->kgrid) {
268d6837840SMatthew G. Knepley     for (d = 0; d < dim; ++d) {
269d6837840SMatthew G. Knepley       if (d > 0) ind *= dim;
270d6837840SMatthew G. Knepley       ind += (PetscInt) (x[d]*div);
271d6837840SMatthew G. Knepley     }
272d6837840SMatthew G. Knepley     k = user->kgrid[ind];
273d6837840SMatthew G. Knepley   }
274d6837840SMatthew G. Knepley   u[0] = mask ? 1.0 : PetscPowRealInt(10.0, -k);
275d6837840SMatthew G. Knepley   PetscFunctionReturn(0);
276d6837840SMatthew G. Knepley }
277d6837840SMatthew G. Knepley 
278c4762a1bSJed Brown void f0_analytic_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
279c4762a1bSJed Brown                    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
280c4762a1bSJed Brown                    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
281c4762a1bSJed Brown                    PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
282c4762a1bSJed Brown {
283c4762a1bSJed Brown   f0[0] = 6.0*(x[0] + x[1]);
284c4762a1bSJed Brown }
285c4762a1bSJed Brown 
286c4762a1bSJed Brown /* gradU[comp*dim+d] = {u_x, u_y} or {u_x, u_y, u_z} */
287c4762a1bSJed Brown void f1_analytic_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
288c4762a1bSJed Brown                    const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
289c4762a1bSJed Brown                    const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
290c4762a1bSJed Brown                    PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])
291c4762a1bSJed Brown {
292c4762a1bSJed Brown   PetscInt d;
293c4762a1bSJed Brown   for (d = 0; d < dim; ++d) f1[d] = (x[0] + x[1])*u_x[d];
294c4762a1bSJed Brown }
295c4762a1bSJed Brown 
296c4762a1bSJed Brown void f1_field_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
297c4762a1bSJed Brown                 const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
298c4762a1bSJed Brown                 const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
299c4762a1bSJed Brown                 PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])
300c4762a1bSJed Brown {
301c4762a1bSJed Brown   PetscInt d;
302c4762a1bSJed Brown   for (d = 0; d < dim; ++d) f1[d] = a[0]*u_x[d];
303c4762a1bSJed Brown }
304c4762a1bSJed Brown 
305c4762a1bSJed Brown /* < \nabla v, \nabla u + {\nabla u}^T >
306c4762a1bSJed Brown    This just gives \nabla u, give the perdiagonal for the transpose */
307c4762a1bSJed Brown void g3_analytic_uu(PetscInt dim, PetscInt Nf, PetscInt NfAux,
308c4762a1bSJed Brown                     const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
309c4762a1bSJed Brown                     const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
310c4762a1bSJed Brown                     PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])
311c4762a1bSJed Brown {
312c4762a1bSJed Brown   PetscInt d;
313c4762a1bSJed Brown   for (d = 0; d < dim; ++d) g3[d*dim+d] = x[0] + x[1];
314c4762a1bSJed Brown }
315c4762a1bSJed Brown 
316c4762a1bSJed Brown void g3_field_uu(PetscInt dim, PetscInt Nf, PetscInt NfAux,
317c4762a1bSJed Brown                  const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
318c4762a1bSJed Brown                  const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
319c4762a1bSJed Brown                  PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])
320c4762a1bSJed Brown {
321c4762a1bSJed Brown   PetscInt d;
322c4762a1bSJed Brown   for (d = 0; d < dim; ++d) g3[d*dim+d] = a[0];
323c4762a1bSJed Brown }
324c4762a1bSJed Brown 
325c4762a1bSJed Brown /*
326c4762a1bSJed Brown   In 2D for Dirichlet conditions with a nonlinear coefficient (p-Laplacian with p = 4), we use exact solution:
327c4762a1bSJed Brown 
328c4762a1bSJed Brown     u  = x^2 + y^2
329c4762a1bSJed Brown     f  = 16 (x^2 + y^2)
330c4762a1bSJed Brown     nu = 1/2 |grad u|^2
331c4762a1bSJed Brown 
332c4762a1bSJed Brown   so that
333c4762a1bSJed Brown 
334c4762a1bSJed Brown     -\div \nu \grad u + f = -16 (x^2 + y^2) + 16 (x^2 + y^2) = 0
335c4762a1bSJed Brown */
336c4762a1bSJed Brown void f0_analytic_nonlinear_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
337c4762a1bSJed Brown                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
338c4762a1bSJed Brown                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
339c4762a1bSJed Brown                              PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
340c4762a1bSJed Brown {
341c4762a1bSJed Brown   f0[0] = 16.0*(x[0]*x[0] + x[1]*x[1]);
342c4762a1bSJed Brown }
343c4762a1bSJed Brown 
344c4762a1bSJed Brown /* gradU[comp*dim+d] = {u_x, u_y} or {u_x, u_y, u_z} */
345c4762a1bSJed Brown void f1_analytic_nonlinear_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
346c4762a1bSJed Brown                              const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
347c4762a1bSJed Brown                              const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
348c4762a1bSJed Brown                              PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])
349c4762a1bSJed Brown {
350c4762a1bSJed Brown   PetscScalar nu = 0.0;
351c4762a1bSJed Brown   PetscInt    d;
352c4762a1bSJed Brown   for (d = 0; d < dim; ++d) nu += u_x[d]*u_x[d];
353c4762a1bSJed Brown   for (d = 0; d < dim; ++d) f1[d] = 0.5*nu*u_x[d];
354c4762a1bSJed Brown }
355c4762a1bSJed Brown 
356c4762a1bSJed Brown /*
357c4762a1bSJed Brown   grad (u + eps w) - grad u = eps grad w
358c4762a1bSJed Brown 
359c4762a1bSJed Brown   1/2 |grad (u + eps w)|^2 grad (u + eps w) - 1/2 |grad u|^2 grad u
360c4762a1bSJed Brown = 1/2 (|grad u|^2 + 2 eps <grad u,grad w>) (grad u + eps grad w) - 1/2 |grad u|^2 grad u
361c4762a1bSJed Brown = 1/2 (eps |grad u|^2 grad w + 2 eps <grad u,grad w> grad u)
362c4762a1bSJed Brown = eps (1/2 |grad u|^2 grad w + grad u <grad u,grad w>)
363c4762a1bSJed Brown */
364c4762a1bSJed Brown void g3_analytic_nonlinear_uu(PetscInt dim, PetscInt Nf, PetscInt NfAux,
365c4762a1bSJed Brown                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
366c4762a1bSJed Brown                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
367c4762a1bSJed Brown                               PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g3[])
368c4762a1bSJed Brown {
369c4762a1bSJed Brown   PetscScalar nu = 0.0;
370c4762a1bSJed Brown   PetscInt    d, e;
371c4762a1bSJed Brown   for (d = 0; d < dim; ++d) nu += u_x[d]*u_x[d];
372c4762a1bSJed Brown   for (d = 0; d < dim; ++d) {
373c4762a1bSJed Brown     g3[d*dim+d] = 0.5*nu;
374c4762a1bSJed Brown     for (e = 0; e < dim; ++e) {
375c4762a1bSJed Brown       g3[d*dim+e] += u_x[d]*u_x[e];
376c4762a1bSJed Brown     }
377c4762a1bSJed Brown   }
378c4762a1bSJed Brown }
379c4762a1bSJed Brown 
380c4762a1bSJed Brown /*
381c4762a1bSJed Brown   In 3D for Dirichlet conditions we use exact solution:
382c4762a1bSJed Brown 
383c4762a1bSJed Brown     u = 2/3 (x^2 + y^2 + z^2)
384c4762a1bSJed Brown     f = 4
385c4762a1bSJed Brown 
386c4762a1bSJed Brown   so that
387c4762a1bSJed Brown 
388c4762a1bSJed Brown     -\Delta u + f = -2/3 * 6 + 4 = 0
389c4762a1bSJed Brown 
390c4762a1bSJed Brown   For Neumann conditions, we have
391c4762a1bSJed Brown 
392c4762a1bSJed Brown     -\nabla u \cdot -\hat z |_{z=0} =  (2z)|_{z=0} =  0 (bottom)
393c4762a1bSJed Brown     -\nabla u \cdot  \hat z |_{z=1} = -(2z)|_{z=1} = -2 (top)
394c4762a1bSJed Brown     -\nabla u \cdot -\hat y |_{y=0} =  (2y)|_{y=0} =  0 (front)
395c4762a1bSJed Brown     -\nabla u \cdot  \hat y |_{y=1} = -(2y)|_{y=1} = -2 (back)
396c4762a1bSJed Brown     -\nabla u \cdot -\hat x |_{x=0} =  (2x)|_{x=0} =  0 (left)
397c4762a1bSJed Brown     -\nabla u \cdot  \hat x |_{x=1} = -(2x)|_{x=1} = -2 (right)
398c4762a1bSJed Brown 
399c4762a1bSJed Brown   Which we can express as
400c4762a1bSJed Brown 
401c4762a1bSJed Brown     \nabla u \cdot  \hat n|_\Gamma = {2 x, 2 y, 2z} \cdot \hat n = 2 (x + y + z)
402c4762a1bSJed Brown */
403c4762a1bSJed Brown static PetscErrorCode quadratic_u_3d(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
404c4762a1bSJed Brown {
405c4762a1bSJed Brown   *u = 2.0*(x[0]*x[0] + x[1]*x[1] + x[2]*x[2])/3.0;
406c4762a1bSJed Brown   return 0;
407c4762a1bSJed Brown }
408c4762a1bSJed Brown 
4098d1b37daSJoe Wallwork static PetscErrorCode ball_u_3d(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
4108d1b37daSJoe Wallwork {
4118d1b37daSJoe Wallwork   const PetscReal alpha   = 500.;
4128d1b37daSJoe Wallwork   const PetscReal radius2 = PetscSqr(0.15);
4138d1b37daSJoe Wallwork   const PetscReal r2      = PetscSqr(x[0] - 0.5) + PetscSqr(x[1] - 0.5) + PetscSqr(x[2] - 0.5);
4148d1b37daSJoe Wallwork   const PetscReal xi      = alpha*(radius2 - r2);
4158d1b37daSJoe Wallwork 
4168d1b37daSJoe Wallwork   *u = PetscTanhScalar(xi) + 1.0;
4178d1b37daSJoe Wallwork   return 0;
4188d1b37daSJoe Wallwork }
4198d1b37daSJoe Wallwork 
420c4762a1bSJed Brown static void quadratic_u_field_3d(PetscInt dim, PetscInt Nf, PetscInt NfAux,
421c4762a1bSJed Brown                                  const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
422c4762a1bSJed Brown                                  const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
423c4762a1bSJed Brown                                  PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar uexact[])
424c4762a1bSJed Brown {
425c4762a1bSJed Brown   uexact[0] = a[0];
426c4762a1bSJed Brown }
427c4762a1bSJed Brown 
4288d1b37daSJoe Wallwork static PetscErrorCode cross_u_3d(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
4298d1b37daSJoe Wallwork {
4308d1b37daSJoe Wallwork   const PetscReal alpha = 50*4;
4318d1b37daSJoe Wallwork   const PetscReal xyz   = (x[0]-0.5)*(x[1]-0.5)*(x[2]-0.5);
4328d1b37daSJoe Wallwork 
4338d1b37daSJoe Wallwork   *u = PetscSinReal(alpha*xyz) * (alpha*PetscAbsReal(xyz) < 2*PETSC_PI ? (alpha*PetscAbsReal(xyz) > -2*PETSC_PI ? 1.0 : 0.01) : 0.01);
4348d1b37daSJoe Wallwork   return 0;
4358d1b37daSJoe Wallwork }
4368d1b37daSJoe Wallwork 
4378d1b37daSJoe Wallwork static void f0_cross_u_3d(PetscInt dim, PetscInt Nf, PetscInt NfAux,
4388d1b37daSJoe Wallwork                           const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
4398d1b37daSJoe Wallwork                           const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
4408d1b37daSJoe Wallwork                           PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
4418d1b37daSJoe Wallwork {
4428d1b37daSJoe Wallwork   const PetscReal alpha = 50*4;
4438d1b37daSJoe Wallwork   const PetscReal xyz   = (x[0]-0.5)*(x[1]-0.5)*(x[2]-0.5);
4448d1b37daSJoe Wallwork 
4458d1b37daSJoe Wallwork   f0[0] = PetscSinReal(alpha*xyz) * (alpha*PetscAbsReal(xyz) < 2*PETSC_PI ? (alpha*PetscAbsReal(xyz) > -2*PETSC_PI ? 1.0 : 0.01) : 0.01);
4468d1b37daSJoe Wallwork }
4478d1b37daSJoe Wallwork 
448c4762a1bSJed Brown static void bd_integral_2d(PetscInt dim, PetscInt Nf, PetscInt NfAux,
449c4762a1bSJed Brown                            const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
450c4762a1bSJed Brown                            const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
451c4762a1bSJed Brown                            PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar *uint)
452c4762a1bSJed Brown {
453c4762a1bSJed Brown   uint[0] = u[0];
454c4762a1bSJed Brown }
455c4762a1bSJed Brown 
456c4762a1bSJed Brown static PetscErrorCode ProcessOptions(MPI_Comm comm, AppCtx *options)
457c4762a1bSJed Brown {
458c4762a1bSJed Brown   const char    *bcTypes[3]  = {"neumann", "dirichlet", "none"};
459c4762a1bSJed Brown   const char    *runTypes[4] = {"full", "exact", "test", "perf"};
4608d1b37daSJoe Wallwork   const char    *coeffTypes[8] = {"none", "analytic", "field", "nonlinear", "ball", "cross", "checkerboard_0", "checkerboard_1"};
46130602db0SMatthew G. Knepley   PetscInt       bc, run, coeff;
462c4762a1bSJed Brown 
463c4762a1bSJed Brown   PetscFunctionBeginUser;
464c4762a1bSJed Brown   options->runType             = RUN_FULL;
465c4762a1bSJed Brown   options->bcType              = DIRICHLET;
466c4762a1bSJed Brown   options->variableCoefficient = COEFF_NONE;
467c4762a1bSJed Brown   options->fieldBC             = PETSC_FALSE;
468c4762a1bSJed Brown   options->jacobianMF          = PETSC_FALSE;
469c4762a1bSJed Brown   options->showInitial         = PETSC_FALSE;
470c4762a1bSJed Brown   options->showSolution        = PETSC_FALSE;
471c4762a1bSJed Brown   options->restart             = PETSC_FALSE;
472c4762a1bSJed Brown   options->quiet               = PETSC_FALSE;
473c4762a1bSJed Brown   options->nonzInit            = PETSC_FALSE;
474c4762a1bSJed Brown   options->bdIntegral          = PETSC_FALSE;
475c4762a1bSJed Brown   options->checkksp            = PETSC_FALSE;
476d6837840SMatthew G. Knepley   options->div                 = 4;
477d6837840SMatthew G. Knepley   options->k                   = 1;
478d6837840SMatthew G. Knepley   options->kgrid               = NULL;
47930602db0SMatthew G. Knepley   options->rand                = PETSC_FALSE;
480c4762a1bSJed Brown 
481d0609cedSBarry Smith   PetscOptionsBegin(comm, "", "Poisson Problem Options", "DMPLEX");
482c4762a1bSJed Brown   run  = options->runType;
4839566063dSJacob Faibussowitsch   PetscCall(PetscOptionsEList("-run_type", "The run type", "ex12.c", runTypes, 4, runTypes[options->runType], &run, NULL));
484c4762a1bSJed Brown   options->runType = (RunType) run;
485c4762a1bSJed Brown   bc   = options->bcType;
4869566063dSJacob Faibussowitsch   PetscCall(PetscOptionsEList("-bc_type","Type of boundary condition","ex12.c",bcTypes,3,bcTypes[options->bcType],&bc,NULL));
487c4762a1bSJed Brown   options->bcType = (BCType) bc;
488c4762a1bSJed Brown   coeff = options->variableCoefficient;
4899566063dSJacob Faibussowitsch   PetscCall(PetscOptionsEList("-variable_coefficient","Type of variable coefficent","ex12.c",coeffTypes,8,coeffTypes[options->variableCoefficient],&coeff,NULL));
490c4762a1bSJed Brown   options->variableCoefficient = (CoeffType) coeff;
491c4762a1bSJed Brown 
4929566063dSJacob Faibussowitsch   PetscCall(PetscOptionsBool("-field_bc", "Use a field representation for the BC", "ex12.c", options->fieldBC, &options->fieldBC, NULL));
4939566063dSJacob Faibussowitsch   PetscCall(PetscOptionsBool("-jacobian_mf", "Calculate the action of the Jacobian on the fly", "ex12.c", options->jacobianMF, &options->jacobianMF, NULL));
4949566063dSJacob Faibussowitsch   PetscCall(PetscOptionsBool("-show_initial", "Output the initial guess for verification", "ex12.c", options->showInitial, &options->showInitial, NULL));
4959566063dSJacob Faibussowitsch   PetscCall(PetscOptionsBool("-show_solution", "Output the solution for verification", "ex12.c", options->showSolution, &options->showSolution, NULL));
4969566063dSJacob Faibussowitsch   PetscCall(PetscOptionsBool("-restart", "Read in the mesh and solution from a file", "ex12.c", options->restart, &options->restart, NULL));
4979566063dSJacob Faibussowitsch   PetscCall(PetscOptionsBool("-quiet", "Don't print any vecs", "ex12.c", options->quiet, &options->quiet, NULL));
4989566063dSJacob Faibussowitsch   PetscCall(PetscOptionsBool("-nonzero_initial_guess", "nonzero initial guess", "ex12.c", options->nonzInit, &options->nonzInit, NULL));
4999566063dSJacob Faibussowitsch   PetscCall(PetscOptionsBool("-bd_integral", "Compute the integral of the solution on the boundary", "ex12.c", options->bdIntegral, &options->bdIntegral, NULL));
500c4762a1bSJed Brown   if (options->runType == RUN_TEST) {
5019566063dSJacob Faibussowitsch     PetscCall(PetscOptionsBool("-run_test_check_ksp", "Check solution of KSP", "ex12.c", options->checkksp, &options->checkksp, NULL));
502c4762a1bSJed Brown   }
5039566063dSJacob Faibussowitsch   PetscCall(PetscOptionsInt("-div", "The number of division for the checkerboard coefficient", "ex12.c", options->div, &options->div, NULL));
5049566063dSJacob Faibussowitsch   PetscCall(PetscOptionsInt("-k", "The exponent for the checkerboard coefficient", "ex12.c", options->k, &options->k, NULL));
5059566063dSJacob Faibussowitsch   PetscCall(PetscOptionsBool("-k_random", "Assign random k values to checkerboard", "ex12.c", options->rand, &options->rand, NULL));
506d0609cedSBarry Smith   PetscOptionsEnd();
507c4762a1bSJed Brown   PetscFunctionReturn(0);
508c4762a1bSJed Brown }
509c4762a1bSJed Brown 
510c4762a1bSJed Brown static PetscErrorCode CreateBCLabel(DM dm, const char name[])
511c4762a1bSJed Brown {
512408cafa0SMatthew G. Knepley   DM             plex;
513c4762a1bSJed Brown   DMLabel        label;
514c4762a1bSJed Brown 
515c4762a1bSJed Brown   PetscFunctionBeginUser;
5169566063dSJacob Faibussowitsch   PetscCall(DMCreateLabel(dm, name));
5179566063dSJacob Faibussowitsch   PetscCall(DMGetLabel(dm, name, &label));
5189566063dSJacob Faibussowitsch   PetscCall(DMConvert(dm, DMPLEX, &plex));
5199566063dSJacob Faibussowitsch   PetscCall(DMPlexMarkBoundaryFaces(plex, 1, label));
5209566063dSJacob Faibussowitsch   PetscCall(DMDestroy(&plex));
521c4762a1bSJed Brown   PetscFunctionReturn(0);
522c4762a1bSJed Brown }
523c4762a1bSJed Brown 
524c4762a1bSJed Brown static PetscErrorCode CreateMesh(MPI_Comm comm, AppCtx *user, DM *dm)
525c4762a1bSJed Brown {
526c4762a1bSJed Brown   PetscFunctionBeginUser;
5279566063dSJacob Faibussowitsch   PetscCall(DMCreate(comm, dm));
5289566063dSJacob Faibussowitsch   PetscCall(DMSetType(*dm, DMPLEX));
5299566063dSJacob Faibussowitsch   PetscCall(DMSetFromOptions(*dm));
530c4762a1bSJed Brown   {
531c4762a1bSJed Brown     char      convType[256];
532c4762a1bSJed Brown     PetscBool flg;
533c4762a1bSJed Brown 
534d0609cedSBarry Smith     PetscOptionsBegin(comm, "", "Mesh conversion options", "DMPLEX");
5359566063dSJacob Faibussowitsch     PetscCall(PetscOptionsFList("-dm_plex_convert_type","Convert DMPlex to another format","ex12",DMList,DMPLEX,convType,256,&flg));
536d0609cedSBarry Smith     PetscOptionsEnd();
537c4762a1bSJed Brown     if (flg) {
538c4762a1bSJed Brown       DM dmConv;
539c4762a1bSJed Brown 
5409566063dSJacob Faibussowitsch       PetscCall(DMConvert(*dm,convType,&dmConv));
541c4762a1bSJed Brown       if (dmConv) {
5429566063dSJacob Faibussowitsch         PetscCall(DMDestroy(dm));
543c4762a1bSJed Brown         *dm  = dmConv;
544c4762a1bSJed Brown       }
5459566063dSJacob Faibussowitsch       PetscCall(DMSetFromOptions(*dm));
5469566063dSJacob Faibussowitsch       PetscCall(DMSetUp(*dm));
54730602db0SMatthew G. Knepley     }
54830602db0SMatthew G. Knepley   }
5499566063dSJacob Faibussowitsch   PetscCall(DMViewFromOptions(*dm, NULL, "-dm_view"));
55030602db0SMatthew G. Knepley   if (user->rand) {
55130602db0SMatthew G. Knepley     PetscRandom r;
55230602db0SMatthew G. Knepley     PetscReal   val;
55330602db0SMatthew G. Knepley     PetscInt    dim, N, i;
554c4762a1bSJed Brown 
5559566063dSJacob Faibussowitsch     PetscCall(DMGetDimension(*dm, &dim));
55630602db0SMatthew G. Knepley     N    = PetscPowInt(user->div, dim);
5579566063dSJacob Faibussowitsch     PetscCall(PetscMalloc1(N, &user->kgrid));
5589566063dSJacob Faibussowitsch     PetscCall(PetscRandomCreate(PETSC_COMM_SELF, &r));
5599566063dSJacob Faibussowitsch     PetscCall(PetscRandomSetFromOptions(r));
5609566063dSJacob Faibussowitsch     PetscCall(PetscRandomSetInterval(r, 0.0, user->k));
5619566063dSJacob Faibussowitsch     PetscCall(PetscRandomSetSeed(r, 1973));
5629566063dSJacob Faibussowitsch     PetscCall(PetscRandomSeed(r));
56330602db0SMatthew G. Knepley     for (i = 0; i < N; ++i) {
5649566063dSJacob Faibussowitsch       PetscCall(PetscRandomGetValueReal(r, &val));
56530602db0SMatthew G. Knepley       user->kgrid[i] = 1 + (PetscInt) val;
566c4762a1bSJed Brown     }
5679566063dSJacob Faibussowitsch     PetscCall(PetscRandomDestroy(&r));
568c4762a1bSJed Brown   }
569c4762a1bSJed Brown   PetscFunctionReturn(0);
570c4762a1bSJed Brown }
571c4762a1bSJed Brown 
572c4762a1bSJed Brown static PetscErrorCode SetupProblem(DM dm, AppCtx *user)
573c4762a1bSJed Brown {
57445480ffeSMatthew G. Knepley   PetscDS          ds;
57545480ffeSMatthew G. Knepley   DMLabel          label;
57645480ffeSMatthew G. Knepley   PetscWeakForm    wf;
577*8fb5bd83SMatthew G. Knepley   const PetscReal *L;
578c4762a1bSJed Brown   const PetscInt   id = 1;
57930602db0SMatthew G. Knepley   PetscInt         bd, dim;
580c4762a1bSJed Brown 
581c4762a1bSJed Brown   PetscFunctionBeginUser;
5829566063dSJacob Faibussowitsch   PetscCall(DMGetDS(dm, &ds));
5839566063dSJacob Faibussowitsch   PetscCall(DMGetDimension(dm, &dim));
584*8fb5bd83SMatthew G. Knepley   PetscCall(DMGetPeriodicity(dm, NULL, &L));
585c4762a1bSJed Brown   switch (user->variableCoefficient) {
586c4762a1bSJed Brown   case COEFF_NONE:
587*8fb5bd83SMatthew G. Knepley     if (L && L[0]) {
588*8fb5bd83SMatthew G. Knepley       if (L && L[1]) {
5899566063dSJacob Faibussowitsch         PetscCall(PetscDSSetResidual(ds, 0, f0_xytrig_u, f1_u));
5909566063dSJacob Faibussowitsch         PetscCall(PetscDSSetJacobian(ds, 0, 0, NULL, NULL, NULL, g3_uu));
591c4762a1bSJed Brown       } else {
5929566063dSJacob Faibussowitsch         PetscCall(PetscDSSetResidual(ds, 0, f0_xtrig_u,  f1_u));
5939566063dSJacob Faibussowitsch         PetscCall(PetscDSSetJacobian(ds, 0, 0, NULL, NULL, NULL, g3_uu));
594c4762a1bSJed Brown       }
595c4762a1bSJed Brown     } else {
5969566063dSJacob Faibussowitsch       PetscCall(PetscDSSetResidual(ds, 0, f0_u, f1_u));
5979566063dSJacob Faibussowitsch       PetscCall(PetscDSSetJacobian(ds, 0, 0, NULL, NULL, NULL, g3_uu));
598c4762a1bSJed Brown     }
599c4762a1bSJed Brown     break;
600c4762a1bSJed Brown   case COEFF_ANALYTIC:
6019566063dSJacob Faibussowitsch     PetscCall(PetscDSSetResidual(ds, 0, f0_analytic_u, f1_analytic_u));
6029566063dSJacob Faibussowitsch     PetscCall(PetscDSSetJacobian(ds, 0, 0, NULL, NULL, NULL, g3_analytic_uu));
603c4762a1bSJed Brown     break;
604c4762a1bSJed Brown   case COEFF_FIELD:
6059566063dSJacob Faibussowitsch     PetscCall(PetscDSSetResidual(ds, 0, f0_analytic_u, f1_field_u));
6069566063dSJacob Faibussowitsch     PetscCall(PetscDSSetJacobian(ds, 0, 0, NULL, NULL, NULL, g3_field_uu));
607c4762a1bSJed Brown     break;
608c4762a1bSJed Brown   case COEFF_NONLINEAR:
6099566063dSJacob Faibussowitsch     PetscCall(PetscDSSetResidual(ds, 0, f0_analytic_nonlinear_u, f1_analytic_nonlinear_u));
6109566063dSJacob Faibussowitsch     PetscCall(PetscDSSetJacobian(ds, 0, 0, NULL, NULL, NULL, g3_analytic_nonlinear_uu));
611c4762a1bSJed Brown     break;
6128d1b37daSJoe Wallwork   case COEFF_BALL:
6139566063dSJacob Faibussowitsch     PetscCall(PetscDSSetResidual(ds, 0, f0_ball_u, f1_u));
6149566063dSJacob Faibussowitsch     PetscCall(PetscDSSetJacobian(ds, 0, 0, NULL, NULL, NULL, g3_uu));
615c4762a1bSJed Brown     break;
616c4762a1bSJed Brown   case COEFF_CROSS:
6178d1b37daSJoe Wallwork     switch (dim) {
6188d1b37daSJoe Wallwork     case 2:
6199566063dSJacob Faibussowitsch       PetscCall(PetscDSSetResidual(ds, 0, f0_cross_u_2d, f1_u));
6208d1b37daSJoe Wallwork       break;
6218d1b37daSJoe Wallwork     case 3:
6229566063dSJacob Faibussowitsch       PetscCall(PetscDSSetResidual(ds, 0, f0_cross_u_3d, f1_u));
6238d1b37daSJoe Wallwork       break;
6248d1b37daSJoe Wallwork     default:
62563a3b9bcSJacob Faibussowitsch       SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_ARG_OUTOFRANGE, "Invalid dimension %" PetscInt_FMT, dim);
6268d1b37daSJoe Wallwork     }
6279566063dSJacob Faibussowitsch     PetscCall(PetscDSSetJacobian(ds, 0, 0, NULL, NULL, NULL, g3_uu));
628c4762a1bSJed Brown     break;
629d6837840SMatthew G. Knepley   case COEFF_CHECKERBOARD_0:
6309566063dSJacob Faibussowitsch     PetscCall(PetscDSSetResidual(ds, 0, f0_checkerboard_0_u, f1_field_u));
6319566063dSJacob Faibussowitsch     PetscCall(PetscDSSetJacobian(ds, 0, 0, NULL, NULL, NULL, g3_field_uu));
632d6837840SMatthew G. Knepley     break;
63398921bdaSJacob Faibussowitsch   default: SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Invalid variable coefficient type %d", user->variableCoefficient);
634c4762a1bSJed Brown   }
63530602db0SMatthew G. Knepley   switch (dim) {
636c4762a1bSJed Brown   case 2:
637c4762a1bSJed Brown     switch (user->variableCoefficient) {
6388d1b37daSJoe Wallwork     case COEFF_BALL:
6398d1b37daSJoe Wallwork       user->exactFuncs[0]  = ball_u_2d;break;
640c4762a1bSJed Brown     case COEFF_CROSS:
641c4762a1bSJed Brown       user->exactFuncs[0]  = cross_u_2d;break;
642d6837840SMatthew G. Knepley     case COEFF_CHECKERBOARD_0:
643d6837840SMatthew G. Knepley       user->exactFuncs[0]  = zero;break;
644c4762a1bSJed Brown     default:
645*8fb5bd83SMatthew G. Knepley       if (L && L[0]) {
646*8fb5bd83SMatthew G. Knepley         if (L && L[1]) {
647c4762a1bSJed Brown           user->exactFuncs[0] = xytrig_u_2d;
648c4762a1bSJed Brown         } else {
649c4762a1bSJed Brown           user->exactFuncs[0] = xtrig_u_2d;
650c4762a1bSJed Brown         }
651c4762a1bSJed Brown       } else {
652c4762a1bSJed Brown         user->exactFuncs[0]  = quadratic_u_2d;
653c4762a1bSJed Brown         user->exactFields[0] = quadratic_u_field_2d;
654c4762a1bSJed Brown       }
655c4762a1bSJed Brown     }
65645480ffeSMatthew G. Knepley     if (user->bcType == NEUMANN) {
6579566063dSJacob Faibussowitsch       PetscCall(DMGetLabel(dm, "boundary", &label));
6589566063dSJacob Faibussowitsch       PetscCall(DMAddBoundary(dm, DM_BC_NATURAL, "wall", label, 1, &id, 0, 0, NULL, NULL, NULL, user, &bd));
6599566063dSJacob Faibussowitsch       PetscCall(PetscDSGetBoundary(ds, bd, &wf, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL));
6609566063dSJacob Faibussowitsch       PetscCall(PetscWeakFormSetIndexBdResidual(wf, label, id, 0, 0, 0, f0_bd_u, 0, NULL));
66145480ffeSMatthew G. Knepley     }
662c4762a1bSJed Brown     break;
663c4762a1bSJed Brown   case 3:
6648d1b37daSJoe Wallwork     switch (user->variableCoefficient) {
6658d1b37daSJoe Wallwork     case COEFF_BALL:
6668d1b37daSJoe Wallwork       user->exactFuncs[0]  = ball_u_3d;break;
6678d1b37daSJoe Wallwork     case COEFF_CROSS:
6688d1b37daSJoe Wallwork       user->exactFuncs[0]  = cross_u_3d;break;
6698d1b37daSJoe Wallwork     default:
670c4762a1bSJed Brown       user->exactFuncs[0]  = quadratic_u_3d;
671c4762a1bSJed Brown       user->exactFields[0] = quadratic_u_field_3d;
6728d1b37daSJoe Wallwork     }
67345480ffeSMatthew G. Knepley     if (user->bcType == NEUMANN) {
6749566063dSJacob Faibussowitsch       PetscCall(DMGetLabel(dm, "boundary", &label));
6759566063dSJacob Faibussowitsch       PetscCall(DMAddBoundary(dm, DM_BC_NATURAL, "wall", label, 1, &id, 0, 0, NULL, NULL, NULL, user, &bd));
6769566063dSJacob Faibussowitsch       PetscCall(PetscDSGetBoundary(ds, bd, &wf, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL));
6779566063dSJacob Faibussowitsch       PetscCall(PetscWeakFormSetIndexBdResidual(wf, label, id, 0, 0, 0, f0_bd_u, 0, NULL));
67845480ffeSMatthew G. Knepley     }
679c4762a1bSJed Brown     break;
680c4762a1bSJed Brown   default:
68163a3b9bcSJacob Faibussowitsch     SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_ARG_OUTOFRANGE, "Invalid dimension %" PetscInt_FMT, dim);
682c4762a1bSJed Brown   }
683d6837840SMatthew G. Knepley   /* Setup constants */
684d6837840SMatthew G. Knepley   switch (user->variableCoefficient) {
685d6837840SMatthew G. Knepley   case COEFF_CHECKERBOARD_0:
686d6837840SMatthew G. Knepley   {
687d6837840SMatthew G. Knepley     PetscScalar constants[2];
688d6837840SMatthew G. Knepley 
689d6837840SMatthew G. Knepley     constants[0] = user->div;
690d6837840SMatthew G. Knepley     constants[1] = user->k;
6919566063dSJacob Faibussowitsch     PetscCall(PetscDSSetConstants(ds, 2, constants));
692d6837840SMatthew G. Knepley   }
693d6837840SMatthew G. Knepley   break;
694d6837840SMatthew G. Knepley   default: break;
695d6837840SMatthew G. Knepley   }
6969566063dSJacob Faibussowitsch   PetscCall(PetscDSSetExactSolution(ds, 0, user->exactFuncs[0], user));
697d6837840SMatthew G. Knepley   /* Setup Boundary Conditions */
69845480ffeSMatthew G. Knepley   if (user->bcType == DIRICHLET) {
6999566063dSJacob Faibussowitsch     PetscCall(DMGetLabel(dm, "marker", &label));
70045480ffeSMatthew G. Knepley     if (!label) {
70145480ffeSMatthew G. Knepley       /* Right now, p4est cannot create labels immediately */
7029566063dSJacob Faibussowitsch       PetscCall(PetscDSAddBoundaryByName(ds, user->fieldBC ? DM_BC_ESSENTIAL_FIELD : DM_BC_ESSENTIAL, "wall", "marker", 1, &id, 0, 0, NULL, user->fieldBC ? (void (*)(void)) user->exactFields[0] : (void (*)(void)) user->exactFuncs[0], NULL, user, NULL));
70345480ffeSMatthew G. Knepley     } else {
7049566063dSJacob Faibussowitsch       PetscCall(DMAddBoundary(dm, user->fieldBC ? DM_BC_ESSENTIAL_FIELD : DM_BC_ESSENTIAL, "wall", label, 1, &id, 0, 0, NULL, user->fieldBC ? (void (*)(void)) user->exactFields[0] : (void (*)(void)) user->exactFuncs[0], NULL, user, NULL));
70545480ffeSMatthew G. Knepley     }
706c4762a1bSJed Brown   }
707c4762a1bSJed Brown   PetscFunctionReturn(0);
708c4762a1bSJed Brown }
709c4762a1bSJed Brown 
710c4762a1bSJed Brown static PetscErrorCode SetupMaterial(DM dm, DM dmAux, AppCtx *user)
711c4762a1bSJed Brown {
712c4762a1bSJed Brown   PetscErrorCode (*matFuncs[1])(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) = {nu_2d};
713d6837840SMatthew G. Knepley   void            *ctx[1];
714c4762a1bSJed Brown   Vec              nu;
715c4762a1bSJed Brown 
716c4762a1bSJed Brown   PetscFunctionBegin;
717d6837840SMatthew G. Knepley   ctx[0] = user;
718d6837840SMatthew G. Knepley   if (user->variableCoefficient == COEFF_CHECKERBOARD_0) {matFuncs[0] = checkerboardCoeff;}
7199566063dSJacob Faibussowitsch   PetscCall(DMCreateLocalVector(dmAux, &nu));
7209566063dSJacob Faibussowitsch   PetscCall(PetscObjectSetName((PetscObject) nu, "Coefficient"));
7219566063dSJacob Faibussowitsch   PetscCall(DMProjectFunctionLocal(dmAux, 0.0, matFuncs, ctx, INSERT_ALL_VALUES, nu));
7229566063dSJacob Faibussowitsch   PetscCall(DMSetAuxiliaryVec(dm, NULL, 0, 0, nu));
7239566063dSJacob Faibussowitsch   PetscCall(VecDestroy(&nu));
724c4762a1bSJed Brown   PetscFunctionReturn(0);
725c4762a1bSJed Brown }
726c4762a1bSJed Brown 
727c4762a1bSJed Brown static PetscErrorCode SetupBC(DM dm, DM dmAux, AppCtx *user)
728c4762a1bSJed Brown {
729c4762a1bSJed Brown   PetscErrorCode (*bcFuncs[1])(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx);
730c4762a1bSJed Brown   Vec            uexact;
731c4762a1bSJed Brown   PetscInt       dim;
732c4762a1bSJed Brown 
733c4762a1bSJed Brown   PetscFunctionBegin;
7349566063dSJacob Faibussowitsch   PetscCall(DMGetDimension(dm, &dim));
735c4762a1bSJed Brown   if (dim == 2) bcFuncs[0] = quadratic_u_2d;
736c4762a1bSJed Brown   else          bcFuncs[0] = quadratic_u_3d;
7379566063dSJacob Faibussowitsch   PetscCall(DMCreateLocalVector(dmAux, &uexact));
7389566063dSJacob Faibussowitsch   PetscCall(DMProjectFunctionLocal(dmAux, 0.0, bcFuncs, NULL, INSERT_ALL_VALUES, uexact));
7399566063dSJacob Faibussowitsch   PetscCall(DMSetAuxiliaryVec(dm, NULL, 0, 0, uexact));
7409566063dSJacob Faibussowitsch   PetscCall(VecDestroy(&uexact));
741c4762a1bSJed Brown   PetscFunctionReturn(0);
742c4762a1bSJed Brown }
743c4762a1bSJed Brown 
744c4762a1bSJed Brown static PetscErrorCode SetupAuxDM(DM dm, PetscFE feAux, AppCtx *user)
745c4762a1bSJed Brown {
746c4762a1bSJed Brown   DM             dmAux, coordDM;
747c4762a1bSJed Brown 
748c4762a1bSJed Brown   PetscFunctionBegin;
749c4762a1bSJed Brown   /* MUST call DMGetCoordinateDM() in order to get p4est setup if present */
7509566063dSJacob Faibussowitsch   PetscCall(DMGetCoordinateDM(dm, &coordDM));
751c4762a1bSJed Brown   if (!feAux) PetscFunctionReturn(0);
7529566063dSJacob Faibussowitsch   PetscCall(DMClone(dm, &dmAux));
7539566063dSJacob Faibussowitsch   PetscCall(DMSetCoordinateDM(dmAux, coordDM));
7549566063dSJacob Faibussowitsch   PetscCall(DMSetField(dmAux, 0, NULL, (PetscObject) feAux));
7559566063dSJacob Faibussowitsch   PetscCall(DMCreateDS(dmAux));
7569566063dSJacob Faibussowitsch   if (user->fieldBC) PetscCall(SetupBC(dm, dmAux, user));
7579566063dSJacob Faibussowitsch   else               PetscCall(SetupMaterial(dm, dmAux, user));
7589566063dSJacob Faibussowitsch   PetscCall(DMDestroy(&dmAux));
759c4762a1bSJed Brown   PetscFunctionReturn(0);
760c4762a1bSJed Brown }
761c4762a1bSJed Brown 
762c4762a1bSJed Brown static PetscErrorCode SetupDiscretization(DM dm, AppCtx *user)
763c4762a1bSJed Brown {
76430602db0SMatthew G. Knepley   DM             plex, cdm = dm;
765c4762a1bSJed Brown   PetscFE        fe, feAux = NULL;
76630602db0SMatthew G. Knepley   PetscBool      simplex;
76730602db0SMatthew G. Knepley   PetscInt       dim;
768c4762a1bSJed Brown   MPI_Comm       comm;
769c4762a1bSJed Brown 
770c4762a1bSJed Brown   PetscFunctionBeginUser;
7719566063dSJacob Faibussowitsch   PetscCall(DMGetDimension(dm, &dim));
7729566063dSJacob Faibussowitsch   PetscCall(DMConvert(dm, DMPLEX, &plex));
7739566063dSJacob Faibussowitsch   PetscCall(DMPlexIsSimplex(plex, &simplex));
7749566063dSJacob Faibussowitsch   PetscCall(DMDestroy(&plex));
7759566063dSJacob Faibussowitsch   PetscCall(PetscObjectGetComm((PetscObject) dm, &comm));
7769566063dSJacob Faibussowitsch   PetscCall(PetscFECreateDefault(PETSC_COMM_SELF, dim, 1, simplex, NULL, -1, &fe));
7779566063dSJacob Faibussowitsch   PetscCall(PetscObjectSetName((PetscObject) fe, "potential"));
778d6837840SMatthew G. Knepley   if (user->variableCoefficient == COEFF_FIELD || user->variableCoefficient == COEFF_CHECKERBOARD_0) {
7799566063dSJacob Faibussowitsch     PetscCall(PetscFECreateDefault(PETSC_COMM_SELF, dim, 1, simplex, "mat_", -1, &feAux));
7809566063dSJacob Faibussowitsch     PetscCall(PetscObjectSetName((PetscObject) feAux, "coefficient"));
7819566063dSJacob Faibussowitsch     PetscCall(PetscFECopyQuadrature(fe, feAux));
782c4762a1bSJed Brown   } else if (user->fieldBC) {
7839566063dSJacob Faibussowitsch     PetscCall(PetscFECreateDefault(PETSC_COMM_SELF, dim, 1, simplex, "bc_", -1, &feAux));
7849566063dSJacob Faibussowitsch     PetscCall(PetscFECopyQuadrature(fe, feAux));
785c4762a1bSJed Brown   }
786c4762a1bSJed Brown   /* Set discretization and boundary conditions for each mesh */
7879566063dSJacob Faibussowitsch   PetscCall(DMSetField(dm, 0, NULL, (PetscObject) fe));
7889566063dSJacob Faibussowitsch   PetscCall(DMCreateDS(dm));
7899566063dSJacob Faibussowitsch   PetscCall(SetupProblem(dm, user));
790c4762a1bSJed Brown   while (cdm) {
7919566063dSJacob Faibussowitsch     PetscCall(SetupAuxDM(cdm, feAux, user));
79230602db0SMatthew G. Knepley     if (user->bcType == DIRICHLET) {
793c4762a1bSJed Brown       PetscBool hasLabel;
794c4762a1bSJed Brown 
7959566063dSJacob Faibussowitsch       PetscCall(DMHasLabel(cdm, "marker", &hasLabel));
7969566063dSJacob Faibussowitsch       if (!hasLabel) PetscCall(CreateBCLabel(cdm, "marker"));
797c4762a1bSJed Brown     }
7989566063dSJacob Faibussowitsch     PetscCall(DMCopyDisc(dm, cdm));
7999566063dSJacob Faibussowitsch     PetscCall(DMGetCoarseDM(cdm, &cdm));
800c4762a1bSJed Brown   }
8019566063dSJacob Faibussowitsch   PetscCall(PetscFEDestroy(&fe));
8029566063dSJacob Faibussowitsch   PetscCall(PetscFEDestroy(&feAux));
803c4762a1bSJed Brown   PetscFunctionReturn(0);
804c4762a1bSJed Brown }
805c4762a1bSJed Brown 
806c4762a1bSJed Brown int main(int argc, char **argv)
807c4762a1bSJed Brown {
808c4762a1bSJed Brown   DM             dm;          /* Problem specification */
809c4762a1bSJed Brown   SNES           snes;        /* nonlinear solver */
810c4762a1bSJed Brown   Vec            u;           /* solution vector */
811c4762a1bSJed Brown   Mat            A,J;         /* Jacobian matrix */
812c4762a1bSJed Brown   MatNullSpace   nullSpace;   /* May be necessary for Neumann conditions */
813c4762a1bSJed Brown   AppCtx         user;        /* user-defined work context */
814c4762a1bSJed Brown   JacActionCtx   userJ;       /* context for Jacobian MF action */
815c4762a1bSJed Brown   PetscReal      error = 0.0; /* L_2 error in the solution */
816c4762a1bSJed Brown 
8179566063dSJacob Faibussowitsch   PetscCall(PetscInitialize(&argc, &argv, NULL,help));
8189566063dSJacob Faibussowitsch   PetscCall(ProcessOptions(PETSC_COMM_WORLD, &user));
8199566063dSJacob Faibussowitsch   PetscCall(SNESCreate(PETSC_COMM_WORLD, &snes));
8209566063dSJacob Faibussowitsch   PetscCall(CreateMesh(PETSC_COMM_WORLD, &user, &dm));
8219566063dSJacob Faibussowitsch   PetscCall(SNESSetDM(snes, dm));
8229566063dSJacob Faibussowitsch   PetscCall(DMSetApplicationContext(dm, &user));
823c4762a1bSJed Brown 
8249566063dSJacob Faibussowitsch   PetscCall(PetscMalloc2(1, &user.exactFuncs, 1, &user.exactFields));
8259566063dSJacob Faibussowitsch   PetscCall(SetupDiscretization(dm, &user));
826c4762a1bSJed Brown 
8279566063dSJacob Faibussowitsch   PetscCall(DMCreateGlobalVector(dm, &u));
8289566063dSJacob Faibussowitsch   PetscCall(PetscObjectSetName((PetscObject) u, "potential"));
829c4762a1bSJed Brown 
8309566063dSJacob Faibussowitsch   PetscCall(DMCreateMatrix(dm, &J));
831c4762a1bSJed Brown   if (user.jacobianMF) {
832c4762a1bSJed Brown     PetscInt M, m, N, n;
833c4762a1bSJed Brown 
8349566063dSJacob Faibussowitsch     PetscCall(MatGetSize(J, &M, &N));
8359566063dSJacob Faibussowitsch     PetscCall(MatGetLocalSize(J, &m, &n));
8369566063dSJacob Faibussowitsch     PetscCall(MatCreate(PETSC_COMM_WORLD, &A));
8379566063dSJacob Faibussowitsch     PetscCall(MatSetSizes(A, m, n, M, N));
8389566063dSJacob Faibussowitsch     PetscCall(MatSetType(A, MATSHELL));
8399566063dSJacob Faibussowitsch     PetscCall(MatSetUp(A));
840c4762a1bSJed Brown #if 0
8419566063dSJacob Faibussowitsch     PetscCall(MatShellSetOperation(A, MATOP_MULT, (void (*)(void))FormJacobianAction));
842c4762a1bSJed Brown #endif
843c4762a1bSJed Brown 
844c4762a1bSJed Brown     userJ.dm   = dm;
845c4762a1bSJed Brown     userJ.J    = J;
846c4762a1bSJed Brown     userJ.user = &user;
847c4762a1bSJed Brown 
8489566063dSJacob Faibussowitsch     PetscCall(DMCreateLocalVector(dm, &userJ.u));
8499566063dSJacob Faibussowitsch     if (user.fieldBC) PetscCall(DMProjectFieldLocal(dm, 0.0, userJ.u, user.exactFields, INSERT_BC_VALUES, userJ.u));
8509566063dSJacob Faibussowitsch     else              PetscCall(DMProjectFunctionLocal(dm, 0.0, user.exactFuncs, NULL, INSERT_BC_VALUES, userJ.u));
8519566063dSJacob Faibussowitsch     PetscCall(MatShellSetContext(A, &userJ));
852c4762a1bSJed Brown   } else {
853c4762a1bSJed Brown     A = J;
854c4762a1bSJed Brown   }
855c4762a1bSJed Brown 
856c4762a1bSJed Brown   nullSpace = NULL;
857c4762a1bSJed Brown   if (user.bcType != DIRICHLET) {
8589566063dSJacob Faibussowitsch     PetscCall(MatNullSpaceCreate(PetscObjectComm((PetscObject) dm), PETSC_TRUE, 0, NULL, &nullSpace));
8599566063dSJacob Faibussowitsch     PetscCall(MatSetNullSpace(A, nullSpace));
860c4762a1bSJed Brown   }
861c4762a1bSJed Brown 
8629566063dSJacob Faibussowitsch   PetscCall(DMPlexSetSNESLocalFEM(dm,&user,&user,&user));
8639566063dSJacob Faibussowitsch   PetscCall(SNESSetJacobian(snes, A, J, NULL, NULL));
864c4762a1bSJed Brown 
8659566063dSJacob Faibussowitsch   PetscCall(SNESSetFromOptions(snes));
866c4762a1bSJed Brown 
8679566063dSJacob Faibussowitsch   if (user.fieldBC) PetscCall(DMProjectField(dm, 0.0, u, user.exactFields, INSERT_ALL_VALUES, u));
8689566063dSJacob Faibussowitsch   else              PetscCall(DMProjectFunction(dm, 0.0, user.exactFuncs, NULL, INSERT_ALL_VALUES, u));
869c4762a1bSJed Brown   if (user.restart) {
870c4762a1bSJed Brown #if defined(PETSC_HAVE_HDF5)
871c4762a1bSJed Brown     PetscViewer viewer;
87230602db0SMatthew G. Knepley     char        filename[PETSC_MAX_PATH_LEN];
873c4762a1bSJed Brown 
8749566063dSJacob Faibussowitsch     PetscCall(PetscOptionsGetString(NULL, NULL, "-dm_plex_filename", filename, sizeof(filename), NULL));
8759566063dSJacob Faibussowitsch     PetscCall(PetscViewerCreate(PETSC_COMM_WORLD, &viewer));
8769566063dSJacob Faibussowitsch     PetscCall(PetscViewerSetType(viewer, PETSCVIEWERHDF5));
8779566063dSJacob Faibussowitsch     PetscCall(PetscViewerFileSetMode(viewer, FILE_MODE_READ));
8789566063dSJacob Faibussowitsch     PetscCall(PetscViewerFileSetName(viewer, filename));
8799566063dSJacob Faibussowitsch     PetscCall(PetscViewerHDF5PushGroup(viewer, "/fields"));
8809566063dSJacob Faibussowitsch     PetscCall(VecLoad(u, viewer));
8819566063dSJacob Faibussowitsch     PetscCall(PetscViewerHDF5PopGroup(viewer));
8829566063dSJacob Faibussowitsch     PetscCall(PetscViewerDestroy(&viewer));
883c4762a1bSJed Brown #endif
884c4762a1bSJed Brown   }
885c4762a1bSJed Brown   if (user.showInitial) {
886c4762a1bSJed Brown     Vec lv;
8879566063dSJacob Faibussowitsch     PetscCall(DMGetLocalVector(dm, &lv));
8889566063dSJacob Faibussowitsch     PetscCall(DMGlobalToLocalBegin(dm, u, INSERT_VALUES, lv));
8899566063dSJacob Faibussowitsch     PetscCall(DMGlobalToLocalEnd(dm, u, INSERT_VALUES, lv));
8909566063dSJacob Faibussowitsch     PetscCall(DMPrintLocalVec(dm, "Local function", 1.0e-10, lv));
8919566063dSJacob Faibussowitsch     PetscCall(DMRestoreLocalVector(dm, &lv));
892c4762a1bSJed Brown   }
893c4762a1bSJed Brown   if (user.runType == RUN_FULL || user.runType == RUN_EXACT) {
894c4762a1bSJed Brown     PetscErrorCode (*initialGuess[1])(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar u[], void *ctx) = {zero};
895c4762a1bSJed Brown 
896c4762a1bSJed Brown     if (user.nonzInit) initialGuess[0] = ecks;
897c4762a1bSJed Brown     if (user.runType == RUN_FULL) {
8989566063dSJacob Faibussowitsch       PetscCall(DMProjectFunction(dm, 0.0, initialGuess, NULL, INSERT_VALUES, u));
899c4762a1bSJed Brown     }
9009566063dSJacob Faibussowitsch     PetscCall(VecViewFromOptions(u, NULL, "-guess_vec_view"));
9019566063dSJacob Faibussowitsch     PetscCall(SNESSolve(snes, NULL, u));
9029566063dSJacob Faibussowitsch     PetscCall(SNESGetSolution(snes, &u));
9039566063dSJacob Faibussowitsch     PetscCall(SNESGetDM(snes, &dm));
904c4762a1bSJed Brown 
905c4762a1bSJed Brown     if (user.showSolution) {
9069566063dSJacob Faibussowitsch       PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Solution\n"));
9079566063dSJacob Faibussowitsch       PetscCall(VecChop(u, 3.0e-9));
9089566063dSJacob Faibussowitsch       PetscCall(VecView(u, PETSC_VIEWER_STDOUT_WORLD));
909c4762a1bSJed Brown     }
910c4762a1bSJed Brown   } else if (user.runType == RUN_PERF) {
911c4762a1bSJed Brown     Vec       r;
912c4762a1bSJed Brown     PetscReal res = 0.0;
913c4762a1bSJed Brown 
9149566063dSJacob Faibussowitsch     PetscCall(SNESGetFunction(snes, &r, NULL, NULL));
9159566063dSJacob Faibussowitsch     PetscCall(SNESComputeFunction(snes, u, r));
9169566063dSJacob Faibussowitsch     PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Initial Residual\n"));
9179566063dSJacob Faibussowitsch     PetscCall(VecChop(r, 1.0e-10));
9189566063dSJacob Faibussowitsch     PetscCall(VecNorm(r, NORM_2, &res));
9199566063dSJacob Faibussowitsch     PetscCall(PetscPrintf(PETSC_COMM_WORLD, "L_2 Residual: %g\n", (double)res));
920c4762a1bSJed Brown   } else {
921c4762a1bSJed Brown     Vec       r;
922c4762a1bSJed Brown     PetscReal res = 0.0, tol = 1.0e-11;
923c4762a1bSJed Brown 
924c4762a1bSJed Brown     /* Check discretization error */
9259566063dSJacob Faibussowitsch     PetscCall(SNESGetFunction(snes, &r, NULL, NULL));
9269566063dSJacob Faibussowitsch     PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Initial guess\n"));
9279566063dSJacob Faibussowitsch     if (!user.quiet) PetscCall(VecView(u, PETSC_VIEWER_STDOUT_WORLD));
9289566063dSJacob Faibussowitsch     PetscCall(DMComputeL2Diff(dm, 0.0, user.exactFuncs, NULL, u, &error));
9299566063dSJacob Faibussowitsch     if (error < tol) PetscCall(PetscPrintf(PETSC_COMM_WORLD, "L_2 Error: < %2.1e\n", (double)tol));
9309566063dSJacob Faibussowitsch     else             PetscCall(PetscPrintf(PETSC_COMM_WORLD, "L_2 Error: %g\n", (double)error));
931c4762a1bSJed Brown     /* Check residual */
9329566063dSJacob Faibussowitsch     PetscCall(SNESComputeFunction(snes, u, r));
9339566063dSJacob Faibussowitsch     PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Initial Residual\n"));
9349566063dSJacob Faibussowitsch     PetscCall(VecChop(r, 1.0e-10));
9359566063dSJacob Faibussowitsch     if (!user.quiet) PetscCall(VecView(r, PETSC_VIEWER_STDOUT_WORLD));
9369566063dSJacob Faibussowitsch     PetscCall(VecNorm(r, NORM_2, &res));
9379566063dSJacob Faibussowitsch     PetscCall(PetscPrintf(PETSC_COMM_WORLD, "L_2 Residual: %g\n", (double)res));
938c4762a1bSJed Brown     /* Check Jacobian */
939c4762a1bSJed Brown     {
940c4762a1bSJed Brown       Vec b;
941c4762a1bSJed Brown 
9429566063dSJacob Faibussowitsch       PetscCall(SNESComputeJacobian(snes, u, A, A));
9439566063dSJacob Faibussowitsch       PetscCall(VecDuplicate(u, &b));
9449566063dSJacob Faibussowitsch       PetscCall(VecSet(r, 0.0));
9459566063dSJacob Faibussowitsch       PetscCall(SNESComputeFunction(snes, r, b));
9469566063dSJacob Faibussowitsch       PetscCall(MatMult(A, u, r));
9479566063dSJacob Faibussowitsch       PetscCall(VecAXPY(r, 1.0, b));
9489566063dSJacob Faibussowitsch       PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Au - b = Au + F(0)\n"));
9499566063dSJacob Faibussowitsch       PetscCall(VecChop(r, 1.0e-10));
9509566063dSJacob Faibussowitsch       if (!user.quiet) PetscCall(VecView(r, PETSC_VIEWER_STDOUT_WORLD));
9519566063dSJacob Faibussowitsch       PetscCall(VecNorm(r, NORM_2, &res));
9529566063dSJacob Faibussowitsch       PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Linear L_2 Residual: %g\n", (double)res));
953c4762a1bSJed Brown       /* check solver */
954c4762a1bSJed Brown       if (user.checkksp) {
955c4762a1bSJed Brown         KSP ksp;
956c4762a1bSJed Brown 
9571baa6e33SBarry Smith         if (nullSpace) PetscCall(MatNullSpaceRemove(nullSpace, u));
9589566063dSJacob Faibussowitsch         PetscCall(SNESComputeJacobian(snes, u, A, J));
9599566063dSJacob Faibussowitsch         PetscCall(MatMult(A, u, b));
9609566063dSJacob Faibussowitsch         PetscCall(SNESGetKSP(snes, &ksp));
9619566063dSJacob Faibussowitsch         PetscCall(KSPSetOperators(ksp, A, J));
9629566063dSJacob Faibussowitsch         PetscCall(KSPSolve(ksp, b, r));
9639566063dSJacob Faibussowitsch         PetscCall(VecAXPY(r, -1.0, u));
9649566063dSJacob Faibussowitsch         PetscCall(VecNorm(r, NORM_2, &res));
9659566063dSJacob Faibussowitsch         PetscCall(PetscPrintf(PETSC_COMM_WORLD, "KSP Error: %g\n", (double)res));
966c4762a1bSJed Brown       }
9679566063dSJacob Faibussowitsch       PetscCall(VecDestroy(&b));
968c4762a1bSJed Brown     }
969c4762a1bSJed Brown   }
9709566063dSJacob Faibussowitsch   PetscCall(VecViewFromOptions(u, NULL, "-vec_view"));
971d6837840SMatthew G. Knepley   {
972d6837840SMatthew G. Knepley     Vec nu;
973d6837840SMatthew G. Knepley 
9749566063dSJacob Faibussowitsch     PetscCall(DMGetAuxiliaryVec(dm, NULL, 0, 0, &nu));
9759566063dSJacob Faibussowitsch     if (nu) PetscCall(VecViewFromOptions(nu, NULL, "-coeff_view"));
976d6837840SMatthew G. Knepley   }
977c4762a1bSJed Brown 
978c4762a1bSJed Brown   if (user.bdIntegral) {
979c4762a1bSJed Brown     DMLabel   label;
980c4762a1bSJed Brown     PetscInt  id = 1;
981c4762a1bSJed Brown     PetscScalar bdInt = 0.0;
982c4762a1bSJed Brown     PetscReal   exact = 3.3333333333;
983c4762a1bSJed Brown 
9849566063dSJacob Faibussowitsch     PetscCall(DMGetLabel(dm, "marker", &label));
9859566063dSJacob Faibussowitsch     PetscCall(DMPlexComputeBdIntegral(dm, u, label, 1, &id, bd_integral_2d, &bdInt, NULL));
9869566063dSJacob Faibussowitsch     PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Solution boundary integral: %.4g\n", (double) PetscAbsScalar(bdInt)));
9870b121fc5SBarry Smith     PetscCheck(PetscAbsReal(PetscAbsScalar(bdInt) - exact) <= PETSC_SQRT_MACHINE_EPSILON,PETSC_COMM_WORLD, PETSC_ERR_PLIB, "Invalid boundary integral %g != %g", (double) PetscAbsScalar(bdInt), (double)exact);
988c4762a1bSJed Brown   }
989c4762a1bSJed Brown 
9909566063dSJacob Faibussowitsch   PetscCall(MatNullSpaceDestroy(&nullSpace));
9919566063dSJacob Faibussowitsch   if (user.jacobianMF) PetscCall(VecDestroy(&userJ.u));
9929566063dSJacob Faibussowitsch   if (A != J) PetscCall(MatDestroy(&A));
9939566063dSJacob Faibussowitsch   PetscCall(MatDestroy(&J));
9949566063dSJacob Faibussowitsch   PetscCall(VecDestroy(&u));
9959566063dSJacob Faibussowitsch   PetscCall(SNESDestroy(&snes));
9969566063dSJacob Faibussowitsch   PetscCall(DMDestroy(&dm));
9979566063dSJacob Faibussowitsch   PetscCall(PetscFree2(user.exactFuncs, user.exactFields));
9989566063dSJacob Faibussowitsch   PetscCall(PetscFree(user.kgrid));
9999566063dSJacob Faibussowitsch   PetscCall(PetscFinalize());
1000b122ec5aSJacob Faibussowitsch   return 0;
1001c4762a1bSJed Brown }
1002c4762a1bSJed Brown 
1003c4762a1bSJed Brown /*TEST
1004c4762a1bSJed Brown   # 2D serial P1 test 0-4
1005c4762a1bSJed Brown   test:
1006c4762a1bSJed Brown     suffix: 2d_p1_0
1007c4762a1bSJed Brown     requires: triangle
100830602db0SMatthew G. Knepley     args: -run_type test -bc_type dirichlet -dm_plex_interpolate 0 -petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1009c4762a1bSJed Brown 
1010c4762a1bSJed Brown   test:
1011c4762a1bSJed Brown     suffix: 2d_p1_1
1012c4762a1bSJed Brown     requires: triangle
101330602db0SMatthew G. Knepley     args: -run_type test -bc_type dirichlet -petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1014c4762a1bSJed Brown 
1015c4762a1bSJed Brown   test:
1016c4762a1bSJed Brown     suffix: 2d_p1_2
1017c4762a1bSJed Brown     requires: triangle
101830602db0SMatthew G. Knepley     args: -run_type test -dm_refine_volume_limit_pre 0.0625 -bc_type dirichlet -petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1019c4762a1bSJed Brown 
1020c4762a1bSJed Brown   test:
1021c4762a1bSJed Brown     suffix: 2d_p1_neumann_0
1022c4762a1bSJed Brown     requires: triangle
102330602db0SMatthew G. Knepley     args: -dm_coord_space 0 -run_type test -bc_type neumann -dm_plex_boundary_label boundary -petscspace_degree 1 -show_initial -dm_plex_print_fem 1 -dm_view ascii::ascii_info_detail
1024c4762a1bSJed Brown 
1025c4762a1bSJed Brown   test:
1026c4762a1bSJed Brown     suffix: 2d_p1_neumann_1
1027c4762a1bSJed Brown     requires: triangle
102830602db0SMatthew G. Knepley     args: -run_type test -dm_refine_volume_limit_pre 0.0625 -bc_type neumann -dm_plex_boundary_label boundary -petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1029c4762a1bSJed Brown 
1030c4762a1bSJed Brown   # 2D serial P2 test 5-8
1031c4762a1bSJed Brown   test:
1032c4762a1bSJed Brown     suffix: 2d_p2_0
1033c4762a1bSJed Brown     requires: triangle
103430602db0SMatthew G. Knepley     args: -run_type test -bc_type dirichlet -petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1035c4762a1bSJed Brown 
1036c4762a1bSJed Brown   test:
1037c4762a1bSJed Brown     suffix: 2d_p2_1
1038c4762a1bSJed Brown     requires: triangle
103930602db0SMatthew G. Knepley     args: -run_type test -dm_refine_volume_limit_pre 0.0625 -bc_type dirichlet -petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1040c4762a1bSJed Brown 
1041c4762a1bSJed Brown   test:
1042c4762a1bSJed Brown     suffix: 2d_p2_neumann_0
1043c4762a1bSJed Brown     requires: triangle
104430602db0SMatthew G. Knepley     args: -dm_coord_space 0 -run_type test -bc_type neumann -dm_plex_boundary_label boundary -petscspace_degree 2 -show_initial -dm_plex_print_fem 1 -dm_view ascii::ascii_info_detail
1045c4762a1bSJed Brown 
1046c4762a1bSJed Brown   test:
1047c4762a1bSJed Brown     suffix: 2d_p2_neumann_1
1048c4762a1bSJed Brown     requires: triangle
104930602db0SMatthew G. Knepley     args: -dm_coord_space 0 -run_type test -dm_refine_volume_limit_pre 0.0625 -bc_type neumann -dm_plex_boundary_label boundary -petscspace_degree 2 -show_initial -dm_plex_print_fem 1 -dm_view ascii::ascii_info_detail
1050c4762a1bSJed Brown 
1051c4762a1bSJed Brown   test:
1052c4762a1bSJed Brown     suffix: bd_int_0
1053c4762a1bSJed Brown     requires: triangle
105430602db0SMatthew G. Knepley     args: -run_type test -bc_type dirichlet -petscspace_degree 2 -bd_integral -dm_view -quiet
1055c4762a1bSJed Brown 
1056c4762a1bSJed Brown   test:
1057c4762a1bSJed Brown     suffix: bd_int_1
1058c4762a1bSJed Brown     requires: triangle
105930602db0SMatthew G. Knepley     args: -run_type test -dm_refine 2 -bc_type dirichlet -petscspace_degree 2 -bd_integral -dm_view -quiet
1060c4762a1bSJed Brown 
1061c4762a1bSJed Brown   # 3D serial P1 test 9-12
1062c4762a1bSJed Brown   test:
1063c4762a1bSJed Brown     suffix: 3d_p1_0
1064c4762a1bSJed Brown     requires: ctetgen
106530602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -bc_type dirichlet -dm_plex_interpolate 0 -petscspace_degree 1 -show_initial -dm_plex_print_fem 1 -dm_view
1066c4762a1bSJed Brown 
1067c4762a1bSJed Brown   test:
1068c4762a1bSJed Brown     suffix: 3d_p1_1
1069c4762a1bSJed Brown     requires: ctetgen
107030602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -bc_type dirichlet -petscspace_degree 1 -show_initial -dm_plex_print_fem 1 -dm_view
1071c4762a1bSJed Brown 
1072c4762a1bSJed Brown   test:
1073c4762a1bSJed Brown     suffix: 3d_p1_2
1074c4762a1bSJed Brown     requires: ctetgen
107530602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -dm_refine_volume_limit_pre 0.0125 -bc_type dirichlet -petscspace_degree 1 -show_initial -dm_plex_print_fem 1 -dm_view
1076c4762a1bSJed Brown 
1077c4762a1bSJed Brown   test:
1078c4762a1bSJed Brown     suffix: 3d_p1_neumann_0
1079c4762a1bSJed Brown     requires: ctetgen
108030602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -bc_type neumann -dm_plex_boundary_label boundary -petscspace_degree 1 -snes_fd -show_initial -dm_plex_print_fem 1 -dm_view
1081c4762a1bSJed Brown 
1082c4762a1bSJed Brown   # Analytic variable coefficient 13-20
1083c4762a1bSJed Brown   test:
1084c4762a1bSJed Brown     suffix: 13
1085c4762a1bSJed Brown     requires: triangle
108630602db0SMatthew G. Knepley     args: -run_type test -variable_coefficient analytic -petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1087c4762a1bSJed Brown   test:
1088c4762a1bSJed Brown     suffix: 14
1089c4762a1bSJed Brown     requires: triangle
109030602db0SMatthew G. Knepley     args: -run_type test -dm_refine_volume_limit_pre 0.0625 -variable_coefficient analytic -petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1091c4762a1bSJed Brown   test:
1092c4762a1bSJed Brown     suffix: 15
1093c4762a1bSJed Brown     requires: triangle
109430602db0SMatthew G. Knepley     args: -run_type test -variable_coefficient analytic -petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1095c4762a1bSJed Brown   test:
1096c4762a1bSJed Brown     suffix: 16
1097c4762a1bSJed Brown     requires: triangle
109830602db0SMatthew G. Knepley     args: -run_type test -dm_refine_volume_limit_pre 0.0625 -variable_coefficient analytic -petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1099c4762a1bSJed Brown   test:
1100c4762a1bSJed Brown     suffix: 17
1101c4762a1bSJed Brown     requires: ctetgen
110230602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -variable_coefficient analytic -petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1103c4762a1bSJed Brown 
1104c4762a1bSJed Brown   test:
1105c4762a1bSJed Brown     suffix: 18
1106c4762a1bSJed Brown     requires: ctetgen
110730602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -dm_refine_volume_limit_pre 0.0125 -variable_coefficient analytic -petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1108c4762a1bSJed Brown 
1109c4762a1bSJed Brown   test:
1110c4762a1bSJed Brown     suffix: 19
1111c4762a1bSJed Brown     requires: ctetgen
111230602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -variable_coefficient analytic -petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1113c4762a1bSJed Brown 
1114c4762a1bSJed Brown   test:
1115c4762a1bSJed Brown     suffix: 20
1116c4762a1bSJed Brown     requires: ctetgen
111730602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -dm_refine_volume_limit_pre 0.0125 -variable_coefficient analytic -petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1118c4762a1bSJed Brown 
1119c4762a1bSJed Brown   # P1 variable coefficient 21-28
1120c4762a1bSJed Brown   test:
1121c4762a1bSJed Brown     suffix: 21
1122c4762a1bSJed Brown     requires: triangle
112330602db0SMatthew G. Knepley     args: -run_type test -variable_coefficient field -petscspace_degree 1 -mat_petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1124c4762a1bSJed Brown 
1125c4762a1bSJed Brown   test:
1126c4762a1bSJed Brown     suffix: 22
1127c4762a1bSJed Brown     requires: triangle
112830602db0SMatthew G. Knepley     args: -run_type test -dm_refine_volume_limit_pre 0.0625 -variable_coefficient field -petscspace_degree 1 -mat_petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1129c4762a1bSJed Brown 
1130c4762a1bSJed Brown   test:
1131c4762a1bSJed Brown     suffix: 23
1132c4762a1bSJed Brown     requires: triangle
113330602db0SMatthew G. Knepley     args: -run_type test -variable_coefficient field -petscspace_degree 2 -mat_petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1134c4762a1bSJed Brown 
1135c4762a1bSJed Brown   test:
1136c4762a1bSJed Brown     suffix: 24
1137c4762a1bSJed Brown     requires: triangle
113830602db0SMatthew G. Knepley     args: -run_type test -dm_refine_volume_limit_pre 0.0625 -variable_coefficient field -petscspace_degree 2 -mat_petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1139c4762a1bSJed Brown 
1140c4762a1bSJed Brown   test:
1141c4762a1bSJed Brown     suffix: 25
1142c4762a1bSJed Brown     requires: ctetgen
114330602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -variable_coefficient field -petscspace_degree 1 -mat_petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1144c4762a1bSJed Brown 
1145c4762a1bSJed Brown   test:
1146c4762a1bSJed Brown     suffix: 26
1147c4762a1bSJed Brown     requires: ctetgen
114830602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -dm_refine_volume_limit_pre 0.0125 -variable_coefficient field -petscspace_degree 1 -mat_petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1149c4762a1bSJed Brown 
1150c4762a1bSJed Brown   test:
1151c4762a1bSJed Brown     suffix: 27
1152c4762a1bSJed Brown     requires: ctetgen
115330602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -variable_coefficient field -petscspace_degree 2 -mat_petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1154c4762a1bSJed Brown 
1155c4762a1bSJed Brown   test:
1156c4762a1bSJed Brown     suffix: 28
1157c4762a1bSJed Brown     requires: ctetgen
115830602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -dm_refine_volume_limit_pre 0.0125 -variable_coefficient field -petscspace_degree 2 -mat_petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1159c4762a1bSJed Brown 
1160c4762a1bSJed Brown   # P0 variable coefficient 29-36
1161c4762a1bSJed Brown   test:
1162c4762a1bSJed Brown     suffix: 29
1163c4762a1bSJed Brown     requires: triangle
116430602db0SMatthew G. Knepley     args: -run_type test -variable_coefficient field -petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1165c4762a1bSJed Brown 
1166c4762a1bSJed Brown   test:
1167c4762a1bSJed Brown     suffix: 30
1168c4762a1bSJed Brown     requires: triangle
116930602db0SMatthew G. Knepley     args: -run_type test -dm_refine_volume_limit_pre 0.0625 -variable_coefficient field -petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1170c4762a1bSJed Brown 
1171c4762a1bSJed Brown   test:
1172c4762a1bSJed Brown     suffix: 31
1173c4762a1bSJed Brown     requires: triangle
117430602db0SMatthew G. Knepley     args: -run_type test -variable_coefficient field -petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1175c4762a1bSJed Brown 
1176c4762a1bSJed Brown   test:
1177c4762a1bSJed Brown     requires: triangle
1178c4762a1bSJed Brown     suffix: 32
117930602db0SMatthew G. Knepley     args: -run_type test -dm_refine_volume_limit_pre 0.0625 -variable_coefficient field -petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1180c4762a1bSJed Brown 
1181c4762a1bSJed Brown   test:
1182c4762a1bSJed Brown     requires: ctetgen
1183c4762a1bSJed Brown     suffix: 33
118430602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -variable_coefficient field -petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1185c4762a1bSJed Brown 
1186c4762a1bSJed Brown   test:
1187c4762a1bSJed Brown     suffix: 34
1188c4762a1bSJed Brown     requires: ctetgen
118930602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -dm_refine_volume_limit_pre 0.0125 -variable_coefficient field -petscspace_degree 1 -show_initial -dm_plex_print_fem 1
1190c4762a1bSJed Brown 
1191c4762a1bSJed Brown   test:
1192c4762a1bSJed Brown     suffix: 35
1193c4762a1bSJed Brown     requires: ctetgen
119430602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -variable_coefficient field -petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1195c4762a1bSJed Brown 
1196c4762a1bSJed Brown   test:
1197c4762a1bSJed Brown     suffix: 36
1198c4762a1bSJed Brown     requires: ctetgen
119930602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -dm_refine_volume_limit_pre 0.0125 -variable_coefficient field -petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1200c4762a1bSJed Brown 
1201c4762a1bSJed Brown   # Full solve 39-44
1202c4762a1bSJed Brown   test:
1203c4762a1bSJed Brown     suffix: 39
1204c4762a1bSJed Brown     requires: triangle !single
1205bae903cbSmarkadams4     args: -run_type full -dm_refine_volume_limit_pre 0.015625 -petscspace_degree 2 -pc_type gamg -pc_gamg_esteig_ksp_type cg -pc_gamg_esteig_ksp_max_it 10 -snes_rtol 1.0e-6 -ksp_rtol 1.0e-7 -ksp_monitor -ksp_converged_reason -snes_monitor_short -snes_converged_reason ::ascii_info_detail
1206c4762a1bSJed Brown   test:
1207c4762a1bSJed Brown     suffix: 40
1208c4762a1bSJed Brown     requires: triangle !single
120930602db0SMatthew G. Knepley     args: -run_type full -dm_refine_volume_limit_pre 0.015625 -variable_coefficient nonlinear -petscspace_degree 2 -pc_type svd -ksp_rtol 1.0e-10 -snes_monitor_short -snes_converged_reason ::ascii_info_detail
1210c4762a1bSJed Brown   test:
1211c4762a1bSJed Brown     suffix: 41
1212c4762a1bSJed Brown     requires: triangle !single
121330602db0SMatthew G. Knepley     args: -run_type full -dm_refine_volume_limit_pre 0.03125 -variable_coefficient nonlinear -petscspace_degree 1 -snes_type fas -snes_fas_levels 2 -fas_coarse_pc_type svd -fas_coarse_ksp_rtol 1.0e-10 -fas_coarse_snes_monitor_short -snes_monitor_short -fas_coarse_snes_linesearch_type basic -snes_converged_reason ::ascii_info_detail -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
1214c4762a1bSJed Brown   test:
1215c4762a1bSJed Brown     suffix: 42
1216c4762a1bSJed Brown     requires: triangle !single
121730602db0SMatthew G. Knepley     args: -run_type full -dm_refine_volume_limit_pre 0.0625 -variable_coefficient nonlinear -petscspace_degree 1 -snes_type fas -snes_fas_levels 3 -fas_coarse_pc_type svd -fas_coarse_ksp_rtol 1.0e-10 -fas_coarse_snes_monitor_short -snes_monitor_short -fas_coarse_snes_linesearch_type basic -snes_converged_reason ::ascii_info_detail -dm_refine_hierarchy 2 -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
1218c4762a1bSJed Brown   test:
1219c4762a1bSJed Brown     suffix: 43
1220c4762a1bSJed Brown     requires: triangle !single
1221c4762a1bSJed Brown     nsize: 2
1222e600fa54SMatthew G. Knepley     args: -run_type full -dm_refine_volume_limit_pre 0.03125 -variable_coefficient nonlinear -petscspace_degree 1 -snes_type fas -snes_fas_levels 2 -fas_coarse_pc_type svd -fas_coarse_ksp_rtol 1.0e-10 -fas_coarse_snes_monitor_short -snes_monitor_short -fas_coarse_snes_linesearch_type basic -snes_converged_reason ::ascii_info_detail -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
1223c4762a1bSJed Brown 
1224c4762a1bSJed Brown   test:
1225c4762a1bSJed Brown     suffix: 44
1226c4762a1bSJed Brown     requires: triangle !single
1227c4762a1bSJed Brown     nsize: 2
1228e600fa54SMatthew G. Knepley     args: -run_type full -dm_refine_volume_limit_pre 0.0625 -variable_coefficient nonlinear -petscspace_degree 1 -snes_type fas -snes_fas_levels 3 -fas_coarse_pc_type svd -fas_coarse_ksp_rtol 1.0e-10 -fas_coarse_snes_monitor_short -snes_monitor_short  -fas_coarse_snes_linesearch_type basic -snes_converged_reason ::ascii_info_detail -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
1229c4762a1bSJed Brown 
1230c4762a1bSJed Brown   # These tests use a loose tolerance just to exercise the PtAP operations for MATIS and multiple PCBDDC setup calls inside PCMG
1231c4762a1bSJed Brown   testset:
1232c4762a1bSJed Brown     requires: triangle !single
1233c4762a1bSJed Brown     nsize: 3
12342b3cbbdaSStefano Zampini     args: -run_type full -petscspace_degree 1 -dm_mat_type is -pc_type mg -mg_coarse_pc_type bddc -pc_mg_galerkin pmat -ksp_rtol 1.0e-2 -snes_converged_reason -dm_refine_hierarchy 2 -snes_max_it 4
1235c4762a1bSJed Brown     test:
1236c4762a1bSJed Brown       suffix: gmg_bddc
1237c4762a1bSJed Brown       filter: sed -e "s/CONVERGED_FNORM_RELATIVE iterations 3/CONVERGED_FNORM_RELATIVE iterations 4/g"
1238c4762a1bSJed Brown       args: -mg_levels_pc_type jacobi
1239c4762a1bSJed Brown     test:
1240c4762a1bSJed Brown       filter: sed -e "s/iterations [0-4]/iterations 4/g"
1241c4762a1bSJed Brown       suffix: gmg_bddc_lev
1242c4762a1bSJed Brown       args: -mg_levels_pc_type bddc
1243c4762a1bSJed Brown 
1244c4762a1bSJed Brown   # Restarting
1245c4762a1bSJed Brown   testset:
1246c4762a1bSJed Brown     suffix: restart
1247c4762a1bSJed Brown     requires: hdf5 triangle !complex
124830602db0SMatthew G. Knepley     args: -run_type test -bc_type dirichlet -petscspace_degree 1
1249c4762a1bSJed Brown     test:
1250c4762a1bSJed Brown       args: -dm_view hdf5:sol.h5 -vec_view hdf5:sol.h5::append
1251c4762a1bSJed Brown     test:
1252cd7e8a5eSksagiyam       args: -dm_plex_filename sol.h5 -dm_plex_name box -restart
1253c4762a1bSJed Brown 
1254c4762a1bSJed Brown   # Periodicity
1255c4762a1bSJed Brown   test:
1256c4762a1bSJed Brown     suffix: periodic_0
1257c4762a1bSJed Brown     requires: triangle
125830602db0SMatthew G. Knepley     args: -run_type full -bc_type dirichlet -petscspace_degree 1 -snes_converged_reason ::ascii_info_detail
1259c4762a1bSJed Brown 
1260c4762a1bSJed Brown   test:
1261c4762a1bSJed Brown     requires: !complex
1262c4762a1bSJed Brown     suffix: periodic_1
126330602db0SMatthew G. Knepley     args: -quiet -run_type test -dm_plex_simplex 0 -dm_plex_box_faces 3,3 -dm_plex_box_bd periodic,periodic -vec_view vtk:test.vtu:vtk_vtu -petscspace_degree 1 -dm_refine 1
1264c4762a1bSJed Brown 
1265c4762a1bSJed Brown   # 2D serial P1 test with field bc
1266c4762a1bSJed Brown   test:
1267c4762a1bSJed Brown     suffix: field_bc_2d_p1_0
1268c4762a1bSJed Brown     requires: triangle
126930602db0SMatthew G. Knepley     args: -run_type test -bc_type dirichlet -field_bc -petscspace_degree 1 -bc_petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1270c4762a1bSJed Brown 
1271c4762a1bSJed Brown   test:
1272c4762a1bSJed Brown     suffix: field_bc_2d_p1_1
1273c4762a1bSJed Brown     requires: triangle
127430602db0SMatthew G. Knepley     args: -run_type test -dm_refine 1 -bc_type dirichlet -field_bc -petscspace_degree 1 -bc_petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1275c4762a1bSJed Brown 
1276c4762a1bSJed Brown   test:
1277c4762a1bSJed Brown     suffix: field_bc_2d_p1_neumann_0
1278c4762a1bSJed Brown     requires: triangle
127930602db0SMatthew G. Knepley     args: -run_type test -bc_type neumann -dm_plex_boundary_label boundary -field_bc -petscspace_degree 1 -bc_petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1280c4762a1bSJed Brown 
1281c4762a1bSJed Brown   test:
1282c4762a1bSJed Brown     suffix: field_bc_2d_p1_neumann_1
1283c4762a1bSJed Brown     requires: triangle
128430602db0SMatthew G. Knepley     args: -run_type test -dm_refine 1 -bc_type neumann -dm_plex_boundary_label boundary -field_bc -petscspace_degree 1 -bc_petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1285c4762a1bSJed Brown 
1286c4762a1bSJed Brown   # 3D serial P1 test with field bc
1287c4762a1bSJed Brown   test:
1288c4762a1bSJed Brown     suffix: field_bc_3d_p1_0
1289c4762a1bSJed Brown     requires: ctetgen
129030602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -bc_type dirichlet -field_bc -petscspace_degree 1 -bc_petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1291c4762a1bSJed Brown 
1292c4762a1bSJed Brown   test:
1293c4762a1bSJed Brown     suffix: field_bc_3d_p1_1
1294c4762a1bSJed Brown     requires: ctetgen
129530602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -dm_refine 1 -bc_type dirichlet -field_bc -petscspace_degree 1 -bc_petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1296c4762a1bSJed Brown 
1297c4762a1bSJed Brown   test:
1298c4762a1bSJed Brown     suffix: field_bc_3d_p1_neumann_0
1299c4762a1bSJed Brown     requires: ctetgen
130030602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -bc_type neumann -dm_plex_boundary_label boundary -field_bc -petscspace_degree 1 -bc_petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1301c4762a1bSJed Brown 
1302c4762a1bSJed Brown   test:
1303c4762a1bSJed Brown     suffix: field_bc_3d_p1_neumann_1
1304c4762a1bSJed Brown     requires: ctetgen
130530602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -dm_refine 1 -bc_type neumann -dm_plex_boundary_label boundary -field_bc -petscspace_degree 1 -bc_petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1306c4762a1bSJed Brown 
1307c4762a1bSJed Brown   # 2D serial P2 test with field bc
1308c4762a1bSJed Brown   test:
1309c4762a1bSJed Brown     suffix: field_bc_2d_p2_0
1310c4762a1bSJed Brown     requires: triangle
131130602db0SMatthew G. Knepley     args: -run_type test -bc_type dirichlet -field_bc -petscspace_degree 2 -bc_petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1312c4762a1bSJed Brown 
1313c4762a1bSJed Brown   test:
1314c4762a1bSJed Brown     suffix: field_bc_2d_p2_1
1315c4762a1bSJed Brown     requires: triangle
131630602db0SMatthew G. Knepley     args: -run_type test -dm_refine 1 -bc_type dirichlet -field_bc -petscspace_degree 2 -bc_petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1317c4762a1bSJed Brown 
1318c4762a1bSJed Brown   test:
1319c4762a1bSJed Brown     suffix: field_bc_2d_p2_neumann_0
1320c4762a1bSJed Brown     requires: triangle
132130602db0SMatthew G. Knepley     args: -run_type test -bc_type neumann -dm_plex_boundary_label boundary -field_bc -petscspace_degree 2 -bc_petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1322c4762a1bSJed Brown 
1323c4762a1bSJed Brown   test:
1324c4762a1bSJed Brown     suffix: field_bc_2d_p2_neumann_1
1325c4762a1bSJed Brown     requires: triangle
132630602db0SMatthew G. Knepley     args: -run_type test -dm_refine 1 -bc_type neumann -dm_plex_boundary_label boundary -field_bc -petscspace_degree 2 -bc_petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1327c4762a1bSJed Brown 
1328c4762a1bSJed Brown   # 3D serial P2 test with field bc
1329c4762a1bSJed Brown   test:
1330c4762a1bSJed Brown     suffix: field_bc_3d_p2_0
1331c4762a1bSJed Brown     requires: ctetgen
133230602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -bc_type dirichlet -field_bc -petscspace_degree 2 -bc_petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1333c4762a1bSJed Brown 
1334c4762a1bSJed Brown   test:
1335c4762a1bSJed Brown     suffix: field_bc_3d_p2_1
1336c4762a1bSJed Brown     requires: ctetgen
133730602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -dm_refine 1 -bc_type dirichlet -field_bc -petscspace_degree 2 -bc_petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1338c4762a1bSJed Brown 
1339c4762a1bSJed Brown   test:
1340c4762a1bSJed Brown     suffix: field_bc_3d_p2_neumann_0
1341c4762a1bSJed Brown     requires: ctetgen
134230602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -bc_type neumann -dm_plex_boundary_label boundary -field_bc -petscspace_degree 2 -bc_petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1343c4762a1bSJed Brown 
1344c4762a1bSJed Brown   test:
1345c4762a1bSJed Brown     suffix: field_bc_3d_p2_neumann_1
1346c4762a1bSJed Brown     requires: ctetgen
134730602db0SMatthew G. Knepley     args: -run_type test -dm_plex_dim 3 -dm_refine 1 -bc_type neumann -dm_plex_boundary_label boundary -field_bc -petscspace_degree 2 -bc_petscspace_degree 2 -show_initial -dm_plex_print_fem 1
1348c4762a1bSJed Brown 
1349c4762a1bSJed Brown   # Full solve simplex: Convergence
1350c4762a1bSJed Brown   test:
13510fdc7489SMatthew Knepley     suffix: 3d_p1_conv
1352c4762a1bSJed Brown     requires: ctetgen
135330602db0SMatthew G. Knepley     args: -run_type full -dm_plex_dim 3 -dm_refine 1 -bc_type dirichlet -petscspace_degree 1 \
13540fdc7489SMatthew Knepley       -snes_convergence_estimate -convest_num_refine 1 -pc_type lu
1355c4762a1bSJed Brown 
1356c4762a1bSJed Brown   # Full solve simplex: PCBDDC
1357c4762a1bSJed Brown   test:
1358c4762a1bSJed Brown     suffix: tri_bddc
1359c4762a1bSJed Brown     requires: triangle !single
1360c4762a1bSJed Brown     nsize: 5
1361e600fa54SMatthew G. Knepley     args: -run_type full -petscpartitioner_type simple -dm_refine 2 -bc_type dirichlet -petscspace_degree 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 ::ascii_info_detail -ksp_converged_reason -snes_view -show_solution 0
1362c4762a1bSJed Brown 
1363c4762a1bSJed Brown   # Full solve simplex: PCBDDC
1364c4762a1bSJed Brown   test:
1365c4762a1bSJed Brown     suffix: tri_parmetis_bddc
1366c4762a1bSJed Brown     requires: triangle !single parmetis
1367c4762a1bSJed Brown     nsize: 4
1368e600fa54SMatthew G. Knepley     args: -run_type full -petscpartitioner_type parmetis -dm_refine 2 -bc_type dirichlet -petscspace_degree 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 ::ascii_info_detail -ksp_converged_reason -snes_view -show_solution 0
1369c4762a1bSJed Brown 
1370c4762a1bSJed Brown   testset:
1371e600fa54SMatthew G. Knepley     args: -run_type full -dm_plex_simplex 0 -dm_plex_box_faces 3,3 -petscpartitioner_type simple -dm_refine 2 -bc_type dirichlet -petscspace_degree 2 -dm_mat_type is -pc_type bddc -ksp_type gmres -snes_monitor_short -ksp_monitor_short -snes_view -petscspace_poly_tensor -pc_bddc_corner_selection -ksp_rtol 1.e-9 -pc_bddc_use_edges 0
1372c4762a1bSJed Brown     nsize: 5
1373c4762a1bSJed Brown     output_file: output/ex12_quad_bddc.out
1374c4762a1bSJed Brown     filter: sed -e "s/aijcusparse/aij/g" -e "s/aijviennacl/aij/g" -e "s/factorization: cusparse/factorization: petsc/g"
1375c4762a1bSJed Brown     test:
1376c4762a1bSJed Brown       requires: !single
1377c4762a1bSJed Brown       suffix: quad_bddc
1378c4762a1bSJed Brown     test:
1379c4762a1bSJed Brown       requires: !single cuda
1380c4762a1bSJed Brown       suffix: quad_bddc_cuda
1381c4762a1bSJed Brown       args: -matis_localmat_type aijcusparse -pc_bddc_dirichlet_pc_factor_mat_solver_type cusparse -pc_bddc_neumann_pc_factor_mat_solver_type cusparse
1382c4762a1bSJed Brown     test:
1383c4762a1bSJed Brown       requires: !single viennacl
1384c4762a1bSJed Brown       suffix: quad_bddc_viennacl
1385c4762a1bSJed Brown       args: -matis_localmat_type aijviennacl
1386c4762a1bSJed Brown 
1387c4762a1bSJed Brown   # Full solve simplex: ASM
1388c4762a1bSJed Brown   test:
1389c4762a1bSJed Brown     suffix: tri_q2q1_asm_lu
1390c4762a1bSJed Brown     requires: triangle !single
139130602db0SMatthew G. Knepley     args: -run_type full -dm_refine 3 -bc_type dirichlet -petscspace_degree 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 ::ascii_info_detail -ksp_converged_reason -snes_view -show_solution 0
1392c4762a1bSJed Brown 
1393c4762a1bSJed Brown   test:
1394c4762a1bSJed Brown     suffix: tri_q2q1_msm_lu
1395c4762a1bSJed Brown     requires: triangle !single
139630602db0SMatthew G. Knepley     args: -run_type full -dm_refine 3 -bc_type dirichlet -petscspace_degree 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 ::ascii_info_detail -ksp_converged_reason -snes_view -show_solution 0
1397c4762a1bSJed Brown 
1398c4762a1bSJed Brown   test:
1399c4762a1bSJed Brown     suffix: tri_q2q1_asm_sor
1400c4762a1bSJed Brown     requires: triangle !single
140130602db0SMatthew G. Knepley     args: -run_type full -dm_refine 3 -bc_type dirichlet -petscspace_degree 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 ::ascii_info_detail -ksp_converged_reason -snes_view -show_solution 0
1402c4762a1bSJed Brown 
1403c4762a1bSJed Brown   test:
1404c4762a1bSJed Brown     suffix: tri_q2q1_msm_sor
1405c4762a1bSJed Brown     requires: triangle !single
140630602db0SMatthew G. Knepley     args: -run_type full -dm_refine 3 -bc_type dirichlet -petscspace_degree 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 ::ascii_info_detail -ksp_converged_reason -snes_view -show_solution 0
1407c4762a1bSJed Brown 
1408c4762a1bSJed Brown   # Full solve simplex: FAS
1409c4762a1bSJed Brown   test:
1410c4762a1bSJed Brown     suffix: fas_newton_0
1411c4762a1bSJed Brown     requires: triangle !single
141230602db0SMatthew G. Knepley     args: -run_type full -variable_coefficient nonlinear -petscspace_degree 1 -snes_type fas -snes_fas_levels 2 -fas_coarse_pc_type svd -fas_coarse_ksp_rtol 1.0e-10 -fas_coarse_snes_monitor_short -snes_monitor_short -fas_coarse_snes_linesearch_type basic -snes_converged_reason ::ascii_info_detail -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
1413c4762a1bSJed Brown 
1414c4762a1bSJed Brown   test:
1415c4762a1bSJed Brown     suffix: fas_newton_1
1416c4762a1bSJed Brown     requires: triangle !single
141730602db0SMatthew G. Knepley     args: -run_type full -dm_refine_hierarchy 3 -petscspace_degree 1 -snes_type fas -snes_fas_levels 3 -fas_coarse_pc_type lu -fas_coarse_snes_monitor_short -snes_monitor_short -fas_coarse_snes_linesearch_type basic -snes_converged_reason ::ascii_info_detail -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
1418c4ef839dSSatish Balay     filter: sed -e "s/total number of linear solver iterations=14/total number of linear solver iterations=15/g"
1419c4762a1bSJed Brown 
1420c4762a1bSJed Brown   test:
1421c4762a1bSJed Brown     suffix: fas_ngs_0
1422c4762a1bSJed Brown     requires: triangle !single
142330602db0SMatthew G. Knepley     args: -run_type full -variable_coefficient nonlinear -petscspace_degree 1 -snes_type fas -snes_fas_levels 2 -fas_coarse_pc_type svd -fas_coarse_ksp_rtol 1.0e-10 -fas_coarse_snes_monitor_short -snes_monitor_short -fas_coarse_snes_linesearch_type basic -snes_converged_reason ::ascii_info_detail -dm_refine_hierarchy 1 -snes_view -fas_levels_1_snes_type ngs -fas_levels_1_snes_monitor_short
1424c4762a1bSJed Brown 
1425071b71afSMatthew G. Knepley   # These two tests are broken because DMPlexComputeInjectorFEM() only works for regularly refined meshes
1426c4762a1bSJed Brown   test:
1427c4762a1bSJed Brown     suffix: fas_newton_coarse_0
1428c4762a1bSJed Brown     requires: pragmatic triangle
1429c4762a1bSJed Brown     TODO: broken
1430071b71afSMatthew G. Knepley     args: -run_type full -variable_coefficient nonlinear -petscspace_degree 1 \
143134b6e994SJoe Wallwork           -dm_refine 2 -dm_coarsen_hierarchy 1 -dm_plex_hash_location -dm_adaptor pragmatic \
1432071b71afSMatthew G. Knepley           -snes_type fas -snes_fas_levels 2 -snes_converged_reason ::ascii_info_detail -snes_monitor_short -snes_view \
1433071b71afSMatthew G. Knepley             -fas_coarse_pc_type svd -fas_coarse_ksp_rtol 1.0e-10 -fas_coarse_snes_monitor_short -fas_coarse_snes_linesearch_type basic \
1434071b71afSMatthew G. Knepley             -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
1435c4762a1bSJed Brown 
1436c4762a1bSJed Brown   test:
1437c4762a1bSJed Brown     suffix: mg_newton_coarse_0
1438c4762a1bSJed Brown     requires: triangle pragmatic
1439c4762a1bSJed Brown     TODO: broken
1440071b71afSMatthew G. Knepley     args: -run_type full -petscspace_degree 1 \
144134b6e994SJoe Wallwork           -dm_refine 3 -dm_coarsen_hierarchy 3 -dm_plex_hash_location -dm_adaptor pragmatic \
1442071b71afSMatthew G. Knepley           -snes_atol 1.0e-8 -snes_rtol 0.0 -snes_monitor_short -snes_converged_reason ::ascii_info_detail -snes_view \
1443071b71afSMatthew G. Knepley             -ksp_type richardson -ksp_atol 1.0e-8 -ksp_rtol 0.0 -ksp_norm_type unpreconditioned -ksp_monitor_true_residual \
1444071b71afSMatthew G. Knepley               -pc_type mg -pc_mg_levels 4 \
1445071b71afSMatthew G. Knepley               -mg_levels_ksp_type gmres -mg_levels_pc_type ilu -mg_levels_ksp_max_it 10
1446c4762a1bSJed Brown 
1447c4762a1bSJed Brown   # Full solve tensor
1448c4762a1bSJed Brown   test:
1449c4762a1bSJed Brown     suffix: tensor_plex_2d
145030602db0SMatthew G. Knepley     args: -run_type test -dm_plex_simplex 0 -bc_type dirichlet -petscspace_degree 1 -dm_refine_hierarchy 2
1451c4762a1bSJed Brown 
1452c4762a1bSJed Brown   test:
1453c4762a1bSJed Brown     suffix: tensor_p4est_2d
1454c4762a1bSJed Brown     requires: p4est
145530602db0SMatthew G. Knepley     args: -run_type test -dm_plex_simplex 0 -bc_type dirichlet -petscspace_degree 1 -dm_forest_initial_refinement 2 -dm_forest_minimum_refinement 0 -dm_plex_convert_type p4est
1456c4762a1bSJed Brown 
1457c4762a1bSJed Brown   test:
1458c4762a1bSJed Brown     suffix: tensor_plex_3d
145930602db0SMatthew G. Knepley     args: -run_type test -dm_plex_simplex 0 -bc_type dirichlet -petscspace_degree 1 -dm_plex_dim 3 -dm_refine_hierarchy 1 -dm_plex_box_faces 2,2,2
1460c4762a1bSJed Brown 
1461c4762a1bSJed Brown   test:
1462c4762a1bSJed Brown     suffix: tensor_p4est_3d
1463c4762a1bSJed Brown     requires: p4est
146430602db0SMatthew G. Knepley     args: -run_type test -dm_plex_simplex 0 -bc_type dirichlet -petscspace_degree 1 -dm_forest_initial_refinement 1 -dm_forest_minimum_refinement 0 -dm_plex_dim 3 -dm_plex_convert_type p8est -dm_plex_box_faces 2,2,2
1465c4762a1bSJed Brown 
1466c4762a1bSJed Brown   test:
1467c4762a1bSJed Brown     suffix: p4est_test_q2_conformal_serial
1468c4762a1bSJed Brown     requires: p4est
146930602db0SMatthew G. Knepley     args: -run_type test -petscspace_degree 2 -dm_plex_simplex 0 -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2
1470c4762a1bSJed Brown 
1471c4762a1bSJed Brown   test:
1472c4762a1bSJed Brown     suffix: p4est_test_q2_conformal_parallel
1473c4762a1bSJed Brown     requires: p4est
1474c4762a1bSJed Brown     nsize: 7
1475e600fa54SMatthew G. Knepley     args: -run_type test -petscspace_degree 2 -dm_plex_simplex 0 -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2 -petscpartitioner_type simple
1476c4762a1bSJed Brown 
1477c4762a1bSJed Brown   test:
1478c4762a1bSJed Brown     suffix: p4est_test_q2_conformal_parallel_parmetis
1479c4762a1bSJed Brown     requires: parmetis p4est
1480c4762a1bSJed Brown     nsize: 4
1481e600fa54SMatthew G. Knepley     args: -run_type test -petscspace_degree 2 -dm_plex_simplex 0 -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2 -petscpartitioner_type parmetis
1482c4762a1bSJed Brown 
1483c4762a1bSJed Brown   test:
1484c4762a1bSJed Brown     suffix: p4est_test_q2_nonconformal_serial
1485c4762a1bSJed Brown     requires: p4est
1486c4762a1bSJed Brown     filter: grep -v "CG or CGNE: variant"
148730602db0SMatthew G. Knepley     args: -run_type test -petscspace_degree 2 -dm_plex_simplex 0 -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
1488c4762a1bSJed Brown 
1489c4762a1bSJed Brown   test:
1490c4762a1bSJed Brown     suffix: p4est_test_q2_nonconformal_parallel
1491c4762a1bSJed Brown     requires: p4est
1492c4762a1bSJed Brown     filter: grep -v "CG or CGNE: variant"
1493c4762a1bSJed Brown     nsize: 7
1494e600fa54SMatthew G. Knepley     args: -run_type test -petscspace_degree 2 -dm_plex_simplex 0 -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
1495c4762a1bSJed Brown 
1496c4762a1bSJed Brown   test:
1497c4762a1bSJed Brown     suffix: p4est_test_q2_nonconformal_parallel_parmetis
1498c4762a1bSJed Brown     requires: parmetis p4est
1499c4762a1bSJed Brown     nsize: 4
1500e600fa54SMatthew G. Knepley     args: -run_type test -petscspace_degree 2 -dm_plex_simplex 0 -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 parmetis
1501c4762a1bSJed Brown 
1502c4762a1bSJed Brown   test:
1503c4762a1bSJed Brown     suffix: p4est_exact_q2_conformal_serial
1504c4762a1bSJed Brown     requires: p4est !single !complex !__float128
150530602db0SMatthew G. Knepley     args: -run_type exact -petscspace_degree 2 -fas_levels_snes_atol 1.e-10 -snes_max_it 1 -snes_type fas -snes_fas_levels 3 -fas_coarse_pc_type none -fas_coarse_ksp_type preonly -fas_coarse_snes_monitor_short -snes_monitor_short -fas_coarse_snes_linesearch_type basic -snes_converged_reason ::ascii_info_detail -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type none -fas_levels_ksp_type preonly -fas_levels_snes_monitor_short -dm_plex_simplex 0 -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2
1506c4762a1bSJed Brown 
1507c4762a1bSJed Brown   test:
1508c4762a1bSJed Brown     suffix: p4est_exact_q2_conformal_parallel
1509c4762a1bSJed Brown     requires: p4est !single !complex !__float128
1510c4762a1bSJed Brown     nsize: 4
1511e600fa54SMatthew G. Knepley     args: -run_type exact -petscspace_degree 2 -fas_levels_snes_atol 1.e-10 -snes_max_it 1 -snes_type fas -snes_fas_levels 3 -fas_coarse_pc_type none -fas_coarse_ksp_type preonly -fas_coarse_snes_monitor_short -snes_monitor_short -fas_coarse_snes_linesearch_type basic -snes_converged_reason ::ascii_info_detail -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type none -fas_levels_ksp_type preonly -fas_levels_snes_monitor_short -dm_plex_simplex 0 -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2
1512c4762a1bSJed Brown 
1513c4762a1bSJed Brown   test:
1514c4762a1bSJed Brown     suffix: p4est_exact_q2_conformal_parallel_parmetis
1515c4762a1bSJed Brown     requires: parmetis p4est !single
1516c4762a1bSJed Brown     nsize: 4
1517e600fa54SMatthew G. Knepley     args: -run_type exact -petscspace_degree 2 -fas_levels_snes_atol 1.e-10 -snes_max_it 1 -snes_type fas -snes_fas_levels 3 -fas_coarse_pc_type none -fas_coarse_ksp_type preonly -fas_coarse_snes_monitor_short -snes_monitor_short -fas_coarse_snes_linesearch_type basic -snes_converged_reason ::ascii_info_detail -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type none -fas_levels_ksp_type preonly -fas_levels_snes_monitor_short -dm_plex_simplex 0 -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 2 -petscpartitioner_type parmetis
1518c4762a1bSJed Brown 
1519c4762a1bSJed Brown   test:
1520c4762a1bSJed Brown     suffix: p4est_exact_q2_nonconformal_serial
1521c4762a1bSJed Brown     requires: p4est
152230602db0SMatthew G. Knepley     args: -run_type exact -petscspace_degree 2 -fas_levels_snes_atol 1.e-10 -snes_max_it 1 -snes_type fas -snes_fas_levels 3 -fas_coarse_pc_type none -fas_coarse_ksp_type preonly -fas_coarse_snes_monitor_short -snes_monitor_short -fas_coarse_snes_linesearch_type basic -snes_converged_reason ::ascii_info_detail -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type none -fas_levels_ksp_type preonly -fas_levels_snes_monitor_short -dm_plex_simplex 0 -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
1523c4762a1bSJed Brown 
1524c4762a1bSJed Brown   test:
1525c4762a1bSJed Brown     suffix: p4est_exact_q2_nonconformal_parallel
1526c4762a1bSJed Brown     requires: p4est
1527c4762a1bSJed Brown     nsize: 7
1528e600fa54SMatthew G. Knepley     args: -run_type exact -petscspace_degree 2 -fas_levels_snes_atol 1.e-10 -snes_max_it 1 -snes_type fas -snes_fas_levels 3 -fas_coarse_pc_type none -fas_coarse_ksp_type preonly -fas_coarse_snes_monitor_short -snes_monitor_short -fas_coarse_snes_linesearch_type basic -snes_converged_reason ::ascii_info_detail -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type none -fas_levels_ksp_type preonly -fas_levels_snes_monitor_short -dm_plex_simplex 0 -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
1529c4762a1bSJed Brown 
1530c4762a1bSJed Brown   test:
1531c4762a1bSJed Brown     suffix: p4est_exact_q2_nonconformal_parallel_parmetis
1532c4762a1bSJed Brown     requires: parmetis p4est
1533c4762a1bSJed Brown     nsize: 4
1534e600fa54SMatthew G. Knepley     args: -run_type exact -petscspace_degree 2 -fas_levels_snes_atol 1.e-10 -snes_max_it 1 -snes_type fas -snes_fas_levels 3 -fas_coarse_pc_type none -fas_coarse_ksp_type preonly -fas_coarse_snes_monitor_short -snes_monitor_short -fas_coarse_snes_linesearch_type basic -snes_converged_reason ::ascii_info_detail -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type none -fas_levels_ksp_type preonly -fas_levels_snes_monitor_short -dm_plex_simplex 0 -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 parmetis
1535c4762a1bSJed Brown 
1536c4762a1bSJed Brown   test:
1537c4762a1bSJed Brown     suffix: p4est_full_q2_nonconformal_serial
1538c4762a1bSJed Brown     requires: p4est !single
1539c4762a1bSJed Brown     filter: grep -v "variant HERMITIAN"
154030602db0SMatthew G. Knepley     args: -run_type full -petscspace_degree 2 -snes_max_it 20 -snes_type fas -snes_fas_levels 3 -fas_coarse_pc_type jacobi -fas_coarse_ksp_type cg -fas_coarse_snes_monitor_short -snes_monitor_short -fas_coarse_snes_linesearch_type basic -snes_converged_reason ::ascii_info_detail -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type jacobi -fas_levels_ksp_type cg -fas_levels_snes_monitor_short -dm_plex_simplex 0 -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
1541c4762a1bSJed Brown 
1542c4762a1bSJed Brown   test:
1543c4762a1bSJed Brown     suffix: p4est_full_q2_nonconformal_parallel
1544c4762a1bSJed Brown     requires: p4est !single
1545c4762a1bSJed Brown     filter: grep -v "variant HERMITIAN"
1546c4762a1bSJed Brown     nsize: 7
1547e600fa54SMatthew G. Knepley     args: -run_type full -petscspace_degree 2 -snes_max_it 20 -snes_type fas -snes_fas_levels 3 -fas_coarse_pc_type jacobi -fas_coarse_ksp_type cg -fas_coarse_snes_monitor_short -snes_monitor_short -fas_coarse_snes_linesearch_type basic -snes_converged_reason ::ascii_info_detail -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type jacobi -fas_levels_ksp_type cg -fas_levels_snes_monitor_short -dm_plex_simplex 0 -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
1548c4762a1bSJed Brown 
1549c4762a1bSJed Brown   test:
1550c4762a1bSJed Brown     suffix: p4est_full_q2_nonconformal_parallel_bddcfas
1551c4762a1bSJed Brown     requires: p4est !single
1552c4762a1bSJed Brown     filter: grep -v "variant HERMITIAN"
1553c4762a1bSJed Brown     nsize: 7
1554e600fa54SMatthew G. Knepley     args: -run_type full -petscspace_degree 2 -snes_max_it 20 -snes_type fas -snes_fas_levels 3 -dm_mat_type is -fas_coarse_pc_type bddc -fas_coarse_ksp_type cg -fas_coarse_snes_monitor_short -snes_monitor_short -fas_coarse_snes_linesearch_type basic -snes_converged_reason ::ascii_info_detail -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type bddc -fas_levels_ksp_type cg -fas_levels_snes_monitor_short -dm_plex_simplex 0 -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
1555c4762a1bSJed Brown 
1556c4762a1bSJed Brown   test:
1557c4762a1bSJed Brown     suffix: p4est_full_q2_nonconformal_parallel_bddc
1558c4762a1bSJed Brown     requires: p4est !single
1559c4762a1bSJed Brown     filter: grep -v "variant HERMITIAN"
1560c4762a1bSJed Brown     nsize: 7
1561e600fa54SMatthew G. Knepley     args: -run_type full -petscspace_degree 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 ::ascii_info_detail -snes_view -dm_plex_simplex 0 -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
1562c4762a1bSJed Brown 
1563c4762a1bSJed Brown   test:
1564c4762a1bSJed Brown     TODO: broken
1565c4762a1bSJed Brown     suffix: p4est_fas_q2_conformal_serial
1566c4762a1bSJed Brown     requires: p4est !complex !__float128
156730602db0SMatthew G. Knepley     args: -run_type full -variable_coefficient nonlinear -petscspace_degree 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 -fas_coarse_snes_linesearch_type basic -snes_converged_reason ::ascii_info_detail -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type svd -fas_levels_ksp_type gmres -fas_levels_snes_monitor_short -dm_plex_simplex 0 -dm_refine_hierarchy 3
1568c4762a1bSJed Brown 
1569c4762a1bSJed Brown   test:
1570c4762a1bSJed Brown     TODO: broken
1571c4762a1bSJed Brown     suffix: p4est_fas_q2_nonconformal_serial
1572c4762a1bSJed Brown     requires: p4est
157330602db0SMatthew G. Knepley     args: -run_type full -variable_coefficient nonlinear -petscspace_degree 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 -fas_coarse_snes_linesearch_type basic -snes_converged_reason ::ascii_info_detail -snes_view -fas_levels_snes_type newtonls -fas_levels_pc_type jacobi -fas_levels_ksp_type gmres -fas_levels_snes_monitor_short -dm_plex_simplex 0 -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
1574c4762a1bSJed Brown 
1575c4762a1bSJed Brown   test:
1576c4762a1bSJed Brown     suffix: fas_newton_0_p4est
1577c4762a1bSJed Brown     requires: p4est !single !__float128
157830602db0SMatthew G. Knepley     args: -run_type full -variable_coefficient nonlinear -petscspace_degree 1 -snes_type fas -snes_fas_levels 2 -fas_coarse_pc_type svd -fas_coarse_ksp_rtol 1.0e-10 -fas_coarse_snes_monitor_short -snes_monitor_short -fas_coarse_snes_linesearch_type basic -snes_converged_reason ::ascii_info_detail -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 -dm_plex_simplex 0 -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
1579c4762a1bSJed Brown 
1580c4762a1bSJed Brown   # Full solve simplicial AMR
1581c4762a1bSJed Brown   test:
1582ab5a7ff4SJoe Wallwork     suffix: tri_p1_adapt_init_pragmatic
1583c4762a1bSJed Brown     requires: pragmatic
15848d1b37daSJoe Wallwork     args: -run_type exact -dm_refine 5 -bc_type dirichlet -petscspace_degree 1 -variable_coefficient ball -snes_converged_reason ::ascii_info_detail -pc_type lu -snes_adapt_initial 1 -adaptor_target_num 4000 -dm_plex_metric_h_max 0.5 -dm_adaptor pragmatic
1585c4762a1bSJed Brown 
1586c4762a1bSJed Brown   test:
15870383c1e7SJoe Wallwork     suffix: tri_p2_adapt_init_pragmatic
15880383c1e7SJoe Wallwork     requires: pragmatic
15890383c1e7SJoe Wallwork     args: -run_type exact -dm_refine 5 -bc_type dirichlet -petscspace_degree 2 -variable_coefficient ball -snes_converged_reason ::ascii_info_detail -pc_type lu -snes_adapt_initial 1 -adaptor_target_num 4000 -dm_plex_metric_h_max 0.5 -dm_adaptor pragmatic
15900383c1e7SJoe Wallwork 
15910383c1e7SJoe Wallwork   test:
1592ab5a7ff4SJoe Wallwork     suffix: tri_p1_adapt_init_mmg
1593ab5a7ff4SJoe Wallwork     requires: mmg
15948d1b37daSJoe Wallwork     args: -run_type exact -dm_refine 5 -bc_type dirichlet -petscspace_degree 1 -variable_coefficient ball -snes_converged_reason ::ascii_info_detail -pc_type lu -snes_adapt_initial 1 -adaptor_target_num 4000 -dm_plex_metric_h_max 0.5 -dm_adaptor mmg
1595c4762a1bSJed Brown 
1596c4762a1bSJed Brown   test:
15970383c1e7SJoe Wallwork     suffix: tri_p2_adapt_init_mmg
15980383c1e7SJoe Wallwork     requires: mmg
15990383c1e7SJoe Wallwork     args: -run_type exact -dm_refine 5 -bc_type dirichlet -petscspace_degree 2 -variable_coefficient ball -snes_converged_reason ::ascii_info_detail -pc_type lu -snes_adapt_initial 1 -adaptor_target_num 4000 -dm_plex_metric_h_max 0.5 -dm_adaptor mmg
16000383c1e7SJoe Wallwork 
16010383c1e7SJoe Wallwork   test:
1602ab5a7ff4SJoe Wallwork     suffix: tri_p1_adapt_seq_pragmatic
1603c4762a1bSJed Brown     requires: pragmatic
16048d1b37daSJoe Wallwork     args: -run_type exact -dm_refine 5 -bc_type dirichlet -petscspace_degree 1 -variable_coefficient ball -snes_converged_reason ::ascii_info_detail -pc_type lu -snes_adapt_sequence 2 -adaptor_target_num 4000 -dm_plex_metric_h_max 0.5 -dm_adaptor pragmatic
1605ab5a7ff4SJoe Wallwork 
1606ab5a7ff4SJoe Wallwork   test:
16070383c1e7SJoe Wallwork     suffix: tri_p2_adapt_seq_pragmatic
16080383c1e7SJoe Wallwork     requires: pragmatic
16090383c1e7SJoe Wallwork     args: -run_type exact -dm_refine 5 -bc_type dirichlet -petscspace_degree 2 -variable_coefficient ball -snes_converged_reason ::ascii_info_detail -pc_type lu -snes_adapt_sequence 2 -adaptor_target_num 4000 -dm_plex_metric_h_max 0.5 -dm_adaptor pragmatic
16100383c1e7SJoe Wallwork 
16110383c1e7SJoe Wallwork   test:
1612ab5a7ff4SJoe Wallwork     suffix: tri_p1_adapt_seq_mmg
1613ab5a7ff4SJoe Wallwork     requires: mmg
16148d1b37daSJoe Wallwork     args: -run_type exact -dm_refine 5 -bc_type dirichlet -petscspace_degree 1 -variable_coefficient ball -snes_converged_reason ::ascii_info_detail -pc_type lu -snes_adapt_sequence 2 -adaptor_target_num 4000 -dm_plex_metric_h_max 0.5 -dm_adaptor mmg
1615ab5a7ff4SJoe Wallwork 
1616ab5a7ff4SJoe Wallwork   test:
16170383c1e7SJoe Wallwork     suffix: tri_p2_adapt_seq_mmg
16180383c1e7SJoe Wallwork     requires: mmg
16190383c1e7SJoe Wallwork     args: -run_type exact -dm_refine 5 -bc_type dirichlet -petscspace_degree 2 -variable_coefficient ball -snes_converged_reason ::ascii_info_detail -pc_type lu -snes_adapt_sequence 2 -adaptor_target_num 4000 -dm_plex_metric_h_max 0.5 -dm_adaptor mmg
16200383c1e7SJoe Wallwork 
16210383c1e7SJoe Wallwork   test:
1622ab5a7ff4SJoe Wallwork     suffix: tri_p1_adapt_analytic_pragmatic
1623ab5a7ff4SJoe Wallwork     requires: pragmatic
1624ab5a7ff4SJoe Wallwork     args: -run_type exact -dm_refine 3 -bc_type dirichlet -petscspace_degree 1 -variable_coefficient cross -snes_adapt_initial 4 -adaptor_target_num 500 -adaptor_monitor -dm_plex_metric_h_min 0.0001 -dm_plex_metric_h_max 0.05 -dm_adaptor pragmatic
1625ab5a7ff4SJoe Wallwork 
1626ab5a7ff4SJoe Wallwork   test:
16270383c1e7SJoe Wallwork     suffix: tri_p2_adapt_analytic_pragmatic
16280383c1e7SJoe Wallwork     requires: pragmatic
16290383c1e7SJoe Wallwork     args: -run_type exact -dm_refine 3 -bc_type dirichlet -petscspace_degree 2 -variable_coefficient cross -snes_adapt_initial 4 -adaptor_target_num 500 -adaptor_monitor -dm_plex_metric_h_min 0.0001 -dm_plex_metric_h_max 0.05 -dm_adaptor pragmatic
16300383c1e7SJoe Wallwork 
16310383c1e7SJoe Wallwork   test:
1632ab5a7ff4SJoe Wallwork     suffix: tri_p1_adapt_analytic_mmg
1633ab5a7ff4SJoe Wallwork     requires: mmg
16348d1b37daSJoe Wallwork     args: -run_type exact -dm_refine 3 -bc_type dirichlet -petscspace_degree 1 -variable_coefficient cross -snes_adapt_initial 4 -adaptor_target_num 500 -adaptor_monitor -dm_plex_metric_h_max 0.5 -dm_adaptor mmg
1635c4762a1bSJed Brown 
1636b8d0c900SJoe Wallwork   test:
16370383c1e7SJoe Wallwork     suffix: tri_p2_adapt_analytic_mmg
16380383c1e7SJoe Wallwork     requires: mmg
16390383c1e7SJoe Wallwork     args: -run_type exact -dm_refine 3 -bc_type dirichlet -petscspace_degree 2 -variable_coefficient cross -snes_adapt_initial 4 -adaptor_target_num 500 -adaptor_monitor -dm_plex_metric_h_max 0.5 -dm_adaptor mmg
16400383c1e7SJoe Wallwork 
16410383c1e7SJoe Wallwork   test:
1642b8d0c900SJoe Wallwork     suffix: tri_p1_adapt_uniform_pragmatic
1643b8d0c900SJoe Wallwork     requires: pragmatic tetgen
1644dc13bed2SJoe Wallwork     nsize: 2
1645e600fa54SMatthew G. Knepley     args: -run_type full -dm_plex_box_faces 8,8,8 -bc_type dirichlet -petscspace_degree 1 -variable_coefficient none -snes_converged_reason ::ascii_info_detail -ksp_type cg -pc_type sor -snes_adapt_sequence 3 -adaptor_target_num 400 -dm_plex_metric_h_max 0.5 -dm_plex_dim 3 -dm_adaptor pragmatic
1646b8d0c900SJoe Wallwork     timeoutfactor: 2
1647b8d0c900SJoe Wallwork 
1648b8d0c900SJoe Wallwork   test:
16490383c1e7SJoe Wallwork     suffix: tri_p2_adapt_uniform_pragmatic
16500383c1e7SJoe Wallwork     requires: pragmatic tetgen
1651dc13bed2SJoe Wallwork     nsize: 2
1652e600fa54SMatthew G. Knepley     args: -run_type full -dm_plex_box_faces 8,8,8 -bc_type dirichlet -petscspace_degree 2 -variable_coefficient none -snes_converged_reason ::ascii_info_detail -ksp_type cg -pc_type sor -snes_adapt_sequence 1 -adaptor_target_num 400 -dm_plex_metric_h_max 0.5 -dm_plex_dim 3 -dm_adaptor pragmatic
16530383c1e7SJoe Wallwork     timeoutfactor: 1
16540383c1e7SJoe Wallwork 
16550383c1e7SJoe Wallwork   test:
1656b8d0c900SJoe Wallwork     suffix: tri_p1_adapt_uniform_mmg
1657b8d0c900SJoe Wallwork     requires: mmg tetgen
16588d1b37daSJoe Wallwork     args: -run_type full -dm_plex_box_faces 4,4,4 -bc_type dirichlet -petscspace_degree 1 -variable_coefficient none -snes_converged_reason ::ascii_info_detail -ksp_type cg -pc_type sor -snes_adapt_sequence 3 -adaptor_target_num 400 -dm_plex_metric_h_max 0.5 -dm_plex_dim 3 -dm_adaptor mmg
1659b8d0c900SJoe Wallwork     timeoutfactor: 2
1660b8d0c900SJoe Wallwork 
1661b8d0c900SJoe Wallwork   test:
16620383c1e7SJoe Wallwork     suffix: tri_p2_adapt_uniform_mmg
16630383c1e7SJoe Wallwork     requires: mmg tetgen
16640383c1e7SJoe Wallwork     args: -run_type full -dm_plex_box_faces 4,4,4 -bc_type dirichlet -petscspace_degree 2 -variable_coefficient none -snes_converged_reason ::ascii_info_detail -ksp_type cg -pc_type sor -snes_adapt_sequence 1 -adaptor_target_num 400 -dm_plex_metric_h_max 0.5 -dm_plex_dim 3 -dm_adaptor mmg
16650383c1e7SJoe Wallwork     timeoutfactor: 1
16660383c1e7SJoe Wallwork 
16670383c1e7SJoe Wallwork   test:
1668b8d0c900SJoe Wallwork     suffix: tri_p1_adapt_uniform_parmmg
1669b8d0c900SJoe Wallwork     requires: parmmg tetgen
1670dc13bed2SJoe Wallwork     nsize: 2
1671e600fa54SMatthew G. Knepley     args: -run_type full -dm_plex_box_faces 8,8,8 -bc_type dirichlet -petscspace_degree 1 -variable_coefficient none -snes_converged_reason ::ascii_info_detail -ksp_type cg -pc_type sor -snes_adapt_sequence 3 -adaptor_target_num 400 -dm_plex_metric_h_max 0.5 -dm_plex_dim 3 -dm_adaptor parmmg
1672b8d0c900SJoe Wallwork     timeoutfactor: 2
1673b8d0c900SJoe Wallwork 
16740383c1e7SJoe Wallwork   test:
16750383c1e7SJoe Wallwork     suffix: tri_p2_adapt_uniform_parmmg
16760383c1e7SJoe Wallwork     requires: parmmg tetgen
1677dc13bed2SJoe Wallwork     nsize: 2
1678e600fa54SMatthew G. Knepley     args: -run_type full -dm_plex_box_faces 8,8,8 -bc_type dirichlet -petscspace_degree 2 -variable_coefficient none -snes_converged_reason ::ascii_info_detail -ksp_type cg -pc_type sor -snes_adapt_sequence 1 -adaptor_target_num 400 -dm_plex_metric_h_max 0.5 -dm_plex_dim 3 -dm_adaptor parmmg
16790383c1e7SJoe Wallwork     timeoutfactor: 1
16800383c1e7SJoe Wallwork 
1681c4762a1bSJed Brown   # Full solve tensor AMR
1682c4762a1bSJed Brown   test:
1683c4762a1bSJed Brown     suffix: quad_q1_adapt_0
1684c4762a1bSJed Brown     requires: p4est
16858d1b37daSJoe Wallwork     args: -run_type exact -dm_plex_simplex 0 -dm_plex_convert_type p4est -bc_type dirichlet -petscspace_degree 1 -variable_coefficient ball -snes_converged_reason ::ascii_info_detail -pc_type lu -dm_forest_initial_refinement 4 -snes_adapt_initial 1 -dm_view
1686c4762a1bSJed Brown     filter: grep -v DM_
1687c4762a1bSJed Brown 
1688c4762a1bSJed Brown   test:
1689c4762a1bSJed Brown     suffix: amr_0
1690c4762a1bSJed Brown     nsize: 5
1691e600fa54SMatthew G. Knepley     args: -run_type test -petscpartitioner_type simple -dm_plex_simplex 0 -bc_type dirichlet -petscspace_degree 1 -dm_refine 1
1692c4762a1bSJed Brown 
1693c4762a1bSJed Brown   test:
1694c4762a1bSJed Brown     suffix: amr_1
1695c4762a1bSJed Brown     requires: p4est !complex
169630602db0SMatthew G. Knepley     args: -run_type test -dm_plex_simplex 0 -bc_type dirichlet -petscspace_degree 1 -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
1697c4762a1bSJed Brown 
1698c4762a1bSJed Brown   test:
1699c4762a1bSJed Brown     suffix: p4est_solve_bddc
1700c4762a1bSJed Brown     requires: p4est !complex
1701e600fa54SMatthew G. Knepley     args: -run_type full -variable_coefficient nonlinear -nonzero_initial_guess 1 -petscspace_degree 2 -snes_max_it 20 -snes_type newtonls -dm_mat_type is -pc_type bddc -ksp_type cg -snes_monitor_short -ksp_monitor -snes_linesearch_type bt -snes_converged_reason -snes_view -dm_plex_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 -pc_bddc_detect_disconnected
1702c4762a1bSJed Brown     nsize: 4
1703c4762a1bSJed Brown 
1704c4762a1bSJed Brown   test:
1705c4762a1bSJed Brown     suffix: p4est_solve_fas
1706c4762a1bSJed Brown     requires: p4est
1707e600fa54SMatthew G. Knepley     args: -run_type full -variable_coefficient nonlinear -nonzero_initial_guess 1 -petscspace_degree 2 -snes_max_it 10 -snes_type fas -snes_linesearch_type bt -snes_fas_levels 3 -fas_coarse_snes_type newtonls -fas_coarse_snes_linesearch_type basic -fas_coarse_ksp_type cg -fas_coarse_pc_type jacobi -fas_coarse_snes_monitor_short -fas_levels_snes_max_it 4 -fas_levels_snes_type newtonls -fas_levels_snes_linesearch_type bt -fas_levels_ksp_type cg -fas_levels_pc_type jacobi -fas_levels_snes_monitor_short -fas_levels_cycle_snes_linesearch_type bt -snes_monitor_short -snes_converged_reason -snes_view -dm_plex_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
1708c4762a1bSJed Brown     nsize: 4
1709c4762a1bSJed Brown     TODO: identical machine two runs produce slightly different solver trackers
1710c4762a1bSJed Brown 
1711c4762a1bSJed Brown   test:
1712c4762a1bSJed Brown     suffix: p4est_convergence_test_1
1713c4762a1bSJed Brown     requires: p4est
1714e600fa54SMatthew G. Knepley     args:  -quiet -run_type test -petscspace_degree 1 -dm_plex_simplex 0 -petscspace_poly_tensor -dm_plex_convert_type p4est -dm_forest_minimum_refinement 2 -dm_forest_initial_refinement 2 -dm_forest_maximum_refinement 4 -dm_p4est_refine_pattern hash
1715c4762a1bSJed Brown     nsize: 4
1716c4762a1bSJed Brown 
1717c4762a1bSJed Brown   test:
1718c4762a1bSJed Brown     suffix: p4est_convergence_test_2
1719c4762a1bSJed Brown     requires: p4est
172030602db0SMatthew G. Knepley     args: -quiet -run_type test -petscspace_degree 1 -dm_plex_simplex 0 -petscspace_poly_tensor -dm_plex_convert_type p4est -dm_forest_minimum_refinement 3 -dm_forest_initial_refinement 3 -dm_forest_maximum_refinement 5 -dm_p4est_refine_pattern hash
1721c4762a1bSJed Brown 
1722c4762a1bSJed Brown   test:
1723c4762a1bSJed Brown     suffix: p4est_convergence_test_3
1724c4762a1bSJed Brown     requires: p4est
172530602db0SMatthew G. Knepley     args: -quiet -run_type test -petscspace_degree 1 -dm_plex_simplex 0 -petscspace_poly_tensor -dm_plex_convert_type p4est -dm_forest_minimum_refinement 4 -dm_forest_initial_refinement 4 -dm_forest_maximum_refinement 6 -dm_p4est_refine_pattern hash
1726c4762a1bSJed Brown 
1727c4762a1bSJed Brown   test:
1728c4762a1bSJed Brown     suffix: p4est_convergence_test_4
1729c4762a1bSJed Brown     requires: p4est
173030602db0SMatthew G. Knepley     args: -quiet -run_type test -petscspace_degree 1 -dm_plex_simplex 0 -petscspace_poly_tensor -dm_plex_convert_type p4est -dm_forest_minimum_refinement 5 -dm_forest_initial_refinement 5 -dm_forest_maximum_refinement 7 -dm_p4est_refine_pattern hash
1731c4762a1bSJed Brown     timeoutfactor: 5
1732c4762a1bSJed Brown 
1733c4762a1bSJed Brown   # Serial tests with GLVis visualization
1734c4762a1bSJed Brown   test:
1735c4762a1bSJed Brown     suffix: glvis_2d_tet_p1
173630602db0SMatthew G. Knepley     args: -quiet -run_type test -bc_type dirichlet -petscspace_degree 1 -vec_view glvis: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/square_periodic.msh -dm_plex_boundary_label marker -dm_plex_gmsh_periodic 0 -dm_coord_space 0
1737c4762a1bSJed Brown   test:
1738c4762a1bSJed Brown     suffix: glvis_2d_tet_p2
173930602db0SMatthew G. Knepley     args: -quiet -run_type test -bc_type dirichlet -petscspace_degree 2 -vec_view glvis: -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/square_periodic.msh -dm_plex_boundary_label marker -dm_plex_gmsh_periodic 0 -dm_coord_space 0
1740c4762a1bSJed Brown   test:
1741c4762a1bSJed Brown     suffix: glvis_2d_hex_p1
174230602db0SMatthew G. Knepley     args: -quiet -run_type test -bc_type dirichlet -petscspace_degree 1 -vec_view glvis: -dm_plex_simplex 0 -dm_refine 1 -dm_coord_space 0
1743c4762a1bSJed Brown   test:
1744c4762a1bSJed Brown     suffix: glvis_2d_hex_p2
174530602db0SMatthew G. Knepley     args: -quiet -run_type test -bc_type dirichlet -petscspace_degree 2 -vec_view glvis: -dm_plex_simplex 0 -dm_refine 1 -dm_coord_space 0
1746c4762a1bSJed Brown   test:
1747c4762a1bSJed Brown     suffix: glvis_2d_hex_p2_p4est
1748c4762a1bSJed Brown     requires: p4est
174930602db0SMatthew G. Knepley     args: -quiet -run_type test -bc_type dirichlet -petscspace_degree 2 -vec_view glvis: -dm_plex_simplex 0 -dm_plex_convert_type p4est -dm_forest_minimum_refinement 0 -dm_forest_initial_refinement 1 -dm_forest_maximum_refinement 4 -dm_p4est_refine_pattern hash -viewer_glvis_dm_plex_enable_ncmesh
1750c4762a1bSJed Brown   test:
1751c4762a1bSJed Brown     suffix: glvis_2d_tet_p0
175230602db0SMatthew G. Knepley     args: -run_type exact -guess_vec_view glvis: -nonzero_initial_guess 1 -dm_plex_filename ${wPETSC_DIR}/share/petsc/datafiles/meshes/square_periodic.msh -dm_plex_boundary_label marker -petscspace_degree 0 -dm_coord_space 0
1753c4762a1bSJed Brown   test:
1754c4762a1bSJed Brown     suffix: glvis_2d_hex_p0
175530602db0SMatthew G. Knepley     args: -run_type exact -guess_vec_view glvis: -nonzero_initial_guess 1 -dm_plex_box_faces 5,7 -dm_plex_simplex 0 -petscspace_degree 0 -dm_coord_space 0
1756c4762a1bSJed Brown 
1757c4762a1bSJed Brown   # PCHPDDM tests
1758c4762a1bSJed Brown   testset:
1759c4762a1bSJed Brown     nsize: 4
1760dfd57a17SPierre Jolivet     requires: hpddm slepc !single defined(PETSC_HAVE_DYNAMIC_LIBRARIES) defined(PETSC_USE_SHARED_LIBRARIES)
1761e600fa54SMatthew G. Knepley     args: -run_type test -run_test_check_ksp -quiet -petscspace_degree 1 -petscpartitioner_type simple -bc_type none -dm_plex_simplex 0 -pc_type hpddm -pc_hpddm_levels_1_sub_pc_type lu -pc_hpddm_levels_1_eps_nev 2 -pc_hpddm_coarse_p 1 -pc_hpddm_coarse_pc_type svd -ksp_rtol 1.e-10 -pc_hpddm_levels_1_st_pc_factor_shift_type INBLOCKS -ksp_converged_reason
1762c4762a1bSJed Brown     test:
1763c4762a1bSJed Brown       suffix: quad_singular_hpddm
176430602db0SMatthew G. Knepley       args: -dm_plex_box_faces 6,7
1765c4762a1bSJed Brown     test:
1766c4762a1bSJed Brown       requires: p4est
1767c4762a1bSJed Brown       suffix: p4est_singular_2d_hpddm
1768c4762a1bSJed Brown       args: -dm_plex_convert_type p4est -dm_forest_minimum_refinement 1 -dm_forest_initial_refinement 3 -dm_forest_maximum_refinement 3
1769c4762a1bSJed Brown     test:
1770c4762a1bSJed Brown       requires: p4est
1771c4762a1bSJed Brown       suffix: p4est_nc_singular_2d_hpddm
1772c4762a1bSJed Brown       args: -dm_plex_convert_type p4est -dm_forest_minimum_refinement 1 -dm_forest_initial_refinement 1 -dm_forest_maximum_refinement 3 -dm_p4est_refine_pattern hash
1773c4762a1bSJed Brown   testset:
1774c4762a1bSJed Brown     nsize: 4
1775dfd57a17SPierre Jolivet     requires: hpddm slepc triangle !single defined(PETSC_HAVE_DYNAMIC_LIBRARIES) defined(PETSC_USE_SHARED_LIBRARIES)
1776e600fa54SMatthew G. Knepley     args: -run_type full -petscpartitioner_type simple -dm_refine 2 -bc_type dirichlet -petscspace_degree 2 -ksp_type gmres -ksp_gmres_restart 100 -pc_type hpddm -snes_monitor_short -ksp_monitor_short -snes_converged_reason ::ascii_info_detail -ksp_converged_reason -snes_view -show_solution 0 -pc_type hpddm -pc_hpddm_levels_1_sub_pc_type lu -pc_hpddm_levels_1_eps_nev 4 -pc_hpddm_coarse_p 2 -pc_hpddm_coarse_pc_type redundant -ksp_rtol 1.e-1
1777c4762a1bSJed Brown     test:
1778c4762a1bSJed Brown       args: -pc_hpddm_coarse_mat_type baij -options_left no
1779c4762a1bSJed Brown       suffix: tri_hpddm_reuse_baij
1780c4762a1bSJed Brown     test:
1781c4762a1bSJed Brown       requires: !complex
1782c4762a1bSJed Brown       suffix: tri_hpddm_reuse
1783c4762a1bSJed Brown   testset:
1784c4762a1bSJed Brown     nsize: 4
1785dfd57a17SPierre Jolivet     requires: hpddm slepc !single defined(PETSC_HAVE_DYNAMIC_LIBRARIES) defined(PETSC_USE_SHARED_LIBRARIES)
1786e600fa54SMatthew G. Knepley     args: -run_type full -petscpartitioner_type simple -dm_plex_box_faces 7,5 -dm_refine 2 -dm_plex_simplex 0 -bc_type dirichlet -petscspace_degree 2 -ksp_type gmres -ksp_gmres_restart 100 -pc_type hpddm -snes_monitor_short -ksp_monitor_short -snes_converged_reason ::ascii_info_detail -ksp_converged_reason -snes_view -show_solution 0 -pc_type hpddm -pc_hpddm_levels_1_sub_pc_type lu -pc_hpddm_levels_1_eps_nev 4 -pc_hpddm_coarse_p 2 -pc_hpddm_coarse_pc_type redundant -ksp_rtol 1.e-1
1787c4762a1bSJed Brown     test:
1788c4762a1bSJed Brown       args: -pc_hpddm_coarse_mat_type baij -options_left no
1789c4762a1bSJed Brown       suffix: quad_hpddm_reuse_baij
1790c4762a1bSJed Brown     test:
1791c4762a1bSJed Brown       requires: !complex
1792c4762a1bSJed Brown       suffix: quad_hpddm_reuse
1793c4762a1bSJed Brown   testset:
1794c4762a1bSJed Brown     nsize: 4
1795dfd57a17SPierre Jolivet     requires: hpddm slepc !single defined(PETSC_HAVE_DYNAMIC_LIBRARIES) defined(PETSC_USE_SHARED_LIBRARIES)
1796e600fa54SMatthew G. Knepley     args: -run_type full -petscpartitioner_type simple -dm_plex_box_faces 7,5 -dm_refine 2 -dm_plex_simplex 0 -bc_type dirichlet -petscspace_degree 1 -ksp_type gmres -ksp_gmres_restart 100 -pc_type hpddm -snes_monitor_short -ksp_monitor_short -snes_converged_reason ::ascii_info_detail -ksp_converged_reason -snes_view -show_solution 0 -pc_type hpddm -pc_hpddm_levels_1_sub_pc_type lu -pc_hpddm_levels_1_eps_threshold 0.1 -pc_hpddm_coarse_p 2 -pc_hpddm_coarse_pc_type redundant -ksp_rtol 1.e-1
1797c4762a1bSJed Brown     test:
1798c4762a1bSJed Brown       args: -pc_hpddm_coarse_mat_type baij -options_left no
1799c4762a1bSJed Brown       suffix: quad_hpddm_reuse_threshold_baij
1800c4762a1bSJed Brown     test:
1801c4762a1bSJed Brown       requires: !complex
1802c4762a1bSJed Brown       suffix: quad_hpddm_reuse_threshold
1803c4762a1bSJed Brown   testset:
1804c4762a1bSJed Brown     nsize: 4
1805dfd57a17SPierre Jolivet     requires: hpddm slepc parmetis !single defined(PETSC_HAVE_DYNAMIC_LIBRARIES) defined(PETSC_USE_SHARED_LIBRARIES)
1806117ef88eSStefano Zampini     filter: sed -e "s/linear solver iterations=17/linear solver iterations=16/g"
1807e600fa54SMatthew G. Knepley     args: -run_type full -petscpartitioner_type parmetis -dm_refine 3 -bc_type dirichlet -petscspace_degree 1 -ksp_type gmres -ksp_gmres_restart 100 -pc_type hpddm -snes_monitor_short -snes_converged_reason ::ascii_info_detail -snes_view -show_solution 0 -pc_type hpddm -pc_hpddm_levels_1_sub_pc_type icc -pc_hpddm_levels_1_eps_nev 20 -pc_hpddm_coarse_p 2 -pc_hpddm_coarse_pc_type redundant -ksp_rtol 1.e-10 -dm_plex_filename ${PETSC_DIR}/share/petsc/datafiles/meshes/square_periodic.msh -dm_plex_boundary_label marker -pc_hpddm_levels_1_sub_pc_factor_levels 3 -variable_coefficient ball -dm_plex_gmsh_periodic 0
1808c4762a1bSJed Brown     test:
1809c4762a1bSJed Brown       args: -pc_hpddm_coarse_mat_type baij -options_left no
18106ba0327bSPierre Jolivet       filter: grep -v "      total: nonzeros=" | grep -v "      rows=" | sed -e "s/total number of linear solver iterations=1[5-7]/total number of linear solver iterations=16/g"
1811c4762a1bSJed Brown       suffix: tri_parmetis_hpddm_baij
1812c4762a1bSJed Brown     test:
18136ba0327bSPierre Jolivet       filter: grep -v "      total: nonzeros=" | grep -v "      rows=" | sed -e "s/total number of linear solver iterations=1[5-7]/total number of linear solver iterations=16/g"
1814c4762a1bSJed Brown       requires: !complex
1815c4762a1bSJed Brown       suffix: tri_parmetis_hpddm
1816d6837840SMatthew G. Knepley 
1817d6837840SMatthew G. Knepley   # 2D serial P1 tests for adaptive MG
1818d6837840SMatthew G. Knepley   test:
1819d6837840SMatthew G. Knepley     suffix: 2d_p1_adaptmg_0
18202b3cbbdaSStefano Zampini     requires: triangle
1821908b9b43SStefano Zampini     args: -petscpartitioner_type simple -dm_refine_hierarchy 3 -dm_plex_box_faces 4,4 -bc_type dirichlet -petscspace_degree 1 \
1822d6837840SMatthew G. Knepley           -variable_coefficient checkerboard_0 -mat_petscspace_degree 0 -div 16 -k 3 \
1823d6837840SMatthew G. Knepley           -snes_max_it 1 -ksp_converged_reason \
1824d6837840SMatthew G. Knepley           -ksp_rtol 1e-8 -pc_type mg
1825d6837840SMatthew G. Knepley   test:
1826d6837840SMatthew G. Knepley     suffix: 2d_p1_adaptmg_1
1827908b9b43SStefano Zampini     requires: triangle bamg todo
1828908b9b43SStefano Zampini     args: -petscpartitioner_type simple -dm_refine_hierarchy 3 -dm_plex_box_faces 4,4 -bc_type dirichlet -petscspace_degree 1 \
1829d6837840SMatthew G. Knepley           -variable_coefficient checkerboard_0 -mat_petscspace_degree 0 -div 16 -k 3 \
1830d6837840SMatthew G. Knepley           -snes_max_it 1 -ksp_converged_reason \
18312b3cbbdaSStefano Zampini           -ksp_rtol 1e-8 -pc_type mg -pc_mg_galerkin -pc_mg_adapt_interp_coarse_space eigenvector -pc_mg_adapt_interp_n 1 \
1832d6837840SMatthew G. Knepley             -pc_mg_mesp_ksp_type richardson -pc_mg_mesp_ksp_richardson_self_scale -pc_mg_mesp_ksp_max_it 100 -pc_mg_mesp_pc_type none
1833908b9b43SStefano Zampini   test:
1834908b9b43SStefano Zampini     suffix: 2d_p1_adaptmg_gdsw
1835908b9b43SStefano Zampini     requires: triangle
1836908b9b43SStefano Zampini     nsize: 4
1837908b9b43SStefano Zampini     args: -petscpartitioner_type simple -dm_refine 3 -dm_plex_box_faces 4,4 -bc_type dirichlet -petscspace_degree 1 \
1838908b9b43SStefano Zampini           -variable_coefficient checkerboard_0 -mat_petscspace_degree 0 -div 16 -k 3 \
1839908b9b43SStefano Zampini           -snes_max_it 1 -ksp_converged_reason \
1840908b9b43SStefano Zampini           -ksp_rtol 1e-8 -pc_type mg -pc_mg_galerkin -pc_mg_adapt_interp_coarse_space gdsw -pc_mg_levels 2 -mg_levels_pc_type asm -dm_mat_type {{aij is}}
1841908b9b43SStefano Zampini 
1842908b9b43SStefano Zampini   test:
1843908b9b43SStefano Zampini     suffix: 2d_p1_adaptmg_agdsw
1844908b9b43SStefano Zampini     requires: triangle mumps
1845908b9b43SStefano Zampini     nsize: 4
1846908b9b43SStefano Zampini     args: -petscpartitioner_type simple -dm_refine 3 -dm_plex_box_faces 4,4 -bc_type dirichlet -petscspace_degree 1 \
1847908b9b43SStefano Zampini           -variable_coefficient checkerboard_0 -mat_petscspace_degree 0 -div 16 -k 3 \
1848908b9b43SStefano Zampini           -snes_max_it 1 -ksp_converged_reason \
1849908b9b43SStefano Zampini           -ksp_rtol 1e-8 -pc_type mg -pc_mg_galerkin -pc_mg_adapt_interp_coarse_space gdsw -pc_mg_levels 2 -mg_levels_pc_type asm -dm_mat_type is -mg_levels_gdsw_tolerance 0.1 -mg_levels_gdsw_pseudo_pc_type qr
1850d6837840SMatthew G. Knepley 
1851c4762a1bSJed Brown TEST*/
1852