libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
Public 成员函数 | 静态 Public 成员函数 | Protected 类型 | Protected 成员函数 | Protected 属性 | 静态 Protected 属性 | 所有成员列表
libMesh::DiagonalMatrix< T > 模板类 参考

对角矩阵类,其底层存储是一个向量 更多...

#include <diagonal_matrix.h>

类 libMesh::DiagonalMatrix< T > 继承关系图:
[图例]

Public 成员函数

 DiagonalMatrix (const Parallel::Communicator &comm)
 构造函数;将矩阵初始化为空,没有任何结构,即矩阵根本无法使用。因此,此构造函数仅对是类成员的矩阵有用。 所有其他矩阵应在数据流中的某一点创建,此时所有必要的信息都是可用的。 更多...
 
virtual ~DiagonalMatrix ()=default
 由于此类不手动管理任何内存,所以析构函数可以安全地默认。 更多...
 
 DiagonalMatrix (DiagonalMatrix &&)=default
 unique pointers 可以移动但不能复制 更多...
 
DiagonalMatrixoperator= (DiagonalMatrix &&)=default
 
DiagonalMatrixoperator= (const NumericVector< T > &vec)
 vec 的内容复制到底层对角线存储中 更多...
 
DiagonalMatrixoperator= (NumericVector< T > &&vec)
 vec 的内容移动到底层对角线存储中 更多...
 
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 init (ParallelType type=PARALLEL) override
 初始化并行矩阵 更多...
 
virtual void init (const NumericVector< T > &other, const bool fast=false)
 使用 NumericVector other 初始化,例如复制 other 的存储分配。 该函数不复制向量条目。如果将 fast 设置为 false,则初始化的条目将显式清零,否则它们的值是不确定的。 更多...
 
virtual void init (const DiagonalMatrix< T > &other, const bool fast=false)
 使用 DiagonalMatrix other 初始化,例如复制 other 底层 NumericVector 的存储分配。 该函数不复制向量条目。如果将 fast 设置为 false,则初始化的条目将显式清零,否则它们的值是不确定的。 更多...
 
virtual void clear () override
 清除矩阵的所有内容,将其恢复到初始状态。 更多...
 
virtual void zero () override
 将矩阵的所有元素置零。 更多...
 
virtual std::unique_ptr
< SparseMatrix< T > > 
zero_clone () const override
 创建当前矩阵的零副本,其结构和维度相同。 更多...
 
virtual std::unique_ptr
< SparseMatrix< T > > 
clone () const override
 克隆当前矩阵,返回一个新的矩阵,其结构和维度相同。 更多...
 
virtual void close () override
 完成矩阵的初始化和结构设置,使其可以用于计算。 更多...
 
virtual numeric_index_type m () const override
 返回矩阵的总行数。 更多...
 
virtual numeric_index_type n () const override
 返回矩阵的总列数。 更多...
 
virtual numeric_index_type row_start () const override
 返回矩阵在本地计算中的起始行号。 更多...
 
virtual numeric_index_type row_stop () const override
 返回矩阵在本地计算中的结束行号。 更多...
 
virtual void set (const numeric_index_type i, const numeric_index_type j, const T value) override
 设置矩阵中指定位置的元素值。 更多...
 
virtual void add (const numeric_index_type i, const numeric_index_type j, const T value) 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 add_matrix (const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &dof_indices) override
 将指定的 DenseMatrix dm 添加到矩阵中的指定自由度索引。 更多...
 
virtual void add (const T a, const SparseMatrix< T > &X) override
 用矩阵 X 中的值乘以标量 a 添加到当前矩阵中。 更多...
 
virtual T operator() (const numeric_index_type i, const numeric_index_type j) const override
 返回矩阵中指定位置的元素值。 更多...
 
virtual Real l1_norm () const override
 计算矩阵的 $l_1$ 范数。 更多...
 
virtual Real linfty_norm () const override
 计算矩阵的 $l_\infty$ 范数。 更多...
 
virtual bool closed () const override
 返回矩阵是否已关闭,即是否已完成初始化并可以用于计算。 更多...
 
virtual void print_personal (std::ostream &os=libMesh::out) const override
 在输出流中打印矩阵的个性化信息。 更多...
 
virtual void get_diagonal (NumericVector< T > &dest) const override
 获取对角矩阵的对角线元素,并将它们存储在指定的 NumericVector 对象中。 更多...
 
virtual void get_transpose (SparseMatrix< T > &dest) const override
 获取当前矩阵的转置,并将其存储在指定的 SparseMatrix 对象中。 更多...
 
virtual void zero_rows (std::vector< numeric_index_type > &rows, T val=0) override
 将指定行的所有元素置零。 更多...
 
const NumericVector< T > & diagonal () const
 返回对底层数据存储 NumericVector 的常量引用。 更多...
 
virtual bool initialized () const
 
void attach_dof_map (const DofMap &dof_map)
 设置要使用的 DofMap 的指针。如果不使用单独的稀疏性模式, 则使用来自 DofMap 的模式。 更多...
 
void attach_sparsity_pattern (const SparsityPattern::Build &sp)
 设置要使用的稀疏性模式的指针。在矩阵需要比系统中的大(或更小以提高效率)的模式, 或者在 DofMap 未计算系统稀疏性模式的情况下使用。 更多...
 
virtual bool need_full_sparsity_pattern () const
 
virtual void update_sparsity_pattern (const SparsityPattern::Graph &)
 更新矩阵的稀疏性模式。当您的 SparseMatrix<T> 实现不需要此数据时, 只需不覆盖此方法。 更多...
 
virtual void flush ()
 对于 PETSc 矩阵,此函数类似于 close,但不收缩内存。 当我们希望在 ADD_VALUES 和 INSERT_VALUES 之间切换时,这很有用。 在使用矩阵之前应该调用 close。 更多...
 
virtual numeric_index_type local_m () const
 获取此进程拥有的行数。 更多...
 
virtual void add_block_matrix (const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &brows, const std::vector< numeric_index_type > &bcols)
 将完整矩阵 dm 添加到 SparseMatrix。这对于在装配时添加元素矩阵很有用。 矩阵被假定为块矩阵,brow、bcol 对应于*块*行和列索引。 更多...
 
virtual void add_block_matrix (const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &dof_indices)
 add_block_matrix() 相同,但假定行和列映射相同。 因此矩阵 dm 必须是方阵。 更多...
 
virtual void matrix_matrix_mult (SparseMatrix< T > &, SparseMatrix< T > &, bool)
 计算 Y = A*X,其中 X 为矩阵。 更多...
 
virtual void add_sparse_matrix (const SparseMatrix< T > &, const std::map< numeric_index_type, numeric_index_type > &, const std::map< numeric_index_type, numeric_index_type > &, const T)
 scalar* spm 添加到此矩阵的行和列中: A(rows[i], cols[j]) += scalar * spm(i,j) 更多...
 
void print (std::ostream &os=libMesh::out, const bool sparse=false) const
 将矩阵的内容以统一的样式打印到屏幕上,而不考虑正在使用的矩阵/求解器包。 更多...
 
template<>
void print (std::ostream &os, const bool sparse) const
 
virtual void print_matlab (const std::string &="") const
 以 Matlab 的稀疏矩阵格式打印矩阵的内容。可选择将矩阵打印到名为 name 的文件中。 如果未指定 name ,则将其转储到屏幕上。 更多...
 
virtual void create_submatrix (SparseMatrix< T > &submatrix, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols) const
 此函数创建一个名为 "submatrix" 的矩阵,其定义由 "rows" 和 "cols" 条目中的行和列索引给定。 目前,此操作仅对 PetscMatrix 类型定义。 注意:rowscols 向量需要排序; 如果 rowscols 向量未排序,则使用下面的 nosort 版本; rowscols 仅包含由此处理器拥有的索引。 更多...
 
virtual void create_submatrix_nosort (SparseMatrix< T > &, const std::vector< numeric_index_type > &, const std::vector< numeric_index_type > &) const
 与上述函数类似,此函数创建由 rowscols 向量中的索引定义的 submatrix。 注意:rowscols 可以是无序的; 如果索引已排序,则对于效率更高的操作,请使用上面的函数; rowscols 可以包含由其他处理器拥有的索引。 更多...
 
virtual void reinit_submatrix (SparseMatrix< T > &submatrix, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols) const
 此函数与上述函数类似,但允许您重用 "submatrix" 的现有稀疏性模式,而不是再次分配它。 如果经常提取相同大小的子矩阵,这应该更有效。 更多...
 
void vector_mult (NumericVector< T > &dest, const NumericVector< T > &arg) const
 将矩阵乘以 NumericVector arg 并将结果存储在 NumericVector dest 中。 更多...
 
void vector_mult_add (NumericVector< T > &dest, const NumericVector< T > &arg) const
 将矩阵乘以 NumericVector arg ,并将结果添加到 NumericVector dest 中。 更多...
 
virtual void get_row (numeric_index_type, std::vector< numeric_index_type > &, std::vector< T > &) const
 从矩阵获取一行。 更多...
 

静态 Public 成员函数

static std::unique_ptr
< SparseMatrix< T > > 
build (const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package(), const MatrixBuildType matrix_build_type=MatrixBuildType::AUTOMATIC)
 使用由 solver_package 指定的线性求解器包构建一个 SparseMatrix<T>。 更多...
 
static std::string get_info ()
 Gets a string containing the reference information. 更多...
 
static void print_info (std::ostream &out_stream=libMesh::out)
 Prints the reference information, by default to libMesh::out. 更多...
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects. 更多...
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info() 更多...
 
static void disable_print_counter_info ()
 

Protected 类型

typedef std::map< std::string,
std::pair< unsigned int,
unsigned int > > 
Counts
 Data structure to log the information. 更多...
 

Protected 成员函数

virtual void _get_submatrix (SparseMatrix< T > &, const std::vector< numeric_index_type > &, const std::vector< numeric_index_type > &, const bool) const
 创建子矩阵和 reinit_submatrix 例程的受保护实现。 更多...
 
void increment_constructor_count (const std::string &name) noexcept
 Increments the construction counter. 更多...
 
void increment_destructor_count (const std::string &name) noexcept
 Increments the destruction counter. 更多...
 

Protected 属性

std::unique_ptr< NumericVector
< T > > 
_diagonal
 底层对角矩阵存储 更多...
 
DofMap const * _dof_map
 与此对象关联的 DofMap 对象。可以查询其在处理器上的自由度计数。 更多...
 
SparsityPattern::Build const * _sp
 与此对象关联的 sparsity pattern。在需要时, 应查询其入口计数(或使用 need_full_sparsity_pattern,模式)。 更多...
 
bool _is_initialized
 标志,指示矩阵是否已初始化。 更多...
 

静态 Protected 属性

static Counts _counts
 Actually holds the data. 更多...
 
static Threads::atomic
< unsigned int > 
_n_objects
 The number of objects. 更多...
 
static Threads::spin_mutex _mutex
 Mutual exclusion object to enable thread-safe reference counting. 更多...
 
static bool _enable_print_counter = true
 Flag to control whether reference count information is printed when print_info is called. 更多...
 

详细描述

template<typename T>
class libMesh::DiagonalMatrix< T >

对角矩阵类,其底层存储是一个向量

作者
Alexander D. Lindsay
日期
2019

在文件 diagonal_matrix.h42 行定义.

成员类型定义说明

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts
protectedinherited

Data structure to log the information.

The log is identified by the class name.

在文件 reference_counter.h119 行定义.

构造及析构函数说明

template<typename T >
libMesh::DiagonalMatrix< T >::DiagonalMatrix ( const Parallel::Communicator &  comm)
explicit

构造函数;将矩阵初始化为空,没有任何结构,即矩阵根本无法使用。因此,此构造函数仅对是类成员的矩阵有用。 所有其他矩阵应在数据流中的某一点创建,此时所有必要的信息都是可用的。

在使用之前,您必须使用 init(...) 初始化矩阵。

参数
comm通信器对象,用于在并行环境中进行通信。

在文件 diagonal_matrix.C33 行定义.

参考 libMesh::DiagonalMatrix< T >::_diagonal , 以及 libMesh::NumericVector< T >::build().

33  : SparseMatrix<T>(comm_in)
34 {
36 }
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
构建一个 NumericVector 对象。
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T>
virtual libMesh::DiagonalMatrix< T >::~DiagonalMatrix ( )
virtualdefault

由于此类不手动管理任何内存,所以析构函数可以安全地默认。

template<typename T>
libMesh::DiagonalMatrix< T >::DiagonalMatrix ( DiagonalMatrix< T > &&  )
default

unique pointers 可以移动但不能复制

成员函数说明

template<typename T>
virtual void libMesh::SparseMatrix< T >::_get_submatrix ( SparseMatrix< T > &  ,
const std::vector< numeric_index_type > &  ,
const std::vector< numeric_index_type > &  ,
const bool   
) const
inlineprotectedvirtualinherited

创建子矩阵和 reinit_submatrix 例程的受保护实现。

注解
派生类必须在此函数中覆盖,以使其正常工作!

libMesh::PetscMatrix< T > 重载.

在文件 sparse_matrix.h483 行定义.

参考自 libMesh::SparseMatrix< T >::create_submatrix() , 以及 libMesh::SparseMatrix< T >::reinit_submatrix().

487  {
488  libmesh_not_implemented();
489  }
template<typename T >
void libMesh::DiagonalMatrix< T >::add ( const numeric_index_type  i,
const numeric_index_type  j,
const T  value 
)
overridevirtual

在矩阵中指定位置的元素上添加一个值。

参数
i行索引。
j列索引。
value要添加的值。

实现了 libMesh::SparseMatrix< T >.

libMesh::LumpedMassMatrix< T > 重载.

在文件 diagonal_matrix.C190 行定义.

191 {
192  if (i == j)
193  _diagonal->add(i, value);
194 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T >
void libMesh::DiagonalMatrix< T >::add ( const T  a,
const SparseMatrix< T > &  X 
)
overridevirtual

用矩阵 X 中的值乘以标量 a 添加到当前矩阵中。

参数
a标量乘法因子。
X要添加到当前矩阵的 SparseMatrix 对象。

实现了 libMesh::SparseMatrix< T >.

libMesh::LumpedMassMatrix< T > 重载.

在文件 diagonal_matrix.C225 行定义.

参考 libMesh::SparseMatrix< T >::get_diagonal().

226 {
227  auto x_diagonal = _diagonal->zero_clone();
228  X.get_diagonal(*x_diagonal);
229  _diagonal->add(a, *x_diagonal);
230 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T >
void libMesh::SparseMatrix< T >::add_block_matrix ( const DenseMatrix< T > &  dm,
const std::vector< numeric_index_type > &  brows,
const std::vector< numeric_index_type > &  bcols 
)
virtualinherited

将完整矩阵 dm 添加到 SparseMatrix。这对于在装配时添加元素矩阵很有用。 矩阵被假定为块矩阵,brow、bcol 对应于*块*行和列索引。

libMesh::PetscMatrix< T > 重载.

在文件 sparse_matrix.C77 行定义.

参考 libMesh::DenseMatrixBase< T >::m() , 以及 libMesh::DenseMatrixBase< T >::n().

参考自 libMesh::SparseMatrix< T >::add_block_matrix().

80 {
81  libmesh_assert_equal_to (dm.m() / brows.size(), dm.n() / bcols.size());
82 
83  const numeric_index_type blocksize = cast_int<numeric_index_type>
84  (dm.m() / brows.size());
85 
86  libmesh_assert_equal_to (dm.m()%blocksize, 0);
87  libmesh_assert_equal_to (dm.n()%blocksize, 0);
88 
89  std::vector<numeric_index_type> rows, cols;
90 
91  rows.reserve(blocksize*brows.size());
92  cols.reserve(blocksize*bcols.size());
93 
94  for (auto & row : brows)
95  {
96  numeric_index_type i = row * blocksize;
97 
98  for (unsigned int v=0; v<blocksize; v++)
99  rows.push_back(i++);
100  }
101 
102  for (auto & col : bcols)
103  {
104  numeric_index_type j = col * blocksize;
105 
106  for (unsigned int v=0; v<blocksize; v++)
107  cols.push_back(j++);
108  }
109 
110  this->add_matrix (dm, rows, cols);
111 }
virtual void add_matrix(const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols)=0
将完整矩阵 dm 添加到 SparseMatrix。这对于在装配时添加元素矩阵很有用。
dof_id_type numeric_index_type
Definition: id_types.h:99
template<typename T>
virtual void libMesh::SparseMatrix< T >::add_block_matrix ( const DenseMatrix< T > &  dm,
const std::vector< numeric_index_type > &  dof_indices 
)
inlinevirtualinherited

add_block_matrix() 相同,但假定行和列映射相同。 因此矩阵 dm 必须是方阵。

libMesh::PetscMatrix< T > 重载.

在文件 sparse_matrix.h278 行定义.

参考 libMesh::SparseMatrix< T >::add_block_matrix().

280  { this->add_block_matrix (dm, dof_indices, dof_indices); }
virtual void add_block_matrix(const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &brows, const std::vector< numeric_index_type > &bcols)
将完整矩阵 dm 添加到 SparseMatrix。这对于在装配时添加元素矩阵很有用。 矩阵被假定为块矩阵,brow、bcol 对应于*块*行和列索引。
Definition: sparse_matrix.C:77
template<typename T >
void libMesh::DiagonalMatrix< T >::add_matrix ( const DenseMatrix< T > &  dm,
const std::vector< numeric_index_type > &  rows,
const std::vector< numeric_index_type > &  cols 
)
overridevirtual

将指定的 DenseMatrix dm 添加到矩阵中的指定行和列。

参数
dm要添加的 DenseMatrix 对象。
rows要添加到的行索引列表。
cols要添加到的列索引列表。

实现了 libMesh::SparseMatrix< T >.

在文件 diagonal_matrix.C198 行定义.

参考 libMesh::DenseMatrixBase< T >::m() , 以及 libMesh::DenseMatrixBase< T >::n().

201 {
202  auto m = dm.m();
203  auto n = dm.n();
204 
205  for (decltype(m) i = 0; i < m; ++i)
206  for (decltype(n) j = 0; j < n; ++j)
207  {
208  auto global_i = rows[i];
209  auto global_j = cols[j];
210  if (global_i == global_j)
211  _diagonal->add(global_i, dm(i, j));
212  }
213 }
virtual numeric_index_type n() const override
返回矩阵的总列数。
virtual numeric_index_type m() const override
返回矩阵的总行数。
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T >
void libMesh::DiagonalMatrix< T >::add_matrix ( const DenseMatrix< T > &  dm,
const std::vector< numeric_index_type > &  dof_indices 
)
overridevirtual

将指定的 DenseMatrix dm 添加到矩阵中的指定自由度索引。

参数
dm要添加的 DenseMatrix 对象。
dof_indices要添加到的自由度索引列表。

实现了 libMesh::SparseMatrix< T >.

在文件 diagonal_matrix.C217 行定义.

参考 libMesh::DenseMatrixBase< T >::diagonal().

219 {
220  _diagonal->add_vector(dm.diagonal(), dof_indices);
221 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T>
virtual void libMesh::SparseMatrix< T >::add_sparse_matrix ( const SparseMatrix< T > &  ,
const std::map< numeric_index_type, numeric_index_type > &  ,
const std::map< numeric_index_type, numeric_index_type > &  ,
const T   
)
inlinevirtualinherited

scalar* spm 添加到此矩阵的行和列中: A(rows[i], cols[j]) += scalar * spm(i,j)

libMesh::PetscMatrix< T > 重载.

在文件 sparse_matrix.h297 行定义.

301  { libmesh_not_implemented(); }
template<typename T >
void libMesh::SparseMatrix< T >::attach_dof_map ( const DofMap dof_map)
inherited

设置要使用的 DofMap 的指针。如果不使用单独的稀疏性模式, 则使用来自 DofMap 的模式。

dof_map 的生命周期必须超过 this 的生命周期。

在文件 sparse_matrix.C58 行定义.

参考 libMesh::DofMap::get_sparsity_pattern().

参考自 libMesh::DofMap::update_sparsity_pattern().

59 {
60  _dof_map = &dof_map;
61  if (!_sp)
62  _sp = dof_map.get_sparsity_pattern();
63 }
const SparsityPattern::Graph & get_sparsity_pattern() const
Rows of sparse matrix indices, indexed by the offset from the first DoF on this processor.
SparsityPattern::Build const * _sp
与此对象关联的 sparsity pattern。在需要时, 应查询其入口计数(或使用 need_full_sparsity_pattern,模式)。
DofMap const * _dof_map
与此对象关联的 DofMap 对象。可以查询其在处理器上的自由度计数。
template<typename T >
void libMesh::SparseMatrix< T >::attach_sparsity_pattern ( const SparsityPattern::Build sp)
inherited

设置要使用的稀疏性模式的指针。在矩阵需要比系统中的大(或更小以提高效率)的模式, 或者在 DofMap 未计算系统稀疏性模式的情况下使用。

sp 的生命周期必须超过 this 的生命周期。

在文件 sparse_matrix.C68 行定义.

参考自 libMesh::DofMap::update_sparsity_pattern().

69 {
70  _sp = &sp;
71 }
SparsityPattern::Build const * _sp
与此对象关联的 sparsity pattern。在需要时, 应查询其入口计数(或使用 need_full_sparsity_pattern,模式)。
template<typename T >
std::unique_ptr< SparseMatrix< T > > libMesh::SparseMatrix< T >::build ( const Parallel::Communicator &  comm,
const SolverPackage  solver_package = libMesh::default_solver_package(),
const MatrixBuildType  matrix_build_type = MatrixBuildType::AUTOMATIC 
)
staticinherited

使用由 solver_package 指定的线性求解器包构建一个 SparseMatrix<T>。

在文件 sparse_matrix.C151 行定义.

参考 libMesh::EIGEN_SOLVERS, libMesh::LASPACK_SOLVERS, libMesh::libmesh_ignore() , 以及 libMesh::TRILINOS_SOLVERS.

参考自 libMesh::DofMap::process_mesh_constraint_rows().

154 {
155  // Avoid unused parameter warnings when no solver packages are enabled.
156  libmesh_ignore(comm);
157 
158  if (matrix_build_type == MatrixBuildType::DIAGONAL)
159  return std::make_unique<DiagonalMatrix<T>>(comm);
160 
161  // Build the appropriate vector
162  switch (solver_package)
163  {
164 
165 #ifdef LIBMESH_HAVE_LASPACK
166  case LASPACK_SOLVERS:
167  return std::make_unique<LaspackMatrix<T>>(comm);
168 #endif
169 
170 
171 #ifdef LIBMESH_HAVE_PETSC
172  case PETSC_SOLVERS:
173  return std::make_unique<PetscMatrix<T>>(comm);
174 #endif
175 
176 
177 #ifdef LIBMESH_TRILINOS_HAVE_EPETRA
178  case TRILINOS_SOLVERS:
179  return std::make_unique<EpetraMatrix<T>>(comm);
180 #endif
181 
182 
183 #ifdef LIBMESH_HAVE_EIGEN
184  case EIGEN_SOLVERS:
185  return std::make_unique<EigenSparseMatrix<T>>(comm);
186 #endif
187 
188  default:
189  libmesh_error_msg("ERROR: Unrecognized solver package: " << solver_package);
190  }
191 }
EIGEN_SOLVERS
Definition: libmesh.C:249
TRILINOS_SOLVERS
Definition: libmesh.C:247
void libmesh_ignore(const Args &...)
LASPACK_SOLVERS
Definition: libmesh.C:251
template<typename T >
void libMesh::DiagonalMatrix< T >::clear ( )
overridevirtual

清除矩阵的所有内容,将其恢复到初始状态。

实现了 libMesh::SparseMatrix< T >.

在文件 diagonal_matrix.C99 行定义.

100 {
101  _diagonal->clear();
102 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T >
std::unique_ptr< SparseMatrix< T > > libMesh::DiagonalMatrix< T >::clone ( ) const
overridevirtual

克隆当前矩阵,返回一个新的矩阵,其结构和维度相同。

实现了 libMesh::SparseMatrix< T >.

libMesh::LumpedMassMatrix< T > 重载.

在文件 diagonal_matrix.C129 行定义.

130 {
131  // Make empty copy with matching comm
132  auto mat_copy = std::make_unique<DiagonalMatrix<T>>(this->comm());
133 
134  // Make copy of our diagonal
135  auto diag_copy = _diagonal->clone();
136 
137  // Swap diag_copy with diagonal in mat_copy
138  *mat_copy = std::move(*diag_copy);
139 
140  // Work around an issue on older compilers. We are able to simply
141  // "return mat_copy;" on newer compilers
142  return std::unique_ptr<SparseMatrix<T>>(mat_copy.release());
143 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T >
void libMesh::DiagonalMatrix< T >::close ( )
overridevirtual

完成矩阵的初始化和结构设置,使其可以用于计算。

实现了 libMesh::SparseMatrix< T >.

在文件 diagonal_matrix.C147 行定义.

148 {
149  _diagonal->close();
150 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T >
bool libMesh::DiagonalMatrix< T >::closed ( ) const
overridevirtual

返回矩阵是否已关闭,即是否已完成初始化并可以用于计算。

返回
如果矩阵已关闭,则为 true;否则为 false。

实现了 libMesh::SparseMatrix< T >.

在文件 diagonal_matrix.C258 行定义.

259 {
260  return _diagonal->closed();
261 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T>
virtual void libMesh::SparseMatrix< T >::create_submatrix ( SparseMatrix< T > &  submatrix,
const std::vector< numeric_index_type > &  rows,
const std::vector< numeric_index_type > &  cols 
) const
inlinevirtualinherited

此函数创建一个名为 "submatrix" 的矩阵,其定义由 "rows" 和 "cols" 条目中的行和列索引给定。 目前,此操作仅对 PetscMatrix 类型定义。 注意:rowscols 向量需要排序; 如果 rowscols 向量未排序,则使用下面的 nosort 版本; rowscols 仅包含由此处理器拥有的索引。

在文件 sparse_matrix.h388 行定义.

参考 libMesh::SparseMatrix< T >::_get_submatrix().

391  {
392  this->_get_submatrix(submatrix,
393  rows,
394  cols,
395  false); // false means DO NOT REUSE submatrix
396  }
virtual void _get_submatrix(SparseMatrix< T > &, const std::vector< numeric_index_type > &, const std::vector< numeric_index_type > &, const bool) const
创建子矩阵和 reinit_submatrix 例程的受保护实现。
template<typename T>
virtual void libMesh::SparseMatrix< T >::create_submatrix_nosort ( SparseMatrix< T > &  ,
const std::vector< numeric_index_type > &  ,
const std::vector< numeric_index_type > &   
) const
inlinevirtualinherited

与上述函数类似,此函数创建由 rowscols 向量中的索引定义的 submatrix。 注意:rowscols 可以是无序的; 如果索引已排序,则对于效率更高的操作,请使用上面的函数; rowscols 可以包含由其他处理器拥有的索引。

libMesh::PetscMatrix< T > 重载.

在文件 sparse_matrix.h404 行定义.

407  {
408  libmesh_not_implemented();
409  }
template<typename T >
const NumericVector< T > & libMesh::DiagonalMatrix< T >::diagonal ( ) const

返回对底层数据存储 NumericVector 的常量引用。

返回
对底层数据存储 NumericVector 的常量引用。

在文件 diagonal_matrix.C299 行定义.

参考自 libMesh::DiagonalMatrix< T >::init().

300 {
301  return *_diagonal;
302 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

在文件 reference_counter.C100 行定义.

参考 libMesh::ReferenceCounter::_enable_print_counter.

101 {
102  _enable_print_counter = false;
103  return;
104 }
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...
void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

Methods to enable/disable the reference counter output from print_info()

在文件 reference_counter.C94 行定义.

参考 libMesh::ReferenceCounter::_enable_print_counter.

95 {
96  _enable_print_counter = true;
97  return;
98 }
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...
template<typename T>
virtual void libMesh::SparseMatrix< T >::flush ( )
inlinevirtualinherited

对于 PETSc 矩阵,此函数类似于 close,但不收缩内存。 当我们希望在 ADD_VALUES 和 INSERT_VALUES 之间切换时,这很有用。 在使用矩阵之前应该调用 close。

libMesh::PetscMatrix< T > 重载.

在文件 sparse_matrix.h202 行定义.

参考 libMesh::SparseMatrix< T >::close().

202 { close(); }
virtual void close()=0
调用 SparseMatrix 的内部装配例程,确保值在处理器之间保持一致。
template<typename T >
void libMesh::DiagonalMatrix< T >::get_diagonal ( NumericVector< T > &  dest) const
overridevirtual

获取对角矩阵的对角线元素,并将它们存储在指定的 NumericVector 对象中。

参数
dest存储对角元素的 NumericVector 对象。

实现了 libMesh::SparseMatrix< T >.

在文件 diagonal_matrix.C272 行定义.

273 {
274  dest = *_diagonal;
275 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

在文件 reference_counter.C47 行定义.

参考 libMesh::ReferenceCounter::_counts.

参考自 libMesh::ReferenceCounter::print_info().

48 {
49 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50 
51  std::ostringstream oss;
52 
53  oss << '\n'
54  << " ---------------------------------------------------------------------------- \n"
55  << "| Reference count information |\n"
56  << " ---------------------------------------------------------------------------- \n";
57 
58  for (const auto & [name, cd] : _counts)
59  oss << "| " << name << " reference count information:\n"
60  << "| Creations: " << cd.first << '\n'
61  << "| Destructions: " << cd.second << '\n';
62 
63  oss << " ---------------------------------------------------------------------------- \n";
64 
65  return oss.str();
66 
67 #else
68 
69  return "";
70 
71 #endif
72 }
static Counts _counts
Actually holds the data.
template<typename T>
virtual void libMesh::SparseMatrix< T >::get_row ( numeric_index_type  ,
std::vector< numeric_index_type > &  ,
std::vector< T > &   
) const
inlinevirtualinherited

从矩阵获取一行。

参数
i要获取的矩阵行
indices将填充为与(可能)非零值对应的列索引的容器
values包含列值的容器
注解
此函数检索矩阵的一行,并将提供的容器填充为列索引和值。

libMesh::PetscMatrix< T > 重载.

在文件 sparse_matrix.h469 行定义.

472  {
473  libmesh_not_implemented();
474  }
template<typename T >
void libMesh::DiagonalMatrix< T >::get_transpose ( SparseMatrix< T > &  dest) const
overridevirtual

获取当前矩阵的转置,并将其存储在指定的 SparseMatrix 对象中。

参数
dest存储转置矩阵的 SparseMatrix 对象。

实现了 libMesh::SparseMatrix< T >.

在文件 diagonal_matrix.C279 行定义.

280 {
281  auto diagonal_dest = dynamic_cast<DiagonalMatrix<T> *>(&dest);
282  if (diagonal_dest)
283  *diagonal_dest = *_diagonal;
284  else
285  libmesh_error_msg("DenseMatrix<T>::get_transpose currently only accepts another DenseMatrix<T> "
286  "as its argument");
287 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
inlineprotectednoexceptinherited

Increments the construction counter.

Should be called in the constructor of any derived class that will be reference counted.

在文件 reference_counter.h183 行定义.

参考 libMesh::err.

参考自 libMesh::ReferenceCountedObject< SparseMatrix< T > >::ReferenceCountedObject().

184 {
185  libmesh_try
186  {
187  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
188  std::pair<unsigned int, unsigned int> & p = _counts[name];
189  p.first++;
190  }
191  libmesh_catch (...)
192  {
193  auto stream = libMesh::err.get();
194  stream->exceptions(stream->goodbit); // stream must not throw
195  libMesh::err << "Encountered unrecoverable error while calling "
196  << "ReferenceCounter::increment_constructor_count() "
197  << "for a(n) " << name << " object." << std::endl;
198  std::terminate();
199  }
200 }
OStreamProxy err
static Counts _counts
Actually holds the data.
void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
inlineprotectednoexceptinherited

Increments the destruction counter.

Should be called in the destructor of any derived class that will be reference counted.

在文件 reference_counter.h207 行定义.

参考 libMesh::err.

参考自 libMesh::ReferenceCountedObject< SparseMatrix< T > >::~ReferenceCountedObject().

208 {
209  libmesh_try
210  {
211  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
212  std::pair<unsigned int, unsigned int> & p = _counts[name];
213  p.second++;
214  }
215  libmesh_catch (...)
216  {
217  auto stream = libMesh::err.get();
218  stream->exceptions(stream->goodbit); // stream must not throw
219  libMesh::err << "Encountered unrecoverable error while calling "
220  << "ReferenceCounter::increment_destructor_count() "
221  << "for a(n) " << name << " object." << std::endl;
222  std::terminate();
223  }
224 }
OStreamProxy err
static Counts _counts
Actually holds the data.
template<typename T >
void libMesh::DiagonalMatrix< T >::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 
)
overridevirtual

初始化矩阵的维度和结构

参数
m矩阵的总行数。
n矩阵的总列数。
m_l矩阵的本地行数(在并行环境中使用)。
n_l矩阵的本地列数(在并行环境中使用)。
nnz矩阵的非零元素的估计数量。
noz矩阵的零元素的估计数量。
blocksize矩阵的块大小。

实现了 libMesh::SparseMatrix< T >.

在文件 diagonal_matrix.C60 行定义.

67 {
68  _diagonal->init(m, m_l);
69 }
virtual numeric_index_type m() const override
返回矩阵的总行数。
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T >
void libMesh::DiagonalMatrix< T >::init ( ParallelType  type = PARALLEL)
overridevirtual

初始化并行矩阵

参数
type并行类型(默认为 PARALLEL)。

实现了 libMesh::SparseMatrix< T >.

在文件 diagonal_matrix.C73 行定义.

74 {
75  libmesh_assert(this->_dof_map);
76 
77  _diagonal->init(this->_dof_map->n_dofs(),
78  this->_dof_map->n_dofs_on_processor(this->processor_id()),
79  /*fast=*/false,
80  type);
81 }
dof_id_type n_dofs() const
Definition: dof_map.h:659
dof_id_type n_dofs_on_processor(const processor_id_type proc) const
Definition: dof_map.h:675
DofMap const * _dof_map
与此对象关联的 DofMap 对象。可以查询其在处理器上的自由度计数。
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T >
void libMesh::DiagonalMatrix< T >::init ( const NumericVector< T > &  other,
const bool  fast = false 
)
virtual

使用 NumericVector other 初始化,例如复制 other 的存储分配。 该函数不复制向量条目。如果将 fast 设置为 false,则初始化的条目将显式清零,否则它们的值是不确定的。

参数
other要初始化的 NumericVector 对象。
fast如果设置为 false,将初始化的条目显式清零;否则,它们的值是不确定的。

在文件 diagonal_matrix.C85 行定义.

86 {
87  _diagonal->init(other, fast);
88 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T >
void libMesh::DiagonalMatrix< T >::init ( const DiagonalMatrix< T > &  other,
const bool  fast = false 
)
virtual

使用 DiagonalMatrix other 初始化,例如复制 other 底层 NumericVector 的存储分配。 该函数不复制向量条目。如果将 fast 设置为 false,则初始化的条目将显式清零,否则它们的值是不确定的。

参数
other要初始化的 DiagonalMatrix 对象。
fast如果设置为 false,将初始化的条目显式清零;否则,它们的值是不确定的。

在文件 diagonal_matrix.C92 行定义.

参考 libMesh::DiagonalMatrix< T >::diagonal().

93 {
94  init(other.diagonal(), fast);
95 }
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
初始化矩阵的维度和结构
template<typename T>
virtual bool libMesh::SparseMatrix< T >::initialized ( ) const
inlinevirtualinherited
返回
如果矩阵已初始化,则为 true,否则为 false。

在文件 sparse_matrix.h102 行定义.

参考 libMesh::SparseMatrix< T >::_is_initialized.

参考自 libMesh::PetscMatrix< T >::_get_submatrix().

102 { return _is_initialized; }
bool _is_initialized
标志,指示矩阵是否已初始化。
template<typename T >
Real libMesh::DiagonalMatrix< T >::l1_norm ( ) const
overridevirtual

计算矩阵的 $l_1$ 范数。

返回
矩阵的 $l_1$ 范数。

实现了 libMesh::SparseMatrix< T >.

在文件 diagonal_matrix.C244 行定义.

245 {
246  return _diagonal->l1_norm();
247 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T >
Real libMesh::DiagonalMatrix< T >::linfty_norm ( ) const
overridevirtual

计算矩阵的 $l_\infty$ 范数。

返回
矩阵的 $l_\infty$ 范数。

实现了 libMesh::SparseMatrix< T >.

在文件 diagonal_matrix.C251 行定义.

252 {
253  return _diagonal->linfty_norm();
254 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T>
virtual numeric_index_type libMesh::SparseMatrix< T >::local_m ( ) const
inlinevirtualinherited

获取此进程拥有的行数。

libMesh::PetscMatrix< T > 重载.

在文件 sparse_matrix.h212 行定义.

参考 libMesh::SparseMatrix< T >::row_start() , 以及 libMesh::SparseMatrix< T >::row_stop().

212 { return row_stop() - row_start(); }
virtual numeric_index_type row_stop() const =0
virtual numeric_index_type row_start() const =0
template<typename T >
numeric_index_type libMesh::DiagonalMatrix< T >::m ( ) const
overridevirtual

返回矩阵的总行数。

实现了 libMesh::SparseMatrix< T >.

在文件 diagonal_matrix.C154 行定义.

155 {
156  return _diagonal->size();
157 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T>
virtual void libMesh::SparseMatrix< T >::matrix_matrix_mult ( SparseMatrix< T > &  ,
SparseMatrix< T > &  ,
bool   
)
inlinevirtualinherited

计算 Y = A*X,其中 X 为矩阵。

libMesh::PetscMatrix< T > 重载.

在文件 sparse_matrix.h290 行定义.

291  { libmesh_not_implemented(); }
template<typename T >
numeric_index_type libMesh::DiagonalMatrix< T >::n ( ) const
overridevirtual

返回矩阵的总列数。

实现了 libMesh::SparseMatrix< T >.

在文件 diagonal_matrix.C161 行定义.

162 {
163  return _diagonal->size();
164 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited

Prints the number of outstanding (created, but not yet destroyed) objects.

在文件 reference_counter.h85 行定义.

参考 libMesh::ReferenceCounter::_n_objects.

参考自 libMesh::LibMeshInit::~LibMeshInit().

86  { return _n_objects; }
static Threads::atomic< unsigned int > _n_objects
The number of objects.
template<typename T>
virtual bool libMesh::SparseMatrix< T >::need_full_sparsity_pattern ( ) const
inlinevirtualinherited
返回
如果此稀疏矩阵格式需要提供稀疏矩阵的图形,则为 true。

这对于 LaspackMatrix 是 true,但对于 PetscMatrix 是 false。 在不需要完整图形的情况下,我们可以有效地近似它以提供对稀疏矩阵所需大小的良好估计。

libMesh::EpetraMatrix< T > , 以及 libMesh::LaspackMatrix< T > 重载.

在文件 sparse_matrix.h126 行定义.

参考自 libMesh::DofMap::attach_matrix() , 以及 libMesh::DofMap::update_sparsity_pattern().

127  { return false; }
template<typename T >
T libMesh::DiagonalMatrix< T >::operator() ( const numeric_index_type  i,
const numeric_index_type  j 
) const
overridevirtual

返回矩阵中指定位置的元素值。

参数
i行索引。
j列索引。
返回
矩阵中指定位置的元素值。

实现了 libMesh::SparseMatrix< T >.

在文件 diagonal_matrix.C234 行定义.

235 {
236  if (i == j)
237  return (*_diagonal)(i);
238  else
239  return 0;
240 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T>
DiagonalMatrix& libMesh::DiagonalMatrix< T >::operator= ( DiagonalMatrix< T > &&  )
default
template<typename T >
DiagonalMatrix< T > & libMesh::DiagonalMatrix< T >::operator= ( const NumericVector< T > &  vec)

vec 的内容复制到底层对角线存储中

参数
vec要复制的 NumericVector 对象。
返回
对 *this 的引用。

在文件 diagonal_matrix.C40 行定义.

41 {
42  *_diagonal = vec;
43  return *this;
44 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T >
DiagonalMatrix< T > & libMesh::DiagonalMatrix< T >::operator= ( NumericVector< T > &&  vec)

vec 的内容移动到底层对角线存储中

参数
vec要移动的 NumericVector 对象。
返回
对 *this 的引用。

在文件 diagonal_matrix.C48 行定义.

49 {
50  // Don't get confused by the &&: vec is an lvalue reference; the && just
51  // indicates that we are receiving an object that is safe to move from. Note
52  // that we are not going to use std::move here because we do not have
53  // (virtual) move assignment operations defined for NumericVector sub-classes
54  _diagonal->swap(vec);
55  return *this;
56 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<>
void libMesh::SparseMatrix< Complex >::print ( std::ostream &  os,
const bool  sparse 
) const
inherited

在文件 sparse_matrix.C117 行定义.

参考 std::imag() , 以及 std::real().

118 {
119  // std::complex<>::operator<<() is defined, but use this form
120 
121  if (sparse)
122  {
123  libmesh_not_implemented();
124  }
125 
126  os << "Real part:" << std::endl;
127  for (auto i : make_range(this->m()))
128  {
129  for (auto j : make_range(this->n()))
130  os << std::setw(8) << (*this)(i,j).real() << " ";
131  os << std::endl;
132  }
133 
134  os << std::endl << "Imaginary part:" << std::endl;
135  for (auto i : make_range(this->m()))
136  {
137  for (auto j : make_range(this->n()))
138  os << std::setw(8) << (*this)(i,j).imag() << " ";
139  os << std::endl;
140  }
141 }
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)
virtual numeric_index_type m() const =0
boost::multiprecision::float128 imag(const boost::multiprecision::float128)
virtual numeric_index_type n() const =0
template<typename T >
void libMesh::SparseMatrix< T >::print ( std::ostream &  os = libMesh::out,
const bool  sparse = false 
) const
inherited

将矩阵的内容以统一的样式打印到屏幕上,而不考虑正在使用的矩阵/求解器包。

在文件 sparse_matrix.C225 行定义.

参考 libMesh::initialized().

参考自 libMesh::EigenSparseMatrix< T >::print_personal() , 以及 libMesh::LaspackMatrix< T >::print_personal().

226 {
227  parallel_object_only();
228 
229  libmesh_assert (this->initialized());
230 
231  libmesh_error_msg_if(!this->_dof_map, "Error! Trying to print a matrix with no dof_map set!");
232 
233  // We'll print the matrix from processor 0 to make sure
234  // it's serialized properly
235  if (this->processor_id() == 0)
236  {
237  libmesh_assert_equal_to (this->_dof_map->first_dof(), 0);
238  for (numeric_index_type i=this->_dof_map->first_dof();
239  i!=this->_dof_map->end_dof(); ++i)
240  {
241  if (sparse)
242  {
243  for (auto j : make_range(this->n()))
244  {
245  T c = (*this)(i,j);
246  if (c != static_cast<T>(0.0))
247  {
248  os << i << " " << j << " " << c << std::endl;
249  }
250  }
251  }
252  else
253  {
254  for (auto j : make_range(this->n()))
255  os << (*this)(i,j) << " ";
256  os << std::endl;
257  }
258  }
259 
260  std::vector<numeric_index_type> ibuf, jbuf;
261  std::vector<T> cbuf;
262  numeric_index_type currenti = this->_dof_map->end_dof();
263  for (auto p : IntRange<processor_id_type>(1, this->n_processors()))
264  {
265  this->comm().receive(p, ibuf);
266  this->comm().receive(p, jbuf);
267  this->comm().receive(p, cbuf);
268  libmesh_assert_equal_to (ibuf.size(), jbuf.size());
269  libmesh_assert_equal_to (ibuf.size(), cbuf.size());
270 
271  if (ibuf.empty())
272  continue;
273  libmesh_assert_greater_equal (ibuf.front(), currenti);
274  libmesh_assert_greater_equal (ibuf.back(), ibuf.front());
275 
276  std::size_t currentb = 0;
277  for (;currenti <= ibuf.back(); ++currenti)
278  {
279  if (sparse)
280  {
281  for (numeric_index_type j=0; j<this->n(); j++)
282  {
283  if (currentb < ibuf.size() &&
284  ibuf[currentb] == currenti &&
285  jbuf[currentb] == j)
286  {
287  os << currenti << " " << j << " " << cbuf[currentb] << std::endl;
288  currentb++;
289  }
290  }
291  }
292  else
293  {
294  for (auto j : make_range(this->n()))
295  {
296  if (currentb < ibuf.size() &&
297  ibuf[currentb] == currenti &&
298  jbuf[currentb] == j)
299  {
300  os << cbuf[currentb] << " ";
301  currentb++;
302  }
303  else
304  os << static_cast<T>(0.0) << " ";
305  }
306  os << std::endl;
307  }
308  }
309  }
310  if (!sparse)
311  {
312  for (; currenti != this->m(); ++currenti)
313  {
314  for (numeric_index_type j=0; j<this->n(); j++)
315  os << static_cast<T>(0.0) << " ";
316  os << std::endl;
317  }
318  }
319  }
320  else
321  {
322  std::vector<numeric_index_type> ibuf, jbuf;
323  std::vector<T> cbuf;
324 
325  // We'll assume each processor has access to entire
326  // matrix rows, so (*this)(i,j) is valid if i is a local index.
327  for (numeric_index_type i=this->_dof_map->first_dof();
328  i!=this->_dof_map->end_dof(); ++i)
329  {
330  for (auto j : make_range(this->n()))
331  {
332  T c = (*this)(i,j);
333  if (c != static_cast<T>(0.0))
334  {
335  ibuf.push_back(i);
336  jbuf.push_back(j);
337  cbuf.push_back(c);
338  }
339  }
340  }
341  this->comm().send(0,ibuf);
342  this->comm().send(0,jbuf);
343  this->comm().send(0,cbuf);
344  }
345 }
virtual bool initialized() const
dof_id_type first_dof(const processor_id_type proc) const
Definition: dof_map.h:684
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map.h:708
dof_id_type numeric_index_type
Definition: id_types.h:99
virtual numeric_index_type m() const =0
DofMap const * _dof_map
与此对象关联的 DofMap 对象。可以查询其在处理器上的自由度计数。
virtual numeric_index_type n() const =0
void libMesh::ReferenceCounter::print_info ( std::ostream &  out_stream = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

在文件 reference_counter.C81 行定义.

参考 libMesh::ReferenceCounter::_enable_print_counter , 以及 libMesh::ReferenceCounter::get_info().

参考自 libMesh::LibMeshInit::~LibMeshInit().

82 {
84  out_stream << ReferenceCounter::get_info();
85 }
static std::string get_info()
Gets a string containing the reference information.
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...
template<typename T>
virtual void libMesh::SparseMatrix< T >::print_matlab ( const std::string &  = "") const
inlinevirtualinherited

以 Matlab 的稀疏矩阵格式打印矩阵的内容。可选择将矩阵打印到名为 name 的文件中。 如果未指定 name ,则将其转储到屏幕上。

libMesh::PetscMatrix< T > 重载.

在文件 sparse_matrix.h376 行定义.

377  {
378  libmesh_not_implemented();
379  }
template<typename T >
void libMesh::DiagonalMatrix< T >::print_personal ( std::ostream &  os = libMesh::out) const
overridevirtual

在输出流中打印矩阵的个性化信息。

参数
os输出流(默认为 libMesh::out)。

实现了 libMesh::SparseMatrix< T >.

在文件 diagonal_matrix.C265 行定义.

266 {
267  _diagonal->print(os);
268 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T>
virtual void libMesh::SparseMatrix< T >::reinit_submatrix ( SparseMatrix< T > &  submatrix,
const std::vector< numeric_index_type > &  rows,
const std::vector< numeric_index_type > &  cols 
) const
inlinevirtualinherited

此函数与上述函数类似,但允许您重用 "submatrix" 的现有稀疏性模式,而不是再次分配它。 如果经常提取相同大小的子矩阵,这应该更有效。

在文件 sparse_matrix.h415 行定义.

参考 libMesh::SparseMatrix< T >::_get_submatrix().

418  {
419  this->_get_submatrix(submatrix,
420  rows,
421  cols,
422  true); // true 表示重用 submatrix
423  }
virtual void _get_submatrix(SparseMatrix< T > &, const std::vector< numeric_index_type > &, const std::vector< numeric_index_type > &, const bool) const
创建子矩阵和 reinit_submatrix 例程的受保护实现。
template<typename T >
numeric_index_type libMesh::DiagonalMatrix< T >::row_start ( ) const
overridevirtual

返回矩阵在本地计算中的起始行号。

实现了 libMesh::SparseMatrix< T >.

在文件 diagonal_matrix.C168 行定义.

169 {
170  return _diagonal->first_local_index();
171 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T >
numeric_index_type libMesh::DiagonalMatrix< T >::row_stop ( ) const
overridevirtual

返回矩阵在本地计算中的结束行号。

实现了 libMesh::SparseMatrix< T >.

在文件 diagonal_matrix.C175 行定义.

176 {
177  return _diagonal->last_local_index();
178 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T >
void libMesh::DiagonalMatrix< T >::set ( const numeric_index_type  i,
const numeric_index_type  j,
const T  value 
)
overridevirtual

设置矩阵中指定位置的元素值。

参数
i行索引。
j列索引。
value元素的值。

实现了 libMesh::SparseMatrix< T >.

libMesh::LumpedMassMatrix< T > 重载.

在文件 diagonal_matrix.C182 行定义.

183 {
184  if (i == j)
185  _diagonal->set(i, value);
186 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T>
virtual void libMesh::SparseMatrix< T >::update_sparsity_pattern ( const SparsityPattern::Graph )
inlinevirtualinherited

更新矩阵的稀疏性模式。当您的 SparseMatrix<T> 实现不需要此数据时, 只需不覆盖此方法。

libMesh::EpetraMatrix< T > , 以及 libMesh::LaspackMatrix< T > 重载.

在文件 sparse_matrix.h133 行定义.

参考自 libMesh::DofMap::update_sparsity_pattern().

133 {}
template<typename T >
void libMesh::SparseMatrix< T >::vector_mult ( NumericVector< T > &  dest,
const NumericVector< T > &  arg 
) const
inherited

将矩阵乘以 NumericVector arg 并将结果存储在 NumericVector dest 中。

参数
dest存储结果的目标 NumericVector。
arg乘法的源 NumericVector。
注解
此函数将矩阵乘以 NumericVector arg 并将结果存储在 dest 中。

在文件 sparse_matrix.C195 行定义.

参考 libMesh::NumericVector< T >::zero().

197 {
198  dest.zero();
199  this->vector_mult_add(dest,arg);
200 }
void vector_mult_add(NumericVector< T > &dest, const NumericVector< T > &arg) const
将矩阵乘以 NumericVector arg ,并将结果添加到 NumericVector dest 中。
template<typename T >
void libMesh::SparseMatrix< T >::vector_mult_add ( NumericVector< T > &  dest,
const NumericVector< T > &  arg 
) const
inherited

将矩阵乘以 NumericVector arg ,并将结果添加到 NumericVector dest 中。

在文件 sparse_matrix.C205 行定义.

参考 libMesh::NumericVector< T >::add_vector().

207 {
208  /* This functionality is actually implemented in the \p
209  NumericVector class. */
210  dest.add_vector(arg,*this);
211 }
template<typename T >
void libMesh::DiagonalMatrix< T >::zero ( )
overridevirtual

将矩阵的所有元素置零。

实现了 libMesh::SparseMatrix< T >.

在文件 diagonal_matrix.C106 行定义.

107 {
108  _diagonal->zero();
109 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储
template<typename T >
std::unique_ptr< SparseMatrix< T > > libMesh::DiagonalMatrix< T >::zero_clone ( ) const
overridevirtual

创建当前矩阵的零副本,其结构和维度相同。

实现了 libMesh::SparseMatrix< T >.

libMesh::LumpedMassMatrix< T > 重载.

在文件 diagonal_matrix.C112 行定义.

113 {
114  // Make empty copy with matching comm
115  auto mat_copy = std::make_unique<DiagonalMatrix<T>>(this->comm());
116 
117  // Initialize copy with our same nonzero structure, and explicitly
118  // zero values using fast == false.
119  mat_copy->init(*this, /*fast=*/false);
120 
121  // Work around an issue on older compilers. We are able to simply
122  // "return mat_copy;" on newer compilers
123  return std::unique_ptr<SparseMatrix<T>>(mat_copy.release());
124 }
template<typename T >
void libMesh::DiagonalMatrix< T >::zero_rows ( std::vector< numeric_index_type > &  rows,
val = 0 
)
overridevirtual

将指定行的所有元素置零。

参数
rows要置零的行索引列表。
val置零的值(默认为 0)。

重载 libMesh::SparseMatrix< T > .

在文件 diagonal_matrix.C291 行定义.

292 {
293  for (auto row : rows)
294  _diagonal->set(row, val);
295 }
std::unique_ptr< NumericVector< T > > _diagonal
底层对角矩阵存储

类成员变量说明

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited

Actually holds the data.

在文件 reference_counter.h124 行定义.

参考自 libMesh::ReferenceCounter::get_info().

template<typename T>
std::unique_ptr<NumericVector<T> > libMesh::DiagonalMatrix< T >::_diagonal
protected

底层对角矩阵存储

在文件 diagonal_matrix.h292 行定义.

参考自 libMesh::DiagonalMatrix< T >::DiagonalMatrix().

template<typename T>
DofMap const* libMesh::SparseMatrix< T >::_dof_map
protectedinherited

与此对象关联的 DofMap 对象。可以查询其在处理器上的自由度计数。

在文件 sparse_matrix.h494 行定义.

bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

在文件 reference_counter.h143 行定义.

参考自 libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info() , 以及 libMesh::ReferenceCounter::print_info().

template<typename T>
bool libMesh::SparseMatrix< T >::_is_initialized
protectedinherited
Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

在文件 reference_counter.h137 行定义.

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects
staticprotectedinherited

The number of objects.

Print the reference count information when the number returns to 0.

在文件 reference_counter.h132 行定义.

参考自 libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter() , 以及 libMesh::ReferenceCounter::~ReferenceCounter().

template<typename T>
SparsityPattern::Build const* libMesh::SparseMatrix< T >::_sp
protectedinherited

与此对象关联的 sparsity pattern。在需要时, 应查询其入口计数(或使用 need_full_sparsity_pattern,模式)。

在文件 sparse_matrix.h500 行定义.


该类的文档由以下文件生成: