simplify the implementation.

This commit is contained in:
Liu Ming 2016-05-23 10:48:51 +08:00
parent 407c7223f6
commit ca030efeb9
5 changed files with 53 additions and 143 deletions

View File

@ -18,80 +18,40 @@ namespace Opm
} }
const std::string std::string
InjectionSpecification::ControlMode2String(const ControlMode& mode) InjectionSpecification::toString(const ControlMode& mode)
{ {
std::string stringValue;
switch(mode) { switch(mode) {
case ControlMode::NONE: case ControlMode::NONE: return "NONE";
stringValue = "NONE"; case ControlMode::RATE: return "RATE";
break; case ControlMode::RESV: return "RESV";
case ControlMode::RATE: case ControlMode::BHP : return "BHP" ;
stringValue = "RATE"; case ControlMode::THP : return "THP" ;
break; case ControlMode::REIN: return "REIN";
case ControlMode::RESV: case ControlMode::VREP: return "VREP";
stringValue = "RESV"; case ControlMode::GRUP: return "GRUP";
break; case ControlMode::FLD : return "FLD" ;
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 std::string
InjectionSpecification::InjectorType2String(const InjectorType& type) InjectionSpecification::toString(const InjectorType& type)
{ {
std::string stringValue;
switch(type) { switch(type) {
case InjectorType::WATER: case InjectorType::WATER: return "WATER";
stringValue = "WATER"; case InjectorType::OIL : return "OIL" ;
break; case InjectorType::GAS : return "GAS" ;
case InjectorType::OIL:
stringValue = "OIL";
break;
case InjectorType::GAS:
stringValue = "GAS";
break;
} }
return stringValue;
} }
const std::string std::string
InjectionSpecification::GuideRateType2String(const GuideRateType& type) InjectionSpecification::toString(const GuideRateType& type)
{ {
std::string stringValue;
switch(type) { switch(type) {
case GuideRateType::RAT: case GuideRateType::RAT : return "RAT" ;
stringValue = "RAT"; case GuideRateType::NONE_GRT: return "NONE_GRT";
break;
case GuideRateType::NONE_GRT:
stringValue = "NONE_GRT";
break;
} }
return stringValue;
} }
} // namespace Opm } // namespace Opm

View File

@ -26,9 +26,9 @@ namespace Opm
}; };
InjectionSpecification(); InjectionSpecification();
const std::string ControlMode2String(const ControlMode& mode); std::string toString(const ControlMode& mode);
const std::string InjectorType2String(const InjectorType& type); std::string toString(const InjectorType& type);
const std::string GuideRateType2String(const GuideRateType& type); std::string toString(const GuideRateType& type);
InjectorType injector_type_; InjectorType injector_type_;
ControlMode control_mode_; ControlMode control_mode_;
double surface_flow_max_rate_; double surface_flow_max_rate_;

View File

@ -20,96 +20,46 @@ namespace Opm
} }
const std::string std::string
ProductionSpecification::ControlMode2String(const ControlMode& mode) ProductionSpecification::toString(const ControlMode& mode)
{ {
std::string stringValue;
switch(mode) { switch(mode) {
case ControlMode::NONE: case ControlMode::NONE: return "NONE";
stringValue = "NONE"; case ControlMode::ORAT: return "ORAT";
break; case ControlMode::WRAT: return "WRAT";
case ControlMode::ORAT: case ControlMode::GRAT: return "GRAT";
stringValue = "ORAT"; case ControlMode::LRAT: return "LRAT";
break; case ControlMode::CRAT: return "CRAT";
case ControlMode::WRAT: case ControlMode::RESV: return "RESV";
stringValue = "WRAT"; case ControlMode::PRBL: return "RPBL";
break; case ControlMode::BHP : return "BHP" ;
case ControlMode::GRAT: case ControlMode::THP : return "THP" ;
stringValue = "GRAT"; case ControlMode::GRUP: return "GRUP";
break; case ControlMode::FLD : return "FLD" ;
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 std::string
ProductionSpecification::Procedure2String(const Procedure& type) ProductionSpecification::toString(const Procedure& type)
{ {
std::string stringValue;
switch(type) { switch(type) {
case Procedure::NONE_P: case Procedure::NONE_P: return "NONE_P";
stringValue = "NONE_P"; case Procedure::RATE : return "RATE" ;
break; case Procedure::WELL : return "WELL" ;
case Procedure::RATE:
stringValue = "RATE";
break;
case Procedure::WELL:
stringValue = "WELL";
break;
} }
return stringValue;
} }
const std::string std::string
ProductionSpecification::GuideRateType2String(const GuideRateType& type) ProductionSpecification::toString(const GuideRateType& type)
{ {
std::string stringValue;
switch(type) { switch(type) {
case GuideRateType::OIL: case GuideRateType::OIL : return "OIL" ;
stringValue = "OIL"; case GuideRateType::GAS : return "GAS" ;
break; case GuideRateType::WATER : return "WATER" ;
case GuideRateType::GAS: case GuideRateType::NONE_GRT: return "NONE_GRT";
stringValue = "GAS";
break;
case GuideRateType::WATER:
stringValue = "WATER";
break;
case GuideRateType::NONE_GRT:
stringValue = "NONE_GRT";
break;
} }
return stringValue;
} }

View File

@ -26,9 +26,9 @@ namespace Opm
}; };
ProductionSpecification(); ProductionSpecification();
const std::string ControlMode2String(const ControlMode& mode); std::string toString(const ControlMode& mode);
const std::string Procedure2String(const Procedure& type); std::string toString(const Procedure& type);
const std::string GuideRateType2String(const GuideRateType& type); std::string toString(const GuideRateType& type);
ControlMode control_mode_; ControlMode control_mode_;
Procedure procedure_; Procedure procedure_;

View File

@ -345,7 +345,7 @@ namespace Opm
mode); mode);
if (my_rate > target_rate) { 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 not met for group " + name() + "\n"
+ "target = " + std::to_string(target_rate) + "\n" + "target = " + std::to_string(target_rate) + "\n"
+ "rate = " + std::to_string(my_rate)); + "rate = " + std::to_string(my_rate));
@ -378,7 +378,7 @@ namespace Opm
child_phases_summed.surf_prod_rates, child_phases_summed.surf_prod_rates,
mode); mode);
if (std::fabs(my_rate) > target_rate) { 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 not met for group " + name() + "\n"
+ "target = " + std::to_string(target_rate) + '\n' + "target = " + std::to_string(target_rate) + '\n'
+ "rate = " + std::to_string(my_rate)); + "rate = " + std::to_string(my_rate));