Actual source code: ao.c
1: /*$Id: ao.c,v 1.39 2001/03/23 23:24:50 balay Exp $*/
2: /*
3: Defines the abstract operations on AO (application orderings)
4: */
5: #include src/dm/ao/aoimpl.h
7: /* Logging support */
8: int AO_COOKIE = 0;
9: int AODATA_COOKIE = 0;
10: int AOEvents[AO_MAX_EVENTS] = {0};
14: /*@C
15: AOView - Displays an application ordering.
17: Collective on AO and PetscViewer
19: Input Parameters:
20: + ao - the application ordering context
21: - viewer - viewer used for display
23: Level: intermediate
25: Note:
26: The available visualization contexts include
27: + PETSC_VIEWER_STDOUT_SELF - standard output (default)
28: - PETSC_VIEWER_STDOUT_WORLD - synchronized standard
29: output where only the first processor opens
30: the file. All other processors send their
31: data to the first processor to print.
33: The user can open an alternative visualization context with
34: PetscViewerASCIIOpen() - output to a specified file.
36: .keywords: application ordering
38: .seealso: PetscViewerASCIIOpen()
39: @*/
40: int AOView(AO ao,PetscViewer viewer)
41: {
46: if (!viewer) viewer = PETSC_VIEWER_STDOUT_(ao->comm);
48: (*ao->ops->view)(ao,viewer);
49: return(0);
50: }
54: /*@
55: AODestroy - Destroys an application ordering set.
57: Collective on AO
59: Input Parameters:
60: . ao - the application ordering context
62: Level: beginner
64: .keywords: destroy, application ordering
66: .seealso: AOCreateBasic()
67: @*/
68: int AODestroy(AO ao)
69: {
73: if (!ao) return(0);
75: if (--ao->refct > 0) return(0);
77: /* if memory was published with AMS then destroy it */
78: PetscObjectDepublish(ao);
80: (*ao->ops->destroy)(ao);
81: PetscLogObjectDestroy(ao);
82: PetscHeaderDestroy(ao);
83: return(0);
84: }
87: /* ---------------------------------------------------------------------*/
90: /*@
91: AOPetscToApplicationIS - Maps an index set in the PETSc ordering to
92: the application-defined ordering.
94: Collective on AO and IS
96: Input Parameters:
97: + ao - the application ordering context
98: - is - the index set
100: Level: intermediate
102: Notes:
103: The index set cannot be of type stride or block
104:
105: Any integers in ia[] that are negative are left unchanged. This
106: allows one to convert, for example, neighbor lists that use negative
107: entries to indicate nonexistent neighbors due to boundary conditions
108: etc.
110: .keywords: application ordering, mapping
112: .seealso: AOCreateBasic(), AOView(),AOApplicationToPetsc(),
113: AOApplicationToPetscIS(),AOPetscToApplication()
114: @*/
115: int AOPetscToApplicationIS(AO ao,IS is)
116: {
117: int n,*ia,ierr;
118: PetscTruth flag;
123: ISBlock(is,&flag);
124: if (flag) SETERRQ(1,"Cannot translate block index sets");
125: ISStride(is,&flag);
126: if (flag) {
127: ISStrideToGeneral(is);
128: }
130: ISGetLocalSize(is,&n);
131: ISGetIndices(is,&ia);
132: (*ao->ops->petsctoapplication)(ao,n,ia);
133: ISRestoreIndices(is,&ia);
134: return(0);
135: }
139: /*@
140: AOApplicationToPetscIS - Maps an index set in the application-defined
141: ordering to the PETSc ordering.
143: Collective on AO and IS
145: Input Parameters:
146: + ao - the application ordering context
147: - is - the index set
149: Level: beginner
151: Note:
152: The index set cannot be of type stride or block
153:
154: Any integers in ia[] that are negative are left unchanged. This
155: allows one to convert, for example, neighbor lists that use negative
156: entries to indicate nonexistent neighbors due to boundary conditions, etc.
158: .keywords: application ordering, mapping
160: .seealso: AOCreateBasic(), AOView(), AOPetscToApplication(),
161: AOPetscToApplicationIS(), AOApplicationToPetsc()
162: @*/
163: int AOApplicationToPetscIS(AO ao,IS is)
164: {
165: int n,*ia,ierr;
166: PetscTruth flag;
171: ISBlock(is,&flag);
172: if (flag) SETERRQ(1,"Cannot translate block index sets");
173: ISStride(is,&flag);
174: if (flag) {
175: ISStrideToGeneral(is);
176: }
178: ISGetLocalSize(is,&n);
179: ISGetIndices(is,&ia);
180: (*ao->ops->applicationtopetsc)(ao,n,ia);
181: ISRestoreIndices(is,&ia);
182: return(0);
183: }
187: /*@
188: AOPetscToApplication - Maps a set of integers in the PETSc ordering to
189: the application-defined ordering.
191: Collective on AO
193: Input Parameters:
194: + ao - the application ordering context
195: . n - the number of integers
196: - ia - the integers
198: Level: beginner
200: Note:
201: Any integers in ia[] that are negative are left unchanged. This
202: allows one to convert, for example, neighbor lists that use negative
203: entries to indicate nonexistent neighbors due to boundary conditions, etc.
205: .keywords: application ordering, mapping
207: .seealso: AOCreateBasic(), AOView(),AOApplicationToPetsc(),
208: AOPetscToApplicationIS(), AOApplicationToPetsc()
209: @*/
210: int AOPetscToApplication(AO ao,int n,int ia[])
211: {
217: (*ao->ops->petsctoapplication)(ao,n,ia);
218: return(0);
219: }
223: /*@
224: AOApplicationToPetsc - Maps a set of integers in the application-defined
225: ordering to the PETSc ordering.
227: Collective on AO
229: Input Parameters:
230: + ao - the application ordering context
231: . n - the number of integers
232: - ia - the integers
234: Level: beginner
236: Note:
237: Any integers in ia[] that are negative are left unchanged. This
238: allows one to convert, for example, neighbor lists that use negative
239: entries to indicate nonexistent neighbors due to boundary conditions, etc.
241: .keywords: application ordering, mapping
243: .seealso: AOCreateBasic(), AOView(), AOPetscToApplication(),
244: AOPetscToApplicationIS(), AOApplicationToPetsc()
245: @*/
246: int AOApplicationToPetsc(AO ao,int n,int ia[])
247: {
253: (*ao->ops->applicationtopetsc)(ao,n,ia);
254: return(0);
255: }
259: /*@
260: AOPetscToApplicationPermuteInt - Permutes an array of blocks of integers
261: in the PETSc ordering to the application-defined ordering.
263: Collective on AO
265: Input Parameters:
266: + ao - The application ordering context
267: . block - The block size
268: - array - The integer array
270: Level: beginner
272: .keywords: application ordering, mapping
273: .seealso: AOCreateBasic(), AOView(), AOApplicationToPetsc(), AOPetscToApplicationIS()
274: @*/
275: int AOPetscToApplicationPermuteInt(AO ao, int block, int array[])
276: {
282: (*ao->ops->petsctoapplicationpermuteint)(ao, block, array);
283: return(0);
284: }
288: /*@
289: AOApplicationToPetscPermuteInt - Permutes an array of blocks of integers
290: in the application-defined ordering to the PETSc ordering.
292: Collective on AO
294: Input Parameters:
295: + ao - The application ordering context
296: . block - The block size
297: - array - The integer array
299: Level: beginner
301: .keywords: application ordering, mapping
303: .seealso: AOCreateBasic(), AOView(), AOPetscToApplicationIS(), AOApplicationToPetsc()
304: @*/
305: int AOApplicationToPetscPermuteInt(AO ao, int block, int array[])
306: {
312: (*ao->ops->applicationtopetscpermuteint)(ao, block, array);
313: return(0);
314: }
318: /*@
319: AOPetscToApplicationPermuteReal - Permutes an array of blocks of reals
320: in the PETSc ordering to the application-defined ordering.
322: Collective on AO
324: Input Parameters:
325: + ao - The application ordering context
326: . block - The block size
327: - array - The integer array
329: Level: beginner
331: .keywords: application ordering, mapping
333: .seealso: AOCreateBasic(), AOView(), AOApplicationToPetsc(), AOPetscToApplicationIS()
334: @*/
335: int AOPetscToApplicationPermuteReal(AO ao, int block, double array[])
336: {
342: (*ao->ops->petsctoapplicationpermutereal)(ao, block, array);
343: return(0);
344: }
348: /*@
349: AOApplicationToPetscPermuteReal - Permutes an array of blocks of reals
350: in the application-defined ordering to the PETSc ordering.
352: Collective on AO
354: Input Parameters:
355: + ao - The application ordering context
356: . block - The block size
357: - array - The integer array
359: Level: beginner
361: .keywords: application ordering, mapping
363: .seealso: AOCreateBasic(), AOView(),AOApplicationToPetsc(), AOPetscToApplicationIS()
364: @*/
365: int AOApplicationToPetscPermuteReal(AO ao, int block, double array[])
366: {
372: (*ao->ops->applicationtopetscpermutereal)(ao, block, array);
373: return(0);
374: }