Actual source code: iispai.c

  1: /*
  2:    3/99 Modified by Stephen Barnard to support SPAI version 3.0
  3: */

  5: /*
  6:       Provides an interface to the SPAI Sparse Approximate Inverse Preconditioner
  7:    Code written by Stephen Barnard.

  9:       Note: there is some BAD memory bleeding below!

 11:       This code needs work

 13:    1) get rid of all memory bleeding
 14:    2) fix PETSc/interface so that it gets if the matrix is symmetric from the matrix
 15:       rather than having the sp flag for PC_SPAI
 16:    3) fix to set the block size based on the matrix block size

 18: */
 19: #include <petscmacros.h>
 20: #if !PetscDefined(SKIP_COMPLEX)
 21:   #define PETSC_SKIP_COMPLEX /* since spai uses I which conflicts with some complex implementations */
 22: #endif

 24: #include <petsc/private/pcimpl.h>

 26: /*
 27:     These are the SPAI include files
 28: */
 29: EXTERN_C_BEGIN
 30: #define SPAI_USE_MPI /* required for setting SPAI_Comm correctly in basics.h */
 31: #include <spai.h>
 32: #include <matrix.h>
 33: EXTERN_C_END

 35: static PetscErrorCode ConvertMatToMatrix(MPI_Comm, Mat, Mat, matrix **);
 36: static PetscErrorCode ConvertMatrixToMat(MPI_Comm, matrix *, Mat *);

 38: typedef struct {
 39:   matrix *B;  /* matrix in SPAI format */
 40:   matrix *BT; /* transpose of matrix in SPAI format */
 41:   matrix *M;  /* the approximate inverse in SPAI format */

 43:   Mat PM; /* the approximate inverse PETSc format */

 45:   double epsilon;    /* tolerance */
 46:   int    nbsteps;    /* max number of "improvement" steps per line */
 47:   int    max;        /* max dimensions of is_I, q, etc. */
 48:   int    maxnew;     /* max number of new entries per step */
 49:   int    block_size; /* constant block size */
 50:   int    cache_size; /* one of (1,2,3,4,5,6) indicting size of cache */
 51:   int    verbose;    /* SPAI prints timing and statistics */

 53:   int      sp;        /* symmetric nonzero pattern */
 54:   MPI_Comm comm_spai; /* communicator to be used with spai */
 55: } PC_SPAI;

 57: static PetscErrorCode PCSetUp_SPAI(PC pc)
 58: {
 59:   PC_SPAI *ispai = (PC_SPAI *)pc->data;
 60:   Mat      AT;

 62:   PetscFunctionBegin;
 63:   init_SPAI();

 65:   if (ispai->sp) {
 66:     PetscCall(ConvertMatToMatrix(ispai->comm_spai, pc->pmat, pc->pmat, &ispai->B));
 67:   } else {
 68:     /* Use the transpose to get the column nonzero structure. */
 69:     PetscCall(MatTranspose(pc->pmat, MAT_INITIAL_MATRIX, &AT));
 70:     PetscCall(ConvertMatToMatrix(ispai->comm_spai, pc->pmat, AT, &ispai->B));
 71:     PetscCall(MatDestroy(&AT));
 72:   }

 74:   /* Destroy the transpose */
 75:   /* Don't know how to do it. PETSc developers? */

 77:   /* construct SPAI preconditioner */
 78:   /* FILE *messages */    /* file for warning messages */
 79:   /* double epsilon */    /* tolerance */
 80:   /* int nbsteps */       /* max number of "improvement" steps per line */
 81:   /* int max */           /* max dimensions of is_I, q, etc. */
 82:   /* int maxnew */        /* max number of new entries per step */
 83:   /* int block_size */    /* block_size == 1 specifies scalar elements
 84:                               block_size == n specifies nxn constant-block elements
 85:                               block_size == 0 specifies variable-block elements */
 86:   /* int cache_size */    /* one of (1,2,3,4,5,6) indicting size of cache. cache_size == 0 indicates no caching */
 87:   /* int    verbose    */ /* verbose == 0 specifies that SPAI is silent
 88:                               verbose == 1 prints timing and matrix statistics */

 90:   PetscCallExternal(bspai, ispai->B, &ispai->M, stdout, ispai->epsilon, ispai->nbsteps, ispai->max, ispai->maxnew, ispai->block_size, ispai->cache_size, ispai->verbose);

 92:   PetscCall(ConvertMatrixToMat(PetscObjectComm((PetscObject)pc), ispai->M, &ispai->PM));

 94:   /* free the SPAI matrices */
 95:   sp_free_matrix(ispai->B);
 96:   sp_free_matrix(ispai->M);
 97:   PetscFunctionReturn(PETSC_SUCCESS);
 98: }

100: static PetscErrorCode PCApply_SPAI(PC pc, Vec xx, Vec y)
101: {
102:   PC_SPAI *ispai = (PC_SPAI *)pc->data;

104:   PetscFunctionBegin;
105:   /* Now using PETSc's multiply */
106:   PetscCall(MatMult(ispai->PM, xx, y));
107:   PetscFunctionReturn(PETSC_SUCCESS);
108: }

110: static PetscErrorCode PCMatApply_SPAI(PC pc, Mat X, Mat Y)
111: {
112:   PC_SPAI *ispai = (PC_SPAI *)pc->data;

114:   PetscFunctionBegin;
115:   /* Now using PETSc's multiply */
116:   PetscCall(MatMatMult(ispai->PM, X, MAT_REUSE_MATRIX, PETSC_CURRENT, &Y));
117:   PetscFunctionReturn(PETSC_SUCCESS);
118: }

120: static PetscErrorCode PCDestroy_SPAI(PC pc)
121: {
122:   PC_SPAI *ispai = (PC_SPAI *)pc->data;

124:   PetscFunctionBegin;
125:   PetscCall(MatDestroy(&ispai->PM));
126:   PetscCallMPI(MPI_Comm_free(&ispai->comm_spai));
127:   PetscCall(PetscFree(pc->data));
128:   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCSPAISetEpsilon_C", NULL));
129:   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCSPAISetNBSteps_C", NULL));
130:   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCSPAISetMax_C", NULL));
131:   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCSPAISetMaxNew_C", NULL));
132:   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCSPAISetBlockSize_C", NULL));
133:   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCSPAISetCacheSize_C", NULL));
134:   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCSPAISetVerbose_C", NULL));
135:   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCSPAISetSp_C", NULL));
136:   PetscFunctionReturn(PETSC_SUCCESS);
137: }

139: static PetscErrorCode PCView_SPAI(PC pc, PetscViewer viewer)
140: {
141:   PC_SPAI  *ispai = (PC_SPAI *)pc->data;
142:   PetscBool isascii;

144:   PetscFunctionBegin;
145:   PetscCall(PetscObjectTypeCompare((PetscObject)viewer, PETSCVIEWERASCII, &isascii));
146:   if (isascii) {
147:     PetscCall(PetscViewerASCIIPrintf(viewer, "    epsilon %g\n", ispai->epsilon));
148:     PetscCall(PetscViewerASCIIPrintf(viewer, "    nbsteps %d\n", ispai->nbsteps));
149:     PetscCall(PetscViewerASCIIPrintf(viewer, "    max %d\n", ispai->max));
150:     PetscCall(PetscViewerASCIIPrintf(viewer, "    maxnew %d\n", ispai->maxnew));
151:     PetscCall(PetscViewerASCIIPrintf(viewer, "    block_size %d\n", ispai->block_size));
152:     PetscCall(PetscViewerASCIIPrintf(viewer, "    cache_size %d\n", ispai->cache_size));
153:     PetscCall(PetscViewerASCIIPrintf(viewer, "    verbose %d\n", ispai->verbose));
154:     PetscCall(PetscViewerASCIIPrintf(viewer, "    sp %d\n", ispai->sp));
155:   }
156:   PetscFunctionReturn(PETSC_SUCCESS);
157: }

159: static PetscErrorCode PCSPAISetEpsilon_SPAI(PC pc, PetscReal epsilon1)
160: {
161:   PC_SPAI *ispai = (PC_SPAI *)pc->data;

163:   PetscFunctionBegin;
164:   ispai->epsilon = (double)epsilon1;
165:   PetscFunctionReturn(PETSC_SUCCESS);
166: }

168: static PetscErrorCode PCSPAISetNBSteps_SPAI(PC pc, PetscInt nbsteps1)
169: {
170:   PC_SPAI *ispai = (PC_SPAI *)pc->data;

172:   PetscFunctionBegin;
173:   ispai->nbsteps = (int)nbsteps1;
174:   PetscFunctionReturn(PETSC_SUCCESS);
175: }

177: /* added 1/7/99 g.h. */
178: static PetscErrorCode PCSPAISetMax_SPAI(PC pc, PetscInt max1)
179: {
180:   PC_SPAI *ispai = (PC_SPAI *)pc->data;

182:   PetscFunctionBegin;
183:   ispai->max = (int)max1;
184:   PetscFunctionReturn(PETSC_SUCCESS);
185: }

187: static PetscErrorCode PCSPAISetMaxNew_SPAI(PC pc, PetscInt maxnew1)
188: {
189:   PC_SPAI *ispai = (PC_SPAI *)pc->data;

191:   PetscFunctionBegin;
192:   ispai->maxnew = (int)maxnew1;
193:   PetscFunctionReturn(PETSC_SUCCESS);
194: }

196: static PetscErrorCode PCSPAISetBlockSize_SPAI(PC pc, PetscInt block_size1)
197: {
198:   PC_SPAI *ispai = (PC_SPAI *)pc->data;

200:   PetscFunctionBegin;
201:   ispai->block_size = (int)block_size1;
202:   PetscFunctionReturn(PETSC_SUCCESS);
203: }

205: static PetscErrorCode PCSPAISetCacheSize_SPAI(PC pc, PetscInt cache_size)
206: {
207:   PC_SPAI *ispai = (PC_SPAI *)pc->data;

209:   PetscFunctionBegin;
210:   ispai->cache_size = (int)cache_size;
211:   PetscFunctionReturn(PETSC_SUCCESS);
212: }

214: static PetscErrorCode PCSPAISetVerbose_SPAI(PC pc, PetscInt verbose)
215: {
216:   PC_SPAI *ispai = (PC_SPAI *)pc->data;

218:   PetscFunctionBegin;
219:   ispai->verbose = (int)verbose;
220:   PetscFunctionReturn(PETSC_SUCCESS);
221: }

223: static PetscErrorCode PCSPAISetSp_SPAI(PC pc, PetscInt sp)
224: {
225:   PC_SPAI *ispai = (PC_SPAI *)pc->data;

227:   PetscFunctionBegin;
228:   ispai->sp = (int)sp;
229:   PetscFunctionReturn(PETSC_SUCCESS);
230: }

232: static PetscErrorCode PCSetFromOptions_SPAI(PC pc, PetscOptionItems PetscOptionsObject)
233: {
234:   PC_SPAI  *ispai = (PC_SPAI *)pc->data;
235:   int       nbsteps1, max1, maxnew1, block_size1, cache_size, verbose, sp;
236:   double    epsilon1;
237:   PetscBool flg;

239:   PetscFunctionBegin;
240:   PetscOptionsHeadBegin(PetscOptionsObject, "SPAI options");
241:   PetscCall(PetscOptionsReal("-pc_spai_epsilon", "", "PCSPAISetEpsilon", ispai->epsilon, &epsilon1, &flg));
242:   if (flg) PetscCall(PCSPAISetEpsilon(pc, epsilon1));
243:   PetscCall(PetscOptionsInt("-pc_spai_nbsteps", "", "PCSPAISetNBSteps", ispai->nbsteps, &nbsteps1, &flg));
244:   if (flg) PetscCall(PCSPAISetNBSteps(pc, nbsteps1));
245:   /* added 1/7/99 g.h. */
246:   PetscCall(PetscOptionsInt("-pc_spai_max", "", "PCSPAISetMax", ispai->max, &max1, &flg));
247:   if (flg) PetscCall(PCSPAISetMax(pc, max1));
248:   PetscCall(PetscOptionsInt("-pc_spai_maxnew", "", "PCSPAISetMaxNew", ispai->maxnew, &maxnew1, &flg));
249:   if (flg) PetscCall(PCSPAISetMaxNew(pc, maxnew1));
250:   PetscCall(PetscOptionsInt("-pc_spai_block_size", "", "PCSPAISetBlockSize", ispai->block_size, &block_size1, &flg));
251:   if (flg) PetscCall(PCSPAISetBlockSize(pc, block_size1));
252:   PetscCall(PetscOptionsInt("-pc_spai_cache_size", "", "PCSPAISetCacheSize", ispai->cache_size, &cache_size, &flg));
253:   if (flg) PetscCall(PCSPAISetCacheSize(pc, cache_size));
254:   PetscCall(PetscOptionsInt("-pc_spai_verbose", "", "PCSPAISetVerbose", ispai->verbose, &verbose, &flg));
255:   if (flg) PetscCall(PCSPAISetVerbose(pc, verbose));
256:   PetscCall(PetscOptionsInt("-pc_spai_sp", "", "PCSPAISetSp", ispai->sp, &sp, &flg));
257:   if (flg) PetscCall(PCSPAISetSp(pc, sp));
258:   PetscOptionsHeadEnd();
259:   PetscFunctionReturn(PETSC_SUCCESS);
260: }

262: /*MC
263:    PCSPAI - Use the Sparse Approximate Inverse method {cite}`gh97`

265:    Options Database Keys:
266: +  -pc_spai_epsilon eps              - set tolerance
267: .  -pc_spai_nbstep n                 - set nbsteps
268: .  -pc_spai_max m                    - set max
269: .  -pc_spai_max_new m                - set maxnew
270: .  -pc_spai_block_size n             - set block size
271: .  -pc_spai_cache_size n             - set cache size
272: .  -pc_spai_sp m                     - set sp
273: -  -pc_spai_set_verbose (true|false) - verbose output

275:    Level: beginner

277:    Note:
278:     This only works with `MATAIJ` matrices.

280: .seealso: [](ch_ksp), `PCCreate()`, `PCSetType()`, `PCType`, `PC`,
281:           `PCSPAISetEpsilon()`, `PCSPAISetMax()`, `PCSPAISetMaxNew()`, `PCSPAISetBlockSize()`,
282:           `PCSPAISetVerbose()`, `PCSPAISetSp()`, `PCSPAISetNBSteps()`, `PCSPAISetCacheSize()`
283: M*/

285: PETSC_EXTERN PetscErrorCode PCCreate_SPAI(PC pc)
286: {
287:   PC_SPAI *ispai;

289:   PetscFunctionBegin;
290:   PetscCall(PetscNew(&ispai));
291:   pc->data = ispai;

293:   pc->ops->destroy         = PCDestroy_SPAI;
294:   pc->ops->apply           = PCApply_SPAI;
295:   pc->ops->matapply        = PCMatApply_SPAI;
296:   pc->ops->applyrichardson = 0;
297:   pc->ops->setup           = PCSetUp_SPAI;
298:   pc->ops->view            = PCView_SPAI;
299:   pc->ops->setfromoptions  = PCSetFromOptions_SPAI;

301:   ispai->epsilon    = .4;
302:   ispai->nbsteps    = 5;
303:   ispai->max        = 5000;
304:   ispai->maxnew     = 5;
305:   ispai->block_size = 1;
306:   ispai->cache_size = 5;
307:   ispai->verbose    = 0;

309:   ispai->sp = 1;
310:   PetscCallMPI(MPI_Comm_dup(PetscObjectComm((PetscObject)pc), &ispai->comm_spai));

312:   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCSPAISetEpsilon_C", PCSPAISetEpsilon_SPAI));
313:   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCSPAISetNBSteps_C", PCSPAISetNBSteps_SPAI));
314:   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCSPAISetMax_C", PCSPAISetMax_SPAI));
315:   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCSPAISetMaxNew_C", PCSPAISetMaxNew_SPAI));
316:   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCSPAISetBlockSize_C", PCSPAISetBlockSize_SPAI));
317:   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCSPAISetCacheSize_C", PCSPAISetCacheSize_SPAI));
318:   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCSPAISetVerbose_C", PCSPAISetVerbose_SPAI));
319:   PetscCall(PetscObjectComposeFunction((PetscObject)pc, "PCSPAISetSp_C", PCSPAISetSp_SPAI));
320:   PetscFunctionReturn(PETSC_SUCCESS);
321: }

323: /*
324:    Converts from a PETSc matrix to an SPAI matrix
325: */
326: static PetscErrorCode ConvertMatToMatrix(MPI_Comm comm, Mat A, Mat AT, matrix **B)
327: {
328:   matrix                  *M;
329:   int                      i, j, col;
330:   int                      row_indx;
331:   int                      len, pe, local_indx, start_indx;
332:   int                     *mapping;
333:   const int               *cols;
334:   const double            *vals;
335:   int                      n, mnl, nnl, nz, rstart, rend;
336:   PetscMPIInt              size, rank;
337:   struct compressed_lines *rows;

339:   PetscFunctionBegin;
340:   PetscCallMPI(MPI_Comm_size(comm, &size));
341:   PetscCallMPI(MPI_Comm_rank(comm, &rank));
342:   PetscCall(MatGetSize(A, &n, &n));
343:   PetscCall(MatGetLocalSize(A, &mnl, &nnl));

345:   /*
346:     not sure why a barrier is required. commenting out
347:   PetscCallMPI(MPI_Barrier(comm));
348:   */

350:   M = new_matrix((SPAI_Comm)comm);

352:   M->n              = n;
353:   M->bs             = 1;
354:   M->max_block_size = 1;

356:   M->mnls          = (int *)malloc(sizeof(int) * size);
357:   M->start_indices = (int *)malloc(sizeof(int) * size);
358:   M->pe            = (int *)malloc(sizeof(int) * n);
359:   M->block_sizes   = (int *)malloc(sizeof(int) * n);
360:   for (i = 0; i < n; i++) M->block_sizes[i] = 1;

362:   PetscCallMPI(MPI_Allgather(&mnl, 1, MPI_INT, M->mnls, 1, MPI_INT, comm));

364:   M->start_indices[0] = 0;
365:   for (i = 1; i < size; i++) M->start_indices[i] = M->start_indices[i - 1] + M->mnls[i - 1];

367:   M->mnl            = M->mnls[M->myid];
368:   M->my_start_index = M->start_indices[M->myid];

370:   for (i = 0; i < size; i++) {
371:     start_indx = M->start_indices[i];
372:     for (j = 0; j < M->mnls[i]; j++) M->pe[start_indx + j] = i;
373:   }

375:   if (AT) {
376:     M->lines = new_compressed_lines(M->mnls[rank], 1);
377:   } else {
378:     M->lines = new_compressed_lines(M->mnls[rank], 0);
379:   }

381:   rows = M->lines;

383:   /* Determine the mapping from global indices to pointers */
384:   PetscCall(PetscMalloc1(M->n, &mapping));
385:   pe         = 0;
386:   local_indx = 0;
387:   for (i = 0; i < M->n; i++) {
388:     if (local_indx >= M->mnls[pe]) {
389:       pe++;
390:       local_indx = 0;
391:     }
392:     mapping[i] = local_indx + M->start_indices[pe];
393:     local_indx++;
394:   }

396:   /************** Set up the row structure *****************/

398:   PetscCall(MatGetOwnershipRange(A, &rstart, &rend));
399:   for (i = rstart; i < rend; i++) {
400:     row_indx = i - rstart;
401:     PetscCall(MatGetRow(A, i, &nz, &cols, &vals));
402:     /* allocate buffers */
403:     rows->ptrs[row_indx] = (int *)malloc(nz * sizeof(int));
404:     rows->A[row_indx]    = (double *)malloc(nz * sizeof(double));
405:     /* copy the matrix */
406:     for (j = 0; j < nz; j++) {
407:       col = cols[j];
408:       len = rows->len[row_indx]++;

410:       rows->ptrs[row_indx][len] = mapping[col];
411:       rows->A[row_indx][len]    = vals[j];
412:     }
413:     rows->slen[row_indx] = rows->len[row_indx];

415:     PetscCall(MatRestoreRow(A, i, &nz, &cols, &vals));
416:   }

418:   /************** Set up the column structure *****************/

420:   if (AT) {
421:     for (i = rstart; i < rend; i++) {
422:       row_indx = i - rstart;
423:       PetscCall(MatGetRow(AT, i, &nz, &cols, &vals));
424:       /* allocate buffers */
425:       rows->rptrs[row_indx] = (int *)malloc(nz * sizeof(int));
426:       /* copy the matrix (i.e., the structure) */
427:       for (j = 0; j < nz; j++) {
428:         col = cols[j];
429:         len = rows->rlen[row_indx]++;

431:         rows->rptrs[row_indx][len] = mapping[col];
432:       }
433:       PetscCall(MatRestoreRow(AT, i, &nz, &cols, &vals));
434:     }
435:   }

437:   PetscCall(PetscFree(mapping));

439:   order_pointers(M);
440:   M->maxnz = calc_maxnz(M);
441:   *B       = M;
442:   PetscFunctionReturn(PETSC_SUCCESS);
443: }

445: /*
446:    Converts from an SPAI matrix B  to a PETSc matrix PB.
447:    This assumes that the SPAI matrix B is stored in
448:    COMPRESSED-ROW format.
449: */
450: static PetscErrorCode ConvertMatrixToMat(MPI_Comm comm, matrix *B, Mat *PB)
451: {
452:   PetscMPIInt size, rank;
453:   int         m, n, M, N;
454:   int         d_nz, o_nz;
455:   int        *d_nnz, *o_nnz;
456:   int         i, k, global_row, global_col, first_diag_col, last_diag_col;
457:   PetscScalar val;

459:   PetscFunctionBegin;
460:   PetscCallMPI(MPI_Comm_size(comm, &size));
461:   PetscCallMPI(MPI_Comm_rank(comm, &rank));

463:   m = n = B->mnls[rank];
464:   d_nz = o_nz = 0;

466:   /* Determine preallocation for MatCreateAIJ */
467:   PetscCall(PetscMalloc1(m, &d_nnz));
468:   PetscCall(PetscMalloc1(m, &o_nnz));
469:   for (i = 0; i < m; i++) d_nnz[i] = o_nnz[i] = 0;
470:   first_diag_col = B->start_indices[rank];
471:   last_diag_col  = first_diag_col + B->mnls[rank];
472:   for (i = 0; i < B->mnls[rank]; i++) {
473:     for (k = 0; k < B->lines->len[i]; k++) {
474:       global_col = B->lines->ptrs[i][k];
475:       if ((global_col >= first_diag_col) && (global_col < last_diag_col)) d_nnz[i]++;
476:       else o_nnz[i]++;
477:     }
478:   }

480:   M = N = B->n;
481:   /* Here we only know how to create AIJ format */
482:   PetscCall(MatCreate(comm, PB));
483:   PetscCall(MatSetSizes(*PB, m, n, M, N));
484:   PetscCall(MatSetType(*PB, MATAIJ));
485:   PetscCall(MatSeqAIJSetPreallocation(*PB, d_nz, d_nnz));
486:   PetscCall(MatMPIAIJSetPreallocation(*PB, d_nz, d_nnz, o_nz, o_nnz));

488:   for (i = 0; i < B->mnls[rank]; i++) {
489:     global_row = B->start_indices[rank] + i;
490:     for (k = 0; k < B->lines->len[i]; k++) {
491:       global_col = B->lines->ptrs[i][k];

493:       val = B->lines->A[i][k];
494:       PetscCall(MatSetValues(*PB, 1, &global_row, 1, &global_col, &val, ADD_VALUES));
495:     }
496:   }
497:   PetscCall(PetscFree(d_nnz));
498:   PetscCall(PetscFree(o_nnz));

500:   PetscCall(MatAssemblyBegin(*PB, MAT_FINAL_ASSEMBLY));
501:   PetscCall(MatAssemblyEnd(*PB, MAT_FINAL_ASSEMBLY));
502:   PetscFunctionReturn(PETSC_SUCCESS);
503: }