16 #ifndef dealii_solver_bicgstab_h 17 #define dealii_solver_bicgstab_h 20 #include <deal.II/base/config.h> 22 #include <deal.II/base/logstream.h> 23 #include <deal.II/base/signaling_nan.h> 24 #include <deal.II/base/subscriptor.h> 26 #include <deal.II/lac/solver.h> 27 #include <deal.II/lac/solver_control.h> 31 DEAL_II_NAMESPACE_OPEN
123 template <
typename VectorType = Vector<
double>>
147 const double breakdown = 1.e-10)
148 : exact_residual(exact_residual)
149 , breakdown(breakdown)
183 template <
typename MatrixType,
typename PreconditionerType>
185 solve(
const MatrixType & A,
187 const VectorType & b,
188 const PreconditionerType &preconditioner);
234 const VectorType *
Vb;
239 template <
typename MatrixType>
241 criterion(
const MatrixType &A,
const VectorType &x,
const VectorType &b);
249 print_vectors(
const unsigned int step,
250 const VectorType & x,
251 const VectorType & r,
252 const VectorType & d)
const;
263 template <
typename MatrixType>
265 start(
const MatrixType &A);
275 unsigned int last_step;
276 double last_residual;
280 const unsigned int last_step,
281 const double last_residual);
288 template <
typename MatrixType,
typename PreconditionerType>
290 iterate(
const MatrixType &A,
const PreconditionerType &preconditioner);
299 template <
typename VectorType>
301 const bool breakdown,
303 const unsigned int last_step,
304 const double last_residual)
305 : breakdown(breakdown)
307 , last_step(last_step)
308 , last_residual(last_residual)
313 template <
typename VectorType>
320 , additional_data(data)
325 template <
typename VectorType>
331 , additional_data(data)
336 template <
typename VectorType>
337 template <
typename MatrixType>
352 template <
typename VectorType>
353 template <
typename MatrixType>
358 Vr->sadd(-1., 1., *Vb);
361 return this->iteration_status(
step,
res, *Vx);
366 template <
typename VectorType>
371 const VectorType &)
const 376 template <
typename VectorType>
377 template <
typename MatrixType,
typename PreconditionerType>
380 const PreconditionerType &preconditioner)
388 VectorType &rbar = *Vrbar;
416 preconditioner.vmult(y, p);
424 if (std::fabs(
alpha) > 1.e10)
427 res = std::sqrt(r.add_and_dot(-
alpha, v, r));
438 print_vectors(
step, *Vx, r, y);
442 preconditioner.vmult(z, r);
448 if (additional_data.exact_residual)
451 res = criterion(A, *Vx, *Vb);
454 res = std::sqrt(r.add_and_dot(-
omega, t, r));
456 state = this->iteration_status(
step,
res, *Vx);
457 print_vectors(
step, *Vx, r, y);
464 template <
typename VectorType>
465 template <
typename MatrixType,
typename PreconditionerType>
469 const VectorType & b,
470 const PreconditionerType &preconditioner)
482 Vrbar->reinit(x,
true);
500 deallog <<
"Restart step " <<
step << std::endl;
506 state = iterate(A, preconditioner);
509 while (state.breakdown ==
true);
514 state.last_residual));
520 DEAL_II_NAMESPACE_CLOSE
Stop iteration, goal not reached.
SolverBicgstab(SolverControl &cn, VectorMemory< VectorType > &mem, const AdditionalData &data=AdditionalData())
VectorMemory< VectorType >::Pointer Vrbar
#define AssertThrow(cond, exc)
VectorMemory< VectorType >::Pointer Vv
VectorMemory< VectorType >::Pointer Vp
VectorMemory< VectorType >::Pointer Vr
Stop iteration, goal reached.
AdditionalData additional_data
void solve(const MatrixType &A, VectorType &x, const VectorType &b, const PreconditionerType &preconditioner)
VectorMemory< VectorType >::Pointer Vt
AdditionalData(const bool exact_residual=true, const double breakdown=1.e-10)
virtual void print_vectors(const unsigned int step, const VectorType &x, const VectorType &r, const VectorType &d) const
IterationResult iterate(const MatrixType &A, const PreconditionerType &preconditioner)
VectorMemory< VectorType >::Pointer Vy
VectorMemory< VectorType >::Pointer Vz
SolverControl::State start(const MatrixType &A)
double criterion(const MatrixType &A, const VectorType &x, const VectorType &b)