Updated with changes from opm-core master
This commit is contained in:
parent
68b5c38f3a
commit
e4df4dd48d
@ -33,7 +33,7 @@ struct MultiWriter : public OutputWriter {
|
||||
}
|
||||
|
||||
virtual void writeTimeStep(const SimulatorTimerInterface& timer,
|
||||
const SimulatorState& reservoirState,
|
||||
const SimulationDataContainer& reservoirState,
|
||||
const WellState& wellState,
|
||||
bool isSubstep) {
|
||||
for (it_t it = writers_->begin (); it != writers_->end(); ++it) {
|
||||
|
@ -30,7 +30,7 @@ namespace Opm {
|
||||
// forward declaration
|
||||
class EclipseState;
|
||||
namespace parameter { class ParameterGroup; }
|
||||
class SimulatorState;
|
||||
class SimulationDataContainer;
|
||||
class WellState;
|
||||
struct PhaseUsage;
|
||||
|
||||
@ -87,7 +87,7 @@ public:
|
||||
* i.e. timer.currentStepNum () > 0.
|
||||
*/
|
||||
virtual void writeTimeStep(const SimulatorTimerInterface& timer,
|
||||
const SimulatorState& reservoirState,
|
||||
const SimulationDataContainer& reservoirState,
|
||||
const WellState& wellState,
|
||||
bool isSubstep) = 0;
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseMode.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
@ -43,9 +43,9 @@ namespace Opm
|
||||
public:
|
||||
CornerPointChopper(const std::string& file)
|
||||
{
|
||||
Opm::ParseMode parseMode;
|
||||
Opm::ParseContext parseContext;
|
||||
Opm::ParserPtr parser(new Opm::Parser());
|
||||
deck_ = parser->parseFile(file , parseMode);
|
||||
deck_ = parser->parseFile(file , parseContext);
|
||||
|
||||
metricUnits_.reset(Opm::UnitSystem::newMETRIC());
|
||||
|
||||
|
@ -2,11 +2,13 @@
|
||||
#define ECLIPSEREADER_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <opm/core/simulator/WellState.hpp>
|
||||
#include <opm/core/simulator/SimulatorState.hpp>
|
||||
#include <opm/core/props/BlackoilPhases.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
|
||||
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
///
|
||||
@ -23,10 +25,12 @@ namespace Opm
|
||||
/// An instance of a WellState object, with correct size for each of the 5 contained std::vector<double> objects
|
||||
///
|
||||
|
||||
class SimulationDataContainer;
|
||||
|
||||
void init_from_restart_file(EclipseStateConstPtr eclipse_state,
|
||||
int numcells,
|
||||
const PhaseUsage& pu,
|
||||
SimulatorState& simulator_state,
|
||||
SimulationDataContainer& simulator_state,
|
||||
WellState& wellstate);
|
||||
|
||||
|
||||
|
@ -21,8 +21,6 @@
|
||||
#define OPM_ECLIPSE_WRITE_RFT_HANDLER_HPP
|
||||
|
||||
#include <opm/core/simulator/SimulatorTimer.hpp>
|
||||
#include <opm/core/simulator/BlackoilState.hpp>
|
||||
#include <opm/core/simulator/SimulatorState.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
|
||||
|
@ -47,7 +47,7 @@ namespace EclipseWriterDetails {
|
||||
class Summary;
|
||||
}
|
||||
|
||||
class SimulatorState;
|
||||
class SimulationDataContainer;
|
||||
class WellState;
|
||||
|
||||
namespace parameter { class ParameterGroup; }
|
||||
@ -101,7 +101,7 @@ public:
|
||||
* \param[in] wellState The production/injection data for all wells
|
||||
*/
|
||||
virtual void writeTimeStep(const SimulatorTimerInterface& timer,
|
||||
const SimulatorState& reservoirState,
|
||||
const SimulationDataContainer& reservoirState,
|
||||
const WellState& wellState,
|
||||
bool isSubstep);
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
#include "EclipseReader.hpp"
|
||||
#include <opm/core/simulator/WellState.hpp>
|
||||
#include <opm/core/simulator/SimulatorState.hpp>
|
||||
#include <opm/core/simulator/BlackoilState.hpp>
|
||||
#include <opm/core/utility/Units.hpp>
|
||||
#include <opm/core/grid/GridHelpers.hpp>
|
||||
@ -38,10 +37,10 @@
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
void restoreTemperatureData(const ecl_file_type* file,
|
||||
EclipseStateConstPtr eclipse_state,
|
||||
int numcells,
|
||||
SimulatorState& simulator_state) {
|
||||
static void restoreTemperatureData(const ecl_file_type* file,
|
||||
EclipseStateConstPtr eclipse_state,
|
||||
int numcells,
|
||||
SimulationDataContainer& simulator_state) {
|
||||
const char* temperature = "TEMP";
|
||||
|
||||
if (ecl_file_has_kw(file , temperature)) {
|
||||
@ -69,7 +68,7 @@ namespace Opm
|
||||
void restorePressureData(const ecl_file_type* file,
|
||||
EclipseStateConstPtr eclipse_state,
|
||||
int numcells,
|
||||
SimulatorState& simulator_state) {
|
||||
SimulationDataContainer& simulator_state) {
|
||||
const char* pressure = "PRESSURE";
|
||||
|
||||
if (ecl_file_has_kw(file , pressure)) {
|
||||
@ -91,10 +90,10 @@ namespace Opm
|
||||
}
|
||||
|
||||
|
||||
void restoreSaturation(const ecl_file_type* file_type,
|
||||
const PhaseUsage& phaseUsage,
|
||||
int numcells,
|
||||
SimulatorState& simulator_state) {
|
||||
static void restoreSaturation(const ecl_file_type* file_type,
|
||||
const PhaseUsage& phaseUsage,
|
||||
int numcells,
|
||||
SimulationDataContainer& simulator_state) {
|
||||
|
||||
float* sgas_data = NULL;
|
||||
float* swat_data = NULL;
|
||||
@ -127,19 +126,20 @@ namespace Opm
|
||||
}
|
||||
|
||||
|
||||
void restoreRSandRV(const ecl_file_type* file_type,
|
||||
SimulationConfigConstPtr sim_config,
|
||||
int numcells,
|
||||
BlackoilState* blackoil_state) {
|
||||
static void restoreRSandRV(const ecl_file_type* file_type,
|
||||
SimulationConfigConstPtr sim_config,
|
||||
int numcells,
|
||||
SimulationDataContainer& simulator_state) {
|
||||
|
||||
if (sim_config->hasDISGAS()) {
|
||||
const char* RS = "RS";
|
||||
if (ecl_file_has_kw(file_type, RS)) {
|
||||
ecl_kw_type* rs_kw = ecl_file_iget_named_kw(file_type, RS, 0);
|
||||
float* rs_data = ecl_kw_get_float_ptr(rs_kw);
|
||||
std::vector<double> rs_datavec(&rs_data[0], &rs_data[numcells]);
|
||||
blackoil_state->gasoilratio().clear();
|
||||
blackoil_state->gasoilratio().insert(blackoil_state->gasoilratio().begin(), rs_datavec.begin(), rs_datavec.end());
|
||||
auto& rs = simulator_state.getCellData( BlackoilState::GASOILRATIO );
|
||||
for (int i = 0; i < ecl_kw_get_size( rs_kw ); i++) {
|
||||
rs[i] = rs_data[i];
|
||||
}
|
||||
} else {
|
||||
throw std::runtime_error("Restart file is missing RS data!\n");
|
||||
}
|
||||
@ -150,9 +150,10 @@ namespace Opm
|
||||
if (ecl_file_has_kw(file_type, RV)) {
|
||||
ecl_kw_type* rv_kw = ecl_file_iget_named_kw(file_type, RV, 0);
|
||||
float* rv_data = ecl_kw_get_float_ptr(rv_kw);
|
||||
std::vector<double> rv_datavec(&rv_data[0], &rv_data[numcells]);
|
||||
blackoil_state->rv().clear();
|
||||
blackoil_state->rv().insert(blackoil_state->rv().begin(), rv_datavec.begin(), rv_datavec.end());
|
||||
auto& rv = simulator_state.getCellData( BlackoilState::RV );
|
||||
for (int i = 0; i < ecl_kw_get_size( rv_kw ); i++) {
|
||||
rv[i] = rv_data[i];
|
||||
}
|
||||
} else {
|
||||
throw std::runtime_error("Restart file is missing RV data!\n");
|
||||
}
|
||||
@ -160,13 +161,13 @@ namespace Opm
|
||||
}
|
||||
|
||||
|
||||
void restoreSOLUTION(const std::string& restart_filename,
|
||||
int reportstep,
|
||||
bool unified,
|
||||
EclipseStateConstPtr eclipseState,
|
||||
int numcells,
|
||||
const PhaseUsage& phaseUsage,
|
||||
SimulatorState& simulator_state)
|
||||
static void restoreSOLUTION(const std::string& restart_filename,
|
||||
int reportstep,
|
||||
bool unified,
|
||||
EclipseStateConstPtr eclipseState,
|
||||
int numcells,
|
||||
const PhaseUsage& phaseUsage,
|
||||
SimulationDataContainer& simulator_state)
|
||||
{
|
||||
const char* filename = restart_filename.c_str();
|
||||
ecl_file_type* file_type = ecl_file_open(filename, 0);
|
||||
@ -178,11 +179,10 @@ namespace Opm
|
||||
restorePressureData(file_type, eclipseState, numcells, simulator_state);
|
||||
restoreTemperatureData(file_type, eclipseState, numcells, simulator_state);
|
||||
restoreSaturation(file_type, phaseUsage, numcells, simulator_state);
|
||||
BlackoilState* blackoilState = dynamic_cast<BlackoilState*>(&simulator_state);
|
||||
if (blackoilState) {
|
||||
if (simulator_state.hasCellData( BlackoilState::RV )) {
|
||||
SimulationConfigConstPtr sim_config = eclipseState->getSimulationConfig();
|
||||
restoreRSandRV(file_type, sim_config, numcells, blackoilState);
|
||||
}
|
||||
restoreRSandRV(file_type, sim_config, numcells, simulator_state );
|
||||
}
|
||||
} else {
|
||||
std::string error_str = "Restart file " + restart_filename + " does not contain data for report step " + std::to_string(reportstep) + "!\n";
|
||||
throw std::runtime_error(error_str);
|
||||
@ -195,7 +195,7 @@ namespace Opm
|
||||
}
|
||||
|
||||
|
||||
void restoreOPM_XWELKeyword(const std::string& restart_filename, int reportstep, bool unified, WellState& wellstate)
|
||||
static void restoreOPM_XWELKeyword(const std::string& restart_filename, int reportstep, bool unified, WellState& wellstate)
|
||||
{
|
||||
const char * keyword = "OPM_XWEL";
|
||||
const char* filename = restart_filename.c_str();
|
||||
@ -229,7 +229,7 @@ namespace Opm
|
||||
void init_from_restart_file(EclipseStateConstPtr eclipse_state,
|
||||
int numcells,
|
||||
const PhaseUsage& phase_usage,
|
||||
SimulatorState& simulator_state,
|
||||
SimulationDataContainer& simulator_state,
|
||||
WellState& wellstate) {
|
||||
|
||||
InitConfigConstPtr initConfig = eclipse_state->getInitConfig();
|
||||
|
@ -20,8 +20,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include <opm/output/eclipse/EclipseWriteRFTHandler.hpp>
|
||||
#include <opm/core/simulator/SimulatorState.hpp>
|
||||
#include <opm/core/simulator/BlackoilState.hpp>
|
||||
#include <opm/core/simulator/SimulatorTimer.hpp>
|
||||
#include <opm/core/props/BlackoilPhases.hpp>
|
||||
#include <opm/core/utility/Units.hpp>
|
||||
|
@ -23,13 +23,16 @@
|
||||
|
||||
#include "EclipseWriter.hpp"
|
||||
|
||||
#include <opm/common/data/SimulationDataContainer.hpp>
|
||||
|
||||
|
||||
#include <opm/core/props/BlackoilPhases.hpp>
|
||||
#include <opm/core/props/phaseUsageFromDeck.hpp>
|
||||
#include <opm/core/grid.h>
|
||||
#include <opm/core/grid/cpgpreprocess/preprocess.h>
|
||||
#include <opm/core/simulator/SimulatorState.hpp>
|
||||
#include <opm/core/simulator/SimulatorTimerInterface.hpp>
|
||||
#include <opm/core/simulator/WellState.hpp>
|
||||
#include <opm/core/simulator/BlackoilState.hpp>
|
||||
#include <opm/output/eclipse/EclipseWriteRFTHandler.hpp>
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
#include <opm/core/utility/parameters/Parameter.hpp>
|
||||
@ -1184,16 +1187,19 @@ void EclipseWriter::writeInit(const SimulatorTimerInterface &timer)
|
||||
if (eclipseState_->hasDeckDoubleGridProperty("PERMX")) {
|
||||
auto data = eclipseState_->getDoubleGridProperty("PERMX")->getData();
|
||||
EclipseWriterDetails::convertFromSiTo(data, Opm::prefix::milli * Opm::unit::darcy);
|
||||
EclipseWriterDetails::restrictAndReorderToActiveCells(data, gridToEclipseIdx_.size(), gridToEclipseIdx_.data());
|
||||
fortio.writeKeyword("PERMX", data);
|
||||
}
|
||||
if (eclipseState_->hasDeckDoubleGridProperty("PERMY")) {
|
||||
auto data = eclipseState_->getDoubleGridProperty("PERMY")->getData();
|
||||
EclipseWriterDetails::convertFromSiTo(data, Opm::prefix::milli * Opm::unit::darcy);
|
||||
EclipseWriterDetails::restrictAndReorderToActiveCells(data, gridToEclipseIdx_.size(), gridToEclipseIdx_.data());
|
||||
fortio.writeKeyword("PERMY", data);
|
||||
}
|
||||
if (eclipseState_->hasDeckDoubleGridProperty("PERMZ")) {
|
||||
auto data = eclipseState_->getDoubleGridProperty("PERMZ")->getData();
|
||||
EclipseWriterDetails::convertFromSiTo(data, Opm::prefix::milli * Opm::unit::darcy);
|
||||
EclipseWriterDetails::restrictAndReorderToActiveCells(data, gridToEclipseIdx_.size(), gridToEclipseIdx_.data());
|
||||
fortio.writeKeyword("PERMZ", data);
|
||||
}
|
||||
}
|
||||
@ -1221,7 +1227,7 @@ void EclipseWriter::writeInit(const SimulatorTimerInterface &timer)
|
||||
|
||||
// implementation of the writeTimeStep method
|
||||
void EclipseWriter::writeTimeStep(const SimulatorTimerInterface& timer,
|
||||
const SimulatorState& reservoirState,
|
||||
const SimulationDataContainer& reservoirState,
|
||||
const WellState& wellState,
|
||||
bool isSubstep)
|
||||
{
|
||||
@ -1342,14 +1348,15 @@ void EclipseWriter::writeTimeStep(const SimulatorTimerInterface& timer,
|
||||
}
|
||||
|
||||
|
||||
const BlackoilState* blackoilState = dynamic_cast<const BlackoilState*>(&reservoirState);
|
||||
if (blackoilState) {
|
||||
// Write RS - Dissolved GOR
|
||||
const std::vector<double>& rs = blackoilState->gasoilratio();
|
||||
// Write RS - Dissolved GOR
|
||||
if (reservoirState.hasCellData( BlackoilState::GASOILRATIO )) {
|
||||
const std::vector<double>& rs = reservoirState.getCellData( BlackoilState::GASOILRATIO );
|
||||
sol.add(EclipseWriterDetails::Keyword<float>("RS", rs));
|
||||
}
|
||||
|
||||
// Write RV - Volatilized oil/gas ratio
|
||||
const std::vector<double>& rv = blackoilState->rv();
|
||||
// Write RV - Volatilized oil/gas ratio
|
||||
if (reservoirState.hasCellData( BlackoilState::RV )) {
|
||||
const std::vector<double>& rv = reservoirState.getCellData( BlackoilState::RV );
|
||||
sol.add(EclipseWriterDetails::Keyword<float>("RV", rv));
|
||||
}
|
||||
}
|
||||
|
@ -50,185 +50,183 @@
|
||||
|
||||
namespace {
|
||||
|
||||
void verifyRFTFile(const std::string& rft_filename) {
|
||||
void verifyRFTFile(const std::string& rft_filename) {
|
||||
|
||||
ecl_rft_file_type * new_rft_file = ecl_rft_file_alloc(rft_filename.c_str());
|
||||
std::shared_ptr<ecl_rft_file_type> rft_file;
|
||||
rft_file.reset(new_rft_file, ecl_rft_file_free);
|
||||
ecl_rft_file_type * new_rft_file = ecl_rft_file_alloc(rft_filename.c_str());
|
||||
std::shared_ptr<ecl_rft_file_type> rft_file;
|
||||
rft_file.reset(new_rft_file, ecl_rft_file_free);
|
||||
|
||||
//Get RFT node for well/time OP_1/10 OKT 2008
|
||||
time_t recording_time = util_make_datetime(0, 0, 0, 10, 10, 2008);
|
||||
ecl_rft_node_type * ecl_rft_node = ecl_rft_file_get_well_time_rft(rft_file.get() , "OP_1" , recording_time);
|
||||
BOOST_CHECK(ecl_rft_node_is_RFT(ecl_rft_node));
|
||||
//Get RFT node for well/time OP_1/10 OKT 2008
|
||||
time_t recording_time = util_make_datetime(0, 0, 0, 10, 10, 2008);
|
||||
ecl_rft_node_type * ecl_rft_node = ecl_rft_file_get_well_time_rft(rft_file.get() , "OP_1" , recording_time);
|
||||
BOOST_CHECK(ecl_rft_node_is_RFT(ecl_rft_node));
|
||||
|
||||
//Verify RFT data for completions (ijk) 9 9 1, 9 9 2 and 9 9 3 for OP_1
|
||||
const ecl_rft_cell_type * ecl_rft_cell1 = ecl_rft_node_lookup_ijk(ecl_rft_node, 8, 8, 0);
|
||||
const ecl_rft_cell_type * ecl_rft_cell2 = ecl_rft_node_lookup_ijk(ecl_rft_node, 8, 8, 1);
|
||||
const ecl_rft_cell_type * ecl_rft_cell3 = ecl_rft_node_lookup_ijk(ecl_rft_node, 8, 8, 2);
|
||||
//Verify RFT data for completions (ijk) 9 9 1, 9 9 2 and 9 9 3 for OP_1
|
||||
const ecl_rft_cell_type * ecl_rft_cell1 = ecl_rft_node_lookup_ijk(ecl_rft_node, 8, 8, 0);
|
||||
const ecl_rft_cell_type * ecl_rft_cell2 = ecl_rft_node_lookup_ijk(ecl_rft_node, 8, 8, 1);
|
||||
const ecl_rft_cell_type * ecl_rft_cell3 = ecl_rft_node_lookup_ijk(ecl_rft_node, 8, 8, 2);
|
||||
|
||||
BOOST_CHECK_CLOSE(ecl_rft_cell_get_pressure(ecl_rft_cell1), 210088*0.00001, 0.00001);
|
||||
BOOST_CHECK_CLOSE(ecl_rft_cell_get_pressure(ecl_rft_cell2), 210188*0.00001, 0.00001);
|
||||
BOOST_CHECK_CLOSE(ecl_rft_cell_get_pressure(ecl_rft_cell3), 210288*0.00001, 0.00001);
|
||||
BOOST_CHECK_CLOSE(ecl_rft_cell_get_pressure(ecl_rft_cell1), 210088*0.00001, 0.00001);
|
||||
BOOST_CHECK_CLOSE(ecl_rft_cell_get_pressure(ecl_rft_cell2), 210188*0.00001, 0.00001);
|
||||
BOOST_CHECK_CLOSE(ecl_rft_cell_get_pressure(ecl_rft_cell3), 210288*0.00001, 0.00001);
|
||||
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_sgas(ecl_rft_cell1), 0.0);
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_sgas(ecl_rft_cell2), 0.0);
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_sgas(ecl_rft_cell3), 0.0);
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_sgas(ecl_rft_cell1), 0.0);
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_sgas(ecl_rft_cell2), 0.0);
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_sgas(ecl_rft_cell3), 0.0);
|
||||
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_swat(ecl_rft_cell1), 0.0);
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_swat(ecl_rft_cell2), 0.0);
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_swat(ecl_rft_cell3), 0.0);
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_swat(ecl_rft_cell1), 0.0);
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_swat(ecl_rft_cell2), 0.0);
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_swat(ecl_rft_cell3), 0.0);
|
||||
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_soil(ecl_rft_cell1), 1.0);
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_soil(ecl_rft_cell2), 1.0);
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_soil(ecl_rft_cell3), 1.0);
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_soil(ecl_rft_cell1), 1.0);
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_soil(ecl_rft_cell2), 1.0);
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_soil(ecl_rft_cell3), 1.0);
|
||||
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_depth(ecl_rft_cell1), (0.250 + (0.250/2)));
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_depth(ecl_rft_cell2), (2*0.250 + (0.250/2)));
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_depth(ecl_rft_cell3), (3*0.250 + (0.250/2)));
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_depth(ecl_rft_cell1), (0.250 + (0.250/2)));
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_depth(ecl_rft_cell2), (2*0.250 + (0.250/2)));
|
||||
BOOST_CHECK_EQUAL(ecl_rft_cell_get_depth(ecl_rft_cell3), (3*0.250 + (0.250/2)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Opm::DeckConstPtr createDeck(const std::string& input_str) {
|
||||
Opm::ParserPtr parser = std::make_shared<Opm::Parser>();
|
||||
Opm::DeckConstPtr deck = parser->parseString(input_str , Opm::ParseContext());
|
||||
return deck;
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<Opm::WellState> createWellState(std::shared_ptr<Opm::BlackoilState> blackoilState)
|
||||
{
|
||||
std::shared_ptr<Opm::WellState> wellState = std::make_shared<Opm::WellState>();
|
||||
wellState->init(0, *blackoilState);
|
||||
return wellState;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::shared_ptr<Opm::BlackoilState> createBlackoilState(int timeStepIdx, std::shared_ptr<Opm::GridManager> ourFineGridManagerPtr)
|
||||
{
|
||||
const UnstructuredGrid &ug_grid = *ourFineGridManagerPtr->c_grid();
|
||||
|
||||
std::shared_ptr<Opm::BlackoilState> blackoilState = std::make_shared<Opm::BlackoilState>(Opm::UgGridHelpers::numCells( ug_grid ) , Opm::UgGridHelpers::numFaces( ug_grid ), 3);
|
||||
size_t numCells = Opm::UgGridHelpers::numCells( ug_grid );
|
||||
|
||||
auto &pressure = blackoilState->pressure();
|
||||
for (size_t cellIdx = 0; cellIdx < numCells; ++cellIdx) {
|
||||
pressure[cellIdx] = timeStepIdx*1e5 + 1e4 + cellIdx;
|
||||
}
|
||||
return blackoilState;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::shared_ptr<Opm::EclipseWriter> createEclipseWriter(std::shared_ptr<const Opm::Deck> deck,
|
||||
std::shared_ptr<Opm::EclipseState> eclipseState,
|
||||
std::shared_ptr<Opm::GridManager> ourFineGridManagerPtr,
|
||||
const int * compressedToCartesianCellIdx)
|
||||
{
|
||||
Opm::parameter::ParameterGroup params;
|
||||
params.insertParameter("deck_filename", "testcase.data");
|
||||
|
||||
Opm::DeckConstPtr createDeck(const std::string& input_str) {
|
||||
Opm::ParserPtr parser = std::make_shared<Opm::Parser>();
|
||||
Opm::DeckConstPtr deck = parser->parseString(input_str , Opm::ParseContext());
|
||||
return deck;
|
||||
}
|
||||
Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck);
|
||||
|
||||
const UnstructuredGrid &ourFinerUnstructuredGrid = *ourFineGridManagerPtr->c_grid();
|
||||
|
||||
std::shared_ptr<Opm::WellState> createWellState(std::shared_ptr<Opm::BlackoilState> blackoilState)
|
||||
{
|
||||
std::shared_ptr<Opm::WellState> wellState = std::make_shared<Opm::WellState>();
|
||||
wellState->init(0, *blackoilState);
|
||||
return wellState;
|
||||
}
|
||||
std::shared_ptr<Opm::EclipseWriter> eclipseWriter = std::make_shared<Opm::EclipseWriter>(params,
|
||||
eclipseState,
|
||||
phaseUsage,
|
||||
ourFinerUnstructuredGrid.number_of_cells,
|
||||
compressedToCartesianCellIdx);
|
||||
|
||||
|
||||
|
||||
std::shared_ptr<Opm::BlackoilState> createBlackoilState(int timeStepIdx, std::shared_ptr<Opm::GridManager> ourFineGridManagerPtr)
|
||||
{
|
||||
const UnstructuredGrid &ourFinerUnstructuredGrid = *ourFineGridManagerPtr->c_grid();
|
||||
|
||||
std::shared_ptr<Opm::BlackoilState> blackoilState = std::make_shared<Opm::BlackoilState>();
|
||||
blackoilState->init(ourFinerUnstructuredGrid, 3);
|
||||
|
||||
size_t numCells = ourFinerUnstructuredGrid.number_of_cells;
|
||||
|
||||
auto &pressure = blackoilState->pressure();
|
||||
for (size_t cellIdx = 0; cellIdx < numCells; ++cellIdx) {
|
||||
pressure[cellIdx] = timeStepIdx*1e5 + 1e4 + cellIdx;
|
||||
}
|
||||
return blackoilState;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::shared_ptr<Opm::EclipseWriter> createEclipseWriter(std::shared_ptr<const Opm::Deck> deck,
|
||||
std::shared_ptr<Opm::EclipseState> eclipseState,
|
||||
std::shared_ptr<Opm::GridManager> ourFineGridManagerPtr,
|
||||
const int * compressedToCartesianCellIdx)
|
||||
{
|
||||
Opm::parameter::ParameterGroup params;
|
||||
params.insertParameter("deck_filename", "testcase.data");
|
||||
|
||||
Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck);
|
||||
|
||||
const UnstructuredGrid &ourFinerUnstructuredGrid = *ourFineGridManagerPtr->c_grid();
|
||||
|
||||
std::shared_ptr<Opm::EclipseWriter> eclipseWriter = std::make_shared<Opm::EclipseWriter>(params,
|
||||
eclipseState,
|
||||
phaseUsage,
|
||||
ourFinerUnstructuredGrid.number_of_cells,
|
||||
compressedToCartesianCellIdx);
|
||||
|
||||
return eclipseWriter;
|
||||
}
|
||||
return eclipseWriter;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_EclipseWriterRFTHandler)
|
||||
{
|
||||
const std::string& deckString =
|
||||
"RUNSPEC\n"
|
||||
"OIL\n"
|
||||
"GAS\n"
|
||||
"WATER\n"
|
||||
"DIMENS\n"
|
||||
" 10 10 10 /\n"
|
||||
"GRID\n"
|
||||
"DXV\n"
|
||||
"10*0.25 /\n"
|
||||
"DYV\n"
|
||||
"10*0.25 /\n"
|
||||
"DZV\n"
|
||||
"10*0.25 /\n"
|
||||
"TOPS\n"
|
||||
"100*0.25 /\n"
|
||||
"\n"
|
||||
"START -- 0 \n"
|
||||
"1 NOV 1979 / \n"
|
||||
"SCHEDULE\n"
|
||||
"DATES -- 1\n"
|
||||
" 1 DES 1979/ \n"
|
||||
"/\n"
|
||||
"WELSPECS\n"
|
||||
" 'OP_1' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n"
|
||||
" 'OP_2' 'OP' 4 4 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n"
|
||||
"/\n"
|
||||
"COMPDAT\n"
|
||||
" 'OP_1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
" 'OP_1' 9 9 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 / \n"
|
||||
" 'OP_1' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
" 'OP_2' 4 4 4 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
"/\n"
|
||||
"DATES -- 2\n"
|
||||
" 10 OKT 2008 / \n"
|
||||
"/\n"
|
||||
"WRFT \n"
|
||||
"/ \n"
|
||||
"WELOPEN\n"
|
||||
" 'OP_1' OPEN / \n"
|
||||
" 'OP_2' OPEN / \n"
|
||||
"/\n"
|
||||
"DATES -- 3\n"
|
||||
" 10 NOV 2008 / \n"
|
||||
"/\n";
|
||||
{
|
||||
const std::string& deckString =
|
||||
"RUNSPEC\n"
|
||||
"OIL\n"
|
||||
"GAS\n"
|
||||
"WATER\n"
|
||||
"DIMENS\n"
|
||||
" 10 10 10 /\n"
|
||||
"GRID\n"
|
||||
"DXV\n"
|
||||
"10*0.25 /\n"
|
||||
"DYV\n"
|
||||
"10*0.25 /\n"
|
||||
"DZV\n"
|
||||
"10*0.25 /\n"
|
||||
"TOPS\n"
|
||||
"100*0.25 /\n"
|
||||
"\n"
|
||||
"START -- 0 \n"
|
||||
"1 NOV 1979 / \n"
|
||||
"SCHEDULE\n"
|
||||
"DATES -- 1\n"
|
||||
" 1 DES 1979/ \n"
|
||||
"/\n"
|
||||
"WELSPECS\n"
|
||||
" 'OP_1' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n"
|
||||
" 'OP_2' 'OP' 4 4 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n"
|
||||
"/\n"
|
||||
"COMPDAT\n"
|
||||
" 'OP_1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
" 'OP_1' 9 9 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 / \n"
|
||||
" 'OP_1' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
" 'OP_2' 4 4 4 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
"/\n"
|
||||
"DATES -- 2\n"
|
||||
" 10 OKT 2008 / \n"
|
||||
"/\n"
|
||||
"WRFT \n"
|
||||
"/ \n"
|
||||
"WELOPEN\n"
|
||||
" 'OP_1' OPEN / \n"
|
||||
" 'OP_2' OPEN / \n"
|
||||
"/\n"
|
||||
"DATES -- 3\n"
|
||||
" 10 NOV 2008 / \n"
|
||||
"/\n";
|
||||
|
||||
|
||||
|
||||
test_work_area_type * new_ptr = test_work_area_alloc("test_EclipseWriterRFTHandler");
|
||||
std::shared_ptr<test_work_area_type> test_area;
|
||||
test_area.reset(new_ptr, test_work_area_free);
|
||||
test_work_area_type * new_ptr = test_work_area_alloc("test_EclipseWriterRFTHandler");
|
||||
std::shared_ptr<test_work_area_type> test_area;
|
||||
test_area.reset(new_ptr, test_work_area_free);
|
||||
|
||||
std::shared_ptr<const Opm::Deck> deck = createDeck(deckString);
|
||||
std::shared_ptr<Opm::EclipseState> eclipseState = std::make_shared<Opm::EclipseState>(deck , Opm::ParseContext());
|
||||
std::shared_ptr<const Opm::Deck> deck = createDeck(deckString);
|
||||
std::shared_ptr<Opm::EclipseState> eclipseState = std::make_shared<Opm::EclipseState>(deck , Opm::ParseContext());
|
||||
|
||||
std::shared_ptr<Opm::SimulatorTimer> simulatorTimer = std::make_shared<Opm::SimulatorTimer>();
|
||||
simulatorTimer->init(eclipseState->getSchedule()->getTimeMap());
|
||||
std::shared_ptr<Opm::SimulatorTimer> simulatorTimer = std::make_shared<Opm::SimulatorTimer>();
|
||||
simulatorTimer->init(eclipseState->getSchedule()->getTimeMap());
|
||||
|
||||
std::shared_ptr<Opm::GridManager> ourFineGridManagerPtr = std::make_shared<Opm::GridManager>(eclipseState->getEclipseGrid());
|
||||
const UnstructuredGrid &ourFinerUnstructuredGrid = *ourFineGridManagerPtr->c_grid();
|
||||
const int* compressedToCartesianCellIdx = Opm::UgGridHelpers::globalCell(ourFinerUnstructuredGrid);
|
||||
std::shared_ptr<Opm::GridManager> ourFineGridManagerPtr = std::make_shared<Opm::GridManager>(eclipseState->getEclipseGrid());
|
||||
const UnstructuredGrid &ourFinerUnstructuredGrid = *ourFineGridManagerPtr->c_grid();
|
||||
const int* compressedToCartesianCellIdx = Opm::UgGridHelpers::globalCell(ourFinerUnstructuredGrid);
|
||||
|
||||
std::shared_ptr<Opm::EclipseWriter> eclipseWriter = createEclipseWriter(deck,
|
||||
eclipseState,
|
||||
ourFineGridManagerPtr,
|
||||
compressedToCartesianCellIdx);
|
||||
eclipseWriter->writeInit(*simulatorTimer);
|
||||
std::shared_ptr<Opm::EclipseWriter> eclipseWriter = createEclipseWriter(deck,
|
||||
eclipseState,
|
||||
ourFineGridManagerPtr,
|
||||
compressedToCartesianCellIdx);
|
||||
eclipseWriter->writeInit(*simulatorTimer);
|
||||
|
||||
|
||||
for (; simulatorTimer->currentStepNum() < simulatorTimer->numSteps(); ++ (*simulatorTimer)) {
|
||||
std::shared_ptr<Opm::BlackoilState> blackoilState2 = createBlackoilState(simulatorTimer->currentStepNum(),ourFineGridManagerPtr);
|
||||
std::shared_ptr<Opm::WellState> wellState = createWellState(blackoilState2);
|
||||
eclipseWriter->writeTimeStep(*simulatorTimer, *blackoilState2, *wellState, false);
|
||||
}
|
||||
for (; simulatorTimer->currentStepNum() < simulatorTimer->numSteps(); ++ (*simulatorTimer)) {
|
||||
std::shared_ptr<Opm::BlackoilState> blackoilState2 = createBlackoilState(simulatorTimer->currentStepNum(),ourFineGridManagerPtr);
|
||||
std::shared_ptr<Opm::WellState> wellState = createWellState(blackoilState2);
|
||||
eclipseWriter->writeTimeStep(*simulatorTimer, *blackoilState2, *wellState, false);
|
||||
}
|
||||
|
||||
std::string cwd(test_work_area_get_cwd(test_area.get()));
|
||||
std::string rft_filename = cwd + "/TESTCASE.RFT";
|
||||
verifyRFTFile(rft_filename);
|
||||
std::string cwd(test_work_area_get_cwd(test_area.get()));
|
||||
std::string rft_filename = cwd + "/TESTCASE.RFT";
|
||||
verifyRFTFile(rft_filename);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <opm/output/eclipse/EclipseWriter.hpp>
|
||||
#include <opm/output/eclipse/EclipseWriter.hpp>
|
||||
#include <opm/core/grid/GridManager.hpp>
|
||||
#include <opm/core/grid/GridHelpers.hpp>
|
||||
#include <opm/core/props/phaseUsageFromDeck.hpp>
|
||||
#include <opm/core/simulator/BlackoilState.hpp>
|
||||
#include <opm/core/simulator/WellState.hpp>
|
||||
@ -109,8 +110,7 @@ void createBlackoilState(int timeStepIdx)
|
||||
{
|
||||
// allocate a new BlackoilState object
|
||||
const UnstructuredGrid &ourFinerUnstructuredGrid = *ourFineGridManagerPtr->c_grid();
|
||||
blackoilState.reset(new Opm::BlackoilState);
|
||||
blackoilState->init(ourFinerUnstructuredGrid, 3);
|
||||
blackoilState.reset(new Opm::BlackoilState( Opm::UgGridHelpers::numCells( ourFinerUnstructuredGrid ) , Opm::UgGridHelpers::numFaces( ourFinerUnstructuredGrid ), 3));
|
||||
|
||||
size_t numCells = ourFinerUnstructuredGrid.number_of_cells;
|
||||
size_t numFaces = ourFinerUnstructuredGrid.number_of_faces;
|
||||
@ -367,55 +367,55 @@ void checkSummaryFile(int /*timeStepIdx*/)
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(EclipseWriterIntegration)
|
||||
{
|
||||
const char *deckString =
|
||||
"RUNSPEC\n"
|
||||
"INIT\n"
|
||||
"UNIFOUT\n"
|
||||
"OIL\n"
|
||||
"GAS\n"
|
||||
"WATER\n"
|
||||
"METRIC\n"
|
||||
"DIMENS\n"
|
||||
"3 3 3/\n"
|
||||
"GRID\n"
|
||||
"DXV\n"
|
||||
"1.0 2.0 3.0 /\n"
|
||||
"DYV\n"
|
||||
"4.0 5.0 6.0 /\n"
|
||||
"DZV\n"
|
||||
"7.0 8.0 9.0 /\n"
|
||||
"TOPS\n"
|
||||
"9*100 /\n"
|
||||
"PROPS\n"
|
||||
"PORO\n"
|
||||
"27*0.3 /\n"
|
||||
"PERMX\n"
|
||||
"27*1 /\n"
|
||||
"SOLUTION\n"
|
||||
"RPTRST\n"
|
||||
"BASIC=2\n"
|
||||
"/\n"
|
||||
"SCHEDULE\n"
|
||||
"TSTEP\n"
|
||||
"1.0 2.0 3.0 4.0 /\n"
|
||||
"WELSPECS\n"
|
||||
"'INJ' 'G' 1 1 2000 'GAS' /\n"
|
||||
"'PROD' 'G' 3 3 1000 'OIL' /\n"
|
||||
"/\n";
|
||||
{
|
||||
const char *deckString =
|
||||
"RUNSPEC\n"
|
||||
"INIT\n"
|
||||
"UNIFOUT\n"
|
||||
"OIL\n"
|
||||
"GAS\n"
|
||||
"WATER\n"
|
||||
"METRIC\n"
|
||||
"DIMENS\n"
|
||||
"3 3 3/\n"
|
||||
"GRID\n"
|
||||
"DXV\n"
|
||||
"1.0 2.0 3.0 /\n"
|
||||
"DYV\n"
|
||||
"4.0 5.0 6.0 /\n"
|
||||
"DZV\n"
|
||||
"7.0 8.0 9.0 /\n"
|
||||
"TOPS\n"
|
||||
"9*100 /\n"
|
||||
"PROPS\n"
|
||||
"PORO\n"
|
||||
"27*0.3 /\n"
|
||||
"PERMX\n"
|
||||
"27*1 /\n"
|
||||
"SOLUTION\n"
|
||||
"RPTRST\n"
|
||||
"BASIC=2\n"
|
||||
"/\n"
|
||||
"SCHEDULE\n"
|
||||
"TSTEP\n"
|
||||
"1.0 2.0 3.0 4.0 /\n"
|
||||
"WELSPECS\n"
|
||||
"'INJ' 'G' 1 1 2000 'GAS' /\n"
|
||||
"'PROD' 'G' 3 3 1000 'OIL' /\n"
|
||||
"/\n";
|
||||
|
||||
createEclipseWriter(deckString);
|
||||
createEclipseWriter(deckString);
|
||||
|
||||
eclWriter->writeInit(*simTimer);
|
||||
eclWriter->writeInit(*simTimer);
|
||||
|
||||
checkEgridFile();
|
||||
checkInitFile();
|
||||
checkEgridFile();
|
||||
checkInitFile();
|
||||
|
||||
for (; simTimer->currentStepNum() < simTimer->numSteps(); ++ (*simTimer)) {
|
||||
createBlackoilState(simTimer->currentStepNum());
|
||||
createWellState(simTimer->currentStepNum());
|
||||
eclWriter->writeTimeStep(*simTimer, *blackoilState, *wellState, false);
|
||||
checkRestartFile(simTimer->currentStepNum());
|
||||
checkSummaryFile(simTimer->currentStepNum());
|
||||
}
|
||||
}
|
||||
for (; simTimer->currentStepNum() < simTimer->numSteps(); ++ (*simTimer)) {
|
||||
createBlackoilState(simTimer->currentStepNum());
|
||||
createWellState(simTimer->currentStepNum());
|
||||
eclWriter->writeTimeStep(*simTimer, *blackoilState, *wellState, false);
|
||||
checkRestartFile(simTimer->currentStepNum());
|
||||
checkSummaryFile(simTimer->currentStepNum());
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <opm/output/eclipse/EclipseReader.hpp>
|
||||
#include <opm/output/eclipse/EclipseIOUtil.hpp>
|
||||
#include <opm/core/grid/GridManager.hpp>
|
||||
#include <opm/core/grid/GridHelpers.hpp>
|
||||
#include <opm/core/props/phaseUsageFromDeck.hpp>
|
||||
#include <opm/core/props/BlackoilPhases.hpp>
|
||||
#include <opm/core/simulator/BlackoilState.hpp>
|
||||
@ -60,155 +61,156 @@
|
||||
|
||||
|
||||
std::string input =
|
||||
"RUNSPEC\n"
|
||||
"OIL\n"
|
||||
"GAS\n"
|
||||
"WATER\n"
|
||||
"DISGAS\n"
|
||||
"VAPOIL\n"
|
||||
"UNIFOUT\n"
|
||||
"UNIFIN\n"
|
||||
"DIMENS\n"
|
||||
" 10 10 10 /\n"
|
||||
"RUNSPEC\n"
|
||||
"OIL\n"
|
||||
"GAS\n"
|
||||
"WATER\n"
|
||||
"DISGAS\n"
|
||||
"VAPOIL\n"
|
||||
"UNIFOUT\n"
|
||||
"UNIFIN\n"
|
||||
"DIMENS\n"
|
||||
" 10 10 10 /\n"
|
||||
|
||||
"GRID\n"
|
||||
"DXV\n"
|
||||
"10*0.25 /\n"
|
||||
"DYV\n"
|
||||
"10*0.25 /\n"
|
||||
"DZV\n"
|
||||
"10*0.25 /\n"
|
||||
"TOPS\n"
|
||||
"100*0.25 /\n"
|
||||
"\n"
|
||||
"GRID\n"
|
||||
"DXV\n"
|
||||
"10*0.25 /\n"
|
||||
"DYV\n"
|
||||
"10*0.25 /\n"
|
||||
"DZV\n"
|
||||
"10*0.25 /\n"
|
||||
"TOPS\n"
|
||||
"100*0.25 /\n"
|
||||
"\n"
|
||||
|
||||
"SOLUTION\n"
|
||||
"RESTART\n"
|
||||
"TESTWELLSTATE 1/\n"
|
||||
"\n"
|
||||
"SOLUTION\n"
|
||||
"RESTART\n"
|
||||
"TESTWELLSTATE 1/\n"
|
||||
"\n"
|
||||
|
||||
"START -- 0 \n"
|
||||
"1 NOV 1979 / \n"
|
||||
"START -- 0 \n"
|
||||
"1 NOV 1979 / \n"
|
||||
|
||||
"SCHEDULE\n"
|
||||
"SKIPREST\n"
|
||||
"RPTRST\n"
|
||||
"BASIC=1\n"
|
||||
"/\n"
|
||||
"DATES -- 1\n"
|
||||
" 10 OKT 2008 / \n"
|
||||
"/\n"
|
||||
"WELSPECS\n"
|
||||
" 'OP_1' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n"
|
||||
" 'OP_2' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n"
|
||||
"/\n"
|
||||
"COMPDAT\n"
|
||||
" 'OP_1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
" 'OP_2' 9 9 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 / \n"
|
||||
" 'OP_1' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
"/\n"
|
||||
"WCONPROD\n"
|
||||
"'OP_1' 'OPEN' 'ORAT' 20000 4* 1000 /\n"
|
||||
"/\n"
|
||||
"WCONINJE\n"
|
||||
"'OP_2' 'GAS' 'OPEN' 'RATE' 100 200 400 /\n"
|
||||
"/\n"
|
||||
"SCHEDULE\n"
|
||||
"SKIPREST\n"
|
||||
"RPTRST\n"
|
||||
"BASIC=1\n"
|
||||
"/\n"
|
||||
"DATES -- 1\n"
|
||||
" 10 OKT 2008 / \n"
|
||||
"/\n"
|
||||
"WELSPECS\n"
|
||||
" 'OP_1' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n"
|
||||
" 'OP_2' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n"
|
||||
"/\n"
|
||||
"COMPDAT\n"
|
||||
" 'OP_1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
" 'OP_2' 9 9 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 / \n"
|
||||
" 'OP_1' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
"/\n"
|
||||
"WCONPROD\n"
|
||||
"'OP_1' 'OPEN' 'ORAT' 20000 4* 1000 /\n"
|
||||
"/\n"
|
||||
"WCONINJE\n"
|
||||
"'OP_2' 'GAS' 'OPEN' 'RATE' 100 200 400 /\n"
|
||||
"/\n"
|
||||
|
||||
"DATES -- 2\n"
|
||||
" 20 JAN 2011 / \n"
|
||||
"/\n"
|
||||
"WELSPECS\n"
|
||||
" 'OP_3' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n"
|
||||
"/\n"
|
||||
"COMPDAT\n"
|
||||
" 'OP_3' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
"/\n"
|
||||
"WCONPROD\n"
|
||||
"'OP_3' 'OPEN' 'ORAT' 20000 4* 1000 /\n"
|
||||
"/\n"
|
||||
"DATES -- 2\n"
|
||||
" 20 JAN 2011 / \n"
|
||||
"/\n"
|
||||
"WELSPECS\n"
|
||||
" 'OP_3' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n"
|
||||
"/\n"
|
||||
"COMPDAT\n"
|
||||
" 'OP_3' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
"/\n"
|
||||
"WCONPROD\n"
|
||||
"'OP_3' 'OPEN' 'ORAT' 20000 4* 1000 /\n"
|
||||
"/\n"
|
||||
|
||||
"DATES -- 3\n"
|
||||
" 15 JUN 2013 / \n"
|
||||
"/\n"
|
||||
"COMPDAT\n"
|
||||
" 'OP_2' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
" 'OP_1' 9 9 7 7 'SHUT' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
"/\n"
|
||||
"DATES -- 3\n"
|
||||
" 15 JUN 2013 / \n"
|
||||
"/\n"
|
||||
"COMPDAT\n"
|
||||
" 'OP_2' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
" 'OP_1' 9 9 7 7 'SHUT' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
"/\n"
|
||||
|
||||
"DATES -- 4\n"
|
||||
" 22 APR 2014 / \n"
|
||||
"/\n"
|
||||
"WELSPECS\n"
|
||||
" 'OP_4' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n"
|
||||
"/\n"
|
||||
"COMPDAT\n"
|
||||
" 'OP_4' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
" 'OP_3' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
"/\n"
|
||||
"WCONPROD\n"
|
||||
"'OP_4' 'OPEN' 'ORAT' 20000 4* 1000 /\n"
|
||||
"/\n"
|
||||
"DATES -- 4\n"
|
||||
" 22 APR 2014 / \n"
|
||||
"/\n"
|
||||
"WELSPECS\n"
|
||||
" 'OP_4' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n"
|
||||
"/\n"
|
||||
"COMPDAT\n"
|
||||
" 'OP_4' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
" 'OP_3' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
"/\n"
|
||||
"WCONPROD\n"
|
||||
"'OP_4' 'OPEN' 'ORAT' 20000 4* 1000 /\n"
|
||||
"/\n"
|
||||
|
||||
"DATES -- 5\n"
|
||||
" 30 AUG 2014 / \n"
|
||||
"/\n"
|
||||
"WELSPECS\n"
|
||||
" 'OP_5' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n"
|
||||
"/\n"
|
||||
"COMPDAT\n"
|
||||
" 'OP_5' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
"/\n"
|
||||
"WCONPROD\n"
|
||||
"'OP_5' 'OPEN' 'ORAT' 20000 4* 1000 /\n"
|
||||
"/\n"
|
||||
"DATES -- 5\n"
|
||||
" 30 AUG 2014 / \n"
|
||||
"/\n"
|
||||
"WELSPECS\n"
|
||||
" 'OP_5' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n"
|
||||
"/\n"
|
||||
"COMPDAT\n"
|
||||
" 'OP_5' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
"/\n"
|
||||
"WCONPROD\n"
|
||||
"'OP_5' 'OPEN' 'ORAT' 20000 4* 1000 /\n"
|
||||
"/\n"
|
||||
|
||||
"DATES -- 6\n"
|
||||
" 15 SEP 2014 / \n"
|
||||
"/\n"
|
||||
"WCONPROD\n"
|
||||
"'OP_3' 'SHUT' 'ORAT' 20000 4* 1000 /\n"
|
||||
"/\n"
|
||||
"DATES -- 6\n"
|
||||
" 15 SEP 2014 / \n"
|
||||
"/\n"
|
||||
"WCONPROD\n"
|
||||
"'OP_3' 'SHUT' 'ORAT' 20000 4* 1000 /\n"
|
||||
"/\n"
|
||||
|
||||
"DATES -- 7\n"
|
||||
" 9 OCT 2014 / \n"
|
||||
"/\n"
|
||||
"WELSPECS\n"
|
||||
" 'OP_6' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n"
|
||||
"/\n"
|
||||
"COMPDAT\n"
|
||||
" 'OP_6' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
"/\n"
|
||||
"WCONPROD\n"
|
||||
"'OP_6' 'OPEN' 'ORAT' 20000 4* 1000 /\n"
|
||||
"/\n"
|
||||
"TSTEP -- 8\n"
|
||||
"10 /"
|
||||
"/\n";
|
||||
"DATES -- 7\n"
|
||||
" 9 OCT 2014 / \n"
|
||||
"/\n"
|
||||
"WELSPECS\n"
|
||||
" 'OP_6' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n"
|
||||
"/\n"
|
||||
"COMPDAT\n"
|
||||
" 'OP_6' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n"
|
||||
"/\n"
|
||||
"WCONPROD\n"
|
||||
"'OP_6' 'OPEN' 'ORAT' 20000 4* 1000 /\n"
|
||||
"/\n"
|
||||
"TSTEP -- 8\n"
|
||||
"10 /"
|
||||
"/\n";
|
||||
|
||||
std::shared_ptr<Opm::BlackoilState> createBlackOilState(Opm::EclipseGridConstPtr eclGrid) {
|
||||
|
||||
std::shared_ptr<Opm::GridManager> ourFineGridManagerPtr(new Opm::GridManager(eclGrid));
|
||||
std::shared_ptr<Opm::BlackoilState> blackoilState(new Opm::BlackoilState);
|
||||
blackoilState->init(*ourFineGridManagerPtr->c_grid(), 3);
|
||||
std::shared_ptr<Opm::BlackoilState> createBlackOilState(Opm::EclipseGridConstPtr eclGrid , const Opm::PhaseUsage& phaseUsage) {
|
||||
|
||||
return blackoilState;
|
||||
std::shared_ptr<Opm::GridManager> grid(new Opm::GridManager(eclGrid));
|
||||
const UnstructuredGrid& ug_grid = *(grid->c_grid());
|
||||
std::shared_ptr<Opm::BlackoilState> blackoilState(new Opm::BlackoilState( Opm::UgGridHelpers::numCells(ug_grid) , Opm::UgGridHelpers::numFaces(ug_grid) , phaseUsage.num_phases) );
|
||||
|
||||
return blackoilState;
|
||||
}
|
||||
|
||||
Opm::EclipseWriterPtr createEclipseWriter(Opm::DeckConstPtr deck,
|
||||
Opm::EclipseStatePtr eclipseState,
|
||||
std::string& eclipse_data_filename) {
|
||||
|
||||
Opm::parameter::ParameterGroup params;
|
||||
params.insertParameter("deck_filename", eclipse_data_filename);
|
||||
Opm::parameter::ParameterGroup params;
|
||||
params.insertParameter("deck_filename", eclipse_data_filename);
|
||||
|
||||
const Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck);
|
||||
const Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck);
|
||||
|
||||
Opm::EclipseWriterPtr eclWriter(new Opm::EclipseWriter(params,
|
||||
eclipseState,
|
||||
phaseUsage,
|
||||
eclipseState->getEclipseGrid()->getCartesianSize(),
|
||||
0));
|
||||
return eclWriter;
|
||||
Opm::EclipseWriterPtr eclWriter(new Opm::EclipseWriter(params,
|
||||
eclipseState,
|
||||
phaseUsage,
|
||||
eclipseState->getEclipseGrid()->getCartesianSize(),
|
||||
0));
|
||||
return eclWriter;
|
||||
}
|
||||
|
||||
void setValuesInWellState(std::shared_ptr<Opm::WellState> wellState){
|
||||
@ -247,102 +249,102 @@ void setValuesInWellState(std::shared_ptr<Opm::WellState> wellState){
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(EclipseReadWriteWellStateData)
|
||||
{
|
||||
std::string eclipse_data_filename = "TestWellState.DATA";
|
||||
test_work_area_type * test_area = test_work_area_alloc("EclipseReadWriteWellStateData");
|
||||
{
|
||||
std::string eclipse_data_filename = "TestWellState.DATA";
|
||||
test_work_area_type * test_area = test_work_area_alloc("EclipseReadWriteWellStateData");
|
||||
|
||||
Opm::Parser parser;
|
||||
Opm::ParseContext parseContext;
|
||||
Opm::DeckConstPtr deck = parser.parseString(input, parseContext);
|
||||
Opm::EclipseStatePtr eclipseState(new Opm::EclipseState(deck , parseContext));
|
||||
Opm::EclipseWriterPtr eclipseWriter = createEclipseWriter(deck, eclipseState, eclipse_data_filename);
|
||||
Opm::Parser parser;
|
||||
Opm::ParseContext parseContext;
|
||||
Opm::DeckConstPtr deck = parser.parseString(input, parseContext);
|
||||
Opm::EclipseStatePtr eclipseState(new Opm::EclipseState(deck , parseContext));
|
||||
Opm::EclipseWriterPtr eclipseWriter = createEclipseWriter(deck, eclipseState, eclipse_data_filename);
|
||||
|
||||
std::shared_ptr<Opm::SimulatorTimer> simTimer( new Opm::SimulatorTimer() );
|
||||
simTimer->init(eclipseState->getSchedule()->getTimeMap());
|
||||
eclipseWriter->writeInit(*simTimer);
|
||||
std::shared_ptr<Opm::WellState> wellState(new Opm::WellState());
|
||||
Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck);
|
||||
std::shared_ptr<Opm::SimulatorTimer> simTimer( new Opm::SimulatorTimer() );
|
||||
simTimer->init(eclipseState->getSchedule()->getTimeMap());
|
||||
eclipseWriter->writeInit(*simTimer);
|
||||
std::shared_ptr<Opm::WellState> wellState(new Opm::WellState());
|
||||
Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck);
|
||||
|
||||
Opm::GridManager gridManager(deck);
|
||||
Opm::WellsManager wellsManager(eclipseState, 1, *gridManager.c_grid(), NULL);
|
||||
const Wells* wells = wellsManager.c_wells();
|
||||
std::shared_ptr<Opm::BlackoilState> blackoilState = createBlackOilState(eclipseState->getEclipseGrid());
|
||||
wellState->init(wells, *blackoilState);
|
||||
Opm::GridManager gridManager(deck);
|
||||
Opm::WellsManager wellsManager(eclipseState, 1, *gridManager.c_grid(), NULL);
|
||||
const Wells* wells = wellsManager.c_wells();
|
||||
std::shared_ptr<Opm::BlackoilState> blackoilState = createBlackOilState(eclipseState->getEclipseGrid(), phaseUsage);
|
||||
wellState->init(wells, *blackoilState);
|
||||
|
||||
//Set test data for pressure
|
||||
std::vector<double>& pressure = blackoilState->pressure();
|
||||
for (std::vector<double>::iterator iter = pressure.begin(); iter != pressure.end(); ++iter) {
|
||||
*iter = 6.0;
|
||||
}
|
||||
//Set test data for pressure
|
||||
std::vector<double>& pressure = blackoilState->pressure();
|
||||
for (std::vector<double>::iterator iter = pressure.begin(); iter != pressure.end(); ++iter) {
|
||||
*iter = 6.0;
|
||||
}
|
||||
|
||||
//Set test data for temperature
|
||||
std::vector<double>& temperature = blackoilState->temperature();
|
||||
for (std::vector<double>::iterator iter = temperature.begin(); iter != temperature.end(); ++iter) {
|
||||
*iter = 7.0;
|
||||
}
|
||||
//Set test data for temperature
|
||||
std::vector<double>& temperature = blackoilState->temperature();
|
||||
for (std::vector<double>::iterator iter = temperature.begin(); iter != temperature.end(); ++iter) {
|
||||
*iter = 7.0;
|
||||
}
|
||||
|
||||
//Set test data for saturation water
|
||||
std::vector<double> swatdata(1000, 8);
|
||||
Opm::EclipseIOUtil::addToStripedData(swatdata, blackoilState->saturation(), phaseUsage.phase_pos[Opm::BlackoilPhases::Aqua], phaseUsage.num_phases);
|
||||
//Set test data for saturation water
|
||||
std::vector<double> swatdata(1000, 8);
|
||||
Opm::EclipseIOUtil::addToStripedData(swatdata, blackoilState->saturation(), phaseUsage.phase_pos[Opm::BlackoilPhases::Aqua], phaseUsage.num_phases);
|
||||
|
||||
//Set test data for saturation gas
|
||||
std::vector<double> sgasdata(1000, 9);
|
||||
Opm::EclipseIOUtil::addToStripedData(sgasdata, blackoilState->saturation(), phaseUsage.phase_pos[Opm::BlackoilPhases::Vapour], phaseUsage.num_phases);
|
||||
//Set test data for saturation gas
|
||||
std::vector<double> sgasdata(1000, 9);
|
||||
Opm::EclipseIOUtil::addToStripedData(sgasdata, blackoilState->saturation(), phaseUsage.phase_pos[Opm::BlackoilPhases::Vapour], phaseUsage.num_phases);
|
||||
|
||||
// Set test data for rs
|
||||
double rs = 300.0;
|
||||
std::vector<double>& rs_vec = blackoilState->gasoilratio();
|
||||
for (std::vector<double>::iterator rs_iter = rs_vec.begin(); rs_iter != rs_vec.end(); ++ rs_iter) {
|
||||
*rs_iter = rs;
|
||||
rs = rs + 1.0;
|
||||
}
|
||||
// Set test data for rs
|
||||
double rs = 300.0;
|
||||
std::vector<double>& rs_vec = blackoilState->gasoilratio();
|
||||
for (std::vector<double>::iterator rs_iter = rs_vec.begin(); rs_iter != rs_vec.end(); ++ rs_iter) {
|
||||
*rs_iter = rs;
|
||||
rs = rs + 1.0;
|
||||
}
|
||||
|
||||
// Set testdata for rv
|
||||
double rv = 400.0;
|
||||
std::vector<double>& rv_vec = blackoilState->rv();
|
||||
for (std::vector<double>::iterator rv_iter = rv_vec.begin(); rv_iter != rv_vec.end(); ++rv_iter) {
|
||||
*rv_iter = rv;
|
||||
rv = rv + 1.0;
|
||||
}
|
||||
// Set testdata for rv
|
||||
double rv = 400.0;
|
||||
std::vector<double>& rv_vec = blackoilState->rv();
|
||||
for (std::vector<double>::iterator rv_iter = rv_vec.begin(); rv_iter != rv_vec.end(); ++rv_iter) {
|
||||
*rv_iter = rv;
|
||||
rv = rv + 1.0;
|
||||
}
|
||||
|
||||
setValuesInWellState(wellState);
|
||||
simTimer->setCurrentStepNum(1);
|
||||
eclipseWriter->writeTimeStep(*simTimer, *blackoilState, *wellState , false);
|
||||
setValuesInWellState(wellState);
|
||||
simTimer->setCurrentStepNum(1);
|
||||
eclipseWriter->writeTimeStep(*simTimer, *blackoilState, *wellState , false);
|
||||
|
||||
std::shared_ptr<Opm::WellState> wellStateRestored(new Opm::WellState());
|
||||
wellStateRestored->init(wells, *blackoilState);
|
||||
std::shared_ptr<Opm::WellState> wellStateRestored(new Opm::WellState());
|
||||
wellStateRestored->init(wells, *blackoilState);
|
||||
|
||||
//Read and verify OPM XWEL data, and solution data: pressure, temperature, saturation data, rs and rv
|
||||
std::shared_ptr<Opm::BlackoilState> blackoilStateRestored = createBlackOilState(eclipseState->getEclipseGrid());
|
||||
Opm::init_from_restart_file(eclipseState, Opm::UgGridHelpers::numCells(*gridManager.c_grid()), phaseUsage, *blackoilStateRestored, *wellStateRestored);
|
||||
//Read and verify OPM XWEL data, and solution data: pressure, temperature, saturation data, rs and rv
|
||||
std::shared_ptr<Opm::BlackoilState> blackoilStateRestored = createBlackOilState(eclipseState->getEclipseGrid(), phaseUsage);
|
||||
Opm::init_from_restart_file(eclipseState, Opm::UgGridHelpers::numCells(*gridManager.c_grid()), phaseUsage, *blackoilStateRestored, *wellStateRestored);
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(wellState->bhp().begin(), wellState->bhp().end(), wellStateRestored->bhp().begin(), wellStateRestored->bhp().end());
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(wellState->temperature().begin(), wellState->temperature().end(), wellStateRestored->temperature().begin(), wellStateRestored->temperature().end());
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(wellState->wellRates().begin(), wellState->wellRates().end(), wellStateRestored->wellRates().begin(), wellStateRestored->wellRates().end());
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(wellState->perfRates().begin(), wellState->perfRates().end(), wellStateRestored->perfRates().begin(), wellStateRestored->perfRates().end());
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(wellState->perfPress().begin(), wellState->perfPress().end(), wellStateRestored->perfPress().begin(), wellStateRestored->perfPress().end());
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(wellState->bhp().begin(), wellState->bhp().end(), wellStateRestored->bhp().begin(), wellStateRestored->bhp().end());
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(wellState->temperature().begin(), wellState->temperature().end(), wellStateRestored->temperature().begin(), wellStateRestored->temperature().end());
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(wellState->wellRates().begin(), wellState->wellRates().end(), wellStateRestored->wellRates().begin(), wellStateRestored->wellRates().end());
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(wellState->perfRates().begin(), wellState->perfRates().end(), wellStateRestored->perfRates().begin(), wellStateRestored->perfRates().end());
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(wellState->perfPress().begin(), wellState->perfPress().end(), wellStateRestored->perfPress().begin(), wellStateRestored->perfPress().end());
|
||||
std::vector<double> swat_restored;
|
||||
std::vector<double> swat;
|
||||
std::vector<double> sgas_restored;
|
||||
std::vector<double> sgas;
|
||||
Opm::EclipseIOUtil::extractFromStripedData(blackoilStateRestored->saturation(), swat_restored, phaseUsage.phase_pos[Opm::BlackoilPhases::Aqua], phaseUsage.num_phases);
|
||||
Opm::EclipseIOUtil::extractFromStripedData(blackoilState->saturation(), swat, phaseUsage.phase_pos[Opm::BlackoilPhases::Aqua], phaseUsage.num_phases);
|
||||
Opm::EclipseIOUtil::extractFromStripedData(blackoilStateRestored->saturation(), sgas_restored, phaseUsage.phase_pos[Opm::BlackoilPhases::Vapour], phaseUsage.num_phases);
|
||||
Opm::EclipseIOUtil::extractFromStripedData(blackoilState->saturation(), sgas, phaseUsage.phase_pos[Opm::BlackoilPhases::Vapour], phaseUsage.num_phases);
|
||||
|
||||
std::vector<double> swat_restored;
|
||||
std::vector<double> swat;
|
||||
std::vector<double> sgas_restored;
|
||||
std::vector<double> sgas;
|
||||
Opm::EclipseIOUtil::extractFromStripedData(blackoilStateRestored->saturation(), swat_restored, phaseUsage.phase_pos[Opm::BlackoilPhases::Aqua], phaseUsage.num_phases);
|
||||
Opm::EclipseIOUtil::extractFromStripedData(blackoilState->saturation(), swat, phaseUsage.phase_pos[Opm::BlackoilPhases::Aqua], phaseUsage.num_phases);
|
||||
Opm::EclipseIOUtil::extractFromStripedData(blackoilStateRestored->saturation(), sgas_restored, phaseUsage.phase_pos[Opm::BlackoilPhases::Vapour], phaseUsage.num_phases);
|
||||
Opm::EclipseIOUtil::extractFromStripedData(blackoilState->saturation(), sgas, phaseUsage.phase_pos[Opm::BlackoilPhases::Vapour], phaseUsage.num_phases);
|
||||
|
||||
for (size_t cellindex = 0; cellindex < 1000; ++cellindex) {
|
||||
BOOST_CHECK_CLOSE(blackoilState->pressure()[cellindex], blackoilStateRestored->pressure()[cellindex], 0.00001);
|
||||
BOOST_CHECK_CLOSE(blackoilState->temperature()[cellindex], blackoilStateRestored->temperature()[cellindex], 0.00001);
|
||||
BOOST_CHECK_CLOSE(swat[cellindex], swat_restored[cellindex], 0.00001);
|
||||
BOOST_CHECK_CLOSE(sgas[cellindex], sgas_restored[cellindex], 0.00001);
|
||||
}
|
||||
for (size_t cellindex = 0; cellindex < 10; ++cellindex) {
|
||||
BOOST_CHECK_CLOSE(blackoilState->pressure()[cellindex], blackoilStateRestored->pressure()[cellindex], 0.00001);
|
||||
BOOST_CHECK_CLOSE(blackoilState->temperature()[cellindex], blackoilStateRestored->temperature()[cellindex], 0.00001);
|
||||
BOOST_CHECK_CLOSE(swat[cellindex], swat_restored[cellindex], 0.00001);
|
||||
BOOST_CHECK_CLOSE(sgas[cellindex], sgas_restored[cellindex], 0.00001);
|
||||
}
|
||||
|
||||
|
||||
for (size_t cellindex = 0; cellindex < 1000; ++cellindex) {
|
||||
BOOST_CHECK_CLOSE(blackoilState->gasoilratio()[cellindex], blackoilStateRestored->gasoilratio()[cellindex], 0.0000001);
|
||||
BOOST_CHECK_CLOSE(blackoilState->rv()[cellindex], blackoilStateRestored->rv()[cellindex], 0.0000001);
|
||||
}
|
||||
for (size_t cellindex = 0; cellindex < 10; ++cellindex) {
|
||||
BOOST_CHECK_CLOSE(blackoilState->gasoilratio()[cellindex], blackoilStateRestored->gasoilratio()[cellindex], 0.0000001);
|
||||
BOOST_CHECK_CLOSE(blackoilState->rv()[cellindex], blackoilStateRestored->rv()[cellindex], 0.0000001);
|
||||
}
|
||||
|
||||
test_work_area_free(test_area);
|
||||
}
|
||||
test_work_area_free(test_area);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <opm/output/eclipse/EclipseWriter.hpp>
|
||||
#include <opm/core/grid/GridManager.hpp>
|
||||
#include <opm/core/grid/GridHelpers.hpp>
|
||||
#include <opm/core/props/phaseUsageFromDeck.hpp>
|
||||
#include <opm/core/simulator/BlackoilState.hpp>
|
||||
#include <opm/core/simulator/WellState.hpp>
|
||||
@ -57,89 +58,89 @@ void verifyWellState(const std::string& rst_filename,
|
||||
Opm::EclipseGridConstPtr ecl_grid,
|
||||
Opm::ScheduleConstPtr schedule) {
|
||||
|
||||
well_info_type * well_info = well_info_alloc(ecl_grid->c_ptr());
|
||||
well_info_load_rstfile(well_info, rst_filename.c_str(), false);
|
||||
well_info_type * well_info = well_info_alloc(ecl_grid->c_ptr());
|
||||
well_info_load_rstfile(well_info, rst_filename.c_str(), false);
|
||||
|
||||
//Verify numwells
|
||||
int numwells = well_info_get_num_wells(well_info);
|
||||
BOOST_CHECK(numwells == (int)schedule->numWells());
|
||||
//Verify numwells
|
||||
int numwells = well_info_get_num_wells(well_info);
|
||||
BOOST_CHECK(numwells == (int)schedule->numWells());
|
||||
|
||||
std::vector<Opm::WellConstPtr> wells = schedule->getWells();
|
||||
std::vector<Opm::WellConstPtr> wells = schedule->getWells();
|
||||
|
||||
for (int i = 0; i < numwells; ++i) {
|
||||
for (int i = 0; i < numwells; ++i) {
|
||||
|
||||
//Verify wellnames
|
||||
const char * wellname = well_info_iget_well_name(well_info, i);
|
||||
Opm::WellConstPtr well = wells.at(i);
|
||||
BOOST_CHECK(wellname == well->name());
|
||||
//Verify wellnames
|
||||
const char * wellname = well_info_iget_well_name(well_info, i);
|
||||
Opm::WellConstPtr well = wells.at(i);
|
||||
BOOST_CHECK(wellname == well->name());
|
||||
|
||||
// Verify well-head position data
|
||||
well_ts_type * well_ts = well_info_get_ts(well_info , wellname);
|
||||
well_state_type * well_state = well_ts_iget_state(well_ts, 0);
|
||||
const well_conn_type * well_head = well_state_get_wellhead(well_state, ECL_GRID_GLOBAL_GRID);
|
||||
BOOST_CHECK(well_conn_get_i(well_head) == well->getHeadI());
|
||||
BOOST_CHECK(well_conn_get_j(well_head) == well->getHeadJ());
|
||||
// Verify well-head position data
|
||||
well_ts_type * well_ts = well_info_get_ts(well_info , wellname);
|
||||
well_state_type * well_state = well_ts_iget_state(well_ts, 0);
|
||||
const well_conn_type * well_head = well_state_get_wellhead(well_state, ECL_GRID_GLOBAL_GRID);
|
||||
BOOST_CHECK(well_conn_get_i(well_head) == well->getHeadI());
|
||||
BOOST_CHECK(well_conn_get_j(well_head) == well->getHeadJ());
|
||||
|
||||
for (int j = 0; j < well_ts_get_size(well_ts); ++j) {
|
||||
well_state = well_ts_iget_state(well_ts, j);
|
||||
for (int j = 0; j < well_ts_get_size(well_ts); ++j) {
|
||||
well_state = well_ts_iget_state(well_ts, j);
|
||||
|
||||
//Verify welltype
|
||||
int ert_well_type = well_state_get_type(well_state);
|
||||
WellType welltype = well->isProducer(j) ? PRODUCER : INJECTOR;
|
||||
Opm::WellInjector::TypeEnum injectortype = well->getInjectionProperties(j).injectorType;
|
||||
int ecl_converted_welltype = Opm::EclipseWriter::eclipseWellTypeMask(welltype, injectortype);
|
||||
int ert_converted_welltype = well_state_translate_ecl_type_int(ecl_converted_welltype);
|
||||
BOOST_CHECK(ert_well_type == ert_converted_welltype);
|
||||
//Verify welltype
|
||||
int ert_well_type = well_state_get_type(well_state);
|
||||
WellType welltype = well->isProducer(j) ? PRODUCER : INJECTOR;
|
||||
Opm::WellInjector::TypeEnum injectortype = well->getInjectionProperties(j).injectorType;
|
||||
int ecl_converted_welltype = Opm::EclipseWriter::eclipseWellTypeMask(welltype, injectortype);
|
||||
int ert_converted_welltype = well_state_translate_ecl_type_int(ecl_converted_welltype);
|
||||
BOOST_CHECK(ert_well_type == ert_converted_welltype);
|
||||
|
||||
//Verify wellstatus
|
||||
int ert_well_status = well_state_is_open(well_state) ? 1 : 0;
|
||||
//Verify wellstatus
|
||||
int ert_well_status = well_state_is_open(well_state) ? 1 : 0;
|
||||
|
||||
Opm::WellCommon::StatusEnum status = well->getStatus(j);
|
||||
int wellstatus = Opm::EclipseWriter::eclipseWellStatusMask(status);
|
||||
Opm::WellCommon::StatusEnum status = well->getStatus(j);
|
||||
int wellstatus = Opm::EclipseWriter::eclipseWellStatusMask(status);
|
||||
|
||||
BOOST_CHECK(ert_well_status == wellstatus);
|
||||
BOOST_CHECK(ert_well_status == wellstatus);
|
||||
|
||||
//Verify number of completion connections
|
||||
const well_conn_collection_type * well_connections = well_state_get_global_connections( well_state );
|
||||
size_t num_wellconnections = well_conn_collection_get_size(well_connections);
|
||||
//Verify number of completion connections
|
||||
const well_conn_collection_type * well_connections = well_state_get_global_connections( well_state );
|
||||
size_t num_wellconnections = well_conn_collection_get_size(well_connections);
|
||||
|
||||
int report_nr = well_state_get_report_nr(well_state);
|
||||
Opm::CompletionSetConstPtr completions_set = well->getCompletions((size_t)report_nr);
|
||||
int report_nr = well_state_get_report_nr(well_state);
|
||||
Opm::CompletionSetConstPtr completions_set = well->getCompletions((size_t)report_nr);
|
||||
|
||||
BOOST_CHECK(num_wellconnections == completions_set->size());
|
||||
BOOST_CHECK(num_wellconnections == completions_set->size());
|
||||
|
||||
//Verify coordinates for each completion connection
|
||||
for (size_t k = 0; k < num_wellconnections; ++k) {
|
||||
const well_conn_type * well_connection = well_conn_collection_iget_const(well_connections , k);
|
||||
//Verify coordinates for each completion connection
|
||||
for (size_t k = 0; k < num_wellconnections; ++k) {
|
||||
const well_conn_type * well_connection = well_conn_collection_iget_const(well_connections , k);
|
||||
|
||||
Opm::CompletionConstPtr completion = completions_set->get(k);
|
||||
Opm::CompletionConstPtr completion = completions_set->get(k);
|
||||
|
||||
BOOST_CHECK(well_conn_get_i(well_connection) == completion->getI());
|
||||
BOOST_CHECK(well_conn_get_j(well_connection) == completion->getJ());
|
||||
BOOST_CHECK(well_conn_get_k(well_connection) == completion->getK());
|
||||
}
|
||||
}
|
||||
BOOST_CHECK(well_conn_get_i(well_connection) == completion->getI());
|
||||
BOOST_CHECK(well_conn_get_j(well_connection) == completion->getJ());
|
||||
BOOST_CHECK(well_conn_get_k(well_connection) == completion->getK());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
well_info_free(well_info);
|
||||
well_info_free(well_info);
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<Opm::BlackoilState> createBlackOilState(Opm::EclipseGridConstPtr eclGrid) {
|
||||
|
||||
std::shared_ptr<Opm::GridManager> ourFineGridManagerPtr(new Opm::GridManager(eclGrid));
|
||||
std::shared_ptr<Opm::BlackoilState> blackoilState(new Opm::BlackoilState);
|
||||
blackoilState->init(*ourFineGridManagerPtr->c_grid(), 3);
|
||||
std::shared_ptr<Opm::GridManager> grid(new Opm::GridManager(eclGrid));
|
||||
const UnstructuredGrid& ug_grid = *(grid->c_grid());
|
||||
std::shared_ptr<Opm::BlackoilState> blackoilState(new Opm::BlackoilState( Opm::UgGridHelpers::numCells(ug_grid) , Opm::UgGridHelpers::numFaces(ug_grid) , 3 ));
|
||||
|
||||
return blackoilState;
|
||||
return blackoilState;
|
||||
}
|
||||
|
||||
|
||||
Opm::DeckConstPtr createDeck(const std::string& eclipse_data_filename) {
|
||||
Opm::ParserPtr parser(new Opm::Parser());
|
||||
Opm::DeckConstPtr deck = parser->parseFile(eclipse_data_filename , Opm::ParseContext());
|
||||
Opm::ParserPtr parser(new Opm::Parser());
|
||||
Opm::DeckConstPtr deck = parser->parseFile(eclipse_data_filename , Opm::ParseContext());
|
||||
|
||||
return deck;
|
||||
return deck;
|
||||
}
|
||||
|
||||
|
||||
@ -147,51 +148,51 @@ Opm::EclipseWriterPtr createEclipseWriter(Opm::DeckConstPtr deck,
|
||||
Opm::EclipseStatePtr eclipseState,
|
||||
std::string& eclipse_data_filename) {
|
||||
|
||||
Opm::parameter::ParameterGroup params;
|
||||
params.insertParameter("deck_filename", eclipse_data_filename);
|
||||
Opm::parameter::ParameterGroup params;
|
||||
params.insertParameter("deck_filename", eclipse_data_filename);
|
||||
|
||||
const Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck);
|
||||
const Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck);
|
||||
|
||||
Opm::EclipseWriterPtr eclWriter(new Opm::EclipseWriter(params,
|
||||
eclipseState,
|
||||
phaseUsage,
|
||||
eclipseState->getEclipseGrid()->getCartesianSize(),
|
||||
0));
|
||||
return eclWriter;
|
||||
Opm::EclipseWriterPtr eclWriter(new Opm::EclipseWriter(params,
|
||||
eclipseState,
|
||||
phaseUsage,
|
||||
eclipseState->getEclipseGrid()->getCartesianSize(),
|
||||
0));
|
||||
return eclWriter;
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(EclipseWriteRestartWellInfo)
|
||||
{
|
||||
std::string eclipse_data_filename = "testBlackoilState3.DATA";
|
||||
std::string eclipse_restart_filename = "TESTBLACKOILSTATE3.X0004";
|
||||
{
|
||||
std::string eclipse_data_filename = "testBlackoilState3.DATA";
|
||||
std::string eclipse_restart_filename = "TESTBLACKOILSTATE3.X0004";
|
||||
|
||||
|
||||
test_work_area_type * test_area = test_work_area_alloc("TEST_EclipseWriteNumWells");
|
||||
test_work_area_copy_file(test_area, eclipse_data_filename.c_str());
|
||||
test_work_area_type * test_area = test_work_area_alloc("TEST_EclipseWriteNumWells");
|
||||
test_work_area_copy_file(test_area, eclipse_data_filename.c_str());
|
||||
|
||||
Opm::ParseContext parseContext;
|
||||
Opm::DeckConstPtr deck = createDeck(eclipse_data_filename);
|
||||
Opm::EclipseStatePtr eclipseState(new Opm::EclipseState(deck , parseContext));
|
||||
Opm::EclipseWriterPtr eclipseWriter = createEclipseWriter(deck, eclipseState, eclipse_data_filename);
|
||||
Opm::ParseContext parseContext;
|
||||
Opm::DeckConstPtr deck = createDeck(eclipse_data_filename);
|
||||
Opm::EclipseStatePtr eclipseState(new Opm::EclipseState(deck , parseContext));
|
||||
Opm::EclipseWriterPtr eclipseWriter = createEclipseWriter(deck, eclipseState, eclipse_data_filename);
|
||||
|
||||
std::shared_ptr<Opm::SimulatorTimer> simTimer( new Opm::SimulatorTimer() );
|
||||
simTimer->init(eclipseState->getSchedule()->getTimeMap());
|
||||
std::shared_ptr<Opm::SimulatorTimer> simTimer( new Opm::SimulatorTimer() );
|
||||
simTimer->init(eclipseState->getSchedule()->getTimeMap());
|
||||
|
||||
eclipseWriter->writeInit(*simTimer);
|
||||
eclipseWriter->writeInit(*simTimer);
|
||||
|
||||
std::shared_ptr<Opm::WellState> wellState(new Opm::WellState());
|
||||
std::shared_ptr<Opm::BlackoilState> blackoilState = createBlackOilState(eclipseState->getEclipseGrid());
|
||||
wellState->init(0, *blackoilState);
|
||||
std::shared_ptr<Opm::WellState> wellState(new Opm::WellState());
|
||||
std::shared_ptr<Opm::BlackoilState> blackoilState = createBlackOilState(eclipseState->getEclipseGrid());
|
||||
wellState->init(0, *blackoilState);
|
||||
|
||||
int countTimeStep = eclipseState->getSchedule()->getTimeMap()->numTimesteps();
|
||||
int countTimeStep = eclipseState->getSchedule()->getTimeMap()->numTimesteps();
|
||||
|
||||
for(int timestep=0; timestep <= countTimeStep; ++timestep){
|
||||
simTimer->setCurrentStepNum(timestep);
|
||||
eclipseWriter->writeTimeStep(*simTimer, *blackoilState, *wellState, false);
|
||||
}
|
||||
for(int timestep=0; timestep <= countTimeStep; ++timestep){
|
||||
simTimer->setCurrentStepNum(timestep);
|
||||
eclipseWriter->writeTimeStep(*simTimer, *blackoilState, *wellState, false);
|
||||
}
|
||||
|
||||
verifyWellState(eclipse_restart_filename, eclipseState->getEclipseGrid(), eclipseState->getSchedule());
|
||||
verifyWellState(eclipse_restart_filename, eclipseState->getEclipseGrid(), eclipseState->getSchedule());
|
||||
|
||||
test_work_area_free(test_area);
|
||||
}
|
||||
test_work_area_free(test_area);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user