LifeV
SolverPolicyLinearSolver.cpp
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 SolverPolicyLinearSolver class
29  @brief This class contains all the informations necessary
30  to solve a linear system
31 
32  @author Gwenol Grandperrin <gwenol.grandperrin@epfl.ch>
33  @date 07-12-2012
34  */
35 
36 #include <lifev/navier_stokes/solver/NavierStokesSolver/SolverPolicyLinearSolver.hpp>
37 
38 #include <string>
39 #include <lifev/core/util/LifeChrono.hpp>
40 
41 namespace LifeV
42 {
43 
44 void
45 SolverPolicyLinearSolver::initSolver ( Teuchos::ParameterList& list )
46 {
47  // Parameter list for the solver
48  std::string resourcesPath = list.get ( "Resources path", "./Resources" );
49  resourcesPath.append ("/");
50  const std::string solverParamFile = list.get ( "Parameters file", "SolverParamList.xml" );
51  Teuchos::RCP< Teuchos::ParameterList > solverParameters = Teuchos::rcp ( new Teuchos::ParameterList );
52  solverParameters = Teuchos::getParametersFromXmlFile ( resourcesPath + solverParamFile );
53 
54  // Solver initialization
55  displayer().leaderPrint ( "\n[Solver initialization]\n" );
56  M_solver.reset ( new solver_Type );
57  M_solver->setCommunicator ( comm() );
58 
59  displayer().leaderPrint ( "Setting up the solver... " );
60  M_solver->setParameters ( *solverParameters );
61  M_solver->showMe();
62 }
63 
64 void
65 SolverPolicyLinearSolver::setPreconditioner ( preconditionerPtr_Type preconditionerPtr )
66 {
67  M_solver->setPreconditioner ( preconditionerPtr );
68 }
69 
70 SolverPolicyLinearSolver::preconditionerPtr_Type
71 SolverPolicyLinearSolver::preconditioner()
72 {
73  return M_solver->preconditioner();
74 }
75 
76 
77 int
78 SolverPolicyLinearSolver::solve ( matrixPtr_Type systemMatrix,
79  vectorPtr_Type rhs,
80  vectorPtr_Type solution )
81 {
82  M_solver->setOperator ( systemMatrix );
83  M_solver->setRightHandSide ( rhs );
84  return M_solver->solve ( solution );
85 }
86 
87 } // namespace LifeV
void initSolver(Teuchos::ParameterList &list)