]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Introduce LA::d::Vector::copy_locally_owned_data_from.
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Tue, 24 Oct 2017 10:35:36 +0000 (12:35 +0200)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Tue, 24 Oct 2017 13:13:22 +0000 (15:13 +0200)
include/deal.II/lac/la_parallel_vector.h
include/deal.II/lac/la_parallel_vector.templates.h
source/lac/la_parallel_vector.inst.in

index e66f0bbf11e243f71ffc35046ad5ed48068dc757..4135df1c3aaa55353bc0911814f067f4ff524563 100644 (file)
@@ -513,6 +513,24 @@ namespace LinearAlgebra
        * @ref GlossGhostedVector "vectors with ghost elements"
        */
       bool has_ghost_elements() const;
+
+      /**
+       * This method copies the data in the locally owned range from another
+       * distributed vector @p src into the calling vector. As opposed to
+       * operator= that also includes ghost entries, this operation ignores
+       * the ghost range. The only prerequisite is that the local range on the
+       * calling vector and the given vector @p src are the same on all
+       * processors. It is explicitly allowed that the two vectors have
+       * different ghost elements that might or might not be related to each
+       * other.
+       *
+       * Since no data exchange is performed, make sure that neither @p src
+       * nor the calling vector have pending communications in order to obtain
+       * correct results.
+       */
+      template <typename Number2>
+      void copy_locally_owned_data_from(const Vector<Number2> &src);
+
       //@}
 
       /**
index 2e65d4e02f8278ca093c0c5885352f9e12538978..c5734e16a61aaf4d4b12031d7b156b4787e9821d 100644 (file)
@@ -359,7 +359,7 @@ namespace LinearAlgebra
 
       thread_loop_partitioner = c.thread_loop_partitioner;
 
-      const size_type this_size = local_size();
+      const size_type this_size = partitioner->local_size();
       if (this_size>0)
         {
           dealii::internal::VectorOperations::Vector_copy<Number,Number2> copier(c.values.get(), values.get());
@@ -376,6 +376,24 @@ namespace LinearAlgebra
 
 
 
+    template <typename Number>
+    template <typename Number2>
+    void
+    Vector<Number>::copy_locally_owned_data_from(const Vector<Number2> &src)
+    {
+      AssertDimension(partitioner->local_size(), src.partitioner->local_size());
+      if (partitioner->local_size() > 0)
+        {
+          dealii::internal::VectorOperations::Vector_copy<Number,Number2> copier(src.values.get(),
+              values.get());
+          internal::VectorOperations::parallel_for(copier, 0, partitioner->local_size(),
+                                                   thread_loop_partitioner);
+        }
+    }
+
+
+
+
 #ifdef DEAL_II_WITH_PETSC
 
     namespace petsc_helpers
@@ -534,6 +552,8 @@ namespace LinearAlgebra
     Vector<Number>::compress_finish (::dealii::VectorOperation::values operation)
     {
 #ifdef DEAL_II_WITH_MPI
+      vector_is_ghosted = false;
+
       if (compress_requests.size() == 0)
         return;
 
@@ -549,8 +569,6 @@ namespace LinearAlgebra
        ArrayView<Number>(values.get(), partitioner->local_size()),
        ArrayView<Number>(values.get() + partitioner->local_size(),partitioner->n_ghost_indices()),
        compress_requests);
-
-      vector_is_ghosted = false;
 #else
       (void)operation;
 #endif
index 21a712093b04b2c0e3768ee00aa689fb878cbce9..cdb4b357b05095ea733bb7fd046a1527ac4d8bf8 100644 (file)
@@ -34,6 +34,7 @@ for (S1, S2 : REAL_SCALARS)
     \{
     template void Vector<S1>::reinit<S2> (const Vector<S2>&,
                                           const bool);
+    template void Vector<S1>::copy_locally_owned_data_from<S2> (const Vector<S2>&);
     template S1 Vector<S1>::inner_product_local<S2> (const Vector<S2>&) const;
     \}
     \}
@@ -58,6 +59,7 @@ for (S1, S2 : COMPLEX_SCALARS)
     \{
     template void Vector<S1>::reinit<S2> (const Vector<S2>&,
                                           const bool);
+    template void Vector<S1>::copy_locally_owned_data_from<S2> (const Vector<S2>&);
     \}
     \}
 }

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.