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: /*@C
 13:    AOView - Displays an application ordering.

 15:    Collective on AO and PetscViewer

 17:    Input Parameters:
 18: +  ao - the application ordering context
 19: -  viewer - viewer used for display

 21:    Level: intermediate

 23:    Note:
 24:    The available visualization contexts include
 25: +     PETSC_VIEWER_STDOUT_SELF - standard output (default)
 26: -     PETSC_VIEWER_STDOUT_WORLD - synchronized standard
 27:          output where only the first processor opens
 28:          the file.  All other processors send their 
 29:          data to the first processor to print. 

 31:    The user can open an alternative visualization context with
 32:    PetscViewerASCIIOpen() - output to a specified file.

 34: .keywords: application ordering

 36: .seealso: PetscViewerASCIIOpen()
 37: @*/
 38: int AOView(AO ao,PetscViewer viewer)
 39: {

 44:   if (!viewer) viewer = PETSC_VIEWER_STDOUT_(ao->comm);
 46:   (*ao->ops->view)(ao,viewer);
 47:   return(0);
 48: }

 50: /*@
 51:    AODestroy - Destroys an application ordering set.

 53:    Collective on AO

 55:    Input Parameters:
 56: .  ao - the application ordering context

 58:    Level: beginner

 60: .keywords: destroy, application ordering

 62: .seealso: AOCreateBasic()
 63: @*/
 64: int AODestroy(AO ao)
 65: {

 69:   if (!ao) return(0);
 71:   if (--ao->refct > 0) return(0);

 73:   /* if memory was published with AMS then destroy it */
 74:   PetscObjectDepublish(ao);

 76:   (*ao->ops->destroy)(ao);
 77:   PetscLogObjectDestroy(ao);
 78:   PetscHeaderDestroy(ao);
 79:   return(0);
 80: }


 83: /* ---------------------------------------------------------------------*/
 84: /*@
 85:    AOPetscToApplicationIS - Maps an index set in the PETSc ordering to 
 86:    the application-defined ordering.

 88:    Collective on AO and IS

 90:    Input Parameters:
 91: +  ao - the application ordering context
 92: -  is - the index set

 94:    Level: intermediate

 96:    Notes:
 97:    The index set cannot be of type stride or block
 98:    
 99:    Any integers in ia[] that are negative are left unchanged. This 
100:          allows one to convert, for example, neighbor lists that use negative
101:          entries to indicate nonexistent neighbors due to boundary conditions
102:          etc.

104: .keywords: application ordering, mapping

106: .seealso: AOCreateBasic(), AOView(),AOApplicationToPetsc(),
107:           AOApplicationToPetscIS(),AOPetscToApplication()
108: @*/
109: int AOPetscToApplicationIS(AO ao,IS is)
110: {
111:   int        n,*ia,ierr;
112:   PetscTruth flag;

116:   ISBlock(is,&flag);
117:   if (flag) SETERRQ(1,"Cannot translate block index sets");
118:   ISStride(is,&flag);
119:   if (flag) {
120:     ISStrideToGeneral(is);
121:   }

123:   ISGetLocalSize(is,&n);
124:   ISGetIndices(is,&ia);
125:   (*ao->ops->petsctoapplication)(ao,n,ia);
126:   ISRestoreIndices(is,&ia);
127:   return(0);
128: }

130: /*@
131:    AOApplicationToPetscIS - Maps an index set in the application-defined
132:    ordering to the PETSc ordering.

134:    Collective on AO and IS

136:    Input Parameters:
137: +  ao - the application ordering context
138: -  is - the index set

140:    Level: beginner

142:    Note:
143:    The index set cannot be of type stride or block
144:    
145:    Any integers in ia[] that are negative are left unchanged. This 
146:    allows one to convert, for example, neighbor lists that use negative
147:    entries to indicate nonexistent neighbors due to boundary conditions, etc.

149: .keywords: application ordering, mapping

151: .seealso: AOCreateBasic(), AOView(), AOPetscToApplication(),
152:           AOPetscToApplicationIS(), AOApplicationToPetsc()
153: @*/
154: int AOApplicationToPetscIS(AO ao,IS is)
155: {
156:   int        n,*ia,ierr;
157:   PetscTruth flag;

161:   ISBlock(is,&flag);
162:   if (flag) SETERRQ(1,"Cannot translate block index sets");
163:   ISStride(is,&flag);
164:   if (flag) {
165:     ISStrideToGeneral(is);
166:   }

168:   ISGetLocalSize(is,&n);
169:   ISGetIndices(is,&ia);
170:   (*ao->ops->applicationtopetsc)(ao,n,ia);
171:   ISRestoreIndices(is,&ia);
172:   return(0);
173: }

175: /*@
176:    AOPetscToApplication - Maps a set of integers in the PETSc ordering to 
177:    the application-defined ordering.

179:    Collective on AO

181:    Input Parameters:
182: +  ao - the application ordering context
183: .  n - the number of integers
184: -  ia - the integers

186:    Level: beginner

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

193: .keywords: application ordering, mapping

195: .seealso: AOCreateBasic(), AOView(),AOApplicationToPetsc(),
196:           AOPetscToApplicationIS(), AOApplicationToPetsc()
197: @*/
198: int AOPetscToApplication(AO ao,int n,int *ia)
199: {

204:   (*ao->ops->petsctoapplication)(ao,n,ia);
205:   return(0);
206: }

208: /*@
209:    AOApplicationToPetsc - Maps a set of integers in the application-defined
210:    ordering to the PETSc ordering.

212:    Collective on AO

214:    Input Parameters:
215: +  ao - the application ordering context
216: .  n - the number of integers
217: -  ia - the integers

219:    Level: beginner

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

226: .keywords: application ordering, mapping

228: .seealso: AOCreateBasic(), AOView(), AOPetscToApplication(),
229:           AOPetscToApplicationIS(), AOApplicationToPetsc()
230: @*/
231: int AOApplicationToPetsc(AO ao,int n,int *ia)
232: {

237:   (*ao->ops->applicationtopetsc)(ao,n,ia);
238:   return(0);
239: }

241: /*@
242:   AOPetscToApplicationPermuteInt - Permutes an array of blocks of integers
243:   in the PETSc ordering to the application-defined ordering.

245:   Collective on AO

247:   Input Parameters:
248: + ao    - The application ordering context
249: . block - The block size
250: - array - The integer array

252:   Level: beginner

254: .keywords: application ordering, mapping
255: .seealso: AOCreateBasic(), AOView(), AOApplicationToPetsc(), AOPetscToApplicationIS()
256: @*/
257: int AOPetscToApplicationPermuteInt(AO ao, int block, int *array)
258: {

263:   (*ao->ops->petsctoapplicationpermuteint)(ao, block, array);
264:   return(0);
265: }

267: /*@
268:   AOApplicationToPetscPermuteInt - Permutes an array of blocks of integers
269:   in the application-defined ordering to the PETSc ordering.

271:   Collective on AO

273:   Input Parameters:
274: + ao    - The application ordering context
275: . block - The block size
276: - array - The integer array

278:   Level: beginner

280: .keywords: application ordering, mapping

282: .seealso: AOCreateBasic(), AOView(), AOPetscToApplicationIS(), AOApplicationToPetsc()
283: @*/
284: int AOApplicationToPetscPermuteInt(AO ao, int block, int *array)
285: {

290:   (*ao->ops->applicationtopetscpermuteint)(ao, block, array);
291:   return(0);
292: }

294: /*@
295:   AOPetscToApplicationPermuteReal - Permutes an array of blocks of reals
296:   in the PETSc ordering to the application-defined ordering.

298:   Collective on AO

300:   Input Parameters:
301: + ao    - The application ordering context
302: . block - The block size
303: - array - The integer array

305:   Level: beginner

307: .keywords: application ordering, mapping

309: .seealso: AOCreateBasic(), AOView(), AOApplicationToPetsc(), AOPetscToApplicationIS()
310: @*/
311: int AOPetscToApplicationPermuteReal(AO ao, int block, double *array)
312: {

317:   (*ao->ops->petsctoapplicationpermutereal)(ao, block, array);
318:   return(0);
319: }

321: /*@
322:   AOApplicationToPetscPermuteReal - Permutes an array of blocks of reals
323:   in the application-defined ordering to the PETSc ordering.

325:   Collective on AO

327:   Input Parameters:
328: + ao    - The application ordering context
329: . block - The block size
330: - array - The integer array

332:   Level: beginner

334: .keywords: application ordering, mapping

336: .seealso: AOCreateBasic(), AOView(),AOApplicationToPetsc(), AOPetscToApplicationIS()
337: @*/
338: int AOApplicationToPetscPermuteReal(AO ao, int block, double *array)
339: {

344:   (*ao->ops->applicationtopetscpermutereal)(ao, block, array);
345:   return(0);
346: }