OGS
ParameterLib::ParameterBase Struct Referenceabstract

Detailed Description

Base class for all parameters, not an interface class. This avoids using of void* when storing parameters and convenient destruction. Its property name helps addressing the right parameter.

Definition at line 47 of file Parameter.h.

#include <Parameter.h>

Inheritance diagram for ParameterLib::ParameterBase:
[legend]
Collaboration diagram for ParameterLib::ParameterBase:
[legend]

Public Member Functions

 ParameterBase (std::string name_, MeshLib::Mesh const *mesh=nullptr)
 
virtual ~ParameterBase ()=default
 
virtual bool isTimeDependent () const =0
 
void setCoordinateSystem (CoordinateSystem const &coordinate_system)
 
virtual void initialize (std::vector< std::unique_ptr< ParameterBase > > const &)
 
MeshLib::Mesh const * mesh () const
 

Public Attributes

std::string const name
 

Protected Member Functions

std::vector< double > rotateWithCoordinateSystem (std::vector< double > const &values, SpatialPosition const &pos) const
 

Protected Attributes

std::optional< CoordinateSystem_coordinate_system
 
MeshLib::Mesh const * _mesh
 

Constructor & Destructor Documentation

◆ ParameterBase()

ParameterLib::ParameterBase::ParameterBase ( std::string name_,
MeshLib::Mesh const * mesh = nullptr )
inlineexplicit

Definition at line 49 of file Parameter.h.

51 : name(std::move(name_)), _mesh(mesh)
52 {
53 }
MeshLib::Mesh const * _mesh
Definition Parameter.h:130
std::string const name
Definition Parameter.h:73
MeshLib::Mesh const * mesh() const
Definition Parameter.h:71

◆ ~ParameterBase()

virtual ParameterLib::ParameterBase::~ParameterBase ( )
virtualdefault

Member Function Documentation

◆ initialize()

virtual void ParameterLib::ParameterBase::initialize ( std::vector< std::unique_ptr< ParameterBase > > const & )
inlinevirtual

Parameters might depend on each other; this method allows to set up the dependencies between parameters after they have been constructed.

Reimplemented in ParameterLib::CurveScaledParameter< T >, and ParameterLib::TimeDependentHeterogeneousParameter.

Definition at line 66 of file Parameter.h.

68 {
69 }

◆ isTimeDependent()

◆ mesh()

MeshLib::Mesh const * ParameterLib::ParameterBase::mesh ( ) const
inline

Definition at line 71 of file Parameter.h.

71{ return _mesh; }

References _mesh.

Referenced by ParameterLib::isDefinedOnSameMesh().

◆ rotateWithCoordinateSystem()

std::vector< double > ParameterLib::ParameterBase::rotateWithCoordinateSystem ( std::vector< double > const & values,
SpatialPosition const & pos ) const
inlineprotected

Definition at line 76 of file Parameter.h.

78 {
79 assert(!!_coordinate_system); // It is checked before calling this
80 // function.
81
82 // Don't rotate isotropic/scalar values.
83 if (values.size() == 1)
84 {
85 return {values[0]};
86 }
87 if (values.size() == 2)
88 {
89 auto const result =
90 _coordinate_system->rotateDiagonalTensor<2>(values, pos);
91 return {result(0, 0), result(0, 1), result(1, 0), result(1, 1)};
92 }
93 if (values.size() == 3)
94 {
95 auto const result =
96 _coordinate_system->rotateDiagonalTensor<3>(values, pos);
97 return {
98 result(0, 0), result(0, 1), result(0, 2),
99 result(1, 0), result(1, 1), result(1, 2),
100 result(2, 0), result(2, 1), result(2, 2),
101 };
102 }
103 if (values.size() == 4)
104 {
105 auto const result =
106 _coordinate_system->rotateTensor<2>(values, pos);
107 return {result(0, 0), result(0, 1), result(1, 0), result(1, 1)};
108 }
109 if (values.size() == 9)
110 {
111 auto const result =
112 _coordinate_system->rotateTensor<3>(values, pos);
113 return {
114 result(0, 0), result(0, 1), result(0, 2),
115 result(1, 0), result(1, 1), result(1, 2),
116 result(2, 0), result(2, 1), result(2, 2),
117 };
118 }
119 OGS_FATAL(
120 "Coordinate transformation for a {:d}-component parameter is not "
121 "implemented.",
122 values.size());
123 }
#define OGS_FATAL(...)
Definition Error.h:26
std::optional< CoordinateSystem > _coordinate_system
Definition Parameter.h:126

References _coordinate_system, and OGS_FATAL.

Referenced by ParameterLib::FunctionParameter< T >::operator()(), ParameterLib::ConstantParameter< T >::operator()(), ParameterLib::GroupBasedParameter< T, MeshItemType >::operator()(), ParameterLib::MeshElementParameter< T >::operator()(), ParameterLib::MeshNodeParameter< T >::operator()(), and ParameterLib::RandomFieldMeshElementParameter< T >::operator()().

◆ setCoordinateSystem()

void ParameterLib::ParameterBase::setCoordinateSystem ( CoordinateSystem const & coordinate_system)
inline

Definition at line 59 of file Parameter.h.

60 {
61 _coordinate_system = coordinate_system;
62 }

References _coordinate_system.

Member Data Documentation

◆ _coordinate_system

◆ _mesh

MeshLib::Mesh const* ParameterLib::ParameterBase::_mesh
protected

A mesh on which the parameter is defined. Some parameters might be mesh-independent.

Definition at line 130 of file Parameter.h.

Referenced by ParameterLib::CurveScaledParameter< T >::initialize(), and mesh().

◆ name


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