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

[MPL] Rewrite string to Variable conversion.

parent 1382ea0c
No related branches found
No related tags found
No related merge requests found
......@@ -16,65 +16,18 @@
namespace MaterialPropertyLib
{
Variable convertStringToVariable(std::string const& input)
Variable convertStringToVariable(std::string const& string)
{
if (boost::iequals(input, "concentration"))
for (int i = 0; i < static_cast<int>(Variable::number_of_variables); ++i)
{
return Variable::concentration;
}
if (boost::iequals(input, "phase_pressure"))
{
return Variable::phase_pressure;
}
if (boost::iequals(input, "liquid_phase_pressure"))
{
return Variable::liquid_phase_pressure;
}
if (boost::iequals(input, "capillary_pressure"))
{
return Variable::capillary_pressure;
}
if (boost::iequals(input, "density"))
{
return Variable::density;
}
if (boost::iequals(input, "equivalent_plastic_strain"))
{
return Variable::equivalent_plastic_strain;
}
if (boost::iequals(input, "temperature"))
{
return Variable::temperature;
}
if (boost::iequals(input, "molar_mass"))
{
return Variable::molar_mass;
}
if (boost::iequals(input, "liquid_saturation"))
{
return Variable::liquid_saturation;
}
if (boost::iequals(input, "displacement"))
{
return Variable::displacement;
}
if (boost::iequals(input, "grain_compressibility"))
{
return Variable::grain_compressibility;
}
if (boost::iequals(input, "solid_grain_pressure"))
{
return Variable::solid_grain_pressure;
}
if (boost::iequals(input, "vapour_pressure"))
{
return Variable::vapour_pressure;
if (boost::iequals(string, variable_enum_to_string[i]))
{
return static_cast<Variable>(i);
}
}
OGS_FATAL(
"The variable name '{:s}' does not correspond to any known variable",
input);
return Variable::number_of_variables; // to avoid the 'no return' warning
string);
}
} // namespace MaterialPropertyLib
......@@ -107,5 +107,7 @@ using VariableType =
using VariableArray =
std::array<VariableType, static_cast<int>(Variable::number_of_variables)>;
Variable convertStringToVariable(std::string const& input);
/// This function converts a string (e.g. a string from the configuration-tree)
/// into one of the entries of the VariableType enumerator.
Variable convertStringToVariable(std::string const& string);
} // 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