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
70 template <
typename VectorType = Vector<
double> >
128 template<
typename MatrixType,
typename PreconditionerType>
130 solve (
const MatrixType &A,
133 const PreconditionerType &precondition);
143 const VectorType &d)
const;
166 const VectorType *
Vb;
190 double last_residual;
193 const double last_residual);
201 template<
typename MatrixType,
typename PreconditionerType>
204 const PreconditionerType &precondition);
217 template<
class VectorType>
219 const double last_residual)
222 last_residual (last_residual)
226 template<
class VectorType>
229 const AdditionalData &data)
231 Solver<VectorType>(cn,mem),
232 additional_data(data)
237 template<
class VectorType>
239 const AdditionalData &data)
242 additional_data(data)
247 template<
class VectorType>
251 return std::sqrt(res2);
256 template<
class VectorType>
261 const VectorType &)
const 266 template<
class VectorType>
267 template<
typename MatrixType,
typename PreconditionerType>
272 const PreconditionerType &precondition)
274 deallog.
push(
"QMRS");
277 Vv = this->memory.alloc();
278 Vp = this->memory.alloc();
279 Vq = this->memory.alloc();
280 Vt = this->memory.alloc();
281 Vd = this->memory.alloc();
300 deallog <<
"Restart step " << step << std::endl;
301 state = iterate(A, precondition);
306 this->memory.free(Vv);
307 this->memory.free(Vp);
308 this->memory.free(Vq);
309 this->memory.free(Vt);
310 this->memory.free(Vd);
318 state.last_residual));
324 template<
class VectorType>
325 template<
typename MatrixType,
typename PreconditionerType>
328 const PreconditionerType &precondition)
345 const VectorType &
b = *Vb;
349 double tau, rho, theta=0;
355 precondition.vmult(q,x);
366 precondition.vmult(q,p);
378 const double sigma = q*t;
381 if (std::fabs(sigma/rho) < additional_data.breakdown)
384 const double alpha = rho/sigma;
388 const double theta_old = theta;
390 const double psi = 1./(1.+theta);
393 d.sadd(psi*theta_old, psi*alpha, p);
396 print_vectors(step,x,v,d);
398 if (additional_data.exact_residual)
405 res = std::sqrt((it+1)*tau);
406 state = this->iteration_status(step,res,x);
409 return IterationResult(state, res);
411 if (std::fabs(rho) < additional_data.breakdown)
414 const double rho_old = rho;
415 precondition.vmult(q,v);
418 const double beta = rho/rho_old;
420 precondition.vmult(q,p);
427 DEAL_II_NAMESPACE_CLOSE
Stop iteration, goal not reached.
IterationResult iterate(const MatrixType &A, const PreconditionerType &precondition)
void solve(const MatrixType &A, VectorType &x, const VectorType &b, const PreconditionerType &precondition)
#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)
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
AdditionalData(bool exact_residual=false, double breakdown=1.e-16)
void push(const std::string &text)
AdditionalData additional_data
virtual double criterion()