eigen_sparse_matrix.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 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_EIGEN_SPARSE_MATRIX_H
21 #define LIBMESH_EIGEN_SPARSE_MATRIX_H
22 
23 #include "libmesh/libmesh_config.h"
24 
25 #ifdef LIBMESH_HAVE_EIGEN
26 
27 // Local includes
28 #include "libmesh/sparse_matrix.h"
30 
31 // Eigen includes
32 
33 // C++ includes
34 #include <algorithm>
35 #include <cstddef>
36 
37 namespace libMesh
38 {
39 
40 
41 
42 // Forward declarations
43 template <typename T> class DenseMatrix;
44 template <typename T> class EigenSparseVector;
45 template <typename T> class EigenSparseLinearSolver;
46 
47 
48 
56 template <typename T>
58 {
59 
60 public:
77  LIBMESH_CAN_DEFAULT_TO_COMMWORLD);
78 
85 
89  typedef EigenSM DataType;
90  typedef Eigen::Triplet<T,eigen_idx_type> TripletType;
91 
102  void init (const numeric_index_type m,
103  const numeric_index_type n,
104  const numeric_index_type m_l,
105  const numeric_index_type n_l,
106  const numeric_index_type nnz=30,
107  const numeric_index_type noz=10,
108  const numeric_index_type blocksize=1);
109 
113  void init ();
114 
121  void clear ();
122 
126  void zero ();
127 
133  void close () const { const_cast<EigenSparseMatrix<T>*>(this)->_closed = true; }
134 
139  numeric_index_type m () const;
140 
145  numeric_index_type n () const;
146 
151  numeric_index_type row_start () const;
152 
157  numeric_index_type row_stop () const;
158 
165  void set (const numeric_index_type i,
166  const numeric_index_type j,
167  const T value);
168 
177  void add (const numeric_index_type i,
178  const numeric_index_type j,
179  const T value);
180 
188  void add_matrix (const DenseMatrix<T> &dm,
189  const std::vector<numeric_index_type> &rows,
190  const std::vector<numeric_index_type> &cols);
191 
196  void add_matrix (const DenseMatrix<T> &dm,
197  const std::vector<numeric_index_type> &dof_indices);
198 
206  void add (const T a, SparseMatrix<T> &X);
207 
216  const numeric_index_type j) const;
217 
228  Real l1_norm () const { libmesh_error(); return 0.; }
229 
241  Real linfty_norm () const { libmesh_error(); return 0.; }
242 
247  bool closed() const { return _closed; }
248 
253  void print_personal(std::ostream& os=libMesh::out) const { this->print(os); }
254 
258  virtual void get_diagonal (NumericVector<T>& dest) const;
259 
264  virtual void get_transpose (SparseMatrix<T>& dest) const;
265 
266 private:
267 
272 
276  bool _closed;
277 
281  friend class EigenSparseVector<T>;
282  friend class EigenSparseLinearSolver<T>;
283 };
284 
285 } // namespace libMesh
286 
287 #endif // #ifdef LIBMESH_HAVE_EIGEN
288 #endif // #ifdef LIBMESH_EIGEN_SPARSE_MATRIX_H

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:04 UTC

Hosted By:
SourceForge.net Logo