PetscObjectComposeFunction

Associates a function with a given PETSc object.

Input Parameters

obj - the PETSc object; this must be cast with a (PetscObject), for example, PetscObjectCompose((PetscObject) mat,...);
name - name associated with child object
fname - name of the function
ptr - function pointer (or PETSC_NULL if using dynamic libraries)

Notes

PetscObjectComposeFunction() can be used with any PETSc object such atMat, Vec, KSP, SNES, etc, or any user-provided object.

Keywords

object, composition

See Also

PetscObjectQueryFunction()
*/ #undef __FUNC__#define __FUNC__ "PetscObjectComposeFunction_Private" int PetscObjectComposeFunction_Private(PetscObject obj,char *name,char *fname,void *ptr) { int ierr;

PetscFunctionBegin; ierr = (*obj->bops->composefunction)(obj,name,fname,ptr);CHKERRQ(ierr); PetscFunctionReturn(0); }

#undef __FUNC__#define __FUNC__ "PetscObjectQueryFunction" /*@ CPetscObjectQueryFunction - Gets a function associated with a given object. Collective on PetscObject

Input Parameters

obj - the PETSc object Thus must be cast with a (PetscObject), for example, PetscObjectCompose((PetscObject) mat,...);
name - name associated with childfunction

Output Parameter

ptr -function pointer

Keywords

object, composition

See Also

PetscObjectComposeFunction()
@*/ int PetscObjectQueryFunction(PetscObject obj,char *name,void **ptr) { int ierr;

PetscFunctionBegin; ierr = (*obj->bops->queryfunction)(obj,name,ptr);CHKERRQ(ierr); PetscFunctionReturn(0); }

/* -------------------------------------------------------------------------------------*/

#undef __FUNC__#define __FUNC__ "PetscDataTypeToMPIDataType" int PetscDataTypeToMPIDataType(PetscDataType ptype,MPI_Datatype* mtype) { PetscFunctionBegin; if (ptype == PETSC_INT) { *mtype = MPI_INT; } else if (ptype == PETSC_DOUBLE) { *mtype = MPI_DOUBLE; } else if (ptype == PETSC_SCALAR) { *mtype = MPIU_SCALAR; #if defined(USE_PETSC_COMPLEX) } else if (ptype == PETSC_COMPLEX) { *mtype = MPIU_COMPLEX; # endif} else if (ptype == PETSC_CHAR) { *mtype = MPI_CHAR; } else if (ptype == PETSC_LOGICAL) { *mtype = MPI_BYTE; } else { SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,1,"Unknown PETSc datatype"); } PetscFunctionReturn(0); }

#undef __FUNC__#define __FUNC__ "PetscDataTypeGetSize" int PetscDataTypeGetSize(PetscDataType ptype,int *size) { PetscFunctionBegin; if (ptype == PETSC_INT) { *size = PETSC_INT_SIZE; } else if (ptype == PETSC_DOUBLE) { *size = PETSC_DOUBLE_SIZE; } else if (ptype == PETSC_SCALAR) { *size = PETSC_SCALAR_SIZE; #if defined(USE_PETSC_COMPLEX) } else if (ptype == PETSC_COMPLEX) { *size = PETSC_COMPLEX_SIZE; # endif} else if (ptype == PETSC_CHAR) { *size = PETSC_CHAR_SIZE; } else if (ptype == PETSC_LOGICAL) { *size = PETSC_LOGICAL_SIZE; } else { SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,1,"Unknown PETSc datatype"); } PetscFunctionReturn(0); }

#undef __FUNC__#define __FUNC__ "PetscDataTypeGetName" int PetscDataTypeGetName(PetscDataType ptype,char **name) { PetscFunctionBegin; if (ptype == PETSC_INT) { *name = "int"; } else if (ptype == PETSC_DOUBLE) { *name = "double"; } else if (ptype == PETSC_SCALAR) { *name = "Scalar"; #if defined(USE_PETSC_COMPLEX) } else if (ptype == PETSC_COMPLEX) { *name = "complex"; # endif} else if (ptype == PETSC_CHAR) { *name = "char"; } else if (ptype == PETSC_LOGICAL) { *name = "logical"; } else { SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,1,"Unknown PETSc datatype"); } PetscFunctionReturn(0); }

struct _p_PetscObjectContainer { PETSCHEADER(int) void *ptr; };

#undef __FUNC__#define __FUNC__ "PetscObjectContainerGetPointer" /*@ CPetscObjectContainerGetPointer - Gets the pointer value contained in the container.

Collective on PetscObjectContainer

Input Parameter

obj -the object created with PetscObjectContainerCreate()

Output Parameter

ptr -the pointer value

See Also

PetscObjectContainerCreate(), PetscObjectContainerDestroy(),
PetscObjectContainerSetPointer() @*/ int PetscObjectContainerGetPointer(PetscObjectContainer obj,void **ptr) { PetscFunctionBegin; *ptr = obj->ptr; PetscFunctionReturn(0); }

#undef __FUNC__#define __FUNC__ "PetscObjectContainerSetPointer" /*@ CPetscObjectContainerSetPointer - Sets the pointer value contained in the container.

Collective on PetscObjectContainer

Input Parameters

obj - the object created with PetscObjectContainerCreate()
ptr - the pointer value

See Also

PetscObjectContainerCreate(), PetscObjectContainerDestroy(),
PetscObjectContainerGetPointer() @*/ int PetscObjectContainerSetPointer(PetscObjectContainer obj,void *ptr) { PetscFunctionBegin; obj->ptr = ptr; PetscFunctionReturn(0); }

#undef __FUNC__#define __FUNC__ "PetscObjectContainerDestroy" /*@ CPetscObjectContainerDestroy - Destroys a PETSc container object.

Collective on PetscObjectContainer

Input Parameter

obj -the object created with PetscObjectContainerCreate()

See Also

PetscObjectContainerCreate()
@*/ int PetscObjectContainerDestroy(PetscObjectContainer obj) { PetscFunctionBegin; if (--obj->refct > 0) PetscFunctionReturn(0); PetscHeaderDestroy(obj); PetscFunctionReturn(0); }

#undef __FUNC__#define __FUNC__ "PetscObjectContainerDestroy" /*@ CPetscObjectContainerCreate - Creates a PETSc object that has room to holda single pointer. This allows one to attach any type of data ( accessiblethrough a pointer) with the PetscObjectCompose() function to a PetscObject.

Collective on MPI_Comm

Input Parameters

comm -MPI communicator that shares the object

See Also

PetscObjectContainerDestroy()
@*/ int PetscObjectContainerCreate(MPI_Comm comm,PetscObjectContainer *container) { PetscObjectContainer contain;

PetscFunctionBegin;

PetscHeaderCreate(contain, _p_PetscObjectContainer,int,PETSC_COOKIE,0,comm, PetscObjectContainerDestroy,0); *container = contain; PetscFunctionReturn(0); }

Location: src/sys/src/objectsinherit.c
System Index
Table of Contents