9#include <kernel/solver/iterative.hpp> 
   42      typedef Matrix_ MatrixType;
 
   43      typedef Filter_ FilterType;
 
   44      typedef typename MatrixType::VectorTypeR VectorType;
 
   45      typedef typename MatrixType::DataType DataType;
 
   56      VectorType 
_vec_r, _vec_s, _vec_q, _vec_z;
 
   71      explicit PMR(
const MatrixType& matrix, 
const FilterType& filter,
 
   72        std::shared_ptr<PrecondType> precond = 
nullptr) :
 
  103        const MatrixType& matrix, 
const FilterType& filter,
 
  104        std::shared_ptr<PrecondType> precond = 
nullptr) :
 
  105        BaseClass(
"PMR", section_name, section, precond),
 
  122        _vec_r = this->_system_matrix.create_vector_r();
 
  123        _vec_s = this->_system_matrix.create_vector_r();
 
  124        _vec_q = this->_system_matrix.create_vector_r();
 
  125        _vec_z = this->_system_matrix.create_vector_r();
 
  130        this->_vec_z.clear();
 
  131        this->_vec_q.clear();
 
  132        this->_vec_s.clear();
 
  133        this->_vec_r.clear();
 
  137      virtual Status apply(VectorType& vec_cor, 
const VectorType& vec_def)
 override 
  140        this->_vec_r.copy(vec_def);
 
  146        this->
_status = _apply_intern(vec_cor);
 
  155      virtual Status correct(VectorType& vec_sol, 
const VectorType& vec_rhs)
 override 
  158        this->_system_matrix.apply(this->_vec_r, vec_sol, vec_rhs, -DataType(1));
 
  159        this->_system_filter.filter_def(this->_vec_r);
 
  162        this->
_status = _apply_intern(vec_sol);
 
  172      virtual Status _apply_intern(VectorType& vec_sol)
 
  174        IterationStats pre_iter(*
this);
 
  175        Statistics::add_solver_expression(std::make_shared<ExpressionStartSolve>(this->
name()));
 
  177        const MatrixType& matrix(this->_system_matrix);
 
  178        const FilterType& filter(this->_system_filter);
 
  179        VectorType& vec_r(this->_vec_r);
 
  180        VectorType& vec_s(this->_vec_s);
 
  181        VectorType& vec_q(this->_vec_q);
 
  182        VectorType& vec_z(this->_vec_z);
 
  189          Statistics::add_solver_expression(std::make_shared<ExpressionEndSolve>(this->
name(), status, this->
get_num_iter()));
 
  205          IterationStats stat(*
this);
 
  208          matrix.apply(vec_q, vec_s);
 
  209          filter.filter_def(vec_q);
 
  221          DataType alpha = vec_q.dot(vec_s) / vec_z.dot(vec_q);
 
  225          vec_sol.axpy(vec_s, alpha);
 
  229          vec_r.axpy(vec_q, -alpha);
 
  236            Statistics::add_solver_expression(std::make_shared<ExpressionEndSolve>(this->
name(), status, this->
get_num_iter()));
 
  242          vec_s.axpy(vec_z, -alpha);
 
  266    template<
typename Matrix_, 
typename Filter_>
 
  267    inline std::shared_ptr<PMR<Matrix_, Filter_>> 
new_pmr(
 
  268      const Matrix_& matrix, 
const Filter_& filter,
 
  271      return std::make_shared<PMR<Matrix_, Filter_>>(matrix, filter, precond);
 
  295    template<
typename Matrix_, 
typename Filter_>
 
  296    inline std::shared_ptr<PMR<Matrix_, Filter_>> 
new_pmr(
 
  298      const Matrix_& matrix, 
const Filter_& filter,
 
  301      return std::make_shared<PMR<Matrix_, Filter_>>(section_name, section, matrix, filter, precond);
 
A class organizing a tree of key-value pairs.
Index get_num_iter() const
Returns number of performed iterations.
Status _status
current status of the solver
void _set_comm_by_matrix(const Matrix_ &matrix)
Sets the communicator for the solver from a matrix.
virtual Status _set_new_defect(const VectorType &vec_def, const VectorType &vec_sol)
Internal function: sets the new (next) defect vector.
virtual void plot_summary() const
Plot a summary of the last solver run.
virtual Status _set_initial_defect(const VectorType &vec_def, const VectorType &vec_sol)
Internal function: sets the initial defect vector.
(Preconditioned) Minimal-Residual-Iteration solver implementation
VectorType _vec_r
temporary vectors
const FilterType & _system_filter
the filter for the solver
virtual void done_symbolic() override
Symbolic finalization method.
virtual void init_symbolic() override
Symbolic initialization method.
PMR(const MatrixType &matrix, const FilterType &filter, std::shared_ptr< PrecondType > precond=nullptr)
Constructor.
const MatrixType & _system_matrix
the matrix for the solver
PMR(const String §ion_name, const PropertyMap *section, const MatrixType &matrix, const FilterType &filter, std::shared_ptr< PrecondType > precond=nullptr)
Constructor using a PropertyMap.
virtual String name() const override
Returns a descriptive string.
Abstract base-class for preconditioned iterative solvers.
virtual void init_symbolic() override
Symbolic initialization method.
bool _apply_precond(VectorType &vec_cor, const VectorType &vec_def, const Filter_ &filter)
Applies the preconditioner onto a defect vector.
virtual void done_symbolic() override
Symbolic finalization method.
Polymorphic solver interface.
String class implementation.
Status
Solver status return codes enumeration.
@ progress
continue iteration (internal use only)
@ undefined
undefined status
@ aborted
premature abort (solver aborted due to internal errors or preconditioner failure)
std::shared_ptr< Descent< Matrix_, Filter_ > > new_pmr(const String §ion_name, const PropertyMap *section, const Matrix_ &matrix, const Filter_ &filter, std::shared_ptr< SolverBase< typename Matrix_::VectorTypeL > > precond=nullptr)
Creates a new Descent solver object using a PropertyMap.