Line data Source code
1 : // The libMesh Finite Element Library. 2 : // Copyright (C) 2002-2026 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 30 350 : PetscMatrixShellMatrix<T>::init(const numeric_index_type m, 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 350 : init_shell_mat(*this, m, n, m_l, n_l, blocksize); 39 350 : this->set_context(); 40 350 : } 41 : 42 : template <typename T> 43 : void 44 4130 : PetscMatrixShellMatrix<T>::init(ParallelType libmesh_dbg_var(type)) 45 : { 46 : #ifndef NDEBUG 47 118 : libmesh_assert(this->_dof_map); 48 118 : const auto m = this->_dof_map->n_dofs(); 49 118 : const auto m_l = this->_dof_map->n_local_dofs(); 50 118 : if (m != m_l) 51 118 : libmesh_assert(type != SERIAL); 52 : #endif 53 4130 : init_shell_mat(*this); 54 4130 : this->set_context(); 55 4130 : } 56 : 57 : template <typename T> 58 : void 59 0 : PetscMatrixShellMatrix<T>::zero() 60 : { 61 : // A shell matrix generally computes its action and stores no entries, so there is nothing to 62 : // clear. This is reachable through System::init_matrices(), which zeroes every matrix it 63 : // initializes. We elect to give this an empty implementation, as opposed to guarding the 64 : // init_matrices() call with something like an is_shell() attribute, as we consider it relatively 65 : // harmless to allow a user to "zero" a shell compared to attempting to add/set something 66 : // nontrivial in the shell 67 0 : } 68 : 69 : template <typename T> 70 : std::unique_ptr<SparseMatrix<T>> 71 0 : PetscMatrixShellMatrix<T>::zero_clone() const 72 : { 73 0 : libmesh_not_implemented(); 74 : } 75 : 76 : template <typename T> 77 : std::unique_ptr<SparseMatrix<T>> 78 0 : PetscMatrixShellMatrix<T>::clone() const 79 : { 80 0 : libmesh_not_implemented(); 81 : } 82 : 83 : template <typename T> 84 : void 85 0 : PetscMatrixShellMatrix<T>::set(const numeric_index_type, const numeric_index_type, const T) 86 : { 87 0 : libmesh_error_msg("Method not appropriate for arbitrary shell matrices"); 88 : } 89 : 90 : template <typename T> 91 : void 92 0 : PetscMatrixShellMatrix<T>::add(const numeric_index_type, const numeric_index_type, const T) 93 : { 94 0 : libmesh_error_msg("Method not appropriate for arbitrary shell matrices"); 95 : } 96 : 97 : template <typename T> 98 : void 99 0 : PetscMatrixShellMatrix<T>::add_matrix(const DenseMatrix<T> &, 100 : const std::vector<numeric_index_type> &, 101 : const std::vector<numeric_index_type> &) 102 : { 103 0 : libmesh_error_msg("Method not appropriate for arbitrary shell matrices"); 104 : } 105 : 106 : template <typename T> 107 : void 108 0 : PetscMatrixShellMatrix<T>::add_matrix(const DenseMatrix<T> &, 109 : const std::vector<numeric_index_type> &) 110 : { 111 0 : libmesh_error_msg("Method not appropriate for arbitrary shell matrices"); 112 : } 113 : 114 : template <typename T> 115 : void 116 0 : PetscMatrixShellMatrix<T>::add(const T, const SparseMatrix<T> &) 117 : { 118 0 : libmesh_error_msg("Method not appropriate for arbitrary shell matrices"); 119 : } 120 : 121 : template <typename T> 122 : T 123 0 : PetscMatrixShellMatrix<T>::operator()(const numeric_index_type, const numeric_index_type) const 124 : { 125 0 : libmesh_error_msg("Method not appropriate for arbitrary shell matrices"); 126 : } 127 : 128 : template <typename T> 129 : Real 130 0 : PetscMatrixShellMatrix<T>::l1_norm() const 131 : { 132 0 : libmesh_error_msg("Method not appropriate for arbitrary shell matrices"); 133 : } 134 : 135 : template <typename T> 136 : Real 137 0 : PetscMatrixShellMatrix<T>::linfty_norm() const 138 : { 139 0 : libmesh_error_msg("Method not appropriate for arbitrary shell matrices"); 140 : } 141 : 142 : template <typename T> 143 : void 144 0 : PetscMatrixShellMatrix<T>::print_personal(std::ostream &) const 145 : { 146 0 : libmesh_error_msg("Method not appropriate for arbitrary shell matrices"); 147 : } 148 : 149 : template <typename T> 150 : void 151 0 : PetscMatrixShellMatrix<T>::get_diagonal(NumericVector<T> &) const 152 : { 153 0 : libmesh_error_msg("Method not appropriate for arbitrary shell matrices"); 154 : } 155 : 156 : template <typename T> 157 : void 158 0 : PetscMatrixShellMatrix<T>::get_transpose(SparseMatrix<T> &) const 159 : { 160 0 : libmesh_error_msg("Method not appropriate for arbitrary shell matrices"); 161 : } 162 : 163 : template <typename T> 164 : void 165 0 : PetscMatrixShellMatrix<T>::get_row(numeric_index_type, 166 : std::vector<numeric_index_type> &, 167 : std::vector<T> &) const 168 : { 169 0 : libmesh_error_msg("Method not appropriate for arbitrary shell matrices"); 170 : } 171 : 172 : template <typename T> 173 : SparseMatrix<T> & 174 0 : PetscMatrixShellMatrix<T>::operator=(const SparseMatrix<T> &) 175 : { 176 0 : libmesh_error_msg("Method not appropriate for arbitrary shell matrices"); 177 : } 178 : 179 : template class LIBMESH_EXPORT PetscMatrixShellMatrix<Number>; 180 : 181 : } // namespace libMesh 182 : 183 : #endif