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

[MPL] Impl. of ExponentialProperty.

parent e49383b0
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 <cmath>
#include <boost/math/special_functions/pow.hpp>
#include "MaterialLib/MPL/Properties/ExponentialProperty.h"
namespace MaterialPropertyLib
{
ExponentialProperty::ExponentialProperty(
PropertyDataType const& property_reference_value,
ExponentData const& v)
: _exponent_data(v)
{
_value = property_reference_value;
}
PropertyDataType ExponentialProperty::value(
VariableArray const& variable_array) const
{
return boost::get<double>(_value) *
std::exp(
-boost::get<double>(_exponent_data.factor) *
(boost::get<double>(
variable_array[static_cast<int>(_exponent_data.type)]) -
boost::get<double>(_exponent_data.reference_condition)));
}
PropertyDataType ExponentialProperty::dValue(
VariableArray const& variable_array, Variable const primary_variable) const
{
return _exponent_data.type == primary_variable
? -boost::get<double>(_value) *
boost::get<double>(_exponent_data.factor) *
std::exp(
-boost::get<double>(_exponent_data.factor) *
(boost::get<double>(variable_array[static_cast<int>(
_exponent_data.type)]) -
boost::get<double>(
_exponent_data.reference_condition)))
: decltype(_value){};
}
PropertyDataType ExponentialProperty::d2Value(
VariableArray const& variable_array,
Variable const pv1,
Variable const pv2) const
{
return _exponent_data.type == pv1 && _exponent_data.type == pv2
? boost::get<double>(_value) *
boost::math::pow<2>(
boost::get<double>(_exponent_data.factor)) *
std::exp(
-boost::get<double>(_exponent_data.factor) *
(boost::get<double>(variable_array[static_cast<int>(
_exponent_data.type)]) -
boost::get<double>(
_exponent_data.reference_condition)))
: 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 ExponentData
{
Variable type;
VariableType reference_condition;
VariableType factor;
};
/// The exponential property class. This property calculates the exponential
/// relationship. The current implementation accepts only the double datatype
/// defined in PropertyDataType.
class ExponentialProperty 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.
ExponentialProperty(PropertyDataType const& property_reference_value,
ExponentData 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,
Variable 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,
Variable const pv1,
Variable const pv2) const override;
private:
ExponentData const _exponent_data;
};
} // namespace MaterialPropertyLib
......@@ -14,3 +14,4 @@
#include "Constant.h"
#include "LinearProperty.h"
#include "ExponentialProperty.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