Avoid using Deck.

Removed incorrect use of Deck for polymer and solvent properties.
This commit is contained in:
Joakim Hove 2016-01-06 14:52:33 +01:00
parent d14de856fe
commit 833f5d053f
7 changed files with 35 additions and 121 deletions

View File

@ -273,7 +273,7 @@ try
if (wells.c_wells() == 0) {
OPM_THROW(std::runtime_error, "Cannot control polymer injection via WPOLYMER without wells.");
}
polymer_inflow.reset(new PolymerInflowFromDeck(deck, eclipseState, *wells.c_wells(), props->numCells(), simtimer.currentStepNum()));
polymer_inflow.reset(new PolymerInflowFromDeck(eclipseState, *wells.c_wells(), props->numCells(), simtimer.currentStepNum()));
} else {
polymer_inflow.reset(new PolymerInflowBasic(param.getDefault("poly_start_days", 300.0)*Opm::unit::day,
param.getDefault("poly_end_days", 800.0)*Opm::unit::day,

View File

@ -310,7 +310,7 @@ try
if (wells.c_wells() == 0) {
OPM_THROW(std::runtime_error, "Cannot control polymer injection via WPOLYMER without wells.");
}
polymer_inflow.reset(new PolymerInflowFromDeck(deck, eclipseState, *wells.c_wells(), props->numCells(), simtimer.currentStepNum()));
polymer_inflow.reset(new PolymerInflowFromDeck(eclipseState, *wells.c_wells(), props->numCells(), simtimer.currentStepNum()));
} else {
polymer_inflow.reset(new PolymerInflowBasic(param.getDefault("poly_start_days", 300.0)*Opm::unit::day,
param.getDefault("poly_end_days", 800.0)*Opm::unit::day,

View File

@ -100,41 +100,28 @@ namespace Opm
const int nw = wells->number_of_wells;
std::vector<double> perfcells_fraction(wells->well_connpos[nw], 0.0);
if (deck_->hasKeyword("WSOLVENT")) {
size_t currentStep = timer.currentStepNum();
ScheduleConstPtr schedule = BaseType::eclipse_state_->getSchedule();
size_t currentStep = timer.currentStepNum();
ScheduleConstPtr schedule = BaseType::eclipse_state_->getSchedule();
Opm::DeckKeywordConstPtr keyword = deck_->getKeyword("WSOLVENT");
const int num_keywords = keyword->size();
for (int recordNr = 0; recordNr < num_keywords; ++recordNr) {
DeckRecordConstPtr record = keyword->getRecord(recordNr);
const std::string& wellNamesPattern = record->getItem("WELL")->getTrimmedString(0);
std::vector<WellPtr> wells_solvent = schedule->getWells(wellNamesPattern);
for (auto wellIter = wells_solvent.begin(); wellIter != wells_solvent.end(); ++wellIter) {
WellPtr well_solvent = *wellIter;
WellInjectionProperties injection = well_solvent->getInjectionProperties(currentStep);
if (injection.injectorType == WellInjector::GAS) {
double solventFraction = well_solvent->getSolventFraction(currentStep);
// Find the solvent well in the well list and add properties to it
int wix = 0;
for (; wix < nw; ++wix) {
if (wellNamesPattern == wells->name[wix]) {
break;
}
}
if (wix == wells->number_of_wells) {
OPM_THROW(std::runtime_error, "Could not find a match for well "
<< wellNamesPattern
<< " from WSOLVENT.");
}
for (int j = wells->well_connpos[wix]; j < wells->well_connpos[wix+1]; ++j) {
perfcells_fraction[j] = solventFraction;
}
} else {
OPM_THROW(std::logic_error, "For solvent injector you must have a gas injector");
for (const auto& well_solvent : schedule->getWells( currentStep )) {
WellInjectionProperties injection = well_solvent->getInjectionProperties(currentStep);
if (injection.injectorType == WellInjector::GAS) {
double solventFraction = well_solvent->getSolventFraction(currentStep);
// Find the solvent well in the well list and add properties to it
int wix = 0;
for (; wix < nw; ++wix) {
if (well_solvent->name() == wells->name[wix]) {
break;
}
}
if (wix == wells->number_of_wells) {
OPM_THROW(std::runtime_error, "Could not find a match for well "
<< well_solvent->name()
<< " from WSOLVENT.");
}
for (int j = wells->well_connpos[wix]; j < wells->well_connpos[wix+1]; ++j) {
perfcells_fraction[j] = solventFraction;
}
}
}
well_state.solventFraction() = perfcells_fraction;

View File

@ -66,94 +66,31 @@ namespace Opm
// ---------- Methods of PolymerInflowFromDeck ----------
/// Constructor.
/// @param[in] deck Input deck expected to contain WPOLYMER.
PolymerInflowFromDeck::PolymerInflowFromDeck(Opm::DeckConstPtr deck,
const Wells& wells,
const int num_cells)
: sparse_inflow_(num_cells)
{
if (!deck->hasKeyword("WPOLYMER")) {
OPM_MESSAGE("PolymerInflowFromDeck initialized without WPOLYMER in current epoch.");
return;
}
// Extract concentrations and put into cell->concentration map.
Opm::DeckKeywordConstPtr wpolymerKeyword = deck->getKeyword("WPOLYMER");
const int num_wpl = wpolymerKeyword->size();
std::map<int, double> perfcell_conc;
for (int i = 0; i < num_wpl; ++i) {
// Only use well name and polymer concentration.
// That is, we ignore salt concentration and group
// names.
int wix = 0;
for (; wix < wells.number_of_wells; ++wix) {
if (wpolymerKeyword->getRecord(i)->getItem("WELL")->getString(0) == wells.name[wix]) {
break;
}
}
if (wix == wells.number_of_wells) {
OPM_THROW(std::runtime_error, "Could not find a match for well "
<< wpolymerKeyword->getRecord(i)->getItem("WELL")->getString(0)
<< " from WPOLYMER.");
}
for (int j = wells.well_connpos[wix]; j < wells.well_connpos[wix+1]; ++j) {
const int perf_cell = wells.well_cells[j];
perfcell_conc[perf_cell] =
wpolymerKeyword->getRecord(i)->getItem("POLYMER_CONCENTRATION")->getSIDouble(0);
}
}
// Build sparse vector from map.
std::map<int, double>::const_iterator it = perfcell_conc.begin();
for (; it != perfcell_conc.end(); ++it) {
sparse_inflow_.addElement(it->second, it->first);
}
}
void
PolymerInflowFromDeck::setInflowValues(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclipseState,
PolymerInflowFromDeck::setInflowValues(Opm::EclipseStateConstPtr eclipseState,
size_t currentStep)
{
Opm::DeckKeywordConstPtr keyword = deck->getKeyword("WPOLYMER");
// Schedule schedule(deck);
ScheduleConstPtr schedule = eclipseState->getSchedule();
for (size_t recordNr = 0; recordNr < keyword->size(); recordNr++) {
DeckRecordConstPtr record = keyword->getRecord(recordNr);
const std::string& wellNamesPattern = record->getItem("WELL")->getTrimmedString(0);
std::string wellName = record->getItem("WELL")->getTrimmedString(0);
std::vector<WellPtr> wells = schedule->getWells(wellNamesPattern);
for (auto wellIter = wells.begin(); wellIter != wells.end(); ++wellIter) {
WellPtr well = *wellIter;
WellInjectionProperties injection = well->getInjectionProperties(currentStep);
if (injection.injectorType == WellInjector::WATER) {
WellPolymerProperties polymer = well->getPolymerProperties(currentStep);
wellPolymerRate_.insert(std::make_pair(wellName, polymer.m_polymerConcentration));
} else {
OPM_THROW(std::logic_error, "For polymer injector you must have a water injector");
}
for (const auto& well : schedule->getWells(currentStep)) {
WellInjectionProperties injection = well->getInjectionProperties(currentStep);
if (injection.injectorType == WellInjector::WATER) {
WellPolymerProperties polymer = well->getPolymerProperties(currentStep);
wellPolymerRate_.insert(std::make_pair(well->name(), polymer.m_polymerConcentration));
} else {
OPM_THROW(std::logic_error, "For polymer injector you must have a water injector");
}
}
}
/// Constructor.
/// @param[in] deck Input deck expected to contain WPOLYMER.
PolymerInflowFromDeck::PolymerInflowFromDeck(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclipseState,
PolymerInflowFromDeck::PolymerInflowFromDeck(Opm::EclipseStateConstPtr eclipseState,
const Wells& wells,
const int num_cells,
size_t currentStep)
: sparse_inflow_(num_cells)
{
if (!deck->hasKeyword("WPOLYMER")) {
OPM_MESSAGE("PolymerInflowFromDeck initialized without WPOLYMER in current epoch.");
return;
}
setInflowValues(deck, eclipseState, currentStep);
setInflowValues(eclipseState, currentStep);
std::unordered_map<std::string, double>::const_iterator map_it;
// Extract concentrations and put into cell->concentration map.

View File

@ -88,21 +88,12 @@ namespace Opm
class PolymerInflowFromDeck : public PolymerInflowInterface
{
public:
/// Constructor.
/// \param[in] deck Input deck expected to contain WPOLYMER.
/// \param[in] wells Wells structure.
/// \param[in] num_cells Number of cells in grid.
PolymerInflowFromDeck(Opm::DeckConstPtr deck,
const Wells& wells,
const int num_cells);
/// Constructor.
/// \param[in] deck Input deck expected to contain WPOLYMER.
/// \param[in] wells Wells structure.
/// \param[in] num_cells Number of cells in grid.
/// \param[in] currentStep Number of current simulation step.
PolymerInflowFromDeck(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclipseState,
PolymerInflowFromDeck(Opm::EclipseStateConstPtr eclipseState,
const Wells& wells,
const int num_cells,
size_t currentStep);
@ -119,8 +110,7 @@ namespace Opm
SparseVector<double> sparse_inflow_;
std::unordered_map<std::string, double> wellPolymerRate_;
void setInflowValues(Opm::DeckConstPtr deck,
Opm::EclipseStateConstPtr eclipseState,
void setInflowValues(Opm::EclipseStateConstPtr eclipseState,
size_t currentStep);
};

View File

@ -110,7 +110,7 @@ namespace Opm
if (wells_manager.c_wells() == 0) {
OPM_THROW(std::runtime_error, "Cannot control polymer injection via WPOLYMER without wells.");
}
polymer_inflow_ptr.reset(new PolymerInflowFromDeck(deck_, BaseType::eclipse_state_, *wells, Opm::UgGridHelpers::numCells(BaseType::grid_), timer.currentStepNum()));
polymer_inflow_ptr.reset(new PolymerInflowFromDeck(BaseType::eclipse_state_, *wells, Opm::UgGridHelpers::numCells(BaseType::grid_), timer.currentStepNum()));
} else {
OPM_MESSAGE("Warning: simulating with no WPOLYMER in deck (no polymer will be injected).");
polymer_inflow_ptr.reset(new PolymerInflowBasic(0.0*Opm::unit::day,

View File

@ -82,7 +82,7 @@ handleAdditionalWellInflow(SimulatorTimer& timer,
if (wells_manager.c_wells() == 0) {
OPM_THROW(std::runtime_error, "Cannot control polymer injection via WPOLYMER without wells.");
}
polymer_inflow_ptr.reset(new PolymerInflowFromDeck(deck_, BaseType::eclipse_state_, *wells, Opm::UgGridHelpers::numCells(BaseType::grid_), timer.currentStepNum()));
polymer_inflow_ptr.reset(new PolymerInflowFromDeck( BaseType::eclipse_state_, *wells, Opm::UgGridHelpers::numCells(BaseType::grid_), timer.currentStepNum()));
} else {
polymer_inflow_ptr.reset(new PolymerInflowBasic(0.0*Opm::unit::day,
1.0*Opm::unit::day,