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

提供了不同线性代数库的向量存储方案的统一接口。 更多...

#include <dof_map.h>

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

Public 成员函数

 NumericVector (const Parallel::Communicator &comm_in, const ParallelType ptype=AUTOMATIC)
 虚拟构造函数。维度=0。 更多...
 
 NumericVector (const Parallel::Communicator &comm_in, const numeric_index_type n, const ParallelType ptype=AUTOMATIC)
 构造函数。将维度设置为 n,并初始化所有元素为零。 更多...
 
 NumericVector (const Parallel::Communicator &comm_in, const numeric_index_type n, const numeric_index_type n_local, const ParallelType ptype=AUTOMATIC)
 构造函数。将本地维度设置为 n_local ,全局维度设置为 n ,并初始化所有元素为零。 更多...
 
 NumericVector (const Parallel::Communicator &comm_in, const numeric_index_type N, const numeric_index_type n_local, const std::vector< numeric_index_type > &ghost, const ParallelType ptype=AUTOMATIC)
 构造函数。将本地维度设置为 n_local ,全局维度设置为 n ,但还为由 ghost 参数指定的索引保留内存。 更多...
 
virtual NumericVector< T > & operator= (const NumericVector< T > &v)=0
 一个复制赋值运算符 更多...
 
 NumericVector (NumericVector &&)=default
 这 5 个特殊函数可以为这个类提供默认值,因为它本身不管理任何内存。 更多...
 
 NumericVector (const NumericVector &)=default
 
NumericVectoroperator= (NumericVector &&)=default
 
virtual ~NumericVector ()=default
 虽然这个类不管理任何内存,但派生类可能会管理内存,用户可能会通过指向这个基类的指针删除内存。 更多...
 
virtual bool initialized () const
 检查向量是否已经初始化。 更多...
 
ParallelType type () const
 获取向量的类型。 更多...
 
ParallelType & type ()
 获取向量的类型。 更多...
 
virtual bool closed () const
 检查向量是否已经关闭并准备好进行计算。 更多...
 
virtual void close ()=0
 调用 NumericVector 的内部组装函数,确保值在处理器之间一致。 更多...
 
virtual void clear ()
 将 NumericVector<T> 恢复到原始状态。 更多...
 
virtual void zero ()=0
 将所有条目设置为零。等同于 v = 0,但更明显且更快。 更多...
 
virtual std::unique_ptr
< NumericVector< T > > 
zero_clone () const =0
 返回一个智能指针,指向具有相同类型、大小和分区的此向量的副本,但所有条目都为零。 更多...
 
virtual std::unique_ptr
< NumericVector< T > > 
clone () const =0
 返回一个包装了此向量副本的智能指针。 更多...
 
virtual void init (const numeric_index_type n, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC)=0
 更改向量的维度为 n 。如果可能的话 ,该向量的保留内存保持不变。 如果 n==0 ,所有内存都将被释放。因此,如果要调整向量的大小并释放不需要的内存, 必须首先调用 init(0) ,然后调用 init(n) 。这种行为类似于 STL 容器。 更多...
 
virtual void init (const numeric_index_type n, const bool fast=false, const ParallelType ptype=AUTOMATIC)=0
 调用 init() ,其中 n_local = N。 更多...
 
virtual void init (const numeric_index_type n, const numeric_index_type n_local, const std::vector< numeric_index_type > &ghost, const bool fast=false, const ParallelType ptype=AUTOMATIC)=0
 创建一个包含本地索引以及在 ghost 参数中指定的索引的向量。 更多...
 
virtual void init (const NumericVector< T > &other, const bool fast=false)=0
 创建一个具有与 other 相同维度和存储类型的向量,包括 ghost dofs。 更多...
 
virtual NumericVector< T > & operator= (const T s)=0
 设置向量的所有条目为值 s。 更多...
 
virtual NumericVector< T > & operator= (const std::vector< T > &v)=0
 设置 (*this)(i) = v(i) 对于向量的每个条目。 更多...
 
virtual Real min () const =0
 获取向量中的最小值,或者在复数情况下获取最小的实部。 更多...
 
virtual Real max () const =0
 获取向量中的最大值,或者在复数情况下获取最大的实部。 更多...
 
virtual T sum () const =0
 获取向量中所有值的总和。 更多...
 
virtual Real l1_norm () const =0
 获取向量的 $ \ell_1 $-范数,即条目的绝对值之和。 更多...
 
virtual Real l2_norm () const =0
 获取向量的 $ \ell_2 $-范数,即条目平方和的平方根。 更多...
 
virtual Real linfty_norm () const =0
 获取向量的 $ \ell_{\infty} $-范数,即向量的最大绝对值。 更多...
 
virtual Real subset_l1_norm (const std::set< numeric_index_type > &indices) const
 获取指定条目的向量的 $ \ell_1 $-范数,即指定条目的绝对值之和。 更多...
 
virtual Real subset_l2_norm (const std::set< numeric_index_type > &indices) const
 获取指定条目的向量的 $ \ell_2 $-范数,即指定条目平方和的平方根。 更多...
 
virtual Real subset_linfty_norm (const std::set< numeric_index_type > &indices) const
 获取指定条目的向量的最大绝对值,即指定条目的 $ \ell_{\infty} $-范数。 更多...
 
Real l2_norm_diff (const NumericVector< T > &other_vec) const
 获取 $ \ell_2 $-范数的向量差值 $ \vec{u} - \vec{v} $, 其中 $ \vec{u} $this。 更多...
 
virtual numeric_index_type size () const =0
 获取向量的大小。 更多...
 
virtual numeric_index_type local_size () const =0
 获取向量的本地大小,即 index_stop - index_start。 更多...
 
virtual numeric_index_type first_local_index () const =0
 获取实际存储在该处理器上的第一个向量元素的索引。 更多...
 
virtual numeric_index_type last_local_index () const =0
 获取实际存储在该处理器上的最后一个向量元素的索引+1。 更多...
 
virtual T operator() (const numeric_index_type i) const =0
 获取向量的第 i 个条目的副本。 更多...
 
virtual T el (const numeric_index_type i) const
 获取向量的第 i 个条目。 更多...
 
virtual void get (const std::vector< numeric_index_type > &index, T *values) const
 一次访问多个组件。 values 将 *不会* 重新分配空间;它应该已经具有足够的空间。 默认实现对每个索引调用 operator() ,但某些实现可能在此处提供更快的方法。 更多...
 
void get (const std::vector< numeric_index_type > &index, std::vector< T > &values) const
 一次访问多个组件。 values 将被调整大小,如果需要,将被填充。 默认实现对每个索引调用 operator() ,但某些实现可能在此处提供更快的方法。 更多...
 
virtual NumericVector< T > & operator+= (const NumericVector< T > &v)=0
 将向量加上 v$ \vec{u} \leftarrow \vec{u} + \vec{v} $。等价于 u.add(1, v)。 更多...
 
virtual NumericVector< T > & operator-= (const NumericVector< T > &v)=0
 v 从 *this 减去, $ \vec{u} \leftarrow \vec{u} - \vec{v} $。等价于 u.add(-1, v)。 更多...
 
NumericVector< T > & operator*= (const T a)
 将向量缩放为 a$ \vec{u} \leftarrow a\vec{u} $。等价于 u.scale(a)。 更多...
 
virtual NumericVector< T > & operator*= (const NumericVector< T > &v)=0
 计算此向量条目与另一个向量的条目之间的分量乘法, $ u_i \leftarrow u_i v_i \, \forall i$更多...
 
NumericVector< T > & operator/= (const T a)
 将向量缩放为 1/a$ \vec{u} \leftarrow \frac{1}{a}\vec{u} $。等价于 u.scale(1. 更多...
 
virtual NumericVector< T > & operator/= (const NumericVector< T > &v)=0
 计算此向量条目与另一个向量的分量除法, $ u_i \leftarrow \frac{u_i}{v_i} \, \forall i$更多...
 
virtual void reciprocal ()=0
 计算每个向量条目的分量倒数, $ u_i \leftarrow \frac{1}{u_i} \, \forall i$更多...
 
virtual void conjugate ()=0
 反转向量中每个条目的虚部。 更多...
 
virtual void set (const numeric_index_type i, const T value)=0
 设置 v(i) = value 。 请注意,此方法的库实现是线程安全的, 例如,将在写入向量之前锁定 _numeric_vector_mutex更多...
 
virtual void add (const numeric_index_type i, const T value)=0
 value 添加到由 i 指定的向量条目。 请注意,此方法的库实现是线程安全的, 例如,将在写入向量之前锁定 _numeric_vector_mutex更多...
 
virtual void add (const T s)=0
 s 添加到向量的每个条目, $ u_i \leftarrow u_i + s $ 更多...
 
virtual void add (const NumericVector< T > &v)=0
 v 添加到 *this, $ \vec{u} \leftarrow \vec{u} + \vec{v} $。 等效于调用 operator+=() 更多...
 
virtual void add (const T a, const NumericVector< T > &v)=0
 带有标量倍数的向量相加, $ \vec{u} \leftarrow \vec{u} + a\vec{v} $。 等效于调用 operator+=() 更多...
 
virtual void add_vector (const T *v, const std::vector< numeric_index_type > &dof_indices)
 计算 $ \vec{u} \leftarrow \vec{u} + \vec{v} $,其中 v 是一个指针, 每个 dof_indices[i] 指定了要添加的值 v[i] 的位置。 这应该在子类中进行重写以提高效率。请注意,此方法的库实现是线程安全的。 更多...
 
void add_vector (const std::vector< T > &v, const std::vector< numeric_index_type > &dof_indices)
 计算 $ \vec{u} \leftarrow \vec{u} + \vec{v} $,其中 v 是一个 std::vector, 每个 dof_indices[i] 指定了要添加的值 v[i] 的位置 默认实现对每个索引调用 operator() ,但某些实现可能在此处提供更快的方法。 请注意,此方法的库实现是线程安全的。 更多...
 
void add_vector (const NumericVector< T > &v, const std::vector< numeric_index_type > &dof_indices)
 计算 $ \vec{u} \leftarrow \vec{u} + \vec{v} $,其中 v 是一个 NumericVector, 每个 dof_indices[i] 指定了要添加的值 v(i) 的位置。此方法是线程安全的。 更多...
 
void add_vector (const DenseVector< T > &v, const std::vector< numeric_index_type > &dof_indices)
 计算 $ \vec{u} \leftarrow \vec{u} + \vec{v} $,其中 v 是一个 DenseVector, 每个 dof_indices[i] 指定了要添加的值 v(i) 的位置。此方法是线程安全的。 更多...
 
virtual void add_vector (const NumericVector< T > &v, const SparseMatrix< T > &A)=0
 计算 $ \vec{u} \leftarrow \vec{u} + A \vec{v} $, 即将 SparseMatrix ANumericVector v 的乘积添加到 this。 更多...
 
void add_vector (const NumericVector< T > &v, const ShellMatrix< T > &A)
 计算 $ \vec{u} \leftarrow \vec{u} + A \vec{v} $, 即将 ShellMatrix ANumericVector v 的乘积添加到 this。 更多...
 
virtual void add_vector_transpose (const NumericVector< T > &v, const SparseMatrix< T > &A)=0
 计算 $ \vec{u} \leftarrow \vec{u} + A^T \vec{v} $, 即将矩阵 A 的转置与 NumericVector v 的乘积添加到 this。 更多...
 
virtual void insert (const T *v, const std::vector< numeric_index_type > &dof_indices)
 v 的条目插入到 *this 中,位置由 dof_indices 指定。请注意,此方法的库实现是线程安全的。 更多...
 
void insert (const NumericVector< T > &v, const std::vector< numeric_index_type > &dof_indices)
 v 的条目插入到 *this 中,位置由 v 指定。 只要使用 NumericVector 的库实现,此方法是线程安全的。 更多...
 
void insert (const DenseVector< T > &v, const std::vector< numeric_index_type > &dof_indices)
 v 的条目插入到 *this 中,位置由 v 指定。 只要使用 NumericVector 的库实现,此方法是线程安全的。 更多...
 
void insert (const DenseSubVector< T > &v, const std::vector< numeric_index_type > &dof_indices)
 v 的条目插入到 *this 中,位置由 v 指定。 只要使用 NumericVector 的库实现,此方法是线程安全的。 更多...
 
virtual void scale (const T factor)=0
 缩放向量的每个元素。 更多...
 
virtual void abs ()=0
 设置 $ u_i \leftarrow |u_i| $,对向量中的每个条目进行绝对值操作。 更多...
 
virtual T dot (const NumericVector< T > &v) const =0
 计算 $ \vec{u} \cdot \vec{v} $,即 (*this) 与向量 v 的点积。 更多...
 
virtual void localize (std::vector< T > &v_local) const =0
 创建全局向量的副本并存储在本地向量 v_local 中。 更多...
 
virtual void localize (NumericVector< T > &v_local) const =0
 创建全局向量的副本并存储在本地向量 v_local 中,而不是 std::vector。 更多...
 
virtual void localize (NumericVector< T > &v_local, const std::vector< numeric_index_type > &send_list) const =0
 创建本地向量 v_local ,其中仅包含与此处理器相关的信息,由 send_list 定义。 更多...
 
virtual void localize (std::vector< T > &v_local, const std::vector< numeric_index_type > &indices) const =0
 用全局索引中给定的值填充本地 std::vector "v_local"。 更多...
 
virtual void localize (const numeric_index_type first_local_idx, const numeric_index_type last_local_idx, const std::vector< numeric_index_type > &send_list)=0
 使用由 send_list 指定的值从相邻处理器中选择的值更新本地向量。 更多...
 
virtual void localize_to_one (std::vector< T > &v_local, const processor_id_type proc_id=0) const =0
 在处理器 proc_id 上创建全局向量的本地副本。 默认情况下,数据发送到处理器 0。此方法对于从一个处理器输出数据非常有用。 更多...
 
virtual int compare (const NumericVector< T > &other_vector, const Real threshold=TOLERANCE) const
 比较 thisother_vector 的等效性,(在给定的 threshold 内) 如果等效则返回 -1 ,或者返回第一个索引,其中 abs(a[i]-b[i]) 超过阈值。 更多...
 
virtual int local_relative_compare (const NumericVector< T > &other_vector, const Real threshold=TOLERANCE) const
 比较该向量与另一个向量的局部相对差异。 更多...
 
virtual void pointwise_mult (const NumericVector< T > &vec1, const NumericVector< T > &vec2)=0
 比较该向量与另一个向量的全局相对差异。 更多...
 
virtual void pointwise_divide (const NumericVector< T > &vec1, const NumericVector< T > &vec2)=0
 计算该向量与另一个向量的逐点除法。 更多...
 
virtual void print (std::ostream &os=libMesh::out) const
 打印本地向量的内容,默认输出到 libMesh::out 流。 更多...
 
virtual void print_global (std::ostream &os=libMesh::out) const
 打印全局向量的内容,默认输出到 libMesh::out 流。 更多...
 
virtual void print_matlab (const std::string &="") const
 以Matlab的稀疏矩阵格式打印向量内容。可选择将向量打印到名为 name 的文件中。 如果未指定 name,则内容将被打印到屏幕上。 更多...
 
virtual void create_subvector (NumericVector< T > &subvector, const std::vector< numeric_index_type > &rows) const
 使用 rows 中的索引从该向量中填充 subvector。类似于 SparseMatrix 类的 create_submatrix() 函数, 当前仅对 PetscVectors 实现了此功能。 更多...
 
virtual void swap (NumericVector< T > &v)
 交换该向量的内容与向量 v 的内容。子类应提供足够的间接性以使此操作成为 O(1) 的头部交换操作。 更多...
 
virtual std::size_t max_allowed_id () const =0
 返回 NumericVector 可以包含的最大条目数(在所有处理器上)。 更多...
 
bool readable () const
 检查该向量是否能够用于全局操作。 更多...
 
bool compatible (const NumericVector< T > &v) const
 检查该向量和向量 v 是否能够一起用于全局操作。 更多...
 
template<>
void print (std::ostream &os) const
 
template<>
void print_global (std::ostream &os) const
 

静态 Public 成员函数

static std::unique_ptr
< NumericVector< T > > 
build (const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
 构建一个 NumericVector 对象。 更多...
 
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 成员函数

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 属性

bool _is_closed
 用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。 更多...
 
bool _is_initialized
 在调用 init() 后设置为 true。 更多...
 
ParallelType _type
 向量的类型。 更多...
 
std::mutex _numeric_vector_mutex
 用于执行线程安全操作的互斥锁。 更多...
 

静态 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. 更多...
 

友元

std::ostream & operator<< (std::ostream &os, const NumericVector< T > &v)
 允许使用流语法打印向量的内容。 更多...
 

详细描述

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

提供了不同线性代数库的向量存储方案的统一接口。

注解
这个类是不同数值向量实现的抽象基类。 大多数情况下,您应该使用 System 对象来创建数值向量。 如果不需要这样做,可以实例化其中一个派生类(如 PetscVector、EigenSparseVector 等), 或使用 NumericVector::build 方法创建一个数值向量。在自己创建向量时, 请确保正确初始化向量(NumericVector::init)。
作者
Benjamin S. Kirk
日期
2003

在文件 dof_map.h67 行定义.

成员类型定义说明

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::NumericVector< T >::NumericVector ( const Parallel::Communicator &  comm_in,
const ParallelType  ptype = AUTOMATIC 
)
inlineexplicit

虚拟构造函数。维度=0。

参数
comm_in通信器对象,表示通信方式。
ptype平行类型,表示数值向量的类型。

在文件 numeric_vector.h938 行定义.

939  :
940  ParallelObject(comm_in),
941  _is_closed(false),
942  _is_initialized(false),
943  _type(ptype)
944 {
945 }
bool _is_initialized
在调用 init() 后设置为 true。
ParallelType _type
向量的类型。
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
template<typename T >
libMesh::NumericVector< T >::NumericVector ( const Parallel::Communicator &  comm_in,
const numeric_index_type  n,
const ParallelType  ptype = AUTOMATIC 
)
inlineexplicit

构造函数。将维度设置为 n,并初始化所有元素为零。

参数
comm_in通信器对象,表示通信方式。
n向量的全局维度。
ptype平行类型,表示数值向量的类型。

在文件 numeric_vector.h951 行定义.

953  :
954  ParallelObject(comm_in),
955  _is_closed(false),
956  _is_initialized(false),
957  _type(ptype)
958 {
959  libmesh_not_implemented(); // Abstract base class!
960  // init(n, n, false, ptype);
961 }
bool _is_initialized
在调用 init() 后设置为 true。
ParallelType _type
向量的类型。
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
template<typename T >
libMesh::NumericVector< T >::NumericVector ( const Parallel::Communicator &  comm_in,
const numeric_index_type  n,
const numeric_index_type  n_local,
const ParallelType  ptype = AUTOMATIC 
)
inline

构造函数。将本地维度设置为 n_local ,全局维度设置为 n ,并初始化所有元素为零。

参数
comm_in通信器对象,表示通信方式。
n向量的全局维度。
n_local向量的本地维度。
ptype平行类型,表示数值向量的类型。

在文件 numeric_vector.h967 行定义.

970  :
971  ParallelObject(comm_in),
972  _is_closed(false),
973  _is_initialized(false),
974  _type(ptype)
975 {
976  libmesh_not_implemented(); // Abstract base class!
977  // init(n, n_local, false, ptype);
978 }
bool _is_initialized
在调用 init() 后设置为 true。
ParallelType _type
向量的类型。
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
template<typename T >
libMesh::NumericVector< T >::NumericVector ( const Parallel::Communicator &  comm_in,
const numeric_index_type  N,
const numeric_index_type  n_local,
const std::vector< numeric_index_type > &  ghost,
const ParallelType  ptype = AUTOMATIC 
)
inline

构造函数。将本地维度设置为 n_local ,全局维度设置为 n ,但还为由 ghost 参数指定的索引保留内存。

参数
comm_in通信器对象,表示通信方式。
N向量的全局维度。
n_local向量的本地维度。
ghost指定的索引。
ptype平行类型,表示数值向量的类型。

在文件 numeric_vector.h984 行定义.

988  :
989  ParallelObject(comm_in),
990  _is_closed(false),
991  _is_initialized(false),
992  _type(ptype)
993 {
994  libmesh_not_implemented(); // 抽象基类!
995  // init(n, n_local, ghost, false, ptype);
996 }
bool _is_initialized
在调用 init() 后设置为 true。
ParallelType _type
向量的类型。
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
template<typename T>
libMesh::NumericVector< T >::NumericVector ( NumericVector< T > &&  )
default

这 5 个特殊函数可以为这个类提供默认值,因为它本身不管理任何内存。

template<typename T>
libMesh::NumericVector< T >::NumericVector ( const NumericVector< T > &  )
default
template<typename T>
virtual libMesh::NumericVector< T >::~NumericVector ( )
virtualdefault

虽然这个类不管理任何内存,但派生类可能会管理内存,用户可能会通过指向这个基类的指针删除内存。

成员函数说明

template<typename T>
virtual void libMesh::NumericVector< T >::abs ( )
pure virtual

设置 $ u_i \leftarrow |u_i| $,对向量中的每个条目进行绝对值操作。

libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual void libMesh::NumericVector< T >::add ( const numeric_index_type  i,
const T  value 
)
pure virtual

value 添加到由 i 指定的向量条目。 请注意,此方法的库实现是线程安全的, 例如,将在写入向量之前锁定 _numeric_vector_mutex

参数
i要添加到的条目的索引。
value要添加的值。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

参考自 libMesh::TensorShellMatrix< T >::vector_mult_add().

template<typename T>
virtual void libMesh::NumericVector< T >::add ( const T  s)
pure virtual

s 添加到向量的每个条目, $ u_i \leftarrow u_i + s $

参数
s要添加的值。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual void libMesh::NumericVector< T >::add ( const NumericVector< T > &  v)
pure virtual

v 添加到 *this, $ \vec{u} \leftarrow \vec{u} + \vec{v} $。 等效于调用 operator+=()

参数
v另一个数值向量。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual void libMesh::NumericVector< T >::add ( const T  a,
const NumericVector< T > &  v 
)
pure virtual

带有标量倍数的向量相加, $ \vec{u} \leftarrow \vec{u} + a\vec{v} $。 等效于调用 operator+=()

参数
a缩放因子。
v另一个数值向量。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T >
void libMesh::NumericVector< T >::add_vector ( const T *  v,
const std::vector< numeric_index_type > &  dof_indices 
)
virtual

计算 $ \vec{u} \leftarrow \vec{u} + \vec{v} $,其中 v 是一个指针, 每个 dof_indices[i] 指定了要添加的值 v[i] 的位置。 这应该在子类中进行重写以提高效率。请注意,此方法的库实现是线程安全的。

参数
v一个指向值的指针。
dof_indices每个要添加值的位置的索引集合。

libMesh::PetscVector< T > , 以及 libMesh::EpetraVector< T > 重载.

在文件 numeric_vector.C379 行定义.

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

381 {
382  libmesh_assert(v);
383 
384  for (auto i : index_range(dof_indices))
385  this->add (dof_indices[i], v[i]);
386 }
virtual void add(const numeric_index_type i, const T value)=0
将 value 添加到由 i 指定的向量条目。 请注意,此方法的库实现是线程安全的, 例如,将在写入向量之前锁定 _numeric_vector_mutex 。
template<typename T >
void libMesh::NumericVector< T >::add_vector ( const std::vector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)
inline

计算 $ \vec{u} \leftarrow \vec{u} + \vec{v} $,其中 v 是一个 std::vector, 每个 dof_indices[i] 指定了要添加的值 v[i] 的位置 默认实现对每个索引调用 operator() ,但某些实现可能在此处提供更快的方法。 请注意,此方法的库实现是线程安全的。

参数
v包含要添加的值的 std::vector。
dof_indices每个要添加值的位置的索引集合。

在文件 numeric_vector.h1041 行定义.

1043 {
1044  libmesh_assert(v.size() == dof_indices.size());
1045  if (!v.empty())
1046  this->add_vector(v.data(), dof_indices);
1047 }
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
计算 ,其中 v 是一个指针, 每个 dof_indices[i] 指定了要添加的值 v[i] 的位置。 这应该在子类中进行重写以提高效率。请注意,此方法的库实现是线程安全的。 ...
template<typename T >
void libMesh::NumericVector< T >::add_vector ( const NumericVector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)

计算 $ \vec{u} \leftarrow \vec{u} + \vec{v} $,其中 v 是一个 NumericVector, 每个 dof_indices[i] 指定了要添加的值 v(i) 的位置。此方法是线程安全的。

参数
v另一个数值向量。
dof_indices每个要添加值的位置的索引集合。

在文件 numeric_vector.C391 行定义.

参考 libMesh::NumericVector< T >::readable() , 以及 libMesh::NumericVector< T >::size().

393 {
394  libmesh_assert(v.readable());
395 
396  const std::size_t n = dof_indices.size();
397  libmesh_assert_equal_to(v.size(), n);
398  for (numeric_index_type i=0; i != n; i++)
399  this->add (dof_indices[i], v(i));
400 }
dof_id_type numeric_index_type
Definition: id_types.h:99
virtual void add(const numeric_index_type i, const T value)=0
将 value 添加到由 i 指定的向量条目。 请注意,此方法的库实现是线程安全的, 例如,将在写入向量之前锁定 _numeric_vector_mutex 。
template<typename T >
void libMesh::NumericVector< T >::add_vector ( const DenseVector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)
inline

计算 $ \vec{u} \leftarrow \vec{u} + \vec{v} $,其中 v 是一个 DenseVector, 每个 dof_indices[i] 指定了要添加的值 v(i) 的位置。此方法是线程安全的。

参数
v另一个数值向量。
dof_indices每个要添加值的位置的索引集合。

在文件 numeric_vector.h1053 行定义.

参考 libMesh::DenseVector< T >::empty() , 以及 libMesh::DenseVector< T >::size().

1055 {
1056  libmesh_assert(v.size() == dof_indices.size());
1057  if (!v.empty())
1058  this->add_vector(&v(0), dof_indices);
1059 }
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
计算 ,其中 v 是一个指针, 每个 dof_indices[i] 指定了要添加的值 v[i] 的位置。 这应该在子类中进行重写以提高效率。请注意,此方法的库实现是线程安全的。 ...
template<typename T>
virtual void libMesh::NumericVector< T >::add_vector ( const NumericVector< T > &  v,
const SparseMatrix< T > &  A 
)
pure virtual

计算 $ \vec{u} \leftarrow \vec{u} + A \vec{v} $, 即将 SparseMatrix ANumericVector v 的乘积添加到 this。

参数
v另一个数值向量。
A稀疏矩阵。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T >
void libMesh::NumericVector< T >::add_vector ( const NumericVector< T > &  v,
const ShellMatrix< T > &  A 
)

计算 $ \vec{u} \leftarrow \vec{u} + A \vec{v} $, 即将 ShellMatrix ANumericVector v 的乘积添加到 this。

参数
v另一个数值向量。
AShell 矩阵。

在文件 numeric_vector.C405 行定义.

参考 libMesh::ShellMatrix< T >::vector_mult_add().

407 {
408  libmesh_assert(this->compatible(v));
409 
410  a.vector_mult_add(*this,v);
411 }
bool compatible(const NumericVector< T > &v) const
检查该向量和向量 v 是否能够一起用于全局操作。
template<typename T>
virtual void libMesh::NumericVector< T >::add_vector_transpose ( const NumericVector< T > &  v,
const SparseMatrix< T > &  A 
)
pure virtual

计算 $ \vec{u} \leftarrow \vec{u} + A^T \vec{v} $, 即将矩阵 A 的转置与 NumericVector v 的乘积添加到 this。

参数
v另一个数值向量。
A稀疏矩阵。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T >
std::unique_ptr< NumericVector< T > > libMesh::NumericVector< T >::build ( const Parallel::Communicator &  comm,
const SolverPackage  solver_package = libMesh::default_solver_package() 
)
static

构建一个 NumericVector 对象。

参数
comm通信器对象,表示通信方式。
solver_package线性求解器包的类型。
返回
指向构建的 NumericVector 对象的 unique_ptr。

在文件 numeric_vector.C50 行定义.

参考 libMesh::EIGEN_SOLVERS, libMesh::LASPACK_SOLVERS , 以及 libMesh::TRILINOS_SOLVERS.

参考自 libMesh::DiagonalMatrix< T >::DiagonalMatrix(), libMesh::DofMap::enforce_adjoint_constraints_exactly(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::DofMap::enforce_constraints_on_residual() , 以及 libMesh::DofMap::process_mesh_constraint_rows().

51 {
52  // Build the appropriate vector
53  switch (solver_package)
54  {
55 
56 #ifdef LIBMESH_HAVE_LASPACK
57  case LASPACK_SOLVERS:
58  return std::make_unique<LaspackVector<T>>(comm, AUTOMATIC);
59 #endif
60 
61 #ifdef LIBMESH_HAVE_PETSC
62  case PETSC_SOLVERS:
63  return std::make_unique<PetscVector<T>>(comm, AUTOMATIC);
64 #endif
65 
66 #ifdef LIBMESH_TRILINOS_HAVE_EPETRA
67  case TRILINOS_SOLVERS:
68  return std::make_unique<EpetraVector<T>>(comm, AUTOMATIC);
69 #endif
70 
71 #ifdef LIBMESH_HAVE_EIGEN
72  case EIGEN_SOLVERS:
73  return std::make_unique<EigenSparseVector<T>>(comm, AUTOMATIC);
74 #endif
75 
76  default:
77  return std::make_unique<DistributedVector<T>>(comm, AUTOMATIC);
78  }
79 }
EIGEN_SOLVERS
Definition: libmesh.C:249
TRILINOS_SOLVERS
Definition: libmesh.C:247
LASPACK_SOLVERS
Definition: libmesh.C:251
template<typename T >
void libMesh::NumericVector< T >::clear ( )
inlinevirtual

将 NumericVector<T> 恢复到原始状态。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 重载.

在文件 numeric_vector.h1002 行定义.

参考 libMesh::libMeshPrivateData::_is_initialized.

1003 {
1004  _is_closed = false;
1005  _is_initialized = false;
1006 }
bool _is_initialized
在调用 init() 后设置为 true。
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
template<typename T>
virtual std::unique_ptr<NumericVector<T> > libMesh::NumericVector< T >::clone ( ) const
pure virtual

返回一个包装了此向量副本的智能指针。

注解
派生类必须重写此方法。
返回
指向新向量副本的 unique_ptr。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual void libMesh::NumericVector< T >::close ( )
pure virtual
template<typename T>
virtual bool libMesh::NumericVector< T >::closed ( ) const
inlinevirtual

检查向量是否已经关闭并准备好进行计算。

返回
如果向量已经关闭并准备好进行计算,则返回 true;否则返回 false。

在文件 numeric_vector.h180 行定义.

参考 libMesh::NumericVector< T >::_is_closed.

参考自 libMesh::DofMap::enforce_adjoint_constraints_exactly(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::PetscVector< T >::localize(), libMesh::DofMap::max_constraint_error(), libMesh::EigenSparseVector< T >::operator=(), libMesh::LaspackVector< T >::operator=() , 以及 libMesh::PetscVector< T >::operator=().

180 { return _is_closed; }
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
template<typename T >
int libMesh::NumericVector< T >::compare ( const NumericVector< T > &  other_vector,
const Real  threshold = TOLERANCE 
) const
virtual

比较 thisother_vector 的等效性,(在给定的 threshold 内) 如果等效则返回 -1 ,或者返回第一个索引,其中 abs(a[i]-b[i]) 超过阈值。

注解
"等效" 表示两个向量非常相似或几乎相同,其差异小于或等于给定的阈值。 这个阈值通常用于考虑浮点数精度问题,因为在计算机中,浮点数运算可能会导致微小的数值差异。 当两个向量被认为等效时,它们的差异小于或等于阈值。 具体来说,这是通过计算两个向量的每个元素之间的差异并将其与阈值进行比较来确定的。 如果两个向量的差异小于阈值,就可以说它们是等效的。 否则,如果差异大于阈值,就可以说它们不等效。
参数
other_vector另一个数值向量。
threshold阈值。
返回
如果向量等效则返回 -1 ,否则返回第一个不等效的索引。

在文件 numeric_vector.C109 行定义.

参考 std::abs().

111 {
112  libmesh_assert(this->compatible(other_vector));
113 
114  int first_different_i = std::numeric_limits<int>::max();
116 
117  while (first_different_i==std::numeric_limits<int>::max()
118  && i<last_local_index())
119  {
120  if (std::abs((*this)(i) - other_vector(i)) > threshold)
121  first_different_i = i;
122  else
123  i++;
124  }
125 
126  // Find the correct first differing index in parallel
127  this->comm().min(first_different_i);
128 
129  if (first_different_i == std::numeric_limits<int>::max())
130  return -1;
131 
132  return first_different_i;
133 }
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的绝对值。
Definition: type_vector.h:112
dof_id_type numeric_index_type
Definition: id_types.h:99
virtual numeric_index_type first_local_index() const =0
获取实际存储在该处理器上的第一个向量元素的索引。
virtual numeric_index_type last_local_index() const =0
获取实际存储在该处理器上的最后一个向量元素的索引+1。
bool compatible(const NumericVector< T > &v) const
检查该向量和向量 v 是否能够一起用于全局操作。
template<typename T >
bool libMesh::NumericVector< T >::compatible ( const NumericVector< T > &  v) const

检查该向量和向量 v 是否能够一起用于全局操作。

参数
v要比较的另一个向量。
返回
如果这两个向量可以一起用于全局操作,则返回 true,否则返回 false。

在文件 numeric_vector.C423 行定义.

参考 libMesh::NumericVector< T >::first_local_index(), libMesh::NumericVector< T >::last_local_index(), libMesh::NumericVector< T >::local_size(), libMesh::NumericVector< T >::readable() , 以及 libMesh::NumericVector< T >::size().

424 {
425  return this->readable() && v.readable() &&
426  this->size() == v.size() &&
427  this->local_size() == v.local_size() &&
428  this->first_local_index() == v.first_local_index() &&
429  this->last_local_index() == v.last_local_index();
430 }
virtual numeric_index_type size() const =0
获取向量的大小。
bool readable() const
检查该向量是否能够用于全局操作。
virtual numeric_index_type first_local_index() const =0
获取实际存储在该处理器上的第一个向量元素的索引。
virtual numeric_index_type local_size() const =0
获取向量的本地大小,即 index_stop - index_start。
virtual numeric_index_type last_local_index() const =0
获取实际存储在该处理器上的最后一个向量元素的索引+1。
template<typename T>
virtual void libMesh::NumericVector< T >::conjugate ( )
pure virtual
template<typename T>
virtual void libMesh::NumericVector< T >::create_subvector ( NumericVector< T > &  subvector,
const std::vector< numeric_index_type > &  rows 
) const
inlinevirtual

使用 rows 中的索引从该向量中填充 subvector。类似于 SparseMatrix 类的 create_submatrix() 函数, 当前仅对 PetscVectors 实现了此功能。

参数
subvector要填充的子向量。
rows包含用于选择要填充到子向量的索引的向量。

libMesh::PetscVector< T > , 以及 libMesh::EpetraVector< T > 重载.

在文件 numeric_vector.h871 行定义.

873  {
874  libmesh_not_implemented();
875  }
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...
template<typename T>
virtual T libMesh::NumericVector< T >::dot ( const NumericVector< T > &  v) const
pure virtual

计算 $ \vec{u} \cdot \vec{v} $,即 (*this) 与向量 v 的点积。

在复数值情况下,使用 v 的复共轭。

参数
v另一个数值向量。
返回
点积的结果。

libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual T libMesh::NumericVector< T >::el ( const numeric_index_type  i) const
inlinevirtual

获取向量的第 i 个条目。

参数
i要获取的条目的索引。
返回
第 i 个条目的值。

在文件 numeric_vector.h416 行定义.

416 { return (*this)(i); }
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 numeric_index_type libMesh::NumericVector< T >::first_local_index ( ) const
pure virtual

获取实际存储在该处理器上的第一个向量元素的索引。

注解
此索引的最小值为 0。
返回
第一个本地索引。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

参考自 libMesh::NumericVector< T >::compatible(), libMesh::DofMap::extract_local_vector() , 以及 libMesh::DofMap::max_constraint_error().

template<typename T >
void libMesh::NumericVector< T >::get ( const std::vector< numeric_index_type > &  index,
T *  values 
) const
inlinevirtual

一次访问多个组件。 values 将 *不会* 重新分配空间;它应该已经具有足够的空间。 默认实现对每个索引调用 operator() ,但某些实现可能在此处提供更快的方法。

参数
index要获取的索引集合。
values存储获取值的数组。

libMesh::PetscVector< T > 重载.

在文件 numeric_vector.h1012 行定义.

参考自 libMesh::DofMap::enforce_adjoint_constraints_exactly(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::DofMap::enforce_constraints_on_residual() , 以及 libMesh::DofMap::max_constraint_error().

1014 {
1015  const std::size_t num = index.size();
1016  for (std::size_t i=0; i<num; i++)
1017  {
1018  values[i] = (*this)(index[i]);
1019  }
1020 }
template<typename T >
void libMesh::NumericVector< T >::get ( const std::vector< numeric_index_type > &  index,
std::vector< T > &  values 
) const
inline

一次访问多个组件。 values 将被调整大小,如果需要,将被填充。 默认实现对每个索引调用 operator() ,但某些实现可能在此处提供更快的方法。

参数
index要获取的索引集合。
values存储获取值的向量。

在文件 numeric_vector.h1026 行定义.

1028 {
1029  const std::size_t num = index.size();
1030  values.resize(num);
1031  if (!num)
1032  return;
1033 
1034  this->get(index, values.data());
1035 }
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.
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>
virtual void libMesh::NumericVector< T >::init ( const numeric_index_type  n,
const numeric_index_type  n_local,
const bool  fast = false,
const ParallelType  ptype = AUTOMATIC 
)
pure virtual

更改向量的维度为 n 。如果可能的话 ,该向量的保留内存保持不变。 如果 n==0 ,所有内存都将被释放。因此,如果要调整向量的大小并释放不需要的内存, 必须首先调用 init(0) ,然后调用 init(n) 。这种行为类似于 STL 容器。

参数
n新的全局维度。
n_local新的本地维度。
fast如果为 false,则向量将被填充为零。
ptype平行类型,表示数值向量的类型。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

参考自 libMesh::DistributedVector< T >::clone(), libMesh::EigenSparseVector< T >::clone(), libMesh::EpetraVector< T >::clone(), libMesh::LaspackVector< T >::clone(), libMesh::PetscVector< T >::clone(), libMesh::DistributedVector< T >::zero_clone(), libMesh::EigenSparseVector< T >::zero_clone(), libMesh::EpetraVector< T >::zero_clone(), libMesh::LaspackVector< T >::zero_clone() , 以及 libMesh::PetscVector< T >::zero_clone().

template<typename T>
virtual void libMesh::NumericVector< T >::init ( const numeric_index_type  n,
const bool  fast = false,
const ParallelType  ptype = AUTOMATIC 
)
pure virtual

调用 init() ,其中 n_local = N。

参数
n新的全局维度。
fast如果为 false,则向量将被填充为零。
ptype平行类型,表示数值向量的类型。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual void libMesh::NumericVector< T >::init ( const numeric_index_type  n,
const numeric_index_type  n_local,
const std::vector< numeric_index_type > &  ghost,
const bool  fast = false,
const ParallelType  ptype = AUTOMATIC 
)
pure virtual

创建一个包含本地索引以及在 ghost 参数中指定的索引的向量。

参数
n新的全局维度。
n_local新的本地维度。
ghost指定的索引。
fast如果为 false,则向量将被填充为零。
ptype平行类型,表示数值向量的类型。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual void libMesh::NumericVector< T >::init ( const NumericVector< T > &  other,
const bool  fast = false 
)
pure virtual

创建一个具有与 other 相同维度和存储类型的向量,包括 ghost dofs。

参数
other另一个数值向量。
fast如果为 false,则向量将被填充为零。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual bool libMesh::NumericVector< T >::initialized ( ) const
inlinevirtual

检查向量是否已经初始化。

返回
如果向量已经初始化,则返回 true;否则返回 false。

在文件 numeric_vector.h159 行定义.

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

参考自 libMesh::PetscVector< T >::create_subvector() , 以及 libMesh::PetscVector< T >::init().

159 { return _is_initialized; }
bool _is_initialized
在调用 init() 后设置为 true。
template<typename T >
void libMesh::NumericVector< T >::insert ( const T *  v,
const std::vector< numeric_index_type > &  dof_indices 
)
virtual

v 的条目插入到 *this 中,位置由 dof_indices 指定。请注意,此方法的库实现是线程安全的。

参数
v一个指向值的指针。
dof_indices每个要插入值的位置的索引集合。

libMesh::PetscVector< T > , 以及 libMesh::EpetraVector< T > 重载.

在文件 numeric_vector.C84 行定义.

86 {
87  libmesh_assert (v);
88 
89  for (auto i : index_range(dof_indices))
90  this->set (dof_indices[i], v[i]);
91 }
virtual void set(const numeric_index_type i, const T value)=0
设置 v(i) = value 。 请注意,此方法的库实现是线程安全的, 例如,将在写入向量之前锁定 _numeric_vector_mutex 。
template<typename T >
void libMesh::NumericVector< T >::insert ( const NumericVector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)

v 的条目插入到 *this 中,位置由 v 指定。 只要使用 NumericVector 的库实现,此方法是线程安全的。

参数
v一个数值向量。
dof_indices每个要插入值的位置的索引集合。

在文件 numeric_vector.C96 行定义.

参考 libMesh::NumericVector< T >::readable() , 以及 libMesh::NumericVector< T >::size().

98 {
99  libmesh_assert_equal_to (V.size(), dof_indices.size());
100  libmesh_assert (V.readable());
101 
102  for (auto i : index_range(dof_indices))
103  this->set (dof_indices[i], V(i));
104 }
virtual void set(const numeric_index_type i, const T value)=0
设置 v(i) = value 。 请注意,此方法的库实现是线程安全的, 例如,将在写入向量之前锁定 _numeric_vector_mutex 。
template<typename T >
void libMesh::NumericVector< T >::insert ( const DenseVector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)
inline

v 的条目插入到 *this 中,位置由 v 指定。 只要使用 NumericVector 的库实现,此方法是线程安全的。

参数
v一个 DenseVector。
dof_indices每个要插入值的位置的索引集合。

在文件 numeric_vector.h1077 行定义.

参考 libMesh::DenseVector< T >::empty() , 以及 libMesh::DenseVector< T >::size().

1079 {
1080  libmesh_assert(v.size() == dof_indices.size());
1081  if (!v.empty())
1082  this->insert(&v(0), dof_indices);
1083 }
virtual void insert(const T *v, const std::vector< numeric_index_type > &dof_indices)
将 v 的条目插入到 *this 中,位置由 dof_indices 指定。请注意,此方法的库实现是线程安全的。
template<typename T >
void libMesh::NumericVector< T >::insert ( const DenseSubVector< T > &  v,
const std::vector< numeric_index_type > &  dof_indices 
)
inline

v 的条目插入到 *this 中,位置由 v 指定。 只要使用 NumericVector 的库实现,此方法是线程安全的。

参数
v一个 DenseSubVector。
dof_indices每个要插入值的位置的索引集合。

在文件 numeric_vector.h1089 行定义.

参考 libMesh::DenseSubVector< T >::empty() , 以及 libMesh::DenseSubVector< T >::size().

1091 {
1092  libmesh_assert(v.size() == dof_indices.size());
1093  if (!v.empty())
1094  this->insert(&v(0), dof_indices);
1095 }
virtual void insert(const T *v, const std::vector< numeric_index_type > &dof_indices)
将 v 的条目插入到 *this 中,位置由 dof_indices 指定。请注意,此方法的库实现是线程安全的。
template<typename T>
virtual Real libMesh::NumericVector< T >::l1_norm ( ) const
pure virtual

获取向量的 $ \ell_1 $-范数,即条目的绝对值之和。

返回
向量的 $ \ell_1 $-范数。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual Real libMesh::NumericVector< T >::l2_norm ( ) const
pure virtual

获取向量的 $ \ell_2 $-范数,即条目平方和的平方根。

返回
向量的 $ \ell_2 $-范数。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<class T >
Real libMesh::NumericVector< T >::l2_norm_diff ( const NumericVector< T > &  other_vec) const

获取 $ \ell_2 $-范数的向量差值 $ \vec{u} - \vec{v} $, 其中 $ \vec{u} $this。

参数
other_vec另一个数值向量。
返回
$ \ell_2 $-范数的向量差值。

在文件 numeric_vector.C363 行定义.

参考 std::norm(), libMesh::TensorTools::norm_sq(), libMesh::Real , 以及 std::sqrt().

364 {
365  libmesh_assert(this->compatible(v));
366 
367  Real norm = 0;
368  for (const auto i : make_range(this->first_local_index(), this->last_local_index()))
369  norm += TensorTools::norm_sq((*this)(i) - v(i));
370 
371  this->comm().sum(norm);
372 
373  return std::sqrt(norm);
374 }
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的平方根。
Definition: type_vector.h:88
T norm_sq(std::complex< T > a)
Definition: tensor_tools.h:74
virtual numeric_index_type first_local_index() const =0
获取实际存储在该处理器上的第一个向量元素的索引。
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
ADRealEigenVector< T, D, asd > norm(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的范数。
Definition: type_vector.h:64
virtual numeric_index_type last_local_index() const =0
获取实际存储在该处理器上的最后一个向量元素的索引+1。
bool compatible(const NumericVector< T > &v) const
检查该向量和向量 v 是否能够一起用于全局操作。
template<typename T>
virtual numeric_index_type libMesh::NumericVector< T >::last_local_index ( ) const
pure virtual

获取实际存储在该处理器上的最后一个向量元素的索引+1。

注解
此索引的最大值为 size()
返回
最后一个本地索引+1。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

参考自 libMesh::NumericVector< T >::compatible(), libMesh::DofMap::extract_local_vector() , 以及 libMesh::DofMap::max_constraint_error().

template<typename T>
virtual Real libMesh::NumericVector< T >::linfty_norm ( ) const
pure virtual

获取向量的 $ \ell_{\infty} $-范数,即向量的最大绝对值。

返回
向量的 $ \ell_{\infty} $-范数。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T >
int libMesh::NumericVector< T >::local_relative_compare ( const NumericVector< T > &  other_vector,
const Real  threshold = TOLERANCE 
) const
virtual

比较该向量与另一个向量的局部相对差异。

如果两个向量在给定的局部相对阈值 abs(a[i]-b[i])/max(a[i],b[i]) 下等效,则返回-1,否则返回首个不等效的索引。

参数
other_vector要比较的另一个向量。
threshold允许的局部相对差异阈值(可选,默认值为 TOLERANCE)。
返回
-1 表示等效,否则返回不等效的索引。

在文件 numeric_vector.C137 行定义.

参考 std::abs().

139 {
140  libmesh_assert(this->compatible(other_vector));
141 
142  int first_different_i = std::numeric_limits<int>::max();
144 
145  do
146  {
147  if (std::abs((*this)(i) - other_vector(i)) > threshold *
148  std::max(std::abs((*this)(i)), std::abs(other_vector(i))))
149  first_different_i = i;
150  else
151  i++;
152  }
153  while (first_different_i==std::numeric_limits<int>::max()
154  && i<last_local_index());
155 
156  // Find the correct first differing index in parallel
157  this->comm().min(first_different_i);
158 
159  if (first_different_i == std::numeric_limits<int>::max())
160  return -1;
161 
162  return first_different_i;
163 }
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的绝对值。
Definition: type_vector.h:112
dof_id_type numeric_index_type
Definition: id_types.h:99
virtual numeric_index_type first_local_index() const =0
获取实际存储在该处理器上的第一个向量元素的索引。
virtual numeric_index_type last_local_index() const =0
获取实际存储在该处理器上的最后一个向量元素的索引+1。
bool compatible(const NumericVector< T > &v) const
检查该向量和向量 v 是否能够一起用于全局操作。
template<typename T>
virtual numeric_index_type libMesh::NumericVector< T >::local_size ( ) const
pure virtual
template<typename T>
virtual void libMesh::NumericVector< T >::localize ( std::vector< T > &  v_local) const
pure virtual
template<typename T>
virtual void libMesh::NumericVector< T >::localize ( NumericVector< T > &  v_local) const
pure virtual

创建全局向量的副本并存储在本地向量 v_local 中,而不是 std::vector。

参数
v_local用于存储本地向量的 NumericVector<T>。

libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual void libMesh::NumericVector< T >::localize ( NumericVector< T > &  v_local,
const std::vector< numeric_index_type > &  send_list 
) const
pure virtual

创建本地向量 v_local ,其中仅包含与此处理器相关的信息,由 send_list 定义。

参数
v_local用于存储本地向量的 NumericVector<T>。
send_list指定要包含在本地向量中的值的索引列表。

libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual void libMesh::NumericVector< T >::localize ( std::vector< T > &  v_local,
const std::vector< numeric_index_type > &  indices 
) const
pure virtual

用全局索引中给定的值填充本地 std::vector "v_local"。

参数
v_local用于存储本地向量的 std::vector。
indices要填充到 v_local 中的全局索引列表。

Fill in the local std::vector "v_local" with the global indices given in "indices".

注解
每个处理器上的索引可能不同, 并且相同的索引可以本地化到多个处理器。 生成的v_local可以比原来的v_local短,并且条目将按照索引指定的顺序排列。

Example:

*   On 4 procs *this = {a, b, c, d, e, f, g, h, i} is a parallel vector.
*   On each proc, the indices arrays are set up as:
*   proc0, indices = {1,2,4,5}
*   proc1, indices = {2,5,6,8}
*   proc2, indices = {2,3,6,7}
*   proc3, indices = {0,1,2,3}
*
*   After calling this version of localize, the v_local vectors are:
*   proc0, v_local = {b,c,e,f}
*   proc1, v_local = {c,f,g,i}
*   proc2, v_local = {c,d,g,h}
*   proc3, v_local = {a,b,c,d}
* 

这个函数在并行I/0例程中很有用,当你有一个解值的并行向量,你想写一个子集。

libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual void libMesh::NumericVector< T >::localize ( const numeric_index_type  first_local_idx,
const numeric_index_type  last_local_idx,
const std::vector< numeric_index_type > &  send_list 
)
pure virtual

使用由 send_list 指定的值从相邻处理器中选择的值更新本地向量。

参数
first_local_idx本地向量的第一个索引。
last_local_idx本地向量的最后一个索引。
send_list用于更新本地向量的值的索引列表。

libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual void libMesh::NumericVector< T >::localize_to_one ( std::vector< T > &  v_local,
const processor_id_type  proc_id = 0 
) const
pure virtual

在处理器 proc_id 上创建全局向量的本地副本。 默认情况下,数据发送到处理器 0。此方法对于从一个处理器输出数据非常有用。

参数
v_local用于存储本地向量的 std::vector。
proc_id目标处理器的 ID。

libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual Real libMesh::NumericVector< T >::max ( ) const
pure virtual

获取向量中的最大值,或者在复数情况下获取最大的实部。

返回
向量的最大值。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual std::size_t libMesh::NumericVector< T >::max_allowed_id ( ) const
pure virtual

返回 NumericVector 可以包含的最大条目数(在所有处理器上)。

尽管我们定义了 numeric_index_type,通常要求 NumericVector 底层实现的索引具有大小等于 sizeof(numeric_index_type) 的大小, 但这两种类型仍可能具有不同的符号,这会影响可以存储在 NumericVector 中的最大值数量。

libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual Real libMesh::NumericVector< T >::min ( ) const
pure virtual

获取向量中的最小值,或者在复数情况下获取最小的实部。

返回
向量的最小值。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

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 T libMesh::NumericVector< T >::operator() ( const numeric_index_type  i) const
pure virtual

获取向量的第 i 个条目的副本。

参数
i要获取的条目的索引。
返回
第 i 个条目的副本。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
NumericVector<T>& libMesh::NumericVector< T >::operator*= ( const T  a)
inline

将向量缩放为 a$ \vec{u} \leftarrow a\vec{u} $。等价于 u.scale(a)。

参数
a缩放因子。
返回
对 *this 的引用。

在文件 numeric_vector.h463 行定义.

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

463 { this->scale(a); return *this; }
virtual void scale(const T factor)=0
缩放向量的每个元素。
template<typename T>
virtual NumericVector<T>& libMesh::NumericVector< T >::operator*= ( const NumericVector< T > &  v)
pure virtual

计算此向量条目与另一个向量的条目之间的分量乘法, $ u_i \leftarrow u_i v_i \, \forall i$

参数
v另一个数值向量。
返回
对 *this 的引用。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual NumericVector<T>& libMesh::NumericVector< T >::operator+= ( const NumericVector< T > &  v)
pure virtual

将向量加上 v$ \vec{u} \leftarrow \vec{u} + \vec{v} $。等价于 u.add(1, v)。

参数
v另一个数值向量。
返回
对 *this 的引用。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual NumericVector<T>& libMesh::NumericVector< T >::operator-= ( const NumericVector< T > &  v)
pure virtual

v 从 *this 减去, $ \vec{u} \leftarrow \vec{u} - \vec{v} $。等价于 u.add(-1, v)。

参数
v另一个数值向量。
返回
对 *this 的引用。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
NumericVector<T>& libMesh::NumericVector< T >::operator/= ( const T  a)
inline

将向量缩放为 1/a$ \vec{u} \leftarrow \frac{1}{a}\vec{u} $。等价于 u.scale(1.

/a)。

参数
a缩放因子。
返回
对 *this 的引用。

在文件 numeric_vector.h481 行定义.

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

481 { this->scale(1./a); return *this; }
virtual void scale(const T factor)=0
缩放向量的每个元素。
template<typename T>
virtual NumericVector<T>& libMesh::NumericVector< T >::operator/= ( const NumericVector< T > &  v)
pure virtual

计算此向量条目与另一个向量的分量除法, $ u_i \leftarrow \frac{u_i}{v_i} \, \forall i$

参数
v另一个数值向量。
返回
对 *this 的引用。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual NumericVector<T>& libMesh::NumericVector< T >::operator= ( const NumericVector< T > &  v)
pure virtual

一个复制赋值运算符

参数
v要复制的 NumericVector 对象。
返回
作为基础类型的 *this 的引用。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
NumericVector& libMesh::NumericVector< T >::operator= ( NumericVector< T > &&  )
default
template<typename T>
virtual NumericVector<T>& libMesh::NumericVector< T >::operator= ( const T  s)
pure virtual

设置向量的所有条目为值 s。

参数
s设置的值。
返回
对 *this 的引用。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual NumericVector<T>& libMesh::NumericVector< T >::operator= ( const std::vector< T > &  v)
pure virtual

设置 (*this)(i) = v(i) 对于向量的每个条目。

参数
v另一个向量。
返回
对 *this 的引用。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual void libMesh::NumericVector< T >::pointwise_divide ( const NumericVector< T > &  vec1,
const NumericVector< T > &  vec2 
)
pure virtual

计算该向量与另一个向量的逐点除法。

执行逐点(分量间)除法操作 $ u_i \leftarrow \frac{v_{1,i}}{v_{2,i}} $, 并将结果存储在该向量中。

参数
vec1被除数的输入向量。
vec2除数的输入向量。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T>
virtual void libMesh::NumericVector< T >::pointwise_mult ( const NumericVector< T > &  vec1,
const NumericVector< T > &  vec2 
)
pure virtual

比较该向量与另一个向量的全局相对差异。

如果两个向量在给定的全局相对阈值 threshold 下等效,则返回-1,否则返回首个不等效的索引, 其中相对差异定义为 $ \frac{|a[i]-b[i]|}{\max_j(a[j],b[j])} $

参数
other_vector要比较的另一个向量。
threshold允许的全局相对差异阈值(可选,默认值为 TOLERANCE)。
返回
-1 表示等效,否则返回不等效的索引。 计算该向量与另一个向量的逐点乘积。

执行逐点(分量间)乘积操作 $ u_i \leftarrow u_i v_i $,并将结果存储在该向量中。

参数
vec1第一个输入向量。
vec2第二个输入向量。

libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

参考自 libMesh::TensorShellMatrix< T >::get_diagonal().

template<typename T >
void libMesh::NumericVector< T >::print ( std::ostream &  os = libMesh::out) const
inlinevirtual

打印本地向量的内容,默认输出到 libMesh::out 流。

参数
os输出流,用于指定输出位置(可选,默认为 libMesh::out)。

在文件 numeric_vector.h1121 行定义.

参考 libMesh::initialized().

1122 {
1123  libmesh_assert (this->initialized());
1124  os << "Size\tglobal = " << this->size()
1125  << "\t\tlocal = " << this->local_size() << std::endl;
1126 
1127  os << "#\tValue" << std::endl;
1128  for (auto i : index_range(*this))
1129  os << i << "\t" << (*this)(i) << std::endl;
1130 }
virtual numeric_index_type size() const =0
获取向量的大小。
virtual bool initialized() const
检查向量是否已经初始化。
virtual numeric_index_type local_size() const =0
获取向量的本地大小,即 index_stop - index_start。
template<>
void libMesh::NumericVector< Complex >::print ( std::ostream &  os) const
inline

在文件 numeric_vector.h1103 行定义.

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

1104 {
1105  libmesh_assert (this->initialized());
1106  os << "Size\tglobal = " << this->size()
1107  << "\t\tlocal = " << this->local_size() << std::endl;
1108 
1109  // std::complex<>::operator<<() is defined, but use this form
1110  os << "#\tReal part\t\tImaginary part" << std::endl;
1111  for (auto i : index_range(*this))
1112  os << i << "\t"
1113  << (*this)(i).real() << "\t\t"
1114  << (*this)(i).imag() << std::endl;
1115 }
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)
virtual numeric_index_type size() const =0
获取向量的大小。
virtual bool initialized() const
检查向量是否已经初始化。
virtual numeric_index_type local_size() const =0
获取向量的本地大小,即 index_stop - index_start。
boost::multiprecision::float128 imag(const boost::multiprecision::float128)
template<typename T >
void libMesh::NumericVector< T >::print_global ( std::ostream &  os = libMesh::out) const
inlinevirtual

打印全局向量的内容,默认输出到 libMesh::out 流。

参数
os输出流,用于指定输出位置(可选,默认为 libMesh::out)。

在文件 numeric_vector.h1158 行定义.

参考 libMesh::initialized().

1159 {
1160  libmesh_assert (this->initialized());
1161 
1162  std::vector<T> v(this->size());
1163  this->localize(v);
1164 
1165  // 现在我们只需要输出的一个副本
1166  if (this->processor_id())
1167  return;
1168 
1169  os << "Size\tglobal = " << this->size() << std::endl;
1170  os << "#\tValue" << std::endl;
1171  for (auto i : make_range(v.size()))
1172  os << i << "\t" << v[i] << std::endl;
1173 }
virtual numeric_index_type size() const =0
获取向量的大小。
virtual bool initialized() const
检查向量是否已经初始化。
virtual void localize(std::vector< T > &v_local) const =0
创建全局向量的副本并存储在本地向量 v_local 中。
template<>
void libMesh::NumericVector< Complex >::print_global ( std::ostream &  os) const
inline

在文件 numeric_vector.h1136 行定义.

参考 libMesh::initialized().

1137 {
1138  libmesh_assert (this->initialized());
1139 
1140  std::vector<Complex> v(this->size());
1141  this->localize(v);
1142 
1143  // 现在我们只需要输出的一个副本
1144  if (this->processor_id())
1145  return;
1146 
1147  os << "Size\tglobal = " << this->size() << std::endl;
1148  os << "#\tReal part\t\tImaginary part" << std::endl;
1149  for (auto i : make_range(v.size()))
1150  os << i << "\t"
1151  << v[i].real() << "\t\t"
1152  << v[i].imag() << std::endl;
1153 }
virtual numeric_index_type size() const =0
获取向量的大小。
virtual bool initialized() const
检查向量是否已经初始化。
virtual void localize(std::vector< T > &v_local) const =0
创建全局向量的副本并存储在本地向量 v_local 中。
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::NumericVector< T >::print_matlab ( const std::string &  = "") const
inlinevirtual

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

参数
name用于指定输出文件名的可选参数(默认为空)。

libMesh::PetscVector< T > 重载.

在文件 numeric_vector.h859 行定义.

860  {
861  libmesh_not_implemented();
862  }
template<typename T >
bool libMesh::NumericVector< T >::readable ( ) const

检查该向量是否能够用于全局操作。

返回
如果向量可以用于全局操作,则返回 true,否则返回 false。

在文件 numeric_vector.C416 行定义.

参考 libMesh::closed() , 以及 libMesh::initialized().

参考自 libMesh::NumericVector< T >::add_vector(), libMesh::NumericVector< T >::compatible() , 以及 libMesh::NumericVector< T >::insert().

417 {
418  return this->initialized() && this->closed();
419 }
virtual bool closed() const
检查向量是否已经关闭并准备好进行计算。
virtual bool initialized() const
检查向量是否已经初始化。
template<typename T>
virtual void libMesh::NumericVector< T >::reciprocal ( )
pure virtual
template<typename T>
virtual void libMesh::NumericVector< T >::scale ( const T  factor)
pure virtual
template<typename T>
virtual void libMesh::NumericVector< T >::set ( const numeric_index_type  i,
const T  value 
)
pure virtual

设置 v(i) = value 。 请注意,此方法的库实现是线程安全的, 例如,将在写入向量之前锁定 _numeric_vector_mutex

参数
i要设置的条目的索引。
value要设置的值。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

参考自 libMesh::DofMap::enforce_adjoint_constraints_exactly(), libMesh::DofMap::enforce_constraints_exactly() , 以及 libMesh::DofMap::enforce_constraints_on_residual().

template<typename T>
virtual numeric_index_type libMesh::NumericVector< T >::size ( ) const
pure virtual
template<class T >
Real libMesh::NumericVector< T >::subset_l1_norm ( const std::set< numeric_index_type > &  indices) const
virtual

获取指定条目的向量的 $ \ell_1 $-范数,即指定条目的绝对值之和。

参数
indices指定的索引集合。
返回
指定条目的向量的 $ \ell_1 $-范数。
注解
索引必须位于此处理器上。

在文件 numeric_vector.C306 行定义.

参考 std::abs(), std::norm() , 以及 libMesh::Real.

307 {
308  libmesh_assert (this->readable());
309 
310  const NumericVector<T> & v = *this;
311 
312  Real norm = 0;
313 
314  for (const auto & index : indices)
315  norm += std::abs(v(index));
316 
317  this->comm().sum(norm);
318 
319  return norm;
320 }
bool readable() const
检查该向量是否能够用于全局操作。
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的绝对值。
Definition: type_vector.h:112
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
ADRealEigenVector< T, D, asd > norm(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的范数。
Definition: type_vector.h:64
template<class T >
Real libMesh::NumericVector< T >::subset_l2_norm ( const std::set< numeric_index_type > &  indices) const
virtual

获取指定条目的向量的 $ \ell_2 $-范数,即指定条目平方和的平方根。

参数
indices指定的索引集合。
返回
指定条目的向量的 $ \ell_2 $-范数。
注解
索引必须位于此处理器上。

在文件 numeric_vector.C323 行定义.

参考 std::norm(), libMesh::TensorTools::norm_sq(), libMesh::Real , 以及 std::sqrt().

324 {
325  libmesh_assert (this->readable());
326 
327  const NumericVector<T> & v = *this;
328 
329  Real norm = 0;
330 
331  for (const auto & index : indices)
332  norm += TensorTools::norm_sq(v(index));
333 
334  this->comm().sum(norm);
335 
336  return std::sqrt(norm);
337 }
bool readable() const
检查该向量是否能够用于全局操作。
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的平方根。
Definition: type_vector.h:88
T norm_sq(std::complex< T > a)
Definition: tensor_tools.h:74
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
ADRealEigenVector< T, D, asd > norm(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的范数。
Definition: type_vector.h:64
template<class T >
Real libMesh::NumericVector< T >::subset_linfty_norm ( const std::set< numeric_index_type > &  indices) const
virtual

获取指定条目的向量的最大绝对值,即指定条目的 $ \ell_{\infty} $-范数。

参数
indices指定的索引集合。
返回
指定条目的向量的最大绝对值。
注解
索引必须位于此处理器上。

在文件 numeric_vector.C340 行定义.

参考 std::abs(), std::norm() , 以及 libMesh::Real.

341 {
342  libmesh_assert (this->readable());
343 
344  const NumericVector<T> & v = *this;
345 
346  Real norm = 0;
347 
348  for (const auto & index : indices)
349  {
350  Real value = std::abs(v(index));
351  if (value > norm)
352  norm = value;
353  }
354 
355  this->comm().max(norm);
356 
357  return norm;
358 }
bool readable() const
检查该向量是否能够用于全局操作。
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的绝对值。
Definition: type_vector.h:112
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
ADRealEigenVector< T, D, asd > norm(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的范数。
Definition: type_vector.h:64
template<typename T>
virtual T libMesh::NumericVector< T >::sum ( ) const
pure virtual

获取向量中所有值的总和。

返回
向量中所有值的总和。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

template<typename T >
void libMesh::NumericVector< T >::swap ( NumericVector< T > &  v)
inlinevirtual

交换该向量的内容与向量 v 的内容。子类应提供足够的间接性以使此操作成为 O(1) 的头部交换操作。

参数
v要交换内容的向量。

libMesh::PetscVector< T >, libMesh::EpetraVector< T >, libMesh::LaspackVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 重载.

在文件 numeric_vector.h1179 行定义.

参考 libMesh::libMeshPrivateData::_is_initialized.

参考自 libMesh::EpetraVector< T >::swap() , 以及 libMesh::PetscVector< T >::swap().

1180 {
1181  std::swap(_is_closed, v._is_closed);
1182  std::swap(_is_initialized, v._is_initialized);
1183  std::swap(_type, v._type);
1184 }
bool _is_initialized
在调用 init() 后设置为 true。
ParallelType _type
向量的类型。
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
template<typename T>
ParallelType libMesh::NumericVector< T >::type ( ) const
inline
template<typename T>
ParallelType& libMesh::NumericVector< T >::type ( )
inline

获取向量的类型。

返回
向量的类型(SERIAL、PARALLEL、GHOSTED)。

在文件 numeric_vector.h173 行定义.

参考 libMesh::NumericVector< T >::_type.

173 { return _type; }
ParallelType _type
向量的类型。
template<typename T>
virtual void libMesh::NumericVector< T >::zero ( )
pure virtual
template<typename T>
virtual std::unique_ptr<NumericVector<T> > libMesh::NumericVector< T >::zero_clone ( ) const
pure virtual

返回一个智能指针,指向具有相同类型、大小和分区的此向量的副本,但所有条目都为零。

注解
派生类必须重写此方法。
返回
指向新向量副本的 unique_ptr。

libMesh::PetscVector< T >, libMesh::LaspackVector< T >, libMesh::EpetraVector< T >, libMesh::EigenSparseVector< T > , 以及 libMesh::DistributedVector< T > 内被实现.

参考自 libMesh::SumShellMatrix< T >::get_diagonal().

友元及相关函数文档

template<typename T>
std::ostream& operator<< ( std::ostream &  os,
const NumericVector< T > &  v 
)
friend

允许使用流语法打印向量的内容。

在文件 numeric_vector.h847 行定义.

848  {
849  v.print_global(os);
850  return os;
851  }

类成员变量说明

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

Actually holds the data.

在文件 reference_counter.h124 行定义.

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

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::NumericVector< T >::_is_closed
protected

用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。

在文件 numeric_vector.h913 行定义.

参考自 libMesh::NumericVector< T >::closed(), libMesh::EpetraVector< T >::EpetraVector(), libMesh::DistributedVector< T >::localize(), libMesh::DistributedVector< T >::operator=() , 以及 libMesh::PetscVector< T >::PetscVector().

template<typename T>
bool libMesh::NumericVector< T >::_is_initialized
protected
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>
std::mutex libMesh::NumericVector< T >::_numeric_vector_mutex
protected

用于执行线程安全操作的互斥锁。

在文件 numeric_vector.h928 行定义.

template<typename T>
ParallelType libMesh::NumericVector< T >::_type
protected

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