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;
  9: int AODATA_COOKIE;
 10: int AOEvents[AO_MAX_EVENTS];

 12: #undef __FUNCT__  
 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: }

 52: #undef __FUNCT__  
 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: /* ---------------------------------------------------------------------*/
 88: #undef __FUNCT__  
 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;

122:   ISBlock(is,&flag);
123:   if (flag) SETERRQ(1,"Cannot translate block index sets");
124:   ISStride(is,&flag);
125:   if (flag) {
126:     ISStrideToGeneral(is);
127:   }

129:   ISGetLocalSize(is,&n);
130:   ISGetIndices(is,&ia);
131:   (*ao->ops->petsctoapplication)(ao,n,ia);
132:   ISRestoreIndices(is,&ia);
133:   return(0);
134: }

136: #undef __FUNCT__  
138: /*@
139:    AOApplicationToPetscIS - Maps an index set in the application-defined
140:    ordering to the PETSc ordering.

142:    Collective on AO and IS

144:    Input Parameters:
145: +  ao - the application ordering context
146: -  is - the index set

148:    Level: beginner

150:    Note:
151:    The index set cannot be of type stride or block
152:    
153:    Any integers in ia[] that are negative are left unchanged. This 
154:    allows one to convert, for example, neighbor lists that use negative
155:    entries to indicate nonexistent neighbors due to boundary conditions, etc.

157: .keywords: application ordering, mapping

159: .seealso: AOCreateBasic(), AOView(), AOPetscToApplication(),
160:           AOPetscToApplicationIS(), AOApplicationToPetsc()
161: @*/
162: int AOApplicationToPetscIS(AO ao,IS is)
163: {
164:   int        n,*ia,ierr;
165:   PetscTruth flag;

169:   ISBlock(is,&flag);
170:   if (flag) SETERRQ(1,"Cannot translate block index sets");
171:   ISStride(is,&flag);
172:   if (flag) {
173:     ISStrideToGeneral(is);
174:   }

176:   ISGetLocalSize(is,&n);
177:   ISGetIndices(is,&ia);
178:   (*ao->ops->applicationtopetsc)(ao,n,ia);
179:   ISRestoreIndices(is,&ia);
180:   return(0);
181: }

183: #undef __FUNCT__  
185: /*@
186:    AOPetscToApplication - Maps a set of integers in the PETSc ordering to 
187:    the application-defined ordering.

189:    Collective on AO

191:    Input Parameters:
192: +  ao - the application ordering context
193: .  n - the number of integers
194: -  ia - the integers

196:    Level: beginner

198:    Note:
199:    Any integers in ia[] that are negative are left unchanged. This 
200:    allows one to convert, for example, neighbor lists that use negative
201:    entries to indicate nonexistent neighbors due to boundary conditions, etc.

203: .keywords: application ordering, mapping

205: .seealso: AOCreateBasic(), AOView(),AOApplicationToPetsc(),
206:           AOPetscToApplicationIS(), AOApplicationToPetsc()
207: @*/
208: int AOPetscToApplication(AO ao,int n,int *ia)
209: {

214:   (*ao->ops->petsctoapplication)(ao,n,ia);
215:   return(0);
216: }

218: #undef __FUNCT__  
220: /*@
221:    AOApplicationToPetsc - Maps a set of integers in the application-defined
222:    ordering to the PETSc ordering.

224:    Collective on AO

226:    Input Parameters:
227: +  ao - the application ordering context
228: .  n - the number of integers
229: -  ia - the integers

231:    Level: beginner

233:    Note:
234:    Any integers in ia[] that are negative are left unchanged. This 
235:    allows one to convert, for example, neighbor lists that use negative
236:    entries to indicate nonexistent neighbors due to boundary conditions, etc.

238: .keywords: application ordering, mapping

240: .seealso: AOCreateBasic(), AOView(), AOPetscToApplication(),
241:           AOPetscToApplicationIS(), AOApplicationToPetsc()
242: @*/
243: int AOApplicationToPetsc(AO ao,int n,int *ia)
244: {

249:   (*ao->ops->applicationtopetsc)(ao,n,ia);
250:   return(0);
251: }

253: #undef __FUNCT__  
255: /*@
256:   AOPetscToApplicationPermuteInt - Permutes an array of blocks of integers
257:   in the PETSc ordering to the application-defined ordering.

259:   Collective on AO

261:   Input Parameters:
262: + ao    - The application ordering context
263: . block - The block size
264: - array - The integer array

266:   Level: beginner

268: .keywords: application ordering, mapping
269: .seealso: AOCreateBasic(), AOView(), AOApplicationToPetsc(), AOPetscToApplicationIS()
270: @*/
271: int AOPetscToApplicationPermuteInt(AO ao, int block, int *array)
272: {

277:   (*ao->ops->petsctoapplicationpermuteint)(ao, block, array);
278:   return(0);
279: }

281: #undef __FUNCT__  
283: /*@
284:   AOApplicationToPetscPermuteInt - Permutes an array of blocks of integers
285:   in the application-defined ordering to the PETSc ordering.

287:   Collective on AO

289:   Input Parameters:
290: + ao    - The application ordering context
291: . block - The block size
292: - array - The integer array

294:   Level: beginner

296: .keywords: application ordering, mapping

298: .seealso: AOCreateBasic(), AOView(), AOPetscToApplicationIS(), AOApplicationToPetsc()
299: @*/
300: int AOApplicationToPetscPermuteInt(AO ao, int block, int *array)
301: {

306:   (*ao->ops->applicationtopetscpermuteint)(ao, block, array);
307:   return(0);
308: }

310: #undef __FUNCT__  
312: /*@
313:   AOPetscToApplicationPermuteReal - Permutes an array of blocks of reals
314:   in the PETSc ordering to the application-defined ordering.

316:   Collective on AO

318:   Input Parameters:
319: + ao    - The application ordering context
320: . block - The block size
321: - array - The integer array

323:   Level: beginner

325: .keywords: application ordering, mapping

327: .seealso: AOCreateBasic(), AOView(), AOApplicationToPetsc(), AOPetscToApplicationIS()
328: @*/
329: int AOPetscToApplicationPermuteReal(AO ao, int block, double *array)
330: {

335:   (*ao->ops->petsctoapplicationpermutereal)(ao, block, array);
336:   return(0);
337: }

339: #undef __FUNCT__  
341: /*@
342:   AOApplicationToPetscPermuteReal - Permutes an array of blocks of reals
343:   in the application-defined ordering to the PETSc ordering.

345:   Collective on AO

347:   Input Parameters:
348: + ao    - The application ordering context
349: . block - The block size
350: - array - The integer array

352:   Level: beginner

354: .keywords: application ordering, mapping

356: .seealso: AOCreateBasic(), AOView(),AOApplicationToPetsc(), AOPetscToApplicationIS()
357: @*/
358: int AOApplicationToPetscPermuteReal(AO ao, int block, double *array)
359: {

364:   (*ao->ops->applicationtopetscpermutereal)(ao, block, array);
365:   return(0);
366: }