From: David Wells Date: Sat, 29 Apr 2017 02:20:14 +0000 (-0400) Subject: Un-inline PETScWrappers::MPI::Vector::operator=(Vector &). X-Git-Tag: v9.0.0-rc1~1638^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4330%2Fhead;p=dealii.git Un-inline PETScWrappers::MPI::Vector::operator=(Vector &). This function is long enough that the compiler probably won't inline it anyway. --- diff --git a/include/deal.II/lac/petsc_parallel_vector.h b/include/deal.II/lac/petsc_parallel_vector.h index fcd19d58ba..1ce64fe10a 100644 --- a/include/deal.II/lac/petsc_parallel_vector.h +++ b/include/deal.II/lac/petsc_parallel_vector.h @@ -471,43 +471,6 @@ namespace PETScWrappers - inline - Vector & - Vector::operator= (const Vector &v) - { - // make sure left- and right-hand side of the assignment are compress()'ed: - Assert(v.last_action == VectorOperation::unknown, - internal::VectorReference::ExcWrongMode (VectorOperation::unknown, - v.last_action)); - Assert(last_action == VectorOperation::unknown, - internal::VectorReference::ExcWrongMode (VectorOperation::unknown, - last_action)); - - // if the vectors have different sizes, - // then first resize the present one - if (size() != v.size()) - { - if (v.has_ghost_elements()) - reinit( v.locally_owned_elements(), v.ghost_indices, v.communicator); - else - reinit (v.communicator, v.size(), v.local_size(), true); - } - - PetscErrorCode ierr = VecCopy (v.vector, vector); - AssertThrow (ierr == 0, ExcPETScError(ierr)); - - if (has_ghost_elements()) - { - ierr = VecGhostUpdateBegin(vector, INSERT_VALUES, SCATTER_FORWARD); - AssertThrow (ierr == 0, ExcPETScError(ierr)); - ierr = VecGhostUpdateEnd(vector, INSERT_VALUES, SCATTER_FORWARD); - AssertThrow (ierr == 0, ExcPETScError(ierr)); - } - return *this; - } - - - template inline Vector & diff --git a/source/lac/petsc_parallel_vector.cc b/source/lac/petsc_parallel_vector.cc index 5965ffaa93..a296d7ef9f 100644 --- a/source/lac/petsc_parallel_vector.cc +++ b/source/lac/petsc_parallel_vector.cc @@ -96,6 +96,42 @@ namespace PETScWrappers + Vector & + Vector::operator= (const Vector &v) + { + // make sure left- and right-hand side of the assignment are compress()'ed: + Assert(v.last_action == VectorOperation::unknown, + internal::VectorReference::ExcWrongMode (VectorOperation::unknown, + v.last_action)); + Assert(last_action == VectorOperation::unknown, + internal::VectorReference::ExcWrongMode (VectorOperation::unknown, + last_action)); + + // if the vectors have different sizes, + // then first resize the present one + if (size() != v.size()) + { + if (v.has_ghost_elements()) + reinit( v.locally_owned_elements(), v.ghost_indices, v.communicator); + else + reinit (v.communicator, v.size(), v.local_size(), true); + } + + PetscErrorCode ierr = VecCopy (v.vector, vector); + AssertThrow (ierr == 0, ExcPETScError(ierr)); + + if (has_ghost_elements()) + { + ierr = VecGhostUpdateBegin(vector, INSERT_VALUES, SCATTER_FORWARD); + AssertThrow (ierr == 0, ExcPETScError(ierr)); + ierr = VecGhostUpdateEnd(vector, INSERT_VALUES, SCATTER_FORWARD); + AssertThrow (ierr == 0, ExcPETScError(ierr)); + } + return *this; + } + + + void Vector::clear () {