From 8b76dd9aa6d9840564ca115b3a2b4b209ee05de9 Mon Sep 17 00:00:00 2001 From: "denis.davydov" Date: Wed, 5 Mar 2014 16:00:24 +0000 Subject: [PATCH] adopted to the recently introduced Vector::operator= (const PETScWrappers::MPI::Vector &) as advised by Martin Kronbichler git-svn-id: https://svn.dealii.org/branches/branch_petscscalar_complex@32623 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/lac/parallel_vector.templates.h | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/deal.II/include/deal.II/lac/parallel_vector.templates.h b/deal.II/include/deal.II/lac/parallel_vector.templates.h index 252c5b926c..af145077fa 100644 --- a/deal.II/include/deal.II/lac/parallel_vector.templates.h +++ b/deal.II/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); @@ -236,7 +263,7 @@ namespace parallel // return a pointer to this object per normal c++ operator overloading // semantics return *this; - } + } #endif -- 2.39.5