OGS
MaterialPropertyLib::Linear Class Referencefinal

Detailed Description

The linear property class. This property calculates the linear relationship. The current implementation accepts only the double datatype defined in PropertyDataType.

Definition at line 38 of file Linear.h.

#include <Linear.h>

Inheritance diagram for MaterialPropertyLib::Linear:
[legend]
Collaboration diagram for MaterialPropertyLib::Linear:
[legend]

Public Member Functions

 Linear (std::string name, PropertyDataType const &property_reference_value, std::vector< IndependentVariable > const &vs)
PropertyDataType value (VariableArray const &variable_array, ParameterLib::SpatialPosition const &, double const, double const) const override
PropertyDataType dValue (VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &, double const, double const) const override
PropertyDataType d2Value (VariableArray const &variable_array, Variable const pv1, Variable const pv2, ParameterLib::SpatialPosition const &, double const, double const) const override
Public Member Functions inherited from MaterialPropertyLib::Property
virtual ~Property ()
virtual PropertyDataType initialValue (ParameterLib::SpatialPosition const &pos, double const t) const
virtual PropertyDataType value () const
virtual PropertyDataType value (VariableArray const &variable_array, VariableArray const &variable_array_prev, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
virtual PropertyDataType dValue (VariableArray const &variable_array, VariableArray const &variable_array_prev, Variable const variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
virtual void setProperties (std::vector< std::unique_ptr< Phase > > const &phases)
 Default implementation:
void setScale (std::variant< Medium *, Phase *, Component * > scale)
template<typename T>
initialValue (ParameterLib::SpatialPosition const &pos, double const t) const
template<typename T>
value () const
template<typename T>
value (VariableArray const &variable_array, VariableArray const &variable_array_prev, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
template<typename T>
value (VariableArray const &variable_array, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
template<typename T>
dValue (VariableArray const &variable_array, VariableArray const &variable_array_prev, Variable const variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
template<typename T>
dValue (VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
template<typename T>
d2Value (VariableArray const &variable_array, Variable const &variable1, Variable const &variable2, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const

Private Attributes

std::vector< IndependentVariable > const independent_variables_

Additional Inherited Members

Protected Attributes inherited from MaterialPropertyLib::Property
std::string name_
PropertyDataType value_
 The single value of a property.
PropertyDataType dvalue_
std::variant< Medium *, Phase *, Component * > scale_

Constructor & Destructor Documentation

◆ Linear()

MaterialPropertyLib::Linear::Linear ( std::string name,
PropertyDataType const & property_reference_value,
std::vector< IndependentVariable > const & vs )

This constructor accepts single values of double data type defined in the PropertyDataType definition and sets the protected attribute value_ of the base class Property to that value.

Definition at line 69 of file Linear.cpp.

73{
74 name_ = std::move(name);
75 value_ = property_reference_value;
76}
std::vector< IndependentVariable > const independent_variables_
Definition Linear.h:72
PropertyDataType value_
The single value of a property.
Definition Property.h:292

References independent_variables_, MaterialPropertyLib::name, MaterialPropertyLib::Property::name_, and MaterialPropertyLib::Property::value_.

Member Function Documentation

◆ d2Value()

PropertyDataType MaterialPropertyLib::Linear::d2Value ( VariableArray const & variable_array,
Variable const pv1,
Variable const pv2,
ParameterLib::SpatialPosition const & ,
double const ,
double const  ) const
overridevirtual

This method will compute the second derivative of a property with respect to the given primary variables pv1 and pv2.

Reimplemented from MaterialPropertyLib::Property.

Definition at line 141 of file Linear.cpp.

145{
146 return decltype(value_){};
147}

References d2Value(), and MaterialPropertyLib::Property::value_.

Referenced by d2Value().

◆ dValue()

PropertyDataType MaterialPropertyLib::Linear::dValue ( VariableArray const & variable_array,
Variable const variable,
ParameterLib::SpatialPosition const & pos,
double const t,
double const  ) const
overridevirtual

This method will compute the derivative of a property with respect to the given primary variable.

Reimplemented from MaterialPropertyLib::Property.

Definition at line 102 of file Linear.cpp.

106{
107 auto const independent_variable = std::find_if(
110 [&variable](auto const& iv) -> bool
111 {
112 if (auto const* var_ptr = std::get_if<Variable>(&iv.type))
113 {
114 return *var_ptr == variable;
115 }
116 return false;
117 });
118
119 auto const zero = decltype(value_){};
120 if (independent_variable == independent_variables_.end())
121 {
122 return zero;
123 }
124
125 auto const& iv = *independent_variable;
126
127 double const x = iv.valueUnclamped(variable_array, pos, t);
128
129 if (iv.min && x < *iv.min)
130 {
131 return zero;
132 }
133 if (iv.max && x > *iv.max)
134 {
135 return zero;
136 }
137
138 return std::get<double>(value_) * std::get<double>(iv.slope);
139}

References independent_variables_.

◆ value()

PropertyDataType MaterialPropertyLib::Linear::value ( VariableArray const & variable_array,
ParameterLib::SpatialPosition const & pos,
double const t,
double const  ) const
overridevirtual

This method computes the value of a property depending linearly on the value of the given primary variable.

Reimplemented from MaterialPropertyLib::Property.

Definition at line 78 of file Linear.cpp.

81{
82 auto calculate_linearized_ratio =
83 [&variable_array, pos, t](double const initial_linearized_ratio,
84 auto const& iv)
85 {
86 double const x = iv.valueClamped(variable_array, pos, t);
87
88 return initial_linearized_ratio +
89 std::get<double>(iv.slope) *
90 (x - std::get<double>(iv.reference_condition));
91 };
92
93 double const linearized_ratio_to_reference_value =
94 std::accumulate(independent_variables_.begin(),
96 1.0,
97 calculate_linearized_ratio);
98
99 return std::get<double>(value_) * linearized_ratio_to_reference_value;
100}

References independent_variables_, and MaterialPropertyLib::Property::value_.

Member Data Documentation

◆ independent_variables_

std::vector<IndependentVariable> const MaterialPropertyLib::Linear::independent_variables_
private

Definition at line 72 of file Linear.h.

Referenced by Linear(), dValue(), and value().


The documentation for this class was generated from the following files: