diff --git a/MaterialLib/MPL/PropertyType.h b/MaterialLib/MPL/PropertyType.h index 01dbc75da1337cdc9a0ce411eb9412cb48a276da..6d8744ac2863b9f64d0a88402da747fbfdc37352 100644 --- a/MaterialLib/MPL/PropertyType.h +++ b/MaterialLib/MPL/PropertyType.h @@ -104,258 +104,6 @@ enum PropertyType : int number_of_properties }; -/// This function converts a string (e.g. a string from the configuration-tree) -/// into one of the entries of the PropertyType enumerator. To avoid confusion, -/// I suggest that the syntax of the properties in the input-files (i.e. the -/// strings) have to be identical to the syntax of the entries in the -/// enumerator. -inline PropertyType convertStringToProperty(std::string const& inString) -{ - if (boost::iequals(inString, "acentric_factor")) - { - return PropertyType::acentric_factor; - } - if (boost::iequals(inString, "binary_interaction_coefficient")) - { - return PropertyType::binary_interaction_coefficient; - } - if (boost::iequals(inString, "biot_coefficient")) - { - return PropertyType::biot_coefficient; - } - if (boost::iequals(inString, "bishops_effective_stress")) - { - return PropertyType::bishops_effective_stress; - } - if (boost::iequals(inString, "brooks_corey_exponent")) - { - return PropertyType::brooks_corey_exponent; - } - if (boost::iequals(inString, "bulk_modulus")) - { - return PropertyType::bulk_modulus; - } - if (boost::iequals(inString, "capillary_pressure")) - { - return PropertyType::capillary_pressure; - } - if (boost::iequals(inString, "critical_density")) - { - return PropertyType::critical_density; - } - if (boost::iequals(inString, "critical_pressure")) - { - return PropertyType::critical_pressure; - } - if (boost::iequals(inString, "critical_temperature")) - { - return PropertyType::critical_temperature; - } - if (boost::iequals(inString, "compressibility")) - { - return PropertyType::compressibility; - } - if (boost::iequals(inString, "concentration")) - { - return PropertyType::concentration; - } - if (boost::iequals(inString, "decay_rate")) - { - return PropertyType::decay_rate; - } - if (boost::iequals(inString, "density")) - { - return PropertyType::density; - } - if (boost::iequals(inString, "diffusion")) - { - return PropertyType::diffusion; - } - if (boost::iequals(inString, "drhodT")) - { - return PropertyType::drhodT; - } - if (boost::iequals(inString, "effective_stress")) - { - return PropertyType::effective_stress; - } - if (boost::iequals(inString, "entry_pressure")) - { - return PropertyType::entry_pressure; - } - if (boost::iequals(inString, "evaporation_enthalpy")) - { - return PropertyType::evaporation_enthalpy; - } - if (boost::iequals(inString, "fredlund_parameters")) - { - return PropertyType::fredlund_parameters; - } - if (boost::iequals(inString, "heat_capacity")) - { - return PropertyType::heat_capacity; - } - if (boost::iequals(inString, "latent_heat")) - { - return PropertyType::latent_heat; - } - if (boost::iequals(inString, "longitudinal_dispersivity")) - { - return PropertyType::longitudinal_dispersivity; - } - if (boost::iequals(inString, "molality")) - { - return PropertyType::molality; - } - if (boost::iequals(inString, "molar_mass")) - { - return PropertyType::molar_mass; - } - if (boost::iequals(inString, "molar_volume")) - { - return PropertyType::molar_volume; - } - if (boost::iequals(inString, "mole_fraction")) - { - return PropertyType::mole_fraction; - } - if (boost::iequals(inString, "molecular_diffusion")) - { - return PropertyType::molecular_diffusion; - } - if (boost::iequals(inString, "name")) - { - return PropertyType::name; - } - if (boost::iequals(inString, "permeability")) - { - return PropertyType::permeability; - } - if (boost::iequals(inString, "pore_diffusion")) - { - return PropertyType::pore_diffusion; - } - if (boost::iequals(inString, "porosity")) - { - return PropertyType::porosity; - } - if (boost::iequals(inString, "phase_velocity")) - { - return PropertyType::phase_velocity; - } - if (boost::iequals(inString, "reference_density")) - { - return PropertyType::reference_density; - } - if (boost::iequals(inString, "reference_temperature")) - { - return PropertyType::reference_temperature; - } - if (boost::iequals(inString, "reference_pressure")) - { - return PropertyType::reference_pressure; - } - if (boost::iequals(inString, "relative_permeability")) - { - return PropertyType::relative_permeability; - } - if (boost::iequals(inString, "relative_permeability_nonwetting_phase")) - { - return PropertyType::relative_permeability_nonwetting_phase; - } - if (boost::iequals(inString, "residual_gas_saturation")) - { - return PropertyType::residual_gas_saturation; - } - if (boost::iequals(inString, "residual_liquid_saturation")) - { - return PropertyType::residual_liquid_saturation; - } - if (boost::iequals(inString, "retardation_factor")) - { - return PropertyType::retardation_factor; - } - if (boost::iequals(inString, "saturation")) - { - return PropertyType::saturation; - } - if (boost::iequals(inString, "saturation_micro")) - { - return PropertyType::saturation_micro; - } - if (boost::iequals(inString, "specific_heat_capacity")) - { - return PropertyType::specific_heat_capacity; - } - if (boost::iequals(inString, "specific_latent_heat")) - { - return PropertyType::specific_latent_heat; - } - if (boost::iequals(inString, "storage")) - { - return PropertyType::storage; - } - if (boost::iequals(inString, "swelling_stress_rate")) - { - return PropertyType::swelling_stress_rate; - } - if (boost::iequals(inString, "thermal_conductivity")) - { - return PropertyType::thermal_conductivity; - } - if (boost::iequals(inString, "thermal_expansivity")) - { - return PropertyType::thermal_expansivity; - } - if (boost::iequals(inString, "thermal_longitudinal_dispersivity")) - { - return PropertyType::thermal_longitudinal_dispersivity; - } - if (boost::iequals(inString, "thermal_osmosis_coefficient")) - { - return PropertyType::thermal_osmosis_coefficient; - } - if (boost::iequals(inString, "thermal_transversal_dispersivity")) - { - return PropertyType::thermal_transversal_dispersivity; - } - if (boost::iequals(inString, "transport_porosity")) - { - return PropertyType::transport_porosity; - } - if (boost::iequals(inString, "transversal_dispersivity")) - { - return PropertyType::transversal_dispersivity; - } - if (boost::iequals(inString, "vapour_pressure")) - { - return PropertyType::vapour_pressure; - } - if (boost::iequals(inString, "vapour_density")) - { - return PropertyType::vapour_density; - } - if (boost::iequals(inString, "vapour_diffusion")) - { - return PropertyType::vapour_diffusion; - } - if (boost::iequals(inString, "viscosity")) - { - return PropertyType::viscosity; - } - if (boost::iequals(inString, "volume_fraction")) - { - return PropertyType::volume_fraction; - } - - OGS_FATAL( - "The property name '{:s}' does not correspond to any known property", - inString); - - return PropertyType::number_of_properties; // to avoid the 'no return' - // warning -} - static const std::array<std::string, PropertyType::number_of_properties> property_enum_to_string{{"acentric_factor", "binary_interaction_coefficient", @@ -417,6 +165,24 @@ static const std::array<std::string, PropertyType::number_of_properties> "viscosity", "volume_fraction"}}; +/// This function converts a string (e.g. a string from the configuration-tree) +/// into one of the entries of the PropertyType enumerator. +inline PropertyType convertStringToProperty(std::string const& string) +{ + for (int i = 0; i < static_cast<int>(PropertyType::number_of_properties); + ++i) + { + if (boost::iequals(string, property_enum_to_string[i])) + { + return static_cast<PropertyType>(i); + } + } + + OGS_FATAL( + "The property name '{:s}' does not correspond to any known property", + string); +} + /// This data type is based on a std::array. It can hold pointers to objects of /// class Property or its inheritors. The size of this array is determined by /// the number of entries of the PropertyType enumerator.