diff --git a/Applications/ApplicationsLib/ProjectData.cpp b/Applications/ApplicationsLib/ProjectData.cpp index d5349c55aca85d1b4dd98b3c1d8d030d4f1ed6e0..41d9256683735174f50fc91335e6aaeea70e3c57 100644 --- a/Applications/ApplicationsLib/ProjectData.cpp +++ b/Applications/ApplicationsLib/ProjectData.cpp @@ -459,7 +459,8 @@ void ProjectData::parseMedia( material_id); } - _media[material_id] = MaterialPropertyLib::createMedium(medium_config); + _media[material_id] = + MaterialPropertyLib::createMedium(medium_config, _parameters); } if (_media.empty()) diff --git a/MaterialLib/MPL/Components/GetThermalExpansivity.cpp b/MaterialLib/MPL/Components/GetThermalExpansivity.cpp index 38aa9ddb5a4a221aac19ec1fe7cf01cedc6c8f82..55a20255a4458bfcfe5b5f06fa5aa6cd7b36d8c8 100644 --- a/MaterialLib/MPL/Components/GetThermalExpansivity.cpp +++ b/MaterialLib/MPL/Components/GetThermalExpansivity.cpp @@ -13,15 +13,17 @@ #include "GetThermalExpansivity.h" +#include "MaterialLib/MPL/Phase.h" #include "MaterialLib/MPL/Phase.h" namespace MaterialPropertyLib { class Phase; -double getThermalExpansivity(Phase const& phase, - VariableArray const& vars, - const double density) +double getThermalExpansivity(Phase const& phase, VariableArray const& vars, + const double density, + ParameterLib::SpatialPosition const& pos, + double const t) { auto const thermal_expansivity_ptr = &phase.property(MaterialPropertyLib::PropertyType::thermal_expansivity); @@ -29,7 +31,7 @@ double getThermalExpansivity(Phase const& phase, // The thermal expansivity is explicitly given in the project file. if (thermal_expansivity_ptr) { - return (*thermal_expansivity_ptr).template value<double>(vars); + return (*thermal_expansivity_ptr).template value<double>(vars, pos, t); } // The thermal expansivity calculated by the density model directly. diff --git a/MaterialLib/MPL/Components/GetThermalExpansivity.h b/MaterialLib/MPL/Components/GetThermalExpansivity.h index 45ce3c11ae9a1102d803de543968923e4e999857..6f39abb5edea9660f4fa7eb07f8b1239ce18f2c4 100644 --- a/MaterialLib/MPL/Components/GetThermalExpansivity.h +++ b/MaterialLib/MPL/Components/GetThermalExpansivity.h @@ -14,6 +14,7 @@ #pragma once #include "MaterialLib/MPL/VariableType.h" // for VariableArray +#include "ParameterLib/SpatialPosition.h" namespace MaterialPropertyLib { @@ -38,7 +39,8 @@ class Phase; * \f] * where \f$\rho\f$ is the density, \f$T\f$ is the temperature. */ -double getThermalExpansivity(Phase const& phase, - VariableArray const& vars, - const double density); +double getThermalExpansivity(Phase const& phase, VariableArray const& vars, + const double density, + ParameterLib::SpatialPosition const& pos, + double const t); } // namespace MaterialPropertyLib diff --git a/MaterialLib/MPL/CreateComponent.cpp b/MaterialLib/MPL/CreateComponent.cpp index d5d3026f2469f51f61b0137a4c01516ac69a444c..9f4b3a80fcc2df016070a60e89e842b03167a603 100644 --- a/MaterialLib/MPL/CreateComponent.cpp +++ b/MaterialLib/MPL/CreateComponent.cpp @@ -14,6 +14,7 @@ #include "CreateComponent.h" #include "BaseLib/ConfigTree.h" +#include "ParameterLib/Parameter.h" #include "Components/Components.h" #include "CreateProperty.h" @@ -21,7 +22,8 @@ namespace { std::unique_ptr<MaterialPropertyLib::Component> createComponent( - BaseLib::ConfigTree const& config) + BaseLib::ConfigTree const& config, + std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters) { using namespace MaterialPropertyLib; // Parsing the component name @@ -40,7 +42,8 @@ std::unique_ptr<MaterialPropertyLib::Component> createComponent( // if specified. std::unique_ptr<PropertyArray> properties = //! \ogs_file_param{prj__media__medium__phases__phase__components__component__properties} - createProperties(config.getConfigSubtreeOptional("properties")); + createProperties(config.getConfigSubtreeOptional("properties"), + parameters); // If a name is given, it must conform with one of the derived component // names in the following list: @@ -64,7 +67,8 @@ std::unique_ptr<MaterialPropertyLib::Component> createComponent( namespace MaterialPropertyLib { std::vector<std::unique_ptr<Component>> createComponents( - boost::optional<BaseLib::ConfigTree> const& config) + boost::optional<BaseLib::ConfigTree> const& config, + std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters) { if (!config) { @@ -77,7 +81,7 @@ std::vector<std::unique_ptr<Component>> createComponents( //! \ogs_file_param{prj__media__medium__phases__phase__components__component} config->getConfigSubtreeList("component")) { - auto component = createComponent(component_config); + auto component = createComponent(component_config, parameters); if (std::find_if(components.begin(), components.end(), diff --git a/MaterialLib/MPL/CreateComponent.h b/MaterialLib/MPL/CreateComponent.h index 1109c58e69b786b69cfacb57582a0b7cb31be6f8..ab092b8dc2023ac6abf451c0ffdf86d2921cba4f 100644 --- a/MaterialLib/MPL/CreateComponent.h +++ b/MaterialLib/MPL/CreateComponent.h @@ -20,6 +20,11 @@ namespace BaseLib { class ConfigTree; } +namespace ParameterLib +{ +struct ParameterBase; +} + namespace MaterialPropertyLib { @@ -32,6 +37,8 @@ namespace MaterialPropertyLib /// Assigning a name is optional; If no name is given, a custom component /// without predefined properties is created. std::vector<std::unique_ptr<Component>> createComponents( - boost::optional<BaseLib::ConfigTree> const& config); + boost::optional<BaseLib::ConfigTree> const& config, + std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& + parameters); } // namespace MaterialPropertyLib diff --git a/MaterialLib/MPL/CreateMedium.cpp b/MaterialLib/MPL/CreateMedium.cpp index b6c8507b38c7669b69b2771b494b8cf6bd05d0ff..e4da5a500c56813a242ee83851b9653df118ad7e 100644 --- a/MaterialLib/MPL/CreateMedium.cpp +++ b/MaterialLib/MPL/CreateMedium.cpp @@ -15,6 +15,7 @@ #include <string> #include "BaseLib/ConfigTree.h" +#include "ParameterLib/Parameter.h" #include "Properties/Properties.h" @@ -23,17 +24,21 @@ namespace MaterialPropertyLib { -std::unique_ptr<Medium> createMedium(BaseLib::ConfigTree const& config) +std::unique_ptr<Medium> createMedium( + BaseLib::ConfigTree const& config, + std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters) { // Parsing the phases // Properties of phases may be not required in all the cases. //! \ogs_file_param{prj__media__medium__phases} - auto&& phases = createPhases(config.getConfigSubtreeOptional("phases")); + auto&& phases = + createPhases(config.getConfigSubtreeOptional("phases"), parameters); // Parsing medium properties, overwriting the defaults. auto&& properties = //! \ogs_file_param{prj__media__medium__properties} - createProperties(config.getConfigSubtreeOptional("properties")); + createProperties(config.getConfigSubtreeOptional("properties"), + parameters); if (phases.empty() && !properties) { diff --git a/MaterialLib/MPL/CreateMedium.h b/MaterialLib/MPL/CreateMedium.h index 6b5c7b94c0c34d80d71cf939146d00f2e296d038..6be67697fb60d4021b990a130a15d2c6e38be652 100644 --- a/MaterialLib/MPL/CreateMedium.h +++ b/MaterialLib/MPL/CreateMedium.h @@ -21,6 +21,10 @@ namespace MaterialPropertyLib { class Medium; } +namespace ParameterLib +{ +struct ParameterBase; +} namespace MaterialPropertyLib { @@ -28,5 +32,7 @@ namespace MaterialPropertyLib /// tree and calls create methods for the phase vector and the properties array. /// Medium properties are optional. If not defined, default properties are /// assigned. -std::unique_ptr<Medium> createMedium(BaseLib::ConfigTree const& config); +std::unique_ptr<Medium> createMedium( + BaseLib::ConfigTree const& config, + std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters); } // namespace MaterialPropertyLib diff --git a/MaterialLib/MPL/CreatePhase.cpp b/MaterialLib/MPL/CreatePhase.cpp index f1c9757de0f622b3e3e59077bf8e633824c87656..5c6d1d2b5b66075b63deb30effbb37b5d1930c49 100644 --- a/MaterialLib/MPL/CreatePhase.cpp +++ b/MaterialLib/MPL/CreatePhase.cpp @@ -17,6 +17,7 @@ #include <string> #include "BaseLib/ConfigTree.h" +#include "ParameterLib/Parameter.h" #include "CreateComponent.h" #include "CreateProperty.h" @@ -25,7 +26,8 @@ namespace { std::unique_ptr<MaterialPropertyLib::Phase> createPhase( - BaseLib::ConfigTree const& config) + BaseLib::ConfigTree const& config, + std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters) { using namespace MaterialPropertyLib; @@ -57,12 +59,14 @@ std::unique_ptr<MaterialPropertyLib::Phase> createPhase( // Parsing of optional components. auto components = //! \ogs_file_param{prj__media__medium__phases__phase__components} - createComponents(config.getConfigSubtreeOptional("components")); + createComponents(config.getConfigSubtreeOptional("components"), + parameters); // Properties of optional properties. auto properties = //! \ogs_file_param{prj__media__medium__phases__phase__properties} - createProperties(config.getConfigSubtreeOptional("properties")); + createProperties(config.getConfigSubtreeOptional("properties"), + parameters); if (components.empty() && !properties) { @@ -80,7 +84,8 @@ std::unique_ptr<MaterialPropertyLib::Phase> createPhase( namespace MaterialPropertyLib { std::vector<std::unique_ptr<Phase>> createPhases( - boost::optional<BaseLib::ConfigTree> const& config) + boost::optional<BaseLib::ConfigTree> const& config, + std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters) { if (!config) { @@ -93,7 +98,7 @@ std::vector<std::unique_ptr<Phase>> createPhases( //! \ogs_file_param{prj__media__medium__phases__phase} config->getConfigSubtreeList("phase")) { - auto phase = createPhase(phase_config); + auto phase = createPhase(phase_config, parameters); if (std::find_if(phases.begin(), phases.end(), diff --git a/MaterialLib/MPL/CreatePhase.h b/MaterialLib/MPL/CreatePhase.h index 4ea426ef6ce64853ff7a305980b5fb4fbe425798..22a519de1e14e6c27780f0c8b64062a588325279 100644 --- a/MaterialLib/MPL/CreatePhase.h +++ b/MaterialLib/MPL/CreatePhase.h @@ -19,6 +19,10 @@ namespace BaseLib { class ConfigTree; } +namespace ParameterLib +{ +struct ParameterBase; +} namespace MaterialPropertyLib { class Phase; @@ -37,5 +41,7 @@ namespace MaterialPropertyLib /// assigned. These default properties average the component properties, /// weighted by mole fraction. std::vector<std::unique_ptr<Phase>> createPhases( - boost::optional<BaseLib::ConfigTree> const& config); + boost::optional<BaseLib::ConfigTree> const& config, + std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& + parameters); } // namespace MaterialPropertyLib diff --git a/MaterialLib/MPL/CreateProperty.cpp b/MaterialLib/MPL/CreateProperty.cpp index d2521df40ded967e72e190052675dd644c5c94b7..3def3fe929d919f00bb7d96cb815e6957508e768 100644 --- a/MaterialLib/MPL/CreateProperty.cpp +++ b/MaterialLib/MPL/CreateProperty.cpp @@ -16,6 +16,8 @@ #include <string> #include <vector> #include "BaseLib/ConfigTree.h" +#include "ParameterLib/Parameter.h" +#include "ParameterLib/Utils.h" #include "Properties/Properties.h" @@ -26,7 +28,8 @@ namespace { std::unique_ptr<MaterialPropertyLib::Property> createProperty( - BaseLib::ConfigTree const& config) + BaseLib::ConfigTree const& config, + std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters) { using namespace MaterialPropertyLib; // Parsing the property type: @@ -170,6 +173,17 @@ std::unique_ptr<MaterialPropertyLib::Property> createProperty( reference_value, exp_data); } + if (property_type == "Parameter") + { + std::string const& parameter_name = + //! \ogs_file_param{properties__property__Parameter__parameter_name} + config.getConfigParameter<std::string>("parameter_name"); + auto const& parameter = ParameterLib::findParameter<double>( + parameter_name, parameters, 1, nullptr); + return std::make_unique<MaterialPropertyLib::ParameterProperty>( + parameter); + } + /* TODO Additional properties go here, for example: if (boost::iequals(property_type, "BilinearTemperaturePressure")) { @@ -186,7 +200,8 @@ std::unique_ptr<MaterialPropertyLib::Property> createProperty( namespace MaterialPropertyLib { std::unique_ptr<PropertyArray> createProperties( - boost::optional<BaseLib::ConfigTree> const& config) + boost::optional<BaseLib::ConfigTree> const& config, + std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters) { if (!config) { @@ -209,7 +224,7 @@ std::unique_ptr<PropertyArray> createProperties( //! \ogs_file_param{properties__property__name} property_config.getConfigParameter<std::string>("name"); // Create a new property based on the configuration subtree: - auto property = createProperty(property_config); + auto property = createProperty(property_config, parameters); // Insert the new property at the right position into the components // private PropertyArray: diff --git a/MaterialLib/MPL/CreateProperty.h b/MaterialLib/MPL/CreateProperty.h index 777e9181c67149e1f333105d43b2d439e2a71998..8db96040da8f98748c0f248d3394bdc82d370ee6 100644 --- a/MaterialLib/MPL/CreateProperty.h +++ b/MaterialLib/MPL/CreateProperty.h @@ -20,6 +20,11 @@ namespace BaseLib { class ConfigTree; } +namespace ParameterLib +{ +struct ParameterBase; +} + namespace MaterialPropertyLib { @@ -38,6 +43,8 @@ using PropertyArray = /// Then, the property name is evaluated and the property is copied into the /// properties array. std::unique_ptr<PropertyArray> createProperties( - boost::optional<BaseLib::ConfigTree> const& config); + boost::optional<BaseLib::ConfigTree> const& config, + std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& + parameters); } // namespace MaterialPropertyLib