15#ifndef dealii_solver_minres_h
16#define dealii_solver_minres_h
69template <
typename VectorType = Vector<
double>>
103 template <
typename MatrixType,
typename PreconditionerType>
107 void solve(const MatrixType &A,
110 const PreconditionerType &preconditioner);
136 print_vectors(const
unsigned int step,
139 const VectorType &d) const;
155template <
typename VectorType>
161 , res2(
numbers::signaling_nan<double>())
166template <
typename VectorType>
169 const AdditionalData &)
171 , res2(
numbers::signaling_nan<double>())
176template <
typename VectorType>
184template <
typename VectorType>
189 const VectorType &)
const
194template <
typename VectorType>
196template <
typename MatrixType,
typename PreconditionerType>
203 const PreconditionerType &preconditioner)
219 using vecptr = VectorType *;
220 vecptr u[3] = {Vu0.get(), Vu1.get(), Vu2.get()};
221 vecptr m[3] = {Vm0.get(), Vm1.get(), Vm2.get()};
226 u[0]->reinit(b,
true);
227 u[1]->reinit(b,
true);
228 u[2]->reinit(b,
true);
229 m[0]->reinit(b,
true);
230 m[1]->reinit(b,
true);
231 m[2]->reinit(b,
true);
235 double delta[3] = {0, 0, 0};
236 double f[2] = {0, 0};
237 double e[2] = {0, 0};
259 preconditioner.vmult(v, *u[1]);
261 delta[1] = v * (*u[1]);
263 Assert(delta[1] >= 0, ExcPreconditionerNotDefinite());
284 u[2]->add(-
std::sqrt(delta[1] / delta[0]), *u[0]);
286 const double gamma = *u[2] * v;
287 u[2]->add(-gamma /
std::sqrt(delta[1]), *u[1]);
293 preconditioner.vmult(v, *u[2]);
295 delta[2] = v * (*u[2]);
297 Assert(delta[2] >= 0, ExcPreconditionerNotDefinite());
306 d_ = s *
e[0] - c *
gamma;
312 const double d =
std::sqrt(d_ * d_ + delta[2]);
324 m[0]->add(-e[0], *m[1]);
326 m[0]->add(-f[0], *m[2]);
329 r_l2 *= std::fabs(s);
331 conv = this->iteration_status(j, r_l2, x);
@ iterate
Continue iteration.
@ success
Stop iteration, goal reached.
virtual ~SolverMinRes() override=default
SolverMinRes(SolverControl &cn, const AdditionalData &data=AdditionalData())
void solve(const MatrixType &A, VectorType &x, const VectorType &b, const PreconditionerType &preconditioner)
virtual void print_vectors(const unsigned int step, const VectorType &x, const VectorType &r, const VectorType &d) const
virtual double criterion()
SolverMinRes(SolverControl &cn, VectorMemory< VectorType > &mem, const AdditionalData &data=AdditionalData())
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_CXX20_REQUIRES(condition)
#define DEAL_II_NAMESPACE_CLOSE
#define DeclException0(Exception0)
#define Assert(cond, exc)
#define AssertThrow(cond, exc)
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
long double gamma(const unsigned int n)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
void swap(SmartPointer< T, P > &t1, SmartPointer< T, Q > &t2)