![]() |
00001 // Copyright (C) 2002 Johan Hoffman and Anders Logg. 00002 // Licensed under the GNU GPL Version 2. 00003 // 00004 // Modified by Thomas Svedberg, 2004. 00005 00006 #ifndef __KRYLOV_SOLVER_H 00007 #define __KRYLOV_SOLVER_H 00008 00009 #include <dolfin/constants.h> 00010 00011 namespace dolfin { 00012 00013 class Matrix; 00014 class Vector; 00015 00017 class KrylovSolver 00018 { 00019 public: 00020 00021 enum Method { GMRES, CG, BiCGSTAB }; 00022 enum Preconditioner { RICHARDSON, JACOBI, GAUSS_SEIDEL, SOR, NONE }; 00023 00024 KrylovSolver(Method method = GMRES); 00025 00026 void solve(const Matrix &A, Vector &x, const Vector &b); 00027 00028 void setMethod(Method method); 00029 void setPreconditioner(Preconditioner pc); 00030 00031 private: 00032 00033 void solveCG (const Matrix &A, Vector &x, const Vector &b); 00034 void solveGMRES (const Matrix &A, Vector &x, const Vector &b); 00035 void solveBiCGSTAB (const Matrix &A, Vector &x, const Vector &b); 00036 00037 int restartedGMRES(const Matrix &A, Vector &x, const Vector &b, Vector& r, unsigned int k_max); 00038 00039 void solvePxu(const Matrix &A, Vector &x, Vector &u); 00040 00041 bool reorthog(const Matrix& A, Matrix& v, Vector &x, int k); 00042 00043 real residual (const Matrix &A, Vector &x, const Vector &b, Vector &r); 00044 00045 Method method; 00046 Preconditioner pc; 00047 00048 real tol; 00049 int no_pc_sweeps; 00050 00051 }; 00052 00053 } 00054 00055 #endif
Documentation automatically generated with Doxygen on 10 Sep 2004.