Merge remote-tracking branch 'opm/master' into fim

Conflicts:
	cmake/Modules/Findopm-autodiff.cmake
This commit is contained in:
Liu Ming 2014-09-23 16:04:15 +08:00
commit 9a41199bd4
15 changed files with 200 additions and 144 deletions

View File

@ -47,6 +47,9 @@
#include <opm/polymer/PolymerInflow.hpp> #include <opm/polymer/PolymerInflow.hpp>
#include <opm/polymer/PolymerProperties.hpp> #include <opm/polymer/PolymerProperties.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
@ -83,10 +86,11 @@ try
// If we have a "deck_filename", grid and props will be read from that. // If we have a "deck_filename", grid and props will be read from that.
bool use_deck = param.has("deck_filename"); bool use_deck = param.has("deck_filename");
boost::scoped_ptr<EclipseGridParser> deck;
boost::scoped_ptr<GridManager> grid; boost::scoped_ptr<GridManager> grid;
boost::scoped_ptr<BlackoilPropertiesInterface> props; boost::scoped_ptr<BlackoilPropertiesInterface> props;
boost::scoped_ptr<RockCompressibility> rock_comp; boost::scoped_ptr<RockCompressibility> rock_comp;
Opm::DeckConstPtr deck;
EclipseStateConstPtr eclipseState;
PolymerBlackoilState state; PolymerBlackoilState state;
Opm::PolymerProperties poly_props; Opm::PolymerProperties poly_props;
// bool check_well_controls = false; // bool check_well_controls = false;
@ -94,26 +98,29 @@ try
double gravity[3] = { 0.0 }; double gravity[3] = { 0.0 };
if (use_deck) { if (use_deck) {
std::string deck_filename = param.get<std::string>("deck_filename"); std::string deck_filename = param.get<std::string>("deck_filename");
deck.reset(new EclipseGridParser(deck_filename)); ParserPtr parser(new Opm::Parser());
deck = parser->parseFile(deck_filename);
eclipseState.reset(new Opm::EclipseState(deck));
// Grid init // Grid init
grid.reset(new GridManager(*deck)); grid.reset(new GridManager(deck));
// Rock and fluid init // Rock and fluid init
props.reset(new BlackoilPropertiesFromDeck(*deck, *grid->c_grid())); props.reset(new BlackoilPropertiesFromDeck(deck, eclipseState, *grid->c_grid()));
// check_well_controls = param.getDefault("check_well_controls", false); // check_well_controls = param.getDefault("check_well_controls", false);
// max_well_control_iterations = param.getDefault("max_well_control_iterations", 10); // max_well_control_iterations = param.getDefault("max_well_control_iterations", 10);
// Rock compressibility. // Rock compressibility.
rock_comp.reset(new RockCompressibility(*deck)); rock_comp.reset(new RockCompressibility(deck, eclipseState));
// Gravity. // Gravity.
gravity[2] = deck->hasField("NOGRAV") ? 0.0 : unit::gravity; gravity[2] = deck->hasKeyword("NOGRAV") ? 0.0 : unit::gravity;
// Init state variables (saturation and pressure). // Init state variables (saturation and pressure).
if (param.has("init_saturation")) { if (param.has("init_saturation")) {
initStateBasic(*grid->c_grid(), *props, param, gravity[2], state); initStateBasic(*grid->c_grid(), *props, param, gravity[2], state);
} else { } else {
initStateFromDeck(*grid->c_grid(), *props, *deck, gravity[2], state); initStateFromDeck(*grid->c_grid(), *props, deck, gravity[2], state);
} }
initBlackoilSurfvol(*grid->c_grid(), *props, state); initBlackoilSurfvol(*grid->c_grid(), *props, state);
// Init polymer properties. // Init polymer properties.
poly_props.readFromDeck(*deck); poly_props.readFromDeck(eclipseState);
} else { } else {
// Grid init. // Grid init.
const int nx = param.getDefault("nx", 100); const int nx = param.getDefault("nx", 100);
@ -175,9 +182,15 @@ try
ads_vals[2] = 0.0025; ads_vals[2] = 0.0025;
// ads_vals[1] = 0.0; // ads_vals[1] = 0.0;
// ads_vals[2] = 0.0; // ads_vals[2] = 0.0;
std::vector<double> water_vel_vals(2, -1e100);
water_vel_vals[0] = 0.0;
water_vel_vals[1] = 10.0;
std::vector<double> shear_vrf_vals(2, -1e100);
shear_vrf_vals[0] = 1.0;
shear_vrf_vals[1] = 1.0;
poly_props.set(c_max, mix_param, rock_density, dead_pore_vol, res_factor, c_max_ads, poly_props.set(c_max, mix_param, rock_density, dead_pore_vol, res_factor, c_max_ads,
static_cast<Opm::PolymerProperties::AdsorptionBehaviour>(ads_index), static_cast<Opm::PolymerProperties::AdsorptionBehaviour>(ads_index),
c_vals_visc, visc_mult_vals, c_vals_ads, ads_vals); c_vals_visc, visc_mult_vals, c_vals_ads, ads_vals, water_vel_vals, shear_vrf_vals);
} }
bool use_gravity = (gravity[0] != 0.0 || gravity[1] != 0.0 || gravity[2] != 0.0); bool use_gravity = (gravity[0] != 0.0 || gravity[1] != 0.0 || gravity[2] != 0.0);
@ -233,8 +246,7 @@ try
std::cout << "\n\n================ Starting main simulation loop ===============\n" std::cout << "\n\n================ Starting main simulation loop ===============\n"
<< " (number of epochs: " << std::flush;
<< (use_deck ? deck->numberOfEpochs() : 1) << ")\n\n" << std::flush;
SimulatorReport rep; SimulatorReport rep;
if (!use_deck) { if (!use_deck) {
@ -264,49 +276,34 @@ try
// With a deck, we may have more epochs etc. // With a deck, we may have more epochs etc.
WellState well_state; WellState well_state;
int step = 0; int step = 0;
Opm::TimeMapPtr timeMap(new Opm::TimeMap(deck));
SimulatorTimer simtimer; SimulatorTimer simtimer;
// Use timer for last epoch to obtain total time. simtimer.init(timeMap);
deck->setCurrentEpoch(deck->numberOfEpochs() - 1); // Check for WPOLYMER presence in last report step to decide
simtimer.init(*deck);
const double total_time = simtimer.totalTime();
// Check for WPOLYMER presence in last epoch to decide
// polymer injection control type. // polymer injection control type.
const bool use_wpolymer = deck->hasField("WPOLYMER"); const bool use_wpolymer = deck->hasKeyword("WPOLYMER");
if (use_wpolymer) { if (use_wpolymer) {
if (param.has("poly_start_days")) { if (param.has("poly_start_days")) {
OPM_MESSAGE("Warning: Using WPOLYMER to control injection since it was found in deck. " OPM_MESSAGE("Warning: Using WPOLYMER to control injection since it was found in deck. "
"You seem to be trying to control it via parameter poly_start_days (etc.) as well."); "You seem to be trying to control it via parameter poly_start_days (etc.) as well.");
} }
} }
for (int epoch = 0; epoch < deck->numberOfEpochs(); ++epoch) { for (size_t reportStepIdx = 0; reportStepIdx < timeMap->numTimesteps(); ++reportStepIdx) {
// Set epoch index. simtimer.setCurrentStepNum(reportStepIdx);
deck->setCurrentEpoch(epoch);
// Update the timer. // Report on start of report step.
if (deck->hasField("TSTEP")) { std::cout << "\n\n-------------- Starting report step " << reportStepIdx << " --------------"
simtimer.init(*deck); << "\n (number of remaining steps: "
} else {
if (epoch != 0) {
OPM_THROW(std::runtime_error, "No TSTEP in deck for epoch " << epoch);
}
simtimer.init(param);
}
simtimer.setCurrentStepNum(step);
simtimer.setTotalTime(total_time);
// Report on start of epoch.
std::cout << "\n\n-------------- Starting epoch " << epoch << " --------------"
<< "\n (number of steps: "
<< simtimer.numSteps() - step << ")\n\n" << std::flush; << simtimer.numSteps() - step << ")\n\n" << std::flush;
// Create new wells, polymer inflow controls. // Create new wells, polymer inflow controls.
WellsManager wells(*deck, *grid->c_grid(), props->permeability()); WellsManager wells(eclipseState , reportStepIdx , *grid->c_grid(), props->permeability());
boost::scoped_ptr<PolymerInflowInterface> polymer_inflow; boost::scoped_ptr<PolymerInflowInterface> polymer_inflow;
if (use_wpolymer) { if (use_wpolymer) {
if (wells.c_wells() == 0) { if (wells.c_wells() == 0) {
OPM_THROW(std::runtime_error, "Cannot control polymer injection via WPOLYMER without wells."); OPM_THROW(std::runtime_error, "Cannot control polymer injection via WPOLYMER without wells.");
} }
polymer_inflow.reset(new PolymerInflowFromDeck(*deck, *wells.c_wells(), props->numCells())); polymer_inflow.reset(new PolymerInflowFromDeck(deck, *wells.c_wells(), props->numCells()));
} else { } else {
polymer_inflow.reset(new PolymerInflowBasic(param.getDefault("poly_start_days", 300.0)*Opm::unit::day, 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, param.getDefault("poly_end_days", 800.0)*Opm::unit::day,
@ -314,9 +311,9 @@ try
} }
// @@@ HACK: we should really make a new well state and // @@@ HACK: we should really make a new well state and
// properly transfer old well state to it every epoch, // properly transfer old well state to it every report step,
// since number of wells may change etc. // since number of wells may change etc.
if (epoch == 0) { if (reportStepIdx == 0) {
well_state.init(wells.c_wells(), state); well_state.init(wells.c_wells(), state);
} }
@ -332,7 +329,7 @@ try
bcs.c_bcs(), bcs.c_bcs(),
linsolver, linsolver,
grav); grav);
if (epoch == 0) { if (reportStepIdx == 0) {
warnIfUnusedParams(param); warnIfUnusedParams(param);
} }
SimulatorReport epoch_rep = simulator.run(simtimer, state, well_state); SimulatorReport epoch_rep = simulator.run(simtimer, state, well_state);

View File

@ -47,6 +47,9 @@
#include <opm/polymer/PolymerInflow.hpp> #include <opm/polymer/PolymerInflow.hpp>
#include <opm/polymer/PolymerProperties.hpp> #include <opm/polymer/PolymerProperties.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
@ -83,10 +86,11 @@ try
// If we have a "deck_filename", grid and props will be read from that. // If we have a "deck_filename", grid and props will be read from that.
bool use_deck = param.has("deck_filename"); bool use_deck = param.has("deck_filename");
boost::scoped_ptr<EclipseGridParser> deck; Opm::DeckConstPtr deck;
boost::scoped_ptr<GridManager> grid; boost::scoped_ptr<GridManager> grid;
boost::scoped_ptr<IncompPropertiesInterface> props; boost::scoped_ptr<IncompPropertiesInterface> props;
boost::scoped_ptr<RockCompressibility> rock_comp; boost::scoped_ptr<RockCompressibility> rock_comp;
EclipseStateConstPtr eclipseState;
PolymerState state; PolymerState state;
Opm::PolymerProperties poly_props; Opm::PolymerProperties poly_props;
// bool check_well_controls = false; // bool check_well_controls = false;
@ -94,25 +98,28 @@ try
double gravity[3] = { 0.0 }; double gravity[3] = { 0.0 };
if (use_deck) { if (use_deck) {
std::string deck_filename = param.get<std::string>("deck_filename"); std::string deck_filename = param.get<std::string>("deck_filename");
deck.reset(new EclipseGridParser(deck_filename)); ParserPtr parser(new Opm::Parser());
deck = parser->parseFile(deck_filename);
eclipseState.reset(new Opm::EclipseState(deck));
// Grid init // Grid init
grid.reset(new GridManager(*deck)); grid.reset(new GridManager(deck));
// Rock and fluid init // Rock and fluid init
props.reset(new IncompPropertiesFromDeck(*deck, *grid->c_grid())); props.reset(new IncompPropertiesFromDeck(deck, eclipseState, *grid->c_grid()));
// check_well_controls = param.getDefault("check_well_controls", false); // check_well_controls = param.getDefault("check_well_controls", false);
// max_well_control_iterations = param.getDefault("max_well_control_iterations", 10); // max_well_control_iterations = param.getDefault("max_well_control_iterations", 10);
// Rock compressibility. // Rock compressibility.
rock_comp.reset(new RockCompressibility(*deck)); rock_comp.reset(new RockCompressibility(deck, eclipseState));
// Gravity. // Gravity.
gravity[2] = deck->hasField("NOGRAV") ? 0.0 : unit::gravity; gravity[2] = deck->hasKeyword("NOGRAV") ? 0.0 : unit::gravity;
// Init state variables (saturation and pressure). // Init state variables (saturation and pressure).
if (param.has("init_saturation")) { if (param.has("init_saturation")) {
initStateBasic(*grid->c_grid(), *props, param, gravity[2], state); initStateBasic(*grid->c_grid(), *props, param, gravity[2], state);
} else { } else {
initStateFromDeck(*grid->c_grid(), *props, *deck, gravity[2], state); initStateFromDeck(*grid->c_grid(), *props, deck, gravity[2], state);
} }
// Init polymer properties. // Init polymer properties.
poly_props.readFromDeck(*deck); poly_props.readFromDeck(eclipseState);
} else { } else {
// Grid init. // Grid init.
const int nx = param.getDefault("nx", 100); const int nx = param.getDefault("nx", 100);
@ -173,9 +180,15 @@ try
ads_vals[2] = 0.0025; ads_vals[2] = 0.0025;
// ads_vals[1] = 0.0; // ads_vals[1] = 0.0;
// ads_vals[2] = 0.0; // ads_vals[2] = 0.0;
std::vector<double> water_vel_vals(2, -1e100);
water_vel_vals[0] = 0.0;
water_vel_vals[1] = 10.0;
std::vector<double> shear_vrf_vals(2, -1e100);
shear_vrf_vals[0] = 1.0;
shear_vrf_vals[1] = 1.0;
poly_props.set(c_max, mix_param, rock_density, dead_pore_vol, res_factor, c_max_ads, poly_props.set(c_max, mix_param, rock_density, dead_pore_vol, res_factor, c_max_ads,
static_cast<Opm::PolymerProperties::AdsorptionBehaviour>(ads_index), static_cast<Opm::PolymerProperties::AdsorptionBehaviour>(ads_index),
c_vals_visc, visc_mult_vals, c_vals_ads, ads_vals); c_vals_visc, visc_mult_vals, c_vals_ads, ads_vals, water_vel_vals, shear_vrf_vals);
} }
// Warn if gravity but no density difference. // Warn if gravity but no density difference.
@ -237,8 +250,7 @@ try
std::cout << "\n\n================ Starting main simulation loop ===============\n" std::cout << "\n\n================ Starting main simulation loop ===============\n"
<< " (number of epochs: " << std::flush;
<< (use_deck ? deck->numberOfEpochs() : 1) << ")\n\n" << std::flush;
SimulatorReport rep; SimulatorReport rep;
if (!use_deck) { if (!use_deck) {
@ -266,51 +278,37 @@ try
rep = simulator.run(simtimer, state, well_state); rep = simulator.run(simtimer, state, well_state);
} else { } else {
// With a deck, we may have more epochs etc. // With a deck, we may have more epochs etc.
WellState well_state; WellState well_state;
int step = 0; int step = 0;
Opm::TimeMapPtr timeMap(new Opm::TimeMap(deck));
SimulatorTimer simtimer; SimulatorTimer simtimer;
// Use timer for last epoch to obtain total time. simtimer.init(timeMap);
deck->setCurrentEpoch(deck->numberOfEpochs() - 1);
simtimer.init(*deck);
const double total_time = simtimer.totalTime();
// Check for WPOLYMER presence in last epoch to decide // Check for WPOLYMER presence in last epoch to decide
// polymer injection control type. // polymer injection control type.
const bool use_wpolymer = deck->hasField("WPOLYMER"); const bool use_wpolymer = deck->hasKeyword("WPOLYMER");
if (use_wpolymer) { if (use_wpolymer) {
if (param.has("poly_start_days")) { if (param.has("poly_start_days")) {
OPM_MESSAGE("Warning: Using WPOLYMER to control injection since it was found in deck. " OPM_MESSAGE("Warning: Using WPOLYMER to control injection since it was found in deck. "
"You seem to be trying to control it via parameter poly_start_days (etc.) as well."); "You seem to be trying to control it via parameter poly_start_days (etc.) as well.");
} }
} }
for (int epoch = 0; epoch < deck->numberOfEpochs(); ++epoch) { for (size_t reportStepIdx = 0; reportStepIdx < timeMap->numTimesteps(); ++reportStepIdx) {
// Set epoch index. simtimer.setCurrentStepNum(reportStepIdx);
deck->setCurrentEpoch(epoch);
// Update the timer. // Report on start of report step.
if (deck->hasField("TSTEP")) { std::cout << "\n\n-------------- Starting report step " << reportStepIdx << " --------------"
simtimer.init(*deck); << "\n (number of remaining steps: "
} else {
if (epoch != 0) {
OPM_THROW(std::runtime_error, "No TSTEP in deck for epoch " << epoch);
}
simtimer.init(param);
}
simtimer.setCurrentStepNum(step);
simtimer.setTotalTime(total_time);
// Report on start of epoch.
std::cout << "\n\n-------------- Starting epoch " << epoch << " --------------"
<< "\n (number of steps: "
<< simtimer.numSteps() - step << ")\n\n" << std::flush; << simtimer.numSteps() - step << ")\n\n" << std::flush;
// Create new wells, polymer inflow controls. // Create new wells, polymer inflow controls.
WellsManager wells(*deck, *grid->c_grid(), props->permeability()); WellsManager wells(eclipseState , reportStepIdx , *grid->c_grid(), props->permeability());
boost::scoped_ptr<PolymerInflowInterface> polymer_inflow; boost::scoped_ptr<PolymerInflowInterface> polymer_inflow;
if (use_wpolymer) { if (use_wpolymer) {
if (wells.c_wells() == 0) { if (wells.c_wells() == 0) {
OPM_THROW(std::runtime_error, "Cannot control polymer injection via WPOLYMER without wells."); OPM_THROW(std::runtime_error, "Cannot control polymer injection via WPOLYMER without wells.");
} }
polymer_inflow.reset(new PolymerInflowFromDeck(*deck, *wells.c_wells(), props->numCells())); polymer_inflow.reset(new PolymerInflowFromDeck(deck, *wells.c_wells(), props->numCells()));
} else { } else {
polymer_inflow.reset(new PolymerInflowBasic(param.getDefault("poly_start_days", 300.0)*Opm::unit::day, 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, param.getDefault("poly_end_days", 800.0)*Opm::unit::day,
@ -318,9 +316,9 @@ try
} }
// @@@ HACK: we should really make a new well state and // @@@ HACK: we should really make a new well state and
// properly transfer old well state to it every epoch, // properly transfer old well state to it every report step,
// since number of wells may change etc. // since number of wells may change etc.
if (epoch == 0) { if (reportStepIdx == 0) {
well_state.init(wells.c_wells(), state); well_state.init(wells.c_wells(), state);
} }
@ -336,7 +334,7 @@ try
bcs.c_bcs(), bcs.c_bcs(),
linsolver, linsolver,
grav); grav);
if (epoch == 0) { if (reportStepIdx == 0) {
warnIfUnusedParams(param); warnIfUnusedParams(param);
} }
SimulatorReport epoch_rep = simulator.run(simtimer, state, well_state); SimulatorReport epoch_rep = simulator.run(simtimer, state, well_state);

View File

@ -69,8 +69,6 @@ try
param.disableOutput(); param.disableOutput();
// std::cout << "--------------- Reading parameters ---------------" << std::endl; // std::cout << "--------------- Reading parameters ---------------" << std::endl;
// If we have a "deck_filename", grid and props will be read from that.
boost::scoped_ptr<EclipseGridParser> deck;
boost::scoped_ptr<GridManager> grid; boost::scoped_ptr<GridManager> grid;
boost::scoped_ptr<IncompPropertiesInterface> props; boost::scoped_ptr<IncompPropertiesInterface> props;
PolymerState state; PolymerState state;
@ -129,9 +127,15 @@ try
ads_vals[2] = 0.0025; ads_vals[2] = 0.0025;
// ads_vals[1] = 0.0; // ads_vals[1] = 0.0;
// ads_vals[2] = 0.0; // ads_vals[2] = 0.0;
std::vector<double> water_vel_vals(2, -1e100);
water_vel_vals[0] = 0.0;
water_vel_vals[1] = 10.0;
std::vector<double> shear_vrf_vals(2, -1e100);
shear_vrf_vals[0] = 1.0;
shear_vrf_vals[1] = 1.0;
poly_props.set(c_max, mix_param, rock_density, dead_pore_vol, res_factor, c_max_ads, poly_props.set(c_max, mix_param, rock_density, dead_pore_vol, res_factor, c_max_ads,
static_cast<Opm::PolymerProperties::AdsorptionBehaviour>(ads_index), static_cast<Opm::PolymerProperties::AdsorptionBehaviour>(ads_index),
c_vals_visc, visc_mult_vals, c_vals_ads, ads_vals); c_vals_visc, visc_mult_vals, c_vals_ads, ads_vals, water_vel_vals, shear_vrf_vals);
// Initialising src // Initialising src
int num_cells = grid->c_grid()->number_of_cells; int num_cells = grid->c_grid()->number_of_cells;

View File

@ -35,9 +35,14 @@ namespace Opm
public: public:
void init(const UnstructuredGrid& g, int num_phases) void init(const UnstructuredGrid& g, int num_phases)
{ {
state_blackoil_.init(g, num_phases); this->init(g.number_of_cells, g.number_of_faces, num_phases);
concentration_.resize(g.number_of_cells, 0.0); }
cmax_.resize(g.number_of_cells, 0.0);
void init(int number_of_cells, int number_of_faces, int num_phases)
{
state_blackoil_.init(number_of_cells, number_of_faces, num_phases);
concentration_.resize(number_of_cells, 0.0);
cmax_.resize(number_of_cells, 0.0);
} }
int numPhases() const int numPhases() const
{ {

View File

@ -18,8 +18,8 @@
*/ */
#include <opm/polymer/PolymerInflow.hpp> #include <opm/polymer/PolymerInflow.hpp>
#include <opm/core/io/eclipse/EclipseGridParser.hpp>
#include <opm/core/wells.h> #include <opm/core/wells.h>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <map> #include <map>
namespace Opm namespace Opm
@ -60,19 +60,19 @@ namespace Opm
/// Constructor. /// Constructor.
/// @param[in] deck Input deck expected to contain WPOLYMER. /// @param[in] deck Input deck expected to contain WPOLYMER.
PolymerInflowFromDeck::PolymerInflowFromDeck(const EclipseGridParser& deck, PolymerInflowFromDeck::PolymerInflowFromDeck(Opm::DeckConstPtr deck,
const Wells& wells, const Wells& wells,
const int num_cells) const int num_cells)
: sparse_inflow_(num_cells) : sparse_inflow_(num_cells)
{ {
if (!deck.hasField("WPOLYMER")) { if (!deck->hasKeyword("WPOLYMER")) {
OPM_MESSAGE("PolymerInflowFromDeck initialized without WPOLYMER in current epoch."); OPM_MESSAGE("PolymerInflowFromDeck initialized without WPOLYMER in current epoch.");
return; return;
} }
// Extract concentrations and put into cell->concentration map. // Extract concentrations and put into cell->concentration map.
const std::vector<WpolymerLine>& wpl = deck.getWPOLYMER().wpolymer_; Opm::DeckKeywordConstPtr wpolymerKeyword = deck->getKeyword("WPOLYMER");
const int num_wpl = wpl.size(); const int num_wpl = wpolymerKeyword->size();
std::map<int, double> perfcell_conc; std::map<int, double> perfcell_conc;
for (int i = 0; i < num_wpl; ++i) { for (int i = 0; i < num_wpl; ++i) {
// Only use well name and polymer concentration. // Only use well name and polymer concentration.
@ -80,16 +80,19 @@ namespace Opm
// names. // names.
int wix = 0; int wix = 0;
for (; wix < wells.number_of_wells; ++wix) { for (; wix < wells.number_of_wells; ++wix) {
if (wpl[i].well_ == wells.name[wix]) { if (wpolymerKeyword->getRecord(i)->getItem("WELL")->getString(0) == wells.name[wix]) {
break; break;
} }
} }
if (wix == wells.number_of_wells) { if (wix == wells.number_of_wells) {
OPM_THROW(std::runtime_error, "Could not find a match for well " << wpl[i].well_ << " from WPOLYMER."); 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) { for (int j = wells.well_connpos[wix]; j < wells.well_connpos[wix+1]; ++j) {
const int perf_cell = wells.well_cells[j]; const int perf_cell = wells.well_cells[j];
perfcell_conc[perf_cell] = wpl[i].polymer_concentration_; perfcell_conc[perf_cell] =
wpolymerKeyword->getRecord(i)->getItem("POLYMER_CONCENTRATION")->getSIDouble(0);
} }
} }

View File

@ -21,17 +21,13 @@
#define OPM_POLYMERINFLOW_HEADER_INCLUDED #define OPM_POLYMERINFLOW_HEADER_INCLUDED
#include <opm/core/utility/SparseVector.hpp> #include <opm/core/utility/SparseVector.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <vector> #include <vector>
struct Wells; struct Wells;
namespace Opm namespace Opm
{ {
class EclipseGridParser;
/// @brief Interface for classes encapsulating polymer inflow information. /// @brief Interface for classes encapsulating polymer inflow information.
class PolymerInflowInterface class PolymerInflowInterface
{ {
@ -90,7 +86,7 @@ namespace Opm
/// \param[in] deck Input deck expected to contain WPOLYMER. /// \param[in] deck Input deck expected to contain WPOLYMER.
/// \param[in] wells Wells structure. /// \param[in] wells Wells structure.
/// \param[in] num_cells Number of cells in grid. /// \param[in] num_cells Number of cells in grid.
PolymerInflowFromDeck(const EclipseGridParser& deck, PolymerInflowFromDeck(Opm::DeckConstPtr deck,
const Wells& wells, const Wells& wells,
const int num_cells); const int num_cells);

View File

@ -21,6 +21,8 @@
#include <cmath> #include <cmath>
#include <vector> #include <vector>
#include <opm/core/utility/linearInterpolation.hpp> #include <opm/core/utility/linearInterpolation.hpp>
#include <opm/core/utility/ErrorMacros.hpp>
#include <opm/core/utility/Exceptions.hpp>
namespace Opm namespace Opm
{ {
@ -59,6 +61,25 @@ namespace Opm
return ads_index_; return ads_index_;
} }
const std::vector<double>&
PolymerProperties::shearWaterVelocity() const
{
return water_vel_vals_;
}
double
PolymerProperties::shearVrf(const double velocity) const
{
return Opm::linearInterpolation(water_vel_vals_, shear_vrf_vals_, velocity);
}
double
PolymerProperties::shearVrfWithDer(const double velocity, double& der) const
{
der = Opm::linearInterpolationDerivative(water_vel_vals_, shear_vrf_vals_, velocity);
return Opm::linearInterpolation(water_vel_vals_, shear_vrf_vals_, velocity);
}
double PolymerProperties::viscMult(double c) const double PolymerProperties::viscMult(double c) const
{ {
return Opm::linearInterpolation(c_vals_visc_, visc_mult_vals_, c); return Opm::linearInterpolation(c_vals_visc_, visc_mult_vals_, c);

View File

@ -20,10 +20,11 @@
#ifndef OPM_POLYMERPROPERTIES_HEADER_INCLUDED #ifndef OPM_POLYMERPROPERTIES_HEADER_INCLUDED
#define OPM_POLYMERPROPERTIES_HEADER_INCLUDED #define OPM_POLYMERPROPERTIES_HEADER_INCLUDED
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <cmath> #include <cmath>
#include <vector> #include <vector>
#include <opm/core/io/eclipse/EclipseGridParser.hpp>
namespace Opm namespace Opm
@ -49,6 +50,8 @@ namespace Opm
/// \param[in] visc_mult_vals Array of effective vicosity multiplier /// \param[in] visc_mult_vals Array of effective vicosity multiplier
/// \param[in] c_vals_ads Array of concentration for adsorption values /// \param[in] c_vals_ads Array of concentration for adsorption values
/// \param[in] ads_vals Array of adsorption values /// \param[in] ads_vals Array of adsorption values
/// \param[in] water_vel_vals_ Array of water phase velocity for shear
/// \param[in] shear_vrf_vals_ Array of viscosity reduction factor
PolymerProperties(double c_max, PolymerProperties(double c_max,
double mix_param, double mix_param,
double rock_density, double rock_density,
@ -59,7 +62,9 @@ namespace Opm
const std::vector<double>& c_vals_visc, const std::vector<double>& c_vals_visc,
const std::vector<double>& visc_mult_vals, const std::vector<double>& visc_mult_vals,
const std::vector<double>& c_vals_ads, const std::vector<double>& c_vals_ads,
const std::vector<double>& ads_vals const std::vector<double>& ads_vals,
const std::vector<double>& water_vel_vals,
const std::vector<double>& shear_vrf_vals
) )
: c_max_(c_max), : c_max_(c_max),
mix_param_(mix_param), mix_param_(mix_param),
@ -71,13 +76,15 @@ namespace Opm
c_vals_visc_(c_vals_visc), c_vals_visc_(c_vals_visc),
visc_mult_vals_(visc_mult_vals), visc_mult_vals_(visc_mult_vals),
c_vals_ads_(c_vals_ads), c_vals_ads_(c_vals_ads),
ads_vals_(ads_vals) ads_vals_(ads_vals),
water_vel_vals_(water_vel_vals),
shear_vrf_vals_(shear_vrf_vals)
{ {
} }
PolymerProperties(const EclipseGridParser& gridparser) PolymerProperties(Opm::EclipseStateConstPtr eclipseState)
{ {
readFromDeck(gridparser); readFromDeck(eclipseState);
} }
void set(double c_max, void set(double c_max,
@ -90,7 +97,9 @@ namespace Opm
const std::vector<double>& c_vals_visc, const std::vector<double>& c_vals_visc,
const std::vector<double>& visc_mult_vals, const std::vector<double>& visc_mult_vals,
const std::vector<double>& c_vals_ads, const std::vector<double>& c_vals_ads,
const std::vector<double>& ads_vals const std::vector<double>& ads_vals,
const std::vector<double>& water_vel_vals,
const std::vector<double>& shear_vrf_vals
) )
{ {
c_max_ = c_max; c_max_ = c_max;
@ -104,36 +113,52 @@ namespace Opm
c_vals_ads_ = c_vals_ads; c_vals_ads_ = c_vals_ads;
ads_vals_ = ads_vals; ads_vals_ = ads_vals;
ads_index_ = ads_index; ads_index_ = ads_index;
water_vel_vals_ = water_vel_vals;
shear_vrf_vals_ = shear_vrf_vals;
} }
void readFromDeck(const EclipseGridParser& gridparser) void readFromDeck(Opm::EclipseStateConstPtr eclipseState)
{ {
// We assume NTMISC=1 // We assume NTMISC=1
const std::vector<double>& plymax = gridparser.getPLYMAX().plymax_; const auto& plymaxTable = eclipseState->getPlymaxTables()[0];
c_max_ = plymax[0]; const auto& tlmixparTable = eclipseState->getTlmixparTables()[0];
const std::vector<double>& tlmixpar = gridparser.getTLMIXPAR().tlmixpar_;
mix_param_ = tlmixpar[0]; // We also assume that each table has exactly one row...
assert(plymaxTable.numRows() == 1);
assert(tlmixparTable.numRows() == 1);
c_max_ = plymaxTable.getPolymerConcentrationColumn()[0];
mix_param_ = tlmixparTable.getViscosityParameterColumn()[0];
// We assume NTSFUN=1 // We assume NTSFUN=1
const std::vector<double>& plyrock = gridparser.getPLYROCK().plyrock_; const auto& plyrockTable = eclipseState->getPlyrockTables()[0];
assert(plyrock.size() == 5);
dead_pore_vol_ = plyrock[0]; // We also assume that each table has exactly one row...
res_factor_ = plyrock[1]; assert(plyrockTable.numRows() == 1);
rock_density_ = plyrock[2];
ads_index_ = static_cast<AdsorptionBehaviour>(plyrock[3]); dead_pore_vol_ = plyrockTable.getDeadPoreVolumeColumn()[0];
c_max_ads_ = plyrock[4]; res_factor_ = plyrockTable.getResidualResistanceFactorColumn()[0];
rock_density_ = plyrockTable.getRockDensityFactorColumn()[0];
ads_index_ = static_cast<AdsorptionBehaviour>(plyrockTable.getAdsorbtionIndexColumn()[0]);
c_max_ads_ = plyrockTable.getMaxAdsorbtionColumn()[0];
// We assume NTPVT=1 // We assume NTPVT=1
const PLYVISC& plyvisc = gridparser.getPLYVISC(); const auto& plyviscTable = eclipseState->getPlyviscTables()[0];
c_vals_visc_ = plyvisc.concentration_;
visc_mult_vals_ = plyvisc.factor_; // We also assume that each table has exactly one row...
assert(plyviscTable.numRows() == 1);
c_vals_visc_[0] = plyviscTable.getPolymerConcentrationColumn()[0];
visc_mult_vals_[0] = plyviscTable.getViscosityMultiplierColumn()[0];
// We assume NTSFUN=1 // We assume NTSFUN=1
const PLYADS& plyads = gridparser.getPLYADS(); const auto& plyadsTable = eclipseState->getPlyadsTables()[0];
c_vals_ads_ = plyads.local_concentration_;
ads_vals_ = plyads.adsorbed_concentration_;
// We also assume that each table has exactly one row...
assert(plyadsTable.numRows() == 1);
c_vals_ads_[0] = plyadsTable.getPolymerConcentrationColumn()[0];
ads_vals_[0] = plyadsTable.getAdsorbedPolymerColumn()[0];
} }
double cMax() const; double cMax() const;
@ -150,6 +175,12 @@ namespace Opm
int adsIndex() const; int adsIndex() const;
const std::vector<double>& shearWaterVelocity() const;
double shearVrf(const double velocity) const;
double shearVrfWithDer(const double velocity, double& der) const;
double viscMult(double c) const; double viscMult(double c) const;
double viscMultWithDer(double c, double* der) const; double viscMultWithDer(double c, double* der) const;
@ -259,6 +290,8 @@ namespace Opm
std::vector<double> visc_mult_vals_; std::vector<double> visc_mult_vals_;
std::vector<double> c_vals_ads_; std::vector<double> c_vals_ads_;
std::vector<double> ads_vals_; std::vector<double> ads_vals_;
std::vector<double> water_vel_vals_;
std::vector<double> shear_vrf_vals_;
void simpleAdsorptionBoth(double c, double& c_ads, void simpleAdsorptionBoth(double c, double& c_ads,
double& dc_ads_dc, bool if_with_der) const; double& dc_ads_dc, bool if_with_der) const;
void adsorptionBoth(double c, double cmax, void adsorptionBoth(double c, double cmax,

View File

@ -34,9 +34,14 @@ namespace Opm
public: public:
void init(const UnstructuredGrid& g, int num_phases) void init(const UnstructuredGrid& g, int num_phases)
{ {
state2p_.init(g, num_phases); this->init(g.number_of_cells, g.number_of_faces, num_phases);
concentration_.resize(g.number_of_cells, 0.0); }
cmax_.resize(g.number_of_cells, 0.0);
void init(int number_of_cells, int number_of_faces, int num_phases)
{
state2p_.init(number_of_cells, number_of_faces, num_phases);
concentration_.resize(number_of_cells, 0.0);
cmax_.resize(number_of_cells, 0.0);
} }
enum ExtremalSat { MinSat = TwophaseState::MinSat, MaxSat = TwophaseState::MaxSat }; enum ExtremalSat { MinSat = TwophaseState::MinSat, MaxSat = TwophaseState::MaxSat };

View File

@ -126,8 +126,6 @@ namespace Opm
WellsManager& wells_manager_; WellsManager& wells_manager_;
const Wells* wells_; const Wells* wells_;
const PolymerInflowInterface& polymer_inflow_; const PolymerInflowInterface& polymer_inflow_;
const std::vector<double>& src_;
const FlowBoundaryConditions* bcs_;
const double* gravity_; const double* gravity_;
// Solvers // Solvers
CompressibleTpfaPolymer psolver_; CompressibleTpfaPolymer psolver_;
@ -190,8 +188,6 @@ namespace Opm
wells_manager_(wells_manager), wells_manager_(wells_manager),
wells_(wells_manager.c_wells()), wells_(wells_manager.c_wells()),
polymer_inflow_(polymer_inflow), polymer_inflow_(polymer_inflow),
src_(src),
bcs_(bcs),
gravity_(gravity), gravity_(gravity),
psolver_(grid, props, rock_comp_props, poly_props, linsolver, psolver_(grid, props, rock_comp_props, poly_props, linsolver,
param.getDefault("nl_pressure_residual_tolerance", 0.0), param.getDefault("nl_pressure_residual_tolerance", 0.0),
@ -388,7 +384,7 @@ namespace Opm
Opm::computeTransportSource(props_, wells_, well_state, transport_src); Opm::computeTransportSource(props_, wells_, well_state, transport_src);
// Find inflow rate. // Find inflow rate.
const double current_time = timer.currentTime(); const double current_time = timer.simulationTimeElapsed();
double stepsize = timer.currentStepLength(); double stepsize = timer.currentStepLength();
polymer_inflow_.getInflowValues(current_time, current_time + stepsize, polymer_inflow_c); polymer_inflow_.getInflowValues(current_time, current_time + stepsize, polymer_inflow_c);
@ -488,12 +484,12 @@ namespace Opm
<< std::endl; << std::endl;
std::cout.precision(8); std::cout.precision(8);
watercut.push(timer.currentTime() + timer.currentStepLength(), watercut.push(timer.simulationTimeElapsed() + timer.currentStepLength(),
produced[0]/(produced[0] + produced[1]), produced[0]/(produced[0] + produced[1]),
tot_produced[0]/tot_porevol_init); tot_produced[0]/tot_porevol_init);
if (wells_) { if (wells_) {
wellreport.push(props_, *wells_, state.pressure(), state.surfacevol(), wellreport.push(props_, *wells_, state.pressure(), state.surfacevol(),
state.saturation(), timer.currentTime() + timer.currentStepLength(), state.saturation(), timer.simulationTimeElapsed() + timer.currentStepLength(),
well_state.bhp(), well_state.perfRates()); well_state.bhp(), well_state.perfRates());
} }
} }

View File

@ -39,7 +39,7 @@ namespace Opm
class SimulatorTimer; class SimulatorTimer;
class PolymerBlackoilState; class PolymerBlackoilState;
class WellState; class WellState;
class SimulatorReport; struct SimulatorReport;
/// Class collecting all necessary components for a two-phase simulation. /// Class collecting all necessary components for a two-phase simulation.
class SimulatorCompressiblePolymer class SimulatorCompressiblePolymer

View File

@ -140,7 +140,6 @@ namespace Opm
const PolymerInflowInterface& polymer_inflow_; const PolymerInflowInterface& polymer_inflow_;
const std::vector<double>& src_; const std::vector<double>& src_;
const FlowBoundaryConditions* bcs_; const FlowBoundaryConditions* bcs_;
const double* gravity_;
// Solvers // Solvers
IncompTpfaPolymer psolver_; IncompTpfaPolymer psolver_;
TransportSolverTwophasePolymer tsolver_; TransportSolverTwophasePolymer tsolver_;
@ -204,7 +203,6 @@ namespace Opm
polymer_inflow_(polymer_inflow), polymer_inflow_(polymer_inflow),
src_(src), src_(src),
bcs_(bcs), bcs_(bcs),
gravity_(gravity),
psolver_(grid, props, rock_comp_props, poly_props, linsolver, psolver_(grid, props, rock_comp_props, poly_props, linsolver,
param.getDefault("nl_pressure_residual_tolerance", 0.0), param.getDefault("nl_pressure_residual_tolerance", 0.0),
param.getDefault("nl_pressure_change_tolerance", 1.0), param.getDefault("nl_pressure_change_tolerance", 1.0),
@ -411,7 +409,7 @@ namespace Opm
wells_, well_state.perfRates(), transport_src); wells_, well_state.perfRates(), transport_src);
// Find inflow rate. // Find inflow rate.
const double current_time = timer.currentTime(); const double current_time = timer.simulationTimeElapsed();
double stepsize = timer.currentStepLength(); double stepsize = timer.currentStepLength();
polymer_inflow_.getInflowValues(current_time, current_time + stepsize, polymer_inflow_c); polymer_inflow_.getInflowValues(current_time, current_time + stepsize, polymer_inflow_c);
@ -498,12 +496,12 @@ namespace Opm
<< std::endl; << std::endl;
std::cout.precision(8); std::cout.precision(8);
watercut.push(timer.currentTime() + timer.currentStepLength(), watercut.push(timer.simulationTimeElapsed() + timer.currentStepLength(),
produced[0]/(produced[0] + produced[1]), produced[0]/(produced[0] + produced[1]),
tot_produced[0]/tot_porevol_init); tot_produced[0]/tot_porevol_init);
if (wells_) { if (wells_) {
wellreport.push(props_, *wells_, state.saturation(), wellreport.push(props_, *wells_, state.saturation(),
timer.currentTime() + timer.currentStepLength(), timer.simulationTimeElapsed() + timer.currentStepLength(),
well_state.bhp(), well_state.perfRates()); well_state.bhp(), well_state.perfRates());
} }
} }
@ -621,7 +619,7 @@ namespace Opm
Opm::estimateCellVelocity(grid, state.faceflux(), cell_velocity); Opm::estimateCellVelocity(grid, state.faceflux(), cell_velocity);
dm["velocity"] = &cell_velocity; dm["velocity"] = &cell_velocity;
writeECLData(grid, dm, simtimer.currentStepNum(), simtimer.currentTime(), simtimer.currentDateTime(), writeECLData(grid, dm, simtimer.currentStepNum(), simtimer.simulationTimeElapsed(), simtimer.currentDateTime(),
output_dir, "polymer_ecl"); output_dir, "polymer_ecl");
#else #else
OPM_THROW(std::runtime_error, "Cannot call outputStateBinary() without ert library support. Reconfigure with --with-ert and recompile."); OPM_THROW(std::runtime_error, "Cannot call outputStateBinary() without ert library support. Reconfigure with --with-ert and recompile.");

View File

@ -39,7 +39,7 @@ namespace Opm
class SimulatorTimer; class SimulatorTimer;
class PolymerState; class PolymerState;
class WellState; class WellState;
class SimulatorReport; struct SimulatorReport;
/// Class collecting all necessary components for a two-phase simulation. /// Class collecting all necessary components for a two-phase simulation.
class SimulatorPolymer class SimulatorPolymer

View File

@ -1259,7 +1259,7 @@ namespace Opm
assert(np == 2); assert(np == 2);
const int dim = grid_.dimensions; const int dim = grid_.dimensions;
density_.resize(nc*np); density_.resize(nc*np);
props_.density(grid_.number_of_cells, &A_[0], &density_[0]); props_.density(grid_.number_of_cells, &A_[0], grid_.global_cell, &density_[0]);
std::fill(gravflux_.begin(), gravflux_.end(), 0.0); std::fill(gravflux_.begin(), gravflux_.end(), 0.0);
for (int f = 0; f < nf; ++f) { for (int f = 0; f < nf; ++f) {
const int* c = &grid_.face_cells[2*f]; const int* c = &grid_.face_cells[2*f];

View File

@ -929,7 +929,7 @@ namespace Opm
tmp_x[1]=x[1]; tmp_x[1]=x[1];
} }
res_eq.computeJacobiRes(tmp_x, dres_s_dsdc, dres_c_dsdc); res_eq.computeJacobiRes(tmp_x, dres_s_dsdc, dres_c_dsdc);
double dFx_dx,dFx_dy,dFy_dx,dFy_dy; double dFx_dx(0),dFx_dy(0),dFy_dx(0),dFy_dy(0);
double det = dFx_dx*dFy_dy - dFy_dx*dFx_dy; double det = dFx_dx*dFy_dy - dFy_dx*dFx_dy;
if(use_sc){ if(use_sc){
dFx_dx=(dres_s_dsdc[0]-tmp_x[1]*dres_s_dsdc[1]/tmp_x[0]); dFx_dx=(dres_s_dsdc[0]-tmp_x[1]*dres_s_dsdc[1]/tmp_x[0]);