From 9979c505b3c61095fcca58bcbb32f2d3d9d96610 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Fri, 20 May 2016 14:27:38 +0800 Subject: [PATCH 1/6] 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 03f384f44..4de390013 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 16:13:37 +0800 Subject: [PATCH 2/6] 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 342012467..12a3cf06f 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 74d20f6a7..db3242339 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 1c6d443a5..2cccd545d 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 6d064a2f0..5d6443015 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 1cb66d2b4f805c7efbfb7a0f1b45742cd0e95aed Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Fri, 20 May 2016 16:14:16 +0800 Subject: [PATCH 3/6] write well related information into OpmLog. --- opm/core/wells/WellsGroup.cpp | 32 +++++++++++++++------------- opm/core/wells/WellsManager_impl.hpp | 7 +++--- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/opm/core/wells/WellsGroup.cpp b/opm/core/wells/WellsGroup.cpp index bf80e4640..ba4ae2b8b 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 9d9190313..21c51cb23 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 407c7223f6f0a1f067ead540583186f455a3ef6c Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Mon, 23 May 2016 10:47:26 +0800 Subject: [PATCH 4/6] fix indentation and messages. --- opm/core/props/rock/RockCompressibility.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/core/props/rock/RockCompressibility.cpp b/opm/core/props/rock/RockCompressibility.cpp index 4de390013..61c3dd54f 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)."); } } From ca030efeb995801ea5488cae71303109107c5c43 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Mon, 23 May 2016 10:48:51 +0800 Subject: [PATCH 5/6] 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)); From 7d0833f2d287c0a5dbb1874f71c44bb5fee2f73e Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Tue, 24 May 2016 09:07:28 +0800 Subject: [PATCH 6/6] 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 c5c8d93b0..e47900b7d 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 3a5ba7e36..4bae4cae5 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 1916b0dec..6eef1e4f0 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));