16#ifndef dealii_mg_transfer_global_coarsening_h
17#define dealii_mg_transfer_global_coarsening_h
44 class MGTwoLevelTransferImplementation;
49 template <
int dim,
int spacedim>
93 const unsigned int degree,
101 std::vector<unsigned int>
103 const unsigned int max_degree,
116 template <
int dim,
int spacedim>
117 std::vector<std::shared_ptr<const Triangulation<dim, spacedim>>>
137 template <
int dim,
int spacedim>
138 std::vector<std::shared_ptr<const Triangulation<dim, spacedim>>>
142 const bool preserve_fine_triangulation,
143 const bool repartition_fine_triangulation);
150 template <
int dim,
int spacedim>
151 std::vector<std::shared_ptr<const Triangulation<dim, spacedim>>>
155 const bool repartition_fine_triangulation =
false);
163template <
typename VectorType>
194 const std::shared_ptr<const Utilities::MPI::Partitioner>
196 const std::shared_ptr<const Utilities::MPI::Partitioner>
197 &partitioner_fine) = 0;
214template <
typename Number>
246 const std::shared_ptr<const Utilities::MPI::Partitioner>
248 const std::shared_ptr<const Utilities::MPI::Partitioner>
249 &partitioner_fine) = 0;
305 template <
int dim, std::
size_t w
idth>
308 const std::shared_ptr<const Utilities::MPI::Partitioner>
310 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner_fine,
314 std::vector<unsigned int> & dof_indices_fine);
351 std::shared_ptr<const Utilities::MPI::Partitioner>
380template <
int dim,
typename VectorType>
401 interpolate(VectorType &dst,
const VectorType &src)
const override;
409 const std::shared_ptr<const Utilities::MPI::Partitioner>
411 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner_fine)
429template <
int dim,
typename Number>
505 const unsigned int fe_degree_coarse);
522 const std::shared_ptr<const Utilities::MPI::Partitioner>
524 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner_fine)
552 struct MGTransferScheme
649 friend class internal::MGTwoLevelTransferImplementation;
658template <
int dim,
typename VectorType>
681 interpolate(VectorType &dst,
const VectorType &src)
const override;
698template <
int dim,
typename Number>
738 const std::shared_ptr<const Utilities::MPI::Partitioner>
740 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner_fine)
776 std::shared_ptr<NonMatching::MappingInfo<dim, dim, Number>>
mapping_info;
818template <
int dim,
typename VectorType>
825 using Number =
typename VectorType::value_type;
836 template <
typename MGTwoLevelTransferObject>
839 const std::function<
void(
const unsigned int, VectorType &)>
851 build(
const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
859 build(
const std::function<
void(
const unsigned int, VectorType &)>
868 const VectorType & src)
const override;
876 const VectorType & src)
const override;
884 const VectorType & src)
const override;
892 template <
class InVector,
int spacedim>
896 const InVector & src)
const;
904 template <
class OutVector,
int spacedim>
922 template <
class InVector>
932 template <
class InVector,
int spacedim>
936 const InVector & src)
const;
974 std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
985template <
int dim,
typename VectorType>
989 typename VectorType::value_type,
990 MGTransferGlobalCoarsening<dim, VectorType>>
1018template <
int dim,
typename VectorType>
1019template <
typename MGTwoLevelTransferObject>
1022 const std::function<
void(
const unsigned int, VectorType &)>
1023 &initialize_dof_vector)
1025 const unsigned int min_level = transfer.
min_level();
1026 const unsigned int max_level = transfer.
max_level();
1028 this->transfer.
resize(min_level, max_level);
1030 for (
unsigned int l = min_level; l <= max_level; ++l)
1035 this->build(initialize_dof_vector);
1040template <
int dim,
typename VectorType>
1043 const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
1044 &external_partitioners)
1046 this->external_partitioners = external_partitioners;
1048 if (this->external_partitioners.size() > 0)
1050 const unsigned int min_level = transfer.
min_level();
1051 const unsigned int max_level = transfer.
max_level();
1055 for (
unsigned int l = min_level + 1;
l <= max_level; ++
l)
1056 transfer[l]->enable_inplace_operations_if_possible(
1057 this->external_partitioners[l - 1 - min_level],
1058 this->external_partitioners[l - min_level]);
1064template <
int dim,
typename VectorType>
1067 const std::function<
void(
const unsigned int, VectorType &)>
1068 &initialize_dof_vector)
1070 if (initialize_dof_vector)
1072 const unsigned int min_level = transfer.
min_level();
1073 const unsigned int max_level = transfer.
max_level();
1074 const unsigned int n_levels = transfer.
n_levels();
1076 std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
1077 external_partitioners(n_levels);
1079 for (
unsigned int l = min_level;
l <= max_level; ++
l)
1083 initialize_dof_vector(l, vector);
1087 this->build(external_partitioners);
1097template <
int dim,
typename VectorType>
1100 const unsigned int level,
1101 VectorType & vec)
const
1106 const auto &external_partitioner =
1109 if (vec.get_partitioner().get() != external_partitioner.get())
1110 vec.reinit(external_partitioner);
1115template <
int dim,
typename VectorType>
1118 const unsigned int to_level,
1120 const VectorType & src)
const
1123 prolongate_and_add(to_level, dst, src);
1128template <
int dim,
typename VectorType>
1131 const unsigned int to_level,
1133 const VectorType & src)
const
1135 this->transfer[to_level]->prolongate_and_add(dst, src);
1140template <
int dim,
typename VectorType>
1143 const unsigned int from_level,
1145 const VectorType & src)
const
1147 this->transfer[from_level]->restrict_and_add(dst, src);
1152template <
int dim,
typename VectorType>
1153template <
class InVector,
int spacedim>
1158 const InVector & src)
const
1167 dst[
level].copy_locally_owned_data_from(src);
1175template <
int dim,
typename VectorType>
1176template <
class OutVector,
int spacedim>
1185 dst.copy_locally_owned_data_from(src[src.
max_level()]);
1190template <
int dim,
typename VectorType>
1191template <
class InVector>
1195 const InVector & src)
const
1197 const unsigned int min_level = transfer.
min_level();
1198 const unsigned int max_level = transfer.
max_level();
1206 dst[transfer.
max_level()].copy_locally_owned_data_from(src);
1208 for (
unsigned int l = max_level;
l > min_level; --
l)
1209 this->transfer[l]->
interpolate(dst[l - 1], dst[l]);
1214template <
int dim,
typename VectorType>
1215template <
class InVector,
int spacedim>
1220 const InVector & src)
const
1224 this->interpolate_to_mg(dst, src);
1229template <
int dim,
typename VectorType>
1233 std::size_t size = 0;
1235 const unsigned int min_level = transfer.
min_level();
1236 const unsigned int max_level = transfer.
max_level();
1238 for (
unsigned int l = min_level + 1;
l <= max_level; ++
l)
1246template <
int dim,
typename VectorType>
1255template <
int dim,
typename VectorType>
const std::shared_ptr< const Utilities::MPI::Partitioner > & get_partitioner() 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
const MGTransferGlobalCoarsening< dim, VectorType > & get_matrix_free_transfer(const unsigned int b) const override
MGTransferBlockGlobalCoarsening(const MGTransferGlobalCoarsening< dim, VectorType > &transfer_operator)
const MGTransferGlobalCoarsening< dim, VectorType > & transfer_operator
void copy_from_mg(const DoFHandler< dim, spacedim > &dof_handler, OutVector &dst, const MGLevelObject< VectorType > &src) const
void interpolate_to_mg(const DoFHandler< dim, spacedim > &dof_handler, MGLevelObject< VectorType > &dst, const InVector &src) const
void prolongate(const unsigned int to_level, VectorType &dst, const VectorType &src) const override
typename VectorType::value_type Number
unsigned int min_level() const
std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > external_partitioners
void copy_to_mg(const DoFHandler< dim, spacedim > &dof_handler, MGLevelObject< VectorType > &dst, const InVector &src) const
MGTransferGlobalCoarsening(const MGLevelObject< MGTwoLevelTransferObject > &transfer, const std::function< void(const unsigned int, VectorType &)> &initialize_dof_vector={})
virtual void restrict_and_add(const unsigned int from_level, VectorType &dst, const VectorType &src) const override
std::size_t memory_consumption() const
void initialize_dof_vector(const unsigned int level, VectorType &vector) const
void build(const std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > &external_partitioners={})
void build(const std::function< void(const unsigned int, VectorType &)> &initialize_dof_vector)
void interpolate_to_mg(MGLevelObject< VectorType > &dst, const InVector &src) const
void prolongate_and_add(const unsigned int to_level, VectorType &dst, const VectorType &src) const override
MGLevelObject< SmartPointer< MGTwoLevelTransferBase< VectorType > > > transfer
unsigned int max_level() const
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner_fine_embedded
bool fine_element_is_continuous
virtual void enable_inplace_operations_if_possible(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_coarse, const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_fine)=0
virtual std::size_t memory_consumption() const =0
LinearAlgebra::distributed::Vector< Number > vec_coarse
void compress(LinearAlgebra::distributed::Vector< Number > &vec, const VectorOperation::values op) const
void internal_enable_inplace_operations_if_possible(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_coarse, const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_fine, internal::MatrixFreeFunctions::ConstraintInfo< dim, VectorizedArray< Number, width > > &constraint_info_coarse, std::vector< unsigned int > &dof_indices_fine)
void zero_out_ghost_values(const LinearAlgebra::distributed::Vector< Number > &vec) const
virtual void restrict_and_add_internal(LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const =0
virtual void prolongate_and_add(VectorType &dst, const VectorType &src) const
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner_coarse
virtual void interpolate(VectorType &dst, const VectorType &src) const =0
void update_ghost_values(const LinearAlgebra::distributed::Vector< Number > &vec) const
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner_fine
AlignedVector< Number > buffer_coarse_embedded
virtual void prolongate_and_add_internal(LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const =0
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner_coarse_embedded
AlignedVector< Number > buffer_fine_embedded
LinearAlgebra::distributed::Vector< Number > vec_fine
virtual void restrict_and_add(VectorType &dst, const VectorType &src) const
virtual void enable_inplace_operations_if_possible(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_coarse, const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_fine)=0
virtual std::size_t memory_consumption() const =0
virtual void restrict_and_add(VectorType &dst, const VectorType &src) const =0
virtual void interpolate(VectorType &dst, const VectorType &src) const =0
virtual void prolongate_and_add(VectorType &dst, const VectorType &src) const =0
void enable_inplace_operations_if_possible(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_coarse, const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_fine) override
std::shared_ptr< NonMatching::MappingInfo< dim, dim, Number > > mapping_info
std::size_t memory_consumption() const override
std::vector< unsigned int > level_dof_indices_fine
internal::MatrixFreeFunctions::ConstraintInfo< dim, VectorizedArrayType > constraint_info
std::unique_ptr< FiniteElement< dim > > fe_coarse
Utilities::MPI::RemotePointEvaluation< dim > rpe
std::vector< unsigned int > level_dof_indices_fine_ptrs
void prolongate_and_add_internal(LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
void interpolate(LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
void restrict_and_add_internal(LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
void reinit(const DoFHandler< dim > &dof_handler_fine, const DoFHandler< dim > &dof_handler_coarse, const Mapping< dim > &mapping_fine, const Mapping< dim > &mapping_coarse, const AffineConstraints< Number > &constraint_fine=AffineConstraints< Number >(), const AffineConstraints< Number > &constraint_coarse=AffineConstraints< Number >())
void prolongate_and_add(VectorType &dst, const VectorType &src) const override
std::size_t memory_consumption() const override
void restrict_and_add(VectorType &dst, const VectorType &src) const override
void interpolate(VectorType &dst, const VectorType &src) const override
internal::MatrixFreeFunctions::ConstraintInfo< dim, VectorizedArrayType > constraint_info_fine
std::vector< Number > weights
void enable_inplace_operations_if_possible(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_coarse, const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_fine) override
void reinit_polynomial_transfer(const DoFHandler< dim > &dof_handler_fine, const DoFHandler< dim > &dof_handler_coarse, const AffineConstraints< Number > &constraint_fine=AffineConstraints< Number >(), const AffineConstraints< Number > &constraint_coarse=AffineConstraints< Number >(), const unsigned int mg_level_fine=numbers::invalid_unsigned_int, const unsigned int mg_level_coarse=numbers::invalid_unsigned_int)
void interpolate(LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
static bool fast_polynomial_transfer_supported(const unsigned int fe_degree_fine, const unsigned int fe_degree_coarse)
unsigned int n_components
void prolongate_and_add_internal(LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
internal::MatrixFreeFunctions::ConstraintInfo< dim, VectorizedArrayType > constraint_info_coarse
void reinit(const DoFHandler< dim > &dof_handler_fine, const DoFHandler< dim > &dof_handler_coarse, const AffineConstraints< Number > &constraint_fine=AffineConstraints< Number >(), const AffineConstraints< Number > &constraint_coarse=AffineConstraints< Number >(), const unsigned int mg_level_fine=numbers::invalid_unsigned_int, const unsigned int mg_level_coarse=numbers::invalid_unsigned_int)
void restrict_and_add_internal(LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
void reinit_geometric_transfer(const DoFHandler< dim > &dof_handler_fine, const DoFHandler< dim > &dof_handler_coarse, const AffineConstraints< Number > &constraint_fine=AffineConstraints< Number >(), const AffineConstraints< Number > &constraint_coarse=AffineConstraints< Number >(), const unsigned int mg_level_fine=numbers::invalid_unsigned_int, const unsigned int mg_level_coarse=numbers::invalid_unsigned_int)
AlignedVector< VectorizedArrayType > weights_compressed
std::size_t memory_consumption() const override
std::vector< MGTransferScheme > schemes
void enable_inplace_operations_if_possible(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_coarse, const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_fine) override
void interpolate(VectorType &dst, const VectorType &src) const override
void restrict_and_add(VectorType &dst, const VectorType &src) const override
void prolongate_and_add(VectorType &dst, const VectorType &src) const override
std::size_t memory_consumption() const override
Abstract base class for mapping classes.
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
std::enable_if_t< std::is_fundamental< T >::value, std::size_t > memory_consumption(const T &t)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
T & get_underlying_value(T &p)
static const unsigned int invalid_unsigned_int
unsigned int n_coarse_cells
AlignedVector< VectorizedArrayType > prolongation_matrix
internal::MatrixFreeFunctions::ShapeInfo< VectorizedArrayType > shape_info_coarse
unsigned int n_dofs_per_cell_coarse
unsigned int n_dofs_per_cell_fine
AlignedVector< VectorizedArrayType > prolongation_matrix_1d
unsigned int degree_coarse
AlignedVector< VectorizedArrayType > restriction_matrix_1d
AlignedVector< VectorizedArrayType > restriction_matrix
const ::Triangulation< dim, spacedim > & tria