OGS
MathLib::EigenVector Class Referencefinal

Detailed Description

Global vector based on Eigen vector.

Definition at line 24 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
 
IndexType getRangeEnd () const
 return an end index of the active data range
 
void setZero ()
 
double const & operator[] (IndexType rowId) const
 access entry
 
double & operator[] (IndexType rowId)
 
double get (IndexType rowId) const
 get entry
 
std::vector< double > get (std::vector< IndexType > const &indices) const
 get entries
 
void set (IndexType rowId, double v)
 set entry
 
void add (IndexType rowId, double v)
 add entry
 
template<class T_SUBVEC >
void set (const std::vector< IndexType > &pos, const T_SUBVEC &sub_vec)
 set entries
 
template<class T_SUBVEC >
void add (const std::vector< IndexType > &pos, const T_SUBVEC &sub_vec)
 add entries
 
void copyValues (std::vector< double > &u) const
 
void write (const std::string &filename) const
 write this vector to a file for debugging
 
RawVectorTypegetRawVector ()
 return a raw Eigen vector object
 
const RawVectorTypegetRawVector () const
 return a raw Eigen vector object
 

Static Public Member Functions

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

Private Attributes

RawVectorType vec_
 

Member Typedef Documentation

◆ IndexType

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

Definition at line 32 of file EigenVector.h.

◆ RawVectorType

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

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

39: vec_(length) {}
RawVectorType vec_

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

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

References add().

◆ add() [2/2]

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

add entry

Definition at line 76 of file EigenVector.h.

76{ vec_[rowId] += v; }
static const double v

References MathLib::v, and vec_.

Referenced by add(), ProcessLib::BoundaryConditionAndSourceTerm::Python::BcAndStLocalAssemblerImpl< BcOrStData, ShapeFunction, LowerOrderShapeFunction, GlobalDim >::assemble(), ProcessLib::HCNonAdvectiveFreeComponentFlowBoundaryConditionLocalAssembler< ShapeFunction, GlobalDim >::assemble(), ProcessLib::NeumannBoundaryConditionLocalAssembler< ShapeFunction, GlobalDim >::assemble(), ProcessLib::NormalTractionBoundaryCondition::NormalTractionBoundaryConditionLocalAssembler< ShapeFunctionDisplacement, GlobalDim >::assemble(), ProcessLib::RobinBoundaryConditionLocalAssembler< ShapeFunction, GlobalDim >::assemble(), ProcessLib::VariableDependentNeumannBoundaryConditionLocalAssembler< ShapeFunction, GlobalDim >::assemble(), ProcessLib::VectorMatrixAssembler::assemble(), ProcessLib::WellboreCompensateNeumannBoundaryConditionLocalAssembler< ShapeFunction, GlobalDim >::assemble(), ProcessLib::ComponentTransport::ComponentTransportLocalAssemblerInterface::assembleReactionEquation(), ProcessLib::VectorMatrixAssembler::assembleWithJacobian(), NumLib::LocalLinearLeastSquaresExtrapolator::extrapolateElement(), ProcessLib::AnchorTerm< GlobalDim >::integrate(), ProcessLib::NodalSourceTerm::integrate(), ProcessLib::VolumetricSourceTermLocalAssembler< ShapeFunction, GlobalDim >::integrate(), and ProcessLib::SmallDeformation::writeMaterialForces().

◆ copyValues()

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

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 21 of file EigenVector.cpp.

22{
23 u.resize(size());
24 toVector(u) = vec_;
25}
IndexType size() const
return a vector length
Definition EigenVector.h:42
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 61 of file EigenVector.h.

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

References vec_.

◆ getRangeBegin()

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

return a start index of the active data range

Definition at line 45 of file EigenVector.h.

45{ return 0; }

Referenced by getIndexForComponentInSolutionVector().

◆ getRangeEnd()

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

return an end index of the active data range

Definition at line 48 of file EigenVector.h.

48{ return size(); }

References size().

Referenced by getIndexForComponentInSolutionVector().

◆ getRawVector() [1/2]

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

return a raw Eigen vector object

Definition at line 111 of file EigenVector.h.

111{ return vec_; }

References vec_.

Referenced by MathLib::applyKnownSolution(), MathLib::EigenLinearSolver::solve(), 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 114 of file EigenVector.h.

114{ return vec_; }

References vec_.

◆ operator[]() [1/2]

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

Definition at line 55 of file EigenVector.h.

55{ return vec_[rowId]; }

References vec_.

◆ operator[]() [2/2]

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

access entry

Definition at line 54 of file EigenVector.h.

54{ 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 80 of file EigenVector.h.

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

References set().

◆ set() [2/2]

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

set entry

Definition at line 73 of file EigenVector.h.

73{ 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 42 of file EigenVector.h.

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

References vec_.

Referenced by copyValues(), and getRangeEnd().

◆ write()

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

write this vector to a file for debugging

Definition at line 28 of file EigenVector.cpp.

29{
30 std::ofstream os(filename);
31 os << vec_;
32}

References vec_.

Member Data Documentation

◆ vec_

RawVectorType MathLib::EigenVector::vec_
private

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