Actual source code: petschead.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:       reference()       - Increases the reference count for a PETSc object; when
     25:                           a reference count reaches zero it is destroyed.
     26:       destroy()         - Is the routine for destroying the entire PETSc object;
     27:                           for example,MatDestroy() is the general matrix
     28:                           destruction routine.
     29:       compose()         - Associates a PETSc object with another PETSc object.
     30:       query()           - Returns a different PETSc object that has been associated
     31:                           with the first object.
     32:       composefunction() - Attaches an additional registered function.
     33:       queryfunction()   - Requests a registered function that has been registered.
     34:       composelanguage() - associates the object's representation in a different language
     35:       querylanguage()   - obtain the object's representation in a different language
     36: */

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

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

     84:   /*  ... */

     86: #define  PETSCFREEDHEADER -1

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

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

     94: /*
     95:     PetscHeaderCreate - Creates a PETSc object

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

    107:     Output Parameter:
    108: .   h - the newly created object
    109: */
    110: #define PetscHeaderCreate(h,tp,pops,cook,t,class_name,com,des,vie)                      \
    111:   { PetscErrorCode _ierr;                                                                          \
    112:     _PetscNew(struct tp,&(h));CHKERRQ(_ierr);                                      \
    113:     _PetscMemzero(h,sizeof(struct tp));CHKERRQ(_ierr);                           \
    114:     _PetscNew(PetscOps,&((h)->bops));CHKERRQ(_ierr);                               \
    115:     _PetscMemzero((h)->bops,sizeof(PetscOps));CHKERRQ(_ierr);                    \
    116:     _PetscNew(pops,&((h)->ops));CHKERRQ(_ierr);                                    \
    117:     _PetscMemzero((h)->ops,sizeof(pops));CHKERRQ(_ierr);                         \
    118:     _PetscHeaderCreate_Private((PetscObject)h,cook,t,class_name,com,             \
    119:                                  (PetscObjectFunction)des,                             \
    120:                                  (PetscObjectViewerFunction)vie);CHKERRQ(_ierr);       \
    121:   }

    123: #define PetscHeaderDestroy(h)                                             \
    124:   { PetscErrorCode _ierr;                                                            \
    125:     _PetscHeaderDestroy_Private((PetscObject)(h));CHKERRQ(_ierr);\
    126:   }

    128: /* ---------------------------------------------------------------------------------------*/

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

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

    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:   } else if (((PetscObject)(h))->cookie == PETSCFREEDHEADER) {                           \
    154:       SETERRQ1(PETSC_ERR_ARG_CORRUPT,"Object already free: Parameter # %d",arg);         \
    155:   } else if (((PetscObject)(h))->cookie < PETSC_COOKIE ||                                \
    156:       ((PetscObject)(h))->cookie > PETSC_LARGEST_COOKIE) {                               \
    157:       SETERRQ1(PETSC_ERR_ARG_CORRUPT,"Invalid type of object: Parameter # %d",arg);      \
    158:   }}

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

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

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

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

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

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

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

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

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

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

    235: #endif

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

    262: /*
    263:    All PETSc objects begin with the fields defined in PETSCHEADER.
    264:    The PetscObject is a way of examining these fields regardless of
    265:    the specific object. In C++ this could be a base abstract class
    266:    from which all objects are derived.
    267: */
    268: struct _p_PetscObject {
    269:   PETSCHEADER(int)
    270: };

    272: EXTERN PetscErrorCode PetscObjectPublishBaseBegin(PetscObject);
    273: EXTERN PetscErrorCode PetscObjectPublishBaseEnd(PetscObject);

    275: EXTERN PetscErrorCode PetscObjectIncreaseState(PetscObject);
    276: EXTERN PetscErrorCode PetscObjectGetState(PetscObject,PetscInt*);
    277: EXTERN PetscErrorCode PetscRegisterComposedData(PetscInt*);
    278: EXTERN PetscErrorCode PetscObjectIncreaseIntComposedData(PetscObject);
    279: EXTERN PetscErrorCode PetscObjectIncreaseIntstarComposedData(PetscObject);
    280: EXTERN PetscErrorCode PetscObjectIncreaseRealComposedData(PetscObject);
    281: EXTERN PetscErrorCode PetscObjectIncreaseRealstarComposedData(PetscObject);
    282: EXTERN PetscErrorCode PetscObjectIncreaseScalarComposedData(PetscObject);
    283: EXTERN PetscErrorCode PetscObjectIncreaseScalarstarComposedData(PetscObject);
    284: EXTERN PetscInt globalcurrentstate,globalmaxstate;
    285: /*MC
    286:    PetscObjectSetIntComposedData - attach integer data to a PetscObject

    288:    Synopsis:
    289:    PetscErrorCode PetscObjectSetIntComposedData(PetscObject obj,int id,int data)

    291:    Not collective

    293:    Input parameters:
    294: +  obj - the object to which data is to be attached
    295: .  id - the identifier for the data
    296: -  data - the data to  be attached

    298:    Notes:

    300:    This routine does not return an error code; any errors are handled
    301:    internally.

    303:    Level: developer
    304: M*/
    305: #define PetscObjectSetIntComposedData(obj,id,data)                  \
    306: 0; {PetscErrorCode ierr_;                                                       \
    307:   if ((obj)->int_idmax < globalmaxstate) {                            \
    308:     ierr_ = PetscObjectIncreaseIntComposedData(obj); CHKERRQ(ierr_);  \
    309:   }                                                                   \
    310:   (obj)->intcomposeddata[id] = data;                                  \
    311:   (obj)->intcomposedstate[id] = (obj)->state;                         \
    312: }
    313: /*MC
    314:    PetscObjectGetIntComposedData - retrieve integer data attached to an object

    316:    Synopsis:
    317:    PetscErrorCode PetscObjectGetIntComposedData(PetscObject obj,int id,int *data,PetscTruth *flag)

    319:    Not collective

    321:    Input parameters:
    322: +  obj - the object from which data is to be retrieved
    323: -  id - the identifier for the data

    325:    Output parameters
    326: +  data - the data to be retrieved
    327: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

    329:    Notes:

    331:    This routine does not return an error code; any errors are handled
    332:    internally.

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

    336:    Level: developer
    337: M*/
    338: #define PetscObjectGetIntComposedData(obj,id,data,flag)              \
    339: 0; {                                                                 \
    340:   if ((obj)->intcomposedstate) {                                     \
    341:     if ((obj)->intcomposedstate[id] == (obj)->state) {               \
    342:       data = (obj)->intcomposeddata[id];                             \
    343:       flag = PETSC_TRUE;                                             \
    344:     } else {                                                         \
    345:       flag = PETSC_FALSE;                                            \
    346:     }                                                                \
    347:   } else flag = PETSC_FALSE;                                         \
    348: }

    350: /*MC
    351:    PetscObjectSetIntstarComposedData - attach integer array data to a PetscObject

    353:    Synopsis:
    354:    PetscErrorCode PetscObjectSetIntstarComposedData(PetscObject obj,int id,int *data)

    356:    Not collective

    358:    Input parameters:
    359: +  obj - the object to which data is to be attached
    360: .  id - the identifier for the data
    361: -  data - the data to  be attached

    363:    Notes:

    365:    This routine does not return an error code; any errors are handled
    366:    internally.

    368:    Level: developer
    369: M*/
    370: #define PetscObjectSetIntstarComposedData(obj,id,data)                    \
    371: 0; {PetscErrorCode ierr_;                                                            \
    372:   if ((obj)->intstar_idmax < globalmaxstate) {                            \
    373:     ierr_ = PetscObjectIncreaseIntstarComposedData(obj); CHKERRQ(ierr_);  \
    374:   }                                                                       \
    375:   (obj)->intstarcomposeddata[id] = data;                                  \
    376:   (obj)->intstarcomposedstate[id] = (obj)->state;                         \
    377: }
    378: /*MC
    379:    PetscObjectGetIntstarComposedData - retrieve integer array data
    380:    attached to an object

    382:    Synopsis:
    383:    PetscErrorCode PetscObjectGetIntstarComposedData(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:    Notes:

    397:    This routine does not return an error code; any errors are handled
    398:    internally.

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

    402:    Level: developer
    403: M*/
    404: #define PetscObjectGetIntstarComposedData(obj,id,data,flag)              \
    405: 0; {                                                                     \
    406:   if ((obj)->intstarcomposedstate) {                                     \
    407:     if ((obj)->intstarcomposedstate[id] == (obj)->state) {               \
    408:       data = (obj)->intstarcomposeddata[id];                             \
    409:       flag = PETSC_TRUE;                                                 \
    410:     } else {                                                             \
    411:       flag = PETSC_FALSE;                                                \
    412:     }                                                                    \
    413:   } else flag = PETSC_FALSE;                                             \
    414: }

    416: /*MC
    417:    PetscObjectSetRealComposedData - attach real data to a PetscObject

    419:    Synopsis:
    420:    PetscErrorCode PetscObjectSetRealComposedData(PetscObject obj,int id,PetscReal data)

    422:    Not collective

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

    429:    Notes:

    431:    This routine does not return an error code; any errors are handled
    432:    internally.

    434:    Level: developer
    435: M*/
    436: #define PetscObjectSetRealComposedData(obj,id,data)                  \
    437: 0; {PetscErrorCode ierr_;                                                       \
    438:   if ((obj)->real_idmax < globalmaxstate) {                          \
    439:     ierr_ = PetscObjectIncreaseRealComposedData(obj); CHKERRQ(ierr_); \
    440:   }                                                                  \
    441:   (obj)->realcomposeddata[id] = data;                                \
    442:   (obj)->realcomposedstate[id] = (obj)->state;                       \
    443: }
    444: /*MC
    445:    PetscObjectGetRealComposedData - retrieve real data attached to an object

    447:    Synopsis:
    448:    PetscErrorCode PetscObjectGetRealComposedData(PetscObject obj,int id,PetscReal *data,PetscTruth *flag)

    450:    Not collective

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

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

    460:    Notes:

    462:    This routine does not return an error code; any errors are handled
    463:    internally.

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

    467:    Level: developer
    468: M*/
    469: #define PetscObjectGetRealComposedData(obj,id,data,flag)             \
    470: 0; {                                                                 \
    471:   if ((obj)->realcomposedstate) {                                    \
    472:     if ((obj)->realcomposedstate[id] == (obj)->state) {              \
    473:       data = (obj)->realcomposeddata[id];                            \
    474:       flag = PETSC_TRUE;                                             \
    475:     } else {                                                         \
    476:       flag = PETSC_FALSE;                                            \
    477:     }                                                                \
    478:   } else {                                                           \
    479:     flag = PETSC_FALSE;                                              \
    480:   }                                                                  \
    481: }

    483: /*MC
    484:    PetscObjectSetRealstarComposedData - attach real array data to a PetscObject

    486:    Synopsis:
    487:    PetscErrorCode PetscObjectSetRealstarComposedData(PetscObject obj,int id,PetscReal *data)

    489:    Not collective

    491:    Input parameters:
    492: +  obj - the object to which data is to be attached
    493: .  id - the identifier for the data
    494: -  data - the data to  be attached

    496:    Notes:

    498:    This routine does not return an error code; any errors are handled
    499:    internally.

    501:    Level: developer
    502: M*/
    503: #define PetscObjectSetRealstarComposedData(obj,id,data)                  \
    504: 0; {PetscErrorCode ierr_;                                                       \
    505:   if ((obj)->realstar_idmax < globalmaxstate) {                          \
    506:     ierr_ = PetscObjectIncreaseRealstarComposedData(obj); CHKERRQ(ierr_); \
    507:   }                                                                  \
    508:   (obj)->realstarcomposeddata[id] = data;                                \
    509:   (obj)->realstarcomposedstate[id] = (obj)->state;                       \
    510: }
    511: /*MC
    512:    PetscObjectGetRealstarComposedData - retrieve real array data
    513:    attached to an object

    515:    Synopsis:
    516:    PetscErrorCode PetscObjectGetRealstarComposedData(PetscObject obj,int id,PetscReal **data,PetscTruth *flag)

    518:    Not collective

    520:    Input parameters:
    521: +  obj - the object from which data is to be retrieved
    522: -  id - the identifier for the data

    524:    Output parameters
    525: +  data - the data to be retrieved
    526: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

    528:    Notes:

    530:    This routine does not return an error code; any errors are handled
    531:    internally.

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

    535:    Level: developer
    536: M*/
    537: #define PetscObjectGetRealstarComposedData(obj,id,data,flag)        \
    538: 0; {                                                                \
    539:   if ((obj)->realstarcomposedstate) {                               \
    540:     if ((obj)->realstarcomposedstate[id] == (obj)->state) {         \
    541:       data = (obj)->realstarcomposeddata[id];                       \
    542:       flag = PETSC_TRUE;                                            \
    543:     } else {                                                        \
    544:       flag = PETSC_FALSE;                                           \
    545:     }                                                               \
    546:   } else {                                                          \
    547:     flag = PETSC_FALSE;                                             \
    548:   }                                                                 \
    549: }

    551: /*MC
    552:    PetscObjectSetScalarComposedData - attach scalar data to a PetscObject

    554:    Synopsis:
    555:    PetscErrorCode PetscObjectSetScalarComposedData(PetscObject obj,int id,PetscScalar data)

    557:    Not collective

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

    564:    Notes:

    566:    This routine does not return an error code; any errors are handled
    567:    internally.

    569:    Level: developer
    570: M*/
    571: #if defined(PETSC_USE_COMPLEX)
    572: #define PetscObjectSetScalarComposedData(obj,id,data)                 \
    573: 0; {PetscErrorCode ierr_;                                                        \
    574:   if ((obj)->scalar_idmax < globalmaxstate) {                         \
    575:     ierr_ = PetscObjectIncreaseScalarComposedData(obj); CHKERRQ(ierr_);\
    576:   }                                                                   \
    577:   (obj)->scalarcomposeddata[id] = data;                               \
    578:   (obj)->scalarcomposedstate[id] = (obj)->state;                      \
    579: }
    580: #else
    581: #define PetscObjectSetScalarComposedData(obj,id,data) \
    582:         PetscObjectSetRealComposedData(obj,id,data)
    583: #endif
    584: /*MC
    585:    PetscObjectGetScalarComposedData - retrieve scalar data attached to an object

    587:    Synopsis:
    588:    PetscErrorCode PetscObjectGetScalarComposedData(PetscObject obj,int id,PetscScalar *data,PetscTruth *flag)

    590:    Not collective

    592:    Input parameters:
    593: +  obj - the object from which data is to be retrieved
    594: -  id - the identifier for the data

    596:    Output parameters
    597: +  data - the data to be retrieved
    598: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

    600:    Notes:

    602:    This routine does not return an error code; any errors are handled
    603:    internally.

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

    607:    Level: developer
    608: M*/
    609: #if defined(PETSC_USE_COMPLEX)
    610: #define PetscObjectGetScalarComposedData(obj,id,data,flag)           \
    611: 0; {                                                                 \
    612:   if ((obj)->scalarcomposedstate) {                                     \
    613:     if ((obj)->scalarcomposedstate[id] == (obj)->state) {            \
    614:       data = (obj)->scalarcomposeddata[id];                          \
    615:       flag = PETSC_TRUE;                                             \
    616:     } else {                                                         \
    617:       flag = PETSC_FALSE;                                            \
    618:     }                                                                \
    619:   } else flag = PETSC_FALSE;                                         \
    620: }
    621: #else
    622: #define PetscObjectGetScalarComposedData(obj,id,data,flag)             \
    623:         PetscObjectGetRealComposedData(obj,id,data,flag)
    624: #endif

    626: /*MC
    627:    PetscObjectSetScalarstarComposedData - attach scalar array data to a PetscObject

    629:    Synopsis:
    630:    PetscErrorCode PetscObjectSetScalarstarComposedData(PetscObject obj,int id,PetscScalar *data)

    632:    Not collective

    634:    Input parameters:
    635: +  obj - the object to which data is to be attached
    636: .  id - the identifier for the data
    637: -  data - the data to  be attached

    639:    Notes:

    641:    This routine does not return an error code; any errors are handled
    642:    internally.

    644:    Level: developer
    645: M*/
    646: #if defined(PETSC_USE_COMPLEX)
    647: #define PetscObjectSetScalarstarComposedData(obj,id,data)                   \
    648: 0; {PetscErrorCode ierr_;                                                              \
    649:   if ((obj)->scalarstar_idmax < globalmaxstate) {                           \
    650:     ierr_ = PetscObjectIncreaseScalarstarComposedData(obj); CHKERRQ(ierr_); \
    651:   }                                                                         \
    652:   (obj)->scalarstarcomposeddata[id] = data;                                 \
    653:   (obj)->scalarstarcomposedstate[id] = (obj)->state;                        \
    654: }
    655: #else
    656: #define PetscObjectSetScalarstarComposedData(obj,id,data) \
    657:         PetscObjectSetRealstarComposedData(obj,id,data)
    658: #endif
    659: /*MC
    660:    PetscObjectGetScalarstarComposedData - retrieve scalar array data
    661:    attached to an object

    663:    Synopsis:
    664:    PetscErrorCode PetscObjectGetScalarstarComposedData(PetscObject obj,int id,PetscScalar **data,PetscTruth *flag)

    666:    Not collective

    668:    Input parameters:
    669: +  obj - the object from which data is to be retrieved
    670: -  id - the identifier for the data

    672:    Output parameters
    673: +  data - the data to be retrieved
    674: -  flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise

    676:    Notes:

    678:    This routine does not return an error code; any errors are handled
    679:    internally.

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

    683:    Level: developer
    684: M*/
    685: #if defined(PETSC_USE_COMPLEX)
    686: #define PetscObjectGetScalarstarComposedData(obj,id,data,flag)           \
    687: 0; {                                                                     \
    688:   if ((obj)->scalarstarcomposedstate) {                                  \
    689:     if ((obj)->scalarstarcomposedstate[id] == (obj)->state) {            \
    690:       data = (obj)->scalarstarcomposeddata[id];                          \
    691:       flag = PETSC_TRUE;                                                 \
    692:     } else {                                                             \
    693:       flag = PETSC_FALSE;                                                \
    694:     }                                                                    \
    695:   } else flag = PETSC_FALSE;                                             \
    696: }
    697: #else
    698: #define PetscObjectGetScalarstarComposedData(obj,id,data,flag)                 \
    699:         PetscObjectGetRealstarComposedData(obj,id,data,flag)
    700: #endif

    703: #endif /* _PETSCHEAD_H */