From f48aecf816769d544b45b3c5fae41729efaec2ce Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Fri, 22 Oct 2021 19:16:45 +0200 Subject: [PATCH] PETScWrappers::MPI::Vector: add new reinit() --- include/deal.II/lac/petsc_vector.h | 9 +++++++++ source/lac/petsc_parallel_vector.cc | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/include/deal.II/lac/petsc_vector.h b/include/deal.II/lac/petsc_vector.h index 32fe3ebbe1..bfcfb92179 100644 --- a/include/deal.II/lac/petsc_vector.h +++ b/include/deal.II/lac/petsc_vector.h @@ -22,6 +22,7 @@ # ifdef DEAL_II_WITH_PETSC # include +# include # include # include @@ -356,6 +357,14 @@ namespace PETScWrappers void reinit(const IndexSet &local, const MPI_Comm &communicator); + /** + * Initialize the vector given to the parallel partitioning described in + * @p partitioner. + */ + void + reinit( + const std::shared_ptr &partitioner); + /** * Return a reference to the MPI communicator object in use with this * vector. diff --git a/source/lac/petsc_parallel_vector.cc b/source/lac/petsc_parallel_vector.cc index af3acaf90e..6c2b1622f5 100644 --- a/source/lac/petsc_parallel_vector.cc +++ b/source/lac/petsc_parallel_vector.cc @@ -254,6 +254,15 @@ namespace PETScWrappers create_vector(local.size(), local.n_elements()); } + void + Vector::reinit( + const std::shared_ptr &partitioner) + { + this->reinit(partitioner->locally_owned_range(), + partitioner->ghost_indices(), + partitioner->get_mpi_communicator()); + } + void Vector::create_vector(const size_type n, const size_type locally_owned_size) -- 2.39.5