OGS
MathLib::EigenVector Class Referencefinal

Detailed Description

Global vector based on Eigen vector.

Definition at line 25 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 33 of file EigenVector.h.

◆ RawVectorType

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

Definition at line 28 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 40 of file EigenVector.h.

40 : vec_(length) {}
RawVectorType vec_
Definition: EigenVector.h:116

◆ 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 84 of file EigenVector.h.

85  {
86  auto const length = pos.size();
87  for (std::size_t i = 0; i < length; ++i)
88  {
89  add(pos[i], sub_vec[i]);
90  }
91  }
void add(IndexType rowId, double v)
add entry
Definition: EigenVector.h:80

References add().

◆ add() [2/2]

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

◆ copyValues()

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

Copy vector values.

Definition at line 94 of file EigenVector.h.

95  {
96  assert(u.size() == (std::size_t)vec_.size());
97  copy_n(vec_.data(), vec_.size(), u.begin());
98  }

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 65 of file EigenVector.h.

66  {
67  std::vector<double> local_x;
68  local_x.reserve(indices.size());
69 
70  transform(cbegin(indices), cend(indices), back_inserter(local_x),
71  [&](auto const i) { return vec_[i]; });
72 
73  return local_x;
74  }

References vec_.

◆ getRangeBegin()

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

return a start index of the active data range

Definition at line 49 of file EigenVector.h.

49 { return 0; }

◆ getRangeEnd()

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

return an end index of the active data range

Definition at line 52 of file EigenVector.h.

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

References size().

◆ getRawVector() [1/2]

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

return a raw Eigen vector object

Definition at line 110 of file EigenVector.h.

110 { 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 113 of file EigenVector.h.

113 { return vec_; }

References vec_.

◆ operator[]() [1/2]

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

Definition at line 59 of file EigenVector.h.

59 { return vec_[rowId]; }

References vec_.

◆ operator[]() [2/2]

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

access entry

Definition at line 58 of file EigenVector.h.

58 { return vec_[rowId]; }

References vec_.

◆ set()

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

set entry

Definition at line 77 of file EigenVector.h.

77 { vec_[rowId] = v; }

References vec_.

Referenced by ProcessLib::PhaseField::PhaseFieldProcess< DisplacementDim >::updateConstraints().

◆ setZero()

◆ size()

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

return a vector length

Definition at line 46 of file EigenVector.h.

46 { return static_cast<IndexType>(vec_.size()); }
Eigen::SparseMatrix< double >::Index IndexType
Definition: EigenVector.h:33

References vec_.

Referenced by getRangeEnd().

◆ write()

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

printout this equation for debugging

Definition at line 102 of file EigenVector.h.

103  {
104  std::ofstream os(filename);
105  os << vec_;
106  }

References vec_.

Member Data Documentation

◆ vec_

RawVectorType MathLib::EigenVector::vec_
private

Definition at line 116 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: