From 08e1f691db71fe2f2c1ee0982b57c00293166415 Mon Sep 17 00:00:00 2001
From: Stefano Zampini <stefano.zampini@gmail.com>
Date: Tue, 29 Nov 2022 00:10:36 +0300
Subject: [PATCH] PETScWrappers: add a couple of missing reinits

---
 include/deal.II/lac/petsc_sparse_matrix.h  | 12 ++++++++++++
 source/lac/petsc_parallel_sparse_matrix.cc | 19 +++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/include/deal.II/lac/petsc_sparse_matrix.h b/include/deal.II/lac/petsc_sparse_matrix.h
index f4022536fe..8fb0274530 100644
--- a/include/deal.II/lac/petsc_sparse_matrix.h
+++ b/include/deal.II/lac/petsc_sparse_matrix.h
@@ -471,6 +471,18 @@ namespace PETScWrappers
              const unsigned int            this_process,
              const bool                    preset_nonzero_locations = true);
 
+      /**
+       * Create a square matrix where the size() of the IndexSet determines the
+       * global number of rows and columns and the entries of the IndexSet
+       * give the rows and columns for the calling processor. Note that only
+       * ascending, 1:1 IndexSets are supported.
+       */
+      template <typename SparsityPatternType>
+      void
+      reinit(const IndexSet &           local_partitioning,
+             const SparsityPatternType &sparsity_pattern,
+             const MPI_Comm &           communicator);
+
       /**
        * Create a matrix where the size() of the IndexSets determine the
        * global number of rows and columns and the entries of the IndexSet
diff --git a/source/lac/petsc_parallel_sparse_matrix.cc b/source/lac/petsc_parallel_sparse_matrix.cc
index 3e2f121a5e..38756d1dd7 100644
--- a/source/lac/petsc_parallel_sparse_matrix.cc
+++ b/source/lac/petsc_parallel_sparse_matrix.cc
@@ -149,6 +149,15 @@ namespace PETScWrappers
 
 
 
+    template <typename SparsityPatternType>
+    void
+    SparseMatrix::reinit(const IndexSet &           local_rows,
+                         const SparsityPatternType &sparsity_pattern,
+                         const MPI_Comm &           communicator)
+    {
+      do_reinit(communicator, local_rows, local_rows, sparsity_pattern);
+    }
+
     template <typename SparsityPatternType>
     void
     SparseMatrix::reinit(const IndexSet &           local_rows,
@@ -705,12 +714,22 @@ namespace PETScWrappers
                          const unsigned int,
                          const bool);
 
+    template void
+    SparseMatrix::reinit(const IndexSet &,
+                         const SparsityPattern &,
+                         const MPI_Comm &);
+
     template void
     SparseMatrix::reinit(const IndexSet &,
                          const IndexSet &,
                          const SparsityPattern &,
                          const MPI_Comm &);
 
+    template void
+    SparseMatrix::reinit(const IndexSet &,
+                         const DynamicSparsityPattern &,
+                         const MPI_Comm &);
+
     template void
     SparseMatrix::reinit(const IndexSet &,
                          const IndexSet &,
-- 
2.39.5