diff --git a/Tests/MaterialLib/TestMPLLinearProperty.cpp b/Tests/MaterialLib/TestMPLLinearProperty.cpp new file mode 100644 index 0000000000000000000000000000000000000000..27dc0ddd63e878812ecdf85c2ead8c0f05ca43d7 --- /dev/null +++ b/Tests/MaterialLib/TestMPLLinearProperty.cpp @@ -0,0 +1,46 @@ +/** + * \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 <gtest/gtest.h> + +#include "MaterialLib/MPL/Properties/LinearProperty.h" + +TEST(MaterialPropertyLib, LinearProperty) +{ + double const y_ref = 1.0; + double const m = 1.0; + double const x_ref = 293.15; + MaterialPropertyLib::IndependentVariable const iv{ + MaterialPropertyLib::Variables::temperature, x_ref, m}; + MaterialPropertyLib::LinearProperty linear_property{y_ref, iv}; + + MaterialPropertyLib::VariableArray variable_array; + variable_array[MaterialPropertyLib::Variables::temperature] = 303.15; + ASSERT_NEAR( + boost::get<double>(linear_property.value(variable_array)), + y_ref + m * (boost::get<double>( + variable_array + [MaterialPropertyLib::Variables::temperature]) - + x_ref), + 1.e-10); + ASSERT_EQ( + boost::get<double>(linear_property.dValue( + variable_array, MaterialPropertyLib::Variables::phase_pressure)), + 0.0); + ASSERT_EQ(boost::get<double>(linear_property.dValue( + variable_array, MaterialPropertyLib::Variables::temperature)), + m); + ASSERT_EQ(boost::get<double>(linear_property.d2Value( + variable_array, + MaterialPropertyLib::Variables::temperature, + MaterialPropertyLib::Variables::temperature)), + 0.0); +} +