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

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

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

 17: /*
 18:    PetscOps: structure of core operations that all PETSc objects support.
 19:    
 20:       getcomm()         - Gets the object's communicator.
 21:       view()            - Is the routine for viewing the entire PETSc object; for
 22:                           example, MatView() is the general matrix viewing routine.
 23:       reference()       - Increases the reference count for a PETSc object; when
 24:                           a reference count reaches zero it is destroyed.
 25:       destroy()         - Is the routine for destroying the entire PETSc object; 
 26:                           for example,MatDestroy() is the general matrix 
 27:                           destruction routine.
 28:       compose()         - Associates a PETSc object with another PETSc object.
 29:       query()           - Returns a different PETSc object that has been associated
 30:                           with the first object.
 31:       composefunction() - Attaches an additional registered function.
 32:       queryfunction()   - Requests a registered function that has been registered.
 33:       composelanguage() - associates the object's representation in a different language
 34:       querylanguage()   - obtain the object's representation in a different language
 35: */

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

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

 82:   /*  ... */

 84: #define  PETSCFREEDHEADER -1

 86: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscHeaderCreate_Private(PetscObject,PetscCookie,PetscInt,const char[],MPI_Comm,PetscErrorCode (*)(PetscObject),PetscErrorCode (*)(PetscObject,PetscViewer));
 87: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscHeaderDestroy_Private(PetscObject);

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

 92: /*
 93:     PetscHeaderCreate - Creates a PETSc object

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

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

115: #define PetscHeaderDestroy(h) \
116:   (PetscLogObjectDestroy((PetscObject)(h)) || \
117:    PetscHeaderDestroy_Private((PetscObject)(h)) || \
118:    PetscFree(h))

120: /* ---------------------------------------------------------------------------------------*/

122: #if !defined(PETSC_USE_DEBUG)


131: #elif !defined(PETSC_HAVE_CRAY90_POINTER)
132: /* 
133:     Macros to test if a PETSc object is valid and if pointers are
134: valid

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

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

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

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

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

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

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

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

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

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

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

226: #if !defined(PETSC_HAVE_DOUBLES_ALIGNED)
228:   {if (!h) {SETERRQ(PETSC_ERR_ARG_NULL,"Null Pointer");}        \
229:   }
230: #else
232:   {if (!h) {SETERRQ(PETSC_ERR_ARG_NULL,"Null Pointer");}        \
233:   }
234: #endif

236: #endif

239: #if !defined(PETSC_USE_DEBUG)


246: #else

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


272: #endif

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

284: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectPublishBaseBegin(PetscObject);
285: EXTERN PetscErrorCode PETSC_DLLEXPORT PetscObjectPublishBaseEnd(PetscObject);

287: /*MC
288:    PetscObjectStateIncrease - Increases the state of any PetscObject, 
289:    regardless of the type.

291:    Synopsis:
292:    PetscErrorCode PetscObjectStateIncrease(PetscObject obj)

294:    Not Collective

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

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

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

311:    Level: developer

313:    seealso: PetscObjectStateQuery, PetscObjectStateDecrease

315:    Concepts: state

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

320: /*MC
321:    PetscObjectStateDecrease - Decreases the state of any PetscObject, 
322:    regardless of the type.

324:    Synopsis:
325:    PetscErrorCode PetscObjectStateDecrease(PetscObject obj)

327:    Not Collective

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

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

339:    Level: developer

341:    seealso: PetscObjectStateQuery, PetscObjectStateIncrease

343:    Concepts: state

345: M*/
346: #define PetscObjectStateDecrease(obj) ((obj)->state--,0)

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

362:    Synopsis:
363:    PetscErrorCode PetscObjectComposedDataSetInt(PetscObject obj,int id,int data)

365:    Not collective

367:    Input parameters:
368: +  obj - the object to which data is to be attached
369: .  id - the identifier for the data
370: -  data - the data to  be attached

372:    Notes
373:    The data identifier can best be determined through a call to
374:    PetscObjectComposedDataRegister()

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

382: /*MC
383:    PetscObjectComposedDataGetInt - retrieve integer data attached to an object

385:    Synopsis:
386:    PetscErrorCode PetscObjectComposedDataGetInt(PetscObject obj,int id,int *data,PetscTruth *flag)

388:    Not collective

390:    Input parameters:
391: +  obj - the object from which data is to be retrieved
392: -  id - the identifier for the data

394:    Output parameters
395: +  data - the data to be retrieved
396: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

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

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

406: /*MC
407:    PetscObjectComposedDataSetIntstar - attach integer array data to a PetscObject

409:    Synopsis:
410:    PetscErrorCode PetscObjectComposedDataSetIntstar(PetscObject obj,int id,int *data)

412:    Not collective

414:    Input parameters:
415: +  obj - the object to which data is to be attached
416: .  id - the identifier for the data
417: -  data - the data to  be attached

419:    Notes
420:    The data identifier can best be determined through a call to
421:    PetscObjectComposedDataRegister()

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

429: /*MC
430:    PetscObjectComposedDataGetIntstar - retrieve integer array data 
431:    attached to an object

433:    Synopsis:
434:    PetscErrorCode PetscObjectComposedDataGetIntstar(PetscObject obj,int id,int **data,PetscTruth *flag)

436:    Not collective

438:    Input parameters:
439: +  obj - the object from which data is to be retrieved
440: -  id - the identifier for the data

442:    Output parameters
443: +  data - the data to be retrieved
444: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

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

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

454: /*MC
455:    PetscObjectComposedDataSetReal - attach real data to a PetscObject

457:    Synopsis:
458:    PetscErrorCode PetscObjectComposedDataSetReal(PetscObject obj,int id,PetscReal data)

460:    Not collective

462:    Input parameters:
463: +  obj - the object to which data is to be attached
464: .  id - the identifier for the data
465: -  data - the data to  be attached

467:    Notes
468:    The data identifier can best be determined through a call to
469:    PetscObjectComposedDataRegister()

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

477: /*MC
478:    PetscObjectComposedDataGetReal - retrieve real data attached to an object

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

483:    Not collective

485:    Input parameters:
486: +  obj - the object from which data is to be retrieved
487: -  id - the identifier for the data

489:    Output parameters
490: +  data - the data to be retrieved
491: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

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

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

501: /*MC
502:    PetscObjectComposedDataSetRealstar - attach real array data to a PetscObject

504:    Synopsis:
505:    PetscErrorCode PetscObjectComposedDataSetRealstar(PetscObject obj,int id,PetscReal *data)

507:    Not collective

509:    Input parameters:
510: +  obj - the object to which data is to be attached
511: .  id - the identifier for the data
512: -  data - the data to  be attached

514:    Notes
515:    The data identifier can best be determined through a call to
516:    PetscObjectComposedDataRegister()

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

524: /*MC
525:    PetscObjectComposedDataGetRealstar - retrieve real array data
526:    attached to an object

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

531:    Not collective

533:    Input parameters:
534: +  obj - the object from which data is to be retrieved
535: -  id - the identifier for the data

537:    Output parameters
538: +  data - the data to be retrieved
539: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

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

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

549: /*MC
550:    PetscObjectSetScalarComposedData - attach scalar data to a PetscObject 

552:    Synopsis:
553:    PetscErrorCode PetscObjectSetScalarComposedData(PetscObject obj,int id,PetscScalar data)

555:    Not collective

557:    Input parameters:
558: +  obj - the object to which data is to be attached
559: .  id - the identifier for the data
560: -  data - the data to  be attached

562:    Notes
563:    The data identifier can best be determined through a call to
564:    PetscObjectComposedDataRegister()

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

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

582:    Not collective

584:    Input parameters:
585: +  obj - the object from which data is to be retrieved
586: -  id - the identifier for the data

588:    Output parameters
589: +  data - the data to be retrieved
590: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

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

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

605: /*MC
606:    PetscObjectComposedDataSetScalarstar - attach scalar array data to a PetscObject 

608:    Synopsis:
609:    PetscErrorCode PetscObjectComposedDataSetScalarstar(PetscObject obj,int id,PetscScalar *data)

611:    Not collective

613:    Input parameters:
614: +  obj - the object to which data is to be attached
615: .  id - the identifier for the data
616: -  data - the data to  be attached

618:    Notes
619:    The data identifier can best be determined through a call to
620:    PetscObjectComposedDataRegister()

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

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

639:    Not collective

641:    Input parameters:
642: +  obj - the object from which data is to be retrieved
643: -  id - the identifier for the data

645:    Output parameters
646: +  data - the data to be retrieved
647: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

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

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

662: /* some vars for logging */

666: #endif /* _PETSCHEAD_H */