From: Stefano Zampini Date: Tue, 24 Jan 2023 12:26:08 +0000 (+0300) Subject: Convenience routine from IndexSet to PETSc IS X-Git-Tag: v9.5.0-rc1~574^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=908e7663d05c59ab254f4105c76c1392ce517430;p=dealii.git Convenience routine from IndexSet to PETSc IS --- diff --git a/include/deal.II/base/index_set.h b/include/deal.II/base/index_set.h index e50f58439e..b17c18282c 100644 --- a/include/deal.II/base/index_set.h +++ b/include/deal.II/base/index_set.h @@ -37,6 +37,10 @@ DEAL_II_ENABLE_EXTRA_DIAGNOSTICS # endif #endif +#ifdef DEAL_II_WITH_PETSC +# include +#endif + DEAL_II_NAMESPACE_OPEN /** @@ -498,6 +502,11 @@ public: # endif #endif +#ifdef DEAL_II_WITH_PETSC + IS + make_petsc_is(const MPI_Comm &communicator = MPI_COMM_WORLD) const; +#endif + /** * Determine an estimate for the memory consumption (in bytes) of this diff --git a/source/base/index_set.cc b/source/base/index_set.cc index ef0a7c05e7..ecdad5d61f 100644 --- a/source/base/index_set.cc +++ b/source/base/index_set.cc @@ -17,6 +17,8 @@ #include #include +#include + #include #ifdef DEAL_II_WITH_TRILINOS @@ -850,6 +852,26 @@ IndexSet::make_trilinos_map(const MPI_Comm &communicator, #endif +#ifdef DEAL_II_WITH_PETSC +IS +IndexSet::make_petsc_is(const MPI_Comm &communicator) const +{ + std::vector indices; + fill_index_vector(indices); + + PetscInt n = indices.size(); + std::vector pindices(indices.begin(), indices.end()); + + IS is; + PetscErrorCode ierr = + ISCreateGeneral(communicator, n, pindices.data(), PETSC_COPY_VALUES, &is); + AssertThrow(ierr == 0, ExcPETScError(ierr)); + + return is; +} +#endif + + bool IndexSet::is_ascending_and_one_to_one(const MPI_Comm &communicator) const