16 #ifndef dealii_solver_qmrs_h 17 #define dealii_solver_qmrs_h 19 #include <deal.II/base/config.h> 20 #include <deal.II/lac/solver.h> 21 #include <deal.II/lac/solver_control.h> 22 #include <deal.II/base/logstream.h> 24 #include <deal.II/base/subscriptor.h> 28 DEAL_II_NAMESPACE_OPEN
91 template <
typename VectorType = Vector<
double> >
174 template <
typename MatrixType,
typename PreconditionerType>
176 solve (
const MatrixType &A,
179 const PreconditionerType &preconditioner);
190 const VectorType &d)
const;
207 double last_residual;
210 const double last_residual);
217 template <
typename MatrixType,
typename PreconditionerType>
222 const PreconditionerType &preconditioner,
241 template <
class VectorType>
243 const double last_residual)
246 last_residual (last_residual)
251 template <
class VectorType>
254 const AdditionalData &data)
256 Solver<VectorType> (cn, mem),
257 additional_data (data),
262 template <
class VectorType>
264 const AdditionalData &data)
267 additional_data (data),
272 template <
class VectorType>
277 const VectorType &)
const 281 template <
class VectorType>
282 template <
typename MatrixType,
typename PreconditionerType>
287 const PreconditionerType &preconditioner)
304 Vr->reinit (x,
true);
305 Vu->reinit (x,
true);
306 Vq->reinit (x,
true);
307 Vt->reinit (x,
true);
308 Vd->reinit (x,
true);
317 deallog <<
"Restart step " << step << std::endl;
318 state = iterate (A, x, b, preconditioner, *Vr, *Vu, *Vq, *Vt, *Vd);
329 template <
class VectorType>
330 template <
typename MatrixType,
typename PreconditionerType>
335 const PreconditionerType &preconditioner,
347 double tau, rho, theta = 0;
355 if (additional_data.left_preconditioning)
358 preconditioner.vmult (t, r);
365 preconditioner.vmult (q, t);
369 res = std::sqrt (tau);
384 const double sigma = q * t;
387 if (additional_data.breakdown_testing ==
true 388 && std::fabs (sigma) < additional_data.breakdown_threshold)
392 const double alpha = rho / sigma;
398 const double theta_old = theta;
401 if (additional_data.left_preconditioning)
404 preconditioner.vmult (t, r);
414 const double psi = 1. / (1. + theta);
418 d.sadd (psi * theta_old, psi * alpha, q);
421 print_vectors (step, x, r, d);
425 res = std::sqrt ((it + 1) * tau);
427 if (res < additional_data.solver_tolerance)
433 state = this->iteration_status (step, res, x);
436 return IterationResult (state, res);
441 if (additional_data.breakdown_testing ==
true 442 && std::fabs (sigma) < additional_data.breakdown_threshold)
445 const double rho_old = rho;
448 if (additional_data.left_preconditioning)
456 preconditioner.vmult (u, t);
461 const double beta = rho / rho_old;
469 DEAL_II_NAMESPACE_CLOSE
Stop iteration, goal not reached.
bool left_preconditioning
#define AssertThrow(cond, exc)
virtual void print_vectors(const unsigned int step, const VectorType &x, const VectorType &r, const VectorType &d) const
SolverQMRS(SolverControl &cn, VectorMemory< VectorType > &mem, const AdditionalData &data=AdditionalData())
Stop iteration, goal reached.
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
void solve(const MatrixType &A, VectorType &x, const VectorType &b, const PreconditionerType &preconditioner)
AdditionalData(const bool left_preconditioning=false, const double solver_tolerance=1.e-9, const bool breakdown_testing=true, const double breakdown_threshold=1.e-16)
IterationResult iterate(const MatrixType &A, VectorType &x, const VectorType &b, const PreconditionerType &preconditioner, VectorType &r, VectorType &u, VectorType &q, VectorType &t, VectorType &d)
double breakdown_threshold
AdditionalData additional_data