From d37587ff778c944cf1e5df42531db305f2c80511 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Tue, 9 May 2017 14:00:17 +0200 Subject: [PATCH] Add get_mpi_communicator(), locally_owned_range_indices() and locally_owned_domain_indices () --- doc/news/changes/minor/20170509DanielArndt | 7 +++ .../lac/trilinos_block_sparse_matrix.h | 50 +++++++++++++++++++ source/lac/trilinos_block_sparse_matrix.cc | 8 ++- 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 doc/news/changes/minor/20170509DanielArndt diff --git a/doc/news/changes/minor/20170509DanielArndt b/doc/news/changes/minor/20170509DanielArndt new file mode 100644 index 0000000000..800ffbf594 --- /dev/null +++ b/doc/news/changes/minor/20170509DanielArndt @@ -0,0 +1,7 @@ +New: TrilinosWrappers::MPI::BlockMatrix can now return its MPI_Comm via +get_mpi_communicator() and its range and domain indices via +locally_owned_range_indices() and locally_owned_domain_indices() +relying on the information of the TrilinosWrappers::MPI::Matrix +object it is based on. +
+(Daniel Arndt, 2017/05/09) diff --git a/include/deal.II/lac/trilinos_block_sparse_matrix.h b/include/deal.II/lac/trilinos_block_sparse_matrix.h index 9753e38bb2..4c0331bb2c 100644 --- a/include/deal.II/lac/trilinos_block_sparse_matrix.h +++ b/include/deal.II/lac/trilinos_block_sparse_matrix.h @@ -224,6 +224,11 @@ namespace TrilinosWrappers */ size_type n_nonzero_elements () const; + /** + * Return the MPI communicator object in use with this matrix. + */ + MPI_Comm get_mpi_communicator () const; + /** * Return a vector of the underlying Trilinos Epetra_Map that sets the * partitioning of the domain space of this block matrix, i.e., the @@ -246,6 +251,19 @@ namespace TrilinosWrappers */ std::vector range_partitioner () const DEAL_II_DEPRECATED; + /** + * Return the partitioning of the domain space for the individual blocks of + * this matrix, i.e., the partitioning of the block vectors this matrix has + * to be multiplied with. + */ + std::vector locally_owned_domain_indices() const; + + /** + * Return the partitioning of the range space for the individual blocks of + * this matrix, i.e., the partitioning of the block vectors that result + * from matrix-vector products. + */ + std::vector locally_owned_range_indices() const; /** * Matrix-vector multiplication: let $dst = M*src$ with $M$ being this @@ -565,6 +583,38 @@ namespace TrilinosWrappers + inline + std::vector + BlockSparseMatrix::locally_owned_domain_indices () const + { + Assert (this->n_block_cols() != 0, ExcNotInitialized()); + Assert (this->n_block_rows() != 0, ExcNotInitialized()); + + std::vector domain_indices; + for (size_type c = 0; c < this->n_block_cols(); ++c) + domain_indices.push_back(this->sub_objects[0][c]->locally_owned_domain_indices()); + + return domain_indices; + } + + + + inline + std::vector + BlockSparseMatrix::locally_owned_range_indices () const + { + Assert (this->n_block_cols() != 0, ExcNotInitialized()); + Assert (this->n_block_rows() != 0, ExcNotInitialized()); + + std::vector range_indices; + for (size_type r = 0; r < this->n_block_rows(); ++r) + range_indices.push_back(this->sub_objects[r][0]->locally_owned_range_indices()); + + return range_indices; + } + + + namespace internal { namespace BlockLinearOperator diff --git a/source/lac/trilinos_block_sparse_matrix.cc b/source/lac/trilinos_block_sparse_matrix.cc index 0ae6ff37bf..69a4a2c935 100644 --- a/source/lac/trilinos_block_sparse_matrix.cc +++ b/source/lac/trilinos_block_sparse_matrix.cc @@ -416,7 +416,13 @@ namespace TrilinosWrappers - + MPI_Comm + BlockSparseMatrix::get_mpi_communicator () const + { + Assert (this->n_block_cols() != 0, ExcNotInitialized()); + Assert (this->n_block_rows() != 0, ExcNotInitialized()); + return this->sub_objects[0][0]->get_mpi_communicator(); + } -- 2.39.5