OGS
ParameterLib::MeshNodeParameter< T > Struct Template Referencefinal

Detailed Description

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

A parameter represented by a mesh property vector.

Definition at line 29 of file MeshNodeParameter.h.

#include <MeshNodeParameter.h>

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

Public Member Functions

 MeshNodeParameter (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

◆ MeshNodeParameter()

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

Definition at line 31 of file MeshNodeParameter.h.

34 : Parameter<T>(name_, &mesh), _property(property)
35 {
36 }
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::MeshNodeParameter< 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 70 of file MeshNodeParameter.h.

72 {
73 auto const n_nodes = element.getNumberOfNodes();
74 Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> result(
76
77 SpatialPosition x_position;
78 auto const nodes = element.getNodes();
79 for (unsigned i = 0; i < n_nodes; ++i)
80 {
81 x_position.setNodeID(nodes[i]->getID());
82 auto const& values = this->operator()(t, x_position);
83 result.row(i) =
84 Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, 1> const>(
85 values.data(), values.size());
86 }
87
88 return result;
89 }
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::getNodes(), ParameterLib::MeshNodeParameter< T >::getNumberOfGlobalComponents(), MeshLib::Element::getNumberOfNodes(), ParameterLib::MeshNodeParameter< T >::operator()(), and ParameterLib::SpatialPosition::setNodeID().

◆ getNumberOfGlobalComponents()

template<typename T >
int ParameterLib::MeshNodeParameter< 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 40 of file MeshNodeParameter.h.

41 {
43 }
int getNumberOfGlobalComponents() const

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

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

◆ isTimeDependent()

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

Implements ParameterLib::ParameterBase.

Definition at line 38 of file MeshNodeParameter.h.

38{ return false; }

◆ operator()()

template<typename T >
std::vector< T > ParameterLib::MeshNodeParameter< 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 45 of file MeshNodeParameter.h.

47 {
48 auto const n = pos.getNodeID();
49 if (!n)
50 {
52 "Trying to access a MeshNodeParameter but the node id is not "
53 "specified.");
54 }
55 auto const num_comp = _property.getNumberOfGlobalComponents();
56 std::vector<T> cache(num_comp);
57 for (int c = 0; c < num_comp; ++c)
58 {
59 cache[c] = _property.getComponent(*n, c);
60 }
61
62 if (!this->_coordinate_system)
63 {
64 return cache;
65 }
66
67 return this->rotateWithCoordinateSystem(cache, pos);
68 }
#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::MeshNodeParameter< T >::_property, MeshLib::PropertyVector< PROP_VAL_TYPE >::getComponent(), ParameterLib::SpatialPosition::getNodeID(), MeshLib::PropertyVectorBase::getNumberOfGlobalComponents(), OGS_FATAL, and ParameterLib::ParameterBase::rotateWithCoordinateSystem().

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

Member Data Documentation

◆ _property


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