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>
342 template <
typename VectorType>
343 template <
typename MatrixType>
358 template <
typename VectorType>
359 template <
typename MatrixType>
364 Vr->sadd(-1., 1., *Vb);
367 return this->iteration_status(
step,
res, *Vx);
372 template <
typename VectorType>
377 const VectorType &)
const 382 template <
typename VectorType>
383 template <
typename MatrixType,
typename PreconditionerType>
386 const PreconditionerType &preconditioner)
394 VectorType &rbar = *Vrbar;
422 preconditioner.vmult(y, p);
430 if (std::fabs(
alpha) > 1.e10)
433 res = std::sqrt(r.add_and_dot(-
alpha, v, r));
444 print_vectors(
step, *Vx, r, y);
448 preconditioner.vmult(z, r);
454 if (additional_data.exact_residual)
457 res = criterion(A, *Vx, *Vb);
460 res = std::sqrt(r.add_and_dot(-
omega, t, r));
462 state = this->iteration_status(
step,
res, *Vx);
463 print_vectors(
step, *Vx, r, y);
470 template <
typename VectorType>
471 template <
typename MatrixType,
typename PreconditionerType>
475 const VectorType & b,
476 const PreconditionerType &preconditioner)
488 Vrbar->reinit(x,
true);
506 deallog <<
"Restart step " <<
step << std::endl;
512 state = iterate(A, preconditioner);
515 while (state.breakdown ==
true);
520 state.last_residual));
526 DEAL_II_NAMESPACE_CLOSE
Stop iteration, goal not reached.
SolverBicgstab(SolverControl &cn, VectorMemory< VectorType > &mem, const AdditionalData &data=AdditionalData())
VectorMemory< VectorType >::Pointer Vrbar
virtual ~SolverBicgstab() override
virtual void print_vectors(const unsigned int step, const VectorType &x, const VectorType &r, const VectorType &d) const
#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)
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)