libMesh
laspack_matrix.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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_LASPACK_MATRIX_H
21 #define LIBMESH_LASPACK_MATRIX_H
22 
23 #include "libmesh/libmesh_config.h"
24 
25 #ifdef LIBMESH_HAVE_LASPACK
26 
27 // Local includes
28 #include "libmesh/sparse_matrix.h"
29 
30 // Laspack includes
31 #include <qmatrix.h>
32 
33 // C++ includes
34 #include <algorithm>
35 #include <cstddef>
36 
37 namespace libMesh
38 {
39 
40 // Forward declarations
41 template <typename T> class DenseMatrix;
42 template <typename T> class LaspackVector;
43 template <typename T> class LaspackLinearSolver;
44 
55 template <typename T>
56 class LaspackMatrix libmesh_final : public SparseMatrix<T>
57 {
58 
59 public:
70  LaspackMatrix (const Parallel::Communicator & comm
71  LIBMESH_CAN_DEFAULT_TO_COMMWORLD);
72 
77  ~LaspackMatrix ();
78 
82  virtual bool need_full_sparsity_pattern() const libmesh_override
83  { return true; }
84 
90  virtual void update_sparsity_pattern (const SparsityPattern::Graph &) libmesh_override;
91 
92  virtual void init (const numeric_index_type m,
93  const numeric_index_type n,
94  const numeric_index_type m_l,
95  const numeric_index_type n_l,
96  const numeric_index_type nnz=30,
97  const numeric_index_type noz=10,
98  const numeric_index_type blocksize=1) libmesh_override;
99 
100  virtual void init () libmesh_override;
101 
102  virtual void clear () libmesh_override;
103 
104  virtual void zero () libmesh_override;
105 
106  virtual void close () libmesh_override { this->_closed = true; }
107 
108  virtual numeric_index_type m () const libmesh_override;
109 
110  virtual numeric_index_type n () const libmesh_override;
111 
112  virtual numeric_index_type row_start () const libmesh_override;
113 
114  virtual numeric_index_type row_stop () const libmesh_override;
115 
116  virtual void set (const numeric_index_type i,
117  const numeric_index_type j,
118  const T value) libmesh_override;
119 
120  virtual void add (const numeric_index_type i,
121  const numeric_index_type j,
122  const T value) libmesh_override;
123 
124  virtual void add_matrix (const DenseMatrix<T> & dm,
125  const std::vector<numeric_index_type> & rows,
126  const std::vector<numeric_index_type> & cols) libmesh_override;
127 
128  virtual void add_matrix (const DenseMatrix<T> & dm,
129  const std::vector<numeric_index_type> & dof_indices) libmesh_override;
130 
138  virtual void add (const T a, SparseMatrix<T> & X) libmesh_override;
139 
140  virtual T operator () (const numeric_index_type i,
141  const numeric_index_type j) const libmesh_override;
142 
143  virtual Real l1_norm () const libmesh_override { libmesh_not_implemented(); return 0.; }
144 
145  virtual Real linfty_norm () const libmesh_override { libmesh_not_implemented(); return 0.; }
146 
147  virtual bool closed() const libmesh_override { return _closed; }
148 
149  virtual void print_personal(std::ostream & os=libMesh::out) const libmesh_override { this->print(os); }
150 
151  virtual void get_diagonal (NumericVector<T> & dest) const libmesh_override;
152 
153  virtual void get_transpose (SparseMatrix<T> & dest) const libmesh_override;
154 
155 private:
156 
162  const numeric_index_type j) const;
163 
167  QMatrix _QMat;
168 
172  std::vector<numeric_index_type> _csr;
173 
178  std::vector<std::vector<numeric_index_type>::const_iterator> _row_start;
179 
183  bool _closed;
184 
188  friend class LaspackVector<T>;
189  friend class LaspackLinearSolver<T>;
190 };
191 
192 } // namespace libMesh
193 
194 #endif // #ifdef LIBMESH_HAVE_LASPACK
195 #endif // #ifdef LIBMESH_LASPACK_MATRIX_H
Encapsulates the MPI_Comm object.
Definition: parallel.h:657
The Hex20 is an element in 3D composed of 20 nodes.
Definition: cell_hex20.h:66
QMatrix _QMat
The Laspack sparse matrix pointer.
virtual void print_personal(std::ostream &os=libMesh::out) const libmesh_override
Print the contents of the matrix to the screen in a package-personalized style, if available...
Numeric vector.
Definition: dof_map.h:66
The libMesh namespace provides an interface to certain functionality in the library.
const Number zero
.
Definition: libmesh.h:178
std::vector< numeric_index_type > _csr
The compressed row indices.
virtual bool closed() const libmesh_override
Generic sparse matrix.
Definition: dof_map.h:65
This class provides an interface to Laspack iterative solvers that is compatible with the libMesh Lin...
dof_id_type numeric_index_type
Definition: id_types.h:92
virtual Real linfty_norm() const libmesh_override
std::vector< std::vector< numeric_index_type >::const_iterator > _row_start
The start of each row in the compressed row index data structure.
void init(triangulateio &t)
Initializes the fields of t to NULL/0 as necessary.
virtual bool need_full_sparsity_pattern() const libmesh_override
The LaspackMatrix needs the full sparsity pattern.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
OStreamProxy out
static const bool value
Definition: xdr_io.C:108
virtual Real l1_norm() const libmesh_override
virtual void close() libmesh_override
Calls the NumericVector&#39;s internal assembly routines, ensuring that the values are consistent across ...
Defines a dense matrix for use in Finite Element-type computations.
Definition: dof_map.h:64