} // namespace MGTransferGlobalCoarseningTools
+
/**
* An abstract base class for transfer operators between two multigrid levels.
- * Specialization for LinearAlgebra::distributed::Vector. The implementation of
+ * The implementation of
* restriction and prolongation between levels is delegated to derived classes,
* which implement prolongate_and_add_internal() and restrict_and_add_internal()
* accordingly.
/**
* Class for transfer between two non-nested multigrid levels.
- *
*/
template <int dim, typename VectorType>
class MGTwoLevelTransferNonNested : public MGTwoLevelTransferBase<VectorType>
{
-public:
- /**
- * Perform prolongation.
- */
- void
- prolongate_and_add(VectorType &dst, const VectorType &src) const override;
-
- /**
- * Perform restriction.
- */
- void
- restrict_and_add(VectorType &dst, const VectorType &src) const override;
-
- /**
- * Perform interpolation of a solution vector from the fine level to the
- * coarse level. This function is different from restriction, where a
- * weighted residual is transferred to a coarser level (transposition of
- * prolongation matrix).
- */
- void
- interpolate(VectorType &dst, const VectorType &src) const override;
-
- /**
- * Return the memory consumption of the allocated memory in this class.
- */
- std::size_t
- memory_consumption() const override;
-};
-
-
-
-/**
- * Class for transfer between two non-nested multigrid levels.
- *
- * Specialization for LinearAlgebra::distributed::Vector.
- *
- */
-template <int dim, typename Number>
-class MGTwoLevelTransferNonNested<dim,
- LinearAlgebra::distributed::Vector<Number>>
- : public MGTwoLevelTransferBase<LinearAlgebra::distributed::Vector<Number>>
-{
private:
+ static_assert(
+ std::is_same_v<
+ VectorType,
+ LinearAlgebra::distributed::Vector<typename VectorType::value_type>>,
+ "This class is currently only implemented for vectors of "
+ "type LinearAlgebra::distributed::Vector.");
+
+ using Number = typename VectorType::value_type;
using VectorizedArrayType = VectorizedArray<Number, 1>;
mg::SignalsNonNested signals_non_nested;
bool enforce_all_points_found;
};
+ /**
+ * Constructor.
+ */
MGTwoLevelTransferNonNested(const AdditionalData &data = AdditionalData());
/**
* prolongation matrix).
*/
void
- interpolate(
- LinearAlgebra::distributed::Vector<Number> &dst,
- const LinearAlgebra::distributed::Vector<Number> &src) const override;
+ interpolate(VectorType &dst, const VectorType &src) const override;
/**
* Enable inplace vector operations if external and internal vectors
* Perform prolongation.
*/
void
- prolongate_and_add_internal(
- LinearAlgebra::distributed::Vector<Number> &dst,
- const LinearAlgebra::distributed::Vector<Number> &src) const override;
+ prolongate_and_add_internal(VectorType &dst,
+ const VectorType &src) const override;
/**
* Perform restriction.
*/
void
- restrict_and_add_internal(
- LinearAlgebra::distributed::Vector<Number> &dst,
- const LinearAlgebra::distributed::Vector<Number> &src) const override;
+ restrict_and_add_internal(VectorType &dst,
+ const VectorType &src) const override;
private:
/**
*/
template <int n_components>
void
- prolongate_and_add_internal_comp(
- LinearAlgebra::distributed::Vector<Number> &dst,
- const LinearAlgebra::distributed::Vector<Number> &src) const;
+ prolongate_and_add_internal_comp(VectorType &dst,
+ const VectorType &src) const;
/**
* Perform restriction for correct number of components.
*/
template <int n_components>
void
- restrict_and_add_internal_comp(
- LinearAlgebra::distributed::Vector<Number> &dst,
- const LinearAlgebra::distributed::Vector<Number> &src) const;
+ restrict_and_add_internal_comp(VectorType &dst, const VectorType &src) const;
/**
* Pointer to the DoFHandler object used during initialization.
-template <int dim, typename Number>
-MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
- MGTwoLevelTransferNonNested(const AdditionalData &data)
+template <int dim, typename VectorType>
+MGTwoLevelTransferNonNested<dim, VectorType>::MGTwoLevelTransferNonNested(
+ const AdditionalData &data)
: additional_data(data)
, rpe(typename Utilities::MPI::RemotePointEvaluation<dim>::AdditionalData(
data.tolerance,
{}))
{}
-template <int dim, typename Number>
+template <int dim, typename VectorType>
void
-MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
- 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,
- const AffineConstraints<Number> &constraint_coarse)
+MGTwoLevelTransferNonNested<dim, VectorType>::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,
+ const AffineConstraints<Number> &constraint_coarse)
{
AssertThrow(dof_handler_coarse.get_fe().has_support_points(),
ExcNotImplemented());
-template <int dim, typename Number>
+template <int dim, typename VectorType>
template <int n_components>
void
-MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
- prolongate_and_add_internal_comp(
- LinearAlgebra::distributed::Vector<Number> &dst,
- const LinearAlgebra::distributed::Vector<Number> &src) const
+MGTwoLevelTransferNonNested<dim, VectorType>::prolongate_and_add_internal_comp(
+ VectorType &dst,
+ const VectorType &src) const
{
using Traits =
internal::FEPointEvaluation::EvaluatorTypeTraits<dim, n_components, Number>;
-template <int dim, typename Number>
+template <int dim, typename VectorType>
void
-MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
- prolongate_and_add_internal(
- LinearAlgebra::distributed::Vector<Number> &dst,
- const LinearAlgebra::distributed::Vector<Number> &src) const
+MGTwoLevelTransferNonNested<dim, VectorType>::prolongate_and_add_internal(
+ VectorType &dst,
+ const VectorType &src) const
{
if (this->fe_coarse->n_components() == 1)
prolongate_and_add_internal_comp<1>(dst, src);
-template <int dim, typename Number>
+template <int dim, typename VectorType>
template <int n_components>
void
-MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
- restrict_and_add_internal_comp(
- LinearAlgebra::distributed::Vector<Number> &dst,
- const LinearAlgebra::distributed::Vector<Number> &src) const
+MGTwoLevelTransferNonNested<dim, VectorType>::restrict_and_add_internal_comp(
+ VectorType &dst,
+ const VectorType &src) const
{
using Traits =
internal::FEPointEvaluation::EvaluatorTypeTraits<dim, n_components, Number>;
-template <int dim, typename Number>
+template <int dim, typename VectorType>
void
-MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
- restrict_and_add_internal(
- LinearAlgebra::distributed::Vector<Number> &dst,
- const LinearAlgebra::distributed::Vector<Number> &src) const
+MGTwoLevelTransferNonNested<dim, VectorType>::restrict_and_add_internal(
+ VectorType &dst,
+ const VectorType &src) const
{
if (this->fe_coarse->n_components() == 1)
restrict_and_add_internal_comp<1>(dst, src);
-template <int dim, typename Number>
+template <int dim, typename VectorType>
void
-MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
- interpolate(LinearAlgebra::distributed::Vector<Number> &dst,
- const LinearAlgebra::distributed::Vector<Number> &src) const
+MGTwoLevelTransferNonNested<dim, VectorType>::interpolate(
+ VectorType &dst,
+ const VectorType &src) const
{
AssertThrow(false, ExcNotImplemented());
(void)dst;
-template <int dim, typename Number>
+template <int dim, typename VectorType>
void
-MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
+MGTwoLevelTransferNonNested<dim, VectorType>::
enable_inplace_operations_if_possible(
const std::shared_ptr<const Utilities::MPI::Partitioner>
&external_partitioner_coarse,
-template <int dim, typename Number>
+template <int dim, typename VectorType>
std::size_t
-MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
- memory_consumption() const
+MGTwoLevelTransferNonNested<dim, VectorType>::memory_consumption() const
{
std::size_t size = 0;
-template <int dim, typename Number>
+template <int dim, typename VectorType>
boost::signals2::connection
-MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
- connect_prolongation_cell_loop(const std::function<void(const bool)> &slot)
+MGTwoLevelTransferNonNested<dim, VectorType>::connect_prolongation_cell_loop(
+ const std::function<void(const bool)> &slot)
{
return signals_non_nested.prolongation_cell_loop.connect(slot);
}
-template <int dim, typename Number>
+template <int dim, typename VectorType>
boost::signals2::connection
-MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
- connect_restriction_cell_loop(const std::function<void(const bool)> &slot)
+MGTwoLevelTransferNonNested<dim, VectorType>::connect_restriction_cell_loop(
+ const std::function<void(const bool)> &slot)
{
return signals_non_nested.restriction_cell_loop.connect(slot);
}
-template <int dim, typename Number>
+template <int dim, typename VectorType>
boost::signals2::connection
-MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
- connect_prolongation(const std::function<void(const bool)> &slot)
+MGTwoLevelTransferNonNested<dim, VectorType>::connect_prolongation(
+ const std::function<void(const bool)> &slot)
{
return signals_non_nested.prolongation.connect(slot);
}
-template <int dim, typename Number>
+template <int dim, typename VectorType>
boost::signals2::connection
-MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
- connect_restriction(const std::function<void(const bool)> &slot)
+MGTwoLevelTransferNonNested<dim, VectorType>::connect_restriction(
+ const std::function<void(const bool)> &slot)
{
return signals_non_nested.restriction.connect(slot);
}