diff --git a/MaterialLib/MPL/CreateProperty.cpp b/MaterialLib/MPL/CreateProperty.cpp index 515ae33a5e302f2ea8444fccc64552fe411023d1..ec6edcbdb2537b72fbc7fcb77a425548282b64b8 100644 --- a/MaterialLib/MPL/CreateProperty.cpp +++ b/MaterialLib/MPL/CreateProperty.cpp @@ -43,41 +43,7 @@ std::unique_ptr<MaterialPropertyLib::Property> createProperty( } if (property_type == "Linear") { - auto const reference_value = - //! \ogs_file_param{properties__property__LinearProperty__reference_value} - config.getConfigParameter<double>("reference_value"); - - std::vector<MaterialPropertyLib::IndependentVariable> ivs; - auto const& independent_variables_config = - //! \ogs_file_param{properties__property__LinearProperty__independent_variables} - config.getConfigSubtree("independent_variables"); - for (auto const& independent_variable_config : - independent_variables_config.getConfigSubtreeList( - "independent_variable")) - { - auto const& variable_name = - //! \ogs_file_param{properties__property__LinearProperty__independent_variables__independent_variable__variable_name} - independent_variable_config.getConfigParameter<std::string>( - "variable_name"); - auto const reference_condition = - //! \ogs_file_param{properties__property__LinearProperty__independent_variables__independent_variable__reference_condition} - independent_variable_config.getConfigParameter<double>( - "reference_condition"); - auto const slope = - //! \ogs_file_param{properties__property__LinearProperty__independent_variables__independent_variable__slope} - independent_variable_config.getConfigParameter<double>("slope"); - - MaterialPropertyLib::Variable ivt = - MaterialPropertyLib::convertStringToVariable(variable_name); - - MaterialPropertyLib::IndependentVariable iv{ - ivt, reference_condition, slope}; - - ivs.push_back(std::move(iv)); - } - - return std::make_unique<MaterialPropertyLib::LinearProperty>( - reference_value, ivs); + return createLinearProperty(config); } if (property_type == "Exponential") diff --git a/MaterialLib/MPL/Properties/CreateLinearProperty.cpp b/MaterialLib/MPL/Properties/CreateLinearProperty.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d4c004a7ca0c5823d587fdb12b3ec43cccc56581 --- /dev/null +++ b/MaterialLib/MPL/Properties/CreateLinearProperty.cpp @@ -0,0 +1,61 @@ +/** + * \file + * \author Norbert Grunwald + * \date Sep 10, 2019 + * + * \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 "BaseLib/ConfigTree.h" +#include "LinearProperty.h" + +namespace MaterialPropertyLib +{ +std::unique_ptr<LinearProperty> createLinearProperty( + BaseLib::ConfigTree const& config) +{ + config.checkConfigParameter("type", "Linear"); + DBUG("Create Linear property"); + + auto const reference_value = + //! \ogs_file_param{properties__property__LinearProperty__reference_value} + config.getConfigParameter<double>("reference_value"); + + std::vector<MaterialPropertyLib::IndependentVariable> ivs; + auto const& independent_variables_config = + //! \ogs_file_param{properties__property__LinearProperty__independent_variables} + config.getConfigSubtree("independent_variables"); + for (auto const& independent_variable_config : + independent_variables_config.getConfigSubtreeList( + "independent_variable")) + { + auto const& variable_name = + //! \ogs_file_param{properties__property__LinearProperty__independent_variables__independent_variable__variable_name} + independent_variable_config.getConfigParameter<std::string>( + "variable_name"); + auto const reference_condition = + //! \ogs_file_param{properties__property__LinearProperty__independent_variables__independent_variable__reference_condition} + independent_variable_config.getConfigParameter<double>( + "reference_condition"); + auto const slope = + //! \ogs_file_param{properties__property__LinearProperty__independent_variables__independent_variable__slope} + independent_variable_config.getConfigParameter<double>("slope"); + + MaterialPropertyLib::Variable ivt = + MaterialPropertyLib::convertStringToVariable(variable_name); + + MaterialPropertyLib::IndependentVariable iv{ivt, reference_condition, + slope}; + + ivs.push_back(std::move(iv)); + } + + return std::make_unique<MaterialPropertyLib::LinearProperty>( + reference_value, ivs); +} +} // namespace MaterialPropertyLib \ No newline at end of file diff --git a/MaterialLib/MPL/Properties/CreateLinearProperty.h b/MaterialLib/MPL/Properties/CreateLinearProperty.h new file mode 100644 index 0000000000000000000000000000000000000000..5edad81276b68bd42dc1ca62e6d3df789da2194c --- /dev/null +++ b/MaterialLib/MPL/Properties/CreateLinearProperty.h @@ -0,0 +1,30 @@ +/** + * \file + * \author Norbert Grunwald + * \date Sep 10, 2019 + * + * \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 + +namespace BaseLib +{ +class ConfigTree; +} + +namespace MaterialPropertyLib +{ +class LinearProperty; +} + +namespace MaterialPropertyLib +{ +std::unique_ptr<LinearProperty> createLinearProperty( + BaseLib::ConfigTree const& config); +} // namespace MaterialPropertyLib \ No newline at end of file diff --git a/MaterialLib/MPL/Properties/CreateProperties.h b/MaterialLib/MPL/Properties/CreateProperties.h index 50bd8e011242d46d853e0132dece9dabd0f8df37..400ceb1eaf734c65947dbb1aa96bc78dd353e8e1 100644 --- a/MaterialLib/MPL/Properties/CreateProperties.h +++ b/MaterialLib/MPL/Properties/CreateProperties.h @@ -14,3 +14,4 @@ #include "CreateConstant.h" #include "CreateIdealGasLaw.h" +#include "CreateLinearProperty.h"