libMesh
Loading...
Searching...
No Matches
petsc_matrix_shell_matrix.C
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#include "libmesh/libmesh_config.h"
19
20#ifdef LIBMESH_HAVE_PETSC
21
22// Local includes
23#include "libmesh/petsc_matrix_shell_matrix.h"
24
25namespace libMesh
26{
27
28template <typename T>
29void
31 const numeric_index_type n,
32 const numeric_index_type m_l,
33 const numeric_index_type n_l,
36 const numeric_index_type blocksize)
37{
38 init_shell_mat(*this, m, n, m_l, n_l, blocksize);
39 this->set_context();
40}
41
42template <typename T>
43void
45{
46#ifndef NDEBUG
47 libmesh_assert(this->_dof_map);
48 const auto m = this->_dof_map->n_dofs();
49 const auto m_l = this->_dof_map->n_local_dofs();
50 if (m != m_l)
51 libmesh_assert(type != SERIAL);
52#endif
53 init_shell_mat(*this);
54 this->set_context();
55}
56
57template <typename T>
58void
60{
61 // A shell matrix generally computes its action and stores no entries, so there is nothing to
62 // clear. This is reachable through System::init_matrices(), which zeroes every matrix it
63 // initializes. We elect to give this an empty implementation, as opposed to guarding the
64 // init_matrices() call with something like an is_shell() attribute, as we consider it relatively
65 // harmless to allow a user to "zero" a shell compared to attempting to add/set something
66 // nontrivial in the shell
67}
68
69template <typename T>
70std::unique_ptr<SparseMatrix<T>>
73 libmesh_not_implemented();
76template <typename T>
77std::unique_ptr<SparseMatrix<T>>
79{
80 libmesh_not_implemented();
81}
82
83template <typename T>
84void
86{
87 libmesh_error_msg("Method not appropriate for arbitrary shell matrices");
88}
89
90template <typename T>
91void
93{
94 libmesh_error_msg("Method not appropriate for arbitrary shell matrices");
95}
96
97template <typename T>
98void
100 const std::vector<numeric_index_type> &,
101 const std::vector<numeric_index_type> &)
102{
103 libmesh_error_msg("Method not appropriate for arbitrary shell matrices");
104}
105
106template <typename T>
107void
109 const std::vector<numeric_index_type> &)
110{
111 libmesh_error_msg("Method not appropriate for arbitrary shell matrices");
112}
113
114template <typename T>
115void
117{
118 libmesh_error_msg("Method not appropriate for arbitrary shell matrices");
119}
120
121template <typename T>
122T
124{
125 libmesh_error_msg("Method not appropriate for arbitrary shell matrices");
126}
127
128template <typename T>
129Real
131{
132 libmesh_error_msg("Method not appropriate for arbitrary shell matrices");
133}
134
135template <typename T>
136Real
138{
139 libmesh_error_msg("Method not appropriate for arbitrary shell matrices");
140}
141
142template <typename T>
143void
145{
146 libmesh_error_msg("Method not appropriate for arbitrary shell matrices");
147}
148
149template <typename T>
150void
152{
153 libmesh_error_msg("Method not appropriate for arbitrary shell matrices");
154}
155
156template <typename T>
157void
159{
160 libmesh_error_msg("Method not appropriate for arbitrary shell matrices");
161}
162
163template <typename T>
164void
166 std::vector<numeric_index_type> &,
167 std::vector<T> &) const
168{
169 libmesh_error_msg("Method not appropriate for arbitrary shell matrices");
170}
171
172template <typename T>
175{
176 libmesh_error_msg("Method not appropriate for arbitrary shell matrices");
177}
178
179template class LIBMESH_EXPORT PetscMatrixShellMatrix<Number>;
180
181} // namespace libMesh
182
183#endif
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 Real l1_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 Real linfty_norm() const override
virtual std::unique_ptr< SparseMatrix< T > > zero_clone() const override
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 set(const numeric_index_type i, const numeric_index_type j, const T value) override
Set the element (i,j) to value.
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.
virtual SparseMatrix< T > & operator=(const SparseMatrix< T > &) override
This looks like a copy assignment operator, but note that, unlike normal copy assignment operators,...
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 void zero() override
Set all entries to 0.
virtual std::unique_ptr< SparseMatrix< T > > clone() const override
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.
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 get_diagonal(NumericVector< T > &dest) const override
Copies the diagonal part of the matrix into dest.
Generic sparse matrix.
The libMesh namespace provides an interface to certain functionality in the library.
void init_shell_mat(Obj &obj, 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 blocksize_in)
Initialize a shell matrix object.
ParallelType
Defines an enum for parallel data structure types.
libmesh_assert(ctx)
dof_id_type numeric_index_type
Definition id_types.h:99
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real