From 63e412f19f060a8c52a9ba6006e321d0cf62f453 Mon Sep 17 00:00:00 2001 From: ESeNonFossiIo Date: Tue, 12 Apr 2016 22:09:22 +0200 Subject: [PATCH] add locally_owned_range_indices and locally_owned_domain_indices --- .../lac/petsc_parallel_sparse_matrix.h | 13 +++++++ source/lac/petsc_parallel_sparse_matrix.cc | 36 +++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/include/deal.II/lac/petsc_parallel_sparse_matrix.h b/include/deal.II/lac/petsc_parallel_sparse_matrix.h index b97810e8c8..fd5905527f 100644 --- a/include/deal.II/lac/petsc_parallel_sparse_matrix.h +++ b/include/deal.II/lac/petsc_parallel_sparse_matrix.h @@ -379,6 +379,19 @@ namespace PETScWrappers PetscScalar matrix_scalar_product (const Vector &u, const Vector &v) const; + /** + * 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; + private: /** diff --git a/source/lac/petsc_parallel_sparse_matrix.cc b/source/lac/petsc_parallel_sparse_matrix.cc index 6aff059d3c..c2837beb54 100644 --- a/source/lac/petsc_parallel_sparse_matrix.cc +++ b/source/lac/petsc_parallel_sparse_matrix.cc @@ -890,6 +890,42 @@ namespace PETScWrappers return u*tmp; } + IndexSet + SparseMatrix::locally_owned_domain_indices () const + { + PetscInt n_rows, n_cols, min, max; + PetscErrorCode ierr; + IS* rows = nullptr; + IS* cols = nullptr; + + ierr = MatGetSize (matrix, &n_rows, &n_cols); + ierr = MatGetOwnershipIS(matrix, rows, cols); + ierr = ISGetMinMax(*rows, &min, &max); + + IndexSet locally_owned_domain_indices(n_rows); + locally_owned_domain_indices.add_range(min, max); + + return locally_owned_domain_indices; + } + + IndexSet + SparseMatrix::locally_owned_range_indices () const + { + PetscInt n_rows, n_cols, min, max; + PetscErrorCode ierr; + IS* rows = nullptr; + IS* cols = nullptr; + + ierr = MatGetSize (matrix, &n_rows, &n_cols); + ierr = MatGetOwnershipIS(matrix, rows, cols); + ierr = ISGetMinMax(*cols, &min, &max); + + IndexSet locally_owned_range_indices(n_cols); + locally_owned_range_indices.add_range(min, max); + + return locally_owned_range_indices; + } + } } -- 2.39.5