14#ifndef multigrid_amg_h
15#define multigrid_amg_h
41 template <
int dim,
typename OperatorType,
typename Number =
double>
77 const OperatorType &mf_operator_,
78 const std::vector<TrilinosWrappers::SparseMatrix *> transfers_)
82 &mf_operator_.get_matrix_free()->get_dof_handler().get_fe()) !=
88 for (
unsigned int l = 0;
l < transfers_.size(); ++
l)
89 Assert((mf_operator_.get_matrix_free()->get_locally_owned_set() ==
90 transfers_[
l]->locally_owned_range_indices()),
98 for (
unsigned int l = 0;
l < transfers_.size(); ++
l)
162 .locally_owned_dofs(),
179 Assert(mg_matrices.n_levels() > 1,
180 ExcMessage(
"Vector of matrices set to invalid size."));
184 const unsigned int min_level = mg_matrices.min_level();
185 const unsigned int max_level = mg_matrices.max_level();
190 for (
unsigned int l = min_level + 1;
l < max_level;
l++)
201 template <
int dim,
typename MatrixType,
typename Number =
double>
228 AmgProjector(
const std::vector<TrilinosWrappers::SparseMatrix> &transfers_)
236 for (
unsigned int l = 0;
l < transfers_.size(); ++
l)
278 Assert(mg_matrices.n_levels() > 1,
279 ExcMessage(
"Vector of matrices set to invalid size."));
282 const unsigned int min_level = mg_matrices.min_level();
283 const unsigned int max_level = mg_matrices.max_level();
291 for (
unsigned int l = max_level;
l-- > min_level;)
294 MatrixType level_operator(
299 mg_matrices[
l] = std::make_unique<MatrixType>();
302 mg_matrices[
l + 1]->mmult(
326 &multigrid_matrices_lo)
328 Assert(mg_matrices.n_levels() > 1,
329 ExcMessage(
"Vector of matrices set to invalid size."));
332 const unsigned int min_level = mg_matrices.min_level();
333 const unsigned int max_level = mg_matrices.max_level();
335 for (
unsigned int l = max_level;
l-- > min_level;)
338 MatrixType level_operator(
343 mg_matrices[
l] = std::make_unique<MatrixType>();
346 mg_matrices[
l + 1]->mmult(
353 multigrid_matrices_lo[
l] =
354 linear_operator_mg<VectorType, VectorType>(*mg_matrices[
l]);
355 multigrid_matrices_lo[
l].vmult =
357 mg_matrices[
l]->vmult(dst, src);
359 multigrid_matrices_lo[
l].n_rows = mg_matrices[
l]->m();
360 multigrid_matrices_lo[
l].n_cols = mg_matrices[
l]->n();
370 ExcMessage(
"Vector of matrices set to invalid size."));
373 const unsigned int min_level = mg_matrices.
min_level();
374 const unsigned int max_level = mg_matrices.
max_level();
382 for (
unsigned int l = max_level;
l-- > min_level;)
385 MatrixType level_operator(
391 mg_matrices[
l + 1].mmult(
408 template <
int dim,
typename VectorType>
436 const VectorType &src)
const override;
445 const VectorType &src)
const override;
454 const VectorType &src)
const override;
466 const VectorType &src)
const;
void reinit(const size_type size, const bool omit_zeroing_entries=false)
MPI_Comm get_mpi_communicator() const
void resize(const unsigned int new_minlevel, const unsigned int new_maxlevel, Args &&...args)
unsigned int max_level() const
unsigned int min_level() const
unsigned int n_levels() const
void compute_level_matrices(MGLevelObject< MatrixType > &mg_matrices)
std::vector< const MatrixType * > transfer_matrices
void compute_level_matrices_as_linear_operators(MGLevelObject< std::unique_ptr< MatrixType > > &mg_matrices, MGLevelObject< LinearOperatorMG< LinearAlgebra::distributed::Vector< Number >, LinearAlgebra::distributed::Vector< Number > > > &multigrid_matrices_lo)
AmgProjector(const MGLevelObject< TrilinosWrappers::SparseMatrix > &transfers_)
void compute_level_matrices(MGLevelObject< std::unique_ptr< MatrixType > > &mg_matrices)
AmgProjector(const std::vector< TrilinosWrappers::SparseMatrix > &transfers_)
void prolongate(const unsigned int to_level, VectorType &dst, const VectorType &src) const override
void copy_from_mg(const DoFHandler< dim > &dof_handler, VectorType &dst, const MGLevelObject< VectorType > &src) const
MGTransferAgglomeration(const MGLevelObject< TrilinosWrappers::SparseMatrix * > &transfer_matrices, const std::vector< DoFHandler< dim > * > &dof_handlers)
MGLevelObject< ObserverPointer< TrilinosWrappers::SparseMatrix > > transfer_matrices
void restrict_and_add(const unsigned int from_level, VectorType &dst, const VectorType &src) const override
std::vector< const DoFHandler< dim > * > dof_handlers
void prolongate_and_add(const unsigned int to_level, VectorType &dst, const VectorType &src) const override
void copy_to_mg(const DoFHandler< dim > &dof_handler, MGLevelObject< VectorType > &dst, const VectorType &src) const
std::vector< TrilinosWrappers::SparseMatrix * > transfer_matrices
const OperatorType * mf_operator
std::vector< LinearOperatorMG< VectorType, VectorType > > level_operators
LinearOperatorMG< VectorType, VectorType > mf_linear_operator
void compute_level_matrices(MGLevelObject< LinearOperatorMG< VectorType, VectorType > > &mg_matrices)
MatrixFreeProjector(const OperatorType &mf_operator_, const std::vector< TrilinosWrappers::SparseMatrix * > transfers_)
#define Assert(cond, exc)
LinearOperator< Domain, Range, Payload > transpose_operator(const LinearOperator< Range, Domain, Payload > &op)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)