16 #ifndef dealii_mg_coarse_h 17 #define dealii_mg_coarse_h 20 #include <deal.II/lac/full_matrix.h> 21 #include <deal.II/lac/householder.h> 22 #include <deal.II/lac/linear_operator.h> 23 #include <deal.II/lac/matrix_lib.h> 25 #include <deal.II/multigrid/mg_base.h> 27 DEAL_II_NAMESPACE_OPEN
38 template <
class VectorType = Vector<
double>>
70 const VectorType & src)
const override;
95 template <
typename SolverType,
class VectorType = Vector<
double>>
109 template <
typename MatrixType,
typename PreconditionerType>
112 const PreconditionerType &);
122 template <
typename MatrixType,
typename PreconditionerType>
124 initialize(SolverType &,
const MatrixType &,
const PreconditionerType &);
139 const VectorType & src)
const;
145 template <
typename MatrixType>
147 set_matrix(
const MatrixType &);
175 template <
class VectorType,
178 class PreconditionerType>
192 const MatrixType &
matrix,
193 const PreconditionerType &precondition);
201 const MatrixType &
matrix,
202 const PreconditionerType &precondition);
217 const VectorType & src)
const override;
263 template <
typename number =
double,
class VectorType = Vector<number>>
281 const VectorType & src)
const override;
298 template <
typename number =
double,
class VectorType = Vector<number>>
316 const VectorType & src)
const;
335 template <
class VectorType>
337 : coarse_smooth(nullptr)
340 template <
class VectorType>
343 : coarse_smooth(nullptr)
349 template <
class VectorType>
357 typeid(*this).name());
361 template <
class VectorType>
365 coarse_smooth =
nullptr;
369 template <
class VectorType>
373 const VectorType & src)
const 375 coarse_smooth->smooth(level, dst, src);
381 template <
typename SolverType,
class VectorType>
383 : solver(0, typeid(*this).name())
389 template <
typename SolverType,
class VectorType>
390 template <
typename MatrixType,
typename PreconditionerType>
393 const MatrixType & m,
394 const PreconditionerType &p)
395 : solver(&s, typeid(*this).name())
401 precondition = linear_operator<VectorType>(
matrix, p);
405 template <
typename SolverType,
class VectorType>
412 template <
typename SolverType,
class VectorType>
413 template <
typename MatrixType,
typename PreconditionerType>
417 const MatrixType & m,
418 const PreconditionerType &p)
425 precondition = linear_operator<VectorType>(
matrix, p);
429 template <
typename SolverType,
class VectorType>
439 template <
typename SolverType,
class VectorType>
444 const VectorType &src)
const 447 solver->solve(matrix, dst, src, precondition);
451 template <
typename SolverType,
class VectorType>
452 template <
typename MatrixType>
467 template <
class VectorType,
470 class PreconditionerType>
475 : solver(0, typeid(*this).name())
476 ,
matrix(0, typeid(*this).name())
477 , preconditioner(0, typeid(*this).name())
482 template <
class VectorType,
485 class PreconditionerType>
489 PreconditionerType>::
490 MGCoarseGridIterativeSolver(SolverType & solver,
491 const MatrixType & matrix,
492 const PreconditionerType &preconditioner)
493 : solver(&solver, typeid(*this).name())
495 , preconditioner(&preconditioner, typeid(*this).name())
500 template <
class VectorType,
503 class PreconditionerType>
509 PreconditionerType>::initialize(SolverType & solver_,
510 const MatrixType & matrix_,
511 const PreconditionerType &preconditioner_)
515 preconditioner = &preconditioner_;
520 template <
class VectorType,
523 class PreconditionerType>
528 PreconditionerType>::clear()
537 template <
class VectorType,
540 class PreconditionerType>
545 PreconditionerType>::
546 operator()(
const unsigned int ,
548 const VectorType &src)
const 553 solver->solve(*matrix, dst, src, *preconditioner);
560 template <
typename number,
class VectorType>
565 householder.initialize(*A);
570 template <
typename number,
class VectorType>
575 householder.initialize(A);
580 template <
typename number,
class VectorType>
585 const VectorType &src)
const 587 householder.least_squares(dst, src);
594 template <
typename number,
class VectorType>
599 matrix.reinit(A.n_rows(), A.n_cols());
601 matrix.compute_inverse_svd(threshold);
605 template <
typename number,
class VectorType>
609 const VectorType &src)
const 615 template <
typename number,
class VectorType>
619 const unsigned int n = std::min(
matrix.n_rows(),
matrix.n_cols());
621 for (
unsigned int i = 0; i < n; ++i)
622 deallog <<
' ' <<
matrix.singular_value(i);
623 deallog << std::endl;
629 DEAL_II_NAMESPACE_CLOSE
virtual void operator()(const unsigned int level, VectorType &dst, const VectorType &src) const =0
void initialize(const FullMatrix< number > &A, const double threshold=0)
Contents is actually a matrix.
void operator()(const unsigned int level, VectorType &dst, const VectorType &src) const override
LinearOperator< VectorType > precondition
static ::ExceptionBase & ExcNotInitialized()
virtual void operator()(const unsigned int level, VectorType &dst, const VectorType &src) const override
SmartPointer< SolverType, MGCoarseGridIterativeSolver< VectorType, SolverType, MatrixType, PreconditionerType > > solver
void operator()(const unsigned int level, VectorType &dst, const VectorType &src) const
MGCoarseGridApplySmoother()
void initialize(SolverType &, const MatrixType &, const PreconditionerType &)
LAPACKFullMatrix< number > matrix
SmartPointer< const MatrixType, MGCoarseGridIterativeSolver< VectorType, SolverType, MatrixType, PreconditionerType > > matrix
#define Assert(cond, exc)
MGCoarseGridSVD()=default
MGCoarseGridIterativeSolver()
void initialize(SolverType &solver, const MatrixType &matrix, const PreconditionerType &precondition)
LinearOperator< VectorType > matrix
SmartPointer< SolverType, MGCoarseGridLACIteration< SolverType, VectorType > > solver
void initialize(const MGSmootherBase< VectorType > &coarse_smooth)
MGCoarseGridLACIteration()
MGCoarseGridHouseholder(const FullMatrix< number > *A=nullptr)
Householder< number > householder
void operator()(const unsigned int level, VectorType &dst, const VectorType &src) const
SmartPointer< const PreconditionerType, MGCoarseGridIterativeSolver< VectorType, SolverType, MatrixType, PreconditionerType > > preconditioner
SmartPointer< const MGSmootherBase< VectorType >, MGCoarseGridApplySmoother< VectorType > > coarse_smooth
void operator()(const unsigned int level, VectorType &dst, const VectorType &src) const override
void initialize(const FullMatrix< number > &A)
~MGCoarseGridLACIteration()
void set_matrix(const MatrixType &)