libMesh
Loading...
Searching...
No Matches
petsc_mffd_matrix.h
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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
27namespace libMesh
28{
29
36template <typename T>
38{
39public:
47 explicit PetscMFFDMatrix(Mat m, const Parallel::Communicator & comm_in);
48
49 explicit PetscMFFDMatrix(const Parallel::Communicator & comm_in);
50
59
68 void assign(Mat m, bool set_context);
69
70 virtual void init(const numeric_index_type,
74 const numeric_index_type = 30,
75 const numeric_index_type = 10,
76 const numeric_index_type = 1) override;
77
82 virtual void init(ParallelType = PARALLEL) override;
83
84 virtual SparseMatrix<T> & operator=(const SparseMatrix<T> &) override;
85
86 virtual void zero() override;
87 virtual std::unique_ptr<SparseMatrix<T>> zero_clone() const override;
88 virtual std::unique_ptr<SparseMatrix<T>> clone() const override;
89 virtual void set(const numeric_index_type i, const numeric_index_type j, const T value) override;
90 virtual void add(const numeric_index_type i, const numeric_index_type j, const T value) override;
91 virtual void add_matrix(const DenseMatrix<T> & dm,
92 const std::vector<numeric_index_type> & rows,
93 const std::vector<numeric_index_type> & cols) override;
94 virtual void add_matrix(const DenseMatrix<T> & dm,
95 const std::vector<numeric_index_type> & dof_indices) override;
96 virtual void add(const T a, const SparseMatrix<T> & X) override;
97 virtual T operator()(const numeric_index_type i, const numeric_index_type j) const override;
98 virtual Real l1_norm() const override;
99 virtual Real linfty_norm() const override;
100 virtual void print_personal(std::ostream & os = libMesh::out) const override;
101 virtual void get_diagonal(NumericVector<T> & dest) const override;
102 virtual void get_transpose(SparseMatrix<T> & dest) const override;
103 virtual void get_row(numeric_index_type i,
104 std::vector<numeric_index_type> & indices,
105 std::vector<T> & values) const override;
106};
107
108template <typename T>
110 : PetscMatrixBase<T>(m, comm_in)
111{
112}
113
114template <typename T>
119
120template <typename T>
121void
122PetscMFFDMatrix<T>::assign(Mat m, bool set_context)
123{
124 if (this->_mat != m)
125 this->clear();
126
127 this->_mat = m;
128 this->_is_initialized = true;
129 this->_destroy_mat_on_exit = false;
130 if (set_context)
131 this->set_context();
132}
133
134template <typename T>
137{
138 this->assign(m, false);
139 return *this;
140}
141
142template <typename T>
143void
145 const numeric_index_type,
146 const numeric_index_type,
147 const numeric_index_type,
148 const numeric_index_type,
149 const numeric_index_type,
150 const numeric_index_type)
151{
152 libmesh_error();
153}
154
155template <typename T>
156void
158{
159 libmesh_error();
160}
161
162template <typename T>
165{
166 libmesh_error();
167}
168
169template <typename T>
170void
172{
173 libmesh_error();
174}
175
176template <typename T>
177std::unique_ptr<SparseMatrix<T>>
179{
180 libmesh_error();
181}
182
183template <typename T>
184std::unique_ptr<SparseMatrix<T>>
186{
187 libmesh_not_implemented();
188}
189
190template <typename T>
191void
193{
194 libmesh_error();
195}
196
197template <typename T>
198void
200{
201 libmesh_error();
202}
203
204template <typename T>
205void
207 const std::vector<numeric_index_type> &,
208 const std::vector<numeric_index_type> &)
209{
210 libmesh_error();
211}
212
213template <typename T>
214void
215PetscMFFDMatrix<T>::add_matrix(const DenseMatrix<T> &, const std::vector<numeric_index_type> &)
216{
217 libmesh_error();
218}
219
220template <typename T>
221void
223{
224 libmesh_error();
225}
226
227template <typename T>
228T
230{
231 libmesh_error();
232}
233
234template <typename T>
235Real
237{
238 libmesh_error();
239}
240
241template <typename T>
242Real
244{
245 libmesh_error();
246}
247
248template <typename T>
249void
251{
252 libmesh_error();
253}
254
255template <typename T>
256void
258{
259 libmesh_error();
260}
261
262template <typename T>
263void
265{
266 libmesh_error();
267}
268
269template <typename T>
270void
272 std::vector<numeric_index_type> &,
273 std::vector<T> &) const
274{
275 libmesh_error();
276}
277
278} // namespace libMesh
279
280#endif // LIBMESH_HAVE_PETSC
281#endif // LIBMESH_SPARSE_SHELL_MATRIX_H
Defines a dense matrix for use in Finite Element-type computations.
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
This class allows to use a PETSc shell matrix as a PetscMatrix.
virtual void zero() override
Set all entries to 0.
virtual Real linfty_norm() const override
virtual Real l1_norm() const override
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 void add(const numeric_index_type i, const numeric_index_type j, const T value) override
Add value to the element (i,j).
virtual void get_diagonal(NumericVector< T > &dest) const override
Copies the diagonal part of the matrix into dest.
virtual std::unique_ptr< SparseMatrix< T > > zero_clone() const override
virtual void set(const numeric_index_type i, const numeric_index_type j, const T value) override
Set the element (i,j) to value.
virtual T operator()(const numeric_index_type i, const numeric_index_type j) const override
virtual std::unique_ptr< SparseMatrix< T > > clone() const override
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.
virtual void get_transpose(SparseMatrix< T > &dest) const override
Copies the transpose of the matrix into dest, which may be *this.
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.
void assign(Mat m, bool set_context)
Adopt an existing, externally-owned Mat, without destroying it when this object goes out of scope.
PetscMFFDMatrix & operator=(Mat m)
Calls assign with set_context equal to false as generally speaking an MFFD matrix will have been crea...
PetscMFFDMatrix(Mat m, const Parallel::Communicator &comm_in)
Constructor.
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,...
void set_context()
Set the context (ourself) for _mat.
virtual numeric_index_type m() const override
Generic sparse matrix.
The libMesh namespace provides an interface to certain functionality in the library.
ParallelType
Defines an enum for parallel data structure types.
OStreamProxy out
dof_id_type numeric_index_type
Definition id_types.h:99
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const bool value
Definition xdr_io.C:55