trilinos_epetra_matrix.h
Go to the documentation of this file.00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2012 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_TRILINOS_EPETRA_MATRIX_H 00021 #define LIBMESH_TRILINOS_EPETRA_MATRIX_H 00022 00023 #include "libmesh/libmesh_common.h" 00024 00025 #ifdef LIBMESH_HAVE_TRILINOS 00026 00027 // Trilinos includes 00028 #include <Epetra_FECrsMatrix.h> 00029 #include <Epetra_Map.h> 00030 #include <EpetraExt_MatrixMatrix.h> 00031 #include <Epetra_MpiComm.h> 00032 00033 // Local includes 00034 #include "libmesh/sparse_matrix.h" 00035 00036 // C++ includes 00037 #include <algorithm> 00038 #include <cstddef> 00039 00040 namespace libMesh 00041 { 00042 00043 // Forward Declarations 00044 template <typename T> class DenseMatrix; 00045 00046 00047 00056 template <typename T> 00057 class EpetraMatrix : public SparseMatrix<T> 00058 { 00059 public: 00075 EpetraMatrix (); 00076 00084 EpetraMatrix (Epetra_FECrsMatrix * m); 00085 00091 virtual ~EpetraMatrix (); 00092 00096 bool need_full_sparsity_pattern () const 00097 { return true; } 00098 00104 void update_sparsity_pattern (const SparsityPattern::Graph &); 00105 00114 void init (const numeric_index_type m, 00115 const numeric_index_type n, 00116 const numeric_index_type m_l, 00117 const numeric_index_type n_l, 00118 const numeric_index_type nnz=30, 00119 const numeric_index_type noz=10); 00120 00124 void init (); 00125 00132 void clear (); 00133 00138 void zero (); 00139 00145 void close () const; 00146 00151 numeric_index_type m () const; 00152 00157 numeric_index_type n () const; 00158 00163 numeric_index_type row_start () const; 00164 00169 numeric_index_type row_stop () const; 00170 00177 void set (const numeric_index_type i, 00178 const numeric_index_type j, 00179 const T value); 00180 00189 void add (const numeric_index_type i, 00190 const numeric_index_type j, 00191 const T value); 00192 00200 void add_matrix (const DenseMatrix<T> &dm, 00201 const std::vector<numeric_index_type> &rows, 00202 const std::vector<numeric_index_type> &cols); 00203 00208 void add_matrix (const DenseMatrix<T> &dm, 00209 const std::vector<numeric_index_type> &dof_indices); 00210 00220 void add (const T a, SparseMatrix<T> &X); 00221 00229 T operator () (const numeric_index_type i, 00230 const numeric_index_type j) const; 00231 00243 Real l1_norm () const; 00244 00257 Real linfty_norm () const; 00258 00263 bool closed() const; 00264 00268 void print_personal(std::ostream& os=libMesh::out) const; 00269 00276 void print_matlab(const std::string name="NULL") const; 00277 00281 void get_diagonal (NumericVector<T>& dest) const; 00282 00287 virtual void get_transpose (SparseMatrix<T>& dest) const; 00288 00292 void swap (EpetraMatrix<T> &); 00293 00299 Epetra_FECrsMatrix * mat () { libmesh_assert(_mat); return _mat; } 00300 00301 const Epetra_FECrsMatrix * mat () const { libmesh_assert(_mat); return _mat; } 00302 00303 00304 private: 00305 00310 Epetra_FECrsMatrix * _mat; 00311 00315 Epetra_Map * _map; 00316 00320 Epetra_CrsGraph * _graph; 00321 00326 bool _destroy_mat_on_exit; 00327 00332 bool _use_transpose; 00333 }; 00334 00335 } // namespace libMesh 00336 00337 #endif // #ifdef LIBMESH_HAVE_TRILINOS 00338 #endif // LIBMESH_TRILINOS_EPETRA_MATRIX_H
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:49 UTC
Hosted By: