16 #ifndef dealii__solver_minres_h 17 #define dealii__solver_minres_h 20 #include <deal.II/base/config.h> 21 #include <deal.II/lac/solver.h> 22 #include <deal.II/lac/solver_control.h> 23 #include <deal.II/base/logstream.h> 25 #include <deal.II/base/subscriptor.h> 27 DEAL_II_NAMESPACE_OPEN
67 template <
class VectorType = Vector<
double> >
101 template<
typename MatrixType,
typename PreconditionerType>
103 solve (
const MatrixType &A,
106 const PreconditionerType &precondition);
132 const VectorType &d)
const;
138 VectorType *
Vu0, *Vu1, *Vu2;
139 VectorType *Vm0, *Vm1, *Vm2;
156 template<
class VectorType>
161 Solver<VectorType>(cn,mem)
166 template<
class VectorType>
174 template<
class VectorType>
180 template<
class VectorType>
188 template<
class VectorType>
193 const VectorType &)
const 198 template<
class VectorType>
199 template<
typename MatrixType,
typename PreconditionerType>
204 const PreconditionerType &precondition)
208 deallog.
push(
"minres");
212 Vu1 = this->
memory.alloc();
213 Vu2 = this->
memory.alloc();
214 Vv = this->
memory.alloc();
215 Vm0 = this->
memory.alloc();
216 Vm1 = this->
memory.alloc();
217 Vm2 = this->
memory.alloc();
219 typedef VectorType *vecptr;
220 vecptr u[3] = {
Vu0, Vu1, Vu2};
221 vecptr m[3] = {Vm0, Vm1, Vm2};
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 };
261 precondition.vmult (v,*u[1]);
263 delta[1] = v * (*u[1]);
265 Assert (delta[1]>=0, ExcPreconditionerNotDefinite());
267 r0 = std::sqrt(delta[1]);
282 v *= 1./std::sqrt(delta[1]);
287 u[2]->add (-std::sqrt(delta[1]/delta[0]), *u[0]);
290 u[2]->add (-gamma / std::sqrt(delta[1]), *u[1]);
296 precondition.vmult(v,*u[2]);
298 delta[2] = v * (*u[2]);
300 Assert (delta[2]>=0, ExcPreconditionerNotDefinite());
305 e[1] = std::sqrt(delta[2]);
309 d_ = s * e[0] - c * gamma;
310 e[0] = c * e[0] + s * gamma;
311 f[1] = s * std::sqrt(delta[2]);
312 e[1] = -c * std::sqrt(delta[2]);
315 d = std::sqrt (d_*d_ + delta[2]);
322 s = std::sqrt(delta[2]) / d;
327 m[0]->add (-e[0], *m[1]);
329 m[0]->add (-f[0], *m[2]);
332 r_l2 *= std::fabs(s);
385 DEAL_II_NAMESPACE_CLOSE
SolverMinRes(SolverControl &cn, VectorMemory< VectorType > &mem, const AdditionalData &data=AdditionalData())
#define AssertThrow(cond, exc)
Stop iteration, goal reached.
#define Assert(cond, exc)
DeclException0(ExcPreconditionerNotDefinite)
VectorMemory< VectorType > & memory
boost::signals2::signal< SolverControl::State(const unsigned int iteration, const double check_value, const VectorType ¤t_iterate), StateCombiner > iteration_status
void push(const std::string &text)
virtual double criterion()
void solve(const MatrixType &A, VectorType &x, const VectorType &b, const PreconditionerType &precondition)
virtual void print_vectors(const unsigned int step, const VectorType &x, const VectorType &r, const VectorType &d) const