OGS
ParameterLib::MeshElementParameter< T > Struct Template Referencefinal

Detailed Description

template<typename T>
struct ParameterLib::MeshElementParameter< T >

A parameter represented by a mesh property vector.

Definition at line 25 of file MeshElementParameter.h.

#include <MeshElementParameter.h>

Inheritance diagram for ParameterLib::MeshElementParameter< T >:
[legend]
Collaboration diagram for ParameterLib::MeshElementParameter< T >:
[legend]

Public Member Functions

 MeshElementParameter (std::string const &name_, MeshLib::Mesh const &mesh, MeshLib::PropertyVector< T > const &property)
 
bool isTimeDependent () const override
 
int getNumberOfGlobalComponents () const override
 
std::vector< T > operator() (double const, SpatialPosition const &pos) const override
 Returns the parameter value at the given time and position.
 
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > getNodalValuesOnElement (MeshLib::Element const &element, double const t) const override
 Returns a matrix of values for all nodes of the given element.
 
- Public Member Functions inherited from ParameterLib::Parameter< T >
 ~Parameter () override=default
 
 ParameterBase (std::string name_, MeshLib::Mesh const *mesh=nullptr)
 
- Public Member Functions inherited from ParameterLib::ParameterBase
 ParameterBase (std::string name_, MeshLib::Mesh const *mesh=nullptr)
 
virtual ~ParameterBase ()=default
 
void setCoordinateSystem (CoordinateSystem const &coordinate_system)
 
virtual void initialize (std::vector< std::unique_ptr< ParameterBase > > const &)
 
MeshLib::Mesh const * mesh () const
 

Private Attributes

MeshLib::PropertyVector< T > const & _property
 

Additional Inherited Members

- Public Attributes inherited from ParameterLib::ParameterBase
std::string const name
 
- Protected Member Functions inherited from ParameterLib::ParameterBase
std::vector< double > rotateWithCoordinateSystem (std::vector< double > const &values, SpatialPosition const &pos) const
 
- Protected Attributes inherited from ParameterLib::ParameterBase
std::optional< CoordinateSystem_coordinate_system
 
MeshLib::Mesh const * _mesh
 

Constructor & Destructor Documentation

◆ MeshElementParameter()

template<typename T >
ParameterLib::MeshElementParameter< T >::MeshElementParameter ( std::string const & name_,
MeshLib::Mesh const & mesh,
MeshLib::PropertyVector< T > const & property )
inline

Definition at line 27 of file MeshElementParameter.h.

30 : Parameter<T>(name_, &mesh), _property(property)
31 {
32 }
MeshLib::PropertyVector< T > const & _property
MeshLib::Mesh const * mesh() const
Definition Parameter.h:71

Member Function Documentation

◆ getNodalValuesOnElement()

template<typename T >
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > ParameterLib::MeshElementParameter< T >::getNodalValuesOnElement ( MeshLib::Element const & element,
double const t ) const
inlineoverridevirtual

Returns a matrix of values for all nodes of the given element.

Reimplemented from ParameterLib::Parameter< T >.

Definition at line 66 of file MeshElementParameter.h.

68 {
69 auto const n_nodes = element.getNumberOfNodes();
70 Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> result(
72
73 // Column vector of values, copied for each node.
74 SpatialPosition x_position;
75 x_position.setElementID(element.getID());
76 auto const& values = this->operator()(t, x_position);
77 auto const row_values =
78 Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, 1> const>(
79 values.data(), values.size());
80 for (unsigned i = 0; i < n_nodes; ++i)
81 {
82 result.row(i) = row_values;
83 }
84 return result;
85 }
std::vector< T > operator()(double const, SpatialPosition const &pos) const override
Returns the parameter value at the given time and position.
int getNumberOfGlobalComponents() const override

References MeshLib::Element::getID(), ParameterLib::MeshElementParameter< T >::getNumberOfGlobalComponents(), MeshLib::Element::getNumberOfNodes(), ParameterLib::MeshElementParameter< T >::operator()(), and ParameterLib::SpatialPosition::setElementID().

◆ getNumberOfGlobalComponents()

template<typename T >
int ParameterLib::MeshElementParameter< T >::getNumberOfGlobalComponents ( ) const
inlineoverridevirtual

Returns the number of components this Parameter has at every position and point in time.

Implements ParameterLib::Parameter< T >.

Definition at line 36 of file MeshElementParameter.h.

37 {
39 }
int getNumberOfGlobalComponents() const

References ParameterLib::MeshElementParameter< T >::_property, and MeshLib::PropertyVectorBase::getNumberOfGlobalComponents().

Referenced by ParameterLib::MeshElementParameter< T >::getNodalValuesOnElement().

◆ isTimeDependent()

template<typename T >
bool ParameterLib::MeshElementParameter< T >::isTimeDependent ( ) const
inlineoverridevirtual

Implements ParameterLib::ParameterBase.

Definition at line 34 of file MeshElementParameter.h.

34{ return false; }

◆ operator()()

template<typename T >
std::vector< T > ParameterLib::MeshElementParameter< T >::operator() ( double const t,
SpatialPosition const & pos ) const
inlineoverridevirtual

Returns the parameter value at the given time and position.

Implements ParameterLib::Parameter< T >.

Definition at line 41 of file MeshElementParameter.h.

43 {
44 auto const e = pos.getElementID();
45 if (!e)
46 {
48 "Trying to access a MeshElementParameter but the element id is "
49 "not specified.");
50 }
51 auto const num_comp = _property.getNumberOfGlobalComponents();
52 std::vector<T> cache(num_comp);
53 for (int c = 0; c < num_comp; ++c)
54 {
55 cache[c] = _property.getComponent(*e, c);
56 }
57
58 if (!this->_coordinate_system)
59 {
60 return cache;
61 }
62
63 return this->rotateWithCoordinateSystem(cache, pos);
64 }
#define OGS_FATAL(...)
Definition Error.h:26
PROP_VAL_TYPE & getComponent(std::size_t tuple_index, int component)
Returns the value for the given component stored in the given tuple.
std::vector< double > rotateWithCoordinateSystem(std::vector< double > const &values, SpatialPosition const &pos) const
Definition Parameter.h:76
std::optional< CoordinateSystem > _coordinate_system
Definition Parameter.h:126

References ParameterLib::ParameterBase::_coordinate_system, ParameterLib::MeshElementParameter< T >::_property, MeshLib::PropertyVector< PROP_VAL_TYPE >::getComponent(), ParameterLib::SpatialPosition::getElementID(), MeshLib::PropertyVectorBase::getNumberOfGlobalComponents(), OGS_FATAL, and ParameterLib::ParameterBase::rotateWithCoordinateSystem().

Referenced by ParameterLib::MeshElementParameter< T >::getNodalValuesOnElement().

Member Data Documentation

◆ _property


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