trilinos_epetra_matrix.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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
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
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 final : public SparseMatrix<T>
64 {
65 public:
77 
86  EpetraMatrix (Epetra_FECrsMatrix * m,
88 
94  EpetraMatrix (EpetraMatrix &&) = delete;
95  EpetraMatrix (const EpetraMatrix &) = delete;
96  EpetraMatrix & operator= (const EpetraMatrix &) = delete;
97  EpetraMatrix & operator= (EpetraMatrix &&) = delete;
98  virtual ~EpetraMatrix ();
99 
103  virtual bool need_full_sparsity_pattern () const override
104  { return true; }
105 
111  virtual void update_sparsity_pattern (const SparsityPattern::Graph &) override;
112 
113  virtual void init (const numeric_index_type m,
114  const numeric_index_type n,
115  const numeric_index_type m_l,
116  const numeric_index_type n_l,
117  const numeric_index_type nnz=30,
118  const numeric_index_type noz=10,
119  const numeric_index_type blocksize=1) override;
120 
121  virtual void init () override;
122 
123  virtual void clear () override;
124 
125  virtual void zero () override;
126 
127  virtual void close () override;
128 
129  virtual numeric_index_type m () const override;
130 
131  virtual numeric_index_type n () const override;
132 
133  virtual numeric_index_type row_start () const override;
134 
135  virtual numeric_index_type row_stop () const override;
136 
137  virtual void set (const numeric_index_type i,
138  const numeric_index_type j,
139  const T value) override;
140 
141  virtual void add (const numeric_index_type i,
142  const numeric_index_type j,
143  const T value) override;
144 
145  virtual void add_matrix (const DenseMatrix<T> & dm,
146  const std::vector<numeric_index_type> & rows,
147  const std::vector<numeric_index_type> & cols) override;
148 
149  virtual void add_matrix (const DenseMatrix<T> & dm,
150  const std::vector<numeric_index_type> & dof_indices) override;
151 
162  virtual void add (const T a, const SparseMatrix<T> & X) override;
163 
164  virtual T operator () (const numeric_index_type i,
165  const numeric_index_type j) const override;
166 
167  virtual Real l1_norm () const override;
168 
169  virtual Real linfty_norm () const override;
170 
171  virtual bool closed() const override;
172 
173  virtual void print_personal(std::ostream & os=libMesh::out) const override;
174 
175  virtual void get_diagonal (NumericVector<T> & dest) const override;
176 
177  virtual void get_transpose (SparseMatrix<T> & dest) const override;
178 
182  void swap (EpetraMatrix<T> &);
183 
192  Epetra_FECrsMatrix * mat () { libmesh_assert(_mat); return _mat; }
193 
194  const Epetra_FECrsMatrix * mat () const { libmesh_assert(_mat); return _mat; }
195 
196 
197 private:
198 
202  Epetra_FECrsMatrix * _mat;
203 
207  Epetra_Map * _map;
208 
212  Epetra_CrsGraph * _graph;
213 
219 
225 };
226 
227 } // namespace libMesh
228 
229 #endif // LIBMESH_TRILINOS_HAVE_EPETRA
230 #endif // LIBMESH_TRILINOS_EPETRA_MATRIX_H
virtual numeric_index_type row_stop() const override
virtual void get_transpose(SparseMatrix< T > &dest) const override
Provides a uniform interface to vector storage schemes for different linear algebra libraries...
Definition: diff_context.h:40
const Parallel::Communicator & comm() const
virtual void add_matrix(const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols) override
virtual numeric_index_type n() const override
virtual void init() override
dof_id_type numeric_index_type
Definition: id_types.h:92
virtual numeric_index_type m() const override
virtual void clear() override
EpetraMatrix & operator=(const EpetraMatrix &)=delete
virtual numeric_index_type row_start() const override
virtual void close() override
virtual void print_personal(std::ostream &os=libMesh::out) const override
EpetraMatrix(const Parallel::Communicator &comm)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real l1_norm() const override
virtual Real linfty_norm() const override
virtual void get_diagonal(NumericVector< T > &dest) const override
virtual bool closed() const override
virtual void zero() override
static const bool value
Definition: xdr_io.C:109
Epetra_FECrsMatrix * _mat
virtual void add(const numeric_index_type i, const numeric_index_type j, const T value) override
Epetra_FECrsMatrix * mat()
A matrix object used for finite element assembly and numerics.
Definition: dense_matrix.h:54
void swap(EpetraMatrix< T > &)
OStreamProxy out(std::cout)
virtual T operator()(const numeric_index_type i, const numeric_index_type j) const override
virtual void update_sparsity_pattern(const SparsityPattern::Graph &) override
const Epetra_FECrsMatrix * mat() const
virtual bool need_full_sparsity_pattern() const override