libMesh
trilinos_epetra_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_TRILINOS_EPETRA_MATRIX_H
21 #define LIBMESH_TRILINOS_EPETRA_MATRIX_H
22 
23 #include "libmesh/libmesh_common.h"
24 
25 #ifdef LIBMESH_TRILINOS_HAVE_EPETRA
26 
27 // Trilinos includes
28 #include "libmesh/ignore_warnings.h"
29 #include <Epetra_FECrsMatrix.h>
30 #include <Epetra_Map.h>
31 #include <Epetra_MpiComm.h>
32 
33 // The EpetraExt interface is only needed for EpetraMatrix::add()
34 #ifdef LIBMESH_TRILINOS_HAVE_EPETRAEXT
35 # include <EpetraExt_MatrixMatrix.h>
36 #endif
37 #include "libmesh/restore_warnings.h"
38 
39 // Local includes
40 #include "libmesh/sparse_matrix.h"
41 
42 // C++ includes
43 #include <algorithm>
44 #include <cstddef>
45 
46 namespace libMesh
47 {
48 
49 // Forward Declarations
50 template <typename T> class DenseMatrix;
51 
52 
53 
62 template <typename T>
63 class EpetraMatrix libmesh_final : public SparseMatrix<T>
64 {
65 public:
76  EpetraMatrix (const Parallel::Communicator & comm
77  LIBMESH_CAN_DEFAULT_TO_COMMWORLD);
78 
87  EpetraMatrix (Epetra_FECrsMatrix * m,
88  const Parallel::Communicator & comm
89  LIBMESH_CAN_DEFAULT_TO_COMMWORLD);
90 
95  virtual ~EpetraMatrix ();
96 
100  virtual bool need_full_sparsity_pattern () const libmesh_override
101  { return true; }
102 
108  virtual void update_sparsity_pattern (const SparsityPattern::Graph &) libmesh_override;
109 
110  virtual void init (const numeric_index_type m,
111  const numeric_index_type n,
112  const numeric_index_type m_l,
113  const numeric_index_type n_l,
114  const numeric_index_type nnz=30,
115  const numeric_index_type noz=10,
116  const numeric_index_type blocksize=1) libmesh_override;
117 
118  virtual void init () libmesh_override;
119 
120  virtual void clear () libmesh_override;
121 
122  virtual void zero () libmesh_override;
123 
124  virtual void close () libmesh_override;
125 
126  virtual numeric_index_type m () const libmesh_override;
127 
128  virtual numeric_index_type n () const libmesh_override;
129 
130  virtual numeric_index_type row_start () const libmesh_override;
131 
132  virtual numeric_index_type row_stop () const libmesh_override;
133 
134  virtual void set (const numeric_index_type i,
135  const numeric_index_type j,
136  const T value) libmesh_override;
137 
138  virtual void add (const numeric_index_type i,
139  const numeric_index_type j,
140  const T value) libmesh_override;
141 
142  virtual void add_matrix (const DenseMatrix<T> & dm,
143  const std::vector<numeric_index_type> & rows,
144  const std::vector<numeric_index_type> & cols) libmesh_override;
145 
146  virtual void add_matrix (const DenseMatrix<T> & dm,
147  const std::vector<numeric_index_type> & dof_indices) libmesh_override;
148 
159  virtual void add (const T a, SparseMatrix<T> & X) libmesh_override;
160 
161  virtual T operator () (const numeric_index_type i,
162  const numeric_index_type j) const libmesh_override;
163 
164  virtual Real l1_norm () const libmesh_override;
165 
166  virtual Real linfty_norm () const libmesh_override;
167 
168  virtual bool closed() const libmesh_override;
169 
170  virtual void print_personal(std::ostream & os=libMesh::out) const libmesh_override;
171 
172  virtual void get_diagonal (NumericVector<T> & dest) const libmesh_override;
173 
174  virtual void get_transpose (SparseMatrix<T> & dest) const libmesh_override;
175 
179  void swap (EpetraMatrix<T> &);
180 
189  Epetra_FECrsMatrix * mat () { libmesh_assert(_mat); return _mat; }
190 
191  const Epetra_FECrsMatrix * mat () const { libmesh_assert(_mat); return _mat; }
192 
193 
194 private:
195 
199  Epetra_FECrsMatrix * _mat;
200 
204  Epetra_Map * _map;
205 
209  Epetra_CrsGraph * _graph;
210 
215  bool _destroy_mat_on_exit;
216 
222 };
223 
224 } // namespace libMesh
225 
226 #endif // LIBMESH_TRILINOS_HAVE_EPETRA
227 #endif // LIBMESH_TRILINOS_EPETRA_MATRIX_H
bool closed()
Checks that the library has been closed.
Definition: libmesh.C:281
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
Epetra_FECrsMatrix * mat()
libmesh_assert(j)
Generic sparse matrix.
Definition: dof_map.h:65
dof_id_type numeric_index_type
Definition: id_types.h:92
void init(triangulateio &t)
Initializes the fields of t to NULL/0 as necessary.
Epetra_Map * _map
Holds the distributed Map.
virtual bool need_full_sparsity_pattern() const libmesh_override
The EpetraMatrix needs the full sparsity pattern.
Epetra_FECrsMatrix * _mat
Actual Epetra datatype to hold matrix entries.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Epetra_CrsGraph * _graph
Holds the sparsity pattern.
X_input swap(X_system)
OStreamProxy out
static const bool value
Definition: xdr_io.C:108
const Epetra_FECrsMatrix * mat() const
Defines a dense matrix for use in Finite Element-type computations.
Definition: dof_map.h:64
bool _use_transpose
Epetra has no GetUseTranspose so we need to keep track of whether we&#39;re transposed manually...