Skip to content
Snippets Groups Projects
Commit 54ec5d3c authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[MPL] Add hasPhase to medium and fluidPhase().

For some processes, like HM, there is no difference between
the gas and liquid phases, a fluid phase is sufficient.
parent 6bcb4f1c
No related branches found
No related tags found
No related merge requests found
......@@ -40,6 +40,12 @@ Phase const& Medium::phase(std::string const& name) const
return phase->name == name;
},
"Could not find phase name '" + name + "'.");
bool Medium::hasPhase(std::string const& phase_name) const
{
return std::any_of(
begin(phases_), end(phases_),
[&phase_name](auto const& phase) { return phase->name == phase_name; });
}
Property const& Medium::property(PropertyType const& p) const
......@@ -67,4 +73,19 @@ std::string Medium::description()
{
return "medium";
}
Phase const& fluidPhase(Medium const& medium)
{
if (medium.hasPhase("Gas"))
{
return medium.phase("Gas");
}
if (medium.hasPhase("AqueousLiquid"))
{
return medium.phase("AqueousLiquid");
}
OGS_FATAL(
"Neither Gas nor AqueousLiquid phase is available for the medium, but "
"a fluid phase was requested.");
}
} // namespace MaterialPropertyLib
......@@ -38,6 +38,10 @@ public:
Phase const& phase(std::size_t index) const;
/// A get-function for a particular phase by phase name.
Phase const& phase(std::string const& phase_name) const;
/// A query for a named phase.
bool hasPhase(std::string const& phase_name) const;
/// A get-function for a property. The argument refers to the name of the
/// property.
Property const& property(PropertyType const& p) const;
......@@ -107,4 +111,7 @@ void checkRequiredProperties(Medium const& medium,
}
}
/// Returns a gas or aqueous liquid phase of the given medium.
Phase const& fluidPhase(Medium const& medium);
} // 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