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_TENSOR_SHELL_MATRIX_H 21 : #define LIBMESH_TENSOR_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/shell_matrix.h" 29 : #include "libmesh/numeric_vector.h" 30 : 31 : namespace libMesh 32 : { 33 : 34 : /** 35 : * Shell matrix that is given by a tensor product of two vectors, 36 : * i.e. A = v*w^T. All overridden virtual functions are documented in 37 : * shell_matrix.h. 38 : * 39 : * \author Tim Kroeger 40 : * \date 2008 41 : */ 42 : template <typename T> 43 : class TensorShellMatrix : public ShellMatrix<T> 44 : { 45 : public: 46 : /** 47 : * Constructor; takes references to the two vectors as arguments. 48 : * The vectors themselves have to be stored elsewhere. 49 : */ 50 : TensorShellMatrix (const NumericVector<T> & v, 51 : const NumericVector<T> & w); 52 : 53 : /** 54 : * Destructor. 55 : */ 56 : virtual ~TensorShellMatrix (); 57 : 58 : virtual numeric_index_type m () const override; 59 : 60 : virtual numeric_index_type n () const override; 61 : 62 : virtual void vector_mult (NumericVector<T> & dest, 63 : const NumericVector<T> & arg) const override; 64 : 65 : virtual void vector_mult_add (NumericVector<T> & dest, 66 : const NumericVector<T> & arg) const override; 67 : 68 : virtual void get_diagonal (NumericVector<T> & dest) const override; 69 : 70 : protected: 71 : /** 72 : * The column vector. 73 : */ 74 : const NumericVector<T> & _v; 75 : 76 : /** 77 : * The row vector. 78 : */ 79 : const NumericVector<T> & _w; 80 : }; 81 : 82 : 83 : 84 : //----------------------------------------------------------------------- 85 : // TensorShellMatrix inline members 86 : template <typename T> 87 : inline 88 0 : TensorShellMatrix<T>::TensorShellMatrix (const NumericVector<T> & v, 89 : const NumericVector<T> & w): 90 : ShellMatrix<T>(v.comm()), 91 0 : _v(v), 92 0 : _w(w) 93 0 : {} 94 : 95 : 96 : 97 : template <typename T> 98 : inline 99 0 : TensorShellMatrix<T>::~TensorShellMatrix () 100 0 : {} 101 : 102 : 103 : 104 : template <typename T> 105 : inline 106 0 : numeric_index_type TensorShellMatrix<T>::m () const 107 : { 108 0 : return _v.size(); 109 : } 110 : 111 : 112 : 113 : template <typename T> 114 : inline 115 0 : numeric_index_type TensorShellMatrix<T>::n () const 116 : { 117 0 : return _w.size(); 118 : } 119 : 120 : 121 : } // namespace libMesh 122 : 123 : 124 : #endif // LIBMESH_TENSOR_SHELL_MATRIX_H