Actual source code: petscimpl.h

  2: /*
  3:     Defines the basic header of all PETSc objects.
  4: */

  6: #if !defined(_PETSCHEAD_H)
  7: #define _PETSCHEAD_H
 8:  #include petsc.h

 11: /*
 12:    All major PETSc data structures have a common core; this is defined 
 13:    below by PETSCHEADER. 

 15:    PetscHeaderCreate() should be used whenever creating a PETSc structure.
 16: */

 18: /*
 19:    PetscOps: structure of core operations that all PETSc objects support.
 20:    
 21:       getcomm()         - Gets the object's communicator.
 22:       view()            - Is the routine for viewing the entire PETSc object; for
 23:                           example, MatView() is the general matrix viewing routine.
 24:       destroy()         - Is the routine for destroying the entire PETSc object; 
 25:                           for example,MatDestroy() is the general matrix 
 26:                           destruction routine.
 27:       compose()         - Associates a PETSc object with another PETSc object.
 28:       query()           - Returns a different PETSc object that has been associated
 29:                           with the first object.
 30:       composefunction() - Attaches an additional registered function.
 31:       queryfunction()   - Requests a registered function that has been registered.
 32:       publish()         - Not currently used
 33: */

 35: typedef struct {
 36:    PetscErrorCode (*getcomm)(PetscObject,MPI_Comm *);
 37:    PetscErrorCode (*view)(PetscObject,PetscViewer);
 38:    PetscErrorCode (*destroy)(PetscObject);
 39:    PetscErrorCode (*compose)(PetscObject,const char[],PetscObject);
 40:    PetscErrorCode (*query)(PetscObject,const char[],PetscObject *);
 41:    PetscErrorCode (*composefunction)(PetscObject,const char[],const char[],void (*)(void));
 42:    PetscErrorCode (*queryfunction)(PetscObject,const char[],void (**)(void));
 43:    PetscErrorCode (*publish)(PetscObject);
 44: } PetscOps;

 46: #define PETSCHEADER(ObjectOps)                                  \
 47:   PetscCookie    cookie;                                        \
 48:   PetscOps       *bops;                                         \
 49:   ObjectOps      *ops;                                          \
 50:   PetscDataType  precision;                                     \
 51:   MPI_Comm       comm;                                          \
 52:   PetscInt       type;                                          \
 53:   PetscLogDouble flops,time,mem;                                \
 54:   PetscInt       id;                                            \
 55:   PetscInt       refct;                                         \
 56:   PetscMPIInt    tag;                                           \
 57:   PetscFList     qlist;                                         \
 58:   PetscOList     olist;                                         \
 59:   char           *class_name;                                   \
 60:   char           *type_name;                                    \
 61:   PetscObject    parent;                                        \
 62:   PetscInt       parentid;                                      \
 63:   char*          name;                                          \
 64:   char           *prefix;                                       \
 65:   void           *cpp;                                          \
 66:   PetscInt       amem;                                          \
 67:   PetscInt       state;                                         \
 68:   PetscInt       int_idmax,        intstar_idmax;               \
 69:   PetscInt       *intcomposedstate,*intstarcomposedstate;       \
 70:   PetscInt       *intcomposeddata, **intstarcomposeddata;       \
 71:   PetscInt       real_idmax,        realstar_idmax;             \
 72:   PetscInt       *realcomposedstate,*realstarcomposedstate;     \
 73:   PetscReal      *realcomposeddata, **realstarcomposeddata;     \
 74:   PetscInt       scalar_idmax,        scalarstar_idmax;         \
 75:   PetscInt       *scalarcomposedstate,*scalarstarcomposedstate; \
 76:   PetscScalar    *scalarcomposeddata, **scalarstarcomposeddata;        \
 77:   void           (**fortran_func_pointers)(void)

 79:   /*  ... */

 81: #define  PETSCFREEDHEADER -1

 83: EXTERN PetscErrorCode  PetscHeaderCreate_Private(PetscObject,PetscCookie,PetscInt,const char[],MPI_Comm,PetscErrorCode (*)(PetscObject),PetscErrorCode (*)(PetscObject,PetscViewer));
 84: EXTERN PetscErrorCode  PetscHeaderDestroy_Private(PetscObject);

 87: typedef PetscErrorCode (*PetscObjectViewerFunction)(PetscObject,PetscViewer);

 89: /*
 90:     PetscHeaderCreate - Creates a PETSc object

 92:     Input Parameters:
 93: +   tp - the data structure type of the object
 94: .   pops - the data structure type of the objects operations (for example VecOps)
 95: .   cook - the cookie associated with this object
 96: .   t - type (no longer should be used)
 97: .   class_name - string name of class; should be static
 98: .   com - the MPI Communicator
 99: .   des - the destroy routine for this object
100: -   vie - the view routine for this object

102:     Output Parameter:
103: .   h - the newly created object
104: */
105: #define PetscHeaderCreate(h,tp,pops,cook,t,class_name,com,des,vie) \
106:   (PetscNew(struct tp,&(h)) || \
107:    PetscNew(PetscOps,&((h)->bops)) || \
108:    PetscNew(pops,&((h)->ops)) || \
109:    PetscHeaderCreate_Private((PetscObject)h,cook,t,class_name,com,(PetscObjectFunction)des,(PetscObjectViewerFunction)vie) || \
110:    PetscLogObjectCreate(h))

112: #define PetscHeaderDestroy(h) \
113:   (PetscLogObjectDestroy((PetscObject)(h)) || \
114:    PetscHeaderDestroy_Private((PetscObject)(h)) || \
115:    PetscFree(h))

117: /* ---------------------------------------------------------------------------------------*/

119: #if !defined(PETSC_USE_DEBUG)


128: #elif !defined(PETSC_HAVE_CRAY90_POINTER)
129: /* 
130:     Macros to test if a PETSc object is valid and if pointers are
131: valid

133: */
135:   {if (!h) {SETERRQ1(PETSC_ERR_ARG_NULL,"Null Object: Parameter # %d",arg);}          \
136:   if ((unsigned long)h & (unsigned long)3) {                                          \
137:     SETERRQ1(PETSC_ERR_ARG_CORRUPT,"Invalid Pointer to Object: Parameter # %d",arg);   \
138:   }                                                                                   \
139:   if (((PetscObject)(h))->cookie != ck) {                                             \
140:     if (((PetscObject)(h))->cookie == PETSCFREEDHEADER) {                             \
141:       SETERRQ1(PETSC_ERR_ARG_CORRUPT,"Object already free: Parameter # %d",arg);       \
142:     } else {                                                                          \
143:       SETERRQ1(PETSC_ERR_ARG_WRONG,"Wrong type of object: Parameter # %d",arg);       \
144:     }                                                                                 \
145:   }} 

148:   {if (!h) {SETERRQ1(PETSC_ERR_ARG_NULL,"Null Object: Parameter # %d",arg);}             \
149:   if ((unsigned long)h & (unsigned long)3) {                                             \
150:     SETERRQ1(PETSC_ERR_ARG_CORRUPT,"Invalid Pointer to Object: Parameter # %d",arg);     \
151:   } else if (((PetscObject)(h))->cookie == PETSCFREEDHEADER) {                           \
152:       SETERRQ1(PETSC_ERR_ARG_CORRUPT,"Object already free: Parameter # %d",arg);         \
153:   } else if (((PetscObject)(h))->cookie < PETSC_SMALLEST_COOKIE ||                                \
154:       ((PetscObject)(h))->cookie > PETSC_LARGEST_COOKIE) {                               \
155:       SETERRQ1(PETSC_ERR_ARG_CORRUPT,"Invalid type of object: Parameter # %d",arg);      \
156:   }}

159:   {if (!h) {SETERRQ1(PETSC_ERR_ARG_NULL,"Null Pointer: Parameter # %d",arg);}             \
160:   if ((unsigned long)h & (unsigned long)3){                                               \
161:     SETERRQ1(PETSC_ERR_ARG_BADPTR,"Invalid Pointer: Parameter # %d",arg);                 \
162:   }}

165:   {if (!h) {SETERRQ1(PETSC_ERR_ARG_NULL,"Null Pointer: Parameter # %d",arg);}              \
166:   }

169:   {if (!h) {SETERRQ1(PETSC_ERR_ARG_BADPTR,"Null Pointer: Parameter # %d",arg);}            \
170:   if ((unsigned long)h & (unsigned long)3){                                                \
171:     SETERRQ1(PETSC_ERR_ARG_BADPTR,"Invalid Pointer to Int: Parameter # %d",arg);           \
172:   }}

174: #if !defined(PETSC_HAVE_DOUBLES_ALIGNED) || defined (PETSC_HAVE_DOUBLES_ALIGNED)
176:   {if (!h) {SETERRQ1(PETSC_ERR_ARG_NULL,"Null Pointer: Parameter # %d",arg);}               \
177:   if ((unsigned long)h & (unsigned long)3) {                                                \
178:     SETERRQ1(PETSC_ERR_ARG_BADPTR,"Invalid Pointer to PetscScalar: Parameter # %d",arg);    \
179:   }}
180: #else
182:   {if (!h) {SETERRQ1(PETSC_ERR_ARG_NULL,"Null Pointer: Parameter # %d",arg);}               \
183:   if ((unsigned long)h & (unsigned long)7) {                                                \
184:     SETERRQ1(PETSC_ERR_ARG_BADPTR,"Invalid Pointer to PetscScalar: Parameter # %d",arg);    \
185:   }}
186: #endif

188: #else
189: /*
190:      Version for Cray 90 that handles pointers differently
191: */
193:   {if (!h) {SETERRQ(PETSC_ERR_ARG_NULL,"Null Object");}        \
194:   if (((PetscObject)(h))->cookie != ck) {                           \
195:     if (((PetscObject)(h))->cookie == PETSCFREEDHEADER) {           \
196:       SETERRQ(PETSC_ERR_ARG_CORRUPT,"Object already free");       \
197:     } else {                                                        \
198:       SETERRQ(PETSC_ERR_ARG_WRONG,"Wrong Object");                \
199:     }                                                               \
200:   }} 

203:   {if (!h) {SETERRQ(PETSC_ERR_ARG_NULL,"Null Object");}        \
204:   if (((PetscObject)(h))->cookie == PETSCFREEDHEADER) {      \
205:       SETERRQ(PETSC_ERR_ARG_CORRUPT,"Object already free");       \
206:   } else if (((PetscObject)(h))->cookie < PETSC_SMALLEST_COOKIE ||           \
207:       ((PetscObject)(h))->cookie > PETSC_LARGEST_COOKIE) {          \
208:       SETERRQ(PETSC_ERR_ARG_CORRUPT,"Invalid type of object");            \
209:   }}

212:   {if (!h) {SETERRQ(PETSC_ERR_ARG_NULL,"Null Pointer");}        \
213:   }

216:   {if (!h) {SETERRQ(PETSC_ERR_ARG_NULL,"Null Pointer");}        \
217:   }

220:   {if (!h) {SETERRQ(PETSC_ERR_ARG_NULL,"Null Pointer");}        \
221:   }

223: #if !defined(PETSC_HAVE_DOUBLES_ALIGNED)
225:   {if (!h) {SETERRQ(PETSC_ERR_ARG_NULL,"Null Pointer");}        \
226:   }
227: #else
229:   {if (!h) {SETERRQ(PETSC_ERR_ARG_NULL,"Null Pointer");}        \
230:   }
231: #endif

233: #endif

236: #if !defined(PETSC_USE_DEBUG)


243: #else

245: /*
246:     For example, in the dot product between two vectors,
247:   both vectors must be either Seq or MPI, not one of each 
248: */
250:   if ((a)->type != (b)->type) SETERRQ2(PETSC_ERR_ARG_NOTSAMETYPE,"Objects not of same type: Argument # %d and %d",arga,argb);
251: /* 
252:    Use this macro to check if the type is set
253: */
255:   if (!(a)->type_name) SETERRQ1(PETSC_ERR_ARG_WRONGSTATE,"Object Type not set: Argument # %d",arg);
256: /*
257:    Sometimes object must live on same communicator to inter-operate
258: */
260:   {PetscErrorCode _6_ierr,__flag; _6_MPI_Comm_compare(((PetscObject)a)->comm,((PetscObject)b)->comm,&__flag);\
261:   CHKERRQ(_6_ierr); \
262:   if (__flag != MPI_CONGRUENT && __flag != MPI_IDENT) \
263:   SETERRQ2(PETSC_ERR_ARG_NOTSAMECOMM,"Different communicators in the two objects: Argument # %d and %d",arga,argb);}


269: #endif

271: /*
272:    All PETSc objects begin with the fields defined in PETSCHEADER.
273:    The PetscObject is a way of examining these fields regardless of 
274:    the specific object. In C++ this could be a base abstract class
275:    from which all objects are derived.
276: */
277: struct _p_PetscObject {
278:   PETSCHEADER(int);
279: };

281: EXTERN PetscErrorCode  PetscObjectPublishBaseBegin(PetscObject);
282: EXTERN PetscErrorCode  PetscObjectPublishBaseEnd(PetscObject);

284: /*MC
285:    PetscObjectStateIncrease - Increases the state of any PetscObject, 
286:    regardless of the type.

288:    Synopsis:
289:    PetscErrorCode PetscObjectStateIncrease(PetscObject obj)

291:    Not Collective

293:    Input Parameter:
294: .  obj - any PETSc object, for example a Vec, Mat or KSP. This must be
295:          cast with a (PetscObject), for example, 
296:          PetscObjectStateIncrease((PetscObject)mat);

298:    Notes: object state is an integer which gets increased every time
299:    the object is changed. By saving and later querying the object state
300:    one can determine whether information about the object is still current.
301:    Currently, state is maintained for Vec and Mat objects.

303:    This routine is mostly for internal use by PETSc; a developer need only
304:    call it after explicit access to an object's internals. Routines such
305:    as VecSet or MatScale already call this routine. It is also called, as a 
306:    precaution, in VecRestoreArray, MatRestoreRow, MatRestoreArray.

308:    Level: developer

310:    seealso: PetscObjectStateQuery, PetscObjectStateDecrease

312:    Concepts: state

314: M*/
315: #define PetscObjectStateIncrease(obj) ((obj)->state++,0)

317: /*MC
318:    PetscObjectStateDecrease - Decreases the state of any PetscObject, 
319:    regardless of the type.

321:    Synopsis:
322:    PetscErrorCode PetscObjectStateDecrease(PetscObject obj)

324:    Not Collective

326:    Input Parameter:
327: .  obj - any PETSc object, for example a Vec, Mat or KSP. This must be
328:          cast with a (PetscObject), for example, 
329:          PetscObjectStateIncrease((PetscObject)mat);

331:    Notes: object state is an integer which gets increased every time
332:    the object is changed. By saving and later querying the object state
333:    one can determine whether information about the object is still current.
334:    Currently, state is maintained for Vec and Mat objects.

336:    Level: developer

338:    seealso: PetscObjectStateQuery, PetscObjectStateIncrease

340:    Concepts: state

342: M*/
343: #define PetscObjectStateDecrease(obj) ((obj)->state--,0)

345: EXTERN PetscErrorCode  PetscObjectStateQuery(PetscObject,PetscInt*);
346: EXTERN PetscErrorCode  PetscObjectSetState(PetscObject,PetscInt);
347: EXTERN PetscErrorCode  PetscObjectComposedDataRegister(PetscInt*);
348: EXTERN PetscErrorCode  PetscObjectComposedDataIncreaseInt(PetscObject);
349: EXTERN PetscErrorCode  PetscObjectComposedDataIncreaseIntstar(PetscObject);
350: EXTERN PetscErrorCode  PetscObjectComposedDataIncreaseReal(PetscObject);
351: EXTERN PetscErrorCode  PetscObjectComposedDataIncreaseRealstar(PetscObject);
352: EXTERN PetscErrorCode  PetscObjectComposedDataIncreaseScalar(PetscObject);
353: EXTERN PetscErrorCode  PetscObjectComposedDataIncreaseScalarstar(PetscObject);
354: EXTERN PetscInt        globalcurrentstate;
355: EXTERN PetscInt        globalmaxstate;
356: /*MC
357:    PetscObjectComposedDataSetInt - attach integer data to a PetscObject

359:    Synopsis:
360:    PetscErrorCode PetscObjectComposedDataSetInt(PetscObject obj,int id,int data)

362:    Not collective

364:    Input parameters:
365: +  obj - the object to which data is to be attached
366: .  id - the identifier for the data
367: -  data - the data to  be attached

369:    Notes
370:    The data identifier can best be determined through a call to
371:    PetscObjectComposedDataRegister()

373:    Level: developer
374: M*/
375: #define PetscObjectComposedDataSetInt(obj,id,data)                                      \
376:   ((((obj)->int_idmax < globalmaxstate) ? PetscObjectComposedDataIncreaseInt(obj) : 0), \
377:    (obj)->intcomposeddata[id] = data,(obj)->intcomposedstate[id] = (obj)->state, 0)

379: /*MC
380:    PetscObjectComposedDataGetInt - retrieve integer data attached to an object

382:    Synopsis:
383:    PetscErrorCode PetscObjectComposedDataGetInt(PetscObject obj,int id,int *data,PetscTruth *flag)

385:    Not collective

387:    Input parameters:
388: +  obj - the object from which data is to be retrieved
389: -  id - the identifier for the data

391:    Output parameters
392: +  data - the data to be retrieved
393: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

395:    The 'data' and 'flag' variables are inlined, so they are not pointers.

397:    Level: developer
398: M*/
399: #define PetscObjectComposedDataGetInt(obj,id,data,flag)                            \
400:   ((((obj)->intcomposedstate && ((obj)->intcomposedstate[id] == (obj)->state)) ?   \
401:    (data = (obj)->intcomposeddata[id],flag = PETSC_TRUE) : (flag = PETSC_FALSE)),0)

403: /*MC
404:    PetscObjectComposedDataSetIntstar - attach integer array data to a PetscObject

406:    Synopsis:
407:    PetscErrorCode PetscObjectComposedDataSetIntstar(PetscObject obj,int id,int *data)

409:    Not collective

411:    Input parameters:
412: +  obj - the object to which data is to be attached
413: .  id - the identifier for the data
414: -  data - the data to  be attached

416:    Notes
417:    The data identifier can best be determined through a call to
418:    PetscObjectComposedDataRegister()

420:    Level: developer
421: M*/
422: #define PetscObjectComposedDataSetIntstar(obj,id,data)                                          \
423:   ((((obj)->intstar_idmax < globalmaxstate) ? PetscObjectComposedDataIncreaseIntstar(obj) : 0), \
424:   (obj)->intstarcomposeddata[id] = data,(obj)->intstarcomposedstate[id] = (obj)->state, 0)

426: /*MC
427:    PetscObjectComposedDataGetIntstar - retrieve integer array data 
428:    attached to an object

430:    Synopsis:
431:    PetscErrorCode PetscObjectComposedDataGetIntstar(PetscObject obj,int id,int **data,PetscTruth *flag)

433:    Not collective

435:    Input parameters:
436: +  obj - the object from which data is to be retrieved
437: -  id - the identifier for the data

439:    Output parameters
440: +  data - the data to be retrieved
441: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

443:    The 'data' and 'flag' variables are inlined, so they are not pointers.

445:    Level: developer
446: M*/
447: #define PetscObjectComposedDataGetIntstar(obj,id,data,flag)                               \
448:   ((((obj)->intstarcomposedstate && ((obj)->intstarcomposedstate[id] == (obj)->state)) ?  \
449:    (data = (obj)->intstarcomposeddata[id],flag = PETSC_TRUE) : (flag = PETSC_FALSE)),0)

451: /*MC
452:    PetscObjectComposedDataSetReal - attach real data to a PetscObject

454:    Synopsis:
455:    PetscErrorCode PetscObjectComposedDataSetReal(PetscObject obj,int id,PetscReal data)

457:    Not collective

459:    Input parameters:
460: +  obj - the object to which data is to be attached
461: .  id - the identifier for the data
462: -  data - the data to  be attached

464:    Notes
465:    The data identifier can best be determined through a call to
466:    PetscObjectComposedDataRegister()

468:    Level: developer
469: M*/
470: #define PetscObjectComposedDataSetReal(obj,id,data)                                       \
471:   ((((obj)->real_idmax < globalmaxstate) ? PetscObjectComposedDataIncreaseReal(obj) : 0), \
472:    (obj)->realcomposeddata[id] = data,(obj)->realcomposedstate[id] = (obj)->state, 0)

474: /*MC
475:    PetscObjectComposedDataGetReal - retrieve real data attached to an object

477:    Synopsis:
478:    PetscErrorCode PetscObjectComposedDataGetReal(PetscObject obj,int id,PetscReal *data,PetscTruth *flag)

480:    Not collective

482:    Input parameters:
483: +  obj - the object from which data is to be retrieved
484: -  id - the identifier for the data

486:    Output parameters
487: +  data - the data to be retrieved
488: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

490:    The 'data' and 'flag' variables are inlined, so they are not pointers.

492:    Level: developer
493: M*/
494: #define PetscObjectComposedDataGetReal(obj,id,data,flag)                            \
495:   ((((obj)->realcomposedstate && ((obj)->realcomposedstate[id] == (obj)->state)) ?  \
496:    (data = (obj)->realcomposeddata[id],flag = PETSC_TRUE) : (flag = PETSC_FALSE)),0)

498: /*MC
499:    PetscObjectComposedDataSetRealstar - attach real array data to a PetscObject

501:    Synopsis:
502:    PetscErrorCode PetscObjectComposedDataSetRealstar(PetscObject obj,int id,PetscReal *data)

504:    Not collective

506:    Input parameters:
507: +  obj - the object to which data is to be attached
508: .  id - the identifier for the data
509: -  data - the data to  be attached

511:    Notes
512:    The data identifier can best be determined through a call to
513:    PetscObjectComposedDataRegister()

515:    Level: developer
516: M*/
517: #define PetscObjectComposedDataSetRealstar(obj,id,data)                                           \
518:   ((((obj)->realstar_idmax < globalmaxstate) ? PetscObjectComposedDataIncreaseRealstar(obj) : 0), \
519:   (obj)->realstarcomposeddata[id] = data, (obj)->realstarcomposedstate[id] = (obj)->state, 0)

521: /*MC
522:    PetscObjectComposedDataGetRealstar - retrieve real array data
523:    attached to an object

525:    Synopsis:
526:    PetscErrorCode PetscObjectComposedDataGetRealstar(PetscObject obj,int id,PetscReal **data,PetscTruth *flag)

528:    Not collective

530:    Input parameters:
531: +  obj - the object from which data is to be retrieved
532: -  id - the identifier for the data

534:    Output parameters
535: +  data - the data to be retrieved
536: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

538:    The 'data' and 'flag' variables are inlined, so they are not pointers.

540:    Level: developer
541: M*/
542: #define PetscObjectComposedDataGetRealstar(obj,id,data,flag)                                \
543:   ((((obj)->realstarcomposedstate && ((obj)->realstarcomposedstate[id] == (obj)->state)) ?  \
544:    (data = (obj)->realstarcomposeddata[id],flag = PETSC_TRUE) : (flag = PETSC_FALSE)),0)

546: /*MC
547:    PetscObjectSetScalarComposedData - attach scalar data to a PetscObject 

549:    Synopsis:
550:    PetscErrorCode PetscObjectSetScalarComposedData(PetscObject obj,int id,PetscScalar data)

552:    Not collective

554:    Input parameters:
555: +  obj - the object to which data is to be attached
556: .  id - the identifier for the data
557: -  data - the data to  be attached

559:    Notes
560:    The data identifier can best be determined through a call to
561:    PetscObjectComposedDataRegister()

563:    Level: developer
564: M*/
565: #if defined(PETSC_USE_COMPLEX)
566: #define PetscObjectComposedDataSetScalar(obj,id,data)                                        \
567:   ((((obj)->scalar_idmax < globalmaxstate) ? PetscObjectComposedDataIncreaseScalar(obj) : 0) \
568:   (obj)->scalarcomposeddata[id] = data,(obj)->scalarcomposedstate[id] = (obj)->state, 0)
569: #else
570: #define PetscObjectComposedDataSetScalar(obj,id,data) \
571:         PetscObjectComposedDataSetReal(obj,id,data)
572: #endif
573: /*MC
574:    PetscObjectComposedDataGetScalar - retrieve scalar data attached to an object

576:    Synopsis:
577:    PetscErrorCode PetscObjectComposedDataGetScalar(PetscObject obj,int id,PetscScalar *data,PetscTruth *flag)

579:    Not collective

581:    Input parameters:
582: +  obj - the object from which data is to be retrieved
583: -  id - the identifier for the data

585:    Output parameters
586: +  data - the data to be retrieved
587: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

589:    The 'data' and 'flag' variables are inlined, so they are not pointers.

591:    Level: developer
592: M*/
593: #if defined(PETSC_USE_COMPLEX)
594: #define PetscObjectComposedDataGetScalar(obj,id,data,flag)                              \
595:   ((((obj)->scalarcomposedstate && ((obj)->scalarcomposedstate[id] == (obj)->state) ) ? \
596:    (data = (obj)->scalarcomposeddata[id],flag = PETSC_TRUE) : (flag = PETSC_FALSE)),0)
597: #else
598: #define PetscObjectComposedDataGetScalar(obj,id,data,flag)                             \
599:         PetscObjectComposedDataGetReal(obj,id,data,flag)
600: #endif

602: /*MC
603:    PetscObjectComposedDataSetScalarstar - attach scalar array data to a PetscObject 

605:    Synopsis:
606:    PetscErrorCode PetscObjectComposedDataSetScalarstar(PetscObject obj,int id,PetscScalar *data)

608:    Not collective

610:    Input parameters:
611: +  obj - the object to which data is to be attached
612: .  id - the identifier for the data
613: -  data - the data to  be attached

615:    Notes
616:    The data identifier can best be determined through a call to
617:    PetscObjectComposedDataRegister()

619:    Level: developer
620: M*/
621: #if defined(PETSC_USE_COMPLEX)
622: #define PetscObjectComposedDataSetScalarstar(obj,id,data)                                             \
623:   ((((obj)->scalarstar_idmax < globalmaxstate) ? PetscObjectComposedDataIncreaseScalarstar(obj) : 0), \
624:    (obj)->scalarstarcomposeddata[id] = data,(obj)->scalarstarcomposedstate[id] = (obj)->state, 0)
625: #else
626: #define PetscObjectComposedDataSetScalarstar(obj,id,data) \
627:         PetscObjectComposedDataSetRealstar(obj,id,data)
628: #endif
629: /*MC
630:    PetscObjectComposedDataGetScalarstar - retrieve scalar array data
631:    attached to an object

633:    Synopsis:
634:    PetscErrorCode PetscObjectComposedDataGetScalarstar(PetscObject obj,int id,PetscScalar **data,PetscTruth *flag)

636:    Not collective

638:    Input parameters:
639: +  obj - the object from which data is to be retrieved
640: -  id - the identifier for the data

642:    Output parameters
643: +  data - the data to be retrieved
644: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

646:    The 'data' and 'flag' variables are inlined, so they are not pointers.

648:    Level: developer
649: M*/
650: #if defined(PETSC_USE_COMPLEX)
651: #define PetscObjectComposedDataGetScalarstar(obj,id,data,flag)                                 \
652:   ((((obj)->scalarstarcomposedstate && ((obj)->scalarstarcomposedstate[id] == (obj)->state)) ? \
653:        (data = (obj)->scalarstarcomposeddata[id],flag = PETSC_TRUE) : (flag = PETSC_FALSE)),0)
654: #else
655: #define PetscObjectComposedDataGetScalarstar(obj,id,data,flag)                 \
656:         PetscObjectComposedDataGetRealstar(obj,id,data,flag)
657: #endif

659: /* some vars for logging */

664: #endif /* _PETSCHEAD_H */