Actual source code: general.c

petsc-3.13.6 2020-09-29
Report Typos and Errors

  2: /*
  3:      Provides the functions for index sets (IS) defined by a list of integers.
  4: */
  5:  #include <../src/vec/is/is/impls/general/general.h>
  6:  #include <petsc/private/viewerimpl.h>
  7:  #include <petsc/private/viewerhdf5impl.h>

  9: static PetscErrorCode ISDuplicate_General(IS is,IS *newIS)
 10: {
 12:   IS_General     *sub = (IS_General*)is->data;
 13:   PetscInt       n;

 16:   PetscLayoutGetLocalSize(is->map, &n);
 17:   ISCreateGeneral(PetscObjectComm((PetscObject) is), n, sub->idx, PETSC_COPY_VALUES, newIS);
 18:   return(0);
 19: }

 21: static PetscErrorCode ISDestroy_General(IS is)
 22: {
 23:   IS_General     *is_general = (IS_General*)is->data;

 27:   if (is_general->allocated) {PetscFree(is_general->idx);}
 28:   PetscObjectComposeFunction((PetscObject)is,"ISGeneralSetIndices_C",NULL);
 29:   PetscObjectComposeFunction((PetscObject)is,"ISGeneralFilter_C",NULL);
 30:   PetscFree(is->data);
 31:   return(0);
 32: }

 34: static PetscErrorCode ISCopy_General(IS is,IS isy)
 35: {
 36:   IS_General     *is_general = (IS_General*)is->data,*isy_general = (IS_General*)isy->data;
 37:   PetscInt       n, N, ny, Ny;

 41:   PetscLayoutGetLocalSize(is->map, &n);
 42:   PetscLayoutGetSize(is->map, &N);
 43:   PetscLayoutGetLocalSize(isy->map, &ny);
 44:   PetscLayoutGetSize(isy->map, &Ny);
 45:   if (n != ny || N != Ny) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Index sets incompatible");
 46:   PetscArraycpy(isy_general->idx,is_general->idx,n);
 47:   return(0);
 48: }

 50: static PetscErrorCode ISOnComm_General(IS is,MPI_Comm comm,PetscCopyMode mode,IS *newis)
 51: {
 53:   IS_General     *sub = (IS_General*)is->data;
 54:   PetscInt       n;

 57:   if (mode == PETSC_OWN_POINTER) SETERRQ(comm,PETSC_ERR_ARG_WRONG,"Cannot use PETSC_OWN_POINTER");
 58:   PetscLayoutGetLocalSize(is->map, &n);
 59:   ISCreateGeneral(comm,n,sub->idx,mode,newis);
 60:   return(0);
 61: }

 63: static PetscErrorCode ISSetBlockSize_General(IS is,PetscInt bs)
 64: {

 68:   PetscLayoutSetBlockSize(is->map, bs);
 69:   return(0);
 70: }

 72: static PetscErrorCode ISContiguousLocal_General(IS is,PetscInt gstart,PetscInt gend,PetscInt *start,PetscBool *contig)
 73: {
 74:   IS_General *sub = (IS_General*)is->data;
 75:   PetscInt   n,i,p;

 79:   *start  = 0;
 80:   *contig = PETSC_TRUE;
 81:   PetscLayoutGetLocalSize(is->map, &n);
 82:   if (!n) return(0);
 83:   p = sub->idx[0];
 84:   if (p < gstart) goto nomatch;
 85:   *start = p - gstart;
 86:   if (n > gend-p) goto nomatch;
 87:   for (i=1; i<n; i++,p++) {
 88:     if (sub->idx[i] != p+1) goto nomatch;
 89:   }
 90:   return(0);
 91: nomatch:
 92:   *start  = -1;
 93:   *contig = PETSC_FALSE;
 94:   return(0);
 95: }

 97: static PetscErrorCode ISLocate_General(IS is,PetscInt key,PetscInt *location)
 98: {
 99:   IS_General     *sub = (IS_General*)is->data;
100:   PetscInt       numIdx, i;
101:   PetscBool      sorted;

105:   PetscLayoutGetLocalSize(is->map,&numIdx);
106:   ISGetInfo(is,IS_SORTED,IS_LOCAL,PETSC_TRUE,&sorted);
107:   if (sorted) {PetscFindInt(key,numIdx,sub->idx,location);}
108:   else {
109:     const PetscInt *idx = sub->idx;

111:     *location = -1;
112:     for (i = 0; i < numIdx; i++) {
113:       if (idx[i] == key) {
114:         *location = i;
115:         return(0);
116:       }
117:     }
118:   }
119:   return(0);
120: }

122: static PetscErrorCode ISGetIndices_General(IS in,const PetscInt *idx[])
123: {
124:   IS_General *sub = (IS_General*)in->data;

127:   *idx = sub->idx;
128:   return(0);
129: }

131: static PetscErrorCode ISRestoreIndices_General(IS in,const PetscInt *idx[])
132: {
133:   IS_General *sub = (IS_General*)in->data;

136:   if (*idx != sub->idx) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must restore with value from ISGetIndices()");
137:   return(0);
138: }

140: static PetscErrorCode ISInvertPermutation_General(IS is,PetscInt nlocal,IS *isout)
141: {
142:   IS_General     *sub = (IS_General*)is->data;
143:   PetscInt       i,*ii,n,nstart;
144:   const PetscInt *idx = sub->idx;
145:   PetscMPIInt    size;
146:   IS             istmp,nistmp;

150:   PetscLayoutGetLocalSize(is->map, &n);
151:   MPI_Comm_size(PetscObjectComm((PetscObject)is),&size);
152:   if (size == 1) {
153:     PetscMalloc1(n,&ii);
154:     for (i=0; i<n; i++) ii[idx[i]] = i;
155:     ISCreateGeneral(PETSC_COMM_SELF,n,ii,PETSC_OWN_POINTER,isout);
156:     ISSetPermutation(*isout);
157:   } else {
158:     /* crude, nonscalable get entire IS on each processor */
159:     ISAllGather(is,&istmp);
160:     ISSetPermutation(istmp);
161:     ISInvertPermutation(istmp,PETSC_DECIDE,&nistmp);
162:     ISDestroy(&istmp);
163:     /* get the part we need */
164:     if (nlocal == PETSC_DECIDE) nlocal = n;
165:     MPI_Scan(&nlocal,&nstart,1,MPIU_INT,MPI_SUM,PetscObjectComm((PetscObject)is));
166: #if defined(PETSC_USE_DEBUG)
167:     {
168:       PetscInt    N;
169:       PetscMPIInt rank;
170:       MPI_Comm_rank(PetscObjectComm((PetscObject)is),&rank);
171:       PetscLayoutGetSize(is->map, &N);
172:       if (rank == size-1) {
173:         if (nstart != N) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Sum of nlocal lengths %d != total IS length %d",nstart,N);
174:       }
175:     }
176: #endif
177:     nstart -= nlocal;
178:     ISGetIndices(nistmp,&idx);
179:     ISCreateGeneral(PetscObjectComm((PetscObject)is),nlocal,idx+nstart,PETSC_COPY_VALUES,isout);
180:     ISRestoreIndices(nistmp,&idx);
181:     ISDestroy(&nistmp);
182:   }
183:   return(0);
184: }

186: #if defined(PETSC_HAVE_HDF5)
187: static PetscErrorCode ISView_General_HDF5(IS is, PetscViewer viewer)
188: {
189:   PetscViewer_HDF5 *hdf5 = (PetscViewer_HDF5*) viewer->data;
190:   hid_t           filespace;  /* file dataspace identifier */
191:   hid_t           chunkspace; /* chunk dataset property identifier */
192:   hid_t           dset_id;    /* dataset identifier */
193:   hid_t           memspace;   /* memory dataspace identifier */
194:   hid_t           inttype;    /* int type (H5T_NATIVE_INT or H5T_NATIVE_LLONG) */
195:   hid_t           file_id, group;
196:   hsize_t         dim, maxDims[3], dims[3], chunkDims[3], count[3],offset[3];
197:   PetscInt        bs, N, n, timestep, low;
198:   const PetscInt *ind;
199:   const char     *isname;
200:   PetscErrorCode  ierr;

203:   ISGetBlockSize(is,&bs);
204:   bs   = PetscMax(bs, 1); /* If N = 0, bs  = 0 as well */
205:   PetscViewerHDF5OpenGroup(viewer, &file_id, &group);
206:   PetscViewerHDF5GetTimestep(viewer, &timestep);

208:   /* Create the dataspace for the dataset.
209:    *
210:    * dims - holds the current dimensions of the dataset
211:    *
212:    * maxDims - holds the maximum dimensions of the dataset (unlimited
213:    * for the number of time steps with the current dimensions for the
214:    * other dimensions; so only additional time steps can be added).
215:    *
216:    * chunkDims - holds the size of a single time step (required to
217:    * permit extending dataset).
218:    */
219:   dim = 0;
220:   if (timestep >= 0) {
221:     dims[dim]      = timestep+1;
222:     maxDims[dim]   = H5S_UNLIMITED;
223:     chunkDims[dim] = 1;
224:     ++dim;
225:   }
226:   ISGetSize(is, &N);
227:   ISGetLocalSize(is, &n);
228:   PetscHDF5IntCast(N/bs,dims + dim);

230:   maxDims[dim]   = dims[dim];
231:   chunkDims[dim] = PetscMax(1,dims[dim]);
232:   ++dim;
233:   if (bs >= 1) {
234:     dims[dim]      = bs;
235:     maxDims[dim]   = dims[dim];
236:     chunkDims[dim] = dims[dim];
237:     ++dim;
238:   }
239:   PetscStackCallHDF5Return(filespace,H5Screate_simple,(dim, dims, maxDims));

241: #if defined(PETSC_USE_64BIT_INDICES)
242:   inttype = H5T_NATIVE_LLONG;
243: #else
244:   inttype = H5T_NATIVE_INT;
245: #endif

247:   /* Create the dataset with default properties and close filespace */
248:   PetscObjectGetName((PetscObject) is, &isname);
249:   if (!H5Lexists(group, isname, H5P_DEFAULT)) {
250:     /* Create chunk */
251:     PetscStackCallHDF5Return(chunkspace,H5Pcreate,(H5P_DATASET_CREATE));
252:     PetscStackCallHDF5(H5Pset_chunk,(chunkspace, dim, chunkDims));

254:     PetscStackCallHDF5Return(dset_id,H5Dcreate2,(group, isname, inttype, filespace, H5P_DEFAULT, chunkspace, H5P_DEFAULT));
255:     PetscStackCallHDF5(H5Pclose,(chunkspace));
256:   } else {
257:     PetscStackCallHDF5Return(dset_id,H5Dopen2,(group, isname, H5P_DEFAULT));
258:     PetscStackCallHDF5(H5Dset_extent,(dset_id, dims));
259:   }
260:   PetscStackCallHDF5(H5Sclose,(filespace));

262:   /* Each process defines a dataset and writes it to the hyperslab in the file */
263:   dim = 0;
264:   if (timestep >= 0) {
265:     count[dim] = 1;
266:     ++dim;
267:   }
268:   PetscHDF5IntCast(n/bs,count + dim);
269:   ++dim;
270:   if (bs >= 1) {
271:     count[dim] = bs;
272:     ++dim;
273:   }
274:   if (n > 0 || H5_VERSION_GE(1,10,0)) {
275:     PetscStackCallHDF5Return(memspace,H5Screate_simple,(dim, count, NULL));
276:   } else {
277:     /* Can't create dataspace with zero for any dimension, so create null dataspace. */
278:     PetscStackCallHDF5Return(memspace,H5Screate,(H5S_NULL));
279:   }

281:   /* Select hyperslab in the file */
282:   PetscLayoutGetRange(is->map, &low, NULL);
283:   dim  = 0;
284:   if (timestep >= 0) {
285:     offset[dim] = timestep;
286:     ++dim;
287:   }
288:   PetscHDF5IntCast(low/bs,offset + dim);
289:   ++dim;
290:   if (bs >= 1) {
291:     offset[dim] = 0;
292:     ++dim;
293:   }
294:   if (n > 0 || H5_VERSION_GE(1,10,0)) {
295:     PetscStackCallHDF5Return(filespace,H5Dget_space,(dset_id));
296:     PetscStackCallHDF5(H5Sselect_hyperslab,(filespace, H5S_SELECT_SET, offset, NULL, count, NULL));
297:   } else {
298:     /* Create null filespace to match null memspace. */
299:     PetscStackCallHDF5Return(filespace,H5Screate,(H5S_NULL));
300:   }

302:   ISGetIndices(is, &ind);
303:   PetscStackCallHDF5(H5Dwrite,(dset_id, inttype, memspace, filespace, hdf5->dxpl_id, ind));
304:   PetscStackCallHDF5(H5Fflush,(file_id, H5F_SCOPE_GLOBAL));
305:   ISRestoreIndices(is, &ind);

307:   /* Close/release resources */
308:   PetscStackCallHDF5(H5Gclose,(group));
309:   PetscStackCallHDF5(H5Sclose,(filespace));
310:   PetscStackCallHDF5(H5Sclose,(memspace));
311:   PetscStackCallHDF5(H5Dclose,(dset_id));
312:   PetscInfo1(is, "Wrote IS object with name %s\n", isname);
313:   return(0);
314: }
315: #endif

317: static PetscErrorCode ISView_General(IS is,PetscViewer viewer)
318: {
319:   IS_General     *sub = (IS_General*)is->data;
321:   PetscInt       i,n,*idx = sub->idx;
322:   PetscBool      iascii,isbinary,ishdf5;

325:   PetscLayoutGetLocalSize(is->map, &n);
326:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&iascii);
327:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERBINARY,&isbinary);
328:   PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERHDF5,&ishdf5);
329:   if (iascii) {
330:     MPI_Comm          comm;
331:     PetscMPIInt       rank,size;
332:     PetscViewerFormat fmt;
333:     PetscBool         isperm;

335:     PetscObjectGetComm((PetscObject)viewer,&comm);
336:     MPI_Comm_rank(comm,&rank);
337:     MPI_Comm_size(comm,&size);

339:     PetscViewerGetFormat(viewer,&fmt);
340:     ISGetInfo(is,IS_PERMUTATION,IS_LOCAL,PETSC_FALSE,&isperm);
341:     if (isperm && fmt != PETSC_VIEWER_ASCII_MATLAB) {PetscViewerASCIIPrintf(viewer,"Index set is permutation\n");}
342:     PetscViewerASCIIPushSynchronized(viewer);
343:     if (size > 1) {
344:       if (fmt == PETSC_VIEWER_ASCII_MATLAB) {
345:         const char* name;

347:         PetscObjectGetName((PetscObject)is,&name);
348:         PetscViewerASCIISynchronizedPrintf(viewer,"%s_%d = [...\n",name,rank);
349:         for (i=0; i<n; i++) {
350:           PetscViewerASCIISynchronizedPrintf(viewer,"%D\n",idx[i]+1);
351:         }
352:         PetscViewerASCIISynchronizedPrintf(viewer,"];\n");
353:       } else {
354:         PetscInt  st = 0;

356:         if (fmt == PETSC_VIEWER_ASCII_INDEX) st = is->map->rstart;
357:         PetscViewerASCIISynchronizedPrintf(viewer,"[%d] Number of indices in set %D\n",rank,n);
358:         for (i=0; i<n; i++) {
359:           PetscViewerASCIISynchronizedPrintf(viewer,"[%d] %D %D\n",rank,i + st,idx[i]);
360:         }
361:       }
362:     } else {
363:       if (fmt == PETSC_VIEWER_ASCII_MATLAB) {
364:         const char* name;

366:         PetscObjectGetName((PetscObject)is,&name);
367:         PetscViewerASCIISynchronizedPrintf(viewer,"%s = [...\n",name);
368:         for (i=0; i<n; i++) {
369:           PetscViewerASCIISynchronizedPrintf(viewer,"%D\n",idx[i]+1);
370:         }
371:         PetscViewerASCIISynchronizedPrintf(viewer,"];\n");
372:       } else {
373:         PetscInt  st = 0;

375:         if (fmt == PETSC_VIEWER_ASCII_INDEX) st = is->map->rstart;
376:         PetscViewerASCIISynchronizedPrintf(viewer,"Number of indices in set %D\n",n);
377:         for (i=0; i<n; i++) {
378:           PetscViewerASCIISynchronizedPrintf(viewer,"%D %D\n",i + st,idx[i]);
379:         }
380:       }
381:     }
382:     PetscViewerFlush(viewer);
383:     PetscViewerASCIIPopSynchronized(viewer);
384:   } else if (isbinary) {
385:     ISView_Binary(is,viewer);
386:   } else if (ishdf5) {
387: #if defined(PETSC_HAVE_HDF5)
388:     ISView_General_HDF5(is,viewer);
389: #endif
390:   }
391:   return(0);
392: }

394: static PetscErrorCode ISSort_General(IS is)
395: {
396:   IS_General     *sub = (IS_General*)is->data;
397:   PetscInt       n;

401:   PetscLayoutGetLocalSize(is->map, &n);
402:   PetscSortInt(n,sub->idx);
403:   return(0);
404: }

406: static PetscErrorCode ISSortRemoveDups_General(IS is)
407: {
408:   IS_General     *sub = (IS_General*)is->data;
409:   PetscLayout    map;
410:   PetscInt       n;
411:   PetscBool      sorted;

415:   PetscLayoutGetLocalSize(is->map, &n);
416:   ISGetInfo(is,IS_SORTED,IS_LOCAL,PETSC_TRUE,&sorted);
417:   if (sorted) {
418:     PetscSortedRemoveDupsInt(&n,sub->idx);
419:   } else {
420:     PetscSortRemoveDupsInt(&n,sub->idx);
421:   }
422:   PetscLayoutCreateFromSizes(PetscObjectComm((PetscObject)is), n, PETSC_DECIDE, is->map->bs, &map);
423:   PetscLayoutDestroy(&is->map);
424:   is->map = map;
425:   return(0);
426: }

428: static PetscErrorCode ISSorted_General(IS is,PetscBool  *flg)
429: {

433:   ISGetInfo(is,IS_SORTED,IS_LOCAL,PETSC_TRUE,flg);
434:   return(0);
435: }

437: PetscErrorCode  ISToGeneral_General(IS is)
438: {
440:   return(0);
441: }

443: static struct _ISOps myops = { ISGetIndices_General,
444:                                ISRestoreIndices_General,
445:                                ISInvertPermutation_General,
446:                                ISSort_General,
447:                                ISSortRemoveDups_General,
448:                                ISSorted_General,
449:                                ISDuplicate_General,
450:                                ISDestroy_General,
451:                                ISView_General,
452:                                ISLoad_Default,
453:                                ISCopy_General,
454:                                ISToGeneral_General,
455:                                ISOnComm_General,
456:                                ISSetBlockSize_General,
457:                                ISContiguousLocal_General,
458:                                ISLocate_General,
459:                                /* no specializations of {sorted,unique,perm,interval}{local,global}
460:                                 * because the default checks in ISGetInfo_XXX in index.c are exactly
461:                                 * what we would do for ISGeneral */
462:                                NULL,
463:                                NULL,
464:                                NULL,
465:                                NULL,
466:                                NULL,
467:                                NULL,
468:                                NULL,
469:                                NULL};

471: PETSC_INTERN PetscErrorCode ISSetUp_General(IS);

473: PetscErrorCode ISSetUp_General(IS is)
474: {
476:   IS_General     *sub = (IS_General*)is->data;
477:   const PetscInt *idx = sub->idx;
478:   PetscInt       n,i,min,max;

481:   PetscLayoutGetLocalSize(is->map, &n);

483:   if (n) {
484:     min = max = idx[0];
485:     for (i=1; i<n; i++) {
486:       if (idx[i] < min) min = idx[i];
487:       if (idx[i] > max) max = idx[i];
488:     }
489:     is->min = min;
490:     is->max = max;
491:   } else {
492:     is->min = PETSC_MAX_INT;
493:     is->max = PETSC_MIN_INT;
494:   }
495:   return(0);
496: }

498: /*@
499:    ISCreateGeneral - Creates a data structure for an index set
500:    containing a list of integers.

502:    Collective

504:    Input Parameters:
505: +  comm - the MPI communicator
506: .  n - the length of the index set
507: .  idx - the list of integers
508: -  mode - PETSC_COPY_VALUES, PETSC_OWN_POINTER, or PETSC_USE_POINTER; see PetscCopyMode for meaning of this flag.

510:    Output Parameter:
511: .  is - the new index set

513:    Notes:
514:    When the communicator is not MPI_COMM_SELF, the operations on IS are NOT
515:    conceptually the same as MPI_Group operations. The IS are then
516:    distributed sets of indices and thus certain operations on them are
517:    collective.


520:    Level: beginner


523: .seealso: ISCreateStride(), ISCreateBlock(), ISAllGather(), PETSC_COPY_VALUES, PETSC_OWN_POINTER, PETSC_USE_POINTER, PetscCopyMode
524: @*/
525: PetscErrorCode  ISCreateGeneral(MPI_Comm comm,PetscInt n,const PetscInt idx[],PetscCopyMode mode,IS *is)
526: {

530:   ISCreate(comm,is);
531:   ISSetType(*is,ISGENERAL);
532:   ISGeneralSetIndices(*is,n,idx,mode);
533:   return(0);
534: }

536: /*@
537:    ISGeneralSetIndices - Sets the indices for an ISGENERAL index set

539:    Collective on IS

541:    Input Parameters:
542: +  is - the index set
543: .  n - the length of the index set
544: .  idx - the list of integers
545: -  mode - see PetscCopyMode for meaning of this flag.

547:    Level: beginner


550: .seealso: ISCreateGeneral(), ISCreateStride(), ISCreateBlock(), ISAllGather()
551: @*/
552: PetscErrorCode  ISGeneralSetIndices(IS is,PetscInt n,const PetscInt idx[],PetscCopyMode mode)
553: {

557:   ISClearInfoCache(is,PETSC_FALSE);
558:   PetscUseMethod(is,"ISGeneralSetIndices_C",(IS,PetscInt,const PetscInt[],PetscCopyMode),(is,n,idx,mode));
559:   return(0);
560: }

562: PetscErrorCode  ISGeneralSetIndices_General(IS is,PetscInt n,const PetscInt idx[],PetscCopyMode mode)
563: {
564:   PetscLayout    map;
566:   IS_General     *sub = (IS_General*)is->data;

569:   if (n < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"length < 0");

572:   PetscLayoutCreateFromSizes(PetscObjectComm((PetscObject)is),n,PETSC_DECIDE,is->map->bs,&map);
573:   PetscLayoutDestroy(&is->map);
574:   is->map = map;

576:   if (sub->allocated) {PetscFree(sub->idx);}
577:   if (mode == PETSC_COPY_VALUES) {
578:     PetscMalloc1(n,&sub->idx);
579:     PetscLogObjectMemory((PetscObject)is,n*sizeof(PetscInt));
580:     PetscArraycpy(sub->idx,idx,n);
581:     sub->allocated = PETSC_TRUE;
582:   } else if (mode == PETSC_OWN_POINTER) {
583:     sub->idx = (PetscInt*)idx;
584:     PetscLogObjectMemory((PetscObject)is,n*sizeof(PetscInt));
585:     sub->allocated = PETSC_TRUE;
586:   } else {
587:     sub->idx = (PetscInt*)idx;
588:     sub->allocated = PETSC_FALSE;
589:   }

591:   ISSetUp_General(is);
592:   ISViewFromOptions(is,NULL,"-is_view");
593:   return(0);
594: }

596: static PetscErrorCode ISGeneralFilter_General(IS is, PetscInt start, PetscInt end)
597: {
598:   IS_General     *sub = (IS_General*)is->data;
599:   PetscInt       *idx = sub->idx,*idxnew;
600:   PetscInt       i,n = is->map->n,nnew = 0,o;

604:   for (i=0; i<n; ++i)
605:     if (idx[i] >= start && idx[i] < end)
606:       nnew++;
607:   PetscMalloc1(nnew, &idxnew);
608:   for (o=0, i=0; i<n; i++) {
609:     if (idx[i] >= start && idx[i] < end)
610:       idxnew[o++] = idx[i];
611:   }
612:   ISGeneralSetIndices_General(is,nnew,idxnew,PETSC_OWN_POINTER);
613:   return(0);
614: }

616: /*@
617:    ISGeneralFilter - Remove all points outside of [start, end)

619:    Collective on IS

621:    Input Parameters:
622: +  is - the index set
623: .  start - the lowest index kept
624: -  end - one more than the highest index kept

626:    Level: beginner

628: .seealso: ISCreateGeneral(), ISGeneralSetIndices()
629: @*/
630: PetscErrorCode ISGeneralFilter(IS is, PetscInt start, PetscInt end)
631: {

636:   ISClearInfoCache(is,PETSC_FALSE);
637:   PetscUseMethod(is,"ISGeneralFilter_C",(IS,PetscInt,PetscInt),(is,start,end));
638:   return(0);
639: }

641: PETSC_EXTERN PetscErrorCode ISCreate_General(IS is)
642: {
644:   IS_General     *sub;

647:   PetscNewLog(is,&sub);
648:   is->data = (void *) sub;
649:   PetscMemcpy(is->ops,&myops,sizeof(myops));
650:   PetscObjectComposeFunction((PetscObject)is,"ISGeneralSetIndices_C",ISGeneralSetIndices_General);
651:   PetscObjectComposeFunction((PetscObject)is,"ISGeneralFilter_C",ISGeneralFilter_General);
652:   return(0);
653: }