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

此类提供了对Trilinos Epetra_Vector对象的友好接口。所有重写的虚拟函数在numeric_vector.h中都有文档。 更多...

#include <trilinos_epetra_vector.h>

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

Public 类型

typedef T value_type
 

Public 成员函数

 EpetraVector (const Parallel::Communicator &comm, const ParallelType type=AUTOMATIC)
 构造函数。创建一个维度为0的虚拟矢量。 更多...
 
 EpetraVector (const Parallel::Communicator &comm, const numeric_index_type n, const ParallelType type=AUTOMATIC)
 构造函数。将维度设置为n并初始化所有元素为零。 更多...
 
 EpetraVector (const Parallel::Communicator &comm, const numeric_index_type n, const numeric_index_type n_local, const ParallelType type=AUTOMATIC)
 构造函数。将本地维度设置为n_local,全局维度设置为n,并初始化所有元素为零。 更多...
 
 EpetraVector (const Parallel::Communicator &comm, const numeric_index_type N, const numeric_index_type n_local, const std::vector< numeric_index_type > &ghost, const ParallelType type=AUTOMATIC)
 构造函数。将本地维度设置为n_local,全局维度设置为n,并为ghost参数指定的索引保留内存。 更多...
 
 EpetraVector (Epetra_Vector &v, const Parallel::Communicator &comm)
 构造函数。创建一个EpetraVector,假设您已经有一个有效的Epetra Vec对象。 在这种情况下,v不会在EpetraVector析构函数销毁时被销毁。这允许保留v的所有权在原始创建者手中, 并提供与EpetraVector的附加功能。 更多...
 
 EpetraVector (EpetraVector &&)=delete
 由于此类手动管理Epetra_Vector的生命周期,因此我们不希望生成任何自动生成的复制/移动函数, 并且无法默认生成析构函数。 更多...
 
 EpetraVector (const EpetraVector &)=delete
 
EpetraVectoroperator= (const EpetraVector &)=delete
 
EpetraVectoroperator= (EpetraVector &&)=delete
 
virtual void close () override
 关闭矢量,使其无法再次修改。 更多...
 
virtual void clear () noexceptoverride
 清除矢量,析构函数中会调用此函数,因此不应抛出异常。 更多...
 
virtual void zero () override
 将所有元素置零。 更多...
 
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 type=AUTOMATIC) override
 初始化矢量。 更多...
 
virtual void init (const numeric_index_type N, const bool fast=false, const ParallelType type=AUTOMATIC) override
 初始化矢量。 更多...
 
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
 初始化矢量。 更多...
 
virtual void init (const NumericVector< T > &other, const bool fast=false) override
 初始化矢量,使用其他矢量进行初始化。 更多...
 
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
 从std::vector复制元素。 更多...
 
virtual Real min () const override
 获取矢量中的最小值。 更多...
 
virtual Real max () const override
 获取矢量中的最大值。 更多...
 
virtual T sum () const override
 计算矢量中所有元素的总和。 更多...
 
virtual Real l1_norm () const override
 计算矢量的L1范数。 更多...
 
virtual Real l2_norm () const override
 计算矢量的L2范数。 更多...
 
virtual Real linfty_norm () const override
 计算矢量的L∞范数。 更多...
 
virtual numeric_index_type size () const override
 获取矢量的全局大小。 更多...
 
virtual numeric_index_type local_size () const override
 获取矢量的本地大小。 更多...
 
virtual numeric_index_type first_local_index () const override
 获取矢量的第一个本地索引。 更多...
 
virtual numeric_index_type last_local_index () const override
 获取矢量的最后一个本地索引。 更多...
 
virtual T operator() (const numeric_index_type i) const override
 获取矢量中索引i处的值。 更多...
 
virtual NumericVector< T > & operator+= (const NumericVector< T > &v) override
 将矢量与另一个矢量相加并将结果存储在当前矢量中。 更多...
 
virtual NumericVector< T > & operator-= (const NumericVector< T > &v) override
 将矢量与另一个矢量相减并将结果存储在当前矢量中。 更多...
 
virtual NumericVector< T > & operator*= (const NumericVector< T > &v) override
 将矢量与另一个矢量逐元素相乘并将结果存储在当前矢量中。 更多...
 
virtual NumericVector< T > & operator/= (const NumericVector< T > &v) override
 将矢量与另一个矢量逐元素相除并将结果存储在当前矢量中。 更多...
 
virtual void reciprocal () override
 计算当前矢量的逐元素倒数。 更多...
 
virtual void conjugate () override
 计算当前矢量的逐元素共轭。 更多...
 
virtual void set (const numeric_index_type i, const T value) override
 设置索引i处的值为value。 更多...
 
virtual void add (const numeric_index_type i, const T value) override
 将索引i处的值增加value。 更多...
 
virtual void add (const T s) override
 将矢量中的所有元素增加s。 更多...
 
virtual void add (const NumericVector< T > &v) override
 将矢量与另一个矢量相加并将结果存储在当前矢量中。 更多...
 
virtual void add (const T a, const NumericVector< T > &v) override
 将矢量与另一个矢量的逐元素乘积与标量a相加并将结果存储在当前矢量中。 更多...
 
virtual void add_vector (const T *v, const std::vector< numeric_index_type > &dof_indices) override
 使用特定的自由度索引添加一个值数组到当前矢量中。 更多...
 
virtual void add_vector (const NumericVector< T > &v, const SparseMatrix< T > &A) override
 使用稀疏矩阵A的乘积将另一个矢量v添加到当前矢量中。 更多...
 
virtual void add_vector_transpose (const NumericVector< T > &v, const SparseMatrix< T > &A) override
 使用稀疏矩阵A的转置乘积将另一个矢量v添加到当前矢量中。 更多...
 
virtual void insert (const T *v, const std::vector< numeric_index_type > &dof_indices) override
 使用特定的自由度索引将一个值数组插入到当前矢量中。 更多...
 
virtual void scale (const T factor) override
 缩放矢量的所有元素。 更多...
 
virtual void abs () override
 计算矢量的绝对值。 更多...
 
virtual T dot (const NumericVector< T > &v) const override
 计算当前矢量与另一个矢量的点积。 更多...
 
virtual void localize (std::vector< T > &v_local) const override
 将当前矢量的值本地化到一个本地矢量中。 更多...
 
virtual void localize (NumericVector< T > &v_local) const override
 将当前矢量的值本地化到另一个矢量的相应位置。 更多...
 
virtual void localize (NumericVector< T > &v_local, const std::vector< numeric_index_type > &send_list) const override
 将当前矢量的部分值本地化到另一个矢量的相应位置。 更多...
 
virtual void localize (std::vector< T > &v_local, const std::vector< numeric_index_type > &indices) const override
 将当前矢量的部分值本地化到本地矢量的相应位置。 更多...
 
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
 将指定范围内的部分值本地化到另一个矢量的相应位置。 更多...
 
virtual void localize_to_one (std::vector< T > &v_local, const processor_id_type proc_id=0) const override
 将所有值本地化到一个本地矢量中,仅保留一个处理器上的值。 更多...
 
virtual void pointwise_mult (const NumericVector< T > &vec1, const NumericVector< T > &vec2) override
 计算当前矢量与另一个矢量的逐元素乘积。 更多...
 
virtual void create_subvector (NumericVector< T > &subvector, const std::vector< numeric_index_type > &rows) const override
 创建当前矢量的子矢量,包含指定行的值。 更多...
 
virtual void swap (NumericVector< T > &v) override
 交换当前矢量与另一个矢量的值。 更多...
 
virtual std::size_t max_allowed_id () const override
 获取允许的最大ID大小。 更多...
 
Epetra_Vector * vec ()
 返回原始的 Epetra_Vector 指针。 更多...
 
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. 更多...
 
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。 更多...
 
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 pointwise_divide (const NumericVector< T > &vec1, const NumericVector< T > &vec2)=0
 计算该向量与另一个向量的逐点除法。 更多...
 
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,则内容将被打印到屏幕上。 更多...
 
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 成员函数

int SumIntoGlobalValues (int numIDs, const int *GIDs, const double *values)
 将值累积到向量中,将它们添加到指定索引已存在的任何值中。 更多...
 
int SumIntoGlobalValues (const Epetra_IntSerialDenseVector &GIDs, const Epetra_SerialDenseVector &values)
 将值累积到向量中,将它们添加到指定 GID 已存在的任何值中。 更多...
 
int ReplaceGlobalValues (int numIDs, const int *GIDs, const double *values)
 将值复制到向量中,覆盖指定索引已存在的任何值。 更多...
 
int ReplaceGlobalValues (const Epetra_IntSerialDenseVector &GIDs, const Epetra_SerialDenseVector &values)
 将值复制到向量中,替换指定 GID 已存在的任何值。 更多...
 
int SumIntoGlobalValues (int numIDs, const int *GIDs, const int *numValuesPerID, const double *values)
 将值累积到向量中,将它们添加到指定索引已存在的任何值中。 更多...
 
int ReplaceGlobalValues (int numIDs, const int *GIDs, const int *numValuesPerID, const double *values)
 将值复制到向量中,替换指定索引已存在的任何值。 更多...
 
int GlobalAssemble (Epetra_CombineMode mode=Add)
 将所有重叠/共享数据收集到由 Map 在构造函数中传递给该向量定义的非重叠分区中。 从其他处理器导入的数据以“sumInto”或累积操作存储在拥有处理器上。这是一种集体方法, 每个处理器在任何处理器完成它之前都必须进入它。 更多...
 
void setIgnoreNonLocalEntries (bool flag)
 设置是否应忽略非本地数据值。 更多...
 
void FEoperatorequals (const EpetraVector &source)
 从另一个 EpetraVector 对象中复制操作符。 更多...
 
int inputValues (int numIDs, const int *GIDs, const double *values, bool accumulate)
 输入值到向量中,覆盖或累积到指定索引的已存在的任何值。 更多...
 
int inputValues (int numIDs, const int *GIDs, const int *numValuesPerID, const double *values, bool accumulate)
 输入值到向量中,替换或累积到指定全局 ID 的已存在的任何值。 更多...
 
int inputNonlocalValue (int GID, double value, bool accumulate)
 输入非本地值到向量中,覆盖或累积到指定 GID 的已存在的任何值。 更多...
 
int inputNonlocalValues (int GID, int numValues, const double *values, bool accumulate)
 输入非本地值到向量中,覆盖或累积到指定 GID 的已存在的任何值。 更多...
 
void destroyNonlocalData ()
 销毁非本地数据。 更多...
 

Private 属性

Epetra_Vector * _vec
 用于保存向量条目的实际 Epetra 向量数据类型。 更多...
 
std::unique_ptr< Epetra_Map > _map
 持有分布式映射。 更多...
 
bool _destroy_vec_on_exit
 此布尔值只应在接受 Epetra Vec 对象的构造函数中设置为 false。 更多...
 
int myFirstID_
 保存向量的第一个全局 ID。 更多...
 
int myNumIDs_
 保存向量的全局 ID 数量。 更多...
 
double * myCoefs_
 保存系数的指针数组。 更多...
 
int * nonlocalIDs_
 非本地 ID 数组。 更多...
 
int * nonlocalElementSize_
 非本地元素大小数组。 更多...
 
int numNonlocalIDs_
 非本地 ID 数量。 更多...
 
int allocatedNonlocalLength_
 已分配的非本地长度。 更多...
 
double ** nonlocalCoefs_
 非本地系数的指针数组。 更多...
 
unsigned char last_edit
 跟踪上次对此向量的写入操作是“无”(0)还是“累积”(1)还是“添加”(2), 以便我们可以决定如何进行 GlobalAssemble()更多...
 
bool ignoreNonLocalEntries_
 是否忽略非本地数据值。 更多...
 

详细描述

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

此类提供了对Trilinos Epetra_Vector对象的友好接口。所有重写的虚拟函数在numeric_vector.h中都有文档。

作者
Derek R. Gaston
日期
2008

在文件 trilinos_epetra_vector.h63 行定义.

成员类型定义说明

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>
typedef T libMesh::EpetraVector< T >::value_type

在文件 trilinos_epetra_vector.h66 行定义.

构造及析构函数说明

template<typename T >
libMesh::EpetraVector< T >::EpetraVector ( const Parallel::Communicator &  comm,
const ParallelType  type = AUTOMATIC 
)
inlineexplicit

构造函数。创建一个维度为0的虚拟矢量。

参数
comm通信器
type并行类型(默认为AUTOMATIC)

在文件 trilinos_epetra_vector.h804 行定义.

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

805  :
806  NumericVector<T>(comm, type),
807  _destroy_vec_on_exit(true),
808  myFirstID_(0),
809  myNumIDs_(0),
810  myCoefs_(nullptr),
811  nonlocalIDs_(nullptr),
812  nonlocalElementSize_(nullptr),
813  numNonlocalIDs_(0),
815  nonlocalCoefs_(nullptr),
816  last_edit(0),
818 {
819  this->_type = type;
820 }
double ** nonlocalCoefs_
非本地系数的指针数组。
int myFirstID_
保存向量的第一个全局 ID。
int allocatedNonlocalLength_
已分配的非本地长度。
double * myCoefs_
保存系数的指针数组。
int myNumIDs_
保存向量的全局 ID 数量。
int * nonlocalElementSize_
非本地元素大小数组。
bool _destroy_vec_on_exit
此布尔值只应在接受 Epetra Vec 对象的构造函数中设置为 false。
unsigned char last_edit
跟踪上次对此向量的写入操作是“无”(0)还是“累积”(1)还是“添加”(2), 以便我们可以决定如何进行 GlobalAssemble()。
int * nonlocalIDs_
非本地 ID 数组。
bool ignoreNonLocalEntries_
是否忽略非本地数据值。
ParallelType _type
向量的类型。
int numNonlocalIDs_
非本地 ID 数量。
ParallelType type() const
获取向量的类型。
template<typename T >
libMesh::EpetraVector< T >::EpetraVector ( const Parallel::Communicator &  comm,
const numeric_index_type  n,
const ParallelType  type = AUTOMATIC 
)
inlineexplicit

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

参数
comm通信器
n全局维度
type并行类型(默认为AUTOMATIC)

在文件 trilinos_epetra_vector.h826 行定义.

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

828  :
829  NumericVector<T>(comm, type),
830  _destroy_vec_on_exit(true),
831  myFirstID_(0),
832  myNumIDs_(0),
833  myCoefs_(nullptr),
834  nonlocalIDs_(nullptr),
835  nonlocalElementSize_(nullptr),
836  numNonlocalIDs_(0),
838  nonlocalCoefs_(nullptr),
839  last_edit(0),
841 
842 {
843  this->init(n, n, false, type);
844 }
double ** nonlocalCoefs_
非本地系数的指针数组。
int myFirstID_
保存向量的第一个全局 ID。
int allocatedNonlocalLength_
已分配的非本地长度。
double * myCoefs_
保存系数的指针数组。
int myNumIDs_
保存向量的全局 ID 数量。
int * nonlocalElementSize_
非本地元素大小数组。
bool _destroy_vec_on_exit
此布尔值只应在接受 Epetra Vec 对象的构造函数中设置为 false。
unsigned char last_edit
跟踪上次对此向量的写入操作是“无”(0)还是“累积”(1)还是“添加”(2), 以便我们可以决定如何进行 GlobalAssemble()。
int * nonlocalIDs_
非本地 ID 数组。
bool ignoreNonLocalEntries_
是否忽略非本地数据值。
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType type=AUTOMATIC) override
初始化矢量。
int numNonlocalIDs_
非本地 ID 数量。
ParallelType type() const
获取向量的类型。
template<typename T >
libMesh::EpetraVector< T >::EpetraVector ( const Parallel::Communicator &  comm,
const numeric_index_type  n,
const numeric_index_type  n_local,
const ParallelType  type = AUTOMATIC 
)
inline

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

参数
comm通信器
n全局维度
n_local本地维度
type并行类型(默认为AUTOMATIC)

在文件 trilinos_epetra_vector.h850 行定义.

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

853  :
854  NumericVector<T>(comm, type),
855  _destroy_vec_on_exit(true),
856  myFirstID_(0),
857  myNumIDs_(0),
858  myCoefs_(nullptr),
859  nonlocalIDs_(nullptr),
860  nonlocalElementSize_(nullptr),
861  numNonlocalIDs_(0),
863  nonlocalCoefs_(nullptr),
864  last_edit(0),
866 {
867  this->init(n, n_local, false, type);
868 }
double ** nonlocalCoefs_
非本地系数的指针数组。
int myFirstID_
保存向量的第一个全局 ID。
int allocatedNonlocalLength_
已分配的非本地长度。
double * myCoefs_
保存系数的指针数组。
int myNumIDs_
保存向量的全局 ID 数量。
int * nonlocalElementSize_
非本地元素大小数组。
bool _destroy_vec_on_exit
此布尔值只应在接受 Epetra Vec 对象的构造函数中设置为 false。
unsigned char last_edit
跟踪上次对此向量的写入操作是“无”(0)还是“累积”(1)还是“添加”(2), 以便我们可以决定如何进行 GlobalAssemble()。
int * nonlocalIDs_
非本地 ID 数组。
bool ignoreNonLocalEntries_
是否忽略非本地数据值。
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType type=AUTOMATIC) override
初始化矢量。
int numNonlocalIDs_
非本地 ID 数量。
ParallelType type() const
获取向量的类型。
template<typename T >
libMesh::EpetraVector< T >::EpetraVector ( const Parallel::Communicator &  comm,
const numeric_index_type  N,
const numeric_index_type  n_local,
const std::vector< numeric_index_type > &  ghost,
const ParallelType  type = AUTOMATIC 
)
inline

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

参数
comm通信器
N全局维度
n_local本地维度
ghost需要保留内存的索引
type并行类型(默认为AUTOMATIC)

在文件 trilinos_epetra_vector.h916 行定义.

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

920  :
921  NumericVector<T>(comm, AUTOMATIC),
922  _destroy_vec_on_exit(true),
923  myFirstID_(0),
924  myNumIDs_(0),
925  myCoefs_(nullptr),
926  nonlocalIDs_(nullptr),
927  nonlocalElementSize_(nullptr),
928  numNonlocalIDs_(0),
930  nonlocalCoefs_(nullptr),
931  last_edit(0),
933 {
934  this->init(n, n_local, ghost, false, type);
935 }
double ** nonlocalCoefs_
非本地系数的指针数组。
int myFirstID_
保存向量的第一个全局 ID。
int allocatedNonlocalLength_
已分配的非本地长度。
double * myCoefs_
保存系数的指针数组。
int myNumIDs_
保存向量的全局 ID 数量。
int * nonlocalElementSize_
非本地元素大小数组。
bool _destroy_vec_on_exit
此布尔值只应在接受 Epetra Vec 对象的构造函数中设置为 false。
unsigned char last_edit
跟踪上次对此向量的写入操作是“无”(0)还是“累积”(1)还是“添加”(2), 以便我们可以决定如何进行 GlobalAssemble()。
int * nonlocalIDs_
非本地 ID 数组。
bool ignoreNonLocalEntries_
是否忽略非本地数据值。
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType type=AUTOMATIC) override
初始化矢量。
int numNonlocalIDs_
非本地 ID 数量。
ParallelType type() const
获取向量的类型。
template<typename T >
libMesh::EpetraVector< T >::EpetraVector ( Epetra_Vector &  v,
const Parallel::Communicator &  comm 
)
inline

构造函数。创建一个EpetraVector,假设您已经有一个有效的Epetra Vec对象。 在这种情况下,v不会在EpetraVector析构函数销毁时被销毁。这允许保留v的所有权在原始创建者手中, 并提供与EpetraVector的附加功能。

参数
v指向现有Epetra_Vector对象的引用
comm通信器

在文件 trilinos_epetra_vector.h875 行定义.

参考 libMesh::NumericVector< T >::_is_closed, libMesh::NumericVector< T >::_is_initialized, libMesh::EpetraVector< T >::_map, libMesh::NumericVector< T >::_type, libMesh::EpetraVector< T >::_vec, libMesh::EpetraVector< T >::myCoefs_, libMesh::EpetraVector< T >::myFirstID_ , 以及 libMesh::EpetraVector< T >::myNumIDs_.

876  :
877  NumericVector<T>(comm, AUTOMATIC),
878  _destroy_vec_on_exit(false),
879  myFirstID_(0),
880  myNumIDs_(0),
881  myCoefs_(nullptr),
882  nonlocalIDs_(nullptr),
883  nonlocalElementSize_(nullptr),
884  numNonlocalIDs_(0),
886  nonlocalCoefs_(nullptr),
887  last_edit(0),
889 {
890  _vec = &v;
891 
892  this->_type = PARALLEL; // FIXME - need to determine this from v!
893 
894  myFirstID_ = _vec->Map().MinMyGID();
895  myNumIDs_ = _vec->Map().NumMyElements();
896 
897  _map = std::make_unique<Epetra_Map>
898  (_vec->GlobalLength(),
899  _vec->MyLength(),
900  0, // IndexBase = 0 for C/C++, 1 for Fortran.
901  Epetra_MpiComm (this->comm().get()));
902 
903  // 目前施加NumVectors==1的限制,所以在调用ExtractView时不需要LDA参数。
904  // 因此才有了“dummy”这个词。
905  int dummy;
906  _vec->ExtractView(&myCoefs_, &dummy);
907 
908  this->_is_closed = true;
909  this->_is_initialized = true;
910 }
double ** nonlocalCoefs_
非本地系数的指针数组。
int myFirstID_
保存向量的第一个全局 ID。
std::unique_ptr< Epetra_Map > _map
持有分布式映射。
int allocatedNonlocalLength_
已分配的非本地长度。
double * myCoefs_
保存系数的指针数组。
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
int myNumIDs_
保存向量的全局 ID 数量。
bool _is_initialized
在调用 init() 后设置为 true。
int * nonlocalElementSize_
非本地元素大小数组。
bool _destroy_vec_on_exit
此布尔值只应在接受 Epetra Vec 对象的构造函数中设置为 false。
unsigned char last_edit
跟踪上次对此向量的写入操作是“无”(0)还是“累积”(1)还是“添加”(2), 以便我们可以决定如何进行 GlobalAssemble()。
int * nonlocalIDs_
非本地 ID 数组。
bool ignoreNonLocalEntries_
是否忽略非本地数据值。
ParallelType _type
向量的类型。
int numNonlocalIDs_
非本地 ID 数量。
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
template<typename T>
libMesh::EpetraVector< T >::EpetraVector ( EpetraVector< T > &&  )
delete

由于此类手动管理Epetra_Vector的生命周期,因此我们不希望生成任何自动生成的复制/移动函数, 并且无法默认生成析构函数。

template<typename T>
libMesh::EpetraVector< T >::EpetraVector ( const EpetraVector< T > &  )
delete

成员函数说明

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

计算矢量的绝对值。

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C325 行定义.

326 {
327  _vec->Abs(*_vec);
328 }
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
template<typename T >
void libMesh::EpetraVector< T >::add ( const numeric_index_type  i,
const T  value 
)
overridevirtual

将索引i处的值增加value。

参数
i索引
value要增加的值

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C214 行定义.

215 {
216  int i = static_cast<int> (i_in);
217  T value = value_in;
218 
219  libmesh_assert_less (i_in, this->size());
220 
221  std::scoped_lock lock(this->_numeric_vector_mutex);
222  SumIntoGlobalValues(1, &i, &value);
223 
224  this->_is_closed = false;
225 }
std::mutex _numeric_vector_mutex
用于执行线程安全操作的互斥锁。
virtual numeric_index_type size() const override
获取矢量的全局大小。
int SumIntoGlobalValues(int numIDs, const int *GIDs, const double *values)
将值累积到向量中,将它们添加到指定索引已存在的任何值中。
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
template<typename T >
void libMesh::EpetraVector< T >::add ( const T  s)
overridevirtual

将矢量中的所有元素增加s。

参数
s要增加的值

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C271 行定义.

272 {
273  const unsigned int nl = _vec->MyLength();
274 
275  T * values = _vec->Values();
276 
277  for (unsigned int i=0; i<nl; i++)
278  values[i]+=v_in;
279 
280  this->_is_closed = false;
281 }
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
template<typename T >
void libMesh::EpetraVector< T >::add ( const NumericVector< T > &  v)
overridevirtual

将矢量与另一个矢量相加并将结果存储在当前矢量中。

参数
v另一个矢量

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C285 行定义.

286 {
287  this->add (1., v);
288 }
virtual void add(const numeric_index_type i, const T value) override
将索引i处的值增加value。
template<typename T >
void libMesh::EpetraVector< T >::add ( const T  a,
const NumericVector< T > &  v 
)
overridevirtual

将矢量与另一个矢量的逐元素乘积与标量a相加并将结果存储在当前矢量中。

参数
a标量
v另一个矢量

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C292 行定义.

参考 libMesh::EpetraVector< T >::_vec , 以及 libMesh::EpetraVector< T >::size().

293 {
294  const EpetraVector<T> * v = cast_ptr<const EpetraVector<T> *>(&v_in);
295 
296  libmesh_assert_equal_to (this->size(), v->size());
297 
298  _vec->Update(a_in,*v->_vec, 1.);
299 }
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
virtual numeric_index_type size() const override
获取矢量的全局大小。
template<typename T >
void libMesh::EpetraVector< T >::add_vector ( const T *  v,
const std::vector< numeric_index_type > &  dof_indices 
)
overridevirtual

使用特定的自由度索引添加一个值数组到当前矢量中。

参数
v值数组
dof_indices自由度索引

重载 libMesh::NumericVector< T > .

在文件 trilinos_epetra_vector.C230 行定义.

参考 libMesh::numeric_trilinos_cast().

232 {
233  libmesh_assert_equal_to (sizeof(numeric_index_type), sizeof(int));
234 
235  std::scoped_lock lock(this->_numeric_vector_mutex);
236  SumIntoGlobalValues (cast_int<numeric_index_type>(dof_indices.size()),
237  numeric_trilinos_cast(dof_indices.data()),
238  const_cast<T *>(v));
239 }
std::mutex _numeric_vector_mutex
用于执行线程安全操作的互斥锁。
dof_id_type numeric_index_type
Definition: id_types.h:99
int SumIntoGlobalValues(int numIDs, const int *GIDs, const double *values)
将值累积到向量中,将它们添加到指定索引已存在的任何值中。
int * numeric_trilinos_cast(const numeric_index_type *p)
template<typename T >
void libMesh::EpetraVector< T >::add_vector ( const NumericVector< T > &  v,
const SparseMatrix< T > &  A 
)
overridevirtual

使用稀疏矩阵A的乘积将另一个矢量v添加到当前矢量中。

参数
v另一个矢量
A稀疏矩阵A

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C245 行定义.

参考 libMesh::EpetraVector< T >::_vec , 以及 libMesh::EpetraVector< T >::zero_clone().

247 {
248  const EpetraVector<T> * v = cast_ptr<const EpetraVector<T> *>(&v_in);
249  const EpetraMatrix<T> * A = cast_ptr<const EpetraMatrix<T> *>(&A_in);
250 
251  // FIXME - does Trilinos let us do this *without* memory allocation?
252  std::unique_ptr<NumericVector<T>> temp = v->zero_clone();
253  EpetraVector<T> * temp_v = cast_ptr<EpetraVector<T> *>(temp.get());
254  A->mat()->Multiply(false, *v->_vec, *temp_v->_vec);
255  *this += *temp;
256 }
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 >
void libMesh::EpetraVector< T >::add_vector_transpose ( const NumericVector< T > &  v,
const SparseMatrix< T > &  A 
)
overridevirtual

使用稀疏矩阵A的转置乘积将另一个矢量v添加到当前矢量中。

参数
v另一个矢量
A稀疏矩阵A

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C262 行定义.

264 {
265  libmesh_not_implemented();
266 }
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::EpetraVector< T >::clear ( )
inlineoverridevirtualnoexcept

清除矢量,析构函数中会调用此函数,因此不应抛出异常。

重载 libMesh::NumericVector< T > .

在文件 trilinos_epetra_vector.h1065 行定义.

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

1066 {
1067  if (this->initialized())
1068  {
1069  // We might just be an interface to a user-provided _vec
1070  if (this->_destroy_vec_on_exit)
1071  {
1072  delete _vec;
1073  _vec = nullptr;
1074  }
1075 
1076  // But we currently always own our own _map
1077  _map.reset();
1078  }
1079 
1080  this->_is_closed = this->_is_initialized = false;
1081 }
std::unique_ptr< Epetra_Map > _map
持有分布式映射。
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
bool _is_initialized
在调用 init() 后设置为 true。
virtual bool initialized() const
检查向量是否已经初始化。
bool _destroy_vec_on_exit
此布尔值只应在接受 Epetra Vec 对象的构造函数中设置为 false。
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
template<typename T >
std::unique_ptr< NumericVector< T > > libMesh::EpetraVector< T >::clone ( ) const
inlineoverridevirtual

创建矢量克隆。

返回
矢量克隆的唯一指针

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.h1110 行定义.

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

1111 {
1112  NumericVector<T> * cloned_vector = new EpetraVector<T>(this->comm(), AUTOMATIC);
1113  cloned_vector->init(*this, true);
1114  *cloned_vector = *this;
1115  return std::unique_ptr<NumericVector<T>>(cloned_vector);
1116 }
template<typename T >
void libMesh::EpetraVector< T >::close ( )
inlineoverridevirtual

关闭矢量,使其无法再次修改。

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.h1041 行定义.

参考 libMesh::initialized().

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

1042 {
1043  libmesh_assert (this->initialized());
1044 
1045  // Are we adding or inserting?
1046  unsigned char global_last_edit = last_edit;
1047  this->comm().max(global_last_edit);
1048  libmesh_assert(!last_edit || last_edit == global_last_edit);
1049 
1050  if (global_last_edit == 1)
1051  this->GlobalAssemble(Insert);
1052  else if (global_last_edit == 2)
1053  this->GlobalAssemble(Add);
1054  else
1055  libmesh_assert(!global_last_edit);
1056 
1057  this->_is_closed = true;
1058  this->last_edit = 0;
1059 }
virtual bool initialized() const
检查向量是否已经初始化。
int GlobalAssemble(Epetra_CombineMode mode=Add)
将所有重叠/共享数据收集到由 Map 在构造函数中传递给该向量定义的非重叠分区中。 从其他处理器导入的数据以“sumInto”或累积操作存储在拥有处理器上。这是一种集体方法, 每个处理器在任何处理器完成...
unsigned char last_edit
跟踪上次对此向量的写入操作是“无”(0)还是“累积”(1)还是“添加”(2), 以便我们可以决定如何进行 GlobalAssemble()。
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::EpetraVector< T >::conjugate ( )
overridevirtual

计算当前矢量的逐元素共轭。

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C206 行定义.

207 {
208  // EPetra is real, rendering this a no-op.
209 }
template<typename T >
void libMesh::EpetraVector< T >::create_subvector ( NumericVector< T > &  subvector,
const std::vector< numeric_index_type > &  rows 
) const
overridevirtual

创建当前矢量的子矢量,包含指定行的值。

参数
subvector子矢量
rows指定行的索引列表

重载 libMesh::NumericVector< T > .

在文件 trilinos_epetra_vector.C581 行定义.

583 {
584  libmesh_not_implemented();
585 }
template<typename T >
void libMesh::EpetraVector< T >::destroyNonlocalData ( )
private

销毁非本地数据。

在文件 trilinos_epetra_vector.C915 行定义.

916 {
917  if (allocatedNonlocalLength_ > 0) {
918  delete [] nonlocalIDs_;
919  delete [] nonlocalElementSize_;
920  nonlocalIDs_ = nullptr;
921  nonlocalElementSize_ = nullptr;
922  for (int i=0; i<numNonlocalIDs_; ++i) {
923  delete [] nonlocalCoefs_[i];
924  }
925  delete [] nonlocalCoefs_;
926  nonlocalCoefs_ = nullptr;
927  numNonlocalIDs_ = 0;
929  }
930  return;
931 }
double ** nonlocalCoefs_
非本地系数的指针数组。
int allocatedNonlocalLength_
已分配的非本地长度。
int * nonlocalElementSize_
非本地元素大小数组。
int * nonlocalIDs_
非本地 ID 数组。
int numNonlocalIDs_
非本地 ID 数量。
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::EpetraVector< T >::dot ( const NumericVector< T > &  v) const
overridevirtual

计算当前矢量与另一个矢量的点积。

参数
v另一个矢量
返回
点积结果

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C332 行定义.

参考 libMesh::EpetraVector< T >::_vec.

333 {
334  const EpetraVector<T> * v = cast_ptr<const EpetraVector<T> *>(&v_in);
335 
336  T result=0.0;
337 
338  _vec->Dot(*v->_vec, &result);
339 
340  return result;
341 }
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
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 >
void libMesh::EpetraVector< T >::FEoperatorequals ( const EpetraVector< T > &  source)
private

从另一个 EpetraVector 对象中复制操作符。

参数
sourceEpetraVector 对象。

在文件 trilinos_epetra_vector.C887 行定义.

参考 libMesh::EpetraVector< T >::_vec, libMesh::EpetraVector< T >::allocatedNonlocalLength_, libMesh::EpetraVector< T >::nonlocalCoefs_, libMesh::EpetraVector< T >::nonlocalElementSize_, libMesh::EpetraVector< T >::nonlocalIDs_ , 以及 libMesh::EpetraVector< T >::numNonlocalIDs_.

888 {
889  (*_vec) = *(source._vec);
890 
892 
893  if (source.allocatedNonlocalLength_ > 0) {
894  allocatedNonlocalLength_ = source.allocatedNonlocalLength_;
895  numNonlocalIDs_ = source.numNonlocalIDs_;
899  for (int i=0; i<numNonlocalIDs_; ++i) {
900  int elemSize = source.nonlocalElementSize_[i];
901  nonlocalCoefs_[i] = new double[elemSize];
902  nonlocalIDs_[i] = source.nonlocalIDs_[i];
903  nonlocalElementSize_[i] = elemSize;
904  for (int j=0; j<elemSize; ++j) {
905  nonlocalCoefs_[i][j] = source.nonlocalCoefs_[i][j];
906  }
907  }
908  }
909 }
double ** nonlocalCoefs_
非本地系数的指针数组。
int allocatedNonlocalLength_
已分配的非本地长度。
int * nonlocalElementSize_
非本地元素大小数组。
int * nonlocalIDs_
非本地 ID 数组。
void destroyNonlocalData()
销毁非本地数据。
int numNonlocalIDs_
非本地 ID 数量。
template<typename T >
numeric_index_type libMesh::EpetraVector< T >::first_local_index ( ) const
inlineoverridevirtual

获取矢量的第一个本地索引。

返回
第一个本地索引

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.h1142 行定义.

参考 libMesh::initialized().

1143 {
1144  libmesh_assert (this->initialized());
1145 
1146  return _vec->Map().MinMyGID();
1147 }
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
virtual bool initialized() const
检查向量是否已经初始化。
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.
template<typename T >
int libMesh::EpetraVector< T >::GlobalAssemble ( Epetra_CombineMode  mode = Add)
private

将所有重叠/共享数据收集到由 Map 在构造函数中传递给该向量定义的非重叠分区中。 从其他处理器导入的数据以“sumInto”或累积操作存储在拥有处理器上。这是一种集体方法, 每个处理器在任何处理器完成它之前都必须进入它。

参数
mode聚合模式(默认为 Add)。
返回
操作的结果代码。

在文件 trilinos_epetra_vector.C841 行定义.

842 {
843  //In this method we need to gather all the non-local (overlapping) data
844  //that's been input on each processor, into the (probably) non-overlapping
845  //distribution defined by the map that 'this' vector was constructed with.
846 
847  //We don't need to do anything if there's only one processor or if
848  //ignoreNonLocalEntries_ is true.
849  if (_vec->Map().Comm().NumProc() < 2 || ignoreNonLocalEntries_) {
850  return(0);
851  }
852 
853 
854 
855  //First build a map that describes the data in nonlocalIDs_/nonlocalCoefs_.
856  //We'll use the arbitrary distribution constructor of Map.
857 
858  Epetra_BlockMap sourceMap(-1, numNonlocalIDs_,
860  _vec->Map().IndexBase(), _vec->Map().Comm());
861 
862  //Now build a vector to hold our nonlocalCoefs_, and to act as the source-
863  //vector for our import operation.
864  Epetra_MultiVector nonlocalVector(sourceMap, 1);
865 
866  int i,j;
867  for (i=0; i<numNonlocalIDs_; ++i) {
868  for (j=0; j<nonlocalElementSize_[i]; ++j) {
869  nonlocalVector.ReplaceGlobalValue(nonlocalIDs_[i], j, 0,
870  nonlocalCoefs_[i][j]);
871  }
872  }
873 
874  Epetra_Export exporter(sourceMap, _vec->Map());
875 
876  EPETRA_CHK_ERR( _vec->Export(nonlocalVector, exporter, mode) );
877 
879 
880  return(0);
881 }
double ** nonlocalCoefs_
非本地系数的指针数组。
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
int * nonlocalElementSize_
非本地元素大小数组。
int * nonlocalIDs_
非本地 ID 数组。
bool ignoreNonLocalEntries_
是否忽略非本地数据值。
void destroyNonlocalData()
销毁非本地数据。
int numNonlocalIDs_
非本地 ID 数量。
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::EpetraVector< T >::init ( const numeric_index_type  N,
const numeric_index_type  n_local,
const bool  fast = false,
const ParallelType  type = AUTOMATIC 
)
inlineoverridevirtual

初始化矢量。

参数
N全局维度
n_local本地维度
fast是否启用快速初始化
type并行类型(默认为AUTOMATIC)

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.h960 行定义.

参考 libMesh::libMeshPrivateData::_is_initialized , 以及 libMesh::zero.

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

964 {
965  // We default to allocating n_local local storage
966  numeric_index_type my_n_local = n_local;
967 
968  if (type == AUTOMATIC)
969  {
970  if (n == n_local)
971  this->_type = SERIAL;
972  else
973  this->_type = PARALLEL;
974  }
975  else if (type == GHOSTED)
976  {
977  // We don't yet support GHOSTED Epetra vectors, so to get the
978  // same functionality we need a SERIAL vector with local
979  // storage allocated for every entry.
980  this->_type = SERIAL;
981  my_n_local = n;
982  }
983  else
984  this->_type = type;
985 
986  libmesh_assert ((this->_type==SERIAL && n==my_n_local) ||
987  this->_type==PARALLEL);
988 
989  _map = std::make_unique<Epetra_Map>
990  (static_cast<int>(n),
991  my_n_local,
992  0,
993  Epetra_MpiComm (this->comm().get()));
994 
995  _vec = new Epetra_Vector(*_map);
996 
997  myFirstID_ = _vec->Map().MinMyGID();
998  myNumIDs_ = _vec->Map().NumMyElements();
999 
1000  // Currently we impose the restriction that NumVectors==1, so we won't
1001  // need the LDA argument when calling ExtractView. Hence the "dummy" arg.
1002  int dummy;
1003  _vec->ExtractView(&myCoefs_, &dummy);
1004 
1005  this->_is_initialized = true;
1006  this->_is_closed = true;
1007  this->last_edit = 0;
1008 
1009  if (fast == false)
1010  this->zero ();
1011 }
int myFirstID_
保存向量的第一个全局 ID。
std::unique_ptr< Epetra_Map > _map
持有分布式映射。
double * myCoefs_
保存系数的指针数组。
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
int myNumIDs_
保存向量的全局 ID 数量。
bool _is_initialized
在调用 init() 后设置为 true。
virtual void zero() override
将所有元素置零。
unsigned char last_edit
跟踪上次对此向量的写入操作是“无”(0)还是“累积”(1)还是“添加”(2), 以便我们可以决定如何进行 GlobalAssemble()。
dof_id_type numeric_index_type
Definition: id_types.h:99
ParallelType _type
向量的类型。
ParallelType type() const
获取向量的类型。
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
template<typename T >
void libMesh::EpetraVector< T >::init ( const numeric_index_type  N,
const bool  fast = false,
const ParallelType  type = AUTOMATIC 
)
inlineoverridevirtual

初始化矢量。

参数
N全局维度
fast是否启用快速初始化
type并行类型(默认为AUTOMATIC)

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.h1030 行定义.

1033 {
1034  this->init(n,n,fast,type);
1035 }
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType type=AUTOMATIC) override
初始化矢量。
ParallelType type() const
获取向量的类型。
template<typename T >
void libMesh::EpetraVector< 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  type = AUTOMATIC 
)
inlineoverridevirtual

初始化矢量。

参数
N全局维度
n_local本地维度
ghost需要保留内存的索引
fast是否启用快速初始化
type并行类型(默认为AUTOMATIC)

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.h1016 行定义.

1021 {
1022  // TODO: we shouldn't ignore the ghost sparsity pattern
1023  this->init(n, n_local, fast, type);
1024 }
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType type=AUTOMATIC) override
初始化矢量。
ParallelType type() const
获取向量的类型。
template<class T >
void libMesh::EpetraVector< T >::init ( const NumericVector< T > &  other,
const bool  fast = false 
)
overridevirtual

初始化矢量,使用其他矢量进行初始化。

参数
other源矢量
fast是否启用快速初始化

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.h941 行定义.

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

943 {
944  this->init(other.size(),other.local_size(),fast,other.type());
945 }
virtual void init(const numeric_index_type N, const numeric_index_type n_local, const bool fast=false, const ParallelType type=AUTOMATIC) override
初始化矢量。
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 >
int libMesh::EpetraVector< T >::inputNonlocalValue ( int  GID,
double  value,
bool  accumulate 
)
private

输入非本地值到向量中,覆盖或累积到指定 GID 的已存在的任何值。

参数
GID全局 ID。
value输入的值。
accumulate如果为 true,则将值累积到已存在的值中。
返回
操作的结果代码。

在文件 trilinos_epetra_vector.C739 行定义.

740 {
741  int insertPoint = -1;
742 
743  //find offset of GID in nonlocalIDs_
744  int offset = Epetra_Util_binary_search(GID, nonlocalIDs_, numNonlocalIDs_,
745  insertPoint);
746  if (offset >= 0) {
747  //if offset >= 0
748  // put value in nonlocalCoefs_[offset][0]
749 
750  if (accumulate) {
751  nonlocalCoefs_[offset][0] += value;
752  }
753  else {
754  nonlocalCoefs_[offset][0] = value;
755  }
756  }
757  else {
758  //else
759  // insert GID in nonlocalIDs_
760  // insert 1 in nonlocalElementSize_
761  // insert value in nonlocalCoefs_
762 
763  int tmp1 = numNonlocalIDs_;
764  int tmp2 = allocatedNonlocalLength_;
765  int tmp3 = allocatedNonlocalLength_;
766  EPETRA_CHK_ERR( Epetra_Util_insert(GID, insertPoint, nonlocalIDs_,
767  tmp1, tmp2) );
768  --tmp1;
769  EPETRA_CHK_ERR( Epetra_Util_insert(1, insertPoint, nonlocalElementSize_,
770  tmp1, tmp3) );
771  double * values = new double[1];
772  values[0] = value;
773  EPETRA_CHK_ERR( Epetra_Util_insert(values, insertPoint, nonlocalCoefs_,
775  }
776 
777  return(0);
778 }
double ** nonlocalCoefs_
非本地系数的指针数组。
int allocatedNonlocalLength_
已分配的非本地长度。
int * nonlocalElementSize_
非本地元素大小数组。
int * nonlocalIDs_
非本地 ID 数组。
int numNonlocalIDs_
非本地 ID 数量。
template<typename T >
int libMesh::EpetraVector< T >::inputNonlocalValues ( int  GID,
int  numValues,
const double *  values,
bool  accumulate 
)
private

输入非本地值到向量中,覆盖或累积到指定 GID 的已存在的任何值。

参数
GID全局 ID。
numValues值的数量。
values包含系数值的数组。
accumulate如果为 true,则将值累积到已存在的值中。
返回
操作的结果代码。

在文件 trilinos_epetra_vector.C782 行定义.

参考 libMesh::err.

786 {
787  int insertPoint = -1;
788 
789  //find offset of GID in nonlocalIDs_
790  int offset = Epetra_Util_binary_search(GID, nonlocalIDs_, numNonlocalIDs_,
791  insertPoint);
792  if (offset >= 0) {
793  //if offset >= 0
794  // put value in nonlocalCoefs_[offset][0]
795 
796  if (numValues != nonlocalElementSize_[offset]) {
797  libMesh::err << "Epetra_FEVector ERROR: block-size for GID " << GID << " is "
798  << numValues<<" which doesn't match previously set block-size of "
799  << nonlocalElementSize_[offset] << std::endl;
800  return(-1);
801  }
802 
803  if (accumulate) {
804  for (int j=0; j<numValues; ++j) {
805  nonlocalCoefs_[offset][j] += values[j];
806  }
807  }
808  else {
809  for (int j=0; j<numValues; ++j) {
810  nonlocalCoefs_[offset][j] = values[j];
811  }
812  }
813  }
814  else {
815  //else
816  // insert GID in nonlocalIDs_
817  // insert numValues in nonlocalElementSize_
818  // insert values in nonlocalCoefs_
819 
820  int tmp1 = numNonlocalIDs_;
821  int tmp2 = allocatedNonlocalLength_;
822  int tmp3 = allocatedNonlocalLength_;
823  EPETRA_CHK_ERR( Epetra_Util_insert(GID, insertPoint, nonlocalIDs_,
824  tmp1, tmp2) );
825  --tmp1;
826  EPETRA_CHK_ERR( Epetra_Util_insert(numValues, insertPoint, nonlocalElementSize_,
827  tmp1, tmp3) );
828  double * newvalues = new double[numValues];
829  for (int j=0; j<numValues; ++j) {
830  newvalues[j] = values[j];
831  }
832  EPETRA_CHK_ERR( Epetra_Util_insert(newvalues, insertPoint, nonlocalCoefs_,
834  }
835 
836  return(0);
837 }
double ** nonlocalCoefs_
非本地系数的指针数组。
int allocatedNonlocalLength_
已分配的非本地长度。
int * nonlocalElementSize_
非本地元素大小数组。
int * nonlocalIDs_
非本地 ID 数组。
int numNonlocalIDs_
非本地 ID 数量。
OStreamProxy err
template<typename T >
int libMesh::EpetraVector< T >::inputValues ( int  numIDs,
const int *  GIDs,
const double *  values,
bool  accumulate 
)
private

输入值到向量中,覆盖或累积到指定索引的已存在的任何值。

参数
numIDs全局 ID 的数量。
GIDs包含全局 ID 的数组。
values包含系数值的数组。
accumulate如果为 true,则将值累积到已存在的值中。
返回
操作的结果代码。

在文件 trilinos_epetra_vector.C659 行定义.

663 {
664  if (accumulate) {
665  libmesh_assert(last_edit == 0 || last_edit == 2);
666  last_edit = 2;
667  } else {
668  libmesh_assert(last_edit == 0 || last_edit == 1);
669  last_edit = 1;
670  }
671 
672  //Important note!! This method assumes that there is only 1 point
673  //associated with each element.
674 
675  for (int i=0; i<numIDs; ++i) {
676  if (_vec->Map().MyGID(GIDs[i])) {
677  if (accumulate) {
678  _vec->SumIntoGlobalValue(GIDs[i], 0, 0, values[i]);
679  }
680  else {
681  _vec->ReplaceGlobalValue(GIDs[i], 0, 0, values[i]);
682  }
683  }
684  else {
685  if (!ignoreNonLocalEntries_) {
686  EPETRA_CHK_ERR( inputNonlocalValue(GIDs[i], values[i], accumulate) );
687  }
688  }
689  }
690 
691  return(0);
692 }
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
unsigned char last_edit
跟踪上次对此向量的写入操作是“无”(0)还是“累积”(1)还是“添加”(2), 以便我们可以决定如何进行 GlobalAssemble()。
int inputNonlocalValue(int GID, double value, bool accumulate)
输入非本地值到向量中,覆盖或累积到指定 GID 的已存在的任何值。
bool ignoreNonLocalEntries_
是否忽略非本地数据值。
template<typename T >
int libMesh::EpetraVector< T >::inputValues ( int  numIDs,
const int *  GIDs,
const int *  numValuesPerID,
const double *  values,
bool  accumulate 
)
private

输入值到向量中,替换或累积到指定全局 ID 的已存在的任何值。

参数
numIDs全局 ID 的数量。
GIDs包含全局 ID 的数组。
numValuesPerID包含每个全局 ID 对应值的数量的数组。
values包含系数值的数组。
accumulate如果为 true,则将值累积到已存在的值中。
返回
操作的结果代码。

在文件 trilinos_epetra_vector.C696 行定义.

701 {
702  if (accumulate) {
703  libmesh_assert(last_edit == 0 || last_edit == 2);
704  last_edit = 2;
705  } else {
706  libmesh_assert(last_edit == 0 || last_edit == 1);
707  last_edit = 1;
708  }
709 
710  int offset=0;
711  for (int i=0; i<numIDs; ++i) {
712  int numValues = numValuesPerID[i];
713  if (_vec->Map().MyGID(GIDs[i])) {
714  if (accumulate) {
715  for (int j=0; j<numValues; ++j) {
716  _vec->SumIntoGlobalValue(GIDs[i], j, 0, values[offset+j]);
717  }
718  }
719  else {
720  for (int j=0; j<numValues; ++j) {
721  _vec->ReplaceGlobalValue(GIDs[i], j, 0, values[offset+j]);
722  }
723  }
724  }
725  else {
726  if (!ignoreNonLocalEntries_) {
727  EPETRA_CHK_ERR( inputNonlocalValues(GIDs[i], numValues,
728  &(values[offset]), accumulate) );
729  }
730  }
731  offset += numValues;
732  }
733 
734  return(0);
735 }
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
int inputNonlocalValues(int GID, int numValues, const double *values, bool accumulate)
输入非本地值到向量中,覆盖或累积到指定 GID 的已存在的任何值。
unsigned char last_edit
跟踪上次对此向量的写入操作是“无”(0)还是“累积”(1)还是“添加”(2), 以便我们可以决定如何进行 GlobalAssemble()。
bool ignoreNonLocalEntries_
是否忽略非本地数据值。
template<typename T >
void libMesh::EpetraVector< T >::insert ( const T *  v,
const std::vector< numeric_index_type > &  dof_indices 
)
overridevirtual

使用特定的自由度索引将一个值数组插入到当前矢量中。

参数
v值数组
dof_indices自由度索引

重载 libMesh::NumericVector< T > .

在文件 trilinos_epetra_vector.C304 行定义.

参考 libMesh::numeric_trilinos_cast().

306 {
307  libmesh_assert_equal_to (sizeof(numeric_index_type), sizeof(int));
308 
309  std::scoped_lock lock(this->_numeric_vector_mutex);
310  ReplaceGlobalValues (cast_int<numeric_index_type>(dof_indices.size()),
311  numeric_trilinos_cast(dof_indices.data()),
312  const_cast<T *>(v));
313  this->_is_closed = false;
314 }
std::mutex _numeric_vector_mutex
用于执行线程安全操作的互斥锁。
int ReplaceGlobalValues(int numIDs, const int *GIDs, const double *values)
将值复制到向量中,覆盖指定索引已存在的任何值。
dof_id_type numeric_index_type
Definition: id_types.h:99
int * numeric_trilinos_cast(const numeric_index_type *p)
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
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::EpetraVector< T >::l1_norm ( ) const
overridevirtual

计算矢量的L1范数。

返回
L1范数

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C69 行定义.

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

70 {
71  libmesh_assert(this->closed());
72 
73  Real value;
74 
75  _vec->Norm1(&value);
76 
77  return value;
78 }
virtual bool closed() const
检查向量是否已经关闭并准备好进行计算。
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
template<typename T >
Real libMesh::EpetraVector< T >::l2_norm ( ) const
overridevirtual

计算矢量的L2范数。

返回
L2范数

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C81 行定义.

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

82 {
83  libmesh_assert(this->closed());
84 
85  Real value;
86 
87  _vec->Norm2(&value);
88 
89  return value;
90 }
virtual bool closed() const
检查向量是否已经关闭并准备好进行计算。
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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::EpetraVector< T >::last_local_index ( ) const
inlineoverridevirtual

获取矢量的最后一个本地索引。

返回
最后一个本地索引

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.h1153 行定义.

参考 libMesh::initialized().

1154 {
1155  libmesh_assert (this->initialized());
1156 
1157  return _vec->Map().MaxMyGID()+1;
1158 }
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
virtual bool initialized() const
检查向量是否已经初始化。
template<typename T >
Real libMesh::EpetraVector< T >::linfty_norm ( ) const
overridevirtual

计算矢量的L∞范数。

返回
L∞范数

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C93 行定义.

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

94 {
95  libmesh_assert(this->closed());
96 
97  Real value;
98 
99  _vec->NormInf(&value);
100 
101  return value;
102 }
virtual bool closed() const
检查向量是否已经关闭并准备好进行计算。
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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::EpetraVector< T >::local_size ( ) const
inlineoverridevirtual

获取矢量的本地大小。

返回
矢量的本地大小

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.h1133 行定义.

参考 libMesh::initialized().

1134 {
1135  libmesh_assert (this->initialized());
1136 
1137  return _vec->MyLength();
1138 }
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
virtual bool initialized() const
检查向量是否已经初始化。
template<typename T >
void libMesh::EpetraVector< T >::localize ( std::vector< T > &  v_local) const
overridevirtual

将当前矢量的值本地化到一个本地矢量中。

参数
v_local存储本地化值的矢量

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C532 行定义.

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

533 {
534  // This function must be run on all processors at once
535  parallel_object_only();
536 
537  const unsigned int n = this->size();
538  const unsigned int nl = this->local_size();
539 
540  libmesh_assert(this->_vec);
541 
542  v_local.clear();
543  v_local.reserve(n);
544 
545  // build up my local part
546  for (unsigned int i=0; i<nl; i++)
547  v_local.push_back((*this->_vec)[i]);
548 
549  this->comm().allgather (v_local);
550 }
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
virtual numeric_index_type size() const override
获取矢量的全局大小。
virtual numeric_index_type local_size() const override
获取矢量的本地大小。
template<typename T >
void libMesh::EpetraVector< T >::localize ( NumericVector< T > &  v_local) const
overridevirtual

将当前矢量的值本地化到另一个矢量的相应位置。

参数
v_local存储本地化值的矢量

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C420 行定义.

参考 libMesh::EpetraVector< T >::_vec.

421 {
422  EpetraVector<T> * v_local = cast_ptr<EpetraVector<T> *>(&v_local_in);
423 
424  Epetra_Map rootMap = Epetra_Util::Create_Root_Map( *_map, -1);
425  v_local->_vec->ReplaceMap(rootMap);
426 
427  Epetra_Import importer(v_local->_vec->Map(), *_map);
428  v_local->_vec->Import(*_vec, importer, Insert);
429 }
std::unique_ptr< Epetra_Map > _map
持有分布式映射。
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
template<typename T >
void libMesh::EpetraVector< T >::localize ( NumericVector< T > &  v_local,
const std::vector< numeric_index_type > &  send_list 
) const
overridevirtual

将当前矢量的部分值本地化到另一个矢量的相应位置。

参数
v_local存储本地化值的矢量
send_list本地化的部分值的索引列表

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C434 行定义.

436 {
437  // TODO: optimize to sync only the send list values
438  this->localize(v_local_in);
439 
440  // EpetraVector<T> * v_local =
441  // cast_ptr<EpetraVector<T> *>(&v_local_in);
442 
443  // libmesh_assert(this->_map.get());
444  // libmesh_assert(v_local->_map.get());
445  // libmesh_assert_equal_to (v_local->local_size(), this->size());
446  // libmesh_assert_less_equal (send_list.size(), v_local->size());
447 
448  // Epetra_Import importer (*v_local->_map, *this->_map);
449 
450  // v_local->_vec->Import (*this->_vec, importer, Insert);
451 }
virtual void localize(std::vector< T > &v_local) const override
将当前矢量的值本地化到一个本地矢量中。
template<typename T >
void libMesh::EpetraVector< T >::localize ( std::vector< T > &  v_local,
const std::vector< numeric_index_type > &  indices 
) const
overridevirtual

将当前矢量的部分值本地化到本地矢量的相应位置。

参数
v_local存储本地化值的矢量
indices本地化的部分值的索引列表

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C456 行定义.

458 {
459  // Create a "replicated" map for importing values. This is
460  // equivalent to creating a general Epetra_Map with
461  // NumGlobalElements == NumMyElements.
462  Epetra_LocalMap import_map(static_cast<int>(indices.size()),
463  /*IndexBase=*/0,
464  _map->Comm());
465 
466  // Get a pointer to the list of global elements for the map, and set
467  // all the values from indices.
468  int * import_map_global_elements = import_map.MyGlobalElements();
469  for (auto i : index_range(indices))
470  import_map_global_elements[i] = indices[i];
471 
472  // Create a new EpetraVector to import values into.
473  Epetra_Vector import_vector(import_map);
474 
475  // Set up an "Import" object which associates the two maps.
476  Epetra_Import import_object(import_map, *_map);
477 
478  // Import the values
479  import_vector.Import(*_vec, import_object, Insert);
480 
481  // Get a pointer to the imported values array and the length of the
482  // array.
483  T * values = import_vector.Values();
484  int import_vector_length = import_vector.MyLength();
485 
486  // Copy the imported values into v_local
487  v_local.resize(import_vector_length);
488  for (int i=0; i<import_vector_length; ++i)
489  v_local[i] = values[i];
490 }
std::unique_ptr< Epetra_Map > _map
持有分布式映射。
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
template<typename T >
void libMesh::EpetraVector< 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

将指定范围内的部分值本地化到另一个矢量的相应位置。

参数
first_local_idx第一个本地索引
last_local_idx最后一个本地索引
send_list本地化的部分值的索引列表

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C495 行定义.

参考 libMesh::EpetraVector< T >::close(), libMesh::EpetraVector< T >::init(), libMesh::EpetraVector< T >::localize() , 以及 libMesh::EpetraVector< T >::set().

498 {
499  // Only good for serial vectors.
500  libmesh_assert_equal_to (this->size(), this->local_size());
501  libmesh_assert_greater (last_local_idx, first_local_idx);
502  libmesh_assert_less_equal (send_list.size(), this->size());
503  libmesh_assert_less (last_local_idx, this->size());
504 
505  const unsigned int my_size = this->size();
506  const unsigned int my_local_size = (last_local_idx - first_local_idx + 1);
507 
508  // Don't bother for serial cases
509  if ((first_local_idx == 0) &&
510  (my_local_size == my_size))
511  return;
512 
513  // Build a parallel vector, initialize it with the local
514  // parts of (*this)
515  EpetraVector<T> parallel_vec(this->comm(), PARALLEL);
516 
517  parallel_vec.init (my_size, my_local_size, true, PARALLEL);
518 
519  // Copy part of *this into the parallel_vec
520  for (numeric_index_type i=first_local_idx; i<=last_local_idx; i++)
521  parallel_vec.set(i,this->el(i));
522 
523  // localize like normal
524  parallel_vec.close();
525  parallel_vec.localize (*this, send_list);
526  this->close();
527 }
virtual void close() override
关闭矢量,使其无法再次修改。
virtual numeric_index_type size() const override
获取矢量的全局大小。
dof_id_type numeric_index_type
Definition: id_types.h:99
virtual numeric_index_type local_size() const override
获取矢量的本地大小。
template<typename T >
void libMesh::EpetraVector< T >::localize_to_one ( std::vector< T > &  v_local,
const processor_id_type  proc_id = 0 
) const
overridevirtual

将所有值本地化到一个本地矢量中,仅保留一个处理器上的值。

参数
v_local存储本地化值的矢量
proc_id用于本地化的处理器ID

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C555 行定义.

557 {
558  // This function must be run on all processors at once
559  parallel_object_only();
560 
561  const unsigned int n = this->size();
562  const unsigned int nl = this->local_size();
563 
564  libmesh_assert_less (pid, this->n_processors());
565  libmesh_assert(this->_vec);
566 
567  v_local.clear();
568  v_local.reserve(n);
569 
570 
571  // build up my local part
572  for (unsigned int i=0; i<nl; i++)
573  v_local.push_back((*this->_vec)[i]);
574 
575  this->comm().gather (pid, v_local);
576 }
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
virtual numeric_index_type size() const override
获取矢量的全局大小。
virtual numeric_index_type local_size() const override
获取矢量的本地大小。
template<typename T >
Real libMesh::EpetraVector< T >::max ( ) const
inlineoverridevirtual

获取矢量中的最大值。

返回
矢量中的最大值

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.h1191 行定义.

参考 libMesh::initialized().

1192 {
1193  libmesh_assert (this->initialized());
1194 
1195  T value;
1196 
1197  _vec->MaxValue(&value);
1198 
1199  return value;
1200 }
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
virtual bool initialized() const
检查向量是否已经初始化。
template<typename T >
std::size_t libMesh::EpetraVector< T >::max_allowed_id ( ) const
inlineoverridevirtual

获取允许的最大ID大小。

返回
最大允许的ID大小

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.h1231 行定义.

1232 {
1233  // Epetra_Vector seems to use hard-coded ints in its various indexing routines.
1234  return std::numeric_limits<int>::max();
1235 }
template<typename T >
Real libMesh::EpetraVector< T >::min ( ) const
inlineoverridevirtual

获取矢量中的最小值。

返回
矢量中的最小值

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.h1176 行定义.

参考 libMesh::initialized().

1177 {
1178  libmesh_assert (this->initialized());
1179 
1180  T value;
1181 
1182  _vec->MinValue(&value);
1183 
1184  return value;
1185 }
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
virtual bool initialized() const
检查向量是否已经初始化。
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::EpetraVector< T >::operator() ( const numeric_index_type  i) const
inlineoverridevirtual

获取矢量中索引i处的值。

参数
i要获取的索引
返回
索引i处的值

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.h1163 行定义.

参考 libMesh::initialized().

1164 {
1165  libmesh_assert (this->initialized());
1166  libmesh_assert ( ((i >= this->first_local_index()) &&
1167  (i < this->last_local_index())) );
1168 
1169  return (*_vec)[i-this->first_local_index()];
1170 }
virtual numeric_index_type last_local_index() const override
获取矢量的最后一个本地索引。
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
virtual bool initialized() const
检查向量是否已经初始化。
virtual numeric_index_type first_local_index() const override
获取矢量的第一个本地索引。
template<typename T >
NumericVector< T > & libMesh::EpetraVector< T >::operator*= ( const NumericVector< T > &  v)
overridevirtual

将矢量与另一个矢量逐元素相乘并将结果存储在当前矢量中。

参数
v另一个矢量
返回
引用到当前矢量

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C131 行定义.

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

132 {
133  libmesh_assert(this->closed());
134  libmesh_assert_equal_to(size(), v.size());
135 
136  const EpetraVector<T> & v_vec = cast_ref<const EpetraVector<T> &>(v);
137 
138  _vec->Multiply(1.0, *v_vec._vec, *_vec, 0.0);
139 
140  return *this;
141 }
virtual bool closed() const
检查向量是否已经关闭并准备好进行计算。
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
virtual numeric_index_type size() const override
获取矢量的全局大小。
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::EpetraVector< T >::operator+= ( const NumericVector< T > &  v)
overridevirtual

将矢量与另一个矢量相加并将结果存储在当前矢量中。

参数
v另一个矢量
返回
引用到当前矢量

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C106 行定义.

参考 libMesh::closed().

107 {
108  libmesh_assert(this->closed());
109 
110  this->add(1., v);
111 
112  return *this;
113 }
virtual bool closed() const
检查向量是否已经关闭并准备好进行计算。
virtual void add(const numeric_index_type i, const T value) override
将索引i处的值增加value。
template<typename T >
NumericVector< T > & libMesh::EpetraVector< T >::operator-= ( const NumericVector< T > &  v)
overridevirtual

将矢量与另一个矢量相减并将结果存储在当前矢量中。

参数
v另一个矢量
返回
引用到当前矢量

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C119 行定义.

参考 libMesh::closed().

120 {
121  libmesh_assert(this->closed());
122 
123  this->add(-1., v);
124 
125  return *this;
126 }
virtual bool closed() const
检查向量是否已经关闭并准备好进行计算。
virtual void add(const numeric_index_type i, const T value) override
将索引i处的值增加value。
template<typename T >
NumericVector< T > & libMesh::EpetraVector< T >::operator/= ( const NumericVector< T > &  v)
overridevirtual

将矢量与另一个矢量逐元素相除并将结果存储在当前矢量中。

参数
v另一个矢量
返回
引用到当前矢量

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C146 行定义.

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

147 {
148  libmesh_assert(this->closed());
149  libmesh_assert_equal_to(size(), v.size());
150 
151  const EpetraVector<T> & v_vec = cast_ref<const EpetraVector<T> &>(v);
152 
153  _vec->ReciprocalMultiply(1.0, *v_vec._vec, *_vec, 0.0);
154 
155  return *this;
156 }
virtual bool closed() const
检查向量是否已经关闭并准备好进行计算。
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
virtual numeric_index_type size() const override
获取矢量的全局大小。
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>
EpetraVector& libMesh::EpetraVector< T >::operator= ( const EpetraVector< T > &  )
delete
template<typename T>
EpetraVector& libMesh::EpetraVector< T >::operator= ( EpetraVector< T > &&  )
delete
template<typename T >
NumericVector< T > & libMesh::EpetraVector< T >::operator= ( const T  s)
overridevirtual

将矢量中的所有元素设置为标量值s。

参数
s标量值
返回
引用到当前矢量

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C357 行定义.

358 {
359  _vec->PutScalar(s_in);
360 
361  return *this;
362 }
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
template<typename T >
NumericVector< T > & libMesh::EpetraVector< T >::operator= ( const NumericVector< T > &  v)
overridevirtual

从其他矢量复制元素。

参数
v源矢量
返回
引用到当前矢量

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C368 行定义.

369 {
370  // This function could be implemented in terms of the copy
371  // assignment operator (see other NumericVector subclasses) but that
372  // function is currently deleted so calling this function is an error.
373  // const EpetraVector<T> * v = cast_ptr<const EpetraVector<T> *>(&v_in);
374  // *this = *v;
375  libmesh_not_implemented();
376  return *this;
377 }
template<typename T >
NumericVector< T > & libMesh::EpetraVector< T >::operator= ( const std::vector< T > &  v)
overridevirtual

从std::vector复制元素。

参数
v源std::vector
返回
引用到当前矢量

Case 1: The vector is the same size of The global vector. Only add the local components.

Case 2: The vector is the same size as our local piece. Insert directly to the local piece.

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C383 行定义.

384 {
385  T * values = _vec->Values();
386 
391  if (this->size() == v.size())
392  {
393  const unsigned int nl=this->local_size();
394  const unsigned int fli=this->first_local_index();
395 
396  for (unsigned int i=0;i<nl;i++)
397  values[i]=v[fli+i];
398  }
399 
404  else
405  {
406  libmesh_assert_equal_to (v.size(), this->local_size());
407 
408  const unsigned int nl=this->local_size();
409 
410  for (unsigned int i=0;i<nl;i++)
411  values[i]=v[i];
412  }
413 
414  return *this;
415 }
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
virtual numeric_index_type size() const override
获取矢量的全局大小。
virtual numeric_index_type first_local_index() const override
获取矢量的第一个本地索引。
virtual numeric_index_type local_size() const override
获取矢量的本地大小。
template<typename T>
virtual void libMesh::NumericVector< T >::pointwise_divide ( const NumericVector< T > &  vec1,
const NumericVector< T > &  vec2 
)
pure virtualinherited

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

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

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

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

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

计算当前矢量与另一个矢量的逐元素乘积。

参数
vec1另一个矢量
vec2另一个矢量

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C345 行定义.

参考 libMesh::EpetraVector< T >::_vec.

347 {
348  const EpetraVector<T> * v1 = cast_ptr<const EpetraVector<T> *>(&vec1);
349  const EpetraVector<T> * v2 = cast_ptr<const EpetraVector<T> *>(&vec2);
350 
351  _vec->Multiply(1.0, *v1->_vec, *v2->_vec, 0.0);
352 }
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
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::EpetraVector< T >::reciprocal ( )
overridevirtual

计算当前矢量的逐元素倒数。

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C178 行定义.

参考 std::abs().

179 {
180  // The Epetra::reciprocal() function takes a constant reference to *another* vector,
181  // and fills _vec with its reciprocal. Does that mean we can't pass *_vec as the
182  // argument?
183  // _vec->reciprocal( *_vec );
184 
185  // Alternatively, compute the reciprocal by hand... see also the add(T) member that does this...
186  const unsigned int nl = _vec->MyLength();
187 
188  T * values = _vec->Values();
189 
190  for (unsigned int i=0; i<nl; i++)
191  {
192  // Don't divide by zero (maybe only check this in debug mode?)
193  libmesh_error_msg_if(std::abs(values[i]) < std::numeric_limits<T>::min(),
194  "Error, divide by zero in DistributedVector<T>::reciprocal()!");
195 
196  values[i] = 1. / values[i];
197  }
198 
199  // Leave the vector in a closed state...
200  this->close();
201 }
virtual void close() override
关闭矢量,使其无法再次修改。
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
计算自动微分实数向量的绝对值。
Definition: type_vector.h:112
template<typename T >
int libMesh::EpetraVector< T >::ReplaceGlobalValues ( int  numIDs,
const int *  GIDs,
const double *  values 
)
private

将值复制到向量中,覆盖指定索引已存在的任何值。

参数
numIDs全局 ID 的数量。
GIDs包含全局 ID 的数组。
values包含系数值的数组。
返回
操作的结果代码。

在文件 trilinos_epetra_vector.C628 行定义.

631 {
632  return( inputValues( numIDs, GIDs, values, false) );
633 }
int inputValues(int numIDs, const int *GIDs, const double *values, bool accumulate)
输入值到向量中,覆盖或累积到指定索引的已存在的任何值。
template<typename T >
int libMesh::EpetraVector< T >::ReplaceGlobalValues ( const Epetra_IntSerialDenseVector &  GIDs,
const Epetra_SerialDenseVector &  values 
)
private

将值复制到向量中,替换指定 GID 已存在的任何值。

参数
GIDs包含全局 ID 的数组,必须与伴随的 values 数组的长度相同。
values包含系数值的数组,必须与伴随的 GIDs 数组的长度相同。
返回
操作的结果代码。

在文件 trilinos_epetra_vector.C637 行定义.

639 {
640  if (GIDs.Length() != values.Length()) {
641  return(-1);
642  }
643 
644  return( inputValues( GIDs.Length(), GIDs.Values(), values.Values(), false) );
645 }
int inputValues(int numIDs, const int *GIDs, const double *values, bool accumulate)
输入值到向量中,覆盖或累积到指定索引的已存在的任何值。
template<typename T >
int libMesh::EpetraVector< T >::ReplaceGlobalValues ( int  numIDs,
const int *  GIDs,
const int *  numValuesPerID,
const double *  values 
)
private

将值复制到向量中,替换指定索引已存在的任何值。

参数
numIDs全局 ID 的数量。
GIDs包含全局 ID 的数组。
numValuesPerID包含每个全局 ID 对应值的数量的数组。
values包含系数值的数组。
返回
操作的结果代码。

在文件 trilinos_epetra_vector.C649 行定义.

653 {
654  return( inputValues( numIDs, GIDs, numValuesPerID, values, false) );
655 }
int inputValues(int numIDs, const int *GIDs, const double *values, bool accumulate)
输入值到向量中,覆盖或累积到指定索引的已存在的任何值。
template<typename T >
void libMesh::EpetraVector< T >::scale ( const T  factor)
overridevirtual

缩放矢量的所有元素。

参数
factor缩放因子

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C319 行定义.

320 {
321  _vec->Scale(factor_in);
322 }
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
template<typename T >
void libMesh::EpetraVector< T >::set ( const numeric_index_type  i,
const T  value 
)
overridevirtual

设置索引i处的值为value。

参数
i索引
value要设置的值

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C162 行定义.

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

163 {
164  int i = static_cast<int> (i_in);
165  T value = value_in;
166 
167  libmesh_assert_less (i_in, this->size());
168 
169  std::scoped_lock lock(this->_numeric_vector_mutex);
170  ReplaceGlobalValues(1, &i, &value);
171 
172  this->_is_closed = false;
173 }
std::mutex _numeric_vector_mutex
用于执行线程安全操作的互斥锁。
virtual numeric_index_type size() const override
获取矢量的全局大小。
int ReplaceGlobalValues(int numIDs, const int *GIDs, const double *values)
将值复制到向量中,覆盖指定索引已存在的任何值。
bool _is_closed
用于跟踪向量的值在在一些或全部处理器上进行插入或添加值操作后是否在所有处理器上保持一致的标志。
template<typename T>
void libMesh::EpetraVector< T >::setIgnoreNonLocalEntries ( bool  flag)
inlineprivate

设置是否应忽略非本地数据值。

参数
flag如果为 true,则忽略非本地数据值。

在文件 trilinos_epetra_vector.h668 行定义.

参考 libMesh::EpetraVector< T >::ignoreNonLocalEntries_.

669  {
670  ignoreNonLocalEntries_ = flag;
671  }
bool ignoreNonLocalEntries_
是否忽略非本地数据值。
template<typename T >
numeric_index_type libMesh::EpetraVector< T >::size ( ) const
inlineoverridevirtual

获取矢量的全局大小。

返回
矢量的全局大小

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.h1122 行定义.

参考 libMesh::initialized().

参考自 libMesh::EpetraVector< T >::add().

1123 {
1124  libmesh_assert (this->initialized());
1125 
1126  return _vec->GlobalLength();
1127 }
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
virtual bool initialized() const
检查向量是否已经初始化。
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::EpetraVector< T >::sum ( ) const
overridevirtual

计算矢量中所有元素的总和。

返回
所有元素的总和

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.C50 行定义.

参考 libMesh::closed().

51 {
52  libmesh_assert(this->closed());
53 
54  const unsigned int nl = _vec->MyLength();
55 
56  T sum=0.0;
57 
58  T * values = _vec->Values();
59 
60  for (unsigned int i=0; i<nl; i++)
61  sum += values[i];
62 
63  this->comm().sum(sum);
64 
65  return sum;
66 }
virtual bool closed() const
检查向量是否已经关闭并准备好进行计算。
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
virtual T sum() const override
计算矢量中所有元素的总和。
template<typename T >
int libMesh::EpetraVector< T >::SumIntoGlobalValues ( int  numIDs,
const int *  GIDs,
const double *  values 
)
private

将值累积到向量中,将它们添加到指定索引已存在的任何值中。

参数
numIDs全局 ID 的数量。
GIDs包含全局 ID 的数组。
values包含系数值的数组。
返回
操作的结果代码。

在文件 trilinos_epetra_vector.C597 行定义.

600 {
601  return( inputValues( numIDs, GIDs, values, true) );
602 }
int inputValues(int numIDs, const int *GIDs, const double *values, bool accumulate)
输入值到向量中,覆盖或累积到指定索引的已存在的任何值。
template<typename T >
int libMesh::EpetraVector< T >::SumIntoGlobalValues ( const Epetra_IntSerialDenseVector &  GIDs,
const Epetra_SerialDenseVector &  values 
)
private

将值累积到向量中,将它们添加到指定 GID 已存在的任何值中。

参数
GIDs包含全局 ID 的数组,必须与伴随的 values 数组的长度相同。
values包含系数值的数组,必须与伴随的 GIDs 数组的长度相同。
返回
操作的结果代码。

在文件 trilinos_epetra_vector.C606 行定义.

608 {
609  if (GIDs.Length() != values.Length()) {
610  return(-1);
611  }
612 
613  return( inputValues( GIDs.Length(), GIDs.Values(), values.Values(), true) );
614 }
int inputValues(int numIDs, const int *GIDs, const double *values, bool accumulate)
输入值到向量中,覆盖或累积到指定索引的已存在的任何值。
template<typename T >
int libMesh::EpetraVector< T >::SumIntoGlobalValues ( int  numIDs,
const int *  GIDs,
const int *  numValuesPerID,
const double *  values 
)
private

将值累积到向量中,将它们添加到指定索引已存在的任何值中。

参数
numIDs全局 ID 的数量。
GIDs包含全局 ID 的数组。
numValuesPerID包含每个全局 ID 对应值的数量的数组。
values包含系数值的数组。
返回
操作的结果代码。

在文件 trilinos_epetra_vector.C618 行定义.

622 {
623  return( inputValues( numIDs, GIDs, numValuesPerID, values, true) );
624 }
int inputValues(int numIDs, const int *GIDs, const double *values, bool accumulate)
输入值到向量中,覆盖或累积到指定索引的已存在的任何值。
template<typename T >
void libMesh::EpetraVector< T >::swap ( NumericVector< T > &  v)
inlineoverridevirtual

交换当前矢量与另一个矢量的值。

参数
v另一个矢量

重载 libMesh::NumericVector< T > .

在文件 trilinos_epetra_vector.h1206 行定义.

参考 libMesh::EpetraVector< T >::_destroy_vec_on_exit, libMesh::EpetraVector< T >::_map, libMesh::EpetraVector< T >::_vec, libMesh::EpetraVector< T >::allocatedNonlocalLength_, libMesh::EpetraVector< T >::ignoreNonLocalEntries_, libMesh::EpetraVector< T >::last_edit, libMesh::EpetraVector< T >::myCoefs_, libMesh::EpetraVector< T >::myFirstID_, libMesh::EpetraVector< T >::myNumIDs_, libMesh::EpetraVector< T >::nonlocalCoefs_, libMesh::EpetraVector< T >::nonlocalElementSize_, libMesh::EpetraVector< T >::nonlocalIDs_, libMesh::EpetraVector< T >::numNonlocalIDs_ , 以及 libMesh::NumericVector< T >::swap().

1207 {
1208  NumericVector<T>::swap(other);
1209 
1210  EpetraVector<T> & v = cast_ref<EpetraVector<T> &>(other);
1211 
1212  std::swap(_vec, v._vec);
1213  _map.swap(v._map);
1214  std::swap(_destroy_vec_on_exit, v._destroy_vec_on_exit);
1215  std::swap(myFirstID_, v.myFirstID_);
1216  std::swap(myNumIDs_, v.myNumIDs_);
1217  std::swap(myCoefs_, v.myCoefs_);
1218  std::swap(nonlocalIDs_, v.nonlocalIDs_);
1219  std::swap(nonlocalElementSize_, v.nonlocalElementSize_);
1220  std::swap(numNonlocalIDs_, v.numNonlocalIDs_);
1221  std::swap(allocatedNonlocalLength_, v.allocatedNonlocalLength_);
1222  std::swap(nonlocalCoefs_, v.nonlocalCoefs_);
1223  std::swap(last_edit, v.last_edit);
1224  std::swap(ignoreNonLocalEntries_, v.ignoreNonLocalEntries_);
1225 }
double ** nonlocalCoefs_
非本地系数的指针数组。
int myFirstID_
保存向量的第一个全局 ID。
std::unique_ptr< Epetra_Map > _map
持有分布式映射。
int allocatedNonlocalLength_
已分配的非本地长度。
double * myCoefs_
保存系数的指针数组。
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
int myNumIDs_
保存向量的全局 ID 数量。
int * nonlocalElementSize_
非本地元素大小数组。
bool _destroy_vec_on_exit
此布尔值只应在接受 Epetra Vec 对象的构造函数中设置为 false。
unsigned char last_edit
跟踪上次对此向量的写入操作是“无”(0)还是“累积”(1)还是“添加”(2), 以便我们可以决定如何进行 GlobalAssemble()。
int * nonlocalIDs_
非本地 ID 数组。
bool ignoreNonLocalEntries_
是否忽略非本地数据值。
int numNonlocalIDs_
非本地 ID 数量。
virtual void swap(NumericVector< T > &v)
交换该向量的内容与向量 v 的内容。子类应提供足够的间接性以使此操作成为 O(1) 的头部交换操作。
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>
Epetra_Vector* libMesh::EpetraVector< T >::vec ( )
inline

返回原始的 Epetra_Vector 指针。

注解
通常情况下,用户级别的代码不需要使用这个函数。
请不要做一些疯狂的事情,比如删除指针,否则可能会发生非常糟糕的事情!
返回
指向 Epetra_Vector 对象的指针。

在文件 trilinos_epetra_vector.h553 行定义.

参考 libMesh::EpetraVector< T >::_vec.

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

553 { libmesh_assert(_vec); return _vec; }
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
template<typename T >
void libMesh::EpetraVector< T >::zero ( )
inlineoverridevirtual

将所有元素置零。

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.h1087 行定义.

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

1088 {
1089  libmesh_assert (this->initialized());
1090  libmesh_assert (this->closed());
1091 
1092  _vec->PutScalar(0.0);
1093 }
virtual bool closed() const
检查向量是否已经关闭并准备好进行计算。
Epetra_Vector * _vec
用于保存向量条目的实际 Epetra 向量数据类型。
virtual bool initialized() const
检查向量是否已经初始化。
template<typename T >
std::unique_ptr< NumericVector< T > > libMesh::EpetraVector< T >::zero_clone ( ) const
inlineoverridevirtual

创建零克隆矢量。

返回
零克隆矢量的唯一指针

实现了 libMesh::NumericVector< T >.

在文件 trilinos_epetra_vector.h1099 行定义.

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

参考自 libMesh::EpetraVector< T >::add_vector().

1100 {
1101  NumericVector<T> * cloned_vector = new EpetraVector<T>(this->comm(), AUTOMATIC);
1102  cloned_vector->init(*this);
1103  return std::unique_ptr<NumericVector<T>>(cloned_vector);
1104 }

类成员变量说明

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

Actually holds the data.

在文件 reference_counter.h124 行定义.

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

template<typename T>
bool libMesh::EpetraVector< T >::_destroy_vec_on_exit
private

此布尔值只应在接受 Epetra Vec 对象的构造函数中设置为 false。

在文件 trilinos_epetra_vector.h570 行定义.

参考自 libMesh::EpetraVector< T >::swap().

bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

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

在文件 reference_counter.h143 行定义.

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

template<typename T>
bool libMesh::NumericVector< T >::_is_closed
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>
std::unique_ptr<Epetra_Map> libMesh::EpetraVector< T >::_map
private

持有分布式映射。

在文件 trilinos_epetra_vector.h565 行定义.

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

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>
Epetra_Vector* libMesh::EpetraVector< T >::_vec
private
template<typename T>
int libMesh::EpetraVector< T >::allocatedNonlocalLength_
private

已分配的非本地长度。

在文件 trilinos_epetra_vector.h778 行定义.

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

template<typename T>
bool libMesh::EpetraVector< T >::ignoreNonLocalEntries_
private

是否忽略非本地数据值。

在文件 trilinos_epetra_vector.h794 行定义.

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

template<typename T>
unsigned char libMesh::EpetraVector< T >::last_edit
private

跟踪上次对此向量的写入操作是“无”(0)还是“累积”(1)还是“添加”(2), 以便我们可以决定如何进行 GlobalAssemble()

在文件 trilinos_epetra_vector.h789 行定义.

参考自 libMesh::EpetraVector< T >::swap().

template<typename T>
double* libMesh::EpetraVector< T >::myCoefs_
private

保存系数的指针数组。

在文件 trilinos_epetra_vector.h758 行定义.

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

template<typename T>
int libMesh::EpetraVector< T >::myFirstID_
private

保存向量的第一个全局 ID。

在文件 trilinos_epetra_vector.h748 行定义.

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

template<typename T>
int libMesh::EpetraVector< T >::myNumIDs_
private

保存向量的全局 ID 数量。

在文件 trilinos_epetra_vector.h753 行定义.

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

template<typename T>
double** libMesh::EpetraVector< T >::nonlocalCoefs_
private

非本地系数的指针数组。

在文件 trilinos_epetra_vector.h783 行定义.

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

template<typename T>
int* libMesh::EpetraVector< T >::nonlocalElementSize_
private

非本地元素大小数组。

在文件 trilinos_epetra_vector.h768 行定义.

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

template<typename T>
int* libMesh::EpetraVector< T >::nonlocalIDs_
private

非本地 ID 数组。

在文件 trilinos_epetra_vector.h763 行定义.

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

template<typename T>
int libMesh::EpetraVector< T >::numNonlocalIDs_
private

非本地 ID 数量。

在文件 trilinos_epetra_vector.h773 行定义.

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


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