libMesh
petsc_matrix_shell_matrix.C
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 #include "libmesh/libmesh_config.h"
19 
20 #ifdef LIBMESH_HAVE_PETSC
21 
22 // Local includes
23 #include "libmesh/petsc_matrix_shell_matrix.h"
24 
25 namespace libMesh
26 {
27 
28 template <typename T>
29 void
31  const numeric_index_type n,
32  const numeric_index_type m_l,
33  const numeric_index_type n_l,
34  const numeric_index_type,
35  const numeric_index_type,
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 
42 template <typename T>
43 void
44 PetscMatrixShellMatrix<T>::init(ParallelType libmesh_dbg_var(type))
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 
57 template class LIBMESH_EXPORT PetscMatrixShellMatrix<Number>;
58 
59 } // namespace libMesh
60 
61 #endif
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.
dof_id_type numeric_index_type
Definition: id_types.h:99
libmesh_assert(ctx)
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.