Add functions converting integer group control modes to enum
This commit is contained in:
parent
b72460f0c8
commit
2bc338e87f
@ -79,6 +79,7 @@ enum class InjectionCMode : int {
|
||||
};
|
||||
static const std::string InjectionCMode2String( InjectionCMode enumValue );
|
||||
static InjectionCMode InjectionCModeFromString( const std::string& stringValue );
|
||||
static InjectionCMode InjectionCModeFromInt(int ecl_int);
|
||||
|
||||
|
||||
enum class ProductionCMode : int {
|
||||
@ -94,7 +95,7 @@ enum class ProductionCMode : int {
|
||||
};
|
||||
static const std::string ProductionCMode2String( ProductionCMode enumValue );
|
||||
static ProductionCMode ProductionCModeFromString( const std::string& stringValue );
|
||||
|
||||
static ProductionCMode ProductionCModeFromInt(int ecl_int);
|
||||
|
||||
enum class GuideRateTarget {
|
||||
OIL = 0,
|
||||
|
@ -17,6 +17,7 @@
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
|
||||
@ -642,6 +643,48 @@ Group::ProductionCMode Group::ProductionCModeFromString( const std::string& stri
|
||||
throw std::invalid_argument("Unknown enum state string: " + stringValue );
|
||||
}
|
||||
|
||||
Group::ProductionCMode Group::ProductionCModeFromInt(int ecl_int) {
|
||||
switch (ecl_int) {
|
||||
case 0:
|
||||
// The inverse function in AggregateGroupData also writes 0
|
||||
// for ProductionCMode::FLD.
|
||||
return ProductionCMode::NONE;
|
||||
case 1:
|
||||
return ProductionCMode::ORAT;
|
||||
case 2:
|
||||
return ProductionCMode::WRAT;
|
||||
case 3:
|
||||
return ProductionCMode::GRAT;
|
||||
case 4:
|
||||
return ProductionCMode::LRAT;
|
||||
case 5:
|
||||
return ProductionCMode::RESV;
|
||||
default:
|
||||
throw std::logic_error(fmt::format("Not recognized value: {} for PRODUCTION CMODE", ecl_int));
|
||||
}
|
||||
}
|
||||
|
||||
Group::InjectionCMode Group::InjectionCModeFromInt(int ecl_int) {
|
||||
switch (ecl_int) {
|
||||
case 0:
|
||||
// The inverse function in AggregateGroupData also writes 0
|
||||
// for InjectionCMode::FLD and InjectionCMode::SALE
|
||||
return InjectionCMode::NONE;
|
||||
case 1:
|
||||
return InjectionCMode::RATE;
|
||||
case 2:
|
||||
return InjectionCMode::RESV;
|
||||
case 3:
|
||||
return InjectionCMode::REIN;
|
||||
case 4:
|
||||
return InjectionCMode::VREP;
|
||||
case 5:
|
||||
return InjectionCMode::RESV;
|
||||
default:
|
||||
throw std::logic_error(fmt::format("Not recognized value: {} for INJECTION CMODE", ecl_int));
|
||||
}
|
||||
}
|
||||
|
||||
Group::GuideRateTarget Group::GuideRateTargetFromString( const std::string& stringValue ) {
|
||||
if (stringValue == "OIL")
|
||||
return GuideRateTarget::OIL;
|
||||
|
Loading…
Reference in New Issue
Block a user