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

该类提供了一个简单的并行分布式向量数据类型, 专门用于 libmesh。提供了一些集体通信功能。 更多...

#include <distributed_vector.h>

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

Public 成员函数

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

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

Private 属性

std::vector< T > _values
 实际的向量数据类型,用于保存向量条目。 更多...
 
numeric_index_type _global_size
 全局向量大小。 更多...
 
numeric_index_type _local_size
 本地向量大小。 更多...
 
numeric_index_type _first_local_index
 本地存储的第一个分量。 更多...
 
numeric_index_type _last_local_index
 本地存储的最后一个分量(+1)。 更多...
 

详细描述

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

该类提供了一个简单的并行分布式向量数据类型, 专门用于 libmesh。提供了一些集体通信功能。

注解
该类在没有 MPI 的情况下仍会正常工作, 但只能在一个处理器上运行。所有覆盖的虚拟函数在 numeric_vector.h 中有文档说明。
作者
Benjamin S. Kirk
日期
2003

在文件 distributed_vector.h52 行定义.

成员类型定义说明

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

虚构造函数。维度为 0。

在文件 distributed_vector.h262 行定义.

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

263  :
264  NumericVector<T>(comm_in, ptype),
265  _global_size (0),
266  _local_size (0),
269 {
270  this->_type = ptype;
271 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
numeric_index_type _global_size
全局向量大小。
ParallelType _type
向量的类型。
numeric_index_type _local_size
本地向量大小。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
libMesh::DistributedVector< T >::DistributedVector ( const Parallel::Communicator &  comm,
const numeric_index_type  n,
const ParallelType  ptype = AUTOMATIC 
)
inlineexplicit

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

在文件 distributed_vector.h277 行定义.

参考 libMesh::DistributedVector< T >::init().

280  : NumericVector<T>(comm_in, ptype)
281 {
282  this->init(n, n, false, ptype);
283 }
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC) override
更改向量的维度为 n 。如果可能的话 ,该向量的保留内存保持不变。 如果 n==0 ,所有内存都将被释放。因此,如果要调整向量的大小并释放不需要的内存, 必须首先调用 init(0) ,然后调用 ini...
template<typename T >
libMesh::DistributedVector< T >::DistributedVector ( const Parallel::Communicator &  comm,
const numeric_index_type  n,
const numeric_index_type  n_local,
const ParallelType  ptype = AUTOMATIC 
)
inline

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

在文件 distributed_vector.h289 行定义.

参考 libMesh::DistributedVector< T >::init().

293  : NumericVector<T>(comm_in, ptype)
294 {
295  this->init(n, n_local, false, ptype);
296 }
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC) override
更改向量的维度为 n 。如果可能的话 ,该向量的保留内存保持不变。 如果 n==0 ,所有内存都将被释放。因此,如果要调整向量的大小并释放不需要的内存, 必须首先调用 init(0) ,然后调用 ini...
template<typename T >
libMesh::DistributedVector< T >::DistributedVector ( const Parallel::Communicator &  comm,
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 参数指定的索引预留内存。

在文件 distributed_vector.h302 行定义.

参考 libMesh::DistributedVector< T >::init().

307  : NumericVector<T>(comm_in, ptype)
308 {
309  this->init(n, n_local, ghost, false, ptype);
310 }
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC) override
更改向量的维度为 n 。如果可能的话 ,该向量的保留内存保持不变。 如果 n==0 ,所有内存都将被释放。因此,如果要调整向量的大小并释放不需要的内存, 必须首先调用 init(0) ,然后调用 ini...
template<typename T>
libMesh::DistributedVector< T >::DistributedVector ( DistributedVector< T > &&  )
default

对于该类,可以将 4 个特殊函数默认设置为默认值,因为它本身不管理任何内存。

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

成员函数说明

template<typename T >
void libMesh::DistributedVector< T >::abs ( )
overridevirtual

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C281 行定义.

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

282 {
283  libmesh_assert (this->initialized());
284  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
285 
286  for (auto & val : _values)
287  val = std::abs(val);
288 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的绝对值。
Definition: type_vector.h:112
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
void libMesh::DistributedVector< T >::add ( const numeric_index_type  i,
const T  value 
)
inlineoverridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h588 行定义.

参考 libMesh::initialized().

589 {
590  libmesh_assert (this->initialized());
591  libmesh_assert_equal_to (_values.size(), _local_size);
592  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
593  libmesh_assert_less (i, size());
594  libmesh_assert_less (i-first_local_index(), local_size());
595 
596  std::scoped_lock lock(this->_numeric_vector_mutex);
597  _values[i - _first_local_index] += value;
598 
599 
600  this->_is_closed = false;
601 }
std::mutex _numeric_vector_mutex
用于执行线程安全操作的互斥锁。
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
virtual numeric_index_type local_size() const override
获取向量的本地大小,即 index_stop - index_start。
virtual numeric_index_type size() const override
获取向量的大小。
numeric_index_type _local_size
本地向量大小。
virtual numeric_index_type first_local_index() const override
获取实际存储在该处理器上的第一个向量元素的索引。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
template<typename T >
void libMesh::DistributedVector< T >::add ( const T  s)
overridevirtual

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

参数
s要添加的值。

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C228 行定义.

参考 libMesh::initialized().

229 {
230  libmesh_assert (this->initialized());
231  libmesh_assert_equal_to (_values.size(), _local_size);
232  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
233 
234  for (auto & val : _values)
235  val += v;
236 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
void libMesh::DistributedVector< T >::add ( const NumericVector< T > &  v)
overridevirtual

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

参数
v另一个数值向量。

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C241 行定义.

参考 libMesh::initialized().

242 {
243  libmesh_assert (this->initialized());
244  libmesh_assert_equal_to (_values.size(), _local_size);
245  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
246 
247  add (1., v);
248 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual void add(const numeric_index_type i, const T value) override
将 value 添加到由 i 指定的向量条目。 请注意,此方法的库实现是线程安全的, 例如,将在写入向量之前锁定 _numeric_vector_mutex 。
virtual bool initialized() const
检查向量是否已经初始化。
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
void libMesh::DistributedVector< T >::add ( const T  a,
const NumericVector< T > &  v 
)
overridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C253 行定义.

参考 libMesh::DistributedVector< T >::_values , 以及 libMesh::initialized().

254 {
255  libmesh_assert (this->initialized());
256  libmesh_assert_equal_to (_values.size(), _local_size);
257  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
258 
259  // Make sure the NumericVector passed in is really a DistributedVector
260  const DistributedVector<T> * v = cast_ptr<const DistributedVector<T> *>(&v_in);
261  libmesh_error_msg_if(!v, "Cannot add different types of NumericVectors.");
262 
263  for (auto i : index_range(_values))
264  _values[i] += a * v->_values[i];
265 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T>
virtual void libMesh::DistributedVector< T >::add_vector ( const NumericVector< T > &  v,
const SparseMatrix< T > &  A 
)
inlineoverridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h188 行定义.

190  { libmesh_not_implemented(); }
template<typename T >
void libMesh::NumericVector< T >::add_vector ( const T *  v,
const std::vector< numeric_index_type > &  dof_indices 
)
virtualinherited

计算 $ \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 
)
inlineinherited

计算 $ \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 
)
inherited

计算 $ \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 
)
inlineinherited

计算 $ \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 >
void libMesh::NumericVector< T >::add_vector ( const NumericVector< T > &  v,
const ShellMatrix< T > &  A 
)
inherited

计算 $ \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::DistributedVector< T >::add_vector_transpose ( const NumericVector< T > &  v,
const SparseMatrix< T > &  A 
)
inlineoverridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h192 行定义.

194  { libmesh_not_implemented(); }
template<typename T >
std::unique_ptr< NumericVector< T > > libMesh::NumericVector< T >::build ( const Parallel::Communicator &  comm,
const SolverPackage  solver_package = libMesh::default_solver_package() 
)
staticinherited

构建一个 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::DistributedVector< T >::clear ( )
inlineoverridevirtual

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

重载 libMesh::NumericVector< T > .

在文件 distributed_vector.h446 行定义.

参考 libMesh::libMeshPrivateData::_is_initialized.

447 {
448  _values.clear();
449 
450  _global_size =
451  _local_size =
453  _last_local_index = 0;
454 
455 
456  this->_is_closed = this->_is_initialized = false;
457 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
bool _is_initialized
在调用 init() 后设置为 true。
numeric_index_type _global_size
全局向量大小。
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
template<typename T >
std::unique_ptr< NumericVector< T > > libMesh::DistributedVector< T >::clone ( ) const
inlineoverridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h489 行定义.

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

490 {
491  NumericVector<T> * cloned_vector = new DistributedVector<T>(this->comm());
492  cloned_vector->init(*this, true);
493  *cloned_vector = *this;
494  return std::unique_ptr<NumericVector<T>>(cloned_vector);
495 }
template<typename T >
void libMesh::DistributedVector< T >::close ( )
inlineoverridevirtual

调用 NumericVector 的内部组装函数,确保值在处理器之间一致。

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h435 行定义.

参考 libMesh::initialized().

436 {
437  libmesh_assert (this->initialized());
438 
439  this->_is_closed = true;
440 }
virtual bool initialized() const
检查向量是否已经初始化。
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
template<typename T>
virtual bool libMesh::NumericVector< T >::closed ( ) const
inlinevirtualinherited

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

返回
如果向量已经关闭并准备好进行计算,则返回 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
virtualinherited

比较 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
inherited

检查该向量和向量 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 >
void libMesh::DistributedVector< T >::conjugate ( )
overridevirtual

反转向量中每个条目的虚部。

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C216 行定义.

参考 libMesh::libmesh_conj().

217 {
218  // Replace values by complex conjugate
219  for (auto & val : _values)
220  val = libmesh_conj(val);
221 }
T libmesh_conj(T a)
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
template<typename T>
virtual void libMesh::NumericVector< T >::create_subvector ( NumericVector< T > &  subvector,
const std::vector< numeric_index_type > &  rows 
) const
inlinevirtualinherited

使用 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 >
T libMesh::DistributedVector< T >::dot ( const NumericVector< T > &  v) const
overridevirtual

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

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C295 行定义.

参考 libMesh::DistributedVector< T >::_values, libMesh::DistributedVector< T >::first_local_index() , 以及 libMesh::DistributedVector< T >::last_local_index().

296 {
297  // This function must be run on all processors at once
298  parallel_object_only();
299 
300  // Make sure the NumericVector passed in is really a DistributedVector
301  const DistributedVector<T> * v = cast_ptr<const DistributedVector<T> *>(&V);
302 
303  // Make sure that the two vectors are distributed in the same way.
304  libmesh_assert_equal_to ( this->first_local_index(), v->first_local_index() );
305  libmesh_assert_equal_to ( this->last_local_index(), v->last_local_index() );
306 
307  // The result of dotting together the local parts of the vector.
308  T local_dot = 0;
309 
310  for (auto i : index_range(_values))
311  local_dot += this->_values[i] * v->_values[i];
312 
313  // The local dot products are now summed via MPI
314  this->comm().sum(local_dot);
315 
316  return local_dot;
317 }
virtual numeric_index_type last_local_index() const override
获取实际存储在该处理器上的最后一个向量元素的索引+1。
virtual numeric_index_type first_local_index() const override
获取实际存储在该处理器上的第一个向量元素的索引。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
template<typename T>
virtual T libMesh::NumericVector< T >::el ( const numeric_index_type  i) const
inlinevirtualinherited

获取向量的第 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 >
numeric_index_type libMesh::DistributedVector< T >::first_local_index ( ) const
inlineoverridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h527 行定义.

参考 libMesh::initialized().

参考自 libMesh::DistributedVector< T >::dot().

528 {
529  libmesh_assert (this->initialized());
530  libmesh_assert_equal_to (_values.size(), _local_size);
531  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
532 
533  return _first_local_index;
534 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
void libMesh::NumericVector< T >::get ( const std::vector< numeric_index_type > &  index,
T *  values 
) const
inlinevirtualinherited

一次访问多个组件。 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
inlineinherited

一次访问多个组件。 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 >
void libMesh::DistributedVector< T >::init ( const numeric_index_type  n,
const numeric_index_type  n_local,
const bool  fast = false,
const ParallelType  ptype = AUTOMATIC 
)
inlineoverridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h316 行定义.

参考 libMesh::libMeshPrivateData::_is_initialized, libMesh::initialized() , 以及 libMesh::zero.

参考自 libMesh::DistributedVector< T >::DistributedVector() , 以及 libMesh::DistributedVector< T >::localize().

320 {
321  // This function must be run on all processors at once
322  parallel_object_only();
323 
324  libmesh_assert_less_equal (n_local, n);
325 
326  if (ptype == AUTOMATIC)
327  {
328  if (n == n_local)
329  this->_type = SERIAL;
330  else
331  this->_type = PARALLEL;
332  }
333  else if (ptype == GHOSTED &&
334  n == n_local) // We can support GHOSTED with no ghosts...
335  this->_type = SERIAL;
336  else
337  this->_type = ptype;
338 
339  libmesh_assert ((this->_type==SERIAL && n==n_local) ||
340  this->_type==PARALLEL);
341 
342  // Clear the data structures if already initialized
343  if (this->initialized())
344  this->clear();
345 
346  // Initialize data structures
347  _values.resize(n_local);
348  _local_size = n_local;
349  _global_size = n;
350 
351  _first_local_index = 0;
352 
353 #ifdef LIBMESH_HAVE_MPI
354 
355  std::vector<numeric_index_type> local_sizes (this->n_processors(), 0);
356 
357  local_sizes[this->processor_id()] = n_local;
358 
359  this->comm().sum(local_sizes);
360 
361  // _first_local_index is the sum of _local_size
362  // for all processor ids less than ours
363  for (auto p : make_range(this->processor_id()))
364  _first_local_index += local_sizes[p];
365 
366 
367 # ifdef DEBUG
368  // Make sure all the local sizes sum up to the global
369  // size, otherwise there is big trouble!
370  numeric_index_type dbg_sum=0;
371 
372  for (auto p : make_range(this->n_processors()))
373  dbg_sum += local_sizes[p];
374 
375  libmesh_assert_equal_to (dbg_sum, n);
376 
377 # endif
378 
379 #else
380 
381  // No other options without MPI!
382  libmesh_error_msg_if(n != n_local, "ERROR: MPI is required for n != n_local!");
383 
384 #endif
385 
387 
388  // Set the initialized flag
389  this->_is_initialized = true;
390 
391  // Zero the components unless directed otherwise
392  if (!fast)
393  this->zero();
394 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
bool _is_initialized
在调用 init() 后设置为 true。
virtual bool initialized() const
检查向量是否已经初始化。
numeric_index_type _global_size
全局向量大小。
virtual void zero() override
将所有条目设置为零。等同于 v = 0,但更明显且更快。
dof_id_type numeric_index_type
Definition: id_types.h:99
ParallelType _type
向量的类型。
numeric_index_type _local_size
本地向量大小。
virtual void clear() override
将 NumericVector&lt;T&gt; 恢复到原始状态。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
void libMesh::DistributedVector< T >::init ( const numeric_index_type  n,
const bool  fast = false,
const ParallelType  ptype = AUTOMATIC 
)
inlineoverridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h424 行定义.

427 {
428  this->init(n,n,fast,ptype);
429 }
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC) override
更改向量的维度为 n 。如果可能的话 ,该向量的保留内存保持不变。 如果 n==0 ,所有内存都将被释放。因此,如果要调整向量的大小并释放不需要的内存, 必须首先调用 init(0) ,然后调用 ini...
template<typename T >
void libMesh::DistributedVector< 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 
)
inlineoverridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h399 行定义.

404 {
405  // TODO: we shouldn't ignore the ghost sparsity pattern
406  this->init(n, n_local, fast, ptype);
407 }
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC) override
更改向量的维度为 n 。如果可能的话 ,该向量的保留内存保持不变。 如果 n==0 ,所有内存都将被释放。因此,如果要调整向量的大小并释放不需要的内存, 必须首先调用 init(0) ,然后调用 ini...
template<class T >
void libMesh::DistributedVector< T >::init ( const NumericVector< T > &  other,
const bool  fast = false 
)
overridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h414 行定义.

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

416 {
417  this->init(other.size(),other.local_size(),fast,other.type());
418 }
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC) override
更改向量的维度为 n 。如果可能的话 ,该向量的保留内存保持不变。 如果 n==0 ,所有内存都将被释放。因此,如果要调整向量的大小并释放不需要的内存, 必须首先调用 init(0) ,然后调用 ini...
template<typename T>
virtual bool libMesh::NumericVector< T >::initialized ( ) const
inlinevirtualinherited

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

返回
如果向量已经初始化,则返回 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 
)
virtualinherited

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 
)
inherited

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 
)
inlineinherited

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 
)
inlineinherited

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 >
Real libMesh::DistributedVector< T >::l1_norm ( ) const
overridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C70 行定义.

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

71 {
72  // This function must be run on all processors at once
73  parallel_object_only();
74 
75  libmesh_assert (this->initialized());
76  libmesh_assert_equal_to (_values.size(), _local_size);
77  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
78 
79  Real local_l1 = 0.;
80 
81  for (auto & val : _values)
82  local_l1 += std::abs(val);
83 
84  this->comm().sum(local_l1);
85 
86  return local_l1;
87 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的绝对值。
Definition: type_vector.h:112
numeric_index_type _local_size
本地向量大小。
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
Real libMesh::DistributedVector< T >::l2_norm ( ) const
overridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C92 行定义.

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

93 {
94  // This function must be run on all processors at once
95  parallel_object_only();
96 
97  libmesh_assert (this->initialized());
98  libmesh_assert_equal_to (_values.size(), _local_size);
99  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
100 
101  Real local_l2 = 0.;
102 
103  for (auto & val : _values)
104  local_l2 += TensorTools::norm_sq(val);
105 
106  this->comm().sum(local_l2);
107 
108  return std::sqrt(local_l2);
109 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() 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
numeric_index_type _local_size
本地向量大小。
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<class T >
Real libMesh::NumericVector< T >::l2_norm_diff ( const NumericVector< T > &  other_vec) const
inherited

获取 $ \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 >
numeric_index_type libMesh::DistributedVector< T >::last_local_index ( ) const
inlineoverridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h540 行定义.

参考 libMesh::initialized().

参考自 libMesh::DistributedVector< T >::dot().

541 {
542  libmesh_assert (this->initialized());
543  libmesh_assert_equal_to (_values.size(), _local_size);
544  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
545 
546  return _last_local_index;
547 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
Real libMesh::DistributedVector< T >::linfty_norm ( ) const
overridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C114 行定义.

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

115 {
116  // This function must be run on all processors at once
117  parallel_object_only();
118 
119  libmesh_assert (this->initialized());
120  libmesh_assert_equal_to (_values.size(), _local_size);
121  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
122 
123  Real local_linfty = 0.;
124 
125  for (auto & val : _values)
126  local_linfty = std::max(local_linfty,
127  static_cast<Real>(std::abs(val))
128  ); // Note we static_cast so that both
129  // types are the same, as required
130  // by std::max
131 
132  this->comm().max(local_linfty);
133 
134  return local_linfty;
135 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的绝对值。
Definition: type_vector.h:112
numeric_index_type _local_size
本地向量大小。
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
int libMesh::NumericVector< T >::local_relative_compare ( const NumericVector< T > &  other_vector,
const Real  threshold = TOLERANCE 
) const
virtualinherited

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

如果两个向量在给定的局部相对阈值 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 >
numeric_index_type libMesh::DistributedVector< T >::local_size ( ) const
inlineoverridevirtual

获取向量的本地大小,即 index_stop - index_start。

返回
向量的本地大小。

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h514 行定义.

参考 libMesh::initialized().

参考自 libMesh::DistributedVector< T >::operator=().

515 {
516  libmesh_assert (this->initialized());
517  libmesh_assert_equal_to (_values.size(), _local_size);
518  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
519 
520  return _local_size;
521 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
void libMesh::DistributedVector< T >::localize ( std::vector< T > &  v_local) const
overridevirtual

创建全局向量的副本并存储在本地向量 v_local 中。

参数
v_local用于存储本地向量的 std::vector。

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C571 行定义.

参考 libMesh::initialized().

参考自 libMesh::DistributedVector< T >::localize().

572 {
573  // This function must be run on all processors at once
574  parallel_object_only();
575 
576  libmesh_assert (this->initialized());
577  libmesh_assert_equal_to (_values.size(), _local_size);
578  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
579 
580  v_local = this->_values;
581 
582  this->comm().allgather (v_local);
583 
584 #ifndef LIBMESH_HAVE_MPI
585  libmesh_assert_equal_to (local_size(), size());
586 #endif
587 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
virtual numeric_index_type local_size() const override
获取向量的本地大小,即 index_stop - index_start。
virtual numeric_index_type size() const override
获取向量的大小。
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
void libMesh::DistributedVector< T >::localize ( NumericVector< T > &  v_local) const
overridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C398 行定义.

参考 libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_global_size, libMesh::NumericVector< T >::_is_closed, libMesh::NumericVector< T >::_is_initialized, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values , 以及 libMesh::initialized().

400 {
401  libmesh_assert (this->initialized());
402  libmesh_assert_equal_to (_values.size(), _local_size);
403  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
404 
405  DistributedVector<T> * v_local = cast_ptr<DistributedVector<T> *>(&v_local_in);
406 
407  v_local->_first_local_index = 0;
408 
409  v_local->_global_size =
410  v_local->_local_size =
411  v_local->_last_local_index = size();
412 
413  v_local->_is_initialized =
414  v_local->_is_closed = true;
415 
416  // Call localize on the vector's values. This will help
417  // prevent code duplication
418  localize (v_local->_values);
419 
420 #ifndef LIBMESH_HAVE_MPI
421 
422  libmesh_assert_equal_to (local_size(), size());
423 
424 #endif
425 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
virtual numeric_index_type local_size() const override
获取向量的本地大小,即 index_stop - index_start。
virtual numeric_index_type size() const override
获取向量的大小。
numeric_index_type _local_size
本地向量大小。
virtual void localize(std::vector< T > &v_local) const override
创建全局向量的副本并存储在本地向量 v_local 中。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
void libMesh::DistributedVector< T >::localize ( NumericVector< T > &  v_local,
const std::vector< numeric_index_type > &  send_list 
) const
overridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C430 行定义.

参考 libMesh::initialized().

432 {
433  libmesh_assert (this->initialized());
434  libmesh_assert_equal_to (_values.size(), _local_size);
435  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
436 
437  // TODO: We don't yet support the send list; this is inefficient:
438  localize (v_local_in);
439 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
numeric_index_type _local_size
本地向量大小。
virtual void localize(std::vector< T > &v_local) const override
创建全局向量的副本并存储在本地向量 v_local 中。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
void libMesh::DistributedVector< T >::localize ( std::vector< T > &  v_local,
const std::vector< numeric_index_type > &  indices 
) const
overridevirtual

用全局索引中给定的值填充本地 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::NumericVector< T >.

在文件 distributed_vector.C444 行定义.

446 {
447  // Resize v_local so there is enough room to hold all the local values.
448  v_local.resize(indices.size());
449 
450  // We need to know who has the values we want, so get everyone's _local_size
451  std::vector<numeric_index_type> local_sizes;
452  this->comm().allgather (_local_size, local_sizes);
453 
454  // Make a vector of partial sums of local sizes
455  std::vector<numeric_index_type> local_size_sums(this->n_processors());
456  local_size_sums[0] = local_sizes[0];
457  for (auto i : IntRange<numeric_index_type>(1, local_sizes.size()))
458  local_size_sums[i] = local_size_sums[i-1] + local_sizes[i];
459 
460  // We now fill in 'requested_ids' based on the indices. Also keep
461  // track of the local index (in the indices vector) for each of
462  // these, since we need that when unpacking.
463  std::map<processor_id_type, std::vector<numeric_index_type>>
464  requested_ids, local_requested_ids;
465 
466  // We'll use this typedef a couple of times below.
467  typedef typename std::vector<numeric_index_type>::iterator iter_t;
468 
469  // For each index in indices, determine which processor it is on.
470  // This is an O(N*log(p)) algorithm that uses std::upper_bound().
471  // Note: upper_bound() returns an iterator to the first entry which is
472  // greater than the given value.
473  for (auto i : index_range(indices))
474  {
475  iter_t ub = std::upper_bound(local_size_sums.begin(),
476  local_size_sums.end(),
477  indices[i]);
478 
479  processor_id_type on_proc = cast_int<processor_id_type>
480  (std::distance(local_size_sums.begin(), ub));
481 
482  requested_ids[on_proc].push_back(indices[i]);
483  local_requested_ids[on_proc].push_back(i);
484  }
485 
486  auto gather_functor =
487  [this]
488  (processor_id_type, const std::vector<dof_id_type> & ids,
489  std::vector<T> & values)
490  {
491  // The first send/receive we did was for indices, the second one will be
492  // for corresponding floating point values, so create storage for that now...
493  const std::size_t ids_size = ids.size();
494  values.resize(ids_size);
495 
496  for (std::size_t i=0; i != ids_size; i++)
497  {
498  // The index of the requested value
499  const numeric_index_type requested_index = ids[i];
500 
501  // Transform into local numbering, and get requested value.
502  values[i] = _values[requested_index - _first_local_index];
503  }
504  };
505 
506  auto action_functor =
507  [& v_local, & local_requested_ids]
508  (processor_id_type pid,
509  const std::vector<dof_id_type> &,
510  const std::vector<T> & values)
511  {
512  // Now write the received values to the appropriate place(s) in v_local
513  for (auto i : index_range(values))
514  {
515  libmesh_assert(local_requested_ids.count(pid));
516  libmesh_assert_less(i, local_requested_ids[pid].size());
517 
518  // Get the index in v_local where this value needs to be inserted.
519  const numeric_index_type local_requested_index =
520  local_requested_ids[pid][i];
521 
522  // Actually set the value in v_local
523  v_local[local_requested_index] = values[i];
524  }
525  };
526 
527  const T * ex = nullptr;
528  Parallel::pull_parallel_vector_data
529  (this->comm(), requested_ids, gather_functor, action_functor, ex);
530 }
uint8_t processor_id_type
Definition: id_types.h:104
dof_id_type numeric_index_type
Definition: id_types.h:99
virtual numeric_index_type size() const override
获取向量的大小。
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
void libMesh::DistributedVector< T >::localize ( const numeric_index_type  first_local_idx,
const numeric_index_type  last_local_idx,
const std::vector< numeric_index_type > &  send_list 
)
overridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C535 行定义.

参考 libMesh::DistributedVector< T >::_values, libMesh::DistributedVector< T >::init() , 以及 libMesh::DistributedVector< T >::localize().

538 {
539  // Only good for serial vectors
540  libmesh_assert_equal_to (this->size(), this->local_size());
541  libmesh_assert_greater (last_local_idx, first_local_idx);
542  libmesh_assert_less_equal (send_list.size(), this->size());
543  libmesh_assert_less (last_local_idx, this->size());
544 
545  const numeric_index_type my_size = this->size();
546  const numeric_index_type my_local_size = (last_local_idx - first_local_idx + 1);
547 
548  // Don't bother for serial cases
549  if ((first_local_idx == 0) &&
550  (my_local_size == my_size))
551  return;
552 
553 
554  // Build a parallel vector, initialize it with the local
555  // parts of (*this)
556  DistributedVector<T> parallel_vec(this->comm());
557 
558  parallel_vec.init (my_size, my_local_size, true, PARALLEL);
559 
560  // Copy part of *this into the parallel_vec
561  for (numeric_index_type i=first_local_idx; i<=last_local_idx; i++)
562  parallel_vec._values[i-first_local_idx] = _values[i];
563 
564  // localize like normal
565  parallel_vec.localize (*this, send_list);
566 }
virtual numeric_index_type local_size() const override
获取向量的本地大小,即 index_stop - index_start。
dof_id_type numeric_index_type
Definition: id_types.h:99
virtual numeric_index_type size() const override
获取向量的大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
template<typename T >
void libMesh::DistributedVector< T >::localize_to_one ( std::vector< T > &  v_local,
const processor_id_type  proc_id = 0 
) const
overridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C592 行定义.

参考 libMesh::initialized().

594 {
595  // This function must be run on all processors at once
596  parallel_object_only();
597 
598  libmesh_assert (this->initialized());
599  libmesh_assert_equal_to (_values.size(), _local_size);
600  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
601 
602  v_local = this->_values;
603 
604  this->comm().gather (pid, v_local);
605 
606 #ifndef LIBMESH_HAVE_MPI
607  libmesh_assert_equal_to (local_size(), size());
608 #endif
609 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
virtual numeric_index_type local_size() const override
获取向量的本地大小,即 index_stop - index_start。
virtual numeric_index_type size() const override
获取向量的大小。
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
Real libMesh::DistributedVector< T >::max ( ) const
inlineoverridevirtual

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

返回
向量的最大值。

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h629 行定义.

参考 libMesh::initialized(), libMesh::libmesh_real() , 以及 libMesh::Real.

630 {
631  // This function must be run on all processors at once
632  parallel_object_only();
633 
634  libmesh_assert (this->initialized());
635  libmesh_assert_equal_to (_values.size(), _local_size);
636  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
637 
638  Real local_max = -std::numeric_limits<Real>::max();
639  for (auto v : _values)
640  local_max = std::max(libmesh_real(v), local_max);
641 
642  this->comm().max(local_max);
643 
644  return local_max;
645 }
T libmesh_real(T a)
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
numeric_index_type _local_size
本地向量大小。
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
std::size_t libMesh::DistributedVector< T >::max_allowed_id ( ) const
inlineoverridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h665 行定义.

666 {
667  // Uses a std:vector<T>, so our indexing matches that
668  return std::numeric_limits<typename std::vector<T>::size_type>::max();
669 }
virtual Real max() const override
获取向量中的最大值,或者在复数情况下获取最大的实部。
template<typename T >
Real libMesh::DistributedVector< T >::min ( ) const
inlineoverridevirtual

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

返回
向量的最小值。

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h607 行定义.

参考 libMesh::initialized(), libMesh::libmesh_real() , 以及 libMesh::Real.

608 {
609  // This function must be run on all processors at once
610  parallel_object_only();
611 
612  libmesh_assert (this->initialized());
613  libmesh_assert_equal_to (_values.size(), _local_size);
614  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
615 
616  Real local_min = std::numeric_limits<Real>::max();
617  for (auto v : _values)
618  local_min = std::min(libmesh_real(v), local_min);
619 
620  this->comm().min(local_min);
621 
622  return local_min;
623 }
T libmesh_real(T a)
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
numeric_index_type _local_size
本地向量大小。
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
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 >
T libMesh::DistributedVector< T >::operator() ( const numeric_index_type  i) const
inlineoverridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h553 行定义.

参考 libMesh::initialized().

554 {
555  libmesh_assert (this->initialized());
556  libmesh_assert_equal_to (_values.size(), _local_size);
557  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
558  libmesh_assert ( ((i >= first_local_index()) &&
559  (i < last_local_index())) );
560 
561  return _values[i - _first_local_index];
562 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual numeric_index_type last_local_index() const override
获取实际存储在该处理器上的最后一个向量元素的索引+1。
virtual bool initialized() const
检查向量是否已经初始化。
numeric_index_type _local_size
本地向量大小。
virtual numeric_index_type first_local_index() const override
获取实际存储在该处理器上的第一个向量元素的索引。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
NumericVector< T > & libMesh::DistributedVector< T >::operator*= ( const NumericVector< T > &  v)
overridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C170 行定义.

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

171 {
172  libmesh_assert_equal_to(size(), v.size());
173 
174  const DistributedVector<T> & v_vec = cast_ref<const DistributedVector<T> &>(v);
175 
176  for (auto i : index_range(_values))
177  _values[i] *= v_vec._values[i];
178 
179  return *this;
180 }
virtual numeric_index_type size() const override
获取向量的大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
template<typename T>
NumericVector<T>& libMesh::NumericVector< T >::operator*= ( const T  a)
inlineinherited

将向量缩放为 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 >
NumericVector< T > & libMesh::DistributedVector< T >::operator+= ( const NumericVector< T > &  v)
overridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C140 行定义.

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

141 {
142  libmesh_assert (this->closed());
143  libmesh_assert (this->initialized());
144  libmesh_assert_equal_to (_values.size(), _local_size);
145  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
146 
147  add(1., v);
148 
149  return *this;
150 }
virtual bool closed() const
检查向量是否已经关闭并准备好进行计算。
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual void add(const numeric_index_type i, const T value) override
将 value 添加到由 i 指定的向量条目。 请注意,此方法的库实现是线程安全的, 例如,将在写入向量之前锁定 _numeric_vector_mutex 。
virtual bool initialized() const
检查向量是否已经初始化。
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
NumericVector< T > & libMesh::DistributedVector< T >::operator-= ( const NumericVector< T > &  v)
overridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C155 行定义.

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

156 {
157  libmesh_assert (this->closed());
158  libmesh_assert (this->initialized());
159  libmesh_assert_equal_to (_values.size(), _local_size);
160  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
161 
162  add(-1., v);
163 
164  return *this;
165 }
virtual bool closed() const
检查向量是否已经关闭并准备好进行计算。
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual void add(const numeric_index_type i, const T value) override
将 value 添加到由 i 指定的向量条目。 请注意,此方法的库实现是线程安全的, 例如,将在写入向量之前锁定 _numeric_vector_mutex 。
virtual bool initialized() const
检查向量是否已经初始化。
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
NumericVector< T > & libMesh::DistributedVector< T >::operator/= ( const NumericVector< T > &  v)
overridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C185 行定义.

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

186 {
187  libmesh_assert_equal_to(size(), v.size());
188 
189  const DistributedVector<T> & v_vec = cast_ref<const DistributedVector<T> &>(v);
190 
191  for (auto i : index_range(_values))
192  _values[i] /= v_vec._values[i];
193 
194  return *this;
195 }
virtual numeric_index_type size() const override
获取向量的大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
template<typename T>
NumericVector<T>& libMesh::NumericVector< T >::operator/= ( const T  a)
inlineinherited

将向量缩放为 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 >
DistributedVector< T > & libMesh::DistributedVector< T >::operator= ( const DistributedVector< T > &  v)

复制赋值运算符。我们不能默认实现它(尽管它本质上实现了默认行为), 因为生成的默认版本尝试自动调用基类(NumericVector)的复制赋值运算符, 而选择使其成为纯虚拟函数,出于其他设计原因。

在文件 distributed_vector.C353 行定义.

参考 libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_global_size, libMesh::NumericVector< T >::_is_closed, libMesh::libMeshPrivateData::_is_initialized, libMesh::NumericVector< T >::_is_initialized, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size, libMesh::DistributedVector< T >::_values , 以及 libMesh::DistributedVector< T >::local_size().

354 {
355  this->_is_initialized = v._is_initialized;
356  this->_is_closed = v._is_closed;
357 
358  _global_size = v._global_size;
359  _local_size = v._local_size;
360  _first_local_index = v._first_local_index;
361  _last_local_index = v._last_local_index;
362 
363  if (v.local_size() == this->local_size())
364  _values = v._values;
365 
366  else
367  libmesh_error_msg("v.local_size() = " << v.local_size() << " must be equal to this->local_size() = " << this->local_size());
368 
369  return *this;
370 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
bool _is_initialized
在调用 init() 后设置为 true。
numeric_index_type _global_size
全局向量大小。
virtual numeric_index_type local_size() const override
获取向量的本地大小,即 index_stop - index_start。
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
template<typename T>
DistributedVector& libMesh::DistributedVector< T >::operator= ( DistributedVector< T > &&  )
default
template<typename T >
NumericVector< T > & libMesh::DistributedVector< T >::operator= ( const T  s)
overridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C323 行定义.

参考 libMesh::initialized().

324 {
325  libmesh_assert (this->initialized());
326  libmesh_assert_equal_to (_values.size(), _local_size);
327  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
328 
329  for (auto & val : _values)
330  val = s;
331 
332  return *this;
333 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
NumericVector< T > & libMesh::DistributedVector< T >::operator= ( const NumericVector< T > &  v)
overridevirtual

一个复制赋值运算符

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C339 行定义.

340 {
341  // Make sure the NumericVector passed in is really a DistributedVector
342  const DistributedVector<T> * v = cast_ptr<const DistributedVector<T> *>(&v_in);
343 
344  *this = *v;
345 
346  return *this;
347 }
template<typename T >
NumericVector< T > & libMesh::DistributedVector< T >::operator= ( const std::vector< T > &  v)
overridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C376 行定义.

参考 libMesh::initialized().

377 {
378  libmesh_assert (this->initialized());
379  libmesh_assert_equal_to (_values.size(), _local_size);
380  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
381 
382  if (v.size() == local_size())
383  _values = v;
384 
385  else if (v.size() == size())
386  for (auto i : index_range(*this))
387  _values[i-first_local_index()] = v[i];
388 
389  else
390  libmesh_error_msg("Incompatible sizes in DistributedVector::operator=");
391 
392  return *this;
393 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
virtual numeric_index_type local_size() const override
获取向量的本地大小,即 index_stop - index_start。
virtual numeric_index_type size() const override
获取向量的大小。
numeric_index_type _local_size
本地向量大小。
virtual numeric_index_type first_local_index() const override
获取实际存储在该处理器上的第一个向量元素的索引。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
void libMesh::DistributedVector< T >::pointwise_divide ( const NumericVector< T > &  vec1,
const NumericVector< T > &  vec2 
)
overridevirtual

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

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C623 行定义.

625 {
626  libmesh_not_implemented();
627 }
template<typename T >
void libMesh::DistributedVector< T >::pointwise_mult ( const NumericVector< T > &  vec1,
const NumericVector< T > &  vec2 
)
overridevirtual

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

如果两个向量在给定的全局相对阈值 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::NumericVector< T >.

在文件 distributed_vector.C614 行定义.

618 {
619  libmesh_not_implemented();
620 }
template<typename T >
void libMesh::NumericVector< T >::print ( std::ostream &  os = libMesh::out) const
inlinevirtualinherited

打印本地向量的内容,默认输出到 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
inlineinherited

在文件 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
inlinevirtualinherited

打印全局向量的内容,默认输出到 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
inlineinherited

在文件 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
inlinevirtualinherited

以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
inherited

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

返回
如果向量可以用于全局操作,则返回 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 >
void libMesh::DistributedVector< T >::reciprocal ( )
overridevirtual

计算每个向量条目的分量倒数, $ u_i \leftarrow \frac{1}{u_i} \, \forall i$

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C201 行定义.

202 {
203  for (auto & val : _values)
204  {
205  // Don't divide by zero
206  libmesh_assert_not_equal_to (val, T(0));
207 
208  val = 1. / val;
209  }
210 }
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
template<typename T >
void libMesh::DistributedVector< T >::scale ( const T  factor)
overridevirtual

缩放向量的每个元素。

参数
factor缩放因子。

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C270 行定义.

参考 libMesh::initialized().

271 {
272  libmesh_assert (this->initialized());
273  libmesh_assert_equal_to (_values.size(), _local_size);
274  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
275 
276  for (auto & val : _values)
277  val *= factor;
278 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
void libMesh::DistributedVector< T >::set ( const numeric_index_type  i,
const T  value 
)
inlineoverridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h568 行定义.

参考 libMesh::initialized().

569 {
570  libmesh_assert (this->initialized());
571  libmesh_assert_equal_to (_values.size(), _local_size);
572  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
573  libmesh_assert_less (i, size());
574  libmesh_assert_less (i-first_local_index(), local_size());
575 
576  std::scoped_lock lock(this->_numeric_vector_mutex);
577  _values[i - _first_local_index] = value;
578 
579 
580  this->_is_closed = false;
581 }
std::mutex _numeric_vector_mutex
用于执行线程安全操作的互斥锁。
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
virtual numeric_index_type local_size() const override
获取向量的本地大小,即 index_stop - index_start。
virtual numeric_index_type size() const override
获取向量的大小。
numeric_index_type _local_size
本地向量大小。
virtual numeric_index_type first_local_index() const override
获取实际存储在该处理器上的第一个向量元素的索引。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
template<typename T >
numeric_index_type libMesh::DistributedVector< T >::size ( ) const
inlineoverridevirtual

获取向量的大小。

返回
向量的大小。

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h501 行定义.

参考 libMesh::initialized().

502 {
503  libmesh_assert (this->initialized());
504  libmesh_assert_equal_to (_values.size(), _local_size);
505  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
506 
507  return _global_size;
508 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
numeric_index_type _global_size
全局向量大小。
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<class T >
Real libMesh::NumericVector< T >::subset_l1_norm ( const std::set< numeric_index_type > &  indices) const
virtualinherited

获取指定条目的向量的 $ \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
virtualinherited

获取指定条目的向量的 $ \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
virtualinherited

获取指定条目的向量的最大绝对值,即指定条目的 $ \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 >
T libMesh::DistributedVector< T >::sum ( ) const
overridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.C48 行定义.

参考 libMesh::initialized().

49 {
50  // This function must be run on all processors at once
51  parallel_object_only();
52 
53  libmesh_assert (this->initialized());
54  libmesh_assert_equal_to (_values.size(), _local_size);
55  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
56 
57  T local_sum = 0.;
58 
59  for (auto & val : _values)
60  local_sum += val;
61 
62  this->comm().sum(local_sum);
63 
64  return local_sum;
65 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
void libMesh::DistributedVector< T >::swap ( NumericVector< T > &  v)
inlineoverridevirtual

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

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

重载 libMesh::NumericVector< T > .

在文件 distributed_vector.h650 行定义.

参考 libMesh::DistributedVector< T >::_first_local_index, libMesh::DistributedVector< T >::_global_size, libMesh::DistributedVector< T >::_last_local_index, libMesh::DistributedVector< T >::_local_size , 以及 libMesh::DistributedVector< T >::_values.

651 {
652  DistributedVector<T> & v = cast_ref<DistributedVector<T> &>(other);
653 
654  std::swap(_global_size, v._global_size);
655  std::swap(_local_size, v._local_size);
656  std::swap(_first_local_index, v._first_local_index);
657  std::swap(_last_local_index, v._last_local_index);
658 
659  // This should be O(1) with any reasonable STL implementation
660  std::swap(_values, v._values);
661 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
numeric_index_type _global_size
全局向量大小。
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T>
ParallelType libMesh::NumericVector< T >::type ( ) const
inlineinherited
template<typename T>
ParallelType& libMesh::NumericVector< T >::type ( )
inlineinherited

获取向量的类型。

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

在文件 numeric_vector.h173 行定义.

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

173 { return _type; }
ParallelType _type
向量的类型。
template<typename T >
void libMesh::DistributedVector< T >::zero ( )
inlineoverridevirtual

将所有条目设置为零。等同于 v = 0,但更明显且更快。

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h463 行定义.

参考 libMesh::initialized().

464 {
465  libmesh_assert (this->initialized());
466  libmesh_assert_equal_to (_values.size(), _local_size);
467  libmesh_assert_equal_to ((_last_local_index - _first_local_index), _local_size);
468 
469  std::fill (_values.begin(),
470  _values.end(),
471  0.);
472 }
numeric_index_type _last_local_index
本地存储的最后一个分量(+1)。
virtual bool initialized() const
检查向量是否已经初始化。
numeric_index_type _local_size
本地向量大小。
std::vector< T > _values
实际的向量数据类型,用于保存向量条目。
numeric_index_type _first_local_index
本地存储的第一个分量。
template<typename T >
std::unique_ptr< NumericVector< T > > libMesh::DistributedVector< T >::zero_clone ( ) const
inlineoverridevirtual

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

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

实现了 libMesh::NumericVector< T >.

在文件 distributed_vector.h478 行定义.

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

479 {
480  NumericVector<T> * cloned_vector = new DistributedVector<T>(this->comm());
481  cloned_vector->init(*this);
482  return std::unique_ptr<NumericVector<T>>(cloned_vector);
483 }

类成员变量说明

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>
numeric_index_type libMesh::DistributedVector< T >::_first_local_index
private
template<typename T>
numeric_index_type libMesh::DistributedVector< T >::_global_size
private
template<typename T>
bool libMesh::NumericVector< T >::_is_closed
protectedinherited

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

在文件 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
protectedinherited
template<typename T>
numeric_index_type libMesh::DistributedVector< T >::_last_local_index
private
template<typename T>
numeric_index_type libMesh::DistributedVector< T >::_local_size
private
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
protectedinherited

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

在文件 numeric_vector.h928 行定义.

template<typename T>
ParallelType libMesh::NumericVector< T >::_type
protectedinherited
template<typename T>
std::vector<T> libMesh::DistributedVector< T >::_values
private

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