From ca030efeb995801ea5488cae71303109107c5c43 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Mon, 23 May 2016 10:48:51 +0800 Subject: [PATCH] simplify the implementation. --- opm/core/wells/InjectionSpecification.cpp | 80 +++++------------ opm/core/wells/InjectionSpecification.hpp | 6 +- opm/core/wells/ProductionSpecification.cpp | 100 ++++++--------------- opm/core/wells/ProductionSpecification.hpp | 6 +- opm/core/wells/WellsGroup.cpp | 4 +- 5 files changed, 53 insertions(+), 143 deletions(-) diff --git a/opm/core/wells/InjectionSpecification.cpp b/opm/core/wells/InjectionSpecification.cpp index 12a3cf06f..fd85a7727 100644 --- a/opm/core/wells/InjectionSpecification.cpp +++ b/opm/core/wells/InjectionSpecification.cpp @@ -18,80 +18,40 @@ namespace Opm } - const std::string - InjectionSpecification::ControlMode2String(const ControlMode& mode) + std::string + InjectionSpecification::toString(const ControlMode& mode) { - std::string stringValue; - switch(mode) { - case ControlMode::NONE: - stringValue = "NONE"; - break; - case ControlMode::RATE: - stringValue = "RATE"; - break; - case ControlMode::RESV: - stringValue = "RESV"; - break; - case ControlMode::BHP: - stringValue = "BHP"; - break; - case ControlMode::THP: - stringValue = "THP"; - break; - case ControlMode::REIN: - stringValue = "REIN"; - break; - case ControlMode::VREP: - stringValue = "VREP"; - break; - case ControlMode::GRUP: - stringValue = "GRUP"; - break; - case ControlMode::FLD: - stringValue = "FLD"; - break; + case ControlMode::NONE: return "NONE"; + case ControlMode::RATE: return "RATE"; + case ControlMode::RESV: return "RESV"; + case ControlMode::BHP : return "BHP" ; + case ControlMode::THP : return "THP" ; + case ControlMode::REIN: return "REIN"; + case ControlMode::VREP: return "VREP"; + case ControlMode::GRUP: return "GRUP"; + case ControlMode::FLD : return "FLD" ; } - - return stringValue; } - const std::string - InjectionSpecification::InjectorType2String(const InjectorType& type) + std::string + InjectionSpecification::toString(const InjectorType& type) { - std::string stringValue; - switch(type) { - case InjectorType::WATER: - stringValue = "WATER"; - break; - case InjectorType::OIL: - stringValue = "OIL"; - break; - case InjectorType::GAS: - stringValue = "GAS"; - break; + case InjectorType::WATER: return "WATER"; + case InjectorType::OIL : return "OIL" ; + case InjectorType::GAS : return "GAS" ; } - - return stringValue; } - const std::string - InjectionSpecification::GuideRateType2String(const GuideRateType& type) + std::string + InjectionSpecification::toString(const GuideRateType& type) { - std::string stringValue; - switch(type) { - case GuideRateType::RAT: - stringValue = "RAT"; - break; - case GuideRateType::NONE_GRT: - stringValue = "NONE_GRT"; - break; + case GuideRateType::RAT : return "RAT" ; + case GuideRateType::NONE_GRT: return "NONE_GRT"; } - - return stringValue; } } // namespace Opm diff --git a/opm/core/wells/InjectionSpecification.hpp b/opm/core/wells/InjectionSpecification.hpp index db3242339..c5c8d93b0 100644 --- a/opm/core/wells/InjectionSpecification.hpp +++ b/opm/core/wells/InjectionSpecification.hpp @@ -26,9 +26,9 @@ namespace Opm }; InjectionSpecification(); - const std::string ControlMode2String(const ControlMode& mode); - const std::string InjectorType2String(const InjectorType& type); - const std::string GuideRateType2String(const GuideRateType& type); + std::string toString(const ControlMode& mode); + std::string toString(const InjectorType& type); + std::string toString(const GuideRateType& type); InjectorType injector_type_; ControlMode control_mode_; double surface_flow_max_rate_; diff --git a/opm/core/wells/ProductionSpecification.cpp b/opm/core/wells/ProductionSpecification.cpp index 2cccd545d..4590e082c 100644 --- a/opm/core/wells/ProductionSpecification.cpp +++ b/opm/core/wells/ProductionSpecification.cpp @@ -20,96 +20,46 @@ namespace Opm } - const std::string - ProductionSpecification::ControlMode2String(const ControlMode& mode) + std::string + ProductionSpecification::toString(const ControlMode& mode) { - std::string stringValue; - switch(mode) { - case ControlMode::NONE: - stringValue = "NONE"; - break; - case ControlMode::ORAT: - stringValue = "ORAT"; - break; - case ControlMode::WRAT: - stringValue = "WRAT"; - break; - case ControlMode::GRAT: - stringValue = "GRAT"; - break; - case ControlMode::LRAT: - stringValue = "LRAT"; - break; - case ControlMode::CRAT: - stringValue = "CRAT"; - break; - case ControlMode::RESV: - stringValue = "RESV"; - break; - case ControlMode::PRBL: - stringValue = "RPBL"; - break; - case ControlMode::BHP: - stringValue = "BHP"; - break; - case ControlMode::THP: - stringValue = "THP"; - break; - case ControlMode::GRUP: - stringValue = "GRUP"; - break; - case ControlMode::FLD: - stringValue = "FLD"; - break; + case ControlMode::NONE: return "NONE"; + case ControlMode::ORAT: return "ORAT"; + case ControlMode::WRAT: return "WRAT"; + case ControlMode::GRAT: return "GRAT"; + case ControlMode::LRAT: return "LRAT"; + case ControlMode::CRAT: return "CRAT"; + case ControlMode::RESV: return "RESV"; + case ControlMode::PRBL: return "RPBL"; + case ControlMode::BHP : return "BHP" ; + case ControlMode::THP : return "THP" ; + case ControlMode::GRUP: return "GRUP"; + case ControlMode::FLD : return "FLD" ; } - - return stringValue; } - const std::string - ProductionSpecification::Procedure2String(const Procedure& type) + std::string + ProductionSpecification::toString(const Procedure& type) { - std::string stringValue; - switch(type) { - case Procedure::NONE_P: - stringValue = "NONE_P"; - break; - case Procedure::RATE: - stringValue = "RATE"; - break; - case Procedure::WELL: - stringValue = "WELL"; - break; + case Procedure::NONE_P: return "NONE_P"; + case Procedure::RATE : return "RATE" ; + case Procedure::WELL : return "WELL" ; } - - return stringValue; } - const std::string - ProductionSpecification::GuideRateType2String(const GuideRateType& type) + std::string + ProductionSpecification::toString(const GuideRateType& type) { - std::string stringValue; - switch(type) { - case GuideRateType::OIL: - stringValue = "OIL"; - break; - case GuideRateType::GAS: - stringValue = "GAS"; - break; - case GuideRateType::WATER: - stringValue = "WATER"; - break; - case GuideRateType::NONE_GRT: - stringValue = "NONE_GRT"; - break; + case GuideRateType::OIL : return "OIL" ; + case GuideRateType::GAS : return "GAS" ; + case GuideRateType::WATER : return "WATER" ; + case GuideRateType::NONE_GRT: return "NONE_GRT"; } - - return stringValue; } diff --git a/opm/core/wells/ProductionSpecification.hpp b/opm/core/wells/ProductionSpecification.hpp index 5d6443015..3a5ba7e36 100644 --- a/opm/core/wells/ProductionSpecification.hpp +++ b/opm/core/wells/ProductionSpecification.hpp @@ -26,9 +26,9 @@ namespace Opm }; ProductionSpecification(); - const std::string ControlMode2String(const ControlMode& mode); - const std::string Procedure2String(const Procedure& type); - const std::string GuideRateType2String(const GuideRateType& type); + std::string toString(const ControlMode& mode); + std::string toString(const Procedure& type); + std::string toString(const GuideRateType& type); ControlMode control_mode_; Procedure procedure_; diff --git a/opm/core/wells/WellsGroup.cpp b/opm/core/wells/WellsGroup.cpp index ba4ae2b8b..1916b0dec 100644 --- a/opm/core/wells/WellsGroup.cpp +++ b/opm/core/wells/WellsGroup.cpp @@ -345,7 +345,7 @@ namespace Opm mode); if (my_rate > target_rate) { - OpmLog::warning("Group " + injSpec().ControlMode2String(mode) + OpmLog::warning("Group " + injSpec().toString(mode) + " target not met for group " + name() + "\n" + "target = " + std::to_string(target_rate) + "\n" + "rate = " + std::to_string(my_rate)); @@ -378,7 +378,7 @@ namespace Opm child_phases_summed.surf_prod_rates, mode); if (std::fabs(my_rate) > target_rate) { - OpmLog::warning("Group" + prodSpec().ControlMode2String(mode) + OpmLog::warning("Group" + prodSpec().toString(mode) + " target not met for group " + name() + "\n" + "target = " + std::to_string(target_rate) + '\n' + "rate = " + std::to_string(my_rate));