20 #ifndef __linear_solver_h__
21 #define __linear_solver_h__
23 #include <boost/mpi/communicator.hpp>
25 #include <feel/feelcore/parameter.hpp>
26 #include <feel/feelalg/enums.hpp>
28 #include <feel/feelcore/traits.hpp>
32 namespace mpi=boost::mpi;
51 typedef boost::shared_ptr<SolverLinear<T> > self_ptrtype;
54 typedef typename type_traits<T>::real_type real_type;
56 typedef boost::shared_ptr<Preconditioner<T> > preconditioner_ptrtype;
61 SolverLinear ( WorldComm
const& worldComm = Environment::worldComm() );
66 SolverLinear ( po::variables_map
const&
vm, WorldComm
const& worldComm = Environment::worldComm() );
73 WorldComm
const& worldComm()
const
77 void setWorldComm( WorldComm
const& worldComm )
79 M_worldComm=worldComm;
100 virtual void init () = 0;
105 po::variables_map
vm()
const
153 std::string
const&
prefix()
const{
return M_prefix; }
158 void setPrefix( std::string
const& p ) { M_prefix = p; }
164 BOOST_PARAMETER_MEMBER_FUNCTION( (
void ),
168 ( rtolerance,(
double ) )
172 ( atolerance,(
double ), 1e-50 )
173 ( dtolerance,(
double ), 1e5 )
220 std::cerr<<
"Preconditioner must be attached before the solver is initialized!"<<std::endl;
229 M_fieldSplit_type = fst;
234 return M_fieldSplit_type;
258 return M_prec_matrix_structure;
271 M_prec_matrix_structure = mstruct;
278 void setShowKSPMonitor(
bool b ) { M_showKSPMonitor=b; }
284 void setShowKSPConvergedReason(
bool b ) { M_showKSPConvergedReason=b; }
301 boost::tuple<bool,unsigned int, real_type>
302 solve ( MatrixSparse<T>
const& mat,
305 const double tolerance,
306 const unsigned int maxit,
327 boost::tuple<bool,unsigned int, real_type>
328 solve ( MatrixSparse<T>
const& mat,
329 MatrixSparse<T>
const& prec,
332 const double tolerance,
333 const unsigned int maxit,
351 WorldComm M_worldComm;
356 po::variables_map M_vm;
358 std::string M_prefix;
403 bool M_showKSPMonitor;
404 bool M_showKSPConvergedReason;
411 template <
typename T>
414 M_worldComm( worldComm ),
415 M_solver_type ( GMRES ),
416 M_preconditioner_type ( LU_PRECOND ),
418 M_is_initialized ( false ),
419 M_prec_matrix_structure( SAME_NONZERO_PATTERN ),
420 M_showKSPMonitor( false ),
421 M_showKSPConvergedReason( false )
425 template <
typename T>
428 M_worldComm( worldComm ),
430 M_solver_type ( GMRES ),
431 M_preconditioner_type ( LU_PRECOND ),
432 M_is_initialized ( false ),
433 M_prec_matrix_structure( SAME_NONZERO_PATTERN ),
434 M_showKSPMonitor( false ),
435 M_showKSPConvergedReason( false )
441 template <
typename T>
451 #endif // #ifdef __solver_h__
bool M_is_initialized
Definition: solverlinear.hpp:399
size_type maxIterations() const
Definition: solverlinear.hpp:145
Definition: solverlinear.hpp:33
value_type dTolerance() const
Definition: solverlinear.hpp:121
SolverType solverType() const
Definition: solverlinear.hpp:137
PreconditionerType
Definition: feelalg/enums.hpp:114
SolverLinear(WorldComm const &worldComm=Environment::worldComm())
Definition: solverlinear.hpp:413
double M_rtolerance
relative tolerance
Definition: solverlinear.hpp:361
bool initialized() const
Definition: solverlinear.hpp:86
std::string const & prefix() const
Definition: solverlinear.hpp:153
SolverType M_solver_type
Definition: solverlinear.hpp:375
MatSolverPackageType matSolverPackageType() const
Definition: solverlinear.hpp:247
MatSolverPackageType M_matSolverPackage_type
Definition: solverlinear.hpp:393
bool showKSPMonitor() const
Definition: solverlinear.hpp:277
MatrixStructure
Definition: feelalg/enums.hpp:146
void setSolverType(const SolverType st)
Definition: solverlinear.hpp:185
void attachPreconditioner(preconditioner_ptrtype preconditioner)
Definition: solverlinear.hpp:216
po::variables_map vm() const
Definition: solverlinear.hpp:105
SolverType
Definition: feelalg/enums.hpp:89
FieldSplitType
Definition: feelalg/enums.hpp:138
virtual boost::tuple< bool, unsigned int, real_type > solve(MatrixSparse< T > const &mat, Vector< T > &x, Vector< T > const &b, const double tolerance, const unsigned int maxit, bool transpose)=0
void setPreconditionerType(const PreconditionerType pct)
Definition: solverlinear.hpp:204
size_type M_maxit
maximum number of iterations
Definition: solverlinear.hpp:370
virtual void setPrecMatrixStructure(MatrixStructure mstruct)
Definition: solverlinear.hpp:265
void setMatSolverPackageType(const MatSolverPackageType mspackt)
Definition: solverlinear.hpp:240
virtual ~SolverLinear()
Definition: solverlinear.hpp:443
size_t size_type
Indices (starting from 0)
Definition: feelcore/feel.hpp:319
preconditioner_ptrtype M_preconditioner
Definition: solverlinear.hpp:385
Definition: solverlinear.hpp:45
virtual MatrixStructure precMatrixStructure() const
Definition: solverlinear.hpp:256
Definition: matrixsparse.hpp:76
value_type rTolerance() const
Definition: solverlinear.hpp:113
PreconditionerType M_preconditioner_type
Definition: solverlinear.hpp:380
value_type aTolerance() const
Definition: solverlinear.hpp:129
bool showKSPConvergedReason() const
Definition: solverlinear.hpp:283
double M_atolerance
absolute tolerance
Definition: solverlinear.hpp:367
PreconditionerType preconditionerType() const
Definition: solverlinear.hpp:193
void setPrefix(std::string const &p)
Definition: solverlinear.hpp:158
virtual void clear()
Definition: solverlinear.hpp:95
void setInitialized(bool init)
Definition: solverlinear.hpp:343
double M_dtolerance
divergence tolerance
Definition: solverlinear.hpp:364