]> https://gitweb.dealii.org/ - dealii.git/commitdiff
extend operator= for PETSc MPI vector to handle complex-valued case
authorDenis Davydov <davydden@gmail.com>
Tue, 16 Jun 2015 21:01:54 +0000 (23:01 +0200)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 17 Jun 2015 19:33:33 +0000 (14:33 -0500)
include/deal.II/lac/parallel_vector.templates.h

index 5e7ab011a99e4781bc70922d49811d9827464ed2..0230a8e926de95fbb1424c0f67a4c1df772bc87d 100644 (file)
@@ -210,6 +210,33 @@ namespace parallel
 
 #ifdef DEAL_II_WITH_PETSC
 
+    namespace internal
+    {
+      template <typename PETSC_Number, typename Number>
+      void copy_petsc_vector (const PETSC_Number *petsc_start_ptr,
+                              const PETSC_Number *petsc_end_ptr,
+                              Number *ptr)
+      {
+        std::copy(petsc_start_ptr, petsc_end_ptr, ptr);
+      }
+
+      template <typename PETSC_Number, typename Number>
+      void copy_petsc_vector (const std::complex<PETSC_Number> *petsc_start_ptr,
+                              const std::complex<PETSC_Number> *petsc_end_ptr,
+                              std::complex<Number> *ptr)
+      {
+        std::copy(petsc_start_ptr, petsc_end_ptr, ptr);
+      }
+
+      template <typename PETSC_Number, typename Number>
+      void copy_petsc_vector (const std::complex<PETSC_Number> *petsc_start_ptr,
+                              const std::complex<PETSC_Number> *petsc_end_ptr,
+                              Number *ptr)
+      {
+        AssertThrow(false, ExcMessage("Tried to copy complex -> real"));
+      }
+    }
+
     template <typename Number>
     Vector<Number> &
     Vector<Number>::operator = (const PETScWrappers::MPI::Vector &petsc_vec)
@@ -223,7 +250,7 @@ namespace parallel
       AssertThrow (ierr == 0, ExcPETScError(ierr));
 
       const size_type vec_size = local_size();
-      std::copy (start_ptr, start_ptr + vec_size, begin());
+      internal::copy_petsc_vector (start_ptr, start_ptr + vec_size, begin());
 
       // restore the representation of the vector
       ierr = VecRestoreArray (static_cast<const Vec &>(petsc_vec), &start_ptr);

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.