static PetscErrorCode TaoSetup_BLMVM(Tao tao) { TAO_BLMVM *blmP = (TAO_BLMVM *)tao->data; PetscInt n,N; PetscErrorCode ierr; KSP H0ksp; PetscFunctionBegin; /* Existence of tao->solution checked in TaoSetup() */ ierr = VecDuplicate(tao->solution,&blmP->Xold);CHKERRQ(ierr); ierr = VecDuplicate(tao->solution,&blmP->Gold);CHKERRQ(ierr); ierr = VecDuplicate(tao->solution, &blmP->unprojected_gradient);CHKERRQ(ierr); if (!tao->stepdirection) { ierr = VecDuplicate(tao->solution, &tao->stepdirection);CHKERRQ(ierr); } if (!tao->gradient) { ierr = VecDuplicate(tao->solution,&tao->gradient);CHKERRQ(ierr); } if (!tao->XL) { ierr = VecDuplicate(tao->solution,&tao->XL);CHKERRQ(ierr); ierr = VecSet(tao->XL,PETSC_NINFINITY);CHKERRQ(ierr); } if (!tao->XU) { ierr = VecDuplicate(tao->solution,&tao->XU);CHKERRQ(ierr); ierr = VecSet(tao->XU,PETSC_INFINITY);CHKERRQ(ierr); } /* Create matrix for the limited memory approximation */ ierr = VecGetLocalSize(tao->solution,&n);CHKERRQ(ierr); ierr = VecGetSize(tao->solution,&N);CHKERRQ(ierr); ierr = MatCreateLMVM(((PetscObject)tao)->comm,n,N,&blmP->M);CHKERRQ(ierr); ierr = MatLMVMAllocateVectors(blmP->M,tao->solution);CHKERRQ(ierr); /* If the user has set a matrix to solve as the initial H0, set the options prefix here, and set up the KSP */ if (blmP->H0) { const char *prefix; PC H0pc; ierr = MatLMVMSetH0(blmP->M, blmP->H0);CHKERRQ(ierr); ierr = MatLMVMGetH0KSP(blmP->M, &H0ksp);CHKERRQ(ierr); ierr = TaoGetOptionsPrefix(tao, &prefix);CHKERRQ(ierr); ierr = KSPSetOptionsPrefix(H0ksp, prefix);CHKERRQ(ierr); ierr = PetscObjectAppendOptionsPrefix((PetscObject)H0ksp, "tao_h0_");CHKERRQ(ierr); ierr = KSPGetPC(H0ksp, &H0pc);CHKERRQ(ierr); ierr = PetscObjectAppendOptionsPrefix((PetscObject)H0pc, "tao_h0_");CHKERRQ(ierr); ierr = KSPSetFromOptions(H0ksp);CHKERRQ(ierr); ierr = KSPSetUp(H0ksp);CHKERRQ(ierr); } PetscFunctionReturn(0); }
PETSC_EXTERN PetscErrorCode MatColoringApply_Power(MatColoring mc,ISColoring *iscoloring) { PetscErrorCode ierr; Mat m = mc->mat,mp,ms; MatColoring imc; PetscInt i; const char *optionsprefix; PetscFunctionBegin; /* square the matrix repeatedly if necessary */ if (mc->dist == 1) { mp = m; } else { ierr = MatMatMult(m,m,MAT_INITIAL_MATRIX,2.0,&mp);CHKERRQ(ierr); for (i=2;i<mc->dist;i++) { ms = mp; ierr = MatMatMult(m,ms,MAT_INITIAL_MATRIX,2.0,&mp);CHKERRQ(ierr); ierr = MatDestroy(&ms);CHKERRQ(ierr); } } ierr = MatColoringCreate(mp,&imc);CHKERRQ(ierr); ierr = PetscObjectGetOptionsPrefix((PetscObject)mc,&optionsprefix);CHKERRQ(ierr); ierr = PetscObjectSetOptionsPrefix((PetscObject)imc,optionsprefix);CHKERRQ(ierr); ierr = PetscObjectAppendOptionsPrefix((PetscObject)imc,"power_");CHKERRQ(ierr); ierr = MatColoringSetType(imc,MATCOLORINGGREEDY);CHKERRQ(ierr); ierr = MatColoringSetDistance(imc,1);CHKERRQ(ierr); ierr = MatColoringSetWeightType(imc,mc->weight_type);CHKERRQ(ierr); ierr = MatColoringSetFromOptions(imc);CHKERRQ(ierr); ierr = MatColoringApply(imc,iscoloring);CHKERRQ(ierr); ierr = MatColoringDestroy(&imc);CHKERRQ(ierr); if (mp != m) {ierr = MatDestroy(&mp);CHKERRQ(ierr);} PetscFunctionReturn(0); }
/*@C TaoAppendOptionsPrefix - Appends to the prefix used for searching for all TAO options in the database. Collective on TAO_SOLVER Input Parameters: + tao - the TAO_SOLVER solver context - prefix - the prefix string to prepend to all TAO option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .keywords: options .seealso: TaoSetOptionsPrefix(), TaoGetOptionsPrefix() @*/ int TaoAppendOptionsPrefix(TAO_SOLVER tao, const char prefix[]) { int info; TaoFunctionBegin; PetscValidHeaderSpecific(tao,TAO_COOKIE,1); info = PetscObjectAppendOptionsPrefix((PetscObject)tao,prefix); CHKERRQ(info); TaoFunctionReturn(0); }
/*@C RGAppendOptionsPrefix - Appends to the prefix used for searching for all RG options in the database. Logically Collective on RG Input Parameters: + rg - the region context - prefix - the prefix string to prepend to all RG option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: RGSetOptionsPrefix() @*/ PetscErrorCode RGAppendOptionsPrefix(RG rg,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(rg,RG_CLASSID,1); ierr = PetscObjectAppendOptionsPrefix((PetscObject)rg,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C PetscViewerAppendOptionsPrefix - Appends to the prefix used for searching for all PetscViewer options in the database. Logically Collective on PetscViewer Input Parameters: + viewer - the PetscViewer context - prefix - the prefix to prepend to all option names Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .keywords: PetscViewer, append, options, prefix, database .seealso: PetscViewerGetOptionsPrefix() @*/ PetscErrorCode PetscViewerAppendOptionsPrefix(PetscViewer viewer,const char prefix[]) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); ierr = PetscObjectAppendOptionsPrefix((PetscObject)viewer,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C BVAppendOptionsPrefix - Appends to the prefix used for searching for all BV options in the database. Logically Collective on BV Input Parameters: + bv - the basis vectors context - prefix - the prefix string to prepend to all BV option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: BVSetOptionsPrefix(), BVGetOptionsPrefix() @*/ PetscErrorCode BVAppendOptionsPrefix(BV bv,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(bv,BV_CLASSID,1); ierr = PetscObjectAppendOptionsPrefix((PetscObject)bv,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); }
PetscErrorCode KSPSetFromOptions_Chebyshev(KSP ksp) { KSP_Chebyshev *cheb = (KSP_Chebyshev*)ksp->data; PetscErrorCode ierr; PetscInt two = 2,four = 4; PetscReal tform[4] = {PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE}; PetscBool flg; PetscFunctionBegin; ierr = PetscOptionsHead("KSP Chebyshev Options");CHKERRQ(ierr); ierr = PetscOptionsInt("-ksp_chebyshev_eststeps","Number of est steps in Chebyshev","",cheb->eststeps,&cheb->eststeps,NULL);CHKERRQ(ierr); ierr = PetscOptionsRealArray("-ksp_chebyshev_eigenvalues","extreme eigenvalues","KSPChebyshevSetEigenvalues",&cheb->emin,&two,0);CHKERRQ(ierr); ierr = PetscOptionsRealArray("-ksp_chebyshev_estimate_eigenvalues","estimate eigenvalues using a Krylov method, then use this transform for Chebyshev eigenvalue bounds","KSPChebyshevSetEstimateEigenvalues",tform,&four,&flg);CHKERRQ(ierr); if (flg) { switch (four) { case 0: ierr = KSPChebyshevSetEstimateEigenvalues(ksp,PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE);CHKERRQ(ierr); break; case 2: /* Base everything on the max eigenvalues */ ierr = KSPChebyshevSetEstimateEigenvalues(ksp,PETSC_DECIDE,tform[0],PETSC_DECIDE,tform[1]);CHKERRQ(ierr); break; case 4: /* Use the full 2x2 linear transformation */ ierr = KSPChebyshevSetEstimateEigenvalues(ksp,tform[0],tform[1],tform[2],tform[3]);CHKERRQ(ierr); break; default: SETERRQ(PetscObjectComm((PetscObject)ksp),PETSC_ERR_ARG_INCOMP,"Must specify either 0, 2, or 4 parameters for eigenvalue estimation"); } } if (cheb->kspest) { PetscBool estrand = PETSC_FALSE; ierr = PetscOptionsBool("-ksp_chebyshev_estimate_eigenvalues_random","Use Random right hand side for eigenvalue estimation","KSPChebyshevEstEigSetRandom",estrand,&estrand,NULL);CHKERRQ(ierr); if (estrand) { PetscRandom random; ierr = PetscRandomCreate(PetscObjectComm((PetscObject)ksp),&random);CHKERRQ(ierr); ierr = PetscObjectSetOptionsPrefix((PetscObject)random,((PetscObject)ksp)->prefix);CHKERRQ(ierr); ierr = PetscObjectAppendOptionsPrefix((PetscObject)random,"ksp_chebyshev_estimate_eigenvalues_");CHKERRQ(ierr); ierr = PetscRandomSetFromOptions(random);CHKERRQ(ierr); ierr = KSPChebyshevEstEigSetRandom(ksp,random);CHKERRQ(ierr); ierr = PetscRandomDestroy(&random);CHKERRQ(ierr); } } if (cheb->kspest) { /* Mask the PC so that PCSetFromOptions does not do anything */ ierr = KSPSetPC(cheb->kspest,cheb->pcnone);CHKERRQ(ierr); ierr = KSPSetOptionsPrefix(cheb->kspest,((PetscObject)ksp)->prefix);CHKERRQ(ierr); ierr = KSPAppendOptionsPrefix(cheb->kspest,"est_");CHKERRQ(ierr); if (!((PetscObject)cheb->kspest)->type_name) { ierr = KSPSetType(cheb->kspest,KSPGMRES);CHKERRQ(ierr); } ierr = KSPSetFromOptions(cheb->kspest);CHKERRQ(ierr); ierr = KSPSetPC(cheb->kspest,ksp->pc);CHKERRQ(ierr); } ierr = PetscOptionsTail();CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C KSPAppendOptionsPrefix - Appends to the prefix used for searching for all KSP options in the database. Logically Collective on KSP Input Parameters: + ksp - the Krylov context - prefix - the prefix string to prepend to all KSP option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .keywords: KSP, append, options, prefix, database .seealso: KSPSetOptionsPrefix(), KSPGetOptionsPrefix() @*/ PetscErrorCode KSPAppendOptionsPrefix(KSP ksp,const char prefix[]) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(ksp,KSP_CLASSID,1); if (!ksp->pc) {ierr = KSPGetPC(ksp,&ksp->pc);CHKERRQ(ierr);} ierr = PCAppendOptionsPrefix(ksp->pc,prefix);CHKERRQ(ierr); ierr = PetscObjectAppendOptionsPrefix((PetscObject)ksp,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C MFNAppendOptionsPrefix - Appends to the prefix used for searching for all MFN options in the database. Logically Collective on MFN Input Parameters: + mfn - the matrix function context - prefix - the prefix string to prepend to all MFN option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: MFNSetOptionsPrefix(), MFNGetOptionsPrefix() @*/ PetscErrorCode MFNAppendOptionsPrefix(MFN mfn,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(mfn,MFN_CLASSID,1); if (!mfn->V) { ierr = MFNGetBV(mfn,&mfn->V);CHKERRQ(ierr); } ierr = BVSetOptionsPrefix(mfn->V,prefix);CHKERRQ(ierr); if (!mfn->ds) { ierr = MFNGetDS(mfn,&mfn->ds);CHKERRQ(ierr); } ierr = DSSetOptionsPrefix(mfn->ds,prefix);CHKERRQ(ierr); ierr = PetscObjectAppendOptionsPrefix((PetscObject)mfn,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); }
static PetscErrorCode PetscDrawGetPopup_Image(PetscDraw draw,PetscDraw *popup) { PetscBool flg = PETSC_FALSE; PetscErrorCode ierr; PetscFunctionBegin; ierr = PetscOptionsGetBool(((PetscObject)draw)->options,((PetscObject)draw)->prefix,"-draw_popup",&flg,NULL);CHKERRQ(ierr); if (!flg) {*popup = NULL; PetscFunctionReturn(0);} ierr = PetscDrawCreate(PetscObjectComm((PetscObject)draw),NULL,NULL,0,0,220,220,popup);CHKERRQ(ierr); ierr = PetscDrawSetType(*popup,PETSC_DRAW_IMAGE);CHKERRQ(ierr); ierr = PetscObjectSetOptionsPrefix((PetscObject)*popup,"popup_");CHKERRQ(ierr); ierr = PetscObjectAppendOptionsPrefix((PetscObject)*popup,((PetscObject)draw)->prefix);CHKERRQ(ierr); draw->popup = *popup; PetscFunctionReturn(0); }
/*@C EPSAppendOptionsPrefix - Appends to the prefix used for searching for all EPS options in the database. Logically Collective on EPS Input Parameters: + eps - the eigensolver context - prefix - the prefix string to prepend to all EPS option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: EPSSetOptionsPrefix(), EPSGetOptionsPrefix() @*/ PetscErrorCode EPSAppendOptionsPrefix(EPS eps,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(eps,EPS_CLASSID,1); if (!eps->st) { ierr = EPSGetST(eps,&eps->st);CHKERRQ(ierr); } ierr = STAppendOptionsPrefix(eps->st,prefix);CHKERRQ(ierr); if (!eps->V) { ierr = EPSGetBV(eps,&eps->V);CHKERRQ(ierr); } ierr = BVSetOptionsPrefix(eps->V,prefix);CHKERRQ(ierr); if (!eps->ds) { ierr = EPSGetDS(eps,&eps->ds);CHKERRQ(ierr); } ierr = DSSetOptionsPrefix(eps->ds,prefix);CHKERRQ(ierr); if (!eps->rg) { ierr = EPSGetRG(eps,&eps->rg);CHKERRQ(ierr); } ierr = RGSetOptionsPrefix(eps->rg,prefix);CHKERRQ(ierr); ierr = PetscObjectAppendOptionsPrefix((PetscObject)eps,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C NEPAppendOptionsPrefix - Appends to the prefix used for searching for all NEP options in the database. Logically Collective on NEP Input Parameters: + nep - the nonlinear eigensolver context - prefix - the prefix string to prepend to all NEP option requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: NEPSetOptionsPrefix(), NEPGetOptionsPrefix() @*/ PetscErrorCode NEPAppendOptionsPrefix(NEP nep,const char *prefix) { PetscErrorCode ierr; PetscFunctionBegin; PetscValidHeaderSpecific(nep,NEP_CLASSID,1); if (!nep->V) { ierr = NEPGetBV(nep,&nep->V);CHKERRQ(ierr); } ierr = BVSetOptionsPrefix(nep->V,prefix);CHKERRQ(ierr); if (!nep->ds) { ierr = NEPGetDS(nep,&nep->ds);CHKERRQ(ierr); } ierr = DSSetOptionsPrefix(nep->ds,prefix);CHKERRQ(ierr); if (!nep->rg) { ierr = NEPGetRG(nep,&nep->rg);CHKERRQ(ierr); } ierr = RGSetOptionsPrefix(nep->rg,prefix);CHKERRQ(ierr); if (!nep->ksp) { ierr = NEPGetKSP(nep,&nep->ksp);CHKERRQ(ierr); } ierr = KSPSetOptionsPrefix(nep->ksp,prefix);CHKERRQ(ierr); ierr = KSPAppendOptionsPrefix(nep->ksp,"nep_");CHKERRQ(ierr); ierr = PetscObjectAppendOptionsPrefix((PetscObject)nep,prefix);CHKERRQ(ierr); PetscFunctionReturn(0); }
/*@C TaoLineSearchAppendOptionsPrefix - Appends to the prefix used for searching for all TaoLineSearch options in the database. Collective on TaoLineSearch Input Parameters: + ls - the TaoLineSearch solver context - prefix - the prefix string to prepend to all line search requests Notes: A hyphen (-) must NOT be given at the beginning of the prefix name. The first character of all runtime options is AUTOMATICALLY the hyphen. Level: advanced .seealso: TaoLineSearchSetOptionsPrefix(), TaoLineSearchGetOptionsPrefix() @*/ PetscErrorCode TaoLineSearchAppendOptionsPrefix(TaoLineSearch ls, const char p[]) { return PetscObjectAppendOptionsPrefix((PetscObject)ls,p); }