149 typedef typename Backend::value_type value_type;
150 typedef typename math::scalar_of<value_type>::type scalar_type;
151 typedef Backend backend_type;
152 using BackendType = backend_type;
154 eSolverType m_solver_type;
157 explicit SolverRuntime(
size_t n, params prm = params(),
158 const backend_params& bprm = backend_params(),
159 const InnerProduct& inner_product = InnerProduct())
160 : m_solver_type(prm.get(
"type", eSolverType::bicgstab))
162 if (!prm.erase(
"type"))
163 ARCCORE_ALINA_PARAM_MISSING(
"type");
165 switch (m_solver_type) {
167#define ARCCORE_ALINA_RUNTIME_SOLVER(type) \
168 case eSolverType::type: \
169 m_solver = new type<Backend, InnerProduct>(n, prm, bprm, inner_product); \
172 ARCCORE_ALINA_ALL_RUNTIME_SOLVER();
174#undef ARCCORE_ALINA_RUNTIME_SOLVER
177 ARCCORE_FATAL(
"Unsupported solver type type={0}", m_solver_type);
186 template <
class Matrix,
class Precond,
class Vec1,
class Vec2>
187 SolverResult operator()(
const Matrix& A,
const Precond& P,
const Vec1& rhs, Vec2&& x)
const
189 switch (m_solver_type) {
191#define ARCCORE_ALINA_RUNTIME_SOLVER(type) \
192 case eSolverType::type: \
193 return static_cast<type<Backend, InnerProduct>*>(m_solver)->operator()(A, P, rhs, x)
195 ARCCORE_ALINA_ALL_RUNTIME_SOLVER();
197#undef ARCCORE_ALINA_RUNTIME_SOLVER
200 ARCCORE_FATAL(
"Unsupported solver type type={0}", m_solver_type);
204 template <
class Precond,
class Vec1,
class Vec2>
205 SolverResult operator()(
const Precond& P,
const Vec1& rhs, Vec2&& x)
const
207 return (*
this)(P.system_matrix(), P, rhs, x);
210 friend std::ostream& operator<<(std::ostream& os,
const SolverRuntime& w)
212 switch (w.m_solver_type) {
214#define ARCCORE_ALINA_RUNTIME_SOLVER(type) \
215 case eSolverType::type: \
216 return os << *static_cast<type<Backend, InnerProduct>*>(w.m_solver)
218 ARCCORE_ALINA_ALL_RUNTIME_SOLVER();
220#undef ARCCORE_ALINA_RUNTIME_SOLVER
223 ARCCORE_FATAL(
"Unsupported solver type type={0}", w.m_solver_type);
229 return m_solver->bytes();