From 54e52a86a8ccf6c6839854db03530071bcf998cb Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Wed, 19 Sep 2018 23:54:23 +0200 Subject: [PATCH] Support older Trilinos versions --- .../lac/trilinos_tpetra_communication_pattern.h | 1 + source/base/index_set.cc | 4 ++-- source/lac/trilinos_tpetra_vector.cc | 10 +++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/deal.II/lac/trilinos_tpetra_communication_pattern.h b/include/deal.II/lac/trilinos_tpetra_communication_pattern.h index 8dc7cf7874..a3a23726fe 100644 --- a/include/deal.II/lac/trilinos_tpetra_communication_pattern.h +++ b/include/deal.II/lac/trilinos_tpetra_communication_pattern.h @@ -25,6 +25,7 @@ # include +# include # include # include diff --git a/source/base/index_set.cc b/source/base/index_set.cc index 6fe2920ffe..143efc6dc6 100644 --- a/source/base/index_set.cc +++ b/source/base/index_set.cc @@ -571,9 +571,9 @@ IndexSet::make_tpetra_map(const MPI_Comm &communicator, fill_index_vector(indices); std::vector int_indices(indices.size()); std::copy(indices.begin(), indices.end(), int_indices.begin()); + const Teuchos::ArrayView arr_view(int_indices); return Tpetra::Map<>(size(), - (n_elements() > 0 ? int_indices.data() : nullptr), - n_elements(), + arr_view, 0, # ifdef DEAL_II_WITH_MPI Teuchos::rcp(new Teuchos::MpiComm(communicator)) diff --git a/source/lac/trilinos_tpetra_vector.cc b/source/lac/trilinos_tpetra_vector.cc index 88324e6d53..dae177f7e5 100644 --- a/source/lac/trilinos_tpetra_vector.cc +++ b/source/lac/trilinos_tpetra_vector.cc @@ -561,9 +561,13 @@ namespace LinearAlgebra else if (vector->getLocalLength() > 0) { const size_type n_indices = vector->getLocalLength(); - auto vector_indices = vector->getMap()->getMyGlobalIndices(); - is.add_indices((unsigned int *)&vector_indices[0], - (unsigned int *)&vector_indices[0] + n_indices); + std::vector vector_indices; + vector_indices.reserve(n_indices); + for (unsigned int i = 0; i < n_indices; ++i) + vector_indices.push_back(vector->getMap()->getGlobalElement(i)); + + is.add_indices(vector_indices.data(), + vector_indices.data() + n_indices); } is.compress(); -- 2.39.5