Actual source code: strgen.c
1: #define PETSCVEC_DLL
2: #include src/vec/is/impls/general/general.h
4: EXTERN PetscErrorCode ISDuplicate_General(IS,IS *);
5: EXTERN PetscErrorCode ISDestroy_General(IS);
6: EXTERN PetscErrorCode ISGetIndices_General(IS,PetscInt **);
7: EXTERN PetscErrorCode ISRestoreIndices_General(IS,PetscInt **);
8: EXTERN PetscErrorCode ISGetSize_General(IS,PetscInt *);
9: EXTERN PetscErrorCode ISGetLocalSize_General(IS,PetscInt *);
10: EXTERN PetscErrorCode ISInvertPermutation_General(IS,PetscInt,IS *);
11: EXTERN PetscErrorCode ISView_General(IS,PetscViewer);
12: EXTERN PetscErrorCode ISSort_General(IS);
13: EXTERN PetscErrorCode ISSorted_General(IS,PetscTruth*);
15: static struct _ISOps myops = { ISGetSize_General,
16: ISGetLocalSize_General,
17: ISGetIndices_General,
18: ISRestoreIndices_General,
19: ISInvertPermutation_General,
20: ISSort_General,
21: ISSorted_General,
22: ISDuplicate_General,
23: ISDestroy_General,
24: ISView_General};
28: /*@C
29: ISStrideToGeneral - Converts a stride index set to a general index set.
31: Collective on IS
33: Input Parameters:
34: . is - the index set
36: Level: advanced
38: Concepts: index sets^converting
39: Concepts: stride^converting index sets
41: .seealso: ISCreateStride(), ISCreateBlock(), ISCreateGeneral()
42: @*/
43: PetscErrorCode ISStrideToGeneral(IS inis)
44: {
46: PetscInt step;
47: IS_General *sub;
48: PetscTruth stride,flg;
51: ISStride(inis,&stride);
52: if (!stride) SETERRQ(PETSC_ERR_SUP,"Can only convert stride index sets");
54: PetscNewLog(inis,IS_General,&sub);
55:
56: ISGetIndices(inis,&sub->idx);
57: /* Note: we never restore the indices, since we need to keep the copy generated */
58: ISGetLocalSize(inis,&sub->n);
60: ISStrideGetInfo(inis,PETSC_NULL,&step);
61: if (step > 0) sub->sorted = PETSC_TRUE; else sub->sorted = PETSC_FALSE;
62: sub->allocated = PETSC_TRUE;
64: /* Remove the old stride data set */
65: PetscFree(inis->data);
67: ((PetscObject)inis)->type = IS_GENERAL;
68: inis->data = (void*)sub;
69: inis->isperm = PETSC_FALSE;
70: PetscMemcpy(inis->ops,&myops,sizeof(myops));
71: PetscOptionsHasName(PETSC_NULL,"-is_view",&flg);
72: if (flg) {
73: PetscViewer viewer;
74: PetscViewerASCIIGetStdout(((PetscObject)inis)->comm,&viewer);
75: ISView(inis,viewer);
76: }
77: return(0);
78: }