OGS
ParameterLib::RandomFieldMeshElementParameter< T > Struct Template Referencefinal

Detailed Description

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

A parameter represented by a mesh property vector.

Definition at line 25 of file RandomFieldMeshElementParameter.h.

#include <RandomFieldMeshElementParameter.h>

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

Public Member Functions

 RandomFieldMeshElementParameter (std::string const &name_, MeshLib::Mesh &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

◆ RandomFieldMeshElementParameter()

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

Definition at line 27 of file RandomFieldMeshElementParameter.h.

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

Member Function Documentation

◆ getNodalValuesOnElement()

template<typename T >
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > ParameterLib::RandomFieldMeshElementParameter< 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 RandomFieldMeshElementParameter.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.

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

◆ getNumberOfGlobalComponents()

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

◆ isTimeDependent()

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

Implements ParameterLib::ParameterBase.

Definition at line 34 of file RandomFieldMeshElementParameter.h.

34{ return false; }

◆ operator()()

template<typename T >
std::vector< T > ParameterLib::RandomFieldMeshElementParameter< 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 RandomFieldMeshElementParameter.h.

43 {
44 auto const e = pos.getElementID();
45 if (!e)
46 {
48 "Trying to access a RandomFieldMeshElementParameter but "
49 "the element id is 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::RandomFieldMeshElementParameter< T >::_property, MeshLib::PropertyVector< PROP_VAL_TYPE >::getComponent(), ParameterLib::SpatialPosition::getElementID(), MeshLib::PropertyVectorBase::getNumberOfGlobalComponents(), OGS_FATAL, and ParameterLib::ParameterBase::rotateWithCoordinateSystem().

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

Member Data Documentation

◆ _property


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