37 #include <lifev/core/algorithm/PreconditionerLinearSolver.hpp> 38 #include <lifev/core/util/LifeDebug.hpp> 39 #include <lifev/core/util/LifeChrono.hpp> 40 #include <lifev/core/filter/GetPot.hpp> 49 Preconditioner ( comm ),
52 M_precDataSection (
"" )
60 M_preconditioner.reset();
70 const std::string& section,
71 const std::string& subSection )
73 createLinearSolverList ( list, dataFile, section, subSection, M_displayer.comm()->MyPID() == 0 );
79 const std::string& section,
80 const std::string& subsection,
83 bool displayList = dataFile ( ( section +
"/displayList" ).data(),
false);
86 const std::string solverParamFile = dataFile ( ( section +
"/" + subsection +
"/parameters_file" ).data(),
"none" );
87 list = * ( Teuchos::getParametersFromXmlFile ( solverParamFile ) );
89 if ( displayList && verbose )
91 std::cout <<
"PreconditionerLinearSolver parameters list:" << std::endl;
92 std::cout <<
"-----------------------------" << std::endl;
93 list.print ( std::cout );
94 std::cout <<
"-----------------------------" << std::endl;
102 M_solver.reset (
new solver_Type (
this->M_displayer.comm() ) );
103 M_solver->setParameters ( M_list.sublist (
"LinearSolver" ) );
104 M_solver->setOperator ( matrix );
107 M_preconditioner.reset ( PRECFactory::instance().createObject ( M_precName ) );
108 ASSERT ( M_preconditioner.get() != 0,
" Preconditioner not set" );
109 M_preconditioner->setDataFromGetPot ( M_dataFile, M_precDataSection );
110 M_solver->setPreconditioner ( M_preconditioner );
111 M_solver->buildPreconditioner();
112 M_solver->setupSolverOperator();
113 M_solver->solver()->setUsedForPreconditioning ( M_printSubiterationCount );
136 M_solver->showMe (output);
145 return M_solver->solver()->SetUseTranspose (useTranspose);
151 return M_solver->solver()->UseTranspose();
157 return M_solver->solver()->Apply ( X, Y );
165 M_solver->solver()->ApplyInverse ( X, Y );
168 M_displayer.leaderPrint (
"> ", M_solver->numIterations(),
" subiterations\n" );
177 return M_solver->solver()->OperatorRangeMap();
183 return M_solver->solver()->OperatorDomainMap();
192 createLinearSolverList ( M_list, dataFile, section,
"LinearSolver", M_displayer.comm()->MyPID() == 0 );
193 M_printSubiterationCount =
this->M_list.get (
"Print Subiteration Count",
false );
194 M_precName =
this->M_list.get (
"Preconditioner",
"ML" );
195 M_precDataSection =
this->M_list.get (
"Preconditioner Data Section",
"" );
196 M_dataFile = dataFile;
212 return M_solver != nullptr ?
true :
false;
218 return M_solver->solver().get();
224 return M_solver->solver();
236 return "LinearSolver preconditioner";
bool isPreconditionerSet() const
Return true if the preconditioner is set.
const Epetra_Map & OperatorDomainMap() const
Return the Domain map of the operator.
std::shared_ptr< prec_raw_type > prec_type
SolverAztecOO - Class to wrap linear solver.
bool M_printSubiterationCount
Int SetUseTranspose(const bool useTranspose=false)
Set the matrix to be used transposed (or not)
bool M_preconditionerCreated
Epetra_Operator prec_raw_type
void setSolver(SolverAztecOO &)
Set the internal solver.
int32_type Int
Generic integer data.
void updateInverseJacobian(const UInt &iQuadPt)
virtual ~PreconditionerLinearSolver()
Destructor.
const Epetra_Map & OperatorRangeMap() const
Return the Range map of the operator.
prec_type preconditionerPtr()
Return a shared pointer on the preconditioner.
std::shared_ptr< solver_Type > solverPtr_Type
solverPtr_Type solverPtr()
Return a shared pointer on the solver.
virtual void showMe(std::ostream &output=std::cout) const
Show informations about the preconditioner.
virtual Real condest()
Return An estimation of the condition number of the preconditioner.
Int ApplyInverse(const Epetra_MultiVector &vector1, Epetra_MultiVector &vector2) const
Apply the inverse of the preconditioner on vector1 and store the result in vector2.
PreconditionerLinearSolver(std::shared_ptr< Epetra_Comm > comm=std::shared_ptr< Epetra_Comm >(new Epetra_MpiComm(MPI_COMM_WORLD)))
Default constructor.
Int Apply(const Epetra_MultiVector &vector1, Epetra_MultiVector &vector2) const
Apply the inverse of the preconditioner on vector1 and store the result in vector2.
virtual void createParametersList(list_Type &list, const GetPot &dataFile, const std::string §ion, const std::string &subSection)
Create the list of parameters of the preconditioner.
double Real
Generic real data.
static void createLinearSolverList(list_Type &list, const GetPot &dataFile, const std::string §ion, const std::string &subSection="SolverLinear", const bool &verbose=true)
Create the list of parameters of the preconditioner.
void setDataFromGetPot(const GetPot &dataFile, const std::string §ion)
Set the data of the preconditioner using a GetPot object.
virtual Int buildPreconditioner(operator_type &matrix)
Build a preconditioner based on the given matrix.
std::string preconditionerType()
Return the type of preconditioner.
virtual void resetPreconditioner()
Reset the preconditioner.
prec_raw_type * preconditioner()
Return a raw pointer on the preconditioner.
Teuchos::ParameterList list_Type
bool UseTranspose()
Return true if the preconditioner is transposed.
std::shared_ptr< operator_raw_type > operator_type