18 class CxrPreconditioner
21 using AlgebraType = AlgebraT;
22 using MatrixType = MatrixT;
23 using VectorType = VectorT;
24 using RelaxSolverType = RelaxSolverT;
25 using CxrSolverType = CxrSolverT;
26 using CxrOpType = CxrOpT;
29 CxrPreconditioner(AlgebraType& alg,
30 MatrixType
const& matrix,
32 CxrSolverType* cxr_solver,
33 RelaxSolverType* relax_solver,
34 ITraceMng* trace_mng =
nullptr
38 , m_relax_solver(relax_solver)
39 , m_cxr_solver(cxr_solver)
41 , m_trace_mng(trace_mng)
45 virtual ~CxrPreconditioner()
52 m_cxr_op->computeCxrMatrix(m_algebra) ;
53 auto& cxr_matrix = m_cxr_op->getCxrMatrix() ;
55 m_relax_solver->init() ;
58 m_cxr_solver->init() ;
59 m_cxr_solver->init(cxr_matrix) ;
60 m_cxr_solver->start() ;
62 m_algebra.allocate(AlgebraType::resource(cxr_matrix),m_x_Cxr,m_y_Cxr,m_r_Cxr);
65 void init(VectorType
const& diag_scale)
67 m_cxr_op->computeCxrMatrix(m_algebra, diag_scale) ;
68 auto& cxr_matrix = m_cxr_op->getCxrMatrix() ;
70 m_relax_solver->init() ;
73 m_cxr_solver->init() ;
74 m_cxr_solver->init(cxr_matrix) ;
75 m_cxr_solver->start() ;
77 m_algebra.allocate(AlgebraType::resource(cxr_matrix),m_x_Cxr,m_y_Cxr,m_r_Cxr);
86 void solve(AlgebraType& alg,
99 m_relax_solver->solve(alg,y,x);
102 m_cxr_op->apply(alg,x,m_x_Cxr);
104 m_cxr_op->get(alg,y,m_r_Cxr);
108 alg.scal(-1.,m_x_Cxr) ;
109 alg.axpy(1.,m_x_Cxr,m_r_Cxr) ;
111 m_cxr_op->scal(alg,m_r_Cxr) ;
116 m_cxr_op->get(alg,x,m_r_Cxr);
117 m_cxr_op->scal(alg,m_r_Cxr) ;
125 alg.copy(m_r_Cxr,m_x_Cxr) ;
126 m_cxr_solver->solve(m_x_Cxr,m_y_Cxr);
130 m_cxr_op->combine(alg,m_y_Cxr,x);
132 m_cxr_op->copy(alg,m_y_Cxr,x);
137 bool m_use_diag_scale = false ;
138 AlgebraType& m_algebra ;
139 MatrixType
const& m_matrix ;
141 mutable VectorType m_x_Cxr;
143 mutable VectorType m_y;
144 mutable VectorType m_y_Cxr;
146 mutable VectorType m_r;
147 mutable VectorType m_r_Cxr;
149 RelaxSolverType* m_relax_solver =
nullptr;
150 CxrSolverType* m_cxr_solver =
nullptr;
151 CxrOpType* m_cxr_op =
nullptr;
153 ITraceMng* m_trace_mng = nullptr ;