libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
laspack_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_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 final : public SparseMatrix<T>
57 {
58 
59 public:
68  LaspackMatrix (const Parallel::Communicator & comm);
69 
74  LaspackMatrix (LaspackMatrix &&) = delete;
75  LaspackMatrix (const LaspackMatrix &) = delete;
76  LaspackMatrix & operator= (const LaspackMatrix &) = delete;
77  LaspackMatrix & operator= (LaspackMatrix &&) = delete;
78  virtual ~LaspackMatrix ();
79 
83  virtual bool need_full_sparsity_pattern() const override
84  { return true; }
85 
91  virtual void update_sparsity_pattern (const SparsityPattern::Graph &) override;
92 
104  virtual void init (const numeric_index_type m,
105  const numeric_index_type n,
106  const numeric_index_type m_l,
107  const numeric_index_type n_l,
108  const numeric_index_type nnz=30,
109  const numeric_index_type noz=10,
110  const numeric_index_type blocksize=1) override;
111 
116  virtual void init (ParallelType = PARALLEL) override;
117 
122  virtual void clear () override;
123 
128  virtual void zero () override;
129 
134  virtual std::unique_ptr<SparseMatrix<T>> zero_clone () const override;
135 
140  virtual std::unique_ptr<SparseMatrix<T>> clone () const override;
141 
146  virtual void close () override;
147 
152  virtual numeric_index_type m () const override;
153 
158  virtual numeric_index_type n () const override;
159 
164  virtual numeric_index_type row_start () const override;
165 
170  virtual numeric_index_type row_stop () const override;
171 
179  virtual void set (const numeric_index_type i,
180  const numeric_index_type j,
181  const T value) override;
182 
190  virtual void add (const numeric_index_type i,
191  const numeric_index_type j,
192  const T value) override;
193 
201  virtual void add_matrix (const DenseMatrix<T> & dm,
202  const std::vector<numeric_index_type> & rows,
203  const std::vector<numeric_index_type> & cols) override;
204 
211  virtual void add_matrix (const DenseMatrix<T> & dm,
212  const std::vector<numeric_index_type> & dof_indices) override;
213 
221  virtual void add (const T a, const SparseMatrix<T> & X) override;
222 
227  virtual T operator () (const numeric_index_type i,
228  const numeric_index_type j) const override;
229 
233  virtual Real l1_norm () const override { libmesh_not_implemented(); return 0.; }
234 
238  virtual Real linfty_norm () const override { libmesh_not_implemented(); return 0.; }
239 
244  virtual bool closed() const override { return _closed; }
245 
250  virtual void print_personal(std::ostream & os=libMesh::out) const override { this->print(os); }
251 
258  virtual void get_diagonal (NumericVector<T> & dest) const override;
259 
266  virtual void get_transpose (SparseMatrix<T> & dest) const override;
267 
268 private:
269 
277  const numeric_index_type j) const;
281  QMatrix _QMat;
282 
289  std::vector<numeric_index_type> _csr;
290 
297  std::vector<std::vector<numeric_index_type>::const_iterator> _row_start;
298 
302  bool _closed;
303 
307  friend class LaspackVector<T>;
308  friend class LaspackLinearSolver<T>;
309 };
310 
311 } // namespace libMesh
312 
313 #endif // #ifdef LIBMESH_HAVE_LASPACK
314 #endif // #ifdef LIBMESH_LASPACK_MATRIX_H
virtual std::unique_ptr< SparseMatrix< T > > zero_clone() const override
创建一个与LaspackMatrix对象具有相同属性但所有元素为零的新矩阵。 这个函数用于创建一个与原矩阵具有相同大小和属性的全零矩阵。
virtual void get_diagonal(NumericVector< T > &dest) const override
获取矩阵的对角线元素,并存储到指定的NumericVector对象中。 这个函数用于获取矩阵的对角线元素。
virtual Real l1_norm() const override
返回矩阵的 范数。当前未实现。
virtual Real linfty_norm() const override
返回矩阵的 范数。当前未实现。
std::vector< numeric_index_type > _csr
压缩行索引。
virtual bool need_full_sparsity_pattern() const override
LaspackMatrix 需要完整的稀疏性模式。
提供了不同线性代数库的向量存储方案的统一接口。
Definition: dof_map.h:67
QMatrix _QMat
Laspack稀疏矩阵指针。
virtual void print_personal(std::ostream &os=libMesh::out) const override
打印LaspackMatrix对象的信息到指定的输出流(默认为libMesh::out)。 这个函数用于将矩阵的信息输出到指定的输出流中。
virtual void add(const numeric_index_type i, const numeric_index_type j, const T value) override
将 处的值增加 value。
这是一个通用的稀疏矩阵类。该类包含了必须在派生类中覆盖的纯虚拟成员。 使用一个公共的基类允许从不同的求解器包中以不同的格式统一访问稀疏矩阵。
Definition: dof_map.h:66
virtual std::unique_ptr< SparseMatrix< T > > clone() const override
克隆LaspackMatrix对象,创建一个具有相同属性和数据的新矩阵。 这个函数用于创建一个与原矩阵具有相同大小、属性和数据的新矩阵。
virtual void get_transpose(SparseMatrix< T > &dest) const override
获取矩阵的转置,并存储到指定的SparseMatrix对象中。 这个函数用于获取矩阵的转置矩阵。
virtual void close() override
关闭LaspackMatrix对象,标记矩阵已经完成构建,不再修改其结构。 这个函数用于标记矩阵的状态为已完成构建,之后不再修改其结构。
dof_id_type numeric_index_type
Definition: id_types.h:99
virtual T operator()(const numeric_index_type i, const numeric_index_type j) const override
获取LaspackMatrix对象的指定位置 处的值。 这个函数用于获取矩阵的特定元素的值。
OStreamProxy out
virtual numeric_index_type row_start() const override
返回LaspackMatrix对象的行起始位置。 这个函数用于获取矩阵的行起始位置,通常用于稀疏矩阵的索引操作。
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
初始化LaspackMatrix对象的属性,包括矩阵的行数、列数、非零元素的预估数量等。这些参数将影响矩阵的内存分配和性能。
virtual void zero() override
将LaspackMatrix对象的所有元素置零。 这个函数用于将矩阵中的所有元素设置为零。
virtual bool closed() const override
检查LaspackMatrix对象是否已关闭。 这个函数用于检查矩阵是否已经完成构建并关闭,不再修改其结构。
virtual void clear() override
清空LaspackMatrix对象,释放分配的内存和资源。 这个函数用于清除矩阵的数据和状态。
这个类为基于laspackc的串行向量数据结构提供了一个很好的接口。 所有被覆盖的虚函数都记录在numeric_vector.h中。
std::vector< std::vector< numeric_index_type >::const_iterator > _row_start
压缩行索引数据结构中每行的起始位置。
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual numeric_index_type m() const override
返回LaspackMatrix对象的行数。 这个函数用于获取矩阵的行数。
virtual numeric_index_type n() const override
返回LaspackMatrix对象的列数。 这个函数用于获取矩阵的列数。
void print(std::ostream &os=libMesh::out, const bool sparse=false) const
将矩阵的内容以统一的样式打印到屏幕上,而不考虑正在使用的矩阵/求解器包。
bool _closed
指示矩阵是否已关闭的标志。
virtual void update_sparsity_pattern(const SparsityPattern::Graph &) override
更新矩阵的稀疏性模式。这将告诉底层矩阵存储方案如何映射 元素。
virtual numeric_index_type row_stop() const override
返回LaspackMatrix对象的行结束位置。 这个函数用于获取矩阵的行结束位置,通常用于稀疏矩阵的索引操作。
LaspackMatrix类封装了Laspack库中的QMatrix对象。 目前,Laspack仅支持实数数据类型,因此这个类是对 SparseMatrix&lt;T&gt; 的全特化,其中 T = Real。 所...
virtual void set(const numeric_index_type i, const numeric_index_type j, const T value) override
设置LaspackMatrix对象的指定位置 处的值为 value。
定义用于有限元类型计算的密集矩阵。 用于在求和成全局矩阵之前存储单元刚度矩阵。所有被覆盖的虚函数都记录在dense_matrix_base.h中。
Definition: dof_map.h:65
LaspackMatrix & operator=(const LaspackMatrix &)=delete
numeric_index_type pos(const numeric_index_type i, const numeric_index_type j) const
virtual void add_matrix(const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols) override
将一个DenseMatrix对象的元素加到LaspackMatrix对象的指定行和列。
LaspackMatrix(const Parallel::Communicator &comm)
构造函数;将矩阵初始化为空,没有任何结构,即矩阵无法使用。因此,此构造函数仅适用于类的成员矩阵。 所有其他矩阵应在所有必要信息都可用的数据流的某一点创建。