]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Copy Tpetra vector if we need to call "sync" 15737/head
authorDaniel Arndt <arndtd@ornl.gov>
Thu, 13 Jul 2023 13:09:20 +0000 (09:09 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Thu, 13 Jul 2023 13:09:41 +0000 (09:09 -0400)
include/deal.II/lac/vector_element_access.h

index fbc849e1b93daf2761d4dfea64a8e4982ae3ad51..4d7d6873011aba5e77ae7a08392c692292c29353 100644 (file)
@@ -228,20 +228,21 @@ namespace internal
     const types::global_dof_index                            i)
   {
     // Extract local indices in the vector.
-    const Tpetra::Vector<NumberType, int, types::signed_global_dof_index>
-      &                               vector = V.trilinos_vector();
-    TrilinosWrappers::types::int_type trilinos_i =
-      vector.getMap()->getLocalElement(
-        static_cast<TrilinosWrappers::types::int_type>(i));
-
 #    if DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0)
+    const Tpetra::Vector<NumberType, int, types::signed_global_dof_index>
+      &  vector = V.trilinos_vector();
     auto vector_2d =
       vector.template getLocalView<Kokkos::HostSpace>(Tpetra::Access::ReadOnly);
 #    else
+    Tpetra::Vector<NumberType, int, types::signed_global_dof_index> vector =
+      V.trilinos_vector();
     vector.template sync<Kokkos::HostSpace>();
     auto vector_2d = vector.template getLocalView<Kokkos::HostSpace>();
 #    endif
     auto vector_1d = Kokkos::subview(vector_2d, Kokkos::ALL(), 0);
+    TrilinosWrappers::types::int_type trilinos_i =
+      vector.getMap()->getLocalElement(
+        static_cast<TrilinosWrappers::types::int_type>(i));
     return vector_1d(trilinos_i);
   }
 #  endif

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.