From 1b7862504c89092fc2078e848e0fb42d4e171c87 Mon Sep 17 00:00:00 2001 From: Kjetil Olsen Lye Date: Wed, 28 Mar 2012 10:55:43 +0200 Subject: [PATCH 1/2] Added reading of Gconinje --- opm/core/eclipse/EclipseGridParser.cpp | 2 +- opm/core/eclipse/EclipseGridParser.hpp | 1 + opm/core/eclipse/SpecialEclipseFields.hpp | 96 +++++++++++++++++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) diff --git a/opm/core/eclipse/EclipseGridParser.cpp b/opm/core/eclipse/EclipseGridParser.cpp index 7734925c..22b7e319 100644 --- a/opm/core/eclipse/EclipseGridParser.cpp +++ b/opm/core/eclipse/EclipseGridParser.cpp @@ -98,7 +98,7 @@ namespace EclipseKeywords string("EQUIL"), string("PVCDO"), string("TSTEP"), string("PLYVISC"), string("PLYROCK"), string("PLYADS"), string("PLYMAX"), string("TLMIXPAR"), string("WPOLYMER"), - string("GRUPTREE"), + string("GRUPTREE"), string("GCONINJE"), // The following fields only have a dummy implementation // that allows us to ignore them. string("SWFN"), diff --git a/opm/core/eclipse/EclipseGridParser.hpp b/opm/core/eclipse/EclipseGridParser.hpp index 22b68e80..b38adb4c 100644 --- a/opm/core/eclipse/EclipseGridParser.hpp +++ b/opm/core/eclipse/EclipseGridParser.hpp @@ -150,6 +150,7 @@ public: SPECIAL_FIELD(TLMIXPAR); SPECIAL_FIELD(WPOLYMER); SPECIAL_FIELD(GRUPTREE); + SPECIAL_FIELD(GCONINJE); // The following fields only have a dummy implementation // that allows us to ignore them. diff --git a/opm/core/eclipse/SpecialEclipseFields.hpp b/opm/core/eclipse/SpecialEclipseFields.hpp index 703474dc..57291649 100644 --- a/opm/core/eclipse/SpecialEclipseFields.hpp +++ b/opm/core/eclipse/SpecialEclipseFields.hpp @@ -990,6 +990,102 @@ struct COMPDAT : public SpecialBase } }; + + +/// Class holding a data line of keyword WCONINJE +struct GconinjeLine +{ + std::string group_; // Well name or well name root + std::string injector_type_; // Injector type + std::string control_mode_; // Control mode + double surface_flow_max_rate_; // Surface flow rate target or upper limit + + double reinjection_fraction_target_; + + // Default values + GconinjeLine() : + surface_flow_max_rate_(1.0E20), reinjection_fraction_target_(1E20) + { + } +}; + +/// Class for keyword WCONINJE +struct GCONINJE : public SpecialBase +{ + std::vector gconinje; + + GCONINJE() + { + } + + virtual ~GCONINJE() + {} + + virtual std::string name() const {return std::string("GCONINJE");} + + virtual void read(std::istream& is) + { + while(is) { + std::cout<< "here" << std::endl; + std::string groupname = readString(is); + if (groupname[0] == '/') { + std::cout << "And we're out" << std::endl; + is >> ignoreLine; + break; + } + while (groupname.find("--") == 0) { + // This line is a comment + is >> ignoreLine; + groupname = readString(is); + } + GconinjeLine gconinje_line; + gconinje_line.group_ = groupname; + gconinje_line.injector_type_ = readString(is); + gconinje_line.control_mode_ = readString(is); + std::vector double_data(10, 1.0E20); + const int num_to_read = 10; + int num_read = readDefaultedVectorData(is, double_data, num_to_read); + gconinje_line.surface_flow_max_rate_ = double_data[0]; + gconinje_line.reinjection_fraction_target_ = double_data[2]; + // HACK! Ignore any further items + if (num_read == num_to_read) { + ignoreSlashLine(is); + } + gconinje.push_back(gconinje_line); + + } + + } + + virtual void write(std::ostream& os) const + { + os << name() << std::endl; + for (int i=0; i<(int) gconinje.size(); ++i) { + os << gconinje[i].group_ << " " + << gconinje[i].injector_type_ << " " + << gconinje[i].control_mode_ << " " + << gconinje[i].surface_flow_max_rate_ << " " + << gconinje[i].reinjection_fraction_target_ + << std::endl; + } + os << std::endl; + } + + virtual void convertToSI(const EclipseUnits& units) + { + for (int i=0; i<(int) gconinje.size(); ++i) { + if (gconinje[i].injector_type_ == "GAS") { + gconinje[i].surface_flow_max_rate_ *= units.gasvol_s/units.time; + } else { + gconinje[i].surface_flow_max_rate_ *= units.liqvol_s/units.time; + } + } + } +}; + + + + /// Class holding a data line of keyword WCONINJE struct WconinjeLine { From c8210a3a9a2a0286f93bfd15be40558b9e34d30c Mon Sep 17 00:00:00 2001 From: Kjetil Olsen Lye Date: Wed, 28 Mar 2012 12:38:48 +0200 Subject: [PATCH 2/2] Fixed some warnings and added GCONPROD reading for the eclipse parser --- opm/core/InjectionSpecification.cpp | 3 - opm/core/InjectionSpecification.hpp | 1 - opm/core/eclipse/EclipseGridParser.cpp | 2 +- opm/core/eclipse/EclipseGridParser.hpp | 1 + opm/core/eclipse/SpecialEclipseFields.hpp | 114 +++++++++++++++++++++- 5 files changed, 114 insertions(+), 7 deletions(-) diff --git a/opm/core/InjectionSpecification.cpp b/opm/core/InjectionSpecification.cpp index 2d6cf769..22d9ead0 100644 --- a/opm/core/InjectionSpecification.cpp +++ b/opm/core/InjectionSpecification.cpp @@ -7,9 +7,6 @@ reinjection_fraction_target_(0.0), BHP_target_(0.0) { } -InjectionSpecification::InjectionSpecification(const InjectionSpecification& orig) { -} - InjectionSpecification::~InjectionSpecification() { } diff --git a/opm/core/InjectionSpecification.hpp b/opm/core/InjectionSpecification.hpp index 728df76a..768495bd 100644 --- a/opm/core/InjectionSpecification.hpp +++ b/opm/core/InjectionSpecification.hpp @@ -14,7 +14,6 @@ public: }; InjectionSpecification(); - InjectionSpecification(const InjectionSpecification& orig); virtual ~InjectionSpecification(); Component component(); diff --git a/opm/core/eclipse/EclipseGridParser.cpp b/opm/core/eclipse/EclipseGridParser.cpp index 22b7e319..b6ef5846 100644 --- a/opm/core/eclipse/EclipseGridParser.cpp +++ b/opm/core/eclipse/EclipseGridParser.cpp @@ -98,7 +98,7 @@ namespace EclipseKeywords string("EQUIL"), string("PVCDO"), string("TSTEP"), string("PLYVISC"), string("PLYROCK"), string("PLYADS"), string("PLYMAX"), string("TLMIXPAR"), string("WPOLYMER"), - string("GRUPTREE"), string("GCONINJE"), + string("GRUPTREE"), string("GCONINJE"), string("GCONPROD"), // The following fields only have a dummy implementation // that allows us to ignore them. string("SWFN"), diff --git a/opm/core/eclipse/EclipseGridParser.hpp b/opm/core/eclipse/EclipseGridParser.hpp index b38adb4c..b466a4be 100644 --- a/opm/core/eclipse/EclipseGridParser.hpp +++ b/opm/core/eclipse/EclipseGridParser.hpp @@ -151,6 +151,7 @@ public: SPECIAL_FIELD(WPOLYMER); SPECIAL_FIELD(GRUPTREE); SPECIAL_FIELD(GCONINJE); + SPECIAL_FIELD(GCONPROD); // The following fields only have a dummy implementation // that allows us to ignore them. diff --git a/opm/core/eclipse/SpecialEclipseFields.hpp b/opm/core/eclipse/SpecialEclipseFields.hpp index 57291649..64a8a918 100644 --- a/opm/core/eclipse/SpecialEclipseFields.hpp +++ b/opm/core/eclipse/SpecialEclipseFields.hpp @@ -1026,10 +1026,8 @@ struct GCONINJE : public SpecialBase virtual void read(std::istream& is) { while(is) { - std::cout<< "here" << std::endl; std::string groupname = readString(is); if (groupname[0] == '/') { - std::cout << "And we're out" << std::endl; is >> ignoreLine; break; } @@ -1199,6 +1197,118 @@ struct WCONINJE : public SpecialBase } }; + + +/// Class holding a data line of keyword WCONPROD +struct GconprodLine +{ + std::string group_; // Well name or well name root + std::string control_mode_; // Control mode + double oil_max_rate_; // Oil rate target or upper limit + double water_max_rate_; // Water rate target or upper limit + double gas_max_rate_; // Gas rate target or upper limit + double liquid_max_rate_; // Liquid rate target or upper limit + std::string procedure_; // Procedure on exceeding a maximum rate limit + // Default values + GconprodLine() : + oil_max_rate_(1.0E20), water_max_rate_(1.0E20), + gas_max_rate_(1.0E20), liquid_max_rate_(1.0E20) + { + } +}; + +/// Class for keyword WCONPROD +struct GCONPROD : public SpecialBase +{ + std::vector gconprod; + + GCONPROD() + { + } + + virtual ~GCONPROD() + {} + + virtual std::string name() const {return std::string("GCONPROD");} + + virtual void read(std::istream& is) + { + while(is) { + std::string groupname = readString(is); + if (groupname[0] == '/') { + is >> ignoreLine; + break; + } + while (groupname.find("--") == 0) { + // This line is a comment + is >> ignoreLine; + groupname = readString(is); + } + GconprodLine gconprod_line; + gconprod_line.group_ = groupname; + gconprod_line.control_mode_ = readString(is); + std::vector double_data(4, 1.0E20); + const int num_to_read = 4; + int num_read = readDefaultedVectorData(is, double_data, num_to_read); + gconprod_line.oil_max_rate_ = double_data[0]; + gconprod_line.water_max_rate_ = double_data[1]; + gconprod_line.gas_max_rate_ = double_data[2]; + gconprod_line.liquid_max_rate_ = double_data[3]; + + + std::string procedure = readString(is); + if (procedure[0] == '/') { + is >> ignoreLine; + break; + } + while (procedure.find("--") == 0) { + // This line is a comment + is >> ignoreLine; + procedure = readString(is); + } + + gconprod_line.procedure_ = procedure; + + gconprod.push_back(gconprod_line); + // HACK! Ignore any further items + if (num_read == num_to_read) { + ignoreSlashLine(is); + } + + } + } + + virtual void write(std::ostream& os) const + { + os << name() << std::endl; + for (int i=0; i<(int) gconprod.size(); ++i) { + os << gconprod[i].group_ << " " + << gconprod[i].control_mode_ << " " + << gconprod[i].oil_max_rate_ << " " + << gconprod[i].water_max_rate_ << " " + << gconprod[i].gas_max_rate_ << " " + << gconprod[i].liquid_max_rate_ << " " + << gconprod[i].procedure_ + << std::endl; + } + os << std::endl; + } + + virtual void convertToSI(const EclipseUnits& units) + { + double lrat = units.liqvol_s / units.time; + double grat = units.gasvol_s / units.time; + for (int i=0; i<(int) gconprod.size(); ++i) { + gconprod[i].oil_max_rate_ *= lrat; + gconprod[i].water_max_rate_ *= lrat; + gconprod[i].gas_max_rate_ *= grat; + gconprod[i].liquid_max_rate_ *= lrat; + } + } +}; + + + /// Class holding a data line of keyword WCONPROD struct WconprodLine {