~ubuntu-branches/ubuntu/warty/petsc/warty

« back to all changes in this revision

Viewing changes to src/snes/examples/tutorials/ex19.c

  • Committer: Bazaar Package Importer
  • Author(s): Adam C. Powell, IV
  • Date: 2004-06-07 13:41:43 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040607134143-92p586zrauvie0le
Tags: 2.2.0-2
* Upstream patch level 2.
* New PETSC_BOPT_EXTRA option for different BOPT and lib names, with _c++
  symlinks only for plain and single (closes: #249617).
* New DEBIAN_DIST=contrib option to link with hypre, parmetis (closes:
  #249619).
* Combined petsc-c and petsc-fortran substvars into petsc-compilers.
* Extra quote in -dev prerm eliminates "too many arguments" problem.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 
64
64
*/
65
65
#include "petscsnes.h"
66
66
#include "petscda.h"
135
135
    /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
136
136
       Create nonlinear solver context
137
137
 
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
220
220
         the array.
221
221
  */
222
 
  ierr = DAVecGetArray(da,X,(void**)&x);CHKERRQ(ierr);
 
222
  ierr = DAVecGetArray(da,X,&x);CHKERRQ(ierr);
223
223
 
224
224
  /*
225
225
     Compute initial guess over the locally owned part of the grid
237
237
  /*
238
238
     Restore vector
239
239
  */
240
 
  ierr = DAVecRestoreArray(da,X,(void**)&x);CHKERRQ(ierr);
 
240
  ierr = DAVecRestoreArray(da,X,&x);CHKERRQ(ierr);
241
241
  return 0;
242
242
243
243
int FormFunctionLocal(DALocalInfo *info,Field **x,Field **f,void *ptr)
400
400
 
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);
407
407
 
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;
414
414
 
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;
421
421
 
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;
428
428
 
429
429
  /* Compute over the interior points */
430
430
  } else {