LifeV
BelosOperator.hpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 
27 /*!
28  @file
29  @brief BelosOperator
30 
31  @author Umberto Villa <umberto.villa@gmail.com>
32 
33  @date 28-09-2010
34  */
35 
36 #ifndef _BELOSOPERATOR_HPP_
37 #define _BELOSOPERATOR_HPP_
38 
39 #include <BelosEpetraAdapter.hpp>
40 #include <BelosSolverManager.hpp>
41 #include <Teuchos_ParameterList.hpp>
42 #include <Teuchos_RefCountPtr.hpp>
43 
44 #include <lifev/core/operator/SolverOperator.hpp>
45 
46 namespace LifeV
47 {
48 namespace Operators
49 {
50 //! @class BelosOperator
51 /*! @brief Class which defines the interface of an Invertible Linear Operator through belos.
52  *
53  */
54 
55 class BelosOperator : public SolverOperator
56 {
57 public:
58 
59  //! @name Public Typedefs and Enumerators
60  //@{
61 
62  enum PreconditionerSide { None, Left, Right };
63 
64  enum SolverManagerType { NotAValidSolverManager, BlockCG, PseudoBlockCG, RCG,
65  BlockGmres, PseudoBlockGmres, GmresPoly,
66  GCRODR, PCPG, TFQMR, MINRES
67  };
68 
69  //@}
70 
71  //! null constructor and destructor
72  //@{
73  BelosOperator();
74  ~BelosOperator();
75  //@}
76 
77 protected:
78 
79  typedef Epetra_MultiVector MV;
80  typedef Epetra_Operator OP;
81  typedef Belos::LinearProblem<double, MV, OP> LinearProblem;
82  typedef Belos::SolverManager<double, MV, OP> SolverType;
83  typedef Teuchos::RCP<LinearProblem> LinearProblem_ptr;
84  typedef Teuchos::RCP<SolverType> SolverType_ptr;
85 
86 
87  virtual int doApplyInverse ( const vector_Type& X, vector_Type& Y ) const;
88  virtual void doSetOperator();
89  virtual void doSetPreconditioner();
90  virtual void doSetParameterList();
91  virtual void doResetSolver();
92  void allocateSolver ( const SolverManagerType& solverManagerType );
93  //! The linearProblem
94  LinearProblem_ptr M_linProblem;
95  //! The linearSolver
96  SolverType_ptr M_solverManager;
97  //! Cast to a Belos Preconditioner
98  Teuchos::RCP<Belos::EpetraPrecOp> M_belosPrec;
99 
100  static SolverManagerType getSolverManagerTypeFromString ( const std::string& str );
101  static PreconditionerSide getPreconditionerSideFromString ( const std::string& str );
102 
103 };
104 
105 inline SolverOperator* createBelosOperator()
106 {
107  return new BelosOperator();
108 }
109 namespace
110 {
112 }
113 
114 
115 } /*end namespace Operators */
116 } /*end namespace LifeV */
117 #endif /* _BELOSOPERATOR_HPP_ */