KrylovSolver.cpp File Reference

#include <BaseVector.hpp>
#include <BaseMatrix.hpp>
#include <Vector.hpp>
#include <SparseMatrix.hpp>
#include <KrylovSolver.hpp>
#include <Preconditioner.hpp>
#include <DiagPrecond.hpp>
#include <IncompleteCholeskiFactorization.hpp>
#include <IdentityPrecond.hpp>
#include <SpectralFEMPreconditioner.hpp>
#include <PDESystem.hpp>
#include <ConjugateGradient.hpp>
#include <BiConjugateGradient.hpp>
#include <BiConjugateGradientStabilized.hpp>
#include <FGMRES.hpp>
#include <GMRES.hpp>
#include <PETScKrylovSolver.hpp>
#include <MultiGrid.hpp>
#include <Timer.hpp>

Include dependency graph for KrylovSolver.cpp:

Go to the source code of this file.

Functions

void KrylovSolverDim (ReferenceCounting< Vector< real_t > > u, const BaseMatrix &A, const BaseVector &b, const Problem &problem, const KrylovSolverOptions::Type &type, const KrylovSolverOptions::PreconditionerType &pType, const DegreeOfFreedomSet &degreeOfFreedomSet)


Function Documentation

void KrylovSolverDim ( ReferenceCounting< Vector< real_t > >  u,
const BaseMatrix A,
const BaseVector b,
const Problem problem,
const KrylovSolverOptions::Type type,
const KrylovSolverOptions::PreconditionerType pType,
const DegreeOfFreedomSet degreeOfFreedomSet 
)

Definition at line 52 of file KrylovSolver.cpp.

References ASSERT, KrylovSolverOptions::biConjugateGradient, KrylovSolverOptions::biConjugateGradientStabilized, KrylovSolverOptions::conjugateGradient, KrylovSolverOptions::diagonal, ffout(), KrylovSolverOptions::fgmres, KrylovSolverOptions::gmres, KrylovSolverOptions::incompleteCholeski, KrylovSolverOptions::iterativeLUFactorization, KrylovSolverOptions::multiGrid, KrylovSolverOptions::none, KrylovSolverOptions::spectralFEM, BaseMatrix::type(), and ErrorHandler::unexpected.

Referenced by KrylovSolver::solve().

00058 {
00059 #warning temporay implementation
00060 #ifdef    HAVE_PETSC
00061   ASSERT(A.type() == BaseMatrix::petscMatrix);
00062   PETScKrylovSolver pks(static_cast<const Vector<real_t>&>(b),
00063                         static_cast<const PETScMatrix&>(A),
00064                         static_cast<Vector<real_t>&>(u));
00065   return;
00066 #endif // HAVE_PETSC
00067   ReferenceCounting<Preconditioner> P = 0;
00068 
00069   switch (pType) {
00070   case KrylovSolverOptions::none: {
00071     P = new IdentityPrecond(problem);
00072     break;
00073   }
00074   case KrylovSolverOptions::diagonal: {
00075     P = new DiagPrecond(problem, A);
00076     break;
00077   }
00078   case KrylovSolverOptions::incompleteCholeski: {
00079     P = new IncompleteCholeskiFactorization(problem, A);
00080     break;
00081   }
00082   case KrylovSolverOptions::multiGrid: {
00083     P = new MultiGrid(problem,
00084                       static_cast<const SparseMatrix&>(A),
00085                       degreeOfFreedomSet);
00086     break;
00087   }
00088   case KrylovSolverOptions::spectralFEM: {
00089     P = new SpectralFEMPreconditioner(problem);
00090     break;
00091   }
00092   default: {
00093     throw ErrorHandler(__FILE__,__LINE__,
00094                        "unexpected preconditioner type",
00095                        ErrorHandler::unexpected);
00096   }
00097   }
00098   ffout(2) << "- preconditioner: " << (*P).name() << '\n';
00099   ffout(2) << "- preconditioner initialization\n";
00100   (*P).initializes();
00101   ffout(2) << "  preconditioner initialization: done\n";
00102 
00103   switch (type) {
00104   case (KrylovSolverOptions::conjugateGradient): {
00105     ConjugateGradient cg(static_cast<const Vector<real_t>&>(b),
00106                          A, *P, *u);
00107     break;
00108   }
00109   case (KrylovSolverOptions::biConjugateGradient): {
00110     BiConjugateGradient bicg(static_cast<const Vector<real_t>&>(b),
00111                              A, *P, *u);
00112     break;
00113   }
00114   case (KrylovSolverOptions::biConjugateGradientStabilized): {
00115     BiConjugateGradientStabilized bicgstab(static_cast<const Vector<real_t>&>(b),
00116                                            A, *P, *u);
00117     break;
00118   }
00119   case (KrylovSolverOptions::fgmres): {
00120     FGMRES fgmres(static_cast<const Vector<real_t>&>(b),
00121                   A, *P, *u);
00122     break;
00123   }
00124   case (KrylovSolverOptions::gmres): {
00125     GMRES gmres(static_cast<const Vector<real_t>&>(b),
00126                 A, *P, *u);
00127     break;
00128   }
00129 //   case (KrylovSolverOptions::multiGrid): {
00130 //     MultiGrid<1, real, real_t> mg(static_cast<const Vector<real_t>&>(b),
00131 //                                  static_cast<SparseMatrix<real_t>&>(A),
00132 //                                  static_cast<Vector<real_t>&>(u),
00133 //                                  os);
00134 //     break;
00135 //   }
00136   case (KrylovSolverOptions::iterativeLUFactorization): {
00137 //     IterativeLUFactorization<1,real,real_t>(static_cast<const Vector<real_t>&>(b),
00138 //                                            static_cast<SparseMatrix<real_t>&>(A),
00139 //                                            static_cast<Vector<real_t>&>(u));
00140     throw ErrorHandler(__FILE__,__LINE__,
00141                        "not implemented",
00142                        ErrorHandler::unexpected);
00143     break;
00144   }
00145   default: {
00146     throw ErrorHandler(__FILE__,__LINE__,
00147                        "unexpected linear solver type",
00148                        ErrorHandler::unexpected);
00149   }
00150   }
00151 }

Here is the call graph for this function:


Generated on Wed Nov 19 00:01:49 2008 for FreeFEM3D (aka ff3d) by  doxygen 1.5.6