15#ifndef dealii_mg_transfer_matrix_free_h
16#define dealii_mg_transfer_matrix_free_h
54template <
int dim,
typename Number>
105 const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
106 &external_partitioners =
107 std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>());
115 const std::function<
void(
const unsigned int,
117 &initialize_dof_vector);
183 template <
typename BlockVectorType2>
239 std::vector<std::vector<std::pair<unsigned int, unsigned int>>>
291 template <
int degree>
301 template <
int degree>
315template <
int dim,
typename Number,
typename TransferType>
317 :
public MGTransferBase<LinearAlgebra::distributed::BlockVector<Number>>
384 template <
typename BlockVectorType2>
394 template <
typename BlockVectorType2>
404 template <
typename BlockVectorType2>
415 template <
typename BlockVectorType2>
459template <
int dim,
typename Number>
463 MGTransferMatrixFree<dim, Number>>
482 const std::vector<MGConstrainedDoFs> &mg_constrained_dofs);
500 const std::vector<MGConstrainedDoFs> &mg_constrained_dofs);
545template <
int dim,
typename Number>
546template <
typename BlockVectorType2>
553 const unsigned int min_level = dst.min_level();
554 const unsigned int max_level = dst.max_level();
556 Assert(max_level == dof_handler.get_triangulation().n_global_levels() - 1,
558 max_level, dof_handler.get_triangulation().n_global_levels() - 1));
560 const auto &fe = dof_handler.get_fe();
564 dst[
level].locally_owned_size() !=
565 dof_handler.locally_owned_mg_dofs(
level).n_elements())
566 dst[
level].reinit(this->vector_partitioners[
level]);
569 this->copy_to_mg(dof_handler, dst, src,
true);
576 dst[max_level].update_ghost_values();
583 if (dst[
level].get_partitioner().get() ==
584 this->vector_partitioners[
level].get())
597 std::vector<types::global_dof_index> dof_indices(fe.n_dofs_per_cell());
598 for (
const auto &cell : dof_handler.cell_iterators_on_level(
level - 1))
599 if (cell->is_locally_owned_on_level())
604 if (cell->is_active())
608 for (
unsigned int child = 0; child < cell->n_children(); ++child)
610 cell->child(child)->get_mg_dof_indices(dof_indices);
613 this->mg_constrained_dofs,
level, dof_indices);
615 for (
unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
617 fe.get_restriction_matrix(child, cell->refinement_case())
619 for (
unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
620 if (fe.restriction_is_additive(i))
622 else if (tmp(i) != 0.)
625 cell->get_mg_dof_indices(dof_indices);
626 for (
unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
627 if (dof_handler.locally_owned_mg_dofs(
level - 1).is_element(
632 dst[
level - 1].update_ghost_values();
636 dst[
level].zero_out_ghost_values();
641template <
int dim,
typename Number,
typename TransferType>
642template <
typename BlockVectorType2>
651 "This object was initialized with support for usage with one "
652 "DoFHandler for each block, but this method assumes that "
653 "the same DoFHandler is used for all the blocks!"));
654 const std::vector<const DoFHandler<dim> *>
mg_dofs(src.n_blocks(),
662template <
int dim,
typename Number,
typename TransferType>
663template <
typename BlockVectorType2>
670 const unsigned int n_blocks = src.n_blocks();
676 const unsigned int min_level = dst.min_level();
677 const unsigned int max_level = dst.max_level();
681 dst[
level].reinit(n_blocks);
685 min_level, max_level);
689 const unsigned int data_block = same_for_all ? 0 :
b;
693 for (
unsigned int l = min_level;
l <= max_level; ++
l)
701template <
int dim,
typename Number,
typename TransferType>
702template <
typename BlockVectorType2>
712 "This object was initialized with support for usage with one "
713 "DoFHandler for each block, but this method assumes that "
714 "the same DoFHandler is used for all the blocks!"));
715 const std::vector<const DoFHandler<dim> *>
mg_dofs(dst.n_blocks(),
718 copy_from_mg(
mg_dofs, dst, src);
721template <
int dim,
typename Number,
typename TransferType>
722template <
typename BlockVectorType2>
730 const unsigned int n_blocks = dst.n_blocks();
736 const unsigned int min_level = src.min_level();
737 const unsigned int max_level = src.max_level();
739 for (
unsigned int l = min_level;
l <= max_level; ++
l)
744 min_level, max_level);
748 for (
unsigned int l = min_level;
l <= max_level; ++
l)
753 const unsigned int data_block = same_for_all ? 0 :
b;
ObserverPointer< const MGConstrainedDoFs > mg_constrained_dofs
virtual void prolongate(const unsigned int to_level, LinearAlgebra::distributed::BlockVector< Number > &dst, const LinearAlgebra::distributed::BlockVector< Number > &src) const override
virtual void prolongate_and_add(const unsigned int to_level, LinearAlgebra::distributed::BlockVector< Number > &dst, const LinearAlgebra::distributed::BlockVector< Number > &src) const override
virtual const TransferType & get_matrix_free_transfer(const unsigned int b) const =0
void copy_from_mg(const std::vector< const DoFHandler< dim > * > &dof_handler, BlockVectorType2 &dst, const MGLevelObject< LinearAlgebra::distributed::BlockVector< Number > > &src) const
void copy_to_mg(const DoFHandler< dim > &dof_handler, MGLevelObject< LinearAlgebra::distributed::BlockVector< Number > > &dst, const BlockVectorType2 &src) const
virtual void restrict_and_add(const unsigned int from_level, LinearAlgebra::distributed::BlockVector< Number > &dst, const LinearAlgebra::distributed::BlockVector< Number > &src) const override
MGTransferBlockMatrixFreeBase(const bool same_for_all)
void copy_from_mg(const DoFHandler< dim > &dof_handler, BlockVectorType2 &dst, const MGLevelObject< LinearAlgebra::distributed::BlockVector< Number > > &src) const
void copy_to_mg(const std::vector< const DoFHandler< dim > * > &dof_handler, MGLevelObject< LinearAlgebra::distributed::BlockVector< Number > > &dst, const BlockVectorType2 &src) const
static const bool supports_dof_handler_vector
std::vector< MGTransferMatrixFree< dim, Number > > matrix_free_transfer_vector
void build(const DoFHandler< dim > &dof_handler)
std::size_t memory_consumption() const
MGTransferBlockMatrixFree()=default
virtual ~MGTransferBlockMatrixFree() override=default
const MGTransferMatrixFree< dim, Number > & get_matrix_free_transfer(const unsigned int b) const override
void initialize_constraints(const MGConstrainedDoFs &mg_constrained_dofs)
void do_restrict_add(const unsigned int from_level, LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const
void do_prolongate_add(const unsigned int to_level, LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const
virtual ~MGTransferMatrixFree() override=default
std::vector< std::vector< unsigned int > > level_dof_indices
unsigned int n_components
virtual void prolongate(const unsigned int to_level, LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
unsigned int n_child_cell_dofs
void initialize_constraints(const MGConstrainedDoFs &mg_constrained_dofs)
std::vector< std::vector< std::vector< unsigned short > > > dirichlet_indices
void interpolate_to_mg(const DoFHandler< dim > &dof_handler, MGLevelObject< LinearAlgebra::distributed::Vector< Number > > &dst, const BlockVectorType2 &src) const
MGLevelObject< std::shared_ptr< const Utilities::MPI::Partitioner > > vector_partitioners
AlignedVector< VectorizedArray< Number > > evaluation_data
void build(const DoFHandler< dim > &dof_handler, const std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > &external_partitioners=std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > >())
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > parent_child_connect
virtual void prolongate_and_add(const unsigned int to_level, LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
std::size_t memory_consumption() const
std::vector< AlignedVector< VectorizedArray< Number > > > weights_on_refined
std::vector< unsigned int > n_owned_level_cells
AlignedVector< VectorizedArray< Number > > prolongation_matrix_1d
bool element_is_continuous
virtual void restrict_and_add(const unsigned int from_level, LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcMessage(std::string arg1)
std::enable_if_t< IsBlockVector< VectorType >::value, void > collect_sizes(VectorType &vector)
std::enable_if_t< IsBlockVector< VectorType >::value, unsigned int > n_blocks(const VectorType &vector)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
void resolve_identity_constraints(const MGConstrainedDoFs *mg_constrained_dofs, const unsigned int level, std::vector< types::global_dof_index > &dof_indices)