Actual source code: ao.c
1: #define PETSCDM_DLL
3: /*
4: Defines the abstract operations on AO (application orderings)
5: */
6: #include ../src/dm/ao/aoimpl.h
8: /* Logging support */
9: PetscCookie AO_COOKIE;
10: PetscLogEvent AO_PetscToApplication, AO_ApplicationToPetsc;
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: PetscErrorCode AOView(AO ao,PetscViewer viewer)
41: {
46: if (!viewer) viewer = PETSC_VIEWER_STDOUT_(((PetscObject)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: PetscErrorCode AODestroy(AO ao)
69: {
74: if (--((PetscObject)ao)->refct > 0) return(0);
75: /* if memory was published with AMS then destroy it */
76: PetscObjectDepublish(ao);
77: /* destroy the internal part */
78: if (ao->ops->destroy) {
79: (*ao->ops->destroy)(ao);
80: }
81: PetscHeaderDestroy(ao);
82: return(0);
83: }
86: #include ../src/vec/is/impls/general/general.h
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: PetscErrorCode AOPetscToApplicationIS(AO ao,IS is)
116: {
118: PetscInt n;
119: PetscInt *ia;
120: PetscTruth flag;
125: ISBlock(is,&flag);
126: if (flag) SETERRQ(PETSC_ERR_SUP,"Cannot translate block index sets");
127: ISStride(is,&flag);
128: if (flag) {
129: ISStrideToGeneral(is);
130: }
131: ia = ((IS_General*)is->data)->idx;
132: ISGetLocalSize(is,&n);
133: (*ao->ops->petsctoapplication)(ao,n,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: PetscErrorCode AOApplicationToPetscIS(AO ao,IS is)
164: {
166: PetscInt n,*ia;
167: PetscTruth flag;
172: ISBlock(is,&flag);
173: if (flag) SETERRQ(PETSC_ERR_SUP,"Cannot translate block index sets");
174: ISStride(is,&flag);
175: if (flag) {
176: ISStrideToGeneral(is);
177: }
179: ia = ((IS_General*)is->data)->idx;
180: ISGetLocalSize(is,&n);
181: (*ao->ops->applicationtopetsc)(ao,n,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: PetscErrorCode AOPetscToApplication(AO ao,PetscInt n,PetscInt 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; these are replaced with their mapped value
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: PetscErrorCode AOApplicationToPetsc(AO ao,PetscInt n,PetscInt 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: Note: The length of the array should be block*N, where N is length
271: provided to the AOCreate*() method that created the AO.
273: The permutation takes array[i_pet] --> array[i_app], where i_app is
274: the index of 'i' in the application ordering and i_pet is the index
275: of 'i' in the petsc ordering.
277: Level: beginner
279: .keywords: application ordering, mapping
280: .seealso: AOCreateBasic(), AOView(), AOApplicationToPetsc(), AOPetscToApplicationIS()
281: @*/
282: PetscErrorCode AOPetscToApplicationPermuteInt(AO ao, PetscInt block, PetscInt array[])
283: {
289: (*ao->ops->petsctoapplicationpermuteint)(ao, block, array);
290: return(0);
291: }
295: /*@
296: AOApplicationToPetscPermuteInt - Permutes an array of blocks of integers
297: in the application-defined ordering to the PETSc ordering.
299: Collective on AO
301: Input Parameters:
302: + ao - The application ordering context
303: . block - The block size
304: - array - The integer array
306: Note: The length of the array should be block*N, where N is length
307: provided to the AOCreate*() method that created the AO.
309: The permutation takes array[i_app] --> array[i_pet], where i_app is
310: the index of 'i' in the application ordering and i_pet is the index
311: of 'i' in the petsc ordering.
313: Level: beginner
315: .keywords: application ordering, mapping
317: .seealso: AOCreateBasic(), AOView(), AOPetscToApplicationIS(), AOApplicationToPetsc()
318: @*/
319: PetscErrorCode AOApplicationToPetscPermuteInt(AO ao, PetscInt block, PetscInt array[])
320: {
326: (*ao->ops->applicationtopetscpermuteint)(ao, block, array);
327: return(0);
328: }
332: /*@
333: AOPetscToApplicationPermuteReal - Permutes an array of blocks of reals
334: in the PETSc ordering to the application-defined ordering.
336: Collective on AO
338: Input Parameters:
339: + ao - The application ordering context
340: . block - The block size
341: - array - The integer array
343: Note: The length of the array should be block*N, where N is length
344: provided to the AOCreate*() method that created the AO.
346: The permutation takes array[i_pet] --> array[i_app], where i_app is
347: the index of 'i' in the application ordering and i_pet is the index
348: of 'i' in the petsc ordering.
350: Level: beginner
352: .keywords: application ordering, mapping
354: .seealso: AOCreateBasic(), AOView(), AOApplicationToPetsc(), AOPetscToApplicationIS()
355: @*/
356: PetscErrorCode AOPetscToApplicationPermuteReal(AO ao, PetscInt block, PetscReal array[])
357: {
363: (*ao->ops->petsctoapplicationpermutereal)(ao, block, array);
364: return(0);
365: }
369: /*@
370: AOApplicationToPetscPermuteReal - Permutes an array of blocks of reals
371: in the application-defined ordering to the PETSc ordering.
373: Collective on AO
375: Input Parameters:
376: + ao - The application ordering context
377: . block - The block size
378: - array - The integer array
380: Note: The length of the array should be block*N, where N is length
381: provided to the AOCreate*() method that created the AO.
383: The permutation takes array[i_app] --> array[i_pet], where i_app is
384: the index of 'i' in the application ordering and i_pet is the index
385: of 'i' in the petsc ordering.
387: Level: beginner
389: .keywords: application ordering, mapping
391: .seealso: AOCreateBasic(), AOView(),AOApplicationToPetsc(), AOPetscToApplicationIS()
392: @*/
393: PetscErrorCode AOApplicationToPetscPermuteReal(AO ao, PetscInt block, PetscReal array[])
394: {
400: (*ao->ops->applicationtopetscpermutereal)(ao, block, array);
401: return(0);
402: }