$extrastylesheet
00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 00003 00004 // This library is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public 00006 // License as published by the Free Software Foundation; either 00007 // version 2.1 of the License, or (at your option) any later version. 00008 00009 // This library is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // Lesser General Public License for more details. 00013 00014 // You should have received a copy of the GNU Lesser General Public 00015 // License along with this library; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 00019 00020 #ifndef LIBMESH_LASPACK_MATRIX_H 00021 #define LIBMESH_LASPACK_MATRIX_H 00022 00023 #include "libmesh/libmesh_config.h" 00024 00025 #ifdef LIBMESH_HAVE_LASPACK 00026 00027 // Local includes 00028 #include "libmesh/sparse_matrix.h" 00029 00030 // Laspack includes 00031 #include <qmatrix.h> 00032 00033 // C++ includes 00034 #include <algorithm> 00035 #include <cstddef> 00036 00037 namespace libMesh 00038 { 00039 00040 00041 00042 // Forward declarations 00043 template <typename T> class DenseMatrix; 00044 template <typename T> class LaspackVector; 00045 template <typename T> class LaspackLinearSolver; 00046 00047 00048 00058 template <typename T> 00059 class LaspackMatrix : public SparseMatrix<T> 00060 { 00061 00062 public: 00078 LaspackMatrix (const Parallel::Communicator &comm 00079 LIBMESH_CAN_DEFAULT_TO_COMMWORLD); 00080 00086 ~LaspackMatrix (); 00087 00091 bool need_full_sparsity_pattern() const 00092 { return true; } 00093 00099 void update_sparsity_pattern (const SparsityPattern::Graph &); 00100 00111 void init (const numeric_index_type m, 00112 const numeric_index_type n, 00113 const numeric_index_type m_l, 00114 const numeric_index_type n_l, 00115 const numeric_index_type nnz=30, 00116 const numeric_index_type noz=10, 00117 const numeric_index_type blocksize=1); 00118 00122 void init (); 00123 00130 void clear (); 00131 00135 void zero (); 00136 00142 void close () const { const_cast<LaspackMatrix<T>*>(this)->_closed = true; } 00143 00148 numeric_index_type m () const; 00149 00154 numeric_index_type n () const; 00155 00160 numeric_index_type row_start () const; 00161 00166 numeric_index_type row_stop () const; 00167 00174 void set (const numeric_index_type i, 00175 const numeric_index_type j, 00176 const T value); 00177 00186 void add (const numeric_index_type i, 00187 const numeric_index_type j, 00188 const T value); 00189 00197 void add_matrix (const DenseMatrix<T> &dm, 00198 const std::vector<numeric_index_type> &rows, 00199 const std::vector<numeric_index_type> &cols); 00200 00205 void add_matrix (const DenseMatrix<T> &dm, 00206 const std::vector<numeric_index_type> &dof_indices); 00207 00215 void add (const T a, SparseMatrix<T> &X); 00216 00224 T operator () (const numeric_index_type i, 00225 const numeric_index_type j) const; 00226 00237 Real l1_norm () const { libmesh_not_implemented(); return 0.; } 00238 00250 Real linfty_norm () const { libmesh_not_implemented(); return 0.; } 00251 00256 bool closed() const { return _closed; } 00257 00262 void print_personal(std::ostream& os=libMesh::out) const { this->print(os); } 00263 00267 virtual void get_diagonal (NumericVector<T>& dest) const; 00268 00273 virtual void get_transpose (SparseMatrix<T>& dest) const; 00274 00275 private: 00276 00281 numeric_index_type pos (const numeric_index_type i, 00282 const numeric_index_type j) const; 00283 00287 QMatrix _QMat; 00288 00292 std::vector<numeric_index_type> _csr; 00293 00298 std::vector<std::vector<numeric_index_type>::const_iterator> _row_start; 00299 00303 bool _closed; 00304 00308 friend class LaspackVector<T>; 00309 friend class LaspackLinearSolver<T>; 00310 }; 00311 00312 } // namespace libMesh 00313 00314 #endif // #ifdef LIBMESH_HAVE_LASPACK 00315 #endif // #ifdef LIBMESH_LASPACK_MATRIX_H