libMesh
petsc_mffd_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_MFFD_MATRIX_H
19 #define LIBMESH_PETSC_MFFD_MATRIX_H
20 
21 #include "libmesh/libmesh_config.h"
22 
23 #ifdef LIBMESH_HAVE_PETSC
24 
25 #include "libmesh/petsc_matrix_base.h"
26 
27 namespace libMesh
28 {
29 
36 template <typename T>
38 {
39 public:
47  explicit PetscMFFDMatrix(Mat m, const Parallel::Communicator & comm_in);
48 
49  explicit PetscMFFDMatrix(const Parallel::Communicator & comm_in);
50 
52 
53  virtual void init(const numeric_index_type,
54  const numeric_index_type,
55  const numeric_index_type,
56  const numeric_index_type,
57  const numeric_index_type = 30,
58  const numeric_index_type = 10,
59  const numeric_index_type = 1) override;
60 
65  virtual void init(ParallelType = PARALLEL) override;
66 
67  virtual SparseMatrix<T> & operator=(const SparseMatrix<T> &) override;
68 
69  virtual void zero() override;
70  virtual std::unique_ptr<SparseMatrix<T>> zero_clone() const override;
71  virtual std::unique_ptr<SparseMatrix<T>> clone() const override;
72  virtual void set(const numeric_index_type i, const numeric_index_type j, const T value) override;
73  virtual void add(const numeric_index_type i, const numeric_index_type j, const T value) override;
74  virtual void add_matrix(const DenseMatrix<T> & dm,
75  const std::vector<numeric_index_type> & rows,
76  const std::vector<numeric_index_type> & cols) override;
77  virtual void add_matrix(const DenseMatrix<T> & dm,
78  const std::vector<numeric_index_type> & dof_indices) override;
79  virtual void add(const T a, const SparseMatrix<T> & X) override;
80  virtual T operator()(const numeric_index_type i, const numeric_index_type j) const override;
81  virtual Real l1_norm() const override;
82  virtual Real linfty_norm() const override;
83  virtual void print_personal(std::ostream & os = libMesh::out) const override;
84  virtual void get_diagonal(NumericVector<T> & dest) const override;
85  virtual void get_transpose(SparseMatrix<T> & dest) const override;
86  virtual void get_row(numeric_index_type i,
87  std::vector<numeric_index_type> & indices,
88  std::vector<T> & values) const override;
89 };
90 
91 template <typename T>
93  : PetscMatrixBase<T>(m, comm_in)
94 {
95 }
96 
97 template <typename T>
99  : PetscMatrixBase<T>(comm_in)
100 {
101 }
102 
103 template <typename T>
106 {
107  this->_mat = m;
108  return *this;
109 }
110 
111 template <typename T>
112 void
114  const numeric_index_type,
115  const numeric_index_type,
116  const numeric_index_type,
117  const numeric_index_type,
118  const numeric_index_type,
119  const numeric_index_type)
120 {
121  libmesh_error();
122 }
123 
124 template <typename T>
125 void
127 {
128  libmesh_error();
129 }
130 
131 template <typename T>
134 {
135  libmesh_error();
136 }
137 
138 template <typename T>
139 void
141 {
142  libmesh_error();
143 }
144 
145 template <typename T>
146 std::unique_ptr<SparseMatrix<T>>
148 {
149  libmesh_error();
150 }
151 
152 template <typename T>
153 std::unique_ptr<SparseMatrix<T>>
155 {
156  libmesh_not_implemented();
157 }
158 
159 template <typename T>
160 void
162 {
163  libmesh_error();
164 }
165 
166 template <typename T>
167 void
169 {
170  libmesh_error();
171 }
172 
173 template <typename T>
174 void
176  const std::vector<numeric_index_type> &,
177  const std::vector<numeric_index_type> &)
178 {
179  libmesh_error();
180 }
181 
182 template <typename T>
183 void
184 PetscMFFDMatrix<T>::add_matrix(const DenseMatrix<T> &, const std::vector<numeric_index_type> &)
185 {
186  libmesh_error();
187 }
188 
189 template <typename T>
190 void
192 {
193  libmesh_error();
194 }
195 
196 template <typename T>
197 T
199 {
200  libmesh_error();
201 }
202 
203 template <typename T>
204 Real
206 {
207  libmesh_error();
208 }
209 
210 template <typename T>
211 Real
213 {
214  libmesh_error();
215 }
216 
217 template <typename T>
218 void
220 {
221  libmesh_error();
222 }
223 
224 template <typename T>
225 void
227 {
228  libmesh_error();
229 }
230 
231 template <typename T>
232 void
234 {
235  libmesh_error();
236 }
237 
238 template <typename T>
239 void
241  std::vector<numeric_index_type> &,
242  std::vector<T> &) const
243 {
244  libmesh_error();
245 }
246 
247 } // namespace libMesh
248 
249 #endif // LIBMESH_HAVE_PETSC
250 #endif // LIBMESH_SPARSE_SHELL_MATRIX_H
virtual T operator()(const numeric_index_type i, const numeric_index_type j) const override
virtual void get_row(numeric_index_type i, std::vector< numeric_index_type > &indices, std::vector< T > &values) const override
Get a row from the matrix.
This class provides a nice interface to the PETSc C-based data structures for parallel, sparse matrices.
virtual numeric_index_type m() const override
virtual void get_diagonal(NumericVector< T > &dest) const override
Copies the diagonal part of the matrix into dest.
Provides a uniform interface to vector storage schemes for different linear algebra libraries...
Definition: vector_fe_ex5.C:44
virtual void zero() override
Set all entries to 0.
The libMesh namespace provides an interface to certain functionality in the library.
const Number zero
.
Definition: libmesh.h:304
virtual Real l1_norm() const override
Generic sparse matrix.
Definition: vector_fe_ex5.C:46
auto l1_norm(const NumericVector< T > &vec)
dof_id_type numeric_index_type
Definition: id_types.h:99
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
virtual void print_personal(std::ostream &os=libMesh::out) const override
Print the contents of the matrix to the screen in a package-personalized style, if available...
virtual std::unique_ptr< SparseMatrix< T > > zero_clone() const override
virtual Real linfty_norm() const override
virtual void get_transpose(SparseMatrix< T > &dest) const override
Copies the transpose of the matrix into dest, which may be *this.
virtual void init(const numeric_index_type, const numeric_index_type, const numeric_index_type, const numeric_index_type, const numeric_index_type=30, const numeric_index_type=10, const numeric_index_type=1) override
Initialize SparseMatrix with the specified sizes.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void add(const numeric_index_type i, const numeric_index_type j, const T value) override
Add value to the element (i,j).
OStreamProxy out
PetscMFFDMatrix & operator=(Mat m)
static const bool value
Definition: xdr_io.C:54
virtual void add_matrix(const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols) override
Add the full matrix dm to the SparseMatrix.
virtual std::unique_ptr< SparseMatrix< T > > clone() const override
Defines a dense matrix for use in Finite Element-type computations.
Definition: dof_map.h:75
PetscMFFDMatrix(Mat m, const Parallel::Communicator &comm_in)
Constructor.
ParallelType
Defines an enum for parallel data structure types.
This class allows to use a PETSc shell matrix as a PetscMatrix.