OGS
MathLib::EigenVector Class Referencefinal

Detailed Description

Global vector based on Eigen vector.

Definition at line 27 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)
 
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 set (const std::vector< IndexType > &pos, const T_SUBVEC &sub_vec)
 set entries 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
 
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 35 of file EigenVector.h.

◆ RawVectorType

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

Definition at line 30 of file EigenVector.h.

Constructor & Destructor Documentation

◆ EigenVector() [1/2]

MathLib::EigenVector::EigenVector ( )
default

◆ EigenVector() [2/2]

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

Constructor for initialization of the number of rows

Parameters
lengthnumber of rows

Definition at line 42 of file EigenVector.h.

42 : vec_(length) {}
RawVectorType vec_
Definition: EigenVector.h:128

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  {
99  add(pos[i], sub_vec[i]);
100  }
101  }
void add(IndexType rowId, double v)
add entry
Definition: EigenVector.h:79

References add().

◆ add() [2/2]

◆ copyValues()

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

Copy local entries to a vector.

Parameters
ua vector for the values of local entries. It will be resized to hold the current vector data.

Definition at line 106 of file EigenVector.h.

107  {
108  u.resize(size());
109  toVector(u) = vec_;
110  }
IndexType size() const
return a vector length
Definition: EigenVector.h:45
Eigen::Map< const Vector > toVector(std::vector< double > const &data, Eigen::VectorXd::Index size)
Creates an Eigen mapped vector from the given data vector.
static const double u

References size(), MathLib::toVector(), MathLib::u, and vec_.

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

◆ get() [1/2]

◆ get() [2/2]

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

get entries

Definition at line 64 of file EigenVector.h.

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

References vec_.

◆ getRangeBegin()

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

return a start index of the active data range

Definition at line 48 of file EigenVector.h.

48 { return 0; }

Referenced by getIndexForComponentInSolutionVector().

◆ getRangeEnd()

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

return an end index of the active data range

Definition at line 51 of file EigenVector.h.

51 { return size(); }

References size().

Referenced by getIndexForComponentInSolutionVector().

◆ getRawVector() [1/2]

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

return a raw Eigen vector object

Definition at line 122 of file EigenVector.h.

122 { 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 125 of file EigenVector.h.

125 { return vec_; }

References vec_.

◆ operator[]() [1/2]

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

Definition at line 58 of file EigenVector.h.

58 { return vec_[rowId]; }

References vec_.

◆ operator[]() [2/2]

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

access entry

Definition at line 57 of file EigenVector.h.

57 { return vec_[rowId]; }

References vec_.

◆ set() [1/2]

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

set entries

Definition at line 83 of file EigenVector.h.

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

References set().

◆ set() [2/2]

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

set entry

Definition at line 76 of file EigenVector.h.

76 { vec_[rowId] = v; }

References MathLib::v, and vec_.

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

◆ setZero()

◆ size()

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

return a vector length

Definition at line 45 of file EigenVector.h.

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

References vec_.

Referenced by copyValues(), and getRangeEnd().

◆ write()

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

printout this equation for debugging

Definition at line 114 of file EigenVector.h.

115  {
116  std::ofstream os(filename);
117  os << vec_;
118  }

References vec_.

Member Data Documentation

◆ vec_

RawVectorType MathLib::EigenVector::vec_
private

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