]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Override MGTransferGlobalCoarsening::prolongate_and_add() 12635/head
authorPeter Munch <peterrmuench@gmail.com>
Tue, 10 Aug 2021 09:14:18 +0000 (11:14 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Tue, 10 Aug 2021 09:14:18 +0000 (11:14 +0200)
include/deal.II/multigrid/mg_transfer_global_coarsening.h
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
tests/multigrid-global-coarsening/mg_transfer_util.h

index 38790e66e5835339ecece076dbc93acd248141bd..1edbf0d7bf8bf28bf1db12ed68e836d3ce52430b 100644 (file)
@@ -159,7 +159,7 @@ public:
    * Perform prolongation.
    */
   void
-  prolongate(VectorType &dst, const VectorType &src) const;
+  prolongate_and_add(VectorType &dst, const VectorType &src) const;
 
   /**
    * Perform restriction.
@@ -253,8 +253,9 @@ public:
    * Perform prolongation.
    */
   void
-  prolongate(LinearAlgebra::distributed::Vector<Number> &      dst,
-             const LinearAlgebra::distributed::Vector<Number> &src) const;
+  prolongate_and_add(
+    LinearAlgebra::distributed::Vector<Number> &      dst,
+    const LinearAlgebra::distributed::Vector<Number> &src) const;
 
   /**
    * Perform restriction.
@@ -475,6 +476,14 @@ public:
              VectorType &       dst,
              const VectorType & src) const override;
 
+  /**
+   * Perform prolongation.
+   */
+  void
+  prolongate_and_add(const unsigned int to_level,
+                     VectorType &       dst,
+                     const VectorType & src) const override;
+
   /**
    * Perform restriction.
    */
@@ -566,7 +575,20 @@ MGTransferGlobalCoarsening<dim, VectorType>::prolongate(
   VectorType &       dst,
   const VectorType & src) const
 {
-  this->transfer[to_level].prolongate(dst, src);
+  dst = 0;
+  prolongate_and_add(to_level, dst, src);
+}
+
+
+
+template <int dim, typename VectorType>
+void
+MGTransferGlobalCoarsening<dim, VectorType>::prolongate_and_add(
+  const unsigned int to_level,
+  VectorType &       dst,
+  const VectorType & src) const
+{
+  this->transfer[to_level].prolongate_and_add(dst, src);
 }
 
 
index 2bdb1f0bc9301d043ae7ca507bc8a4fe77e75025..5bf9a45126c89ee2d9bf3f1227a5253da61d187c 100644 (file)
@@ -2296,9 +2296,10 @@ namespace MGTransferGlobalCoarseningTools
 
 template <int dim, typename Number>
 void
-MGTwoLevelTransfer<dim, LinearAlgebra::distributed::Vector<Number>>::prolongate(
-  LinearAlgebra::distributed::Vector<Number> &      dst,
-  const LinearAlgebra::distributed::Vector<Number> &src) const
+MGTwoLevelTransfer<dim, LinearAlgebra::distributed::Vector<Number>>::
+  prolongate_and_add(
+    LinearAlgebra::distributed::Vector<Number> &      dst,
+    const LinearAlgebra::distributed::Vector<Number> &src) const
 {
   using VectorizedArrayType = VectorizedArray<Number>;
 
@@ -2339,7 +2340,7 @@ MGTwoLevelTransfer<dim, LinearAlgebra::distributed::Vector<Number>>::prolongate(
   this->vec_coarse
     .update_ghost_values(); // note: make sure that ghost values are set
 
-  if (fine_element_is_continuous)
+  if (fine_element_is_continuous && (use_dst_inplace == false))
     *vec_fine_ptr = Number(0.);
 
   AlignedVector<VectorizedArrayType> evaluation_data_fine;
@@ -2368,7 +2369,7 @@ MGTwoLevelTransfer<dim, LinearAlgebra::distributed::Vector<Number>>::prolongate(
                     weights[i];
               else
                 for (unsigned int i = 0; i < scheme.dofs_per_cell_fine; ++i)
-                  vec_fine_ptr->local_element(indices_fine[i]) =
+                  vec_fine_ptr->local_element(indices_fine[i]) +=
                     this->vec_coarse.local_element(indices_coarse[i]);
 
               indices_fine += scheme.dofs_per_cell_fine;
@@ -2448,7 +2449,7 @@ MGTwoLevelTransfer<dim, LinearAlgebra::distributed::Vector<Number>>::prolongate(
                       evaluation_data_fine[i][v] * weights[i];
                 else
                   for (unsigned int i = 0; i < scheme.dofs_per_cell_fine; ++i)
-                    vec_fine_ptr->local_element(indices[i]) =
+                    vec_fine_ptr->local_element(indices[i]) +=
                       evaluation_data_fine[i][v];
 
                 indices += scheme.dofs_per_cell_fine;
@@ -2467,7 +2468,7 @@ MGTwoLevelTransfer<dim, LinearAlgebra::distributed::Vector<Number>>::prolongate(
     vec_fine_ptr->compress(VectorOperation::add);
 
   if (use_dst_inplace == false)
-    dst.copy_locally_owned_data_from(this->vec_fine);
+    dst += this->vec_fine;
 }
 
 
index 7cb31d2e26f15c741d6af6743c34b4689dca97d4..162541d3d3d24196488089e496064b4c1c73a4c8 100644 (file)
@@ -85,7 +85,8 @@ test_transfer_operator(
   {
     src = 0.0;
     src = 1.0;
-    transfer.prolongate(dst, src);
+    dst = 0.0;
+    transfer.prolongate_and_add(dst, src);
 
     // transfer operator sets only non-constrained dofs -> update the rest
     // via constraint matrix
@@ -114,7 +115,7 @@ test_transfer_operator(
             src[i] = 1.0;
             dst    = 0.0;
 
-            transfer.prolongate(dst, src);
+            transfer.prolongate_and_add(dst, src);
 
             for (unsigned int j = 0; j < dst.size(); j++)
               prolongation_matrix[j][i] = dst[j];

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.