Actual source code: ex19.c
1: /* Portions of this code are under:
2: Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
3: */
4: static char help[] = "Nonlinear driven cavity with multigrid in 2d.\n \
5: \n\
6: The 2D driven cavity problem is solved in a velocity-vorticity formulation.\n\
7: The flow can be driven with the lid or with buoyancy or both:\n\
8: -lidvelocity <lid>, where <lid> = dimensionless velocity of lid\n\
9: -grashof <gr>, where <gr> = dimensionless temperature gradent\n\
10: -prandtl <pr>, where <pr> = dimensionless thermal/momentum diffusity ratio\n\
11: -contours : draw contour plots of solution\n\n";
12: /* in HTML, '<' = '<' and '>' = '>' */
14: /*
15: See src/ksp/ksp/tutorials/ex45.c
16: */
18: /*F-----------------------------------------------------------------------
20: We thank David E. Keyes for contributing the driven cavity discretization within this example code.
22: This problem is modeled by the partial differential equation system
24: \begin{eqnarray}
25: - \triangle U - \nabla_y \Omega & = & 0 \\
26: - \triangle V + \nabla_x\Omega & = & 0 \\
27: - \triangle \Omega + \nabla \cdot ([U*\Omega,V*\Omega]) - GR* \nabla_x T & = & 0 \\
28: - \triangle T + PR* \nabla \cdot ([U*T,V*T]) & = & 0
29: \end{eqnarray}
31: in the unit square, which is uniformly discretized in each of x and y in this simple encoding.
33: No-slip, rigid-wall Dirichlet conditions are used for $[U,V]$.
34: Dirichlet conditions are used for Omega, based on the definition of
35: vorticity: $\Omega = - \nabla_y U + \nabla_x V$, where along each
36: constant coordinate boundary, the tangential derivative is zero.
37: Dirichlet conditions are used for T on the left and right walls,
38: and insulation homogeneous Neumann conditions are used for T on
39: the top and bottom walls.
41: A finite difference approximation with the usual 5-point stencil
42: is used to discretize the boundary value problem to obtain a
43: nonlinear system of equations. Upwinding is used for the divergence
44: (convective) terms and central for the gradient (source) terms.
46: The Jacobian can be either
47: * formed via finite differencing using coloring (the default), or
48: * applied matrix-free via the option -snes_mf
49: (for larger grid problems this variant may not converge
50: without a preconditioner due to ill-conditioning).
52: ------------------------------------------------------------------------F*/
54: /*
55: Include "petscdmda.h" so that we can use distributed arrays (DMDAs).
56: Include "petscsnes.h" so that we can use SNES solvers. Note that this
57: file automatically includes:
58: petscsys.h - base PETSc routines
59: petscvec.h - vectors
60: petscmat.h - matrices
61: petscis.h - index sets
62: petscpc.h - preconditioners
63: petscksp.h - linear solvers
64: */
65: #if defined(PETSC_APPLE_FRAMEWORK)
66: #import <PETSc/petscsnes.h>
67: #import <PETSc/petscdmda.h>
68: #else
69: #include <petscsnes.h>
70: #include <petscdm.h>
71: #include <petscdmda.h>
72: #endif
74: /*
75: User-defined routines and data structures
76: */
77: typedef struct {
78: PetscScalar u, v, omega, temp;
79: } Field;
81: PetscErrorCode FormFunctionLocal(DMDALocalInfo *, Field **, Field **, void *);
83: typedef struct {
84: PetscReal lidvelocity, prandtl, grashof; /* physical parameters */
85: PetscBool draw_contours; /* flag - 1 indicates drawing contours */
86: } AppCtx;
88: extern PetscErrorCode FormInitialGuess(AppCtx *, DM, Vec);
89: extern PetscErrorCode NonlinearGS(SNES, Vec, Vec, void *);
91: int main(int argc, char **argv)
92: {
93: AppCtx user; /* user-defined work context */
94: PetscInt mx, my, its;
95: MPI_Comm comm;
96: SNES snes;
97: DM da;
98: Vec x;
100: PetscFunctionBeginUser;
101: PetscCall(PetscInitialize(&argc, &argv, NULL, help));
102: comm = PETSC_COMM_WORLD;
103: PetscCall(SNESCreate(comm, &snes));
105: /*
106: Create distributed array object to manage parallel grid and vectors
107: for principal unknowns (x) and governing residuals (f)
108: */
109: PetscCall(DMDACreate2d(PETSC_COMM_WORLD, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, DMDA_STENCIL_STAR, 4, 4, PETSC_DECIDE, PETSC_DECIDE, 4, 1, NULL, NULL, &da));
110: PetscCall(DMSetFromOptions(da));
111: PetscCall(DMSetUp(da));
112: PetscCall(SNESSetDM(snes, da));
113: PetscCall(SNESSetNGS(snes, NonlinearGS, (void *)&user));
115: PetscCall(DMDAGetInfo(da, NULL, &mx, &my, PETSC_IGNORE, PETSC_IGNORE, PETSC_IGNORE, PETSC_IGNORE, PETSC_IGNORE, PETSC_IGNORE, PETSC_IGNORE, PETSC_IGNORE, PETSC_IGNORE, PETSC_IGNORE));
116: /*
117: Problem parameters (velocity of lid, prandtl, and grashof numbers)
118: */
119: user.lidvelocity = 1.0 / (mx * my);
120: user.prandtl = 1.0;
121: user.grashof = 1.0;
123: PetscCall(PetscOptionsGetReal(NULL, NULL, "-lidvelocity", &user.lidvelocity, NULL));
124: PetscCall(PetscOptionsGetReal(NULL, NULL, "-prandtl", &user.prandtl, NULL));
125: PetscCall(PetscOptionsGetReal(NULL, NULL, "-grashof", &user.grashof, NULL));
126: PetscCall(PetscOptionsHasName(NULL, NULL, "-contours", &user.draw_contours));
128: PetscCall(DMDASetFieldName(da, 0, "x_velocity"));
129: PetscCall(DMDASetFieldName(da, 1, "y_velocity"));
130: PetscCall(DMDASetFieldName(da, 2, "Omega"));
131: PetscCall(DMDASetFieldName(da, 3, "temperature"));
133: /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
134: Create user context, set problem data, create vector data structures.
135: Also, compute the initial guess.
136: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
138: /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
139: Create nonlinear solver context
141: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
142: PetscCall(DMSetApplicationContext(da, &user));
143: PetscCall(DMDASNESSetFunctionLocal(da, INSERT_VALUES, (DMDASNESFunctionFn *)FormFunctionLocal, &user));
144: PetscCall(SNESSetFromOptions(snes));
145: PetscCall(PetscPrintf(comm, "lid velocity = %g, prandtl # = %g, grashof # = %g\n", (double)user.lidvelocity, (double)user.prandtl, (double)user.grashof));
147: /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
148: Solve the nonlinear system
149: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
150: PetscCall(DMCreateGlobalVector(da, &x));
151: PetscCall(FormInitialGuess(&user, da, x));
153: PetscCall(SNESSolve(snes, NULL, x));
155: PetscCall(SNESGetIterationNumber(snes, &its));
156: PetscCall(PetscPrintf(comm, "Number of SNES iterations = %" PetscInt_FMT "\n", its));
158: /*
159: Visualize solution
160: */
161: if (user.draw_contours) PetscCall(VecView(x, PETSC_VIEWER_DRAW_WORLD));
163: /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
164: Free work space. All PETSc objects should be destroyed when they
165: are no longer needed.
166: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
167: PetscCall(VecDestroy(&x));
168: PetscCall(DMDestroy(&da));
169: PetscCall(SNESDestroy(&snes));
170: PetscCall(PetscFinalize());
171: return 0;
172: }
174: /* ------------------------------------------------------------------- */
176: /*
177: FormInitialGuess - Forms initial approximation.
179: Input Parameters:
180: user - user-defined application context
181: X - vector
183: Output Parameter:
184: X - vector
185: */
186: PetscErrorCode FormInitialGuess(AppCtx *user, DM da, Vec X)
187: {
188: PetscInt i, j, mx, xs, ys, xm, ym;
189: PetscReal grashof, dx;
190: Field **x;
192: PetscFunctionBeginUser;
193: grashof = user->grashof;
195: PetscCall(DMDAGetInfo(da, NULL, &mx, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL));
196: dx = 1.0 / (mx - 1);
198: /*
199: Get local grid boundaries (for 2-dimensional DMDA):
200: xs, ys - starting grid indices (no ghost points)
201: xm, ym - widths of local grid (no ghost points)
202: */
203: PetscCall(DMDAGetCorners(da, &xs, &ys, NULL, &xm, &ym, NULL));
205: /*
206: Get a pointer to vector data.
207: - For default PETSc vectors, VecGetArray() returns a pointer to
208: the data array. Otherwise, the routine is implementation dependent.
209: - You MUST call VecRestoreArray() when you no longer need access to
210: the array.
211: */
212: PetscCall(DMDAVecGetArrayWrite(da, X, &x));
214: /*
215: Compute initial guess over the locally owned part of the grid
216: Initial condition is motionless fluid and equilibrium temperature
217: */
218: for (j = ys; j < ys + ym; j++) {
219: for (i = xs; i < xs + xm; i++) {
220: x[j][i].u = 0.0;
221: x[j][i].v = 0.0;
222: x[j][i].omega = 0.0;
223: x[j][i].temp = (grashof > 0) * i * dx;
224: }
225: }
227: /*
228: Restore vector
229: */
230: PetscCall(DMDAVecRestoreArrayWrite(da, X, &x));
231: PetscFunctionReturn(PETSC_SUCCESS);
232: }
234: PetscErrorCode FormFunctionLocal(DMDALocalInfo *info, Field **x, Field **f, void *ptr)
235: {
236: AppCtx *user = (AppCtx *)ptr;
237: PetscInt xints, xinte, yints, yinte, i, j;
238: PetscReal hx, hy, dhx, dhy, hxdhy, hydhx;
239: PetscReal grashof, prandtl, lid;
240: PetscScalar u, uxx, uyy, vx, vy, avx, avy, vxp, vxm, vyp, vym;
242: PetscFunctionBeginUser;
243: grashof = user->grashof;
244: prandtl = user->prandtl;
245: lid = user->lidvelocity;
247: /*
248: Define mesh intervals ratios for uniform grid.
250: Note: FD formulae below are normalized by multiplying through by
251: local volume element (i.e. hx*hy) to obtain coefficients O(1) in two dimensions.
253: */
254: dhx = (PetscReal)(info->mx - 1);
255: dhy = (PetscReal)(info->my - 1);
256: hx = 1.0 / dhx;
257: hy = 1.0 / dhy;
258: hxdhy = hx * dhy;
259: hydhx = hy * dhx;
261: xints = info->xs;
262: xinte = info->xs + info->xm;
263: yints = info->ys;
264: yinte = info->ys + info->ym;
266: /* Test whether we are on the bottom edge of the global array */
267: if (yints == 0) {
268: j = 0;
269: yints = yints + 1;
270: /* bottom edge */
271: for (i = info->xs; i < info->xs + info->xm; i++) {
272: f[j][i].u = x[j][i].u;
273: f[j][i].v = x[j][i].v;
274: f[j][i].omega = x[j][i].omega + (x[j + 1][i].u - x[j][i].u) * dhy;
275: f[j][i].temp = x[j][i].temp - x[j + 1][i].temp;
276: }
277: }
279: /* Test whether we are on the top edge of the global array */
280: if (yinte == info->my) {
281: j = info->my - 1;
282: yinte = yinte - 1;
283: /* top edge */
284: for (i = info->xs; i < info->xs + info->xm; i++) {
285: f[j][i].u = x[j][i].u - lid;
286: f[j][i].v = x[j][i].v;
287: f[j][i].omega = x[j][i].omega + (x[j][i].u - x[j - 1][i].u) * dhy;
288: f[j][i].temp = x[j][i].temp - x[j - 1][i].temp;
289: }
290: }
292: /* Test whether we are on the left edge of the global array */
293: if (xints == 0) {
294: i = 0;
295: xints = xints + 1;
296: /* left edge */
297: for (j = info->ys; j < info->ys + info->ym; j++) {
298: f[j][i].u = x[j][i].u;
299: f[j][i].v = x[j][i].v;
300: f[j][i].omega = x[j][i].omega - (x[j][i + 1].v - x[j][i].v) * dhx;
301: f[j][i].temp = x[j][i].temp;
302: }
303: }
305: /* Test whether we are on the right edge of the global array */
306: if (xinte == info->mx) {
307: i = info->mx - 1;
308: xinte = xinte - 1;
309: /* right edge */
310: for (j = info->ys; j < info->ys + info->ym; j++) {
311: f[j][i].u = x[j][i].u;
312: f[j][i].v = x[j][i].v;
313: f[j][i].omega = x[j][i].omega - (x[j][i].v - x[j][i - 1].v) * dhx;
314: f[j][i].temp = x[j][i].temp - (PetscReal)(grashof > 0);
315: }
316: }
318: /* Compute over the interior points */
319: for (j = yints; j < yinte; j++) {
320: for (i = xints; i < xinte; i++) {
321: /*
322: convective coefficients for upwinding
323: */
324: vx = x[j][i].u;
325: avx = PetscAbsScalar(vx);
326: vxp = .5 * (vx + avx);
327: vxm = .5 * (vx - avx);
328: vy = x[j][i].v;
329: avy = PetscAbsScalar(vy);
330: vyp = .5 * (vy + avy);
331: vym = .5 * (vy - avy);
333: /* U velocity */
334: u = x[j][i].u;
335: uxx = (2.0 * u - x[j][i - 1].u - x[j][i + 1].u) * hydhx;
336: uyy = (2.0 * u - x[j - 1][i].u - x[j + 1][i].u) * hxdhy;
337: f[j][i].u = uxx + uyy - .5 * (x[j + 1][i].omega - x[j - 1][i].omega) * hx;
339: /* V velocity */
340: u = x[j][i].v;
341: uxx = (2.0 * u - x[j][i - 1].v - x[j][i + 1].v) * hydhx;
342: uyy = (2.0 * u - x[j - 1][i].v - x[j + 1][i].v) * hxdhy;
343: f[j][i].v = uxx + uyy + .5 * (x[j][i + 1].omega - x[j][i - 1].omega) * hy;
345: /* Omega */
346: u = x[j][i].omega;
347: uxx = (2.0 * u - x[j][i - 1].omega - x[j][i + 1].omega) * hydhx;
348: uyy = (2.0 * u - x[j - 1][i].omega - x[j + 1][i].omega) * hxdhy;
349: f[j][i].omega = uxx + uyy + (vxp * (u - x[j][i - 1].omega) + vxm * (x[j][i + 1].omega - u)) * hy + (vyp * (u - x[j - 1][i].omega) + vym * (x[j + 1][i].omega - u)) * hx - .5 * grashof * (x[j][i + 1].temp - x[j][i - 1].temp) * hy;
351: /* Temperature */
352: u = x[j][i].temp;
353: uxx = (2.0 * u - x[j][i - 1].temp - x[j][i + 1].temp) * hydhx;
354: uyy = (2.0 * u - x[j - 1][i].temp - x[j + 1][i].temp) * hxdhy;
355: f[j][i].temp = uxx + uyy + prandtl * ((vxp * (u - x[j][i - 1].temp) + vxm * (x[j][i + 1].temp - u)) * hy + (vyp * (u - x[j - 1][i].temp) + vym * (x[j + 1][i].temp - u)) * hx);
356: }
357: }
359: /*
360: Flop count (multiply-adds are counted as 2 operations)
361: */
362: PetscCall(PetscLogFlops(84.0 * info->ym * info->xm));
363: PetscFunctionReturn(PETSC_SUCCESS);
364: }
366: /*
367: Performs sweeps of point block nonlinear Gauss-Seidel on all the local grid points
368: */
369: PetscErrorCode NonlinearGS(SNES snes, Vec X, Vec B, PetscCtx ctx)
370: {
371: DMDALocalInfo info;
372: Field **x, **b;
373: Vec localX, localB;
374: DM da;
375: PetscInt xints, xinte, yints, yinte, i, j, k, l;
376: PetscInt max_its, tot_its;
377: PetscInt sweeps;
378: PetscReal rtol, atol, stol;
379: PetscReal hx, hy, dhx, dhy, hxdhy, hydhx;
380: PetscReal grashof, prandtl, lid;
381: PetscScalar u, uxx, uyy, vx, vy, avx, avy, vxp, vxm, vyp, vym;
382: PetscScalar fu, fv, fomega, ftemp;
383: PetscScalar dfudu;
384: PetscScalar dfvdv;
385: PetscScalar dfodu, dfodv, dfodo;
386: PetscScalar dftdu, dftdv, dftdt;
387: PetscScalar yu = 0, yv = 0, yo = 0, yt = 0;
388: PetscScalar bjiu, bjiv, bjiomega, bjitemp;
389: PetscBool ptconverged;
390: PetscReal pfnorm, pfnorm0, pynorm, pxnorm;
391: AppCtx *user = (AppCtx *)ctx;
393: PetscFunctionBeginUser;
394: grashof = user->grashof;
395: prandtl = user->prandtl;
396: lid = user->lidvelocity;
397: tot_its = 0;
398: PetscCall(SNESNGSGetTolerances(snes, &rtol, &atol, &stol, &max_its));
399: PetscCall(SNESNGSGetSweeps(snes, &sweeps));
400: PetscCall(SNESGetDM(snes, &da));
401: PetscCall(DMGetLocalVector(da, &localX));
402: if (B) PetscCall(DMGetLocalVector(da, &localB));
403: /*
404: Scatter ghost points to local vector, using the 2-step process
405: DMGlobalToLocalBegin(), DMGlobalToLocalEnd().
406: */
407: PetscCall(DMGlobalToLocalBegin(da, X, INSERT_VALUES, localX));
408: PetscCall(DMGlobalToLocalEnd(da, X, INSERT_VALUES, localX));
409: if (B) {
410: PetscCall(DMGlobalToLocalBegin(da, B, INSERT_VALUES, localB));
411: PetscCall(DMGlobalToLocalEnd(da, B, INSERT_VALUES, localB));
412: }
413: PetscCall(DMDAGetLocalInfo(da, &info));
414: PetscCall(DMDAVecGetArrayWrite(da, localX, &x));
415: if (B) PetscCall(DMDAVecGetArrayRead(da, localB, &b));
416: /* looks like a combination of the formfunction / formjacobian routines */
417: dhx = (PetscReal)(info.mx - 1);
418: dhy = (PetscReal)(info.my - 1);
419: hx = 1.0 / dhx;
420: hy = 1.0 / dhy;
421: hxdhy = hx * dhy;
422: hydhx = hy * dhx;
424: xints = info.xs;
425: xinte = info.xs + info.xm;
426: yints = info.ys;
427: yinte = info.ys + info.ym;
429: /* Set the boundary conditions on the momentum equations */
430: /* Test whether we are on the bottom edge of the global array */
431: if (yints == 0) {
432: j = 0;
433: /* bottom edge */
434: for (i = info.xs; i < info.xs + info.xm; i++) {
435: if (B) {
436: bjiu = b[j][i].u;
437: bjiv = b[j][i].v;
438: } else {
439: bjiu = 0.0;
440: bjiv = 0.0;
441: }
442: x[j][i].u = 0.0 + bjiu;
443: x[j][i].v = 0.0 + bjiv;
444: }
445: }
447: /* Test whether we are on the top edge of the global array */
448: if (yinte == info.my) {
449: j = info.my - 1;
450: /* top edge */
451: for (i = info.xs; i < info.xs + info.xm; i++) {
452: if (B) {
453: bjiu = b[j][i].u;
454: bjiv = b[j][i].v;
455: } else {
456: bjiu = 0.0;
457: bjiv = 0.0;
458: }
459: x[j][i].u = lid + bjiu;
460: x[j][i].v = bjiv;
461: }
462: }
464: /* Test whether we are on the left edge of the global array */
465: if (xints == 0) {
466: i = 0;
467: /* left edge */
468: for (j = info.ys; j < info.ys + info.ym; j++) {
469: if (B) {
470: bjiu = b[j][i].u;
471: bjiv = b[j][i].v;
472: } else {
473: bjiu = 0.0;
474: bjiv = 0.0;
475: }
476: x[j][i].u = 0.0 + bjiu;
477: x[j][i].v = 0.0 + bjiv;
478: }
479: }
481: /* Test whether we are on the right edge of the global array */
482: if (xinte == info.mx) {
483: i = info.mx - 1;
484: /* right edge */
485: for (j = info.ys; j < info.ys + info.ym; j++) {
486: if (B) {
487: bjiu = b[j][i].u;
488: bjiv = b[j][i].v;
489: } else {
490: bjiu = 0.0;
491: bjiv = 0.0;
492: }
493: x[j][i].u = 0.0 + bjiu;
494: x[j][i].v = 0.0 + bjiv;
495: }
496: }
498: for (k = 0; k < sweeps; k++) {
499: for (j = info.ys; j < info.ys + info.ym; j++) {
500: for (i = info.xs; i < info.xs + info.xm; i++) {
501: ptconverged = PETSC_FALSE;
502: pfnorm0 = 0.0;
503: fu = 0.0;
504: fv = 0.0;
505: fomega = 0.0;
506: ftemp = 0.0;
507: /* Run Newton's method on a single grid point */
508: for (l = 0; l < max_its && !ptconverged; l++) {
509: if (B) {
510: bjiu = b[j][i].u;
511: bjiv = b[j][i].v;
512: bjiomega = b[j][i].omega;
513: bjitemp = b[j][i].temp;
514: } else {
515: bjiu = 0.0;
516: bjiv = 0.0;
517: bjiomega = 0.0;
518: bjitemp = 0.0;
519: }
521: if (i != 0 && i != info.mx - 1 && j != 0 && j != info.my - 1) {
522: /* U velocity */
523: u = x[j][i].u;
524: uxx = (2.0 * u - x[j][i - 1].u - x[j][i + 1].u) * hydhx;
525: uyy = (2.0 * u - x[j - 1][i].u - x[j + 1][i].u) * hxdhy;
526: fu = uxx + uyy - .5 * (x[j + 1][i].omega - x[j - 1][i].omega) * hx - bjiu;
527: dfudu = 2.0 * (hydhx + hxdhy);
528: /* V velocity */
529: u = x[j][i].v;
530: uxx = (2.0 * u - x[j][i - 1].v - x[j][i + 1].v) * hydhx;
531: uyy = (2.0 * u - x[j - 1][i].v - x[j + 1][i].v) * hxdhy;
532: fv = uxx + uyy + .5 * (x[j][i + 1].omega - x[j][i - 1].omega) * hy - bjiv;
533: dfvdv = 2.0 * (hydhx + hxdhy);
534: /*
535: convective coefficients for upwinding
536: */
537: vx = x[j][i].u;
538: avx = PetscAbsScalar(vx);
539: vxp = .5 * (vx + avx);
540: vxm = .5 * (vx - avx);
541: vy = x[j][i].v;
542: avy = PetscAbsScalar(vy);
543: vyp = .5 * (vy + avy);
544: vym = .5 * (vy - avy);
545: /* Omega */
546: u = x[j][i].omega;
547: uxx = (2.0 * u - x[j][i - 1].omega - x[j][i + 1].omega) * hydhx;
548: uyy = (2.0 * u - x[j - 1][i].omega - x[j + 1][i].omega) * hxdhy;
549: fomega = uxx + uyy + (vxp * (u - x[j][i - 1].omega) + vxm * (x[j][i + 1].omega - u)) * hy + (vyp * (u - x[j - 1][i].omega) + vym * (x[j + 1][i].omega - u)) * hx - .5 * grashof * (x[j][i + 1].temp - x[j][i - 1].temp) * hy - bjiomega;
550: /* convective coefficient derivatives */
551: dfodo = 2.0 * (hydhx + hxdhy) + ((vxp - vxm) * hy + (vyp - vym) * hx);
552: if (PetscRealPart(vx) > 0.0) dfodu = (u - x[j][i - 1].omega) * hy;
553: else dfodu = (x[j][i + 1].omega - u) * hy;
555: if (PetscRealPart(vy) > 0.0) dfodv = (u - x[j - 1][i].omega) * hx;
556: else dfodv = (x[j + 1][i].omega - u) * hx;
558: /* Temperature */
559: u = x[j][i].temp;
560: uxx = (2.0 * u - x[j][i - 1].temp - x[j][i + 1].temp) * hydhx;
561: uyy = (2.0 * u - x[j - 1][i].temp - x[j + 1][i].temp) * hxdhy;
562: ftemp = uxx + uyy + prandtl * ((vxp * (u - x[j][i - 1].temp) + vxm * (x[j][i + 1].temp - u)) * hy + (vyp * (u - x[j - 1][i].temp) + vym * (x[j + 1][i].temp - u)) * hx) - bjitemp;
563: dftdt = 2.0 * (hydhx + hxdhy) + prandtl * ((vxp - vxm) * hy + (vyp - vym) * hx);
564: if (PetscRealPart(vx) > 0.0) dftdu = prandtl * (u - x[j][i - 1].temp) * hy;
565: else dftdu = prandtl * (x[j][i + 1].temp - u) * hy;
567: if (PetscRealPart(vy) > 0.0) dftdv = prandtl * (u - x[j - 1][i].temp) * hx;
568: else dftdv = prandtl * (x[j + 1][i].temp - u) * hx;
570: /* invert the system:
571: [ dfu / du 0 0 0 ][yu] = [fu]
572: [ 0 dfv / dv 0 0 ][yv] [fv]
573: [ dfo / du dfo / dv dfo / do 0 ][yo] [fo]
574: [ dft / du dft / dv 0 dft / dt ][yt] [ft]
575: by simple back-substitution
576: */
577: yu = fu / dfudu;
578: yv = fv / dfvdv;
579: yo = (fomega - (dfodu * yu + dfodv * yv)) / dfodo;
580: yt = (ftemp - (dftdu * yu + dftdv * yv)) / dftdt;
582: x[j][i].u = x[j][i].u - yu;
583: x[j][i].v = x[j][i].v - yv;
584: x[j][i].temp = x[j][i].temp - yt;
585: x[j][i].omega = x[j][i].omega - yo;
586: }
587: if (i == 0) {
588: fomega = x[j][i].omega - (x[j][i + 1].v - x[j][i].v) * dhx - bjiomega;
589: ftemp = x[j][i].temp - bjitemp;
590: yo = fomega;
591: yt = ftemp;
592: x[j][i].omega = x[j][i].omega - fomega;
593: x[j][i].temp = x[j][i].temp - ftemp;
594: }
595: if (i == info.mx - 1) {
596: fomega = x[j][i].omega - (x[j][i].v - x[j][i - 1].v) * dhx - bjiomega;
597: ftemp = x[j][i].temp - (PetscReal)(grashof > 0) - bjitemp;
598: yo = fomega;
599: yt = ftemp;
600: x[j][i].omega = x[j][i].omega - fomega;
601: x[j][i].temp = x[j][i].temp - ftemp;
602: }
603: if (j == 0) {
604: fomega = x[j][i].omega + (x[j + 1][i].u - x[j][i].u) * dhy - bjiomega;
605: ftemp = x[j][i].temp - x[j + 1][i].temp - bjitemp;
606: yo = fomega;
607: yt = ftemp;
608: x[j][i].omega = x[j][i].omega - fomega;
609: x[j][i].temp = x[j][i].temp - ftemp;
610: }
611: if (j == info.my - 1) {
612: fomega = x[j][i].omega + (x[j][i].u - x[j - 1][i].u) * dhy - bjiomega;
613: ftemp = x[j][i].temp - x[j - 1][i].temp - bjitemp;
614: yo = fomega;
615: yt = ftemp;
616: x[j][i].omega = x[j][i].omega - fomega;
617: x[j][i].temp = x[j][i].temp - ftemp;
618: }
619: tot_its++;
620: pfnorm = PetscRealPart(fu * fu + fv * fv + fomega * fomega + ftemp * ftemp);
621: pfnorm = PetscSqrtReal(pfnorm);
622: pynorm = PetscRealPart(yu * yu + yv * yv + yo * yo + yt * yt);
623: pynorm = PetscSqrtReal(pynorm);
624: pxnorm = PetscRealPart(x[j][i].u * x[j][i].u + x[j][i].v * x[j][i].v + x[j][i].omega * x[j][i].omega + x[j][i].temp * x[j][i].temp);
625: pxnorm = PetscSqrtReal(pxnorm);
626: if (l == 0) pfnorm0 = pfnorm;
627: if (rtol * pfnorm0 > pfnorm || atol > pfnorm || pxnorm * stol > pynorm) ptconverged = PETSC_TRUE;
628: }
629: }
630: }
631: }
632: PetscCall(DMDAVecRestoreArrayWrite(da, localX, &x));
633: if (B) PetscCall(DMDAVecRestoreArrayRead(da, localB, &b));
634: PetscCall(DMLocalToGlobalBegin(da, localX, INSERT_VALUES, X));
635: PetscCall(DMLocalToGlobalEnd(da, localX, INSERT_VALUES, X));
636: PetscCall(PetscLogFlops(tot_its * (84.0 + 41.0 + 26.0)));
637: PetscCall(DMRestoreLocalVector(da, &localX));
638: if (B) PetscCall(DMRestoreLocalVector(da, &localB));
639: PetscFunctionReturn(PETSC_SUCCESS);
640: }
642: /*TEST
644: test:
645: nsize: 2
646: args: -da_refine 3 -snes_monitor -pc_type mg -ksp_type fgmres -pc_mg_type full
647: requires: !single
649: test:
650: suffix: 10
651: nsize: 3
652: args: -snes_monitor -ksp_monitor -pc_type fieldsplit -pc_fieldsplit_type symmetric_multiplicative -snes_view -da_refine 1 -ksp_type fgmres
653: requires: !single
655: test:
656: suffix: 11
657: nsize: 4
658: requires: pastix
659: args: -snes_monitor -pc_type redundant -dm_mat_type mpiaij -redundant_pc_factor_mat_solver_type pastix -mat_pastix_thread_nbr 1 -pc_redundant_number 2 -da_refine 4 -ksp_type fgmres
661: test:
662: suffix: 12
663: nsize: 12
664: requires: pastix
665: args: -snes_monitor -pc_type redundant -dm_mat_type mpiaij -redundant_pc_factor_mat_solver_type pastix -mat_pastix_thread_nbr 1 -pc_redundant_number 5 -da_refine 4 -ksp_type fgmres
667: test:
668: suffix: 13
669: nsize: 3
670: args: -snes_monitor -ksp_monitor -pc_type fieldsplit -pc_fieldsplit_type multiplicative -snes_view -da_refine 1 -ksp_type fgmres -snes_mf_operator
671: requires: !single
673: test:
674: suffix: 14
675: nsize: 4
676: args: -snes_monitor -pc_type mg -dm_mat_type baij -mg_coarse_pc_type bjacobi -da_refine 3 -ksp_type fgmres
677: requires: !single
679: test:
680: suffix: 14_ds
681: nsize: 4
682: args: -snes_converged_reason -pc_type mg -dm_mat_type baij -mg_coarse_pc_type bjacobi -da_refine 3 -ksp_type fgmres -mat_fd_type ds
683: output_file: output/ex19_2.out
684: requires: !single
686: test:
687: suffix: 17
688: args: -snes_monitor -ksp_pc_side right
689: requires: !single
691: test:
692: suffix: 18
693: args: -snes_monitor_ksp draw::draw_lg -ksp_pc_side right
694: requires: x !single
696: test:
697: suffix: 19
698: nsize: 2
699: args: -da_refine 3 -snes_monitor -pc_type mg -ksp_type fgmres -pc_mg_type full -snes_type newtontrdc
700: requires: !single
702: test:
703: suffix: 20
704: nsize: 2
705: args: -da_refine 3 -snes_monitor -pc_type mg -ksp_type fgmres -pc_mg_type full -snes_type newtontrdc -snes_trdc_use_cauchy false
706: requires: !single
708: test:
709: suffix: 2
710: nsize: 4
711: args: -da_refine 3 -snes_converged_reason -pc_type mg -mat_fd_type ds
712: requires: !single
714: test:
715: suffix: 2_bcols1
716: nsize: 4
717: args: -da_refine 3 -snes_converged_reason -pc_type mg -mat_fd_type ds -mat_fd_coloring_bcols
718: output_file: output/ex19_2.out
719: requires: !single
721: test:
722: suffix: 3
723: nsize: 4
724: requires: mumps
725: args: -da_refine 3 -snes_monitor -pc_type redundant -dm_mat_type mpiaij -redundant_ksp_type preonly -redundant_pc_factor_mat_solver_type mumps -pc_redundant_number 2
727: test:
728: suffix: 4
729: nsize: 12
730: requires: mumps
731: args: -da_refine 3 -snes_monitor -pc_type redundant -dm_mat_type mpiaij -redundant_ksp_type preonly -redundant_pc_factor_mat_solver_type mumps -pc_redundant_number 5
732: output_file: output/ex19_3.out
734: test:
735: suffix: 6
736: args: -snes_monitor -ksp_monitor -pc_type fieldsplit -snes_view -ksp_type fgmres -da_refine 1
737: requires: !single
739: test:
740: suffix: 7
741: nsize: 3
742: args: -snes_monitor -ksp_monitor -pc_type fieldsplit -snes_view -da_refine 1 -ksp_type fgmres
744: requires: !single
745: test:
746: suffix: 8
747: args: -snes_monitor -ksp_monitor -pc_type fieldsplit -pc_fieldsplit_block_size 2 -pc_fieldsplit_0_fields 0,1 -pc_fieldsplit_1_fields 0,1 -pc_fieldsplit_type multiplicative -snes_view -fieldsplit_pc_type lu -da_refine 1 -ksp_type fgmres
748: requires: !single
750: test:
751: suffix: 9
752: nsize: 3
753: args: -snes_monitor -ksp_monitor -pc_type fieldsplit -pc_fieldsplit_type multiplicative -snes_view -da_refine 1 -ksp_type fgmres
754: requires: !single
756: test:
757: suffix: aspin
758: nsize: 4
759: args: -da_refine 3 -da_overlap 2 -snes_monitor -snes_type aspin -grashof 4e4 -lidvelocity 100 -ksp_monitor -npc_sub_ksp_type preonly -npc_sub_pc_type lu
760: requires: !single
762: test:
763: suffix: bcgsl
764: nsize: 2
765: args: -ksp_type bcgsl -ksp_monitor -da_refine 2 -ksp_bcgsl_ell 3 -snes_view
766: requires: !single
768: test:
769: suffix: bcols1
770: nsize: 2
771: args: -da_refine 3 -snes_monitor -pc_type mg -ksp_type fgmres -pc_mg_type full -mat_fd_coloring_bcols 1
772: output_file: output/ex19_1.out
773: requires: !single
775: test:
776: suffix: bjacobi
777: nsize: 4
778: args: -da_refine 4 -ksp_type fgmres -pc_type bjacobi -pc_bjacobi_blocks 2 -sub_ksp_type gmres -sub_ksp_max_it 2 -sub_pc_type bjacobi -sub_sub_ksp_type preonly -sub_sub_pc_type ilu -snes_monitor
779: requires: !single
781: test:
782: suffix: cgne
783: args: -da_refine 2 -pc_type lu -ksp_type cgne -ksp_monitor -ksp_converged_reason -ksp_view -ksp_norm_type unpreconditioned
784: filter: grep -v HERMITIAN
785: requires: !single
787: test:
788: suffix: cgs
789: args: -da_refine 1 -ksp_monitor -ksp_type cgs
790: requires: !single
792: test:
793: suffix: composite_fieldsplit
794: args: -ksp_type fgmres -pc_type composite -pc_composite_type MULTIPLICATIVE -pc_composite_pcs fieldsplit,none -sub_0_pc_fieldsplit_block_size 4 -sub_0_pc_fieldsplit_type additive -sub_0_pc_fieldsplit_0_fields 0,1,2 -sub_0_pc_fieldsplit_1_fields 3 -snes_monitor -ksp_monitor
795: requires: !single
797: test:
798: suffix: composite_fieldsplit_bjacobi
799: args: -ksp_type fgmres -pc_type composite -pc_composite_type MULTIPLICATIVE -pc_composite_pcs fieldsplit,bjacobi -sub_0_pc_fieldsplit_block_size 4 -sub_0_pc_fieldsplit_type additive -sub_0_pc_fieldsplit_0_fields 0,1,2 -sub_0_pc_fieldsplit_1_fields 3 -sub_1_pc_bjacobi_blocks 16 -sub_1_sub_pc_type lu -snes_monitor -ksp_monitor
800: requires: !single
802: test:
803: suffix: composite_fieldsplit_bjacobi_2
804: nsize: 4
805: args: -ksp_type fgmres -pc_type composite -pc_composite_type MULTIPLICATIVE -pc_composite_pcs fieldsplit,bjacobi -sub_0_pc_fieldsplit_block_size 4 -sub_0_pc_fieldsplit_type additive -sub_0_pc_fieldsplit_0_fields 0,1,2 -sub_0_pc_fieldsplit_1_fields 3 -sub_1_pc_bjacobi_blocks 16 -sub_1_sub_pc_type lu -snes_monitor -ksp_monitor
806: requires: !single
808: test:
809: suffix: composite_gs_newton
810: nsize: 2
811: args: -da_refine 3 -grashof 4e4 -lidvelocity 100 -snes_monitor -snes_type composite -snes_composite_type additiveoptimal -snes_composite_sneses ngs,newtonls -sub_0_snes_max_it 20 -sub_1_pc_type mg
812: requires: !single
814: test:
815: suffix: cuda
816: requires: cuda !single
817: args: -dm_vec_type cuda -dm_mat_type aijcusparse -pc_type none -ksp_type fgmres -snes_monitor -snes_rtol 1.e-5
819: test:
820: suffix: hip
821: requires: hip !single
822: args: -dm_vec_type hip -dm_mat_type aijhipsparse -pc_type none -ksp_type fgmres -snes_monitor -snes_rtol 1.e-5
824: test:
825: suffix: draw
826: args: -pc_type fieldsplit -snes_view draw -fieldsplit_x_velocity_pc_type mg -fieldsplit_x_velocity_pc_mg_galerkin pmat -fieldsplit_x_velocity_pc_mg_levels 2 -da_refine 1 -fieldsplit_x_velocity_mg_coarse_pc_type svd
827: requires: x !single
829: test:
830: suffix: drawports
831: args: -snes_monitor_solution draw::draw_ports -da_refine 1
832: output_file: output/ex19_draw.out
833: requires: x !single
835: test:
836: suffix: fas
837: args: -da_refine 4 -snes_monitor -snes_type fas -fas_levels_snes_type ngs -fas_levels_snes_ngs_sweeps 3 -fas_levels_snes_ngs_atol 0.0 -fas_levels_snes_ngs_stol 0.0 -grashof 4e4 -snes_fas_smoothup 6 -snes_fas_smoothdown 6 -lidvelocity 100
838: requires: !single
840: test:
841: suffix: fas_full
842: args: -da_refine 4 -snes_monitor -snes_type fas -snes_fas_type full -snes_fas_full_downsweep -fas_levels_snes_type ngs -fas_levels_snes_ngs_sweeps 3 -fas_levels_snes_ngs_atol 0.0 -fas_levels_snes_ngs_stol 0.0 -grashof 4e4 -snes_fas_smoothup 6 -snes_fas_smoothdown 6 -lidvelocity 100
843: requires: !single
845: test:
846: suffix: fdcoloring_ds
847: args: -da_refine 3 -snes_converged_reason -pc_type mg -mat_fd_type ds
848: output_file: output/ex19_2.out
849: requires: !single
851: test:
852: suffix: fdcoloring_ds_baij
853: args: -da_refine 3 -snes_converged_reason -pc_type mg -mat_fd_type ds -dm_mat_type baij
854: output_file: output/ex19_2.out
855: requires: !single
857: test:
858: suffix: fdcoloring_ds_bcols1
859: args: -da_refine 3 -snes_converged_reason -pc_type mg -mat_fd_type ds -mat_fd_coloring_bcols 1
860: output_file: output/ex19_2.out
861: requires: !single
863: test:
864: suffix: fdcoloring_wp
865: args: -da_refine 3 -snes_monitor -pc_type mg
866: requires: !single
868: test:
869: suffix: fdcoloring_wp_baij
870: args: -da_refine 3 -snes_monitor -pc_type mg -dm_mat_type baij
871: output_file: output/ex19_fdcoloring_wp.out
872: requires: !single
874: test:
875: suffix: fdcoloring_wp_bcols1
876: args: -da_refine 3 -snes_monitor -pc_type mg -mat_fd_coloring_bcols 1
877: output_file: output/ex19_fdcoloring_wp.out
878: requires: !single
880: test:
881: suffix: fieldsplit_2
882: args: -ksp_type fgmres -pc_type fieldsplit -pc_fieldsplit_block_size 4 -pc_fieldsplit_type additive -pc_fieldsplit_0_fields 0,1,2 -pc_fieldsplit_1_fields 3 -snes_monitor -ksp_monitor
883: requires: !single
885: test:
886: suffix: fieldsplit_3
887: args: -ksp_type fgmres -pc_type fieldsplit -pc_fieldsplit_block_size 4 -pc_fieldsplit_type additive -pc_fieldsplit_0_fields 0,1,2 -pc_fieldsplit_1_fields 3 -fieldsplit_0_pc_type lu -fieldsplit_1_pc_type lu -snes_monitor -ksp_monitor
888: requires: !single
890: test:
891: suffix: fieldsplit_4
892: args: -ksp_type fgmres -pc_type fieldsplit -pc_fieldsplit_block_size 4 -pc_fieldsplit_type SCHUR -pc_fieldsplit_0_fields 0,1,2 -pc_fieldsplit_1_fields 3 -fieldsplit_0_pc_type lu -fieldsplit_1_pc_type lu -snes_monitor -ksp_monitor
893: requires: !single
895: # HYPRE PtAP broken with complex numbers
896: test:
897: suffix: fieldsplit_hypre
898: nsize: 2
899: requires: hypre mumps !complex !defined(PETSC_HAVE_HYPRE_DEVICE)
900: args: -pc_type fieldsplit -pc_fieldsplit_block_size 4 -pc_fieldsplit_type SCHUR -pc_fieldsplit_0_fields 0,1,2 -pc_fieldsplit_1_fields 3 -fieldsplit_0_pc_type lu -fieldsplit_0_pc_factor_mat_solver_type mumps -fieldsplit_1_pc_type hypre -fieldsplit_1_pc_hypre_type boomeramg -snes_monitor -ksp_monitor
902: test:
903: suffix: fieldsplit_mumps
904: nsize: 2
905: requires: mumps
906: args: -pc_type fieldsplit -pc_fieldsplit_block_size 4 -pc_fieldsplit_type SCHUR -pc_fieldsplit_0_fields 0,1,2 -pc_fieldsplit_1_fields 3 -fieldsplit_0_pc_type lu -fieldsplit_1_pc_type lu -snes_monitor -ksp_monitor -fieldsplit_0_pc_factor_mat_solver_type mumps -fieldsplit_1_pc_factor_mat_solver_type mumps
907: output_file: output/ex19_fieldsplit_5.out
909: test:
910: suffix: greedy_coloring
911: nsize: 2
912: args: -da_refine 3 -snes_monitor -snes_fd_color -snes_fd_color_use_mat -mat_coloring_type greedy -mat_coloring_weight_type lf -mat_coloring_view> ex19_greedy_coloring.tmp 2>&1
913: requires: !single
915: # HYPRE PtAP broken with complex numbers
916: test:
917: suffix: hypre
918: nsize: 2
919: requires: hypre !complex !defined(PETSC_HAVE_HYPRE_DEVICE)
920: args: -da_refine 3 -snes_monitor -pc_type hypre -ksp_norm_type unpreconditioned
922: # ibcgs is broken when using device vectors
923: test:
924: suffix: ibcgs
925: nsize: 2
926: args: -ksp_type ibcgs -ksp_monitor -da_refine 2 -snes_view
927: requires: !complex !single
929: test:
930: suffix: kaczmarz
931: nsize: 2
932: args: -pc_type kaczmarz -ksp_monitor -snes_monitor -snes_view
933: requires: !single
935: test:
936: suffix: klu
937: requires: suitesparse
938: args: -da_grid_x 20 -da_grid_y 20 -pc_type lu -pc_factor_mat_solver_type klu
939: output_file: output/ex19_superlu.out
941: test:
942: suffix: klu_2
943: requires: suitesparse
944: args: -da_grid_x 20 -da_grid_y 20 -pc_type lu -pc_factor_mat_solver_type klu -pc_factor_mat_ordering_type nd
945: output_file: output/ex19_superlu.out
947: test:
948: suffix: klu_3
949: requires: suitesparse
950: args: -da_grid_x 20 -da_grid_y 20 -pc_type lu -pc_factor_mat_solver_type klu -mat_klu_use_btf 0
951: output_file: output/ex19_superlu.out
953: test:
954: suffix: ml
955: nsize: 2
956: requires: ml
957: args: -da_refine 3 -snes_monitor -pc_type ml
959: test:
960: suffix: ngmres_fas
961: args: -da_refine 4 -snes_monitor -snes_type ngmres -npc_fas_levels_snes_type ngs -npc_fas_levels_snes_ngs_sweeps 3 -npc_fas_levels_snes_ngs_atol 0.0 -npc_fas_levels_snes_ngs_stol 0.0 -npc_snes_type fas -npc_fas_levels_snes_type ngs -npc_snes_max_it 1 -npc_snes_fas_smoothup 6 -npc_snes_fas_smoothdown 6 -lidvelocity 100 -grashof 4e4
962: requires: !single
964: test:
965: suffix: ngmres_fas_gssecant
966: args: -da_refine 3 -snes_monitor -snes_type ngmres -npc_snes_type fas -npc_fas_levels_snes_type ngs -npc_fas_levels_snes_max_it 6 -npc_fas_levels_snes_ngs_secant -npc_fas_levels_snes_ngs_max_it 1 -npc_fas_coarse_snes_max_it 1 -lidvelocity 100 -grashof 4e4
967: requires: !single
969: test:
970: suffix: ngmres_fas_ms
971: nsize: 2
972: args: -snes_grid_sequence 2 -lidvelocity 200 -grashof 1e4 -snes_monitor -snes_view -snes_converged_reason -snes_type ngmres -npc_snes_type fas -npc_fas_coarse_snes_type newtonls -npc_fas_coarse_ksp_type preonly -npc_snes_max_it 1
973: requires: !single
975: test:
976: suffix: ngmres_nasm
977: nsize: 4
978: args: -da_refine 4 -da_overlap 2 -snes_monitor -snes_type ngmres -snes_max_it 10 -npc_snes_type nasm -npc_snes_nasm_type basic -grashof 4e4 -lidvelocity 100
979: requires: !single
981: test:
982: suffix: ngs
983: args: -snes_type ngs -snes_view -snes_monitor -snes_rtol 1e-4
984: requires: !single
986: test:
987: suffix: ngs_fd
988: args: -snes_type ngs -snes_ngs_secant -snes_view -snes_monitor -snes_rtol 1e-4
989: requires: !single
991: test:
992: suffix: parms
993: nsize: 2
994: requires: parms
995: args: -pc_type parms -ksp_monitor -snes_view
997: test:
998: suffix: superlu
999: requires: superlu
1000: args: -da_grid_x 20 -da_grid_y 20 -pc_type lu -pc_factor_mat_solver_type superlu
1002: test:
1003: suffix: superlu_sell
1004: requires: superlu
1005: args: -da_grid_x 20 -da_grid_y 20 -pc_type lu -pc_factor_mat_solver_type superlu -dm_mat_type sell -pc_factor_mat_ordering_type natural
1006: output_file: output/ex19_superlu.out
1008: test:
1009: suffix: superlu_dist
1010: requires: superlu_dist
1011: args: -da_grid_x 20 -da_grid_y 20 -pc_type lu -pc_factor_mat_solver_type superlu_dist
1012: output_file: output/ex19_superlu.out
1014: test:
1015: suffix: superlu_dist_2
1016: nsize: 2
1017: requires: superlu_dist
1018: args: -da_grid_x 20 -da_grid_y 20 -pc_type lu -pc_factor_mat_solver_type superlu_dist
1019: output_file: output/ex19_superlu.out
1021: test:
1022: suffix: superlu_dist_3d
1023: nsize: 4
1024: requires: superlu_dist superlu_dist_version_ge(9,0,0) !defined(PETSCTEST_VALGRIND)
1025: filter: grep -v iam | grep -v openMP | sed -e "s/Column permutation MMD_AT_PLUS_A/Column permutation METIS_AT_PLUS_A/g"
1026: args: -da_grid_x 20 -da_grid_y 20 -pc_type lu -pc_factor_mat_solver_type superlu_dist -mat_superlu_dist_3d -mat_superlu_dist_d 2 -snes_view -snes_monitor -ksp_monitor
1028: test:
1029: suffix: superlu_dist_2s
1030: nsize: 2
1031: requires: superlu_dist defined(PETSC_HAVE_SUPERLU_DIST_SINGLE)
1032: args: -da_grid_x 20 -da_grid_y 20 -pc_type lu -pc_factor_mat_solver_type superlu_dist -pc_precision single
1033: output_file: output/ex19_superlu.out
1035: test:
1036: suffix: mumps_mixed
1037: nsize: 2
1038: requires: mumps defined(PETSC_HAVE_MUMPS_MIXED_PRECISION)
1039: args: -da_grid_x 20 -da_grid_y 20 -pc_type lu -pc_factor_mat_solver_type mumps -pc_precision {{single double}}
1040: output_file: output/ex19_superlu.out
1042: test:
1043: suffix: superlu_dist_3ds
1044: nsize: 4
1045: requires: superlu_dist superlu_dist_version_ge(9,0,0) !defined(PETSCTEST_VALGRIND) defined(PETSC_HAVE_SUPERLU_DIST_SINGLE)
1046: filter: grep -v iam | grep -v openMP | sed -e "s/Column permutation MMD_AT_PLUS_A/Column permutation METIS_AT_PLUS_A/g"
1047: args: -da_grid_x 20 -da_grid_y 20 -pc_type lu -pc_factor_mat_solver_type superlu_dist -mat_superlu_dist_3d -mat_superlu_dist_d 2 -snes_view -snes_monitor -ksp_monitor -pc_precision single
1049: test:
1050: suffix: superlu_equil
1051: requires: superlu
1052: args: -da_grid_x 20 -da_grid_y 20 -{snes,ksp}_monitor -pc_type lu -pc_factor_mat_solver_type superlu -mat_superlu_equil
1054: test:
1055: suffix: superlu_equil_sell
1056: requires: superlu
1057: args: -da_grid_x 20 -da_grid_y 20 -{snes,ksp}_monitor -pc_type lu -pc_factor_mat_solver_type superlu -mat_superlu_equil -dm_mat_type sell -pc_factor_mat_ordering_type natural
1058: output_file: output/ex19_superlu_equil.out
1060: test:
1061: suffix: tcqmr
1062: args: -da_refine 1 -ksp_monitor -ksp_type tcqmr
1063: requires: !single
1065: test:
1066: suffix: tfqmr
1067: args: -da_refine 1 -ksp_monitor -ksp_type tfqmr
1068: requires: !single
1070: test:
1071: suffix: umfpack
1072: requires: suitesparse
1073: args: -da_refine 2 -pc_type lu -pc_factor_mat_solver_type umfpack -snes_view -snes_monitor -ksp_monitor -pc_factor_mat_ordering_type external
1075: test:
1076: suffix: tut_1
1077: nsize: 4
1078: requires: !single
1079: args: -da_refine 5 -snes_monitor -ksp_monitor -snes_view
1081: test:
1082: suffix: tut_2
1083: nsize: 4
1084: requires: !single
1085: args: -da_refine 5 -snes_monitor -ksp_monitor -snes_view -pc_type mg
1087: # HYPRE PtAP broken with complex numbers
1088: test:
1089: suffix: tut_3
1090: nsize: 4
1091: requires: hypre !single !complex !defined(PETSC_HAVE_HYPRE_DEVICE)
1092: args: -da_refine 5 -snes_monitor -snes_converged_reason -pc_type hypre -dm_mat_type {{aij baij}}
1094: test:
1095: suffix: tut_3_seq
1096: nsize: 1
1097: requires: hypre !single !complex !defined(PETSC_HAVE_HYPRE_DEVICE)
1098: args: -da_refine 1 -snes_monitor -snes_converged_reason -pc_type hypre -dm_mat_type {{seqaij mpiaij seqbaij mpibaij}}
1100: test:
1101: suffix: tut_8
1102: nsize: 4
1103: requires: ml !single
1104: args: -da_refine 5 -snes_monitor -ksp_monitor -snes_view -pc_type ml
1106: test:
1107: suffix: tut_4
1108: nsize: 1
1109: requires: !single
1110: args: -da_refine 5 -log_view
1111: filter: head -n 2
1112: filter_output: head -n 2
1114: test:
1115: suffix: tut_5
1116: nsize: 1
1117: requires: !single
1118: args: -da_refine 5 -log_view -pc_type mg
1119: filter: head -n 2
1120: filter_output: head -n 2
1122: test:
1123: suffix: tut_6
1124: nsize: 4
1125: requires: !single
1126: args: -da_refine 5 -log_view
1127: filter: head -n 2
1128: filter_output: head -n 2
1130: test:
1131: suffix: tut_7
1132: nsize: 4
1133: requires: !single
1134: args: -da_refine 5 -log_view -pc_type mg
1135: filter: head -n 2
1136: filter_output: head -n 2
1138: test:
1139: suffix: cuda_1
1140: nsize: 1
1141: requires: cuda
1142: args: -snes_monitor -dm_mat_type seqaijcusparse -dm_vec_type seqcuda -pc_type gamg -ksp_monitor -mg_levels_ksp_max_it 1
1144: test:
1145: suffix: cuda_2
1146: nsize: 3
1147: requires: cuda !single
1148: args: -snes_monitor -dm_mat_type mpiaijcusparse -dm_vec_type mpicuda -pc_type gamg -ksp_monitor -mg_levels_ksp_max_it 1
1150: test:
1151: suffix: cuda_dm_bind_below
1152: nsize: 2
1153: requires: cuda defined(PETSC_USE_LOG)
1154: args: -dm_mat_type aijcusparse -dm_vec_type cuda -da_refine 3 -pc_type mg -mg_levels_ksp_type chebyshev -mg_levels_pc_type jacobi -log_view -pc_mg_log -dm_bind_below 10000
1155: filter: awk "/Level/ {print \$NF}"
1157: test:
1158: suffix: hip_1
1159: nsize: 1
1160: requires: hip
1161: args: -snes_monitor -dm_mat_type mpiaijhipsparse -dm_vec_type hip -pc_type gamg -ksp_monitor -mg_levels_ksp_max_it 1
1163: test:
1164: suffix: hip_2
1165: nsize: 3
1166: requires: hip !single
1167: args: -snes_monitor -dm_mat_type mpiaijhipsparse -dm_vec_type mpihip -pc_type gamg -ksp_monitor -mg_levels_ksp_max_it 1
1169: test:
1170: suffix: hip_dm_bind_below
1171: nsize: 2
1172: requires: hip
1173: args: -dm_mat_type aijhipsparse -dm_vec_type hip -da_refine 3 -pc_type mg -mg_levels_ksp_type chebyshev -mg_levels_pc_type jacobi -log_view -pc_mg_log -dm_bind_below 10000
1174: filter: awk "/Level/ {print \$NF}"
1176: test:
1177: suffix: viennacl_dm_bind_below
1178: nsize: 2
1179: requires: viennacl
1180: args: -dm_mat_type aijviennacl -dm_vec_type viennacl -da_refine 3 -pc_type mg -mg_levels_ksp_type chebyshev -mg_levels_pc_type jacobi -log_view -pc_mg_log -dm_bind_below 10000
1181: filter: awk "/Level/ {print \$NF}"
1183: test:
1184: suffix: seqbaijmkl
1185: nsize: 1
1186: requires: defined(PETSC_HAVE_MKL_SPARSE_OPTIMIZE)
1187: args: -dm_mat_type baij -snes_monitor -ksp_monitor -snes_view
1189: test:
1190: suffix: mpibaijmkl
1191: nsize: 2
1192: requires: defined(PETSC_HAVE_MKL_SPARSE_OPTIMIZE)
1193: args: -dm_mat_type baij -snes_monitor -ksp_monitor -snes_view
1195: test:
1196: suffix: cpardiso
1197: nsize: 4
1198: requires: mkl_cpardiso
1199: args: -pc_type lu -pc_factor_mat_solver_type mkl_cpardiso -ksp_monitor
1201: test:
1202: suffix: logviewmemory
1203: requires: defined(PETSC_USE_LOG) !defined(PETSC_HAVE_THREADSAFETY)
1204: args: -log_view -log_view_memory -da_refine 4
1205: filter: grep MatFDColorSetUp | wc -w | xargs -I % sh -c "expr % \> 21"
1207: test:
1208: suffix: fs
1209: requires: !single
1210: args: -pc_type fieldsplit -da_refine 3 -all_ksp_monitor -fieldsplit_y_velocity_pc_type lu -fieldsplit_temperature_pc_type lu -fieldsplit_x_velocity_pc_type lu -snes_view
1212: test:
1213: suffix: asm_matconvert
1214: args: -mat_type aij -pc_type asm -pc_asm_sub_mat_type dense -snes_view
1216: test:
1217: suffix: euclid
1218: nsize: 2
1219: requires: hypre !single !complex !defined(PETSC_HAVE_HYPRE_MIXEDINT) !defined(PETSC_HAVE_HYPRE_DEVICE)
1220: args: -da_refine 2 -ksp_monitor -snes_monitor -snes_view -pc_type hypre -pc_hypre_type euclid
1222: test:
1223: suffix: euclid_bj
1224: nsize: 2
1225: requires: hypre !single !complex !defined(PETSC_HAVE_HYPRE_MIXEDINT) !defined(PETSC_HAVE_HYPRE_DEVICE)
1226: args: -da_refine 2 -ksp_monitor -snes_monitor -snes_view -pc_type hypre -pc_hypre_type euclid -pc_hypre_euclid_bj
1228: test:
1229: suffix: euclid_droptolerance
1230: nsize: 1
1231: requires: hypre !single !complex !defined(PETSC_HAVE_HYPRE_MIXEDINT) !defined(PETSC_HAVE_HYPRE_DEVICE)
1232: args: -da_refine 2 -ksp_monitor -snes_monitor -snes_view -pc_type hypre -pc_hypre_type euclid -pc_hypre_euclid_droptolerance .1
1234: test:
1235: suffix: failure_size
1236: nsize: 1
1237: requires: !defined(PETSC_USE_64BIT_INDICES) !defined(PETSCTEST_VALGRIND) !defined(PETSC_HAVE_SANITIZER)
1238: args: -da_refine 100 -petsc_ci_portable_error_output -error_output_stdout
1239: filter: grep -E -v "(memory block|leaked context|not freed before MPI_Finalize|Could be the program crashed)"
1241: testset:
1242: requires: hpddm cuda
1243: args: -snes_monitor -ksp_converged_reason -ksp_type hpddm -pc_type jacobi -dm_mat_type aijcusparse -dm_vec_type cuda
1244: test:
1245: suffix: hpddm_cuda
1246: filter: sed -e "s/Linear solve converged due to CONVERGED_RTOL iterations 15/Linear solve converged due to CONVERGED_RTOL iterations 14/g" -e "s/Linear solve converged due to CONVERGED_RTOL iterations 11/Linear solve converged due to CONVERGED_RTOL iterations 10/"
1247: args: -ksp_hpddm_type {{gmres gcrodr}separate output} -ksp_hpddm_precision {{single double}shared output}
1248: test:
1249: suffix: hpddm_cuda_right
1250: filter: sed -e "s/Linear solve converged due to CONVERGED_RTOL iterations 15/Linear solve converged due to CONVERGED_RTOL iterations 14/g"
1251: args: -ksp_hpddm_type gcrodr -ksp_pc_side right
1252: output_file: output/ex19_hpddm_cuda_ksp_hpddm_type-gcrodr.out
1254: TEST*/