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 : #ifndef LIBMESH_LUMPED_MASS_MATRIX_H 19 : #define LIBMESH_LUMPED_MASS_MATRIX_H 20 : 21 : #include "libmesh/diagonal_matrix.h" 22 : 23 : namespace libMesh 24 : { 25 : 26 : /** 27 : * Template class used to construct a lumped mass matrix. Potentially also useful for computing 28 : * quantities relevant to overall system scaling. Any time the add method is called on this class we 29 : * sum into the row index \p i with the absolute value of the provided value 30 : * 31 : * \author Alexander D. Lindsay 32 : * \date 2021 33 : */ 34 : template <typename T> 35 : class LumpedMassMatrix : public DiagonalMatrix<T> 36 : { 37 : public: 38 : /** 39 : * Constructor; initializes the matrix to be empty, without any 40 : * structure, i.e. the matrix is not usable at all. This 41 : * constructor is therefore only useful for matrices which are 42 : * members of a class. All other matrices should be created at a 43 : * point in the data flow where all necessary information is 44 : * available. 45 : * 46 : * You have to initialize the matrix before usage with 47 : * \p init(...). 48 : */ 49 : explicit LumpedMassMatrix(const Parallel::Communicator & comm); 50 : 51 : /** 52 : * unique pointers can be moved but not copied 53 : */ 54 : LumpedMassMatrix(LumpedMassMatrix &&) = default; 55 : LumpedMassMatrix & operator=(LumpedMassMatrix &&) = default; 56 0 : virtual SparseMatrix<T> & operator=(const SparseMatrix<T> &) override 57 : { 58 0 : libmesh_not_implemented(); 59 : return *this; 60 : } 61 : 62 : virtual std::unique_ptr<SparseMatrix<T>> zero_clone() const override; 63 : 64 : virtual std::unique_ptr<SparseMatrix<T>> clone() const override; 65 : 66 : virtual void set(const numeric_index_type i, 67 : const numeric_index_type j, 68 : const T value) override; 69 : 70 : virtual void add(const numeric_index_type i, 71 : const numeric_index_type j, 72 : const T value) override; 73 : virtual void add(const T a, const SparseMatrix<T> & X) override; 74 : 75 : protected: 76 : /** 77 : * Copy contents from vec into underlying diagonal storage 78 : */ 79 : LumpedMassMatrix & operator=(const NumericVector<T> & vec); 80 : 81 : /** 82 : * Move contents from vec into underlying diagonal storage 83 : */ 84 : LumpedMassMatrix & operator=(NumericVector<T> && vec); 85 : }; 86 : 87 : } // namespace libMesh 88 : 89 : #endif // LIBMESH_LUMPED_MASS_MATRIX_H