From f55d21656117626b2338d811ba734d64562c9e00 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Fri, 20 May 2016 14:27:38 +0800 Subject: [PATCH 1/8] log the warning messages to OpmLog. --- opm/core/props/rock/RockCompressibility.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/opm/core/props/rock/RockCompressibility.cpp b/opm/core/props/rock/RockCompressibility.cpp index 03f384f4..4de39001 100644 --- a/opm/core/props/rock/RockCompressibility.cpp +++ b/opm/core/props/rock/RockCompressibility.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -64,14 +65,16 @@ namespace Opm if (rockKeyword.size() != 1) { // here it would be better not to use std::cout directly but to add the // warning to some "warning list"... - std::cout << "Can only handle a single region in ROCK ("< Date: Fri, 20 May 2016 14:30:43 +0800 Subject: [PATCH 2/8] write the parameters information into OpmLog. --- .../parameters/ParameterGroup_impl.hpp | 39 +++++-------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/opm/core/utility/parameters/ParameterGroup_impl.hpp b/opm/core/utility/parameters/ParameterGroup_impl.hpp index 7f9da7f5..388c6d5f 100644 --- a/opm/core/utility/parameters/ParameterGroup_impl.hpp +++ b/opm/core/utility/parameters/ParameterGroup_impl.hpp @@ -45,6 +45,7 @@ #include #include #include +#include namespace Opm { namespace parameter { @@ -143,9 +144,9 @@ namespace Opm { assignments.push_back(std::make_pair(name, value)); continue; } - std::cout << "WARNING: Too many assignements (' " - << ID_delimiter_assignment - << "') detected in argument " << i << ".\n"; + OpmLog::warning("WARNING: Too many assignements (' " + + ID_delimiter_assignment + + "') detected in argument " + to_string(i) +); } for (int i = 0; i < int(files.size()); ++i) { std::pair file_type = filename_split(files[i]); @@ -186,12 +187,7 @@ namespace Opm { if (parent_ != 0) { // If we have a parent, ask it instead. if (output_is_enabled_) { - //TermColors::Red(); - std::cout << name; - //TermColors::Normal(); - std::cout << " not found at " - << (path() + ID_delimiter_path) - << ", asking parent." << std::endl; + OpmLog::error(name + path() + ID_delimiter_path + ", asking parent."); } return parent_->get(name, r); } else { @@ -208,11 +204,7 @@ namespace Opm { T val = this->translate(*it, r); it->second->setUsed(); if (output_is_enabled_) { - //TermColors::Green(); - std::cout << name; - //TermColors::Normal(); - std::cout << " found at " << (path() + ID_delimiter_path) - << ", value is " << to_string(val) << std::endl; + OpmLog::info(name + " found at " + path() + ID_delimiter_path + ", value is " + to_string(val)); } return val; } else { @@ -241,11 +233,7 @@ namespace Opm { if (parent_ != 0) { // If we have a parent, ask it instead. if (output_is_enabled_) { - //TermColors::Red(); - std::cout << name; - //TermColors::Normal(); - std::cout << " not found at " << (path() + ID_delimiter_path) - << ", asking parent." << std::endl; + OpmLog::error(name + " not found at " + path() + ID_delimiter_path + ", asking parent."); } return parent_->getDefault(name, default_value, r); } else { @@ -265,11 +253,7 @@ namespace Opm { } } if (output_is_enabled_) { - //TermColors::Blue(); - std::cout << name; - //TermColors::Normal(); - std::cout << " not found. Using default value '" - << to_string(default_value) << "'." << std::endl; + OpmLog::info(name + " not found. Using default value '" + to_string(default_value) + "."); } return default_value; } @@ -277,11 +261,8 @@ namespace Opm { T val = this->translate(*it, r); it->second->setUsed(); if (output_is_enabled_) { - //TermColors::Green(); - std::cout << name; - //TermColors::Normal(); - std::cout << " found at " << (path() + ID_delimiter_path) - << ", value is '" << to_string(val) << "'." << std::endl; + OpmLog::info(name + " found at " + path() + ID_delimiter_path + + ", value is '" + to_string(val) + "'."); } return val; } else { From b7f7352b6d67c71f4594d3f1377ab872d45b6738 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Fri, 20 May 2016 16:13:37 +0800 Subject: [PATCH 3/8] Add enum to string functions. --- opm/core/wells/InjectionSpecification.cpp | 76 +++++++++++++++++ opm/core/wells/InjectionSpecification.hpp | 5 +- opm/core/wells/ProductionSpecification.cpp | 94 ++++++++++++++++++++++ opm/core/wells/ProductionSpecification.hpp | 4 + 4 files changed, 178 insertions(+), 1 deletion(-) diff --git a/opm/core/wells/InjectionSpecification.cpp b/opm/core/wells/InjectionSpecification.cpp index 34201246..12a3cf06 100644 --- a/opm/core/wells/InjectionSpecification.cpp +++ b/opm/core/wells/InjectionSpecification.cpp @@ -18,4 +18,80 @@ namespace Opm } + const std::string + InjectionSpecification::ControlMode2String(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; + } + + return stringValue; + } + + + const std::string + InjectionSpecification::InjectorType2String(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; + } + + return stringValue; + } + + + const std::string + InjectionSpecification::GuideRateType2String(const GuideRateType& type) + { + std::string stringValue; + + switch(type) { + case GuideRateType::RAT: + stringValue = "RAT"; + break; + case GuideRateType::NONE_GRT: + stringValue = "NONE_GRT"; + break; + } + + return stringValue; + } } // namespace Opm diff --git a/opm/core/wells/InjectionSpecification.hpp b/opm/core/wells/InjectionSpecification.hpp index 74d20f6a..db324233 100644 --- a/opm/core/wells/InjectionSpecification.hpp +++ b/opm/core/wells/InjectionSpecification.hpp @@ -2,6 +2,7 @@ #define OPM_INJECTORSPECIFICATION_HPP #include +#include namespace Opm { @@ -25,7 +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); 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 1c6d443a..2cccd545 100644 --- a/opm/core/wells/ProductionSpecification.cpp +++ b/opm/core/wells/ProductionSpecification.cpp @@ -19,4 +19,98 @@ namespace Opm { } + + const std::string + ProductionSpecification::ControlMode2String(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; + } + + return stringValue; + } + + + const std::string + ProductionSpecification::Procedure2String(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; + } + + return stringValue; + } + + + const std::string + ProductionSpecification::GuideRateType2String(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; + } + + return stringValue; + } + + } diff --git a/opm/core/wells/ProductionSpecification.hpp b/opm/core/wells/ProductionSpecification.hpp index 6d064a2f..5d644301 100644 --- a/opm/core/wells/ProductionSpecification.hpp +++ b/opm/core/wells/ProductionSpecification.hpp @@ -2,6 +2,7 @@ #define OPM_PRODUCTIONSPECIFICATION_HPP #include +#include namespace Opm { @@ -25,6 +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); ControlMode control_mode_; Procedure procedure_; From 341472456a29ef32eb35ec22c6e64aa24b48628e Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Fri, 20 May 2016 16:14:16 +0800 Subject: [PATCH 4/8] write well related information into OpmLog. --- .../parameters/ParameterGroup_impl.hpp | 2 +- opm/core/wells/WellsGroup.cpp | 32 ++++++++++--------- opm/core/wells/WellsManager_impl.hpp | 7 ++-- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/opm/core/utility/parameters/ParameterGroup_impl.hpp b/opm/core/utility/parameters/ParameterGroup_impl.hpp index 388c6d5f..a2452f59 100644 --- a/opm/core/utility/parameters/ParameterGroup_impl.hpp +++ b/opm/core/utility/parameters/ParameterGroup_impl.hpp @@ -146,7 +146,7 @@ namespace Opm { } OpmLog::warning("WARNING: Too many assignements (' " + ID_delimiter_assignment - + "') detected in argument " + to_string(i) +); + + "') detected in argument " + to_string(i)); } for (int i = 0; i < int(files.size()); ++i) { std::pair file_type = filename_split(files[i]); diff --git a/opm/core/wells/WellsGroup.cpp b/opm/core/wells/WellsGroup.cpp index bf80e464..ba4ae2b8 100644 --- a/opm/core/wells/WellsGroup.cpp +++ b/opm/core/wells/WellsGroup.cpp @@ -345,9 +345,10 @@ namespace Opm mode); if (my_rate > target_rate) { - std::cout << "Group " << mode<<" target not met for group " << name() << std::endl; - std::cout << "target = " << target_rate << '\n' - << "rate = " << my_rate << std::endl; + OpmLog::warning("Group " + injSpec().ControlMode2String(mode) + + " target not met for group " + name() + "\n" + + "target = " + std::to_string(target_rate) + "\n" + + "rate = " + std::to_string(my_rate)); applyInjGroupControl(mode, target_rate, true); injSpec().control_mode_ = mode; return false; @@ -377,9 +378,10 @@ namespace Opm child_phases_summed.surf_prod_rates, mode); if (std::fabs(my_rate) > target_rate) { - std::cout << "Group" << mode << " target not met for group " << name() << std::endl; - std::cout << "target = " << target_rate << '\n' - << "rate = " << my_rate << std::endl; + OpmLog::warning("Group" + prodSpec().ControlMode2String(mode) + + " target not met for group " + name() + "\n" + + "target = " + std::to_string(target_rate) + '\n' + + "rate = " + std::to_string(my_rate)); production_violated = true; production_mode_violated = mode; break; @@ -677,9 +679,9 @@ namespace Opm ctrl_violated = is_producer ? (my_target_bhp > my_well_bhp) : (my_target_bhp < my_well_bhp); if (ctrl_violated) { - std::cout << "BHP limit violated for well " << name() << ":\n"; - std::cout << "BHP limit = " << my_target_bhp << std::endl; - std::cout << "BHP = " << my_well_bhp << std::endl; + OpmLog::info("BHP limit violated for well " + name() + ":\n" + + "BHP limit = " + std::to_string(my_target_bhp) + + "BHP = " + std::to_string(my_well_bhp)); } break; } @@ -698,9 +700,9 @@ namespace Opm const double my_rate_target = well_controls_iget_target(ctrls , ctrl_index); ctrl_violated = std::fabs(my_rate) - std::fabs(my_rate_target)> std::max(std::abs(my_rate), std::abs(my_rate_target))*1e-6; if (ctrl_violated) { - std::cout << "RESERVOIR_RATE limit violated for well " << name() << ":\n"; - std::cout << "rate limit = " << my_rate_target << std::endl; - std::cout << "rate = " << my_rate << std::endl; + OpmLog::info("RESERVOIR_RATE limit violated for well " + name() + ":\n" + + "rate limit = " + std::to_string(my_rate_target) + + "rate = " + std::to_string(my_rate)); } break; } @@ -714,9 +716,9 @@ namespace Opm const double my_rate_target = well_controls_iget_target(ctrls , ctrl_index); ctrl_violated = std::fabs(my_rate) > std::fabs(my_rate_target); if (ctrl_violated) { - std::cout << "SURFACE_RATE limit violated for well " << name() << ":\n"; - std::cout << "rate limit = " << my_rate_target << std::endl; - std::cout << "rate = " << my_rate << std::endl; + OpmLog::info("SURFACE_RATE limit violated for well " + name() + ":\n" + + "rate limit = " + std::to_string(my_rate_target) + + "rate = " + std::to_string(my_rate)); } break; } diff --git a/opm/core/wells/WellsManager_impl.hpp b/opm/core/wells/WellsManager_impl.hpp index 9d919031..21c51cb2 100644 --- a/opm/core/wells/WellsManager_impl.hpp +++ b/opm/core/wells/WellsManager_impl.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -233,9 +234,9 @@ void WellsManager::createWellsFromSpecs(std::vector& wells, size_t // Check that the complete well is on this process if ( sum_completions_on_proc < completionSet->size() ) { - std::cout<< "Well "<< well->name() << " does not seem to be" - << "completely in the disjoint partition of " - << "process. Therefore we deactivate it here." << std::endl; + OpmLog::warning("Well " + well->name() + " does not seem to be" + + "completely in the disjoint partition of " + + "process. Therefore we deactivate it here."); // Mark well as not existent on this process wells_on_proc[wellIter-wells.begin()] = 0; wellperf_data[well_index_on_proc].clear(); From 97eeee516dec8a95ff9db61d5f69b43d58dbbf10 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Mon, 23 May 2016 10:47:26 +0800 Subject: [PATCH 5/8] fix indentation and messages. --- opm/core/props/rock/RockCompressibility.cpp | 2 +- opm/core/utility/parameters/ParameterGroup_impl.hpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/opm/core/props/rock/RockCompressibility.cpp b/opm/core/props/rock/RockCompressibility.cpp index 4de39001..61c3dd54 100644 --- a/opm/core/props/rock/RockCompressibility.cpp +++ b/opm/core/props/rock/RockCompressibility.cpp @@ -74,7 +74,7 @@ namespace Opm pref_ = rockKeyword.getRecord(0).getItem("PREF").getSIDouble(0); rock_comp_ = rockKeyword.getRecord(0).getItem("COMPRESSIBILITY").getSIDouble(0); } else { - OpmLog::warning("**** warning: no rock compressibility data found in deck (ROCK or ROCKTAB)."); + OpmLog::warning("No rock compressibility data found in deck (ROCK or ROCKTAB)."); } } diff --git a/opm/core/utility/parameters/ParameterGroup_impl.hpp b/opm/core/utility/parameters/ParameterGroup_impl.hpp index a2452f59..74b324e6 100644 --- a/opm/core/utility/parameters/ParameterGroup_impl.hpp +++ b/opm/core/utility/parameters/ParameterGroup_impl.hpp @@ -144,7 +144,7 @@ namespace Opm { assignments.push_back(std::make_pair(name, value)); continue; } - OpmLog::warning("WARNING: Too many assignements (' " + OpmLog::warning("Too many assignements (' " + ID_delimiter_assignment + "') detected in argument " + to_string(i)); } @@ -187,7 +187,7 @@ namespace Opm { if (parent_ != 0) { // If we have a parent, ask it instead. if (output_is_enabled_) { - OpmLog::error(name + path() + ID_delimiter_path + ", asking parent."); + OpmLog::warning(name + "not found at " + path() + ID_delimiter_path + ", asking parent."); } return parent_->get(name, r); } else { @@ -233,7 +233,7 @@ namespace Opm { if (parent_ != 0) { // If we have a parent, ask it instead. if (output_is_enabled_) { - OpmLog::error(name + " not found at " + path() + ID_delimiter_path + ", asking parent."); + OpmLog::warning(name + " not found at " + path() + ID_delimiter_path + ", asking parent."); } return parent_->getDefault(name, default_value, r); } else { @@ -253,7 +253,7 @@ namespace Opm { } } if (output_is_enabled_) { - OpmLog::info(name + " not found. Using default value '" + to_string(default_value) + "."); + OpmLog::info(name + " not found. Using default value '" + to_string(default_value) + "'."); } return default_value; } From eab67baa3b11695049966e14f9744eb00faff5ef Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Mon, 23 May 2016 10:48:51 +0800 Subject: [PATCH 6/8] 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 12a3cf06..fd85a772 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 db324233..c5c8d93b 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 2cccd545..4590e082 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 5d644301..3a5ba7e3 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 ba4ae2b8..1916b0de 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)); From 7eba8b01f5b384029e8d0b2a335d604a5c042344 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Mon, 23 May 2016 10:55:36 +0800 Subject: [PATCH 7/8] fix strange indentation. --- .../utility/parameters/ParameterGroup_impl.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/opm/core/utility/parameters/ParameterGroup_impl.hpp b/opm/core/utility/parameters/ParameterGroup_impl.hpp index 74b324e6..b324f596 100644 --- a/opm/core/utility/parameters/ParameterGroup_impl.hpp +++ b/opm/core/utility/parameters/ParameterGroup_impl.hpp @@ -144,9 +144,9 @@ namespace Opm { assignments.push_back(std::make_pair(name, value)); continue; } - OpmLog::warning("Too many assignements (' " - + ID_delimiter_assignment - + "') detected in argument " + to_string(i)); + OpmLog::warning("Too many assignements (' " + + ID_delimiter_assignment + + "') detected in argument " + to_string(i)); } for (int i = 0; i < int(files.size()); ++i) { std::pair file_type = filename_split(files[i]); @@ -187,7 +187,7 @@ namespace Opm { if (parent_ != 0) { // If we have a parent, ask it instead. if (output_is_enabled_) { - OpmLog::warning(name + "not found at " + path() + ID_delimiter_path + ", asking parent."); + OpmLog::warning(name + "not found at " + path() + ID_delimiter_path + ", asking parent."); } return parent_->get(name, r); } else { @@ -204,7 +204,7 @@ namespace Opm { T val = this->translate(*it, r); it->second->setUsed(); if (output_is_enabled_) { - OpmLog::info(name + " found at " + path() + ID_delimiter_path + ", value is " + to_string(val)); + OpmLog::info(name + " found at " + path() + ID_delimiter_path + ", value is " + to_string(val)); } return val; } else { @@ -233,7 +233,7 @@ namespace Opm { if (parent_ != 0) { // If we have a parent, ask it instead. if (output_is_enabled_) { - OpmLog::warning(name + " not found at " + path() + ID_delimiter_path + ", asking parent."); + OpmLog::warning(name + " not found at " + path() + ID_delimiter_path + ", asking parent."); } return parent_->getDefault(name, default_value, r); } else { @@ -253,7 +253,7 @@ namespace Opm { } } if (output_is_enabled_) { - OpmLog::info(name + " not found. Using default value '" + to_string(default_value) + "'."); + OpmLog::info(name + " not found. Using default value '" + to_string(default_value) + "'."); } return default_value; } @@ -261,7 +261,7 @@ namespace Opm { T val = this->translate(*it, r); it->second->setUsed(); if (output_is_enabled_) { - OpmLog::info(name + " found at " + path() + ID_delimiter_path + OpmLog::info(name + " found at " + path() + ID_delimiter_path + ", value is '" + to_string(val) + "'."); } return val; From 94ee69505a1a89ca454ed86ac0b99f48a8975e99 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Tue, 24 May 2016 09:07:28 +0800 Subject: [PATCH 8/8] make toString() method as static. --- opm/core/wells/InjectionSpecification.hpp | 6 +++--- opm/core/wells/ProductionSpecification.hpp | 6 +++--- opm/core/wells/WellsGroup.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/opm/core/wells/InjectionSpecification.hpp b/opm/core/wells/InjectionSpecification.hpp index c5c8d93b..e47900b7 100644 --- a/opm/core/wells/InjectionSpecification.hpp +++ b/opm/core/wells/InjectionSpecification.hpp @@ -26,9 +26,9 @@ namespace Opm }; InjectionSpecification(); - std::string toString(const ControlMode& mode); - std::string toString(const InjectorType& type); - std::string toString(const GuideRateType& type); + static std::string toString(const ControlMode& mode); + static std::string toString(const InjectorType& type); + static std::string toString(const GuideRateType& type); InjectorType injector_type_; ControlMode control_mode_; double surface_flow_max_rate_; diff --git a/opm/core/wells/ProductionSpecification.hpp b/opm/core/wells/ProductionSpecification.hpp index 3a5ba7e3..4bae4cae 100644 --- a/opm/core/wells/ProductionSpecification.hpp +++ b/opm/core/wells/ProductionSpecification.hpp @@ -26,9 +26,9 @@ namespace Opm }; ProductionSpecification(); - std::string toString(const ControlMode& mode); - std::string toString(const Procedure& type); - std::string toString(const GuideRateType& type); + static std::string toString(const ControlMode& mode); + static std::string toString(const Procedure& type); + static 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 1916b0de..6eef1e4f 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().toString(mode) + OpmLog::warning("Group " + InjectionSpecification::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().toString(mode) + OpmLog::warning("Group" + ProductionSpecification::toString(mode) + " target not met for group " + name() + "\n" + "target = " + std::to_string(target_rate) + '\n' + "rate = " + std::to_string(my_rate));