OGS 6.2.1-499-g3b941532c.dirty.20191012113459
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 48 of file Parameter.h.

#include <Parameter.h>

Inheritance diagram for ParameterLib::ParameterBase:
Collaboration diagram for ParameterLib::ParameterBase:

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

boost::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 50 of file Parameter.h.

52  : name(std::move(name_)), _mesh(mesh)
53  {
54  }
std::string const name
Definition: Parameter.h:74
MeshLib::Mesh const * mesh() const
Definition: Parameter.h:72
MeshLib::Mesh const * _mesh
Definition: Parameter.h:131

◆ ~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 67 of file Parameter.h.

69  {
70  }

◆ isTimeDependent()

◆ mesh()

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

Definition at line 72 of file Parameter.h.

Referenced by ParameterLib::isDefinedOnSameMesh().

72 { return _mesh; }
MeshLib::Mesh const * _mesh
Definition: Parameter.h:131

◆ rotateWithCoordinateSystem()

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

Definition at line 77 of file Parameter.h.

References OGS_FATAL.

Referenced by ParameterLib::ConstantParameter< T >::operator()(), and ParameterLib::FunctionParameter< T >::operator()().

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

◆ setCoordinateSystem()

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

Definition at line 60 of file Parameter.h.

61  {
62  _coordinate_system = coordinate_system;
63  }
boost::optional< CoordinateSystem > _coordinate_system
Definition: Parameter.h:127

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

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

◆ name


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