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

« back to all changes in this revision

Viewing changes to src/mat/impls/adic/matadic.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:
58
58
#include "src/dm/da/daimpl.h"
59
59
 
60
60
#undef __FUNCT__  
61
 
#define __FUNCT__ "MatGetDiagonal_DAD"
 
61
#define __FUNCT__ "MatGetDiagonal_DAAD"
62
62
int MatGetDiagonal_DAAD(Mat A,Vec dd)
63
63
{
64
64
  Mat_DAAD      *a = (Mat_DAAD*)A->data;
82
82
  ierr = VecRestoreArray(a->localu,&avu);CHKERRQ(ierr);
83
83
 
84
84
  PetscADResetIndep();
85
 
  PetscADIncrementTotalGradSize(1);
 
85
  ierr = PetscADIncrementTotalGradSize(1);CHKERRQ(ierr);
86
86
  PetscADSetIndepDone();
87
87
 
88
88
  ierr = VecGetArray(dd,&d);CHKERRQ(ierr);
93
93
    for (stencil.j = info.ys; stencil.j<info.ys+info.ym; stencil.j++) {
94
94
      for (stencil.i = info.xs; stencil.i<info.xs+info.xm; stencil.i++) {
95
95
        for (stencil.c = 0; stencil.c<info.dof; stencil.c++) {
96
 
          gI   = stencil.c + (stencil.i - info.gxs)*info.dof + (stencil.j - info.gys)*info.dof*info.xm + (stencil.k - info.gzs)*info.dof*info.xm*info.ym;
 
96
          gI   = stencil.c + (stencil.i - info.gxs)*info.dof + (stencil.j - info.gys)*info.dof*info.gxm + (stencil.k - info.gzs)*info.dof*info.gxm*info.gym;
97
97
          ad_vustart[1+2*gI] = 1.0;
98
98
          ierr = (*a->da->adicmf_lfi)(&info,&stencil,ad_vu,ad_f,a->ctx);CHKERRQ(ierr);
99
99
          d[nI] = ad_f[1];
123
123
  void*         *ad_vu;
124
124
 
125
125
  PetscFunctionBegin;
 
126
  if (omega != 1.0) SETERRQ(PETSC_ERR_ARG_WRONG,"Currently only support omega of 1.0");
 
127
  if (fshift)       SETERRQ(PETSC_ERR_ARG_WRONG,"Currently do not support fshift");
126
128
  if (its <= 0 || lits <= 0) SETERRQ2(PETSC_ERR_ARG_WRONG,"Relaxation requires global its %d and local its %d both positive",its,lits);
 
129
 
127
130
  if (!a->diagonal) {
128
131
    ierr = DACreateGlobalVector(a->da,&a->diagonal);CHKERRQ(ierr);
129
132
  }
156
159
  ierr = VecRestoreArray(localxx,&av);CHKERRQ(ierr);
157
160
 
158
161
  PetscADResetIndep();
159
 
  PetscADIncrementTotalGradSize(1);
 
162
  ierr = PetscADIncrementTotalGradSize(1);CHKERRQ(ierr);
160
163
  PetscADSetIndepDone();
161
164
 
162
165
  ierr = VecGetArray(dd,&d);CHKERRQ(ierr);
171
174
          for (stencil.i = info.xs; stencil.i<info.xs+info.xm; stencil.i++) {
172
175
            for (stencil.c = 0; stencil.c<info.dof; stencil.c++) {
173
176
              ierr = (*a->da->adicmf_lfi)(&info,&stencil,ad_vu,ad_f,a->ctx);CHKERRQ(ierr);
174
 
              gI   = stencil.c + (stencil.i - info.gxs)*info.dof + (stencil.j - info.gys)*info.dof*info.xm + (stencil.k - info.gzs)*info.dof*info.xm*info.ym;
 
177
              gI   = stencil.c + (stencil.i - info.gxs)*info.dof + (stencil.j - info.gys)*info.dof*info.gxm + (stencil.k - info.gzs)*info.dof*info.gxm*info.gym;
175
178
              ad_vustart[1+2*gI] += (b[nI] - ad_f[1])/d[nI];
176
179
              nI++;
177
180
            }
186
189
          for (stencil.i = info.xs+info.xm-1; stencil.i>=info.xs; stencil.i--) {
187
190
            for (stencil.c = info.dof-1; stencil.c>=0; stencil.c--) {
188
191
              ierr = (*a->da->adicmf_lfi)(&info,&stencil,ad_vu,ad_f,a->ctx);CHKERRQ(ierr);
189
 
              gI   = stencil.c + (stencil.i - info.gxs)*info.dof + (stencil.j - info.gys)*info.dof*info.xm + (stencil.k - info.gzs)*info.dof*info.xm*info.ym;
 
192
              gI   = stencil.c + (stencil.i - info.gxs)*info.dof + (stencil.j - info.gys)*info.dof*info.gxm + (stencil.k - info.gzs)*info.dof*info.gxm*info.gym;
190
193
              ad_vustart[1+2*gI] += (b[nI] - ad_f[1])/d[nI];
191
194
              nI--;
192
195
            }
233
236
       0,
234
237
       0,
235
238
       MatMult_DAAD,
236
 
       0,
237
 
       0,
238
 
       0,
239
 
       0,
240
 
       0,
241
 
       0,
242
 
       0,
 
239
/* 4*/ 0,
 
240
       0,
 
241
       0,
 
242
       0,
 
243
       0,
 
244
       0,
 
245
/*10*/ 0,
243
246
       0,
244
247
       0,
245
248
       MatRelax_DAAD,
246
249
       0,
247
 
       0,
 
250
/*15*/ 0,
248
251
       0,
249
252
       MatGetDiagonal_DAAD,
250
253
       0,
251
254
       0,
252
 
       0,
 
255
/*20*/ 0,
253
256
       MatAssemblyEnd_DAAD,
254
257
       0,
255
258
       0,
256
259
       0,
257
 
       0,
258
 
       0,
259
 
       0,
260
 
       0,
261
 
       0,
262
 
       0,
263
 
       0,
264
 
       0,
265
 
       0,
266
 
       0,
267
 
       0,
268
 
       0,
269
 
       0,
270
 
       0,
271
 
       0,
272
 
       0,
273
 
       0,
274
 
       0,
275
 
       0,
276
 
       0,
277
 
       0,
278
 
       0,
279
 
       0,
280
 
       0,
281
 
       0,
282
 
       0,
283
 
       0,
284
 
       0,
285
 
       0,
286
 
       0,
287
 
       0,
288
 
       0,
289
 
       0,
290
 
       0,
291
 
       0,
292
 
       0,
 
260
/*25*/ 0,
 
261
       0,
 
262
       0,
 
263
       0,
 
264
       0,
 
265
/*30*/ 0,
 
266
       0,
 
267
       0,
 
268
       0,
 
269
       0,
 
270
/*35*/ 0,
 
271
       0,
 
272
       0,
 
273
       0,
 
274
       0,
 
275
/*40*/ 0,
 
276
       0,
 
277
       0,
 
278
       0,
 
279
       0,
 
280
/*45*/ 0,
 
281
       0,
 
282
       0,
 
283
       0,
 
284
       0,
 
285
/*50*/ 0,
 
286
       0,
 
287
       0,
 
288
       0,
 
289
       0,
 
290
/*55*/ 0,
 
291
       0,
 
292
       0,
 
293
       0,
 
294
       0,
 
295
/*60*/ 0,
293
296
       MatDestroy_DAAD,
294
297
       0,
295
298
       0,
296
299
       0,
297
 
       0,
298
 
       0,
299
 
       0,
300
 
       0,
301
 
       0,
302
 
       0,
303
 
       0,
304
 
       0,
305
 
       0,
306
 
       0};
 
300
/*65*/ 0,
 
301
       0,
 
302
       0,
 
303
       0,
 
304
       0,
 
305
/*70*/ 0,
 
306
       0,
 
307
       0,
 
308
       0,
 
309
       0,
 
310
/*75*/ 0,
 
311
       0,
 
312
       0,
 
313
       0,
 
314
       0,
 
315
/*80*/ 0,
 
316
       0,
 
317
       0,
 
318
       0,
 
319
/*85*/ 0
 
320
};
307
321
 
308
322
/* --------------------------------------------------------------------------------*/
309
323
 
369
383
}
370
384
EXTERN_C_END
371
385
 
 
386
/*MC
 
387
  MATDAAD - MATDAAD = "daad" - A matrix type that can do matrix-vector products using a local function that
 
388
  is differentiated with ADIFOR or ADIC. 
 
389
 
 
390
  Level: intermediate
 
391
 
 
392
.seealso: MatCreateDAAD
 
393
M*/
 
394
 
372
395
EXTERN_C_BEGIN
373
396
#undef __FUNCT__  
374
397
#define __FUNCT__ "MatCreate_DAAD"
417
440
  int      ierr,(*f)(Mat,void*);
418
441
 
419
442
  PetscFunctionBegin;
420
 
  PetscValidHeaderSpecific(A,MAT_COOKIE);
421
 
  PetscValidHeader(da);
 
443
  PetscValidHeaderSpecific(A,MAT_COOKIE,1);
 
444
  PetscValidHeaderSpecific(da,DA_COOKIE,2);
422
445
  ierr = PetscObjectQueryFunction((PetscObject)A,"MatDAADSetDA_C",(void (**)(void))&f);CHKERRQ(ierr);
423
446
  if (f) {
424
447
    ierr = (*f)(A,da);CHKERRQ(ierr);
447
470
  int      ierr,(*f)(Mat,void*);
448
471
 
449
472
  PetscFunctionBegin;
450
 
  PetscValidHeaderSpecific(A,MAT_COOKIE);
451
 
  PetscValidHeader(snes);
 
473
  PetscValidHeaderSpecific(A,MAT_COOKIE,1);
 
474
  PetscValidHeaderSpecific(snes,SNES_COOKIE,2);
452
475
  ierr = PetscObjectQueryFunction((PetscObject)A,"MatDAADSetSNES_C",(void (**)(void))&f);CHKERRQ(ierr);
453
476
  if (f) {
454
477
    ierr = (*f)(A,snes);CHKERRQ(ierr);
477
500
  int      ierr,(*f)(Mat,void*);
478
501
 
479
502
  PetscFunctionBegin;
480
 
  PetscValidHeaderSpecific(A,MAT_COOKIE);
 
503
  PetscValidHeaderSpecific(A,MAT_COOKIE,1);
481
504
  ierr = PetscObjectQueryFunction((PetscObject)A,"MatDAADSetCtx_C",(void (**)(void))&f);CHKERRQ(ierr);
482
505
  if (f) {
483
506
    ierr = (*f)(A,ctx);CHKERRQ(ierr);