You are on page 1of 16

/*

Defines the basic header of all PETSc objects.


*/
#if !defined(_PETSCHEAD_H)
#define _PETSCHEAD_H
#include <petscsys.h>
/*
All major PETSc data structures have a common core; this is defined
below by PETSCHEADER.
PetscHeaderCreate() should be used whenever creating a PETSc structure.
*/
/*
PetscOps: structure of core operations that all PETSc objects support.
getcomm()
view()

- Gets the object's communicator.


- Is the routine for viewing the entire PETSc object; fo

r
example, MatView() is the general matrix viewing routi
ne.
This is used by PetscObjectView((PetscObject)obj) to a
llow
destroy()

viewing any PETSc object.


- Is the routine for destroying the entire PETSc object;
for example,MatDestroy() is the general matrix
destruction routine.
This is used by PetscObjectDestroy((PetscObject*)&obj)

to allow
compose()
th a name
query()
ted

destroying any PETSc object.


- Associates a PETSc object with another PETSc object wi
- Returns a different PETSc object that has been associa

with the first object using a name.


composefunction() - Attaches an a function to a PETSc object with a name.
queryfunction() - Requests a registered function that has been attached
to a PETSc object.
*/
typedef struct {
PetscErrorCode
PetscErrorCode
PetscErrorCode
PetscErrorCode
PetscErrorCode
PetscErrorCode
PetscErrorCode
} PetscOps;

(*getcomm)(PetscObject,MPI_Comm *);
(*view)(PetscObject,PetscViewer);
(*destroy)(PetscObject*);
(*compose)(PetscObject,const char[],PetscObject);
(*query)(PetscObject,const char[],PetscObject *);
(*composefunction)(PetscObject,const char[],void (*)(void));
(*queryfunction)(PetscObject,const char[],void (**)(void));

typedef enum {PETSC_FORTRAN_CALLBACK_CLASS,PETSC_FORTRAN_CALLBACK_SUBTYPE,PETSC_


FORTRAN_CALLBACK_MAXTYPE} PetscFortranCallbackType;
typedef int PetscFortranCallbackId;
#define PETSC_SMALLEST_FORTRAN_CALLBACK ((PetscFortranCallbackId)1000)
PETSC_EXTERN PetscErrorCode PetscFortranCallbackRegister(PetscClassId,const char
*,PetscFortranCallbackId*);
PETSC_EXTERN PetscErrorCode PetscFortranCallbackGetSizes(PetscClassId,PetscInt*,

PetscInt*);
typedef struct {
void (*func)(void);
void *ctx;
} PetscFortranCallback;
/*
All PETSc objects begin with the fields defined in PETSCHEADER.
The PetscObject is a way of examining these fields regardless of
the specific object. In C++ this could be a base abstract class
from which all objects are derived.
*/
#define PETSC_MAX_OPTIONS_HANDLER 5
typedef struct _p_PetscObject {
PetscClassId
classid;
PetscOps
*bops;
MPI_Comm
comm;
PetscInt
type;
PetscLogDouble
flops,time,mem,memchildren;
PetscObjectId
id;
PetscInt
refct;
PetscMPIInt
tag;
PetscFunctionList
qlist;
PetscObjectList
olist;
char
*class_name;
/* for example, "Vec" */
char
*description;
char
*mansec;
char
*type_name;
/* this is the subclass, for example VEC
SEQ which equals "seq" */
PetscObject
parent;
PetscObjectId
parentid;
char*
name;
char
*prefix;
PetscInt
tablevel;
void
*cpp;
PetscObjectState
state;
PetscInt
int_idmax,
intstar_idmax;
PetscObjectState
*intcomposedstate,*intstarcomposedstate;
PetscInt
*intcomposeddata, **intstarcomposeddata;
PetscInt
real_idmax,
realstar_idmax;
PetscObjectState
*realcomposedstate,*realstarcomposedstate;
PetscReal
*realcomposeddata, **realstarcomposeddata;
PetscInt
scalar_idmax,
scalarstar_idmax;
PetscObjectState
*scalarcomposedstate,*scalarstarcomposedstate;
PetscScalar
*scalarcomposeddata, **scalarstarcomposeddata;
void
(**fortran_func_pointers)(void);
/* used
by Fortran interface functions to stash user provided Fortran functions */
PetscInt
num_fortran_func_pointers;
/* numb
er of Fortran function pointers allocated */
PetscFortranCallback *fortrancallback[PETSC_FORTRAN_CALLBACK_MAXTYPE];
PetscInt
num_fortrancallback[PETSC_FORTRAN_CALLBACK_MAXTYPE];
void
*python_context;
PetscErrorCode
(*python_destroy)(void*);
PetscInt
PetscErrorCode
oid*);
PetscErrorCode
oid*);

noptionhandler;
(*optionhandler[PETSC_MAX_OPTIONS_HANDLER])(PetscObject,v
(*optiondestroy[PETSC_MAX_OPTIONS_HANDLER])(PetscObject,v

void
*optionctx[PETSC_MAX_OPTIONS_HANDLER];
PetscPrecision
precision;
PetscBool
optionsprinted;
#if defined(PETSC_HAVE_SAWS)
PetscBool
amsmem;
/* if PETSC_TRUE then this object is reg
istered with SAWs and visible to clients */
PetscBool
amspublishblock; /* if PETSC_TRUE and publishing objects
then will block at PetscObjectSAWsBlock() */
#endif
} _p_PetscObject;
#define PETSCHEADER(ObjectOps) \
_p_PetscObject hdr;
\
ObjectOps
*ops
#define PETSCFREEDHEADER -1
PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*PetscObjectFunction)(PetscObject*)
; /* force cast in next macro to NEVER use extern "C" style */
PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*PetscObjectViewerFunction)(PetscOb
ject,PetscViewer);
/*@C
PetscHeaderCreate - Creates a PETSc object of a particular class, indicated
by tp
Input Parameters:
tp - the data structure type of the object (for example _p_Vec)
pops - the data structure type of the objects operations (for example VecOps

+
.
)
.
.
.
.
-

classid - the classid associated with this object (for example VEC_CLASSID)
class_name - string name of class; should be static (for example "Vec")
com - the MPI Communicator
des - the destroy routine for this object (for example VecDestroy())
vie - the view routine for this object (for example VecView())
Output Parameter:
h - the newly created object

Level: developer
Developer Note: This currently is a CPP macro because it takes the types (for
example _p_Vec and VecOps) as arguments
.seealso: PetscHeaderDestroy(), PetscClassIdRegister()
@*/
#define PetscHeaderCreate(h,tp,pops,classid,class_name,descr,mansec,com,des,vie)
\
(PetscNew(&(h)) ||
\
PetscNew(&(((PetscObject)(h))->bops)) ||
\
PetscNew(&((h)->ops)) ||
\
PetscHeaderCreate_Private((PetscObject)h,classid,class_name,descr,mansec,com,
(PetscObjectFunction)des,(PetscObjectViewerFunction)vie) || \
PetscLogObjectCreate(h) ||
\
PetscLogObjectMemory((PetscObject)h, sizeof(struct tp) + sizeof(PetscOps) + s
izeof(pops)))
PETSC_EXTERN PetscErrorCode PetscComposedQuantitiesDestroy(PetscObject obj);

PETSC_EXTERN PetscErrorCode PetscHeaderCreate_Private(PetscObject,PetscClassId,c


onst char[],const char[],const char[],MPI_Comm,PetscErrorCode (*)(PetscObject*),
PetscErrorCode (*)(PetscObject,PetscViewer));
/*@C
PetscHeaderDestroy - Final step in destroying a PetscObject
.

Input Parameters:
h - the header created with PetscHeaderCreate()
Level: developer

Developer Note: This currently is a CPP macro because it accesses (*h)->ops w


hich is a field in the derived class but not the PetscObject base class
.seealso: PetscHeaderCreate()
@*/
#define PetscHeaderDestroy(h)
(PetscHeaderDestroy_Private((PetscObject)(*h)) ||
PetscFree((*h)->ops) ||
PetscFree(*h))

\
\
\

PETSC_EXTERN PetscErrorCode PetscHeaderDestroy_Private(PetscObject);


PETSC_EXTERN PetscErrorCode PetscObjectCopyFortranFunctionPointers(PetscObject,P
etscObject);
PETSC_EXTERN PetscErrorCode PetscObjectSetFortranCallback(PetscObject,PetscFortr
anCallbackType,PetscFortranCallbackId*,void(*)(void),void *ctx);
PETSC_EXTERN PetscErrorCode PetscObjectGetFortranCallback(PetscObject,PetscFortr
anCallbackType,PetscFortranCallbackId,void(**)(void),void **ctx);
PETSC_INTERN PetscErrorCode PetscCitationsInitialize(void);
PETSC_INTERN PetscErrorCode PetscOptionsFindPair_Private(const char[],const char
[],char**,PetscBool*);
PETSC_EXTERN PetscBool PetscCheckPointer(const void*,PetscDataType);
/*
Macros to test if a PETSc object is valid and if pointers are valid
*/
#if !defined(PETSC_USE_DEBUG)
#define
#define
#define
#define
#define
#define
#define
#define

PetscValidHeaderSpecific(h,ck,arg) do {} while (0)


PetscValidHeader(h,arg) do {} while (0)
PetscValidPointer(h,arg) do {} while (0)
PetscValidCharPointer(h,arg) do {} while (0)
PetscValidIntPointer(h,arg) do {} while (0)
PetscValidScalarPointer(h,arg) do {} while (0)
PetscValidRealPointer(h,arg) do {} while (0)
PetscValidFunction(h,arg) do {} while (0)

#else
#define PetscValidHeaderSpecific(h,ck,arg)
\
do {
\
if (!h) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_NULL,"Null Object: Parameter
# %d",arg); \
if (!PetscCheckPointer(h,PETSC_OBJECT)) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_A
RG_CORRUPT,"Invalid Pointer to Object: Parameter # %d",arg); \
if (((PetscObject)(h))->classid != ck) {
\
if (((PetscObject)(h))->classid == PETSCFREEDHEADER) SETERRQ1(PETSC_COMM_S

ELF,PETSC_ERR_ARG_CORRUPT,"Object already free: Parameter # %d",arg); \


else SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Wrong type of object: P
arameter # %d",arg); \
}
\
} while (0)
#define PetscValidHeader(h,arg)
\
do {
\
if (!h) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_NULL,"Null Object: Parameter
# %d",arg); \
if (!PetscCheckPointer(h,PETSC_OBJECT)) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_A
RG_CORRUPT,"Invalid Pointer to Object: Parameter # %d",arg); \
if (((PetscObject)(h))->classid == PETSCFREEDHEADER) SETERRQ1(PETSC_COMM_SEL
F,PETSC_ERR_ARG_CORRUPT,"Object already free: Parameter # %d",arg); \
else if (((PetscObject)(h))->classid < PETSC_SMALLEST_CLASSID || ((PetscObje
ct)(h))->classid > PETSC_LARGEST_CLASSID) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG
_CORRUPT,"Invalid type of object: Parameter # %d",arg); \
} while (0)
#define PetscValidPointer(h,arg)
\
do {
\
if (!h) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_NULL,"Null Pointer: Parameter
# %d",arg); \
if (!PetscCheckPointer(h,PETSC_CHAR)) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG
_BADPTR,"Invalid Pointer: Parameter # %d",arg); \
} while (0)
#define PetscValidCharPointer(h,arg)
\
do {
\
if (!h) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_NULL,"Null Pointer: Parameter
# %d",arg);\
if (!PetscCheckPointer(h,PETSC_CHAR)) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG
_BADPTR,"Invalid Pointer to char: Parameter # %d",arg); \
} while (0)
#define PetscValidIntPointer(h,arg)
\
do {
\
if (!h) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_BADPTR,"Null Pointer: Paramet
er # %d",arg); \
if (!PetscCheckPointer(h,PETSC_INT)) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_
BADPTR,"Invalid Pointer to Int: Parameter # %d",arg); \
} while (0)
#define PetscValidScalarPointer(h,arg)
\
do {
\
if (!h) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_NULL,"Null Pointer: Parameter
# %d",arg); \
if (!PetscCheckPointer(h,PETSC_SCALAR)) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_A
RG_BADPTR,"Invalid Pointer to PetscScalar: Parameter # %d",arg); \
} while (0)
#define PetscValidRealPointer(h,arg)
\
do {
\
if (!h) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_NULL,"Null Pointer: Parameter
# %d",arg); \
if (!PetscCheckPointer(h,PETSC_REAL)) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG
_BADPTR,"Invalid Pointer to PetscReal: Parameter # %d",arg); \
} while (0)
#define PetscValidFunction(f,arg)

do {
\
if (!f) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_NULL,"Null Function Pointer:
Parameter # %d",arg); \
} while (0)
#endif
#if !defined(PETSC_USE_DEBUG)
#define
#define
#define
#define
#define
#define
#define
#define
#define

PetscCheckSameType(a,arga,b,argb) do {} while (0)


PetscValidType(a,arg) do {} while (0)
PetscCheckSameComm(a,arga,b,argb) do {} while (0)
PetscCheckSameTypeAndComm(a,arga,b,argb) do {} while (0)
PetscValidLogicalCollectiveScalar(a,b,c) do {} while (0)
PetscValidLogicalCollectiveReal(a,b,c) do {} while (0)
PetscValidLogicalCollectiveInt(a,b,c) do {} while (0)
PetscValidLogicalCollectiveBool(a,b,c) do {} while (0)
PetscValidLogicalCollectiveEnum(a,b,c) do {} while (0)

#else
/*
For example, in the dot product between two vectors,
both vectors must be either Seq or MPI, not one of each
*/
#define PetscCheckSameType(a,arga,b,argb) \
if (((PetscObject)a)->type != ((PetscObject)b)->type) SETERRQ2(PETSC_COMM_SELF
,PETSC_ERR_ARG_NOTSAMETYPE,"Objects not of same type: Argument # %d and %d",arga
,argb);
/*
Use this macro to check if the type is set
*/
#define PetscValidType(a,arg) \
if (!((PetscObject)a)->type_name) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG
STATE,"%s object's type is not set: Argument # %d",((PetscObject)a)->class_name,
arg);
/*
Sometimes object must live on same communicator to inter-operate
*/
#define PetscCheckSameComm(a,arga,b,argb)
\
do {
\
PetscErrorCode _6_ierr,__flag;
\
_6_ierr = MPI_Comm_compare(PetscObjectComm((PetscObject)a),PetscObjectComm((
PetscObject)b),&__flag);CHKERRQ(_6_ierr);
\
if (__flag != MPI_CONGRUENT && __flag != MPI_IDENT) SETERRQ3(PETSC_COMM_SELF
,PETSC_ERR_ARG_NOTSAMECOMM,"Different communicators in the two objects: Argument
# %d and %d flag %d",arga,argb,__flag); \
} while (0)
#define PetscCheckSameTypeAndComm(a,arga,b,argb)
do {
PetscCheckSameType(a,arga,b,argb);
PetscCheckSameComm(a,arga,b,argb);
} while (0)
#define PetscValidLogicalCollectiveScalar(a,b,c)
do {
PetscErrorCode _7_ierr;
PetscReal b1[2],b2[2];

\
\
\
\
\
\
\
\

b1[0] = -PetscRealPart(b); b1[1] = PetscRealPart(b);


\
_7_ierr = MPI_Allreduce(b1,b2,2,MPIU_REAL,MPIU_MAX,PetscObjectComm((PetscObj
ect)a));CHKERRQ(_7_ierr); \
if (-b2[0] != b2[1]) SETERRQ1(PetscObjectComm((PetscObject)a),PETSC_ERR_ARG_
WRONG,"Scalar value must be same on all processes, argument # %d",c); \
} while (0)
#define PetscValidLogicalCollectiveReal(a,b,c)
\
do {
\
PetscErrorCode _7_ierr;
\
PetscReal b1[2],b2[2];
\
b1[0] = -b; b1[1] = b;
\
_7_ierr = MPI_Allreduce(b1,b2,2,MPIU_REAL,MPIU_MAX,PetscObjectComm((PetscObj
ect)a));CHKERRQ(_7_ierr); \
if (-b2[0] != b2[1]) SETERRQ1(PetscObjectComm((PetscObject)a),PETSC_ERR_ARG_
WRONG,"Real value must be same on all processes, argument # %d",c); \
} while (0)
#define PetscValidLogicalCollectiveInt(a,b,c)
\
do {
\
PetscErrorCode _7_ierr;
\
PetscInt b1[2],b2[2];
\
b1[0] = -b; b1[1] = b;
\
_7_ierr = MPI_Allreduce(b1,b2,2,MPIU_INT,MPI_MAX,PetscObjectComm((PetscObjec
t)a));CHKERRQ(_7_ierr); \
if (-b2[0] != b2[1]) SETERRQ1(PetscObjectComm((PetscObject)a),PETSC_ERR_ARG_
WRONG,"Int value must be same on all processes, argument # %d",c); \
} while (0)
#define PetscValidLogicalCollectiveBool(a,b,c)
\
do {
\
PetscErrorCode _7_ierr;
\
PetscMPIInt b1[2],b2[2];
\
b1[0] = -(PetscMPIInt)b; b1[1] = (PetscMPIInt)b;
\
_7_ierr = MPI_Allreduce(b1,b2,2,MPI_INT,MPI_MAX,PetscObjectComm((PetscObject
)a));CHKERRQ(_7_ierr); \
if (-b2[0] != b2[1]) SETERRQ1(PetscObjectComm((PetscObject)a),PETSC_ERR_ARG_
WRONG,"Bool value must be same on all processes, argument # %d",c); \
} while (0)
#define PetscValidLogicalCollectiveEnum(a,b,c)
\
do {
\
PetscErrorCode _7_ierr;
\
PetscMPIInt b1[2],b2[2];
\
b1[0] = -(PetscMPIInt)b; b1[1] = (PetscMPIInt)b;
\
_7_ierr = MPI_Allreduce(b1,b2,2,MPI_INT,MPI_MAX,PetscObjectComm((PetscObject
)a));CHKERRQ(_7_ierr); \
if (-b2[0] != b2[1]) SETERRQ1(PetscObjectComm((PetscObject)a),PETSC_ERR_ARG_
WRONG,"Enum value must be same on all processes, argument # %d",c); \
} while (0)
#endif
/*
PetscTryMethod - Queries an object for a method, if it exists then calls it.
These are intended to be used only inside PETSc functions.
Level: developer
.seealso: PetscUseMethod()

*/
#define PetscTryMethod(obj,A,B,C) \
0;{ PetscErrorCode (*f)B, __ierr; \
__ierr = PetscObjectQueryFunction((PetscObject)obj,A,&f);CHKERRQ(__ierr); \
if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\
}
/*
PetscUseMethod - Queries an object for a method, if it exists then calls it,
otherwise generates an error.
These are intended to be used only inside PETSc functions.
Level: developer
.seealso: PetscTryMethod()
*/
#define PetscUseMethod(obj,A,B,C) \
0;{ PetscErrorCode (*f)B, __ierr; \
__ierr = PetscObjectQueryFunction((PetscObject)obj,A,&f);CHKERRQ(__ierr); \
if (f) {__ierr = (*f)C;CHKERRQ(__ierr);}\
else SETERRQ1(PetscObjectComm((PetscObject)obj),PETSC_ERR_SUP,"Cannot locate
function %s in object",A); \
}
/*MC
PetscObjectStateIncrease - Increases the state of any PetscObject
Synopsis:
#include "petsc-private/petscimpl.h"
PetscErrorCode PetscObjectStateIncrease(PetscObject obj)
Logically Collective
Input Parameter:
. obj - any PETSc object, for example a Vec, Mat or KSP. This must be
cast with a (PetscObject), for example,
PetscObjectStateIncrease((PetscObject)mat);
Notes: object state is an integer which gets increased every time
the object is changed internally. By saving and later querying the object sta
te
one can determine whether information about the object is still current.
Currently, state is maintained for Vec and Mat objects.
This routine is mostly for internal use by PETSc; a developer need only
call it after explicit access to an object's internals. Routines such
as VecSet() or MatScale() already call this routine. It is also called, as a
precaution, in VecRestoreArray(), MatRestoreRow(), MatDenseRestoreArray().
This routine is logically collective because state equality comparison needs
to be possible without communication.
Level: developer
seealso: PetscObjectStateGet()
Concepts: state
M*/
#define PetscObjectStateIncrease(obj) ((obj)->state++,0)

PETSC_EXTERN PetscErrorCode PetscObjectStateGet(PetscObject,PetscObjectState*);


PETSC_EXTERN PetscErrorCode PetscObjectStateSet(PetscObject,PetscObjectState);
PETSC_EXTERN PetscErrorCode PetscObjectComposedDataRegister(PetscInt*);
PETSC_EXTERN PetscErrorCode PetscObjectComposedDataIncreaseInt(PetscObject);
PETSC_EXTERN PetscErrorCode PetscObjectComposedDataIncreaseIntstar(PetscObject);
PETSC_EXTERN PetscErrorCode PetscObjectComposedDataIncreaseReal(PetscObject);
PETSC_EXTERN PetscErrorCode PetscObjectComposedDataIncreaseRealstar(PetscObject)
;
PETSC_EXTERN PetscErrorCode PetscObjectComposedDataIncreaseScalar(PetscObject);
PETSC_EXTERN PetscErrorCode PetscObjectComposedDataIncreaseScalarstar(PetscObjec
t);
PETSC_EXTERN PetscInt
PetscObjectComposedDataMax;
/*MC
PetscObjectComposedDataSetInt - attach integer data to a PetscObject
Synopsis:
#include "petsc-private/petscimpl.h"
PetscErrorCode PetscObjectComposedDataSetInt(PetscObject obj,int id,int data)
Not collective
Input parameters:
+ obj - the object to which data is to be attached
. id - the identifier for the data
- data - the data to be attached
Notes
The data identifier can best be created through a call to PetscObjectCompose
dDataRegister()
Level: developer
M*/
#define PetscObjectComposedDataSetInt(obj,id,data)
\
((((obj)->int_idmax < PetscObjectComposedDataMax) && PetscObjectComposedDataIn
creaseInt(obj)) || \
((obj)->intcomposeddata[id] = data,(obj)->intcomposedstate[id] = (obj)->state
, 0))
/*MC
PetscObjectComposedDataGetInt - retrieve integer data attached to an object
Synopsis:
#include "petsc-private/petscimpl.h"
PetscErrorCode PetscObjectComposedDataGetInt(PetscObject obj,int id,int data,
PetscBool flag)
Not collective
Input parameters:
+ obj - the object from which data is to be retrieved
- id - the identifier for the data
Output parameters
+ data - the data to be retrieved
- flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise
The 'data' and 'flag' variables are inlined, so they are not pointers.

Level: developer
M*/
#define PetscObjectComposedDataGetInt(obj,id,data,flag)
\
((((obj)->intcomposedstate && ((obj)->intcomposedstate[id] == (obj)->state)) ?
\
(data = (obj)->intcomposeddata[id],flag = PETSC_TRUE) : (flag = PETSC_FALSE))
,0)
/*MC
PetscObjectComposedDataSetIntstar - attach integer array data to a PetscObjec
t
Synopsis:
#include "petsc-private/petscimpl.h"
PetscErrorCode PetscObjectComposedDataSetIntstar(PetscObject obj,int id,int *
data)
Not collective
Input parameters:
+ obj - the object to which data is to be attached
. id - the identifier for the data
- data - the data to be attached
Notes
The data identifier can best be determined through a call to
PetscObjectComposedDataRegister()
Level: developer
M*/
#define PetscObjectComposedDataSetIntstar(obj,id,data)
\
((((obj)->intstar_idmax < PetscObjectComposedDataMax) && PetscObjectComposedDa
taIncreaseIntstar(obj)) || \
((obj)->intstarcomposeddata[id] = data,(obj)->intstarcomposedstate[id] = (obj
)->state, 0))
/*MC
PetscObjectComposedDataGetIntstar - retrieve integer array data
attached to an object
Synopsis:
#include "petsc-private/petscimpl.h"
PetscErrorCode PetscObjectComposedDataGetIntstar(PetscObject obj,int id,int *
data,PetscBool flag)
Not collective
Input parameters:
+ obj - the object from which data is to be retrieved
- id - the identifier for the data
Output parameters
+ data - the data to be retrieved
- flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise
The 'data' and 'flag' variables are inlined, so they are not pointers.
Level: developer

M*/
#define PetscObjectComposedDataGetIntstar(obj,id,data,flag)
\
((((obj)->intstarcomposedstate && ((obj)->intstarcomposedstate[id] == (obj)->s
tate)) ? \
(data = (obj)->intstarcomposeddata[id],flag = PETSC_TRUE) : (flag = PETSC_FAL
SE)),0)
/*MC
PetscObjectComposedDataSetReal - attach real data to a PetscObject
Synopsis:
#include "petsc-private/petscimpl.h"
PetscErrorCode PetscObjectComposedDataSetReal(PetscObject obj,int id,PetscRea
l data)
Not collective
Input parameters:
+ obj - the object to which data is to be attached
. id - the identifier for the data
- data - the data to be attached
Notes
The data identifier can best be determined through a call to
PetscObjectComposedDataRegister()
Level: developer
M*/
#define PetscObjectComposedDataSetReal(obj,id,data)
\
((((obj)->real_idmax < PetscObjectComposedDataMax) && PetscObjectComposedDataI
ncreaseReal(obj)) || \
((obj)->realcomposeddata[id] = data,(obj)->realcomposedstate[id] = (obj)->sta
te, 0))
/*MC
PetscObjectComposedDataGetReal - retrieve real data attached to an object
Synopsis:
#include "petsc-private/petscimpl.h"
PetscErrorCode PetscObjectComposedDataGetReal(PetscObject obj,int id,PetscRea
l data,PetscBool flag)
Not collective
Input parameters:
+ obj - the object from which data is to be retrieved
- id - the identifier for the data
Output parameters
+ data - the data to be retrieved
- flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise
The 'data' and 'flag' variables are inlined, so they are not pointers.
Level: developer
M*/
#define PetscObjectComposedDataGetReal(obj,id,data,flag)
\

((((obj)->realcomposedstate && ((obj)->realcomposedstate[id] == (obj)->state))


? \
(data = (obj)->realcomposeddata[id],flag = PETSC_TRUE) : (flag = PETSC_FALSE)
),0)
/*MC
PetscObjectComposedDataSetRealstar - attach real array data to a PetscObject
Synopsis:
#include "petsc-private/petscimpl.h"
PetscErrorCode PetscObjectComposedDataSetRealstar(PetscObject obj,int id,Pets
cReal *data)
Not collective
Input parameters:
+ obj - the object to which data is to be attached
. id - the identifier for the data
- data - the data to be attached
Notes
The data identifier can best be determined through a call to
PetscObjectComposedDataRegister()
Level: developer
M*/
#define PetscObjectComposedDataSetRealstar(obj,id,data)
\
((((obj)->realstar_idmax < PetscObjectComposedDataMax) && PetscObjectComposedD
ataIncreaseRealstar(obj)) || \
((obj)->realstarcomposeddata[id] = data, (obj)->realstarcomposedstate[id] = (
obj)->state, 0))
/*MC
PetscObjectComposedDataGetRealstar - retrieve real array data
attached to an object
Synopsis:
#include "petsc-private/petscimpl.h"
PetscErrorCode PetscObjectComposedDataGetRealstar(PetscObject obj,int id,Pets
cReal *data,PetscBool flag)
Not collective
Input parameters:
+ obj - the object from which data is to be retrieved
- id - the identifier for the data
Output parameters
+ data - the data to be retrieved
- flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise
The 'data' and 'flag' variables are inlined, so they are not pointers.
Level: developer
M*/
#define PetscObjectComposedDataGetRealstar(obj,id,data,flag)
\
((((obj)->realstarcomposedstate && ((obj)->realstarcomposedstate[id] == (obj)>state)) ? \

(data = (obj)->realstarcomposeddata[id],flag = PETSC_TRUE) : (flag = PETSC_FA


LSE)),0)
/*MC
PetscObjectComposedDataSetScalar - attach scalar data to a PetscObject
Synopsis:
#include "petsc-private/petscimpl.h"
PetscErrorCode PetscObjectComposedDataSetScalar(PetscObject obj,int id,PetscS
calar data)
Not collective
Input parameters:
+ obj - the object to which data is to be attached
. id - the identifier for the data
- data - the data to be attached
Notes
The data identifier can best be determined through a call to
PetscObjectComposedDataRegister()
Level: developer
M*/
#if defined(PETSC_USE_COMPLEX)
#define PetscObjectComposedDataSetScalar(obj,id,data)
\
((((obj)->scalar_idmax < PetscObjectComposedDataMax) && PetscObjectComposedDat
aIncreaseScalar(obj)) || \
((obj)->scalarcomposeddata[id] = data,(obj)->scalarcomposedstate[id] = (obj)>state, 0))
#else
#define PetscObjectComposedDataSetScalar(obj,id,data) \
PetscObjectComposedDataSetReal(obj,id,data)
#endif
/*MC
PetscObjectComposedDataGetScalar - retrieve scalar data attached to an object
Synopsis:
#include "petsc-private/petscimpl.h"
PetscErrorCode PetscObjectComposedDataGetScalar(PetscObject obj,int id,PetscS
calar data,PetscBool flag)
Not collective
Input parameters:
+ obj - the object from which data is to be retrieved
- id - the identifier for the data
Output parameters
+ data - the data to be retrieved
- flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise
The 'data' and 'flag' variables are inlined, so they are not pointers.
Level: developer
M*/
#if defined(PETSC_USE_COMPLEX)
#define PetscObjectComposedDataGetScalar(obj,id,data,flag)
\

((((obj)->scalarcomposedstate && ((obj)->scalarcomposedstate[id] == (obj)->sta


te) ) ? \
(data = (obj)->scalarcomposeddata[id],flag = PETSC_TRUE) : (flag = PETSC_FALS
E)),0)
#else
#define PetscObjectComposedDataGetScalar(obj,id,data,flag)
\
PetscObjectComposedDataGetReal(obj,id,data,flag)
#endif
/*MC
PetscObjectComposedDataSetScalarstar - attach scalar array data to a PetscObj
ect
Synopsis:
#include "petsc-private/petscimpl.h"
PetscErrorCode PetscObjectComposedDataSetScalarstar(PetscObject obj,int id,Pe
tscScalar *data)
Not collective
Input parameters:
+ obj - the object to which data is to be attached
. id - the identifier for the data
- data - the data to be attached
Notes
The data identifier can best be determined through a call to
PetscObjectComposedDataRegister()
Level: developer
M*/
#if defined(PETSC_USE_COMPLEX)
#define PetscObjectComposedDataSetScalarstar(obj,id,data)
\
((((obj)->scalarstar_idmax < PetscObjectComposedDataMax) && PetscObjectCompose
dDataIncreaseScalarstar(obj)) || \
((obj)->scalarstarcomposeddata[id] = data,(obj)->scalarstarcomposedstate[id]
= (obj)->state, 0))
#else
#define PetscObjectComposedDataSetScalarstar(obj,id,data) \
PetscObjectComposedDataSetRealstar(obj,id,data)
#endif
/*MC
PetscObjectComposedDataGetScalarstar - retrieve scalar array data
attached to an object
Synopsis:
#include "petsc-private/petscimpl.h"
PetscErrorCode PetscObjectComposedDataGetScalarstar(PetscObject obj,int id,Pe
tscScalar *data,PetscBool flag)
Not collective
Input parameters:
+ obj - the object from which data is to be retrieved
- id - the identifier for the data
Output parameters
+ data - the data to be retrieved

- flag - PETSC_TRUE if the data item exists and is valid, PETSC_FALSE otherwise
The 'data' and 'flag' variables are inlined, so they are not pointers.
Level: developer
M*/
#if defined(PETSC_USE_COMPLEX)
#define PetscObjectComposedDataGetScalarstar(obj,id,data,flag)
\
((((obj)->scalarstarcomposedstate && ((obj)->scalarstarcomposedstate[id] == (o
bj)->state)) ? \
(data = (obj)->scalarstarcomposeddata[id],flag = PETSC_TRUE) : (flag = PE
TSC_FALSE)),0)
#else
#define PetscObjectComposedDataGetScalarstar(obj,id,data,flag)
\
PetscObjectComposedDataGetRealstar(obj,id,data,flag)
#endif
PETSC_EXTERN PetscErrorCode PetscObjectGetId(PetscObject,PetscObjectId*);
PETSC_EXTERN PetscMPIInt Petsc_Counter_keyval;
PETSC_EXTERN PetscMPIInt Petsc_InnerComm_keyval;
PETSC_EXTERN PetscMPIInt Petsc_OuterComm_keyval;
/*
PETSc communicators have this attribute, see
PetscCommDuplicate(), PetscCommDestroy(), PetscCommGetNewTag(), PetscObjectGet
Name()
*/
typedef struct {
PetscMPIInt tag;
/* next free tag value */
PetscInt
refcount;
/* number of references, communicator can be fre
ed when this reaches 0 */
PetscInt
namecount;
/* used to generate the next name, as in Vec_0,
Mat_1, ... */
} PetscCommCounter;
#if defined(PETSC_HAVE_CUSP)
/*E
PetscCUSPFlag - indicates which memory (CPU, GPU, or none contains valid vec
tor
PETSC_CUSP_UNALLOCATED - no memory contains valid matrix entries; NEVER used
for vectors
PETSC_CUSP_GPU - GPU has valid vector/matrix entries
PETSC_CUSP_CPU - CPU has valid vector/matrix entries
PETSC_CUSP_BOTH - Both GPU and CPU have valid vector/matrix entries and they
match
Level: developer
E*/
typedef enum {PETSC_CUSP_UNALLOCATED,PETSC_CUSP_GPU,PETSC_CUSP_CPU,PETSC_CUSP_BO
TH} PetscCUSPFlag;
#endif
#if defined(PETSC_HAVE_VIENNACL)
/*E
PetscViennaCLFlag - indicates which memory (CPU, GPU, or none contains valid
vector

PETSC_VIENNACL_UNALLOCATED - no memory contains valid matrix entries; NEVER


used for vectors
PETSC_VIENNACL_GPU - GPU has valid vector/matrix entries
PETSC_VIENNACL_CPU - CPU has valid vector/matrix entries
PETSC_VIENNACL_BOTH - Both GPU and CPU have valid vector/matrix entries and t
hey match
Level: developer
E*/
typedef enum {PETSC_VIENNACL_UNALLOCATED,PETSC_VIENNACL_GPU,PETSC_VIENNACL_CPU,P
ETSC_VIENNACL_BOTH} PetscViennaCLFlag;
#endif
#endif /* _PETSCHEAD_H */

You might also like