xref: /petsc/src/snes/tutorials/ex24.c (revision 40badf4fbc550ac1f60bd080eaff6de6d55b946d)
1 static char help[] = "Poisson Problem in mixed form with 2d and 3d with finite elements.\n\
2 We solve the Poisson problem in a rectangular\n\
3 domain, using a parallel unstructured mesh (DMPLEX) to discretize it.\n\
4 This example supports automatic convergence estimation\n\
5 and Hdiv elements.\n\n\n";
6 
7 /*
8 
9 The mixed form of Poisson's equation, e.g. https://firedrakeproject.org/demos/poisson_mixed.py.html, is given
10 in the strong form by
11 \begin{align}
12   \vb{q} - \nabla u   &= 0 \\
13   \nabla \cdot \vb{q} &= f
14 \end{align}
15 where $u$ is the potential, as in the original problem, but we also discretize the gradient of potential $\vb{q}$,
16 or flux, directly. The weak form is then
17 \begin{align}
18   <t, \vb{q}> + <\nabla \cdot t, u> - <t_n, u>_\Gamma &= 0 \\
19   <v, \nabla \cdot \vb{q}> &= <v, f>
20 \end{align}
21 For the original Poisson problem, the Dirichlet boundary forces an essential boundary condition on the potential space,
22 and the Neumann boundary gives a natural boundary condition in the weak form. In the mixed formulation, the Neumann
23 boundary gives an essential boundary condition on the flux space, $\vb{q} \cdot \vu{n} = h$, and the Dirichlet condition
24 becomes a natural condition in the weak form, <t_n, g>_\Gamma.
25 */
26 
27 #include <petscdmplex.h>
28 #include <petscsnes.h>
29 #include <petscds.h>
30 #include <petscconvest.h>
31 
32 typedef enum {SOL_LINEAR, SOL_QUADRATIC, SOL_QUARTIC, SOL_QUARTIC_NEUMANN, SOL_UNKNOWN, NUM_SOLTYPE} SolType;
33 const char *SolTypeNames[NUM_SOLTYPE+3] = {"linear", "quadratic", "quartic", "quartic_neumann", "unknown", "SolType", "SOL_", NULL};
34 
35 typedef struct {
36   SolType solType; /* The type of exact solution */
37 } AppCtx;
38 
39 static void f0_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
40                  const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
41                  const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
42                  PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
43 {
44   PetscInt d;
45   for (d = 0; d < dim; ++d) f0[0] += u_x[uOff_x[0]+d*dim+d];
46 }
47 
48 /* 2D Dirichlet potential example
49 
50   u = x
51   q = <1, 0>
52   f = 0
53 
54   We will need a boundary integral of u over \Gamma.
55 */
56 static PetscErrorCode linear_u(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
57 {
58   u[0] = x[0];
59   return 0;
60 }
61 static PetscErrorCode linear_q(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
62 {
63   PetscInt c;
64   for (c = 0; c < Nc; ++c) u[c] = c ? 0.0 : 1.0;
65   return 0;
66 }
67 
68 static void f0_linear_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
69                         const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
70                         const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
71                         PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
72 {
73   f0[0] = 0.0;
74   f0_u(dim, Nf, NfAux, uOff, uOff_x, u, u_t, u_x, aOff, aOff_x, a, a_t, a_x, t, x, numConstants, constants, f0);
75 }
76 static void f0_bd_linear_q(PetscInt dim, PetscInt Nf, PetscInt NfAux,
77                            const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
78                            const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
79                            PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
80 {
81   PetscScalar potential;
82   PetscInt    d;
83 
84   linear_u(dim, t, x, dim, &potential, NULL);
85   for (d = 0; d < dim; ++d) f0[d] = -potential*n[d];
86 }
87 
88 /* 2D Dirichlet potential example
89 
90   u = x^2 + y^2
91   q = <2x, 2y>
92   f = 4
93 
94   We will need a boundary integral of u over \Gamma.
95 */
96 static PetscErrorCode quadratic_u(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
97 {
98   PetscInt d;
99 
100   u[0] = 0.0;
101   for (d = 0; d < dim; ++d) u[0] += x[d]*x[d];
102   return 0;
103 }
104 static PetscErrorCode quadratic_q(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
105 {
106   PetscInt c;
107   for (c = 0; c < Nc; ++c) u[c] = 2.0*x[c];
108   return 0;
109 }
110 
111 static void f0_quadratic_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
112                            const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
113                            const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
114                            PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
115 {
116   f0[0] = -4.0;
117   f0_u(dim, Nf, NfAux, uOff, uOff_x, u, u_t, u_x, aOff, aOff_x, a, a_t, a_x, t, x, numConstants, constants, f0);
118 }
119 static void f0_bd_quadratic_q(PetscInt dim, PetscInt Nf, PetscInt NfAux,
120                               const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
121                               const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
122                               PetscReal t, const PetscReal x[], const PetscReal n[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
123 {
124   PetscScalar potential;
125   PetscInt    d;
126 
127   quadratic_u(dim, t, x, dim, &potential, NULL);
128   for (d = 0; d < dim; ++d) f0[d] = -potential*n[d];
129 }
130 
131 /* 2D Dirichlet potential example
132 
133   u = x (1-x) y (1-y)
134   q = <(1-2x) y (1-y), x (1-x) (1-2y)>
135   f = -y (1-y) - x (1-x)
136 
137   u|_\Gamma = 0 so that the boundary integral vanishes
138 */
139 static PetscErrorCode quartic_u(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
140 {
141   PetscInt d;
142 
143   u[0] = 1.0;
144   for (d = 0; d < dim; ++d) u[0] *= x[d]*(1.0 - x[d]);
145   return 0;
146 }
147 static PetscErrorCode quartic_q(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nc, PetscScalar *u, void *ctx)
148 {
149   PetscInt c, d;
150 
151   for (c = 0; c < Nc; ++c) {
152     u[c] = 1.0;
153     for (d = 0; d < dim; ++d) {
154       if (c == d) u[c] *= 1 - 2.0*x[d];
155       else        u[c] *= x[d]*(1.0 - x[d]);
156     }
157   }
158   return 0;
159 }
160 
161 static void f0_quartic_u(PetscInt dim, PetscInt Nf, PetscInt NfAux,
162                         const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
163                         const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
164                         PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
165 {
166   PetscInt d;
167   f0[0] = 0.0;
168   for (d = 0; d < dim; ++d) f0[0] += 2.0*x[d]*(1.0 - x[d]);
169   f0_u(dim, Nf, NfAux, uOff, uOff_x, u, u_t, u_x, aOff, aOff_x, a, a_t, a_x, t, x, numConstants, constants, f0);
170 }
171 
172 /* 2D Dirichlet potential example
173 
174   u = x (1-x) y (1-y)
175   q = <(1-2x) y (1-y), x (1-x) (1-2y)>
176   f = -y (1-y) - x (1-x)
177 
178   du/dn_\Gamma = {(1-2x) y (1-y), x (1-x) (1-2y)} . n produces an essential condition on q
179 */
180 
181 static void f0_q(PetscInt dim, PetscInt Nf, PetscInt NfAux,
182                  const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
183                  const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
184                  PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f0[])
185 {
186   PetscInt c;
187   for (c = 0; c < dim; ++c) f0[c] = u[uOff[0]+c];
188 }
189 
190 /* <\nabla\cdot w, u> = <\nabla w, Iu> */
191 static void f1_q(PetscInt dim, PetscInt Nf, PetscInt NfAux,
192                  const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
193                  const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
194                  PetscReal t, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar f1[])
195 {
196   PetscInt c;
197   for (c = 0; c < dim; ++c) f1[c*dim+c] = u[uOff[1]];
198 }
199 
200 /* <t, q> */
201 static void g0_qq(PetscInt dim, PetscInt Nf, PetscInt NfAux,
202                   const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
203                   const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
204                   PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g0[])
205 {
206   PetscInt c;
207   for (c = 0; c < dim; ++c) g0[c*dim+c] = 1.0;
208 }
209 
210 /* <\nabla\cdot t, u> = <\nabla t, Iu> */
211 static void g2_qu(PetscInt dim, PetscInt Nf, PetscInt NfAux,
212                   const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
213                   const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
214                   PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g2[])
215 {
216   PetscInt d;
217   for (d = 0; d < dim; ++d) g2[d*dim+d] = 1.0;
218 }
219 
220 /* <v, \nabla\cdot q> */
221 static void g1_uq(PetscInt dim, PetscInt Nf, PetscInt NfAux,
222                   const PetscInt uOff[], const PetscInt uOff_x[], const PetscScalar u[], const PetscScalar u_t[], const PetscScalar u_x[],
223                   const PetscInt aOff[], const PetscInt aOff_x[], const PetscScalar a[], const PetscScalar a_t[], const PetscScalar a_x[],
224                   PetscReal t, PetscReal u_tShift, const PetscReal x[], PetscInt numConstants, const PetscScalar constants[], PetscScalar g1[])
225 {
226   PetscInt d;
227   for (d = 0; d < dim; ++d) g1[d*dim+d] = 1.0;
228 }
229 
230 static PetscErrorCode ProcessOptions(MPI_Comm comm, AppCtx *options)
231 {
232   PetscErrorCode ierr;
233 
234   PetscFunctionBeginUser;
235   options->solType = SOL_LINEAR;
236 
237   ierr = PetscOptionsBegin(comm, "", "Poisson Problem Options", "DMPLEX");CHKERRQ(ierr);
238   CHKERRQ(PetscOptionsEnum("-sol_type", "Type of exact solution", "ex24.c", SolTypeNames, (PetscEnum) options->solType, (PetscEnum *) &options->solType, NULL));
239   ierr = PetscOptionsEnd();CHKERRQ(ierr);
240   PetscFunctionReturn(0);
241 }
242 
243 static PetscErrorCode CreateMesh(MPI_Comm comm, AppCtx *user, DM *dm)
244 {
245   PetscFunctionBeginUser;
246   CHKERRQ(DMCreate(comm, dm));
247   CHKERRQ(DMSetType(*dm, DMPLEX));
248   CHKERRQ(PetscObjectSetName((PetscObject)*dm, "Example Mesh"));
249   CHKERRQ(DMSetApplicationContext(*dm, user));
250   CHKERRQ(DMSetFromOptions(*dm));
251   CHKERRQ(DMViewFromOptions(*dm, NULL, "-dm_view"));
252   PetscFunctionReturn(0);
253 }
254 
255 static PetscErrorCode SetupPrimalProblem(DM dm, AppCtx *user)
256 {
257   PetscDS        ds;
258   DMLabel        label;
259   PetscWeakForm  wf;
260   const PetscInt id = 1;
261   PetscInt       bd;
262 
263   PetscFunctionBeginUser;
264   CHKERRQ(DMGetLabel(dm, "marker", &label));
265   CHKERRQ(DMGetDS(dm, &ds));
266   CHKERRQ(PetscDSSetResidual(ds, 0, f0_q, f1_q));
267   CHKERRQ(PetscDSSetJacobian(ds, 0, 0, g0_qq, NULL, NULL, NULL));
268   CHKERRQ(PetscDSSetJacobian(ds, 0, 1, NULL, NULL, g2_qu, NULL));
269   CHKERRQ(PetscDSSetJacobian(ds, 1, 0, NULL, g1_uq, NULL, NULL));
270   switch (user->solType)
271   {
272     case SOL_LINEAR:
273       CHKERRQ(PetscDSSetResidual(ds, 1, f0_linear_u, NULL));
274       CHKERRQ(DMAddBoundary(dm, DM_BC_NATURAL, "Dirichlet Bd Integral", label, 1, &id, 0, 0, NULL, NULL, NULL, user, &bd));
275       CHKERRQ(PetscDSGetBoundary(ds, bd, &wf, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL));
276       CHKERRQ(PetscWeakFormSetIndexBdResidual(wf, label, 1, 0, 0, 0, f0_bd_linear_q, 0, NULL));
277       CHKERRQ(PetscDSSetExactSolution(ds, 0, linear_q, user));
278       CHKERRQ(PetscDSSetExactSolution(ds, 1, linear_u, user));
279       break;
280     case SOL_QUADRATIC:
281       CHKERRQ(PetscDSSetResidual(ds, 1, f0_quadratic_u, NULL));
282       CHKERRQ(DMAddBoundary(dm, DM_BC_NATURAL, "Dirichlet Bd Integral", label, 1, &id, 0, 0, NULL, NULL, NULL, user, &bd));
283       CHKERRQ(PetscDSGetBoundary(ds, bd, &wf, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL));
284       CHKERRQ(PetscWeakFormSetIndexBdResidual(wf, label, 1, 0, 0, 0, f0_bd_quadratic_q, 0, NULL));
285       CHKERRQ(PetscDSSetExactSolution(ds, 0, quadratic_q, user));
286       CHKERRQ(PetscDSSetExactSolution(ds, 1, quadratic_u, user));
287       break;
288     case SOL_QUARTIC:
289       CHKERRQ(PetscDSSetResidual(ds, 1, f0_quartic_u, NULL));
290       CHKERRQ(PetscDSSetExactSolution(ds, 0, quartic_q, user));
291       CHKERRQ(PetscDSSetExactSolution(ds, 1, quartic_u, user));
292       break;
293     case SOL_QUARTIC_NEUMANN:
294       CHKERRQ(PetscDSSetResidual(ds, 1, f0_quartic_u, NULL));
295       CHKERRQ(PetscDSSetExactSolution(ds, 0, quartic_q, user));
296       CHKERRQ(PetscDSSetExactSolution(ds, 1, quartic_u, user));
297       CHKERRQ(DMAddBoundary(dm, DM_BC_ESSENTIAL, "Flux condition", label, 1, &id, 0, 0, NULL, (void (*)(void)) quartic_q, NULL, user, NULL));
298       break;
299     default: SETERRQ(PetscObjectComm((PetscObject) dm), PETSC_ERR_ARG_WRONG, "Invalid exact solution type %s", SolTypeNames[PetscMin(user->solType, SOL_UNKNOWN)]);
300   }
301   PetscFunctionReturn(0);
302 }
303 
304 static PetscErrorCode SetupDiscretization(DM dm, PetscErrorCode (*setup)(DM, AppCtx *), AppCtx *user)
305 {
306   DM             cdm = dm;
307   PetscFE        feq, feu;
308   DMPolytopeType ct;
309   PetscBool      simplex;
310   PetscInt       dim, cStart;
311 
312   PetscFunctionBeginUser;
313   CHKERRQ(DMGetDimension(dm, &dim));
314   CHKERRQ(DMPlexGetHeightStratum(dm, 0, &cStart, NULL));
315   CHKERRQ(DMPlexGetCellType(dm, cStart, &ct));
316   simplex = DMPolytopeTypeGetNumVertices(ct) == DMPolytopeTypeGetDim(ct)+1 ? PETSC_TRUE : PETSC_FALSE;
317   /* Create finite element */
318   CHKERRQ(PetscFECreateDefault(PETSC_COMM_SELF, dim, dim, simplex, "field_",     -1, &feq));
319   CHKERRQ(PetscObjectSetName((PetscObject) feq, "field"));
320   CHKERRQ(PetscFECreateDefault(PETSC_COMM_SELF, dim, 1,   simplex, "potential_", -1, &feu));
321   CHKERRQ(PetscObjectSetName((PetscObject) feu, "potential"));
322   CHKERRQ(PetscFECopyQuadrature(feq, feu));
323   /* Set discretization and boundary conditions for each mesh */
324   CHKERRQ(DMSetField(dm, 0, NULL, (PetscObject) feq));
325   CHKERRQ(DMSetField(dm, 1, NULL, (PetscObject) feu));
326   CHKERRQ(DMCreateDS(dm));
327   CHKERRQ((*setup)(dm, user));
328   while (cdm) {
329     CHKERRQ(DMCopyDisc(dm,cdm));
330     CHKERRQ(DMGetCoarseDM(cdm, &cdm));
331   }
332   CHKERRQ(PetscFEDestroy(&feq));
333   CHKERRQ(PetscFEDestroy(&feu));
334   PetscFunctionReturn(0);
335 }
336 
337 int main(int argc, char **argv)
338 {
339   DM             dm;   /* Problem specification */
340   SNES           snes; /* Nonlinear solver */
341   Vec            u;    /* Solutions */
342   AppCtx         user; /* User-defined work context */
343   PetscErrorCode ierr;
344 
345   ierr = PetscInitialize(&argc, &argv, NULL, help);if (ierr) return ierr;
346   CHKERRQ(ProcessOptions(PETSC_COMM_WORLD, &user));
347   /* Primal system */
348   CHKERRQ(SNESCreate(PETSC_COMM_WORLD, &snes));
349   CHKERRQ(CreateMesh(PETSC_COMM_WORLD, &user, &dm));
350   CHKERRQ(SNESSetDM(snes, dm));
351   CHKERRQ(SetupDiscretization(dm, SetupPrimalProblem, &user));
352   CHKERRQ(DMCreateGlobalVector(dm, &u));
353   CHKERRQ(VecSet(u, 0.0));
354   CHKERRQ(PetscObjectSetName((PetscObject) u, "potential"));
355   CHKERRQ(DMPlexSetSNESLocalFEM(dm, &user, &user, &user));
356   CHKERRQ(SNESSetFromOptions(snes));
357   CHKERRQ(DMSNESCheckFromOptions(snes, u));
358   CHKERRQ(SNESSolve(snes, NULL, u));
359   CHKERRQ(SNESGetSolution(snes, &u));
360   CHKERRQ(VecViewFromOptions(u, NULL, "-potential_view"));
361   /* Cleanup */
362   CHKERRQ(VecDestroy(&u));
363   CHKERRQ(SNESDestroy(&snes));
364   CHKERRQ(DMDestroy(&dm));
365   ierr = PetscFinalize();
366   return ierr;
367 }
368 
369 /*TEST
370 
371   test:
372     suffix: 2d_bdm1_p0
373     requires: triangle
374     args: -sol_type linear \
375           -field_petscspace_degree 1 -field_petscdualspace_type bdm -dm_refine 1 \
376           -dmsnes_check .001 -snes_error_if_not_converged \
377           -ksp_rtol 1e-10 -ksp_error_if_not_converged \
378           -pc_type fieldsplit -pc_fieldsplit_type schur -pc_fieldsplit_schur_factorization_type full -pc_fieldsplit_schur_precondition full \
379             -fieldsplit_field_pc_type lu \
380             -fieldsplit_potential_ksp_rtol 1e-10 -fieldsplit_potential_pc_type lu
381   test:
382     # Using -dm_refine 2 -convest_num_refine 3 we get L_2 convergence rate: [2.0, 1.0]
383     # Using -sol_type quadratic -dm_refine 2 -convest_num_refine 3 we get L_2 convergence rate: [2.9, 1.0]
384     suffix: 2d_bdm1_p0_conv
385     requires: triangle
386     args: -sol_type quartic \
387           -field_petscspace_degree 1 -field_petscdualspace_type bdm -dm_refine 0 -convest_num_refine 1 -snes_convergence_estimate \
388           -snes_error_if_not_converged \
389           -ksp_rtol 1e-10 -ksp_error_if_not_converged \
390           -pc_type fieldsplit -pc_fieldsplit_type schur -pc_fieldsplit_schur_factorization_type full -pc_fieldsplit_schur_precondition full \
391             -fieldsplit_field_pc_type lu \
392             -fieldsplit_potential_ksp_rtol 1e-10 -fieldsplit_potential_pc_type lu
393 
394   test:
395     # HDF5 output: -dm_view hdf5:${PETSC_DIR}/sol.h5 -potential_view hdf5:${PETSC_DIR}/sol.h5::append -exact_vec_view hdf5:${PETSC_DIR}/sol.h5::append
396     # VTK output: -potential_view vtk: -exact_vec_view vtk:
397     # VTU output: -potential_view vtk:multifield.vtu -exact_vec_view vtk:exact.vtu
398     suffix: 2d_q2_p0
399     requires: triangle
400     args: -sol_type linear -dm_plex_simplex 0 \
401           -field_petscspace_degree 2 -dm_refine 0 \
402           -dmsnes_check .001 -snes_error_if_not_converged \
403           -ksp_rtol 1e-10 -ksp_error_if_not_converged \
404           -pc_type fieldsplit -pc_fieldsplit_type schur -pc_fieldsplit_schur_factorization_type full -pc_fieldsplit_schur_precondition full \
405             -fieldsplit_field_pc_type lu \
406             -fieldsplit_potential_ksp_rtol 1e-10 -fieldsplit_potential_pc_type lu
407   test:
408     # Using -dm_refine 1 -convest_num_refine 3 we get L_2 convergence rate: [0.0057, 1.0]
409     suffix: 2d_q2_p0_conv
410     requires: triangle
411     args: -sol_type linear -dm_plex_simplex 0 \
412           -field_petscspace_degree 2 -dm_refine 0 -convest_num_refine 1 -snes_convergence_estimate \
413           -snes_error_if_not_converged \
414           -ksp_rtol 1e-10 -ksp_error_if_not_converged \
415           -pc_type fieldsplit -pc_fieldsplit_type schur -pc_fieldsplit_schur_factorization_type full -pc_fieldsplit_schur_precondition full \
416             -fieldsplit_field_pc_type lu \
417             -fieldsplit_potential_ksp_rtol 1e-10 -fieldsplit_potential_pc_type lu
418   test:
419     # Using -dm_refine 1 -convest_num_refine 3 we get L_2 convergence rate: [-0.014, 0.0066]
420     suffix: 2d_q2_p0_neumann_conv
421     requires: triangle
422     args: -sol_type quartic_neumann -dm_plex_simplex 0 \
423           -field_petscspace_degree 2 -dm_refine 0 -convest_num_refine 1 -snes_convergence_estimate \
424           -snes_error_if_not_converged \
425           -ksp_rtol 1e-10 -ksp_error_if_not_converged \
426           -pc_type fieldsplit -pc_fieldsplit_type schur -pc_fieldsplit_schur_factorization_type full -pc_fieldsplit_schur_precondition full \
427             -fieldsplit_field_pc_type lu \
428             -fieldsplit_potential_ksp_rtol 1e-10 -fieldsplit_potential_pc_type svd
429 
430 TEST*/
431 
432 /* These tests will be active once tensor P^- is working
433 
434   test:
435     suffix: 2d_bdmq1_p0_0
436     requires: triangle
437     args: -dm_plex_simplex 0 -sol_type linear \
438           -field_petscspace_poly_type pminus_hdiv -field_petscspace_degree 1 -field_petscdualspace_type bdm -dm_refine 0 -convest_num_refine 3 -snes_convergence_estimate \
439           -dmsnes_check .001 -snes_error_if_not_converged \
440           -ksp_rtol 1e-10 -ksp_error_if_not_converged \
441           -pc_type fieldsplit -pc_fieldsplit_type schur -pc_fieldsplit_schur_factorization_type full -pc_fieldsplit_schur_precondition full \
442             -fieldsplit_field_pc_type lu \
443             -fieldsplit_potential_ksp_rtol 1e-10 -fieldsplit_potential_pc_type lu
444   test:
445     suffix: 2d_bdmq1_p0_2
446     requires: triangle
447     args: -dm_plex_simplex 0 -sol_type quartic \
448           -field_petscspace_poly_type_no pminus_hdiv -field_petscspace_degree 1 -field_petscdualspace_type bdm -dm_refine 0 -convest_num_refine 3 -snes_convergence_estimate \
449           -dmsnes_check .001 -snes_error_if_not_converged \
450           -ksp_rtol 1e-10 -ksp_error_if_not_converged \
451           -pc_type fieldsplit -pc_fieldsplit_type schur -pc_fieldsplit_schur_factorization_type full -pc_fieldsplit_schur_precondition full \
452             -fieldsplit_field_pc_type lu \
453             -fieldsplit_potential_ksp_rtol 1e-10 -fieldsplit_potential_pc_type lu
454 
455 */
456