36 #include<lifev/core/operator
/BelosOperator.hpp> 38 #include <BelosBlockCGSolMgr.hpp> 39 #include <BelosBlockGmresSolMgr.hpp> 40 #include <BelosGCRODRSolMgr.hpp> 41 #include <BelosGmresPolySolMgr.hpp> 42 #include <BelosPCPGSolMgr.hpp> 43 #include <BelosPseudoBlockCGSolMgr.hpp> 44 #include <BelosPseudoBlockGmresSolMgr.hpp> 45 #ifdef HAVE_TRILINOS_GT_10_6 46 #include <BelosMinresSolMgr.hpp> 48 #include <BelosRCGSolMgr.hpp> 49 #include <BelosTFQMRSolMgr.hpp> 50 #include "Teuchos_RCPBoostSharedPtrConversions.hpp" 61 M_name =
"BelosOperator";
66 M_belosPrec = Teuchos::null;
67 M_linProblem = Teuchos::null;
68 M_solverManager = Teuchos::null;
74 Teuchos::RCP<vector_Type> Xcopy (
new vector_Type ( X ) );
76 bool set = M_linProblem->setProblem ( Teuchos::rcp ( &Y,
false ), Xcopy );
79 std::cout << std::endl <<
"SLV- ERROR: Belos::LinearProblem failed to set up correctly!" << std::endl;
83 M_solverManager->setProblem ( M_linProblem );
87 Belos::ReturnType ret = M_solverManager->solve();
90 M_numIterations = M_solverManager->getNumIters();
93 if ( M_solverManager->isLOADetected() )
102 if ( ret == Belos::Converged )
117 Teuchos::RCP<OP> tmpPtr ( M_oper.get(),
false );
118 M_linProblem->setOperator ( tmpPtr );
123 Teuchos::RCP<OP> tmpPtr ( M_prec.get(),
false );
124 M_belosPrec = Teuchos::rcp (
new Belos::EpetraPrecOp ( tmpPtr ),
true );
133 if ( !M_pList->sublist (
"Trilinos: Belos List" ).isParameter (
"Verbosity" ) )
134 M_pList->sublist (
"Trilinos: Belos List" ).set (
"Verbosity", Belos::Errors + Belos::Warnings +
135 Belos::TimingDetails + Belos::StatusTestDetails );
139 M_pList->sublist (
"Trilinos: Belos List" ).set (
"Convergence Tolerance", M_tolerance );
142 std::string solverType ( M_pList->get<std::string> (
"Solver Manager Type" ) );
144 M_solverManager->setParameters ( sublist ( M_pList,
"Trilinos: Belos List",
true ) );
146 std::string precSideStr ( M_pList->get<std::string> (
"Preconditioner Side" ) );
154 M_linProblem->setLeftPrec ( M_belosPrec );
157 M_linProblem->setRightPrec ( M_belosPrec );
171 if ( !M_solverManager.is_null() )
173 M_solverManager = Teuchos::null;
176 switch ( solverManagerType )
178 case NotAValidSolverManager:
179 std::cout <<
"SLV- ERROR: Not a Valid Solver Manager \n";
184 M_solverManager = rcp (
new Belos::BlockCGSolMgr<Real, vector_Type, operator_Type>() );
188 M_solverManager = rcp (
new Belos::PseudoBlockCGSolMgr<Real, vector_Type, operator_Type>() );
191 M_solverManager = rcp (
new Belos::RCGSolMgr<Real, vector_Type, operator_Type>() );
194 M_solverManager = rcp (
new Belos::BlockGmresSolMgr<Real, vector_Type, operator_Type>() );
196 case PseudoBlockGmres:
197 M_solverManager = rcp (
new Belos::PseudoBlockGmresSolMgr<Real, vector_Type, operator_Type>() );
200 M_solverManager = rcp (
new Belos::GmresPolySolMgr<Real, vector_Type, operator_Type>() );
203 M_solverManager = rcp (
new Belos::GCRODRSolMgr<Real, vector_Type, operator_Type>() );
206 M_solverManager = rcp (
new Belos::PCPGSolMgr<Real, vector_Type, operator_Type>() );
210 M_solverManager = rcp (
new Belos::TFQMRSolMgr<Real, vector_Type, operator_Type>() );
212 #ifdef HAVE_TRILINOS_GT_10_6 215 M_solverManager = rcp (
new Belos::MinresSolMgr<Real, vector_Type, operator_Type>() );
227 if ( str ==
"BlockCG" )
231 else if ( str ==
"PseudoBlockCG" )
235 else if ( str ==
"RCG" )
239 else if ( str ==
"BlockGmres" )
243 else if ( str ==
"PseudoBlockGmres" )
247 else if ( str ==
"GmresPoly" )
251 else if ( str ==
"GCRODR" )
255 else if ( str ==
"PCPG" )
259 else if ( str ==
"TFQMR" )
263 else if ( str ==
"MINRES" )
276 if ( str ==
"Right" || str ==
"right" )
280 else if ( str ==
"Left" || str ==
"left" )
293 M_solverManager->reset (Belos::Problem);
294 M_belosPrec = Teuchos::null;
SolverOperatorStatusType M_lossOfAccuracy
Status to see if there is a loss of accuracy.
SolverOperator(std::shared_ptr< Epetra_Comm > comm=std::shared_ptr< Epetra_Comm >(new Epetra_MpiComm(MPI_COMM_WORLD)))
Class which defines the interface of an Invertible Linear Operator through belos. ...
virtual void doSetOperator()
static PreconditionerSide getPreconditionerSideFromString(const std::string &str)
void updateInverseJacobian(const UInt &iQuadPt)
virtual void doResetSolver()
SolverOperatorStatusType M_converged
Status to see if the solver has converged.
static SolverManagerType getSolverManagerTypeFromString(const std::string &str)
virtual void doSetParameterList()
virtual int doApplyInverse(const vector_Type &X, vector_Type &Y) const
Epetra_MultiVector vector_Type
virtual void doSetPreconditioner()
BelosOperator()
null constructor and destructor
Real M_tolerance
Solver tolerance.
void allocateSolver(const SolverManagerType &solverManagerType)