From 56cb89850f196d5d92b6a098dd6531614c2ed5c3 Mon Sep 17 00:00:00 2001 From: Sebastian Kinnewig Date: Fri, 2 Feb 2024 11:35:56 +0100 Subject: [PATCH] Make TpetraWrapps::Vector compatible with BlockVectorBase. --- include/deal.II/lac/trilinos_tpetra_vector.h | 30 +++++++++++++++++++ .../lac/trilinos_tpetra_vector.templates.h | 2 ++ .../trilinos_tpetra_block_sparse_matrix.cc | 12 -------- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/include/deal.II/lac/trilinos_tpetra_vector.h b/include/deal.II/lac/trilinos_tpetra_vector.h index 0b9a2d3c16..6018ff6fa0 100644 --- a/include/deal.II/lac/trilinos_tpetra_vector.h +++ b/include/deal.II/lac/trilinos_tpetra_vector.h @@ -208,6 +208,34 @@ namespace LinearAlgebra << "An error with error number " << arg1 << " occurred while calling a Trilinos function"); + /* + * Access to a an element that is not (locally-)owned. + * + * @ingroup Exceptions + */ + DeclException4( + ExcAccessToNonLocalElement, + size_type, + size_type, + size_type, + size_type, + << "You are trying to access element " << arg1 + << " of a distributed vector, but this element is not stored " + << "on the current processor. Note: There are " << arg2 + << " elements stored " + << "on the current processor from within the range [" << arg3 << ',' + << arg4 << "] but Trilinos vectors need not store contiguous " + << "ranges on each processor, and not every element in " + << "this range may in fact be stored locally." + << "\n\n" + << "A common source for this kind of problem is that you " + << "are passing a 'fully distributed' vector into a function " + << "that needs read access to vector elements that correspond " + << "to degrees of freedom on ghost cells (or at least to " + << "'locally active' degrees of freedom that are not also " + << "'locally owned'). You need to pass a vector that has these " + << "elements as ghost entries."); + private: /** * Point to the vector we are referencing. @@ -261,6 +289,8 @@ namespace LinearAlgebra using real_type = typename numbers::NumberTraits::real_type; using size_type = types::global_dof_index; using reference = internal::VectorReference; + using const_reference = + const internal::VectorReference; using MapType = Tpetra::Map; using VectorType = Tpetra:: diff --git a/include/deal.II/lac/trilinos_tpetra_vector.templates.h b/include/deal.II/lac/trilinos_tpetra_vector.templates.h index db6cc93ed5..c48c17e7de 100644 --- a/include/deal.II/lac/trilinos_tpetra_vector.templates.h +++ b/include/deal.II/lac/trilinos_tpetra_vector.templates.h @@ -182,6 +182,7 @@ namespace LinearAlgebra 0, 0, Utilities::Trilinos::tpetra_comm_self())); has_ghost = false; compressed = true; + nonlocal_vector.reset(); } @@ -1066,6 +1067,7 @@ namespace LinearAlgebra } + template MPI_Comm Vector::mpi_comm() const diff --git a/source/lac/trilinos_tpetra_block_sparse_matrix.cc b/source/lac/trilinos_tpetra_block_sparse_matrix.cc index fafcebe325..283dad3bda 100644 --- a/source/lac/trilinos_tpetra_block_sparse_matrix.cc +++ b/source/lac/trilinos_tpetra_block_sparse_matrix.cc @@ -52,18 +52,6 @@ namespace LinearAlgebra BlockSparseMatrix::Tvmult( TpetraWrappers::BlockVector &, const TpetraWrappers::BlockVector &) const; - - template void - BlockSparseMatrix::vmult( - ::dealii::BlockVector &, - const ::dealii::BlockVector &) const; - - template void - BlockSparseMatrix::Tvmult( - ::dealii::BlockVector &, - const ::dealii::BlockVector &) const; - - } // namespace TpetraWrappers } // namespace LinearAlgebra # endif // DOXYGEN -- 2.39.5