From: Daniel Arndt Date: Thu, 13 Jul 2023 13:09:20 +0000 (-0400) Subject: Copy Tpetra vector if we need to call "sync" X-Git-Tag: relicensing~685^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F15737%2Fhead;p=dealii.git Copy Tpetra vector if we need to call "sync" --- diff --git a/include/deal.II/lac/vector_element_access.h b/include/deal.II/lac/vector_element_access.h index fbc849e1b9..4d7d687301 100644 --- a/include/deal.II/lac/vector_element_access.h +++ b/include/deal.II/lac/vector_element_access.h @@ -228,20 +228,21 @@ namespace internal const types::global_dof_index i) { // Extract local indices in the vector. - const Tpetra::Vector - & vector = V.trilinos_vector(); - TrilinosWrappers::types::int_type trilinos_i = - vector.getMap()->getLocalElement( - static_cast(i)); - # if DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0) + const Tpetra::Vector + & vector = V.trilinos_vector(); auto vector_2d = vector.template getLocalView(Tpetra::Access::ReadOnly); # else + Tpetra::Vector vector = + V.trilinos_vector(); vector.template sync(); auto vector_2d = vector.template getLocalView(); # endif auto vector_1d = Kokkos::subview(vector_2d, Kokkos::ALL(), 0); + TrilinosWrappers::types::int_type trilinos_i = + vector.getMap()->getLocalElement( + static_cast(i)); return vector_1d(trilinos_i); } # endif