Skip to content
Snippets Groups Projects
Commit ea316b34 authored by Tom Fischer's avatar Tom Fischer
Browse files

[Mat/MPL] Class for linear properties.

parent e946d4c5
No related branches found
No related tags found
No related merge requests found
/**
* \file
*
* \copyright
* Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#include "MaterialLib/MPL/Properties/LinearProperty.h"
namespace MaterialPropertyLib
{
LinearProperty::LinearProperty(PropertyDataType const& property_reference_value,
IndependentVariable const& v)
: _independent_variable(v)
{
_value = property_reference_value;
}
PropertyDataType LinearProperty::value(
VariableArray const& variable_array) const
{
return boost::get<double>(_value) +
boost::get<double>(_independent_variable.slope) *
(boost::get<double>(variable_array[_independent_variable.type]) -
boost::get<double>(_independent_variable.reference_condition));
}
PropertyDataType LinearProperty::dValue(VariableArray const& /*variable_array*/,
Variables const primary_variable) const
{
return _independent_variable.type == primary_variable
? _independent_variable.slope
: decltype(_value){};
}
PropertyDataType LinearProperty::d2Value(
VariableArray const& /*variable_array*/,
Variables const /*pv1*/,
Variables const /*pv2*/) const
{
return decltype(_value){};
}
} // namespace MaterialPropertyLib
/**
* \file
*
* \copyright
* Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#pragma once
#include "MaterialLib/MPL/Property.h"
#include "MaterialLib/MPL/VariableType.h"
namespace MaterialPropertyLib
{
struct IndependentVariable
{
Variables type;
VariableType reference_condition; // scalar or vector
VariableType slope; // scalar or matrix
};
/// The linear property class. This property calculates the linear relationship.
/// The current implementation accepts only the double datatype defined in
/// PropertyDataType.
class LinearProperty final : public Property
{
public:
/// 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.
LinearProperty(PropertyDataType const& property_reference_value,
IndependentVariable const& v);
/// This method computes the value of a property depending linearly on
/// the value of the given primary variable.
PropertyDataType value(VariableArray const& variable_array) const override;
/// This method will compute the derivative of a property with respect to
/// the given primary variable.
PropertyDataType dValue(VariableArray const& variable_array,
Variables const primary_variable) const override;
/// This method will compute the second derivative of a
/// property with respect to the given primary variables pv1 and pv2.
PropertyDataType d2Value(VariableArray const& variable_array,
Variables const pv1,
Variables const pv2) const override;
private:
IndependentVariable const _independent_variable;
};
}
......@@ -13,3 +13,4 @@
#pragma once
#include "Constant.h"
#include "LinearProperty.h"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment