From 36447358f536ab190b3c81d06616cdf718db17d7 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Fri, 14 Sep 2018 17:34:33 +0200 Subject: [PATCH] Also instantiate for value_type float --- cmake/configure/configure_2_trilinos.cmake | 2 +- include/deal.II/lac/trilinos_sparse_matrix.h | 56 ++++++++++++--- source/lac/trilinos_sparse_matrix.cc | 76 +++++++++++++------- 3 files changed, 97 insertions(+), 37 deletions(-) diff --git a/cmake/configure/configure_2_trilinos.cmake b/cmake/configure/configure_2_trilinos.cmake index 661c739b7c..c159fe2552 100644 --- a/cmake/configure/configure_2_trilinos.cmake +++ b/cmake/configure/configure_2_trilinos.cmake @@ -228,7 +228,7 @@ MACRO(FEATURE_TRILINOS_CONFIGURE_EXTERNAL) IF (TRILINOS_WITH_MPI) SET(DEAL_II_EXPAND_EPETRA_VECTOR "LinearAlgebra::EpetraWrappers::Vector") SET(DEAL_II_EXPAND_TPETRA_VECTOR_DOUBLE "LinearAlgebra::TpetraWrappers::Vector") - #SET(DEAL_II_EXPAND_TPETRA_VECTOR_FLOAT "LinearAlgebra::TpetraWrappers::Vector") + SET(DEAL_II_EXPAND_TPETRA_VECTOR_FLOAT "LinearAlgebra::TpetraWrappers::Vector") ENDIF() IF(${DEAL_II_TRILINOS_WITH_SACADO}) # Note: Only CMake 3.0 and greater support line continuation with the "\" character diff --git a/include/deal.II/lac/trilinos_sparse_matrix.h b/include/deal.II/lac/trilinos_sparse_matrix.h index b158a224d4..2ae42c5ef1 100644 --- a/include/deal.II/lac/trilinos_sparse_matrix.h +++ b/include/deal.II/lac/trilinos_sparse_matrix.h @@ -1325,13 +1325,6 @@ namespace TrilinosWrappers const Number * values, const bool elide_zero_values = false); - void - set(const size_type row, - const size_type n_cols, - const size_type * col_indices, - const TrilinosScalar *values, - const bool elide_zero_values = false); - /** * Add @p value to the element (i,j). * @@ -1588,7 +1581,13 @@ namespace TrilinosWrappers * distributed. Otherwise, an exception will be thrown. */ template - void + typename std::enable_if::value>::type + vmult(VectorType &dst, const VectorType &src) const; + + template + typename std::enable_if::value>::type vmult(VectorType &dst, const VectorType &src) const; /** @@ -1602,7 +1601,13 @@ namespace TrilinosWrappers * see the discussion about @p VectorType in vmult(). */ template - void + typename std::enable_if::value>::type + Tvmult(VectorType &dst, const VectorType &src) const; + + template + typename std::enable_if::value>::type Tvmult(VectorType &dst, const VectorType &src) const; /** @@ -2992,6 +2997,32 @@ namespace TrilinosWrappers // Inline the set() and add() functions, since they will be called // frequently, and the compiler can optimize away some unnecessary loops // when the sizes are given at compile time. + template <> + void + SparseMatrix::set(const size_type row, + const size_type n_cols, + const size_type * col_indices, + const TrilinosScalar *values, + const bool elide_zero_values); + + + + template + void + SparseMatrix::set(const size_type row, + const size_type n_cols, + const size_type *col_indices, + const Number * values, + const bool elide_zero_values) + { + std::vector trilinos_values(n_cols); + std::copy(values, values + n_cols, trilinos_values.begin()); + this->set( + row, n_cols, col_indices, trilinos_values.data(), elide_zero_values); + } + + + inline void SparseMatrix::set(const size_type i, const size_type j, @@ -3298,6 +3329,13 @@ namespace TrilinosWrappers } // namespace LinearOperatorImplementation } // namespace internal + template <> + void + SparseMatrix::set(const size_type row, + const size_type n_cols, + const size_type * col_indices, + const TrilinosScalar *values, + const bool elide_zero_values); # endif // DOXYGEN } /* namespace TrilinosWrappers */ diff --git a/source/lac/trilinos_sparse_matrix.cc b/source/lac/trilinos_sparse_matrix.cc index 0996f76053..250a6d0519 100644 --- a/source/lac/trilinos_sparse_matrix.cc +++ b/source/lac/trilinos_sparse_matrix.cc @@ -1540,28 +1540,13 @@ namespace TrilinosWrappers - template + template <> void - SparseMatrix::set(const size_type row, - const size_type n_cols, - const size_type *col_indices, - const Number * values, - const bool elide_zero_values) - { - std::vector trilinos_values(n_cols); - std::copy(values, values + n_cols, trilinos_values.begin()); - this->set( - row, n_cols, col_indices, trilinos_values.data(), elide_zero_values); - } - - - - void - SparseMatrix::set(const size_type row, - const size_type n_cols, - const size_type * col_indices, - const TrilinosScalar *values, - const bool elide_zero_values) + SparseMatrix::set(const size_type row, + const size_type n_cols, + const size_type * col_indices, + const TrilinosScalar *values, + const bool elide_zero_values) { AssertIndexRange(row, this->m()); @@ -2124,7 +2109,8 @@ namespace TrilinosWrappers template - void + typename std::enable_if< + std::is_same::value>::type SparseMatrix::vmult(VectorType &dst, const VectorType &src) const { Assert(&src != &dst, ExcSourceEqualsDestination()); @@ -2157,7 +2143,18 @@ namespace TrilinosWrappers template - void + typename std::enable_if< + !std::is_same::value>::type + SparseMatrix::vmult(VectorType & /*dst*/, const VectorType & /*src*/) const + { + AssertThrow(false, ExcNotImplemented()); + } + + + + template + typename std::enable_if< + std::is_same::value>::type SparseMatrix::Tvmult(VectorType &dst, const VectorType &src) const { Assert(&src != &dst, ExcSourceEqualsDestination()); @@ -2186,6 +2183,16 @@ namespace TrilinosWrappers + template + typename std::enable_if< + !std::is_same::value>::type + SparseMatrix::Tvmult(VectorType & /*dst*/, const VectorType & /*src*/) const + { + AssertThrow(false, ExcNotImplemented()); + } + + + template void SparseMatrix::vmult_add(VectorType &dst, const VectorType &src) const @@ -3508,10 +3515,10 @@ namespace TrilinosWrappers dealii::LinearAlgebra::TpetraWrappers::Vector &, const dealii::LinearAlgebra::TpetraWrappers::Vector &) const; - /*template void - SparseMatrix::vmult( - dealii::LinearAlgebra::TpetraWrappers::Vector &, - const dealii::LinearAlgebra::TpetraWrappers::Vector &) const;*/ + template void + SparseMatrix::vmult( + dealii::LinearAlgebra::TpetraWrappers::Vector &, + const dealii::LinearAlgebra::TpetraWrappers::Vector &) const; template void SparseMatrix::vmult( @@ -3537,6 +3544,11 @@ namespace TrilinosWrappers dealii::LinearAlgebra::TpetraWrappers::Vector &, const dealii::LinearAlgebra::TpetraWrappers::Vector &) const; + template void + SparseMatrix::Tvmult( + dealii::LinearAlgebra::TpetraWrappers::Vector &, + const dealii::LinearAlgebra::TpetraWrappers::Vector &) const; + template void SparseMatrix::Tvmult( dealii::LinearAlgebra::EpetraWrappers::Vector &, @@ -3561,6 +3573,11 @@ namespace TrilinosWrappers dealii::LinearAlgebra::TpetraWrappers::Vector &, const dealii::LinearAlgebra::TpetraWrappers::Vector &) const; + template void + SparseMatrix::vmult_add( + dealii::LinearAlgebra::TpetraWrappers::Vector &, + const dealii::LinearAlgebra::TpetraWrappers::Vector &) const; + template void SparseMatrix::vmult_add( dealii::LinearAlgebra::EpetraWrappers::Vector &, @@ -3585,6 +3602,11 @@ namespace TrilinosWrappers dealii::LinearAlgebra::TpetraWrappers::Vector &, const dealii::LinearAlgebra::TpetraWrappers::Vector &) const; + template void + SparseMatrix::Tvmult_add( + dealii::LinearAlgebra::TpetraWrappers::Vector &, + const dealii::LinearAlgebra::TpetraWrappers::Vector &) const; + template void SparseMatrix::Tvmult_add( dealii::LinearAlgebra::EpetraWrappers::Vector &, -- 2.39.5