4 * Created on: 13 April. 2013
8 #ifndef LINEARSOLVER_HXX_
9 #define LINEARSOLVER_HXX_
16 #include "GenericMatrix.hxx"
22 public: //----------------------------------------------------------------
24 LinearSolver ( void ) ;
26 ~LinearSolver ( void ) ;
28 LinearSolver( const GenericMatrix& matrix,
29 const Vector& secondMember,
32 std::string nameOfMethod,
33 std::string nameOfPc="" );
35 LinearSolver( const GenericMatrix& matrix,
36 const std::vector<double>& secondMember,
39 std::string nameOfMethod,
40 std::string nameOfPc="" );
42 const LinearSolver& operator= ( const LinearSolver& linearSolver ) ;
44 LinearSolver ( const LinearSolver& LS ) ;
46 void setMethod(std::string nameOfMethod) ;
48 void setPreconditioner(std::string pc) ;
50 void setComputeConditionNumber(bool display=true);
51 double getConditionNumber() const;
53 int getNumberOfIter( void ) const ;
55 bool getStatus( void ) const ;
57 double getResidu( void ) const ;
59 double getTolerance( void ) const ;
61 int getNumberMaxOfIter( void ) const ;
63 void setTolerance(double tol) ;
65 void setNumberMaxOfIter(int numberMaxOfIter) ;
67 Vector getSndMember( void ) const ;
69 std::string getNameOfMethod( void ) const ;
71 std::string getNameOfPc( void ) const ;
73 Vector solve( void ) ;
75 void setMatrix(const GenericMatrix& matrix) ;
77 void setSndMember(const Vector& secondMember) ;
79 void setMatrixIsSingular(bool sing=true) ;
81 bool isMatrixSingular( void ) const;
83 bool isSparseMatrix( void ) const ;
85 Mat getPetscMatrix() const ;
86 Vec getPetscVector() const ;
87 void viewPetscMatrix() const ;
88 void viewPetscRHS() const;
89 double getPetscMatValue(int i, int j) const;
90 double getPetscRHSValue(int i) const ;
92 void kspDuplicate(const KSP source, const Mat mat, KSP* destination) const;
94 void precDuplicate(const PC source, const KSP ksp, PC* destination) const;
97 private: //----------------------------------------------------------------
99 void setLinearSolver(const GenericMatrix& matrix, const Vector& secondMember) ;
100 KSP getPetscKsp() const ;
101 PC getPetscPc() const ;
103 Vec vectorToVec( const Vector& myVector ) const ;
105 Vector vecToVector(const Vec& vec) const ;
108 int _numberMaxOfIter;
113 bool _isSparseMatrix;
114 bool _computeConditionNumber;
115 double _conditionNumber;
116 std::string _nameOfPc;
117 std::string _nameOfMethod;
118 Vector _secondMember;
126 #endif /* LINEARSOLVER_HXX_ */