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

[MPL] Pass through the Parameters needed by ParameterProperty.

parent 72b380a0
No related branches found
No related tags found
No related merge requests found
...@@ -459,7 +459,8 @@ void ProjectData::parseMedia( ...@@ -459,7 +459,8 @@ void ProjectData::parseMedia(
material_id); material_id);
} }
_media[material_id] = MaterialPropertyLib::createMedium(medium_config); _media[material_id] =
MaterialPropertyLib::createMedium(medium_config, _parameters);
} }
if (_media.empty()) if (_media.empty())
......
...@@ -13,15 +13,17 @@ ...@@ -13,15 +13,17 @@
#include "GetThermalExpansivity.h" #include "GetThermalExpansivity.h"
#include "MaterialLib/MPL/Phase.h"
#include "MaterialLib/MPL/Phase.h" #include "MaterialLib/MPL/Phase.h"
namespace MaterialPropertyLib namespace MaterialPropertyLib
{ {
class Phase; class Phase;
double getThermalExpansivity(Phase const& phase, double getThermalExpansivity(Phase const& phase, VariableArray const& vars,
VariableArray const& vars, const double density,
const double density) ParameterLib::SpatialPosition const& pos,
double const t)
{ {
auto const thermal_expansivity_ptr = auto const thermal_expansivity_ptr =
&phase.property(MaterialPropertyLib::PropertyType::thermal_expansivity); &phase.property(MaterialPropertyLib::PropertyType::thermal_expansivity);
...@@ -29,7 +31,7 @@ double getThermalExpansivity(Phase const& phase, ...@@ -29,7 +31,7 @@ double getThermalExpansivity(Phase const& phase,
// The thermal expansivity is explicitly given in the project file. // The thermal expansivity is explicitly given in the project file.
if (thermal_expansivity_ptr) 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. // The thermal expansivity calculated by the density model directly.
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#pragma once #pragma once
#include "MaterialLib/MPL/VariableType.h" // for VariableArray #include "MaterialLib/MPL/VariableType.h" // for VariableArray
#include "ParameterLib/SpatialPosition.h"
namespace MaterialPropertyLib namespace MaterialPropertyLib
{ {
...@@ -38,7 +39,8 @@ class Phase; ...@@ -38,7 +39,8 @@ class Phase;
* \f] * \f]
* where \f$\rho\f$ is the density, \f$T\f$ is the temperature. * where \f$\rho\f$ is the density, \f$T\f$ is the temperature.
*/ */
double getThermalExpansivity(Phase const& phase, double getThermalExpansivity(Phase const& phase, VariableArray const& vars,
VariableArray const& vars, const double density,
const double density); ParameterLib::SpatialPosition const& pos,
double const t);
} // namespace MaterialPropertyLib } // namespace MaterialPropertyLib
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "CreateComponent.h" #include "CreateComponent.h"
#include "BaseLib/ConfigTree.h" #include "BaseLib/ConfigTree.h"
#include "ParameterLib/Parameter.h"
#include "Components/Components.h" #include "Components/Components.h"
#include "CreateProperty.h" #include "CreateProperty.h"
...@@ -21,7 +22,8 @@ ...@@ -21,7 +22,8 @@
namespace namespace
{ {
std::unique_ptr<MaterialPropertyLib::Component> createComponent( 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; using namespace MaterialPropertyLib;
// Parsing the component name // Parsing the component name
...@@ -40,7 +42,8 @@ std::unique_ptr<MaterialPropertyLib::Component> createComponent( ...@@ -40,7 +42,8 @@ std::unique_ptr<MaterialPropertyLib::Component> createComponent(
// if specified. // if specified.
std::unique_ptr<PropertyArray> properties = std::unique_ptr<PropertyArray> properties =
//! \ogs_file_param{prj__media__medium__phases__phase__components__component__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 // If a name is given, it must conform with one of the derived component
// names in the following list: // names in the following list:
...@@ -64,7 +67,8 @@ std::unique_ptr<MaterialPropertyLib::Component> createComponent( ...@@ -64,7 +67,8 @@ std::unique_ptr<MaterialPropertyLib::Component> createComponent(
namespace MaterialPropertyLib namespace MaterialPropertyLib
{ {
std::vector<std::unique_ptr<Component>> createComponents( 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) if (!config)
{ {
...@@ -77,7 +81,7 @@ std::vector<std::unique_ptr<Component>> createComponents( ...@@ -77,7 +81,7 @@ std::vector<std::unique_ptr<Component>> createComponents(
//! \ogs_file_param{prj__media__medium__phases__phase__components__component} //! \ogs_file_param{prj__media__medium__phases__phase__components__component}
config->getConfigSubtreeList("component")) config->getConfigSubtreeList("component"))
{ {
auto component = createComponent(component_config); auto component = createComponent(component_config, parameters);
if (std::find_if(components.begin(), if (std::find_if(components.begin(),
components.end(), components.end(),
......
...@@ -20,6 +20,11 @@ namespace BaseLib ...@@ -20,6 +20,11 @@ namespace BaseLib
{ {
class ConfigTree; class ConfigTree;
} }
namespace ParameterLib
{
struct ParameterBase;
}
namespace MaterialPropertyLib namespace MaterialPropertyLib
{ {
...@@ -32,6 +37,8 @@ namespace MaterialPropertyLib ...@@ -32,6 +37,8 @@ namespace MaterialPropertyLib
/// Assigning a name is optional; If no name is given, a custom component /// Assigning a name is optional; If no name is given, a custom component
/// without predefined properties is created. /// without predefined properties is created.
std::vector<std::unique_ptr<Component>> createComponents( 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 } // namespace MaterialPropertyLib
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <string> #include <string>
#include "BaseLib/ConfigTree.h" #include "BaseLib/ConfigTree.h"
#include "ParameterLib/Parameter.h"
#include "Properties/Properties.h" #include "Properties/Properties.h"
...@@ -23,17 +24,21 @@ ...@@ -23,17 +24,21 @@
namespace MaterialPropertyLib 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 // Parsing the phases
// Properties of phases may be not required in all the cases. // Properties of phases may be not required in all the cases.
//! \ogs_file_param{prj__media__medium__phases} //! \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. // Parsing medium properties, overwriting the defaults.
auto&& properties = auto&& properties =
//! \ogs_file_param{prj__media__medium__properties} //! \ogs_file_param{prj__media__medium__properties}
createProperties(config.getConfigSubtreeOptional("properties")); createProperties(config.getConfigSubtreeOptional("properties"),
parameters);
if (phases.empty() && !properties) if (phases.empty() && !properties)
{ {
......
...@@ -21,6 +21,10 @@ namespace MaterialPropertyLib ...@@ -21,6 +21,10 @@ namespace MaterialPropertyLib
{ {
class Medium; class Medium;
} }
namespace ParameterLib
{
struct ParameterBase;
}
namespace MaterialPropertyLib namespace MaterialPropertyLib
{ {
...@@ -28,5 +32,7 @@ namespace MaterialPropertyLib ...@@ -28,5 +32,7 @@ namespace MaterialPropertyLib
/// tree and calls create methods for the phase vector and the properties array. /// tree and calls create methods for the phase vector and the properties array.
/// Medium properties are optional. If not defined, default properties are /// Medium properties are optional. If not defined, default properties are
/// assigned. /// 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 } // namespace MaterialPropertyLib
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <string> #include <string>
#include "BaseLib/ConfigTree.h" #include "BaseLib/ConfigTree.h"
#include "ParameterLib/Parameter.h"
#include "CreateComponent.h" #include "CreateComponent.h"
#include "CreateProperty.h" #include "CreateProperty.h"
...@@ -25,7 +26,8 @@ ...@@ -25,7 +26,8 @@
namespace namespace
{ {
std::unique_ptr<MaterialPropertyLib::Phase> createPhase( 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; using namespace MaterialPropertyLib;
...@@ -57,12 +59,14 @@ std::unique_ptr<MaterialPropertyLib::Phase> createPhase( ...@@ -57,12 +59,14 @@ std::unique_ptr<MaterialPropertyLib::Phase> createPhase(
// Parsing of optional components. // Parsing of optional components.
auto components = auto components =
//! \ogs_file_param{prj__media__medium__phases__phase__components} //! \ogs_file_param{prj__media__medium__phases__phase__components}
createComponents(config.getConfigSubtreeOptional("components")); createComponents(config.getConfigSubtreeOptional("components"),
parameters);
// Properties of optional properties. // Properties of optional properties.
auto properties = auto properties =
//! \ogs_file_param{prj__media__medium__phases__phase__properties} //! \ogs_file_param{prj__media__medium__phases__phase__properties}
createProperties(config.getConfigSubtreeOptional("properties")); createProperties(config.getConfigSubtreeOptional("properties"),
parameters);
if (components.empty() && !properties) if (components.empty() && !properties)
{ {
...@@ -80,7 +84,8 @@ std::unique_ptr<MaterialPropertyLib::Phase> createPhase( ...@@ -80,7 +84,8 @@ std::unique_ptr<MaterialPropertyLib::Phase> createPhase(
namespace MaterialPropertyLib namespace MaterialPropertyLib
{ {
std::vector<std::unique_ptr<Phase>> createPhases( 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) if (!config)
{ {
...@@ -93,7 +98,7 @@ std::vector<std::unique_ptr<Phase>> createPhases( ...@@ -93,7 +98,7 @@ std::vector<std::unique_ptr<Phase>> createPhases(
//! \ogs_file_param{prj__media__medium__phases__phase} //! \ogs_file_param{prj__media__medium__phases__phase}
config->getConfigSubtreeList("phase")) config->getConfigSubtreeList("phase"))
{ {
auto phase = createPhase(phase_config); auto phase = createPhase(phase_config, parameters);
if (std::find_if(phases.begin(), if (std::find_if(phases.begin(),
phases.end(), phases.end(),
......
...@@ -19,6 +19,10 @@ namespace BaseLib ...@@ -19,6 +19,10 @@ namespace BaseLib
{ {
class ConfigTree; class ConfigTree;
} }
namespace ParameterLib
{
struct ParameterBase;
}
namespace MaterialPropertyLib namespace MaterialPropertyLib
{ {
class Phase; class Phase;
...@@ -37,5 +41,7 @@ namespace MaterialPropertyLib ...@@ -37,5 +41,7 @@ namespace MaterialPropertyLib
/// assigned. These default properties average the component properties, /// assigned. These default properties average the component properties,
/// weighted by mole fraction. /// weighted by mole fraction.
std::vector<std::unique_ptr<Phase>> createPhases( 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 } // namespace MaterialPropertyLib
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "BaseLib/ConfigTree.h" #include "BaseLib/ConfigTree.h"
#include "ParameterLib/Parameter.h"
#include "ParameterLib/Utils.h"
#include "Properties/Properties.h" #include "Properties/Properties.h"
...@@ -26,7 +28,8 @@ ...@@ -26,7 +28,8 @@
namespace namespace
{ {
std::unique_ptr<MaterialPropertyLib::Property> createProperty( 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; using namespace MaterialPropertyLib;
// Parsing the property type: // Parsing the property type:
...@@ -170,6 +173,17 @@ std::unique_ptr<MaterialPropertyLib::Property> createProperty( ...@@ -170,6 +173,17 @@ std::unique_ptr<MaterialPropertyLib::Property> createProperty(
reference_value, exp_data); 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: /* TODO Additional properties go here, for example:
if (boost::iequals(property_type, "BilinearTemperaturePressure")) if (boost::iequals(property_type, "BilinearTemperaturePressure"))
{ {
...@@ -186,7 +200,8 @@ std::unique_ptr<MaterialPropertyLib::Property> createProperty( ...@@ -186,7 +200,8 @@ std::unique_ptr<MaterialPropertyLib::Property> createProperty(
namespace MaterialPropertyLib namespace MaterialPropertyLib
{ {
std::unique_ptr<PropertyArray> createProperties( 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) if (!config)
{ {
...@@ -209,7 +224,7 @@ std::unique_ptr<PropertyArray> createProperties( ...@@ -209,7 +224,7 @@ std::unique_ptr<PropertyArray> createProperties(
//! \ogs_file_param{properties__property__name} //! \ogs_file_param{properties__property__name}
property_config.getConfigParameter<std::string>("name"); property_config.getConfigParameter<std::string>("name");
// Create a new property based on the configuration subtree: // 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 // Insert the new property at the right position into the components
// private PropertyArray: // private PropertyArray:
......
...@@ -20,6 +20,11 @@ namespace BaseLib ...@@ -20,6 +20,11 @@ namespace BaseLib
{ {
class ConfigTree; class ConfigTree;
} }
namespace ParameterLib
{
struct ParameterBase;
}
namespace MaterialPropertyLib namespace MaterialPropertyLib
{ {
...@@ -38,6 +43,8 @@ using PropertyArray = ...@@ -38,6 +43,8 @@ using PropertyArray =
/// Then, the property name is evaluated and the property is copied into the /// Then, the property name is evaluated and the property is copied into the
/// properties array. /// properties array.
std::unique_ptr<PropertyArray> createProperties( 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 } // namespace MaterialPropertyLib
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