From: ESeNonFossiIo Date: Tue, 12 Apr 2016 20:09:22 +0000 (+0200) Subject: add locally_owned_range_indices and locally_owned_domain_indices X-Git-Tag: v8.5.0-rc1~1104^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63e412f19f060a8c52a9ba6006e321d0cf62f453;p=dealii.git add locally_owned_range_indices and locally_owned_domain_indices --- 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; + } + } }