Example #1
0
PetscErrorCode KSPDestroy_BiCG(KSP ksp)
{
  PetscErrorCode ierr;

  PetscFunctionBegin;
  ierr = KSPDefaultFreeWork(ksp);CHKERRQ(ierr);
  PetscFunctionReturn(0);
}
Example #2
0
/*@
   KSPBCGSLSetXRes - Sets the parameter governing when
   exact residuals will be used instead of computed residuals.

   Collective on KSP

   Input Parameters:
+  ksp - iterative context obtained from KSPCreate
-  delta - computed residuals are used alone when delta is not positive

   Options Database Keys:

.  -ksp_bcgsl_xres delta

   Level: intermediate

.keywords: KSP, BiCGStab(L), set, exact residuals

.seealso: KSPBCGSLSetEll(), KSPBCGSLSetPol()
@*/
PetscErrorCode PETSCKSP_DLLEXPORT KSPBCGSLSetXRes(KSP ksp, PetscReal delta)
{
    KSP_BCGSL      *bcgsl = (KSP_BCGSL *)ksp->data;
    PetscErrorCode ierr;

    PetscFunctionBegin;
    if (ksp->setupcalled) {
        if ((delta<=0 && bcgsl->delta>0) || (delta>0 && bcgsl->delta<=0)) {
            ierr = KSPDefaultFreeWork(ksp);
            CHKERRQ(ierr);
            ierr = PetscFree5(AY0c,AYlc,AYtc,MZa,MZb);
            CHKERRQ(ierr);
            ksp->setupcalled = 0;
        }
    }
    bcgsl->delta = delta;
    PetscFunctionReturn(0);
}
Example #3
0
/*@
   KSPBCGSLSetEll - Sets the number of search directions in BiCGStab(L).

   Collective on KSP

   Input Parameters:
+  ksp - iterative context obtained from KSPCreate
-  ell - number of search directions

   Options Database Keys:

.  -ksp_bcgsl_ell ell

   Level: intermediate

.keywords: KSP, BiCGStab(L), set, exact residuals,

.seealso: @()
@*/
PetscErrorCode PETSCKSP_DLLEXPORT KSPBCGSLSetEll(KSP ksp, int ell)
{
    KSP_BCGSL      *bcgsl = (KSP_BCGSL *)ksp->data;
    PetscErrorCode ierr;

    PetscFunctionBegin;
    if (ell < 1) SETERRQ(PETSC_ERR_ARG_OUTOFRANGE, "KSPBCGSLSetEll: second argument must be positive");

    if (!ksp->setupcalled) {
        bcgsl->ell = ell;
    } else if (bcgsl->ell != ell) {
        /* free the data structures, then create them again */
        ierr = KSPDefaultFreeWork(ksp);
        CHKERRQ(ierr);
        ierr = PetscFree5(AY0c,AYlc,AYtc,MZa,MZb);
        CHKERRQ(ierr);
        bcgsl->ell = ell;
        ksp->setupcalled = 0;
    }
    PetscFunctionReturn(0);
}
Example #4
0
/*@
   KSPBCGSLSetPol - Sets the type of polynomial part will
   be used in the BiCGSTab(L) solver.

   Collective on KSP

   Input Parameters:
+  ksp - iterative context obtained from KSPCreate
-  uMROR - set to PETSC_TRUE when the polynomial is a convex combination of an MR and an OR step.

   Options Database Keys:

+  -ksp_bcgsl_cxpoly - use enhanced polynomial
.  -ksp_bcgsl_mrpoly - use standard polynomial

   Level: intermediate

.keywords: KSP, BiCGStab(L), set, polynomial

.seealso: @()
@*/
PetscErrorCode PETSCKSP_DLLEXPORT KSPBCGSLSetPol(KSP ksp, PetscTruth uMROR)
{
    KSP_BCGSL      *bcgsl = (KSP_BCGSL *)ksp->data;
    PetscErrorCode ierr;

    PetscFunctionBegin;
    if (!ksp->setupcalled) {
        bcgsl->bConvex = uMROR;
    } else if (bcgsl->bConvex != uMROR) {
        /* free the data structures,
           then create them again
         */
        ierr = KSPDefaultFreeWork(ksp);
        CHKERRQ(ierr);
        ierr = PetscFree5(AY0c,AYlc,AYtc,MZa,MZb);
        CHKERRQ(ierr);
        bcgsl->bConvex = uMROR;
        ksp->setupcalled = 0;
    }
    PetscFunctionReturn(0);
}