/*@C PFSetType - Builds PF for a particular function Collective on PF Input Parameter: + pf - the function context. . type - a known method - ctx - optional type dependent context Options Database Key: . -pf_type <type> - Sets PF type Notes: See "petsc/include/petscpf.h" for available methods (for instance, PFCONSTANT) Level: intermediate .keywords: PF, set, method, type .seealso: PFSet(), PFRegisterDynamic(), PFCreate(), DMDACreatePF() @*/ PetscErrorCode PFSetType(PF pf,const PFType type,void *ctx) { PetscErrorCode ierr,(*r)(PF,void*); PetscBool match; PetscFunctionBegin; PetscValidHeaderSpecific(pf,PF_CLASSID,1); PetscValidCharPointer(type,2); ierr = PetscObjectTypeCompare((PetscObject)pf,type,&match);CHKERRQ(ierr); if (match) PetscFunctionReturn(0); if (pf->ops->destroy) {ierr = (*pf->ops->destroy)(pf);CHKERRQ(ierr);} pf->data = 0; /* Determine the PFCreateXXX routine for a particular function */ ierr = PetscFListFind(PFList,((PetscObject)pf)->comm,type,PETSC_TRUE,(void (**)(void)) &r);CHKERRQ(ierr); if (!r) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_UNKNOWN_TYPE,"Unable to find requested PF type %s",type); pf->ops->destroy = 0; pf->ops->view = 0; pf->ops->apply = 0; pf->ops->applyvec = 0; /* Call the PFCreateXXX routine for this particular function */ ierr = (*r)(pf,ctx);CHKERRQ(ierr); ierr = PetscObjectChangeTypeName((PetscObject)pf,type);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C MatSetType - Builds matrix object for a particular matrix type Collective on Mat Input Parameters: + mat - the matrix object - matype - matrix type Options Database Key: . -mat_type <method> - Sets the type; use -help for a list of available methods (for instance, seqaij) Notes: See "${PETSC_DIR}/include/petscmat.h" for available methods Level: intermediate .keywords: Mat, MatType, set, method .seealso: PCSetType(), VecSetType(), MatCreate(), MatType, Mat @*/ PetscErrorCode PETSCMAT_DLLEXPORT MatSetType(Mat mat, const MatType matype) { PetscErrorCode ierr,(*r)(Mat); PetscTruth sametype; PetscFunctionBegin; PetscValidHeaderSpecific(mat,MAT_COOKIE,1); ierr = PetscTypeCompare((PetscObject)mat,matype,&sametype);CHKERRQ(ierr); if (sametype) PetscFunctionReturn(0); ierr = PetscFListFind(MatList,((PetscObject)mat)->comm,matype,(void(**)(void))&r);CHKERRQ(ierr); if (!r) SETERRQ1(PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown Mat type given: %s",matype); /* free the old data structure if it existed */ if (mat->ops->destroy) { ierr = MatPreallocated(mat);CHKERRQ(ierr); ierr = (*mat->ops->destroy)(mat);CHKERRQ(ierr); mat->ops->destroy = PETSC_NULL; mat->preallocated = PETSC_FALSE; } /* create the new data structure */ if (mat->rmap->n < 0 && mat->rmap->N < 0 && mat->cmap->n < 0 && mat->cmap->N < 0) { mat->ops->create = r; } else { ierr = (*r)(mat);CHKERRQ(ierr); } ierr = PetscPublishAll(mat);CHKERRQ(ierr); PetscFunctionReturn(0); }
PetscErrorCode PetscObjectQueryFunction_Petsc(PetscObject obj,const char name[],void (**ptr)(void)) { PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscFListFind(obj->qlist,obj->comm,name,ptr);CHKERRQ(ierr); PetscFunctionReturn(0); }
PetscErrorCode PETSCTS_DLLEXPORT TSGLAdaptSetType(TSGLAdapt adapt,const TSGLAdaptType type) { PetscErrorCode ierr,(*r)(TSGLAdapt); PetscFunctionBegin; ierr = PetscFListFind(TSGLAdaptList,((PetscObject)adapt)->comm,type,(void(**)(void))&r);CHKERRQ(ierr); if (!r) SETERRQ1(PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown TSGLAdapt type \"%s\" given",type); if (((PetscObject)adapt)->type_name) {ierr = (*adapt->ops->destroy)(adapt);CHKERRQ(ierr);} ierr = (*r)(adapt);CHKERRQ(ierr); ierr = PetscObjectChangeTypeName((PetscObject)adapt,type);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C PetscDrawSetType - Builds graphics object for a particular implementation Collective on PetscDraw Input Parameter: + draw - the graphics context - type - for example, PETSC_DRAW_X Options Database Command: . -draw_type <type> - Sets the type; use -help for a list of available methods (for instance, x) Level: intermediate Notes: See "petsc/include/petscdraw.h" for available methods (for instance, PETSC_DRAW_X) Concepts: drawing^X windows Concepts: X windows^graphics Concepts: drawing^postscript Concepts: postscript^graphics Concepts: drawing^Microsoft Windows .seealso: PetscDrawSetFromOptions(), PetscDrawCreate(), PetscDrawDestroy() @*/ PetscErrorCode PetscDrawSetType(PetscDraw draw,const PetscDrawType type) { PetscErrorCode ierr,(*r)(PetscDraw); PetscBool match; PetscBool flg=PETSC_FALSE; PetscFunctionBegin; PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); PetscValidCharPointer(type,2); ierr = PetscObjectTypeCompare((PetscObject)draw,type,&match);CHKERRQ(ierr); if (match) PetscFunctionReturn(0); /* User requests no graphics */ ierr = PetscOptionsHasName(PETSC_NULL,"-nox",&flg);CHKERRQ(ierr); /* This is not ideal, but it allows codes to continue to run if X graphics was requested but is not installed on this machine. Mostly this is for testing. */ #if !defined(PETSC_HAVE_X) if (!flg) { ierr = PetscStrcmp(type,PETSC_DRAW_X,&match);CHKERRQ(ierr); if (match) { PetscBool dontwarn = PETSC_TRUE; flg = PETSC_TRUE; ierr = PetscOptionsHasName(PETSC_NULL,"-nox_warning",&dontwarn);CHKERRQ(ierr); if (!dontwarn) { (*PetscErrorPrintf)("PETSc installed without X windows on this machine\nproceeding without graphics\n"); } } } #endif if (flg) { type = PETSC_DRAW_NULL; } if (draw->data) { /* destroy the old private PetscDraw context */ ierr = (*draw->ops->destroy)(draw);CHKERRQ(ierr); draw->ops->destroy = PETSC_NULL; draw->data = 0; } ierr = PetscFListFind(PetscDrawList,((PetscObject)draw)->comm,type,PETSC_TRUE,(void (**)(void)) &r);CHKERRQ(ierr); if (!r) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown PetscDraw type given: %s",type); ierr = PetscObjectChangeTypeName((PetscObject)draw,type);CHKERRQ(ierr); draw->data = 0; ierr = (*r)(draw);CHKERRQ(ierr); PetscFunctionReturn(0); }
EXTERN_C_BEGIN #undef __FUNCT__ #define __FUNCT__ "TSSSPSetType_SSP" PetscErrorCode TSSSPSetType_SSP(TS ts,const TSSSPType type) { PetscErrorCode ierr,(*r)(TS,PetscReal,PetscReal,Vec); TS_SSP *ssp = (TS_SSP*)ts->data; PetscFunctionBegin; ierr = PetscFListFind(TSSSPList,((PetscObject)ts)->comm,type,PETSC_TRUE,(PetscVoidStarFunction)&r);CHKERRQ(ierr); if (!r) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown TS_SSP type %s given",type); ssp->onestep = r; ierr = PetscFree(ssp->type_name);CHKERRQ(ierr); ierr = PetscStrallocpy(type,&ssp->type_name);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C AOSetType - Builds an application ordering for a particular implementation. Collective on AO Input Parameters: + ao - The AO object - method - The name of the AO type Options Database Key: . -ao_type <type> - Sets the AO type; use -help for a list of available types Notes: See "petsc/include/petscao.h" for available AO types (for instance, AOBASIC and AOMEMORYSCALABLE). Level: intermediate .keywords: ao, set, type .seealso: AOGetType(), AOCreate() @*/ PetscErrorCode AOSetType(AO ao, const AOType method) { PetscErrorCode (*r)(AO); PetscBool match; PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ao, AO_CLASSID,1); ierr = PetscObjectTypeCompare((PetscObject)ao, method, &match);CHKERRQ(ierr); if (match) PetscFunctionReturn(0); if (!AORegisterAllCalled) {ierr = AORegisterAll(PETSC_NULL);CHKERRQ(ierr);} ierr = PetscFListFind(AOList, ((PetscObject)ao)->comm, method,PETSC_TRUE,(void (**)(void)) &r);CHKERRQ(ierr); if (!r) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_UNKNOWN_TYPE, "Unknown AO type: %s", method); if (ao->ops->destroy) { ierr = (*ao->ops->destroy)(ao);CHKERRQ(ierr); ao->ops->destroy = PETSC_NULL; } ierr = (*r)(ao);CHKERRQ(ierr); PetscFunctionReturn(0); }