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