]> https://gitweb.dealii.org/ - dealii.git/commitdiff
PETScWrappers::BlockSparseMatrix unify constructors
authorStefano Zampini <stefano.zampini@gmail.com>
Tue, 18 Apr 2023 08:18:45 +0000 (11:18 +0300)
committerStefano Zampini <stefano.zampini@gmail.com>
Thu, 20 Apr 2023 09:35:04 +0000 (12:35 +0300)
add missing test

include/deal.II/lac/petsc_block_sparse_matrix.h
source/lac/petsc_parallel_block_sparse_matrix.cc
tests/petsc/block_matrices_01.cc

index 397725d162cb4f4d4bb9c7f8749ce7b29b23dfa5..63b9edab52c77b2db581005ee8c9c3a052b33c8f 100644 (file)
@@ -100,7 +100,7 @@ namespace PETScWrappers
        * reinit(BlockSparsityPattern). The number of blocks per row and column
        * are then determined by that function.
        */
-      BlockSparseMatrix() = default;
+      BlockSparseMatrix();
 
       /**
        * Create a BlockSparseMatrix with a PETSc Mat that describes the entire
@@ -339,7 +339,7 @@ namespace PETScWrappers
        * a "nested" matrix using PETSc's MATNEST object whose individual
        * blocks are the blocks of this matrix.
        */
-      Mat petsc_nest_matrix = nullptr;
+      Mat petsc_nest_matrix;
 
       /**
        * Utility to setup the MATNEST object
@@ -361,6 +361,12 @@ namespace PETScWrappers
     /** @} */
 
     // ------------- inline and template functions -----------------
+    inline BlockSparseMatrix::BlockSparseMatrix()
+      : BaseClass()
+      , petsc_nest_matrix(nullptr)
+    {}
+
+
 
     inline BlockSparseMatrix::BlockSparseMatrix(const Mat &A)
       : BlockSparseMatrix()
@@ -368,9 +374,12 @@ namespace PETScWrappers
       this->reinit(A);
     }
 
+
+
     template <size_t block_rows, size_t block_columns>
     inline BlockSparseMatrix::BlockSparseMatrix(
       const std::array<std::array<Mat, block_columns>, block_rows> &arrayA)
+      : BlockSparseMatrix()
     {
       this->reinit(block_rows, block_columns);
       this->sub_objects.reinit(block_rows, block_columns);
@@ -385,6 +394,8 @@ namespace PETScWrappers
       this->collect_sizes();
     }
 
+
+
     inline BlockSparseMatrix &
     BlockSparseMatrix::operator=(const double d)
     {
index a8faa324eb689f9152328c4fe683ad2bd8f53f3d..798f2e514d78ba00e268677455ced10d29d32ba4 100644 (file)
@@ -260,6 +260,9 @@ namespace PETScWrappers
       ierr = MatCreateNest(
         comm, m, nullptr, n, nullptr, psub_objects.data(), &petsc_nest_matrix);
       AssertThrow(ierr == 0, ExcPETScError(ierr));
+
+      ierr = MatNestSetVecType(petsc_nest_matrix, VECNEST);
+      AssertThrow(ierr == 0, ExcPETScError(ierr));
     }
 
 
index aca37f14574439ab63d452bc1753e137c16485fd..9cb37b47a89b94d468e869630c167dcd7a7b855c 100644 (file)
@@ -78,6 +78,7 @@ test()
   Assert(tmp2.n_block_cols() == pbsm.n_block_cols(), ExcInternalError());
   Assert(tmp2.m() == pbsm.m(), ExcInternalError());
   Assert(tmp2.n() == pbsm.n(), ExcInternalError());
+  Assert(tmp2.petsc_matrix() == pbsm.petsc_matrix(), ExcInternalError());
   for (unsigned int blr = 0; blr < 2; ++blr)
     {
       for (unsigned int blc = 0; blc < 2; ++blc)

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.