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: /*@C
     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

    105:     Level: developer

    107: .seealso: PetscHeaderDestroy(), PetscLogClassRegister()

    109: @*/
    110: #define PetscHeaderCreate(h,tp,pops,cook,t,class_name,com,des,vie) \
    111:   (PetscNew(struct tp,&(h)) || \
    112:    PetscNew(PetscOps,&((h)->bops)) || \
    113:    PetscNew(pops,&((h)->ops)) || \
    114:    PetscHeaderCreate_Private((PetscObject)h,cook,t,class_name,com,(PetscObjectFunction)des,(PetscObjectViewerFunction)vie) || \
    115:    PetscLogObjectCreate(h))

    117: /*@C
    118:     PetscHeaderDestroy - Final step in destroying a PetscObject

    120:     Input Parameters:
    121: .   h - the header created with PetscHeaderCreate()

    123:     Level: developer

    125: .seealso: PetscHeaderCreate()
    126: @*/
    127: #define PetscHeaderDestroy(h) \
    128:   (PetscLogObjectDestroy((PetscObject)(h)) || \
    129:    PetscHeaderDestroy_Private((PetscObject)(h)) || \
    130:    PetscFree(h))

    132: /* ---------------------------------------------------------------------------------------*/

    134: #if !defined(PETSC_USE_DEBUG)

    143: #elif !defined(PETSC_HAVE_CRAY90_POINTER)
    144: /*
    145:     Macros to test if a PETSc object is valid and if pointers are
    146: valid

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

    163:   {if (!h) {SETERRQ1(PETSC_ERR_ARG_NULL,"Null Object: Parameter # %d",arg);}             \
    164:   if ((unsigned long)h & (unsigned long)3) {                                             \
    165:     SETERRQ1(PETSC_ERR_ARG_CORRUPT,"Invalid Pointer to Object: Parameter # %d",arg);     \
    166:   } else if (((PetscObject)(h))->cookie == PETSCFREEDHEADER) {                           \
    167:       SETERRQ1(PETSC_ERR_ARG_CORRUPT,"Object already free: Parameter # %d",arg);         \
    168:   } else if (((PetscObject)(h))->cookie < PETSC_SMALLEST_COOKIE ||                                \
    169:       ((PetscObject)(h))->cookie > PETSC_LARGEST_COOKIE) {                               \
    170:       SETERRQ1(PETSC_ERR_ARG_CORRUPT,"Invalid type of object: Parameter # %d",arg);      \
    171:   }}

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

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

    184:   {if (!h) {SETERRQ1(PETSC_ERR_ARG_BADPTR,"Null Pointer: Parameter # %d",arg);}            \
    185:   if ((unsigned long)h & (unsigned long)3){                                                \
    186:     SETERRQ1(PETSC_ERR_ARG_BADPTR,"Invalid Pointer to Int: Parameter # %d",arg);           \
    187:   }}

    189: #if !defined(PETSC_HAVE_DOUBLES_ALIGNED) || defined (PETSC_HAVE_DOUBLES_ALIGNED)
    191:   {if (!h) {SETERRQ1(PETSC_ERR_ARG_NULL,"Null Pointer: Parameter # %d",arg);}               \
    192:   if ((unsigned long)h & (unsigned long)3) {                                                \
    193:     SETERRQ1(PETSC_ERR_ARG_BADPTR,"Invalid Pointer to PetscScalar: Parameter # %d",arg);    \
    194:   }}
    195: #else
    197:   {if (!h) {SETERRQ1(PETSC_ERR_ARG_NULL,"Null Pointer: Parameter # %d",arg);}               \
    198:   if ((unsigned long)h & (unsigned long)7) {                                                \
    199:     SETERRQ1(PETSC_ERR_ARG_BADPTR,"Invalid Pointer to PetscScalar: Parameter # %d",arg);    \
    200:   }}
    201: #endif

    203: #else
    204: /*
    205:      Version for Cray 90 that handles pointers differently
    206: */
    208:   {if (!h) {SETERRQ(PETSC_ERR_ARG_NULL,"Null Object");}        \
    209:   if (((PetscObject)(h))->cookie != ck) {                           \
    210:     if (((PetscObject)(h))->cookie == PETSCFREEDHEADER) {           \
    211:       SETERRQ(PETSC_ERR_ARG_CORRUPT,"Object already free");       \
    212:     } else {                                                        \
    213:       SETERRQ(PETSC_ERR_ARG_WRONG,"Wrong Object");                \
    214:     }                                                               \
    215:   }}

    218:   {if (!h) {SETERRQ(PETSC_ERR_ARG_NULL,"Null Object");}        \
    219:   if (((PetscObject)(h))->cookie == PETSCFREEDHEADER) {      \
    220:       SETERRQ(PETSC_ERR_ARG_CORRUPT,"Object already free");       \
    221:   } else if (((PetscObject)(h))->cookie < PETSC_SMALLEST_COOKIE ||           \
    222:       ((PetscObject)(h))->cookie > PETSC_LARGEST_COOKIE) {          \
    223:       SETERRQ(PETSC_ERR_ARG_CORRUPT,"Invalid type of object");            \
    224:   }}

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

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

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

    238: #if !defined(PETSC_HAVE_DOUBLES_ALIGNED)
    240:   {if (!h) {SETERRQ(PETSC_ERR_ARG_NULL,"Null Pointer");}        \
    241:   }
    242: #else
    244:   {if (!h) {SETERRQ(PETSC_ERR_ARG_NULL,"Null Pointer");}        \
    245:   }
    246: #endif

    248: #endif

    251: #if !defined(PETSC_USE_DEBUG)

    258: #else

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

    284: #endif

    286: /*
    287:    All PETSc objects begin with the fields defined in PETSCHEADER.
    288:    The PetscObject is a way of examining these fields regardless of
    289:    the specific object. In C++ this could be a base abstract class
    290:    from which all objects are derived.
    291: */
    292: struct _p_PetscObject {
    293:   PETSCHEADER(int);
    294: };

    296: EXTERN PetscErrorCode  PetscObjectPublishBaseBegin(PetscObject);
    297: EXTERN PetscErrorCode  PetscObjectPublishBaseEnd(PetscObject);

    299: /*MC
    300:    PetscObjectStateIncrease - Increases the state of any PetscObject,
    301:    regardless of the type.

    303:    Synopsis:
    304:    PetscErrorCode PetscObjectStateIncrease(PetscObject obj)

    306:    Not Collective

    308:    Input Parameter:
    309: .  obj - any PETSc object, for example a Vec, Mat or KSP. This must be
    310:          cast with a (PetscObject), for example,
    311:          PetscObjectStateIncrease((PetscObject)mat);

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

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

    323:    Level: developer

    325:    seealso: PetscObjectStateQuery(), PetscObjectStateDecrease()

    327:    Concepts: state

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

    332: /*MC
    333:    PetscObjectStateDecrease - Decreases the state of any PetscObject,
    334:    regardless of the type.

    336:    Synopsis:
    337:    PetscErrorCode PetscObjectStateDecrease(PetscObject obj)

    339:    Not Collective

    341:    Input Parameter:
    342: .  obj - any PETSc object, for example a Vec, Mat or KSP. This must be
    343:          cast with a (PetscObject), for example,
    344:          PetscObjectStateIncrease((PetscObject)mat);

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

    351:    Level: developer

    353:    seealso: PetscObjectStateQuery(), PetscObjectStateIncrease()

    355:    Concepts: state

    357: M*/
    358: #define PetscObjectStateDecrease(obj) ((obj)->state--,0)

    360: EXTERN PetscErrorCode  PetscObjectStateQuery(PetscObject,PetscInt*);
    361: EXTERN PetscErrorCode  PetscObjectSetState(PetscObject,PetscInt);
    362: EXTERN PetscErrorCode  PetscObjectComposedDataRegister(PetscInt*);
    363: EXTERN PetscErrorCode  PetscObjectComposedDataIncreaseInt(PetscObject);
    364: EXTERN PetscErrorCode  PetscObjectComposedDataIncreaseIntstar(PetscObject);
    365: EXTERN PetscErrorCode  PetscObjectComposedDataIncreaseReal(PetscObject);
    366: EXTERN PetscErrorCode  PetscObjectComposedDataIncreaseRealstar(PetscObject);
    367: EXTERN PetscErrorCode  PetscObjectComposedDataIncreaseScalar(PetscObject);
    368: EXTERN PetscErrorCode  PetscObjectComposedDataIncreaseScalarstar(PetscObject);
    369: EXTERN PetscInt        globalcurrentstate;
    370: EXTERN PetscInt        globalmaxstate;
    371: /*MC
    372:    PetscObjectComposedDataSetInt - attach integer data to a PetscObject

    374:    Synopsis:
    375:    PetscErrorCode PetscObjectComposedDataSetInt(PetscObject obj,int id,int data)

    377:    Not collective

    379:    Input parameters:
    380: +  obj - the object to which data is to be attached
    381: .  id - the identifier for the data
    382: -  data - the data to  be attached

    384:    Notes
    385:    The data identifier can best be determined through a call to
    386:    PetscObjectComposedDataRegister()

    388:    Level: developer
    389: M*/
    390: #define PetscObjectComposedDataSetInt(obj,id,data)                                      \
    391:   ((((obj)->int_idmax < globalmaxstate) ? PetscObjectComposedDataIncreaseInt(obj) : 0), \
    392:    (obj)->intcomposeddata[id] = data,(obj)->intcomposedstate[id] = (obj)->state, 0)

    394: /*MC
    395:    PetscObjectComposedDataGetInt - retrieve integer data attached to an object

    397:    Synopsis:
    398:    PetscErrorCode PetscObjectComposedDataGetInt(PetscObject obj,int id,int *data,PetscTruth *flag)

    400:    Not collective

    402:    Input parameters:
    403: +  obj - the object from which data is to be retrieved
    404: -  id - the identifier for the data

    406:    Output parameters
    407: +  data - the data to be retrieved
    408: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

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

    412:    Level: developer
    413: M*/
    414: #define PetscObjectComposedDataGetInt(obj,id,data,flag)                            \
    415:   ((((obj)->intcomposedstate && ((obj)->intcomposedstate[id] == (obj)->state)) ?   \
    416:    (data = (obj)->intcomposeddata[id],flag = PETSC_TRUE) : (flag = PETSC_FALSE)),0)

    418: /*MC
    419:    PetscObjectComposedDataSetIntstar - attach integer array data to a PetscObject

    421:    Synopsis:
    422:    PetscErrorCode PetscObjectComposedDataSetIntstar(PetscObject obj,int id,int *data)

    424:    Not collective

    426:    Input parameters:
    427: +  obj - the object to which data is to be attached
    428: .  id - the identifier for the data
    429: -  data - the data to  be attached

    431:    Notes
    432:    The data identifier can best be determined through a call to
    433:    PetscObjectComposedDataRegister()

    435:    Level: developer
    436: M*/
    437: #define PetscObjectComposedDataSetIntstar(obj,id,data)                                          \
    438:   ((((obj)->intstar_idmax < globalmaxstate) ? PetscObjectComposedDataIncreaseIntstar(obj) : 0), \
    439:   (obj)->intstarcomposeddata[id] = data,(obj)->intstarcomposedstate[id] = (obj)->state, 0)

    441: /*MC
    442:    PetscObjectComposedDataGetIntstar - retrieve integer array data
    443:    attached to an object

    445:    Synopsis:
    446:    PetscErrorCode PetscObjectComposedDataGetIntstar(PetscObject obj,int id,int **data,PetscTruth *flag)

    448:    Not collective

    450:    Input parameters:
    451: +  obj - the object from which data is to be retrieved
    452: -  id - the identifier for the data

    454:    Output parameters
    455: +  data - the data to be retrieved
    456: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

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

    460:    Level: developer
    461: M*/
    462: #define PetscObjectComposedDataGetIntstar(obj,id,data,flag)                               \
    463:   ((((obj)->intstarcomposedstate && ((obj)->intstarcomposedstate[id] == (obj)->state)) ?  \
    464:    (data = (obj)->intstarcomposeddata[id],flag = PETSC_TRUE) : (flag = PETSC_FALSE)),0)

    466: /*MC
    467:    PetscObjectComposedDataSetReal - attach real data to a PetscObject

    469:    Synopsis:
    470:    PetscErrorCode PetscObjectComposedDataSetReal(PetscObject obj,int id,PetscReal data)

    472:    Not collective

    474:    Input parameters:
    475: +  obj - the object to which data is to be attached
    476: .  id - the identifier for the data
    477: -  data - the data to  be attached

    479:    Notes
    480:    The data identifier can best be determined through a call to
    481:    PetscObjectComposedDataRegister()

    483:    Level: developer
    484: M*/
    485: #define PetscObjectComposedDataSetReal(obj,id,data)                                       \
    486:   ((((obj)->real_idmax < globalmaxstate) ? PetscObjectComposedDataIncreaseReal(obj) : 0), \
    487:    (obj)->realcomposeddata[id] = data,(obj)->realcomposedstate[id] = (obj)->state, 0)

    489: /*MC
    490:    PetscObjectComposedDataGetReal - retrieve real data attached to an object

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

    495:    Not collective

    497:    Input parameters:
    498: +  obj - the object from which data is to be retrieved
    499: -  id - the identifier for the data

    501:    Output parameters
    502: +  data - the data to be retrieved
    503: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

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

    507:    Level: developer
    508: M*/
    509: #define PetscObjectComposedDataGetReal(obj,id,data,flag)                            \
    510:   ((((obj)->realcomposedstate && ((obj)->realcomposedstate[id] == (obj)->state)) ?  \
    511:    (data = (obj)->realcomposeddata[id],flag = PETSC_TRUE) : (flag = PETSC_FALSE)),0)

    513: /*MC
    514:    PetscObjectComposedDataSetRealstar - attach real array data to a PetscObject

    516:    Synopsis:
    517:    PetscErrorCode PetscObjectComposedDataSetRealstar(PetscObject obj,int id,PetscReal *data)

    519:    Not collective

    521:    Input parameters:
    522: +  obj - the object to which data is to be attached
    523: .  id - the identifier for the data
    524: -  data - the data to  be attached

    526:    Notes
    527:    The data identifier can best be determined through a call to
    528:    PetscObjectComposedDataRegister()

    530:    Level: developer
    531: M*/
    532: #define PetscObjectComposedDataSetRealstar(obj,id,data)                                           \
    533:   ((((obj)->realstar_idmax < globalmaxstate) ? PetscObjectComposedDataIncreaseRealstar(obj) : 0), \
    534:   (obj)->realstarcomposeddata[id] = data, (obj)->realstarcomposedstate[id] = (obj)->state, 0)

    536: /*MC
    537:    PetscObjectComposedDataGetRealstar - retrieve real array data
    538:    attached to an object

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

    543:    Not collective

    545:    Input parameters:
    546: +  obj - the object from which data is to be retrieved
    547: -  id - the identifier for the data

    549:    Output parameters
    550: +  data - the data to be retrieved
    551: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

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

    555:    Level: developer
    556: M*/
    557: #define PetscObjectComposedDataGetRealstar(obj,id,data,flag)                                \
    558:   ((((obj)->realstarcomposedstate && ((obj)->realstarcomposedstate[id] == (obj)->state)) ?  \
    559:    (data = (obj)->realstarcomposeddata[id],flag = PETSC_TRUE) : (flag = PETSC_FALSE)),0)

    561: /*MC
    562:    PetscObjectSetScalarComposedData - attach scalar data to a PetscObject

    564:    Synopsis:
    565:    PetscErrorCode PetscObjectSetScalarComposedData(PetscObject obj,int id,PetscScalar data)

    567:    Not collective

    569:    Input parameters:
    570: +  obj - the object to which data is to be attached
    571: .  id - the identifier for the data
    572: -  data - the data to  be attached

    574:    Notes
    575:    The data identifier can best be determined through a call to
    576:    PetscObjectComposedDataRegister()

    578:    Level: developer
    579: M*/
    580: #if defined(PETSC_USE_COMPLEX)
    581: #define PetscObjectComposedDataSetScalar(obj,id,data)                                        \
    582:   ((((obj)->scalar_idmax < globalmaxstate) ? PetscObjectComposedDataIncreaseScalar(obj) : 0) \
    583:   (obj)->scalarcomposeddata[id] = data,(obj)->scalarcomposedstate[id] = (obj)->state, 0)
    584: #else
    585: #define PetscObjectComposedDataSetScalar(obj,id,data) \
    586:         PetscObjectComposedDataSetReal(obj,id,data)
    587: #endif
    588: /*MC
    589:    PetscObjectComposedDataGetScalar - retrieve scalar data attached to an object

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

    594:    Not collective

    596:    Input parameters:
    597: +  obj - the object from which data is to be retrieved
    598: -  id - the identifier for the data

    600:    Output parameters
    601: +  data - the data to be retrieved
    602: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

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

    606:    Level: developer
    607: M*/
    608: #if defined(PETSC_USE_COMPLEX)
    609: #define PetscObjectComposedDataGetScalar(obj,id,data,flag)                              \
    610:   ((((obj)->scalarcomposedstate && ((obj)->scalarcomposedstate[id] == (obj)->state) ) ? \
    611:    (data = (obj)->scalarcomposeddata[id],flag = PETSC_TRUE) : (flag = PETSC_FALSE)),0)
    612: #else
    613: #define PetscObjectComposedDataGetScalar(obj,id,data,flag)                             \
    614:         PetscObjectComposedDataGetReal(obj,id,data,flag)
    615: #endif

    617: /*MC
    618:    PetscObjectComposedDataSetScalarstar - attach scalar array data to a PetscObject

    620:    Synopsis:
    621:    PetscErrorCode PetscObjectComposedDataSetScalarstar(PetscObject obj,int id,PetscScalar *data)

    623:    Not collective

    625:    Input parameters:
    626: +  obj - the object to which data is to be attached
    627: .  id - the identifier for the data
    628: -  data - the data to  be attached

    630:    Notes
    631:    The data identifier can best be determined through a call to
    632:    PetscObjectComposedDataRegister()

    634:    Level: developer
    635: M*/
    636: #if defined(PETSC_USE_COMPLEX)
    637: #define PetscObjectComposedDataSetScalarstar(obj,id,data)                                             \
    638:   ((((obj)->scalarstar_idmax < globalmaxstate) ? PetscObjectComposedDataIncreaseScalarstar(obj) : 0), \
    639:    (obj)->scalarstarcomposeddata[id] = data,(obj)->scalarstarcomposedstate[id] = (obj)->state, 0)
    640: #else
    641: #define PetscObjectComposedDataSetScalarstar(obj,id,data) \
    642:         PetscObjectComposedDataSetRealstar(obj,id,data)
    643: #endif
    644: /*MC
    645:    PetscObjectComposedDataGetScalarstar - retrieve scalar array data
    646:    attached to an object

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

    651:    Not collective

    653:    Input parameters:
    654: +  obj - the object from which data is to be retrieved
    655: -  id - the identifier for the data

    657:    Output parameters
    658: +  data - the data to be retrieved
    659: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

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

    663:    Level: developer
    664: M*/
    665: #if defined(PETSC_USE_COMPLEX)
    666: #define PetscObjectComposedDataGetScalarstar(obj,id,data,flag)                                 \
    667:   ((((obj)->scalarstarcomposedstate && ((obj)->scalarstarcomposedstate[id] == (obj)->state)) ? \
    668:        (data = (obj)->scalarstarcomposeddata[id],flag = PETSC_TRUE) : (flag = PETSC_FALSE)),0)
    669: #else
    670: #define PetscObjectComposedDataGetScalarstar(obj,id,data,flag)                 \
    671:         PetscObjectComposedDataGetRealstar(obj,id,data,flag)
    672: #endif

    674: /* some vars for logging */

    679: #endif /* _PETSCHEAD_H */