Line data Source code
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 : 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 : 40 : /** 41 : * Generic shell matrix, i.e. a matrix that does not define anything 42 : * but its action on a vector. This class contains pure virtual 43 : * members that must be overridden in derived classes. 44 : * 45 : * \author Tim Kroeger 46 : * \date 2008 47 : */ 48 : template <typename T> 49 : class ShellMatrix : public ReferenceCountedObject<ShellMatrix<T>>, 50 : public ParallelObject 51 : { 52 : public: 53 : /** 54 : * Constructor; does nothing. 55 : */ 56 : ShellMatrix (const Parallel::Communicator & comm_in); 57 : 58 : /** 59 : * Builds a \p ShellMatrix<T> using the linear solver package specified by 60 : * \p solver_package 61 : */ 62 : static std::unique_ptr<ShellMatrix<T>> 63 : build(const Parallel::Communicator & comm, 64 : const SolverPackage solver_package = libMesh::default_solver_package()); 65 : 66 : /** 67 : * Destructor. 68 : */ 69 : virtual ~ShellMatrix (); 70 : 71 : /** 72 : * \returns \p m, the row-dimension of the matrix where the matrix is 73 : * \f$ M \times N \f$. 74 : */ 75 : virtual numeric_index_type m () const = 0; 76 : 77 : /** 78 : * \returns \p n, the column-dimension of the matrix where the matrix 79 : * is \f$ M \times N \f$. 80 : */ 81 : virtual numeric_index_type n () const = 0; 82 : 83 : /** 84 : * Multiplies the matrix with \p arg and stores the result in \p 85 : * dest. 86 : */ 87 : virtual void vector_mult (NumericVector<T> & dest, 88 : const NumericVector<T> & arg) const = 0; 89 : 90 : /** 91 : * Multiplies the matrix with \p arg and adds the result to \p dest. 92 : */ 93 : virtual void vector_mult_add (NumericVector<T> & dest, 94 : const NumericVector<T> & arg) const = 0; 95 : 96 : /** 97 : * Copies the diagonal part of the matrix into \p dest. 98 : */ 99 : virtual void get_diagonal (NumericVector<T> & dest) const = 0; 100 : 101 : /** 102 : * Get a pointer to the \p DofMap to use. 103 : */ 104 0 : void attach_dof_map (const DofMap & dof_map) 105 132 : { _dof_map = &dof_map; } 106 : 107 : 108 0 : virtual void clear () { libmesh_error_msg ("Not implemented yet"); } 109 : 110 0 : virtual void init () { libmesh_error_msg ("Not implemented yet"); } 111 : 112 132 : void omit_constrained_dofs() { _omit_constrained_dofs = true; } 113 : 114 : protected: 115 : /** 116 : * The \p DofMap object associated with this object. 117 : */ 118 : DofMap const * _dof_map; 119 : 120 : /** 121 : * Whether to omit constrained dofs from this data structure 122 : */ 123 : bool _omit_constrained_dofs; 124 : }; 125 : 126 : 127 : 128 : //----------------------------------------------------------------------- 129 : // ShellMatrix inline members 130 : template <typename T> 131 : inline 132 132 : ShellMatrix<T>::ShellMatrix (const Parallel::Communicator & comm_in) : 133 : ParallelObject(comm_in), 134 132 : _dof_map(nullptr), 135 132 : _omit_constrained_dofs(false) 136 0 : {} 137 : 138 : 139 : template <typename T> 140 : inline 141 0 : ShellMatrix<T>::~ShellMatrix () 142 0 : {} 143 : 144 : 145 : } // namespace libMesh 146 : 147 : 148 : #endif // LIBMESH_SHELL_MATRIX_H