60
60
petscsys.h - system routines petscmat.h - matrices
61
61
petscis.h - index sets petscksp.h - Krylov subspace methods
62
62
petscviewer.h - viewers petscpc.h - preconditioners
63
petscsles.h - linear solvers
63
petscksp.h - linear solvers
65
65
#include "petscsnes.h"
66
66
#include "petscda.h"
135
135
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
136
136
Create nonlinear solver context
138
Process adiC: FormFunctionLocal FormFunctionLocali
138
Process adiC(36): FormFunctionLocal FormFunctionLocali
139
139
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
140
140
ierr = DMMGSetSNESLocal(dmmg,FormFunctionLocal,0,ad_FormFunctionLocal,admf_FormFunctionLocal);CHKERRQ(ierr);
141
141
ierr = DMMGSetSNESLocali(dmmg,FormFunctionLocali,ad_FormFunctionLocali,admf_FormFunctionLocali);CHKERRQ(ierr);
219
219
- You MUST call VecRestoreArray() when you no longer need access to
222
ierr = DAVecGetArray(da,X,(void**)&x);CHKERRQ(ierr);
222
ierr = DAVecGetArray(da,X,&x);CHKERRQ(ierr);
225
225
Compute initial guess over the locally owned part of the grid
240
ierr = DAVecRestoreArray(da,X,(void**)&x);CHKERRQ(ierr);
240
ierr = DAVecRestoreArray(da,X,&x);CHKERRQ(ierr);
243
243
int FormFunctionLocal(DALocalInfo *info,Field **x,Field **f,void *ptr)
401
401
/* Test whether we are on the right edge of the global array */
402
402
if (i == info->mx-1) {
403
if (c == 0) *f = x[j][i].u;
404
else if (c == 1) *f = x[j][i].v;
403
if (c == 0) *f = x[j][i].u;
404
else if (c == 1) *f = x[j][i].v;
405
405
else if (c == 2) *f = x[j][i].omega - (x[j][i].v - x[j][i-1].v)*dhx;
406
else *f = x[j][i].temp - (PetscReal)(grashof>0);
406
else *f = x[j][i].temp - (PetscReal)(grashof>0);
408
408
/* Test whether we are on the left edge of the global array */
409
409
} else if (i == 0) {
410
if (c == 0) *f = x[j][i].u;
411
else if (c == 1) *f = x[j][i].v;
410
if (c == 0) *f = x[j][i].u;
411
else if (c == 1) *f = x[j][i].v;
412
412
else if (c == 2) *f = x[j][i].omega - (x[j][i+1].v - x[j][i].v)*dhx;
413
else *f = x[j][i].temp;
413
else *f = x[j][i].temp;
415
415
/* Test whether we are on the top edge of the global array */
416
416
} else if (j == info->my-1) {
417
if (c == 0) *f = x[j][i].u - lid;
418
else if (c == 1) *f = x[j][i].v;
417
if (c == 0) *f = x[j][i].u - lid;
418
else if (c == 1) *f = x[j][i].v;
419
419
else if (c == 2) *f = x[j][i].omega + (x[j][i].u - x[j-1][i].u)*dhy;
420
else *f = x[j][i].temp-x[j-1][i].temp;
420
else *f = x[j][i].temp-x[j-1][i].temp;
422
422
/* Test whether we are on the bottom edge of the global array */
423
423
} else if (j == 0) {
424
if (c == 0) *f = x[j][i].u;
425
else if (c == 1) *f = x[j][i].v;
424
if (c == 0) *f = x[j][i].u;
425
else if (c == 1) *f = x[j][i].v;
426
426
else if (c == 2) *f = x[j][i].omega + (x[j+1][i].u - x[j][i].u)*dhy;
427
else *f = x[j][i].temp-x[j+1][i].temp;
427
else *f = x[j][i].temp - x[j+1][i].temp;
429
429
/* Compute over the interior points */