libMesh
petsc_matrix_shell_matrix.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 #ifndef LIBMESH_PETSC_MATRIX_SHELL_MATRIX_H
19 #define LIBMESH_PETSC_MATRIX_SHELL_MATRIX_H
20 
21 #include "libmesh/libmesh_config.h"
22 
23 #ifdef LIBMESH_HAVE_PETSC
24 
25 #include "libmesh/petsc_matrix_base.h"
26 #include "libmesh/petsc_shell_matrix.h"
27 
28 namespace libMesh
29 {
30 
37 template <typename T>
39 {
40 public:
41  explicit PetscMatrixShellMatrix(const Parallel::Communicator & comm_in);
42 
43  virtual void init(const numeric_index_type m,
44  const numeric_index_type n,
45  const numeric_index_type m_l,
46  const numeric_index_type n_l,
47  const numeric_index_type = 30,
48  const numeric_index_type = 10,
49  const numeric_index_type blocksize = 1) override;
50 
55  virtual void init(ParallelType = PARALLEL) override;
56 
57  virtual SparseMatrix<T> & operator=(const SparseMatrix<T> &) override;
58 
59  virtual bool require_sparsity_pattern() const override { return false; }
60 
61 private:
62  // Make this private because we mark as initialized after we've done our initialization, and we
63  // don't want derived classes to mistakenly register their data as initialized (or not)
65 
68 
69  friend void init_shell_mat<PetscMatrixShellMatrix<T>>(PetscMatrixShellMatrix<T> & obj);
70  friend void init_shell_mat<PetscMatrixShellMatrix<T>>(PetscMatrixShellMatrix<T> & obj,
71  const numeric_index_type m,
72  const numeric_index_type n,
73  const numeric_index_type m_l,
74  const numeric_index_type n_l,
75  const numeric_index_type blocksize_in);
76 };
77 
78 //-----------------------------------------------------------------------
79 // PetscMatrixShellMatrix inline members
80 template <typename T>
82  : PetscMatrixBase<T>(comm_in), _omit_constrained_dofs(false)
83 {
84 }
85 
86 template <typename T>
89 {
90  libmesh_error();
91 }
92 
93 } // namespace libMesh
94 
95 #endif // LIBMESH_HAVE_PETSC
96 #endif // LIBMESH_SPARSE_SHELL_MATRIX_H
virtual numeric_index_type n() const override
This class provides a nice interface to the PETSc C-based data structures for parallel, sparse matrices.
PetscMatrixShellMatrix(const Parallel::Communicator &comm_in)
This class allows to use a PETSc shell matrix as a PetscMatrix.
virtual numeric_index_type m() const override
The libMesh namespace provides an interface to certain functionality in the library.
Generic sparse matrix.
Definition: vector_fe_ex5.C:46
dof_id_type numeric_index_type
Definition: id_types.h:99
const bool _omit_constrained_dofs
Whether to omit constrained degrees of freedom.
virtual bool require_sparsity_pattern() const override
virtual SparseMatrix< T > & operator=(const SparseMatrix< T > &) override
This looks like a copy assignment operator, but note that, unlike normal copy assignment operators...
ParallelType
Defines an enum for parallel data structure types.
virtual void init(const numeric_index_type m, const numeric_index_type n, const numeric_index_type m_l, const numeric_index_type n_l, const numeric_index_type=30, const numeric_index_type=10, const numeric_index_type blocksize=1) override
Initialize SparseMatrix with the specified sizes.