]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Implementation for TpetraWrappers::Vector::operator Number() 16613/head
authorSebastian Kinnewig <kinnewig@ifam.uni-hannover.de>
Fri, 9 Feb 2024 08:46:23 +0000 (09:46 +0100)
committerSebastian Kinnewig <kinnewig@ifam.uni-hannover.de>
Fri, 9 Feb 2024 08:46:23 +0000 (09:46 +0100)
include/deal.II/lac/trilinos_tpetra_vector.templates.h

index cfb5ecfb2bec580e7e6025e0924c5e0587b5b106..eed13a0575f616c3786b9b9d77c8590d1e075429 100644 (file)
@@ -44,6 +44,37 @@ namespace LinearAlgebra
 {
   namespace TpetraWrappers
   {
+    namespace internal
+    {
+      template <typename Number, typename MemorySpace>
+      VectorReference<Number, MemorySpace>::operator Number() const
+      {
+        // Get the local index
+        const TrilinosWrappers::types::int_type local_index =
+          vector.vector->getMap()->getLocalElement(
+            static_cast<TrilinosWrappers::types::int_type>(index));
+
+#  if DEAL_II_TRILINOS_VERSION_GTE(14, 0, 0)
+        Assert((local_index != Teuchos::OrdinalTraits<int>::invalid()),
+               ExcAccessToNonLocalElement(
+                 index,
+                 vector.vector->getMap()->getLocalNumElements(),
+                 vector.vector->getMap()->getMinLocalIndex(),
+                 vector.vector->getMap()->getMaxLocalIndex()));
+#  else
+        Assert((local_index != Teuchos::OrdinalTraits<int>::invalid()),
+               ExcAccessToNonLocalElement(
+                 index,
+                 vector.vector->getMap()->getNodeNumElements(),
+                 vector.vector->getMap()->getMinLocalIndex(),
+                 vector.vector->getMap()->getMaxLocalIndex()));
+#  endif
+        return vector.vector->getData()[local_index];
+      }
+    } // namespace internal
+
+
+
     template <typename Number, typename MemorySpace>
     Vector<Number, MemorySpace>::Vector()
       : Subscriptor()

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.