Added WELOPEN, now schedules DATES and TSTEP properly.
This commit is contained in:
1 parent
f1bc8ca160
commit
3aa067b374
3 files changed
+107
-10
No files matched your search
@@ -41,6 +41,7 @@
|
||||
#include <exception>
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <numeric>
|
||||
#include <cfloat>
|
||||
#include <opm/core/eclipse/EclipseGridParser.hpp>
|
||||
#include <opm/core/eclipse/EclipseGridParserHelpers.hpp>
|
||||
@@ -97,6 +98,7 @@ namespace EclipseKeywords
|
||||
string("SGOF"), string("SWOF"), string("ROCK"),
|
||||
string("ROCKTAB"), string("WELSPECS"), string("COMPDAT"),
|
||||
string("WCONINJE"), string("WCONPROD"), string("WELTARG"),
|
||||
string("WELOPEN"),
|
||||
string("EQUIL"), string("PVCDO"), string("TSTEP"),
|
||||
string("PLYVISC"), string("PLYROCK"), string("PLYADS"),
|
||||
string("PLYMAX"), string("TLMIXPAR"), string("WPOLYMER"),
|
||||
@@ -280,6 +282,8 @@ namespace {
|
||||
EclipseGridParser::EclipseGridParser()
|
||||
//---------------------------------------------------------------------------
|
||||
: current_reading_mode_(Regular),
|
||||
start_date_(boost::date_time::not_a_date_time),
|
||||
current_time_days_(0.0),
|
||||
current_epoch_(0)
|
||||
{
|
||||
}
|
||||
@@ -290,6 +294,8 @@ EclipseGridParser::EclipseGridParser()
|
||||
EclipseGridParser::EclipseGridParser(const string& filename, bool convert_to_SI)
|
||||
//---------------------------------------------------------------------------
|
||||
: current_reading_mode_(Regular),
|
||||
start_date_(boost::date_time::not_a_date_time),
|
||||
current_time_days_(0.0),
|
||||
current_epoch_(0)
|
||||
{
|
||||
// Store directory of filename
|
||||
@@ -384,22 +390,50 @@ void EclipseGridParser::readImpl(istream& is)
|
||||
break;
|
||||
}
|
||||
case Timestepping: {
|
||||
SpecialMap& sm = special_field_by_epoch_[current_epoch_];
|
||||
if (start_date_.is_not_a_date()) {
|
||||
// Set it to START date, or default if no START.
|
||||
// This will only ever happen in the first epoch,
|
||||
// upon first encountering a timestepping keyword.
|
||||
SpecialMap::const_iterator it = sm.find("START");
|
||||
if (hasField("START")) {
|
||||
start_date_ = getSTART().date;
|
||||
} else {
|
||||
start_date_ = boost::gregorian::date(1983, 1, 1);
|
||||
}
|
||||
}
|
||||
if (current_reading_mode_ == Regular) {
|
||||
current_reading_mode_ = Timesteps;
|
||||
}
|
||||
SpecialMap& sm = special_field_by_epoch_[current_epoch_];
|
||||
// Append to current epoch's TSTEP, if it exists.
|
||||
// Get current epoch's TSTEP, if it exists, create new if not.
|
||||
SpecialMap::iterator it = sm.find("TSTEP");
|
||||
TSTEP* tstep = 0;
|
||||
if (it != sm.end()) {
|
||||
it->second->read(is); // This will append to the TSTEP object.
|
||||
tstep = dynamic_cast<TSTEP*>(it->second.get());
|
||||
} else {
|
||||
// There is no existing TSTEP for this epoch, create it.
|
||||
SpecialFieldPtr sb_ptr = createSpecialField(is, keyword);
|
||||
if (sb_ptr) {
|
||||
sm[keyword] = sb_ptr;
|
||||
} else {
|
||||
THROW("Could not create field " << keyword);
|
||||
SpecialFieldPtr sb_ptr(new TSTEP());
|
||||
tstep = dynamic_cast<TSTEP*>(sb_ptr.get());
|
||||
sm["TSTEP"] = sb_ptr;
|
||||
}
|
||||
ASSERT(tstep != 0);
|
||||
// Append new steps to current TSTEP object
|
||||
if (keyword == "TSTEP") {
|
||||
const int num_steps_old = tstep->tstep_.size();
|
||||
tstep->read(is); // This will append to the TSTEP object.
|
||||
const double added_days
|
||||
= std::accumulate(tstep->tstep_.begin() + num_steps_old, tstep->tstep_.end(), 0.0);
|
||||
current_time_days_ += added_days;
|
||||
} else if (keyword == "DATES") {
|
||||
DATES dates;
|
||||
dates.read(is);
|
||||
for (std::size_t dix = 0; dix < dates.dates.size(); ++dix) {
|
||||
boost::gregorian::date_duration since_start = dates.dates[dix] - start_date_;
|
||||
double step = double(since_start.days()) - current_time_days_;
|
||||
tstep->tstep_.push_back(step);
|
||||
current_time_days_ = double(since_start.days());
|
||||
}
|
||||
} else {
|
||||
THROW("Keyword " << keyword << " cannot be handled here.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -150,6 +150,7 @@ public:
|
||||
SPECIAL_FIELD(WCONINJE);
|
||||
SPECIAL_FIELD(WCONPROD);
|
||||
SPECIAL_FIELD(WELTARG);
|
||||
SPECIAL_FIELD(WELOPEN);
|
||||
SPECIAL_FIELD(EQUIL);
|
||||
SPECIAL_FIELD(PVCDO);
|
||||
SPECIAL_FIELD(TSTEP);
|
||||
@@ -205,7 +206,8 @@ private:
|
||||
// For SCHEDULE handling.
|
||||
enum ReadingMode { Regular, Timesteps };
|
||||
ReadingMode current_reading_mode_;
|
||||
boost::gregorian::date current_reading_date_;
|
||||
boost::gregorian::date start_date_;
|
||||
double current_time_days_;
|
||||
int current_epoch_;
|
||||
typedef std::map<std::string, SpecialFieldPtr> SpecialMap;
|
||||
std::vector<SpecialMap> special_field_by_epoch_;
|
||||
|
||||
@@ -1658,6 +1658,67 @@ struct WELTARG : public SpecialBase
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct WelopenLine
|
||||
{
|
||||
std::string well_; // Well name or well name root
|
||||
std::string openshutflag_; // What to do with the well.
|
||||
};
|
||||
|
||||
/// Class for keyword WELOPEN
|
||||
struct WELOPEN : public SpecialBase
|
||||
{
|
||||
std::vector<WelopenLine> welopen;
|
||||
|
||||
WELOPEN()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~WELOPEN()
|
||||
{}
|
||||
|
||||
virtual std::string name() const {return std::string("WELOPEN");}
|
||||
|
||||
virtual void read(std::istream& is)
|
||||
{
|
||||
while(is) {
|
||||
std::string wellname = readString(is);
|
||||
if (wellname[0] == '/') {
|
||||
is >> ignoreLine;
|
||||
break;
|
||||
}
|
||||
while (wellname.find("--") == 0) {
|
||||
// This line is a comment
|
||||
is >> ignoreLine;
|
||||
wellname = readString(is);
|
||||
}
|
||||
WelopenLine welopen_line;
|
||||
welopen_line.well_ = wellname;
|
||||
welopen_line.openshutflag_ = readString(is);
|
||||
ignoreSlashLine(is);
|
||||
welopen.push_back(welopen_line);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void write(std::ostream& os) const
|
||||
{
|
||||
os << name() << std::endl;
|
||||
for (int i=0; i<(int)welopen.size(); ++i) {
|
||||
os << welopen[i].well_ << " "
|
||||
<< welopen[i].openshutflag_
|
||||
<< std::endl;
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
|
||||
virtual void convertToSI(const EclipseUnits& /*units*/)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/// Class holding a data line of keyword EQUIL
|
||||
struct EquilLine
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user