OGS
ParameterLib::GroupBasedParameter< T, MeshItemType > Struct Template Referencefinal

Detailed Description

template<typename T, MeshLib::MeshItemType MeshItemType>
struct ParameterLib::GroupBasedParameter< T, MeshItemType >

A parameter class looking for values from indices in a property vector. This class can be used for material ID dependent parameters.

Definition at line 31 of file GroupBasedParameter.h.

#include <GroupBasedParameter.h>

Inheritance diagram for ParameterLib::GroupBasedParameter< T, MeshItemType >:
[legend]
Collaboration diagram for ParameterLib::GroupBasedParameter< T, MeshItemType >:
[legend]

Classes

struct  type
 

Public Member Functions

 GroupBasedParameter (std::string const &name_, MeshLib::Mesh const &mesh, MeshLib::PropertyVector< int > const &property, std::map< int, std::vector< double >> vec_values)
 
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. More...
 
- Public Member Functions inherited from ParameterLib::Parameter< T >
 ~Parameter () override=default
 
virtual Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > getNodalValuesOnElement (MeshLib::Element const &element, double const t) const
 Returns a matrix of values for all nodes of the given element. More...
 
 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
 

Static Private Member Functions

static std::optional< std::size_t > getMeshItemID (SpatialPosition const &pos, type< MeshLib::MeshItemType::Cell >)
 
static std::optional< std::size_t > getMeshItemID (SpatialPosition const &pos, type< MeshLib::MeshItemType::Node >)
 

Private Attributes

MeshLib::PropertyVector< int > const & _property_index
 
std::map< int, std::vector< T > > const _vec_values
 

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

◆ GroupBasedParameter()

template<typename T , MeshLib::MeshItemType MeshItemType>
ParameterLib::GroupBasedParameter< T, MeshItemType >::GroupBasedParameter ( std::string const &  name_,
MeshLib::Mesh const &  mesh,
MeshLib::PropertyVector< int > const &  property,
std::map< int, std::vector< double >>  vec_values 
)
inline

Constructing from a property vector of index and corresponding values

Parameters
name_the parameter's name
meshthe parameter's domain of definition.
propertya property vector of index for mesh items
vec_valuesa vector of values for each index

Definition at line 41 of file GroupBasedParameter.h.

46  : Parameter<T>(name_, &mesh),
47  _property_index(property),
48  _vec_values(std::move(vec_values))
49  {
50  }
std::map< int, std::vector< T > > const _vec_values
MeshLib::PropertyVector< int > const & _property_index
MeshLib::Mesh const * mesh() const
Definition: Parameter.h:70

Member Function Documentation

◆ getMeshItemID() [1/2]

template<typename T , MeshLib::MeshItemType MeshItemType>
static std::optional<std::size_t> ParameterLib::GroupBasedParameter< T, MeshItemType >::getMeshItemID ( SpatialPosition const &  pos,
type< MeshLib::MeshItemType::Cell  
)
inlinestaticprivate

Definition at line 88 of file GroupBasedParameter.h.

91  {
92  return pos.getElementID();
93  }

References ParameterLib::SpatialPosition::getElementID().

Referenced by ParameterLib::GroupBasedParameter< T, MeshItemType >::operator()().

◆ getMeshItemID() [2/2]

template<typename T , MeshLib::MeshItemType MeshItemType>
static std::optional<std::size_t> ParameterLib::GroupBasedParameter< T, MeshItemType >::getMeshItemID ( SpatialPosition const &  pos,
type< MeshLib::MeshItemType::Node  
)
inlinestaticprivate

Definition at line 95 of file GroupBasedParameter.h.

98  {
99  return pos.getNodeID();
100  }

References ParameterLib::SpatialPosition::getNodeID().

◆ getNumberOfGlobalComponents()

template<typename T , MeshLib::MeshItemType MeshItemType>
int ParameterLib::GroupBasedParameter< T, MeshItemType >::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 54 of file GroupBasedParameter.h.

55  {
56  return _vec_values.empty()
57  ? 0
58  : static_cast<int>(_vec_values.begin()->second.size());
59  }

References ParameterLib::GroupBasedParameter< T, MeshItemType >::_vec_values.

◆ isTimeDependent()

template<typename T , MeshLib::MeshItemType MeshItemType>
bool ParameterLib::GroupBasedParameter< T, MeshItemType >::isTimeDependent ( ) const
inlineoverridevirtual

Implements ParameterLib::ParameterBase.

Definition at line 52 of file GroupBasedParameter.h.

52 { return false; }

◆ operator()()

template<typename T , MeshLib::MeshItemType MeshItemType>
std::vector<T> ParameterLib::GroupBasedParameter< T, MeshItemType >::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 61 of file GroupBasedParameter.h.

63  {
64  auto const item_id = getMeshItemID(pos, type<MeshItemType>());
65  assert(item_id);
66  int const index = _property_index[item_id.value()];
67  auto const v = _vec_values.find(index);
68  if (v == _vec_values.end())
69  {
70  OGS_FATAL("No data found for the group index {:d}", index);
71  }
72  auto const& values = v->second;
73 
74  if (!this->_coordinate_system)
75  {
76  return values;
77  }
78 
79  return this->rotateWithCoordinateSystem(values, pos);
80  }
#define OGS_FATAL(...)
Definition: Error.h:26
static std::optional< std::size_t > getMeshItemID(SpatialPosition const &pos, type< MeshLib::MeshItemType::Cell >)
std::optional< CoordinateSystem > _coordinate_system
Definition: Parameter.h:125
std::vector< double > rotateWithCoordinateSystem(std::vector< double > const &values, SpatialPosition const &pos) const
Definition: Parameter.h:75

References ParameterLib::ParameterBase::_coordinate_system, ParameterLib::GroupBasedParameter< T, MeshItemType >::_property_index, ParameterLib::GroupBasedParameter< T, MeshItemType >::_vec_values, ParameterLib::GroupBasedParameter< T, MeshItemType >::getMeshItemID(), OGS_FATAL, and ParameterLib::ParameterBase::rotateWithCoordinateSystem().

Member Data Documentation

◆ _property_index

template<typename T , MeshLib::MeshItemType MeshItemType>
MeshLib::PropertyVector<int> const& ParameterLib::GroupBasedParameter< T, MeshItemType >::_property_index
private

◆ _vec_values

template<typename T , MeshLib::MeshItemType MeshItemType>
std::map<int, std::vector<T> > const ParameterLib::GroupBasedParameter< T, MeshItemType >::_vec_values
private

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