]> https://gitweb.dealii.org/ - dealii.git/commitdiff
LA::d::BV add copy_locally_owned_data_from() 13396/head
authorPeter Munch <peterrmuench@gmail.com>
Wed, 16 Feb 2022 07:11:51 +0000 (08:11 +0100)
committerPeter Munch <peterrmuench@gmail.com>
Wed, 16 Feb 2022 07:11:51 +0000 (08:11 +0100)
include/deal.II/lac/la_parallel_block_vector.h
include/deal.II/lac/la_parallel_block_vector.templates.h
source/lac/la_parallel_block_vector.inst.in

index 13fe98bbbb500a320771ffecbb6973fa8edaee5a..ed6f38500f9f9aa169b6d32fd83f826019f66d03 100644 (file)
@@ -366,6 +366,24 @@ namespace LinearAlgebra
       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 BlockVector<Number2> &src);
+
       /**
        * This is a collective add operation that adds a whole set of values
        * stored in @p values to the vector components specified by @p indices.
index 188d03138a23835127f302d02ae249e97b8e5179..8583819aef35dc37fbecb65f8f6e9fb8e3e9741c 100644 (file)
@@ -211,6 +211,20 @@ namespace LinearAlgebra
 
 
 
+    template <typename Number>
+    template <typename Number2>
+    void
+    BlockVector<Number>::copy_locally_owned_data_from(
+      const BlockVector<Number2> &v)
+    {
+      AssertDimension(this->n_blocks(), v.n_blocks());
+
+      for (unsigned int b = 0; b < this->n_blocks(); ++b)
+        this->block(b).copy_locally_owned_data_from(v.block(b));
+    }
+
+
+
 #ifdef DEAL_II_WITH_PETSC
 
     namespace petsc_helpers
index 7968153ad289d9fe0d9debd4f4210360b40e0bf4..eb29b8491e50a32c4bebbc4e79defbee43b72858 100644 (file)
@@ -65,6 +65,9 @@ for (S1 : REAL_AND_COMPLEX_SCALARS; S2 : REAL_SCALARS)
         template void
         BlockVector<S1>::reinit<S2>(const BlockVector<S2> &, const bool);
         template void
+        BlockVector<S1>::copy_locally_owned_data_from<S2>(
+          const BlockVector<S2> &);
+        template void
         BlockVector<S1>::add<S2>(const std::vector<size_type> &,
                                  const ::dealii::Vector<S2> &);
       \}
@@ -82,6 +85,9 @@ for (S1, S2 : COMPLEX_SCALARS)
         template void
         BlockVector<S1>::reinit<S2>(const BlockVector<S2> &, const bool);
         template void
+        BlockVector<S1>::copy_locally_owned_data_from<S2>(
+          const BlockVector<S2> &);
+        template void
         BlockVector<S1>::add<S2>(const std::vector<size_type> &,
                                  const ::dealii::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.