]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use correct template parameters also for 64bit-indices
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Fri, 2 Nov 2018 18:59:37 +0000 (19:59 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Wed, 20 Feb 2019 12:46:19 +0000 (13:46 +0100)
include/deal.II/base/index_set.h
include/deal.II/lac/read_write_vector.h
include/deal.II/lac/read_write_vector.templates.h
include/deal.II/lac/trilinos_tpetra_communication_pattern.h
include/deal.II/lac/trilinos_tpetra_vector.h
include/deal.II/lac/vector_element_access.h
source/base/index_set.cc
source/lac/trilinos_tpetra_communication_pattern.cc
source/lac/trilinos_tpetra_vector.cc

index 2e21fab6449883be1a565c54663e8b31e7d4b5ae..afb90fe2d784cf9502f231ff0542d5b3e6488fbb 100644 (file)
@@ -448,7 +448,7 @@ public:
   make_trilinos_map(const MPI_Comm &communicator = MPI_COMM_WORLD,
                     const bool      overlapping  = false) const;
 
-  Tpetra::Map<>
+  Tpetra::Map<int, types::global_dof_index>
   make_tpetra_map(const MPI_Comm &communicator = MPI_COMM_WORLD,
                   const bool      overlapping  = false) const;
 #endif
index 0ed6f9d829d3f204a6377a566c0beadd12f29210..b72a95eae23345c8e5b9edb1835b4534c25ff4af 100644 (file)
@@ -615,12 +615,13 @@ namespace LinearAlgebra
      * used directly.
      */
     void
-    import(const Tpetra::Vector<Number> &tpetra_vector,
-           const IndexSet &              locally_owned_elements,
-           VectorOperation::values       operation,
-           const MPI_Comm &              mpi_comm,
-           const std::shared_ptr<const CommunicationPatternBase>
-             &communication_pattern);
+    import(
+      const Tpetra::Vector<Number, int, types::global_dof_index> &tpetra_vector,
+      const IndexSet &        locally_owned_elements,
+      VectorOperation::values operation,
+      const MPI_Comm &        mpi_comm,
+      const std::shared_ptr<const CommunicationPatternBase>
+        &communication_pattern);
 
     /**
      * Import all the elements present in the vector's IndexSet from the input
index 9da3c32e68e0218dfa37f42318c17b388a51323c..572c28f1dec919cdc3f1a88db0ac1fce159f75cd 100644 (file)
@@ -509,10 +509,10 @@ namespace LinearAlgebra
   template <typename Number>
   void
   ReadWriteVector<Number>::import(
-    const Tpetra::Vector<Number> &vector,
-    const IndexSet &              source_elements,
-    VectorOperation::values       operation,
-    const MPI_Comm &              mpi_comm,
+    const Tpetra::Vector<Number, int, types::global_dof_index> &vector,
+    const IndexSet &                                            source_elements,
+    VectorOperation::values                                     operation,
+    const MPI_Comm &                                            mpi_comm,
     const std::shared_ptr<const CommunicationPatternBase>
       &communication_pattern)
   {
@@ -552,9 +552,11 @@ namespace LinearAlgebra
                       "LinearAlgebra::TpetraWrappers::CommunicationPattern."));
       }
 
-    Tpetra::Export<> tpetra_export(tpetra_comm_pattern->get_tpetra_export());
+    Tpetra::Export<int, types::global_dof_index> tpetra_export(
+      tpetra_comm_pattern->get_tpetra_export());
 
-    Tpetra::Vector<Number> target_vector(tpetra_export.getSourceMap());
+    Tpetra::Vector<Number, int, types::global_dof_index> target_vector(
+      tpetra_export.getSourceMap());
     target_vector.doImport(vector, tpetra_export, Tpetra::REPLACE);
 
     const auto *new_values = target_vector.getData().get();
index a3a23726fecbbf55165f6c01125fc9881672dbe5..fd3e074b2aa9595b37b00d4081d1c2e8248fdaad 100644 (file)
@@ -70,13 +70,13 @@ namespace LinearAlgebra
       /**
        * Return the underlying Tpetra::Import object.
        */
-      const Tpetra::Import<> &
+      const Tpetra::Import<int, types::global_dof_index> &
       get_tpetra_import() const;
 
       /**
        * Return the underlying Tpetra::Export object.
        */
-      const Tpetra::Export<> &
+      const Tpetra::Export<int, types::global_dof_index> &
       get_tpetra_export() const;
 
     private:
@@ -88,12 +88,14 @@ namespace LinearAlgebra
       /**
        * Shared pointer to the Tpetra::Import object used.
        */
-      std::unique_ptr<Tpetra::Import<>> tpetra_import;
+      std::unique_ptr<Tpetra::Import<int, types::global_dof_index>>
+        tpetra_import;
 
       /**
        * Shared pointer to the Tpetra::Export object used.
        */
-      std::unique_ptr<Tpetra::Export<>> tpetra_export;
+      std::unique_ptr<Tpetra::Export<int, types::global_dof_index>>
+        tpetra_export;
     };
   } // end of namespace TpetraWrappers
 } // end of namespace LinearAlgebra
index 798248703ab4ef2e6dc59e20b991177df37fea13..911863c9d99e39ee4a77b8ac6b8207acbe9247f5 100644 (file)
@@ -310,14 +310,14 @@ namespace LinearAlgebra
        * Return a const reference to the underlying Trilinos
        * Tpetra::Vector class.
        */
-      const Tpetra::Vector<Number> &
+      const Tpetra::Vector<Number, int, types::global_dof_index> &
       trilinos_vector() const;
 
       /**
        * Return a (modifyable) reference to the underlying Trilinos
        * Tpetra::Vector class.
        */
-      Tpetra::Vector<Number> &
+      Tpetra::Vector<Number, int, types::global_dof_index> &
       trilinos_vector();
 
       /**
@@ -371,7 +371,8 @@ namespace LinearAlgebra
       /**
        * Pointer to the actual Tpetra vector object.
        */
-      std::unique_ptr<Tpetra::Vector<Number>> vector;
+      std::unique_ptr<Tpetra::Vector<Number, int, types::global_dof_index>>
+        vector;
 
       /**
        * IndexSet of the elements of the last imported vector.
index 22e541033c520f1677002513f08fec06588b052b..4a81d97fdbc17f93defea4444c2661c87bea9b04 100644 (file)
@@ -133,7 +133,8 @@ namespace internal
     LinearAlgebra::TpetraWrappers::Vector<double> &V)
   {
     // Extract local indices in the vector.
-    Tpetra::Vector<double>            vector = V.trilinos_vector();
+    Tpetra::Vector<double, int, types::global_dof_index> vector =
+      V.trilinos_vector();
     TrilinosWrappers::types::int_type trilinos_i =
       vector.getMap()->getLocalElement(
         static_cast<TrilinosWrappers::types::int_type>(i));
@@ -144,7 +145,8 @@ namespace internal
     // We're going to modify the data on host.
     vector.modify<Kokkos::HostSpace>();
     vector_1d(trilinos_i) += value;
-    vector.sync<Tpetra::Vector<double>::device_type::memory_space>();
+    vector.sync<Tpetra::Vector<double, int, types::global_dof_index>::
+                  device_type::memory_space>();
   }
 
 
@@ -157,7 +159,8 @@ namespace internal
     LinearAlgebra::TpetraWrappers::Vector<float> &V)
   {
     // Extract local indices in the vector.
-    Tpetra::Vector<float>             vector = V.trilinos_vector();
+    Tpetra::Vector<float, int, types::global_dof_index> vector =
+      V.trilinos_vector();
     TrilinosWrappers::types::int_type trilinos_i =
       vector.getMap()->getLocalElement(
         static_cast<TrilinosWrappers::types::int_type>(i));
@@ -168,7 +171,8 @@ namespace internal
     // We're going to modify the data on host.
     vector.modify<Kokkos::HostSpace>();
     vector_1d(trilinos_i) += value;
-    vector.sync<Tpetra::Vector<float>::device_type::memory_space>();
+    vector.sync<Tpetra::Vector<float, int, types::global_dof_index>::
+                  device_type::memory_space>();
   }
 
 
@@ -181,7 +185,8 @@ namespace internal
     LinearAlgebra::TpetraWrappers::Vector<double> &V)
   {
     // Extract local indices in the vector.
-    Tpetra::Vector<double>            vector = V.trilinos_vector();
+    Tpetra::Vector<double, int, types::global_dof_index> vector =
+      V.trilinos_vector();
     TrilinosWrappers::types::int_type trilinos_i =
       vector.getMap()->getLocalElement(
         static_cast<TrilinosWrappers::types::int_type>(i));
@@ -192,7 +197,8 @@ namespace internal
     // We're going to modify the data on host.
     vector.modify<Kokkos::HostSpace>();
     vector_1d(trilinos_i) = value;
-    vector.sync<Tpetra::Vector<double>::device_type::memory_space>();
+    vector.sync<Tpetra::Vector<double, int, types::global_dof_index>::
+                  device_type::memory_space>();
   }
 
 
@@ -205,7 +211,8 @@ namespace internal
     LinearAlgebra::TpetraWrappers::Vector<float> &V)
   {
     // Extract local indices in the vector.
-    Tpetra::Vector<float>             vector = V.trilinos_vector();
+    Tpetra::Vector<float, int, types::global_dof_index> vector =
+      V.trilinos_vector();
     TrilinosWrappers::types::int_type trilinos_i =
       vector.getMap()->getLocalElement(
         static_cast<TrilinosWrappers::types::int_type>(i));
@@ -216,7 +223,8 @@ namespace internal
     // We're going to modify the data on host.
     vector.modify<Kokkos::HostSpace>();
     vector_1d(trilinos_i) = value;
-    vector.sync<Tpetra::Vector<float>::device_type::memory_space>();
+    vector.sync<Tpetra::Vector<float, int, types::global_dof_index>::
+                  device_type::memory_space>();
   }
 
 
@@ -228,7 +236,8 @@ namespace internal
     const types::global_dof_index                        i)
   {
     // Extract local indices in the vector.
-    Tpetra::Vector<double>            vector = V.trilinos_vector();
+    Tpetra::Vector<double, int, types::global_dof_index> vector =
+      V.trilinos_vector();
     TrilinosWrappers::types::int_type trilinos_i =
       vector.getMap()->getLocalElement(
         static_cast<TrilinosWrappers::types::int_type>(i));
@@ -249,7 +258,8 @@ namespace internal
     const types::global_dof_index                       i)
   {
     // Extract local indices in the vector.
-    Tpetra::Vector<float>             vector = V.trilinos_vector();
+    Tpetra::Vector<float, int, types::global_dof_index> vector =
+      V.trilinos_vector();
     TrilinosWrappers::types::int_type trilinos_i =
       vector.getMap()->getLocalElement(
         static_cast<TrilinosWrappers::types::int_type>(i));
index 143efc6dc6b49843570276c6eac61cad9c240d7d..d9257454852e02760fc66e7163828d7fba2e8b17 100644 (file)
@@ -520,7 +520,7 @@ IndexSet::fill_index_vector(std::vector<size_type> &indices) const
 
 #ifdef DEAL_II_WITH_TRILINOS
 
-Tpetra::Map<>
+Tpetra::Map<int, types::global_dof_index>
 IndexSet::make_tpetra_map(const MPI_Comm &communicator,
                           const bool      overlapping) const
 {
@@ -556,29 +556,31 @@ IndexSet::make_tpetra_map(const MPI_Comm &communicator,
   const bool linear =
     overlapping ? false : is_ascending_and_one_to_one(communicator);
   if (linear)
-    return Tpetra::Map<>(size(),
-                         n_elements(),
-                         0,
+    return Tpetra::Map<int, types::global_dof_index>(
+      size(),
+      n_elements(),
+      0,
 #  ifdef DEAL_II_WITH_MPI
-                         Teuchos::rcp(new Teuchos::MpiComm<int>(communicator))
+      Teuchos::rcp(new Teuchos::MpiComm<int>(communicator))
 #  else
-                         Teuchos::rcp(new Teuchos::Comm<int>())
+      Teuchos::rcp(new Teuchos::Comm<int>())
 #  endif
     );
   else
     {
       std::vector<size_type> indices;
       fill_index_vector(indices);
-      std::vector<int> int_indices(indices.size());
+      std::vector<types::global_dof_index> int_indices(indices.size());
       std::copy(indices.begin(), indices.end(), int_indices.begin());
-      const Teuchos::ArrayView<int> arr_view(int_indices);
-      return Tpetra::Map<>(size(),
-                           arr_view,
-                           0,
+      const Teuchos::ArrayView<types::global_dof_index> arr_view(int_indices);
+      return Tpetra::Map<int, types::global_dof_index>(
+        size(),
+        arr_view,
+        0,
 #  ifdef DEAL_II_WITH_MPI
-                           Teuchos::rcp(new Teuchos::MpiComm<int>(communicator))
+        Teuchos::rcp(new Teuchos::MpiComm<int>(communicator))
 #  else
-                           Teuchos::rcp(new Teuchos::Comm<int>())
+        Teuchos::rcp(new Teuchos::Comm<int>())
 #  endif
       );
     }
index e78dfda3d3d1d6905ccde7b74443ccfc9f09376e..626622d49d36a8d459ee56880032ef9c787c8997 100644 (file)
@@ -55,20 +55,22 @@ namespace LinearAlgebra
     {
       comm = std::make_shared<const MPI_Comm>(communicator);
 
-      auto vector_space_vector_map = Teuchos::rcp(new Tpetra::Map<>(
-        vector_space_vector_index_set.make_tpetra_map(*comm, false)));
-      auto read_write_vector_map   = Teuchos::rcp(new Tpetra::Map<>(
-        read_write_vector_index_set.make_tpetra_map(*comm, true)));
+      auto vector_space_vector_map =
+        Teuchos::rcp(new Tpetra::Map<int, types::global_dof_index>(
+          vector_space_vector_index_set.make_tpetra_map(*comm, false)));
+      auto read_write_vector_map =
+        Teuchos::rcp(new Tpetra::Map<int, types::global_dof_index>(
+          read_write_vector_index_set.make_tpetra_map(*comm, true)));
 
       // Target map is read_write_vector_map
       // Source map is vector_space_vector_map. This map must have uniquely
       // owned GID.
       tpetra_import =
-        std_cxx14::make_unique<Tpetra::Import<>>(read_write_vector_map,
-                                                 vector_space_vector_map);
+        std_cxx14::make_unique<Tpetra::Import<int, types::global_dof_index>>(
+          read_write_vector_map, vector_space_vector_map);
       tpetra_export =
-        std_cxx14::make_unique<Tpetra::Export<>>(read_write_vector_map,
-                                                 vector_space_vector_map);
+        std_cxx14::make_unique<Tpetra::Export<int, types::global_dof_index>>(
+          read_write_vector_map, vector_space_vector_map);
     }
 
 
@@ -81,7 +83,7 @@ namespace LinearAlgebra
 
 
 
-    const Tpetra::Import<> &
+    const Tpetra::Import<int, types::global_dof_index> &
     CommunicationPattern::get_tpetra_import() const
     {
       return *tpetra_import;
@@ -89,7 +91,7 @@ namespace LinearAlgebra
 
 
 
-    const Tpetra::Export<> &
+    const Tpetra::Export<int, types::global_dof_index> &
     CommunicationPattern::get_tpetra_export() const
     {
       return *tpetra_export;
index 264f21da77c959fce1df7afe64d5b9c289645d2b..f4e368669728c7ba1e44ccb3469b903009b1c0dc 100644 (file)
@@ -42,8 +42,12 @@ namespace LinearAlgebra
   {
     template <typename Number>
     Vector<Number>::Vector()
-      : vector(new Tpetra::Vector<Number>(Teuchos::RCP<Tpetra::Map<>>(
-          new Tpetra::Map<>(0, 0, Utilities::Trilinos::tpetra_comm_self()))))
+      : vector(new Tpetra::Vector<Number, int, types::global_dof_index>(
+          Teuchos::RCP<Tpetra::Map<int, types::global_dof_index>>(
+            new Tpetra::Map<int, types::global_dof_index>(
+              0,
+              0,
+              Utilities::Trilinos::tpetra_comm_self()))))
     {}
 
 
@@ -51,7 +55,9 @@ namespace LinearAlgebra
     template <typename Number>
     Vector<Number>::Vector(const Vector<Number> &V)
       : Subscriptor()
-      , vector(new Tpetra::Vector<Number>(V.trilinos_vector(), Teuchos::Copy))
+      , vector(new Tpetra::Vector<Number, int, types::global_dof_index>(
+          V.trilinos_vector(),
+          Teuchos::Copy))
     {}
 
 
@@ -59,8 +65,9 @@ namespace LinearAlgebra
     template <typename Number>
     Vector<Number>::Vector(const IndexSet &parallel_partitioner,
                            const MPI_Comm &communicator)
-      : vector(new Tpetra::Vector<Number>(Teuchos::rcp(new Tpetra::Map<>(
-          parallel_partitioner.make_tpetra_map(communicator, false)))))
+      : vector(new Tpetra::Vector<Number, int, types::global_dof_index>(
+          Teuchos::rcp(new Tpetra::Map<int, types::global_dof_index>(
+            parallel_partitioner.make_tpetra_map(communicator, false)))))
     {}
 
 
@@ -71,11 +78,12 @@ namespace LinearAlgebra
                            const MPI_Comm &communicator,
                            const bool      omit_zeroing_entries)
     {
-      Tpetra::Map<> input_map =
+      Tpetra::Map<int, types::global_dof_index> input_map =
         parallel_partitioner.make_tpetra_map(communicator, false);
       if (vector->getMap()->isSameAs(input_map) == false)
-        vector = std_cxx14::make_unique<Tpetra::Vector<Number>>(
-          Teuchos::rcp(new Tpetra::Map<>(input_map)));
+        vector = std_cxx14::make_unique<
+          Tpetra::Vector<Number, int, types::global_dof_index>>(Teuchos::rcp(
+          new Tpetra::Map<int, types::global_dof_index>(input_map)));
       else if (omit_zeroing_entries == false)
         {
           vector->putScalar(0.);
@@ -117,15 +125,16 @@ namespace LinearAlgebra
         {
           if (size() == V.size())
             {
-              Tpetra::Import<> data_exchange(vector->getMap(),
-                                             V.trilinos_vector().getMap());
+              Tpetra::Import<int, types::global_dof_index> data_exchange(
+                vector->getMap(), V.trilinos_vector().getMap());
 
               vector->doImport(V.trilinos_vector(),
                                data_exchange,
                                Tpetra::REPLACE);
             }
           else
-            vector = std_cxx14::make_unique<Tpetra::Vector<Number>>(
+            vector = std_cxx14::make_unique<
+              Tpetra::Vector<Number, int, types::global_dof_index>>(
               V.trilinos_vector());
         }
 
@@ -185,8 +194,10 @@ namespace LinearAlgebra
               "LinearAlgebra::TpetraWrappers::CommunicationPattern."));
         }
 
-      Tpetra::Export<> tpetra_export(tpetra_comm_pattern->get_tpetra_export());
-      Tpetra::Vector<Number> source_vector(tpetra_export.getSourceMap());
+      Tpetra::Export<int, types::global_dof_index> tpetra_export(
+        tpetra_comm_pattern->get_tpetra_export());
+      Tpetra::Vector<Number, int, types::global_dof_index> source_vector(
+        tpetra_export.getSourceMap());
 
       source_vector.template sync<Kokkos::HostSpace>();
       auto x_2d = source_vector.template getLocalView<Kokkos::HostSpace>();
@@ -197,7 +208,8 @@ namespace LinearAlgebra
       for (size_t k = 0; k < localLength; ++k)
         x_1d(k) = *values_it++;
       source_vector.template sync<
-        typename Tpetra::Vector<Number>::device_type::memory_space>();
+        typename Tpetra::Vector<Number, int, types::global_dof_index>::
+          device_type::memory_space>();
       if (operation == VectorOperation::insert)
         vector->doExport(source_vector, tpetra_export, Tpetra::REPLACE);
       else if (operation == VectorOperation::add)
@@ -254,15 +266,16 @@ namespace LinearAlgebra
                  ExcDimensionMismatch(this->size(), down_V.size()));
 
           // TODO: The code doesn't work as expected so we use a workaround.
-          /*Tpetra::Export<> data_exchange(vector->getMap(),
-                                         down_V.trilinos_vector().getMap());
+          /*Tpetra::Export<int, types::global_dof_index>
+          data_exchange(vector->getMap(), down_V.trilinos_vector().getMap());
           vector->doExport(down_V.trilinos_vector(),
                            data_exchange,
                            Tpetra::ADD);*/
 
-          Tpetra::Vector<Number> dummy(vector->getMap(), false);
-          Tpetra::Import<>       data_exchange(dummy.getMap(),
-                                         down_V.trilinos_vector().getMap());
+          Tpetra::Vector<Number, int, types::global_dof_index> dummy(
+            vector->getMap(), false);
+          Tpetra::Import<int, types::global_dof_index> data_exchange(
+            dummy.getMap(), down_V.trilinos_vector().getMap());
 
           dummy.doExport(down_V.trilinos_vector(),
                          data_exchange,
@@ -322,7 +335,8 @@ namespace LinearAlgebra
           vector_1d(k) += a;
         }
       vector->template sync<
-        typename Tpetra::Vector<Number>::device_type::memory_space>();
+        typename Tpetra::Vector<Number, int, types::global_dof_index>::
+          device_type::memory_space>();
     }
 
 
@@ -577,7 +591,7 @@ namespace LinearAlgebra
 
 
     template <typename Number>
-    const Tpetra::Vector<Number> &
+    const Tpetra::Vector<Number, int, types::global_dof_index> &
     Vector<Number>::trilinos_vector() const
     {
       return *vector;
@@ -586,7 +600,7 @@ namespace LinearAlgebra
 
 
     template <typename Number>
-    Tpetra::Vector<Number> &
+    Tpetra::Vector<Number, int, types::global_dof_index> &
     Vector<Number>::trilinos_vector()
     {
       return *vector;

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.