libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
trilinos_epetra_matrix.h
浏览该文件的文档.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2023 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 
60 template <typename T>
61 class EpetraMatrix final : public SparseMatrix<T>
62 {
63 public:
64  typedef T value_type;
65 
72  EpetraMatrix (const Parallel::Communicator & comm);
73 
82  EpetraMatrix (Epetra_FECrsMatrix * m,
83  const Parallel::Communicator & comm);
84 
88  EpetraMatrix (EpetraMatrix &&) = delete;
89  EpetraMatrix (const EpetraMatrix &) = delete;
90  EpetraMatrix & operator= (const EpetraMatrix &) = delete;
91  EpetraMatrix & operator= (EpetraMatrix &&) = delete;
92 
96  virtual ~EpetraMatrix ();
97 
103  virtual bool need_full_sparsity_pattern () const override;
104 
110  virtual void update_sparsity_pattern (const SparsityPattern::Graph & graph) override;
111 
123  virtual void init (const numeric_index_type m,
124  const numeric_index_type n,
125  const numeric_index_type m_l,
126  const numeric_index_type n_l,
127  const numeric_index_type nnz=30,
128  const numeric_index_type noz=10,
129  const numeric_index_type blocksize=1) override;
130 
136  virtual void init (ParallelType parallelType = PARALLEL) override;
137 
141  virtual void clear () noexcept override;
142 
146  virtual void zero () override;
147 
153  virtual std::unique_ptr<SparseMatrix<T>> zero_clone () const override;
154 
160  virtual std::unique_ptr<SparseMatrix<T>> clone () const override;
161 
165  virtual void close () override;
166 
172  virtual numeric_index_type m () const override;
173 
179  virtual numeric_index_type n () const override;
180 
186  virtual numeric_index_type row_start () const override;
187 
193  virtual numeric_index_type row_stop () const override;
194 
202  virtual void set (const numeric_index_type i,
203  const numeric_index_type j,
204  const T value) override;
205 
213  virtual void add (const numeric_index_type i,
214  const numeric_index_type j,
215  const T value) override;
216 
224  virtual void add_matrix (const DenseMatrix<T> & dm,
225  const std::vector<numeric_index_type> & rows,
226  const std::vector<numeric_index_type> & cols) override;
227 
234  virtual void add_matrix (const DenseMatrix<T> & dm,
235  const std::vector<numeric_index_type> & dof_indices) override;
236 
245  virtual void add (const T a, const SparseMatrix<T> & X) override;
246 
255  virtual T operator () (const numeric_index_type i,
256  const numeric_index_type j) const override;
257 
263  virtual Real l1_norm () const override;
264 
270  virtual Real linfty_norm () const override;
271 
277  virtual bool closed() const override;
278 
284  virtual void print_personal(std::ostream & os=libMesh::out) const override;
285 
291  virtual void get_diagonal (NumericVector<T> & dest) const override;
292 
298  virtual void get_transpose (SparseMatrix<T> & dest) const override;
299 
305  void swap (EpetraMatrix<T> & other);
306 
315  Epetra_FECrsMatrix * mat () { libmesh_assert(_mat); return _mat; }
316 
325  const Epetra_FECrsMatrix * mat () const { libmesh_assert(_mat); return _mat; }
326 
327 private:
331  Epetra_FECrsMatrix * _mat;
332 
336  Epetra_Map * _map;
337 
341  Epetra_CrsGraph * _graph;
342 
347 
352 };
353 
354 } // namespace libMesh
355 
356 #endif // LIBMESH_TRILINOS_HAVE_EPETRA
357 #endif // LIBMESH_TRILINOS_EPETRA_MATRIX_H
virtual ~EpetraMatrix()
析构函数
virtual std::unique_ptr< SparseMatrix< T > > clone() const override
创建矩阵克隆。
virtual numeric_index_type row_stop() const override
获取本地行索引的结束位置。
const Epetra_FECrsMatrix * mat() const
获取原始Epetra_FECrsMatrix指针(const版本)。
virtual void get_transpose(SparseMatrix< T > &dest) const override
获取矩阵的转置。
bool _destroy_mat_on_exit
在接口函数中是否销毁_mat。
virtual void update_sparsity_pattern(const SparsityPattern::Graph &graph) override
更新矩阵的稀疏性模式。这将告诉底层矩阵存储方案如何映射(i,j)元素。
提供了不同线性代数库的向量存储方案的统一接口。
Definition: dof_map.h:67
bool _use_transpose
手动跟踪是否手动进行了转置。
virtual std::unique_ptr< SparseMatrix< T > > zero_clone() const override
创建零克隆矩阵。
virtual void init(const numeric_index_type m, const numeric_index_type n, const numeric_index_type m_l, const numeric_index_type n_l, const numeric_index_type nnz=30, const numeric_index_type noz=10, const numeric_index_type blocksize=1) override
初始化矩阵。
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 set(const numeric_index_type i, const numeric_index_type j, const T value) override
设置矩阵元素值。
这是一个通用的稀疏矩阵类。该类包含了必须在派生类中覆盖的纯虚拟成员。 使用一个公共的基类允许从不同的求解器包中以不同的格式统一访问稀疏矩阵。
Definition: dof_map.h:66
dof_id_type numeric_index_type
Definition: id_types.h:99
Epetra_CrsGraph * _graph
稀疏性模式
virtual numeric_index_type m() const override
获取全局行数。
void swap(EpetraMatrix< T > &other)
交换内部数据指针,不交换实际值。
OStreamProxy out
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
获取矩阵的L1范数。
virtual Real linfty_norm() const override
获取矩阵的L∞范数。
virtual void get_diagonal(NumericVector< T > &dest) const override
获取矩阵的对角线元素。
virtual bool closed() const override
检查矩阵是否已关闭。
virtual void zero() override
将矩阵元素设置为零。
virtual void clear() noexceptoverride
清除矩阵。
Epetra_FECrsMatrix * _mat
实际Epetra数据类型来保存矩阵条目。
virtual void add(const numeric_index_type i, const numeric_index_type j, const T value) override
添加矩阵元素值。
Epetra_FECrsMatrix * mat()
获取原始Epetra_FECrsMatrix指针。
定义用于有限元类型计算的密集矩阵。 用于在求和成全局矩阵之前存储单元刚度矩阵。所有被覆盖的虚函数都记录在dense_matrix_base.h中。
Definition: dof_map.h:65
Epetra_Map * _map
分布映射
此类提供了对Epetra数据结构的并行、稀疏矩阵的友好接口。所有重写的虚拟函数在sparse_matrix.h中都有文档。
virtual bool need_full_sparsity_pattern() const override
EpetraMatrix需要完整的稀疏性模式。