37 #ifndef _LINEARSOLVER_HPP 38 #define _LINEARSOLVER_HPP 1
44 #include <Epetra_ConfigDefs.h> 46 #include <Epetra_MpiComm.h> 48 #include <Epetra_SerialComm.h> 51 #include <BelosConfigDefs.hpp> 52 #include <BelosLinearProblem.hpp> 53 #include <BelosEpetraAdapter.hpp> 54 #include <BelosEpetraOperator.h> 55 #include <BelosOutputManager.hpp> 56 #include <BelosMVOPTester.hpp> 57 #include <BelosBlockCGSolMgr.hpp> 58 #include <BelosBlockGmresSolMgr.hpp> 60 #include <BelosGmresPolySolMgr.hpp> 61 #include <BelosPCPGSolMgr.hpp> 62 #include <BelosPseudoBlockCGSolMgr.hpp> 63 #include <BelosPseudoBlockGmresSolMgr.hpp> 64 #include <BelosRCGSolMgr.hpp> 65 #include <BelosTFQMRSolMgr.hpp> 67 #include <Teuchos_ParameterList.hpp> 70 #include <lifev/core/LifeV.hpp> 72 #include <lifev/core/util/LifeDebug.hpp> 73 #include <lifev/core/util/LifeChrono.hpp> 74 #include <lifev/core/util/Displayer.hpp> 75 #include <lifev/core/array/VectorEpetra.hpp> 76 #include <lifev/core/array/MatrixEpetra.hpp> 77 #include <lifev/core/algorithm/Preconditioner.hpp> 78 #include <lifev/core/filter/GetPot.hpp> 79 #include <lifev/core/operator
/SolverOperator.hpp> 80 #include <lifev/core/operator
/BelosOperator.hpp> 81 #include <lifev/core/operator
/AztecooOperator.hpp> 101 typedef LinearSolver solver_Type;
102 typedef Epetra_MultiVector multiVector_Type;
103 typedef std::shared_ptr<multiVector_Type> multiVectorPtr_Type;
104 typedef Epetra_Operator operator_Type;
105 typedef std::shared_ptr<operator_Type> operatorPtr_Type;
106 typedef Operators::SolverOperator SolverOperator_Type;
107 typedef std::shared_ptr< SolverOperator_Type > SolverOperatorPtr_Type;
108 typedef MatrixEpetra<
Real> matrix_Type;
109 typedef std::shared_ptr<matrix_Type> matrixPtr_Type;
110 typedef VectorEpetra vector_Type;
111 typedef std::shared_ptr<VectorEpetra> vectorPtr_Type;
112 typedef Preconditioner preconditioner_Type;
113 typedef std::shared_ptr<preconditioner_Type> preconditionerPtr_Type;
114 typedef Teuchos::ParameterList parameterList_Type;
115 typedef Teuchos::RCP< parameterList_Type > parameterListPtr_Type;
117 enum SolverType { UndefinedSolver, Belos, AztecOO };
131 LinearSolver (
const std::shared_ptr<Epetra_Comm> commPtr );
151 Int solve ( vectorPtr_Type solutionPtr );
158 Real computeResidual ( vectorPtr_Type solutionPtr );
161 std::string printStatus();
168 void setPreconditionerFromGetPot (
const GetPot& dataFile,
const std::string& section );
176 void buildPreconditioner();
183 void resetPreconditioner();
186 bool isPreconditionerSet()
const;
192 void showMe ( std::ostream& output = std::cout )
const;
195 void setupSolverOperator();
208 void setSolverType (
const SolverType& solverType );
214 void setCommunicator (
const std::shared_ptr<Epetra_Comm> commPtr );
220 void setOperator ( matrixPtr_Type matrixPtr );
226 void setOperator ( operatorPtr_Type operPtr );
232 void setRightHandSide (
const vectorPtr_Type rhsPtr );
238 void setPreconditioner ( preconditionerPtr_Type preconditionerPtr );
244 void setPreconditioner ( operatorPtr_Type preconditionerPtr );
250 void setBaseMatrixForPreconditioner ( matrixPtr_Type baseMatrixPtr );
257 void setParameters (
const Teuchos::ParameterList& list );
266 void setParameter (
const std::string& name, T value );
269 void resetParameters();
275 void setReusePreconditioner (
const bool reusePreconditioner );
284 void setQuitOnFailure (
const bool enable );
290 void setTolerance (
const Real& tolerance );
298 Int numIterations()
const;
304 Real recursiveResidual();
307 preconditionerPtr_Type& preconditioner();
310 Teuchos::ParameterList& parametersList();
313 SolverOperatorPtr_Type solver();
316 std::shared_ptr<Displayer> displayer();
319 Int maxItersForReuse()
const;
322 bool reusePreconditioner()
const;
325 bool quitOnFailure()
const;
331 SolverOperator_Type::SolverOperatorStatusType hasReachedMaxNumIters()
const;
334 SolverOperator_Type::SolverOperatorStatusType isLossOfAccuracyDetected()
const;
337 SolverOperator_Type::SolverOperatorStatusType hasConverged()
const;
348 operatorPtr_Type M_operator;
349 matrixPtr_Type M_matrix;
350 matrixPtr_Type M_baseMatrixForPreconditioner;
351 vectorPtr_Type M_rhs;
353 preconditionerPtr_Type M_preconditioner;
354 operatorPtr_Type M_preconditionerOperator;
356 SolverType M_solverType;
357 SolverOperatorPtr_Type M_solverOperator;
359 Teuchos::ParameterList M_parameterList;
360 std::shared_ptr<Displayer> M_displayer;
364 bool M_reusePreconditioner;
365 bool M_quitOnFailure;
369 SolverOperator_Type::SolverOperatorStatusType M_lossOfPrecision;
370 SolverOperator_Type::SolverOperatorStatusType M_maxNumItersReached;
371 SolverOperator_Type::SolverOperatorStatusType M_converged;
379 LinearSolver::setParameter (
const std::string& name, T value )
381 M_parameterList.set ( name, value );
384 namespace defaultParameterLists
393 Teuchos::ParameterList
394 belosParameterList();
403 Teuchos::ParameterList
404 aztecOOParameterList();
int32_type Int
Generic integer data.
double Real
Generic real data.