8 #include <BelosBlockCGSolMgr.hpp> 9 #include <BelosBlockGmresSolMgr.hpp> 10 #include <BelosGCRODRSolMgr.hpp> 11 #include <BelosGmresPolySolMgr.hpp> 12 #include <BelosPCPGSolMgr.hpp> 13 #include <BelosPseudoBlockCGSolMgr.hpp> 14 #include <BelosPseudoBlockGmresSolMgr.hpp> 15 #include <BelosRCGSolMgr.hpp> 16 #include <BelosMinresSolMgr.hpp> 17 #include <BelosTFQMRSolMgr.hpp> 19 #include<lifev/core/linear_algebra/BelosOperatorAlgebra.hpp> 33 M_name =
"BelosOperatorAlgebra";
39 Teuchos::RCP<vector_Type> Xcopy(
new vector_Type(X) );
41 bool set = M_linProblem->setProblem(Teuchos::rcp(&Y,
false), Xcopy);
44 std::cout << std::endl <<
"ERROR: Belos::LinearProblem failed to set up correctly!" << std::endl;
48 M_solverManager->setProblem ( M_linProblem );
53 Belos::ReturnType ret = M_solverManager->solve();
58 M_numIterations = M_solverManager->getNumIters();
60 if(ret == Belos::Converged)
69 M_linProblem->setOperator(M_oper);
74 M_belosPrec = Teuchos::rcp(
new Belos::EpetraPrecOp( M_prec ) );
76 std::string precSideStr( M_pList->get<std::string>(
"Preconditioner Side"));
84 M_linProblem->setLeftPrec(M_belosPrec);
87 M_linProblem->setRightPrec(M_belosPrec);
93 M_solverManager->setProblem(M_linProblem);
99 if(! M_pList->sublist(
"options").isParameter(
"Verbosity"))
100 M_pList->sublist(
"options").set(
"Verbosity", Belos::Errors + Belos::Warnings +
101 Belos::TimingDetails + Belos::StatusTestDetails );
103 std::string solverType(M_pList->get<std::string>(
"Solver Type"));
104 allocateSolver( (*S_solverManagerMap)[solverType]);
105 M_solverManager->setParameters(sublist(M_pList,
"options",
true));
107 std::string precSideStr( M_pList->get<std::string>(
"Preconditioner Side"));
115 M_linProblem->setLeftPrec(M_belosPrec);
118 M_linProblem->setRightPrec(M_belosPrec);
124 M_solverManager->setProblem(M_linProblem);
134 if ( !M_solverManager.is_null() )
136 M_solverManager.reset();
139 switch ( solverManagerType )
141 case NotAValidSolverManager:
142 std::cout<<
"Not a Valid Solver Manager \n";
147 M_solverManager = Teuchos::rcp(
new Belos::BlockCGSolMgr<Real,vector_Type,operator_Type>() );
151 M_solverManager = Teuchos::rcp(
new Belos::PseudoBlockCGSolMgr<Real,vector_Type,operator_Type>() );
154 M_solverManager = Teuchos::rcp(
new Belos::RCGSolMgr<Real,vector_Type,operator_Type>() );
157 M_solverManager = Teuchos::rcp(
new Belos::BlockGmresSolMgr<Real,vector_Type,operator_Type>() );
159 case PseudoBlockGmres:
160 M_solverManager = Teuchos::rcp(
new Belos::PseudoBlockGmresSolMgr<Real,vector_Type,operator_Type>() );
163 M_solverManager = Teuchos::rcp(
new Belos::GmresPolySolMgr<Real,vector_Type,operator_Type>() );
166 M_solverManager = Teuchos::rcp(
new Belos::GCRODRSolMgr<Real,vector_Type,operator_Type>() );
169 M_solverManager = Teuchos::rcp(
new Belos::PCPGSolMgr<Real,vector_Type,operator_Type>() );
172 M_solverManager = Teuchos::rcp(
new Belos::MinresSolMgr<Real,vector_Type,operator_Type>() );
176 M_solverManager = Teuchos::rcp(
new Belos::TFQMRSolMgr<Real,vector_Type,operator_Type>() );
185 (*map)[
"BlockCG"] = BlockCG;
186 (*map)[
"PseudoBlockCG"] = PseudoBlockCG;
188 (*map)[
"BlockGmres"] = BlockGmres;
189 (*map)[
"PseudoBlockGmres"] = PseudoBlockGmres;
190 (*map)[
"GmresPoly"] = GmresPoly;
191 (*map)[
"GCRODR"] = GCRODR;
192 (*map)[
"PCPG"] = PCPG;
193 (*map)[
"Minres"] = Minres;
194 (*map)[
"TFQMR"] = TFQMR;
202 (*map)[
"None"] = None;
203 (*map)[
"Right"] = Right;
204 (*map)[
"Left"] = Left;
206 (*map)[
"none"] = None;
207 (*map)[
"right"] = Right;
208 (*map)[
"left"] = Left;
void start()
Start the timer.
std::map< std::string, PreconditionerSide > precSideMap_Type
virtual int doApplyInverse(const vector_Type &X, vector_Type &Y) const
static precSideMap_Type * singletonPrecSideMap()
virtual void doSetPreconditioner()
static solverManagerMap_Type * singletonSolverManagerMap()
std::map< std::string, SolverManagerType > solverManagerMap_Type
void updateInverseJacobian(const UInt &iQuadPt)
virtual void doSetParameterList()
InvertibleOperator interface to Belos in Trilinos. BelosOperator requires the operator to be solved a...
Abstract class which defines the interface of an Invertible Linear Operator Algebra.
static std::unique_ptr< precSideMap_Type > S_precSideMap
double M_solutionTime
Time spent to solve the linear system.
static std::unique_ptr< solverManagerMap_Type > S_solverManagerMap
void allocateSolver(const SolverManagerType &solverManagerType)
virtual void doSetOperator()
Real diff()
Compute the difference in time between start and stop.
BelosOperatorAlgebra()
null constructor and destructor
Epetra_MultiVector vector_Type
void stop()
Stop the timer.