libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
diagonal_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 #ifndef LIBMESH_DIAGONAL_MATRIX_H
19 #define LIBMESH_DIAGONAL_MATRIX_H
20 
21 #include "libmesh/id_types.h"
22 #include "libmesh/sparse_matrix.h"
23 
24 #include <memory>
25 
26 namespace libMesh
27 {
28 template <typename>
29 class NumericVector;
30 namespace Parallel
31 {
32 class Communicator;
33 }
34 
41 template <typename T>
42 class DiagonalMatrix : public SparseMatrix<T>
43 {
44 public:
53  explicit DiagonalMatrix(const Parallel::Communicator & comm);
54 
58  virtual ~DiagonalMatrix() = default;
59 
63  DiagonalMatrix(DiagonalMatrix &&) = default;
64  DiagonalMatrix & operator=(DiagonalMatrix &&) = default;
65 
74 
83 
84 
96  virtual
97  void init(const numeric_index_type m,
98  const numeric_index_type n,
99  const numeric_index_type m_l,
100  const numeric_index_type n_l,
101  const numeric_index_type nnz = 30,
102  const numeric_index_type noz = 10,
103  const numeric_index_type blocksize = 1) override;
104 
110  virtual void init(ParallelType type = PARALLEL) override;
111 
119  virtual void init(const NumericVector<T> & other, const bool fast = false);
120 
128  virtual void init(const DiagonalMatrix<T> & other, const bool fast = false);
129 
133  virtual void clear() override;
134 
138  virtual void zero() override;
139 
143  virtual std::unique_ptr<SparseMatrix<T>> zero_clone () const override;
144 
148  virtual std::unique_ptr<SparseMatrix<T>> clone () const override;
149 
153  virtual void close() override;
154 
158  virtual numeric_index_type m() const override;
159 
163  virtual numeric_index_type n() const override;
164 
168  virtual numeric_index_type row_start() const override;
169 
173  virtual numeric_index_type row_stop() const override;
174 
182  virtual void set(const numeric_index_type i, const numeric_index_type j, const T value) override;
183 
191  virtual void add(const numeric_index_type i, const numeric_index_type j, const T value) override;
192 
200  virtual
201  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
212  void add_matrix(const DenseMatrix<T> & dm,
213  const std::vector<numeric_index_type> & dof_indices) override;
214 
221  virtual void add(const T a, const SparseMatrix<T> & X) override;
222 
231  virtual T operator()(const numeric_index_type i, const numeric_index_type j) const override;
232 
238  virtual Real l1_norm() const override;
239 
245  virtual Real linfty_norm() const override;
246 
252  virtual bool closed() const override;
253 
259  virtual void print_personal(std::ostream & os = libMesh::out) const override;
260 
266  virtual void get_diagonal(NumericVector<T> & dest) const override;
267 
273  virtual void get_transpose(SparseMatrix<T> & dest) const override;
274 
281  virtual void zero_rows(std::vector<numeric_index_type> & rows, T val = 0) override;
282 
288  const NumericVector<T> & diagonal() const;
289 
290 protected:
292  std::unique_ptr<NumericVector<T>> _diagonal;
293 };
294 } // namespace libMesh
295 
296 #endif // LIBMESH_DIAGONAL_MATRIX_H
virtual void get_transpose(SparseMatrix< T > &dest) const override
获取当前矩阵的转置,并将其存储在指定的 SparseMatrix 对象中。
提供了不同线性代数库的向量存储方案的统一接口。
Definition: dof_map.h:67
virtual Real l1_norm() const override
计算矩阵的 范数。
virtual void add_matrix(const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols) override
将指定的 DenseMatrix dm 添加到矩阵中的指定行和列。
virtual void zero() override
将矩阵的所有元素置零。
virtual bool closed() const override
返回矩阵是否已关闭,即是否已完成初始化并可以用于计算。
virtual numeric_index_type n() const override
返回矩阵的总列数。
const NumericVector< T > & diagonal() const
返回对底层数据存储 NumericVector 的常量引用。
这是一个通用的稀疏矩阵类。该类包含了必须在派生类中覆盖的纯虚拟成员。 使用一个公共的基类允许从不同的求解器包中以不同的格式统一访问稀疏矩阵。
Definition: dof_map.h:66
virtual numeric_index_type m() const override
返回矩阵的总行数。
virtual void close() override
完成矩阵的初始化和结构设置,使其可以用于计算。
dof_id_type numeric_index_type
Definition: id_types.h:99
virtual numeric_index_type row_stop() const override
返回矩阵在本地计算中的结束行号。
virtual ~DiagonalMatrix()=default
由于此类不手动管理任何内存,所以析构函数可以安全地默认。
virtual void clear() override
清除矩阵的所有内容,将其恢复到初始状态。
OStreamProxy out
DiagonalMatrix(const Parallel::Communicator &comm)
构造函数;将矩阵初始化为空,没有任何结构,即矩阵根本无法使用。因此,此构造函数仅对是类成员的矩阵有用。 所有其他矩阵应在数据流中的某一点创建,此时所有必要的信息都是可用的。 ...
virtual T operator()(const numeric_index_type i, const numeric_index_type j) const override
返回矩阵中指定位置的元素值。
对角矩阵类,其底层存储是一个向量
virtual void print_personal(std::ostream &os=libMesh::out) const override
在输出流中打印矩阵的个性化信息。
virtual void zero_rows(std::vector< numeric_index_type > &rows, T val=0) override
将指定行的所有元素置零。
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void get_diagonal(NumericVector< T > &dest) const override
获取对角矩阵的对角线元素,并将它们存储在指定的 NumericVector 对象中。
virtual Real linfty_norm() const override
计算矩阵的 范数。
DiagonalMatrix & operator=(DiagonalMatrix &&)=default
virtual void set(const numeric_index_type i, const numeric_index_type j, const T value) override
设置矩阵中指定位置的元素值。
virtual std::unique_ptr< SparseMatrix< T > > clone() const override
克隆当前矩阵,返回一个新的矩阵,其结构和维度相同。
virtual numeric_index_type row_start() const override
返回矩阵在本地计算中的起始行号。
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
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
初始化矩阵的维度和结构
定义用于有限元类型计算的密集矩阵。 用于在求和成全局矩阵之前存储单元刚度矩阵。所有被覆盖的虚函数都记录在dense_matrix_base.h中。
Definition: dof_map.h:65
virtual void add(const numeric_index_type i, const numeric_index_type j, const T value) override
在矩阵中指定位置的元素上添加一个值。
virtual std::unique_ptr< SparseMatrix< T > > zero_clone() const override
创建当前矩阵的零副本,其结构和维度相同。