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 46 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 48 of file Parameter.h.

50  : name(std::move(name_)), _mesh(mesh)
51  {
52  }
MeshLib::Mesh const * _mesh
Definition: Parameter.h:129
std::string const name
Definition: Parameter.h:72
MeshLib::Mesh const * mesh() const
Definition: Parameter.h:70

◆ ~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::TimeDependentHeterogeneousParameter, and ParameterLib::CurveScaledParameter< T >.

Definition at line 65 of file Parameter.h.

67  {
68  }

◆ isTimeDependent()

◆ mesh()

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

Definition at line 70 of file Parameter.h.

70 { 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 75 of file Parameter.h.

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

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 58 of file Parameter.h.

59  {
60  _coordinate_system = coordinate_system;
61  }

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 129 of file Parameter.h.

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

◆ name

std::string const ParameterLib::ParameterBase::name

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