mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-19 16:22:57 -06:00
Removes the WELSPECS usage in WellsManager constructor. Step 1 in rewrite of constructor
This commit is contained in:
parent
691148122c
commit
3b0a9067b4
@ -247,18 +247,11 @@ namespace Opm
|
|||||||
if (grid.dimensions != 3) {
|
if (grid.dimensions != 3) {
|
||||||
OPM_THROW(std::runtime_error, "We cannot initialize wells from a deck unless the corresponding grid is 3-dimensional.");
|
OPM_THROW(std::runtime_error, "We cannot initialize wells from a deck unless the corresponding grid is 3-dimensional.");
|
||||||
}
|
}
|
||||||
// NOTE: Implementation copied and modified from dune-porsol's class BlackoilWells.
|
|
||||||
std::vector<std::string> keywords;
|
if (eclipseState->getSchedule()->numWells() == 0) {
|
||||||
keywords.push_back("WELSPECS");
|
OPM_MESSAGE("No wells specified in Schedule section, initializing no wells");
|
||||||
keywords.push_back("COMPDAT");
|
|
||||||
// keywords.push_back("WELTARG");
|
|
||||||
if (!deck.hasFields(keywords)) {
|
|
||||||
OPM_MESSAGE("Missing well keywords in deck, initializing no wells.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(deck.hasField("WCONINJE") || deck.hasField("WCONPROD")) ) {
|
|
||||||
OPM_THROW(std::runtime_error, "Needed field is missing in file");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtain phase usage data.
|
// Obtain phase usage data.
|
||||||
PhaseUsage pu = phaseUsageFromDeck(eclipseState);
|
PhaseUsage pu = phaseUsageFromDeck(eclipseState);
|
||||||
@ -273,44 +266,35 @@ namespace Opm
|
|||||||
std::map<std::string, int> well_names_to_index;
|
std::map<std::string, int> well_names_to_index;
|
||||||
typedef std::map<std::string, int>::const_iterator WNameIt;
|
typedef std::map<std::string, int>::const_iterator WNameIt;
|
||||||
|
|
||||||
// Get WELSPECS data.
|
|
||||||
// It is allowed to have multiple lines corresponding to
|
|
||||||
// the same well, in which case the last one encountered
|
// Main "well-loop" to populate the data structures (well_names, well_data, ...)
|
||||||
// is the one used.
|
ScheduleConstPtr schedule = eclipseState->getSchedule();
|
||||||
const WELSPECS& welspecs = deck.getWELSPECS();
|
std::vector<WellConstPtr> wells = schedule->getWells(timeStep);
|
||||||
const int num_welspecs = welspecs.welspecs.size();
|
well_names.reserve(wells.size());
|
||||||
well_names.reserve(num_welspecs);
|
well_data.reserve(wells.size());
|
||||||
well_data.reserve(num_welspecs);
|
|
||||||
for (int w = 0; w < num_welspecs; ++w) {
|
int well_index = 0;
|
||||||
// First check if this well has already been encountered.
|
for (auto wellIter= wells.begin(); wellIter != wells.end(); ++wellIter) {
|
||||||
// If so, we modify it's data instead of appending a new well
|
WellConstPtr well = (*wellIter);
|
||||||
// to the well_data and well_names vectors.
|
well_names_to_index[well->name()] = well_index;
|
||||||
const std::string& name = welspecs.welspecs[w].name_;
|
well_names.push_back(well->name());
|
||||||
const double refdepth = welspecs.welspecs[w].datum_depth_BHP_;
|
{
|
||||||
WNameIt wit = well_names_to_index.find(name);
|
|
||||||
if (wit == well_names_to_index.end()) {
|
|
||||||
// New well, append data.
|
|
||||||
well_names_to_index[welspecs.welspecs[w].name_] = well_data.size();
|
|
||||||
well_names.push_back(name);
|
|
||||||
WellData wd;
|
WellData wd;
|
||||||
// If negative (defaulted), set refdepth to a marker
|
// If negative (defaulted), set refdepth to a marker
|
||||||
// value, will be changed after getting perforation
|
// value, will be changed after getting perforation
|
||||||
// data to the centroid of the cell of the top well
|
// data to the centroid of the cell of the top well
|
||||||
// perforation.
|
// perforation.
|
||||||
wd.reference_bhp_depth = (refdepth < 0.0) ? -1e100 : refdepth;
|
wd.reference_bhp_depth = (well->getRefDepth() < 0.0) ? -1e100 : well->getRefDepth();
|
||||||
wd.welspecsline = w;
|
wd.welspecsline = -1;
|
||||||
well_data.push_back(wd);
|
well_data.push_back(wd);
|
||||||
} else {
|
|
||||||
// Existing well, change data.
|
|
||||||
const int wix = wit->second;
|
|
||||||
well_data[wix].reference_bhp_depth = (refdepth < 0.0) ? -1e100 : refdepth;
|
|
||||||
well_data[wix].welspecsline = w;
|
|
||||||
}
|
}
|
||||||
|
well_index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int num_wells = well_data.size();
|
const int num_wells = well_data.size();
|
||||||
wellperf_data.resize(num_wells);
|
wellperf_data.resize(num_wells);
|
||||||
|
|
||||||
|
|
||||||
// global_cell is a map from compressed cells to Cartesian grid cells.
|
// global_cell is a map from compressed cells to Cartesian grid cells.
|
||||||
// We must make the inverse lookup.
|
// We must make the inverse lookup.
|
||||||
const int* global_cell = grid.global_cell;
|
const int* global_cell = grid.global_cell;
|
||||||
@ -345,23 +329,20 @@ namespace Opm
|
|||||||
bool found = false;
|
bool found = false;
|
||||||
for (int wix = 0; wix < num_wells; ++wix) {
|
for (int wix = 0; wix < num_wells; ++wix) {
|
||||||
if (well_names[wix].compare(0,len, name) == 0) { // equal
|
if (well_names[wix].compare(0,len, name) == 0) { // equal
|
||||||
// Extract corresponding WELSPECS defintion for
|
|
||||||
// purpose of default location specification.
|
|
||||||
const WelspecsLine& wspec = welspecs.welspecs[well_data[wix].welspecsline];
|
|
||||||
|
|
||||||
// We have a matching name.
|
// We have a matching name.
|
||||||
int ix = compdat.compdat[kw].grid_ind_[0] - 1;
|
int ix = compdat.compdat[kw].grid_ind_[0] - 1;
|
||||||
int jy = compdat.compdat[kw].grid_ind_[1] - 1;
|
int jy = compdat.compdat[kw].grid_ind_[1] - 1;
|
||||||
int kz1 = compdat.compdat[kw].grid_ind_[2] - 1;
|
int kz1 = compdat.compdat[kw].grid_ind_[2] - 1;
|
||||||
int kz2 = compdat.compdat[kw].grid_ind_[3] - 1;
|
int kz2 = compdat.compdat[kw].grid_ind_[3] - 1;
|
||||||
|
|
||||||
|
WellConstPtr well = schedule->getWell(well_names[wix]);
|
||||||
if (ix < 0) {
|
if (ix < 0) {
|
||||||
// Defaulted I location. Extract from WELSPECS.
|
// Defaulted I location. Extract from WELSPECS.
|
||||||
ix = wspec.I_ - 1;
|
ix = well->getHeadI() - 1;
|
||||||
}
|
}
|
||||||
if (jy < 0) {
|
if (jy < 0) {
|
||||||
// Defaulted J location. Extract from WELSPECS.
|
// Defaulted J location. Extract from WELSPECS.
|
||||||
jy = wspec.J_ - 1;
|
jy = well->getHeadJ() - 1;
|
||||||
}
|
}
|
||||||
if (kz1 < 0) {
|
if (kz1 < 0) {
|
||||||
// Defaulted KZ1. Use top layer.
|
// Defaulted KZ1. Use top layer.
|
||||||
@ -784,9 +765,8 @@ namespace Opm
|
|||||||
well_collection_.addChild(it->first, it->second, deck);
|
well_collection_.addChild(it->first, it->second, deck);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < welspecs.welspecs.size(); ++i) {
|
for (auto wellIter = wells.begin(); wellIter != wells.end(); ++wellIter ) {
|
||||||
WelspecsLine line = welspecs.welspecs[i];
|
well_collection_.addChild((*wellIter)->name(), (*wellIter)->getGroupName(timeStep), deck);
|
||||||
well_collection_.addChild(line.name_, line.group_, deck);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ BOOST_AUTO_TEST_CASE(Constructor_Works) {
|
|||||||
BOOST_AUTO_TEST_CASE(New_Constructor_Works) {
|
BOOST_AUTO_TEST_CASE(New_Constructor_Works) {
|
||||||
|
|
||||||
Opm::ParserPtr parser(new Opm::Parser());
|
Opm::ParserPtr parser(new Opm::Parser());
|
||||||
Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(parser->parse("wells_manager_data.data")));
|
Opm::EclipseStateConstPtr eclipseState(new Opm::EclipseState(parser->parseFile("wells_manager_data.data")));
|
||||||
|
|
||||||
Opm::EclipseGridParser Deck("wells_manager_data.data");
|
Opm::EclipseGridParser Deck("wells_manager_data.data");
|
||||||
Opm::GridManager gridManager(Deck);
|
Opm::GridManager gridManager(Deck);
|
||||||
|
Loading…
Reference in New Issue
Block a user