16 #ifndef dealii_eigen_h 17 #define dealii_eigen_h 20 #include <deal.II/base/config.h> 21 #include <deal.II/lac/linear_operator.h> 22 #include <deal.II/lac/precondition.h> 23 #include <deal.II/lac/solver_cg.h> 24 #include <deal.II/lac/solver_control.h> 25 #include <deal.II/lac/solver_gmres.h> 26 #include <deal.II/lac/solver.h> 27 #include <deal.II/lac/solver_minres.h> 28 #include <deal.II/lac/vector_memory.h> 32 DEAL_II_NAMESPACE_OPEN
53 template <
typename VectorType = Vector<
double> >
87 const AdditionalData &data=AdditionalData());
100 template <
typename MatrixType>
102 solve (
double &value,
136 template <
typename VectorType = Vector<
double> >
182 const AdditionalData &data=AdditionalData());
197 template <
typename MatrixType>
199 solve (
double &value,
214 template <
class VectorType>
219 Solver<VectorType>(cn, mem),
220 additional_data(data)
225 template <
class VectorType>
231 template <
class VectorType>
232 template <
typename MatrixType>
249 double length = x.l2_norm ();
250 double old_length = 0.;
259 y.add(additional_data.shift, x);
263 length = y.l2_norm ();
269 double thresh = length/x.size();
275 while (std::fabs(entry) < thresh);
280 value = (entry * x (i) < 0.) ? -length : length;
281 value -= additional_data.shift;
291 conv = this->iteration_status (iter, std::fabs(1./length-1./old_length), x);
296 std::fabs(1./length-1./old_length)));
303 template <
class VectorType>
308 Solver<VectorType>(cn, mem),
309 additional_data(data)
314 template <
class VectorType>
320 template <
class VectorType>
321 template <
typename MatrixType>
333 double current_shift = -value;
340 solver(inner_control, this->memory);
343 unsigned int goal = additional_data.start_adaption;
353 double length = x.l2_norm ();
354 double old_value = value;
359 double res = -std::numeric_limits<double>::max();
363 solver.
solve (A_s, y, x, prec);
366 length = y.l2_norm ();
372 double thresh = length/x.size();
378 while (std::fabs(entry) < thresh);
383 value = (entry * x(i) < 0. ? -1. : 1.) / length - current_shift;
387 const auto &relaxation = additional_data.relaxation;
388 const double new_shift =
389 relaxation * (-value) + (1. - relaxation) * current_shift;
392 current_shift = new_shift;
398 x.equ (1./length, y);
400 if (additional_data.use_residual)
404 r.sadd(-1., value, x);
407 conv = this->iteration_status (iter, res, x);
411 res = std::fabs(1./value-1./old_value);
412 conv = this->iteration_status (iter, res, x);
425 DEAL_II_NAMESPACE_CLOSE
types::global_dof_index size_type
AdditionalData additional_data
void solve(double &value, const MatrixType &A, VectorType &x)
#define AssertThrow(cond, exc)
void solve(double &value, const MatrixType &A, VectorType &x)
void solve(const MatrixType &A, VectorType &x, const VectorType &b, const PreconditionerType &preconditioner)
unsigned int global_dof_index
Stop iteration, goal reached.
#define Assert(cond, exc)
AdditionalData additional_data
EigenPower(SolverControl &cn, VectorMemory< VectorType > &mem, const AdditionalData &data=AdditionalData())
AdditionalData(const double shift=0.)
EigenInverse(SolverControl &cn, VectorMemory< VectorType > &mem, const AdditionalData &data=AdditionalData())
unsigned int start_adaption
LinearOperator< Range, Range, Payload > identity_operator(const std::function< void(Range &, bool)> &reinit_vector)
types::global_dof_index size_type
AdditionalData(double relaxation=1., unsigned int start_adaption=6, bool use_residual=true)
LinearOperator< Range, Domain, Payload > linear_operator(const Matrix &matrix)
static ::ExceptionBase & ExcInternalError()