static PetscErrorCode ISToGeneral_Block(IS inis) { IS_Block *sub = (IS_Block*)inis->data; PetscInt bs,n; const PetscInt *idx; PetscErrorCode ierr; PetscFunctionBegin; ierr = ISGetBlockSize(inis,&bs); CHKERRQ(ierr); ierr = ISGetLocalSize(inis,&n); CHKERRQ(ierr); ierr = ISGetIndices(inis,&idx); CHKERRQ(ierr); if (bs == 1) { PetscCopyMode mode = sub->borrowed_indices ? PETSC_USE_POINTER : PETSC_OWN_POINTER; sub->borrowed_indices = PETSC_TRUE; /* prevent deallocation when changing the subtype*/ ierr = ISSetType(inis,ISGENERAL); CHKERRQ(ierr); ierr = ISGeneralSetIndices(inis,n,idx,mode); CHKERRQ(ierr); } else { ierr = ISSetType(inis,ISGENERAL); CHKERRQ(ierr); ierr = ISGeneralSetIndices(inis,n,idx,PETSC_OWN_POINTER); CHKERRQ(ierr); } PetscFunctionReturn(0); }
/*@ ISCreateGeneral - Creates a data structure for an index set containing a list of integers. Collective on MPI_Comm Input Parameters: + comm - the MPI communicator . n - the length of the index set . idx - the list of integers - mode - see PetscCopyMode for meaning of this flag. Output Parameter: . is - the new index set Notes: When the communicator is not MPI_COMM_SELF, the operations on IS are NOT conceptually the same as MPI_Group operations. The IS are then distributed sets of indices and thus certain operations on them are collective. Level: beginner Concepts: index sets^creating Concepts: IS^creating .seealso: ISCreateStride(), ISCreateBlock(), ISAllGather() @*/ PetscErrorCode ISCreateGeneral(MPI_Comm comm,PetscInt n,const PetscInt idx[],PetscCopyMode mode,IS *is) { PetscErrorCode ierr; PetscFunctionBegin; ierr = ISCreate(comm,is);CHKERRQ(ierr); ierr = ISSetType(*is,ISGENERAL);CHKERRQ(ierr); ierr = ISGeneralSetIndices(*is,n,idx,mode);CHKERRQ(ierr); PetscFunctionReturn(0); }
PetscErrorCode ISToGeneral_Stride(IS inis) { PetscErrorCode ierr; const PetscInt *idx; PetscInt n; PetscFunctionBegin; ierr = ISGetLocalSize(inis,&n);CHKERRQ(ierr); ierr = ISGetIndices(inis,&idx);CHKERRQ(ierr); ierr = ISSetType(inis,ISGENERAL);CHKERRQ(ierr); ierr = ISGeneralSetIndices(inis,n,idx,PETSC_OWN_POINTER);CHKERRQ(ierr); PetscFunctionReturn(0); }
PETSC_EXTERN void PETSC_STDCALL isgeneralsetindices_(IS is,PetscInt *n, PetscInt idx[],PetscCopyMode *mode, int *__ierr ){ *__ierr = ISGeneralSetIndices( (IS)PetscToPointer((is) ),*n,idx,*mode); }