libMesh
shell_matrix.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 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 
19 
20 #ifndef LIBMESH_SHELL_MATRIX_H
21 #define LIBMESH_SHELL_MATRIX_H
22 
23 
24 // Local includes
25 #include "libmesh/libmesh_common.h"
26 #include "libmesh/reference_counted_object.h"
27 #include "libmesh/libmesh.h"
28 #include "libmesh/id_types.h"
29 #include "libmesh/parallel_object.h"
30 #include "libmesh/dof_map.h"
31 #include "libmesh/parallel.h"
32 
33 namespace libMesh
34 {
35 
36 // forward declarations
37 template <typename T> class NumericVector;
38 enum SolverPackage : int;
39 
48 template <typename T>
49 class ShellMatrix : public ReferenceCountedObject<ShellMatrix<T>>,
50  public ParallelObject
51 {
52 public:
56  ShellMatrix (const Parallel::Communicator & comm_in);
57 
62  static std::unique_ptr<ShellMatrix<T>>
63  build(const Parallel::Communicator & comm,
64  const SolverPackage solver_package = libMesh::default_solver_package());
65 
69  virtual ~ShellMatrix ();
70 
75  virtual numeric_index_type m () const = 0;
76 
81  virtual numeric_index_type n () const = 0;
82 
87  virtual void vector_mult (NumericVector<T> & dest,
88  const NumericVector<T> & arg) const = 0;
89 
93  virtual void vector_mult_add (NumericVector<T> & dest,
94  const NumericVector<T> & arg) const = 0;
95 
99  virtual void get_diagonal (NumericVector<T> & dest) const = 0;
100 
104  void attach_dof_map (const DofMap & dof_map)
105  { _dof_map = &dof_map; }
106 
107 
108  virtual void clear () { libmesh_error_msg ("Not implemented yet"); }
109 
110  virtual void init () { libmesh_error_msg ("Not implemented yet"); }
111 
112 protected:
116  DofMap const * _dof_map;
117 };
118 
119 
120 
121 //-----------------------------------------------------------------------
122 // ShellMatrix inline members
123 template <typename T>
124 inline
126  ParallelObject(comm_in),
127  _dof_map(nullptr)
128 {}
129 
130 
131 template <typename T>
132 inline
134 {}
135 
136 
137 } // namespace libMesh
138 
139 
140 #endif // LIBMESH_SHELL_MATRIX_H
virtual ~ShellMatrix()
Destructor.
Definition: shell_matrix.h:133
void attach_dof_map(const DofMap &dof_map)
Get a pointer to the DofMap to use.
Definition: shell_matrix.h:104
static std::unique_ptr< ShellMatrix< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a ShellMatrix<T> using the linear solver package specified by solver_package.
Definition: shell_matrix.C:32
const Parallel::Communicator & comm() const
The libMesh namespace provides an interface to certain functionality in the library.
virtual numeric_index_type m() const =0
virtual void vector_mult_add(NumericVector< T > &dest, const NumericVector< T > &arg) const =0
Multiplies the matrix with arg and adds the result to dest.
SolverPackage default_solver_package()
Definition: libmesh.C:1050
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:169
dof_id_type numeric_index_type
Definition: id_types.h:99
ShellMatrix(const Parallel::Communicator &comm_in)
Constructor; does nothing.
Definition: shell_matrix.h:125
virtual void init()
Definition: shell_matrix.h:110
DofMap const * _dof_map
The DofMap object associated with this object.
Definition: shell_matrix.h:116
An object whose state is distributed along a set of processors.
virtual void clear()
Definition: shell_matrix.h:108
virtual numeric_index_type n() const =0
virtual void get_diagonal(NumericVector< T > &dest) const =0
Copies the diagonal part of the matrix into dest.
SolverPackage
Defines an enum for various linear solver packages.
Generic shell matrix, i.e.
virtual void vector_mult(NumericVector< T > &dest, const NumericVector< T > &arg) const =0
Multiplies the matrix with arg and stores the result in dest.
void ErrorVector unsigned int
Definition: adjoints_ex3.C:360