OGS  v6.4.0
MathLib::EigenVector Class Referencefinal

Detailed Description

Global vector based on Eigen vector.

Definition at line 26 of file EigenVector.h.

#include <EigenVector.h>

Public Types

using RawVectorType = Eigen::VectorXd
 
using IndexType = Eigen::SparseMatrix< double >::Index
 

Public Member Functions

 EigenVector ()=default
 
 EigenVector (IndexType length)
 
 EigenVector (EigenVector const &src)=default
 copy constructor More...
 
IndexType size () const
 return a vector length More...
 
IndexType getRangeEnd () const
 return an end index of the active data range More...
 
void setZero ()
 
double const & operator[] (IndexType rowId) const
 access entry More...
 
double & operator[] (IndexType rowId)
 
double get (IndexType rowId) const
 get entry More...
 
std::vector< double > get (std::vector< IndexType > const &indices) const
 get entries More...
 
void set (IndexType rowId, double v)
 set entry More...
 
void add (IndexType rowId, double v)
 add entry More...
 
template<class T_SUBVEC >
void add (const std::vector< IndexType > &pos, const T_SUBVEC &sub_vec)
 add entries More...
 
void copyValues (std::vector< double > &u) const
 Copy vector values. More...
 
void write (const std::string &filename) const
 printout this equation for debugging More...
 
RawVectorTypegetRawVector ()
 return a raw Eigen vector object More...
 
const RawVectorTypegetRawVector () const
 return a raw Eigen vector object More...
 

Static Public Member Functions

static constexpr IndexType getRangeBegin ()
 return a start index of the active data range More...
 

Private Attributes

RawVectorType _vec
 

Member Typedef Documentation

◆ IndexType

using MathLib::EigenVector::IndexType = Eigen::SparseMatrix<double>::Index

Definition at line 34 of file EigenVector.h.

◆ RawVectorType

using MathLib::EigenVector::RawVectorType = Eigen::VectorXd

Definition at line 29 of file EigenVector.h.

Constructor & Destructor Documentation

◆ EigenVector() [1/3]

MathLib::EigenVector::EigenVector ( )
default

◆ EigenVector() [2/3]

MathLib::EigenVector::EigenVector ( IndexType  length)
inlineexplicit

Constructor for initialization of the number of rows

Parameters
lengthnumber of rows

Definition at line 41 of file EigenVector.h.

41 : _vec(length) {}
RawVectorType _vec
Definition: EigenVector.h:121

◆ EigenVector() [3/3]

MathLib::EigenVector::EigenVector ( EigenVector const &  src)
default

copy constructor

Member Function Documentation

◆ add() [1/2]

template<class T_SUBVEC >
void MathLib::EigenVector::add ( const std::vector< IndexType > &  pos,
const T_SUBVEC &  sub_vec 
)
inline

add entries

Definition at line 94 of file EigenVector.h.

95  {
96  auto const length = pos.size();
97  for (std::size_t i=0; i<length; ++i) {
98  add(pos[i], sub_vec[i]);
99  }
100  }
void add(IndexType rowId, double v)
add entry
Definition: EigenVector.h:87

References add().

◆ add() [2/2]

◆ copyValues()

void MathLib::EigenVector::copyValues ( std::vector< double > &  u) const
inline

Copy vector values.

Definition at line 103 of file EigenVector.h.

104  {
105  assert(u.size() == (std::size_t) _vec.size());
106  copy_n(_vec.data(), _vec.size(), u.begin());
107  }

References _vec.

Referenced by ProcessLib::PhaseField::PhaseFieldProcess< DisplacementDim >::assembleWithJacobianConcreteProcess(), and ProcessLib::SmallDeformationNonlocal::SmallDeformationNonlocalProcess< DisplacementDim >::assembleWithJacobianConcreteProcess().

◆ get() [1/2]

◆ get() [2/2]

std::vector<double> MathLib::EigenVector::get ( std::vector< IndexType > const &  indices) const
inline

get entries

Definition at line 69 of file EigenVector.h.

70  {
71  std::vector<double> local_x;
72  local_x.reserve(indices.size());
73 
74  transform(cbegin(indices), cend(indices), back_inserter(local_x),
75  [&](auto const i) { return _vec[i]; });
76 
77  return local_x;
78  }

References _vec.

◆ getRangeBegin()

static constexpr IndexType MathLib::EigenVector::getRangeBegin ( )
inlinestaticconstexpr

return a start index of the active data range

Definition at line 50 of file EigenVector.h.

50 { return 0; }

◆ getRangeEnd()

IndexType MathLib::EigenVector::getRangeEnd ( ) const
inline

return an end index of the active data range

Definition at line 53 of file EigenVector.h.

53 { return size(); }
IndexType size() const
return a vector length
Definition: EigenVector.h:47

References size().

◆ getRawVector() [1/2]

RawVectorType& MathLib::EigenVector::getRawVector ( )
inline

return a raw Eigen vector object

Definition at line 115 of file EigenVector.h.

115 {return _vec; }

References _vec.

Referenced by MathLib::applyKnownSolution(), MathLib::EigenLinearSolver::solve(), and MathLib::EigenLisLinearSolver::solve().

◆ getRawVector() [2/2]

const RawVectorType& MathLib::EigenVector::getRawVector ( ) const
inline

return a raw Eigen vector object

Definition at line 118 of file EigenVector.h.

118 {return _vec; }

References _vec.

◆ operator[]() [1/2]

double& MathLib::EigenVector::operator[] ( IndexType  rowId)
inline

Definition at line 60 of file EigenVector.h.

60 { return _vec[rowId]; }

References _vec.

◆ operator[]() [2/2]

double const& MathLib::EigenVector::operator[] ( IndexType  rowId) const
inline

access entry

Definition at line 59 of file EigenVector.h.

59 { return _vec[rowId]; }

References _vec.

◆ set()

void MathLib::EigenVector::set ( IndexType  rowId,
double  v 
)
inline

set entry

Definition at line 81 of file EigenVector.h.

82  {
83  _vec[rowId] = v;
84  }

References _vec.

◆ setZero()

◆ size()

IndexType MathLib::EigenVector::size ( ) const
inline

return a vector length

Definition at line 47 of file EigenVector.h.

47 { return static_cast<IndexType>(_vec.size()); }
Eigen::SparseMatrix< double >::Index IndexType
Definition: EigenVector.h:34

References _vec.

Referenced by getRangeEnd().

◆ write()

void MathLib::EigenVector::write ( const std::string &  filename) const
inline

printout this equation for debugging

Definition at line 111 of file EigenVector.h.

111 { std::ofstream os(filename); os << _vec; }

References _vec.

Member Data Documentation

◆ _vec

RawVectorType MathLib::EigenVector::_vec
private

Definition at line 121 of file EigenVector.h.

Referenced by add(), copyValues(), get(), getRawVector(), operator[](), set(), setZero(), size(), and write().


The documentation for this class was generated from the following file: