From: Denis Davydov Date: Tue, 16 Jun 2015 21:01:54 +0000 (+0200) Subject: extend operator= for PETSc MPI vector to handle complex-valued case X-Git-Tag: v8.3.0-rc1~104^2~14 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc7e4e3e2508e3c66bec565a5391f01753938516;p=dealii.git extend operator= for PETSc MPI vector to handle complex-valued case --- diff --git a/include/deal.II/lac/parallel_vector.templates.h b/include/deal.II/lac/parallel_vector.templates.h index 5e7ab011a9..0230a8e926 100644 --- a/include/deal.II/lac/parallel_vector.templates.h +++ b/include/deal.II/lac/parallel_vector.templates.h @@ -210,6 +210,33 @@ namespace parallel #ifdef DEAL_II_WITH_PETSC + namespace internal + { + template + 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 + void copy_petsc_vector (const std::complex *petsc_start_ptr, + const std::complex *petsc_end_ptr, + std::complex *ptr) + { + std::copy(petsc_start_ptr, petsc_end_ptr, ptr); + } + + template + void copy_petsc_vector (const std::complex *petsc_start_ptr, + const std::complex *petsc_end_ptr, + Number *ptr) + { + AssertThrow(false, ExcMessage("Tried to copy complex -> real")); + } + } + template Vector & Vector::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(petsc_vec), &start_ptr);