]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Also remove the specialization structure of MGTwoLevelTransferNonNested. 16730/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 7 Mar 2024 17:01:55 +0000 (10:01 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 7 Mar 2024 17:01:55 +0000 (10:01 -0700)
include/deal.II/multigrid/mg_transfer_global_coarsening.h
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h

index f84b2ea795eaafcdfa4b58842a0f9da5df4587f2..6f6e63727263cc74117563ba1682736d3609d6a6 100644 (file)
@@ -206,9 +206,10 @@ namespace MGTransferGlobalCoarseningTools
 } // 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.
@@ -651,54 +652,19 @@ private:
 
 /**
  * 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;
@@ -752,6 +718,9 @@ public:
     bool enforce_all_points_found;
   };
 
+  /**
+   * Constructor.
+   */
   MGTwoLevelTransferNonNested(const AdditionalData &data = AdditionalData());
 
   /**
@@ -775,9 +744,7 @@ public:
    * 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
@@ -826,17 +793,15 @@ protected:
    * 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:
   /**
@@ -844,18 +809,15 @@ 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.
index 3025bd18a95675371c5fc13413cba20e2bc8db32..69cabe4a3b1c9b6de7c4bc6a803ff23947abc2d9 100644 (file)
@@ -4716,9 +4716,9 @@ namespace internal
 
 
 
-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,
@@ -4727,15 +4727,15 @@ MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
       {}))
 {}
 
-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());
@@ -4889,13 +4889,12 @@ namespace internal
 
 
 
-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>;
@@ -5001,12 +5000,11 @@ MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<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);
@@ -5018,13 +5016,12 @@ MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
 
 
 
-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>;
@@ -5126,12 +5123,11 @@ MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<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);
@@ -5143,11 +5139,11 @@ MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
 
 
 
-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;
@@ -5156,9 +5152,9 @@ MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
 
 
 
-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,
@@ -5175,10 +5171,9 @@ MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
 
 
 
-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;
 
@@ -5192,40 +5187,40 @@ MGTwoLevelTransferNonNested<dim, LinearAlgebra::distributed::Vector<Number>>::
 
 
 
-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);
 }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.