From: Daniel Arndt Date: Fri, 2 Feb 2024 21:58:02 +0000 (-0500) Subject: Enable a couple unit tests for LinearAlgebra::TpetraWrappers::Vector X-Git-Tag: relicensing~76^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fa154a9c1ca6cce282ba3e3ec41f2e826be4395;p=dealii.git Enable a couple unit tests for LinearAlgebra::TpetraWrappers::Vector --- diff --git a/include/deal.II/lac/trilinos_tpetra_sparse_matrix.h b/include/deal.II/lac/trilinos_tpetra_sparse_matrix.h index 858115ca85..7e1eab0da5 100644 --- a/include/deal.II/lac/trilinos_tpetra_sparse_matrix.h +++ b/include/deal.II/lac/trilinos_tpetra_sparse_matrix.h @@ -598,6 +598,28 @@ namespace LinearAlgebra trilinos_rcp(); /** @} */ + /** + * @name Partitioners + */ + /** @{ */ + + /** + * Return the partitioning of the domain space of this matrix, i.e., the + * partitioning of the vectors this matrix has to be multiplied with. + */ + IndexSet + locally_owned_domain_indices() const; + + /** + * Return the partitioning of the range space of this matrix, i.e., the + * partitioning of the vectors that are result from matrix-vector + * products. + */ + IndexSet + locally_owned_range_indices() const; + + /** @} */ + /** * @addtogroup Exceptions */ @@ -760,6 +782,24 @@ namespace LinearAlgebra return matrix; } + + + template + inline IndexSet + SparseMatrix::locally_owned_domain_indices() const + { + return IndexSet(matrix->getDomainMap()); + } + + + + template + inline IndexSet + SparseMatrix::locally_owned_range_indices() const + { + return IndexSet(matrix->getRangeMap()); + } + } // namespace TpetraWrappers } // namespace LinearAlgebra diff --git a/include/deal.II/lac/trilinos_tpetra_vector.h b/include/deal.II/lac/trilinos_tpetra_vector.h index 1411617a8f..63f871badf 100644 --- a/include/deal.II/lac/trilinos_tpetra_vector.h +++ b/include/deal.II/lac/trilinos_tpetra_vector.h @@ -1200,6 +1200,51 @@ namespace LinearAlgebra } // namespace LinearAlgebra + +namespace internal +{ + namespace LinearOperatorImplementation + { + template + class ReinitHelper; + + /** + * A helper class used internally in linear_operator.h. Specialization for + * LinearAlgebra::TpetraWrappers::Vector. + */ + template + class ReinitHelper< + LinearAlgebra::TpetraWrappers::Vector> + { + public: + template + static void + reinit_range_vector( + const Matrix &matrix, + LinearAlgebra::TpetraWrappers::Vector &v, + bool omit_zeroing_entries) + { + v.reinit(matrix.locally_owned_range_indices(), + matrix.get_mpi_communicator(), + omit_zeroing_entries); + } + + template + static void + reinit_domain_vector( + const Matrix &matrix, + LinearAlgebra::TpetraWrappers::Vector &v, + bool omit_zeroing_entries) + { + v.reinit(matrix.locally_owned_domain_indices(), + matrix.get_mpi_communicator(), + omit_zeroing_entries); + } + }; + + } // namespace LinearOperatorImplementation +} /* namespace internal */ + /** * Declare dealii::LinearAlgebra::TpetraWrappers::Vector as distributed vector. */ diff --git a/tests/lac/linear_operator_04.cc b/tests/lac/linear_operator_04.cc index 598e4025fd..31e235a5a8 100644 --- a/tests/lac/linear_operator_04.cc +++ b/tests/lac/linear_operator_04.cc @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include "../tests.h" @@ -33,15 +35,27 @@ main(int argc, char *argv[]) initlog(); deallog << std::setprecision(10); - TrilinosWrappers::SparseMatrix a; - - auto op_a = linear_operator(a); - auto op_a2 = linear_operator(a); - - TrilinosWrappers::BlockSparseMatrix b; - - auto op_b = linear_operator(b); - auto op_b3 = linear_operator(b); + { + TrilinosWrappers::SparseMatrix a; + auto op_a = linear_operator(a); + auto op_a2 = linear_operator(a); + } + +#ifdef DEAL_II_TRILINOS_WITH_TPETRA + { + LinearAlgebra::TpetraWrappers::SparseMatrix a; + auto op_a = + linear_operator>(a); + auto op_a2 = + linear_operator>(a); + } +#endif + + { + TrilinosWrappers::BlockSparseMatrix b; + auto op_b = linear_operator(b); + auto op_b3 = linear_operator(b); + } deallog << "OK" << std::endl; diff --git a/tests/lac/vector_reinit_02.cc b/tests/lac/vector_reinit_02.cc index 3a2df37243..657e39c3ab 100644 --- a/tests/lac/vector_reinit_02.cc +++ b/tests/lac/vector_reinit_02.cc @@ -21,6 +21,7 @@ #include +#include #include #include @@ -113,4 +114,9 @@ main(int argc, char **argv) do_test(); do_test(); + +#ifdef DEAL_II_TRILINOS_WITH_TPETRA + do_test>(); + do_test>(); +#endif }